Authored by qinchao

瑕疵分等级扣款

... ... @@ -48,6 +48,7 @@ public class SellerWalletDetail {
SELLER_OVER_TIME("卖家发货超时", 32),
APPRAISE_FAIL("鉴定不通过", 33),
SELLER_SHAM_SEND_OUT("卖家虚假发货", 34),
MINI_FAULT_REJECT("瑕疵确认不接受", 35),
BUYER_CANCEL_NO_DELIVERY("买家取消(无物流)", 41),
BUYER_CANCEL_DELIVERY("买家取消(有物流)", 42),
APPRAISE_OK("鉴定通过", 51),
... ...
... ... @@ -5,12 +5,14 @@ import com.yohoufo.order.common.RefundCase;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Builder;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class PaymentRequest {
private int uid;
... ...
... ... @@ -4,11 +4,8 @@ import com.alibaba.fastjson.JSONObject;
import com.yoho.core.rabbitmq.YhConsumer;
import com.yohobuy.ufo.model.order.bo.AppraiseExpressInfoBo;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohoufo.order.event.BuyerConfirmEvent;
import com.yohoufo.order.event.BuyerMiniFaultOuterTimeEvent;
import com.yohoufo.order.model.request.OrderRequest;
import com.yohoufo.order.mq.TopicConstants;
import com.yohoufo.order.service.IBuyerOrderService;
import com.yohoufo.order.service.impl.AppraiseService;
import com.yohoufo.order.utils.LoggerUtils;
import org.slf4j.Logger;
... ...
... ... @@ -526,6 +526,7 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
// 退还保证金:总账修改
// 卖家下架、系统下架、鉴定通过、买家取消
// add 退还保证金情形 20190128 :瑕疵确认不通过 (保证金扣掉10元后的金额退还给卖家)
public SellerWallet refundEarnest(Integer uid, BigDecimal money, MerchantOrderAttachInfo attach, long orderCode, SellerWalletDetail.Type type) {
return changeEarnest(uid, money, orderCode, attach, type);
}
... ... @@ -740,6 +741,7 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
} else if (type == SellerWalletDetail.Type.SELLER_OFF
|| type == SellerWalletDetail.Type.SYSTEM_OFF
|| type == SellerWalletDetail.Type.APPRAISE_OK
|| type == SellerWalletDetail.Type.MINI_FAULT_REJECT
|| type == SellerWalletDetail.Type.BUYER_CANCEL_DELIVERY
|| type == SellerWalletDetail.Type.BUYER_CANCEL_NO_DELIVERY) {
// 增加保证金
... ...
... ... @@ -38,6 +38,7 @@ 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;
... ... @@ -107,6 +108,12 @@ public class AppraiseService {
@Autowired
private OrderOperateRecordService orderOperateRecordService;
/**
* 瑕疵确认不通过的情况,卖家的保证金扣掉一部分给平台,暂定10元
*/
@Value("${order.seller.earnestmoney.miniFaultRejectPunishFee:10}")
private Double miniFaultRejectPunishFee ;
public ApiResponse appraiseSuccess(Integer expressCompanyId, Long orderCode, String wayBillCode,Integer depotNum,String mobile){
ApiResponse apiResponse=new ApiResponse();
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
... ... @@ -178,41 +185,12 @@ public class AppraiseService {
*/
//refund earnestMoney
BigDecimal earnestMoney = sellerOrder.getEarnestMoney();
PaymentRequest refundReqOfSeller = PaymentRequest.builder().uid(sellerUid)
.refundCase(RefundCase.SELLER_EARNEST_MONEY)
.orderCode(sellerOrderCode).refundAmount(earnestMoney.doubleValue())
.build();
boolean sellerIsSuper = sellerService.isSuperEntrySeller(sellerUid);
refundReqOfSeller.setSuper(sellerIsSuper);
if (!sellerIsSuper && PaymentHelper.isWallet(sellerOrder.getPayment())){
SellerWalletDetail.Type swdType = SellerWalletDetail.Type.APPRAISE_OK;
MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(sellerUid)
.orderCode(sellerOrderCode).skup(skup).earnestMoney(sellerOrder.getEarnestMoney())
.type(swdType.getValue()).build();
refundReqOfSeller.setRefundattch(moai);
}
BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder()
.buyerUid(buyerUid).sellerUid(sellerUid).orderCode(sellerOrder.getOrderCode())
.payType(sellerOrder.getPayment()).refundCase(RefundCase.SELLER_EARNEST_MONEY)
.skup(skup);
SellerOrderGoods sellerOrderGoods;
sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
new RefundEarnestMoneyHandler()
.loadRefundAction(payRefundService::refund)
.loadBillLogEventBuilder(bleb)
.loadPaymentRequest(refundReqOfSeller)
.loadBuyer(null, null, null)
.loadSeller(sellerUid, sellerIsSuper, orderCode, targetSoStatus)
.loadLogger(LOGGER)
.refund();
PaymentRequest refundReqOfSeller = refundEarnestMoney(SellerWalletDetail.Type.APPRAISE_OK,orderCode,sellerUid ,sellerOrder,skup,buyerUid,targetSoStatus,earnestMoney.doubleValue());
LOGGER.info("in appraiseSuccess,refund ok, refundReqOfSeller {}", refundReqOfSeller);
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
try {
/*
payRefundService.refund(refundReqOfSeller, bleb);
*/
//通知卖家退还保证金
//鉴定通过后自动发货,这个时候产生:买家确认收货的mq
BuyerConfirmEvent buyerConfirmEvent = BuyerConfirmEvent.builder().uid(buyerUid).orderCode(orderCode).build();
EventBusPublisher.publishEvent(buyerConfirmEvent);
//记录物流信息
... ... @@ -273,6 +251,42 @@ public class AppraiseService {
return apiResponse;
}
//退保证金给卖家
private PaymentRequest refundEarnestMoney(SellerWalletDetail.Type swdType,Long orderCode,Integer sellerUid ,SellerOrder sellerOrder,int skup,Integer buyerUid,SellerOrderStatus targetSoStatus ,double refundMoney){
Long sellerOrderCode = sellerOrder.getOrderCode();
PaymentRequest refundReqOfSeller = PaymentRequest.builder().uid(sellerUid)
.refundCase(RefundCase.SELLER_EARNEST_MONEY)
.orderCode(sellerOrderCode).refundAmount(refundMoney)
.build();
boolean sellerIsSuper = sellerService.isSuperEntrySeller(sellerUid);
refundReqOfSeller.setSuper(sellerIsSuper);
LOGGER.info("in refundEarnestMoney begin, swdType {} seller uid {},sellerIsSuper {},seller order code {}, skup {}, refundMoney {},refundReqOfSeller {}",swdType,
sellerUid,sellerIsSuper, sellerOrderCode, skup, refundMoney ,refundReqOfSeller);
if (!sellerIsSuper && PaymentHelper.isWallet(sellerOrder.getPayment())){
//SellerWalletDetail.Type swdType = SellerWalletDetail.Type.APPRAISE_OK;
MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(sellerUid)
.orderCode(sellerOrderCode).skup(skup).earnestMoney(sellerOrder.getEarnestMoney())
.type(swdType.getValue()).build();
refundReqOfSeller.setRefundattch(moai);
}
BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder()
.buyerUid(buyerUid).sellerUid(sellerUid).orderCode(sellerOrder.getOrderCode())
.payType(sellerOrder.getPayment()).refundCase(RefundCase.SELLER_EARNEST_MONEY)
.skup(skup);
new RefundEarnestMoneyHandler()
.loadRefundAction(payRefundService::refund)
.loadBillLogEventBuilder(bleb)
.loadPaymentRequest(refundReqOfSeller)
.loadBuyer(null, null, null)
.loadSeller(sellerUid, sellerIsSuper, orderCode, targetSoStatus)
.loadLogger(LOGGER)
.refund();
return refundReqOfSeller;
}
/**
* 触发物流
*/
... ... @@ -484,27 +498,33 @@ public class AppraiseService {
ErpBuyerOrderEvent event = new ErpBuyerOrderEvent(buyerUid);
EventBusPublisher.publishEvent(event);
//将卖家的保证金分账给平台和买家
TransferCase transferCase = TransferCase.EARNEST_MONEY_TO_BUYER;
TransferMoneyRequest tmReq = TransferMoneyRequest.builder()
.sellerUid(sellerUid)
.buyerOrderCode(orderCode)
.type(transferCase.getCode())
.transferCase(transferCase)
.swdType(SellerWalletDetail.Type.APPRAISE_FAIL)
.alarmConfig(AlarmConfig.APPRAISE_FAIL)
.build();
//先校验,提前把错误抛出
paymentService.transferMonCheck(tmReq);
//再分账
if(type==3 || type==4){
//将卖家的保证金扣掉10元后,剩余的钱退回给卖家
BigDecimal earnestMoney = sellerOrder.getEarnestMoney().subtract(new BigDecimal(miniFaultRejectPunishFee));
PaymentRequest refundReqOfSeller = refundEarnestMoney(SellerWalletDetail.Type.MINI_FAULT_REJECT,orderCode,sellerUid ,sellerOrder,skup,buyerUid,targetSoStatus,earnestMoney.doubleValue());
LOGGER.info("in appraiseFail,refund ok, refundReqOfSeller {}", refundReqOfSeller);
}else{
//将卖家的保证金分账给平台和买家
TransferCase transferCase = TransferCase.EARNEST_MONEY_TO_BUYER;
TransferMoneyRequest tmReq = TransferMoneyRequest.builder()
.sellerUid(sellerUid)
.buyerOrderCode(orderCode)
.type(transferCase.getCode())
.transferCase(transferCase)
.swdType(SellerWalletDetail.Type.APPRAISE_FAIL)
.alarmConfig(AlarmConfig.APPRAISE_FAIL)
.build();
//改成异步的分账,不关心分账执行结果
executorService.execute(()->{
LOGGER.info("in appraiseFail,begin transfer async");
transferService.transfer(tmReq);
});
//先校验,提前把错误抛出
paymentService.transferMonCheck(tmReq);
//再分账
//改成异步的分账,不关心分账执行结果
executorService.execute(()->{
LOGGER.info("in appraiseFail,begin transfer async");
transferService.transfer(tmReq);
});
}
BigDecimal goodsMoney = buyerOrder.getAmount();
/*
PaymentRequest req = PaymentRequest.builder().uid(buyerUid)
... ...
... ... @@ -92,6 +92,7 @@ redis.proxy.port=6379
order.seller.earnestmoney.min=1
order.seller.earnestmoney.max=200
order.seller.earnestmoney.miniFaultRejectPunishFee=0.05
order.seller.packageFee=0.1
order.seller.appraiseFee=0.1
order.seller.goodsPaymentRate=0.05
... ...
... ... @@ -65,6 +65,7 @@ alipay.notifyurl=${alipay.notifyurl}
order.seller.earnestmoney.min=${order.seller.earnestmoney.min}
order.seller.earnestmoney.max=${order.seller.earnestmoney.max}
order.seller.earnestmoney.miniFaultRejectPunishFee=${order.seller.earnestmoney.miniFaultRejectPunishFee}
order.seller.packageFee=${order.seller.packageFee}
order.seller.appraiseFee=${order.seller.appraiseFee}
order.seller.goodsPaymentRate=${order.seller.goodsPaymentRate}
... ...