Authored by qinchao

优化物流

@@ -101,7 +101,7 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); @@ -101,7 +101,7 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger();
101 101
102 // 正常订单,签收消息 102 // 正常订单,签收消息
103 if (state == ExpressInfoConstant.EXPRESS_STATUS_SIGN) { 103 if (state == ExpressInfoConstant.EXPRESS_STATUS_SIGN) {
104 - handleAcceptExpress(erpExpressBo,initExpressType.intValue()); 104 + handleAcceptExpress(erpExpressBo,initExpressType);
105 return; 105 return;
106 } 106 }
107 107
@@ -110,14 +110,31 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); @@ -110,14 +110,31 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger();
110 && logisticsType < 1 110 && logisticsType < 1
111 && (StringUtils.isEmpty(waybillCode) || StringUtils.equals(waybillCode, "0"))) { 111 && (StringUtils.isEmpty(waybillCode) || StringUtils.equals(waybillCode, "0"))) {
112 state = ExpressInfoConstant.EXPRESS_STATUS_UNSEND; 112 state = ExpressInfoConstant.EXPRESS_STATUS_UNSEND;
  113 + }
113 114
  115 + processExpressInfo( state, logisticsType, orderCode, waybillCode, acceptAddress, acceptRemark, createTime, uid, initExpressType);
114 } 116 }
115 117
  118 + /**
  119 + *
  120 + * @param state 快递状态
  121 + * @param logisticsType 快递公司id
  122 + * @param orderCode 订单号
  123 + * @param waybillCode 快递单号
  124 + * @param acceptAddress 运单接收地
  125 + * @param acceptRemark 运单信息
  126 + * @param createTime 创建时间
  127 + * @param uid
  128 + * @param initExpressType 物流类型
  129 + */
  130 + private void processExpressInfo( Integer state, Integer logisticsType, Long orderCode, String waybillCode,
  131 + String acceptAddress, String acceptRemark, Integer createTime, Integer uid, Byte initExpressType) {
  132 +
116 ExpressInfo expressInfo = new ExpressInfo(); 133 ExpressInfo expressInfo = new ExpressInfo();
117 expressInfo.setDataType(EnumExpressDataType.erp_logistics.getCode()); 134 expressInfo.setDataType(EnumExpressDataType.erp_logistics.getCode());
118 expressInfo.setUid(uid); 135 expressInfo.setUid(uid);
119 expressInfo.setOrderCode(orderCode); 136 expressInfo.setOrderCode(orderCode);
120 - expressInfo.setWaybillCode(StringUtils.defaultString(waybillCode)); 137 + expressInfo.setWaybillCode(StringUtils.defaultString(waybillCode).trim());
121 expressInfo.setAcceptAddress(StringUtils.defaultString(acceptAddress)); 138 expressInfo.setAcceptAddress(StringUtils.defaultString(acceptAddress));
122 expressInfo.setAcceptRemark(StringUtils.defaultString(acceptRemark)); 139 expressInfo.setAcceptRemark(StringUtils.defaultString(acceptRemark));
123 expressInfo.setLogisticsType(logisticsType); 140 expressInfo.setLogisticsType(logisticsType);
@@ -125,9 +142,31 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); @@ -125,9 +142,31 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger();
125 expressInfo.setExpressType(initExpressType); 142 expressInfo.setExpressType(initExpressType);
126 expressInfo.setState(state); 143 expressInfo.setState(state);
127 expressInfoMapper.insert(expressInfo); 144 expressInfoMapper.insert(expressInfo);
  145 +
128 updateSellerDeliverStatusAfterInsertExpress(orderCode,expressInfo); 146 updateSellerDeliverStatusAfterInsertExpress(orderCode,expressInfo);
129 } 147 }
130 148
  149 + /**
  150 + * 确认收货处理
  151 + */
  152 + private void handleAcceptExpress(ErpExpressBo erpExpressBo,Byte expressType) {
  153 + String waybillCode = erpExpressBo.getWaybillCode();
  154 + int logisticsType = erpExpressBo.getLogisticsType();
  155 + String acceptAddress = erpExpressBo.getAcceptAddress();
  156 + String acceptRemark = erpExpressBo.getAcceptRemark();
  157 + int state = erpExpressBo.getState();
  158 + long orderCode = erpExpressBo.getOrderCode();
  159 + int uid = erpExpressBo.getUid();
  160 +
  161 + int createTime = erpExpressBo.getCreateTime();
  162 + if(createTime<=0){
  163 + createTime = DateUtil.getCurrentTimeSecond();
  164 + }
  165 +
  166 + processExpressInfo( state, logisticsType, orderCode, waybillCode, acceptAddress, acceptRemark, createTime, uid, expressType);
  167 + }
  168 +
  169 +
