|
@@ -10,6 +10,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.jzg.commons.core.base.BaseController;
|
|
import com.jzg.commons.core.base.BaseController;
|
|
|
import com.jzg.commons.core.base.StateResult;
|
|
import com.jzg.commons.core.base.StateResult;
|
|
|
import com.jzg.commons.core.page.HttpResult;
|
|
import com.jzg.commons.core.page.HttpResult;
|
|
|
|
|
+import com.jzg.commons.entity.account.po.InvAccountCard;
|
|
|
|
|
+import com.jzg.commons.entity.account.po.SysUserAccountChangeLog;
|
|
|
import com.jzg.commons.entity.dto.*;
|
|
import com.jzg.commons.entity.dto.*;
|
|
|
import com.jzg.commons.entity.po.SysAmountAuditing;
|
|
import com.jzg.commons.entity.po.SysAmountAuditing;
|
|
|
import com.jzg.commons.entity.po.SysUserAccount;
|
|
import com.jzg.commons.entity.po.SysUserAccount;
|
|
@@ -21,12 +23,10 @@ import com.jzg.commons.util.AssertionUtils;
|
|
|
import com.jzg.commons.util.BigDecimalUtil;
|
|
import com.jzg.commons.util.BigDecimalUtil;
|
|
|
import com.jzg.commons.util.StringUtils;
|
|
import com.jzg.commons.util.StringUtils;
|
|
|
import com.jzg.organization.mapper.SysAmountAuditingMapper;
|
|
import com.jzg.organization.mapper.SysAmountAuditingMapper;
|
|
|
-import com.jzg.organization.service.SysAmountAuditingService;
|
|
|
|
|
-import com.jzg.organization.service.SysUserAccountService;
|
|
|
|
|
-import com.jzg.organization.service.SysUserJzgInfoBankCardService;
|
|
|
|
|
-import com.jzg.organization.service.SysUserJzgInfoService;
|
|
|
|
|
|
|
+import com.jzg.organization.service.*;
|
|
|
import com.jzg.organization.state.AuditState;
|
|
import com.jzg.organization.state.AuditState;
|
|
|
import com.jzg.organization.state.listener.AuditStateListener;
|
|
import com.jzg.organization.state.listener.AuditStateListener;
|
|
|
|
|
+import io.seata.spring.annotation.GlobalTransactional;
|
|
|
import org.redisson.api.RBucket;
|
|
import org.redisson.api.RBucket;
|
|
|
import org.redisson.api.RedissonClient;
|
|
import org.redisson.api.RedissonClient;
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
@@ -56,6 +56,9 @@ public class SysAmountAuditingServiceImpl extends ServiceImpl<SysAmountAuditingM
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private BaseController baseController;
|
|
private BaseController baseController;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SysUserJzgInfoService sysJzgInfoService;
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private RedissonClient redissonClient;
|
|
private RedissonClient redissonClient;
|
|
|
|
|
|
|
@@ -74,6 +77,11 @@ public class SysAmountAuditingServiceImpl extends ServiceImpl<SysAmountAuditingM
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ExportBaseServiceImpl exportBaseService;
|
|
private ExportBaseServiceImpl exportBaseService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SysUserAccountIncomeLogService sysUserAccountIncomeLogService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private InvAccountCardService invAccountCardService;
|
|
|
|
|
+
|
|
|
private static final String AMOUNT_LOCK_PREFIX = "amountLock:";
|
|
private static final String AMOUNT_LOCK_PREFIX = "amountLock:";
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -176,10 +184,11 @@ public class SysAmountAuditingServiceImpl extends ServiceImpl<SysAmountAuditingM
|
|
|
/**
|
|
/**
|
|
|
* 提现付款
|
|
* 提现付款
|
|
|
*
|
|
*
|
|
|
- * @param param
|
|
|
|
|
|
|
+ * @param param 提现付款的付款凭证等信息
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ @GlobalTransactional(rollbackFor = Exception.class)
|
|
|
public HttpResult<String> verifyAmount(AmountAuditEditParam param) {
|
|
public HttpResult<String> verifyAmount(AmountAuditEditParam param) {
|
|
|
String userName = baseController.getUserName();
|
|
String userName = baseController.getUserName();
|
|
|
String userId = baseController.getUserId();
|
|
String userId = baseController.getUserId();
|
|
@@ -189,20 +198,7 @@ public class SysAmountAuditingServiceImpl extends ServiceImpl<SysAmountAuditingM
|
|
|
return HttpResult.error("付款账户不能为空");
|
|
return HttpResult.error("付款账户不能为空");
|
|
|
}
|
|
}
|
|
|
SysAmountAuditing audit = this.getById(param.getId());
|
|
SysAmountAuditing audit = this.getById(param.getId());
|
|
|
- if(audit.getAuditingStatus() > 0){
|
|
|
|
|
- if(audit.getAuditingStatus() == 1){
|
|
|
|
|
- AssertionUtils.isFail(true, "提现已付款请刷新列表");
|
|
|
|
|
- }else{
|
|
|
|
|
- AssertionUtils.isFail(true, "提现已驳回请刷新列表");
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if(StringUtils.isBlank(audit.getReceiveUser())){
|
|
|
|
|
- AssertionUtils.isFail(true, "请领取提现申请后再进行付款,返回待付款提现申请列表!");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (!userName.equals(audit.getReceiveUser())) {
|
|
|
|
|
- AssertionUtils.isFail(true, "申请已被"+audit.getReceiveUser()+"领取返回待付款提现申请列表!");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ this.validateBeforePass(audit, userName);
|
|
|
if(StringUtils.isNotBlank(audit.getReceiveUser())){
|
|
if(StringUtils.isNotBlank(audit.getReceiveUser())){
|
|
|
if(userName.equals(audit.getReceiveUser())){
|
|
if(userName.equals(audit.getReceiveUser())){
|
|
|
StateResult stateFailResult = auditStateListener.statusChange(AuditState.AuditStateEnum.SUCCESS_AUDIT,audit.getAuditingStatus()+"", userName,userId);
|
|
StateResult stateFailResult = auditStateListener.statusChange(AuditState.AuditStateEnum.SUCCESS_AUDIT,audit.getAuditingStatus()+"", userName,userId);
|
|
@@ -218,18 +214,24 @@ public class SysAmountAuditingServiceImpl extends ServiceImpl<SysAmountAuditingM
|
|
|
SysUserAccount userAccount = userAccountService.queryByUserId(audit.getUserId(),systemCode);
|
|
SysUserAccount userAccount = userAccountService.queryByUserId(audit.getUserId(),systemCode);
|
|
|
AssertionUtils.isFail(Objects.isNull(userAccount), "用户账户数据异常!");
|
|
AssertionUtils.isFail(Objects.isNull(userAccount), "用户账户数据异常!");
|
|
|
AssertionUtils.isFail(audit.getAmount().compareTo(audit.getBalanceAmount()) > 0, "提现金额大于账户余额!");
|
|
AssertionUtils.isFail(audit.getAmount().compareTo(audit.getBalanceAmount()) > 0, "提现金额大于账户余额!");
|
|
|
-
|
|
|
|
|
- if(userAccount.getSumAmount().compareTo(audit.getAmount()) < 0){
|
|
|
|
|
|
|
+ if(userAccount.getSumAmountUnpaid().compareTo(audit.getAmount()) < 0){
|
|
|
log.info("账户金额少于提现金额,请审核账户。 userId=[{}}], userAccount.getSumAmount()=[{}],audit.getAmount()=[{}]",userAccount.getUserId(), userAccount.getSumAmount(), audit.getAmount());
|
|
log.info("账户金额少于提现金额,请审核账户。 userId=[{}}], userAccount.getSumAmount()=[{}],audit.getAmount()=[{}]",userAccount.getUserId(), userAccount.getSumAmount(), audit.getAmount());
|
|
|
throw new SystemException("账户金额少于提现金额,请审核账户");
|
|
throw new SystemException("账户金额少于提现金额,请审核账户");
|
|
|
}
|
|
}
|
|
|
|
|
+ BigDecimal amountBefore = userAccount.getSumAmountUnpaid();
|
|
|
// 应付总计: 只添加,不减。 modify by lipf ,2026年6月3日14:30:33
|
|
// 应付总计: 只添加,不减。 modify by lipf ,2026年6月3日14:30:33
|
|
|
- // sumAmount = sumAmountPaid + SumAmountUnpaid
|
|
|
|
|
- //userAccount.setSumAmount(userAccount.getSumAmount().subtract(audit.getAmount()));
|
|
|
|
|
userAccount.setSumAmountPaid(userAccount.getSumAmountPaid().add(audit.getAmount()));
|
|
userAccount.setSumAmountPaid(userAccount.getSumAmountPaid().add(audit.getAmount()));
|
|
|
userAccount.setSumAmountUnpaid(userAccount.getSumAmountUnpaid().subtract(audit.getAmount()));
|
|
userAccount.setSumAmountUnpaid(userAccount.getSumAmountUnpaid().subtract(audit.getAmount()));
|
|
|
-
|
|
|
|
|
- userAccountService.saveOrUpdate(userAccount);
|
|
|
|
|
|
|
+ SysUserAccountChangeLog changeLog = this.fillSysUserAccountChangeLog(systemCode,userName,amountBefore,
|
|
|
|
|
+ audit.getAmount(),userAccount.getUserId(),param);
|
|
|
|
|
+ try{
|
|
|
|
|
+ log.info("changeLog=【{}】",JSONUtil.toJsonStr(changeLog));
|
|
|
|
|
+ sysUserAccountIncomeLogService.save(changeLog);
|
|
|
|
|
+ userAccountService.saveOrUpdate(userAccount);
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ log.error("新增明细异常",e);
|
|
|
|
|
+ throw new SystemException(e.getMessage());
|
|
|
|
|
+ }
|
|
|
}else{
|
|
}else{
|
|
|
AssertionUtils.isFail(true, "提现申请已被" + audit.getReceiveUser() + "领取!");
|
|
AssertionUtils.isFail(true, "提现申请已被" + audit.getReceiveUser() + "领取!");
|
|
|
}
|
|
}
|
|
@@ -239,6 +241,89 @@ public class SysAmountAuditingServiceImpl extends ServiceImpl<SysAmountAuditingM
|
|
|
return HttpResult.ok("提现审核成功");
|
|
return HttpResult.ok("提现审核成功");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 提现申请通过前的校验
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author lipf
|
|
|
|
|
+ * @date 2026/6/8 15:57
|
|
|
|
|
+ */
|
|
|
|
|
+ private void validateBeforePass(SysAmountAuditing audit, String userName) {
|
|
|
|
|
+ if(audit.getAuditingStatus() > 0){
|
|
|
|
|
+ if(audit.getAuditingStatus() == 1){
|
|
|
|
|
+ AssertionUtils.isFail(true, "提现已付款请刷新列表");
|
|
|
|
|
+ }else{
|
|
|
|
|
+ AssertionUtils.isFail(true, "提现已驳回请刷新列表");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if(StringUtils.isBlank(audit.getReceiveUser())){
|
|
|
|
|
+ AssertionUtils.isFail(true, "请领取提现申请后再进行付款,返回待付款提现申请列表!");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!userName.equals(audit.getReceiveUser())) {
|
|
|
|
|
+ AssertionUtils.isFail(true, "申请已被"+ audit.getReceiveUser()+"领取返回待付款提现申请列表!");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 填充账户变更记录信息
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param systemCode 租户代码
|
|
|
|
|
+ * @param userName 操作用户
|
|
|
|
|
+ * @param amount 操作的金额
|
|
|
|
|
+ * @param ywyUserId 业务员账户信息
|
|
|
|
|
+ * @param param 里面的id表示提现申请表 sys_amount_auditing 表的序号, accountId 表示 inv_account_card 表中账号
|
|
|
|
|
+ * @author lipf
|
|
|
|
|
+ * @date 2026/6/8 15:53
|
|
|
|
|
+ */
|
|
|
|
|
+ private SysUserAccountChangeLog fillSysUserAccountChangeLog(String systemCode, String userName,
|
|
|
|
|
+ BigDecimal amountBefore,
|
|
|
|
|
+ BigDecimal amount, String ywyUserId,
|
|
|
|
|
+ AmountAuditEditParam param) {
|
|
|
|
|
+ log.info("填充业务员收支明细: param=[{}]systemCode=[{}],userName=[{}], amount=[{}], amountBefore=[{}], ywyUserId=[{}]", JSONUtil.toJsonStr(param), systemCode, userName, amount, amountBefore, ywyUserId);
|
|
|
|
|
+ // modify by lipf 2026年6月8日14:38:36 提现的时候,往账户操作记录表中插入数据
|
|
|
|
|
+ SysUserJzgInfo sysUserJzgInfo = sysJzgInfoService.getUserByUserId(ywyUserId);
|
|
|
|
|
+ String jzgInfoId=null;
|
|
|
|
|
+ String yewUserName = null;
|
|
|
|
|
+ if(sysUserJzgInfo != null){
|
|
|
|
|
+ jzgInfoId = sysUserJzgInfo.getId();
|
|
|
|
|
+ yewUserName = sysUserJzgInfo.getName();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ SysUserAccountChangeLog changeLog = new SysUserAccountChangeLog(systemCode,ywyUserId,jzgInfoId);
|
|
|
|
|
+ changeLog.setUserName(yewUserName);
|
|
|
|
|
+ changeLog.setAmountBefore(amountBefore);
|
|
|
|
|
+ // 提现操作
|
|
|
|
|
+ changeLog.setOperType(3);
|
|
|
|
|
+ changeLog.setRemark("提现");
|
|
|
|
|
+ SysAmountAuditing sysAmountAuditing = baseMapper.selectById(param.getId());
|
|
|
|
|
+ if(sysAmountAuditing != null){
|
|
|
|
|
+ String bankCardNum = sysAmountAuditing.getBankCardNum();
|
|
|
|
|
+ List<SysUserJzgInfoBankCard> sysUserJzgInfoBankCards = sysUserJzgInfoBankCardService.queryBankCardBybankCardNum(bankCardNum,systemCode);
|
|
|
|
|
+ if(CollUtil.isNotEmpty(sysUserJzgInfoBankCards)){
|
|
|
|
|
+ SysUserJzgInfoBankCard sysUserJzgInfoBankCard = sysUserJzgInfoBankCards.get(0);
|
|
|
|
|
+ changeLog.setBankCardIdTo(sysUserJzgInfoBankCard.getId());
|
|
|
|
|
+ changeLog.setBankCardNoTo(sysUserJzgInfoBankCard.getBankCardNumber());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ changeLog.setUserId(ywyUserId);
|
|
|
|
|
+ List<InvAccountCard> accountCardVos = invAccountCardService.queryByAccountId(param.getAccountId(), systemCode);
|
|
|
|
|
+ if(CollUtil.size(accountCardVos) > 1){
|
|
|
|
|
+ throw new SystemException(String.format("租户%s下根据账号%s找到%d条",systemCode,param.getAccountId(),accountCardVos.size()));
|
|
|
|
|
+ }
|
|
|
|
|
+ if(CollUtil.isNotEmpty(accountCardVos)){
|
|
|
|
|
+ InvAccountCard accountCardVo = accountCardVos.get(0);
|
|
|
|
|
+ changeLog.setBankCardIdIn(accountCardVo.getId());
|
|
|
|
|
+ changeLog.setBankCardNoIn(accountCardVo.getBankCardNum());
|
|
|
|
|
+ }
|
|
|
|
|
+ changeLog.setAmount(BigDecimalUtil.negate(BigDecimalUtil.abs(amount)));
|
|
|
|
|
+ changeLog.setCreateBy(userName);
|
|
|
|
|
+ changeLog.setCreateTime(LocalDateTime.now());
|
|
|
|
|
+ changeLog.setUpdateBy(userName);
|
|
|
|
|
+ changeLog.setUpdateTime(LocalDateTime.now());
|
|
|
|
|
+ changeLog.setIsDelete(0);
|
|
|
|
|
+ return changeLog;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public void rejectAmount(AmountAuditRejectParam param) {
|
|
public void rejectAmount(AmountAuditRejectParam param) {
|
|
|
String userName = baseController.getUserName();
|
|
String userName = baseController.getUserName();
|
|
@@ -325,7 +410,6 @@ public class SysAmountAuditingServiceImpl extends ServiceImpl<SysAmountAuditingM
|
|
|
if(sumAmount.compareTo(applyWithdrawParam.getWithdrawAmount()) < 0){
|
|
if(sumAmount.compareTo(applyWithdrawParam.getWithdrawAmount()) < 0){
|
|
|
throw new SystemException("无法提现,请检查当前账户余额");
|
|
throw new SystemException("无法提现,请检查当前账户余额");
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
// 获取用户的银行卡信息
|
|
// 获取用户的银行卡信息
|
|
|
SysUserJzgInfo sysUserJzgInfo = sysUserJzgInfoService.getUserByUserId(baseController.getUserId());
|
|
SysUserJzgInfo sysUserJzgInfo = sysUserJzgInfoService.getUserByUserId(baseController.getUserId());
|
|
|
List<SysUserJzgInfoBankCardDto> bankCardByUserId = sysUserJzgInfoBankCardService.getBankCardByUserId(sysUserJzgInfo.getId(),baseController.getSystemCode());
|
|
List<SysUserJzgInfoBankCardDto> bankCardByUserId = sysUserJzgInfoBankCardService.getBankCardByUserId(sysUserJzgInfo.getId(),baseController.getSystemCode());
|
|
@@ -334,7 +418,6 @@ public class SysAmountAuditingServiceImpl extends ServiceImpl<SysAmountAuditingM
|
|
|
throw new SystemException("提供的银行卡信息错误");
|
|
throw new SystemException("提供的银行卡信息错误");
|
|
|
}
|
|
}
|
|
|
SysUserJzgInfoBankCardDto sysUserJzgInfoBankCardDto = bankCardByUserId.stream().filter(x -> x.getId().equals(applyWithdrawParam.getBankCardId())).findFirst().get();
|
|
SysUserJzgInfoBankCardDto sysUserJzgInfoBankCardDto = bankCardByUserId.stream().filter(x -> x.getId().equals(applyWithdrawParam.getBankCardId())).findFirst().get();
|
|
|
-
|
|
|
|
|
// 构造提现对象
|
|
// 构造提现对象
|
|
|
SysAmountAuditing sysAmountAuditing = new SysAmountAuditing(applyWithdrawParam,sysUserAccount,sysUserJzgInfoBankCardDto,baseController.getUserId());
|
|
SysAmountAuditing sysAmountAuditing = new SysAmountAuditing(applyWithdrawParam,sysUserAccount,sysUserJzgInfoBankCardDto,baseController.getUserId());
|
|
|
baseMapper.insert(sysAmountAuditing);
|
|
baseMapper.insert(sysAmountAuditing);
|
|
@@ -348,6 +431,7 @@ public class SysAmountAuditingServiceImpl extends ServiceImpl<SysAmountAuditingM
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
public String exportAuditList(AmountAuditParam param) {
|
|
public String exportAuditList(AmountAuditParam param) {
|
|
|
|
|
+ log.info("导出提现申请列表:param=[{}] ",JSONUtil.toJsonStr(param));
|
|
|
List<AmountAuditVo> amountAuditVos = baseMapper.queryList(param.getPage(), param);
|
|
List<AmountAuditVo> amountAuditVos = baseMapper.queryList(param.getPage(), param);
|
|
|
|
|
|
|
|
// 调用动态导出
|
|
// 调用动态导出
|
|
@@ -357,6 +441,30 @@ public class SysAmountAuditingServiceImpl extends ServiceImpl<SysAmountAuditingM
|
|
|
"应付账款-提现申请-导出-" + Instant.now()
|
|
"应付账款-提现申请-导出-" + Instant.now()
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 导出业务员收入支出明显
|
|
|
|
|
+ *
|
|
|
|
|
+ * param ywyIOParam 导出条件, 包含开始日期,结束日期
|
|
|
|
|
+ * @return String
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String exportYwyIORecs(YwyIOParam ywyIOParam) {
|
|
|
|
|
+ log.info("导出业务员收支明细:ywyIOParam=[{}]", JSONUtil.toJsonStr(ywyIOParam));
|
|
|
|
|
+ List<SysUserAccountChangeLog> changeLogs = sysUserAccountIncomeLogService.queryYwyIORecs(ywyIOParam);
|
|
|
|
|
+ String userName=null;
|
|
|
|
|
+ if(CollUtil.isNotEmpty(changeLogs)){
|
|
|
|
|
+ SysUserAccountChangeLog sysUserAccountChangeLog = changeLogs.get(0);
|
|
|
|
|
+ userName = sysUserAccountChangeLog.getUserName();
|
|
|
|
|
+ }
|
|
|
|
|
+ String suffix = String.join("-",Objects.toString(userName,""),Objects.toString(ywyIOParam.getBeginDate(),null) , Objects.toString(ywyIOParam.getEndDate(),null));
|
|
|
|
|
+ // 调用动态导出
|
|
|
|
|
+ return exportBaseService.upLoadFile(
|
|
|
|
|
+ SysUserAccountChangeLog.class,
|
|
|
|
|
+ changeLogs,
|
|
|
|
|
+ "业务员收支明细-导出-"+suffix + Instant.now()
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|