Explorar el Código

取消订阅取最新返利

wujiefeng hace 9 meses
padre
commit
b910e191db

+ 12 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/model/TransferRulerModel.java

@@ -18,6 +18,18 @@ public class TransferRulerModel {
 
     private Long createTime;
 
+    /**
+     * 当前是否可提现
+     */
+    private Boolean isTransfer;
+
+    private String remark;
+
+    /**
+     * 可提现余额
+     */
+    private BigDecimal total = BigDecimal.ZERO;
+
     /**
      * 单笔最小提现金额
      */

+ 7 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/controller/wallet/WalletController.java

@@ -69,6 +69,13 @@ public class WalletController {
         return ResultContent.buildFail("没有此平台");
     }
 
+    @Operation(summary = "获取当前用户提现规则信息", description = "获取当前用户提现规则信息")
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @GetMapping (value = "transferRulerInfo")
+    public Object transferRulerInfo(){
+        return wxTransferService.transferRulerInfo();
+    }
+
     @Operation(summary = "发起提现", description = "发起提现")
     @ResourceAuth(value = "user", type = AuthType.User)
     @PostMapping (value = "transfer", consumes = MediaType.APPLICATION_JSON_VALUE)

+ 28 - 3
RewardServer/src/main/java/com/zhongshu/reward/server/core/service/WxTransferService.java

@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.lang.Assert;
 import cn.hutool.core.lang.Snowflake;
 import com.wechat.pay.java.service.transferbatch.model.TransferDetailCompact;
+import com.zhongshu.reward.client.model.TransferRulerModel;
 import com.zhongshu.reward.client.ret.ResultContent;
 import com.github.microservice.auth.security.helper.AuthHelper;
 import com.github.microservice.components.data.mongo.mongo.helper.DBHelper;
@@ -33,6 +34,7 @@ import com.zhongshu.reward.server.core.helper.RedisHelper;
 import com.zhongshu.reward.server.core.util.DateUtils;
 import com.zhongshu.reward.server.core.util.JedisUtil;
 import com.zhongshu.reward.server.core.util.wx.BusinessUtil;
+import io.swagger.models.Model;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;
 import org.jetbrains.annotations.NotNull;
@@ -87,6 +89,9 @@ public class WxTransferService {
     @Autowired
     JedisUtil jedisUtil;
 
+    @Autowired
+    WalletService walletService;
+
 
 
     public ResultContent transferLock(WalletTransferParam param){
@@ -280,6 +285,26 @@ public class WxTransferService {
         return model;
     }
 
+
+    public Object transferRulerInfo(){
+        List<TransferRuler> list = transferRulerDao.findAll();
+        if (list.isEmpty()){
+            return ResultContent.buildFail("管理员未设置提现规则");
+        }
+        TransferRuler transferRuler = list.get(0);
+        TransferRulerModel model = new TransferRulerModel();
+        if (ObjectUtils.isNotEmpty(transferRuler)){
+            BeanUtil.copyProperties(transferRuler, model);
+        }
+        String userId = authHelper.getCurrentUser().getUserId();
+        Wallet wallet = walletService.getWalletByUserId(userId);
+        ResultContent resultContent = validTransfer(new BigDecimal("30"), wallet);
+        model.setIsTransfer(resultContent.getState().equals(ResultState.Success));
+        model.setRemark(resultContent.getMsg());
+        model.setTotal(wallet.getAmount());
+        return ResultContent.buildContent(model);
+    }
+
     public ResultContent validTransfer(BigDecimal total, Wallet wallet){
         long currentTime = System.currentTimeMillis();
         Integer size = 0;
@@ -291,7 +316,7 @@ public class WxTransferService {
 
         //判断可提现金额是否足够
         if (total.compareTo(wallet.getAmount()) > 0){
-            return ResultContent.build(ResultState.Fail, "可提现余额不足");
+            return ResultContent.buildFail("可提现余额不足");
         }
         //单笔金额
         if (total.compareTo(transferRuler.getMinTotal()) < 0){
@@ -318,11 +343,11 @@ public class WxTransferService {
         //判断提现额度是否超出每日上限
         Integer sumDayTotal = wxTransferBatchDao.sumDayTotal(wallet.getId(), DateUtils.getCurrentDayStartTime().getTime(), DateUtils.getCurrentDayEndTime().getTime());
         if (total.add(BigDecimal.valueOf(sumDayTotal)).compareTo(transferRuler.getDayMaxTotal()) > 0){
-            return ResultContent.build(ResultState.Fail, "超出每日提现金额上限");
+            return ResultContent.buildFail("超出每日提现金额上限");
         }
         //提现次数
         if (size >= transferRuler.getSize()){
-            return ResultContent.build(ResultState.Fail, "超过可提现次数");
+            return ResultContent.buildFail("超过可提现次数");
         }
         return ResultContent.buildSuccess();
     }