From 445551f0d5a6c36f33734ce516e91748358f5e75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=9B=E5=8F=89=E9=97=AA=E9=97=AA?= <18322780655@163.com> Date: Thu, 29 Aug 2024 14:45:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/service/MemberService.java | 39 ++++++++++--------- .../resources/mapper/TbShopUserFlowMapper.xml | 9 +++-- 2 files changed, 27 insertions(+), 21 deletions(-) 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 cb5d6fa..9e9d0e7 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/MemberService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/MemberService.java @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.chaozhanggui.system.cashierservice.bean.TableStateEnum; import com.chaozhanggui.system.cashierservice.dao.*; import com.chaozhanggui.system.cashierservice.entity.*; +import com.chaozhanggui.system.cashierservice.exception.MsgException; import com.chaozhanggui.system.cashierservice.model.ScanPayReq; import com.chaozhanggui.system.cashierservice.model.TradeQueryReq; import com.chaozhanggui.system.cashierservice.mybatis.MpShopTableMapper; @@ -14,6 +15,7 @@ import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer; import com.chaozhanggui.system.cashierservice.sign.CodeEnum; import com.chaozhanggui.system.cashierservice.sign.Result; import com.chaozhanggui.system.cashierservice.thirdpay.resp.MainScanResp; +import com.chaozhanggui.system.cashierservice.thirdpay.resp.OrderReturnResp; import com.chaozhanggui.system.cashierservice.thirdpay.resp.OrderStatusQueryResp; import com.chaozhanggui.system.cashierservice.thirdpay.resp.PublicResp; import com.chaozhanggui.system.cashierservice.thirdpay.service.ThirdPayService; @@ -331,7 +333,7 @@ public class MemberService { String orderNo = DateUtils.getSsdfTimes(); - PublicResp publicResp = thirdPayService.mainScan(url, thirdApply.getAppId(), "会员充值", "会员充值", amount.setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(), wechatpay.equals("wxpay") ? thirdApply.getSmallAppid() : null, authCode, DateUtils.getSsdfTimes(), thirdApply.getStoreId(), callBack, thirdApply.getAppToken()); + PublicResp publicResp = thirdPayService.mainScan(url, thirdApply.getAppId(), "会员充值", "会员充值", amount.setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(), wechatpay.equals("wxpay") ? thirdApply.getSmallAppid() : null, authCode, orderNo, thirdApply.getStoreId(), callBack, thirdApply.getAppToken()); if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) { if ("000000".equals(publicResp.getCode())) { MainScanResp mainScanResp = publicResp.getObjData(); @@ -355,6 +357,7 @@ public class MemberService { flow.setAmount(amount); flow.setBalance(shopUser.getAmount()); flow.setCreateTime(new Date()); + flow.setRemark(orderNo); tbShopUserFlowMapper.insert(flow); BigDecimal fl=null; @@ -761,24 +764,26 @@ public class MemberService { } - if("scanMemberIn".equals(flow.getBizCode())){ - PublicResp orderstatus = thirdPayService.queryOrder(url, thirdApply.getAppId(),flow.getAmount().toPlainString(), null, thirdApply.getAppToken()); - if (ObjectUtil.isNotNull(orderstatus) && ObjectUtil.isNotEmpty(orderstatus)) { - if ("000000".equals(orderstatus.getCode())) { - if ("TRADE_SUCCESS".equals(orderstatus.getObjData().getState())) { - user.setAmount(user.getAmount().subtract(flow.getAmount())); - user.setUpdatedAt(System.currentTimeMillis()); - tbShopUserMapper.updateByPrimaryKey(user); + if("scanMemberIn".equals(flow.getBizCode())) { - flow.setIsReturn("1"); - flow.setRemark(remark); - tbShopUserFlowMapper.updateByPrimaryKey(flow); - return Result.success(CodeEnum.SUCCESS); + String no=DateUtils.getSsdfTimes(); + + PublicResp publicResp = thirdPayService.returnOrder(url, thirdApply.getAppId(),no , flow.getRemark(), null, "充值退款", flow.getAmount().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")) { + MsgException.check(true, "退款渠道调用失败"); } + } else { + MsgException.check(true, "退款渠道调用失败"); } - } - }else if("cashMemberIn".equals(flow.getBizCode())){ + } else if ("cashMemberIn".equals(flow.getBizCode())) { + + + } else { + return Result.fail(CodeEnum.OPARETIONERROR); + } user.setAmount(user.getAmount().subtract(flow.getAmount())); user.setUpdatedAt(System.currentTimeMillis()); tbShopUserMapper.updateByPrimaryKey(user); @@ -786,14 +791,12 @@ public class MemberService { flow.setIsReturn("1"); flow.setRemark(remark); tbShopUserFlowMapper.updateByPrimaryKey(flow); + return Result.success(CodeEnum.SUCCESS); - }else { - return Result.fail(CodeEnum.OPARETIONERROR); } return Result.fail(CodeEnum.FAIL); - } diff --git a/src/main/resources/mapper/TbShopUserFlowMapper.xml b/src/main/resources/mapper/TbShopUserFlowMapper.xml index e359ea3..8ecdf81 100644 --- a/src/main/resources/mapper/TbShopUserFlowMapper.xml +++ b/src/main/resources/mapper/TbShopUserFlowMapper.xml @@ -10,9 +10,12 @@ + + + - id, shop_user_id, amount, balance, biz_code, biz_name, create_time, type + id, shop_user_id, amount, balance, biz_code, biz_name, create_time, type,is_return,remark