...
|
...
|
@@ -41,11 +41,14 @@ import org.apache.commons.lang3.StringUtils; |
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.Date;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
|
|
|
|
|
|
@Service
|
|
|
public class PaymentServiceImpl implements IPaymentService {
|
...
|
...
|
@@ -101,7 +104,20 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
@Autowired
|
|
|
TradeBillsMapper tradeBillsMapper;
|
|
|
|
|
|
|
|
|
@Value("${order.buyer.cancelWhenSellerDelivery.money}")
|
|
|
private String buyerCancelDelivery;
|
|
|
@Value("${order.buyer.cancelWhenSellerUnDelivery.money}")
|
|
|
private String buyerCancelUnDelivery;
|
|
|
@Value("${order.buyer.cancelWhenSellerDelivery.sellerGetMoneyRate}")
|
|
|
private String sellerGetRateDelivery;
|
|
|
@Value("${order.buyer.cancelWhenSellerUnDelivery.sellerGetMoneyRate}")
|
|
|
private String sellerGetRateUnDelivery;
|
|
|
|
|
|
private BigDecimal buyerCancelDeliveryMoney;
|
|
|
private BigDecimal buyerCancelUnDeliveryMoney;
|
|
|
private BigDecimal sellerGetRateDeliveryMoney;
|
|
|
private BigDecimal sellerGetRateUnDeliveryMoney;
|
|
|
|
|
|
/**
|
|
|
* 获取主场的订单service
|
|
|
* @param codeMeta
|
...
|
...
|
@@ -407,6 +423,9 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
* 1:鉴定通过(货款-->卖家);
|
|
|
* 2:鉴定不通过(保证金 --> 买家);
|
|
|
* 3:有买家时卖家不卖了(保证金 --> 买家)
|
|
|
* // 20181109 add
|
|
|
* 4:买家付款后[卖家未发货],取消订单(货款部分-->卖家);
|
|
|
* 5:买家付款后[卖家已发货],取消订单(货款部分-->卖家);
|
|
|
* </pre>
|
|
|
*
|
|
|
* @param request 请求
|
...
|
...
|
@@ -425,7 +444,7 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
|
|
|
}
|
|
|
// 类型检查
|
|
|
if (transferType < 1 || transferType > 3) {
|
|
|
if (transferType < 1 || transferType > 5) {
|
|
|
logger.warn("transferMonErr transferType invalid");
|
|
|
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
|
|
|
}
|
...
|
...
|
@@ -451,7 +470,8 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
}
|
|
|
|
|
|
long sellerOrderCode = sellerOrder.getOrderCode();
|
|
|
Integer targetUid = transferType == 1 ? sellerOrder.getUid() : buyerOrder.getUid();
|
|
|
Integer targetUserType = (transferType == 2 || transferType == 3) ? 1 : 2;
|
|
|
Integer targetUid = targetUserType == 1 ? buyerOrder.getUid() : sellerOrder.getUid();
|
|
|
|
|
|
if (targetUid == null || targetUid < 1) {
|
|
|
logger.warn("transferMonErr uid {} 不合法", targetUid);
|
...
|
...
|
@@ -488,11 +508,11 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
TradeBills record = new TradeBills();
|
|
|
record.setUid(targetUid);
|
|
|
record.setOrderCode(buyerOrderCode);
|
|
|
record.setUserType(transferType == 1 ? 2 : 1);
|
|
|
record.setUserType(targetUserType);
|
|
|
record.setPayType(1);
|
|
|
record.setTradeType(transferType == 1 ? 2 : 3);
|
|
|
record.setIncomeOutcome(1);
|
|
|
record.setTradeStatus(transferType == 1 ? 0 : 1);
|
|
|
record.setTradeStatus(0);
|
|
|
record.setCreateTime(now);
|
|
|
|
|
|
logger.info("transferMon参数检查成功!");
|
...
|
...
|
@@ -590,7 +610,7 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
|
|
|
}
|
|
|
// 类型检查
|
|
|
if (transferType < 1 || transferType > 3) {
|
|
|
if (transferType < 1 || transferType > 5) {
|
|
|
logger.warn("transferMonErr transferType invalid");
|
|
|
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
|
|
|
}
|
...
|
...
|
@@ -900,6 +920,13 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
|
|
|
|
|
|
private BigDecimal calcTransferAmount(Integer sellerUid, Integer skup, int transferType) {
|
|
|
if (transferType == 4) {
|
|
|
return sellerGetRateUnDeliveryMoney;
|
|
|
}
|
|
|
if (transferType == 5) {
|
|
|
return sellerGetRateDeliveryMoney;
|
|
|
}
|
|
|
|
|
|
SellerOrderMeta meta = sellerOrderMetaMapper.selectByMetaKey(sellerUid, skup, "fee");
|
|
|
if (meta == null) {
|
|
|
logger.warn("查询SellerOrderMeta无数据, sellerUid is {}, skup is {}", sellerUid, skup);
|
...
|
...
|
@@ -1021,12 +1048,33 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
CommonAlarmEventPublisher.publish(name, type, content);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostConstruct
|
|
|
private void init() {
|
|
|
try {
|
|
|
buyerCancelDeliveryMoney = new BigDecimal(buyerCancelUnDelivery);
|
|
|
buyerCancelUnDeliveryMoney = new BigDecimal(buyerCancelUnDelivery);
|
|
|
sellerGetRateDeliveryMoney = buyerCancelDeliveryMoney.multiply(new BigDecimal(sellerGetRateDelivery))
|
|
|
.setScale(2, BigDecimal.ROUND_HALF_DOWN);
|
|
|
sellerGetRateUnDeliveryMoney = buyerCancelUnDeliveryMoney.multiply(new BigDecimal(sellerGetRateUnDelivery))
|
|
|
.setScale(2, BigDecimal.ROUND_HALF_DOWN);
|
|
|
} catch (Exception e) {
|
|
|
logger.error("买家取消罚款金额相关参数配置错误!", e);
|
|
|
throw new Error("买家取消罚款金额相关参数配置错误!");
|
|
|
}
|
|
|
if (buyerCancelDeliveryMoney.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
throw new Error("buyerCancelDeliveryMoney买家取消(货已寄出)罚款金额不能为负数");
|
|
|
}
|
|
|
if (buyerCancelUnDeliveryMoney.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
throw new Error("buyerCancelUnDeliveryMoney买家取消(货未寄出)罚款金额不能为负数");
|
|
|
}
|
|
|
if (sellerGetRateDeliveryMoney.compareTo(BigDecimal.ZERO) < 0
|
|
|
|| sellerGetRateDeliveryMoney.compareTo(BigDecimal.ONE) > 0) {
|
|
|
throw new Error("sellerGetRateDeliveryMoney买家取消(货已寄出)卖家获得赔偿比率必须在[0,1]");
|
|
|
}
|
|
|
if (sellerGetRateUnDeliveryMoney.compareTo(BigDecimal.ZERO) < 0
|
|
|
|| sellerGetRateUnDeliveryMoney.compareTo(BigDecimal.ONE) > 0) {
|
|
|
throw new Error("sellerGetRateUnDeliveryMoney买家取消(货未寄出)卖家获得赔偿比率必须在[0,1]");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|