This commit is contained in:
老齐 2024-06-17 10:03:27 +08:00
commit 53a900dae6
29 changed files with 1382 additions and 88 deletions

View File

@ -19,6 +19,20 @@
<img src="preview.png" /> <img src="preview.png" />
### 开放计划
+ [ ] 打单--> 备货 --> 发货 --> 物流跟踪
+ [ ] 接入店铺退款
+ [ ] 淘宝
+ [ ] 京东
+ [ ] 拼多多
+ [ ] 抖店
+ [ ] 视频号小店
+ [ ] 接入电子面单打印
+ [x] 淘宝
+ [x] 视频号小店
+ [ ] 拼多多
+ [ ] 抖店
## 二、关键流程 ## 二、关键流程
### 2.1 关联商品SKU ### 2.1 关联商品SKU

68
docs/erp_ship_waybill.sql Normal file
View File

@ -0,0 +1,68 @@
/*
Navicat Premium Data Transfer
Source Server : localhost
Source Server Type : MySQL
Source Server Version : 80200
Source Host : localhost:3306
Source Schema : qihang-erp
Target Server Type : MySQL
Target Server Version : 80200
File Encoding : 65001
Date: 16/06/2024 18:29:52
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for erp_ship_waybill
-- ----------------------------
DROP TABLE IF EXISTS `erp_ship_waybill`;
CREATE TABLE `erp_ship_waybill` (
`id` bigint NOT NULL AUTO_INCREMENT,
`order_id` varchar(35) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '订单号',
`shop_id` bigint NOT NULL COMMENT '店铺id',
`shop_type` int NOT NULL COMMENT '店铺类型',
`waybill_code` varchar(35) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '快递单号',
`logistics_code` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '快递公司编码',
`print_data` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '打印数据',
`status` int NULL DEFAULT NULL COMMENT '状态1已取号2已打印3已发货',
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
`create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
`update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新人',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '发货电子面单记录表' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for oms_tao_waybill_account
-- ----------------------------
DROP TABLE IF EXISTS `oms_tao_waybill_account`;
CREATE TABLE `oms_tao_waybill_account` (
`id` bigint NOT NULL AUTO_INCREMENT,
`shop_id` bigint NOT NULL COMMENT '店铺id',
`seller_id` bigint NULL DEFAULT NULL COMMENT '商家ID',
`cp_code` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '物流服务商编码',
`cp_type` int NULL DEFAULT NULL COMMENT '1是直营2是加盟',
`quantity` int NULL DEFAULT NULL COMMENT '可用单数',
`allocated_quantity` int NULL DEFAULT NULL COMMENT '已用单数',
`branch_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '网点ID',
`branch_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '网点名称',
`print_quantity` int NULL DEFAULT NULL COMMENT '已经打印的面单总数',
`cancel_quantity` int NULL DEFAULT NULL COMMENT '取消的面对总数',
`waybill_address_id` bigint NULL DEFAULT NULL COMMENT 'waybill 地址记录ID(非地址库ID)',
`province` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '省名称(一级地址)',
`city` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '市名称(二级地址)',
`area` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '区名称(三级地址)',
`address_detail` varchar(55) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '详细地址',
`name` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '发货人',
`mobile` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '发货手机号',
`phone` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '发货固定电话',
`is_show` int NULL DEFAULT NULL COMMENT '是否前台显示1显示0不显示',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '淘宝电子面单账户信息表' ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;

Binary file not shown.

View File

@ -26,9 +26,9 @@
<dependency> <dependency>
<groupId>cn.qihangerp.open.tao</groupId> <groupId>cn.qihangerp.open.tao</groupId>
<artifactId>tao-api2</artifactId> <artifactId>tao-api2</artifactId>
<version>1.5.4</version> <version>1.6.16</version>
<scope>system</scope> <scope>system</scope>
<systemPath>${project.basedir}/libs/tao-api2-1.5.4.jar</systemPath> <systemPath>${project.basedir}/libs/tao-api2-1.6.16.jar</systemPath>
</dependency> </dependency>
</dependencies> </dependencies>
<!-- <dependencyManagement>--> <!-- <dependencyManagement>-->

View File

@ -0,0 +1,246 @@
package com.qihang.tao.controller;
import cn.qihangerp.open.tao.WaybillAccountApiHelper;
import cn.qihangerp.open.tao.WaybillApiHelper;
import cn.qihangerp.open.tao.common.ApiResultVo;
import cn.qihangerp.open.tao.model.WaybillBranchAccountList;
import cn.qihangerp.open.tao.model.WaybillCloudPrint;
import cn.qihangerp.open.tao.request.WaybillCloudPrintApplyNewRequest;
import cn.qihangerp.open.tao.request.WaybillCloudPrintApplyNewRequestSender;
import cn.qihangerp.open.tao.request.WaybillCloudPrintApplyNewRequestTradeOrderInfoDto;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qihang.common.common.AjaxResult;
import com.qihang.common.common.ResultVoEnum;
import com.qihang.common.enums.EnumShopType;
import com.qihang.common.enums.HttpStatus;
import com.qihang.common.mq.MqMessage;
import com.qihang.common.mq.MqType;
import com.qihang.tao.common.BaseController;
import com.qihang.tao.common.TaoRequest;
import com.qihang.tao.domain.ErpShipWaybill;
import com.qihang.tao.domain.OmsTaoOrder;
import com.qihang.tao.domain.OmsTaoWaybillAccount;
import com.qihang.tao.domain.bo.TaoOrderPushBo;
import com.qihang.tao.domain.bo.TaoWaybillGetBo;
import com.qihang.tao.openApi.ApiCommon;
import com.qihang.tao.service.ErpShipWaybillService;
import com.qihang.tao.service.OmsTaoOrderService;
import com.qihang.tao.service.OmsTaoWaybillAccountService;
import lombok.AllArgsConstructor;
import lombok.extern.java.Log;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Log
@AllArgsConstructor
@RestController
@RequestMapping("/ewaybill")
public class EwaybillController extends BaseController {
private final ApiCommon apiCommon;
private final OmsTaoWaybillAccountService waybillAccountService;
private final OmsTaoOrderService orderService;
private final ErpShipWaybillService erpShipWaybillService;
@RequestMapping(value = "/get_waybill_account_list", method = RequestMethod.POST)
public AjaxResult getWaybillAccountList(@RequestBody TaoRequest params) throws Exception {
if (params.getShopId() == null || params.getShopId() <= 0) {
return AjaxResult.error(HttpStatus.PARAMS_ERROR, "参数错误没有店铺Id");
}
List<OmsTaoWaybillAccount> list = waybillAccountService.list(new LambdaQueryWrapper<OmsTaoWaybillAccount>().eq(OmsTaoWaybillAccount::getShopId, params.getShopId()).eq(OmsTaoWaybillAccount::getIsShow, 1));
return AjaxResult.success(list);
}
/**
* 拉取电子面单账号
* @param params
* @return
* @throws Exception
*/
@RequestMapping(value = "/pull_waybill_account", method = RequestMethod.POST)
public AjaxResult pullWaybillAccount(@RequestBody TaoRequest params) throws Exception {
if (params.getShopId() == null || params.getShopId() <= 0) {
return AjaxResult.error(HttpStatus.PARAMS_ERROR, "参数错误没有店铺Id");
}
var checkResult = apiCommon.checkBefore(params.getShopId());
if (checkResult.getCode() != HttpStatus.SUCCESS) {
return AjaxResult.error(checkResult.getCode(), checkResult.getMsg(), checkResult.getData());
}
String accessToken = checkResult.getData().getAccessToken();
String appKey = checkResult.getData().getAppKey();
String appSecret = checkResult.getData().getAppSecret();
Long sellId = checkResult.getData().getSellerShopId();
ApiResultVo<WaybillBranchAccountList> apiResultVo = WaybillAccountApiHelper.pullWaybillBranchAccountList(appKey, appSecret, accessToken);
List<OmsTaoWaybillAccount> list = new ArrayList<>();
if(apiResultVo.getCode()==0){
for (var item : apiResultVo.getList()){
for(var acc:item.getBranchAccountCols().getWaybillBranchAccount()){
OmsTaoWaybillAccount vo = new OmsTaoWaybillAccount();
vo.setShopId(params.getShopId());
vo.setSellerId(sellId);
vo.setIsShow(1);
vo.setCpCode(item.getCpCode());
vo.setCpType(item.getCpType());
vo.setAllocatedQuantity(acc.getAllocatedQuantity());
vo.setBranchCode(acc.getBranchCode());
vo.setBranchName(acc.getBranchName());
vo.setCancelQuantity(acc.getCancelQuantity());
vo.setPrintQuantity(acc.getPrintQuantity());
vo.setQuantity(acc.getQuantity());
if(acc.getShippAddressCols().getWaybillAddress().size()>0) {
vo.setAddressDetail(acc.getShippAddressCols().getWaybillAddress().get(0).getAddressDetail());
vo.setArea(acc.getShippAddressCols().getWaybillAddress().get(0).getArea());
vo.setCity(acc.getShippAddressCols().getWaybillAddress().get(0).getCity());
vo.setProvince(acc.getShippAddressCols().getWaybillAddress().get(0).getProvince());
vo.setWaybillAddressId(acc.getShippAddressCols().getWaybillAddress().get(0).getWaybillAddressId().longValue());
list.add(vo);
}
waybillAccountService.save(vo);
log.info("========添加tao电子面单账户信息==========");
}
}
}
return AjaxResult.success(list);
}
@PostMapping("/get_waybill_code")
@ResponseBody
public AjaxResult getWaybillCode(@RequestBody TaoWaybillGetBo req) {
if (req.getAccountId() == null || req.getAccountId() <= 0) {
return AjaxResult.error(HttpStatus.PARAMS_ERROR, "参数错误,请选择电子面单账户");
}
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, "参数错误,没有选择订单");
}
var checkResult = apiCommon.checkBefore(req.getShopId());
if (checkResult.getCode() != HttpStatus.SUCCESS) {
return AjaxResult.error(checkResult.getCode(), checkResult.getMsg(), checkResult.getData());
}
String accessToken = checkResult.getData().getAccessToken();
String appKey = checkResult.getData().getAppKey();
String appSecret = checkResult.getData().getAppSecret();
Long sellerShopId = checkResult.getData().getSellerShopId();
// 获取电子面单账户信息(包含了发货地址信息)
OmsTaoWaybillAccount 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());
erpShipWaybillService.waybillUpdate(waybill);
log.info("====保存電子面單信息========"+result.getObjectId());
}
}else{
return AjaxResult.error(apiResultVo.getMsg());
}
return success();
}
@PostMapping("/get_print_data")
@ResponseBody
public AjaxResult getPrintData(@RequestBody TaoWaybillGetBo 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 TaoWaybillGetBo 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();
}
}

