Browse Source

Merge branch 'dev/2024/0407/update-business' of Harper/feifan-backend-zx-business into master

更新商户查询商品和订单
Yangzw 1 year ago
parent
commit
39698b23df

+ 6 - 1
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/dal/dataobject/spu/ProductSpuDO.java

@@ -177,8 +177,13 @@ public class ProductSpuDO extends BaseDO {
      */
     private Integer spuType;
 
-
+    /**
+     * 店铺编号
+     */
     private Long shopId;
+    /**
+     * 商户编号
+     */
     private Long merchantId;
 
 

+ 22 - 0
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/dal/mysql/spu/ProductSpuMapper.java

@@ -9,7 +9,9 @@ import cn.newfeifan.mall.module.product.controller.app.spu.vo.AppProductSpuPageR
 import cn.newfeifan.mall.module.product.dal.dataobject.spu.ProductSpuDO;
 import cn.newfeifan.mall.module.product.enums.ProductConstants;
 import cn.newfeifan.mall.module.product.enums.spu.ProductSpuStatusEnum;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
 import org.apache.ibatis.annotations.Mapper;
 
 import java.util.Objects;
@@ -51,6 +53,26 @@ public interface ProductSpuMapper extends BaseMapperX<ProductSpuDO> {
         return selectCount(queryWrapper);
     }
 
+    default Long selectCount(SFunction<ProductSpuDO, ?> field, Object value,Long merId){
+        return selectCount(new LambdaQueryWrapper<ProductSpuDO>()
+                .eq(field, value)
+                .eq(ProductSpuDO::getMerchantId, merId));
+    }
+
+    /**
+     * 查询触发警戒库存的 SPU 数量ByShopId and merId
+     * @param merId 商户ID
+     * @return 触发警戒库存的 SPU 数量
+     */
+    default Long selectCount(Long merId) {
+        return selectCount(new LambdaQueryWrapperX<ProductSpuDO>()
+                .eqIfPresent(ProductSpuDO::getMerchantId, merId)
+                // 库存小于等于警戒库存
+                .le(ProductSpuDO::getStock, ProductConstants.ALERT_STOCK)
+                // 如果库存触发警戒库存且状态为回收站的话则不计入触发警戒库存的个数
+                .notIn(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus()));
+    }
+
     /**
      * 获得商品 SPU 分页,提供给用户 App 使用
      */

+ 5 - 5
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/service/spu/ProductSpuServiceImpl.java

@@ -277,19 +277,19 @@ public class ProductSpuServiceImpl implements ProductSpuService {
         Map<Integer, Long> counts = Maps.newLinkedHashMapWithExpectedSize(5);
         // 查询销售中的商品数量
         counts.put(ProductSpuPageReqVO.FOR_SALE,
-                productSpuMapper.selectCount(ProductSpuDO::getStatus, ProductSpuStatusEnum.ENABLE.getStatus()));
+                productSpuMapper.selectCount(ProductSpuDO::getStatus, ProductSpuStatusEnum.ENABLE.getStatus(), merId));
         // 查询仓库中的商品数量
         counts.put(ProductSpuPageReqVO.IN_WAREHOUSE,
-                productSpuMapper.selectCount(ProductSpuDO::getStatus, ProductSpuStatusEnum.DISABLE.getStatus()));
+                productSpuMapper.selectCount(ProductSpuDO::getStatus, ProductSpuStatusEnum.DISABLE.getStatus(), merId));
         // 查询售空的商品数量
         counts.put(ProductSpuPageReqVO.SOLD_OUT,
-                productSpuMapper.selectCount(ProductSpuDO::getStock, 0));
+                productSpuMapper.selectCount(ProductSpuDO::getStock, 0, merId));
         // 查询触发警戒库存的商品数量
         counts.put(ProductSpuPageReqVO.ALERT_STOCK,
-                productSpuMapper.selectCount());
+                productSpuMapper.selectCount(merId));
         // 查询回收站中的商品数量
         counts.put(ProductSpuPageReqVO.RECYCLE_BIN,
-                productSpuMapper.selectCount(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus()));
+                productSpuMapper.selectCount(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus(), merId));
         return counts;
     }
 

+ 2 - 2
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/admin/order/TradeOrderController.java

