Authored by Lixiaodi

支持买家退款

@@ -22,7 +22,10 @@ public class TransferMoneyRequest { @@ -22,7 +22,10 @@ public class TransferMoneyRequest {
22 * <pre> 22 * <pre>
23 * 1:鉴定通过(货款-->卖家); 23 * 1:鉴定通过(货款-->卖家);
24 * 2:鉴定不通过(保证金 --> 买家); 24 * 2:鉴定不通过(保证金 --> 买家);
25 - * 3:有买家时卖家不卖了(保证金 --> 买家) 25 + * 3:有买家时卖家不卖了(保证金 --> 买家);
  26 + * // 20181109 add
  27 + * 4:买家付款后[卖家未发货],取消订单(货款部分-->卖家);
  28 + * 5:买家付款后[卖家已发货],取消订单(货款部分-->卖家);
26 * </pre> 29 * </pre>
27 */ 30 */
28 private int type; 31 private int type;
@@ -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 }
@@ -95,5 +95,11 @@ order.seller.appraiseFee=0.1 @@ -95,5 +95,11 @@ order.seller.appraiseFee=0.1
95 order.seller.goodsPaymentRate=0.05 95 order.seller.goodsPaymentRate=0.05
96 order.seller.earnestMoneyRate=0.2 96 order.seller.earnestMoneyRate=0.2
97 order.seller.payChannelRate=0.0006 97 order.seller.payChannelRate=0.0006
  98 +order.buyer.cancelWhenSellerDelivery.money=68
  99 +order.buyer.cancelWhenSellerUnDelivery.money=38
  100 +order.buyer.cancelWhenSellerDelivery.sellerGetMoneyRate=0.8
  101 +order.buyer.cancelWhenSellerUnDelivery.sellerGetMoneyRate=0.8
  102 +
  103 +
98 uic.url=http://java-yoho-uic.test3.ingress.dev.yohocorp.com/uic 104 uic.url=http://java-yoho-uic.test3.ingress.dev.yohocorp.com/uic
99 yoho.message.controller.url=http://message-controller.yohoops.org/yoho-message-controller 105 yoho.message.controller.url=http://message-controller.yohoops.org/yoho-message-controller
@@ -63,6 +63,11 @@ order.seller.appraiseFee=${order.seller.appraiseFee} @@ -63,6 +63,11 @@ order.seller.appraiseFee=${order.seller.appraiseFee}
63 order.seller.goodsPaymentRate=${order.seller.goodsPaymentRate} 63 order.seller.goodsPaymentRate=${order.seller.goodsPaymentRate}
64 order.seller.earnestMoneyRate=${order.seller.earnestMoneyRate} 64 order.seller.earnestMoneyRate=${order.seller.earnestMoneyRate}
65 order.seller.payChannelRate=${order.seller.payChannelRate} 65 order.seller.payChannelRate=${order.seller.payChannelRate}
  66 +order.buyer.cancelWhenSellerDelivery.money=${order.buyer.cancelWhenSellerDelivery.money}
  67 +order.buyer.cancelWhenSellerUnDelivery.money=${order.buyer.cancelWhenSellerUnDelivery.money}
  68 +order.buyer.cancelWhenSellerDelivery.sellerGetMoneyRate=${order.buyer.cancelWhenSellerDelivery.sellerGetMoneyRate}
  69 +order.buyer.cancelWhenSellerUnDelivery.sellerGetMoneyRate=${order.buyer.cancelWhenSellerUnDelivery.sellerGetMoneyRate}
  70 +
66 erp-gateway.url=${erp-gateway.url} 71 erp-gateway.url=${erp-gateway.url}
67 uic.url=${uic.url} 72 uic.url=${uic.url}
68 yoho.message.controller.url=${yoho.message.controller.url} 73 yoho.message.controller.url=${yoho.message.controller.url}