新增pdd电子面单取号
This commit is contained in:
parent
88d59cb5e1
commit
d2958d9a25
Binary file not shown.
|
|
@ -2,15 +2,22 @@ package com.qihang.pdd.controller;
|
||||||
|
|
||||||
|
|
||||||
import cn.qihangerp.open.pdd.WaybillAccountApiHelper;
|
import cn.qihangerp.open.pdd.WaybillAccountApiHelper;
|
||||||
|
import cn.qihangerp.open.pdd.WaybillApiHelper;
|
||||||
import cn.qihangerp.open.pdd.common.ApiResultVo;
|
import cn.qihangerp.open.pdd.common.ApiResultVo;
|
||||||
import cn.qihangerp.open.pdd.model.WaybillAccount;
|
import cn.qihangerp.open.pdd.model.WaybillAccount;
|
||||||
|
import cn.qihangerp.open.pdd.model.WaybillCodeModule;
|
||||||
|
import cn.qihangerp.open.pdd.request.*;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.qihang.common.common.AjaxResult;
|
import com.qihang.common.common.AjaxResult;
|
||||||
import com.qihang.common.enums.HttpStatus;
|
import com.qihang.common.enums.HttpStatus;
|
||||||
|
import com.qihang.pdd.domain.ErpShipWaybill;
|
||||||
|
import com.qihang.pdd.domain.OmsPddOrder;
|
||||||
import com.qihang.pdd.domain.OmsPddWaybillAccount;
|
import com.qihang.pdd.domain.OmsPddWaybillAccount;
|
||||||
|
import com.qihang.pdd.domain.bo.PddWaybillGetBo;
|
||||||
import com.qihang.pdd.openapi.ApiCommon;
|
import com.qihang.pdd.openapi.ApiCommon;
|
||||||
import com.qihang.pdd.openapi.PullRequest;
|
import com.qihang.pdd.openapi.PullRequest;
|
||||||
import com.qihang.pdd.service.ErpShipWaybillService;
|
import com.qihang.pdd.service.ErpShipWaybillService;
|
||||||
|
import com.qihang.pdd.service.OmsPddOrderService;
|
||||||
import com.qihang.pdd.service.OmsPddWaybillAccountService;
|
import com.qihang.pdd.service.OmsPddWaybillAccountService;
|
||||||
import com.qihang.security.common.BaseController;
|
import com.qihang.security.common.BaseController;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
|
@ -28,7 +35,7 @@ import java.util.List;
|
||||||
public class EwaybillController extends BaseController {
|
public class EwaybillController extends BaseController {
|
||||||
private final ApiCommon apiCommon;
|
private final ApiCommon apiCommon;
|
||||||
private final OmsPddWaybillAccountService waybillAccountService;
|
private final OmsPddWaybillAccountService waybillAccountService;
|
||||||
// private final OmsTaoOrderService orderService;
|
private final OmsPddOrderService orderService;
|
||||||
private final ErpShipWaybillService erpShipWaybillService;
|
private final ErpShipWaybillService erpShipWaybillService;
|
||||||
|
|
||||||
@GetMapping(value = "/get_waybill_account_list")
|
@GetMapping(value = "/get_waybill_account_list")
|
||||||
|
|
@ -99,112 +106,114 @@ public class EwaybillController extends BaseController {
|
||||||
return AjaxResult.success(list);
|
return AjaxResult.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @PostMapping("/get_waybill_code")
|
@PostMapping("/get_waybill_code")
|
||||||
// @ResponseBody
|
@ResponseBody
|
||||||
// public AjaxResult getWaybillCode(@RequestBody TaoWaybillGetBo req) {
|
public AjaxResult getWaybillCode(@RequestBody PddWaybillGetBo req) {
|
||||||
// if (req.getAccountId() == null || req.getAccountId() <= 0) {
|
if (req.getAccountId() == null || req.getAccountId() <= 0) {
|
||||||
// return AjaxResult.error(HttpStatus.PARAMS_ERROR, "参数错误,请选择电子面单账户");
|
return AjaxResult.error(HttpStatus.PARAMS_ERROR, "参数错误,请选择电子面单账户");
|
||||||
// }
|
}
|
||||||
// if (req.getShopId() == null || req.getShopId() <= 0) {
|
if (req.getShopId() == null || req.getShopId() <= 0) {
|
||||||
// return AjaxResult.error(HttpStatus.PARAMS_ERROR, "参数错误,没有店铺Id");
|
return AjaxResult.error(HttpStatus.PARAMS_ERROR, "参数错误,没有店铺Id");
|
||||||
// }
|
}
|
||||||
// if(req.getIds()==null || req.getIds().length<=0) {
|
if(req.getIds()==null || req.getIds().length<=0) {
|
||||||
// return AjaxResult.error(HttpStatus.PARAMS_ERROR, "参数错误,没有选择订单");
|
return AjaxResult.error(HttpStatus.PARAMS_ERROR, "参数错误,没有选择订单");
|
||||||
// }
|
}
|
||||||
// var checkResult = apiCommon.checkBefore(req.getShopId());
|
var checkResult = apiCommon.checkBefore(req.getShopId());
|
||||||
// if (checkResult.getCode() != HttpStatus.SUCCESS) {
|
if (checkResult.getCode() != HttpStatus.SUCCESS) {
|
||||||
// return AjaxResult.error(checkResult.getCode(), checkResult.getMsg(), checkResult.getData());
|
return AjaxResult.error(checkResult.getCode(), checkResult.getMsg(), checkResult.getData());
|
||||||
// }
|
}
|
||||||
// String accessToken = checkResult.getData().getAccessToken();
|
String accessToken = checkResult.getData().getAccessToken();
|
||||||
// String appKey = checkResult.getData().getAppKey();
|
String appKey = checkResult.getData().getAppKey();
|
||||||
// String appSecret = checkResult.getData().getAppSecret();
|
String appSecret = checkResult.getData().getAppSecret();
|
||||||
// Long sellerShopId = checkResult.getData().getSellerShopId();
|
Long sellerShopId = checkResult.getData().getSellerShopId();
|
||||||
//
|
|
||||||
// // 获取电子面单账户信息(包含了发货地址信息)
|
// 获取电子面单账户信息(包含了发货地址信息)
|
||||||
// OmsTaoWaybillAccount account = waybillAccountService.getById(req.getAccountId());
|
OmsPddWaybillAccount account = waybillAccountService.getById(req.getAccountId());
|
||||||
//
|
|
||||||
// WaybillCloudPrintApplyNewRequest request = new WaybillCloudPrintApplyNewRequest();
|
WaybillCloudPrintApplyNewRequest request = new WaybillCloudPrintApplyNewRequest();
|
||||||
// request.setCp_code(account.getCpCode());
|
request.setWp_code(account.getCpCode());
|
||||||
//
|
request.setNeed_encrypt(true);
|
||||||
// WaybillCloudPrintApplyNewRequestSender sender = new WaybillCloudPrintApplyNewRequestSender();
|
|
||||||
// sender.setName(account.getName());
|
WaybillCloudPrintApplyNewRequestContact sender = new WaybillCloudPrintApplyNewRequestContact();
|
||||||
// sender.setMobile(account.getMobile());
|
sender.setName(account.getName());
|
||||||
// WaybillCloudPrintApplyNewRequestSender.AddressDTO addressDTO = new WaybillCloudPrintApplyNewRequestSender.AddressDTO();
|
sender.setMobile(account.getMobile());
|
||||||
// addressDTO.setCity(account.getCity());
|
WaybillCloudPrintApplyNewRequestContactAddress addressDTO = new WaybillCloudPrintApplyNewRequestContactAddress();
|
||||||
// addressDTO.setProvince(account.getProvince());
|
addressDTO.setCity(account.getCity());
|
||||||
// addressDTO.setDistrict(account.getArea());
|
addressDTO.setProvince(account.getProvince());
|
||||||
// addressDTO.setTown("");
|
addressDTO.setDistrict(account.getArea());
|
||||||
// addressDTO.setDetail(account.getAddressDetail());
|
addressDTO.setTown("");
|
||||||
// sender.setAddress(addressDTO);
|
addressDTO.setDetail(account.getAddressDetail());
|
||||||
// request.setSender(sender);
|
sender.setAddress(addressDTO);
|
||||||
//
|
request.setSender(sender);
|
||||||
// // 组合取号的订单信息trade_order_info_dtos
|
|
||||||
// List<WaybillCloudPrintApplyNewRequestTradeOrderInfoDto> orderList = new ArrayList<>();
|
// 组合取号的订单信息trade_order_info_dtos
|
||||||
//
|
List<WaybillCloudPrintApplyNewRequestTradeOrderInfoDto> orderList = new ArrayList<>();
|
||||||
// for(String orderId:req.getIds()){
|
|
||||||
// if(StringUtils.hasText(orderId)){
|
for(String orderSn:req.getIds()){
|
||||||
// OmsTaoOrder omsTaoOrder = orderService.queryDetailByTid(orderId);
|
if(StringUtils.hasText(orderSn)){
|
||||||
// if(omsTaoOrder!=null) {
|
OmsPddOrder order = orderService.queryDetailByOrderSn(orderSn);
|
||||||
// WaybillCloudPrintApplyNewRequestTradeOrderInfoDto dto = new WaybillCloudPrintApplyNewRequestTradeOrderInfoDto();
|
if(order!=null) {
|
||||||
// dto.setObjectId(omsTaoOrder.getTid());
|
WaybillCloudPrintApplyNewRequestTradeOrderInfoDto dto = new WaybillCloudPrintApplyNewRequestTradeOrderInfoDto();
|
||||||
// dto.setTemplateUrl("http://cloudprint.cainiao.com/template/standard/101");
|
dto.setObject_id(order.getOrderSn());
|
||||||
// dto.setUserId(sellerShopId.intValue());
|
dto.setTemplate_url("https://file-link.pinduoduo.com/yunda_std");
|
||||||
//
|
dto.setUser_id(sellerShopId);
|
||||||
// WaybillCloudPrintApplyNewRequestTradeOrderInfoDto.OrderInfoDTO orderInfoDTO = new WaybillCloudPrintApplyNewRequestTradeOrderInfoDto.OrderInfoDTO();
|
|
||||||
// orderInfoDTO.setOrderChannelsType("TB");
|
OrderInfo orderInfo = new OrderInfo();
|
||||||
// orderInfoDTO.setTradeOrderList(omsTaoOrder.getTid());
|
orderInfo.setOrder_channels_type("PDD");
|
||||||
// dto.setOrderInfo(orderInfoDTO);
|
orderInfo.setTrade_order_list(new String[] {order.getOrderSn()});
|
||||||
//
|
dto.setOrder_info(orderInfo);
|
||||||
// WaybillCloudPrintApplyNewRequestTradeOrderInfoDto.PackageInfoDTO packageInfoDTO = new WaybillCloudPrintApplyNewRequestTradeOrderInfoDto.PackageInfoDTO();
|
|
||||||
// List<WaybillCloudPrintApplyNewRequestTradeOrderInfoDto.PackageInfoDTO.ItemsDTO> items = new ArrayList<>();
|
|
||||||
// for (var orderItem : omsTaoOrder.getItems()) {
|
PackageInfo packageInfo = new PackageInfo();
|
||||||
// WaybillCloudPrintApplyNewRequestTradeOrderInfoDto.PackageInfoDTO.ItemsDTO itemsDTO = new WaybillCloudPrintApplyNewRequestTradeOrderInfoDto.PackageInfoDTO.ItemsDTO();
|
List<PackageInfoItem> items = new ArrayList<>();
|
||||||
// itemsDTO.setCount(orderItem.getNum());
|
for (var orderItem : order.getItemList()) {
|
||||||
// itemsDTO.setName(orderItem.getTitle());
|
PackageInfoItem item = new PackageInfoItem();
|
||||||
// items.add(itemsDTO);
|
item.setName(orderItem.getGoodsName());
|
||||||
// }
|
item.setCount(orderItem.getGoodsCount());
|
||||||
// packageInfoDTO.setItems(items);
|
items.add(item);
|
||||||
// dto.setPackageInfo(packageInfoDTO);
|
}
|
||||||
//
|
packageInfo.setItems(items);
|
||||||
// WaybillCloudPrintApplyNewRequestTradeOrderInfoDto.RecipientDTO recipientDTO = new WaybillCloudPrintApplyNewRequestTradeOrderInfoDto.RecipientDTO();
|
dto.setPackage_info(packageInfo);
|
||||||
// WaybillCloudPrintApplyNewRequestTradeOrderInfoDto.RecipientDTO.AddressDTO addressDTO1 = new WaybillCloudPrintApplyNewRequestTradeOrderInfoDto.RecipientDTO.AddressDTO();
|
|
||||||
// addressDTO1.setCity(omsTaoOrder.getReceiverCity());
|
|
||||||
// addressDTO1.setTown(omsTaoOrder.getReceiverTown());
|
WaybillCloudPrintApplyNewRequestContact recipient = new WaybillCloudPrintApplyNewRequestContact();
|
||||||
// addressDTO1.setProvince(omsTaoOrder.getReceiverState());
|
recipient.setName("启航");
|
||||||
// addressDTO1.setDistrict(omsTaoOrder.getReceiverDistrict());
|
recipient.setMobile("15818590112");
|
||||||
// addressDTO1.setDetail(omsTaoOrder.getReceiverAddress());
|
WaybillCloudPrintApplyNewRequestContactAddress recipientAddress = new WaybillCloudPrintApplyNewRequestContactAddress();
|
||||||
// recipientDTO.setAddress(addressDTO1);
|
recipientAddress.setProvince(order.getProvince());
|
||||||
// recipientDTO.setName(omsTaoOrder.getReceiverName());
|
recipientAddress.setCity(order.getCity());
|
||||||
// recipientDTO.setOaid(omsTaoOrder.getOaid());
|
recipientAddress.setDistrict(order.getTown());
|
||||||
// recipientDTO.setTid(omsTaoOrder.getTid());
|
recipientAddress.setDetail(order.getAddress());
|
||||||
// dto.setRecipient(recipientDTO);
|
recipient.setAddress(recipientAddress);
|
||||||
// orderList.add(dto);
|
dto.setRecipient(recipient);
|
||||||
// }
|
|
||||||
// }
|
orderList.add(dto);
|
||||||
// }
|
}
|
||||||
//
|
}
|
||||||
// request.setTrade_order_info_dtos(orderList);
|
}
|
||||||
//
|
|
||||||
// ApiResultVo<WaybillCloudPrint> apiResultVo = WaybillApiHelper.waybillCloudPrintApplyNew(appKey, appSecret, accessToken, request);
|
request.setTrade_order_info_dtos(orderList);
|
||||||
// if(apiResultVo.getCode()==0){
|
|
||||||
// // 保持数据
|
ApiResultVo<WaybillCodeModule> apiResultVo = WaybillApiHelper.getWaybillCode(appKey, appSecret, accessToken, request);
|
||||||
// for(var result: apiResultVo.getList()){
|
if(apiResultVo.getCode()==0){
|
||||||
// ErpShipWaybill waybill = new ErpShipWaybill();
|
// 保持数据
|
||||||
// waybill.setShopId(req.getShopId());
|
for(var result: apiResultVo.getList()){
|
||||||
// waybill.setOrderId(result.getObjectId());
|
ErpShipWaybill waybill = new ErpShipWaybill();
|
||||||
// waybill.setWaybillCode(result.getWaybillCode());
|
waybill.setShopId(req.getShopId());
|
||||||
// waybill.setLogisticsCode(result.getCpCode());
|
waybill.setOrderId(result.getObject_id());
|
||||||
// waybill.setPrintData(result.getPrintData());
|
waybill.setWaybillCode(result.getWaybill_code());
|
||||||
// erpShipWaybillService.waybillUpdate(waybill);
|
waybill.setLogisticsCode(account.getCpCode());
|
||||||
// log.info("====保存電子面單信息========"+result.getObjectId());
|
waybill.setPrintData(result.getPrint_data());
|
||||||
// }
|
erpShipWaybillService.waybillUpdate(waybill);
|
||||||
// }else{
|
log.info("====保存電子面單信息========"+result.getObject_id());
|
||||||
// return AjaxResult.error(apiResultVo.getMsg());
|
}
|
||||||
// }
|
}else{
|
||||||
//
|
return AjaxResult.error(apiResultVo.getMsg());
|
||||||
// return success();
|
}
|
||||||
// }
|
|
||||||
//
|
return success();
|
||||||
|
}
|
||||||
|
|
||||||
// @PostMapping("/get_print_data")
|
// @PostMapping("/get_print_data")
|
||||||
// @ResponseBody
|
// @ResponseBody
|
||||||
// public AjaxResult getPrintData(@RequestBody TaoWaybillGetBo req) {
|
// public AjaxResult getPrintData(@RequestBody TaoWaybillGetBo req) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
package com.qihang.pdd.domain;
|
package com.qihang.pdd.domain;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -12,6 +15,7 @@ public class OmsPddWaybillAccount implements Serializable {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.qihang.pdd.domain.bo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class PddWaybillGetBo {
|
||||||
|
private Long accountId;//电子面单账户id
|
||||||
|
private String[] ids;
|
||||||
|
private Long shopId;//店铺Id
|
||||||
|
}
|
||||||
|
|
@ -49,16 +49,15 @@ public class ApiCommon {
|
||||||
// return ResultVo.error(HttpStatus.PARAMS_ERROR, "第三方平台配置错误,没有找到ServerUrl");
|
// return ResultVo.error(HttpStatus.PARAMS_ERROR, "第三方平台配置错误,没有找到ServerUrl");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// if(shop.getSellerId() == null || shop.getSellerId() <= 0) {
|
if(shop.getSellerShopId() == null || shop.getSellerShopId() <= 0) {
|
||||||
// return com.qihang.tao.common.ApiResult.build(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());
|
||||||
params.setAppSecret(platform.getAppSecret());
|
params.setAppSecret(platform.getAppSecret());
|
||||||
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());
|
params.setSellerShopId(shop.getSellerShopId());
|
||||||
if (!StringUtils.hasText(shop.getAccessToken())) {
|
if (!StringUtils.hasText(shop.getAccessToken())) {
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,19 @@
|
||||||
package com.qihang.pdd.service;
|
package com.qihang.pdd.service;
|
||||||
|
|
||||||
|
import com.qihang.common.common.ResultVo;
|
||||||
import com.qihang.pdd.domain.ErpShipWaybill;
|
import com.qihang.pdd.domain.ErpShipWaybill;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author TW
|
* @author TW
|
||||||
* @description 针对表【erp_ship_waybill(发货电子面单记录表)】的数据库操作Service
|
* @description 针对表【erp_ship_waybill(发货电子面单记录表)】的数据库操作Service
|
||||||
* @createDate 2024-06-17 10:16:47
|
* @createDate 2024-06-17 10:16:47
|
||||||
*/
|
*/
|
||||||
public interface ErpShipWaybillService extends IService<ErpShipWaybill> {
|
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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,4 +14,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
public interface OmsPddOrderService extends IService<OmsPddOrder> {
|
public interface OmsPddOrderService extends IService<OmsPddOrder> {
|
||||||
PageResult<OmsPddOrder> queryPageList(OmsPddOrder bo, PageQuery pageQuery);
|
PageResult<OmsPddOrder> queryPageList(OmsPddOrder bo, PageQuery pageQuery);
|
||||||
ResultVo<Integer> saveOrder(Long shopId, OmsPddOrder order);
|
ResultVo<Integer> saveOrder(Long shopId, OmsPddOrder order);
|
||||||
|
|
||||||
|
OmsPddOrder queryDetailByOrderSn(String orderSn);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,121 @@
|
||||||
package com.qihang.pdd.service.impl;
|
package com.qihang.pdd.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.qihang.common.common.ResultVo;
|
||||||
|
import com.qihang.common.enums.EnumShopType;
|
||||||
import com.qihang.pdd.domain.ErpShipWaybill;
|
import com.qihang.pdd.domain.ErpShipWaybill;
|
||||||
|
import com.qihang.pdd.domain.OmsPddOrder;
|
||||||
|
import com.qihang.pdd.mapper.OmsPddOrderMapper;
|
||||||
import com.qihang.pdd.service.ErpShipWaybillService;
|
import com.qihang.pdd.service.ErpShipWaybillService;
|
||||||
import com.qihang.pdd.mapper.ErpShipWaybillMapper;
|
import com.qihang.pdd.mapper.ErpShipWaybillMapper;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author TW
|
* @author TW
|
||||||
* @description 针对表【erp_ship_waybill(发货电子面单记录表)】的数据库操作Service实现
|
* @description 针对表【erp_ship_waybill(发货电子面单记录表)】的数据库操作Service实现
|
||||||
* @createDate 2024-06-17 10:16:47
|
* @createDate 2024-06-17 10:16:47
|
||||||
*/
|
*/
|
||||||
|
@AllArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class ErpShipWaybillServiceImpl extends ServiceImpl<ErpShipWaybillMapper, ErpShipWaybill>
|
public class ErpShipWaybillServiceImpl extends ServiceImpl<ErpShipWaybillMapper, ErpShipWaybill>
|
||||||
implements ErpShipWaybillService{
|
implements ErpShipWaybillService{
|
||||||
|
private final ErpShipWaybillMapper mapper;
|
||||||
|
private final OmsPddOrderMapper orderMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新电子面单信息
|
||||||
|
* @param shipWaybill
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public ResultVo<Integer> waybillUpdate(ErpShipWaybill shipWaybill) {
|
||||||
|
String orderSn= 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, orderSn));
|
||||||
|
if(erpShipWaybills==null|| erpShipWaybills.size()==0) {
|
||||||
|
shipWaybill.setStatus(1);//已取号
|
||||||
|
shipWaybill.setShopType(EnumShopType.PDD.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状态
|
||||||
|
OmsPddOrder orderUpdate = new OmsPddOrder();
|
||||||
|
orderUpdate.setErpSendStatus(shipWaybill.getStatus());
|
||||||
|
orderUpdate.setErpSendCode(shipWaybill.getWaybillCode());
|
||||||
|
orderUpdate.setErpSendCompany(shipWaybill.getLogisticsCode());
|
||||||
|
orderMapper.update(orderUpdate,new LambdaQueryWrapper<OmsPddOrder>().eq(OmsPddOrder::getOrderSn,orderSn));
|
||||||
|
|
||||||
|
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状态
|
||||||
|
OmsPddOrder orderUpdate = new OmsPddOrder();
|
||||||
|
orderUpdate.setErpSendStatus(update.getStatus());
|
||||||
|
|
||||||
|
orderMapper.update(orderUpdate,new LambdaQueryWrapper<OmsPddOrder>().eq(OmsPddOrder::getOrderSn,w.getOrderId()));
|
||||||
|
|
||||||
|
//TODO: 打印成功之后 加入备货清单
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ResultVo.success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -158,6 +158,16 @@ public class OmsPddOrderServiceImpl extends ServiceImpl<OmsPddOrderMapper, OmsPd
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OmsPddOrder queryDetailByOrderSn(String orderSn) {
|
||||||
|
List<OmsPddOrder> omsTaoOrders = orderMapper.selectList(new LambdaQueryWrapper<OmsPddOrder>().eq(OmsPddOrder::getOrderSn, orderSn));
|
||||||
|
if(omsTaoOrders == null) return null;
|
||||||
|
|
||||||
|
OmsPddOrder order = omsTaoOrders.get(0);
|
||||||
|
order.setItemList(orderItemMapper.selectList(new LambdaQueryWrapper<OmsPddOrderItem>().eq(OmsPddOrderItem::getOrderSn,orderSn)));
|
||||||
|
return order;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
<print-pdd></print-pdd>
|
<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>
|
<print-dou></print-dou>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane label="视频号小店" name="printWei" lazy>
|
<el-tab-pane label="视频号小店" name="printWei" lazy>
|
||||||
<print-wei></print-wei>
|
<print-wei></print-wei>
|
||||||
|
|
@ -26,11 +26,12 @@
|
||||||
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";
|
import printPdd from "@/views/shop/pdd/ewaybill/index.vue";
|
||||||
|
import printDou from "@/views/shop/dou/ewaybill/index.vue";
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "print",
|
name: "print",
|
||||||
components:{printWei,printTao,printPdd},
|
components:{printWei,printTao,printPdd,printDou},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
activeName: 'printTao'
|
activeName: 'printTao'
|
||||||
|
|
|
||||||
|
|
@ -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="orderId">
|
||||||
|
<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="orderId" >
|
||||||
|
<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}} -->
|
||||||
|
<!-- <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}} {{scope.row.receiverPhoneMask}}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
{{scope.row.province}} {{scope.row.city}} {{scope.row.town}}
|
||||||
|
</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: "printDou",
|
||||||
|
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:13888');
|
||||||
|
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:13888');
|
||||||
|
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>
|
||||||
|
|
@ -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="orderId">
|
||||||
|
<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="orderId" >
|
||||||
|
<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}} -->
|
||||||
|
<!-- <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}} {{scope.row.receiverPhoneMask}}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
{{scope.row.province}} {{scope.row.city}} {{scope.row.town}}
|
||||||
|
</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: "printDou",
|
||||||
|
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:9113');
|
||||||
|
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:9113');
|
||||||
|
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>
|
||||||
Loading…
Reference in New Issue