Authored by wujiexiang

Merge branch 'dev_bid' into test6.9.13

@@ -41,7 +41,10 @@ public class OrderStatisticController { @@ -41,7 +41,10 @@ public class OrderStatisticController {
41 41
42 OrderSummaryResp orderSummaryResp2 = ibuyerOrderService.selectOrderNumByUid(uid); 42 OrderSummaryResp orderSummaryResp2 = ibuyerOrderService.selectOrderNumByUid(uid);
43 43
44 - return new ApiResponse.ApiResponseBuilder().code(200).data(Lists.newArrayList(orderSummaryResp1, orderSummaryResp2)).message("查询成功").build(); 44 + //求购中
  45 + OrderSummaryResp orderSummaryResp3 = ibuyerOrderService.selectBidingOrderNumByUid(uid, "biding");
  46 +
  47 + return new ApiResponse.ApiResponseBuilder().code(200).data(Lists.newArrayList(orderSummaryResp1, orderSummaryResp2, orderSummaryResp3)).message("查询成功").build();
45 } 48 }
46 49
47 @RequestMapping(params = "method=ufo.seller.orderSummary") 50 @RequestMapping(params = "method=ufo.seller.orderSummary")
@@ -62,7 +62,7 @@ public class BidAndSuggestPrice { @@ -62,7 +62,7 @@ public class BidAndSuggestPrice {
62 private void validateBidPriceConfig(BigDecimal prdPrice, BigDecimal minBidPrice) { 62 private void validateBidPriceConfig(BigDecimal prdPrice, BigDecimal minBidPrice) {
63 if (prdPrice.subtract(minBidPrice).doubleValue() < 0D) { 63 if (prdPrice.subtract(minBidPrice).doubleValue() < 0D) {
64 log.warn("BidPrice validate,prdPrice:{} < minBidPrice:{}", prdPrice, minBidPrice); 64 log.warn("BidPrice validate,prdPrice:{} < minBidPrice:{}", prdPrice, minBidPrice);
65 - throw new UfoServiceException(501, "您的出价过低"); 65 + throw new UfoServiceException(501, "出价请大于等于" + minBidPrice.toPlainString());
66 } 66 }
67 } 67 }
68 68
@@ -72,7 +72,7 @@ public class BidAndSuggestPrice { @@ -72,7 +72,7 @@ public class BidAndSuggestPrice {
72 * @param leastPrice 现货最低价 72 * @param leastPrice 现货最低价
73 * @param suggestRate 建议比例 73 * @param suggestRate 建议比例
74 */ 74 */
75 - public BigDecimal calculateSuggestPrice(BigDecimal leastPrice,double suggestRate) { 75 + public BigDecimal calculateSuggestPrice(BigDecimal leastPrice, double suggestRate) {
76 log.info("in BidAndSuggestPrice, leastPrice:{}, suggestRate:{}", leastPrice, suggestRate); 76 log.info("in BidAndSuggestPrice, leastPrice:{}, suggestRate:{}", leastPrice, suggestRate);
77 String priceText = leastPrice.multiply(BigDecimal.valueOf(suggestRate)).setScale(0, BigDecimal.ROUND_DOWN).toPlainString(); 77 String priceText = leastPrice.multiply(BigDecimal.valueOf(suggestRate)).setScale(0, BigDecimal.ROUND_DOWN).toPlainString();
78 String endNumber = "9"; 78 String endNumber = "9";
@@ -99,6 +99,7 @@ public abstract class AbstractBuyerOrderStateChanger<T extends RequestedStatusCh @@ -99,6 +99,7 @@ public abstract class AbstractBuyerOrderStateChanger<T extends RequestedStatusCh
99 afterChange(statusChangeBuyerOrder); 99 afterChange(statusChangeBuyerOrder);
100 //清理缓存 100 //清理缓存
101 cacheCleaner.cleanList(buyerOrder.getUid(), TabType.BUY.getValue()); 101 cacheCleaner.cleanList(buyerOrder.getUid(), TabType.BUY.getValue());
  102 + cacheCleaner.cleanDetail(buyerOrder.getUid(), buyerOrder.getOrderCode(), TabType.BUY);
102 } else { 103 } else {
103 logger.warn("[{}] change order fail, order status has changed", buyerOrder.getOrderCode()); 104 logger.warn("[{}] change order fail, order status has changed", buyerOrder.getOrderCode());
104 switch (operator) { 105 switch (operator) {
1 package com.yohoufo.order.service; 1 package com.yohoufo.order.service;
2 2
3 -import com.yoho.core.dal.datasource.annotation.Database;  
4 import com.yohobuy.ufo.model.order.common.OrderListType; 3 import com.yohobuy.ufo.model.order.common.OrderListType;
5 import com.yohobuy.ufo.model.order.common.OrderStatus; 4 import com.yohobuy.ufo.model.order.common.OrderStatus;
6 import com.yohobuy.ufo.model.order.req.SellerDeliverToDepotReq; 5 import com.yohobuy.ufo.model.order.req.SellerDeliverToDepotReq;
@@ -61,6 +60,14 @@ public interface IBuyerOrderService { @@ -61,6 +60,14 @@ public interface IBuyerOrderService {
61 */ 60 */
62 OrderSummaryResp selectOrderNumByUid(int uid); 61 OrderSummaryResp selectOrderNumByUid(int uid);
63 62
  63 + /**
  64 + * 根据uid查询求购中的订单数量
  65 + *
  66 + * @param uid
  67 + * @return
  68 + */
  69 + OrderSummaryResp selectBidingOrderNumByUid(int uid, String statKey);
  70 +
64 71
65 boolean delete(int uid, long orderCode); 72 boolean delete(int uid, long orderCode);
66 73
@@ -51,6 +51,20 @@ public class OrderCacheService { @@ -51,6 +51,20 @@ public class OrderCacheService {
51 return cacheClient.hashGet(key, hashKey, Integer.class); 51 return cacheClient.hashGet(key, hashKey, Integer.class);
52 } 52 }
53 53
  54 + public void cacheStatOrderSummary(int uid, TabType actor, String statKey, Integer cnt) {
  55 + String key = CacheKeyBuilder.orderListKey(uid, actor.getValue()).getKey();
  56 + try {
  57 + cacheClient.hashPut(key, statKey, cnt, ExpiredTime.ORDER_LIST);
  58 + } catch (Exception ex) {
  59 + logger.warn("in cacheStatOrderSummary fail ,uid {} actor {} cnt {}", uid, actor, cnt);
  60 + }
  61 + }
  62 +
  63 + public Integer getStatOrderSummary(int uid, TabType actor, String statKey) {
  64 + String key = CacheKeyBuilder.orderListKey(uid, actor.getValue()).getKey();
  65 + return cacheClient.hashGet(key, statKey, Integer.class);
  66 + }
  67 +
54 public void cacheSellerSaleGoodsTabSummary(int uid,List<OrderSummaryResp> list){ 68 public void cacheSellerSaleGoodsTabSummary(int uid,List<OrderSummaryResp> list){
55 TabType actor = TabType.SELL; 69 TabType actor = TabType.SELL;
56 String key = CacheKeyBuilder.sellerSaleGoodsSummarykey(uid, actor.getValue()).getKey(); 70 String key = CacheKeyBuilder.sellerSaleGoodsSummarykey(uid, actor.getValue()).getKey();
@@ -786,6 +786,23 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { @@ -786,6 +786,23 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
786 return null == num ? new OrderSummaryResp("buy", 0) : new OrderSummaryResp("buy", num); 786 return null == num ? new OrderSummaryResp("buy", 0) : new OrderSummaryResp("buy", num);
787 } 787 }
788 788
  789 + /**
  790 + * 根据uid查询求购中的订单数量
  791 + *
  792 + * @param uid
  793 + * @return
  794 + */
  795 + public OrderSummaryResp selectBidingOrderNumByUid(int uid, String statKey) {
  796 + Integer num = orderCacheService.getStatOrderSummary(uid, TabType.BUY, statKey);
  797 + if (num == null) {
  798 + num = buyerOrderMapper.selectCntByUidStatus(uid, Lists.newArrayList(OrderStatus.BIDING.getCode()));
  799 + }
  800 + if (num != null) {
  801 + orderCacheService.cacheStatOrderSummary(uid, TabType.BUY, statKey, num);
  802 + }
  803 + return null == num ? new OrderSummaryResp(statKey, 0) : new OrderSummaryResp(statKey, num);
  804 + }
  805 +
789 806
790 807
791 808
@@ -87,6 +87,7 @@ public class BuyerOrderWaitingPayCancelChanger extends AbstractBuyerOrderStateCh @@ -87,6 +87,7 @@ public class BuyerOrderWaitingPayCancelChanger extends AbstractBuyerOrderStateCh
87 List<Statement> statements = new ArrayList<>(); 87 List<Statement> statements = new ArrayList<>();
88 if (buyerOrder.isBidOrder()) { 88 if (buyerOrder.isBidOrder()) {
89 statements.add(() -> bidOrderAfterStatement(buyerOrder)); 89 statements.add(() -> bidOrderAfterStatement(buyerOrder));
  90 + statements.add(() -> cacheCleaner.cleanSellerAndBuyerOrderDetailAndList(buyerOrder.getSellerUid(), buyerOrder.getUid(), buyerOrder.getOrderCode()));
90 } else { 91 } else {
91 //nothing 92 //nothing
92 } 93 }
@@ -107,8 +108,8 @@ public class BuyerOrderWaitingPayCancelChanger extends AbstractBuyerOrderStateCh @@ -107,8 +108,8 @@ public class BuyerOrderWaitingPayCancelChanger extends AbstractBuyerOrderStateCh
107 int sellerUid = buyerOrder.getSellerUid(); 108 int sellerUid = buyerOrder.getSellerUid();
108 logger.info("Transfer deposit to sellerUid:{} with depositAmount:{},because buyerOrder:{} is canceled", sellerUid, depositAmount, buyerOrderCode); 109 logger.info("Transfer deposit to sellerUid:{} with depositAmount:{},because buyerOrder:{} is canceled", sellerUid, depositAmount, buyerOrderCode);
109 TransferMoneyRequest tmReq = buildTransferMoneyRequest4Seller(buyerUid, buyerOrderCode, sellerUid, BigDecimal.valueOf(depositAmount)); 110 TransferMoneyRequest tmReq = buildTransferMoneyRequest4Seller(buyerUid, buyerOrderCode, sellerUid, BigDecimal.valueOf(depositAmount));
110 - transferService.transfer(tmReq);  
111 - logger.info("Transfer deposit to sellerUid:{} with depositAmount:{} end ", sellerUid, depositAmount); 111 + boolean result = transferService.transfer(tmReq);
  112 + logger.info("Transfer deposit to sellerUid:{} with depositAmount:{} end,result:{}", sellerUid, depositAmount, result);
112 } 113 }
113 114
114 /** 115 /**