...
|
...
|
@@ -56,71 +56,137 @@ public class ExpressInfoServiceImpl implements IExpressInfoService { |
|
|
@Autowired
|
|
|
private BuyerOrderMapper buyerOrderMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private OrderCodeGenerator orderCodeGenerator;
|
|
|
|
|
|
@Resource( name = "yhProducer")
|
|
|
private YhProducer yhProducer;
|
|
|
|
|
|
private static String EXPRESS_MQ_SEND = "logistics.logistics_data";
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
* @param uid 卖家的uid
|
|
|
* @param expressCompanyId 快递公司id
|
|
|
* @param orderCode 订单号 :一定是买家订单编号
|
|
|
* @param wayBillCode 快递单号
|
|
|
*/
|
|
|
@Override
|
|
|
public void deliverToDepot(Integer uid,Integer expressCompanyId, Long orderCode, String wayBillCode) {
|
|
|
LOGGER.info("deliverToDepot uid={} ,expressCompanyId = {}, orderCode = {}, wayBillCode = {}", new Object[]{uid ,expressCompanyId, orderCode, wayBillCode});
|
|
|
|
|
|
//保存物流信息+更新订单状态;
|
|
|
//本阶段的物流类型和订单状态
|
|
|
Integer expressType = ExpressInfoConstant.EXPRESS_TYPE_1;
|
|
|
OrderStatus orderStatus=OrderStatus.SELLER_SEND_OUT;
|
|
|
Integer expressType = ExpressInfoConstant.EXPRESS_TYPE_1;
|
|
|
|
|
|
LOGGER.info("deliverToDepot saveExpressAndUpdateBuyerOrderStatus uid={} ,expressCompanyId = {}, orderCode = {}, wayBillCode = {} " +
|
|
|
",expressType = {} ,orderStatus = {}", new Object[]{uid ,expressCompanyId, orderCode, wayBillCode,expressType,orderStatus});
|
|
|
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
|
|
|
|
|
|
if (buyerOrder == null){
|
|
|
LOGGER.warn("getOrderInfo order not exist, orderCode is {}", orderCode);
|
|
|
LOGGER.warn("deliverToDepot getOrderInfo order not exist, orderCode is {}", orderCode);
|
|
|
throw new ServiceException(ServiceError.ORDER_NULL);
|
|
|
}
|
|
|
|
|
|
if(uid!=buyerOrder.getUid()){
|
|
|
LOGGER.warn("deliverToDepot saveExpressAndUpdateBuyerOrderStatus uid {} not equal buyer order uid {}",uid, buyerOrder.getUid());
|
|
|
throw new ServiceException(ServiceError.ORDER_NULL);
|
|
|
//卖家的uid
|
|
|
if(uid.intValue()!=buyerOrder.getSellerUid().intValue()){
|
|
|
LOGGER.warn("deliverToDepot saveExpressAndUpdateBuyerOrderStatus uid {} not equal buyer order sellerUid {}",uid, buyerOrder.getSellerUid());
|
|
|
throw new ServiceException(400,"参数错误,传入的卖家uid与订单卖家uid不一致");
|
|
|
}
|
|
|
|
|
|
Integer dealUid=buyerOrder.getSellerUid();
|
|
|
|
|
|
// 保存订单物流信息
|
|
|
int ts=DateUtil.getCurrentTimeSecond();
|
|
|
ExpressInfo expressInfo=new ExpressInfo();
|
|
|
expressInfo.setUid(uid);
|
|
|
expressInfo.setOrderCode(orderCode);
|
|
|
expressInfo.setWaybillCode(wayBillCode);
|
|
|
expressInfo.setLogisticsType(expressCompanyId);
|
|
|
expressInfo.setCreateTime(ts);
|
|
|
expressInfo.setExpressType(expressType.byteValue());
|
|
|
expressInfo.setState(0);
|
|
|
LOGGER.info("deliverToDepot save express info {} ", expressInfo);
|
|
|
expressInfoMapper.insert(expressInfo);
|
|
|
saveExpress(dealUid,expressCompanyId,orderCode,wayBillCode,expressType);
|
|
|
|
|
|
// 更新买家订单状态
|
|
|
buyerOrder.setStatus(orderStatus.getCode());
|
|
|
buyerOrder.setUpdateTime(ts);
|
|
|
buyerOrder.setUpdateTime(DateUtil.getCurrentTimeSecond());
|
|
|
LOGGER.info("deliverToDepot update buyer order {} ", buyerOrder);
|
|
|
buyerOrderMapper.updateByPrimaryKeySelective(buyerOrder);
|
|
|
|
|
|
// 发送mq获取物流信息
|
|
|
sendExpressMQ(uid,expressCompanyId,orderCode,wayBillCode);
|
|
|
sendExpressMQ(dealUid,expressCompanyId,orderCode,wayBillCode);
|
|
|
LOGGER.info("deliverToDepot end ! send express to erp ");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void appraiseFail(Integer expressCompanyId, Long orderCode, String wayBillCode) {
|
|
|
LOGGER.info("appraiseFail expressCompanyId = {}, orderCode = {}, wayBillCode = {}", new Object[]{expressCompanyId, orderCode, wayBillCode});
|
|
|
// TODO
|
|
|
OrderStatus orderStatus=OrderStatus.CHECKING_FAKE;
|
|
|
Integer expressType = ExpressInfoConstant.EXPRESS_TYPE_3;
|
|
|
|
|
|
LOGGER.info("appraiseFail expressCompanyId = {}, orderCode = {}, wayBillCode = {} " +
|
|
|
",expressType = {} ,orderStatus = {}", new Object[]{expressCompanyId, orderCode, wayBillCode,expressType,orderStatus});
|
|
|
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
|
|
|
|
|
|
if (buyerOrder == null){
|
|
|
LOGGER.warn("appraiseFail getOrderInfo order not exist, orderCode is {}", orderCode);
|
|
|
throw new ServiceException(ServiceError.ORDER_NULL);
|
|
|
}
|
|
|
|
|
|
Integer dealUid=buyerOrder.getSellerUid();
|
|
|
|
|
|
// 保存订单物流信息
|
|
|
saveExpress(dealUid,expressCompanyId,orderCode,wayBillCode,expressType);
|
|
|
|
|
|
// 更新买家订单状态
|
|
|
buyerOrder.setStatus(orderStatus.getCode());
|
|
|
buyerOrder.setUpdateTime(DateUtil.getCurrentTimeSecond());
|
|
|
LOGGER.info("appraiseFail update buyer order {} ", buyerOrder);
|
|
|
buyerOrderMapper.updateByPrimaryKeySelective(buyerOrder);
|
|
|
|
|
|
// 发送mq获取物流信息
|
|
|
sendExpressMQ(dealUid,expressCompanyId,orderCode,wayBillCode);
|
|
|
LOGGER.info("appraiseFail end ! send express to erp ");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void appraiseSuccess(Integer expressCompanyId, Long orderCode, String wayBillCode) {
|
|
|
LOGGER.info("appraiseSuccess expressCompanyId = {}, orderCode = {}, wayBillCode = {}", new Object[]{expressCompanyId, orderCode, wayBillCode});
|
|
|
// TODO
|
|
|
OrderStatus orderStatus=OrderStatus.WAITING_RECEIVE;
|
|
|
Integer expressType = ExpressInfoConstant.EXPRESS_TYPE_2;
|
|
|
|
|
|
LOGGER.info("appraiseSuccess expressCompanyId = {}, orderCode = {}, wayBillCode = {} " +
|
|
|
",expressType = {} ,orderStatus = {}", new Object[]{expressCompanyId, orderCode, wayBillCode,expressType,orderStatus});
|
|
|
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
|
|
|
|
|
|
if (buyerOrder == null){
|
|
|
LOGGER.warn("appraiseSuccess getOrderInfo order not exist, orderCode is {}", orderCode);
|
|
|
throw new ServiceException(ServiceError.ORDER_NULL);
|
|
|
}
|
|
|
|
|
|
Integer dealUid=buyerOrder.getUid();
|
|
|
|
|
|
// 保存订单物流信息
|
|
|
saveExpress(dealUid,expressCompanyId,orderCode,wayBillCode,expressType);
|
|
|
|
|
|
// 更新买家订单状态
|
|
|
buyerOrder.setStatus(orderStatus.getCode());
|
|
|
buyerOrder.setUpdateTime(DateUtil.getCurrentTimeSecond());
|
|
|
LOGGER.info("appraiseSuccess update buyer order {} ", buyerOrder);
|
|
|
buyerOrderMapper.updateByPrimaryKeySelective(buyerOrder);
|
|
|
|
|
|
// 发送mq获取物流信息
|
|
|
sendExpressMQ(dealUid,expressCompanyId,orderCode,wayBillCode);
|
|
|
LOGGER.info("appraiseSuccess end ! send express to erp ");
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 保存物流信息
|
|
|
* @param uid 卖家到鉴定中心和鉴定失败时,记录卖家的uid,鉴定成功记录买家uid
|
|
|
* @param expressCompanyId
|
|
|
* @param orderCode
|
|
|
* @param wayBillCode
|
|
|
* @param expressType
|
|
|
*/
|
|
|
private void saveExpress(Integer uid,Integer expressCompanyId, Long orderCode, String wayBillCode,Integer expressType ){
|
|
|
ExpressInfo expressInfo=new ExpressInfo();
|
|
|
expressInfo.setUid(uid);/// 存卖家的uid
|
|
|
expressInfo.setOrderCode(orderCode);
|
|
|
expressInfo.setWaybillCode(wayBillCode);
|
|
|
expressInfo.setLogisticsType(expressCompanyId);
|
|
|
expressInfo.setCreateTime(DateUtil.getCurrentTimeSecond());
|
|
|
expressInfo.setExpressType(expressType.byteValue());
|
|
|
expressInfo.setState(0);
|
|
|
LOGGER.info("deliverToDepot save express info {} ", expressInfo);
|
|
|
expressInfoMapper.insert(expressInfo);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -148,8 +214,8 @@ public class ExpressInfoServiceImpl implements IExpressInfoService { |
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public ExpressInfoRespBo queryExpressDetailInfo(Long orderCode) {
|
|
|
LOGGER.info("queryExpressDetailInfo orderCode = {}", orderCode);
|
|
|
public ExpressInfoRespBo queryExpressDetailInfo(Integer uid,Long orderCode) {
|
|
|
LOGGER.info("queryExpressDetailInfo uid={}, orderCode = {}",uid, orderCode);
|
|
|
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
|
|
|
|
|
|
if (buyerOrder == null){
|
...
|
...
|
@@ -157,9 +223,8 @@ public class ExpressInfoServiceImpl implements IExpressInfoService { |
|
|
throw new ServiceException(ServiceError.ORDER_NULL);
|
|
|
}
|
|
|
|
|
|
Integer uid=buyerOrder.getUid();
|
|
|
ExpressInfoRespBo expressInfoRespBo = new ExpressInfoRespBo();
|
|
|
Integer expressType = getExpressType(orderCode);
|
|
|
Integer expressType = getExpressType(buyerOrder);
|
|
|
LOGGER.info("getExpressType result = {}", expressType);
|
|
|
List<ExpressInfo> expressInfoList = expressInfoMapper.queryExpressInfo(uid, orderCode, expressType);
|
|
|
processExpressInfo(expressInfoList, expressInfoRespBo);
|
...
|
...
|
@@ -192,9 +257,20 @@ public class ExpressInfoServiceImpl implements IExpressInfoService { |
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Integer getExpressType(Long orderCode) {
|
|
|
Integer uid = null;
|
|
|
/**
|
|
|
* orderCode 一定是买家订单号
|
|
|
* @return
|
|
|
*/
|
|
|
private Integer getExpressType(BuyerOrder buyerOrder) {
|
|
|
if(OrderStatus.SELLER_SEND_OUT.getCode()==buyerOrder.getStatus()||OrderStatus.PLATFORM_CHECKING.getCode()==buyerOrder.getStatus()){
|
|
|
return ExpressInfoConstant.EXPRESS_TYPE_1;
|
|
|
}else if(OrderStatus.CHECKING_FAKE.getCode()==buyerOrder.getStatus()){
|
|
|
return ExpressInfoConstant.EXPRESS_TYPE_3;
|
|
|
}else if(OrderStatus.WAITING_RECEIVE.getCode()==buyerOrder.getStatus()||OrderStatus.DONE.getCode()==buyerOrder.getStatus()){
|
|
|
return ExpressInfoConstant.EXPRESS_TYPE_2;
|
|
|
}
|
|
|
return 0;
|
|
|
/*Integer uid = null;
|
|
|
boolean buyer = true;
|
|
|
//根据订单号判断是买家还是卖家
|
|
|
CodeMeta codeMeta = orderCodeGenerator.expId(orderCode);
|
...
|
...
|
@@ -224,6 +300,6 @@ public class ExpressInfoServiceImpl implements IExpressInfoService { |
|
|
return ExpressInfoConstant.EXPRESS_TYPE_3;
|
|
|
}
|
|
|
}
|
|
|
return 0;
|
|
|
return 0;*/
|
|
|
}
|
|
|
} |
...
|
...
|
|