View File

@ -0,0 +1,78 @@
package com.qihang.tao.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 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;
}

View File

@ -0,0 +1,98 @@
package com.qihang.tao.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import java.io.Serializable;
/**
* 淘宝电子面单账户信息表
* @TableName oms_tao_waybill_account
*/
@Data
public class OmsTaoWaybillAccount implements Serializable {
/**
*
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
private Long shopId;
/**
* 物流服务商编码
*/
private String cpCode;
/**
* 1是直营2是加盟
*/
private Integer cpType;
/**
* 商家ID
*/
private Long sellerId;
/**
* 可用单数
*/
private Integer quantity;
/**
* 已用单数
*/
private Integer allocatedQuantity;
/**
* 网点ID
*/
private String branchCode;
private String branchName;
/**
* 已经打印的面单总数
*/
private Integer printQuantity;
/**
* 取消的面对总数
*/
private Integer cancelQuantity;
/**
* waybill 地址记录ID(非地址库ID)
*/
private Long waybillAddressId;
/**
* 省名称一级地址
*/
private String province;
/**
* 市名称二级地址
*/
private String city;
/**
* 区名称三级地址
*/
private String area;
/**
* 详细地址
*/
private String addressDetail;
private String name;
private String mobile;
private String phone;
/**
* 是否前台显示1显示0不显示
*/
private Integer isShow;
private static final long serialVersionUID = 1L;
}

