he2802 2 rokov pred
rodič
commit
fca4a63074

+ 6 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/schedule/ScheduleController.java

@@ -424,4 +424,10 @@ public class ScheduleController extends BaseController {
         return AjaxResult.success();
     }
 
+    @ApiOperation("分销佣金解冻")
+    @GetMapping("/distributionRebate")
+    public AjaxResult distributionRebate(UserQueryBo bo){
+        iScheduleService.distributionRebate();
+        return AjaxResult.success();
+    }
 }

+ 4 - 2
zhongzheng-system/src/main/java/com/zhongzheng/modules/distribution/bo/DistributionRebateQueryBo.java

@@ -35,8 +35,6 @@ public class DistributionRebateQueryBo extends BaseEntity {
 	/** 排序的方向desc或者asc */
 	@ApiModelProperty(value = "排序的方向", example = "asc,desc")
 	private String isAsc;
-
-
 	/** 分销码 */
 	@ApiModelProperty("分销码")
 	private String distributionCode;
@@ -70,4 +68,8 @@ public class DistributionRebateQueryBo extends BaseEntity {
 	/** 状态:1有效, -1无效 */
 	@ApiModelProperty("状态:1有效, -1无效")
 	private Integer status;
+	@ApiModelProperty("解冻开始时间")
+	private Long openStartTime;
+	@ApiModelProperty("解冻结束时间")
+	private Long openEndTime;
 }

+ 1 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/distribution/service/impl/DistributionRebateServiceImpl.java

@@ -52,6 +52,7 @@ public class DistributionRebateServiceImpl extends ServiceImpl<DistributionRebat
         lqw.eq(bo.getCashStatus() != null, DistributionRebate::getCashStatus, bo.getCashStatus());
         lqw.eq(bo.getOpenTime() != null, DistributionRebate::getOpenTime, bo.getOpenTime());
         lqw.eq(bo.getStatus() != null, DistributionRebate::getStatus, bo.getStatus());
+        lqw.between(bo.getOpenStartTime() != null, DistributionRebate::getOpenTime, bo.getOpenStartTime(), bo.getOpenEndTime());
         return entity2Vo(this.list(lqw));
     }
 

+ 65 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/schedule/service/impl/ScheduleServiceImpl.java

@@ -27,6 +27,14 @@ import com.zhongzheng.modules.course.vo.CourseChapterSectionVo;
 import com.zhongzheng.modules.course.vo.CourseMenuVo;
 import com.zhongzheng.modules.course.vo.CourseModuleChapterVo;
 import com.zhongzheng.modules.course.vo.CourseSectionVo;
+import com.zhongzheng.modules.distribution.bo.DistributionCashLogAddBo;
+import com.zhongzheng.modules.distribution.bo.DistributionRebateQueryBo;
+import com.zhongzheng.modules.distribution.domain.DistributionRebate;
+import com.zhongzheng.modules.distribution.domain.DistributionSeller;
+import com.zhongzheng.modules.distribution.service.IDistributionCashLogService;
+import com.zhongzheng.modules.distribution.service.IDistributionRebateService;
+import com.zhongzheng.modules.distribution.service.IDistributionSellerService;
+import com.zhongzheng.modules.distribution.vo.DistributionRebateVo;
 import com.zhongzheng.modules.exam.bo.ExamApplyQueryBo;
 import com.zhongzheng.modules.exam.bo.ExamBeforeQueryBo;
 import com.zhongzheng.modules.exam.bo.ExamTodayRecordBo;
@@ -266,6 +274,15 @@ public class ScheduleServiceImpl extends ServiceImpl<PolyvVideoMapper, PolyvVide
     @Autowired
     private IWisdomService iWisdomService;
 
+    @Autowired
+    private IDistributionRebateService iDistributionRebateService;
+
+    @Autowired
+    private IDistributionCashLogService iDistributionCashLogService;
+
+    @Autowired
+    private IDistributionSellerService iDistributionSellerService;
+
     @Value("${aliyun.sms.OpenTheGoodsCode}")
     private String OpenTheGoodsCode;
 
@@ -1084,7 +1101,54 @@ public class ScheduleServiceImpl extends ServiceImpl<PolyvVideoMapper, PolyvVide
 
     @Override
     public void distributionRebate() {
-
+        DistributionRebateQueryBo queryBo = new DistributionRebateQueryBo();
+        Long startTime = DateUtils.getTodayZeroTime();
+        Long endTime = DateUtils.getNowTime();
+        queryBo.setOpenStartTime(startTime);
+        queryBo.setOpenEndTime(endTime);
+        queryBo.setCashStatus(1);
+        List<DistributionRebateVo> list = iDistributionRebateService.queryList(queryBo);
+        for(DistributionRebateVo vo : list){
+            DistributionSeller seller = iDistributionSellerService.getOne(new LambdaQueryWrapper<DistributionSeller>()
+                    .eq(DistributionSeller::getSellerId, vo.getSellerId()).last("limit 1"));
+            if(Validator.isEmpty(seller)){
+                throw new CustomException("业务员不存在");
+            }
+            //冻结金额日志
+            BigDecimal oldFreezeCash = seller.getFreezeCash();
+            BigDecimal newFreezeCash = seller.getFreezeCash().subtract(vo.getCash());
+            DistributionCashLogAddBo cashFreezeLogAddBo = new DistributionCashLogAddBo();
+            cashFreezeLogAddBo.setSellerId(seller.getSellerId());
+            cashFreezeLogAddBo.setOldNum(oldFreezeCash);
+            cashFreezeLogAddBo.setNewNum(newFreezeCash);
+            cashFreezeLogAddBo.setDiffNum(vo.getCash().negate());
+            cashFreezeLogAddBo.setRelatedSn(vo.getOrderSn());
+            cashFreezeLogAddBo.setType(1L);
+            iDistributionCashLogService.insertByAddBo(cashFreezeLogAddBo);
+
+            //可提现日志
+            BigDecimal oldCash = seller.getCash();
+            BigDecimal newCash = seller.getCash().add(vo.getCash());
+            DistributionCashLogAddBo cashLogAddBo = new DistributionCashLogAddBo();
+            cashLogAddBo.setSellerId(seller.getSellerId());
+            cashLogAddBo.setOldNum(oldCash);
+            cashLogAddBo.setNewNum(newCash);
+            cashLogAddBo.setDiffNum(vo.getCash());
+            cashLogAddBo.setRelatedSn(vo.getOrderSn());
+            cashLogAddBo.setType(2L);
+            iDistributionCashLogService.insertByAddBo(cashLogAddBo);
+
+            seller.setCash(newCash);
+            seller.setFreezeCash(newFreezeCash);
+            seller.setUpdateTime(DateUtils.getNowTime());
+            iDistributionSellerService.updateById(seller);
+
+            DistributionRebate rebate = new DistributionRebate();
+            rebate.setId(vo.getId());
+            rebate.setCashStatus(2);
+            rebate.setUpdateTime(DateUtils.getNowTime());
+            iDistributionRebateService.updateById(rebate);
+        }
     }
 
     @Override