Authored by mali

Merge branch 'dev_确认收货优化' into test6.9.7

Conflicts:
	order/src/main/java/com/yoho/ufo/order/service/IBuyerOrderService.java
	order/src/main/java/com/yoho/ufo/order/service/impl/BuyerOrderServiceImpl.java
@@ -26,4 +26,20 @@ public interface ExpressRecordMapper { @@ -26,4 +26,20 @@ public interface ExpressRecordMapper {
26 */ 26 */
27 ExpressRecord selectByOrderCodeAndExpressType( @Param("orderCode") Long orderCode, @Param("expressType") Integer expressType); 27 ExpressRecord selectByOrderCodeAndExpressType( @Param("orderCode") Long orderCode, @Param("expressType") Integer expressType);
28 28
  29 + /**
  30 + * 根据物流单号和物流类型查询快递信息
  31 + * @param wayBillCode
  32 + * @param code
  33 + * @return
  34 + */
  35 + List<ExpressRecord> selectByWayBillCodeAndExpressType(@Param("wayBillCode") String wayBillCode, @Param("expressType") Integer expressType);
  36 +
  37 + /**
  38 + * 根据订单号和物流类型更新鉴定室
  39 + * @param orderCodeList
  40 + * @param expressType
  41 + * @param depotNum
  42 + * @return
  43 + */
  44 + int updateDeptNoByOrder(@Param("orderCodeList") List<Long> orderCodeList, @Param("expressType") Integer expressType, @Param("depotNum") Integer depotNum);
29 } 45 }
@@ -110,4 +110,12 @@ public interface SellerOrderGoodsMapper { @@ -110,4 +110,12 @@ public interface SellerOrderGoodsMapper {
110 * @return 110 * @return
111 */ 111 */
112 int updateByCondition(@Param("condition") SellerOrderGoods condition, @Param("updateTo") SellerOrderGoods updateTo); 112 int updateByCondition(@Param("condition") SellerOrderGoods condition, @Param("updateTo") SellerOrderGoods updateTo);
  113 +
  114 + /**
  115 + * 根据skup更新鉴定室
  116 + * @param skupList
  117 + * @param depotNum
  118 + * @return
  119 + */
  120 + int updateDeptNoBySkups(@Param("skupList")List<Integer> skupList, @Param("depotNum")Integer depotNum);
113 } 121 }
@@ -79,4 +79,12 @@ public interface StoragePriceMapper { @@ -79,4 +79,12 @@ public interface StoragePriceMapper {
79 79
80 80
81 int updateOneStatusByeAnothers(@Param("oldskup") Integer oldskup, @Param("newskup") Integer newskup); 81 int updateOneStatusByeAnothers(@Param("oldskup") Integer oldskup, @Param("newskup") Integer newskup);
  82 +
  83 + /**
  84 + * 批量更新库存的鉴定室
  85 + * @param skupList
  86 + * @param depotNo
  87 + * @return
  88 + */
  89 + int updateBatchDepotNum(@Param("skupList") List<Integer> skupList, @Param("depotNum") Integer depotNo);
82 } 90 }
@@ -41,4 +41,23 @@ @@ -41,4 +41,23 @@
41 limit 1 41 limit 1
42 </select> 42 </select>
43 43
  44 + <select id="selectByWayBillCodeAndExpressType" resultMap="BaseResultMap">
  45 + SELECT <include refid="Base_Column_List" />
  46 + FROM express_record
  47 + where waybill_code = #{wayBillCode} and express_type = #{expressType}
  48 + </select>
  49 +
  50 + <update id="updateDeptNoByOrder" >
  51 + update express_record
  52 + <set>
  53 + <if test="depotNum != null">
  54 + depot_num = #{depotNum,jdbcType=INTEGER},
  55 + </if>
  56 + </set>
  57 + where order_code in
  58 + <foreach collection="orderCodeList" item="orderCode" open="(" close=")" separator=",">
  59 + #{orderCode, jdbcType=BIGINT}
  60 + </foreach>
  61 + and express_type = #{expressType, jdbcType=INTEGER}
  62 + </update>