View File

@ -11,4 +11,5 @@ public class TaoOrderBo implements Serializable {
private Long erpGoodsSkuId; private Long erpGoodsSkuId;
private Long shopId; private Long shopId;
private String status; private String status;
private Integer erpSendStatus;
} }

View File

@ -0,0 +1,10 @@
package com.qihang.tao.domain.bo;
import lombok.Data;
@Data
public class TaoWaybillGetBo {
private Long accountId;//电子面单账户id
private String[] ids;
private Long shopId;//店铺Id
}

View File

@ -0,0 +1,32 @@
//package com.qihang.tao.domain.vo;
//
//import com.fasterxml.jackson.annotation.JsonProperty;
//import lombok.Data;
//
//@Data
//public class WaybillBranchAccountVo {
// private String cpCode;
// private Integer cpType;
//
// private Integer allocatedQuantity;
//
// private String branchCode;
//
// private String branchName;
//
// private Integer cancelQuantity;
//
// private Integer printQuantity;
//
// private Integer quantity;
//
// private String addressDetail;
//
// private String area;
//
// private String city;
//
// private String province;
//
// private Integer waybillAddressId;
//}

View File

@ -0,0 +1,18 @@
package com.qihang.tao.mapper;
import com.qihang.tao.domain.ErpShipWaybill;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author qilip
* @description 针对表erp_ship_waybill(发货电子面单记录表)的数据库操作Mapper
* @createDate 2024-06-16 17:18:22
* @Entity com.qihang.tao.domain.ErpShipWaybill
*/
public interface ErpShipWaybillMapper extends BaseMapper<ErpShipWaybill> {
}

View File

@ -0,0 +1,18 @@
package com.qihang.tao.mapper;
import com.qihang.tao.domain.OmsTaoWaybillAccount;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author qilip
* @description 针对表oms_tao_waybill_account(淘宝电子面单账户信息表)的数据库操作Mapper
* @createDate 2024-06-16 11:56:38
* @Entity com.qihang.tao.domain.OmsTaoWaybillAccount
*/
public interface OmsTaoWaybillAccountMapper extends BaseMapper<OmsTaoWaybillAccount> {
}

View File

