|
@@ -14,21 +14,21 @@ import com.szwl.model.bean.RefundRequestBody;
|
|
import com.szwl.model.bo.R;
|
|
import com.szwl.model.bo.R;
|
|
import com.szwl.model.bo.ResponseModel;
|
|
import com.szwl.model.bo.ResponseModel;
|
|
import com.szwl.model.dto.*;
|
|
import com.szwl.model.dto.*;
|
|
|
|
+import com.szwl.model.entity.TAirwallexPayment;
|
|
import com.szwl.model.entity.TOrderAbroad;
|
|
import com.szwl.model.entity.TOrderAbroad;
|
|
import com.szwl.model.utils.AccessTokenThreadUtil;
|
|
import com.szwl.model.utils.AccessTokenThreadUtil;
|
|
-import com.szwl.service.AirwallexService;
|
|
|
|
-import com.szwl.service.TAdminService;
|
|
|
|
-import com.szwl.service.TOrderAbroadService;
|
|
|
|
|
|
+import com.szwl.service.*;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import javax.annotation.Resource;
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
+import java.sql.Timestamp;
|
|
|
|
+import java.time.OffsetDateTime;
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
//@CrossOrigin
|
|
//@CrossOrigin
|
|
@@ -46,10 +46,13 @@ public class AirwallexPayController {
|
|
|
|
|
|
TOrderAbroadService tOrderAbroadService;
|
|
TOrderAbroadService tOrderAbroadService;
|
|
|
|
|
|
- public AirwallexPayController(TAdminService tAdminService, AirwallexService airwallexService, TOrderAbroadService tOrderAbroadService) {
|
|
|
|
|
|
+ TAirwallexPaymentService tAirwallexPaymentService;
|
|
|
|
+
|
|
|
|
+ public AirwallexPayController(TAdminService tAdminService, AirwallexService airwallexService, TOrderAbroadService tOrderAbroadService, TAirwallexPaymentService tAirwallexPaymentService) {
|
|
this.tAdminService = tAdminService;
|
|
this.tAdminService = tAdminService;
|
|
this.airwallexService = airwallexService;
|
|
this.airwallexService = airwallexService;
|
|
this.tOrderAbroadService = tOrderAbroadService;
|
|
this.tOrderAbroadService = tOrderAbroadService;
|
|
|
|
+ this.tAirwallexPaymentService = tAirwallexPaymentService;
|
|
}
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "创建收款人")
|
|
@ApiOperation(value = "创建收款人")
|
|
@@ -353,6 +356,8 @@ public class AirwallexPayController {
|
|
@PostMapping("/caPayment")
|
|
@PostMapping("/caPayment")
|
|
public R caPayment(@RequestBody CaPaymentRequestDTO caPaymentRequestDTO) {
|
|
public R caPayment(@RequestBody CaPaymentRequestDTO caPaymentRequestDTO) {
|
|
|
|
|
|
|
|
+ Long adminId = caPaymentRequestDTO.getAdminId();
|
|
|
|
+
|
|
String resp = airwallexService.caPayment(caPaymentRequestDTO);
|
|
String resp = airwallexService.caPayment(caPaymentRequestDTO);
|
|
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
@@ -366,6 +371,44 @@ public class AirwallexPayController {
|
|
assert jsonNode != null;
|
|
assert jsonNode != null;
|
|
String paymentId = jsonNode.get("payment_id").asText();
|
|
String paymentId = jsonNode.get("payment_id").asText();
|
|
|
|
|
|
|
|
+ String paymentCurrency = jsonNode.get("payment_currency").asText();
|
|
|
|
+ String paymentAmountStr = jsonNode.get("payment_amount").asText();
|
|
|
|
+ String beneficiaryId = jsonNode.get("beneficiary_id").asText();
|
|
|
|
+ String createdAtStr = jsonNode.get("created_at").asText();
|
|
|
|
+
|
|
|
|
+ // TODO: 保存支付提现明细
|
|
|
|
+ TAirwallexPayment tAirwallexPayment = new TAirwallexPayment();
|
|
|
|
+ tAirwallexPayment.setPaymentId(paymentId);
|
|
|
|
+ tAirwallexPayment.setPaymentCurrency(paymentCurrency);
|
|
|
|
+ BigDecimal paymentAmount = new BigDecimal(paymentAmountStr);
|
|
|
|
+ tAirwallexPayment.setPaymentAmount(paymentAmount);
|
|
|
|
+ tAirwallexPayment.setBeneficiaryId(beneficiaryId);
|
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ");
|
|
|
|
+ OffsetDateTime createdAt = OffsetDateTime.parse(createdAtStr, formatter);
|
|
|
|
+ Timestamp from = Timestamp.from(createdAt.toInstant());
|
|
|
|
+ tAirwallexPayment.setCreateTime(from);
|
|
|
|
+ tAirwallexPayment.setAdminId(adminId);
|
|
|
|
+ tAirwallexPaymentService.save(tAirwallexPayment);
|
|
|
|
+
|
|
|
|
+ // TODO: 从当前余额中扣除提现金额,考虑货币
|
|
|
|
+ // TODO: 改成每次将余额全部提现
|
|
|
|
+// tAirwallexWalletService.list()
|
|
|
|
+// LambdaQueryWrapper<TAirwallexWallet> wrapper = Wrappers.lambdaQuery();
|
|
|
|
+// wrapper.eq(TAirwallexWallet::getAdminId, adminId);
|
|
|
|
+//// List<TAirwallexWallet> list = tAirwallexWalletService.list(wrapper);
|
|
|
|
+// TAirwallexWallet one = tAirwallexWalletService.getOne(wrapper);
|
|
|
|
+// String accountCurrency = one.getAccountCurrency();
|
|
|
|
+// BigDecimal accountAmount = one.getAccountAmount();
|
|
|
|
+
|
|
|
|
+ // 先判断货币是否一样
|
|
|
|
+// if (accountCurrency.equals(paymentCurrency)) {
|
|
|
|
+// accountAmount = accountAmount.subtract(paymentAmount);
|
|
|
|
+// } else {
|
|
|
|
+// //
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
// 返回 payment_id
|
|
// 返回 payment_id
|
|
return R.ok(paymentId);
|
|
return R.ok(paymentId);
|
|
}
|
|
}
|
|
@@ -388,4 +431,5 @@ public class AirwallexPayController {
|
|
|
|
|
|
return R.ok(resp);
|
|
return R.ok(resp);
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|