44 </mapper> 63 </mapper>
@@ -482,4 +482,16 @@ @@ -482,4 +482,16 @@
482 </if> 482 </if>
483 </update> 483 </update>
484 484
  485 + <update id="updateDeptNoBySkups" >
  486 + update seller_order_goods
  487 + <set>
  488 + <if test="depotNum != null">
  489 + depot_no = #{depotNum,jdbcType=INTEGER},
  490 + </if>
  491 + </set>
  492 + where id in
  493 + <foreach collection="skupList" item="skup" open="(" close=")" separator=",">
  494 + #{skup, jdbcType=INTEGER}
  495 + </foreach>
  496 + </update>
485 </mapper> 497 </mapper>
@@ -238,4 +238,13 @@ @@ -238,4 +238,13 @@
238 a.skup = #{newskup,jdbcType=INTEGER} and b.skup = #{oldskup,jdbcType=INTEGER} 238 a.skup = #{newskup,jdbcType=INTEGER} and b.skup = #{oldskup,jdbcType=INTEGER}
239 </update> 239 </update>
240 240
  241 +
  242 + <update id="updateBatchDepotNum">
  243 + update storage_price set depot_num = #{depotNum,jdbcType=INTEGER},
  244 + update_time = unix_timestamp()
  245 + where skup in
  246 + <foreach item="item" index="index" collection="skupList" open="(" separator="," close=")">
  247 + #{item}
  248 + </foreach>
  249 + </update>
241 </mapper> 250 </mapper>
@@ -197,5 +197,15 @@ public class AppraiseController { @@ -197,5 +197,15 @@ public class AppraiseController {
197 appraiseService.deliverGoods(appraiseExpressInfoBo); 197 appraiseService.deliverGoods(appraiseExpressInfoBo);
198 return new ApiResponse(); 198 return new ApiResponse();
199 }*/ 199 }*/
200 - 200 + /**
  201 + * TODO 手机质检: 修改鉴定室
  202 + */
  203 + @RequestMapping(value="/updateDeptNo")
  204 + @IgnoreSession
  205 + @IgnoreSignature
  206 + public ApiResponse updateDeptNo(@RequestBody AppraiseExpressInfoBo appraiseExpressInfoBo){
  207 + logger.info("method in updateDeptNo, appraiseExpressInfoBo {}", appraiseExpressInfoBo);
  208 + appraiseService.updateDeptNo(appraiseExpressInfoBo);
  209 + return new ApiResponse();
  210 + }
201 } 211 }
@@ -42,9 +42,11 @@ import com.yohoufo.order.service.listener.OrderChangeListenerContainer; @@ -42,9 +42,11 @@ import com.yohoufo.order.service.listener.OrderChangeListenerContainer;
42 import com.yohoufo.order.service.proxy.InBoxFacade; 42 import com.yohoufo.order.service.proxy.InBoxFacade;
43 import com.yohoufo.order.service.proxy.OrderOperateRecordService; 43 import com.yohoufo.order.service.proxy.OrderOperateRecordService;
44 import com.yohoufo.order.service.proxy.OrderStatusFlowService; 44 import com.yohoufo.order.service.proxy.OrderStatusFlowService;
  45 +import com.yohoufo.order.service.proxy.ProductProxyService;
45 import com.yohoufo.order.utils.PaymentHelper; 46 import com.yohoufo.order.utils.PaymentHelper;
46 import com.yohoufo.order.utils.PubThreadFactory; 47 import com.yohoufo.order.utils.PubThreadFactory;
47 import lombok.Data; 48 import lombok.Data;
  49 +import org.apache.commons.collections.CollectionUtils;
48 import org.apache.commons.lang3.StringUtils; 50 import org.apache.commons.lang3.StringUtils;
49 import org.slf4j.Logger; 51 import org.slf4j.Logger;
50 import org.slf4j.LoggerFactory; 52 import org.slf4j.LoggerFactory;
@@ -61,6 +63,7 @@ import java.util.concurrent.ArrayBlockingQueue; @@ -61,6 +63,7 @@ import java.util.concurrent.ArrayBlockingQueue;
61 import java.util.concurrent.ExecutorService; 63 import java.util.concurrent.ExecutorService;
62 import java.util.concurrent.ThreadPoolExecutor; 64 import java.util.concurrent.ThreadPoolExecutor;
63 import java.util.concurrent.TimeUnit; 65 import java.util.concurrent.TimeUnit;
  66 +import java.util.stream.Collectors;
