Browse Source

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

完善商品和订单部分
Yangzw 1 year ago
parent
commit
30f9278692

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

@@ -53,20 +53,23 @@ public interface ProductSpuMapper extends BaseMapperX<ProductSpuDO> {
         return selectCount(queryWrapper);
     }
 
-    default Long selectCount(SFunction<ProductSpuDO, ?> field, Object value,Long merId){
+    default Long selectCount(SFunction<ProductSpuDO, ?> field, Object value,Long merId,Long shopId){
         return selectCount(new LambdaQueryWrapper<ProductSpuDO>()
                 .eq(field, value)
-                .eq(ProductSpuDO::getMerchantId, merId));
+                .eq(ProductSpuDO::getMerchantId, merId)
+                .eq(ProductSpuDO::getShopId, shopId));
     }
 
     /**
      * 查询触发警戒库存的 SPU 数量ByShopId and merId
      * @param merId 商户ID
+     * @param shopId 店铺ID
      * @return 触发警戒库存的 SPU 数量
      */
-    default Long selectCount(Long merId) {
+    default Long selectCount(Long merId,Long shopId) {
         return selectCount(new LambdaQueryWrapperX<ProductSpuDO>()
                 .eqIfPresent(ProductSpuDO::getMerchantId, merId)
+                .eqIfPresent(ProductSpuDO::getShopId, shopId)
                 // 库存小于等于警戒库存
                 .le(ProductSpuDO::getStock, ProductConstants.ALERT_STOCK)
                 // 如果库存触发警戒库存且状态为回收站的话则不计入触发警戒库存的个数

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

@@ -243,6 +243,9 @@ public class ProductSpuServiceImpl implements ProductSpuService {
 
     @Override
     public PageResult<ProductSpuDO> getSpuPage(ProductSpuPageReqVO pageReqVO) {
+        ShopBO shop = getShop();
+        pageReqVO.setShopId(shop.getShopId());
+        pageReqVO.setMerchantId(shop.getMerId());
         return productSpuMapper.selectPage(pageReqVO);
     }
 
@@ -308,21 +311,24 @@ public class ProductSpuServiceImpl implements ProductSpuService {
     @Override
     public Map<Integer, Long> getTabsCount(Long merId) {
         Map<Integer, Long> counts = Maps.newLinkedHashMapWithExpectedSize(5);
+
+        ShopBO shop = getShop();
+
         // 查询销售中的商品数量
         counts.put(ProductSpuPageReqVO.FOR_SALE,
-                productSpuMapper.selectCount(ProductSpuDO::getStatus, ProductSpuStatusEnum.ENABLE.getStatus(), merId));
+                productSpuMapper.selectCount(ProductSpuDO::getStatus, ProductSpuStatusEnum.ENABLE.getStatus(), shop.getMerId(),shop.getShopId()));
         // 查询仓库中的商品数量
         counts.put(ProductSpuPageReqVO.IN_WAREHOUSE,
-                productSpuMapper.selectCount(ProductSpuDO::getStatus, ProductSpuStatusEnum.DISABLE.getStatus(), merId));
+                productSpuMapper.selectCount(ProductSpuDO::getStatus, ProductSpuStatusEnum.DISABLE.getStatus(), shop.getMerId(),shop.getShopId()));
         // 查询售空的商品数量
         counts.put(ProductSpuPageReqVO.SOLD_OUT,
-                productSpuMapper.selectCount(ProductSpuDO::getStock, 0, merId));
+                productSpuMapper.selectCount(ProductSpuDO::getStock, 0, shop.getMerId(),shop.getShopId()));
         // 查询触发警戒库存的商品数量
         counts.put(ProductSpuPageReqVO.ALERT_STOCK,
-                productSpuMapper.selectCount(merId));
+                productSpuMapper.selectCount(shop.getMerId(),shop.getShopId()));
         // 查询回收站中的商品数量
         counts.put(ProductSpuPageReqVO.RECYCLE_BIN,
-                productSpuMapper.selectCount(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus(), merId));
+                productSpuMapper.selectCount(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus(), shop.getMerId(),shop.getShopId()));
         return counts;
     }
 

+ 19 - 0
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/admin/aftersale/AfterSaleController.java

@@ -29,6 +29,7 @@ import javax.annotation.security.PermitAll;
 import javax.validation.Valid;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
 import static cn.newfeifan.mall.framework.common.util.collection.CollectionUtils.convertSet;
@@ -143,4 +144,22 @@ public class AfterSaleController {
         return success(true);
     }
 
