Browse Source

提现确认接口

xucaiqin 1 year ago
parent
commit
3f0b9677cf

+ 10 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/WalletController.java

@@ -243,6 +243,16 @@ public class WalletController {
         return HttpResult.ok(walletService.dealQuery(operateReq));
     }
 
+    /**
+     * 提现确认
+     * @param cashCheck
+     * @return
+     */
+    @PostMapping("cashCheck")
+    public HttpResult cashCheck(@RequestBody @Valid CashCheck cashCheck) {
+        return HttpResult.ok(walletService.cashCheck(cashCheck));
+    }
+
     /**
      * 预付追加校验
      *

+ 10 - 7
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/wallet/Filter.java

@@ -1,14 +1,17 @@
 package com.sckw.payment.model.dto.wallet;
 
-import lombok.Data;
+import lombok.*;
 
 import java.io.Serial;
 import java.io.Serializable;
 
-@Data
+@Getter
+@Setter
+@AllArgsConstructor
+@NoArgsConstructor
 public class Filter implements Serializable {
-	@Serial
-	private static final long serialVersionUID = 4605531733184843818L;
-	private String uid;
-	private String text;
-}
+    @Serial
+    private static final long serialVersionUID = 4605531733184843818L;
+    private String uid;
+    private String text;
+}

+ 23 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/CashCheck.java

@@ -0,0 +1,23 @@
+package com.sckw.payment.model.vo.req;
+
+import jakarta.validation.constraints.NotBlank;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 提现确认
+ *
+ * @author xucaiqin
+ * @date 2023-08-29 09:14:04
+ */
+@Getter
+@Setter
+public class CashCheck {
+    /**
+     * 支付通道 1-汇付 2-新生
+     */
+    @NotBlank(message = "支付通道不能为空")
+    private String channel;
+//    @NotBlank(message = "uid不能为空")
+//    private String uid;
+}

+ 4 - 4
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/CashWalletReq.java