131 private void updateSellerDeliverStatusAfterInsertExpress(long orderCode,ExpressInfo expressInfo ){ 170 private void updateSellerDeliverStatusAfterInsertExpress(long orderCode,ExpressInfo expressInfo ){
132 //卖家物流的情形 171 //卖家物流的情形
133 LOGGER.info("ExpressInfoUpdateConsumer update SellerDeliveryStatus enter orderCode {}",orderCode); 172 LOGGER.info("ExpressInfoUpdateConsumer update SellerDeliveryStatus enter orderCode {}",orderCode);
@@ -185,74 +224,4 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); @@ -185,74 +224,4 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger();
185 return flag; 224 return flag;
186 } 225 }
187 226
188 - /**  
189 - * 确认收货处理  
190 - */  
191 - private void handleAcceptExpress(ErpExpressBo erpExpressBo,Integer expressType) {  
192 - String waybillCode = erpExpressBo.getWaybillCode();  
193 - int logisticsType = erpExpressBo.getLogisticsType();  
194 - String acceptAddress = erpExpressBo.getAcceptAddress();  
195 - String acceptRemark = erpExpressBo.getAcceptRemark();  
196 - int state = erpExpressBo.getState();  
197 - long orderCode = erpExpressBo.getOrderCode();  
198 - int uid = erpExpressBo.getUid();  
199 -  
200 - int createTime = erpExpressBo.getCreateTime();  
201 - if(createTime<=0){  
202 - createTime = DateUtil.getCurrentTimeSecond();  
203 - }  
204 -  
205 - //快递100推送过来的数据,如果当前订单已经被签收,则所有推送过来的记录都是已签收,原来的for循环逻辑只能存一条签收记录,  
206 - //因此修改为以下方式,不管如何都直接存下来。  
207 - List<ExpressInfo> expressInfos = null;  
208 - processExpressInfo(expressInfos, state, logisticsType, orderCode, waybillCode, acceptAddress, acceptRemark, createTime, uid, expressType);  
209 - }  
210 -  
211 -  
212 - /**  
213 - *  
214 - * @param expressInfos 快递信息  
215 - * @param state 快递状态  
216 - * @param logisticsType 快递公司id  
217 - * @param orderCode 订单号  
218 - * @param waybillCode 快递单号  
219 - * @param acceptAddress 运单接收地  
220 - * @param acceptRemark 运单信息  
221 - * @param createTime 创建时间  
222 - * @param uid  
223 - * @param expressType 物流类型  
224 - */  
225 - private void processExpressInfo(List<ExpressInfo> expressInfos, Integer state, Integer logisticsType, Long orderCode, String waybillCode,  
226 - String acceptAddress, String acceptRemark, Integer createTime, Integer uid, Integer expressType) {  
227 - if (CollectionUtils.isEmpty(expressInfos)) {  
228 - ExpressInfo expressInfo = new ExpressInfo();  
229 - expressInfo.setDataType(EnumExpressDataType.erp_logistics.getCode());  
230 - expressInfo.setState(state);  
231 - expressInfo.setLogisticsType(logisticsType);  
232 - expressInfo.setOrderCode(orderCode);  
233 - expressInfo.setWaybillCode(StringUtils.defaultString(waybillCode));  
234 - expressInfo.setAcceptAddress(StringUtils.defaultString(acceptAddress));  
235 - expressInfo.setAcceptRemark(StringUtils.defaultString(acceptRemark));  
236 - expressInfo.setCreateTime(createTime);  
237 - expressInfo.setUid(uid);  
238 - expressInfo.setExpressType(expressType.byteValue());  
239 - expressInfoMapper.insert(expressInfo);  
240 - updateSellerDeliverStatusAfterInsertExpress(orderCode,expressInfo);  
241 - } /*else {  
242 - for (ExpressInfo expressInfo : expressInfos) {  
243 - expressInfo.setDataType(EnumExpressDataType.erp_logistics.getCode());  
244 - expressInfo.setState(state);  
245 - expressInfo.setLogisticsType(logisticsType);  
246 - expressInfo.setOrderCode(orderCode);  
247 - expressInfo.setWaybillCode(StringUtils.defaultString(waybillCode));  
248 - expressInfo.setAcceptAddress(StringUtils.defaultString(acceptAddress));  
249 - expressInfo.setAcceptRemark(StringUtils.defaultString(acceptRemark));  
250 - expressInfo.setCreateTime(createTime);  
251 - expressInfo.setUid(uid);  
252 - expressInfo.setExpressType(expressType.byteValue());  
253 - expressInfoMapper.updateByPrimaryKeySelective(expressInfo);  
254 - }  
255 - }*/  
256 - }  
257 -  
258 } 227 }