Authored by chenchao

fix bugs

@@ -96,7 +96,7 @@ public interface SellerOrderGoodsMapper { @@ -96,7 +96,7 @@ public interface SellerOrderGoodsMapper {
96 * @param statusList 96 * @param statusList
97 * @return 97 * @return
98 */ 98 */
99 - List<SellerOrderGoods> selectByPayment(@Param("payment") int payment, 99 + List<SellerOrderGoods> selectByPayment(@Param("payment") Integer payment,
100 @Param("condition") SellerOrderGoods record, 100 @Param("condition") SellerOrderGoods record,
101 @Param("statusList") Collection<Integer> statusList, 101 @Param("statusList") Collection<Integer> statusList,
102 @Param("num") int num); 102 @Param("num") int num);
@@ -457,7 +457,9 @@ @@ -457,7 +457,9 @@
457 and sog.uid = #{condition.uid,jdbcType=INTEGER} 457 and sog.uid = #{condition.uid,jdbcType=INTEGER}
458 and sog.product_id = #{condition.productId,jdbcType=INTEGER} 458 and sog.product_id = #{condition.productId,jdbcType=INTEGER}
459 and sog.storage_id = #{condition.storageId,jdbcType=INTEGER} 459 and sog.storage_id = #{condition.storageId,jdbcType=INTEGER}
  460 + <if test="payment != null">
460 and so.payment = #{payment,jdbcType=INTEGER} 461 and so.payment = #{payment,jdbcType=INTEGER}
  462 + </if>
461 and sog.goods_price = #{condition.goodsPrice,jdbcType=DECIMAL} 463 and sog.goods_price = #{condition.goodsPrice,jdbcType=DECIMAL}
462 <if test="condition.attributes != null"> 464 <if test="condition.attributes != null">
463 and sog.attributes = #{condition.attributes,jdbcType=INTEGER} 465 and sog.attributes = #{condition.attributes,jdbcType=INTEGER}
@@ -27,6 +27,7 @@ import com.yohoufo.order.model.response.PrepayResponse; @@ -27,6 +27,7 @@ import com.yohoufo.order.model.response.PrepayResponse;
27 import com.yohoufo.order.mq.DelayTime; 27 import com.yohoufo.order.mq.DelayTime;
28 import com.yohoufo.order.service.cache.CacheCleaner; 28 import com.yohoufo.order.service.cache.CacheCleaner;
29 import com.yohoufo.order.service.cache.CacheKeyBuilder; 29 import com.yohoufo.order.service.cache.CacheKeyBuilder;
  30 +import com.yohoufo.order.service.impl.AppraiseService;
30 import com.yohoufo.order.service.impl.MetaConfigService; 31 import com.yohoufo.order.service.impl.MetaConfigService;
31 import com.yohoufo.order.service.impl.OrderOverTimeService; 32 import com.yohoufo.order.service.impl.OrderOverTimeService;
32 import com.yohoufo.order.service.impl.TradeBillsService; 33 import com.yohoufo.order.service.impl.TradeBillsService;
@@ -93,22 +94,27 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService { @@ -93,22 +94,27 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService {
93 @Autowired 94 @Autowired
94 private DepositService depositService; 95 private DepositService depositService;
95 96
  97 + @Autowired
  98 + private AppraiseService appraiseService;
96 /** 99 /**
97 * 更新订单状态 100 * 更新订单状态
98 * @param orderInfo 101 * @param orderInfo
99 */ 102 */
100 public int updateOrderStatusPaid(OrderInfo orderInfo){ 103 public int updateOrderStatusPaid(OrderInfo orderInfo){
101 Integer uid = orderInfo.getUid(); 104 Integer uid = orderInfo.getUid();
  105 + Long orderCode;
102 BuyerOrder buyerOrder = new BuyerOrder(); 106 BuyerOrder buyerOrder = new BuyerOrder();
103 - buyerOrder.setOrderCode(orderInfo.getOrderCode()); 107 + buyerOrder.setOrderCode(orderCode = orderInfo.getOrderCode());
104 buyerOrder.setUid(uid); 108 buyerOrder.setUid(uid);
105 -  
106 - int orderStatusCode = OrderStatus.HAS_PAYED.getCode(); 109 + OrderStatus targetOrderStatus = OrderStatus.HAS_PAYED;
  110 + boolean isQuickDeliver = false;
107 //门店订单支付后直接完成 111 //门店订单支付后直接完成
108 - if(BuyerOrderUtils.isOffline(orderInfo)) {  
109 - orderStatusCode = OrderStatus.DONE.getCode(); 112 + if(BuyerOrderUtils.isOffline(orderInfo) ) {
  113 + targetOrderStatus = OrderStatus.DONE;
  114 + }else if(isQuickDeliver=BuyerOrderUtils.isQuickDeliver(orderInfo.getAttributes())){
  115 + targetOrderStatus = OrderStatus.WAITING_RECEIVE;
110 } 116 }
111 - 117 + int orderStatusCode = targetOrderStatus.getCode();
112 buyerOrder.setStatus(orderStatusCode); 118 buyerOrder.setStatus(orderStatusCode);
113 119
114 // 用于控制并发更新的 120 // 用于控制并发更新的
@@ -120,8 +126,11 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService { @@ -120,8 +126,11 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService {
120 if(result>0){ 126 if(result>0){
121 //记录状态信息 127 //记录状态信息
122 logger.info("in updateOrderStatusPaid record status change, orderCode {}, status: {}", 128 logger.info("in updateOrderStatusPaid record status change, orderCode {}, status: {}",
123 - orderInfo.getOrderCode(), orderStatusCode);  
124 - orderStatusFlowService.addAsy(orderInfo.getOrderCode(), orderStatusCode); 129 + orderCode, orderStatusCode);
  130 + orderStatusFlowService.addAsy(orderCode, orderStatusCode);
  131 + if (isQuickDeliver){
  132 + appraiseService.processQuickDeliverOrderAfterPaid(orderCode, uid);
  133 + }
125 } 134 }
126 orderInfo.setStatus(orderStatusCode); 135 orderInfo.setStatus(orderStatusCode);
127 return result; 136 return result;
@@ -410,6 +410,8 @@ public class AppraiseService { @@ -410,6 +410,8 @@ public class AppraiseService {
410 inBoxFacade.sellerQualityCheckNotPass_send_back(sellerOrderGoods, orderCode, wayBillCode, type); 410 inBoxFacade.sellerQualityCheckNotPass_send_back(sellerOrderGoods, orderCode, wayBillCode, type);
411 } 411 }
412 412
  413 +
  414 +
413 private SellerOrderGoods cleanCacheAfterUpdateStatus(long orderCode, int uid, int sellerUid) { 415 private SellerOrderGoods cleanCacheAfterUpdateStatus(long orderCode, int uid, int sellerUid) {
414 BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(uid, orderCode); 416 BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(uid, orderCode);
415 SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(bog.getSkup()); 417 SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(bog.getSkup());
@@ -770,8 +772,12 @@ public class AppraiseService { @@ -770,8 +772,12 @@ public class AppraiseService {
770 } 772 }
771 773
772 //更新卖家订单的状态,并清缓存 774 //更新卖家订单的状态,并清缓存
773 - private SellerOrderGoods updateSellerOrderStatusAndCleanCache(int sellerUid, long sellerOrderCode, SellerOrderStatus expectSOStatus, SellerOrderStatus targetSoStatus,  
774 - int skup, Long orderCode, int buyerUid) { 775 + private SellerOrderGoods updateSellerOrderStatusAndCleanCache(int sellerUid,
  776 + long sellerOrderCode,
  777 + SellerOrderStatus expectSOStatus,
  778 + SellerOrderStatus targetSoStatus,
  779 + int skup,
  780 + Long orderCode, int buyerUid) {
775 SellerOrder tso = new SellerOrder(); 781 SellerOrder tso = new SellerOrder();
776 tso.setUid(sellerUid); 782 tso.setUid(sellerUid);
777 tso.setOrderCode(sellerOrderCode); 783 tso.setOrderCode(sellerOrderCode);
@@ -780,19 +786,12 @@ public class AppraiseService { @@ -780,19 +786,12 @@ public class AppraiseService {
780 tso.setUpdateTime(DateUtil.getCurrentTimeSecond()); 786 tso.setUpdateTime(DateUtil.getCurrentTimeSecond());
781 int soCnt = sellerOrderMapper.updateByOrderCode(tso); 787 int soCnt = sellerOrderMapper.updateByOrderCode(tso);
782 SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup); 788 SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
783 - cacheCleaner.delete(Arrays.asList(CacheKeyBuilder.orderListKey(sellerUid, TabType.SELL.getValue()),  
784 - CacheKeyBuilder.orderListKey(buyerUid, TabType.BUY.getValue()),  
785 - CacheKeyBuilder.sellerOrderDetailKey(sellerOrderGoods),  
786 - CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), orderCode),  
787 - CacheKeyBuilder.orderDetailKey(buyerUid, TabType.BUY.getValue(), orderCode),  
788 - CacheKeyBuilder.buyerOrderNums(buyerUid)));  
789 -  
790 -  
791 - ErpBuyerOrderEvent event = new ErpBuyerOrderEvent(buyerUid);  
792 - EventBusPublisher.publishEvent(event); 789 + cleanCacheAfterUpdateStatus(orderCode, buyerUid, sellerUid);
793 return sellerOrderGoods; 790 return sellerOrderGoods;
794 } 791 }
795 792
  793 +
  794 +
796 /** 795 /**
797 * 更新发到卖家的物流信息 796 * 更新发到卖家的物流信息
798 * 将卖家的保证金分账给平台和买家 797 * 将卖家的保证金分账给平台和买家
@@ -1035,6 +1034,7 @@ public class AppraiseService { @@ -1035,6 +1034,7 @@ public class AppraiseService {
1035 return model; 1034 return model;
1036 } 1035 }
1037 1036
  1037 +
1038 /** 1038 /**
1039 * 手机质检端的鉴定不通过 1039 * 手机质检端的鉴定不通过
1040 * <p> 1040 * <p>
@@ -1287,12 +1287,8 @@ public class AppraiseService { @@ -1287,12 +1287,8 @@ public class AppraiseService {
1287 return apiResponse; 1287 return apiResponse;
1288 } 1288 }
1289 1289
  1290 + private void transferGoodsMoneyWhenPass(Integer sellerUid, Integer skup, Long orderCode){
1290 1291
1291 - /**  
1292 - * 通过时 ,操作钱  
1293 - */  
1294 - private PaymentRequest operateMoneyWhenOk(Integer buyerUid, Long orderCode, int skup, SellerOrder sellerOrder, SellerOrderStatus targetSoStatus) {  
1295 - final Integer sellerUid = sellerOrder.getUid();  
1296 BigDecimal saleIncome = getSaleIncome(sellerUid, skup); 1292 BigDecimal saleIncome = getSaleIncome(sellerUid, skup);
1297 1293
1298 TransferCase transferCase = TransferCase.ALL_GOODS_MONEY_TO_SELLER; 1294 TransferCase transferCase = TransferCase.ALL_GOODS_MONEY_TO_SELLER;
@@ -1315,6 +1311,21 @@ public class AppraiseService { @@ -1315,6 +1311,21 @@ public class AppraiseService {
1315 LOGGER.info("in appraiseSuccess,begin transfer async"); 1311 LOGGER.info("in appraiseSuccess,begin transfer async");
1316 transferService.transfer(tmReq); 1312 transferService.transfer(tmReq);
1317 }); 1313 });
  1314 + }
  1315 +
  1316 + /**
  1317 + * 通过时 ,操作钱
  1318 + */
  1319 + private PaymentRequest operateMoneyWhenOk(Integer buyerUid, Long orderCode, int skup, SellerOrder sellerOrder, SellerOrderStatus targetSoStatus) {
  1320 + final Integer sellerUid = sellerOrder.getUid();
  1321 + BigDecimal saleIncome = getSaleIncome(sellerUid, skup);
  1322 +
  1323 + TranseferCellNode transeferCellNode = new TranseferCellNode();
  1324 + transeferCellNode.setUid(sellerUid);
  1325 + transeferCellNode.setAmount(saleIncome);
  1326 +
  1327 +
  1328 + transferGoodsMoneyWhenPass(sellerUid, skup, orderCode);
1318 1329
1319 //退保证金给卖家 1330 //退保证金给卖家
1320 //refund earnestMoney 1331 //refund earnestMoney
@@ -1539,4 +1550,16 @@ public class AppraiseService { @@ -1539,4 +1550,16 @@ public class AppraiseService {
1539 } 1550 }
1540 } 1551 }
1541 } 1552 }
  1553 +
  1554 + public void processQuickDeliverOrderAfterPaid(long orderCode,int uid){
  1555 + BuyerOrderGoods pbog = buyerOrderGoodsMapper.selectOnlyByOrderCode(orderCode);
  1556 + BuyerOrder pbo = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
  1557 + try {
  1558 + transferGoodsMoneyWhenPass(pbo.getSellerUid(), pbog.getSkup(), orderCode);
  1559 + }catch (Exception ex){
  1560 + LOGGER.warn("in processQuickDeliverOrderAfterPaid transferGoodsMoneyWhenPass fail orderCode {} uid {}",
  1561 + orderCode, uid, ex);
  1562 + }
  1563 +
  1564 + }
1542 } 1565 }
1 package com.yohoufo.order.service.seller.processor; 1 package com.yohoufo.order.service.seller.processor;
2 2
3 import com.yohobuy.ufo.model.order.common.SkupStatus; 3 import com.yohobuy.ufo.model.order.common.SkupStatus;
  4 +import com.yohobuy.ufo.model.order.constants.SkupType;
4 import com.yohobuy.ufo.model.order.req.SellerBatchChangeReq; 5 import com.yohobuy.ufo.model.order.req.SellerBatchChangeReq;
5 import com.yohoufo.common.exception.UfoServiceException; 6 import com.yohoufo.common.exception.UfoServiceException;
6 import com.yohoufo.dal.order.model.SellerOrderGoods; 7 import com.yohoufo.dal.order.model.SellerOrderGoods;
7 import com.yohobuy.ufo.model.order.common.Payment; 8 import com.yohobuy.ufo.model.order.common.Payment;
8 import com.yohoufo.order.model.dto.SkupDto; 9 import com.yohoufo.order.model.dto.SkupDto;
  10 +import com.yohoufo.order.utils.SellerGoodsHelper;
9 import org.springframework.stereotype.Service; 11 import org.springframework.stereotype.Service;
10 import org.springframework.util.Assert; 12 import org.springframework.util.Assert;
11 13
@@ -31,7 +33,12 @@ public class AdjustPricePrepareProcessor extends AbsEntryChangePricePrepareProce @@ -31,7 +33,12 @@ public class AdjustPricePrepareProcessor extends AbsEntryChangePricePrepareProce
31 condition.setStorageId(req.getStorageId()); 33 condition.setStorageId(req.getStorageId());
32 condition.setGoodsPrice(req.getOldPrice()); 34 condition.setGoodsPrice(req.getOldPrice());
33 condition.setAttributes(req.getSkupType()); 35 condition.setAttributes(req.getSkupType());
34 - return sellerOrderGoodsMapper.selectByPayment(Payment.WALLET.getCode(), condition, Arrays.asList(SkupStatus.CAN_SELL.getCode()), req.getNum()); 36 + SkupType skupType = SkupType.getSkupType(req.getSkupType());
  37 + Integer payment = Payment.WALLET.getCode();
  38 + if (SellerGoodsHelper.isQuickDeliver(skupType)){
  39 + payment = null;
  40 + }
  41 + return sellerOrderGoodsMapper.selectByPayment(payment, condition, Arrays.asList(SkupStatus.CAN_SELL.getCode()), req.getNum());
35 } 42 }
36 43
37 @Override 44 @Override
@@ -10,6 +10,7 @@ import com.yohobuy.ufo.model.order.common.Payment; @@ -10,6 +10,7 @@ import com.yohobuy.ufo.model.order.common.Payment;
10 import com.yohoufo.order.model.dto.SkupDownShelfPrepareDto; 10 import com.yohoufo.order.model.dto.SkupDownShelfPrepareDto;
11 import com.yohoufo.order.model.dto.SkupDto; 11 import com.yohoufo.order.model.dto.SkupDto;
12 import com.yohoufo.order.utils.LoggerUtils; 12 import com.yohoufo.order.utils.LoggerUtils;
  13 +import com.yohoufo.order.utils.SellerGoodsHelper;