+
+    @GetMapping("/after_sale")
+    @Operation(summary = "新增接口20240410-售后信息-商户查询售后")
+    @PreAuthorize("@ss.hasPermission('trade:order:query')")
+    public CommonResult<List<AfterSaleDetailRespVO>> afterSale() {
+        List<AfterSaleDO> afterSaleDOS = afterSaleService.getAfterSaleByMerAndShop() ;
+        return success(AfterSaleConvert.INSTANCE.convertList02(afterSaleDOS));
+    }
+
+    @GetMapping("/after_saleByPro")
+    @Operation(summary = "新增接口20240410-售后信息-商户根据商品号查询售后")
+    @Parameter(name = "spuId", description = "商品ID", required = true, example = "1")
+    @PreAuthorize("@ss.hasPermission('trade:order:query')")
+    public CommonResult<List<AfterSaleDetailRespVO>> afterSaleByPro(@RequestParam("spuId") Long spuId) {
+        List<AfterSaleDO> afterSaleDOS = afterSaleService.getAfterSaleByProId(spuId);
+        return success(AfterSaleConvert.INSTANCE.convertList02(afterSaleDOS));
+    }
+
 }

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

@@ -108,7 +108,7 @@ public class TradeOrderDetailController {
     }
 
     @GetMapping("/after_saleByMer")
