|
@@ -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();
|
|
|
}
|