完善视频号小店电子面单打印
This commit is contained in:
parent
90443ce3ec
commit
68ce2785c5
Binary file not shown.
|
|
@ -32,9 +32,9 @@
|
|||
<dependency>
|
||||
<groupId>wei-api</groupId>
|
||||
<artifactId>wei-api</artifactId>
|
||||
<version>1.6.3</version>
|
||||
<version>1.6.20</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/libs/wei-api-1.6.3.jar</systemPath>
|
||||
<systemPath>${project.basedir}/libs/wei-api-1.6.20.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,15 @@
|
|||
package com.qihang.wei.controller;
|
||||
|
||||
import cn.qihangerp.open.wei.EwaybillAccountApiHelper;
|
||||
import cn.qihangerp.open.wei.EwaybillApiHelper;
|
||||
import cn.qihangerp.open.wei.bo.ewaybill.EcOrderInfo;
|
||||
import cn.qihangerp.open.wei.bo.ewaybill.GoodsInfo;
|
||||
import cn.qihangerp.open.wei.bo.ewaybill.SenderAddressBo;
|
||||
import cn.qihangerp.open.wei.bo.ewaybill.WaybillRequest;
|
||||
import cn.qihangerp.open.wei.common.ApiResultVo;
|
||||
import cn.qihangerp.open.wei.vo.ewaybill.AccountVo;
|
||||
import cn.qihangerp.open.wei.vo.ewaybill.DeliveryVo;
|
||||
import cn.qihangerp.open.wei.vo.ewaybill.EwaybillOrderCreateVo;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.qihang.common.common.AjaxResult;
|
||||
|
|
@ -12,7 +18,11 @@ import com.qihang.common.enums.HttpStatus;
|
|||
import com.qihang.wei.bo.PullRequest;
|
||||
|
||||
import com.qihang.wei.bo.WeiWaybillGetBo;
|
||||
import com.qihang.wei.domain.ErpShipWaybill;
|
||||
import com.qihang.wei.domain.OmsWeiOrder;
|
||||
import com.qihang.wei.domain.OmsWeiWaybillAccount;
|
||||
import com.qihang.wei.service.ErpShipWaybillService;
|
||||
import com.qihang.wei.service.OmsWeiOrderService;
|
||||
import com.qihang.wei.service.OmsWeiWaybillAccountService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.java.Log;
|
||||
|
|
@ -30,6 +40,8 @@ import java.util.List;
|
|||
public class WayBillController {
|
||||
private final WeiApiCommon apiCommon;
|
||||
private final OmsWeiWaybillAccountService waybillAccountService;
|
||||
private final OmsWeiOrderService orderService;
|
||||
private final ErpShipWaybillService erpShipWaybillService;
|
||||
@RequestMapping(value = "/get_waybill_account_list", method = RequestMethod.POST)
|
||||
public AjaxResult getWaybillAccountList(@RequestBody PullRequest params) throws Exception {
|
||||
if (params.getShopId() == null || params.getShopId() <= 0) {
|
||||
|
|
@ -57,7 +69,7 @@ public class WayBillController {
|
|||
String appSecret = checkResult.getData().getAppSecret();
|
||||
|
||||
// ApiResultVo<DeliveryVo> apiResultVo = EwaybillApiHelper.getDeliveryList(appKey, appSecret, accessToken);
|
||||
ApiResultVo<AccountVo> apiResultVo = EwaybillApiHelper.getAccountList(appKey, appSecret, accessToken);
|
||||
ApiResultVo<AccountVo> apiResultVo = EwaybillAccountApiHelper.getAccountList(appKey, appSecret, accessToken);
|
||||
|
||||
List<OmsWeiWaybillAccount> list = new ArrayList<>();
|
||||
if(apiResultVo.getCode()==0){
|
||||
|
|
@ -85,6 +97,11 @@ public class WayBillController {
|
|||
vo.setSenderCity(item.getSenderAddress().getCity());
|
||||
vo.setSenderCounty(item.getSenderAddress().getCounty());
|
||||
}
|
||||
if(item.getSiteInfo()!=null){
|
||||
vo.setSiteCode(item.getSiteInfo().getSiteCode());
|
||||
vo.setSiteName(item.getSiteInfo().getSiteName());
|
||||
vo.setSenderStreet(item.getSiteInfo().getAddress().getStreetName());
|
||||
}
|
||||
list.add(vo);
|
||||
waybillAccountService.save(vo);
|
||||
log.info("========添加wei电子面单账户信息==========");
|
||||
|
|
@ -110,7 +127,7 @@ public class WayBillController {
|
|||
return AjaxResult.error(HttpStatus.PARAMS_ERROR, "参数错误,没有选择订单");
|
||||
}
|
||||
var checkResult = apiCommon.checkBefore(req.getShopId());
|
||||
if (checkResult.getCode() != HttpStatus.SUCCESS) {
|
||||
if (checkResult.getCode() != 0) {
|
||||
return AjaxResult.error(checkResult.getCode(), checkResult.getMsg(), checkResult.getData());
|
||||
}
|
||||
String accessToken = checkResult.getData().getAccessToken();
|
||||
|
|
@ -121,85 +138,126 @@ public class WayBillController {
|
|||
// 获取电子面单账户信息(包含了发货地址信息)
|
||||
OmsWeiWaybillAccount account = waybillAccountService.getById(req.getAccountId());
|
||||
|
||||
// WaybillCloudPrintApplyNewRequest request = new WaybillCloudPrintApplyNewRequest();
|
||||
// request.setCp_code(account.getCpCode());
|
||||
//
|
||||
// WaybillCloudPrintApplyNewRequestSender sender = new WaybillCloudPrintApplyNewRequestSender();
|
||||
// sender.setName(account.getName());
|
||||
// sender.setMobile(account.getMobile());
|
||||
// WaybillCloudPrintApplyNewRequestSender.AddressDTO addressDTO = new WaybillCloudPrintApplyNewRequestSender.AddressDTO();
|
||||
// addressDTO.setCity(account.getCity());
|
||||
// addressDTO.setProvince(account.getProvince());
|
||||
// addressDTO.setDistrict(account.getArea());
|
||||
// addressDTO.setTown("");
|
||||
// addressDTO.setDetail(account.getAddressDetail());
|
||||
// sender.setAddress(addressDTO);
|
||||
// request.setSender(sender);
|
||||
//
|
||||
// // 组合取号的订单信息trade_order_info_dtos
|
||||
// List<WaybillCloudPrintApplyNewRequestTradeOrderInfoDto> orderList = new ArrayList<>();
|
||||
//
|
||||
// for(String orderId:req.getIds()){
|
||||
// if(StringUtils.hasText(orderId)){
|
||||
// OmsTaoOrder omsTaoOrder = orderService.queryDetailByTid(orderId);
|
||||
// if(omsTaoOrder!=null) {
|
||||
// WaybillCloudPrintApplyNewRequestTradeOrderInfoDto dto = new WaybillCloudPrintApplyNewRequestTradeOrderInfoDto();
|
||||
// dto.setObjectId(omsTaoOrder.getTid());
|
||||
// dto.setTemplateUrl("http://cloudprint.cainiao.com/template/standard/101");
|
||||
// dto.setUserId(sellerShopId.intValue());
|
||||
//
|
||||
// WaybillCloudPrintApplyNewRequestTradeOrderInfoDto.OrderInfoDTO orderInfoDTO = new WaybillCloudPrintApplyNewRequestTradeOrderInfoDto.OrderInfoDTO();
|
||||
// orderInfoDTO.setOrderChannelsType("TB");
|
||||
// orderInfoDTO.setTradeOrderList(omsTaoOrder.getTid());
|
||||
// dto.setOrderInfo(orderInfoDTO);
|
||||
//
|
||||
// WaybillCloudPrintApplyNewRequestTradeOrderInfoDto.PackageInfoDTO packageInfoDTO = new WaybillCloudPrintApplyNewRequestTradeOrderInfoDto.PackageInfoDTO();
|
||||
// List<WaybillCloudPrintApplyNewRequestTradeOrderInfoDto.PackageInfoDTO.ItemsDTO> items = new ArrayList<>();
|
||||
// for (var orderItem : omsTaoOrder.getItems()) {
|
||||
// WaybillCloudPrintApplyNewRequestTradeOrderInfoDto.PackageInfoDTO.ItemsDTO itemsDTO = new WaybillCloudPrintApplyNewRequestTradeOrderInfoDto.PackageInfoDTO.ItemsDTO();
|
||||
// itemsDTO.setCount(orderItem.getNum());
|
||||
// itemsDTO.setName(orderItem.getTitle());
|
||||
// items.add(itemsDTO);
|
||||
// }
|
||||
// packageInfoDTO.setItems(items);
|
||||
// dto.setPackageInfo(packageInfoDTO);
|
||||
//
|
||||
// WaybillCloudPrintApplyNewRequestTradeOrderInfoDto.RecipientDTO recipientDTO = new WaybillCloudPrintApplyNewRequestTradeOrderInfoDto.RecipientDTO();
|
||||
// WaybillCloudPrintApplyNewRequestTradeOrderInfoDto.RecipientDTO.AddressDTO addressDTO1 = new WaybillCloudPrintApplyNewRequestTradeOrderInfoDto.RecipientDTO.AddressDTO();
|
||||
// addressDTO1.setCity(omsTaoOrder.getReceiverCity());
|
||||
// addressDTO1.setTown(omsTaoOrder.getReceiverTown());
|
||||
// addressDTO1.setProvince(omsTaoOrder.getReceiverState());
|
||||
// addressDTO1.setDistrict(omsTaoOrder.getReceiverDistrict());
|
||||
// addressDTO1.setDetail(omsTaoOrder.getReceiverAddress());
|
||||
// recipientDTO.setAddress(addressDTO1);
|
||||
// recipientDTO.setName(omsTaoOrder.getReceiverName());
|
||||
// recipientDTO.setOaid(omsTaoOrder.getOaid());
|
||||
// recipientDTO.setTid(omsTaoOrder.getTid());
|
||||
// dto.setRecipient(recipientDTO);
|
||||
// orderList.add(dto);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// request.setTrade_order_info_dtos(orderList);
|
||||
//
|
||||
// ApiResultVo<WaybillCloudPrint> apiResultVo = WaybillApiHelper.waybillCloudPrintApplyNew(appKey, appSecret, accessToken, request);
|
||||
// if(apiResultVo.getCode()==0){
|
||||
// // 保持数据
|
||||
// for(var result: apiResultVo.getList()){
|
||||
// ErpShipWaybill waybill = new ErpShipWaybill();
|
||||
// waybill.setShopId(req.getShopId());
|
||||
// waybill.setOrderId(result.getObjectId());
|
||||
// waybill.setWaybillCode(result.getWaybillCode());
|
||||
// waybill.setLogisticsCode(result.getCpCode());
|
||||
// waybill.setPrintData(result.getPrintData());
|
||||
// waybill.setStatus(1);//1已取号
|
||||
// erpShipWaybillService.waybillUpdate(waybill);
|
||||
// log.info("====保存電子面單信息========"+result.getObjectId());
|
||||
// }
|
||||
// }else{
|
||||
// return AjaxResult.error(apiResultVo.getMsg());
|
||||
// }
|
||||
WaybillRequest apiBo = new WaybillRequest();
|
||||
|
||||
apiBo.setDelivery_id(account.getDeliveryId());
|
||||
apiBo.setEwaybill_acct_id(account.getAcctId());
|
||||
|
||||
SenderAddressBo sender = new SenderAddressBo();
|
||||
sender.setName(account.getName());
|
||||
sender.setMobile(account.getMobile());
|
||||
sender.setProvince(account.getSenderProvince());
|
||||
sender.setCity(account.getSenderCity());
|
||||
sender.setCounty(account.getSenderCounty());
|
||||
sender.setStreet(account.getSenderStreet());
|
||||
sender.setAddress(account.getSenderAddress());
|
||||
apiBo.setSender(sender);
|
||||
|
||||
for (String orderId : req.getIds()) {
|
||||
if (StringUtils.hasText(orderId)) {
|
||||
OmsWeiOrder order = orderService.queryDetailByOrderId(orderId);
|
||||
if (order != null) {
|
||||
|
||||
SenderAddressBo receiver = new SenderAddressBo();
|
||||
receiver.setName(order.getUserName());
|
||||
receiver.setMobile(order.getTelNumber());
|
||||
receiver.setProvince(order.getProvinceName());
|
||||
receiver.setCity(order.getCityName());
|
||||
receiver.setCounty(order.getCountyName());
|
||||
receiver.setStreet("");
|
||||
receiver.setAddress("****");
|
||||
apiBo.setReceiver(receiver);
|
||||
|
||||
List<EcOrderInfo> orderInfos = new ArrayList<>();
|
||||
// 订单信息
|
||||
EcOrderInfo orderInfo = new EcOrderInfo();
|
||||
orderInfo.setEc_order_id(Long.parseLong(order.getOrderId()));
|
||||
|
||||
List<GoodsInfo> goodsInfos = new ArrayList<>();
|
||||
if(order.getItems()!=null&&order.getItems().size()>0) {
|
||||
for (var item:order.getItems()) {
|
||||
GoodsInfo gi = new GoodsInfo();
|
||||
gi.setProduct_id(Long.parseLong(item.getProductId()));
|
||||
gi.setSku_id(Long.parseLong(item.getSkuId()));
|
||||
gi.setGood_name(item.getTitle());
|
||||
gi.setGood_count(item.getSkuCnt());
|
||||
goodsInfos.add(gi);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
orderInfo.setGoods_list(goodsInfos);
|
||||
orderInfos.add(orderInfo);
|
||||
|
||||
apiBo.setEc_order_list(orderInfos);
|
||||
|
||||
apiBo.setShop_id(account.getSellerShopId());
|
||||
|
||||
ApiResultVo<EwaybillOrderCreateVo> apiResultVo = EwaybillApiHelper.getWaybillCode(appKey, appSecret, accessToken, apiBo);
|
||||
if (apiResultVo.getCode() == 0) {
|
||||
// 保持数据
|
||||
ErpShipWaybill waybill = new ErpShipWaybill();
|
||||
waybill.setShopId(req.getShopId());
|
||||
waybill.setOrderId(order.getOrderId());
|
||||
waybill.setWaybillOrderId(apiResultVo.getData().getEwaybill_order_id());
|
||||
waybill.setWaybillCode(apiResultVo.getData().getWaybill_id());
|
||||
waybill.setLogisticsCode(account.getDeliveryId());
|
||||
waybill.setPrintData(apiResultVo.getData().getPrint_info());
|
||||
waybill.setStatus(1);//1已取号
|
||||
erpShipWaybillService.waybillUpdate(waybill);
|
||||
log.info("====保存wei電子面單信息========" + order.getOrderId());
|
||||
|
||||
} else {
|
||||
return AjaxResult.error(apiResultVo.getMsg());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("/get_print_data")
|
||||
@ResponseBody
|
||||
public AjaxResult getPrintData(@RequestBody WeiWaybillGetBo req) {
|
||||
if (req.getShopId() == null || req.getShopId() <= 0) {
|
||||
return AjaxResult.error(HttpStatus.PARAMS_ERROR, "参数错误,没有店铺Id");
|
||||
}
|
||||
if (req.getIds() == null || req.getIds().length <= 0) {
|
||||
return AjaxResult.error(HttpStatus.PARAMS_ERROR, "参数错误,没有选择订单");
|
||||
}
|
||||
List<ErpShipWaybill> listByOrderIds = erpShipWaybillService.getListByOrderIds(req.getShopId(), req.getIds());
|
||||
return AjaxResult.success(listByOrderIds);
|
||||
}
|
||||
|
||||
@PostMapping("/push_print_success")
|
||||
@ResponseBody
|
||||
public AjaxResult pushPrintSuccess(@RequestBody WeiWaybillGetBo req) {
|
||||
if (req.getShopId() == null || req.getShopId() <= 0) {
|
||||
return AjaxResult.error(HttpStatus.PARAMS_ERROR, "参数错误,没有店铺Id");
|
||||
}
|
||||
if (req.getIds() == null || req.getIds().length <= 0) {
|
||||
return AjaxResult.error(HttpStatus.PARAMS_ERROR, "参数错误,没有选择订单");
|
||||
}
|
||||
erpShipWaybillService.printSuccess(req.getShopId(), req.getIds());
|
||||
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 发货
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/push_ship_send")
|
||||
@ResponseBody
|
||||
public AjaxResult pushShipSend(@RequestBody WeiWaybillGetBo req) {
|
||||
if (req.getShopId() == null || req.getShopId() <= 0) {
|
||||
return AjaxResult.error(HttpStatus.PARAMS_ERROR, "参数错误,没有店铺Id");
|
||||
}
|
||||
if (req.getIds() == null || req.getIds().length <= 0) {
|
||||
return AjaxResult.error(HttpStatus.PARAMS_ERROR, "参数错误,没有选择订单");
|
||||
}
|
||||
erpShipWaybillService.pushShipSend(req.getShopId(), req.getIds());
|
||||
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,79 @@
|
|||
package com.qihang.wei.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 发货电子面单记录表
|
||||
* @TableName erp_ship_waybill
|
||||
*/
|
||||
@Data
|
||||
public class ErpShipWaybill implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 订单号
|
||||
*/
|
||||
private String orderId;
|
||||
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 店铺类型
|
||||
*/
|
||||
private Integer shopType;
|
||||
|
||||
/**
|
||||
* 快递单号
|
||||
*/
|
||||
private String waybillCode;
|
||||
private String waybillOrderId;
|
||||
|
||||
/**
|
||||
* 快递公司编码
|
||||
*/
|
||||
private String logisticsCode;
|
||||
|
||||
/**
|
||||
* 打印数据
|
||||
*/
|
||||
private String printData;
|
||||
|
||||
/**
|
||||
* 状态(1已取号2已打印3已发货)
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
|
@ -38,6 +38,16 @@ public class OmsWeiWaybillAccount implements Serializable {
|
|||
*/
|
||||
private Integer companyType;
|
||||
|
||||
/**
|
||||
* 网点编码
|
||||
*/
|
||||
private String siteCode;
|
||||
|
||||
/**
|
||||
* 网点名称
|
||||
*/
|
||||
private String siteName;
|
||||
|
||||
/**
|
||||
* 电子面单账号id,每绑定一个网点分配一个acct_id
|
||||
*/
|
||||
|
|
@ -98,6 +108,11 @@ public class OmsWeiWaybillAccount implements Serializable {
|
|||
*/
|
||||
private String senderCounty;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String senderStreet;
|
||||
|
||||
/**
|
||||
* 详细地址
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package com.qihang.wei.mapper;
|
||||
|
||||
import com.qihang.wei.domain.ErpShipWaybill;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author TW
|
||||
* @description 针对表【erp_ship_waybill(发货电子面单记录表)】的数据库操作Mapper
|
||||
* @createDate 2024-06-20 10:05:35
|
||||
* @Entity com.qihang.wei.domain.ErpShipWaybill
|
||||
*/
|
||||
public interface ErpShipWaybillMapper extends BaseMapper<ErpShipWaybill> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||
/**
|
||||
* @author TW
|
||||
* @description 针对表【oms_wei_waybill_account(视频号小店电子面单账户信息表)】的数据库操作Mapper
|
||||
* @createDate 2024-06-19 17:08:54
|
||||
* @createDate 2024-06-20 09:18:48
|
||||
* @Entity com.qihang.wei.domain.OmsWeiWaybillAccount
|
||||
*/
|
||||
public interface OmsWeiWaybillAccountMapper extends BaseMapper<OmsWeiWaybillAccount> {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
package com.qihang.wei.service;
|
||||
|
||||
import com.qihang.common.common.ResultVo;
|
||||
import com.qihang.wei.domain.ErpShipWaybill;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author TW
|
||||
* @description 针对表【erp_ship_waybill(发货电子面单记录表)】的数据库操作Service
|
||||
* @createDate 2024-06-20 10:05:35
|
||||
*/
|
||||
public interface ErpShipWaybillService extends IService<ErpShipWaybill> {
|
||||
ResultVo<Integer> waybillUpdate(ErpShipWaybill shipWaybill);
|
||||
List<ErpShipWaybill> getListByOrderIds(Long shopId, String[] orderIds);
|
||||
|
||||
ResultVo<Integer> printSuccess(Long shopId,String[] orderIds);
|
||||
ResultVo<Integer> pushShipSend(Long shopId,String[] orderIds);
|
||||
}
|
||||
|
|
@ -16,5 +16,5 @@ public interface OmsWeiOrderService extends IService<OmsWeiOrder> {
|
|||
PageResult<OmsWeiOrder> queryPageList(OmsWeiOrder bo, PageQuery pageQuery);
|
||||
ResultVo<Integer> saveOrder(Long shopId, OmsWeiOrder order);
|
||||
OmsWeiOrder queryDetailById(Long id);
|
||||
|
||||
OmsWeiOrder queryDetailByOrderId(String orderId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
/**
|
||||
* @author TW
|
||||
* @description 针对表【oms_wei_waybill_account(视频号小店电子面单账户信息表)】的数据库操作Service
|
||||
* @createDate 2024-06-19 17:08:54
|
||||
* @createDate 2024-06-20 09:18:48
|
||||
*/
|
||||
public interface OmsWeiWaybillAccountService extends IService<OmsWeiWaybillAccount> {
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,161 @@
|
|||
package com.qihang.wei.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.qihang.common.common.ResultVo;
|
||||
import com.qihang.common.enums.EnumShopType;
|
||||
import com.qihang.common.mq.MqMessage;
|
||||
import com.qihang.common.mq.MqType;
|
||||
import com.qihang.wei.domain.ErpShipWaybill;
|
||||
import com.qihang.wei.domain.OmsWeiOrder;
|
||||
import com.qihang.wei.mapper.OmsWeiOrderMapper;
|
||||
import com.qihang.wei.service.ErpShipWaybillService;
|
||||
import com.qihang.wei.mapper.ErpShipWaybillMapper;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author TW
|
||||
* @description 针对表【erp_ship_waybill(发货电子面单记录表)】的数据库操作Service实现
|
||||
* @createDate 2024-06-20 10:05:35
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Service
|
||||
public class ErpShipWaybillServiceImpl extends ServiceImpl<ErpShipWaybillMapper, ErpShipWaybill>
|
||||
implements ErpShipWaybillService{
|
||||
private final ErpShipWaybillMapper mapper;
|
||||
private final OmsWeiOrderMapper orderMapper;
|
||||
private final KafkaTemplate<String,Object> kafkaTemplate;
|
||||
|
||||
/**
|
||||
* 更新电子面单信息
|
||||
* @param shipWaybill
|
||||
* @return
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public ResultVo<Integer> waybillUpdate(ErpShipWaybill shipWaybill) {
|
||||
String orderId= shipWaybill.getOrderId();
|
||||
if(shipWaybill.getId()!=null&&shipWaybill.getId()>0){
|
||||
// 存在,修改
|
||||
shipWaybill.setCreateBy(null);
|
||||
shipWaybill.setCreateTime(null);
|
||||
shipWaybill.setOrderId(null);
|
||||
shipWaybill.setShopId(null);
|
||||
shipWaybill.setShopType(null);
|
||||
mapper.updateById(shipWaybill);
|
||||
}else{
|
||||
// 新增
|
||||
List<ErpShipWaybill> erpShipWaybills = mapper.selectList(new LambdaQueryWrapper<ErpShipWaybill>().eq(ErpShipWaybill::getOrderId, orderId));
|
||||
if(erpShipWaybills==null|| erpShipWaybills.size()==0) {
|
||||
shipWaybill.setStatus(1);//已取号
|
||||
shipWaybill.setShopType(EnumShopType.TAO.getIndex());
|
||||
shipWaybill.setCreateTime(new Date());
|
||||
mapper.insert(shipWaybill);
|
||||
}else{
|
||||
ErpShipWaybill update = new ErpShipWaybill();
|
||||
update.setId(erpShipWaybills.get(0).getId());
|
||||
update.setWaybillCode(shipWaybill.getWaybillCode());
|
||||
update.setLogisticsCode(shipWaybill.getLogisticsCode());
|
||||
update.setPrintData(shipWaybill.getPrintData());
|
||||
update.setStatus(1);
|
||||
update.setUpdateTime(new Date());
|
||||
update.setUpdateBy("重新取号");
|
||||
mapper.updateById(update);
|
||||
}
|
||||
}
|
||||
// 更新关联订单erp_send_status状态
|
||||
OmsWeiOrder orderUpdate = new OmsWeiOrder();
|
||||
orderUpdate.setErpSendStatus(shipWaybill.getStatus());
|
||||
orderUpdate.setErpSendCode(shipWaybill.getWaybillCode());
|
||||
orderUpdate.setErpSendCompany(shipWaybill.getLogisticsCode());
|
||||
orderMapper.update(orderUpdate,new LambdaQueryWrapper<OmsWeiOrder>().eq(OmsWeiOrder::getOrderId,orderId));
|
||||
|
||||
return ResultVo.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ErpShipWaybill> getListByOrderIds(Long shopId, String[] orderIds) {
|
||||
List<ErpShipWaybill> erpShipWaybills = mapper.selectList(
|
||||
new LambdaQueryWrapper<ErpShipWaybill>()
|
||||
.eq(ErpShipWaybill::getShopId,shopId)
|
||||
.in(ErpShipWaybill::getOrderId, Arrays.stream(orderIds).toList()));
|
||||
return erpShipWaybills;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public ResultVo<Integer> printSuccess(Long shopId, String[] orderIds) {
|
||||
List<ErpShipWaybill> erpShipWaybills = mapper.selectList(
|
||||
new LambdaQueryWrapper<ErpShipWaybill>()
|
||||
.eq(ErpShipWaybill::getShopId,shopId)
|
||||
.in(ErpShipWaybill::getOrderId, Arrays.stream(orderIds).toList()));
|
||||
if(erpShipWaybills!=null){
|
||||
for (var w : erpShipWaybills){
|
||||
if(w.getStatus()==1) {
|
||||
ErpShipWaybill update = new ErpShipWaybill();
|
||||
update.setId(erpShipWaybills.get(0).getId());
|
||||
update.setStatus(2);
|
||||
update.setUpdateTime(new Date());
|
||||
update.setUpdateBy("打印面单");
|
||||
mapper.updateById(update);
|
||||
|
||||
// 更新关联订单erp_send_status状态
|
||||
OmsWeiOrder orderUpdate = new OmsWeiOrder();
|
||||
orderUpdate.setErpSendStatus(update.getStatus());
|
||||
|
||||
orderMapper.update(orderUpdate, new LambdaQueryWrapper<OmsWeiOrder>().eq(OmsWeiOrder::getOrderId, w.getOrderId()));
|
||||
|
||||
//TODO: 打印成功之后 加入备货清单 采用kafka推送消息处理
|
||||
|
||||
// 打印完成,通知备货
|
||||
kafkaTemplate.send(MqType.SHIP_STOCK_UP_MQ, JSONObject.toJSONString(MqMessage.build(w.getShopId(), w.getOrderId())));
|
||||
}
|
||||
}
|
||||
}
|
||||
return ResultVo.success();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public ResultVo<Integer> pushShipSend(Long shopId, String[] orderIds) {
|
||||
List<ErpShipWaybill> erpShipWaybills = mapper.selectList(
|
||||
new LambdaQueryWrapper<ErpShipWaybill>()
|
||||
.eq(ErpShipWaybill::getShopId,shopId)
|
||||
.in(ErpShipWaybill::getOrderId, Arrays.stream(orderIds).toList()));
|
||||
if(erpShipWaybills!=null){
|
||||
for (var w : erpShipWaybills){
|
||||
if(w.getStatus() > 0 && w.getStatus()<3) {
|
||||
ErpShipWaybill update = new ErpShipWaybill();
|
||||
update.setId(erpShipWaybills.get(0).getId());
|
||||
update.setStatus(3);// 已发货
|
||||
update.setUpdateTime(new Date());
|
||||
update.setUpdateBy("电子面单发货");
|
||||
mapper.updateById(update);
|
||||
|
||||
// 更新关联订单erp_send_status状态
|
||||
OmsWeiOrder orderUpdate = new OmsWeiOrder();
|
||||
orderUpdate.setErpSendStatus(update.getStatus());
|
||||
|
||||
orderMapper.update(orderUpdate, new LambdaQueryWrapper<OmsWeiOrder>().eq(OmsWeiOrder::getOrderId, w.getOrderId()));
|
||||
|
||||
// 更新erp_sale_order发货状态(controller层采用kafka推送消息处理)
|
||||
// 发货完成,通知发货出库
|
||||
kafkaTemplate.send(MqType.SHIP_SEND_MQ, JSONObject.toJSONString(MqMessage.build(w.getShopId(),w.getOrderId(),w.getLogisticsCode(),w.getWaybillCode())));
|
||||
}
|
||||
}
|
||||
}
|
||||
return ResultVo.success();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -123,7 +123,14 @@ public class OmsWeiOrderServiceImpl extends ServiceImpl<OmsWeiOrderMapper, OmsWe
|
|||
}
|
||||
return weiOrder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OmsWeiOrder queryDetailByOrderId(String orderId) {
|
||||
List<OmsWeiOrder> weiOrders = mapper.selectList(new LambdaQueryWrapper<OmsWeiOrder>().eq(OmsWeiOrder::getOrderId,orderId));
|
||||
if(weiOrders!=null&&weiOrders.size()>0){
|
||||
weiOrders.get(0).setItems(itemMapper.selectList(new LambdaQueryWrapper<OmsWeiOrderItem>().eq(OmsWeiOrderItem::getOrderId,orderId)));
|
||||
return weiOrders.get(0);
|
||||
}else return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import org.springframework.stereotype.Service;
|
|||
/**
|
||||
* @author TW
|
||||
* @description 针对表【oms_wei_waybill_account(视频号小店电子面单账户信息表)】的数据库操作Service实现
|
||||
* @createDate 2024-06-19 17:08:54
|
||||
* @createDate 2024-06-20 09:18:48
|
||||
*/
|
||||
@Service
|
||||
public class OmsWeiWaybillAccountServiceImpl extends ServiceImpl<OmsWeiWaybillAccountMapper, OmsWeiWaybillAccount>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.qihang.wei.mapper.ErpShipWaybillMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.qihang.wei.domain.ErpShipWaybill">
|
||||
<id property="id" column="id" jdbcType="BIGINT"/>
|
||||
<result property="orderId" column="order_id" jdbcType="VARCHAR"/>
|
||||
<result property="shopId" column="shop_id" jdbcType="BIGINT"/>
|
||||
<result property="shopType" column="shop_type" jdbcType="INTEGER"/>
|
||||
<result property="waybillCode" column="waybill_code" jdbcType="VARCHAR"/>
|
||||
<result property="waybillOrderId" column="waybill_order_id" jdbcType="VARCHAR"/>
|
||||
<result property="logisticsCode" column="logistics_code" jdbcType="VARCHAR"/>
|
||||
<result property="printData" column="print_data" jdbcType="VARCHAR"/>
|
||||
<result property="status" column="status" jdbcType="INTEGER"/>
|
||||
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="createBy" column="create_by" jdbcType="VARCHAR"/>
|
||||
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id,order_id,shop_id,
|
||||
shop_type,waybill_code,waybill_order_id,logistics_code,
|
||||
print_data,status,create_time,
|
||||
create_by,update_time,update_by
|
||||
</sql>
|
||||
</mapper>
|
||||
|
|
@ -10,6 +10,8 @@
|
|||
<result property="sellerShopId" column="seller_shop_id" jdbcType="BIGINT"/>
|
||||
<result property="deliveryId" column="delivery_id" jdbcType="VARCHAR"/>
|
||||
<result property="companyType" column="company_type" jdbcType="INTEGER"/>
|
||||
<result property="siteCode" column="site_code" jdbcType="VARCHAR"/>
|
||||
<result property="siteName" column="site_name" jdbcType="VARCHAR"/>
|
||||
<result property="acctId" column="acct_id" jdbcType="BIGINT"/>
|
||||
<result property="acctType" column="acct_type" jdbcType="INTEGER"/>
|
||||
<result property="status" column="status" jdbcType="INTEGER"/>
|
||||
|
|
@ -22,6 +24,7 @@
|
|||
<result property="senderProvince" column="sender_province" jdbcType="VARCHAR"/>
|
||||
<result property="senderCity" column="sender_city" jdbcType="VARCHAR"/>
|
||||
<result property="senderCounty" column="sender_county" jdbcType="VARCHAR"/>
|
||||
<result property="senderStreet" column="sender_street" jdbcType="VARCHAR"/>
|
||||
<result property="senderAddress" column="sender_address" jdbcType="VARCHAR"/>
|
||||
<result property="name" column="name" jdbcType="VARCHAR"/>
|
||||
<result property="mobile" column="mobile" jdbcType="VARCHAR"/>
|
||||
|
|
@ -31,11 +34,12 @@
|
|||
|
||||
<sql id="Base_Column_List">
|
||||
id,shop_id,seller_shop_id,
|
||||
delivery_id,company_type,acct_id,
|
||||
acct_type,status,available,
|
||||
allocated,cancel,recycled,
|
||||
monthly_card,site_info,sender_province,
|
||||
sender_city,sender_county,sender_address,
|
||||
delivery_id,company_type,site_code,
|
||||
site_name,acct_id,acct_type,
|
||||
status,available,allocated,
|
||||
cancel,recycled,monthly_card,
|
||||
site_info,sender_province,sender_city,
|
||||
sender_county,sender_street,sender_address,
|
||||
name,mobile,phone,
|
||||
is_show
|
||||
</sql>
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ export function getWaybillPrintData(data) {
|
|||
// 打印成功
|
||||
export function pushWaybillPrintSuccess(data) {
|
||||
return request({
|
||||
url: '/api/tao-api/ewaybill/push_print_success',
|
||||
url: '/api/wei-api/ewaybill/push_print_success',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
|
|
@ -48,7 +48,7 @@ export function pushWaybillPrintSuccess(data) {
|
|||
|
||||
export function pushShipSend(data) {
|
||||
return request({
|
||||
url: '/api/tao-api/ewaybill/push_ship_send',
|
||||
url: '/api/wei-api/ewaybill/push_ship_send',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@
|
|||
:label="item.deliveryId"
|
||||
:value="item.id">
|
||||
<span style="float: left">{{ item.deliveryId }}</span>
|
||||
<span style="float: right; color: #8492a6; font-size: 13px" >{{item.senderProvince}}{{item.senderCity}}{{item.senderCounty}}{{item.senderAddress}}:{{item.available}}</span>
|
||||
<span style="float: right; color: #8492a6; font-size: 13px" >{{item.siteName}}:{{item.available}}</span>
|
||||
</el-option>
|
||||
</el-select>
|
||||
<el-button type="success" plain @click="updateWaybillAccount" >更新电子面单账户信息</el-button>
|
||||
|
|
@ -171,8 +171,10 @@
|
|||
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||
|
||||
import {listShop} from "@/api/shop/shop";
|
||||
import {getWaybillAccountList,pullWaybillAccount,getWaybillCode} from "@/api/wei/ewaybill";
|
||||
import {getWaybillAccountList, pullWaybillAccount, getWaybillCode, pushWaybillPrintSuccess,pushShipSend} from "@/api/wei/ewaybill";
|
||||
import {listOrder} from "@/api/wei/order";
|
||||
import {getWaybillPrintData} from "@/api/tao/ewaybill";
|
||||
|
||||
|
||||
export default {
|
||||
name: "printWei",
|
||||
|
|
@ -218,7 +220,6 @@ export default {
|
|||
};
|
||||
},
|
||||
created() {
|
||||
this.openWs()
|
||||
this.openWs()
|
||||
listShop({platform: 2}).then(response => {
|
||||
this.shopList = response.rows;
|
||||
|
|
@ -357,23 +358,19 @@ export default {
|
|||
};
|
||||
},
|
||||
handlePrintEwaybill() {
|
||||
// if (!this.ws) {
|
||||
// this.$modal.msgError('打印组件连接失败!请安装并启动微信视频号小单打印组件!');
|
||||
// this.openWs()
|
||||
// }
|
||||
// if(!this.printParams.deliver){
|
||||
// this.$modal.msgError('请选择快递公司!');
|
||||
// return
|
||||
// }
|
||||
if (!this.printParams.printer) {
|
||||
this.$modal.msgError('请选择打印机!');
|
||||
return
|
||||
}
|
||||
getWaybillPrintData({shopId: this.queryParams.shopId, ids: this.ids}).then(response => {
|
||||
console.log("======打印======", response.data)
|
||||
if (response.data) {
|
||||
const ws = new WebSocket('ws://127.0.0.1:12705');
|
||||
|
||||
ws.onopen = () => {
|
||||
console.log('开始打印: ');
|
||||
// 打印
|
||||
this.ws.send(JSON.stringify({
|
||||
ws.send(JSON.stringify({
|
||||
command: 'print',
|
||||
version: '2.0', // 必传
|
||||
requestID: '1234', // String, 调用方保证唯一
|
||||
|
|
@ -399,12 +396,16 @@ export default {
|
|||
printer: this.printParams.printer, // 选中的打印机,printer.name
|
||||
}))
|
||||
};
|
||||
|
||||
|
||||
let obj = this.$modal;
|
||||
ws.onmessage = (e) => {
|
||||
const resp = JSON.parse(e.data || '{}')
|
||||
if (resp.command === 'print') {
|
||||
console.log('打印结果: ', resp);
|
||||
obj.msgError("打印结果!"+JSON.stringify(resp));
|
||||
// 请求回调
|
||||
return pushWaybillPrintSuccess({shopId: this.queryParams.shopId, ids: this.ids})
|
||||
// obj.msgError("打印结果!"+JSON.stringify(resp));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -415,8 +416,16 @@ export default {
|
|||
console.error('WebSocket error:', error);
|
||||
// alert('WebSocket error occurred. Check the console for more details.');
|
||||
};
|
||||
|
||||
}
|
||||
});
|
||||
},
|
||||
handleShipSend(){
|
||||
// this.$modal.msgError("开源版本未实现平台发货!请自行对接发货");
|
||||
pushShipSend({shopId: this.queryParams.shopId, ids: this.ids}).then(response => {
|
||||
this.$modal.msgSuccess("发货成功!");
|
||||
this.getList()
|
||||
})
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in New Issue