|
@@ -6,9 +6,11 @@ import com.txz.cif.core.ResultGenerator;
|
|
|
import com.txz.cif.dubbo.client.OperatingConfigDubboServiceClient;
|
|
|
import com.txz.cif.model.Account;
|
|
|
import com.txz.cif.model.RechargeRecord;
|
|
|
+import com.txz.cif.model.User;
|
|
|
import com.txz.cif.model.WithdrawRecord;
|
|
|
import com.txz.cif.service.AccountService;
|
|
|
import com.txz.cif.service.SequenceService;
|
|
|
+import com.txz.cif.service.UserService;
|
|
|
import com.txz.cif.service.WithdrawRecordService;
|
|
|
|
|
|
import com.txz.cif.core.ResultCode;
|
|
@@ -60,6 +62,10 @@ public class WithdrawRecordApiController {
|
|
|
@Resource
|
|
|
private AccountService accountService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private UserService userService;
|
|
|
+
|
|
|
+
|
|
|
@Resource
|
|
|
private OperatingConfigDubboServiceClient operatingConfigDubboServiceClient;
|
|
|
|
|
@@ -71,6 +77,7 @@ public class WithdrawRecordApiController {
|
|
|
}
|
|
|
try {
|
|
|
|
|
|
+
|
|
|
Triple<Boolean, String, Claims> result = authService.verifyToken(token);
|
|
|
|
|
|
if (!result.getLeft()) {
|
|
@@ -81,14 +88,30 @@ public class WithdrawRecordApiController {
|
|
|
}
|
|
|
Claims claims = result.getRight();
|
|
|
Long userId = Long.valueOf(claims.get("userId").toString());
|
|
|
+ User user = userService.findById(userId);
|
|
|
+ if (user == null){
|
|
|
+ return ResultGenerator.genFailResult(ResultCode.USER_IS_NULL);
|
|
|
+ }
|
|
|
+ if(StrUtil.isNotBlank(user.getBank()) ){
|
|
|
+ if (StrUtil.isNotBlank(param.getBank()) || StrUtil.isNotBlank(param.getBankAccount()) ||StrUtil.isNotBlank(param.getBankAccountName()) ) {
|
|
|
+ return ResultGenerator.genFailResult(ResultCode.BANK_IS_NULL);
|
|
|
+ }
|
|
|
+ userService.update(User.builder().
|
|
|
+ id(user.getId()).bank(param.getBank())
|
|
|
+ .bankAccountName(param.getBankAccountName())
|
|
|
+ .bankAccount(param.getBankAccount()).build());
|
|
|
+ user.setBank(param.getBank());
|
|
|
+ user.setBankAccount(param.getBankAccount());
|
|
|
+ user.setBankAccountName(param.getBankAccountName());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
com.txz.operating.result.Result<ConfigDTO> openRedEnvelopeRate = operatingConfigDubboServiceClient.getConfigByCode("join_red_envelope_rate");
|
|
|
String rate = openRedEnvelopeRate.getData().getValueInfo();
|
|
|
BigDecimal fee = param.getAmount().multiply(new BigDecimal(rate)).divide(BigDecimal.valueOf(100),2, RoundingMode.DOWN);
|
|
|
|
|
|
String orderNo = sequenceService.genSerialNumber("withdraw_rule",null);
|
|
|
|
|
|
-
|
|
|
-
|
|
|
WithdrawRecord withdrawRecord = new WithdrawRecord();
|
|
|
withdrawRecord.setOrderNo(orderNo);
|
|
|
withdrawRecord.setStatus(1);
|