Showing
6 changed files
with
513 additions
and
0 deletions
1 | package com.yohoufo.dal.order; | 1 | package com.yohoufo.dal.order; |
2 | 2 | ||
3 | import com.yohoufo.dal.order.model.ExpressInfo; | 3 | import com.yohoufo.dal.order.model.ExpressInfo; |
4 | +import org.apache.ibatis.annotations.Param; | ||
5 | + | ||
6 | +import java.util.List; | ||
4 | 7 | ||
5 | public interface ExpressInfoMapper { | 8 | public interface ExpressInfoMapper { |
6 | int deleteByPrimaryKey(Integer id); | 9 | int deleteByPrimaryKey(Integer id); |
@@ -14,4 +17,24 @@ public interface ExpressInfoMapper { | @@ -14,4 +17,24 @@ public interface ExpressInfoMapper { | ||
14 | int updateByPrimaryKeySelective(ExpressInfo record); | 17 | int updateByPrimaryKeySelective(ExpressInfo record); |
15 | 18 | ||
16 | int updateByPrimaryKey(ExpressInfo record); | 19 | int updateByPrimaryKey(ExpressInfo record); |
20 | + | ||
21 | + /** | ||
22 | + * 根据uid和快递单号查询快递信息 | ||
23 | + * @param uid | ||
24 | + * @param orderCode 订单号 | ||
25 | + * @param expressType 物流类型; 1:卖家到鉴定中心,2:鉴定中心到买家,3:鉴定中心退回到卖家 | ||
26 | + * @return | ||
27 | + */ | ||
28 | + List<ExpressInfo> queryExpressInfo(@Param("uid") Integer uid, @Param("orderCode") Long orderCode, @Param("expressType") Integer expressType); | ||
29 | + | ||
30 | + /** | ||
31 | + * 根据uid、订单号、物流类型和快递状态查询快递信息 | ||
32 | + * @param uid | ||
33 | + * @param orderCode | ||
34 | + * @param states 0:未签收 1签收 2未发货 | ||
35 | + * @param expressType 物流类型; 1:卖家到鉴定中心,2:鉴定中心到买家,3:鉴定中心退回到卖家 | ||
36 | + * @return | ||
37 | + */ | ||
38 | + List<ExpressInfo> selectByOrderCodeAndStatesAndUidAndExpressType(@Param("uid") Integer uid, @Param("orderCode") Long orderCode, @Param("states") List<Integer> states, @Param("expressType") Integer expressType); | ||
39 | + | ||
17 | } | 40 | } |
@@ -144,4 +144,21 @@ | @@ -144,4 +144,21 @@ | ||
144 | state = #{state,jdbcType=INTEGER} | 144 | state = #{state,jdbcType=INTEGER} |
145 | where id = #{id,jdbcType=INTEGER} | 145 | where id = #{id,jdbcType=INTEGER} |
146 | </update> | 146 | </update> |
147 | + | ||
148 | + <select id="queryExpressInfo" resultMap="BaseResultMap"> | ||
149 | + SELECT id, uid, order_code, waybill_code, accept_address, accept_remark, logistics_type, create_time, express_type, state | ||
150 | + FROM express_info | ||
151 | + where uid = #{uid} and order_code = #{orderCode} and express_type = #{expressType} | ||
152 | + ORDER BY create_time DESC | ||
153 | + </select> | ||
154 | + | ||
155 | + <select id="selectByOrderCodeAndStatesAndUidAndExpressType" resultMap="BaseResultMap"> | ||
156 | + SELECT id, uid, order_code, waybill_code, accept_address, accept_remark, logistics_type, create_time, express_type, state | ||
157 | + FROM express_info | ||
158 | + where uid = #{uid} and order_code = #{orderCode} and express_type = #{expressType} and | ||
159 | + <foreach collection="states" item="state" separator="," open="(" close=")" > | ||
160 | + #{state,jdbcType=INTEGER} | ||
161 | + </foreach> | ||
162 | + ORDER BY create_time DESC | ||
163 | + </select> | ||
147 | </mapper> | 164 | </mapper> |
1 | +package com.yohoufo.order.controller; | ||
2 | + | ||
3 | +import com.yohobuy.ufo.model.order.resp.ExpressInfoRespBo; | ||
4 | +import com.yohoufo.common.ApiResponse; | ||
5 | +import com.yohoufo.order.service.IExpressInfoService; | ||
6 | +import org.springframework.beans.factory.annotation.Autowired; | ||
7 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
8 | +import org.springframework.web.bind.annotation.RequestParam; | ||
9 | +import org.springframework.web.bind.annotation.RestController; | ||
10 | + | ||
11 | +/** | ||
12 | + * @author kun.wang | ||
13 | + * @date 2018/9/25 | ||
14 | + */ | ||
15 | +@RequestMapping | ||
16 | +@RestController | ||
17 | +public class ExpressInfoController { | ||
18 | + | ||
19 | + @Autowired | ||
20 | + private IExpressInfoService expressInfoService; | ||
21 | + | ||
22 | + | ||
23 | + /** | ||
24 | + * 卖家发货到鉴定中心 | ||
25 | + * @param expressCompanyId 快递公司id | ||
26 | + * @param orderCode 订单号 | ||
27 | + * @param wayBillCode 运单号(快递单号) | ||
28 | + * @return | ||
29 | + */ | ||
30 | + @RequestMapping(params = "method=ufo.order.deliverToDepot") | ||
31 | + public ApiResponse deliverToDepot(@RequestParam("expressCompanyId") Integer expressCompanyId, | ||
32 | + @RequestParam("orderCode") Long orderCode, @RequestParam("wayBillCode") String wayBillCode) { | ||
33 | + expressInfoService.deliverToDepot(expressCompanyId, orderCode, wayBillCode); | ||
34 | + return new ApiResponse(); | ||
35 | + } | ||
36 | + | ||
37 | + | ||
38 | + /** | ||
39 | + * 商品鉴定不通过,鉴定中心寄回商品给卖家 | ||
40 | + * @param expressCompanyId 快递公司id | ||
41 | + * @param orderCode 订单号 | ||
42 | + * @param wayBillCode 快递单号 | ||
43 | + * @return | ||
44 | + */ | ||
45 | + @RequestMapping(params = "method=ufo.order.appraiseFail") | ||
46 | + public ApiResponse appraiseFail(@RequestParam("expressCompanyId") Integer expressCompanyId, | ||
47 | + @RequestParam("orderCode") Long orderCode, @RequestParam("wayBillCode") String wayBillCode) { | ||
48 | + expressInfoService.appraiseFail(expressCompanyId, orderCode, wayBillCode); | ||
49 | + return new ApiResponse(); | ||
50 | + } | ||
51 | + | ||
52 | + /** | ||
53 | + * 鉴定通过,鉴定中心发货给买家 | ||
54 | + * @param expressCompanyId | ||
55 | + * @param orderCode | ||
56 | + * @param wayBillCode | ||
57 | + * @return | ||
58 | + */ | ||
59 | + @RequestMapping(params = "method=ufo.order.appraiseSuccess") | ||
60 | + public ApiResponse appraiseSuccess(@RequestParam("expressCompanyId") Integer expressCompanyId, | ||
61 | + @RequestParam("orderCode") Long orderCode, @RequestParam("wayBillCode") String wayBillCode) { | ||
62 | + expressInfoService.appraiseSuccess(expressCompanyId, orderCode, wayBillCode); | ||
63 | + return new ApiResponse(); | ||
64 | + } | ||
65 | + | ||
66 | + /** | ||
67 | + * 查询快递详情 | ||
68 | + * @param orderCode | ||
69 | + * @return | ||
70 | + */ | ||
71 | + @RequestMapping(params = "method=ufo.order.expressDetailInfo") | ||
72 | + public ApiResponse queryExpressDetailInfo(@RequestParam("orderCode") Long orderCode) { | ||
73 | + ExpressInfoRespBo expressInfoRespBo = expressInfoService.queryExpressDetailInfo(orderCode); | ||
74 | + return new ApiResponse.ApiResponseBuilder().code(200).data(expressInfoRespBo).build(); | ||
75 | + } | ||
76 | +} |
1 | + | ||
2 | +package com.yohoufo.order.mq.consumer; | ||
3 | + | ||
4 | +import com.alibaba.fastjson.JSONObject; | ||
5 | +import com.google.common.collect.Lists; | ||
6 | +import com.yoho.core.rabbitmq.YhConsumer; | ||
7 | +import com.yohoufo.common.constant.ExpressInfoConstant; | ||
8 | +import com.yohoufo.common.utils.DateUtil; | ||
9 | +import com.yohoufo.dal.order.BuyerOrderMapper; | ||
10 | +import com.yohoufo.dal.order.ExpressInfoMapper; | ||
11 | +import com.yohoufo.dal.order.SellerOrderMapper; | ||
12 | +import com.yohoufo.dal.order.model.BuyerOrder; | ||
13 | +import com.yohoufo.dal.order.model.ExpressInfo; | ||
14 | +import com.yohoufo.dal.order.model.SellerOrder; | ||
15 | +import com.yohoufo.order.service.IExpressInfoService; | ||
16 | +import org.apache.commons.collections.CollectionUtils; | ||
17 | +import org.apache.commons.lang3.StringUtils; | ||
18 | +import org.slf4j.Logger; | ||
19 | +import org.slf4j.LoggerFactory; | ||
20 | +import org.springframework.beans.factory.annotation.Autowired; | ||
21 | +import org.springframework.stereotype.Component; | ||
22 | + | ||
23 | +import java.util.List; | ||
24 | +import java.util.Objects; | ||
25 | + | ||
26 | + | ||
27 | +@Component | ||
28 | +public class ExpressInfoUpdateConsumer implements YhConsumer { | ||
29 | + | ||
30 | +private static final Logger LOGGER = LoggerFactory.getLogger(ExpressInfoUpdateConsumer.class); | ||
31 | + | ||
32 | + | ||
33 | + private final String topic = "order.updateExpressInfo"; | ||
34 | + | ||
35 | + @Autowired | ||
36 | + private ExpressInfoMapper expressInfoMapper; | ||
37 | + | ||
38 | + @Autowired | ||
39 | + private SellerOrderMapper sellerOrderMapper; | ||
40 | + | ||
41 | + @Autowired | ||
42 | + private BuyerOrderMapper buyerOrderMapper; | ||
43 | + | ||
44 | + @Autowired | ||
45 | + private IExpressInfoService expressInfoService; | ||
46 | + | ||
47 | + | ||
48 | + | ||
49 | + public String getMessageTopic() { | ||
50 | + return topic; | ||
51 | + } | ||
52 | + | ||
53 | + @Override | ||
54 | + public void handleMessage(Object message) { | ||
55 | + try { | ||
56 | + LOGGER.info("begin handle express info update message, message is {}.", message); | ||
57 | + updateExpressInfo(message); | ||
58 | + LOGGER.info("handle express info update message success, message is {}.", message); | ||
59 | + } catch (Exception e) { | ||
60 | + //消费失败上报到influxdb 暂时不需要 | ||
61 | + //consumerExceptionPublisher.pushlishEvent(getMessageTopic(), e); | ||
62 | + LOGGER.warn("handle express info update message fail, message is {}.", message); | ||
63 | + LOGGER.error("handleMessage error = ", e); | ||
64 | + } | ||
65 | + } | ||
66 | + | ||
67 | + private void updateExpressInfo(Object message) { | ||
68 | + JSONObject jsonMsg = JSONObject.parseObject(message.toString()); | ||
69 | + if (!checkValidMessage(jsonMsg)) { | ||
70 | + return; | ||
71 | + } | ||
72 | + long orderCode = jsonMsg.getLongValue("orderCode"); | ||
73 | + int uid = jsonMsg.getIntValue("uid"); | ||
74 | + if (uid == 0) { | ||
75 | + LOGGER.info("handle express info update message, not give me a uid, message is {}.", message); | ||
76 | + return; | ||
77 | + } | ||
78 | + // 判断是买家订单号还是卖家订单号 | ||
79 | + boolean buyer = false; | ||
80 | + //TODO | ||
81 | + if (buyer) { | ||
82 | + // 买家 | ||
83 | + BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCodeSellerUid(orderCode, uid); | ||
84 | + if (Objects.isNull(buyerOrder)) { | ||
85 | + LOGGER.info("handle express info update message, orders not found, message is {}.", message); | ||
86 | + return; | ||
87 | + } | ||
88 | + } else { | ||
89 | + // 卖家 | ||
90 | + SellerOrder sellerOrder = sellerOrderMapper.selectByOrderCodeUid(orderCode, uid); | ||
91 | + if (Objects.isNull(sellerOrder)) { | ||
92 | + LOGGER.info("handle express info update message, orders not found, message is {}.", message); | ||
93 | + return; | ||
94 | + } | ||
95 | + } | ||
96 | + int createTime = jsonMsg.getIntValue("createTime"); | ||
97 | + //int smsType = jsonMsg.getIntValue("businessType"); | ||
98 | + int state = jsonMsg.getIntValue("state"); | ||
99 | + | ||
100 | + // 正常订单,签收消息 | ||
101 | + if (state == ExpressInfoConstant.EXPRESS_STATUS_SIGN) { | ||
102 | + handleAcceptExpress(jsonMsg); | ||
103 | + return; | ||
104 | + } | ||
105 | + int logisticsType = jsonMsg.getIntValue("logisticsType"); | ||
106 | + String waybillCode = jsonMsg.getString("waybillCode"); | ||
107 | + | ||
108 | + // 正常订单,物流调拨消息 | ||
109 | + if (state == ExpressInfoConstant.EXPRESS_STATUS_UNSING | ||
110 | + && logisticsType < 1 | ||
111 | + && (StringUtils.isEmpty(waybillCode) || StringUtils.equals(waybillCode, "0"))) { | ||
112 | + state = ExpressInfoConstant.EXPRESS_STATUS_UNSEND; | ||
113 | + // 清除order详情缓存 | ||
114 | + /*noSyncRedisCacheManager.newCacheCleaner4Orders(orders) | ||
115 | + .buildOrderDetailKey(uid, orderCode) | ||
116 | + .clear();*/ | ||
117 | + | ||
118 | + } | ||
119 | + String acceptAddress = jsonMsg.getString("acceptAddress"); | ||
120 | + String acceptRemark = jsonMsg.getString("acceptRemark"); | ||
121 | + ExpressInfo expressInfo = new ExpressInfo(); | ||
122 | + expressInfo.setState(state); | ||
123 | + expressInfo.setLogisticsType(logisticsType); | ||
124 | + expressInfo.setOrderCode(orderCode); | ||
125 | + expressInfo.setWaybillCode(StringUtils.defaultString(waybillCode)); | ||
126 | + expressInfo.setAcceptAddress(StringUtils.defaultString(acceptAddress)); | ||
127 | + expressInfo.setAcceptRemark(StringUtils.defaultString(acceptRemark)); | ||
128 | + expressInfo.setCreateTime(createTime); | ||
129 | + expressInfo.setUid(uid); | ||
130 | + expressInfo.setExpressType(expressInfoService.getExpressType(orderCode).byteValue()); | ||
131 | + expressInfoMapper.insert(expressInfo); | ||
132 | + } | ||
133 | + | ||
134 | + private boolean checkValidMessage(JSONObject jsonMsg) { | ||
135 | + boolean flag = true; | ||
136 | + int smsType = jsonMsg.getIntValue("businessType"); | ||
137 | + int logisticsType = jsonMsg.getIntValue("logisticsType"); | ||
138 | + int state = jsonMsg.getIntValue("state"); | ||
139 | + long orderCode = jsonMsg.getLongValue("orderCode"); | ||
140 | + String waybillCode = jsonMsg.getString("waybillCode"); | ||
141 | + if (smsType < 1 || state < 0 || logisticsType < 0 || orderCode < 0) { | ||
142 | + LOGGER.warn("invalid express info message,message is {}.", jsonMsg); | ||
143 | + flag = false; | ||
144 | + } | ||
145 | + if (logisticsType > 0 && StringUtils.isBlank(waybillCode)) { | ||
146 | + LOGGER.warn("invalid express info message,message is {}.", jsonMsg); | ||
147 | + flag = false; | ||
148 | + } | ||
149 | + return flag; | ||
150 | + } | ||
151 | + | ||
152 | + /** | ||
153 | + * 确认收货处理 | ||
154 | + */ | ||
155 | + public void handleAcceptExpress(JSONObject jsonMsg) { | ||
156 | + int state = jsonMsg.getIntValue("state"); | ||
157 | + long orderCode = jsonMsg.getLongValue("orderCode"); | ||
158 | + int logisticsType = jsonMsg.getIntValue("logisticsType"); | ||
159 | + String waybillCode = jsonMsg.getString("waybillCode"); | ||
160 | + String acceptAddress = jsonMsg.getString("acceptAddress"); | ||
161 | + String acceptRemark = jsonMsg.getString("acceptRemark"); | ||
162 | + int uid = jsonMsg.getIntValue("uid"); | ||
163 | + int createTime = DateUtil.getCurrentTimeSecond(); | ||
164 | + | ||
165 | + Integer expressType = expressInfoService.getExpressType(orderCode); | ||
166 | + List<ExpressInfo> expressInfos = expressInfoMapper.selectByOrderCodeAndStatesAndUidAndExpressType(uid, orderCode, Lists.newArrayList(ExpressInfoConstant.EXPRESS_STATUS_SIGN), expressType); | ||
167 | + processExpressInfo(expressInfos, state, logisticsType, orderCode, waybillCode, acceptAddress, acceptRemark, createTime, uid, expressType); | ||
168 | + } | ||
169 | + | ||
170 | + | ||
171 | + /** | ||
172 | + * | ||
173 | + * @param expressInfos 快递信息 | ||
174 | + * @param state 快递状态 | ||
175 | + * @param logisticsType 快递公司id | ||
176 | + * @param orderCode 订单号 | ||
177 | + * @param waybillCode 快递单号 | ||
178 | + * @param acceptAddress 运单接收地 | ||
179 | + * @param acceptRemark 运单信息 | ||
180 | + * @param createTime 创建时间 | ||
181 | + * @param uid | ||
182 | + * @param expressType 物流类型 | ||
183 | + */ | ||
184 | + private void processExpressInfo(List<ExpressInfo> expressInfos, Integer state, Integer logisticsType, Long orderCode, String waybillCode, | ||
185 | + String acceptAddress, String acceptRemark, Integer createTime, Integer uid, Integer expressType) { | ||
186 | + if (CollectionUtils.isEmpty(expressInfos)) { | ||
187 | + ExpressInfo expressInfo = new ExpressInfo(); | ||
188 | + expressInfo.setState(state); | ||
189 | + expressInfo.setLogisticsType(logisticsType); | ||
190 | + expressInfo.setOrderCode(orderCode); | ||
191 | + expressInfo.setWaybillCode(StringUtils.defaultString(waybillCode)); | ||
192 | + expressInfo.setAcceptAddress(StringUtils.defaultString(acceptAddress)); | ||
193 | + expressInfo.setAcceptRemark(StringUtils.defaultString(acceptRemark)); | ||
194 | + expressInfo.setCreateTime(createTime); | ||
195 | + expressInfo.setUid(uid); | ||
196 | + expressInfo.setExpressType(expressType.byteValue()); | ||
197 | + expressInfoMapper.insert(expressInfo); | ||
198 | + } else { | ||
199 | + for (ExpressInfo expressInfo : expressInfos) { | ||
200 | + expressInfo.setState(state); | ||
201 | + expressInfo.setLogisticsType(logisticsType); | ||
202 | + expressInfo.setOrderCode(orderCode); | ||
203 | + expressInfo.setWaybillCode(StringUtils.defaultString(waybillCode)); | ||
204 | + expressInfo.setAcceptAddress(StringUtils.defaultString(acceptAddress)); | ||
205 | + expressInfo.setAcceptRemark(StringUtils.defaultString(acceptRemark)); | ||
206 | + expressInfo.setCreateTime(createTime); | ||
207 | + expressInfo.setUid(uid); | ||
208 | + expressInfo.setExpressType(expressType.byteValue()); | ||
209 | + expressInfoMapper.updateByPrimaryKeySelective(expressInfo); | ||
210 | + } | ||
211 | + } | ||
212 | + } | ||
213 | + | ||
214 | +} |
1 | +package com.yohoufo.order.service; | ||
2 | + | ||
3 | +import com.yohobuy.ufo.model.order.resp.ExpressInfoRespBo; | ||
4 | + | ||
5 | +/** | ||
6 | + * @author kun.wang | ||
7 | + * @date 2018/9/25 | ||
8 | + */ | ||
9 | +public interface IExpressInfoService { | ||
10 | + | ||
11 | + /** | ||
12 | + * 卖家发货到鉴定中心 | ||
13 | + * | ||
14 | + * @param expressCompanyId 快递公司id | ||
15 | + * @param orderCode 订单号 | ||
16 | + * @param wayBillCode 快递单号 | ||
17 | + */ | ||
18 | + void deliverToDepot(Integer expressCompanyId, Long orderCode, String wayBillCode); | ||
19 | + | ||
20 | + | ||
21 | + /** | ||
22 | + * 商品鉴定不通过,鉴定中心寄回商品给卖家 | ||
23 | + * | ||
24 | + * @param expressCompanyId 快递公司id | ||
25 | + * @param orderCode 订单号 | ||
26 | + * @param wayBillCode 快递单号 | ||
27 | + */ | ||
28 | + void appraiseFail(Integer expressCompanyId, Long orderCode, String wayBillCode); | ||
29 | + | ||
30 | + /** | ||
31 | + * 商品鉴定通过,鉴定中心发货给买家 | ||
32 | + * | ||
33 | + * @param expressCompanyId 快递公司id | ||
34 | + * @param orderCode 订单号 | ||
35 | + * @param wayBillCode 快递单号 | ||
36 | + */ | ||
37 | + void appraiseSuccess(Integer expressCompanyId, Long orderCode, String wayBillCode); | ||
38 | + | ||
39 | + /** | ||
40 | + * 根据订单号查询快递信息 | ||
41 | + * | ||
42 | + * @param orderCode | ||
43 | + * @return | ||
44 | + */ | ||
45 | + ExpressInfoRespBo queryExpressDetailInfo(Long orderCode); | ||
46 | + | ||
47 | + | ||
48 | + /** | ||
49 | + * 根据订单号获取快递类型 | ||
50 | + * 1:卖家到鉴定中心 | ||
51 | + * 2:鉴定中心到买家 | ||
52 | + * 3:鉴定中心退回到卖家 | ||
53 | + * | ||
54 | + * @param orderCode | ||
55 | + * @return | ||
56 | + */ | ||
57 | + Integer getExpressType(Long orderCode); | ||
58 | +} |
1 | +package com.yohoufo.order.service.impl; | ||
2 | + | ||
3 | +import com.alibaba.fastjson.JSON; | ||
4 | +import com.yoho.error.exception.ServiceException; | ||
5 | +import com.yohobuy.ufo.model.order.resp.ExpressInfoDetail; | ||
6 | +import com.yohobuy.ufo.model.order.resp.ExpressInfoRespBo; | ||
7 | +import com.yohoufo.common.constant.ExpressInfoConstant; | ||
8 | +import com.yohoufo.common.utils.DateUtil; | ||
9 | +import com.yohoufo.dal.order.ExpressInfoMapper; | ||
10 | +import com.yohoufo.dal.order.SellerOrderMapper; | ||
11 | +import com.yohoufo.dal.order.model.ExpressInfo; | ||
12 | +import com.yohoufo.dal.order.model.SellerOrder; | ||
13 | +import com.yohoufo.order.common.SellerOrderStatus; | ||
14 | +import com.yohoufo.order.service.IExpressCompanyService; | ||
15 | +import com.yohoufo.order.service.IExpressInfoService; | ||
16 | +import org.apache.commons.collections.CollectionUtils; | ||
17 | +import org.slf4j.Logger; | ||
18 | +import org.slf4j.LoggerFactory; | ||
19 | +import org.springframework.beans.factory.annotation.Autowired; | ||
20 | +import org.springframework.stereotype.Service; | ||
21 | + | ||
22 | +import java.util.ArrayList; | ||
23 | +import java.util.List; | ||
24 | + | ||
25 | +/** | ||
26 | + * @author kun.wang | ||
27 | + * @date 2018/9/25 | ||
28 | + */ | ||
29 | +@Service | ||
30 | +public class ExpressInfoServiceImpl implements IExpressInfoService { | ||
31 | + | ||
32 | + private static final Logger LOGGER = LoggerFactory.getLogger(ExpressInfoServiceImpl.class); | ||
33 | + | ||
34 | + @Autowired | ||
35 | + private ExpressInfoMapper expressInfoMapper; | ||
36 | + | ||
37 | + @Autowired | ||
38 | + private IExpressCompanyService expressCompanyService; | ||
39 | + | ||
40 | + @Autowired | ||
41 | + private SellerOrderMapper sellerOrderMapper; | ||
42 | + | ||
43 | + @Override | ||
44 | + public void deliverToDepot(Integer expressCompanyId, Long orderCode, String wayBillCode) { | ||
45 | + LOGGER.info("deliverToDepot expressCompanyId = {}, orderCode = {}, wayBillCode = {}", new Object[]{expressCompanyId, orderCode, wayBillCode}); | ||
46 | + // TODO | ||
47 | + // 保存订单物流信息 | ||
48 | + // 更新买家订单状态 | ||
49 | + } | ||
50 | + | ||
51 | + @Override | ||
52 | + public void appraiseFail(Integer expressCompanyId, Long orderCode, String wayBillCode) { | ||
53 | + LOGGER.info("appraiseFail expressCompanyId = {}, orderCode = {}, wayBillCode = {}", new Object[]{expressCompanyId, orderCode, wayBillCode}); | ||
54 | + // TODO | ||
55 | + } | ||
56 | + | ||
57 | + @Override | ||
58 | + public void appraiseSuccess(Integer expressCompanyId, Long orderCode, String wayBillCode) { | ||
59 | + LOGGER.info("appraiseSuccess expressCompanyId = {}, orderCode = {}, wayBillCode = {}", new Object[]{expressCompanyId, orderCode, wayBillCode}); | ||
60 | + // TODO | ||
61 | + } | ||
62 | + | ||
63 | + @Override | ||
64 | + public ExpressInfoRespBo queryExpressDetailInfo(Long orderCode) { | ||
65 | + LOGGER.info("queryExpressDetailInfo orderCode = {}", orderCode); | ||
66 | + ExpressInfoRespBo expressInfoRespBo = new ExpressInfoRespBo(); | ||
67 | + // TODO 获取uid | ||
68 | + Integer uid = null; | ||
69 | + Integer expressType = getExpressType(orderCode); | ||
70 | + LOGGER.info("getExpressType result = {}", expressType); | ||
71 | + List<ExpressInfo> expressInfoList = expressInfoMapper.queryExpressInfo(uid, orderCode, expressType); | ||
72 | + processExpressInfo(expressInfoList, expressInfoRespBo); | ||
73 | + LOGGER.info("queryExpressDetailInfo result = {}", JSON.toJSONString(expressInfoRespBo)); | ||
74 | + return expressInfoRespBo; | ||
75 | + } | ||
76 | + | ||
77 | + /** | ||
78 | + * @param expressInfoList | ||
79 | + * @param expressInfoRespBo | ||
80 | + */ | ||
81 | + private void processExpressInfo(List<ExpressInfo> expressInfoList, ExpressInfoRespBo expressInfoRespBo) { | ||
82 | + if (CollectionUtils.isNotEmpty(expressInfoList)) { | ||
83 | + List<ExpressInfoDetail> expressInfoDetailList = new ArrayList<>(); | ||
84 | + ExpressInfoDetail expressInfoDetail; | ||
85 | + for (ExpressInfo expressInfo : expressInfoList) { | ||
86 | + expressInfoDetail = new ExpressInfoDetail(); | ||
87 | + // 运单接收地 | ||
88 | + expressInfoDetail.setAcceptAddress(expressInfo.getAcceptAddress()); | ||
89 | + // 运单信息 | ||
90 | + expressInfoDetail.setAcceptRemark(expressInfo.getAcceptRemark()); | ||
91 | + expressInfoDetail.setCreateTimeStr(DateUtil.formatDate(expressInfo.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS)); | ||
92 | + expressInfoDetailList.add(expressInfoDetail); | ||
93 | + } | ||
94 | + expressInfoRespBo.setExpressInfoDetailList(expressInfoDetailList); | ||
95 | + // 快递单号 | ||
96 | + expressInfoRespBo.setWayBillCode(expressInfoList.get(0).getWaybillCode()); | ||
97 | + // 快递公司名称 | ||
98 | + expressInfoRespBo.setExpressCompanyName(expressCompanyService.getExpressName(expressInfoList.get(0).getLogisticsType())); | ||
99 | + } | ||
100 | + } | ||
101 | + | ||
102 | + @Override | ||
103 | + public Integer getExpressType(Long orderCode) { | ||
104 | + Integer uid = null; | ||
105 | + // TODO 根据订单号判断是买家还是卖家 | ||
106 | + boolean buyer = true; | ||
107 | + if (buyer) { | ||
108 | + return ExpressInfoConstant.EXPRESS_TYPE_2; | ||
109 | + } else { | ||
110 | + SellerOrder sellerOrder = sellerOrderMapper.selectByOrderCodeUid(orderCode, uid); | ||
111 | + if (sellerOrder == null) { | ||
112 | + LOGGER.warn("query seller order is null.orderCode = {}, uid = {}", sellerOrder, uid); | ||
113 | + throw new ServiceException(400, "卖家订单信息不存在!"); | ||
114 | + } | ||
115 | + if (SellerOrderStatus.HAS_PAYED.getCode() == sellerOrder.getStatus()) { | ||
116 | + // 查询卖家发货到鉴定中心的物流信息 | ||
117 | + return ExpressInfoConstant.EXPRESS_TYPE_1; | ||
118 | + } else if (SellerOrderStatus.APPRAISAL_FAIL_COMPENSATE.getCode() == sellerOrder.getStatus()) { | ||
119 | + // 查询鉴定中心发货给卖家的物流信息 | ||
120 | + return ExpressInfoConstant.EXPRESS_TYPE_3; | ||
121 | + } | ||
122 | + } | ||
123 | + return 0; | ||
124 | + } | ||
125 | +} |
-
Please register or login to post a comment