Authored by qinchao

手机质检:发货

@@ -156,6 +156,17 @@ public class BuyerOrderController { @@ -156,6 +156,17 @@ public class BuyerOrderController {
156 } 156 }
157 }*/ 157 }*/
158 158
  159 + //发货给买家
  160 + @RequestMapping(value = "/deliveryGoodsToBuyer")
  161 + public ApiResponse deliveryGoodsToBuyer(BuyerOrderReq req) {
  162 + LOGGER.info("deliveryGoodsToBuyer in. req is {}", req);
  163 + JSONObject result = buyerOrderService.deliveryGoodsToBuyer(req);
  164 + if(result.getIntValue("code") == 200) {
  165 + return new ApiResponse.ApiResponseBuilder().code(200).message("更新成功").build();
  166 + }else {
  167 + return new ApiResponse.ApiResponseBuilder().code(500).message(result.getString("message")).build();
  168 + }
  169 + }
159 170
160 @RequestMapping(value = "/judgeRejectAndDelivery") 171 @RequestMapping(value = "/judgeRejectAndDelivery")
161 public ApiResponse judgeRejectAndDelivery(BuyerOrderReq req) { 172 public ApiResponse judgeRejectAndDelivery(BuyerOrderReq req) {
@@ -181,6 +192,19 @@ public class BuyerOrderController { @@ -181,6 +192,19 @@ public class BuyerOrderController {
181 } 192 }
182 193
183 */ 194 */
  195 +
  196 + //寄回给卖家
  197 + @RequestMapping(value = "/sendBackGoodsToSeller")
  198 + public ApiResponse sendBackGoodsToSeller(BuyerOrderReq req) {
  199 + LOGGER.info("sendBackGoodsToSeller in. req is {}", req);
  200 + JSONObject result = buyerOrderService.sendBackGoodsToSeller(req);
  201 + if(result.getIntValue("code") == 200) {
  202 + return new ApiResponse.ApiResponseBuilder().code(200).message("更新成功").build();
  203 + }else {
  204 + return new ApiResponse.ApiResponseBuilder().code(500).message(result.getString("message")).build();
  205 + }
  206 + }
  207 +
184 //寄回给卖家 208 //寄回给卖家
185 @RequestMapping(value = "/returnBackOrderCauseOfJudgeFailure") 209 @RequestMapping(value = "/returnBackOrderCauseOfJudgeFailure")
186 public ApiResponse returnBackOrderCauseOfJudgeFailure(BuyerOrderReq req) { 210 public ApiResponse returnBackOrderCauseOfJudgeFailure(BuyerOrderReq req) {
@@ -41,12 +41,14 @@ public interface IBuyerOrderService { @@ -41,12 +41,14 @@ public interface IBuyerOrderService {
41 41
42 42
43 //JSONObject deliverGoods(BuyerOrderReq req); 43 //JSONObject deliverGoods(BuyerOrderReq req);
44 - 44 + JSONObject deliveryGoodsToBuyer(BuyerOrderReq req);
45 JSONObject judgeRejectAndDelivery(BuyerOrderReq req); 45 JSONObject judgeRejectAndDelivery(BuyerOrderReq req);
46 46
47 //JSONObject updateOrderStatus(BuyerOrderReq req); 47 //JSONObject updateOrderStatus(BuyerOrderReq req);
48 48
49 49
  50 + JSONObject sendBackGoodsToSeller(BuyerOrderReq req);
  51 +
50 JSONObject returnBackOrderCauseOfJudgeFailure(BuyerOrderReq req); 52 JSONObject returnBackOrderCauseOfJudgeFailure(BuyerOrderReq req);
51 53
52 JSONObject returnBackOrder(BuyerOrderReq req); 54 JSONObject returnBackOrder(BuyerOrderReq req);
@@ -603,6 +603,87 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { @@ -603,6 +603,87 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
603 return jsonObject; 603 return jsonObject;
604 } 604 }
605 605
  606 + //发货
  607 + public JSONObject deliveryGoodsToBuyer(BuyerOrderReq req){
  608 + LOGGER.info("deliveryGoodsToBuyer enter, req is {}", req);
  609 + BuyerOrder buyerOrder = checkForPlatformExpress(req);
  610 + String args = "orderAppraise.deliveryGoodsToBuyer";
  611 + if( Constant.BUYER_ORDER_STATUS_JUDGE_PASS.getByteVal()!=buyerOrder.getStatus().byteValue()){
  612 + throw new ServiceException(400,"错误:订单状态变化,不允许发货,请重新刷新列表");
  613 + }
  614 + //重新设置mobile
  615 + restMobileFromBuyer(req,buyerOrder.getOrderCode());
  616 +
  617 + //记录操作日志
  618 + int operateType =OperateTypeEnum.OPERATE_TYPE_DELIVERY_GOODS.getCode();
  619 + UserHelper userHelper = new UserHelper();
  620 + saveOrderOperateRecord(buyerOrder.getOrderCode(), userHelper, operateType, "");
  621 +
  622 + JSONObject jsonObject = asyncCallAppraise(args, buyerOrder.getOrderCode(), req);
  623 + LOGGER.info("deliveryGoodsToBuyer saveOrderOperateRecord operateType={} ,order code ={} ,userHelper = {} ,result json {}",operateType,buyerOrder.getOrderCode() ,userHelper,jsonObject);
  624 + return jsonObject;
  625 + }
  626 +
  627 + private BuyerOrder checkForPlatformExpress(BuyerOrderReq req){
  628 + if(StringUtils.isBlank(req.getOrderCode())) {
  629 + throw new ServiceException(400,"错误:参数错误,订单号为空");
  630 + }
  631 + //物流公司id,默认值为 23
  632 + if(req.getExpressCompanyId()==null){
  633 + throw new ServiceException(400,"错误:参数错误,物流公司为空");
  634 + }
  635 + if(StringUtils.isBlank(req.getWaybillCode())){
  636 + throw new ServiceException(400,"错误:参数错误,物流单号为空");
  637 + }
  638 + if(req.getDepotNo()==null){
  639 + throw new ServiceException(400,"错误:参数错误,仓库号为空");
  640 + }
  641 + if(StringUtils.isBlank(req.getMobile())){
  642 + throw new ServiceException(400,"错误:参数错误,手机号为空");
  643 + }
  644 +
  645 + BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(req.getOrderCode());
  646 + if(null == buyerOrder) {
  647 + throw new ServiceException(400,"错误:订单为空");
  648 + }
  649 +
  650 + //查看是否存在寄回的物流信息,如果存在,则不允许再次寄回
  651 + List<ExpressRecord> sellerExpressRecordList = expressRecordMapper.selectByOrderCodeListAndType(Lists.newArrayList(buyerOrder.getOrderCode()), Lists.newArrayList(EXPRESS_TYPE_JUDGE_TO_BUYER, EXPRESS_TYPE_JUDGE_TO_SELLER,EXPRESS_TYPE_RETURN_BACK_TO_SELLER));
  652 + if(CollectionUtils.isNotEmpty(sellerExpressRecordList)) {
  653 + throw new ServiceException(400,"错误:订单已存在物流信息["+sellerExpressRecordList.get(0).getWaybillCode()+"]");
  654 + }
  655 + return buyerOrder;
  656 + }
  657 +
  658 + public JSONObject sendBackGoodsToSeller(BuyerOrderReq req){
  659 + LOGGER.info("sendBackGoodsToSeller enter, req is {}", req);
  660 + BuyerOrder buyerOrder = checkForPlatformExpress(req);
  661 + //重新设置mobile
  662 + resetMobileFromSeller(req,buyerOrder.getOrderCode());
  663 +
  664 + //调用前台接口
  665 + String args ;
  666 + if(buyerOrder.getStatus().byteValue()==Constant.BUYER_ORDER_STATUS_BUYER_CANCEL_AFTER_SELLER_DELIVERY.getByteVal()) {
  667 + args = "orderAppraise.returnBack";
  668 + }else if(buyerOrder.getStatus().byteValue()==Constant.BUYER_ORDER_STATUS_JUDGE_NOT_PASS.getByteVal()
  669 + ||buyerOrder.getStatus().byteValue()==Constant.CANCEL_QUALITY_CHECK_FAKE.getByteVal()
  670 + ||buyerOrder.getStatus().byteValue()==Constant.CANCEL_MINI_FAULT_REJECT.getByteVal()
  671 + ||buyerOrder.getStatus().byteValue()==Constant.CANCEL_MINI_FAULT_OUT_TIME_REJECT.getByteVal()){
  672 + args = "orderAppraise.returnBackOrderCauseOfJudgeFailure";
  673 + }else{
  674 + throw new ServiceException(400,"错误:订单状态不合法,不允许平台发货或寄回");
  675 + }
  676 +
  677 + //记录操作日志
  678 + int operateType =OperateTypeEnum.OPERATE_TYPE_DELIVERY_GOODS.getCode();
  679 + UserHelper userHelper = new UserHelper();
  680 + saveOrderOperateRecord(buyerOrder.getOrderCode(), userHelper, operateType, "");
  681 +
  682 + JSONObject jsonObject = asyncCallAppraise(args, buyerOrder.getOrderCode(), req);
  683 + LOGGER.info("sendBackGoodsToSeller saveOrderOperateRecord operateType={} ,order code ={} ,userHelper = {} ,result json {}",operateType,buyerOrder.getOrderCode() ,userHelper,jsonObject);
  684 + return jsonObject;
  685 + }
  686 +
606 //鉴定通过 :更新订单状态为judge_pass ,期望状态有两种情况:平台鉴定中或者瑕疵接受了 687 //鉴定通过 :更新订单状态为judge_pass ,期望状态有两种情况:平台鉴定中或者瑕疵接受了
607 public JSONObject judgeCenterNotPass(String orderCode){ 688 public JSONObject judgeCenterNotPass(String orderCode){
608 if(StringUtils.isBlank(orderCode)){ 689 if(StringUtils.isBlank(orderCode)){
@@ -754,6 +835,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { @@ -754,6 +835,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
754 } 835 }
755 836
756 837
  838 +
757 public JSONObject returnBackOrderCauseOfJudgeFailure(BuyerOrderReq req){ 839 public JSONObject returnBackOrderCauseOfJudgeFailure(BuyerOrderReq req){
758 if(null == req.getId() || null == req.getStatus()) { 840 if(null == req.getId() || null == req.getStatus()) {
759 return null; 841 return null;