Prechádzať zdrojové kódy

Merge branch 'develop-kjf' into develop

* develop-kjf:
  修改了接口可循环SN列表根据机具类型返回,修改了接口可循环列表返回id,申请机具添加了校验:校验预发机是否存在于machine库
mac 2 rokov pred
rodič
commit
cfb7c20c07

+ 1 - 1
kxs-product/kxs-product-api/src/main/java/com/kxs/product/api/vo/kxsapp/machine/RecycleMachinesVO.java

@@ -22,7 +22,7 @@ public class RecycleMachinesVO implements Serializable {
 
 	@Serial
 	private static final long serialVersionUID = 1L;
-
+    private Long id;
 
     /**
      * 机具码

+ 2 - 2
kxs-product/kxs-product-biz/src/main/java/com/kxs/product/biz/controller/kxsapp/MachineController.java

@@ -44,9 +44,9 @@ public class MachineController {
      * @return 可循环机列表
      */
     @GetMapping("/recycleMachines")
-    public R recycleMachines(@ParameterObject Page<RecycleMachinesVO> page, @RequestParam("brandId") Integer brandId ) {
+    public R recycleMachines(@ParameterObject Page<RecycleMachinesVO> page, @RequestParam("brandType") Integer brandType ) {
 
-        return R.ok(kxsMachineService.recycleMachinesPage(page, brandId));
+        return R.ok(kxsMachineService.recycleMachinesPage(page, brandType));
     }
 
 

+ 2 - 2
kxs-product/kxs-product-biz/src/main/java/com/kxs/product/biz/mapper/KxsMachineMapper.java

@@ -36,10 +36,10 @@ public interface KxsMachineMapper extends BaseMapper<KxsMachine> {
      *
      * @param page    页
      * @param userId
-     * @param brandId
+     * @param brandIds
      * @return {@link IPage}<{@link RecycleMachinesVO}>
      */
-    IPage<RecycleMachinesVO> recycleMachinesPage(Page<RecycleMachinesVO> page, @Param("userId") Long userId, @Param("brandId") Integer brandId);
+    IPage<RecycleMachinesVO> recycleMachinesPage(Page<RecycleMachinesVO> page, @Param("userId") Long userId, @Param("brandIds") List<Integer> brandIds);
 
     /**
      * app 未绑定列表

+ 2 - 2
kxs-product/kxs-product-biz/src/main/java/com/kxs/product/biz/service/KxsMachineService.java

@@ -40,10 +40,10 @@ public interface KxsMachineService extends IService<KxsMachine> {
      * 可循环机列表
      *
      * @param page    页
-     * @param brandId
+     * @param brandType
      * @return {@link IPage}<{@link RecycleMachinesVO}>
      */
-    IPage<RecycleMachinesVO> recycleMachinesPage(Page<RecycleMachinesVO> page, Integer brandId);
+    IPage<RecycleMachinesVO> recycleMachinesPage(Page<RecycleMachinesVO> page, Integer brandType);
 
     /**
      * 未绑定机具列表

+ 3 - 4
kxs-product/kxs-product-biz/src/main/java/com/kxs/product/biz/service/impl/KxsMachineServiceImpl.java

@@ -84,16 +84,15 @@ public class KxsMachineServiceImpl extends ServiceImpl<KxsMachineMapper, KxsMach
     }
 
     @Override
-    public IPage<RecycleMachinesVO> recycleMachinesPage(Page<RecycleMachinesVO> page, Integer brandId) {
+    public IPage<RecycleMachinesVO> recycleMachinesPage(Page<RecycleMachinesVO> page, Integer brandType) {
 
         Long userId = SecurityUtils.getUser().getId();
 
         //查询品牌
-        KxsBrand kxsBrand = kxsBrandMapper.selectById(brandId);
-        List<KxsBrand> brands = kxsBrandMapper.selectList(Wrappers.<KxsBrand>lambdaQuery().eq(KxsBrand::getBrandType, kxsBrand.getBrandType()));
+        List<KxsBrand> brands = kxsBrandMapper.selectList(Wrappers.<KxsBrand>lambdaQuery().eq(KxsBrand::getBrandType, brandType));
         List<Integer> brandIds = brands.stream().map(KxsBrand::getId).toList();
 
-        IPage<RecycleMachinesVO> recycleMachines = baseMapper.recycleMachinesPage(page, userId, brandId);
+        IPage<RecycleMachinesVO> recycleMachines = baseMapper.recycleMachinesPage(page, userId, brandIds);
 
         recycleMachines.getRecords().forEach(item -> item.setBrandList(brandIds));
 

+ 6 - 5
kxs-product/kxs-product-biz/src/main/resources/mapper/KxsMachineMapper.xml

@@ -62,14 +62,15 @@
 
     </select>
     <select id="recycleMachinesPage" resultType="com.kxs.product.api.vo.kxsapp.machine.RecycleMachinesVO">
-        select create_time, pos_sn, machine_type, recycle_end_time from kxs_machine
+        select id,create_time, pos_sn, machine_type, recycle_end_time from kxs_machine
         <where>
             and del_flag = 0
             and recycle_status = 1
             and user_id = #{userId}
-            <if test="brandId != null">
-                and brand_id = #{brandId}
-            </if>
+            AND brand_id IN
+            <foreach collection="brandIds" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
         </where>
 
     </select>
@@ -161,7 +162,7 @@
         </where>
         GROUP BY `month`
         ) as tmp
-        ORDER BY `date` desc
+        ORDER BY `month` desc
     </select>
     <select id="activateMachineMonthTotalDetail"
             resultType="com.kxs.product.api.vo.kxsapp.machine.StoreActMachineDayDetailVO">

+ 1 - 1
kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/constant/enums/StoreErrorTypeEnum.java

@@ -12,7 +12,7 @@ import lombok.RequiredArgsConstructor;
 @Getter
 @RequiredArgsConstructor
 public enum StoreErrorTypeEnum {
-
+	MACHINE_IS_NULL(-1, "机具不存在"),
 	TICKET_NOT_FIND(-1, "券码不存在"),
 	TICKET_CODE_UN(-1, "券码已使用"),
 	SN_FIND_NULL(-1, "SN码不存在"),

+ 0 - 1
kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/controller/kxsapp/StoreAdvanceController.java

@@ -7,7 +7,6 @@ import com.kxs.store.api.model.KxsMachineAdvance;
 import com.kxs.store.api.model.KxsMachineAdvanceInfo;
 import com.kxs.store.api.model.KxsWarehouseLimit;
 import com.kxs.store.api.vo.kxsapp.storeAdvance.UserWarehouseListVO;
-import com.kxs.store.biz.mapper.KxsWarehouseLimitMapper;
 import com.kxs.store.biz.service.KxsMachineAdvanceService;
 import com.kxs.store.biz.service.KxsWarehouseLimitService;
 import com.kxs.store.biz.service.KxsWarehouseUserService;

+ 20 - 1
kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/service/impl/KxsMachineAdvanceServiceImpl.java

@@ -68,7 +68,6 @@ public class KxsMachineAdvanceServiceImpl extends ServiceImpl<KxsMachineAdvanceM
 
     private final RemoteUserMsgService remoteUserMsgService;
 
-
     private final KxsMachineAdvanceInfoMapper kxsMachineAdvanceInfoMapper;
 
 
@@ -208,11 +207,31 @@ public class KxsMachineAdvanceServiceImpl extends ServiceImpl<KxsMachineAdvanceM
                 .orElseThrow(() -> new GlobalCustomerException(ErrorTypeEnum.USER_NOT_FOUND.getDescription()));
 
         String pidPath = toUser.getPidPath();
+
         //判断是否是下级
         boolean contains = pidPath.contains("," + userId + ",");
         if (!contains) {
             return R.failed(StoreErrorTypeEnum.USER_IS_NOT_FIND.getDescription());
         }
+        //判断用户是否具备小分仓
+        KxsWarehouseLimit kxsWarehouseLimit = kxsWarehouseLimitMapper.selectOne(Wrappers.<KxsWarehouseLimit>query().lambda().eq(KxsWarehouseLimit::getUserId, toUser.getId()));
+        //当用户不存在小分仓时为用户构建小分仓
+        if (kxsWarehouseLimit == null){
+            //构建用户小分仓
+            //todo 此时需同步用户上月分润金额作为小分仓额度,暂时无法实现 初始化为0
+            kxsWarehouseLimit = new KxsWarehouseLimit();
+            kxsWarehouseLimit.setCreateTime(LocalDateTime.now());
+            kxsWarehouseLimit.setDelFlag("0");
+            kxsWarehouseLimit.setUserId(toUser.getId());
+            kxsWarehouseLimit.setValidAmount(BigDecimal.ZERO);
+            kxsWarehouseLimit.setFixedAmount(BigDecimal.ZERO);
+            kxsWarehouseLimit.setForAmount(BigDecimal.ZERO);
+            kxsWarehouseLimit.setCreditAmount(BigDecimal.ZERO);
+            kxsWarehouseLimit.setYueForAmount(BigDecimal.ZERO);
+            kxsWarehouseLimit.setUsedAmount(BigDecimal.ZERO);
+            kxsWarehouseLimit.setWarehouseType(1);
+            kxsWarehouseLimitMapper.insert(kxsWarehouseLimit);
+        }
         //预发数量
         Long advanceCount = baseMapper.selectUserByCount(toUser.getId());
         //预发数量+本次申请数量不能超过10

+ 3 - 1
kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/service/impl/KxsMachineApplyServiceImpl.java

@@ -184,7 +184,9 @@ public class KxsMachineApplyServiceImpl extends ServiceImpl<KxsMachineApplyMappe
                 //查询预发机
                 KxsMachineAdvanceInfo kxsMachineAdvance = kxsMachineAdvanceInfoMapper.selectOne(Wrappers.<KxsMachineAdvanceInfo>lambdaQuery()
                         .eq(KxsMachineAdvanceInfo::getPosSn, advanceSn));
-
+                if (adMachine == null){
+                    throw new GlobalCustomerException(StoreErrorTypeEnum.MACHINE_IS_NULL.getDescription());
+                }
                 if (kxsMachineAdvance == null ) {
                     throw new GlobalCustomerException(StoreErrorTypeEnum.ADVANCE_MACHINE_NOT_FIND.getDescription());
                 }