修改提现,添加获取用户信息返回商户号

This commit is contained in:
韩鹏辉
2023-08-24 09:56:04 +08:00
parent 4e833b7585
commit 409135d38d
4 changed files with 15 additions and 35 deletions

View File

@@ -91,8 +91,13 @@ public class CashController {
@PostMapping("/v3")
public Result<Object> addV3(@RequestBody Cash cash) {
cashService.apiSaveCashV3(cash);
return ResultGenerator.genSuccessResult();
try {
cashService.apiSaveCashV3(cash);
return ResultGenerator.genSuccessResult();
} catch (Exception e) {
e.printStackTrace();
return ResultGenerator.genFailResult(e.getMessage());
}
}
/**

View File

@@ -1727,6 +1727,7 @@ public class UserAppController {
map.put("userId", one.getUserId());
map.put("myLoginName", one1.getLoginName());
map.put("token", one.getToken());
map.put("merchantCode",byId.getMerchantCode());
return ResultGenerator.genSuccessResult(map);
}

View File

@@ -37,7 +37,7 @@ public interface CashService extends IService<Cash> {
*
* @param cash
*/
void apiSaveCashV3(Cash cash);
void apiSaveCashV3(Cash cash) throws Exception;
Cash queryCash(Cash cash);

View File

@@ -290,7 +290,8 @@ public class CashServiceImpl extends ServiceImpl<CashMapper, Cash> implements Ca
}
@Override
public void apiSaveCashV3(Cash cash) {
@Transactional(rollbackFor = Exception.class)
public void apiSaveCashV3(Cash cash) throws Exception {
UserApp tokenUa = userAppService.queryUserAppByToken();
cash.setUserId(tokenUa.getUserId());
@@ -300,42 +301,14 @@ public class CashServiceImpl extends ServiceImpl<CashMapper, Cash> implements Ca
throw new MsgException("提现金额必须大于" + Cash.MINIMUM_CASH + "");
}
LambdaQueryWrapper<Cash> qWrapper = Wrappers.lambdaQuery();
qWrapper.eq(Cash::getUserId, cash.getUserId())
.orderByDesc(Cash::getCreateDt)
.last("limit 1");
Cash existData = getOne(qWrapper);
//TODO 注释掉限制一天只能提现一次
/*if (existData != null && DateUtil.isSameDay(new Date(), existData.getCreateDt())) {
throw new MsgException("一天只能提现一次");
}*/
// ======查询可提现金额
// 查询商户所有分润
BigDecimal totalProfit = mpService.getSumValidProfit(cash.getUserId() + "");
totalProfit = totalProfit == null? BigDecimal.ZERO: totalProfit;
if (!StringUtils.isEmpty(tokenUa.getMerchantCode())) {
Map<String, Object> map = new HashMap<>();
map.put("lastMerchantCode", tokenUa.getMerchantCode());
// 查询可提现粉丝分润
Double sum = fansService.queryFansSumShareMoney(map);
if (sum != null) {
BigDecimal fansProfit = BigDecimal.valueOf(sum);
totalProfit = totalProfit.add(fansProfit);
}
}
// 查询商户已提现总数
BigDecimal totalCashAmt = getSumValidCashAmtTotal(cash.getUserId() + "");
totalCashAmt = totalCashAmt == null? BigDecimal.ZERO: totalCashAmt;
UserAccount userAccount= userAccountService.getUserAccountByUserId(cash.getUserId());
MsgException.checkNull(userAccount,"可用资金不足");
MsgException.check(cash.getCashAmt().compareTo(userAccount.getBalance().subtract(userAccount.getFreezeBalance()))>0,"可用资金不足");
// 校验提现金额是否充足
int flag = cash.getCashAmt().compareTo(totalProfit.subtract(totalCashAmt));
if (flag > 0) {
throw new MsgException("可提现金额不足!");
}
cash.setCashNumber(StringUtil.getBillno());
cash.setCreateDt(new Date());
@@ -366,6 +339,7 @@ public class CashServiceImpl extends ServiceImpl<CashMapper, Cash> implements Ca
LinkedList<CashStatusVO> cashMap = getCashMap(String.valueOf(cash.getUserId()), new LinkedList<>());
cash.setCashStatus(JSONUtil.toJsonStr(cashMap));
save(cash);
userAccountService.modForzenFunds(cash.getUserId().intValue(),"108","提现冻结",cash.getCashAmt(),"");
}
@Autowired