diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/MemberService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/MemberService.java index d2e4969..c48a945 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/MemberService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/MemberService.java @@ -724,8 +724,8 @@ public class MemberService { } - public Result returnAccount(String flowId, String remark,String amount) { - if (ObjectUtil.isEmpty(flowId) || ObjectUtil.isNull(flowId)||ObjectUtil.isNull(amount)||ObjectUtil.isEmpty(amount)) { + 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,35 +737,28 @@ public class MemberService { return Result.fail(CodeEnum.ORDERRETURN); } - if(N.gt(new BigDecimal(amount),flow.getAmount())){ + if (N.gt(new BigDecimal(amount), flow.getAmount())) { return Result.fail(CodeEnum.INPURAMOUNTERROR); } - TbShopUser user = tbShopUserMapper.selectByPrimaryKey(flow.getShopUserId()); if (ObjectUtil.isEmpty(user) || ObjectUtil.isNull(user)) { return Result.fail(CodeEnum.ACCOUNTEIXST); } - if(N.gt(new BigDecimal(amount),user.getAmount())){ + if (N.gt(new BigDecimal(amount), user.getAmount())) { return Result.fail(CodeEnum.ACCOUNTBALANCEERROR); } - - - TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(user.getShopId())); if (ObjectUtil.isEmpty(shopInfo) || ObjectUtil.isNull(shopInfo)) { return Result.fail(CodeEnum.MERCHANTEIXST); } - - - if ("scanMemberIn".equals(flow.getBizCode())) { TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(Integer.valueOf(shopInfo.getMerchantId())); if (ObjectUtil.isEmpty(thirdApply) || ObjectUtil.isNull(thirdApply)) { @@ -774,7 +767,7 @@ public class MemberService { String no = DateUtils.getSsdfTimes(); - PublicResp 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()); + PublicResp 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")) { @@ -800,6 +793,19 @@ public class MemberService { tbShopUserFlowMapper.updateByPrimaryKey(flow); + TbShopUserFlow userFlow = new TbShopUserFlow(); + userFlow.setShopUserId(user.getId()); + userFlow.setBizCode("memberReturn"); + userFlow.setBizName("会员退款"); + userFlow.setType("-"); + userFlow.setAmount(new BigDecimal(amount)); + userFlow.setBalance(user.getAmount()); + userFlow.setCreateTime(new Date()); + userFlow.setIsReturn("1"); + userFlow.setRemark(flowId); + + tbShopUserFlowMapper.insert(userFlow); + JSONObject baObj = new JSONObject(); baObj.put("userId", user.getUserId()); baObj.put("shopId", user.getId());