This commit is contained in:
牛叉闪闪
2024-08-29 16:51:15 +08:00
parent 40b8198c7e
commit adb1c28bb8
4 changed files with 22 additions and 15 deletions

View File

@@ -724,8 +724,8 @@ public class MemberService {
}
public Result returnAccount(String flowId, String remark) {
if (ObjectUtil.isEmpty(flowId) || ObjectUtil.isNull(flowId)) {
public Result returnAccount(String flowId, String remark,String amount) {
if (ObjectUtil.isEmpty(flowId) || ObjectUtil.isNull(flowId)||ObjectUtil.isNull(amount)||ObjectUtil.isEmpty(amount)) {
return Result.fail(CodeEnum.PARAM);
}
TbShopUserFlow flow = tbShopUserFlowMapper.selectByPrimaryKey(Integer.valueOf(flowId));
@@ -737,6 +737,11 @@ public class MemberService {
return Result.fail(CodeEnum.ORDERRETURN);
}
if(N.gt(new BigDecimal(amount),flow.getAmount())){
return Result.fail(CodeEnum.INPURAMOUNTERROR);
}
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(flow.getShopUserId());
@@ -744,15 +749,8 @@ public class MemberService {
return Result.fail(CodeEnum.ACCOUNTEIXST);
}
BigDecimal amount=BigDecimal.ZERO;
/**
*
*/
if(N.gt(flow.getAmount(),user.getAmount())){
amount=user.getAmount();
}else {
amount=flow.getAmount();
if(N.gt(new BigDecimal(amount),user.getAmount())){
return Result.fail(CodeEnum.ACCOUNTBALANCEERROR);
}
@@ -776,7 +774,7 @@ public class MemberService {
String no = DateUtils.getSsdfTimes();
PublicResp<OrderReturnResp> publicResp = thirdPayService.returnOrder(url, thirdApply.getAppId(), no, null, flow.getRemark(), "充值退款",amount.setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(), callBack, null, thirdApply.getAppToken());
PublicResp<OrderReturnResp> publicResp = thirdPayService.returnOrder(url, thirdApply.getAppId(), no, null, flow.getRemark(), "充值退款",new BigDecimal(amount).setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(), callBack, null, thirdApply.getAppToken());
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
if ("000000".equals(publicResp.getCode())) {
if (!"SUCCESS".equals(publicResp.getObjData().getState()) && !publicResp.getObjData().getState().equals("ING")) {
@@ -793,7 +791,7 @@ public class MemberService {
} else {
return Result.fail(CodeEnum.OPARETIONERROR);
}
user.setAmount(user.getAmount().subtract(amount));
user.setAmount(user.getAmount().subtract(new BigDecimal(amount)));
user.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.updateByPrimaryKey(user);

View File

@@ -805,6 +805,9 @@ public class PayService {
return Result.fail("余额不足或扣除余额失败");
}
TbShopUserFlow userFlow = new TbShopUserFlow();
userFlow.setAmount((payAmount != null && discountAmount != null) ? payAmount : orderInfo.getOrderAmount());
userFlow.setBalance(shopUser.getAmount());