13 import org.apache.commons.collections.CollectionUtils; 14 import org.apache.commons.collections.CollectionUtils;
14 import org.slf4j.Logger; 15 import org.slf4j.Logger;
15 import org.springframework.beans.factory.annotation.Autowired; 16 import org.springframework.beans.factory.annotation.Autowired;
@@ -66,8 +67,9 @@ public class SellerDownShelfPrepareProcessor { @@ -66,8 +67,9 @@ public class SellerDownShelfPrepareProcessor {
66 logger.warn("batch off shelve checkAndAcquire uid illegal , req {}", req); 67 logger.warn("batch off shelve checkAndAcquire uid illegal , req {}", req);
67 throw new UfoServiceException(400, "参数[oldPrice]不合法"); 68 throw new UfoServiceException(400, "参数[oldPrice]不合法");
68 } 69 }
  70 +
69 //检查 71 //检查
70 - Map<Integer, SkupDto> skupMap = checkNeedProcessSkups(req); 72 + Map<Integer, SkupDto> skupMap = checkNeedProcessSkups(req, skupType);
71 73
72 SkupDownShelfPrepareDto sdspDto = SkupDownShelfPrepareDto.builder() 74 SkupDownShelfPrepareDto sdspDto = SkupDownShelfPrepareDto.builder()
73 .idSkupMap(skupMap) 75 .idSkupMap(skupMap)
@@ -76,14 +78,19 @@ public class SellerDownShelfPrepareProcessor { @@ -76,14 +78,19 @@ public class SellerDownShelfPrepareProcessor {
76 return sdspDto; 78 return sdspDto;
77 } 79 }
78 80
79 - private Map<Integer, SkupDto> checkNeedProcessSkups(SellerBatchChangeReq req) { 81 + private Map<Integer, SkupDto> checkNeedProcessSkups(SellerBatchChangeReq req, SkupType skupType) {
  82 +
80 SellerOrderGoods condition = new SellerOrderGoods(); 83 SellerOrderGoods condition = new SellerOrderGoods();
81 condition.setUid(req.getUid()); 84 condition.setUid(req.getUid());
82 condition.setProductId(req.getProductId()); 85 condition.setProductId(req.getProductId());
83 condition.setStorageId(req.getStorageId()); 86 condition.setStorageId(req.getStorageId());
84 condition.setGoodsPrice(req.getOldPrice()); 87 condition.setGoodsPrice(req.getOldPrice());
85 condition.setAttributes(req.getSkupType()); 88 condition.setAttributes(req.getSkupType());
86 - List<SellerOrderGoods> sellerOrderGoodList = sellerOrderGoodsMapper.selectByPayment(Payment.WALLET.getCode(), condition, CAN_OFF_STATUS, req.getNum()); 89 + Integer payment = Payment.WALLET.getCode();
  90 + if (SellerGoodsHelper.isQuickDeliver(skupType)){
  91 + payment = null;
  92 + }
  93 + List<SellerOrderGoods> sellerOrderGoodList = sellerOrderGoodsMapper.selectByPayment(payment, condition, CAN_OFF_STATUS, req.getNum());
87 if (CollectionUtils.isEmpty(sellerOrderGoodList)) { 94 if (CollectionUtils.isEmpty(sellerOrderGoodList)) {
88 logger.warn("batch off shelve checkAndAcquire not find skups by batchNo, req {}", req); 95 logger.warn("batch off shelve checkAndAcquire not find skups by batchNo, req {}", req);
89 throw new UfoServiceException(501, "商品已被下单购买"); 96 throw new UfoServiceException(501, "商品已被下单购买");
@@ -248,4 +248,5 @@ public class QuickDeliverGoodsService { @@ -248,4 +248,5 @@ public class QuickDeliverGoodsService {
248 return respBuilder.build(); 248 return respBuilder.build();
249 } 249 }
250 250
  251 +
251 } 252 }
@@ -5,6 +5,8 @@ import com.yohobuy.ufo.model.order.common.OrderAttributes; @@ -5,6 +5,8 @@ import com.yohobuy.ufo.model.order.common.OrderAttributes;
5 import com.yohobuy.ufo.model.order.common.OrderStatus; 5 import com.yohobuy.ufo.model.order.common.OrderStatus;
6 import com.yohoufo.dal.order.model.BuyerOrder; 6 import com.yohoufo.dal.order.model.BuyerOrder;
7 7
  8 +import java.util.Objects;
  9 +
8 public class BuyerOrderUtils { 10 public class BuyerOrderUtils {
9 11
10 /** 12 /**
@@ -57,4 +59,9 @@ public class BuyerOrderUtils { @@ -57,4 +59,9 @@ public class BuyerOrderUtils {
57 public static boolean isDeposit(BuyerOrder buyerOrder) { 59 public static boolean isDeposit(BuyerOrder buyerOrder) {
58 return isDeposit(buyerOrder.getAttributes()); 60 return isDeposit(buyerOrder.getAttributes());
59 } 61 }
  62 +
  63 +
  64 + public static boolean isQuickDeliver(Integer orderAttrCode){
  65 + return Objects.nonNull(orderAttrCode) && Objects.equals(OrderAttributes.QUICK_DELIVER.getCode(), orderAttrCode);
  66 + }
60 } 67 }
1 package com.yohoufo.product.service.listener; 1 package com.yohoufo.product.service.listener;
2 2
3 -import com.alibaba.fastjson.JSONObject;  
4 -import com.yoho.core.rest.client.ServiceCaller;  
5 -import com.yohobuy.ufo.model.order.bo.AppraiseExpressInfoBo;  
6 import com.yohobuy.ufo.model.request.nfc.ProductIdentifyVo; 3 import com.yohobuy.ufo.model.request.nfc.ProductIdentifyVo;
7 import com.yohoufo.product.event.ProductIdentifyEvent; 4 import com.yohoufo.product.event.ProductIdentifyEvent;
8 import com.yohoufo.product.service.ProductIdentifyService; 5 import com.yohoufo.product.service.ProductIdentifyService;
@@ -12,8 +9,6 @@ import org.springframework.beans.factory.annotation.Autowired; @@ -12,8 +9,6 @@ import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.context.ApplicationListener; 9 import org.springframework.context.ApplicationListener;
13 import org.springframework.stereotype.Service; 10 import org.springframework.stereotype.Service;
14 11
15 -import java.util.concurrent.TimeUnit;  
16 -  
17 /** 12 /**
18 * Created by li.ma on 2019/7/11. 13 * Created by li.ma on 2019/7/11.
19 */ 14 */