Authored by caoyan

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

@@ -5,6 +5,7 @@ import java.util.List; @@ -5,6 +5,7 @@ import java.util.List;
5 import org.apache.ibatis.annotations.Param; 5 import org.apache.ibatis.annotations.Param;
6 6
7 import com.yoho.order.model.AbnormalPackage; 7 import com.yoho.order.model.AbnormalPackage;
  8 +import com.yoho.order.model.BuyerOrderReq;
8 9
9 /** 10 /**
10 * Created by caoyan on 2019/6/24. 11 * Created by caoyan on 2019/6/24.
@@ -19,5 +20,5 @@ public interface AbnormalPackageMapper { @@ -19,5 +20,5 @@ public interface AbnormalPackageMapper {
19 20
20 int selectValidCnt(); 21 int selectValidCnt();
21 22
22 - List<String> selectValidSellerWaybillCodeList(); 23 + List<String> selectValidSellerWaybillCodeList(@Param("buyerOrderReq") BuyerOrderReq buyerOrderReq);
23 } 24 }
@@ -18,13 +18,16 @@ @@ -18,13 +18,16 @@
18 select count(1) from abnormal_package where is_del = 0 18 select count(1) from abnormal_package where is_del = 0
19 </select> 19 </select>
20 20
21 - <select id="selectValidSellerWaybillCodeList" resultType="java.lang.String"> 21 + <select id="selectValidSellerWaybillCodeList" resultType="java.lang.String" parameterType="com.yoho.order.model.BuyerOrderReq">
22 select seller_waybillCode from abnormal_package where is_del=0 22 select seller_waybillCode from abnormal_package where is_del=0
  23 + <if test="buyerOrderReq.start!=null and buyerOrderReq.size != null">
  24 + limit #{buyerOrderReq.start},#{buyerOrderReq.size}
  25 + </if>
23 </select> 26 </select>
24 27
25 <select id="selectBySellerWaybillCode" resultMap="BaseResultMap"> 28 <select id="selectBySellerWaybillCode" resultMap="BaseResultMap">
26 select <include refid="Base_Column_List" /> 29 select <include refid="Base_Column_List" />
27 - from abnormal_package where seller_waybillCode = #{sellerWaybillCode} 30 + from abnormal_package where is_del=0 and seller_waybillCode = #{sellerWaybillCode}
28 </select> 31 </select>
29 32
30 <insert id="insert" parameterType="com.yoho.order.model.AbnormalPackage"> 33 <insert id="insert" parameterType="com.yoho.order.model.AbnormalPackage">
@@ -419,7 +419,14 @@ public class BuyerOrderController { @@ -419,7 +419,14 @@ public class BuyerOrderController {
419 @RequestMapping(value = "/queryByOrderCodeOrWaybillCode4Qc") 419 @RequestMapping(value = "/queryByOrderCodeOrWaybillCode4Qc")
420 public ApiResponse queryByOrderCodeOrWaybillCode4Qc(BuyerOrderReq req) { 420 public ApiResponse queryByOrderCodeOrWaybillCode4Qc(BuyerOrderReq req) {
421 LOGGER.info("queryByOrderCodeOrWaybillCode4Qc in. queryStr is {}", req.getQueryStr()); 421 LOGGER.info("queryByOrderCodeOrWaybillCode4Qc in. queryStr is {}", req.getQueryStr());
422 - JSONObject result = buyerOrderService.queryOrderForQc(req.getQueryStr()); 422 + PageResponseBO<BuyerOrderResp> result = buyerOrderService.queryOrderForQc(req.getQueryStr());
  423 + return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(result).build();
  424 + }
  425 +
  426 + @RequestMapping(value = "/queryByWaybillCode4Qc")
  427 + public ApiResponse queryByWaybillCode4Qc(BuyerOrderReq req) {
  428 + LOGGER.info("queryByWaybillCode4Qc in. queryStr is {}", req.getSellerWaybillCode());
  429 + JSONObject result = buyerOrderService.queryOrderBySellerWaybillCodeForQc(req.getSellerWaybillCode());
423 return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(result).build(); 430 return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(result).build();
424 } 431 }
425 432
@@ -516,6 +523,13 @@ public class BuyerOrderController { @@ -516,6 +523,13 @@ public class BuyerOrderController {
516 } 523 }
517 } 524 }
518 525
  526 + @RequestMapping(value = "/queryAbnormalPackage")
  527 + public ApiResponse queryAbnormalPackage(BuyerOrderReq req) {
  528 + LOGGER.info("queryAbnormalPackage in. param is {}", req);
  529 + PageResponseBO<String> result = buyerOrderService.queryAbnormalPackage(req);
  530 + return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(null == result ? new PageResponseBO<BuyerOrderResp>() : result).build();
  531 + }
  532 +
519 533
520 @RequestMapping(value = "/queryIdentifyCenter") 534 @RequestMapping(value = "/queryIdentifyCenter")
521 public ApiResponse queryIdentifyCenter() { 535 public ApiResponse queryIdentifyCenter() {
@@ -85,7 +85,6 @@ public interface IBuyerOrderService { @@ -85,7 +85,6 @@ public interface IBuyerOrderService {
85 85
86 PageResponseBO<BuyerOrderResp> queryByOrderCodeOrWaybillCode(String queryStr); 86 PageResponseBO<BuyerOrderResp> queryByOrderCodeOrWaybillCode(String queryStr);
87 87
88 -  
89 void submitBuyerOrderFeedback(String orderCode, String feedbackContent); 88 void submitBuyerOrderFeedback(String orderCode, String feedbackContent);
90 89
91 List<BuyerOrderFeedback> queryBuyerOrderFeedback(String orderCode); 90 List<BuyerOrderFeedback> queryBuyerOrderFeedback(String orderCode);
@@ -94,7 +93,9 @@ public interface IBuyerOrderService { @@ -94,7 +93,9 @@ public interface IBuyerOrderService {
94 93
95 QualityCheckResp queryQualityCheck(BuyerOrderReq req); 94 QualityCheckResp queryQualityCheck(BuyerOrderReq req);
96 95
97 - JSONObject queryOrderForQc(String queryStr); 96 + PageResponseBO<BuyerOrderResp> queryOrderForQc(String queryStr);
  97 +
  98 + JSONObject queryOrderBySellerWaybillCodeForQc(String queryStr);
98 99
99 Map<String, Integer> getCountForQc(BuyerOrderReq req); 100 Map<String, Integer> getCountForQc(BuyerOrderReq req);
100 101
@@ -115,4 +116,6 @@ public interface IBuyerOrderService { @@ -115,4 +116,6 @@ public interface IBuyerOrderService {
115 List<IdentifyCenterResp> queryIdentifyCenter(); 116 List<IdentifyCenterResp> queryIdentifyCenter();
116 117
117 int addAbnormalPackage(String sellerWaybillCode); 118 int addAbnormalPackage(String sellerWaybillCode);
  119 +
  120 + PageResponseBO<String> queryAbnormalPackage(BuyerOrderReq req);
118 } 121 }
@@ -635,39 +635,58 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { @@ -635,39 +635,58 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
635 } 635 }
636 636
637 @Override 637 @Override
638 - public JSONObject queryOrderForQc(String queryStr) {  
639 - JSONObject jsonObject = new JSONObject();  
640 - PageResponseBO<BuyerOrderResp> result=new PageResponseBO<>();  
641 - jsonObject.put("orderNums", 0);  
642 - jsonObject.put("receivedNums", 0);  
643 - jsonObject.put("canceledNums", 0);  
644 - jsonObject.put("orderList", result);  
645 - jsonObject.put("isExistException", 0); 638 + public PageResponseBO<BuyerOrderResp> queryOrderForQc(String queryStr) {
646 if(StringUtils.isEmpty(queryStr)) { 639 if(StringUtils.isEmpty(queryStr)) {
647 - return jsonObject; 640 + return null;
648 } 641 }
649 642
650 //查询卖家已发货的订单 643 //查询卖家已发货的订单
651 List<BuyerOrder> orderList = queryOrderByQueryStr(queryStr, null, null); 644 List<BuyerOrder> orderList = queryOrderByQueryStr(queryStr, null, null);
652 if(CollectionUtils.isEmpty(orderList)) { 645 if(CollectionUtils.isEmpty(orderList)) {
653 - return jsonObject; 646 + return null;
654 } 647 }
655 648
656 - jsonObject.replace("orderNums", orderList.size()); 649 + List<BuyerOrderResp> respList = buildBuyerOrderRespForQc(orderList);
  650 + if(CollectionUtils.isEmpty(respList)) {
  651 + return null;
  652 + }
  653 +
  654 + //是否签收
  655 + buildIsSignForPackage(respList, queryStr);
  656 +
  657 + PageResponseBO<BuyerOrderResp> result=new PageResponseBO<>();
  658 + result.setPage(1);
  659 + result.setList(respList);
  660 + result.setSize(respList.size());
  661 + result.setTotal(respList.size());
657 662
658 - //包裹是否已签收  
659 - if(isSignedPackage(queryStr)) {  
660 - jsonObject.replace("receivedNums", orderList.size()); 663 + return result;
  664 + }
  665 +
  666 + @Override
  667 + public JSONObject queryOrderBySellerWaybillCodeForQc(String sellerWaybillCode) {
  668 + JSONObject jsonObject = new JSONObject();
  669 + PageResponseBO<BuyerOrderResp> result=new PageResponseBO<>();
  670 + jsonObject.put("orderNum", 0);
  671 + jsonObject.put("receivedNum", 0);
  672 + jsonObject.put("canceledNum", 0);
  673 + jsonObject.put("orderList", result);
  674 + jsonObject.put("isExceptionPackage", 0);
  675 + jsonObject.put("exceptionBtn", 0);
  676 + jsonObject.put("receiveBtn", 0);
  677 + if(StringUtils.isEmpty(sellerWaybillCode)) {
661 return jsonObject; 678 return jsonObject;
662 } 679 }
663 680
664 - //是否存在买家在卖家发货后取消的订单  
665 - int excepitonOrderTotal = getExcepitonOrderTotal(orderList);  
666 - if(excepitonOrderTotal > 0) {  
667 - jsonObject.replace("isExistException", 1);  
668 - jsonObject.replace("canceledNums", excepitonOrderTotal); 681 + //查询订单
  682 + List<BuyerOrder> orderList = queryOrderByQueryStr(sellerWaybillCode, null, null);
  683 + if(CollectionUtils.isEmpty(orderList)) {
  684 + return jsonObject;
669 } 685 }
670 686
  687 + //计算附加信息
  688 + buildExtraInfo(jsonObject, orderList, sellerWaybillCode);
  689 +
671 List<BuyerOrderResp> respList = buildBuyerOrderRespForQc(orderList); 690 List<BuyerOrderResp> respList = buildBuyerOrderRespForQc(orderList);
672 if(CollectionUtils.isEmpty(respList)) { 691 if(CollectionUtils.isEmpty(respList)) {
673 return jsonObject; 692 return jsonObject;
@@ -681,23 +700,37 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { @@ -681,23 +700,37 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
681 return jsonObject; 700 return jsonObject;
682 } 701 }
683 702
684 - private int getExcepitonOrderTotal(List<BuyerOrder> orderList) {  
685 - int total = 0; 703 + private void buildExtraInfo(JSONObject jsonObject, List<BuyerOrder> orderList, String sellerWaybillCode){
  704 + jsonObject.replace("orderNum", orderList.size());
  705 +
  706 + //是否是异常包裹
  707 + AbnormalPackage pkg = abnormalPackageMapper.selectBySellerWaybillCode(sellerWaybillCode);
  708 + if(null != pkg){
  709 + jsonObject.replace("isExceptionPackage", 1);//是异常包裹
  710 + }
  711 +
  712 + //是否存在买家在卖家发货后取消的订单
  713 + int canceledNum = 0;
  714 + int receivedNum = 0;
686 for(BuyerOrder order : orderList) { 715 for(BuyerOrder order : orderList) {
687 - if(order.getStatus().equals(Constant.BUYER_ORDER_STATUS_BUYER_CANCEL_AFTER_SELLER_DELIVERY.getByteVal())) {  
688 - total += 1; 716 + if(order.getStatus().equals(Constant.BUYER_ORDER_STATUS_BUYER_CANCEL_AFTER_SELLER_DELIVERY.getByteVal())
  717 + || order.getStatus().equals(Constant.CS_CANCEL_BEFORE_DEPOT_RECEIVE.getByteVal())) {
  718 + canceledNum += 1;
  719 + }else if(!order.getStatus().equals(Constant.BUYER_ORDER_STATUS_ALLOCATING.getByteVal())){
  720 + receivedNum +=1;
689 } 721 }
690 } 722 }
691 723
692 - return total; 724 + if(canceledNum > 0) {
  725 + jsonObject.replace("exceptionBtn", jsonObject.getIntValue("isExceptionPackage") == 1 ? 0: 1);//0:按钮不展示 1:按钮展示
  726 + jsonObject.replace("canceledNum", canceledNum);
  727 + jsonObject.replace("receiveBtn", 0);
693 } 728 }
694 729
695 - private boolean isSignedPackage(String sellerWaybillCode){  
696 - BuyerOrderReq buyerOrderReq = new BuyerOrderReq();  
697 - buyerOrderReq.setSellerWaybillCode(sellerWaybillCode);  
698 - List<SignForPackage> sfpList = signForPackageMapper.selectByCondition(buyerOrderReq);  
699 -  
700 - return CollectionUtils.isNotEmpty(sfpList); 730 + jsonObject.replace("receivedNum", receivedNum);
  731 + if(orderList.size() - receivedNum - canceledNum > 0 && canceledNum == 0){
  732 + jsonObject.replace("receiveBtn", jsonObject.getIntValue("isExceptionPackage") == 1 ? 0: 1);//0:按钮不展示 1:按钮展示
  733 + }
701 } 734 }
702 735
703 private void buildIsSignForPackage(List<BuyerOrderResp> respList, String sellerWaybillCode) { 736 private void buildIsSignForPackage(List<BuyerOrderResp> respList, String sellerWaybillCode) {
@@ -2505,6 +2538,22 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { @@ -2505,6 +2538,22 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
2505 return abnormalPackageMapper.insert(pkg); 2538 return abnormalPackageMapper.insert(pkg);
2506 } 2539 }
2507 2540
  2541 + @Override
  2542 + public PageResponseBO<String> queryAbnormalPackage(BuyerOrderReq req){
  2543 + int total = abnormalPackageMapper.selectValidCnt();
  2544 + if(total == 0){
  2545 + return null;
  2546 + }
  2547 + List<String> list = abnormalPackageMapper.selectValidSellerWaybillCodeList(req);
  2548 + PageResponseBO<String> result=new PageResponseBO<>();
  2549 + result.setPage(req.getPage());
  2550 + result.setList(list);
  2551 + result.setSize(req.getSize());
  2552 + result.setTotal(total);
  2553 +
  2554 + return result;
  2555 + }
  2556 +
2508 private JSONObject updateBuyerReceiveInfo(BuyerOrderReq req, String oldMetaValue, Integer buyerUid) { 2557 private JSONObject updateBuyerReceiveInfo(BuyerOrderReq req, String oldMetaValue, Integer buyerUid) {
2509 JSONObject metaValue = JSONObject.parseObject(oldMetaValue); 2558 JSONObject metaValue = JSONObject.parseObject(oldMetaValue);
2510 metaValue.replace("consignee", req.getReceiveName()); 2559 metaValue.replace("consignee", req.getReceiveName());