|  | @@ -4,6 +4,11 @@ import cn.hutool.core.bean.BeanUtil;
 | 
	
		
			
				|  |  |  import cn.hutool.core.lang.Snowflake;
 | 
	
		
			
				|  |  |  import com.github.microservice.auth.client.content.ResultContent;
 | 
	
		
			
				|  |  |  import com.github.microservice.auth.client.content.ResultState;
 | 
	
		
			
				|  |  | +import com.github.microservice.auth.security.helper.AuthHelper;
 | 
	
		
			
				|  |  | +import com.github.microservice.components.data.mongo.mongo.helper.DBHelper;
 | 
	
		
			
				|  |  | +import com.wechat.pay.java.core.exception.HttpException;
 | 
	
		
			
				|  |  | +import com.wechat.pay.java.core.exception.MalformedMessageException;
 | 
	
		
			
				|  |  | +import com.wechat.pay.java.core.exception.ServiceException;
 | 
	
		
			
				|  |  |  import com.wechat.pay.java.service.transferbatch.model.InitiateBatchTransferResponse;
 | 
	
		
			
				|  |  |  import com.wechat.pay.java.service.transferbatch.model.TransferBatchEntity;
 | 
	
		
			
				|  |  |  import com.wechat.pay.java.service.transferbatch.model.TransferDetailInput;
 | 
	
	
		
			
				|  | @@ -12,13 +17,16 @@ import com.zhongshu.reward.client.model.wallet.TransferModel;
 | 
	
		
			
				|  |  |  import com.zhongshu.reward.client.model.wallet.TransferStatusModel;
 | 
	
		
			
				|  |  |  import com.zhongshu.reward.client.model.wallet.WxTransferBatchModel;
 | 
	
		
			
				|  |  |  import com.zhongshu.reward.client.ret.CommentException;
 | 
	
		
			
				|  |  | +import com.zhongshu.reward.client.type.OperateType;
 | 
	
		
			
				|  |  |  import com.zhongshu.reward.client.type.TimeUnitType;
 | 
	
		
			
				|  |  |  import com.zhongshu.reward.client.type.TransferChannel;
 | 
	
		
			
				|  |  |  import com.zhongshu.reward.client.type.TransferStatus;
 | 
	
		
			
				|  |  |  import com.zhongshu.reward.server.core.config.WeChatConfig;
 | 
	
		
			
				|  |  | +import com.zhongshu.reward.server.core.dao.OperateDisableDao;
 | 
	
		
			
				|  |  |  import com.zhongshu.reward.server.core.dao.TransferRulerDao;
 | 
	
		
			
				|  |  |  import com.zhongshu.reward.server.core.dao.WalletDao;
 | 
	
		
			
				|  |  |  import com.zhongshu.reward.server.core.dao.WxTransferBatchDao;
 | 
	
		
			
				|  |  | +import com.zhongshu.reward.server.core.domain.OperateDisable;
 | 
	
		
			
				|  |  |  import com.zhongshu.reward.server.core.domain.TransferRuler;
 | 
	
		
			
				|  |  |  import com.zhongshu.reward.server.core.domain.Wallet;
 | 
	
		
			
				|  |  |  import com.zhongshu.reward.server.core.domain.WxTransferBatch;
 | 
	
	
		
			
				|  | @@ -34,9 +42,7 @@ import java.math.BigDecimal;
 | 
	
		
			
				|  |  |  import java.time.LocalDateTime;
 | 
	
		
			
				|  |  |  import java.time.temporal.TemporalAdjuster;
 | 
	
		
			
				|  |  |  import java.time.temporal.TemporalAdjusters;
 | 
	
		
			
				|  |  | -import java.util.ArrayList;
 | 
	
		
			
				|  |  | -import java.util.Calendar;
 | 
	
		
			
				|  |  | -import java.util.List;
 | 
	
		
			
				|  |  | +import java.util.*;
 | 
	
		
			
				|  |  |  import java.util.stream.Collectors;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
	
		
			
				|  | @@ -65,6 +71,15 @@ public class WxTransferService {
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      WeChatConfig weChatConfig;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    OperateDisableDao operateDisableDao;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    AuthHelper authHelper;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    DBHelper dbHelper;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 发起提现
 | 
	
	
		
			
				|  | @@ -73,6 +88,16 @@ public class WxTransferService {
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Transactional
 | 
	
		
			
				|  |  |      public Object transfer(WalletTransferParam param){
 | 
	
		
			
				|  |  | +        String userId = authHelper.getCurrentUser().getUserId();
 | 
	
		
			
				|  |  | +        OperateDisable operateDisable = operateDisableDao.findTopByUserIdAndType(userId, OperateType.TRANSFER);
 | 
	
		
			
				|  |  | +        if (ObjectUtils.isNotEmpty(operateDisable)){
 | 
	
		
			
				|  |  | +            if (new Date().getTime() < operateDisable.getTTL().getTime()){
 | 
	
		
			
				|  |  | +                return ResultContent.build(ResultState.Fail, "系统异常,请"+ DateUtils.paresTime(operateDisable.getTTL().getTime(), DateUtils.patternyyyyMis) + "后重试");
 | 
	
		
			
				|  |  | +            }else {
 | 
	
		
			
				|  |  | +                operateDisableDao.delete(operateDisable);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          Wallet wallet = walletDao.findTop1ById(param.getWalletId());
 | 
	
		
			
				|  |  |          //校验提现规则
 | 
	
		
			
				|  |  |          validTransfer(param.getTotal(), wallet);
 | 
	
	
		
			
				|  | @@ -98,9 +123,13 @@ public class WxTransferService {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          InitiateBatchTransferResponse response = wechatService.initiateBatchTransfer(transferModel, param.getAppid());
 | 
	
		
			
				|  |  |          if (response==null){
 | 
	
		
			
				|  |  | +            OperateDisable newDisable = new OperateDisable();
 | 
	
		
			
				|  |  | +            newDisable.setUserId(userId);
 | 
	
		
			
				|  |  | +            newDisable.setType(OperateType.TRANSFER);
 | 
	
		
			
				|  |  | +            newDisable.setTTL(new Date(this.dbHelper.getTime() + 60*60 * 1000L));
 | 
	
		
			
				|  |  | +            operateDisableDao.save(newDisable);
 | 
	
		
			
				|  |  |              return ResultContent.build(ResultState.Fail);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |          WxTransferBatch wxTransferBatch = new WxTransferBatch();
 | 
	
		
			
				|  |  |          wxTransferBatch.setBatchNo(outBatchNo);
 | 
	
		
			
				|  |  |          wxTransferBatch.setDetailNo(outDetailNo);
 | 
	
	
		
			
				|  | @@ -111,7 +140,6 @@ public class WxTransferService {
 | 
	
		
			
				|  |  |          wxTransferBatch.setBatchStatus(response.getBatchStatus());
 | 
	
		
			
				|  |  |          wxTransferBatch.setWxBatchId(response.getBatchId());
 | 
	
		
			
				|  |  |          wxTransferBatch.setTransferStatus(TransferStatus.PROCESSING);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |          wxTransferBatchDao.save(wxTransferBatch);
 | 
	
		
			
				|  |  |          wallet.setAmount(wallet.getAmount().subtract(param.getTotal()));
 | 
	
		
			
				|  |  |          wallet.setTodayTransferAmount(wallet.getTodayTransferAmount().add(param.getTotal()));
 |