Authored by chenchao

Merge branch 'dev_order' into test6.8.2

1 package com.yohoufo.order.model.request; 1 package com.yohoufo.order.model.request;
2 2
  3 +import com.yohoufo.dal.order.model.SellerWalletDetail;
3 import com.yohoufo.order.common.TransferCase; 4 import com.yohoufo.order.common.TransferCase;
4 import lombok.AllArgsConstructor; 5 import lombok.AllArgsConstructor;
5 import lombok.Data; 6 import lombok.Data;
@@ -30,6 +31,7 @@ public class TransferMoneyRequest { @@ -30,6 +31,7 @@ public class TransferMoneyRequest {
30 */ 31 */
31 private int type; 32 private int type;
32 33
  34 + private SellerWalletDetail.Type swdType;
33 35
34 private TransferCase transferCase; 36 private TransferCase transferCase;
35 37
@@ -8,6 +8,7 @@ import com.yohoufo.common.alarm.SmsAlarmEvent; @@ -8,6 +8,7 @@ import com.yohoufo.common.alarm.SmsAlarmEvent;
8 import com.yohoufo.common.utils.DateUtil; 8 import com.yohoufo.common.utils.DateUtil;
9 import com.yohoufo.dal.order.BuyerOrderMapper; 9 import com.yohoufo.dal.order.BuyerOrderMapper;
10 import com.yohoufo.dal.order.model.BuyerOrder; 10 import com.yohoufo.dal.order.model.BuyerOrder;
  11 +import com.yohoufo.dal.order.model.SellerWalletDetail;
11 import com.yohoufo.order.common.BillTradeStatus; 12 import com.yohoufo.order.common.BillTradeStatus;
12 import com.yohoufo.order.common.RefundCase; 13 import com.yohoufo.order.common.RefundCase;
13 import com.yohoufo.order.common.TransferCase; 14 import com.yohoufo.order.common.TransferCase;
@@ -75,7 +76,7 @@ public class SellerOrderCancelDeliverDelayMsgConsumer implements YhConsumer { @@ -75,7 +76,7 @@ public class SellerOrderCancelDeliverDelayMsgConsumer implements YhConsumer {
75 //将卖家的保证金分账给平台和买家 76 //将卖家的保证金分账给平台和买家
76 TransferMoneyRequest tmReq = TransferMoneyRequest.builder().buyerOrderCode(orderCode) 77 TransferMoneyRequest tmReq = TransferMoneyRequest.builder().buyerOrderCode(orderCode)
77 .type(TransferCase.SELLER_PLAY_BUYER.getCode()).transferCase(TransferCase.DELIVER_TIME_OUT) 78 .type(TransferCase.SELLER_PLAY_BUYER.getCode()).transferCase(TransferCase.DELIVER_TIME_OUT)
78 - .build(); 79 + .swdType(SellerWalletDetail.Type.SELLER_OVER_TIME).build();
79 transferService.transfer(tmReq); 80 transferService.transfer(tmReq);
80 // 81 //
81 BigDecimal goodsMoney = buyerOrder.getAmount(); 82 BigDecimal goodsMoney = buyerOrder.getAmount();
@@ -388,7 +388,10 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { @@ -388,7 +388,10 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
388 388
389 // 处罚保证金:总账修改 389 // 处罚保证金:总账修改
390 // 卖家取消、鉴定失败 390 // 卖家取消、鉴定失败
391 - public SellerWallet punishEarnest(Integer uid, BigDecimal money, MerchantOrderAttachInfo attach, long orderCode, SellerWalletDetail.Type type) { 391 + public SellerWallet punishEarnest( MerchantOrderAttachInfo attach, SellerWalletDetail.Type type) {
  392 + Long orderCode = attach.getOrderCode();
  393 + Integer uid = attach.getUid();
  394 + BigDecimal money = attach.getEarnestMoney();
392 return changeEarnest(uid, money, orderCode, attach, type); 395 return changeEarnest(uid, money, orderCode, attach, type);
393 } 396 }
394 397
@@ -303,7 +303,7 @@ public class AppraiseService { @@ -303,7 +303,7 @@ public class AppraiseService {
303 //将卖家的保证金分账给平台和买家 303 //将卖家的保证金分账给平台和买家
304 TransferCase transferCase = TransferCase.APPRAISE_FAIL; 304 TransferCase transferCase = TransferCase.APPRAISE_FAIL;
305 TransferMoneyRequest tmReq = TransferMoneyRequest.builder().buyerOrderCode(orderCode) 305 TransferMoneyRequest tmReq = TransferMoneyRequest.builder().buyerOrderCode(orderCode)
306 - .type(transferCase.getCode()).transferCase(transferCase).build(); 306 + .type(transferCase.getCode()).swdType(SellerWalletDetail.Type.APPRAISE_FAIL).transferCase(transferCase).build();
307 307
308 //先校验,提前把错误抛出 308 //先校验,提前把错误抛出
309 paymentService.transferMonCheck(tmReq); 309 paymentService.transferMonCheck(tmReq);
@@ -6,6 +6,7 @@ import com.yoho.core.dal.datasource.annotation.Database; @@ -6,6 +6,7 @@ import com.yoho.core.dal.datasource.annotation.Database;
6 import com.yoho.error.ServiceError; 6 import com.yoho.error.ServiceError;
7 import com.yoho.error.exception.ServiceException; 7 import com.yoho.error.exception.ServiceException;
8 import com.yoho.tools.common.beans.ApiResponse; 8 import com.yoho.tools.common.beans.ApiResponse;
  9 +import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo;
9 import com.yohobuy.ufo.model.order.bo.OrderInfo; 10 import com.yohobuy.ufo.model.order.bo.OrderInfo;
10 import com.yohobuy.ufo.model.order.common.OrderCodeType; 11 import com.yohobuy.ufo.model.order.common.OrderCodeType;
11 import com.yohobuy.ufo.model.order.constants.OrderConstant; 12 import com.yohobuy.ufo.model.order.constants.OrderConstant;
@@ -40,6 +41,7 @@ import com.yohoufo.order.service.pay.weixin.WeixinPayUFORealAppService; @@ -40,6 +41,7 @@ import com.yohoufo.order.service.pay.weixin.WeixinPayUFORealAppService;
40 import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; 41 import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
41 import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta; 42 import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta;
42 import com.yohoufo.order.utils.LoggerUtils; 43 import com.yohoufo.order.utils.LoggerUtils;
  44 +import com.yohoufo.order.utils.PaymentHelper;
43 import org.apache.commons.collections.CollectionUtils; 45 import org.apache.commons.collections.CollectionUtils;
44 import org.apache.commons.lang3.StringUtils; 46 import org.apache.commons.lang3.StringUtils;
45 import org.slf4j.Logger; 47 import org.slf4j.Logger;
@@ -50,6 +52,7 @@ import org.springframework.stereotype.Service; @@ -50,6 +52,7 @@ import org.springframework.stereotype.Service;
50 52
51 import java.math.BigDecimal; 53 import java.math.BigDecimal;
52 import java.util.Date; 54 import java.util.Date;
  55 +import java.util.Objects;
53 56
54 import javax.annotation.PostConstruct; 57 import javax.annotation.PostConstruct;
55 58
@@ -442,7 +445,18 @@ public class PaymentServiceImpl implements IPaymentService { @@ -442,7 +445,18 @@ public class PaymentServiceImpl implements IPaymentService {
442 445
443 } 446 }
444 447
  448 + private void punishEarnest(SellerWalletDetail.Type swdType, SellerOrder sellerOrder){
  449 + Integer sellerUid = sellerOrder.getUid();
  450 + Long sellerOrderCode = sellerOrder.getOrderCode();
  451 + Integer skup = sellerOrder.getSkup();
  452 + if (Objects.nonNull(swdType) && PaymentHelper.isWallet(sellerOrder.getPayment())){
445 453
  454 + MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(sellerUid)
  455 + .orderCode(sellerOrderCode).skup(skup).earnestMoney(sellerOrder.getEarnestMoney())
  456 + .type(swdType.getValue()).build();
  457 + merchantOrderPaymentService.punishEarnest( moai, swdType);
  458 + }
  459 + }
446 460
447 /** 461 /**
448 * <pre> 462 * <pre>
@@ -488,17 +502,19 @@ public class PaymentServiceImpl implements IPaymentService { @@ -488,17 +502,19 @@ public class PaymentServiceImpl implements IPaymentService {
488 } 502 }
489 503
490 // 卖家订单检查 504 // 卖家订单检查
491 - SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(buyerOrderGoods.getSkup()); 505 + Integer skup = buyerOrderGoods.getSkup();
  506 + SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(skup);
492 if (sellerOrder == null){ 507 if (sellerOrder == null){
493 logger.warn("transferMonErr getOrderInfo seller order not exist, skup is {}", buyerOrderGoods.getSkup()); 508 logger.warn("transferMonErr getOrderInfo seller order not exist, skup is {}", buyerOrderGoods.getSkup());
494 throw new ServiceException(ServiceError.ORDER_NULL); 509 throw new ServiceException(ServiceError.ORDER_NULL);
495 } 510 }
496 -  
497 - long sellerOrderCode = sellerOrder.getOrderCode(); 511 + Integer sellerUid = sellerOrder.getUid();
  512 + long sellerOrderCode = sellerOrder.getOrderCode();
  513 + punishEarnest(request.getSwdType(), sellerOrder);
498 TargetUserType targetUserType = (transferType == TransferCase.APPRAISE_FAIL.getCode() 514 TargetUserType targetUserType = (transferType == TransferCase.APPRAISE_FAIL.getCode()
499 || transferType == TransferCase.SELLER_PLAY_BUYER.getCode()) ? TargetUserType.buyer : TargetUserType.seller; 515 || transferType == TransferCase.SELLER_PLAY_BUYER.getCode()) ? TargetUserType.buyer : TargetUserType.seller;
500 //Integer targetUserType = (transferType == 2 || transferType == 3) ? 1 : 2; 516 //Integer targetUserType = (transferType == 2 || transferType == 3) ? 1 : 2;
501 - Integer targetUid = targetUserType == TargetUserType.buyer ? buyerOrder.getUid() : sellerOrder.getUid(); 517 + Integer targetUid = targetUserType == TargetUserType.buyer ? buyerOrder.getUid() : sellerUid;
502 518
503 if (targetUid == null || targetUid < 1) { 519 if (targetUid == null || targetUid < 1) {
504 logger.warn("transferMonErr uid {} 不合法", targetUid); 520 logger.warn("transferMonErr uid {} 不合法", targetUid);
@@ -363,7 +363,7 @@ public class SellerOrderCancelService { @@ -363,7 +363,7 @@ public class SellerOrderCancelService {
363 //分赃(分账) 有待考虑使用2比对 363 //分赃(分账) 有待考虑使用2比对
364 TransferCase transferCase = TransferCase.SELLER_PLAY_BUYER; 364 TransferCase transferCase = TransferCase.SELLER_PLAY_BUYER;
365 TransferMoneyRequest tmReq = TransferMoneyRequest.builder().buyerOrderCode(buyerOrderCode) 365 TransferMoneyRequest tmReq = TransferMoneyRequest.builder().buyerOrderCode(buyerOrderCode)
366 - .type(transferCase.getCode()).transferCase(transferCase).build(); 366 + .type(transferCase.getCode()).swdType(SellerWalletDetail.Type.SELLER_CANCEL).transferCase(transferCase).build();
367 transferService.transfer(tmReq); 367 transferService.transfer(tmReq);
368 PayRefundBo refundResp = payRefundService.refund(refundReq, bleb); 368 PayRefundBo refundResp = payRefundService.refund(refundReq, bleb);
369 369