添加pdd电子面单打印

This commit is contained in:
老齐 2024-06-17 10:57:48 +08:00
parent 53a900dae6
commit 88d59cb5e1
21 changed files with 1197 additions and 110 deletions

View File

@ -1,68 +0,0 @@
/*
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;

View File

@ -11,7 +11,7 @@
Target Server Version : 80032 Target Server Version : 80032
File Encoding : 65001 File Encoding : 65001
Date: 15/06/2024 10:14:13 Date: 17/06/2024 10:57:02
*/ */
SET NAMES utf8mb4; SET NAMES utf8mb4;
@ -383,7 +383,7 @@ CREATE TABLE `erp_sale_order` (
PRIMARY KEY (`id`) USING BTREE, PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `order_sn_index`(`order_num`) USING BTREE, UNIQUE INDEX `order_sn_index`(`order_num`) USING BTREE,
INDEX `shopid_index`(`shop_id`) USING BTREE INDEX `shopid_index`(`shop_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1801197273742716930 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '订单表' ROW_FORMAT = Dynamic; ) ENGINE = InnoDB AUTO_INCREMENT = 1801809140794216449 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '订单表' ROW_FORMAT = Dynamic;
-- ---------------------------- -- ----------------------------
-- Table structure for erp_sale_order_item -- Table structure for erp_sale_order_item
@ -425,7 +425,7 @@ CREATE TABLE `erp_sale_order_item` (
PRIMARY KEY (`id`) USING BTREE, PRIMARY KEY (`id`) USING BTREE,
INDEX `goodId_index`(`goods_id`) USING BTREE, INDEX `goodId_index`(`goods_id`) USING BTREE,
INDEX `order_id`(`order_id`) USING BTREE INDEX `order_id`(`order_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1801197275089088515 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '订单明细表' ROW_FORMAT = Dynamic; ) ENGINE = InnoDB AUTO_INCREMENT = 1801809144007053315 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '订单明细表' ROW_FORMAT = Dynamic;
-- ---------------------------- -- ----------------------------
-- Table structure for erp_ship_logistics -- Table structure for erp_ship_logistics
@ -545,6 +545,26 @@ CREATE TABLE `erp_ship_order_fee` (
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1786238985318604802 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '订单发货物流费用' ROW_FORMAT = Dynamic; ) ENGINE = InnoDB AUTO_INCREMENT = 1786238985318604802 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '订单发货物流费用' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for erp_ship_waybill
-- ----------------------------
DROP TABLE IF EXISTS `erp_ship_waybill`;
CREATE TABLE `erp_ship_waybill` (
`id` bigint(0) NOT NULL AUTO_INCREMENT,
`order_id` varchar(35) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '订单号',
`shop_id` bigint(0) NOT NULL COMMENT '店铺id',
`shop_type` int(0) 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 DEFAULT NULL COMMENT '快递公司编码',
`print_data` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '打印数据',
`status` int(0) DEFAULT NULL COMMENT '状态1已取号2已打印3已发货',
`create_time` datetime(0) DEFAULT NULL COMMENT '创建时间',
`create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
`update_time` datetime(0) DEFAULT NULL COMMENT '更新时间',
`update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '更新人',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '发货电子面单记录表' ROW_FORMAT = Dynamic;
-- ---------------------------- -- ----------------------------
-- Table structure for oms_dou_goods -- Table structure for oms_dou_goods
-- ---------------------------- -- ----------------------------
@ -1146,6 +1166,9 @@ CREATE TABLE `oms_pdd_order` (
`audit_time` datetime(0) DEFAULT NULL COMMENT '发货时间(仓库真实发货时间)', `audit_time` datetime(0) DEFAULT NULL COMMENT '发货时间(仓库真实发货时间)',
`create_time` datetime(0) DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '系统创建时间', `create_time` datetime(0) DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '系统创建时间',
`update_time` datetime(0) DEFAULT NULL COMMENT '系统更新时间', `update_time` datetime(0) DEFAULT NULL COMMENT '系统更新时间',
`erp_send_company` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL COMMENT 'erp发货快递公司',
`erp_send_code` varchar(30) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL COMMENT 'erp发货快递单号',
`erp_send_status` int(0) DEFAULT 0 COMMENT 'erp发货状态',
PRIMARY KEY (`id`) USING BTREE, PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `order_sn_index`(`order_sn`) USING BTREE, UNIQUE INDEX `order_sn_index`(`order_sn`) USING BTREE,
INDEX `shopid_index`(`shop_id`) USING BTREE INDEX `shopid_index`(`shop_id`) USING BTREE
@ -1221,6 +1244,34 @@ CREATE TABLE `oms_pdd_refund` (
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '拼多多订单退款表' ROW_FORMAT = Dynamic; ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '拼多多订单退款表' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for oms_pdd_waybill_account
-- ----------------------------
DROP TABLE IF EXISTS `oms_pdd_waybill_account`;
CREATE TABLE `oms_pdd_waybill_account` (
`id` bigint(0) NOT NULL AUTO_INCREMENT,
`shop_id` bigint(0) NOT NULL COMMENT '店铺id',
`seller_id` bigint(0) DEFAULT NULL COMMENT '商家ID',
`cp_code` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '物流服务商编码',
`cp_type` int(0) DEFAULT NULL COMMENT '1是直营2是加盟',
`quantity` int(0) DEFAULT NULL COMMENT '可用单数',
`allocated_quantity` int(0) DEFAULT NULL COMMENT '已用单数',
`branch_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '网点ID',
`branch_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '网点名称',
`print_quantity` int(0) DEFAULT NULL COMMENT '已经打印的面单总数',
`cancel_quantity` int(0) DEFAULT NULL COMMENT '取消的面对总数',
`waybill_address_id` bigint(0) DEFAULT NULL COMMENT 'waybill 地址记录ID(非地址库ID)',
`province` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '省名称(一级地址)',
`city` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '市名称(二级地址)',
`area` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '区名称(三级地址)',
`address_detail` varchar(55) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '详细地址',
`name` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '发货人',
`mobile` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '发货手机号',
`phone` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '发货固定电话',
`is_show` int(0) DEFAULT NULL COMMENT '是否前台显示1显示0不显示',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '拼多多电子面单账户信息表' ROW_FORMAT = Dynamic;
-- ---------------------------- -- ----------------------------
-- Table structure for oms_tao_goods -- Table structure for oms_tao_goods
-- ---------------------------- -- ----------------------------
@ -1424,7 +1475,7 @@ CREATE TABLE `oms_tao_order_item` (
`refund_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '最近退款ID', `refund_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '最近退款ID',
`remark` varchar(500) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, `remark` varchar(500) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1801155298620596227 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '淘宝订单明细表' ROW_FORMAT = Dynamic; ) ENGINE = InnoDB AUTO_INCREMENT = 1801155298620596226 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '淘宝订单明细表' ROW_FORMAT = Dynamic;
-- ---------------------------- -- ----------------------------
-- Table structure for oms_tao_order_promotion -- Table structure for oms_tao_order_promotion
@ -1497,6 +1548,34 @@ CREATE TABLE `oms_tao_refund` (
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1800733684028329986 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '淘宝退款表' ROW_FORMAT = Dynamic; ) ENGINE = InnoDB AUTO_INCREMENT = 1800733684028329986 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(0) NOT NULL AUTO_INCREMENT,
`shop_id` bigint(0) NOT NULL COMMENT '店铺id',
`seller_id` bigint(0) DEFAULT NULL COMMENT '商家ID',
`cp_code` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '物流服务商编码',
`cp_type` int(0) DEFAULT NULL COMMENT '1是直营2是加盟',
`quantity` int(0) DEFAULT NULL COMMENT '可用单数',
`allocated_quantity` int(0) DEFAULT NULL COMMENT '已用单数',
`branch_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '网点ID',
`branch_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '网点名称',
`print_quantity` int(0) DEFAULT NULL COMMENT '已经打印的面单总数',
`cancel_quantity` int(0) DEFAULT NULL COMMENT '取消的面对总数',
`waybill_address_id` bigint(0) DEFAULT NULL COMMENT 'waybill 地址记录ID(非地址库ID)',
`province` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '省名称(一级地址)',
`city` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '市名称(二级地址)',
`area` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '区名称(三级地址)',
`address_detail` varchar(55) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '详细地址',
`name` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '发货人',
`mobile` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '发货手机号',
`phone` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '发货固定电话',
`is_show` int(0) DEFAULT NULL COMMENT '是否前台显示1显示0不显示',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '淘宝电子面单账户信息表' ROW_FORMAT = Dynamic;
-- ---------------------------- -- ----------------------------
-- Table structure for oms_wei_goods -- Table structure for oms_wei_goods
-- ---------------------------- -- ----------------------------
@ -2294,7 +2373,7 @@ CREATE TABLE `sys_logininfor` (
PRIMARY KEY (`info_id`) USING BTREE, PRIMARY KEY (`info_id`) USING BTREE,
INDEX `idx_sys_logininfor_s`(`status`) USING BTREE, INDEX `idx_sys_logininfor_s`(`status`) USING BTREE,
INDEX `idx_sys_logininfor_lt`(`login_time`) USING BTREE INDEX `idx_sys_logininfor_lt`(`login_time`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 302 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统访问记录' ROW_FORMAT = Dynamic; ) ENGINE = InnoDB AUTO_INCREMENT = 304 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统访问记录' ROW_FORMAT = Dynamic;
-- ---------------------------- -- ----------------------------
-- Table structure for sys_menu -- Table structure for sys_menu

View File

@ -0,0 +1,233 @@
package com.qihang.pdd.controller;
import cn.qihangerp.open.pdd.WaybillAccountApiHelper;
import cn.qihangerp.open.pdd.common.ApiResultVo;
import cn.qihangerp.open.pdd.model.WaybillAccount;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qihang.common.common.AjaxResult;
import com.qihang.common.enums.HttpStatus;
import com.qihang.pdd.domain.OmsPddWaybillAccount;
import com.qihang.pdd.openapi.ApiCommon;
import com.qihang.pdd.openapi.PullRequest;
import com.qihang.pdd.service.ErpShipWaybillService;
import com.qihang.pdd.service.OmsPddWaybillAccountService;
import com.qihang.security.common.BaseController;
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.List;
@Log
@AllArgsConstructor
@RestController
@RequestMapping("/ewaybill")
public class EwaybillController extends BaseController {
private final ApiCommon apiCommon;
private final OmsPddWaybillAccountService waybillAccountService;
// private final OmsTaoOrderService orderService;
private final ErpShipWaybillService erpShipWaybillService;
@GetMapping(value = "/get_waybill_account_list")
public AjaxResult getWaybillAccountList(@RequestParam Long shopId) throws Exception {
// if (params.getShopId() == null || params.getShopId() <= 0) {
// return AjaxResult.error(HttpStatus.PARAMS_ERROR, "参数错误没有店铺Id");
// }
List<OmsPddWaybillAccount> list = waybillAccountService.list(
new LambdaQueryWrapper<OmsPddWaybillAccount>().eq(OmsPddWaybillAccount::getShopId, shopId)
.eq(OmsPddWaybillAccount::getIsShow, 1));
return AjaxResult.success(list);
}
/**
* 拉取电子面单账号
* @param params
* @return
* @throws Exception
*/
@RequestMapping(value = "/pull_waybill_account", method = RequestMethod.POST)
public AjaxResult pullWaybillAccount(@RequestBody PullRequest 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<WaybillAccount> apiResultVo = WaybillAccountApiHelper.pullWaybillBranchAccountList(appKey, appSecret, accessToken);
List<OmsPddWaybillAccount> list = new ArrayList<>();
if(apiResultVo.getCode()==0){
for (var item : apiResultVo.getList()){
for(var acc:item.getBranchAccountCols()){
OmsPddWaybillAccount vo = new OmsPddWaybillAccount();
vo.setShopId(params.getShopId());
vo.setSellerId(sellId);
vo.setIsShow(1);
vo.setCpCode(item.getWpCode());
vo.setCpType(item.getWpType());
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().size()>0) {
vo.setAddressDetail(acc.getShippAddressCols().get(0).getDetail());
vo.setArea(acc.getShippAddressCols().get(0).getDistrict());
vo.setCity(acc.getShippAddressCols().get(0).getCity());
vo.setProvince(acc.getShippAddressCols().get(0).getProvince());
// vo.setWaybillAddressId(acc.getShippAddressCols().get(0).getWaybillAddressId().longValue());
list.add(vo);
}
waybillAccountService.save(vo);
log.info("========添加pdd电子面单账户信息==========");
}
}
}
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,74 @@
package com.qihang.pdd.domain;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 发货电子面单记录表
* @TableName erp_ship_waybill
*/
@Data
public class ErpShipWaybill implements Serializable {
/**
*
*/
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

@ -353,6 +353,21 @@ public class OmsPddOrder implements Serializable {
*/ */
private Date updateTime; private Date updateTime;
/**
* erp发货快递公司
*/
private String erpSendCompany;
/**
* erp发货快递单号
*/
private String erpSendCode;
/**
* erp发货状态
*/
private Integer erpSendStatus;
@TableField(exist = false) @TableField(exist = false)
private List<OmsPddOrderItem> itemList; private List<OmsPddOrderItem> itemList;

View File

@ -0,0 +1,113 @@
package com.qihang.pdd.domain;
import java.io.Serializable;
import lombok.Data;
/**
* 拼多多电子面单账户信息表
* @TableName oms_pdd_waybill_account
*/
@Data
public class OmsPddWaybillAccount implements Serializable {
/**
*
*/
private Long id;
/**
* 店铺id
*/
private Long shopId;
/**
* 商家ID
*/
private Long sellerId;
/**
* 物流服务商编码
*/
private String cpCode;
/**
* 1是直营2是加盟
*/
private Integer cpType;
/**
* 可用单数
*/
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

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

View File

@ -0,0 +1,18 @@
package com.qihang.pdd.mapper;
import com.qihang.pdd.domain.OmsPddWaybillAccount;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author TW
* @description 针对表oms_pdd_waybill_account(拼多多电子面单账户信息表)的数据库操作Mapper
* @createDate 2024-06-17 10:09:25
* @Entity com.qihang.pdd.domain.OmsPddWaybillAccount
*/
public interface OmsPddWaybillAccountMapper extends BaseMapper<OmsPddWaybillAccount> {
}

View File

@ -0,0 +1,13 @@
package com.qihang.pdd.service;
import com.qihang.pdd.domain.ErpShipWaybill;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author TW
* @description 针对表erp_ship_waybill(发货电子面单记录表)的数据库操作Service
* @createDate 2024-06-17 10:16:47
*/
public interface ErpShipWaybillService extends IService<ErpShipWaybill> {
}

View File

@ -0,0 +1,13 @@
package com.qihang.pdd.service;
import com.qihang.pdd.domain.OmsPddWaybillAccount;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author TW
* @description 针对表oms_pdd_waybill_account(拼多多电子面单账户信息表)的数据库操作Service
* @createDate 2024-06-17 10:09:25
*/
public interface OmsPddWaybillAccountService extends IService<OmsPddWaybillAccount> {
}

View File

@ -0,0 +1,22 @@
package com.qihang.pdd.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qihang.pdd.domain.ErpShipWaybill;
import com.qihang.pdd.service.ErpShipWaybillService;
import com.qihang.pdd.mapper.ErpShipWaybillMapper;
import org.springframework.stereotype.Service;
/**
* @author TW
* @description 针对表erp_ship_waybill(发货电子面单记录表)的数据库操作Service实现
* @createDate 2024-06-17 10:16:47
*/
@Service
public class ErpShipWaybillServiceImpl extends ServiceImpl<ErpShipWaybillMapper, ErpShipWaybill>
implements ErpShipWaybillService{
}

View File

@ -36,12 +36,16 @@ public class OmsPddOrderServiceImpl extends ServiceImpl<OmsPddOrderMapper, OmsPd
@Override @Override
public PageResult<OmsPddOrder> queryPageList(OmsPddOrder bo, PageQuery pageQuery) { public PageResult<OmsPddOrder> queryPageList(OmsPddOrder bo, PageQuery pageQuery) {
LambdaQueryWrapper<OmsPddOrder> queryWrapper = new LambdaQueryWrapper<OmsPddOrder>() LambdaQueryWrapper<OmsPddOrder> queryWrapper = new LambdaQueryWrapper<OmsPddOrder>()
.eq(bo.getShopId()!=null,OmsPddOrder::getShopId,bo.getShopId()); .eq(bo.getShopId() != null, OmsPddOrder::getShopId, bo.getShopId())
.eq(StringUtils.hasText(bo.getOrderSn()), OmsPddOrder::getOrderSn, bo.getOrderSn())
.eq(bo.getOrderStatus() != null, OmsPddOrder::getOrderStatus, bo.getOrderStatus())
.eq(bo.getRefundStatus() != null, OmsPddOrder::getRefundStatus, bo.getRefundStatus())
.eq(bo.getErpSendStatus() != null, OmsPddOrder::getErpSendStatus, bo.getErpSendStatus());
Page<OmsPddOrder> goodsPage = orderMapper.selectPage(pageQuery.build(), queryWrapper); Page<OmsPddOrder> goodsPage = orderMapper.selectPage(pageQuery.build(), queryWrapper);
if(goodsPage.getRecords()!=null){ if (goodsPage.getRecords() != null) {
for (var o: goodsPage.getRecords()) { for (var o : goodsPage.getRecords()) {
o.setItemList(orderItemMapper.selectList(new LambdaQueryWrapper<OmsPddOrderItem>().eq(OmsPddOrderItem::getOrderSn,o.getOrderSn()))); o.setItemList(orderItemMapper.selectList(new LambdaQueryWrapper<OmsPddOrderItem>().eq(OmsPddOrderItem::getOrderSn, o.getOrderSn())));
} }
} }
return PageResult.build(goodsPage); return PageResult.build(goodsPage);

View File

@ -0,0 +1,22 @@
package com.qihang.pdd.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qihang.pdd.domain.OmsPddWaybillAccount;
import com.qihang.pdd.service.OmsPddWaybillAccountService;
import com.qihang.pdd.mapper.OmsPddWaybillAccountMapper;
import org.springframework.stereotype.Service;
/**
* @author TW
* @description 针对表oms_pdd_waybill_account(拼多多电子面单账户信息表)的数据库操作Service实现
* @createDate 2024-06-17 10:09:25
*/
@Service
public class OmsPddWaybillAccountServiceImpl extends ServiceImpl<OmsPddWaybillAccountMapper, OmsPddWaybillAccount>
implements OmsPddWaybillAccountService{
}

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.pdd.mapper.ErpShipWaybillMapper">
<resultMap id="BaseResultMap" type="com.qihang.pdd.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

@ -73,11 +73,14 @@
<result property="auditTime" column="audit_time" jdbcType="TIMESTAMP"/> <result property="auditTime" column="audit_time" jdbcType="TIMESTAMP"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="erpSendCompany" column="erp_send_company" jdbcType="VARCHAR"/>
<result property="erpSendCode" column="erp_send_code" jdbcType="VARCHAR"/>
<result property="erpSendStatus" column="erp_send_status" jdbcType="INTEGER"/>
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id,shop_id,order_sn, id,shop_id,order_sn,
trade_type,free_sf,is_lucky_flag, trade_type,free_sf,is_lucky_flag,erp_send_company,erp_send_code,erp_send_status,
group_status,confirm_status,order_status, group_status,confirm_status,order_status,
refund_status,capital_free_discount,seller_discount, refund_status,capital_free_discount,seller_discount,
platform_discount,goods_amount,discount_amount, platform_discount,goods_amount,discount_amount,

View File

@ -0,0 +1,39 @@
<?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.pdd.mapper.OmsPddWaybillAccountMapper">
<resultMap id="BaseResultMap" type="com.qihang.pdd.domain.OmsPddWaybillAccount">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="shopId" column="shop_id" jdbcType="BIGINT"/>
<result property="sellerId" column="seller_id" jdbcType="BIGINT"/>
<result property="cpCode" column="cp_code" jdbcType="VARCHAR"/>
<result property="cpType" column="cp_type" jdbcType="INTEGER"/>
<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,shop_id,seller_id,
cp_code,cp_type,quantity,
allocated_quantity,branch_code,branch_name,
print_quantity,cancel_quantity,waybill_address_id,
province,city,area,
address_detail,name,mobile,
phone,is_show
</sql>
</mapper>

View File

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

View File

@ -5,10 +5,10 @@
<print-tao></print-tao> <print-tao></print-tao>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="京东POP" name="printJd" lazy> <el-tab-pane label="京东POP" name="printJd" lazy>
<el-col style="color:red">京东POP电子面单打印暂不提供</el-col> <el-col style="color:red">京东POP电子面单打印暂不支持</el-col>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="拼多多" name="printPdd" lazy> <el-tab-pane label="拼多多" name="printPdd" lazy>
<el-col style="color:red">拼多多电子面单打印正在开发中</el-col> <print-pdd></print-pdd>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="抖店" name="printDou" lazy> <el-tab-pane label="抖店" name="printDou" lazy>
<el-col style="color:red">抖店电子面单打印后续开放</el-col> <el-col style="color:red">抖店电子面单打印后续开放</el-col>
@ -25,11 +25,12 @@
<script> <script>
import printWei 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"; import printTao from "@/views/shop/tao/ewaybill/index.vue";
import printPdd from "@/views/shop/pdd/ewaybill/index.vue";
export default { export default {
name: "print", name: "print",
components:{printWei,printTao}, components:{printWei,printTao,printPdd},
data() { data() {
return { return {
activeName: 'printTao' activeName: 'printTao'

View File

@ -0,0 +1,442 @@
<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="orderSn">
<el-input
v-model="queryParams.orderSn"
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-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="orderSn" >
<template slot-scope="scope">
<p>{{scope.row.orderSn}}</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="450">
<template slot-scope="scope">
<el-table :data="scope.row.itemList" :show-header="false">
<el-table-column label="商品" align="center" prop="outerId" />
<el-table-column label="规格" align="center" prop="goodsSpec" />
<el-table-column label="数量" align="center" prop="goodsCount" width="60">
<template slot-scope="scope">
<el-tag size="small">x {{scope.row.goodsCount}}</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.createdTime) }}</span>
</template>
</el-table-column>
<el-table-column label="买家留言" align="center" prop="buyerMemo" />
<el-table-column label="备注" align="center" prop="remark" />
<!-- <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.receiverNameMask}}&nbsp;{{scope.row.receiverPhoneMask}}
</p>
<p>
{{scope.row.province}} &nbsp;{{scope.row.city}}&nbsp;{{scope.row.town}}&nbsp;
</p>
<p>
{{scope.row.receiverAddressMask}}
</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/pdd/order";
import {
getWaybillAccountList,
pullWaybillAccount,
getWaybillCode,
getWaybillPrintData,
pushWaybillPrintSuccess
} from "@/api/pdd/ewaybill";
export default {
name: "printPdd",
data() {
return {
//
loading: true,
//
ids: [],
shopList: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
title: "",
//
getCodeOpen: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
orderStatus: 1,
refundStatus: 1,
erpSendStatus:0,
shopId: null
},
//
printParams: {
deliver: null,
printer: null
},
//
form: {},
orderList: [],
printerList: [],
deliverList: [],
//
rules: {
accountId: [{ required: true, message: '请选择电子面单账户' }],
}
};
},
created() {
this.openWs()
listShop({platform: 5}).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.orderSn)
this.single = selection.length !== 1
this.multiple = !selection.length
},
openWs() {
const ws = new WebSocket('ws://127.0.0.1:5000');
ws.onopen = () => {
console.log('与打印组件建立连接成功: ');
//
ws.send(JSON.stringify({
requestID: '1234554',
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:5000');
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

@ -41,34 +41,6 @@
<el-row :gutter="10" class="mb8"> <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-col :span="1.5">
<el-button <el-button
type="primary" type="primary"
@ -331,7 +303,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.');
}; };