Authored by Lixiaodi

支持买家退款

... ... @@ -22,7 +22,10 @@ public class TransferMoneyRequest {
* <pre>
* 1:鉴定通过(货款-->卖家);
* 2:鉴定不通过(保证金 --> 买家);
* 3:有买家时卖家不卖了(保证金 --> 买家)
* 3:有买家时卖家不卖了(保证金 --> 买家);
* // 20181109 add
* 4:买家付款后[卖家未发货],取消订单(货款部分-->卖家);
* 5:买家付款后[卖家已发货],取消订单(货款部分-->卖家);
* </pre>
*/
private int type;
... ...
... ... @@ -40,11 +40,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 {
... ... @@ -100,7 +103,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
... ... @@ -405,6 +421,9 @@ public class PaymentServiceImpl implements IPaymentService {
* 1:鉴定通过(货款-->卖家);
* 2:鉴定不通过(保证金 --> 买家);
* 3:有买家时卖家不卖了(保证金 --> 买家)
* // 20181109 add
* 4:买家付款后[卖家未发货],取消订单(货款部分-->卖家);
* 5:买家付款后[卖家已发货],取消订单(货款部分-->卖家);
* </pre>
*
* @param request 请求
... ... @@ -423,7 +442,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);
}
... ... @@ -449,7 +468,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);
... ... @@ -486,11 +506,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参数检查成功!");
... ... @@ -898,6 +918,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);
... ... @@ -1018,12 +1045,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]");
}
}
}
... ...
... ... @@ -95,5 +95,11 @@ order.seller.appraiseFee=0.1
order.seller.goodsPaymentRate=0.05
order.seller.earnestMoneyRate=0.2
order.seller.payChannelRate=0.0006
order.buyer.cancelWhenSellerDelivery.money=68
order.buyer.cancelWhenSellerUnDelivery.money=38
order.buyer.cancelWhenSellerDelivery.sellerGetMoneyRate=0.8
order.buyer.cancelWhenSellerUnDelivery.sellerGetMoneyRate=0.8
uic.url=http://java-yoho-uic.test3.ingress.dev.yohocorp.com/uic
yoho.message.controller.url=http://message-controller.yohoops.org/yoho-message-controller
\ No newline at end of file
... ...
... ... @@ -63,6 +63,11 @@ order.seller.appraiseFee=${order.seller.appraiseFee}
order.seller.goodsPaymentRate=${order.seller.goodsPaymentRate}
order.seller.earnestMoneyRate=${order.seller.earnestMoneyRate}
order.seller.payChannelRate=${order.seller.payChannelRate}
order.buyer.cancelWhenSellerDelivery.money=${order.buyer.cancelWhenSellerDelivery.money}
order.buyer.cancelWhenSellerUnDelivery.money=${order.buyer.cancelWhenSellerUnDelivery.money}
order.buyer.cancelWhenSellerDelivery.sellerGetMoneyRate=${order.buyer.cancelWhenSellerDelivery.sellerGetMoneyRate}
order.buyer.cancelWhenSellerUnDelivery.sellerGetMoneyRate=${order.buyer.cancelWhenSellerUnDelivery.sellerGetMoneyRate}
erp-gateway.url=${erp-gateway.url}
uic.url=${uic.url}
yoho.message.controller.url=${yoho.message.controller.url}
... ...