|
|
@@ -265,7 +265,9 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
|
|
|
orderDon.setMoney(payRequest.getDonMoney());
|
|
|
orderDon.setRealMoney(payRequest.getDonMoney());
|
|
|
-
|
|
|
+ //未传货币单元 默认美元
|
|
|
+ orderDon.setCurrency(Optional.ofNullable(payRequest.getCurrency()).orElse("USD"));
|
|
|
+ orderDon.setRate(payRequest.getRate());
|
|
|
List<Long> dpSkuIds = payRequest.getDpSkuIds();
|
|
|
if (CollUtil.isNotEmpty(dpSkuIds)) {
|
|
|
if (dpSkuIds.size() > 1) {
|
|
|
@@ -349,6 +351,9 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
});
|
|
|
}
|
|
|
orderDon.setPayTitle(payTitle.toString());
|
|
|
+ if ("TWD".equals(payRequest.getCurrency())){
|
|
|
+ orderDon.setMoney(orderDon.getMoney().setScale(-2, RoundingMode.HALF_UP));
|
|
|
+ }
|
|
|
this.saveOrUpdate(orderDon);
|
|
|
|
|
|
if (orderDon.getIsDp()) {
|
|
|
@@ -763,13 +768,25 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
|
|
|
|
String payOpenId = user.getOpenId();
|
|
|
+ BigDecimal price = sku.getPrice();
|
|
|
+ if ("TWD".equals(payRequest.getCurrency())){
|
|
|
+ price = sku.getTwPrice();
|
|
|
+ }else if ("HKD".equals(payRequest.getCurrency())){
|
|
|
+ price = sku.getHkPrice();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (price.compareTo(BigDecimal.ZERO) == 0){
|
|
|
+ price = sku.getPrice().multiply(payRequest.getRate());
|
|
|
+ }
|
|
|
|
|
|
/* 生成订单 */
|
|
|
String donNo = SEQUENCE.nextId().toString();
|
|
|
OrderDon orderDon = new OrderDon();
|
|
|
orderDon.setOrderNo(donNo);
|
|
|
orderDon.setOpenId(payOpenId);
|
|
|
- orderDon.setMoney(sku.getPrice().multiply(BigDecimal.valueOf(payRequest.getNum())));
|
|
|
+ orderDon.setMoney(price.multiply(BigDecimal.valueOf(payRequest.getNum())));
|
|
|
+ orderDon.setCurrency(payRequest.getCurrency());
|
|
|
+ orderDon.setRate(payRequest.getRate());
|
|
|
orderDon.setSkuId(renewSkuId);
|
|
|
orderDon.setRelationId(relation.getId());
|
|
|
//续费订单
|
|
|
@@ -796,7 +813,10 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
|
orderDon.setRealMoney(orderDon.getMoney());
|
|
|
//扣除使用优惠券、余额的订单金额
|
|
|
- deductOrderMoney(orderDon, couponUser, payRequest.getBalance(), user, sku.getPrice(), goodsDon.getType());
|
|
|
+ deductOrderMoney(orderDon, couponUser, payRequest.getBalance(), user, price, goodsDon.getType());
|
|
|
+ if ("TWD".equals(payRequest.getCurrency())){
|
|
|
+ orderDon.setMoney(orderDon.getMoney().setScale(-2, RoundingMode.HALF_UP));
|
|
|
+ }
|
|
|
this.saveOrUpdate(orderDon);
|
|
|
//订单金额为0 且订单为已完成 更新虚物车票
|
|
|
if (orderDon.getMoney().compareTo(BigDecimal.ZERO) == 0) {
|
|
|
@@ -1979,6 +1999,9 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
|
BigDecimal userBalance = user.getBalance();
|
|
|
//扣除余额 是否成功
|
|
|
+ if (!"USD".equals(orderDon.getCurrency())){
|
|
|
+ subBalance = subBalance.divide(orderDon.getRate(),0,RoundingMode.HALF_UP);
|
|
|
+ }
|
|
|
Integer success = userMapper.deductBalance(user.getId(), subBalance, userBalance);
|
|
|
if (success != 1) throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("user_balance_not_enough"));
|
|
|
orderDon.setBalance(subBalance);
|