Search in sources :

Example 16 with LongIdentity

use of com.stardata.starshop2.sharedcontext.domain.LongIdentity in project starshop by beautautumn.

the class ProductSettlementService method increaseCurMonthSale.

public void increaseCurMonthSale(@NotNull Map<LongIdentity, Integer> productCountsMap) {
    List<Product> products = repository.instancesOf(productCountsMap.keySet());
    for (Product product : products) {
        int count = productCountsMap.get(product.getId());
        product.increaseCurMonthSale(count);
        repository.update(product);
    }
}
Also used : Product(com.stardata.starshop2.productcontext.command.domain.product.Product)

Example 17 with LongIdentity

use of com.stardata.starshop2.sharedcontext.domain.LongIdentity in project starshop by beautautumn.

the class ProductSettlementService method calcSettlement.

public int calcSettlement(@NotNull Map<LongIdentity, Integer> productCountsMap, @NotNull List<ProductSettlement> settlements) {
    List<Product> products = repository.instancesOf(productCountsMap.keySet());
    int totalPriceFen = 0;
    settlements.clear();
    for (Product product : products) {
        int count = productCountsMap.get(product.getId());
        ProductSettlement settlement = product.settlePrice(count);
        totalPriceFen += settlement.getSettlePriceFen();
        settlements.add(settlement);
    }
    return totalPriceFen;
}
Also used : ProductSettlement(com.stardata.starshop2.productcontext.command.domain.product.ProductSettlement) Product(com.stardata.starshop2.productcontext.command.domain.product.Product)

Aggregations

LongIdentity (com.stardata.starshop2.sharedcontext.domain.LongIdentity)11 WxPrepayOrder (com.stardata.starshop2.ordercontext.command.domain.order.WxPrepayOrder)6 Order (com.stardata.starshop2.ordercontext.command.domain.order.Order)5 MobileNumber (com.stardata.starshop2.sharedcontext.domain.MobileNumber)5 User (com.stardata.starshop2.authcontext.domain.user.User)4 WxAuthInfo (com.stardata.starshop2.authcontext.domain.user.WxAuthInfo)3 Product (com.stardata.starshop2.productcontext.command.domain.product.Product)3 ApplicationValidationException (com.stardata.starshop2.sharedcontext.exception.ApplicationValidationException)3 SessionUser (com.stardata.starshop2.sharedcontext.pl.SessionUser)3 Transactional (jakarta.transaction.Transactional)3 Test (org.junit.jupiter.api.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 Rollback (org.springframework.test.annotation.Rollback)3 ShoppingCart (com.stardata.starshop2.ordercontext.command.domain.shoppingcart.ShoppingCart)1 ProductSettlement (com.stardata.starshop2.productcontext.command.domain.product.ProductSettlement)1 Shop (com.stardata.starshop2.shopcontext.domain.Shop)1