64 67
65 /** 68 /**
66 * Created by chenchao on 2018/9/27. 69 * Created by chenchao on 2018/9/27.
@@ -143,6 +146,8 @@ public class AppraiseService { @@ -143,6 +146,8 @@ public class AppraiseService {
143 //@Value("${order.seller.earnestmoney.miniFaultRejectPunishFee:0}") 146 //@Value("${order.seller.earnestmoney.miniFaultRejectPunishFee:0}")
144 private Double miniFaultRejectPunishFee = 0D; 147 private Double miniFaultRejectPunishFee = 0D;
145 148
  149 + @Autowired
  150 + private ProductProxyService productProxyService;
146 151
147 /** 152 /**
148 * 触发物流 153 * 触发物流
@@ -867,6 +872,8 @@ public class AppraiseService { @@ -867,6 +872,8 @@ public class AppraiseService {
867 } 872 }
868 } 873 }
869 874
  875 +
  876 +
870 @Data 877 @Data
871 class RefundMoneyResultModel { 878 class RefundMoneyResultModel {
872 boolean refundGoodsMoneyFlag; 879 boolean refundGoodsMoneyFlag;
@@ -1422,4 +1429,35 @@ public class AppraiseService { @@ -1422,4 +1429,35 @@ public class AppraiseService {
1422 1429
1423 } 1430 }
1424 1431
  1432 + /**
  1433 + * 根据物流单号修改鉴定室
  1434 + * @param appraiseExpressInfoBo
  1435 + */
  1436 + public void updateDeptNo(AppraiseExpressInfoBo appraiseExpressInfoBo) {
  1437 + List<Long> orderCodeList = null;
  1438 +
  1439 + if (null == appraiseExpressInfoBo.getOrderCode() && StringUtils.isNotEmpty(appraiseExpressInfoBo.getWayBillCode())) {
  1440 + List<ExpressRecord> expressRecords = expressRecordMapper.selectByWayBillCodeAndExpressType(appraiseExpressInfoBo.getWayBillCode(),
  1441 + EnumExpressType.EXPRESS_TYPE_1.getCode());
  1442 +
  1443 + orderCodeList = expressRecords.stream().filter(item -> null == item.getDepotNum() || !item.getDepotNum().equals(appraiseExpressInfoBo.getDepotNum()))
  1444 + .map(ExpressRecord::getOrderCode).collect(Collectors.toList()); // 是否存在不符合的鉴定室
  1445 + } else if (null != appraiseExpressInfoBo.getOrderCode()) {
  1446 + orderCodeList = Lists.newArrayList(appraiseExpressInfoBo.getOrderCode());
  1447 + }
  1448 +
  1449 + if (CollectionUtils.isNotEmpty(orderCodeList)) {
  1450 + LOGGER.info("updateDeptNo method in orderCodeList = {}", orderCodeList);
  1451 +
  1452 + List<BuyerOrderGoods> buyerOrderGoodses = buyerOrderGoodsMapper.selectByOrderCodeList(null, orderCodeList);
  1453 + if (CollectionUtils.isNotEmpty(buyerOrderGoodses)) {
  1454 + List<Integer> skupList = buyerOrderGoodses.stream().map(BuyerOrderGoods::getSkup).collect(Collectors.toList());
  1455 +
  1456 + sellerOrderGoodsMapper.updateDeptNoBySkups(skupList, appraiseExpressInfoBo.getDepotNum());
  1457 + expressRecordMapper.updateDeptNoByOrder(orderCodeList, EnumExpressType.EXPRESS_TYPE_1.getCode(), appraiseExpressInfoBo.getDepotNum());
  1458 +
  1459 + productProxyService.setBatchDepotNum(skupList, appraiseExpressInfoBo.getDepotNum());
  1460 + }
  1461 + }
  1462 + }
