Authored by mali

更新鉴定室

... ... @@ -525,7 +525,7 @@ public class BuyerOrderController {
if(StringUtils.isEmpty(req.getSellerWaybillCode())) {
return new ApiResponse.ApiResponseBuilder().code(500).message("卖家快递单号不能为空").build();
}
int result = buyerOrderService.addAbnormalPackage(req.getSellerWaybillCode());
int result = buyerOrderService.addAbnormalPackage(req);
if(result > 0) {
return new ApiResponse.ApiResponseBuilder().code(200).message("添加异常包裹成功").build();
}else {
... ...
... ... @@ -116,7 +116,7 @@ public interface IBuyerOrderService {
PageResponseBO<String> queryPackage(Integer depotNo, String sellerWaybillCode, Integer date);
int addAbnormalPackage(String sellerWaybillCode);
int addAbnormalPackage(BuyerOrderReq req);
PageResponseBO<String> queryAbnormalPackage(BuyerOrderReq req);
... ...
package com.yoho.ufo.order.service.event;
import com.alibaba.fastjson.JSONObject;
import com.yoho.order.model.BuyerOrderReq;
import com.yohobuy.ufo.model.order.bo.AppraiseExpressInfoBo;
import org.springframework.context.ApplicationEvent;
/**
* Created by li.ma on 2019/6/27.
*/
public class DepotNumUpdateEvent extends ApplicationEvent {
private AppraiseExpressInfoBo record;
/**
* Create a new ApplicationEvent.
*
* @param record the object on which the event initially occurred (never {@code null})
*/
public DepotNumUpdateEvent(AppraiseExpressInfoBo record) {
super(record);
this.record = record;
}
public AppraiseExpressInfoBo getRecord() {
return record;
}
public void setRecord(AppraiseExpressInfoBo record) {
this.record = record;
}
@Override
public String toString() {
return JSONObject.toJSONString(this);
}
}
... ...
package com.yoho.ufo.order.service.event;
import com.alibaba.fastjson.JSONObject;
import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.ufo.util.DateUtil;
import com.yohobuy.ufo.model.order.bo.AppraiseExpressInfoBo;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
import java.util.concurrent.TimeUnit;
/**
* Created by li.ma on 2019/6/27.
*/
@Component
public class DepotNumUpdateListener implements ApplicationListener<DepotNumUpdateEvent> {
private static final Logger LOGGER = LoggerFactory.getLogger(DepotNumUpdateListener.class);
@Autowired
private ServiceCaller serviceCaller;
@Override
public void onApplicationEvent(DepotNumUpdateEvent event) {
AppraiseExpressInfoBo record = event.getRecord();
LOGGER.info("updateDeptNo begin, AppraiseExpressInfoBo is {}", record);
JSONObject jsonObject = serviceCaller.asyncCall("ufo-gateway.updateDeptNo", record, JSONObject.class).get(5, TimeUnit.SECONDS);
LOGGER.info("updateDeptNo end , record is {} , result is {}", record, jsonObject);
}
}
... ...
... ... @@ -16,6 +16,7 @@ import java.util.stream.Collectors;
import javax.annotation.Resource;
import com.yoho.ufo.order.service.event.DepotNumUpdateEvent;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.common.collect.Lists;
... ... @@ -25,6 +26,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
... ... @@ -130,7 +133,7 @@ import com.yohobuy.ufo.model.resp.product.SecondDetailResp;
* @date 2018/9/13
*/
@Service
public class BuyerOrderServiceImpl implements IBuyerOrderService {
public class BuyerOrderServiceImpl implements IBuyerOrderService, ApplicationContextAware {
private static final Logger LOGGER = LoggerFactory.getLogger(BuyerOrderServiceImpl.class);
... ... @@ -888,6 +891,8 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
//记录操作日志
int operateType =OperateTypeEnum.OPERATE_TYPE_CONFIRM_RECEIVE.getCode();
UserHelper userHelper = new UserHelper();
updateDeptNo(Long.valueOf(buyerOrder.getOrderCode()), null, req.getPhoneUid());
saveOrderOperateRecord(buyerOrder.getOrderCode(),userHelper, operateType, "");
LOGGER.info("confirmReceive saveOrderOperateRecord operateType={} ,order code ={} ,userHelper = {} ,result json {}",operateType,buyerOrder.getOrderCode() ,userHelper,jsonObject);
... ... @@ -920,6 +925,9 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
if(jsonObject == null || jsonObject.getIntValue("code") != 200) {
throw new ServiceException(400,"错误:订单"+orderCode +"确认收货失败");
}
updateDeptNo(null, sellerWaybillCode, req.getPhoneUid());
saveOrderOperateRecord(buyerOrder.getOrderCode(),userHelper, operateType, ""); //记录操作日志
LOGGER.info("confirmReceive saveOrderOperateRecord operateType={} ,order code ={} ,userHelper = {} ,result json {}",operateType,buyerOrder.getOrderCode() ,userHelper,jsonObject);
}
... ... @@ -1627,7 +1635,8 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
||buyerOrder.getStatus().byteValue() == Constant.CANCEL_MINI_FAULT_REJECT.getByteVal()
||buyerOrder.getStatus().byteValue() == Constant.CANCEL_MINI_FAULT_OUT_TIME_REJECT.getByteVal()
||buyerOrder.getStatus().byteValue() == Constant.BUYER_ORDER_STATUS_BUYER_CANCEL_AFTER_SELLER_DELIVERY.getByteVal()
||buyerOrder.getStatus().byteValue() == Constant.BUYER_ORDER_STATUS_APPRAISE_UNSURE.getByteVal()){
||buyerOrder.getStatus().byteValue() == Constant.BUYER_ORDER_STATUS_APPRAISE_UNSURE.getByteVal()
||buyerOrder.getStatus().byteValue() == Constant.CS_CANCEL_BEFORE_DEPOT_RECEIVE.getByteVal()){
//卖家地址
LOGGER.info("getDeliveryAddressByOrderCode call seller address ,req is {}", req);
return this.getSendBackInfoByOrderCode(req);
... ... @@ -2531,7 +2540,9 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
}
@Override
public int addAbnormalPackage(String sellerWaybillCode) {
public int addAbnormalPackage(BuyerOrderReq req) {
String sellerWaybillCode = req.getSellerWaybillCode();
//数据库已存在
AbnormalPackage pkg = abnormalPackageMapper.selectBySellerWaybillCode(sellerWaybillCode);
if(null != pkg) {
... ... @@ -2543,6 +2554,10 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
pkg.setIsDel(0);
pkg.setCreateTime(DateUtil.getCurrentTimeSeconds());
pkg.setOperateUid(new UserHelper().getUserId());
// 校验鉴定中心是否是当前的鉴定室
updateDeptNo(null, sellerWaybillCode, req.getPhoneUid());
return abnormalPackageMapper.insert(pkg);
}
... ... @@ -3028,5 +3043,23 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
}
}
}
private void updateDeptNo(Long orderCode, String wayBillCode, String phoneUid) {
LOGGER.error("method. updateDeptNo begin orderCode is {} , wayBillCode is {}, phoneUid is {}", orderCode, wayBillCode, phoneUid);
PhoneUidDepot phoneUidDepot = phoneUidDepotMapper.selectByphoneUid(phoneUid);
if (null == phoneUidDepot) {
LOGGER.error("phoneUidDepotMapper.selectByphoneUid is null phoneUid is {}", phoneUid);
return;
}
applicationContext.publishEvent(new DepotNumUpdateEvent(new AppraiseExpressInfoBo(null , orderCode, wayBillCode, phoneUidDepot.getDepotNo(), null)));
}
private ApplicationContext applicationContext;
public void setApplicationContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
}
}
... ...