-        @Operation(summary = "新增接口20240402-售后信息-商户根据订单号查询售后")
+    @Operation(summary = "新增接口20240402-售后信息-商户根据订单号查询售后")
     @Parameter(name = "id", description = "订单ID", required = true, example = "1")
     @PreAuthorize("@ss.hasPermission('trade:order:query')")
     public CommonResult<List<AfterSaleDetailRespVO>> afterSaleByMer(@RequestParam("id") Long id) {

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

@@ -54,7 +54,7 @@ public interface AfterSaleService {
     /**
      * 【管理员】获得售后单 通过订单编号
      *
-     * @param id 售后编号
+     * @param orderNo 售后编号
      * @return 售后订单
      */
     AfterSaleDO getAfterSaleByOrderNo(String orderNo);
@@ -144,9 +144,22 @@ public interface AfterSaleService {
     Long getApplyingAfterSaleCount(Long userId,Long shopId, Long merId);
 
     /**
-     * 【户】获取售后订单
+     * 【户】获取售后订单
      * @param orderIds  订单ID集
      * @return          售后订单
      */
     List<AfterSaleDO> getAfterSaleByMer(List<Long> orderIds);
+
+    /**
+     * 【用户】获取售后订单
+     * @param spuId  商品ID
+     * @return       售后订单
+     */
+    List<AfterSaleDO> getAfterSaleByProId(Long spuId);
+
+    /**
+     * 【用户】获取售后订单
+     * @return       售后订单
+     */
+    List<AfterSaleDO> getAfterSaleByMerAndShop();
 }

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

@@ -8,9 +8,12 @@ import cn.newfeifan.mall.framework.common.pojo.PageResult;
 import cn.newfeifan.mall.framework.common.util.object.ObjectUtils;
 import cn.newfeifan.mall.module.pay.api.refund.PayRefundApi;
 import cn.newfeifan.mall.module.pay.api.refund.dto.PayRefundCreateReqDTO;
+import cn.newfeifan.mall.module.system.dal.dataobject.user.AdminUserDO;
+import cn.newfeifan.mall.module.system.dal.mysql.user.AdminUserMapper;
 import cn.newfeifan.mall.module.trade.controller.admin.aftersale.vo.AfterSaleDisagreeReqVO;
 import cn.newfeifan.mall.module.trade.controller.admin.aftersale.vo.AfterSalePageReqVO;
 import cn.newfeifan.mall.module.trade.controller.admin.aftersale.vo.AfterSaleRefuseReqVO;
+import cn.newfeifan.mall.module.trade.controller.admin.delivery.vo.expresstemplate.ShopBO;
 import cn.newfeifan.mall.module.trade.controller.app.aftersale.vo.AppAfterSaleCreateReqVO;
 import cn.newfeifan.mall.module.trade.controller.app.aftersale.vo.AppAfterSaleDeliveryReqVO;
 import cn.newfeifan.mall.module.trade.convert.aftersale.AfterSaleConvert;
@@ -32,9 +35,13 @@ import cn.newfeifan.mall.module.trade.framework.order.config.TradeOrderPropertie
 import cn.newfeifan.mall.module.trade.service.delivery.DeliveryExpressService;
 import cn.newfeifan.mall.module.trade.service.order.TradeOrderQueryService;
 import cn.newfeifan.mall.module.trade.service.order.TradeOrderUpdateService;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.support.TransactionSynchronization;
@@ -46,6 +53,7 @@ import java.time.LocalDateTime;
 import java.util.List;
 
 import static cn.newfeifan.mall.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.newfeifan.mall.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
 import static cn.newfeifan.mall.module.trade.enums.ErrorCodeConstants.*;
 
 /**
@@ -76,6 +84,11 @@ public class AfterSaleServiceImpl implements AfterSaleService {
     @Resource
     private TradeOrderProperties tradeOrderProperties;
 
+    @Resource
+    private StringRedisTemplate stringRedisTemplate;
+    @Resource
+    private AdminUserMapper userMapper;
+
     @Override
     public PageResult<AfterSaleDO> getAfterSalePage(AfterSalePageReqVO pageReqVO) {
         return tradeAfterSaleMapper.selectPage(pageReqVO);
@@ -98,7 +111,7 @@ public class AfterSaleServiceImpl implements AfterSaleService {
 
     @Override
     public AfterSaleDO getAfterSaleByOrderNo(String orderNo) {
-        return tradeAfterSaleMapper.selectOne(new LambdaQueryWrapper<AfterSaleDO>().eq(AfterSaleDO::getOrderNo,orderNo));
+        return tradeAfterSaleMapper.selectOne(new LambdaQueryWrapper<AfterSaleDO>().eq(AfterSaleDO::getOrderNo, orderNo));
     }
 
     @Override
@@ -419,8 +432,9 @@ 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) {
+    public Long getApplyingAfterSaleCount(Long userId, Long shopId, Long merId) {
         return tradeAfterSaleMapper.selectCountByUserIdAndStatus(userId, shopId, merId, AfterSaleStatusEnum.APPLYING_STATUSES);
     }
 
@@ -430,4 +444,39 @@ public class AfterSaleServiceImpl implements AfterSaleService {
                 .in(AfterSaleDO::getOrderId, orderIds));
     }
 
+    @Override
+    public List<AfterSaleDO> getAfterSaleByProId(Long spuId) {
+        return tradeAfterSaleMapper.selectList(new LambdaQueryWrapper<AfterSaleDO>()
+                .eq(AfterSaleDO::getSpuId, spuId));
+    }
+
+    @Override
+    public List<AfterSaleDO> getAfterSaleByMerAndShop() {
+        ShopBO shop = getShop();
+
+        return tradeAfterSaleMapper.selectList(new LambdaQueryWrapper<AfterSaleDO>()
+                .eq(AfterSaleDO::getShopId, shop.getShopId())
+                .eq(AfterSaleDO::getMerchantId, shop.getMerId()));
+    }
+
+    private ShopBO getShop() {
+        return getShopBO(stringRedisTemplate, userMapper, log);
+    }
+
+    public static ShopBO getShopBO(StringRedisTemplate stringRedisTemplate, AdminUserMapper userMapper, Logger log) {
+        Long loginUserId = getLoginUserId();
+        String s = stringRedisTemplate.opsForValue().get("shop:" + loginUserId);
+        if (StringUtils.isEmpty(s)) {
+            AdminUserDO adminUserDO = userMapper.selectById(loginUserId);
+            ShopBO shop = new ShopBO();
+            shop.setShopId(adminUserDO.getShopId());
+            shop.setMerId(adminUserDO.getMerchantId());
+            log.info("====shop:{}", shop);
+            return shop;
+        } else {
+            log.info("====shop:{}", s);
+            return JSONObject.parseObject(s, ShopBO.class);
+        }
+    }
+
 }

+ 2 - 13
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/order/TradeOrderQueryServiceImpl.java

@@ -45,6 +45,7 @@ import static cn.newfeifan.mall.framework.common.util.collection.CollectionUtils
 import static cn.newfeifan.mall.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
 import static cn.newfeifan.mall.module.trade.enums.ErrorCodeConstants.EXPRESS_NOT_EXISTS;
 import static cn.newfeifan.mall.module.trade.enums.ErrorCodeConstants.ORDER_NOT_FOUND;
+import static cn.newfeifan.mall.module.trade.service.aftersale.AfterSaleServiceImpl.getShopBO;
 
 /**
  * 交易订单【读】 Service 实现类
@@ -211,19 +212,7 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService {
     }
 
     private ShopBO getShop() {
-        Long loginUserId = getLoginUserId();
-        String s = stringRedisTemplate.opsForValue().get("shop:" + loginUserId);
-        if (StringUtils.isEmpty(s)) {
-            AdminUserDO adminUserDO = userMapper.selectById(loginUserId);
-            ShopBO shop = new ShopBO();
-            shop.setShopId(adminUserDO.getShopId());
-            shop.setMerId(adminUserDO.getMerchantId());
-            log.info("====shop:{}",shop);
-            return shop;
-        } else {
-            log.info("====shop:{}",s);
-            return JSONObject.parseObject(s, ShopBO.class);
-        }
+        return getShopBO(stringRedisTemplate, userMapper, log);
     }
 
     @Override