|
@@ -3,6 +3,7 @@ package com.zhongzheng.modules.distribution.service.impl;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.lang.Validator;
|
|
import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
@@ -13,6 +14,8 @@ import com.zhongzheng.common.core.domain.entity.SysRole;
|
|
|
import com.zhongzheng.common.core.domain.entity.SysUser;
|
|
import com.zhongzheng.common.core.domain.entity.SysUser;
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
|
|
+import com.zhongzheng.common.utils.ToolsUtils;
|
|
|
|
|
+import com.zhongzheng.common.utils.http.HttpUtils;
|
|
|
import com.zhongzheng.modules.distribution.bo.*;
|
|
import com.zhongzheng.modules.distribution.bo.*;
|
|
|
import com.zhongzheng.modules.distribution.domain.DistributionCashWithdrawal;
|
|
import com.zhongzheng.modules.distribution.domain.DistributionCashWithdrawal;
|
|
|
import com.zhongzheng.modules.distribution.domain.DistributionCheck;
|
|
import com.zhongzheng.modules.distribution.domain.DistributionCheck;
|
|
@@ -25,17 +28,24 @@ import com.zhongzheng.modules.distribution.service.IDistributionSellerService;
|
|
|
import com.zhongzheng.modules.distribution.vo.DistributionCashWithdrawalVo;
|
|
import com.zhongzheng.modules.distribution.vo.DistributionCashWithdrawalVo;
|
|
|
import com.zhongzheng.modules.distribution.vo.DistributionCheckDetailVo;
|
|
import com.zhongzheng.modules.distribution.vo.DistributionCheckDetailVo;
|
|
|
import com.zhongzheng.modules.distribution.vo.DistributionCheckVo;
|
|
import com.zhongzheng.modules.distribution.vo.DistributionCheckVo;
|
|
|
|
|
+import com.zhongzheng.modules.grade.domain.ClassGradeUser;
|
|
|
|
|
+import com.zhongzheng.modules.grade.service.impl.UserPeriodServiceImpl;
|
|
|
|
|
+import com.zhongzheng.modules.order.domain.OrderGoods;
|
|
|
import com.zhongzheng.modules.system.domain.SysUserRole;
|
|
import com.zhongzheng.modules.system.domain.SysUserRole;
|
|
|
import com.zhongzheng.modules.system.service.ISysRoleService;
|
|
import com.zhongzheng.modules.system.service.ISysRoleService;
|
|
|
import com.zhongzheng.modules.system.service.ISysUserRoleService;
|
|
import com.zhongzheng.modules.system.service.ISysUserRoleService;
|
|
|
import com.zhongzheng.modules.system.service.ISysUserService;
|
|
import com.zhongzheng.modules.system.service.ISysUserService;
|
|
|
|
|
+import com.zhongzheng.modules.user.domain.UserVisitLog;
|
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
-import java.util.Collection;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -60,6 +70,11 @@ public class DistributionCashWithdrawalServiceImpl extends ServiceImpl<Distribut
|
|
|
@Autowired
|
|
@Autowired
|
|
|
public IDistributionCheckService iDistributionCheckService;
|
|
public IDistributionCheckService iDistributionCheckService;
|
|
|
|
|
|
|
|
|
|
+ @Value("${distributionOldPay.host}")
|
|
|
|
|
+ private String OLD_PAY_HOST;
|
|
|
|
|
+
|
|
|
|
|
+ private static Logger log = LoggerFactory.getLogger(DistributionCashWithdrawalServiceImpl.class);
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public DistributionCashWithdrawalVo queryById(Long id){
|
|
public DistributionCashWithdrawalVo queryById(Long id){
|
|
|
DistributionCashWithdrawal db = this.baseMapper.selectById(id);
|
|
DistributionCashWithdrawal db = this.baseMapper.selectById(id);
|
|
@@ -78,6 +93,7 @@ public class DistributionCashWithdrawalServiceImpl extends ServiceImpl<Distribut
|
|
|
lqw.eq(StrUtil.isNotBlank(bo.getRefundResaon()), DistributionCashWithdrawal::getRefundResaon, bo.getRefundResaon());
|
|
lqw.eq(StrUtil.isNotBlank(bo.getRefundResaon()), DistributionCashWithdrawal::getRefundResaon, bo.getRefundResaon());
|
|
|
lqw.eq(bo.getCash() != null, DistributionCashWithdrawal::getCash, bo.getCash());
|
|
lqw.eq(bo.getCash() != null, DistributionCashWithdrawal::getCash, bo.getCash());
|
|
|
lqw.eq(bo.getApplyTime() != null, DistributionCashWithdrawal::getApplyTime, bo.getApplyTime());
|
|
lqw.eq(bo.getApplyTime() != null, DistributionCashWithdrawal::getApplyTime, bo.getApplyTime());
|
|
|
|
|
+ lqw.between(bo.getApplyStartTime()!= null, DistributionCashWithdrawal::getApplyTime,bo.getApplyStartTime(),bo.getApplyEndTime());
|
|
|
return entity2Vo(this.list(lqw));
|
|
return entity2Vo(this.list(lqw));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -255,13 +271,118 @@ public class DistributionCashWithdrawalServiceImpl extends ServiceImpl<Distribut
|
|
|
return list.stream().map(item -> BeanUtil.toBean(item,DistributionCheckDetailVo.class)).collect(Collectors.toList());
|
|
return list.stream().map(item -> BeanUtil.toBean(item,DistributionCheckDetailVo.class)).collect(Collectors.toList());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean payCash(DistributionCheckQueryBo bo) {
|
|
|
|
|
+ DistributionCashWithdrawal withdrawal = getOne(new LambdaQueryWrapper<DistributionCashWithdrawal>()
|
|
|
|
|
+ .eq(DistributionCashWithdrawal::getCwSn, "CW23032517295715731864"));
|
|
|
|
|
+ if(withdrawal.getStatus()!=3){
|
|
|
|
|
+ throw new CustomException("非法操作");
|
|
|
|
|
+ }
|
|
|
|
|
+ DistributionSeller seller = iDistributionSellerService.getOne(new LambdaQueryWrapper<DistributionSeller>()
|
|
|
|
|
+ .eq(DistributionSeller::getSellerId, withdrawal.getSellerId()).last("limit 1"));
|
|
|
|
|
+ if(Validator.isEmpty(seller)||Validator.isEmpty(seller.getGzhOpenId())){
|
|
|
|
|
+ throw new CustomException("非法业务员或不存在openID");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, String> params = new HashMap<>();
|
|
|
|
|
+ Long nowTime = DateUtils.getNowTime();
|
|
|
|
|
+ String sign = ToolsUtils.EncoderByMd5(withdrawal.getCwSn()+nowTime.toString()+"pubilc2022");
|
|
|
|
|
+ params.put("stamp", nowTime.toString());
|
|
|
|
|
+ params.put("sign", sign);
|
|
|
|
|
+ params.put("OpenId", seller.getGzhOpenId());
|
|
|
|
|
+ params.put("MchBillno", withdrawal.getCwSn());
|
|
|
|
|
+ params.put("Money", withdrawal.getCash().toString());
|
|
|
|
|
+ String respone = "";
|
|
|
|
|
+ try {
|
|
|
|
|
+ respone = HttpUtils.postFormBody(OLD_PAY_HOST, params);
|
|
|
|
|
+ log.info("分享红包打款结果"+respone,"");
|
|
|
|
|
+ if (!respone.contains("\"Status\":true")) {
|
|
|
|
|
+ throw new CustomException("打款请求错误"+respone);
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
|
+ throw new CustomException("打款请求错误"+e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ withdrawal.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
|
+ withdrawal.setCwStatus(5);
|
|
|
|
|
+ updateById(withdrawal);
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean payCashCallBack(DistributionCashWithdrawalPayBo bo) {
|
|
|
|
|
+ DistributionCashWithdrawal withdrawal = getOne(new LambdaQueryWrapper<DistributionCashWithdrawal>()
|
|
|
|
|
+ .eq(DistributionCashWithdrawal::getCwSn, bo.getCwSn()));
|
|
|
|
|
+ if(Validator.isEmpty(withdrawal)||withdrawal.getStatus()!=5){
|
|
|
|
|
+ throw new CustomException("非法操作");
|
|
|
|
|
+ }
|
|
|
|
|
+ if(bo.getStatus()==1){
|
|
|
|
|
+ withdrawal.setCwStatus(4);
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ withdrawal.setCwStatus(6);
|
|
|
|
|
+ }
|
|
|
|
|
+ withdrawal.setPayTime(DateUtils.getNowTime());
|
|
|
|
|
+ withdrawal.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
|
+ updateById(withdrawal);
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public boolean cancelApply(DistributionCashWithdrawalEditBo bo) {
|
|
|
|
|
+ DistributionCashWithdrawal withdrawal = getOne(new LambdaQueryWrapper<DistributionCashWithdrawal>()
|
|
|
|
|
+ .eq(DistributionCashWithdrawal::getCwSn, bo.getCwSn())
|
|
|
|
|
+ .eq(DistributionCashWithdrawal::getSellerId, bo.getSellerId()));
|
|
|
|
|
+ if(Validator.isEmpty(withdrawal)){
|
|
|
|
|
+ throw new CustomException("数据错误");
|
|
|
|
|
+ }
|
|
|
|
|
+ if(withdrawal.getCwStatus()!=0){
|
|
|
|
|
+ throw new CustomException("非法操作");
|
|
|
|
|
+ }
|
|
|
|
|
+ withdrawal.setCwStatus(-2);
|
|
|
|
|
+ withdrawal.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
|
+ updateById(withdrawal);
|
|
|
|
|
+
|
|
|
|
|
+ DistributionSeller seller = iDistributionSellerService.getOne(new LambdaQueryWrapper<DistributionSeller>()
|
|
|
|
|
+ .eq(DistributionSeller::getSellerId, withdrawal.getSellerId()).last("limit 1"));
|
|
|
|
|
+ BigDecimal oldCash = seller.getCash();
|
|
|
|
|
+ BigDecimal newCash = seller.getCash().add(withdrawal.getCash());
|
|
|
|
|
+ //可提现日志
|
|
|
|
|
+ DistributionCashLogAddBo cashLogAddBo = new DistributionCashLogAddBo();
|
|
|
|
|
+ cashLogAddBo.setSellerId(withdrawal.getSellerId());
|
|
|
|
|
+ cashLogAddBo.setOldNum(oldCash);
|
|
|
|
|
+ cashLogAddBo.setNewNum(newCash);
|
|
|
|
|
+ cashLogAddBo.setDiffNum(withdrawal.getCash());
|
|
|
|
|
+ cashLogAddBo.setRelatedSn(withdrawal.getCwSn());
|
|
|
|
|
+ cashLogAddBo.setType(2L);
|
|
|
|
|
+ cashLogAddBo.setRemark("用户取消申请");
|
|
|
|
|
+ iDistributionCashLogService.insertByAddBo(cashLogAddBo);
|
|
|
|
|
+ //已提现日志
|
|
|
|
|
+ BigDecimal oldUsedCash = seller.getUsedCash();
|
|
|
|
|
+ BigDecimal newUsedCash = seller.getUsedCash().subtract(withdrawal.getCash());
|
|
|
|
|
+ DistributionCashLogAddBo usedCashLogAddBo = new DistributionCashLogAddBo();
|
|
|
|
|
+ usedCashLogAddBo.setSellerId(withdrawal.getSellerId());
|
|
|
|
|
+ usedCashLogAddBo.setOldNum(oldUsedCash);
|
|
|
|
|
+ usedCashLogAddBo.setNewNum(newUsedCash);
|
|
|
|
|
+ usedCashLogAddBo.setDiffNum(withdrawal.getCash().negate());
|
|
|
|
|
+ usedCashLogAddBo.setRelatedSn(withdrawal.getCwSn());
|
|
|
|
|
+ usedCashLogAddBo.setType(3L);
|
|
|
|
|
+ usedCashLogAddBo.setRemark("用户取消申请");
|
|
|
|
|
+ iDistributionCashLogService.insertByAddBo(usedCashLogAddBo);
|
|
|
|
|
+
|
|
|
|
|
+ seller.setCash(newCash);
|
|
|
|
|
+ seller.setUsedCash(newUsedCash);
|
|
|
|
|
+ seller.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
|
+ iDistributionSellerService.updateById(seller);
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private void addNextAuditor(DistributionCheck check,Integer nextStatus,String nextKey){
|
|
private void addNextAuditor(DistributionCheck check,Integer nextStatus,String nextKey){
|
|
|
check.setNextStatus(nextStatus);//初审
|
|
check.setNextStatus(nextStatus);//初审
|
|
|
List<String> userNames = iSysUserService.getUserNameByRoleKey(nextKey);
|
|
List<String> userNames = iSysUserService.getUserNameByRoleKey(nextKey);
|
|
|
if (CollectionUtils.isNotEmpty(userNames)){
|
|
if (CollectionUtils.isNotEmpty(userNames)){
|
|
|
check.setNextAuditor(userNames.stream().collect(Collectors.joining()));
|
|
check.setNextAuditor(userNames.stream().collect(Collectors.joining()));
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void validPermission(DistributionCheckHandleBo bo,String roleKey) {
|
|
private void validPermission(DistributionCheckHandleBo bo,String roleKey) {
|