1425 } 1463 }
@@ -68,6 +68,8 @@ public class ProductProxyService extends AbsProxyService{ @@ -68,6 +68,8 @@ public class ProductProxyService extends AbsProxyService{
68 68
69 private static final String UFO_SECONDHAND_COPYINFO= "ufo.secondhand.copyInfo"; 69 private static final String UFO_SECONDHAND_COPYINFO= "ufo.secondhand.copyInfo";
70 70
  71 + private static final String BATCH_UPDATE_SKUP_DEPOTNO = "ufo.product.updateSkupDepotNo"; // 根据库存的鉴定室
  72 +
71 public boolean subtractStorage(Integer productId, Integer skup){ 73 public boolean subtractStorage(Integer productId, Integer skup){
72 74
73 ApiResponse resp = ufoServiceCaller.call(SUBTRACT_STORAGE, productId, skup); 75 ApiResponse resp = ufoServiceCaller.call(SUBTRACT_STORAGE, productId, skup);
@@ -459,4 +461,9 @@ public class ProductProxyService extends AbsProxyService{ @@ -459,4 +461,9 @@ public class ProductProxyService extends AbsProxyService{
459 logger.info("finish {} -> preSkup {} currentSkup {}", method, preSkup, currentSkup); 461 logger.info("finish {} -> preSkup {} currentSkup {}", method, preSkup, currentSkup);
460 return (null == resp || null == resp.getData())? false : (boolean)resp.getData(); 462 return (null == resp || null == resp.getData())? false : (boolean)resp.getData();
461 } 463 }
  464 +
  465 + public ApiResponse setBatchDepotNum(List<Integer> skupList, Integer depotNum){
  466 + ApiResponse apiResponse = ufoServiceCaller.call(BATCH_UPDATE_SKUP_DEPOTNO, skupList, depotNum);
  467 + return apiResponse;
  468 + }
462 } 469 }
  1 +package com.yohoufo.product.controller;
  2 +
  3 +import com.yoho.error.exception.ServiceException;
  4 +import com.yohobuy.ufo.model.request.StoragePriceBo;
  5 +import com.yohoufo.common.ApiResponse;
  6 +import com.yohoufo.product.service.impl.StoragePriceService;
  7 +import org.slf4j.Logger;
  8 +import org.slf4j.LoggerFactory;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.web.bind.annotation.RequestBody;
  11 +import org.springframework.web.bind.annotation.RequestMapping;
  12 +import org.springframework.web.bind.annotation.RequestParam;
  13 +import org.springframework.web.bind.annotation.RestController;
  14 +
  15 +import java.util.List;
  16 +
  17 +/**
  18 + * Created by li.ma on 2019/6/27.
  19 + */
  20 +@RestController
  21 +public class StoragePriceController {
  22 + private final Logger LOG = LoggerFactory.getLogger(ProductController.class);
  23 +
  24 + @Autowired
  25 + private StoragePriceService storagePriceService;
  26 +
  27 + // 更新skup的鉴定室
  28 + @RequestMapping(params = "method=ufo.product.updateSkupDepotNo")
  29 + public ApiResponse updateSkupDepotNo(@RequestParam(value = "skupList", required = true) List<Integer> skupList,
  30 + @RequestParam(value = "depotNo", required = true) Integer depotNo) {
  31 + LOG.info("in method=ufo.product.updateSkupDepotNo skupList = {} ; depotNo is {}", skupList, depotNo);
  32 + try {
  33 + storagePriceService.updateSkupDepotNo(skupList, depotNo);
  34 + return new ApiResponse();
  35 + } catch (Exception e) {
  36 + LOG.error("ufo.product.updateSkupDepotNo! skupList : " + skupList, e);
  37 + int code = (e instanceof ServiceException) ? ((ServiceException) e).getCode() : 500;
  38 + return new ApiResponse(code, e.getMessage(), Boolean.FALSE);
  39 + }
  40 + }
  41 +}
  1 +package com.yohoufo.product.service.impl;
  2 +
  3 +import com.yohoufo.dal.product.StoragePriceMapper;
  4 +import org.springframework.beans.factory.annotation.Autowired;
  5 +import org.springframework.stereotype.Service;
  6 +import org.springframework.web.bind.annotation.RequestParam;
  7 +
  8 +import java.util.List;
  9 +
  10 +/**
  11 + * Created by li.ma on 2019/6/27.
  12 + */
  13 +@Service
  14 +public class StoragePriceService {
  15 + @Autowired
  16 + private StoragePriceMapper storagePriceMapper;
  17 +
  18 + public int updateSkupDepotNo(List<Integer> skupList, Integer depotNo) {
  19 + return storagePriceMapper.updateBatchDepotNum(skupList, depotNo);
  20 + }
  21 +}