Authored by chenchao

Merge branch 'dev_order' into test6.8.2

package com.yohoufo.order.model.request;
import com.yohoufo.dal.order.model.SellerWalletDetail;
import com.yohoufo.order.common.TransferCase;
import lombok.AllArgsConstructor;
import lombok.Data;
... ... @@ -30,6 +31,7 @@ public class TransferMoneyRequest {
*/
private int type;
private SellerWalletDetail.Type swdType;
private TransferCase transferCase;
... ...
... ... @@ -8,6 +8,7 @@ import com.yohoufo.common.alarm.SmsAlarmEvent;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.BuyerOrderMapper;
import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.dal.order.model.SellerWalletDetail;
import com.yohoufo.order.common.BillTradeStatus;
import com.yohoufo.order.common.RefundCase;
import com.yohoufo.order.common.TransferCase;
... ... @@ -75,7 +76,7 @@ public class SellerOrderCancelDeliverDelayMsgConsumer implements YhConsumer {
//将卖家的保证金分账给平台和买家
TransferMoneyRequest tmReq = TransferMoneyRequest.builder().buyerOrderCode(orderCode)
.type(TransferCase.SELLER_PLAY_BUYER.getCode()).transferCase(TransferCase.DELIVER_TIME_OUT)
.build();
.swdType(SellerWalletDetail.Type.SELLER_OVER_TIME).build();
transferService.transfer(tmReq);
//
BigDecimal goodsMoney = buyerOrder.getAmount();
... ...
... ... @@ -388,7 +388,10 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
// 处罚保证金:总账修改
// 卖家取消、鉴定失败
public SellerWallet punishEarnest(Integer uid, BigDecimal money, MerchantOrderAttachInfo attach, long orderCode, SellerWalletDetail.Type type) {
public SellerWallet punishEarnest( MerchantOrderAttachInfo attach, SellerWalletDetail.Type type) {
Long orderCode = attach.getOrderCode();
Integer uid = attach.getUid();
BigDecimal money = attach.getEarnestMoney();
return changeEarnest(uid, money, orderCode, attach, type);
}
... ...
... ... @@ -303,7 +303,7 @@ public class AppraiseService {
//将卖家的保证金分账给平台和买家
TransferCase transferCase = TransferCase.APPRAISE_FAIL;
TransferMoneyRequest tmReq = TransferMoneyRequest.builder().buyerOrderCode(orderCode)
.type(transferCase.getCode()).transferCase(transferCase).build();
.type(transferCase.getCode()).swdType(SellerWalletDetail.Type.APPRAISE_FAIL).transferCase(transferCase).build();
//先校验,提前把错误抛出
paymentService.transferMonCheck(tmReq);
... ...
... ... @@ -6,6 +6,7 @@ import com.yoho.core.dal.datasource.annotation.Database;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yoho.tools.common.beans.ApiResponse;
import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo;
import com.yohobuy.ufo.model.order.bo.OrderInfo;
import com.yohobuy.ufo.model.order.common.OrderCodeType;
import com.yohobuy.ufo.model.order.constants.OrderConstant;
... ... @@ -40,6 +41,7 @@ import com.yohoufo.order.service.pay.weixin.WeixinPayUFORealAppService;
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta;
import com.yohoufo.order.utils.LoggerUtils;
import com.yohoufo.order.utils.PaymentHelper;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
... ... @@ -50,6 +52,7 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Objects;
import javax.annotation.PostConstruct;
... ... @@ -442,7 +445,18 @@ public class PaymentServiceImpl implements IPaymentService {
}
private void punishEarnest(SellerWalletDetail.Type swdType, SellerOrder sellerOrder){
Integer sellerUid = sellerOrder.getUid();
Long sellerOrderCode = sellerOrder.getOrderCode();
Integer skup = sellerOrder.getSkup();
if (Objects.nonNull(swdType) && PaymentHelper.isWallet(sellerOrder.getPayment())){
MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(sellerUid)
.orderCode(sellerOrderCode).skup(skup).earnestMoney(sellerOrder.getEarnestMoney())
.type(swdType.getValue()).build();
merchantOrderPaymentService.punishEarnest( moai, swdType);
}
}
/**
* <pre>
... ... @@ -488,17 +502,19 @@ public class PaymentServiceImpl implements IPaymentService {
}
// 卖家订单检查
SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(buyerOrderGoods.getSkup());
Integer skup = buyerOrderGoods.getSkup();
SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(skup);
if (sellerOrder == null){
logger.warn("transferMonErr getOrderInfo seller order not exist, skup is {}", buyerOrderGoods.getSkup());
throw new ServiceException(ServiceError.ORDER_NULL);
}
Integer sellerUid = sellerOrder.getUid();
long sellerOrderCode = sellerOrder.getOrderCode();
punishEarnest(request.getSwdType(), sellerOrder);
TargetUserType targetUserType = (transferType == TransferCase.APPRAISE_FAIL.getCode()
|| transferType == TransferCase.SELLER_PLAY_BUYER.getCode()) ? TargetUserType.buyer : TargetUserType.seller;
//Integer targetUserType = (transferType == 2 || transferType == 3) ? 1 : 2;
Integer targetUid = targetUserType == TargetUserType.buyer ? buyerOrder.getUid() : sellerOrder.getUid();
Integer targetUid = targetUserType == TargetUserType.buyer ? buyerOrder.getUid() : sellerUid;
if (targetUid == null || targetUid < 1) {
logger.warn("transferMonErr uid {} 不合法", targetUid);
... ...
... ... @@ -363,7 +363,7 @@ public class SellerOrderCancelService {
//分赃(分账) 有待考虑使用2比对
TransferCase transferCase = TransferCase.SELLER_PLAY_BUYER;
TransferMoneyRequest tmReq = TransferMoneyRequest.builder().buyerOrderCode(buyerOrderCode)
.type(transferCase.getCode()).transferCase(transferCase).build();
.type(transferCase.getCode()).swdType(SellerWalletDetail.Type.SELLER_CANCEL).transferCase(transferCase).build();
transferService.transfer(tmReq);
PayRefundBo refundResp = payRefundService.refund(refundReq, bleb);
... ...