use of cn.lili.modules.system.entity.dos.Logistics in project lilishop by lilishop.
the class LogisticsServiceImpl method getOrderTracesByJson.
/**
* 获取物流信息
*
* @param logisticsId 物流公司ID
* @param expNo 物流单号
* @param customerName 手机号后四位
* @return 物流信息
* @throws Exception
*/
private Traces getOrderTracesByJson(String logisticsId, String expNo, String customerName) throws Exception {
Setting setting = settingService.get(SettingEnum.KUAIDI_SETTING.name());
if (CharSequenceUtil.isBlank(setting.getSettingValue())) {
throw new ServiceException(ResultCode.LOGISTICS_NOT_SETTING);
}
KuaidiSetting kuaidiSetting = new Gson().fromJson(setting.getSettingValue(), KuaidiSetting.class);
// ID
String EBusinessID = kuaidiSetting.getEbusinessID();
// KEY
String AppKey = kuaidiSetting.getAppKey();
// 请求url
String ReqURL = kuaidiSetting.getReqURL();
Logistics logistics = this.getById(logisticsId);
if (logistics != null) {
String requestData = "{'OrderCode':'','ShipperCode':'" + logistics.getCode() + "','LogisticCode':'" + expNo + "'" + ",'CustomerName':'" + customerName + "'" + "}";
Map<String, String> params = new HashMap<>(8);
params.put("RequestData", urlEncoder(requestData, "UTF-8"));
params.put("EBusinessID", EBusinessID);
params.put("RequestType", "1002");
String dataSign = encrypt(requestData, AppKey, "UTF-8");
params.put("DataSign", urlEncoder(dataSign, "UTF-8"));
params.put("DataType", "2");
String result = sendPost(ReqURL, params);
Map map = (Map) JSON.parse(result);
return new Traces(logistics.getName(), expNo, (List<Map>) map.get("Traces"));
}
return null;
}
use of cn.lili.modules.system.entity.dos.Logistics in project lilishop by lilishop.
the class OrderServiceImpl method checkBatchDeliver.
/**
* 循环检查批量发货订单列表
*
* @param list 待发货订单列表
*/
private void checkBatchDeliver(List<OrderBatchDeliverDTO> list) {
List<Logistics> logistics = logisticsService.list();
for (OrderBatchDeliverDTO orderBatchDeliverDTO : list) {
// 查看订单号是否存在-是否是当前店铺的订单
Order order = this.getOne(new LambdaQueryWrapper<Order>().eq(Order::getStoreId, UserContext.getCurrentUser().getStoreId()).eq(Order::getSn, orderBatchDeliverDTO.getOrderSn()));
if (order == null) {
throw new ServiceException("订单编号:'" + orderBatchDeliverDTO.getOrderSn() + " '不存在");
} else if (!order.getOrderStatus().equals(OrderStatusEnum.UNDELIVERED.name())) {
throw new ServiceException("订单编号:'" + orderBatchDeliverDTO.getOrderSn() + " '不能发货");
}
// 获取物流公司
logistics.forEach(item -> {
if (item.getName().equals(orderBatchDeliverDTO.getLogisticsName())) {
orderBatchDeliverDTO.setLogisticsId(item.getId());
}
});
if (CharSequenceUtil.isEmpty(orderBatchDeliverDTO.getLogisticsId())) {
throw new ServiceException("物流公司:'" + orderBatchDeliverDTO.getLogisticsName() + " '不存在");
}
}
}
use of cn.lili.modules.system.entity.dos.Logistics in project lilishop by lilishop.
the class OrderServiceImpl method delivery.
@Override
@OrderLogPoint(description = "'订单['+#orderSn+']发货,发货单号['+#logisticsNo+']'", orderSn = "#orderSn")
@Transactional(rollbackFor = Exception.class)
public Order delivery(String orderSn, String logisticsNo, String logisticsId) {
Order order = OperationalJudgment.judgment(this.getBySn(orderSn));
// 如果订单未发货,并且订单状态值等于待发货
if (order.getDeliverStatus().equals(DeliverStatusEnum.UNDELIVERED.name()) && order.getOrderStatus().equals(OrderStatusEnum.UNDELIVERED.name())) {
// 获取对应物流
Logistics logistics = logisticsService.getById(logisticsId);
if (logistics == null) {
throw new ServiceException(ResultCode.ORDER_LOGISTICS_ERROR);
}
// 写入物流信息
order.setLogisticsCode(logistics.getId());
order.setLogisticsName(logistics.getName());
order.setLogisticsNo(logisticsNo);
order.setLogisticsTime(new Date());
order.setDeliverStatus(DeliverStatusEnum.DELIVERED.name());
this.updateById(order);
// 修改订单状态为已发送
this.updateStatus(orderSn, OrderStatusEnum.DELIVERED);
// 修改订单货物可以进行售后、投诉
orderItemService.update(new UpdateWrapper<OrderItem>().eq(ORDER_SN_COLUMN, orderSn).set("after_sale_status", OrderItemAfterSaleStatusEnum.NOT_APPLIED).set("complain_status", OrderComplaintStatusEnum.NO_APPLY));
// 发送订单状态改变消息
OrderMessage orderMessage = new OrderMessage();
orderMessage.setNewStatus(OrderStatusEnum.DELIVERED);
orderMessage.setOrderSn(order.getSn());
this.sendUpdateStatusMessage(orderMessage);
} else {
throw new ServiceException(ResultCode.ORDER_DELIVER_ERROR);
}
return order;
}
use of cn.lili.modules.system.entity.dos.Logistics in project lilishop by lilishop.
the class AfterSaleServiceImpl method buyerDelivery.
@AfterSaleLogPoint(sn = "#afterSaleSn", description = "'买家退货,物流填写:单号['+#afterSaleSn+'],物流单号为['+#logisticsNo+']'")
@SystemLogPoint(description = "售后-买家退货,物流填写", customerLog = "'买家退货,物流填写:单号['+#afterSaleSn+'],物流单号为['+#logisticsNo+']'")
@Override
public AfterSale buyerDelivery(String afterSaleSn, String logisticsNo, String logisticsId, Date mDeliverTime) {
// 根据售后单号获取售后单
AfterSale afterSale = OperationalJudgment.judgment(this.getBySn(afterSaleSn));
// 判断为已审核通过,待邮寄的售后服务
if (!afterSale.getServiceStatus().equals(AfterSaleStatusEnum.PASS.name())) {
throw new ServiceException(ResultCode.AFTER_STATUS_ERROR);
}
// 查询会员回寄的物流公司信息
Logistics logistics = logisticsService.getById(logisticsId);
// 判断物流公司是否为空
if (logistics == null) {
throw new ServiceException(ResultCode.AFTER_STATUS_ERROR);
}
afterSale.setMLogisticsCode(logistics.getId());
afterSale.setMLogisticsName(logistics.getName());
afterSale.setMLogisticsNo(logisticsNo);
afterSale.setMDeliverTime(mDeliverTime);
// 修改售后单状态
afterSale.setServiceStatus(AfterSaleStatusEnum.BUYER_RETURN.name());
// 根据售后编号修改售后单
this.updateAfterSale(afterSaleSn, afterSale);
return afterSale;
}
Aggregations