Authored by chenchao

Merge branch 'dev_支持买家退款' into dev_order

# Conflicts:
#	web/src/main/resources/config.properties
#	web/src/main/webapp/META-INF/autoconf/config.properties
... ... @@ -22,7 +22,10 @@ public class TransferMoneyRequest {
* <pre>
* 1:鉴定通过(货款-->卖家);
* 2:鉴定不通过(保证金 --> 买家);
* 3:有买家时卖家不卖了(保证金 --> 买家)
* 3:有买家时卖家不卖了(保证金 --> 买家);
* // 20181109 add
* 4:买家付款后[卖家未发货],取消订单(货款部分-->卖家);
* 5:买家付款后[卖家已发货],取消订单(货款部分-->卖家);
* </pre>
*/
private int type;
... ...
... ... @@ -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]");
}
}
}
... ...
... ... @@ -95,7 +95,16 @@ order.seller.appraiseFee=0.1
order.seller.goodsPaymentRate=0.05
order.seller.earnestMoneyRate=0.2
order.seller.payChannelRate=0.0006
order.buyer.compensate.before_seller_deliver=38
order.buyer.compensate.before_depot_receive=68
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,8 +63,16 @@ 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.compensate.before_depot_receive=${order.buyer.compensate.before_depot_receive}
order.buyer.compensate.before_seller_deliver=${order.buyer.compensate.before_seller_deliver}
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}
... ...