Authored by LUOXC

Merge branch 'dev6.8.9' into test6.8.9

... ... @@ -15,7 +15,7 @@ import lombok.experimental.Builder;
@AllArgsConstructor
public class BuyerRefundCouponEvent extends Event {
public enum BizCase{
APPRAISE_FAIL, SELLER_DELIVER_TIMEOUT, SELLER_PLAY_BUYER, BUYER_CANCEL_BSD, BUYER_CANCEL_BDR, SELLER_SHAM_SEND_OUT
APPRAISE_FAIL, APPRAISE_UNSURE,SELLER_DELIVER_TIMEOUT, SELLER_PLAY_BUYER, BUYER_CANCEL_BSD, BUYER_CANCEL_BDR, SELLER_SHAM_SEND_OUT
}
Integer uid;
... ...
package com.yohoufo.order.mq.consumer;
import com.alibaba.fastjson.JSONObject;
import com.yoho.core.rabbitmq.YhConsumer;
import com.yohobuy.ufo.model.promotion.response.CrmCouponSendResultBean;
import com.yohoufo.order.service.impl.function.BuyerNoticeSender;
import com.yohoufo.order.service.proxy.InBoxFacade;
import com.yohoufo.order.utils.LoggerUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Objects;
/**
* @author LUOXC
* @date 2019/3/22 17:57
*/
@Component
public class BuyerCouponSendResultForAppraiseUnsureConsumer implements YhConsumer {
private Logger logger = LoggerUtils.getMqConsumerLogger();
@Autowired
private InBoxFacade inBoxFacade;
@Override
public void handleMessage(Object o) throws Exception {
try {
logger.info("BuyerCouponSendResultForAppraiseUnsureConsumer receive msg:{}", o);
if (Objects.isNull(o)) {
return;
}
CrmCouponSendResultBean message = JSONObject.parseObject(o.toString(), CrmCouponSendResultBean.class);
if (Objects.isNull(message)) {
throw new RuntimeException("parse message result is null");
}
BuyerNoticeSender.Request request = JSONObject.parseObject(message.getParams(), BuyerNoticeSender.Request.class);
if (Objects.isNull(request) || Objects.isNull(request.getUid()) || Objects.isNull(request.getOrderCode())) {
throw new RuntimeException("parse message params result is null");
}
// 通知买家商品无法鉴定
inBoxFacade.noticeBuyerAppraiseUnsure(request);
} catch (Exception e) {
logger.info("BuyerCouponSendResultForAppraiseUnsureConsumer fail receive msg:{}", o, e);
}
}
}
... ...
package com.yohoufo.order.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.google.common.collect.Range;
import com.yoho.core.rabbitmq.YhProducer;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.bo.AppraiseExpressInfoBo;
import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo;
import com.yohobuy.ufo.model.order.common.*;
import com.yohobuy.ufo.model.promotion.request.CouponSendMqBean;
import com.yohobuy.ufo.model.promotion.request.CouponSendType;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.common.utils.DateUtil;
... ... @@ -14,7 +19,6 @@ import com.yohoufo.dal.order.*;
import com.yohoufo.dal.order.model.*;
import com.yohoufo.dal.product.ProductMapper;
import com.yohoufo.dal.product.model.Product;
import com.yohoufo.order.common.Payment;
import com.yohoufo.order.common.RefundCase;
import com.yohoufo.order.common.TransferCase;
import com.yohoufo.order.constants.AlarmConfig;
... ... @@ -44,14 +48,16 @@ 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 javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
... ... @@ -126,6 +132,9 @@ public class AppraiseService {
@Autowired
private ProductMapper productMapper;
@Resource(name = "tradeMqProducer")
private YhProducer tradeMqProducer;
/**
* 瑕疵确认不通过的情况,卖家的保证金扣掉一部分给平台,暂定0元
*/
... ... @@ -133,45 +142,44 @@ public class AppraiseService {
private Double miniFaultRejectPunishFee = 0D;
/**
* 触发物流
*/
public void triggerSellerToPlatformExpress(AppraiseExpressInfoBo appraiseExpressInfoBo ){
LOGGER.info("AppraiseService triggerSellerToPlatformExpress enter , appraiseExpressInfoBo {} ",appraiseExpressInfoBo);
public void triggerSellerToPlatformExpress(AppraiseExpressInfoBo appraiseExpressInfoBo) {
LOGGER.info("AppraiseService triggerSellerToPlatformExpress enter , appraiseExpressInfoBo {} ", appraiseExpressInfoBo);
String wayBillCode = appraiseExpressInfoBo.getWayBillCode();
Long orderCode = appraiseExpressInfoBo.getOrderCode();
if(StringUtils.isBlank(wayBillCode)||orderCode==null){
if (StringUtils.isBlank(wayBillCode) || orderCode == null) {
LOGGER.warn("triggerSellerToPlatformExpress error param {}", appraiseExpressInfoBo);
throw new ServiceException(ServiceError.PARAM_ERROR);
}
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
if (buyerOrder == null){
if (buyerOrder == null) {
LOGGER.warn("triggerSellerToPlatformExpress getOrderInfo order not exist, orderCode {}", orderCode);
throw new ServiceException(ServiceError.ORDER_NULL);
}
//只有卖家已发货才能更改物流,对应的物流类型:expressType = 1
if(buyerOrder.getStatus().byteValue() == OrderStatus.SELLER_SEND_OUT.getCode()) {
ExpressRecord record = expressRecordMapper.selectByOrderCodeAndExpressType(orderCode,EnumExpressType.EXPRESS_TYPE_1.getCode());
LOGGER.info("triggerSellerToPlatformExpress begin trigger , orderCode {} ,record = {}", orderCode,record);
if(record!=null&&StringUtils.equals(wayBillCode,record.getWaybillCode())){
if (buyerOrder.getStatus().byteValue() == OrderStatus.SELLER_SEND_OUT.getCode()) {
ExpressRecord record = expressRecordMapper.selectByOrderCodeAndExpressType(orderCode, EnumExpressType.EXPRESS_TYPE_1.getCode());
LOGGER.info("triggerSellerToPlatformExpress begin trigger , orderCode {} ,record = {}", orderCode, record);
if (record != null && StringUtils.equals(wayBillCode, record.getWaybillCode())) {
Integer uid = record.getUid();
String mobile ="";
AppraiseAddressResp appraiseAddressResp =appraiseAddressService.queryInitAddressByDepotNum(record.getDepotNum());
if(appraiseAddressResp!=null){
String mobile = "";
AppraiseAddressResp appraiseAddressResp = appraiseAddressService.queryInitAddressByDepotNum(record.getDepotNum());
if (appraiseAddressResp != null) {
mobile = appraiseAddressResp.getMobile();
}
expressInfoService.triggerExpressMQ(uid,record.getLogisticsType(),orderCode,wayBillCode,mobile);
}else{
LOGGER.warn("triggerSellerToPlatformExpress begin trigger fail ,express record is null or wayBillCode not the same, orderCode {},changed wayBillCode {},record {} ", orderCode,wayBillCode,record);
expressInfoService.triggerExpressMQ(uid, record.getLogisticsType(), orderCode, wayBillCode, mobile);
} else {
LOGGER.warn("triggerSellerToPlatformExpress begin trigger fail ,express record is null or wayBillCode not the same, orderCode {},changed wayBillCode {},record {} ", orderCode, wayBillCode, record);
}
}else{
LOGGER.info("triggerSellerToPlatformExpress not trigger because of error status , orderCode {} ,status {}", orderCode,buyerOrder.getStatus());
} else {
LOGGER.info("triggerSellerToPlatformExpress not trigger because of error status , orderCode {} ,status {}", orderCode, buyerOrder.getStatus());
}
}
... ... @@ -180,22 +188,22 @@ public class AppraiseService {
* 鉴定通过 -- 待收货
* 瑕疵接收 -- 待收货
*/
public void deliveryGoodsToBuyer(AppraiseExpressInfoBo appraiseExpressInfoBo){
public void deliveryGoodsToBuyer(AppraiseExpressInfoBo appraiseExpressInfoBo) {
LOGGER.info("deliveryGoodsToBuyer enter req {}", appraiseExpressInfoBo);
final OrderStatus expectOrderStatus ;
final OrderStatus expectOrderStatus;
final OrderStatus targetOrderStatus = OrderStatus.WAITING_RECEIVE;
Long orderCode = appraiseExpressInfoBo.getOrderCode();
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
if (buyerOrder == null){
if (buyerOrder == null) {
LOGGER.warn("deliveryGoodsToBuyer getOrderInfo order not exist, orderCode is {}", orderCode);
throw new ServiceException(ServiceError.ORDER_NULL);
}
if(buyerOrder.getStatus() == OrderStatus.JUDGE_PASS.getCode()){
if (buyerOrder.getStatus() == OrderStatus.JUDGE_PASS.getCode()) {
expectOrderStatus = OrderStatus.JUDGE_PASS;
}else if(buyerOrder.getStatus() == OrderStatus.MINI_FAULT_ACCEPT.getCode()){
} else if (buyerOrder.getStatus() == OrderStatus.MINI_FAULT_ACCEPT.getCode()) {
expectOrderStatus = OrderStatus.MINI_FAULT_ACCEPT;
}else{
} else {
LOGGER.warn("in deliveryGoodsToBuyer, buyer Order orderCode {} pstatus {}, expect Order Status JUDGE_PASS or MINI_FAULT_ACCEPT ",
orderCode, buyerOrder.getStatus());
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
... ... @@ -204,23 +212,23 @@ public class AppraiseService {
Integer buyerUid = buyerOrder.getUid();
int updateBuyerCnt = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid,
expectOrderStatus.getCode(), targetOrderStatus.getCode(), DateUtil.getCurrentTimeSecond());
if (updateBuyerCnt == 1){
if (updateBuyerCnt == 1) {
//发货,这个时候产生:买家确认收货的mq
BuyerConfirmEvent buyerConfirmEvent = BuyerConfirmEvent.builder().uid(buyerUid).orderCode(orderCode).build();
EventBusPublisher.publishEvent(buyerConfirmEvent);
//记录物流信息
//发物流
expressInfoService.deliverGoods(buyerUid, appraiseExpressInfoBo.getExpressCompanyId(), orderCode, appraiseExpressInfoBo.getWayBillCode(), appraiseExpressInfoBo.getDepotNum(),appraiseExpressInfoBo.getMobile());
expressInfoService.deliverGoods(buyerUid, appraiseExpressInfoBo.getExpressCompanyId(), orderCode, appraiseExpressInfoBo.getWayBillCode(), appraiseExpressInfoBo.getDepotNum(), appraiseExpressInfoBo.getMobile());
//记录订单的状态变更信息
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(),targetOrderStatus.getCode());
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetOrderStatus.getCode());
//清缓存
SellerOrderGoods sellerOrderGoods = cleanCacheAfterUpdateStatus(buyerOrder.getOrderCode(),buyerOrder.getUid(),buyerOrder.getSellerUid());
Product product =Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null);
inBoxFacade.noticeBuyerWhenDeliveryGoodsToBuyer(buyerUid, orderCode, sellerOrderGoods,product);
}else{
SellerOrderGoods sellerOrderGoods = cleanCacheAfterUpdateStatus(buyerOrder.getOrderCode(), buyerOrder.getUid(), buyerOrder.getSellerUid());
Product product = Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null);
inBoxFacade.noticeBuyerWhenDeliveryGoodsToBuyer(buyerUid, orderCode, sellerOrderGoods, product);
} else {
LOGGER.warn("in deliveryGoodsToBuyer update status number zero, buyer Order orderCode {} pstatus {}, expect Order Status {}",
orderCode, buyerOrder.getStatus(), expectOrderStatus);
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
... ... @@ -232,75 +240,75 @@ public class AppraiseService {
* (1)记录物流
* (2)消息 :寄回有4种情形: 鉴定不通过、质检不通过的商品、瑕疵不接受的 、瑕疵不接受(超时)的
*/
public void returnBackOrderCauseOfJudgeFailure(AppraiseExpressInfoBo appraiseExpressInfoBo){
public void returnBackOrderCauseOfJudgeFailure(AppraiseExpressInfoBo appraiseExpressInfoBo) {
Integer expressCompanyId = appraiseExpressInfoBo.getExpressCompanyId();
Long orderCode=appraiseExpressInfoBo.getOrderCode();
String wayBillCode=appraiseExpressInfoBo.getWayBillCode();
Integer depotNum=appraiseExpressInfoBo.getDepotNum();
String mobile=appraiseExpressInfoBo.getMobile();
Long orderCode = appraiseExpressInfoBo.getOrderCode();
String wayBillCode = appraiseExpressInfoBo.getWayBillCode();
Integer depotNum = appraiseExpressInfoBo.getDepotNum();
String mobile = appraiseExpressInfoBo.getMobile();
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
if (buyerOrder == null){
if (buyerOrder == null) {
LOGGER.warn("returnBackOrderCauseOfJudgeFailure getOrderInfo order not exist, orderCode {}", orderCode);
throw new ServiceException(ServiceError.ORDER_NULL);
}
OrderStatus expectStatus ;
OrderStatus expectStatus;
int type = 0 ;//鉴定不通过
if (buyerOrder.getStatus() == OrderStatus.CHECKING_FAKE.getCode()){
int type = 0;//鉴定不通过
if (buyerOrder.getStatus() == OrderStatus.CHECKING_FAKE.getCode()) {
expectStatus = OrderStatus.CHECKING_FAKE;
//TODO 新版本6.8.7以后,判断type可直接根据状态,而不再需要根据qualityCheck,可去掉以下if判断
//TODO 现在6.8.6.5手机质检版本上线,还需要保留,存在过度订单,鉴定不通过都是类型:13
QualityCheck qualityCheck = qualityCheckMapper.selectByOrderCode(orderCode);
if(qualityCheck!=null&&qualityCheck.getType()!=null){
if(EnumQualityCheckType.CHECK_NOT_PASS.getCode().intValue()==qualityCheck.getType().intValue()){
if (qualityCheck != null && qualityCheck.getType() != null) {
if (EnumQualityCheckType.CHECK_NOT_PASS.getCode().intValue() == qualityCheck.getType().intValue()) {
type = 1;//质检不通过
}else if(EnumQualityCheckType.MINI_FAULT.getCode().intValue()==qualityCheck.getType().intValue()){
if(qualityCheck.getStatus()!=null){
if(EnumQualityCheckStatus.REJECT_BY_BUYER.getCode().intValue()==qualityCheck.getStatus().intValue()){
} else if (EnumQualityCheckType.MINI_FAULT.getCode().intValue() == qualityCheck.getType().intValue()) {
if (qualityCheck.getStatus() != null) {
if (EnumQualityCheckStatus.REJECT_BY_BUYER.getCode().intValue() == qualityCheck.getStatus().intValue()) {
type = 2;//用户不接受瑕疵
}else if(EnumQualityCheckStatus.REJECT_BY_OUTER_TIME.getCode().intValue()==qualityCheck.getStatus().intValue()){
} else if (EnumQualityCheckStatus.REJECT_BY_OUTER_TIME.getCode().intValue() == qualityCheck.getStatus().intValue()) {
type = 3;//用户不接受超时
}
}
}
}
}else if(buyerOrder.getStatus() == OrderStatus.QUALITY_CHECK_FAKE.getCode()){
} else if (buyerOrder.getStatus() == OrderStatus.QUALITY_CHECK_FAKE.getCode()) {
type = 1;//质检不通过
expectStatus = OrderStatus.QUALITY_CHECK_FAKE;
}else if(buyerOrder.getStatus() == OrderStatus.MINI_FAULT_REJECT.getCode()){
} else if (buyerOrder.getStatus() == OrderStatus.MINI_FAULT_REJECT.getCode()) {
type = 2;//用户不接受瑕疵
expectStatus = OrderStatus.MINI_FAULT_REJECT;
}else if(buyerOrder.getStatus() == OrderStatus.MINI_FAULT_OUT_TIME_REJECT.getCode()){
} else if (buyerOrder.getStatus() == OrderStatus.MINI_FAULT_OUT_TIME_REJECT.getCode()) {
type = 3;//用户不接受超时
expectStatus = OrderStatus.MINI_FAULT_OUT_TIME_REJECT;
}else{
} else {
//if (buyerOrder.getStatus() != expectStatus.getCode()){
LOGGER.warn("returnBackOrderCauseOfJudgeFailure expectStatus CHECKING_FAKE QUALITY_CHECK_FAKE MINI_FAULT_REJECT or MINI_FAULT_OUT_TIME_REJECT, actual status {}, orderCode {}",
buyerOrder.getStatus(), orderCode);
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
}
LOGGER.info("returnBackOrderCauseOfJudgeFailure check status ok expectStatus {}, actual status {}, orderCode {}",expectStatus,
LOGGER.info("returnBackOrderCauseOfJudgeFailure check status ok expectStatus {}, actual status {}, orderCode {}", expectStatus,
buyerOrder.getStatus(), orderCode);
//更新物流信息
int sellerUid = buyerOrder.getSellerUid();
expressInfoService.returnBackOrderCauseOfJudgeFailure(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum,mobile);
expressInfoService.returnBackOrderCauseOfJudgeFailure(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile);
//清缓存
SellerOrderGoods sellerOrderGoods = cleanCacheAfterUpdateStatus(buyerOrder.getOrderCode(),buyerOrder.getUid(),buyerOrder.getSellerUid());
SellerOrderGoods sellerOrderGoods = cleanCacheAfterUpdateStatus(buyerOrder.getOrderCode(), buyerOrder.getUid(), buyerOrder.getSellerUid());
inBoxFacade.sellerQualityCheckNotPass_send_back(sellerOrderGoods,orderCode,wayBillCode, type);
inBoxFacade.sellerQualityCheckNotPass_send_back(sellerOrderGoods, orderCode, wayBillCode, type);
}
private SellerOrderGoods cleanCacheAfterUpdateStatus(long orderCode,int uid,int sellerUid){
private SellerOrderGoods cleanCacheAfterUpdateStatus(long orderCode, int uid, int sellerUid) {
BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(uid, orderCode);
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(bog.getSkup());
LOGGER.info("in appraise service cleanCacheAfterUpdateStatus begin clean cache orderCode {},uid {} ,sellerUid {}", orderCode,uid,sellerUid);
LOGGER.info("in appraise service cleanCacheAfterUpdateStatus begin clean cache orderCode {},uid {} ,sellerUid {}", orderCode, uid, sellerUid);
cacheCleaner.delete(Arrays.asList(CacheKeyBuilder.orderListKey(sellerUid, TabType.SELL.getValue()),
CacheKeyBuilder.orderListKey(uid, TabType.BUY.getValue()),
CacheKeyBuilder.sellerOrderDetailKey(sellerOrderGoods),
... ... @@ -310,27 +318,28 @@ public class AppraiseService {
ErpBuyerOrderEvent event = new ErpBuyerOrderEvent(uid);
EventBusPublisher.publishEvent(event);
return sellerOrderGoods;
return sellerOrderGoods;
}
/**
* 直接退回商品,记录物流,不涉及状态更改
*
* @param expressCompanyId
* @param orderCode
* @param wayBillCode
* @return
*/
public ApiResponse returnBackCauseOfBuyerCancelAfterSellerSendOut(Integer expressCompanyId, Long orderCode, String wayBillCode, Integer depotNum,String mobile){
ApiResponse apiResponse=new ApiResponse();
public ApiResponse returnBackCauseOfBuyerCancelAfterSellerSendOut(Integer expressCompanyId, Long orderCode, String wayBillCode, Integer depotNum, String mobile) {
ApiResponse apiResponse = new ApiResponse();
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
if (buyerOrder == null){
if (buyerOrder == null) {
LOGGER.warn("returnBack getOrderInfo order not exist, orderCode {}", orderCode);
throw new ServiceException(ServiceError.ORDER_NULL);
}
OrderStatus expectStatus = OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE;
if (buyerOrder.getStatus() != expectStatus.getCode()){
if (buyerOrder.getStatus() != expectStatus.getCode()) {
LOGGER.warn("returnBack expectStatus {}, actual status {}, orderCode {}", expectStatus,
buyerOrder.getStatus(), orderCode);
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
... ... @@ -338,22 +347,23 @@ public class AppraiseService {
//记录物流信息
int sellerUid = buyerOrder.getSellerUid();
expressInfoService.returnBackCauseOfBuyerCancelAfterSellerSendOut(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum,mobile);
expressInfoService.returnBackCauseOfBuyerCancelAfterSellerSendOut(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile);
//发送消息
inBoxFacade.sendCancelledProductToSellerByCenter(sellerUid,wayBillCode);
inBoxFacade.sendCancelledProductToSellerByCenter(sellerUid, wayBillCode);
//清缓存
cleanCacheAfterUpdateStatus(buyerOrder.getOrderCode(),buyerOrder.getUid(),buyerOrder.getSellerUid());
cleanCacheAfterUpdateStatus(buyerOrder.getOrderCode(), buyerOrder.getUid(), buyerOrder.getSellerUid());
return apiResponse;
}
/**
* 接受瑕疵
*
* @param orderRequest
*/
public void miniFaultAccept(OrderRequest orderRequest){
public void miniFaultAccept(OrderRequest orderRequest) {
LOGGER.info("Buyer Order miniFaultAccept (OrderRequest) {}", orderRequest);
//订单状态变更为鉴定中 ,记录调拨的物流信息 ,发消息 ,
OrderStatus expectStatus = OrderStatus.MINI_FAULT_WAITING;
... ... @@ -364,26 +374,26 @@ public class AppraiseService {
// 参数检查
if (orderRequest.getUid() < 0
|| orderRequest.getOrderCode() < 0){
|| orderRequest.getOrderCode() < 0) {
LOGGER.warn("miniFaultNotAccept check uid or orderCode empty");
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
}
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCodeUid(orderRequest.getOrderCode(), orderRequest.getUid());
if (buyerOrder == null){
if (buyerOrder == null) {
LOGGER.warn("miniFaultNotAccept check orderCode exist, uid is {}, orderCode is {}",
orderRequest.getUid(), orderRequest.getOrderCode() );
orderRequest.getUid(), orderRequest.getOrderCode());
throw new ServiceException(ServiceError.ORDER_NULL);
}
if (buyerOrder.getStatus() != expectStatus.getCode()){
if (buyerOrder.getStatus() != expectStatus.getCode()) {
LOGGER.warn("miniFaultNotAccept expectStatus {}, actual status {}, orderCode {}", expectStatus,
buyerOrder.getStatus(), buyerOrder.getOrderCode());
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
}
//checkStatusWithMoreExpectStatus(buyerOrder,orderRequest, expectStatusList);
int buyerUid=orderRequest.getUid();
long orderCode=orderRequest.getOrderCode();
int buyerUid = orderRequest.getUid();
long orderCode = orderRequest.getOrderCode();
int sellerUid = buyerOrder.getSellerUid();
if (1 == buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid,
expectStatus.getCode(),
... ... @@ -391,12 +401,12 @@ public class AppraiseService {
DateUtil.getCurrentTimeSecond())) {
LOGGER.info("Buyer Order miniFaultAccept (OrderRequest) {} ,update status success ", orderRequest);
//更新瑕疵确认结果
int updateNum = qualityCheckMapper.updateByOrderCode(orderCode,EnumQualityCheckStatus.PASS.getCode(),DateUtil.getCurrentTimeSecond());
LOGGER.info("Buyer Order miniFaultAccept (OrderRequest) {} ,update quality check record status num {} ", orderRequest,updateNum);
int updateNum = qualityCheckMapper.updateByOrderCode(orderCode, EnumQualityCheckStatus.PASS.getCode(), DateUtil.getCurrentTimeSecond());
LOGGER.info("Buyer Order miniFaultAccept (OrderRequest) {} ,update quality check record status num {} ", orderRequest, updateNum);
//记录订单的状态变更信息
LOGGER.info("in judgeCenterPass record status change, orderCode {},uid {} ,sellerUid {}", orderCode,buyerUid,sellerUid);
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(),targetStatus.getCode());
LOGGER.info("in judgeCenterPass record status change, orderCode {},uid {} ,sellerUid {}", orderCode, buyerUid, sellerUid);
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetStatus.getCode());
BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(buyerUid, orderCode);
int skup = bog.getSkup();
... ... @@ -409,12 +419,12 @@ public class AppraiseService {
/**
* 更新卖家订单状态,
*/
SellerOrderGoods sellerOrderGoods = updateSellerOrderStatusAndCleanCache(sellerUid ,sellerOrderCode,expectSOStatus,targetSoStatus,
SellerOrderGoods sellerOrderGoods = updateSellerOrderStatusAndCleanCache(sellerUid, sellerOrderCode, expectSOStatus, targetSoStatus,
skup, orderCode, buyerUid);
//退款给卖家(仅退一次)
PaymentRequest refundReqOfSeller = operateMoneyWhenOk(buyerUid,orderCode,skup,sellerOrder,targetSoStatus);
PaymentRequest refundReqOfSeller = operateMoneyWhenOk(buyerUid, orderCode, skup, sellerOrder, targetSoStatus);
//记录新的调拨信息
... ... @@ -422,31 +432,32 @@ public class AppraiseService {
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.mini_fault_accept;
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
expressInfoService.saveOperateTransferExpressInfo(sellerUid, orderCode, expressType.getCode(), expressDataType, operateTransferCode);
// 新的变更,买家接受,直接退款,因此还需要增加一个鉴定通过的物流 2019-2-28 craig
expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
expressDataType = EnumExpressDataType.operate_transfer;
operateTransferCode = EnumExpressDataOperateTransferCode.judge_pass;
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
expressInfoService.saveOperateTransferExpressInfo(sellerUid, orderCode, expressType.getCode(), expressDataType, operateTransferCode);
cleanCacheAfterUpdateStatus(orderCode,buyerUid,sellerUid);
cleanCacheAfterUpdateStatus(orderCode, buyerUid, sellerUid);
//记录操作记录
orderOperateRecordService.addRecord(orderCode,"买家操作",OperateTypeEnum.OPERATE_TYPE_QUALITY_MINI_FAULT_PASS);
orderOperateRecordService.addRecord(orderCode, "买家操作", OperateTypeEnum.OPERATE_TYPE_QUALITY_MINI_FAULT_PASS);
//TODO 发消息 瑕疵接收,只给卖家发消息
Product product =Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null);
inBoxFacade.appraisePassNoticeSeller(buyerUid, orderCode, sellerOrderGoods,product);
}else{
Product product = Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null);
inBoxFacade.appraisePassNoticeSeller(buyerUid, orderCode, sellerOrderGoods, product);
} else {
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE); // 更新失败,可能是因为订单状态已经被并发修改
}
}
/**
* 不接受瑕疵
*
* @param orderRequest
*/
public void miniFaultNotAccept(OrderRequest orderRequest){
public void miniFaultNotAccept(OrderRequest orderRequest) {
LOGGER.info("Buyer Order miniFaultNotAccept (OrderRequest) {}", orderRequest);
//订单状态变更为 鉴定不通过 ,记录调拨的物流信息 ,发消息 ,
OrderStatus expectStatus = OrderStatus.MINI_FAULT_WAITING;
... ... @@ -456,19 +467,19 @@ public class AppraiseService {
OrderStatus targetStatus = OrderStatus.MINI_FAULT_REJECT;
// 参数检查
if (orderRequest.getUid() < 0
|| orderRequest.getOrderCode() < 0){
|| orderRequest.getOrderCode() < 0) {
LOGGER.warn("miniFaultNotAccept check uid or orderCode empty");
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
}
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCodeUid(orderRequest.getOrderCode(), orderRequest.getUid());
if (buyerOrder == null){
if (buyerOrder == null) {
LOGGER.warn("miniFaultNotAccept check orderCode exist, uid is {}, orderCode is {}",
orderRequest.getUid(), orderRequest.getOrderCode() );
orderRequest.getUid(), orderRequest.getOrderCode());
throw new ServiceException(ServiceError.ORDER_NULL);
}
if (buyerOrder.getStatus() != expectStatus.getCode()){
if (buyerOrder.getStatus() != expectStatus.getCode()) {
LOGGER.warn("miniFaultNotAccept expectStatus {}, actual status {}, orderCode {}", expectStatus,
buyerOrder.getStatus(), buyerOrder.getOrderCode());
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
... ... @@ -476,14 +487,14 @@ public class AppraiseService {
//checkStatusWithMoreExpectStatus(buyerOrder,orderRequest, expectStatusList);
long orderCode=orderRequest.getOrderCode();
ApiResponse result=this.miniFaultReject(orderCode,targetStatus,false);
long orderCode = orderRequest.getOrderCode();
ApiResponse result = this.miniFaultReject(orderCode, targetStatus, false);
if(result!=null&&result.getCode()==200){
if (result != null && result.getCode() == 200) {
//TODO 发消息
}else{
LOGGER.warn("Buyer Order miniFaultReject (OrderRequest) {} ,call appraiseFail fail result {} ", orderRequest,result);
} else {
LOGGER.warn("Buyer Order miniFaultReject (OrderRequest) {} ,call appraiseFail fail result {} ", orderRequest, result);
}
... ... @@ -504,26 +515,28 @@ public class AppraiseService {
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
}
}*/
/**
* 瑕疵不通过: 买家不接受或者超时确认
* @outTimeFlag 超时
* 瑕疵不通过: 买家不接受或者超时确认
*
* @return
* @outTimeFlag 超时
*/
public ApiResponse miniFaultReject(Long orderCode,OrderStatus targetStatus,boolean outTimeFlag){
LOGGER.info("miniFaultReject enter , orderCode {} ,targetStatus {},outTimeFlag {}", orderCode ,targetStatus ,outTimeFlag);
public ApiResponse miniFaultReject(Long orderCode, OrderStatus targetStatus, boolean outTimeFlag) {
LOGGER.info("miniFaultReject enter , orderCode {} ,targetStatus {},outTimeFlag {}", orderCode, targetStatus, outTimeFlag);
OrderStatus expectStatus = OrderStatus.MINI_FAULT_WAITING;
//拆分状态,版本升级之后存在的特殊订单
//OrderStatus expectStatusAnother = OrderStatus.PLATFORM_RECEIVE;
//List<Integer> expectStatusList= Lists.newArrayList(expectStatusNew.getCode(),expectStatusAnother.getCode());
ApiResponse apiResponse=new ApiResponse();
ApiResponse apiResponse = new ApiResponse();
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
if (buyerOrder == null){
if (buyerOrder == null) {
LOGGER.warn("miniFaultReject getOrderInfo order not exist, orderCode {}", orderCode);
throw new ServiceException(ServiceError.ORDER_NULL);
}
if (buyerOrder.getStatus() != expectStatus.getCode()){
if (buyerOrder.getStatus() != expectStatus.getCode()) {
LOGGER.warn("miniFaultReject expectStatus {}, actual status {}, orderCode {}", expectStatus,
buyerOrder.getStatus(), orderCode);
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
... ... @@ -534,7 +547,7 @@ public class AppraiseService {
int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expectStatus.getCode(), targetStatus.getCode(),
DateUtil.getCurrentTimeSecond());
if (rows > 0){
if (rows > 0) {
//refund coupons of buyer
BuyerRefundCouponEvent brce = BuyerRefundCouponEvent.builder().bizCase(BuyerRefundCouponEvent.BizCase.APPRAISE_FAIL)
.uid(buyerUid).orderCode(orderCode).build();
... ... @@ -550,12 +563,12 @@ public class AppraiseService {
final SellerOrderStatus expectSOStatus = SellerOrderStatus.HAS_PAYED;
final SellerOrderStatus targetSoStatus = SellerOrderStatus.MINI_FAULT_REJECT;
SellerOrderGoods sellerOrderGoods = updateSellerOrderStatusAndCleanCache(sellerUid ,sellerOrderCode,expectSOStatus,targetSoStatus,
skup, orderCode, buyerUid);
SellerOrderGoods sellerOrderGoods = updateSellerOrderStatusAndCleanCache(sellerUid, sellerOrderCode, expectSOStatus, targetSoStatus,
skup, orderCode, buyerUid);
//将卖家的保证金扣掉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());
PaymentRequest refundReqOfSeller = refundEarnestMoney(SellerWalletDetail.Type.MINI_FAULT_REJECT, orderCode, sellerUid, sellerOrder, skup, buyerUid, targetSoStatus, earnestMoney.doubleValue());
LOGGER.info("in miniFaultReject,refund ok, refundReqOfSeller {}", refundReqOfSeller);
//退买家的钱
... ... @@ -565,63 +578,63 @@ public class AppraiseService {
.payType(buyerOrder.getPayment()).refundCase(RefundCase.BUYER_GOODS_MONEY)
.amount(goodsMoney)
.skup(skup);
boolean refundGoodsMoneyFlag = new RefundGoodsMoneyHandler().loadPaymentRequest(buyerUid,orderCode,goodsMoney)
boolean refundGoodsMoneyFlag = new RefundGoodsMoneyHandler().loadPaymentRequest(buyerUid, orderCode, goodsMoney)
.loadBillLogEventBuilder(bleb)
.loadTargetOrderStatus(targetStatus)
.loadRefundAction(payRefundService::refund)
.loadLogger(LOGGER)
.refund();
if (!refundGoodsMoneyFlag){
if (!refundGoodsMoneyFlag) {
apiResponse.setCode(400);
String content = "瑕疵不接受时,退用户" + sellerUid + "货款订单"+ orderCode +"失败";
String content = "瑕疵不接受时,退用户" + sellerUid + "货款订单" + orderCode + "失败";
apiResponse.setMessage(content);
}
//记录订单的状态变更信息
LOGGER.info("in miniFaultReject record status change, orderCode {},uid {} ,sellerUid {}", orderCode,buyerUid,sellerUid);
LOGGER.info("in miniFaultReject record status change, orderCode {},uid {} ,sellerUid {}", orderCode, buyerUid, sellerUid);
try {
//记录订单状态流转
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetStatus.getCode());
//瑕疵不接受(用户不接受和超时不接受),只给买家发消息
inBoxFacade.buyerMiniFaultUnAccept(buyerUid,buyerOrder.getOrderCode(), sellerOrderGoods,outTimeFlag);
inBoxFacade.sellerMiniFaultUnAccept(sellerOrderGoods,orderCode,outTimeFlag);
inBoxFacade.buyerMiniFaultUnAccept(buyerUid, buyerOrder.getOrderCode(), sellerOrderGoods, outTimeFlag);
inBoxFacade.sellerMiniFaultUnAccept(sellerOrderGoods, orderCode, outTimeFlag);
}catch(Exception ex) {
} catch (Exception ex) {
LOGGER.warn("in miniFaultReject orderStatusFlowService or notice fail orderCode {}", orderCode, ex);
}finally {
} finally {
/// 物流信息异步执行
executorService.execute(()->{
executorService.execute(() -> {
//记下订单的操作记录
if (outTimeFlag) {
//更新瑕疵确认结果
int updateNum = qualityCheckMapper.updateByOrderCode(orderCode, EnumQualityCheckStatus.REJECT_BY_OUTER_TIME.getCode(), DateUtil.getCurrentTimeSecond());
LOGGER.info("Buyer Order miniFaultReject by auto orderCode {} ,update quality check record status num {} ", orderCode, updateNum);
orderOperateRecordService.addRecord(orderCode, "系统操作", OperateTypeEnum.OPERATE_TYPE_QUALITY_MINI_FAULT_REJECT_BY_OUT_TIME);
} else {
//更新瑕疵确认结果
int updateNum = qualityCheckMapper.updateByOrderCode(orderCode, EnumQualityCheckStatus.REJECT_BY_BUYER.getCode(), DateUtil.getCurrentTimeSecond());
LOGGER.info("Buyer Order miniFaultReject by buyer orderCode {} ,update quality check record status num {} ", orderCode, updateNum);
orderOperateRecordService.addRecord(orderCode, "买家操作", OperateTypeEnum.OPERATE_TYPE_QUALITY_MINI_FAULT_REJECT);
}
//记下订单的操作记录
if(outTimeFlag){
//更新瑕疵确认结果
int updateNum = qualityCheckMapper.updateByOrderCode(orderCode,EnumQualityCheckStatus.REJECT_BY_OUTER_TIME.getCode(), DateUtil.getCurrentTimeSecond());
LOGGER.info("Buyer Order miniFaultReject by auto orderCode {} ,update quality check record status num {} ", orderCode,updateNum);
orderOperateRecordService.addRecord(orderCode,"系统操作",OperateTypeEnum.OPERATE_TYPE_QUALITY_MINI_FAULT_REJECT_BY_OUT_TIME);
}else{
//更新瑕疵确认结果
int updateNum = qualityCheckMapper.updateByOrderCode(orderCode,EnumQualityCheckStatus.REJECT_BY_BUYER.getCode(), DateUtil.getCurrentTimeSecond());
LOGGER.info("Buyer Order miniFaultReject by buyer orderCode {} ,update quality check record status num {} ", orderCode,updateNum);
orderOperateRecordService.addRecord(orderCode,"买家操作",OperateTypeEnum.OPERATE_TYPE_QUALITY_MINI_FAULT_REJECT);
}
//更新物流信息,写到最后
//先补加一条鉴定中物流
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.mini_fault_reject;
expressInfoService.saveOperateTransferExpressInfo(sellerUid, orderCode, expressType.getCode(), expressDataType, operateTransferCode);
//更新物流信息,写到最后
//先补加一条鉴定中物流
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.mini_fault_reject;
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
operateTransferCode = EnumExpressDataOperateTransferCode.mini_fault_not_pass;
expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
expressDataType = EnumExpressDataType.operate_transfer;
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
operateTransferCode = EnumExpressDataOperateTransferCode.mini_fault_not_pass;
expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
expressDataType = EnumExpressDataType.operate_transfer;
expressInfoService.saveOperateTransferExpressInfo(sellerUid, orderCode, expressType.getCode(), expressDataType, operateTransferCode);
});
}
}else{
} else {
LOGGER.warn("in miniFaultReject, buyer Order now status {}, expect expectStatus {}",
buyerOrder.getStatus(), expectStatus);
apiResponse.setCode(400);
... ... @@ -631,8 +644,8 @@ public class AppraiseService {
}
//更新卖家订单的状态,并清缓存
private SellerOrderGoods updateSellerOrderStatusAndCleanCache(int sellerUid ,long sellerOrderCode,SellerOrderStatus expectSOStatus,SellerOrderStatus targetSoStatus,
int skup,Long orderCode,int buyerUid){
private SellerOrderGoods updateSellerOrderStatusAndCleanCache(int sellerUid, long sellerOrderCode, SellerOrderStatus expectSOStatus, SellerOrderStatus targetSoStatus,
int skup, Long orderCode, int buyerUid) {
SellerOrder tso = new SellerOrder();
tso.setUid(sellerUid);
tso.setOrderCode(sellerOrderCode);
... ... @@ -658,10 +671,11 @@ public class AppraiseService {
* 更新发到卖家的物流信息
* 将卖家的保证金分账给平台和买家
* 更新买家订单状态
*
* @return
*/
public ApiResponse appraiseFailAndDelivery(AppraiseExpressInfoBo appraiseExpressInfoBo){
LOGGER.info("appraiseFail enter , appraiseExpressInfoBo {} ,appraiseNotPassFlag {}", appraiseExpressInfoBo );
public ApiResponse appraiseFailAndDelivery(AppraiseExpressInfoBo appraiseExpressInfoBo) {
LOGGER.info("appraiseFail enter , appraiseExpressInfoBo {} ,appraiseNotPassFlag {}", appraiseExpressInfoBo);
OrderStatus expectStatus = OrderStatus.PLATFORM_CHECKING;
OrderStatus targetStatus = OrderStatus.CHECKING_FAKE;
Long orderCode = appraiseExpressInfoBo.getOrderCode();
... ... @@ -670,15 +684,15 @@ public class AppraiseService {
Integer depotNum = appraiseExpressInfoBo.getDepotNum();
String mobile = appraiseExpressInfoBo.getMobile();
ApiResponse apiResponse=new ApiResponse();
ApiResponse apiResponse = new ApiResponse();
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
if (buyerOrder == null){
if (buyerOrder == null) {
LOGGER.warn("appraiseFail getOrderInfo order not exist, orderCode {}", orderCode);
throw new ServiceException(ServiceError.ORDER_NULL);
}
if (buyerOrder.getStatus() != expectStatus.getCode()){
if (buyerOrder.getStatus() != expectStatus.getCode()) {
LOGGER.warn("appraiseFail expectStatus {}, actual status {}, orderCode {}", expectStatus,
buyerOrder.getStatus(), orderCode);
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
... ... @@ -690,7 +704,7 @@ public class AppraiseService {
int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expectStatus.getCode(), targetStatus.getCode(),
DateUtil.getCurrentTimeSecond());
if (rows > 0){
if (rows > 0) {
/*
//refund coupons of buyer
BuyerRefundCouponEvent brce = BuyerRefundCouponEvent.builder().bizCase(BuyerRefundCouponEvent.BizCase.APPRAISE_FAIL)
... ... @@ -755,18 +769,18 @@ public class AppraiseService {
.loadLogger(LOGGER)
.refund();
*/
RefundMoneyResultModel refundMoneyResultModel= operateMoneyWhenCheckFail(buyerOrder,orderCode,targetStatus);
RefundMoneyResultModel refundMoneyResultModel = operateMoneyWhenCheckFail(buyerOrder, orderCode, targetStatus);
boolean refundGoodsMoneyFlag = refundMoneyResultModel.isRefundGoodsMoneyFlag();
SellerOrderGoods sellerOrderGoods = refundMoneyResultModel.getSellerOrderGoods();
if (!refundGoodsMoneyFlag){
if (!refundGoodsMoneyFlag) {
apiResponse.setCode(400);
String content = "鉴定不通过时,退用户" + sellerUid + "货款订单"+ orderCode +"失败";
String content = "鉴定不通过时,退用户" + sellerUid + "货款订单" + orderCode + "失败";
apiResponse.setMessage(content);
}
//记录订单的状态变更信息
LOGGER.info("in appraiseFail record status change, orderCode {},uid {} ,sellerUid {}", orderCode,buyerUid,sellerUid);
LOGGER.info("in appraiseFail record status change, orderCode {},uid {} ,sellerUid {}", orderCode, buyerUid, sellerUid);
try {
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetStatus.getCode());
... ... @@ -775,27 +789,27 @@ public class AppraiseService {
inBoxFacade.noticeSellerWhenAppraiseFail(sellerOrderGoods, orderCode, wayBillCode);
inBoxFacade.buyerGetEarnestMoneyWhenAppraiseFail(buyerUid, buyerOrder.getOrderCode(), sellerOrderGoods);
}catch(Exception ex) {
} catch (Exception ex) {
LOGGER.warn("in appraiseFail orderStatusFlowService or notice fail orderCode {}", orderCode, ex);
}finally {
} finally {
/// 物流信息异步执行
executorService.execute(()->{
executorService.execute(() -> {
//更新物流信息,写到最后
//鉴定不通过,发物流
//补:鉴定不通过
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.judge_reject;
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
expressInfoService.saveOperateTransferExpressInfo(sellerUid, orderCode, expressType.getCode(), expressDataType, operateTransferCode);
//发货物流(平台已发货)
expressInfoService.returnBackOrderCauseOfJudgeFailure(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum,mobile);
expressInfoService.returnBackOrderCauseOfJudgeFailure(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile);
});
}
}else{
} else {
LOGGER.warn("in appraiseFail, buyer Order now status {}, expect expectStatus {}",
buyerOrder.getStatus(), expectStatus);
apiResponse.setCode(400);
... ... @@ -805,7 +819,7 @@ public class AppraiseService {
}
//退保证金给卖家
private PaymentRequest refundEarnestMoney(SellerWalletDetail.Type swdType,Long orderCode,Integer sellerUid ,SellerOrder sellerOrder,int skup,Integer buyerUid,SellerOrderStatus targetSoStatus ,double refundMoney){
private PaymentRequest refundEarnestMoney(SellerWalletDetail.Type swdType, Long orderCode, Integer sellerUid, SellerOrder sellerOrder, int skup, Integer buyerUid, SellerOrderStatus targetSoStatus, double refundMoney) {
Long sellerOrderCode = sellerOrder.getOrderCode();
Integer sop = sellerOrder.getPayment() == null ? 0 : sellerOrder.getPayment();
PaymentRequest refundReqOfSeller = PaymentRequest.builder().uid(sellerUid)
... ... @@ -816,13 +830,13 @@ public class AppraiseService {
boolean sellerIsSuper = sellerService.isSuperEntrySeller(sellerUid);
refundReqOfSeller.setSuper(sellerIsSuper);
LOGGER.info("in refundEarnestMoney begin, orderCode {} ,swdType {} seller uid {},sellerIsSuper {},seller order code {}, skup {}, refundMoney {},refundReqOfSeller {}"
,orderCode ,swdType,
sellerUid,sellerIsSuper, sellerOrderCode, skup, refundMoney ,refundReqOfSeller);
, orderCode, swdType,
sellerUid, sellerIsSuper, sellerOrderCode, skup, refundMoney, refundReqOfSeller);
if (!sellerIsSuper && PaymentHelper.isWallet(sop)){
if (!sellerIsSuper && PaymentHelper.isWallet(sop)) {
LOGGER.info("in refundEarnestMoney begin set MerchantOrderAttachInfo orderCode {} ,swdType {} seller uid {},sellerIsSuper {},seller order code {}, skup {}, refundMoney {},refundReqOfSeller {}"
,orderCode ,swdType,
sellerUid,sellerIsSuper, sellerOrderCode, skup, refundMoney ,refundReqOfSeller);
, orderCode, swdType,
sellerUid, sellerIsSuper, sellerOrderCode, skup, refundMoney, refundReqOfSeller);
//SellerWalletDetail.Type swdType = SellerWalletDetail.Type.APPRAISE_OK;
MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(sellerUid)
.orderCode(sellerOrderCode).skup(skup).earnestMoney(sellerOrder.getEarnestMoney())
... ... @@ -831,15 +845,15 @@ public class AppraiseService {
}
//瑕疵不接受的情况,并且是超级卖家的话,直接走惩罚接口
if(SellerWalletDetail.Type.MINI_FAULT_REJECT == swdType && sellerIsSuper && PaymentHelper.isWallet(sellerOrder.getPayment())){
if (SellerWalletDetail.Type.MINI_FAULT_REJECT == swdType && sellerIsSuper && PaymentHelper.isWallet(sellerOrder.getPayment())) {
LOGGER.info("in refundEarnestMoney call punishEarnest orderCode {} ,swdType {} seller uid {},sellerIsSuper {},seller order code {}, skup {}, refundMoney {},refundReqOfSeller {}"
,orderCode ,swdType,
sellerUid,sellerIsSuper, sellerOrderCode, skup, refundMoney ,refundReqOfSeller);
punishEarnest(swdType,sellerOrder);
}else{
, orderCode, swdType,
sellerUid, sellerIsSuper, sellerOrderCode, skup, refundMoney, refundReqOfSeller);
punishEarnest(swdType, sellerOrder);
} else {
LOGGER.info("in refundEarnestMoney call refund orderCode {} ,swdType {} seller uid {},sellerIsSuper {},seller order code {}, skup {}, refundMoney {},refundReqOfSeller {}"
,orderCode ,swdType,
sellerUid,sellerIsSuper, sellerOrderCode, skup, refundMoney ,refundReqOfSeller);
, orderCode, swdType,
sellerUid, sellerIsSuper, sellerOrderCode, skup, refundMoney, refundReqOfSeller);
BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder()
.buyerUid(buyerUid).sellerUid(sellerUid).orderCode(sellerOrder.getOrderCode())
.payType(sop).refundCase(RefundCase.SELLER_EARNEST_MONEY)
... ... @@ -860,22 +874,22 @@ public class AppraiseService {
}
//惩罚
private void punishEarnest(SellerWalletDetail.Type swdType, SellerOrder sellerOrder){
private void punishEarnest(SellerWalletDetail.Type swdType, SellerOrder sellerOrder) {
Integer sellerUid = sellerOrder.getUid();
Long sellerOrderCode = sellerOrder.getOrderCode();
Integer skup = sellerOrder.getSkup();
if (miniFaultRejectPunishFee>0 && Objects.nonNull(swdType) && PaymentHelper.isWallet(sellerOrder.getPayment())){
if (miniFaultRejectPunishFee > 0 && Objects.nonNull(swdType) && PaymentHelper.isWallet(sellerOrder.getPayment())) {
MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(sellerUid)
.orderCode(sellerOrderCode).skup(skup).earnestMoney(sellerOrder.getEarnestMoney())
.type(swdType.getValue()).build();
LOGGER.info("in refundEarnestMoney punishEarnest enter sellerOrder {} ,swdType {} ",sellerOrder ,swdType);
merchantOrderPaymentService.punishEarnest( moai, swdType);
LOGGER.info("in refundEarnestMoney punishEarnest enter sellerOrder {} ,swdType {} ", sellerOrder, swdType);
merchantOrderPaymentService.punishEarnest(moai, swdType);
}
}
@Data
class RefundMoneyResultModel{
class RefundMoneyResultModel {
boolean refundGoodsMoneyFlag;
SellerOrderGoods sellerOrderGoods;
}
... ... @@ -884,8 +898,8 @@ public class AppraiseService {
* 鉴定不通或者质检不通过
* 操作钱
*/
private RefundMoneyResultModel operateMoneyWhenCheckFail(BuyerOrder buyerOrder, Long orderCode, OrderStatus targetStatus){
LOGGER.info("operateMoney enter , orderCode {},targetStatus {} ", orderCode ,targetStatus);
private RefundMoneyResultModel operateMoneyWhenCheckFail(BuyerOrder buyerOrder, Long orderCode, OrderStatus targetStatus) {
LOGGER.info("operateMoney enter , orderCode {},targetStatus {} ", orderCode, targetStatus);
RefundMoneyResultModel model = new RefundMoneyResultModel();
int buyerUid = buyerOrder.getUid();
int sellerUid = buyerOrder.getSellerUid();
... ... @@ -905,14 +919,14 @@ public class AppraiseService {
final SellerOrderStatus expectSOStatus = SellerOrderStatus.HAS_PAYED;
final SellerOrderStatus targetSoStatus = SellerOrderStatus.APPRAISAL_FAIL_COMPENSATE;
SellerOrderGoods sellerOrderGoods = updateSellerOrderStatusAndCleanCache(sellerUid ,sellerOrderCode,expectSOStatus,targetSoStatus,
SellerOrderGoods sellerOrderGoods = updateSellerOrderStatusAndCleanCache(sellerUid, sellerOrderCode, expectSOStatus, targetSoStatus,
skup, orderCode, buyerUid);
//将卖家的保证金分账给平台和买家
PenaltyResult penaltyResult = SellerEarnestMoney2BuyerPenaltyCalculator.from(sellerOrderMetaMapper.selectByMetaKey(sellerUid, skup, "fee"))
.calculate()
.orElse(null);
if(Objects.nonNull(penaltyResult)){
if (Objects.nonNull(penaltyResult)) {
TransferCase transferCase = TransferCase.EARNEST_MONEY_TO_BUYER;
TranseferCellNode transeferCellNode = new TranseferCellNode();
transeferCellNode.setUid(buyerUid);
... ... @@ -932,7 +946,7 @@ public class AppraiseService {
//再分账
//改成异步的分账,不关心分账执行结果
executorService.execute(()->{
executorService.execute(() -> {
LOGGER.info("in appraiseFail,begin transfer async");
transferService.transfer(tmReq);
});
... ... @@ -946,7 +960,7 @@ public class AppraiseService {
.payType(buyerOrder.getPayment()).refundCase(RefundCase.BUYER_GOODS_MONEY)
.amount(goodsMoney)
.skup(skup);
boolean refundGoodsMoneyFlag = new RefundGoodsMoneyHandler().loadPaymentRequest(buyerUid,orderCode,goodsMoney)
boolean refundGoodsMoneyFlag = new RefundGoodsMoneyHandler().loadPaymentRequest(buyerUid, orderCode, goodsMoney)
.loadBillLogEventBuilder(bleb)
.loadTargetOrderStatus(targetStatus)
.loadRefundAction(payRefundService::refund)
... ... @@ -960,24 +974,24 @@ public class AppraiseService {
/**
* 手机质检端的鉴定不通过
*
* <p>
* 直接平台收货后 -> 直接鉴定不通过
*/
public ApiResponse judgeCenterNotPass(Long orderCode){
LOGGER.info("judgeCenterNotPass enter , orderCode {} ", orderCode );
OrderStatus expectStatus = OrderStatus.PLATFORM_RECEIVE;
public ApiResponse judgeCenterNotPass(Long orderCode) {
LOGGER.info("judgeCenterNotPass enter , orderCode {} ", orderCode);
OrderStatus expectStatus = OrderStatus.PLATFORM_RECEIVE;
OrderStatus targetStatus = OrderStatus.CHECKING_FAKE;
ApiResponse apiResponse=new ApiResponse();
ApiResponse apiResponse = new ApiResponse();
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
if (buyerOrder == null){
if (buyerOrder == null) {
LOGGER.warn("judgeCenterNotPass getOrderInfo order not exist, orderCode {}", orderCode);
throw new ServiceException(ServiceError.ORDER_NULL);
}
if (buyerOrder.getStatus()!= expectStatus.getCode()){
LOGGER.warn("judgeCenterNotPass expectStatus {}, actual status {}, orderCode {}",expectStatus,
if (buyerOrder.getStatus() != expectStatus.getCode()) {
LOGGER.warn("judgeCenterNotPass expectStatus {}, actual status {}, orderCode {}", expectStatus,
buyerOrder.getStatus(), orderCode);
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
}
... ... @@ -988,46 +1002,46 @@ public class AppraiseService {
int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expectStatus.getCode(), targetStatus.getCode(),
DateUtil.getCurrentTimeSecond());
if (rows > 0){
RefundMoneyResultModel refundMoneyResultModel= operateMoneyWhenCheckFail(buyerOrder,orderCode,targetStatus);
if (rows > 0) {
RefundMoneyResultModel refundMoneyResultModel = operateMoneyWhenCheckFail(buyerOrder, orderCode, targetStatus);
boolean refundGoodsMoneyFlag = refundMoneyResultModel.isRefundGoodsMoneyFlag();
SellerOrderGoods sellerOrderGoods = refundMoneyResultModel.getSellerOrderGoods();
if (!refundGoodsMoneyFlag){
if (!refundGoodsMoneyFlag) {
apiResponse.setCode(400);
String content = "后台鉴定商品不通过,退用户" + sellerUid + "货款订单"+ orderCode +"失败";
String content = "后台鉴定商品不通过,退用户" + sellerUid + "货款订单" + orderCode + "失败";
apiResponse.setMessage(content);
}
//记录订单的状态变更信息
LOGGER.info("in judgeCenterNotPass record status change, orderCode {},uid {} ,sellerUid {}", orderCode,buyerUid,sellerUid);
LOGGER.info("in judgeCenterNotPass record status change, orderCode {},uid {} ,sellerUid {}", orderCode, buyerUid, sellerUid);
try {
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetStatus.getCode());
//鉴定不通过
inBoxFacade.noticeBuyerWhenQualityCheckNotPass(buyerUid, buyerOrder.getOrderCode(), sellerOrderGoods);
inBoxFacade.sellerQualityCheckNotPass(sellerOrderGoods,orderCode);
inBoxFacade.sellerQualityCheckNotPass(sellerOrderGoods, orderCode);
}catch(Exception ex) {
} catch (Exception ex) {
LOGGER.warn("in judgeCenterNotPass orderStatusFlowService or notice fail orderCode {}", orderCode, ex);
}finally {
} finally {
/// 物流信息异步执行
executorService.execute(()->{
executorService.execute(() -> {
//鉴定不通过,不发物流
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.judging;
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
expressInfoService.saveOperateTransferExpressInfo(sellerUid, orderCode, expressType.getCode(), expressDataType, operateTransferCode);
expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
expressDataType = EnumExpressDataType.operate_transfer;
operateTransferCode = EnumExpressDataOperateTransferCode.judge_reject;
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
expressInfoService.saveOperateTransferExpressInfo(sellerUid, orderCode, expressType.getCode(), expressDataType, operateTransferCode);
});
}
}else{
} else {
LOGGER.warn("in judgeCenterNotPass, buyer Order now status {}, expect expectStatus {}",
buyerOrder.getStatus(), expectStatus);
apiResponse.setCode(400);
... ... @@ -1040,22 +1054,22 @@ public class AppraiseService {
* 质检不通过 31->20
* 不发物流
*/
public ApiResponse qualityCheckReject(SaveQualityCheckInfoRequest request){
LOGGER.info("qualityCheckReject enter , appraiseExpressInfoBo {} ", request );
public ApiResponse qualityCheckReject(SaveQualityCheckInfoRequest request) {
LOGGER.info("qualityCheckReject enter , appraiseExpressInfoBo {} ", request);
OrderStatus expectStatus = OrderStatus.PLATFORM_RECEIVE;
OrderStatus targetStatus = OrderStatus.QUALITY_CHECK_FAKE;
Long orderCode = request.getOrderCode();
QualityCheck qualityCheck = request.getQualityCheck();
ApiResponse apiResponse=new ApiResponse();
ApiResponse apiResponse = new ApiResponse();
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
if (buyerOrder == null){
if (buyerOrder == null) {
LOGGER.warn("qualityCheckReject getOrderInfo order not exist, orderCode {}", orderCode);
throw new ServiceException(ServiceError.ORDER_NULL);
}
if (buyerOrder.getStatus() != expectStatus.getCode()){
if (buyerOrder.getStatus() != expectStatus.getCode()) {
LOGGER.warn("qualityCheckReject expectStatus {}, actual status {}, orderCode {}", expectStatus,
buyerOrder.getStatus(), orderCode);
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
... ... @@ -1065,9 +1079,9 @@ public class AppraiseService {
int sellerUid = buyerOrder.getSellerUid();
//保存质检有问题的图片信息
if(qualityCheck==null){
LOGGER.warn("in qualityCheckReject qualityCheck is null, orderCode {},uid {} ,sellerUid {}", orderCode,buyerUid,sellerUid);
throw new ServiceException(400,"质检不合格信息为空");
if (qualityCheck == null) {
LOGGER.warn("in qualityCheckReject qualityCheck is null, orderCode {},uid {} ,sellerUid {}", orderCode, buyerUid, sellerUid);
throw new ServiceException(400, "质检不合格信息为空");
}
qualityCheckMapper.insert(qualityCheck);
... ... @@ -1075,48 +1089,48 @@ public class AppraiseService {
int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expectStatus.getCode(), targetStatus.getCode(),
DateUtil.getCurrentTimeSecond());
if (rows > 0){
RefundMoneyResultModel refundMoneyResultModel= operateMoneyWhenCheckFail(buyerOrder,orderCode,targetStatus);
if (rows > 0) {
RefundMoneyResultModel refundMoneyResultModel = operateMoneyWhenCheckFail(buyerOrder, orderCode, targetStatus);
boolean refundGoodsMoneyFlag = refundMoneyResultModel.isRefundGoodsMoneyFlag();
SellerOrderGoods sellerOrderGoods = refundMoneyResultModel.getSellerOrderGoods();
if (!refundGoodsMoneyFlag){
if (!refundGoodsMoneyFlag) {
apiResponse.setCode(400);
String content = "后台质检不通过时,退用户" + sellerUid + "货款订单"+ orderCode +"失败";
String content = "后台质检不通过时,退用户" + sellerUid + "货款订单" + orderCode + "失败";
apiResponse.setMessage(content);
}
//记录订单的状态变更信息
LOGGER.info("in qualityCheckReject record status change, orderCode {},uid {} ,sellerUid {}", orderCode,buyerUid,sellerUid);
LOGGER.info("in qualityCheckReject record status change, orderCode {},uid {} ,sellerUid {}", orderCode, buyerUid, sellerUid);
try {
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetStatus.getCode());
//质检不通过
inBoxFacade.noticeBuyerWhenQualityCheckNotPass(buyerUid, buyerOrder.getOrderCode(), sellerOrderGoods);
inBoxFacade.sellerQualityCheckNotPass(sellerOrderGoods,orderCode);
inBoxFacade.sellerQualityCheckNotPass(sellerOrderGoods, orderCode);
}catch(Exception ex) {
} catch (Exception ex) {
LOGGER.warn("in qualityCheckReject orderStatusFlowService or notice fail orderCode {}", orderCode, ex);
}finally {
} finally {
/// 物流信息异步执行
executorService.execute(()->{
executorService.execute(() -> {
//质检不通过,不发物流
//先补加一条鉴定中物流
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.judging;
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
expressInfoService.saveOperateTransferExpressInfo(sellerUid, orderCode, expressType.getCode(), expressDataType, operateTransferCode);
//再加一个鉴定不通过的物流
operateTransferCode = EnumExpressDataOperateTransferCode.quality_check_reject;
expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
expressDataType = EnumExpressDataType.operate_transfer;
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
expressInfoService.saveOperateTransferExpressInfo(sellerUid, orderCode, expressType.getCode(), expressDataType, operateTransferCode);
});
}
}else{
} else {
LOGGER.warn("in qualityCheckReject, buyer Order now status {}, expect expectStatus {}",
buyerOrder.getStatus(), expectStatus);
apiResponse.setCode(400);
... ... @@ -1128,26 +1142,27 @@ public class AppraiseService {
/**
* 鉴定通过,但是不发货
* 手机质检端 :平台已收货 --> JUDGE_PASS
*
* @return
*/
public ApiResponse judgeCenterPass(Long orderCode){
public ApiResponse judgeCenterPass(Long orderCode) {
LOGGER.info("judgeCenterPass enter orderCode {}", orderCode);
ApiResponse apiResponse=new ApiResponse();
ApiResponse apiResponse = new ApiResponse();
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
if (buyerOrder == null){
if (buyerOrder == null) {
LOGGER.warn("judgeCenterPass getOrderInfo order not exist, orderCode is {}", orderCode);
throw new ServiceException(ServiceError.ORDER_NULL);
}
final OrderStatus expectOrderStatus = OrderStatus.PLATFORM_RECEIVE;
final OrderStatus expectOrderStatus = OrderStatus.PLATFORM_RECEIVE;
final OrderStatus targetOrderStatus = OrderStatus.JUDGE_PASS;
if ( buyerOrder.getStatus() != expectOrderStatus.getCode()){
LOGGER.warn("in judgeCenterPass, buyer Order orderCode {} status {}, expect Order Status is {} ",expectOrderStatus,
if (buyerOrder.getStatus() != expectOrderStatus.getCode()) {
LOGGER.warn("in judgeCenterPass, buyer Order orderCode {} status {}, expect Order Status is {} ", expectOrderStatus,
orderCode, buyerOrder.getStatus());
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
}
LOGGER.info("judgeCenterPass enter orderCode {} ,expectOrderStatus {}", orderCode ,expectOrderStatus);
LOGGER.info("judgeCenterPass enter orderCode {} ,expectOrderStatus {}", orderCode, expectOrderStatus);
Integer buyerUid = buyerOrder.getUid();
BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(buyerUid, orderCode);
... ... @@ -1158,7 +1173,7 @@ public class AppraiseService {
int updateBuyerCnt = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid,
expectOrderStatus.getCode(), targetOrderStatus.getCode(), DateUtil.getCurrentTimeSecond());
if (updateBuyerCnt == 1){
if (updateBuyerCnt == 1) {
final Integer sellerUid = sellerOrder.getUid();
final Long sellerOrderCode = sellerOrder.getOrderCode();
final SellerOrderStatus expectSOStatus = SellerOrderStatus.HAS_PAYED;
... ... @@ -1167,39 +1182,39 @@ public class AppraiseService {
/**
* 更新卖家订单状态,
*/
SellerOrderGoods sellerOrderGoods = updateSellerOrderStatusAndCleanCache(sellerUid ,sellerOrderCode,expectSOStatus,targetSoStatus,
SellerOrderGoods sellerOrderGoods = updateSellerOrderStatusAndCleanCache(sellerUid, sellerOrderCode, expectSOStatus, targetSoStatus,
skup, orderCode, buyerUid);
//退款给卖家(仅退一次)
PaymentRequest refundReqOfSeller = operateMoneyWhenOk(buyerUid,orderCode,skup,sellerOrder,targetSoStatus);
PaymentRequest refundReqOfSeller = operateMoneyWhenOk(buyerUid, orderCode, skup, sellerOrder, targetSoStatus);
try {
//记录订单的状态变更信息
LOGGER.info("in judgeCenterPass record status change, orderCode {},uid {} ,sellerUid {}", orderCode,buyerUid,sellerUid);
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(),targetOrderStatus.getCode());
LOGGER.info("in judgeCenterPass record status change, orderCode {},uid {} ,sellerUid {}", orderCode, buyerUid, sellerUid);
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetOrderStatus.getCode());
//TODO 鉴定通过,
Product product =Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null);
inBoxFacade.appraisePassNoticeSeller(buyerUid, orderCode, sellerOrderGoods,product);
}catch (Exception ex){
Product product = Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null);
inBoxFacade.appraisePassNoticeSeller(buyerUid, orderCode, sellerOrderGoods, product);
} catch (Exception ex) {
LOGGER.warn("in judgeCenterPass,refund fail, refundReqOfSeller {}", refundReqOfSeller, ex);
String content = "后台鉴定通过商品,订单"+ orderCode + "退还保证金失败";
String content = "后台鉴定通过商品,订单" + orderCode + "退还保证金失败";
apiResponse.setCode(400);
apiResponse.setMessage(content);
}finally {
} finally {
//记录调拨信息
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.judge_pass;
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
expressInfoService.saveOperateTransferExpressInfo(sellerUid, orderCode, expressType.getCode(), expressDataType, operateTransferCode);
}
LOGGER.info("in judgeCenterPass, refund earnestMoney finish, seller {}, order code {}, skup {}, earnestMoney {}",
sellerUid, sellerOrderCode, skup, sellerOrder.getEarnestMoney() );
sellerUid, sellerOrderCode, skup, sellerOrder.getEarnestMoney());
}else{
} else {
LOGGER.warn("in judgeCenterPass, buyer Order pstatus {}, expect expectOrderStatus {}",
buyerOrder.getStatus(), expectOrderStatus);
apiResponse.setCode(400);
... ... @@ -1213,7 +1228,7 @@ public class AppraiseService {
/**
* 通过时 ,操作钱
*/
private PaymentRequest operateMoneyWhenOk(Integer buyerUid,Long orderCode,int skup,SellerOrder sellerOrder,SellerOrderStatus targetSoStatus){
private PaymentRequest operateMoneyWhenOk(Integer buyerUid, Long orderCode, int skup, SellerOrder sellerOrder, SellerOrderStatus targetSoStatus) {
final Integer sellerUid = sellerOrder.getUid();
BigDecimal saleIncome = getSaleIncome(sellerUid, skup);
... ... @@ -1233,7 +1248,7 @@ public class AppraiseService {
paymentService.transferMonCheck(tmReq);
//改成异步的分账,不关心分账执行结果
executorService.execute(()->{
executorService.execute(() -> {
LOGGER.info("in appraiseSuccess,begin transfer async");
transferService.transfer(tmReq);
});
... ... @@ -1241,22 +1256,22 @@ public class AppraiseService {
//退保证金给卖家
//refund earnestMoney
BigDecimal earnestMoney = sellerOrder.getEarnestMoney();
PaymentRequest refundReqOfSeller = refundEarnestMoney(SellerWalletDetail.Type.APPRAISE_OK,orderCode,sellerUid ,sellerOrder,skup,buyerUid,targetSoStatus,earnestMoney.doubleValue());
PaymentRequest refundReqOfSeller = refundEarnestMoney(SellerWalletDetail.Type.APPRAISE_OK, orderCode, sellerUid, sellerOrder, skup, buyerUid, targetSoStatus, earnestMoney.doubleValue());
LOGGER.info("in appraiseSuccess,refund ok, refundReqOfSeller {}", refundReqOfSeller);
return refundReqOfSeller;
}
public ApiResponse appraiseSuccessAndDelivery(Integer expressCompanyId, Long orderCode, String wayBillCode,Integer depotNum,String mobile){
ApiResponse apiResponse=new ApiResponse();
public ApiResponse appraiseSuccessAndDelivery(Integer expressCompanyId, Long orderCode, String wayBillCode, Integer depotNum, String mobile) {
ApiResponse apiResponse = new ApiResponse();
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
if (buyerOrder == null){
if (buyerOrder == null) {
LOGGER.warn("appraiseSuccess getOrderInfo order not exist, orderCode is {}", orderCode);
throw new ServiceException(ServiceError.ORDER_NULL);
}
final OrderStatus expectOrderStatus = OrderStatus.PLATFORM_CHECKING;
final OrderStatus targetOrderStatus = OrderStatus.WAITING_RECEIVE;
if (expectOrderStatus.getCode() != buyerOrder.getStatus().intValue()){
if (expectOrderStatus.getCode() != buyerOrder.getStatus().intValue()) {
LOGGER.warn("in appraiseSuccess, buyer Order orderCode {} pstatus {}, expect Order Status {}",
orderCode, buyerOrder.getStatus(), expectOrderStatus);
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
... ... @@ -1271,7 +1286,7 @@ public class AppraiseService {
int updateBuyerCnt = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid,
expectOrderStatus.getCode(), targetOrderStatus.getCode(), DateUtil.getCurrentTimeSecond());
if (updateBuyerCnt == 1){
if (updateBuyerCnt == 1) {
final Integer sellerUid = sellerOrder.getUid();
final Long sellerOrderCode = sellerOrder.getOrderCode();
final SellerOrderStatus expectSOStatus = SellerOrderStatus.HAS_PAYED;
... ... @@ -1291,11 +1306,11 @@ public class AppraiseService {
int soCnt = sellerOrderMapper.updateByOrderCode(tso);
*/
//更新卖家订单状态
SellerOrderGoods sellerOrderGoods = updateSellerOrderStatusAndCleanCache(sellerUid ,sellerOrderCode,expectSOStatus,targetSoStatus,
SellerOrderGoods sellerOrderGoods = updateSellerOrderStatusAndCleanCache(sellerUid, sellerOrderCode, expectSOStatus, targetSoStatus,
skup, orderCode, buyerUid);
//退款给卖家(仅退一次)
PaymentRequest refundReqOfSeller = operateMoneyWhenOk(buyerUid,orderCode,skup,sellerOrder,targetSoStatus);
PaymentRequest refundReqOfSeller = operateMoneyWhenOk(buyerUid, orderCode, skup, sellerOrder, targetSoStatus);
/*
... ... @@ -1336,27 +1351,27 @@ public class AppraiseService {
EventBusPublisher.publishEvent(buyerConfirmEvent);
//记录物流信息
//发物流
expressInfoService.deliverGoods(buyerUid, expressCompanyId, orderCode, wayBillCode, depotNum,mobile);
expressInfoService.deliverGoods(buyerUid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile);
//记录订单的状态变更信息
LOGGER.info("in appraiseSuccess record status change, orderCode {},uid {} ,sellerUid {}", orderCode,buyerUid,sellerUid);
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(),targetOrderStatus.getCode());
LOGGER.info("in appraiseSuccess record status change, orderCode {},uid {} ,sellerUid {}", orderCode, buyerUid, sellerUid);
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetOrderStatus.getCode());
//平台已发货给买家
Product product =Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null);
inBoxFacade.appraisePassNoticeBuyer(buyerUid, orderCode, sellerOrderGoods,product);
inBoxFacade.appraisePassNoticeSeller(buyerUid, orderCode, sellerOrderGoods,product);
}catch (Exception ex){
Product product = Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null);
inBoxFacade.appraisePassNoticeBuyer(buyerUid, orderCode, sellerOrderGoods, product);
inBoxFacade.appraisePassNoticeSeller(buyerUid, orderCode, sellerOrderGoods, product);
} catch (Exception ex) {
LOGGER.warn("in appraiseSuccess,refund fail, refundReqOfSeller {}", refundReqOfSeller, ex);
String content = "鉴定通过时,订单"+ orderCode + "退还保证金失败";
String content = "鉴定通过时,订单" + orderCode + "退还保证金失败";
apiResponse.setCode(400);
apiResponse.setMessage(content);
}finally {
} finally {
//记录调拨信息
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.judge_pass;
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
expressInfoService.saveOperateTransferExpressInfo(sellerUid, orderCode, expressType.getCode(), expressDataType, operateTransferCode);
}
/*
... ... @@ -1372,10 +1387,10 @@ public class AppraiseService {
*/
LOGGER.info("in appraiseSuccess, refund earnestMoney finish, seller {}, order code {}, skup {}, earnestMoney {}",
sellerUid, sellerOrderCode, skup, sellerOrder.getEarnestMoney() );
sellerUid, sellerOrderCode, skup, sellerOrder.getEarnestMoney());
}else{
} else {
LOGGER.warn("in appraiseSuccess, buyer Order pstatus {}, expect expectOrderStatus {}",
buyerOrder.getStatus(), expectOrderStatus);
apiResponse.setCode(400);
... ... @@ -1420,7 +1435,7 @@ public class AppraiseService {
// 通知买家商品无法鉴定(并发券)
.withNoticeBuyer(this::noticeBuyerAndSendCouponForAppraiseUnsure).and()
// 退优惠券
.withRefundCoupon(BuyerRefundCouponEvent.BizCase.SELLER_DELIVER_TIMEOUT)
.withRefundCoupon(BuyerRefundCouponEvent.BizCase.APPRAISE_UNSURE)
.withCacheCleaner(cacheCleaner::delete)
.withFailAlarm(AlarmConfig.APPRAISE_UNSURE)
.cancel();
... ... @@ -1433,8 +1448,17 @@ public class AppraiseService {
*/
private void noticeBuyerAndSendCouponForAppraiseUnsure(BuyerNoticeSender.Request request) {
// 发送优惠券
// 通知买家商品无法鉴定
inBoxFacade.noticeBuyerAppraiseUnsure(request);
CouponSendMqBean mqBean = CouponSendMqBean.builder()
.messageId(String.valueOf(request.getOrderCode()))
.uid(request.getUid())
.couponTokens(Lists.newArrayList("f489885f-0e99-4e15-a628-c40e660128fa"))
.systemParam(JSONObject.toJSONString(request))
.sendType(CouponSendType.PLATFORM_APPRAISE_UNSURE)
// 回调中通知买家商品无法鉴定
.notifyTopic("buyerOrder.couponSendResultForAppraiseUnsure")
.build();
tradeMqProducer.send("ufo.couponSendWithTradeMqNotify", mqBean);
}
}
... ...
... ... @@ -15,6 +15,7 @@ import com.yohoufo.inboxclient.model.InboxReqVO;
import com.yohoufo.inboxclient.sdk.InBoxSDK;
import com.yohoufo.order.service.impl.function.BuyerNoticeSender;
import com.yohoufo.order.utils.PaymentHelper;
import lombok.NonNull;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -1219,7 +1220,11 @@ public class InBoxFacade {
}
}
public void noticeBuyerAppraiseUnsure(BuyerNoticeSender.Request request){
/**
* 通知买家商品无法鉴定
* @param request
*/
public void noticeBuyerAppraiseUnsure(@NonNull BuyerNoticeSender.Request request){
Integer uid = request.getUid();
Long orderCode = request.getOrderCode();
String params = buildParams(orderCode);
... ...
... ... @@ -9,6 +9,10 @@ public class LoggerUtils {
return buildByName("mqConsumerLog");
}
public static Logger getMqProducerLogger() {
return buildByName("mqProducerLog");
}
static Logger buildByName(String logName){
return LoggerFactory.getLogger(logName);
}
... ...
package com.yohoufo.promotion.mq;
import com.alibaba.fastjson.JSON;
import com.yoho.core.rabbitmq.YhConsumer;
import com.yoho.core.rabbitmq.YhProducer;
import com.yohobuy.ufo.model.promotion.request.CouponSendMqBean;
import com.yohobuy.ufo.model.promotion.response.CouponSendBo;
import com.yohobuy.ufo.model.promotion.response.CrmCouponSendResultBean;
import com.yohoufo.promotion.common.LoggerUtils;
import com.yohoufo.promotion.service.ICouponService;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import java.util.Objects;
public abstract class AbstractCouponSendConsumer implements YhConsumer {
private Logger logger = LoggerUtils.getMqConsumerLogger();
@Autowired
private ICouponService couponService;
protected String getNotifyTopic() {
return null;
}
protected abstract YhProducer getNotifyProducer();
@Override
public void handleMessage(Object o) {
try {
logger.info("mq coupon send receive msg:{}", o);
CouponSendMqBean mqBean = parseRequestMessage(o);
List<CouponSendBo> couponSendBoList = couponService.batchSendCoupon(mqBean.getUid(), String.join(",", mqBean.getCouponTokens()), mqBean.getSendType());
logger.info("mq coupon send success. msg:{} success", o);
notifySendResultWithMq(mqBean, couponSendBoList);
} catch (Exception e) {
logger.warn("mq coupon send failed. msg:{}", o, e);
}
}
private CouponSendMqBean parseRequestMessage(Object o) {
if (null == o) {
throw new RuntimeException("message is null");
}
CouponSendMqBean mqBean = JSON.parseObject(o.toString(), CouponSendMqBean.class);
if (mqBean == null) {
throw new RuntimeException("message parse result is null");
}
if (mqBean.getUid() <= 0) {
throw new RuntimeException("message parse result uid is null");
}
if (mqBean.getCouponTokens() == null) {
throw new RuntimeException("message parse result token is null");
}
return mqBean;
}
private void notifySendResultWithMq(CouponSendMqBean mqBean, List<CouponSendBo> couponSendBoList) {
String notifyTopic = getNotifyTopic();
if (Objects.nonNull(mqBean.getNotifyTopic())) {
notifyTopic = mqBean.getNotifyTopic();
}
if (Objects.isNull(notifyTopic)) {
logger.info("send coupon notify fail {} notify topic is null", mqBean);
return;
}
// 将领券成功的couponToken,通知crm
for (CouponSendBo couponSendBo : couponSendBoList) {
if (!couponSendBo.isSuccess()) {
logger.info("send coupon notify fail {} res is {}", mqBean, couponSendBoList);
return;
}
}
CrmCouponSendResultBean crmCouponSendResultBean = CrmCouponSendResultBean.builder()
.uid(mqBean.getUid())
.markingPushId(mqBean.getSystemId())
.status(200)
.params(mqBean.getSystemParam())
.build();
try {
getNotifyProducer().send(notifyTopic, crmCouponSendResultBean);
logger.info("send coupon notify success {}", crmCouponSendResultBean);
} catch (Exception e) {
logger.warn("send coupon notify fail {}", crmCouponSendResultBean, e);
}
}
}
\ No newline at end of file
... ...
package com.yohoufo.promotion.mq;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yoho.core.rabbitmq.YhConsumer;
import com.yoho.core.rabbitmq.YhProducer;
import com.yohobuy.ufo.model.promotion.request.CouponSendMqBean;
import com.yohobuy.ufo.model.promotion.response.CouponSendBo;
import com.yohobuy.ufo.model.promotion.response.CrmCouponSendResultBean;
import com.yohoufo.promotion.common.LoggerUtils;
import com.yohoufo.promotion.service.ICouponService;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
@Component
public class CouponSendConsumer implements YhConsumer {
public class CouponSendConsumer extends AbstractCouponSendConsumer {
private Logger logger = LoggerUtils.getMqConsumerLogger();
@Autowired
ICouponService couponService;
/**
* topic名称
*/
private static final String CRM_COUPON_SEND_FEEDBACK_TOPIC = "crm.couponSendResult";
@Resource(name="crmMqProducer")
@Resource(name = "crmMqProducer")
private YhProducer crmMqProducer;
@Override
public void handleMessage(Object o) {
try{
logger.info("mq coupon send for crm receive msg:{}", o);
if(null==o){
logger.warn("mq coupon send for crm receive msg is null");
return;
}
CouponSendMqBean mqBean = JSON.parseObject(o.toString(), CouponSendMqBean.class);
if (mqBean.getCouponTokens()== null){
logger.warn("mq coupon send for crm receive token is null. msg is {}", o);
return;
}
List<CouponSendBo> couponSendBoList = couponService.batchSendCoupon(mqBean.getUid(), String.join(",", mqBean.getCouponTokens()));
// 将领券成功的couponToken,通知crm
for (CouponSendBo couponSendBo : couponSendBoList) {
if (!couponSendBo.isSuccess()) {
return;
}
}
CrmCouponSendResultBean crmCouponSendResultBean = CrmCouponSendResultBean.builder()
.uid(mqBean.getUid())
.markingPushId(mqBean.getSystemId())
.status(200)
.params(mqBean.getSystemParam()).build();
try {
crmMqProducer.send(CRM_COUPON_SEND_FEEDBACK_TOPIC, crmCouponSendResultBean);
} catch (Exception e) {
logger.error("send coupon by mq params:{},error:{}", crmCouponSendResultBean, e.getMessage());
}
protected String getNotifyTopic() {
return "crm.couponSendResult";
}
}catch (Exception e){
logger.warn("mq coupon send for crm handle failed. msg:{}", o, e);
}
@Override
protected YhProducer getNotifyProducer() {
return crmMqProducer;
}
}
\ No newline at end of file
... ...
package com.yohoufo.promotion.mq;
import com.yoho.core.rabbitmq.YhProducer;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@Component
public class CouponSendWithTradeMqNotifyConsumer extends AbstractCouponSendConsumer {
@Resource(name = "tradeMqProducer")
private YhProducer tradeMqProducer;
@Override
protected YhProducer getNotifyProducer() {
return tradeMqProducer;
}
}
\ No newline at end of file
... ...
package com.yohoufo.promotion.service;
import com.google.common.collect.Range;
import com.yohobuy.ufo.model.promotion.UserCouponsListBo;
import com.yohobuy.ufo.model.promotion.response.CouponInfo;
import com.yohobuy.ufo.model.promotion.response.CouponSendBo;
import java.time.LocalDateTime;
import java.util.List;
public interface ICouponService {
... ... @@ -24,6 +26,14 @@ public interface ICouponService {
public List<CouponSendBo> batchSendCoupon(Integer uid, String couponTokens);
/**
* 领取优惠券
* @param uid
* @param couponTokens
* @return
*/
public List<CouponSendBo> batchSendCoupon(Integer uid, String couponTokens, Integer sendType);
/**
* 使用优惠券
* @param uid
* @param couponCodes
... ...
package com.yohoufo.promotion.service.impl;
import com.google.common.collect.Lists;
import com.google.common.collect.Range;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.promotion.UserCouponsBo;
... ... @@ -8,6 +9,7 @@ import com.yohobuy.ufo.model.promotion.UserCouponsListBo;
import com.yohobuy.ufo.model.promotion.constant.CouponProductLimitTypeEnum;
import com.yohobuy.ufo.model.promotion.constant.CouponUseStatusEnum;
import com.yohobuy.ufo.model.promotion.constant.CouponsStatusEnum;
import com.yohobuy.ufo.model.promotion.request.CouponSendType;
import com.yohobuy.ufo.model.promotion.response.CouponInfo;
import com.yohobuy.ufo.model.promotion.response.CouponSendBo;
import com.yohoufo.common.utils.DateUtil;
... ... @@ -23,7 +25,13 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneOffset;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
... ... @@ -56,6 +64,26 @@ public class CouponServiceImpl implements ICouponService {
* @return
*/
public List<CouponSendBo> batchSendCoupon(Integer uid, String couponTokens){
return batchSendCoupon(uid,couponTokens,null);
}
@Override
public List<CouponSendBo> batchSendCoupon(Integer uid, String couponTokens, Integer sendType) {
// 允许重复发放
boolean repeatable;
// 有效期
Range<Integer> validityRange;
if(CouponSendType.PLATFORM_APPRAISE_UNSURE.equals(sendType)){
repeatable = true;
Integer now = DateUtil.getCurrentTimeSecond();
Integer end = (int) LocalDateTime.of(LocalDate.now().plusDays(7), LocalTime.MAX).toEpochSecond(ZoneOffset.of("+8"));
validityRange = Range.open(now, end);
}else {
repeatable = false;
validityRange = null;
}
if (uid == null || uid.intValue() <=0
|| StringUtils.isEmpty(couponTokens)){
... ... @@ -72,7 +100,7 @@ public class CouponServiceImpl implements ICouponService {
CouponSendBo couponSendBo = new CouponSendBo();
couponSendBo.setCouponToken(couponToken);
try {
couponSendBo.setCouponCode(sendCoupon(uid, couponToken));
couponSendBo.setCouponCode(sendCoupon(uid, couponToken, repeatable,validityRange));
couponSendBo.setSuccess(true);
} catch (ServiceException ex) {
logger.warn("happened serviceException,uid:{},couponTokens:{}", uid, couponTokens, ex);
... ... @@ -90,7 +118,7 @@ public class CouponServiceImpl implements ICouponService {
return couponSendBoList;
}
private String sendCoupon(Integer uid, String couponToken) {
private String sendCoupon(Integer uid, String couponToken,boolean repeatable, Range<Integer> validityRange) {
logger.info("senCoupon enter,{},{},{}", uid, couponToken);
... ... @@ -101,9 +129,10 @@ public class CouponServiceImpl implements ICouponService {
throw new ServiceException(ServiceError.PROMOTION_COUPON_HAS_NOT_EXISTS);
}
// 校验是否可以领取(重复领取,时间是否合法,状态)
checkCanAcquire(uid, couponToken, couponAndType);
if(!repeatable){
// 校验是否可以领取(重复领取,时间是否合法,状态)
checkCanAcquire(uid, couponToken, couponAndType);
}
// 校验 优惠券发放总数
checkAndAddCouponSendNum(uid, couponToken);
... ... @@ -111,6 +140,13 @@ public class CouponServiceImpl implements ICouponService {
// 发送优惠券
UserCoupon userCoupon = CouponConvert.convertUserCoupon(uid, couponCode, couponAndType);
// 指定有效期
if (Objects.nonNull(validityRange)
&& Objects.nonNull(validityRange.lowerEndpoint())
&& Objects.nonNull(validityRange.upperEndpoint())) {
userCoupon.setStartTime(validityRange.lowerEndpoint());
userCoupon.setEndTime(validityRange.upperEndpoint());
}
int count = userCouponMapper.insert(userCoupon);
logger.info("senCoupon success,{},{},{},{}", uid, couponToken, couponCode, count);
return couponCode;
... ...
... ... @@ -43,6 +43,17 @@ consumer:
delay:
interval: 2160
# 平台鉴定不能确定补发优惠券回调
- class: com.yohoufo.order.mq.consumer.BuyerCouponSendResultForAppraiseUnsureConsumer
topic: buyerOrder.couponSendResultForAppraiseUnsure
ratelimit: 20
### promotion
# 发券
- class: com.yohoufo.promotion.mq.CouponSendWithTradeMqNotifyConsumer
topic: ufo.couponSendWithTradeMqNotify
ratelimit: 20
#更新物流调拨信息
- address: 192.168.102.45:5672
username: yoho
... ...
... ... @@ -3,6 +3,7 @@ consumer:
username: ${rabbit_ufo_user}
password: ${rabbit_ufo_password}
consumers:
### order
- class: com.yohoufo.order.mq.consumer.SellerOrderAutoCancelDelayMsgConsumer
topic: sellerOrder.autoCancel
delay:
... ... @@ -61,6 +62,19 @@ consumer:
delay:
interval: 7200
# 平台鉴定不能确定补发优惠券回调
- class: com.yohoufo.order.mq.consumer.BuyerCouponSendResultForAppraiseUnsureConsumer
topic: buyerOrder.couponSendResultForAppraiseUnsure
ratelimit: 20
### promotion
# 发券
- class: com.yohoufo.promotion.mq.CouponSendWithTradeMqNotifyConsumer
topic: ufo.couponSendWithTradeMqNotify
ratelimit: 20
- address: ${rabbit_ufo}
username: ${rabbit_ufo_user}
password: ${rabbit_ufo_password}
... ...