Authored by mali

Merge branch 'test6.9.12' of http://git.yoho.cn/ufo/yohoufo-fore into test6.9.12

@@ -103,4 +103,6 @@ public interface StorageDepositMapper { @@ -103,4 +103,6 @@ public interface StorageDepositMapper {
103 103
104 int updateValidStatus(@Param("id")Integer id); 104 int updateValidStatus(@Param("id")Integer id);
105 105
  106 + int updateSellLock(@Param("id")Integer id, @Param("sellLock")Integer sellLock, @Param("preSellLock")Integer preSellLock);
  107 +
106 } 108 }
@@ -49,6 +49,8 @@ public class StorageDeposit { @@ -49,6 +49,8 @@ public class StorageDeposit {
49 private Integer depositType; 49 private Integer depositType;
50 50
51 private Long parentOrderCode; 51 private Long parentOrderCode;
  52 +
  53 + private Integer sellLock;
52 54
53 public Long getParentOrderCode() { 55 public Long getParentOrderCode() {
54 return parentOrderCode; 56 return parentOrderCode;
@@ -233,4 +235,13 @@ public class StorageDeposit { @@ -233,4 +235,13 @@ public class StorageDeposit {
233 public void setNewSkup(Integer newSkup) { 235 public void setNewSkup(Integer newSkup) {
234 this.newSkup = newSkup; 236 this.newSkup = newSkup;
235 } 237 }
  238 +
  239 + public Integer getSellLock() {
  240 + return sellLock;
  241 + }
  242 +
  243 + public void setSellLock(Integer sellLock) {
  244 + this.sellLock = sellLock;
  245 + }
  246 +
236 } 247 }
@@ -25,6 +25,7 @@ @@ -25,6 +25,7 @@
25 <result column="deposit_type" property="depositType" jdbcType="INTEGER" /> 25 <result column="deposit_type" property="depositType" jdbcType="INTEGER" />
26 <result column="source" property="source" jdbcType="INTEGER" /> 26 <result column="source" property="source" jdbcType="INTEGER" />
27 <result column="parent_order_code" property="parentOrderCode" jdbcType="BIGINT" /> 27 <result column="parent_order_code" property="parentOrderCode" jdbcType="BIGINT" />
  28 + <result column="sell_lock" property="sellLock" jdbcType="INTEGER" />
28 </resultMap> 29 </resultMap>
29 30
30 <resultMap id="CountResultMap" type="com.yohoufo.dal.order.model.StorageDepositCount" > 31 <resultMap id="CountResultMap" type="com.yohoufo.dal.order.model.StorageDepositCount" >
@@ -38,7 +39,7 @@ @@ -38,7 +39,7 @@
38 <sql id="Base_Column_List" > 39 <sql id="Base_Column_List" >
39 id, product_id, goods_id, storage_id, deposit_code, shelf_code, owner_uid, order_code, 40 id, product_id, goods_id, storage_id, deposit_code, shelf_code, owner_uid, order_code,
40 skup, status, order_status, update_time, create_time, deposit_start_time, deposit_end_time, 41 skup, status, order_status, update_time, create_time, deposit_start_time, deposit_end_time,
41 - edit_pid, del_status, out_type, new_order_code, new_skup, parent_order_code, source, deposit_type, parent_order_code 42 + edit_pid, del_status, out_type, new_order_code, new_skup, parent_order_code, source, deposit_type, parent_order_code, sell_lock
42 </sql> 43 </sql>
43 <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" > 44 <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
44 select 45 select
@@ -278,4 +279,12 @@ @@ -278,4 +279,12 @@
278 where id=#{id} and del_status=1 279 where id=#{id} and del_status=1
279 </update> 280 </update>
280 281
  282 + <update id="updateSellLock">
  283 + update storage_deposit
  284 + set sell_lock = #{sellLock,jdbcType=INTEGER} ,update_time = unix_timestamp(now())
  285 + where id = #{id,jdbcType=INTEGER}
  286 + AND sell_lock = #{preSellLock,jdbcType=INTEGER}
  287 + AND del_status = 0
  288 + </update>
  289 +
281 </mapper> 290 </mapper>
@@ -249,7 +249,7 @@ public class DepositController { @@ -249,7 +249,7 @@ public class DepositController {
249 249
250 @RequestMapping(params = "method=ufo.deposit.list") 250 @RequestMapping(params = "method=ufo.deposit.list")
251 @Cachable(expire = 30, pageArgs = {2,3}) 251 @Cachable(expire = 30, pageArgs = {2,3})
252 - public ApiResponse save(@RequestParam("uid") Integer uid, @RequestParam("storageId") Integer storageId, 252 + public ApiResponse queryListByUidAndStorageId(@RequestParam("uid") Integer uid, @RequestParam("storageId") Integer storageId,
253 @RequestParam(value = "page", required = false, defaultValue = "1") Integer page, 253 @RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
254 @RequestParam(value = "limit", required = false, defaultValue = "10") Integer limit) { 254 @RequestParam(value = "limit", required = false, defaultValue = "10") Integer limit) {
255 LOG.info("ufo.deposit.list in. uid is {}", uid); 255 LOG.info("ufo.deposit.list in. uid is {}", uid);
@@ -133,5 +133,14 @@ public interface DepositService { @@ -133,5 +133,14 @@ public interface DepositService {
133 * @return 133 * @return
134 */ 134 */
135 boolean updateDepositAfterCancelBuy(Integer uid, String depositCode); 135 boolean updateDepositAfterCancelBuy(Integer uid, String depositCode);
  136 +
  137 + /**
  138 + * 更新出售锁状态
  139 + * @param uid
  140 + * @param depositCode
  141 + * @param sellLock
  142 + * @return
  143 + */
  144 + int updateSellLock(Integer uid, String depositCode, Integer sellLock);
136 145
137 } 146 }
@@ -10,14 +10,23 @@ import java.util.concurrent.*; @@ -10,14 +10,23 @@ import java.util.concurrent.*;
10 public class ThreadPoolFactory { 10 public class ThreadPoolFactory {
11 11
12 static class GoodKids{ 12 static class GoodKids{
13 - private static ForkJoinPool forkJoinPool ;  
14 - private static ThreadPoolExecutor threadpool ; 13 + private final static ForkJoinPool forkJoinPool ;
  14 + private final static ThreadPoolExecutor threadpool ;
15 private final static ExecutorService executorService ; 15 private final static ExecutorService executorService ;
  16 + private final static ExecutorService appraiseExecutorService;
  17 + private final static ExecutorService depositRebateExecutorService;
16 static { 18 static {
  19 + int numberOfProcessorsAvailable = Runtime.getRuntime().availableProcessors();
17 forkJoinPool = new ForkJoinPool(6); 20 forkJoinPool = new ForkJoinPool(6);
18 - threadpool = new ThreadPoolExecutor(4, 10, 60, TimeUnit.SECONDS, 21 + threadpool = new ThreadPoolExecutor(numberOfProcessorsAvailable, numberOfProcessorsAvailable*2, 60, TimeUnit.SECONDS,
19 new ArrayBlockingQueue<>(100), NamedThreadFactory.newThreadFactory("buyer-cancel-order")); 22 new ArrayBlockingQueue<>(100), NamedThreadFactory.newThreadFactory("buyer-cancel-order"));
20 - executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2); 23 + executorService = Executors.newFixedThreadPool(numberOfProcessorsAvailable * 2);
  24 + //appraise
  25 + appraiseExecutorService = new ThreadPoolExecutor(numberOfProcessorsAvailable, numberOfProcessorsAvailable * 2, 60, TimeUnit.SECONDS,
  26 + new ArrayBlockingQueue<>(1000), NamedThreadFactory.newThreadFactory("appraise"));
  27 + //
  28 + depositRebateExecutorService = new ThreadPoolExecutor(numberOfProcessorsAvailable , numberOfProcessorsAvailable * 2, 60, TimeUnit.SECONDS,
  29 + new ArrayBlockingQueue<>(10), NamedThreadFactory.newThreadFactory("depositRebate"));
21 } 30 }
22 31
23 32
@@ -35,4 +44,13 @@ public class ThreadPoolFactory { @@ -35,4 +44,13 @@ public class ThreadPoolFactory {
35 public static ExecutorService getCommomExecutorService(){ 44 public static ExecutorService getCommomExecutorService(){
36 return GoodKids.executorService; 45 return GoodKids.executorService;
37 } 46 }
  47 +
  48 + public static ExecutorService getAppraiseExecutorService(){
  49 + return GoodKids.appraiseExecutorService;
  50 + }
  51 +
  52 +
  53 + public static ExecutorService getDepositRebateExecutorService(){
  54 + return GoodKids.depositRebateExecutorService;
  55 + }
38 } 56 }
@@ -17,21 +17,17 @@ import com.yohoufo.order.constants.AlarmConfig; @@ -17,21 +17,17 @@ import com.yohoufo.order.constants.AlarmConfig;
17 import com.yohoufo.order.model.request.TranseferCellNode; 17 import com.yohoufo.order.model.request.TranseferCellNode;
18 import com.yohoufo.order.model.request.TransferMoneyRequest; 18 import com.yohoufo.order.model.request.TransferMoneyRequest;
19 import com.yohoufo.order.service.IGoodsService; 19 import com.yohoufo.order.service.IGoodsService;
20 -import com.yohoufo.order.service.handler.transfer.TransferChancelSelector; 20 +import com.yohoufo.order.service.concurrent.ThreadPoolFactory;
21 import com.yohoufo.order.service.proxy.OrderStatusFlowService; 21 import com.yohoufo.order.service.proxy.OrderStatusFlowService;
22 import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; 22 import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
23 import com.yohoufo.order.utils.LoggerUtils; 23 import com.yohoufo.order.utils.LoggerUtils;
24 -import com.yohoufo.order.utils.NamedThreadFactory;  
25 import org.apache.commons.collections.CollectionUtils; 24 import org.apache.commons.collections.CollectionUtils;
26 import org.slf4j.Logger; 25 import org.slf4j.Logger;
27 import org.springframework.beans.factory.annotation.Autowired; 26 import org.springframework.beans.factory.annotation.Autowired;
28 27
29 import java.math.BigDecimal; 28 import java.math.BigDecimal;
30 import java.util.List; 29 import java.util.List;
31 -import java.util.concurrent.ArrayBlockingQueue;  
32 import java.util.concurrent.ExecutorService; 30 import java.util.concurrent.ExecutorService;
33 -import java.util.concurrent.ThreadPoolExecutor;  
34 -import java.util.concurrent.TimeUnit;  
35 import java.util.stream.Collectors; 31 import java.util.stream.Collectors;
36 32
37 public abstract class AbsGoodsServiceOrderService implements IGoodsService { 33 public abstract class AbsGoodsServiceOrderService implements IGoodsService {
@@ -46,9 +42,6 @@ public abstract class AbsGoodsServiceOrderService implements IGoodsService { @@ -46,9 +42,6 @@ public abstract class AbsGoodsServiceOrderService implements IGoodsService {
46 OrderCodeGenerator orderCodeGenerator; 42 OrderCodeGenerator orderCodeGenerator;
47 43
48 @Autowired 44 @Autowired
49 - private TransferChancelSelector transferChancelSelector;  
50 -  
51 - @Autowired  
52 TransferService transferService; 45 TransferService transferService;
53 46
54 @Autowired 47 @Autowired
@@ -60,9 +53,7 @@ public abstract class AbsGoodsServiceOrderService implements IGoodsService { @@ -60,9 +53,7 @@ public abstract class AbsGoodsServiceOrderService implements IGoodsService {
60 @Autowired 53 @Autowired
61 UfoOrderPayConfigReader ufoOrderPayConfigReader; 54 UfoOrderPayConfigReader ufoOrderPayConfigReader;
62 55
63 - private ExecutorService executorService = new ThreadPoolExecutor(5, 10, 60, TimeUnit.SECONDS,  
64 - new ArrayBlockingQueue<>(1000),  
65 - NamedThreadFactory.newThreadFactory("appraise")); 56 +
66 57
67 /** 58 /**
68 * 申请寄存返利 59 * 申请寄存返利
@@ -90,7 +81,7 @@ public abstract class AbsGoodsServiceOrderService implements IGoodsService { @@ -90,7 +81,7 @@ public abstract class AbsGoodsServiceOrderService implements IGoodsService {
90 List<AppraiseOrder> depositCodeList = appraiseOrderList.stream() 81 List<AppraiseOrder> depositCodeList = appraiseOrderList.stream()
91 .filter(appraiseOrder -> appraiseOrder.getAttributes() == OrderAttributes.DEPOSITE.getCode()) 82 .filter(appraiseOrder -> appraiseOrder.getAttributes() == OrderAttributes.DEPOSITE.getCode())
92 .collect(Collectors.toList()); 83 .collect(Collectors.toList());
93 - 84 + final ExecutorService executorService = ThreadPoolFactory.getDepositRebateExecutorService();
94 executorService.execute(() -> { 85 executorService.execute(() -> {
95 // 只返4单 86 // 只返4单
96 int DEFAULT_REBATE_CNT = ufoOrderPayConfigReader.depositRebateCnt(); 87 int DEFAULT_REBATE_CNT = ufoOrderPayConfigReader.depositRebateCnt();
@@ -37,7 +37,7 @@ import com.yohoufo.order.model.response.AppraiseAddressResp; @@ -37,7 +37,7 @@ import com.yohoufo.order.model.response.AppraiseAddressResp;
37 import com.yohoufo.order.mq.TopicConstants; 37 import com.yohoufo.order.mq.TopicConstants;
38 import com.yohoufo.order.service.*; 38 import com.yohoufo.order.service.*;
39 import com.yohoufo.order.service.cache.CacheCleaner; 39 import com.yohoufo.order.service.cache.CacheCleaner;
40 -import com.yohoufo.order.service.cache.CacheKeyBuilder; 40 +import com.yohoufo.order.service.concurrent.ThreadPoolFactory;
41 import com.yohoufo.order.service.handler.RefundEarnestMoneyHandler; 41 import com.yohoufo.order.service.handler.RefundEarnestMoneyHandler;
42 import com.yohoufo.order.service.handler.RefundGoodsMoneyHandler; 42 import com.yohoufo.order.service.handler.RefundGoodsMoneyHandler;
43 import com.yohoufo.order.service.handler.penalty.PenaltyResult; 43 import com.yohoufo.order.service.handler.penalty.PenaltyResult;
@@ -49,7 +49,6 @@ import com.yohoufo.order.service.proxy.*; @@ -49,7 +49,6 @@ import com.yohoufo.order.service.proxy.*;
49 import com.yohoufo.order.service.seller.orderMeta.SellerAddressService; 49 import com.yohoufo.order.service.seller.orderMeta.SellerAddressService;
50 import com.yohoufo.order.service.seller.setting.SellerService; 50 import com.yohoufo.order.service.seller.setting.SellerService;
51 import com.yohoufo.order.utils.BuyerOrderUtils; 51 import com.yohoufo.order.utils.BuyerOrderUtils;
52 -import com.yohoufo.order.utils.NamedThreadFactory;  
53 import com.yohoufo.order.utils.PaymentHelper; 52 import com.yohoufo.order.utils.PaymentHelper;
54 import lombok.Data; 53 import lombok.Data;
55 import org.apache.commons.collections.CollectionUtils; 54 import org.apache.commons.collections.CollectionUtils;
@@ -61,11 +60,11 @@ import org.springframework.stereotype.Service; @@ -61,11 +60,11 @@ import org.springframework.stereotype.Service;
61 60
62 import javax.annotation.Resource; 61 import javax.annotation.Resource;
63 import java.math.BigDecimal; 62 import java.math.BigDecimal;
64 -import java.util.*;  
65 -import java.util.concurrent.ArrayBlockingQueue; 63 +import java.util.List;
  64 +import java.util.Objects;
  65 +import java.util.Optional;
  66 +import java.util.Set;
66 import java.util.concurrent.ExecutorService; 67 import java.util.concurrent.ExecutorService;
67 -import java.util.concurrent.ThreadPoolExecutor;  
68 -import java.util.concurrent.TimeUnit;  
69 import java.util.function.Consumer; 68 import java.util.function.Consumer;
70 import java.util.stream.Collectors; 69 import java.util.stream.Collectors;
71 70
@@ -80,9 +79,7 @@ public class AppraiseService { @@ -80,9 +79,7 @@ public class AppraiseService {
80 79
81 private static final Logger LOGGER = LoggerFactory.getLogger(AppraiseService.class); 80 private static final Logger LOGGER = LoggerFactory.getLogger(AppraiseService.class);
82 81
83 - private ExecutorService executorService = new ThreadPoolExecutor(5, 10, 60, TimeUnit.SECONDS,  
84 - new ArrayBlockingQueue<>(1000),  
85 - NamedThreadFactory.newThreadFactory("appraise")); 82 + private static final ExecutorService executorService = ThreadPoolFactory.getAppraiseExecutorService();
86 83
87 @Autowired 84 @Autowired
88 private IExpressInfoService expressInfoService; 85 private IExpressInfoService expressInfoService;
@@ -191,8 +188,6 @@ public class AppraiseService { @@ -191,8 +188,6 @@ public class AppraiseService {
191 @Autowired 188 @Autowired
192 private AppraiseOrderGoodsMapper appraiseOrderGoodsMapper; 189 private AppraiseOrderGoodsMapper appraiseOrderGoodsMapper;
193 190
194 - @Autowired  
195 - private BuyerOrderAssistant buyerOrderAssistant;  
196 191
197 @Autowired 192 @Autowired
198 private IBuyerOrderMetaService buyerOrderMetaService; 193 private IBuyerOrderMetaService buyerOrderMetaService;
@@ -73,8 +73,6 @@ import static org.apache.zookeeper.ZooDefs.OpCode.delete; @@ -73,8 +73,6 @@ import static org.apache.zookeeper.ZooDefs.OpCode.delete;
73 @Service 73 @Service
74 public class BuyerOrderCancelService { 74 public class BuyerOrderCancelService {
75 75
76 - private ExecutorService executorService = new ThreadPoolExecutor(4, 10,  
77 - 60, TimeUnit.SECONDS, new ArrayBlockingQueue<>(1000), NamedThreadFactory.newThreadFactory("buyer-order-cancel"));  
78 76
79 private Logger logger = LoggerUtils.getOrderCloseLogger(); 77 private Logger logger = LoggerUtils.getOrderCloseLogger();
80 78
@@ -656,7 +654,7 @@ public class BuyerOrderCancelService { @@ -656,7 +654,7 @@ public class BuyerOrderCancelService {
656 654
657 655
658 private void asyncRefundGoodsAmount() { 656 private void asyncRefundGoodsAmount() {
659 - 657 + final ExecutorService executorService = ThreadPoolFactory.getBuyerCancelThreadPool();
660 executorService.execute(()->{ 658 executorService.execute(()->{
661 BigDecimal leftGoodsMoney = buyerOrder.getAmount(); 659 BigDecimal leftGoodsMoney = buyerOrder.getAmount();
662 660
@@ -678,6 +676,7 @@ public class BuyerOrderCancelService { @@ -678,6 +676,7 @@ public class BuyerOrderCancelService {
678 } 676 }
679 677
680 private void saveFailRecord(int uid, long orderCode, String failReason){ 678 private void saveFailRecord(int uid, long orderCode, String failReason){
  679 + final ExecutorService executorService = ThreadPoolFactory.getBuyerCancelThreadPool();
681 executorService.execute(()-> { 680 executorService.execute(()-> {
682 BuyerOrderMeta record = new BuyerOrderMeta(); 681 BuyerOrderMeta record = new BuyerOrderMeta();
683 record.setOrderCode(orderCode); 682 record.setOrderCode(orderCode);
@@ -509,6 +509,8 @@ public class DepositServiceImpl implements DepositService { @@ -509,6 +509,8 @@ public class DepositServiceImpl implements DepositService {
509 if (storageId != null) { 509 if (storageId != null) {
510 Method queryUserStorageOffCount = DepositController.class.getMethod("queryUserStorageOffCount", new Class[]{Integer.class, Integer.class}); 510 Method queryUserStorageOffCount = DepositController.class.getMethod("queryUserStorageOffCount", new Class[]{Integer.class, Integer.class});
511 cacheAop.clearCache(queryUserStorageOffCount, new Object[]{uid, storageId}); 511 cacheAop.clearCache(queryUserStorageOffCount, new Object[]{uid, storageId});
  512 + Method queryListByUidAndStorageId = DepositController.class.getMethod("queryListByUidAndStorageId", new Class[]{Integer.class, Integer.class});
  513 + cacheAop.clearCache(queryListByUidAndStorageId, new Object[]{uid, storageId});
512 } 514 }
513 515
514 Method queryUserStorageCount = DepositController.class.getMethod("queryUserStorageCount", new Class[]{Integer.class}); 516 Method queryUserStorageCount = DepositController.class.getMethod("queryUserStorageCount", new Class[]{Integer.class});
@@ -864,6 +866,17 @@ public class DepositServiceImpl implements DepositService { @@ -864,6 +866,17 @@ public class DepositServiceImpl implements DepositService {
864 return num > 0 ? true : false; 866 return num > 0 ? true : false;
865 } 867 }
866 868
  869 + @Override
  870 + public int updateSellLock(Integer uid, String depositCode, Integer sellLock) {
  871 + StorageDeposit deposit = storageDepositMapper.queryByDepositCode(uid, depositCode);
  872 + if(null == deposit) {
  873 + throw new UfoServiceException(400, "寄存商品不存在");
  874 + }
  875 +
  876 + Integer preSellLock = sellLock.intValue() == 0 ? 1: 0;
  877 + return storageDepositMapper.updateSellLock(deposit.getId(), sellLock, preSellLock);
  878 + }
  879 +
867 private List<DepositDetailBo> convertDepositResp(List<StorageDeposit> list, List<Long> orderCodeList){ 880 private List<DepositDetailBo> convertDepositResp(List<StorageDeposit> list, List<Long> orderCodeList){
868 Map<Long, BigDecimal> orderCodePriceMap = Maps.newHashMap(); 881 Map<Long, BigDecimal> orderCodePriceMap = Maps.newHashMap();
869 List<BuyerOrder> buyerOrderList = buyerOrderMapper.selectByOrderCodes(orderCodeList, null); 882 List<BuyerOrder> buyerOrderList = buyerOrderMapper.selectByOrderCodes(orderCodeList, null);