Преглед на файлове

电子钱包接口调整

xucaiqin преди 2 години
родител
ревизия
b15f0fc75f

+ 1 - 7
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/WalletController.java

@@ -1,20 +1,14 @@
 package com.sckw.payment.controller;
 
-import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.payment.model.vo.req.*;
-import com.sckw.payment.service.MessageSender;
 import com.sckw.payment.service.WalletService;
-import com.sckw.stream.enums.MessageEnum;
-import com.sckw.stream.model.UserInfo;
 import jakarta.annotation.Resource;
 import jakarta.validation.Valid;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.HashMap;
-
 /**
  * 钱包
  *
@@ -66,7 +60,7 @@ public class WalletController {
      * @return
      */
     @PostMapping("recharge")
-    public HttpResult recharge(@RequestBody @Valid AddWalletReq addWalletReq) {
+    public HttpResult recharge(@RequestBody @Valid WalletAppendReq addWalletReq) {
         return HttpResult.ok(walletService.addWalletMoney(addWalletReq));
     }
 

+ 4 - 4
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/constant/CashEnum.java

@@ -10,10 +10,10 @@ import java.util.Objects;
  * @date 2023-07-11 12:00:52
  */
 public enum CashEnum {
-    ALL(-1, "全部", "-1"),
-    FAIL(0, "提现失败", "0"),
-    SUCCESS(1, "提现成功", "1"),
-    LOAD(2, "提现中", "2"),
+    ALL(-1, "全部", "all"),
+    FAIL(0, "提现失败", "failed"),
+    SUCCESS(1, "提现成功", "success"),
+    LOAD(2, "提现中", "processing"),
     WAIT(3, "等待提现", "3");
 
     private final int status;

+ 5 - 3
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/AddWalletReq.java

@@ -1,8 +1,10 @@
 package com.sckw.payment.model.vo.req;
 
-import com.sckw.core.model.vo.BasePara;
 import com.sckw.payment.model.vo.res.MoneyChange;
-import jakarta.validation.constraints.*;
+import jakarta.validation.constraints.Digits;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.Positive;
+import jakarta.validation.constraints.Size;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -16,7 +18,7 @@ import java.math.BigDecimal;
  */
 @Getter
 @Setter
-public class AddWalletReq extends BasePara implements MoneyChange {
+public class AddWalletReq implements MoneyChange {
     /**
      * 支付通道 huifu
      */

+ 1 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/PrePayCheck.java

@@ -14,7 +14,7 @@ import lombok.Setter;
 @Setter
 public class PrePayCheck {
     /**
-     * 支付通道 huifu
+     * 支付通道 1-汇付 2-新生
      */
     @NotBlank(message = "支付通道不能为空")
     private String channel;

+ 38 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/WalletAppendReq.java

@@ -0,0 +1,38 @@
+package com.sckw.payment.model.vo.req;
+
+import com.sckw.payment.model.vo.res.MoneyChange;
+import jakarta.validation.constraints.Digits;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.Positive;
+import jakarta.validation.constraints.Size;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+
+/**
+ * 账目账目追加
+ *
+ * @author xucaiqin
+ * @date 2023-08-29 09:14:04
+ */
+@Getter
+@Setter
+public class WalletAppendReq  implements MoneyChange {
+    /**
+     * 支付通道 huifu
+     */
+    @NotBlank(message = "支付通道不能为空")
+    private String channel;
+
+    @NotBlank(message = "合作企业不能为空")
+    private String filter;
+
+    @Positive(message = "充值金额必须大于0")
+    @Digits(message = "小数位数过长", integer = 10, fraction = 2)
+    private BigDecimal money;
+
+    @Size(message = "备注不能超过200")
+    private String remark;
+
+}

+ 1 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/WalletDetailReq.java

@@ -13,7 +13,7 @@ import lombok.Setter;
 public class WalletDetailReq extends BasePara {
     private String entName;
     /**
-     * 支付通道字典值
+     * 支付通道字典值 1-汇付 2-新生
      */
     private String channel;
 }

+ 27 - 8
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/WalletService.java

@@ -45,6 +45,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
 import java.text.DecimalFormat;
 import java.time.LocalDateTime;
 import java.util.ArrayList;
@@ -168,6 +169,23 @@ public class WalletService {
         }
     }
 
+    /**
+     * 资金明细设置退款中金额
+     *
+     * @param fundVo 返回值vo
+     */
+    private void refundMoney2(FundVo fundVo) {
+        DecimalFormat df = new DecimalFormat("0.00");
+        LambdaQueryWrapper<KwpWalletRefund> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(KwpWalletRefund::getUid, fundVo.getUid()).eq(KwpWalletRefund::getFilter, fundVo.getFilter()).eq(KwpWalletRefund::getChannel, fundVo.getChannel()).eq(KwpWalletRefund::getStatus, RefundEnum.REFUNDING.getStatus()).last("limit 1");
+        KwpWalletRefund kwpWalletRefund = kwpWalletRefundMapper.selectOne(wrapper);
+        if (Objects.nonNull(kwpWalletRefund)) {
+            fundVo.setRefundMoney(df.format(kwpWalletRefund.getActualMoney()));
+        } else {
+            fundVo.setRefundMoney("0.00");
+        }
+    }
+
     /**
      * 钱包总览信息
      *
@@ -255,7 +273,7 @@ public class WalletService {
             fundVo.setWithdrawingMoney(dfMoney(re.getWithdrawingMoney()));
             fundVo.setChargingMoney(dfMoney(re.getChargingMoney()));
             fundVo.setTotalMoney(dfMoney(re.getTotalMoney()));
-//            fundVo.setRefundMoney(dfMoney(re.getMoney()));
+            refundMoney2(fundVo);
             vo.add(fundVo);
         }
         DecimalFormat df = new DecimalFormat("0.00");
@@ -304,18 +322,14 @@ public class WalletService {
      *
      * @return
      */
-    public Object addWalletMoney(AddWalletReq addWalletReq) {
+    public Object addWalletMoney(WalletAppendReq addWalletReq) {
         log.info("账目充值:{}", JSONObject.toJSONString(addWalletReq));
         Long entId1 = LoginUserHolder.getEntId();
         String uid = walletRelationService.getRelation(entId1);
         if (StringUtils.isBlank(uid)) {
             throw new BusinessException("您暂未开通电子钱包");
         }
-        String entId = addWalletReq.getEntId();
-        String filter = walletRelationService.getRelation(Long.parseLong(entId));
-        if (StringUtils.isBlank(filter)) {
-            throw new BusinessException("合作单位暂未开通电子钱包");
-        }
+        String filter = addWalletReq.getFilter();
         ChannelEnum channelEnum = ChannelEnum.getByChannel(addWalletReq.getChannel());
         if (Objects.isNull(channelEnum)) {
             throw new BusinessException("支付通道不存在");
@@ -648,7 +662,11 @@ public class WalletService {
             throw new BusinessException("支付通道不存在");
         }
 
-        R<Order> orderR = payCenterService.advancePayApply(uid, channelEnum, prePay.getEntId(), prePay.bigMoney(prePay.getMoney()));
+        String filter = walletRelationService.getRelation(Long.parseLong(prePay.getEntId()));
+        if (StringUtils.isBlank(filter)) {
+            throw new BusinessException("合作企业开通电子钱包");
+        }
+        R<Order> orderR = payCenterService.advancePayApply(uid, channelEnum, filter, prePay.bigMoney(prePay.getMoney()));
         if (!orderR.getStatus()) {
             throw new BusinessException(StringUtils.isNotBlank(orderR.getMsg()) ? orderR.getMsg() : "预付失败");
         }
@@ -702,6 +720,7 @@ public class WalletService {
         kwpWalletRefundAdd.setToEnt(walletRelationService.getEnt(refundReq.getFilter()));
         kwpWalletRefundAdd.setChannel(refundReq.getChannel());
         kwpWalletRefundAdd.setMoney(refundReq.getMoney());
+        kwpWalletRefundAdd.setActualMoney(new BigDecimal("0.0"));
         kwpWalletRefundAdd.setRemark(refundReq.getRemark());
         kwpWalletRefundAdd.setCreateBy(LoginUserHolder.getUserId());
         kwpWalletRefundAdd.setCreateTime(LocalDateTime.now());

+ 1 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/dubbo/PaymentDubboServiceImpl.java

@@ -60,6 +60,7 @@ public class PaymentDubboServiceImpl implements PaymentDubboService {
 
     @Override
     public LedgerCount countLedger(Long entId) {
+        //todo-xcq
         return new LedgerCount(1, 1, 1, 1);
     }
 }

+ 1 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/task/RefundTask.java

@@ -37,7 +37,7 @@ public class RefundTask {
         wrapper.eq(KwpWalletRefund::getStatus, RefundEnum.REFUNDING.getStatus());
         List<KwpWalletRefund> kwpWalletRefunds = kwpWalletRefundMapper.selectList(wrapper);
         if (CollectionUtils.isEmpty(kwpWalletRefunds)) {
-            log.warn("无数据");
+//            log.warn("无数据");
             return;
         }
         try {