|
@@ -40,11 +40,14 @@ import org.apache.commons.lang3.StringUtils; |
|
@@ -40,11 +40,14 @@ import org.apache.commons.lang3.StringUtils; |
40
|
import org.slf4j.Logger;
|
40
|
import org.slf4j.Logger;
|
41
|
import org.slf4j.LoggerFactory;
|
41
|
import org.slf4j.LoggerFactory;
|
42
|
import org.springframework.beans.factory.annotation.Autowired;
|
42
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
43
|
+import org.springframework.beans.factory.annotation.Value;
|
43
|
import org.springframework.stereotype.Service;
|
44
|
import org.springframework.stereotype.Service;
|
44
|
|
45
|
|
45
|
import java.math.BigDecimal;
|
46
|
import java.math.BigDecimal;
|
46
|
import java.util.Date;
|
47
|
import java.util.Date;
|
47
|
|
48
|
|
|
|
49
|
+import javax.annotation.PostConstruct;
|
|
|
50
|
+
|
48
|
|
51
|
|
49
|
@Service
|
52
|
@Service
|
50
|
public class PaymentServiceImpl implements IPaymentService {
|
53
|
public class PaymentServiceImpl implements IPaymentService {
|
|
@@ -100,7 +103,20 @@ public class PaymentServiceImpl implements IPaymentService { |
|
@@ -100,7 +103,20 @@ public class PaymentServiceImpl implements IPaymentService { |
100
|
@Autowired
|
103
|
@Autowired
|
101
|
TradeBillsMapper tradeBillsMapper;
|
104
|
TradeBillsMapper tradeBillsMapper;
|
102
|
|
105
|
|
103
|
-
|
106
|
+ @Value("${order.buyer.cancelWhenSellerDelivery.money}")
|
|
|
107
|
+ private String buyerCancelDelivery;
|
|
|
108
|
+ @Value("${order.buyer.cancelWhenSellerUnDelivery.money}")
|
|
|
109
|
+ private String buyerCancelUnDelivery;
|
|
|
110
|
+ @Value("${order.buyer.cancelWhenSellerDelivery.sellerGetMoneyRate}")
|
|
|
111
|
+ private String sellerGetRateDelivery;
|
|
|
112
|
+ @Value("${order.buyer.cancelWhenSellerUnDelivery.sellerGetMoneyRate}")
|
|
|
113
|
+ private String sellerGetRateUnDelivery;
|
|
|
114
|
+
|
|
|
115
|
+ private BigDecimal buyerCancelDeliveryMoney;
|
|
|
116
|
+ private BigDecimal buyerCancelUnDeliveryMoney;
|
|
|
117
|
+ private BigDecimal sellerGetRateDeliveryMoney;
|
|
|
118
|
+ private BigDecimal sellerGetRateUnDeliveryMoney;
|
|
|
119
|
+
|
104
|
/**
|
120
|
/**
|
105
|
* 获取主场的订单service
|
121
|
* 获取主场的订单service
|
106
|
* @param codeMeta
|
122
|
* @param codeMeta
|
|
@@ -405,6 +421,9 @@ public class PaymentServiceImpl implements IPaymentService { |
|
@@ -405,6 +421,9 @@ public class PaymentServiceImpl implements IPaymentService { |
405
|
* 1:鉴定通过(货款-->卖家);
|
421
|
* 1:鉴定通过(货款-->卖家);
|
406
|
* 2:鉴定不通过(保证金 --> 买家);
|
422
|
* 2:鉴定不通过(保证金 --> 买家);
|
407
|
* 3:有买家时卖家不卖了(保证金 --> 买家)
|
423
|
* 3:有买家时卖家不卖了(保证金 --> 买家)
|
|
|
424
|
+ * // 20181109 add
|
|
|
425
|
+ * 4:买家付款后[卖家未发货],取消订单(货款部分-->卖家);
|
|
|
426
|
+ * 5:买家付款后[卖家已发货],取消订单(货款部分-->卖家);
|
408
|
* </pre>
|
427
|
* </pre>
|
409
|
*
|
428
|
*
|
410
|
* @param request 请求
|
429
|
* @param request 请求
|
|
@@ -423,7 +442,7 @@ public class PaymentServiceImpl implements IPaymentService { |
|
@@ -423,7 +442,7 @@ public class PaymentServiceImpl implements IPaymentService { |
423
|
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
|
442
|
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
|
424
|
}
|
443
|
}
|
425
|
// 类型检查
|
444
|
// 类型检查
|
426
|
- if (transferType < 1 || transferType > 3) {
|
445
|
+ if (transferType < 1 || transferType > 5) {
|
427
|
logger.warn("transferMonErr transferType invalid");
|
446
|
logger.warn("transferMonErr transferType invalid");
|
428
|
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
|
447
|
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
|
429
|
}
|
448
|
}
|
|
@@ -449,7 +468,8 @@ public class PaymentServiceImpl implements IPaymentService { |
|
@@ -449,7 +468,8 @@ public class PaymentServiceImpl implements IPaymentService { |
449
|
}
|
468
|
}
|
450
|
|
469
|
|
451
|
long sellerOrderCode = sellerOrder.getOrderCode();
|
470
|
long sellerOrderCode = sellerOrder.getOrderCode();
|
452
|
- Integer targetUid = transferType == 1 ? sellerOrder.getUid() : buyerOrder.getUid();
|
471
|
+ Integer targetUserType = (transferType == 2 || transferType == 3) ? 1 : 2;
|
|
|
472
|
+ Integer targetUid = targetUserType == 1 ? buyerOrder.getUid() : sellerOrder.getUid();
|
453
|
|
473
|
|
454
|
if (targetUid == null || targetUid < 1) {
|
474
|
if (targetUid == null || targetUid < 1) {
|
455
|
logger.warn("transferMonErr uid {} 不合法", targetUid);
|
475
|
logger.warn("transferMonErr uid {} 不合法", targetUid);
|
|
@@ -486,11 +506,11 @@ public class PaymentServiceImpl implements IPaymentService { |
|
@@ -486,11 +506,11 @@ public class PaymentServiceImpl implements IPaymentService { |
486
|
TradeBills record = new TradeBills();
|
506
|
TradeBills record = new TradeBills();
|
487
|
record.setUid(targetUid);
|
507
|
record.setUid(targetUid);
|
488
|
record.setOrderCode(buyerOrderCode);
|
508
|
record.setOrderCode(buyerOrderCode);
|
489
|
- record.setUserType(transferType == 1 ? 2 : 1);
|
509
|
+ record.setUserType(targetUserType);
|
490
|
record.setPayType(1);
|
510
|
record.setPayType(1);
|
491
|
record.setTradeType(transferType == 1 ? 2 : 3);
|
511
|
record.setTradeType(transferType == 1 ? 2 : 3);
|
492
|
record.setIncomeOutcome(1);
|
512
|
record.setIncomeOutcome(1);
|
493
|
- record.setTradeStatus(transferType == 1 ? 0 : 1);
|
513
|
+ record.setTradeStatus(0);
|
494
|
record.setCreateTime(now);
|
514
|
record.setCreateTime(now);
|
495
|
|
515
|
|
496
|
logger.info("transferMon参数检查成功!");
|
516
|
logger.info("transferMon参数检查成功!");
|
|
@@ -898,6 +918,13 @@ public class PaymentServiceImpl implements IPaymentService { |
|
@@ -898,6 +918,13 @@ public class PaymentServiceImpl implements IPaymentService { |
898
|
|
918
|
|
899
|
|
919
|
|
900
|
private BigDecimal calcTransferAmount(Integer sellerUid, Integer skup, int transferType) {
|
920
|
private BigDecimal calcTransferAmount(Integer sellerUid, Integer skup, int transferType) {
|
|
|
921
|
+ if (transferType == 4) {
|
|
|
922
|
+ return sellerGetRateUnDeliveryMoney;
|
|
|
923
|
+ }
|
|
|
924
|
+ if (transferType == 5) {
|
|
|
925
|
+ return sellerGetRateDeliveryMoney;
|
|
|
926
|
+ }
|
|
|
927
|
+
|
901
|
SellerOrderMeta meta = sellerOrderMetaMapper.selectByMetaKey(sellerUid, skup, "fee");
|
928
|
SellerOrderMeta meta = sellerOrderMetaMapper.selectByMetaKey(sellerUid, skup, "fee");
|
902
|
if (meta == null) {
|
929
|
if (meta == null) {
|
903
|
logger.warn("查询SellerOrderMeta无数据, sellerUid is {}, skup is {}", sellerUid, skup);
|
930
|
logger.warn("查询SellerOrderMeta无数据, sellerUid is {}, skup is {}", sellerUid, skup);
|
|
@@ -1018,12 +1045,33 @@ public class PaymentServiceImpl implements IPaymentService { |
|
@@ -1018,12 +1045,33 @@ public class PaymentServiceImpl implements IPaymentService { |
1018
|
CommonAlarmEventPublisher.publish(name, type, content);
|
1045
|
CommonAlarmEventPublisher.publish(name, type, content);
|
1019
|
}
|
1046
|
}
|
1020
|
|
1047
|
|
1021
|
-
|
|
|
1022
|
-
|
|
|
1023
|
-
|
|
|
1024
|
-
|
|
|
1025
|
-
|
|
|
1026
|
-
|
|
|
1027
|
-
|
1048
|
+ @PostConstruct
|
|
|
1049
|
+ private void init() {
|
|
|
1050
|
+ try {
|
|
|
1051
|
+ buyerCancelDeliveryMoney = new BigDecimal(buyerCancelUnDelivery);
|
|
|
1052
|
+ buyerCancelUnDeliveryMoney = new BigDecimal(buyerCancelUnDelivery);
|
|
|
1053
|
+ sellerGetRateDeliveryMoney = buyerCancelDeliveryMoney.multiply(new BigDecimal(sellerGetRateDelivery))
|
|
|
1054
|
+ .setScale(2, BigDecimal.ROUND_HALF_DOWN);
|
|
|
1055
|
+ sellerGetRateUnDeliveryMoney = buyerCancelUnDeliveryMoney.multiply(new BigDecimal(sellerGetRateUnDelivery))
|
|
|
1056
|
+ .setScale(2, BigDecimal.ROUND_HALF_DOWN);
|
|
|
1057
|
+ } catch (Exception e) {
|
|
|
1058
|
+ logger.error("买家取消罚款金额相关参数配置错误!", e);
|
|
|
1059
|
+ throw new Error("买家取消罚款金额相关参数配置错误!");
|
|
|
1060
|
+ }
|
|
|
1061
|
+ if (buyerCancelDeliveryMoney.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
1062
|
+ throw new Error("buyerCancelDeliveryMoney买家取消(货已寄出)罚款金额不能为负数");
|
|
|
1063
|
+ }
|
|
|
1064
|
+ if (buyerCancelUnDeliveryMoney.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
1065
|
+ throw new Error("buyerCancelUnDeliveryMoney买家取消(货未寄出)罚款金额不能为负数");
|
|
|
1066
|
+ }
|
|
|
1067
|
+ if (sellerGetRateDeliveryMoney.compareTo(BigDecimal.ZERO) < 0
|
|
|
1068
|
+ || sellerGetRateDeliveryMoney.compareTo(BigDecimal.ONE) > 0) {
|
|
|
1069
|
+ throw new Error("sellerGetRateDeliveryMoney买家取消(货已寄出)卖家获得赔偿比率必须在[0,1]");
|
|
|
1070
|
+ }
|
|
|
1071
|
+ if (sellerGetRateUnDeliveryMoney.compareTo(BigDecimal.ZERO) < 0
|
|
|
1072
|
+ || sellerGetRateUnDeliveryMoney.compareTo(BigDecimal.ONE) > 0) {
|
|
|
1073
|
+ throw new Error("sellerGetRateUnDeliveryMoney买家取消(货未寄出)卖家获得赔偿比率必须在[0,1]");
|
|
|
1074
|
+ }
|
|
|
1075
|
+ }
|
1028
|
|
1076
|
|
1029
|
} |
1077
|
} |