@ -50,9 +50,9 @@ public class ApiCommon {
// if(!StringUtils.hasText(platform.getServerUrl())) { // if(!StringUtils.hasText(platform.getServerUrl())) {
// return ResultVo.error(HttpStatus.PARAMS_ERROR, "第三方平台配置错误没有找到ApiRequestUrl"); // return ResultVo.error(HttpStatus.PARAMS_ERROR, "第三方平台配置错误没有找到ApiRequestUrl");
// } // }
// if(shop.getSellerId() == null || shop.getSellerId() <= 0) { if(shop.getSellerShopId() == null || shop.getSellerShopId() <= 0) {
// return ResultVo.error(HttpStatus.PARAMS_ERROR, "第三方平台配置错误没有找到SellerUserId"); return ResultVo.error(HttpStatus.PARAMS_ERROR, "第三方平台配置错误没有找到SellerShopId");
// } }
ShopApiParams params = new ShopApiParams(); ShopApiParams params = new ShopApiParams();
params.setAppKey(platform.getAppKey()); params.setAppKey(platform.getAppKey());
@ -60,7 +60,7 @@ public class ApiCommon {
params.setAccessToken(shop.getAccessToken()); params.setAccessToken(shop.getAccessToken());
params.setRedirectUrl(platform.getRedirectUrl()); params.setRedirectUrl(platform.getRedirectUrl());
params.setServerUrl(platform.getServerUrl()); params.setServerUrl(platform.getServerUrl());
params.setSellerShopId(shop.getSellerShopId());
if (!StringUtils.hasText(shop.getAccessToken())) { if (!StringUtils.hasText(shop.getAccessToken())) {
return ResultVo.error(HttpStatus.UNAUTHORIZED, "Token已过期请重新授权", params); return ResultVo.error(HttpStatus.UNAUTHORIZED, "Token已过期请重新授权", params);

View File

@ -0,0 +1,19 @@
package com.qihang.tao.service;
import com.qihang.common.common.ResultVo;
import com.qihang.tao.domain.ErpShipWaybill;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* @author qilip
* @description 针对表erp_ship_waybill(发货电子面单记录表)的数据库操作Service
* @createDate 2024-06-16 17:18:22
*/
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);
}

View File

@ -25,5 +25,5 @@ public interface OmsTaoOrderService extends IService<OmsTaoOrder> {
PageResult<OmsTaoOrder> queryPageList(TaoOrderBo bo, PageQuery pageQuery); PageResult<OmsTaoOrder> queryPageList(TaoOrderBo bo, PageQuery pageQuery);
OmsTaoOrder queryDetailById(Long id); OmsTaoOrder queryDetailById(Long id);
OmsTaoOrder queryDetailByTid(String tid);
} }

View File

@ -0,0 +1,13 @@
package com.qihang.tao.service;
import com.qihang.tao.domain.OmsTaoWaybillAccount;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author qilip
* @description 针对表oms_tao_waybill_account(淘宝电子面单账户信息表)的数据库操作Service
* @createDate 2024-06-16 11:56:38
*/
public interface OmsTaoWaybillAccountService extends IService<OmsTaoWaybillAccount> {
}

View File

@ -0,0 +1,123 @@
package com.qihang.tao.service.impl;
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.tao.domain.ErpShipWaybill;
import com.qihang.tao.domain.OmsTaoOrder;
import com.qihang.tao.mapper.OmsTaoOrderMapper;
import com.qihang.tao.service.ErpShipWaybillService;
import com.qihang.tao.mapper.ErpShipWaybillMapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
* @author qilip
* @description 针对表erp_ship_waybill(发货电子面单记录表)的数据库操作Service实现
* @createDate 2024-06-16 17:18:22
*/
@AllArgsConstructor
@Service
public class ErpShipWaybillServiceImpl extends ServiceImpl<ErpShipWaybillMapper, ErpShipWaybill>
implements ErpShipWaybillService{
private final ErpShipWaybillMapper mapper;
private final OmsTaoOrderMapper orderMapper;
/**
* 更新电子面单信息
* @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状态
OmsTaoOrder orderUpdate = new OmsTaoOrder();
orderUpdate.setErpSendStatus(shipWaybill.getStatus());
orderUpdate.setErpSendCode(shipWaybill.getWaybillCode());
orderUpdate.setErpSendCompany(shipWaybill.getLogisticsCode());
orderMapper.update(orderUpdate,new LambdaQueryWrapper<OmsTaoOrder>().eq(OmsTaoOrder::getTid,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){
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状态
OmsTaoOrder orderUpdate = new OmsTaoOrder();
orderUpdate.setErpSendStatus(update.getStatus());
orderMapper.update(orderUpdate,new LambdaQueryWrapper<OmsTaoOrder>().eq(OmsTaoOrder::getTid,w.getOrderId()));
//TODO: 打印成功之后 加入备货清单
}
}
return ResultVo.success();
}
}

View File

@ -165,6 +165,7 @@ public class OmsTaoOrderServiceImpl extends ServiceImpl<OmsTaoOrderMapper, OmsTa
.eq(bo.getShopId()!=null,OmsTaoOrder::getShopId,bo.getShopId()) .eq(bo.getShopId()!=null,OmsTaoOrder::getShopId,bo.getShopId())
.eq(StringUtils.hasText(bo.getTid()),OmsTaoOrder::getTid,bo.getTid()) .eq(StringUtils.hasText(bo.getTid()),OmsTaoOrder::getTid,bo.getTid())
.eq(StringUtils.hasText(bo.getStatus()),OmsTaoOrder::getStatus,bo.getStatus()) .eq(StringUtils.hasText(bo.getStatus()),OmsTaoOrder::getStatus,bo.getStatus())
.eq(bo.getErpSendStatus()!=null,OmsTaoOrder::getErpSendStatus,bo.getErpSendStatus())
; ;
Page<OmsTaoOrder> taoGoodsPage = mapper.selectPage(pageQuery.build(), queryWrapper); Page<OmsTaoOrder> taoGoodsPage = mapper.selectPage(pageQuery.build(), queryWrapper);
@ -182,6 +183,15 @@ public class OmsTaoOrderServiceImpl extends ServiceImpl<OmsTaoOrderMapper, OmsTa
omsTaoOrder.setItems(itemMapper.selectList(new LambdaQueryWrapper<OmsTaoOrderItem>().eq(OmsTaoOrderItem::getTid,omsTaoOrder.getTid()))); omsTaoOrder.setItems(itemMapper.selectList(new LambdaQueryWrapper<OmsTaoOrderItem>().eq(OmsTaoOrderItem::getTid,omsTaoOrder.getTid())));
return omsTaoOrder; return omsTaoOrder;
} }
@Override
public OmsTaoOrder queryDetailByTid(String tid) {
List<OmsTaoOrder> omsTaoOrders = mapper.selectList(new LambdaQueryWrapper<OmsTaoOrder>().eq(OmsTaoOrder::getTid, tid));
if(omsTaoOrders == null) return null;
OmsTaoOrder omsTaoOrder = omsTaoOrders.get(0);
omsTaoOrder.setItems(itemMapper.selectList(new LambdaQueryWrapper<OmsTaoOrderItem>().eq(OmsTaoOrderItem::getTid,omsTaoOrder.getTid())));
return omsTaoOrder;
}
} }

View File

@ -0,0 +1,22 @@
package com.qihang.tao.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qihang.tao.domain.OmsTaoWaybillAccount;
import com.qihang.tao.service.OmsTaoWaybillAccountService;
import com.qihang.tao.mapper.OmsTaoWaybillAccountMapper;
import org.springframework.stereotype.Service;
/**
* @author qilip
* @description 针对表oms_tao_waybill_account(淘宝电子面单账户信息表)的数据库操作Service实现
* @createDate 2024-06-16 11:56:38
*/
@Service
public class OmsTaoWaybillAccountServiceImpl extends ServiceImpl<OmsTaoWaybillAccountMapper, OmsTaoWaybillAccount>
implements OmsTaoWaybillAccountService{
}

View File

@ -0,0 +1,28 @@
<?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.tao.mapper.ErpShipWaybillMapper">
<resultMap id="BaseResultMap" type="com.qihang.tao.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="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,logistics_code,
print_data,status,create_time,
create_by,update_time,update_by
</sql>
</mapper>

View File

@ -0,0 +1,37 @@
<?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.tao.mapper.OmsTaoWaybillAccountMapper">
<resultMap id="BaseResultMap" type="com.qihang.tao.domain.OmsTaoWaybillAccount">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="cpCode" column="cp_code" jdbcType="VARCHAR"/>
<result property="cpType" column="cp_type" jdbcType="INTEGER"/>
<result property="shopId" column="shop_id" jdbcType="BIGINT"/>
<result property="sellerId" column="seller_id" jdbcType="BIGINT"/>
<result property="quantity" column="quantity" jdbcType="INTEGER"/>
<result property="allocatedQuantity" column="allocated_quantity" jdbcType="INTEGER"/>
<result property="branchCode" column="branch_code" jdbcType="VARCHAR"/>
<result property="branchName" column="branch_name" jdbcType="VARCHAR"/>
<result property="printQuantity" column="print_quantity" jdbcType="INTEGER"/>
<result property="cancelQuantity" column="cancel_quantity" jdbcType="INTEGER"/>
<result property="waybillAddressId" column="waybill_address_id" jdbcType="BIGINT"/>
<result property="province" column="province" jdbcType="VARCHAR"/>
<result property="city" column="city" jdbcType="VARCHAR"/>
<result property="area" column="area" jdbcType="VARCHAR"/>
<result property="addressDetail" column="address_detail" jdbcType="VARCHAR"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="mobile" column="mobile" jdbcType="VARCHAR"/>
<result property="phone" column="phone" jdbcType="VARCHAR"/>
<result property="isShow" column="is_show" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
id,cp_code,cp_type,shop_id,branch_name,
seller_id,quantity,allocated_quantity,
branch_code,print_quantity,cancel_quantity,
waybill_address_id,province,city,`name`,mobile,phone
area,address_detail,is_show
</sql>
</mapper>

View File

@ -24,58 +24,11 @@
</properties> </properties>
<dependencies> <dependencies>
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter</artifactId>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-web</artifactId>-->
<!-- <exclusions>-->
<!-- <exclusion>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-tomcat</artifactId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-undertow</artifactId>-->
<!-- </dependency>-->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId> <artifactId>spring-boot-starter-webflux</artifactId>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>com.alibaba.cloud</groupId>-->
<!-- <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>-->
<!-- </dependency>-->
<!-- &lt;!&ndash;SpringCloud Alibaba nacos 服务发现依赖&ndash;&gt;-->
<!-- <dependency>-->
<!-- <groupId>com.alibaba.cloud</groupId>-->
<!-- <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.qihang</groupId>-->
<!-- <artifactId>security</artifactId>-->
<!-- <version>1.0-SNAPSHOT</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>mysql</groupId>-->
<!-- <artifactId>mysql-connector-java</artifactId>-->
<!-- <version>8.0.33</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.baomidou</groupId>-->
<!-- <artifactId>mybatis-plus-spring-boot3-starter</artifactId>-->
<!-- <version>3.5.5</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.projectlombok</groupId>-->
<!-- <artifactId>lombok</artifactId>-->
<!-- <version>1.18.30</version>-->
<!-- <scope>provided</scope>-->
<!-- </dependency>-->
<dependency> <dependency>
<groupId>wei-api</groupId> <groupId>wei-api</groupId>
<artifactId>wei-api</artifactId> <artifactId>wei-api</artifactId>
@ -84,22 +37,4 @@
<systemPath>${project.basedir}/libs/wei-api-1.6.3.jar</systemPath> <systemPath>${project.basedir}/libs/wei-api-1.6.3.jar</systemPath>
</dependency> </dependency>
</dependencies> </dependencies>
<!-- <dependencyManagement>-->
<!-- <dependencies>-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-dependencies</artifactId>-->
<!-- <version>${spring-boot.version}</version>-->
<!-- <type>pom</type>-->
<!-- <scope>import</scope>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.alibaba.cloud</groupId>-->
<!-- <artifactId>spring-cloud-alibaba-dependencies</artifactId>-->
<!-- <version>${spring-cloud-alibaba.version}</version>-->
<!-- <type>pom</type>-->
<!-- <scope>import</scope>-->
<!-- </dependency>-->
<!-- </dependencies>-->
<!-- </dependencyManagement>-->
</project> </project>

View File

@ -0,0 +1,46 @@
import request from '@/utils/request'
// 获取电子面单账户list
export function getWaybillAccountList(data) {
return request({
url: '/api/tao-api/ewaybill/get_waybill_account_list',
method: 'post',
data: data
})
}
// 更新电子面单账户
export function pullWaybillAccount(data) {
return request({
url: '/api/tao-api/ewaybill/pull_waybill_account',
method: 'post',
data: data
})
}
// 取号
export function getWaybillCode(data) {
return request({
url: '/api/tao-api/ewaybill/get_waybill_code',
method: 'post',
data: data
})
}
// 获取打印的数据
export function getWaybillPrintData(data) {
return request({
url: '/api/tao-api/ewaybill/get_print_data',
method: 'post',
data: data
})
}
// 打印成功
export function pushWaybillPrintSuccess(data) {
return request({
url: '/api/tao-api/ewaybill/push_print_success',
method: 'post',
data: data
})
}

View File

@ -1,28 +1,38 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-tabs v-model="activeName" @tab-click="handleClick"> <el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane label="视频号小店" name="ewaybillWei"> <el-tab-pane label="淘宝天猫" name="printTao" >
<ewaybill-wei></ewaybill-wei> <print-tao></print-tao>
</el-tab-pane> </el-tab-pane>
<!-- <el-tab-pane label="供应商代发货" name="supplierShip" lazy>--> <el-tab-pane label="京东POP" name="printJd" lazy>
<!-- <supplier-ship></supplier-ship>--> <el-col style="color:red">京东POP电子面单打印暂不提供</el-col>
<!-- </el-tab-pane>--> </el-tab-pane>
<el-tab-pane label="拼多多" name="printPdd" lazy>
<el-col style="color:red">拼多多电子面单打印正在开发中</el-col>
</el-tab-pane>
<el-tab-pane label="抖店" name="printDou" lazy>
<el-col style="color:red">抖店电子面单打印后续开放</el-col>
</el-tab-pane>
<el-tab-pane label="视频号小店" name="printWei" lazy>
<print-wei></print-wei>
</el-tab-pane>
</el-tabs> </el-tabs>
</div> </div>
</template> </template>
<script> <script>
import ewaybillWei from "@/views/shop/wei/ewaybill/index.vue"; import printWei from "@/views/shop/wei/ewaybill/index.vue";
import printTao from "@/views/shop/tao/ewaybill/index.vue";
export default { export default {
name: "ewaybillPrint", name: "print",
components:{ewaybillWei}, components:{printWei,printTao},
data() { data() {
return { return {
activeName: 'ewaybillWei' activeName: 'printTao'
}; };
}, },
created() { created() {

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-tabs v-model="activeName" @tab-click="handleClick"> <el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane label="天猫" name="taoOrder"> <el-tab-pane label="淘宝天猫" name="taoOrder">
<order-tao></order-tao> <order-tao></order-tao>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="京东POP" name="jdOrder" lazy> <el-tab-pane label="京东POP" name="jdOrder" lazy>

View File

@ -0,0 +1,468 @@
<template>
<div class="app-container">
<el-row>
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="订单号" prop="tid">
<el-input
v-model="queryParams.tid"
placeholder="请输入订单号"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="店铺" prop="shopId">
<el-select v-model="queryParams.shopId" placeholder="请选择店铺" clearable @change="handleQuery">
<el-option
v-for="item in shopList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
<el-form-item>
<el-select v-model="printParams.printer" placeholder="请选择打印机" clearable>
<el-option
v-for="item in printerList"
:key="item.name"
:label="item.name"
:value="item.name">
</el-option>
</el-select>
</el-form-item>
</el-form>
</el-row>
<el-row :gutter="10" class="mb8">
<!-- <el-form :model="printParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="108px">-->
<!-- <el-form-item label="快递公司" prop="deliver">-->
<!-- <el-select v-model="printParams.deliver" placeholder="请选择快递公司" clearable>-->
<!-- <el-option-->
<!-- v-for="item in deliverList"-->
<!-- :key="item.delivery_id"-->
<!-- :label="item.delivery_name"-->
<!-- :value="item.delivery_id">-->
<!-- </el-option>-->
<!-- </el-select>-->
<!-- <el-button @click="getDeliverList"> 获取 </el-button>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="打印机" prop="printer">-->
<!-- <el-select v-model="printParams.printer" placeholder="请选择打印机" clearable>-->
<!-- <el-option-->
<!-- v-for="item in printerList"-->
<!-- :key="item.name"-->
<!-- :label="item.name"-->
<!-- :value="item.name">-->
<!-- </el-option>-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<!-- <el-form-item>-->
<!-- &lt;!&ndash; <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>&ndash;&gt;-->
<!-- </el-form-item>-->
<!-- </el-form>-->
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-time"
size="mini"
:disabled="multiple"
@click="handleGetEwaybillCode"
>取号</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
:disabled="multiple"
icon="el-icon-printer"
size="mini"
@click="handlePrintEwaybill"
>打印电子面单</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-d-arrow-right"
size="mini"
:disabled="multiple"
@click="handleShipSend"
>发货</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="orderList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<!-- <el-table-column label="ID" align="center" prop="id" />-->
<el-table-column label="订单号" align="center" prop="tid" >
<template slot-scope="scope">
<p>{{scope.row.tid}}</p>
<el-tag effect="plain">{{shopList.find(x=>x.id === scope.row.shopId).name}}</el-tag>
</template>
</el-table-column>
<el-table-column label="商品" width="550">
<template slot-scope="scope">
<el-table :data="scope.row.items" :show-header="false">
<el-table-column label="商品" align="center" prop="title" />
<el-table-column label="规格" align="center" prop="skuPropertiesName" />
<el-table-column label="数量" align="center" prop="num" width="60">
<template slot-scope="scope">
<el-tag size="small">x {{scope.row.num}}</el-tag>
</template>
</el-table-column>
</el-table>
<!-- <el-row v-for="item in scope.row.items" :key="item.id" :gutter="20">-->
<!-- <div style="float: left;display: flex;align-items: center;" >-->
<!-- <div style="margin-left:10px">-->
<!-- <p>{{item.title}}</p>-->
<!-- <p>{{item.skuPropertiesName}}&nbsp;-->
<!-- <el-tag size="small">x {{item.num}}</el-tag>-->
<!-- </p>-->
<!-- </div>-->
<!-- </div>-->
<!-- </el-row>-->
</template>
</el-table-column>
<el-table-column label="下单时间" align="center" prop="orderCreateTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.created) }}</span>
</template>
</el-table-column>
<el-table-column label="买家留言" align="center" prop="buyerMessage" />
<el-table-column label="卖家备注" align="center" prop="sellerMemo" />
<!-- <el-table-column label="店铺" align="center" prop="categoryId" >-->
<!-- <template slot-scope="scope">-->
<!-- <el-tag size="small">{{categoryList.find(x=>x.id === scope.row.categoryId).name}}</el-tag>-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column label="收件信息" align="left" prop="receiverState" >
<template slot-scope="scope">
<p>
{{scope.row.receiverName}}&nbsp;{{scope.row.receiverMobile}}
</p>
<p>
{{scope.row.receiverState}} &nbsp;{{scope.row.receiverCity}}&nbsp;{{scope.row.receiverDistrict}}&nbsp;{{scope.row.receiverTown}}
</p>
<p>
{{scope.row.receiverAddress}}
</p>
</template>
</el-table-column>
<el-table-column label="面单号" align="center" prop="erpSendCode" />
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 取号 -->
<el-dialog title="取号" :visible.sync="getCodeOpen" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-form-item label="电子面单账户" prop="accountId">
<el-select v-model="form.accountId" placeholder="请选择电子面单账户" clearable>
<el-option
v-for="item in deliverList"
:key="item.id"
:label="item.cpCode"
:value="item.id">
<span style="float: left">{{ item.cpCode }}</span>
<span style="float: right; color: #8492a6; font-size: 13px" >{{item.branchName}}:{{item.quantity}}</span>
</el-option>
</el-select>
<el-button type="success" plain @click="updateWaybillAccount" >更新电子面单账户信息</el-button>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="getCodeOpenForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import {listShop} from "@/api/shop/shop";
import {listOrder} from "@/api/tao/order";
import {
getWaybillAccountList,
pullWaybillAccount,
getWaybillCode,
getWaybillPrintData,
pushWaybillPrintSuccess
} from "@/api/tao/ewaybill";
export default {
name: "printTao",
data() {
return {
//
loading: true,
//
ids: [],
shopList: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
title: "",
//
getCodeOpen: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
status: 'WAIT_SELLER_SEND_GOODS',
erpSendStatus:0,
shopId: null
},
//
printParams: {
deliver: null,
printer: null
},
//
form: {},
orderList: [],
printerList: [],
deliverList: [],
//
rules: {
accountId: [{ required: true, message: '请选择电子面单账户' }],
}
};
},
created() {
this.openWs()
listShop({platform: 4}).then(response => {
this.shopList = response.rows;
if (this.shopList && this.shopList.length > 0) {
this.queryParams.shopId = this.shopList[0].id
}
this.getList();
});
},
methods: {
/** 查询商品管理列表 */
getList() {
this.loading = true;
listOrder(this.queryParams).then(response => {
this.orderList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.getCodeOpen = false;
this.reset();
},
//
reset() {
this.form = {
id: null,
erpSkuId: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.tid)
this.single = selection.length !== 1
this.multiple = !selection.length
},
openWs() {
const ws = new WebSocket('ws://127.0.0.1:13528');
ws.onopen = () => {
console.log('与打印组件建立连接成功: ');
//
ws.send(JSON.stringify({
requestID: '12345',
cmd: 'getPrinters',
"version": "1.0"
}))
};
let obj = this.$modal;
ws.onmessage = (e) => {
const resp = JSON.parse(e.data || '{}')
if (resp.cmd === 'getPrinters') {
this.printerList = resp.printers
obj.msgSuccess("打印组件连接成功!");
console.log('打印机列表: ', resp.printers);
}
};
//
ws.onerror = function (error) {
obj.msgError("打印组件连接失败!请安装并启动菜鸟云打印打印组件!");
console.error('WebSocket error:', error);
// alert('WebSocket error occurred. Check the console for more details.');
};
},
//
handleGetEwaybillCode() {
const ids = this.ids;
if (ids) {
getWaybillAccountList({shopId: this.queryParams.shopId}).then(response => {
this.deliverList = response.data;
this.getCodeOpen = true
});
} else {
this.$modal.msgError("请选择订单")
}
},
//
updateWaybillAccount() {
pullWaybillAccount({shopId: this.queryParams.shopId}).then(response => {
this.deliverList = response.data;
});
},
/** 取号提交按钮 */
getCodeOpenForm() {
this.$refs["form"].validate(valid => {
if (valid) {
const ids = this.ids;
console.log('=========3333========', ids)
if (ids) {
console.log('===请求参数=====', {shopId: this.queryParams.shopId, ids: ids, accountId: this.form.accountId})
getWaybillCode({
shopId: this.queryParams.shopId,
ids: ids,
accountId: this.form.accountId
}).then(response => {
this.$modal.msgSuccess("取号成功")
this.getList()
this.getCodeOpen = false
});
} else {
this.$modal.msgError("请选择订单")
}
}
});
},
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
}
const ids = this.ids;
getWaybillPrintData({shopId: this.queryParams.shopId, ids: ids}).then(response => {
console.log("======打印======", response.data)
if (response.data) {
const ws = new WebSocket('ws://127.0.0.1:13528');
ws.onopen = () => {
let printData = []
response.data.forEach(x => printData.push(JSON.parse(x.printData)))
console.log('开始打印: 组合打印数据:', printData);
//
ws.send(JSON.stringify({
"cmd": "print",
"requestID": this.getUUID(8, 16),
"version": "1.0",
"task": {
"taskID": this.getUUID(8,10),
"preview": false,
"printer": this.printParams.printer,
"previewType": "pdf",
"firstDocumentNumber": 10,
"totalDocumentCount": 100,
"documents": [{
"documentID": this.getUUID(8,10),
"contents": printData
}]
}
}))
};
let obj = this.$modal;
ws.onmessage = (e) => {
const resp = JSON.parse(e.data || '{}')
if (resp.cmd === 'print') {
console.log('打印结果: ', resp);
obj.msgSuccess("打印成功!" + JSON.stringify(resp));
//
return pushWaybillPrintSuccess({shopId: this.queryParams.shopId, ids: ids})
}
};
//
ws.onerror = function (error) {
obj.msgError("打印失败!");
console.error('WebSocket error:', error);
// alert('WebSocket error occurred. Check the console for more details.');
};
}
});
},
handleShipSend(){
this.$modal.msgError("开源版本未实现平台发货!请自行对接发货");
},
getUUID(len, radix) {
var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
var uuid = [], i;
radix = radix || chars.length;
if (len) {
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
} else {
var r;
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
uuid[14] = '4';
for (i = 0; i < 36; i++) {
if (!uuid[i]) {
r = 0 | Math.random() * 16;
uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
}
}
}
return uuid.join('');
}
}
};
</script>

View File

@ -107,9 +107,9 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="总金额" align="center" prop="payment" :formatter="amountFormatter" /> <el-table-column label="总金额" align="center" prop="payment" :formatter="amountFormatter" />
<el-table-column label="订单创建时间" align="center" prop="orderCreateTime" width="180"> <el-table-column label="下单时间" align="center" prop="orderCreateTime" width="180">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ parseTime(scope.row.created, '{y}-{m}-{d} {h}:{m}:{s}') }}</span> <span>{{ parseTime(scope.row.created) }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="买家留言" align="center" prop="buyerMessage" /> <el-table-column label="买家留言" align="center" prop="buyerMessage" />

View File

@ -113,7 +113,7 @@ import {listShop} from "@/api/shop/shop";
import {getDeliverList} from "@/api/wei/ewaybill"; import {getDeliverList} from "@/api/wei/ewaybill";
export default { export default {
name: "ewaybillWei", name: "printWei",
data() { data() {
return { return {
// //
@ -241,7 +241,7 @@ export default {
}; };
// //
ws.onerror = function(error) { ws.onerror = function(error) {
obj.msgError("打印组件连接失败!请安装并启动微信视频号小打印组件!"); obj.msgError("打印组件连接失败!请安装并启动微信视频号小打印组件!");
console.error('WebSocket error:', error); console.error('WebSocket error:', error);
// alert('WebSocket error occurred. Check the console for more details.'); // alert('WebSocket error occurred. Check the console for more details.');
}; };