fix: 购物车角标数目不准确修复

This commit is contained in:
张松 2024-12-16 09:32:55 +08:00
parent 331e1ddc00
commit 9543878cd1
3 changed files with 13 additions and 5 deletions

View File

@ -20,7 +20,9 @@ public interface TbProductMapper {
List<TbProduct> selectByShopIdAndShopTypeCheckGrounding(@Param("shopId") String shopId, @Param("categoryId") String categoryId,@Param("commdityName") String commdityName);
List<TbProduct> selectByShopIdAndShopTypeUnGrounding(@Param("shopId") String shopId,@Param("commdityName") String commdityName);
Integer countOrderByshopIdAndProductId(@Param("shopId") String shopId, @Param("productId") String productId, @Param("masterId") String masterId,@Param("day") String day, @Param("tableId") String tableId);
Integer countOrderByshopIdAndProductId(@Param("shopId") String shopId, @Param("productId") String productId,
@Param("masterId") String masterId,@Param("day") String day,
@Param("tableId") String tableId, @Param("useType") String useType);
@Update("update tb_product set stock_number = stock_number - #{num,jdbcType=INTEGER} where id = #{productId}")
void updateStockById(@Param("productId")Integer productId, @Param("num")Integer num);

View File

@ -7,6 +7,7 @@ import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.entity.dto.ProductStatusDTO;
import com.chaozhanggui.system.cashierservice.entity.dto.ProductStockDTO;
import com.chaozhanggui.system.cashierservice.entity.dto.ShopEatTypeInfoDTO;
import com.chaozhanggui.system.cashierservice.entity.vo.ProductGroupVo;
import com.chaozhanggui.system.cashierservice.entity.vo.ShopCategoryVo;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
@ -55,6 +56,9 @@ public class ProductService {
private TbShopUnitMapper tbShopUnitMapper;
@Autowired
private MpShopUnitMapper mpShopUnitMapper;
private MpCashierCartService cashierCartService;
@Autowired
private OrderService orderService;
public ProductService(RabbitProducer producer) {
this.producer = producer;
@ -87,7 +91,7 @@ public class ProductService {
String day = DateUtils.getDay();
if(ObjectUtil.isNotEmpty(tbProductWithBLOBs)){
tbProductWithBLOBs.parallelStream().forEach(it->{
Integer orderCount=tbProductMapper.countOrderByshopIdAndProductId(it.getShopId(),it.getId().toString(),masterId,day, "");
Integer orderCount=tbProductMapper.countOrderByshopIdAndProductId(it.getShopId(),it.getId().toString(),masterId,day, "", null);
it.setOrderCount((ObjectUtil.isNull(orderCount)||ObjectUtil.isEmpty(orderCount))?0:orderCount);
TbProductSpec tbProductSpec= tbProductSpecMapper.selectByPrimaryKey(it.getSpecId());
if(ObjectUtil.isEmpty(tbProductSpec)){
@ -139,10 +143,11 @@ public class ProductService {
));
}
String day = DateUtils.getDay();
ShopEatTypeInfoDTO shopEatTypeInfoDTO = orderService.checkEatModel(shopId, tableId);
if(ObjectUtil.isNotEmpty(tbProductWithBLOBs)){
Map<String, TbShopUnit> finalShopUnitsMap = shopUnitsMap;
tbProductWithBLOBs.parallelStream().forEach(it->{
Integer orderCount=tbProductMapper.countOrderByshopIdAndProductId(it.getShopId(),it.getId().toString(),masterId,day, tableId);
Integer orderCount=tbProductMapper.countOrderByshopIdAndProductId(it.getShopId(),it.getId().toString(),masterId,day, tableId, shopEatTypeInfoDTO.getUseType());
it.setOrderCount((ObjectUtil.isNull(orderCount)||ObjectUtil.isEmpty(orderCount))?0:orderCount);
TbProductSpec tbProductSpec= tbProductSpecMapper.selectByPrimaryKey(it.getSpecId());
if(ObjectUtil.isEmpty(tbProductSpec)){

View File

@ -537,9 +537,10 @@
shop_id = #{shopId}
AND product_id = #{productId}
AND `status` = 'create'
and master_id = #{masterId}
AND created_at > DATE_SUB(NOW(), INTERVAL 1 DAY)
AND (master_id = #{masterId} OR master_id IS NULL)
and table_id = #{tableId}
and trade_day = #{day}
AND use_type = #{useType}
group by shop_id,product_id
</select>