feat:记账扣款余额判断
This commit is contained in:
1 parent
5a2e90f67c
commit
96fe841151
3 files changed
+92
-1
No files matched your search
+28
@@ -23,6 +23,16 @@ public class WalletRechargeApplyCompareVo extends HashMap<String, Object> {
|
||||
*/
|
||||
private String userMobile;
|
||||
|
||||
/**
|
||||
* 操作前的余额
|
||||
*/
|
||||
private Integer prenBalance;
|
||||
|
||||
/**
|
||||
* 扣减之后的余额
|
||||
*/
|
||||
private Integer discountBalance;
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
this.put("userId", userId);
|
||||
@@ -58,4 +68,22 @@ public class WalletRechargeApplyCompareVo extends HashMap<String, Object> {
|
||||
this.userMobile = userMobile;
|
||||
this.put("userMobile", userMobile);
|
||||
}
|
||||
|
||||
public Integer getPrenBalance() {
|
||||
return (Integer) this.get("prenBalance");
|
||||
}
|
||||
|
||||
public void setPrenBalance(Integer prenBalance) {
|
||||
this.prenBalance = prenBalance;
|
||||
this.put("prenBalance", prenBalance);
|
||||
}
|
||||
|
||||
public Integer getDiscountBalance() {
|
||||
return (Integer) this.get("discountBalance");
|
||||
}
|
||||
|
||||
public void setDiscountBalance(Integer discountBalance) {
|
||||
this.discountBalance = discountBalance;
|
||||
this.put("discountBalance", discountBalance);
|
||||
}
|
||||
}
|
||||
+25
@@ -7,14 +7,18 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.common.core.util.BeanUtils;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletBizEnum;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletBizRechargeEnum;
|
||||
import com.bsd.pjcloud.wallet.api.dto.WalletManageDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeApplyDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeImportDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeApplyEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeImportEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeApplyCompareAceVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeApplyCompareVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeApplySelectCompareVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeImportVo;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletManageMapper;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletTransactionMapper;
|
||||
import com.bsd.pjcloud.wallet.service.WalletRechargeApplyComposeService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -38,6 +42,7 @@ public class WalletRechargeApplyComposeServiceImpl implements WalletRechargeAppl
|
||||
private final WalletRechargeApplyServiceImpl rechargeApplyService;
|
||||
|
||||
private final WalletTransactionMapper walletTransactionMapper;
|
||||
private final WalletManageMapper walletManageMapper;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -145,6 +150,26 @@ public class WalletRechargeApplyComposeServiceImpl implements WalletRechargeAppl
|
||||
v.put(currentImportKey + "_price", target.getPrice());
|
||||
}
|
||||
}
|
||||
|
||||
// 查询当前钱包余额
|
||||
WalletManageDto userWalletDto = new WalletManageDto();
|
||||
userWalletDto.setUserIds(userIdList);
|
||||
userWalletDto.setWalletTypeId(topUpApplyDetail.getWalletTypeId());
|
||||
List<WalletManageEntity> userWalletList = walletManageMapper.list(userWalletDto);
|
||||
if (ObjectUtil.isNotEmpty(userWalletList) && ObjectUtil.isNotEmpty(resultList)) {
|
||||
for (WalletRechargeApplyCompareVo i : resultList) {
|
||||
userWalletList.stream().filter(j -> ObjectUtil.equals(i.getUserId(), j.getUserId())).findFirst().ifPresent(j -> {
|
||||
i.setPrenBalance(j.getBalance());
|
||||
if (ObjectUtil.equals(topUpApplyDetail.getBizType(), WalletBizRechargeEnum.REDUCTION.getCode())) {
|
||||
Integer currentImportPrice = (Integer) i.get("currentImport_price");
|
||||
if (ObjectUtil.isNotEmpty(currentImportPrice)) {
|
||||
i.setDiscountBalance(j.getBalance() - currentImportPrice);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
resultVo.setRecords(resultList);
|
||||
List<String> tableListStr = new ArrayList<>();
|
||||
tableListStr.add(merge.get(0) + "(上个月总充值金额)");
|
||||
|
||||
+39
-1
@@ -16,6 +16,7 @@ import com.bsd.pjcloud.admin.api.entity.SysUser;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteDeptService;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
|
||||
import com.bsd.pjcloud.admin.api.utils.DataUtil;
|
||||
import com.bsd.pjcloud.admin.api.vo.UserVO;
|
||||
import com.bsd.pjcloud.common.core.exception.ErrorCodes;
|
||||
import com.bsd.pjcloud.common.core.util.BeanUtils;
|
||||
import com.bsd.pjcloud.common.core.util.CollectionUtils;
|
||||
@@ -32,6 +33,7 @@ import com.bsd.pjcloud.flow.task.dto.TaskDto;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletBizEnum;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletBizRechargeEnum;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
|
||||
import com.bsd.pjcloud.wallet.api.dto.WalletManageDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.WalletTypeDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeApplyDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeImportDto;
|
||||
@@ -44,6 +46,7 @@ import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeApplyVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeImportVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.excel.WalletRechargeByApplyExcelVo;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletManageMapper;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletTransactionMapper;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletTypeMapper;
|
||||
import com.bsd.pjcloud.wallet.mapper.recharge.WalletRechargeApplyMapper;
|
||||
@@ -84,6 +87,7 @@ public class WalletRechargeApplyServiceImpl extends ServiceImpl<WalletRechargeAp
|
||||
private final WalletTypeService walletTypeService;
|
||||
|
||||
private final WalletTransactionMapper walletTransactionMapper;
|
||||
private final WalletManageMapper walletManageMapper;
|
||||
private final WalletTypeMapper walletTypeMapper;
|
||||
private final WalletThirdZyService walletThirdZyService;
|
||||
|
||||
@@ -176,6 +180,40 @@ public class WalletRechargeApplyServiceImpl extends ServiceImpl<WalletRechargeAp
|
||||
if (ObjectUtil.isEmpty(walletType)) {
|
||||
throw new RuntimeException("饭卡类型不存在");
|
||||
}
|
||||
// 判断申请下如果类型为记账扣款,余额是否够扣款
|
||||
if (ObjectUtil.equals(detail.getBizType(), WalletBizRechargeEnum.REDUCTION.getCode())) {
|
||||
List<WalletRechargeImportEntity> importList = rechargeImportService.list(new LambdaQueryWrapper<WalletRechargeImportEntity>()
|
||||
.eq(WalletRechargeImportEntity::getApplyId, detail.getId())
|
||||
);
|
||||
List<Long> importUserIds = importList.stream().map(WalletRechargeImportEntity::getUserId).distinct().toList();
|
||||
// 查询用户
|
||||
List<UserVO> userList = userService.getUserDeptByIds(importUserIds).getData();
|
||||
// 错误信息
|
||||
StringBuilder errorMsg = new StringBuilder();
|
||||
// 查询用户余额
|
||||
WalletManageDto userWalletDto = new WalletManageDto();
|
||||
userWalletDto.setUserIds(importUserIds);
|
||||
userWalletDto.setWalletTypeId(detail.getWalletTypeId());
|
||||
List<WalletManageEntity> userWalletList = walletManageMapper.list(userWalletDto);
|
||||
for (WalletRechargeImportEntity i : importList) {
|
||||
userWalletList.stream().filter(j -> ObjectUtil.equals(i.getUserId(), j.getUserId())).findFirst().ifPresent(wallet -> {
|
||||
int discountPrice = wallet.getBalance() - i.getPrice();
|
||||
// 查询用户名字
|
||||
UserVO userTarget = userList.stream().filter(j -> ObjectUtil.equals(i.getUserId(), j.getUserId())).findFirst().get();
|
||||
if (ObjectUtil.isEmpty(userTarget)) {
|
||||
errorMsg.append("用户id<").append(wallet.getUserId()).append(">");
|
||||
} else {
|
||||
errorMsg.append("用户名<").append(userTarget.getName()).append(">");
|
||||
}
|
||||
errorMsg.append("记账扣款失败,");
|
||||
errorMsg.append("操作前的金额<").append(wallet.getBalance() / 100).append(">,");
|
||||
errorMsg.append("记账扣款的金额<").append(i.getPrice() / 100).append(">,");
|
||||
errorMsg.append("记账扣款后的金额<").append(discountPrice / 100).append(">\n");
|
||||
});
|
||||
}
|
||||
String errorMsgString = errorMsg.toString();
|
||||
if (ObjectUtil.isNotEmpty(errorMsgString)) throw new RuntimeException(errorMsgString);
|
||||
}
|
||||
// 发起审批
|
||||
WalletRechargeApplyFlowDto flowDto = new WalletRechargeApplyFlowDto();
|
||||
flowDto.setApplyUsername(user.getSysUser().getUsername());
|
||||
@@ -277,7 +315,7 @@ public class WalletRechargeApplyServiceImpl extends ServiceImpl<WalletRechargeAp
|
||||
List<WalletRechargeImportEntity> batchSaveList = list.stream().map(v -> WalletRechargeImportEntity.builder().price(v.getPriceNumber()).userId(v.getUserId()).userDeptId(v.getUserDeptId()).build()).toList();
|
||||
batchSaveList.forEach(v -> v.setApplyId(insertObj.getId()));
|
||||
rechargeImportService.saveBatch(batchSaveList);
|
||||
return R.ok(null, MsgUtils.getMessage(ErrorCodes.SYS_USER_IMPORT_SUCCEED));
|
||||
return R.ok(null, "导入成功");
|
||||
}
|
||||
|
||||
/* ************************************* end excel end ************************************* */
|
||||
|
||||
Reference in new issue
Block a user