@@ -25,11 +25,11 @@ public class CashWalletReq implements MoneyChange {
     @NotBlank(message = "支付通道不能为空")
     private String channel;
 
-    @NotBlank(message = "uid不能为空")
-    private String uid;
+//    @NotBlank(message = "uid不能为空")
+//    private String uid;
 
-    @NotBlank(message = "filter不能为空")
-    private String filter;
+//    @NotBlank(message = "filter不能为空")
+//    private String filter;
 
     @Positive(message = "提现金额必须大于0")
     @Digits(message = "小数位数过长或金额过大", integer = 10, fraction = 2)

+ 55 - 6
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/WalletService.java

@@ -1,5 +1,7 @@
 package com.sckw.payment.service;
 
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson2.JSONObject;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
@@ -14,6 +16,7 @@ import com.sckw.manage.api.RemoteManageService;
 import com.sckw.manage.api.model.dto.res.FindEntCooperateResVo;
 import com.sckw.payment.api.model.constant.ChannelEnum;
 import com.sckw.payment.api.model.dto.WalletDto;
+import com.sckw.payment.api.model.dto.WalletVo;
 import com.sckw.payment.api.model.dto.common.R;
 import com.sckw.payment.dao.KwpWalletReceiveMapper;
 import com.sckw.payment.dao.KwpWalletRefundMapper;
@@ -370,6 +373,7 @@ public class WalletService {
                             channelDetail = new ChannelDetail();
                             channelDetail.setChannel(key);
                             channelDetail.setName(WalletChannelEnum.getDesc(key));
+                            channelDetail.setUid(uid);
                             channelDetail.setMoney(String.valueOf(money / 100D));
                             channelDetail.setTotalMoney(String.valueOf(totalMoney / 100D));
                             channelDetail.setOpenFlag(true);
@@ -385,6 +389,7 @@ public class WalletService {
                         channelDetail = new ChannelDetail();
                         channelDetail.setChannel(channel);
                         channelDetail.setName(WalletChannelEnum.getDesc(channel));
+                        channelDetail.setUid(uid);
                         channelDetail.setMoney("-");
                         channelDetail.setTotalMoney("-");
                         channelDetail.setOpenFlag(true);
@@ -699,17 +704,22 @@ public class WalletService {
      */
     public Object cashOUt(CashWalletReq cashWalletReq) {
         log.info("提现:{}", JSONObject.toJSONString(cashWalletReq));
-        ChannelEnum byChannel = ChannelEnum.getByChannel(cashWalletReq.getChannel());
+        ChannelEnum byChannel = ChannelEnum.getByValue(cashWalletReq.getChannel());
         if (Objects.isNull(byChannel)) {
             throw new BusinessException("支付通道不存在");
         }
-        R<Order> payIndexR = payCenterService.withdrawTake(cashWalletReq.getUid(), byChannel, cashWalletReq.bigMoney(cashWalletReq.getMoney()), cashWalletReq.getRemark());
+        String uid = walletRelationService.getRelation(LoginUserHolder.getEntId());
+        if (StringUtils.isBlank(uid)) {
+            throw new BusinessException("您暂未开通电子钱包");
+        }
+        R<Order> payIndexR = payCenterService.withdrawTake(uid, byChannel, cashWalletReq.bigMoney(cashWalletReq.getMoney()), cashWalletReq.getRemark());
         if (!payIndexR.getStatus()) {
             throw new BusinessException(StringUtils.isNotBlank(payIndexR.getMsg()) ? payIndexR.getMsg() : "申请提现异常");
         }
         KwpWallet kwpWallet = new KwpWallet();
-        kwpWallet.setUid(cashWalletReq.getUid());
-        kwpWallet.setFilter(cashWalletReq.getFilter());
+        kwpWallet.setUid(uid);
+        //提现只需要知道收款方的uid就行。
+        kwpWallet.setFilter("");
         kwpWallet.setChannel(byChannel.getChannel());
         kwpWallet.setAction(WalletActionEnum.CASHING.getDesc());
         kwpWallet.setActionTime(LocalDateTime.now());
@@ -734,8 +744,12 @@ public class WalletService {
         if (Objects.isNull(byChannel)) {
             throw new BusinessException("支付通道不存在");
         }
+        String uid = walletRelationService.getRelation(LoginUserHolder.getEntId());
+        if (StringUtils.isBlank(uid)) {
+            throw new BusinessException("您暂未开通电子钱包");
+        }
         //申请提现
-        R<Order> orderR = payCenterService.withdrawTake(cashWalletReq.getUid(), byChannel, cashWalletReq.bigMoney(cashWalletReq.getMoney()), cashWalletReq.getRemark());
+        R<Order> orderR = payCenterService.withdrawTake(uid, byChannel, cashWalletReq.bigMoney(cashWalletReq.getMoney()), cashWalletReq.getRemark());
         log.info("重新提现-申请提现:{}", JSONObject.toJSONString(orderR));
         if (!orderR.getStatus()) {
             throw new BusinessException(StringUtils.isNotBlank(orderR.getMsg()) ? orderR.getMsg() : "申请提现异常");
@@ -1415,6 +1429,7 @@ public class WalletService {
         kwpWalletService.saveTime(uid, filter, channelEnum.getChannel());
         return orderR.getData();
     }
+
     public Object dealQuery(OperateReq operateReq) {
         String[] strings = new String[0];
         if (StringUtils.isNotBlank(operateReq.getStartTime()) && StringUtils.isNotBlank(operateReq.getEndTime())) {
@@ -1434,7 +1449,11 @@ public class WalletService {
                     operateVo.setTypeText(row.getTypeText());
                     operateVo.setType(row.getType());
                     operateVo.setApMoney(BigDecimal.valueOf(row.getApMoney().getValue() / 100D));
-                    operateVo.setFilter(row.getFilter());
+                    //前端取的filter作为往来单位。中台这里是uid其实代表的
+                    Filter filter = row.getFilter();
+                    if (Objects.nonNull(filter)) {
+                        operateVo.setFilter(new Filter(filter.getUid(), getFirmName(filter.getUid())));
+                    }
                     operateVo.setUid(row.getUid());
                     operateVo.setFile(row.getFile());
                     operateVo.setMoney(BigDecimal.valueOf(row.getMoney().getValue() / 100D));
@@ -2287,6 +2306,36 @@ public class WalletService {
         return new PageRes<>(moneyPage.getPage(), moneyPage.getPageSize(), 0, 0, new ArrayList<>());
     }
 
+    /**
+     * 提现确认
+     *
+     * @param cashCheck
+     * @return
+     */
+    public WalletVo cashCheck(CashCheck cashCheck) {
+        String uid = walletRelationService.getRelation(LoginUserHolder.getEntId());
+        if (StringUtils.isBlank(uid)) {
+            throw new BusinessException("您暂未开通电子钱包");
+        }
+        R<List<WalletDto>> wallet = payCenterService.wallet(uid, ChannelEnum.getByValue(cashCheck.getChannel()), "");
+        if (org.springframework.util.CollectionUtils.isEmpty(wallet.getData())) {
+            throw new BusinessException("交易双方暂未开通电子钱包");
+        }
+        //获取filter为空的提现钱包
+        List<WalletDto> data = wallet.getData();
+        Optional<WalletVo> first = data.stream().filter(d -> StrUtil.isBlank(d.getFilter())).map(walletDto -> {
+            WalletVo walletVo = BeanUtil.copyProperties(walletDto, WalletVo.class);
+            walletVo.setFreeze(Objects.nonNull(walletDto.getFreeze()) ? BigDecimal.valueOf(walletDto.getFreeze() / 100D) : new BigDecimal("0"));
+            walletVo.setApMoney(Objects.nonNull(walletDto.getApMoney()) ? BigDecimal.valueOf(walletDto.getApMoney() / 100D) : new BigDecimal("0"));
+            walletVo.setTotalMoney(Objects.nonNull(walletDto.getTotalMoney()) ? BigDecimal.valueOf(walletDto.getTotalMoney() / 100D) : new BigDecimal("0"));
+            walletVo.setMoney(Objects.nonNull(walletDto.getMoney()) ? BigDecimal.valueOf(walletDto.getMoney() / 100D) : new BigDecimal("0"));
+            walletVo.setChargingMoney(Objects.nonNull(walletDto.getChargingMoney()) ? BigDecimal.valueOf(walletDto.getChargingMoney() / 100D) : new BigDecimal("0"));
+            walletVo.setWithdrawingMoney(Objects.nonNull(walletDto.getWithdrawingMoney()) ? BigDecimal.valueOf(walletDto.getWithdrawingMoney() / 100D) : new BigDecimal("0"));
+            return walletVo;
+        }).findFirst();
+        return first.orElse(new WalletVo());
+    }
+
     /**
      * 退款处理
      *