Authored by caoyan

订单管理

@@ -22,7 +22,6 @@ import com.alibaba.fastjson.JSONObject; @@ -22,7 +22,6 @@ import com.alibaba.fastjson.JSONObject;
22 import com.yoho.core.common.utils.DateUtil; 22 import com.yoho.core.common.utils.DateUtil;
23 import com.yoho.core.rest.client.ServiceCaller; 23 import com.yoho.core.rest.client.ServiceCaller;
24 import com.yoho.core.rest.governance.ServiceStragetyFinder; 24 import com.yoho.core.rest.governance.ServiceStragetyFinder;
25 -import com.yoho.core.rest.governance.model.ServiceGovernStrategy;  
26 import com.yoho.order.dal.AppraiseAddressMapper; 25 import com.yoho.order.dal.AppraiseAddressMapper;
27 import com.yoho.order.dal.AreaMapper; 26 import com.yoho.order.dal.AreaMapper;
28 import com.yoho.order.dal.BuyerOrderGoodsMapper; 27 import com.yoho.order.dal.BuyerOrderGoodsMapper;
@@ -55,6 +54,7 @@ import com.yoho.ufo.order.service.IBuyerOrderService; @@ -55,6 +54,7 @@ import com.yoho.ufo.order.service.IBuyerOrderService;
55 import com.yoho.ufo.service.impl.UserHelper; 54 import com.yoho.ufo.service.impl.UserHelper;
56 import com.yoho.ufo.service.model.PageResponseBO; 55 import com.yoho.ufo.service.model.PageResponseBO;
57 import com.yohobuy.ufo.model.order.bo.AppraiseExpressInfoBo; 56 import com.yohobuy.ufo.model.order.bo.AppraiseExpressInfoBo;
  57 +import com.yohobuy.ufo.model.order.req.BuyerOrderMetaUpdateReq;
58 import com.yohobuy.ufo.model.order.resp.BuyerOrderResp; 58 import com.yohobuy.ufo.model.order.resp.BuyerOrderResp;
59 import com.yohobuy.ufo.model.order.resp.ExpressInfoResp; 59 import com.yohobuy.ufo.model.order.resp.ExpressInfoResp;
60 import com.yohobuy.ufo.model.order.resp.OrderDetailResp; 60 import com.yohobuy.ufo.model.order.resp.OrderDetailResp;
@@ -519,8 +519,6 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { @@ -519,8 +519,6 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
519 519
520 int operateType = OPERATE_TYPE_UPDATE_SELLERWAYBILLCODE; 520 int operateType = OPERATE_TYPE_UPDATE_SELLERWAYBILLCODE;
521 String oldInfo = ""; 521 String oldInfo = "";
522 - OrderOperateRecord optRecord = new OrderOperateRecord();  
523 - optRecord.setOrderCode(req.getOrderCode());  
524 522
525 //卖家已发货,更新卖家物流单号 523 //卖家已发货,更新卖家物流单号
526 if(buyerOrder.getStatus().byteValue() == Constant.BUYER_ORDER_STATUS_ALLOCATING.getByteVal()) { 524 if(buyerOrder.getStatus().byteValue() == Constant.BUYER_ORDER_STATUS_ALLOCATING.getByteVal()) {
@@ -540,31 +538,47 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { @@ -540,31 +538,47 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
540 if(null == buyerMeta) { 538 if(null == buyerMeta) {
541 return 0; 539 return 0;
542 } 540 }
543 - JSONObject metaValue = JSONObject.parseObject(buyerMeta.getMetaValue());  
544 - metaValue.replace("consignee", req.getReceiveName());  
545 - metaValue.replace("mobile", req.getReceiveMobile());  
546 - metaValue.replace("address", req.getReceiveAddressDetail());  
547 - metaValue.replace("zipCode", req.getReceiveZipCode());  
548 - metaValue.replace("areaCode", req.getReceiveAreaCode());  
549 - metaValue.replace("area", getAddressInfo(req.getReceiveAreaCode()));  
550 - result = buyerOrderMetaMapper.updateMetaValue(req.getOrderCode(), BUYER_ORDER_META_KEY_DELIVERY_ADDRESS, metaValue.toJSONString()); 541 +
  542 + JSONObject jsonObject = updateBuyerReceiveInfo(req, buyerMeta.getMetaValue(), buyerOrder.getUid());
  543 + if(jsonObject.getIntValue("code") == 200) {
  544 + return 0;
  545 + }
  546 +
551 oldInfo = buyerMeta.getMetaValue(); 547 oldInfo = buyerMeta.getMetaValue();
552 } 548 }
553 549
554 //记录操作日志 550 //记录操作日志
555 - UserHelper userInfo = new UserHelper();  
556 - Integer uid = userInfo.getUserId();  
557 - if(null == uid) {  
558 - return 0;  
559 - } 551 + saveOrderOperateRecord(req.getOrderCode(), new UserHelper(), operateType, oldInfo);
  552 +
  553 + return result;
  554 + }
  555 +
  556 + private JSONObject updateBuyerReceiveInfo(BuyerOrderReq req, String oldMetaValue, Integer buyerUid) {
  557 + JSONObject metaValue = JSONObject.parseObject(oldMetaValue);
  558 + metaValue.replace("consignee", req.getReceiveName());
  559 + metaValue.replace("mobile", req.getReceiveMobile());
  560 + metaValue.replace("address", req.getReceiveAddressDetail());
  561 + metaValue.replace("zipCode", req.getReceiveZipCode());
  562 + metaValue.replace("areaCode", req.getReceiveAreaCode());
  563 + metaValue.replace("area", getAddressInfo(req.getReceiveAreaCode()));
  564 +
  565 + BuyerOrderMetaUpdateReq metaReq = new BuyerOrderMetaUpdateReq();
  566 + metaReq.setOrderCode(Long.valueOf(req.getOrderCode()));
  567 + metaReq.setUid(buyerUid);
  568 + metaReq.setAddress(metaValue.toJSONString());
  569 + //调用前台接口更新收货信息
  570 + return serviceCaller.call("orderBuyerOrderMeta.updateDeliveryAddress", metaReq, JSONObject.class);
  571 + }
  572 +
  573 + private void saveOrderOperateRecord(String orderCode, UserHelper userInfo, int operateType, String oldInfo) {
  574 + OrderOperateRecord optRecord = new OrderOperateRecord();
  575 + optRecord.setOrderCode(orderCode);
560 optRecord.setType(operateType); 576 optRecord.setType(operateType);
561 - optRecord.setUid(uid); 577 + optRecord.setUid(userInfo.getUserId());
562 optRecord.setUserName(userInfo.getUserName()); 578 optRecord.setUserName(userInfo.getUserName());
563 optRecord.setUpdateTime(DateUtil.getCurrentTimeSecond()); 579 optRecord.setUpdateTime(DateUtil.getCurrentTimeSecond());
564 optRecord.setOldInfo(oldInfo); 580 optRecord.setOldInfo(oldInfo);
565 orderOperateRecordMapper.insert(optRecord); 581 orderOperateRecordMapper.insert(optRecord);
566 -  
567 - return result;  
568 } 582 }
569 583
570 private String getAddressInfo(String areaCode) { 584 private String getAddressInfo(String areaCode) {