@@ -207,8 +207,8 @@ public class TradeOrderController {
     public CommonResult<Map<Integer, Long>> getOrderCount(@RequestParam(value = "shopId", required = false) Long shopId,
                                                           @RequestParam(value = "merId", required = false) Long merId) {
         Map<Integer, Long> orderCount = Maps.newLinkedHashMapWithExpectedSize(6);
-        orderCount.put(-1, tradeOrderQueryService.getOrderCount(null));
-        orderCount.put(-2, afterSaleService.getApplyingAfterSaleCount(null));
+        orderCount.put(-1, tradeOrderQueryService.getOrderCount(null, shopId, merId));
+        orderCount.put(TradeOrderStatusEnum.AFTER_SALE.getStatus(), afterSaleService.getApplyingAfterSaleCount(null, shopId, merId));
         orderCount.put(TradeOrderStatusEnum.UNPAID.getStatus(), tradeOrderQueryService.getOrderCount(TradeOrderStatusEnum.UNPAID.getStatus(), shopId, merId));
         orderCount.put(TradeOrderStatusEnum.UNDELIVERED.getStatus(), tradeOrderQueryService.getOrderCount(TradeOrderStatusEnum.UNDELIVERED.getStatus(), shopId, merId));
         orderCount.put(TradeOrderStatusEnum.DELIVERED.getStatus(), tradeOrderQueryService.getOrderCount(TradeOrderStatusEnum.DELIVERED.getStatus(), shopId, merId));

+ 8 - 2
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/dal/dataobject/aftersale/AfterSaleDO.java

@@ -193,13 +193,19 @@ public class AfterSaleDO extends BaseDO {
     private LocalDateTime receiveTime;
     /**
      * 收货备注
-     *
      * 注意,只有拒绝收货才会填写
      */
     private String receiveReason;
 
 
-
+    /**
+     * 店铺id
+     */
     private Long shopId;
 
+    /**
+     * 商户id
+     */
+    private Long merchant_id;
+
 }

+ 7 - 0
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/dal/mysql/aftersale/AfterSaleMapper.java

@@ -48,5 +48,12 @@ public interface AfterSaleMapper extends BaseMapperX<AfterSaleDO> {
                 .eqIfPresent(AfterSaleDO::getUserId, userId)
                 .in(AfterSaleDO::getStatus, statuses));
     }
+    default Long selectCountByUserIdAndStatus(Long userId, Long shopId, Long merId, Collection<Integer> statuses) {
+        return selectCount(new LambdaQueryWrapperX<AfterSaleDO>()
+                .eqIfPresent(AfterSaleDO::getUserId, userId)
+                .eqIfPresent(AfterSaleDO::getShopId, shopId)
+                .eqIfPresent(AfterSaleDO::getMerchant_id, merId)
+                .in(AfterSaleDO::getStatus, statuses));
+    }
 
 }

+ 10 - 0
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/aftersale/AfterSaleService.java

@@ -133,6 +133,16 @@ public interface AfterSaleService {
      */
     Long getApplyingAfterSaleCount(Long userId);
 
+    /**
+     * 【会员】获得正在进行中的售后订单数量
+     *
+     * @param userId 用户编号
+     * @param shopId 店铺编号
+     * @param merId  商户编号
+     * @return 数量
+     */
+    Long getApplyingAfterSaleCount(Long userId,Long shopId, Long merId);
+
     /**
      * 【用户】获取售后订单
      * @param orderIds  订单ID集

+ 4 - 0
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/aftersale/AfterSaleServiceImpl.java

@@ -419,6 +419,10 @@ public class AfterSaleServiceImpl implements AfterSaleService {
     public Long getApplyingAfterSaleCount(Long userId) {
         return tradeAfterSaleMapper.selectCountByUserIdAndStatus(userId, AfterSaleStatusEnum.APPLYING_STATUSES);
     }
+    @Override
+    public Long getApplyingAfterSaleCount(Long userId,Long shopId, Long merId) {
+        return tradeAfterSaleMapper.selectCountByUserIdAndStatus(userId, shopId, merId, AfterSaleStatusEnum.APPLYING_STATUSES);
+    }
 
     @Override
     public List<AfterSaleDO> getAfterSaleByMer(List<Long> orderIds) {