优化tao订单发货

This commit is contained in:
Richie 2025-05-23 19:06:20 +08:00
parent 43412a9099
commit 3f8d2ff1ed
7 changed files with 364 additions and 425 deletions

View File

@ -1,11 +1,11 @@
package cn.qihangerp.api.common.bo; package cn.qihangerp.common.bo;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal; import java.math.BigDecimal;
@Data @Data
public class ErpOrderShipBo { public class ShopOrderShipBo {
private String Id;//订单id private String Id;//订单id
private Double length; private Double length;
private Double width; private Double width;

View File

@ -5,6 +5,7 @@ import cn.qihangerp.common.AjaxResult;
import cn.qihangerp.common.PageQuery; import cn.qihangerp.common.PageQuery;
import cn.qihangerp.common.PageResult; import cn.qihangerp.common.PageResult;
import cn.qihangerp.common.TableDataInfo; import cn.qihangerp.common.TableDataInfo;
import cn.qihangerp.common.bo.ShopOrderShipBo;
import cn.qihangerp.common.enums.EnumShopType; import cn.qihangerp.common.enums.EnumShopType;
import cn.qihangerp.common.mq.MqMessage; import cn.qihangerp.common.mq.MqMessage;
import cn.qihangerp.common.mq.MqType; import cn.qihangerp.common.mq.MqType;
@ -33,7 +34,9 @@ public class TaoOrderController extends BaseController {
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) public AjaxResult getInfo(@PathVariable("id") Long id)
{ {
return success(orderService.queryDetailById(id)); TaoOrder taoOrder = orderService.queryDetailById(id);
if(taoOrder==null) return AjaxResult.error("没有找到订单信息");
return success(taoOrder);
} }
/** /**
@ -52,4 +55,32 @@ public class TaoOrderController extends BaseController {
} }
return success(); return success();
} }
/**
* 订单发货(手动发货)
* @param shipBo
* @return
*/
@PostMapping("/manualShipment")
public AjaxResult manualShipment(@RequestBody ShopOrderShipBo shipBo)
{
// var result = orderService.manualShipmentOrder(shipBo,getUsername());
// if(result.getCode() == 0) return AjaxResult.success();
// else return AjaxResult.error(result.getMsg());
return AjaxResult.error("未实现");
}
/**
* 分配供应商发货
* @param shipBo
* @return
*/
@PostMapping("/allocateShipmentOrder")
public AjaxResult allocateShipmentOrder(@RequestBody ShopOrderShipBo shipBo)
{
// var result = orderService.allocateShipmentOrder(shipBo,getUsername());
// if(result.getCode() == 0) return AjaxResult.success();
// else return AjaxResult.error(result.getMsg());
return AjaxResult.error("未实现");
}
} }

View File

@ -1,33 +1,11 @@
package cn.qihangerp.services.dou.controller; package cn.qihangerp.api.tao.controller;
import cn.qihangerp.api.tao.TaoApiCommon;
import cn.qihangerp.common.AjaxResult; import cn.qihangerp.common.AjaxResult;
import cn.qihangerp.common.BaseController;
import cn.qihangerp.common.ResultVoEnum; import cn.qihangerp.common.ResultVoEnum;
import cn.qihangerp.common.enums.EnumShopType; import cn.qihangerp.common.enums.EnumShopType;
import cn.qihangerp.common.enums.HttpStatus; import cn.qihangerp.common.enums.HttpStatus;
import cn.qihangerp.module.open.dou.domain.DouOrder; import cn.qihangerp.security.common.BaseController;
import cn.qihangerp.module.open.dou.domain.OmsDouLogisticsTemplate;
import cn.qihangerp.module.open.dou.domain.OmsDouWaybillAccount;
import cn.qihangerp.module.open.dou.service.DouOrderService;
import cn.qihangerp.module.open.dou.service.OmsDouLogisticsTemplateService;
import cn.qihangerp.module.open.dou.service.OmsDouWaybillAccountService;
import cn.qihangerp.module.order.domain.OShipWaybill;
import cn.qihangerp.module.order.service.OOrderService;
import cn.qihangerp.module.order.service.OShipWaybillService;
import cn.qihangerp.open.common.ApiResultVo;
import cn.qihangerp.sdk.dou.DouTokenApiHelper;
import cn.qihangerp.sdk.dou.DouWaybillAccountApiHelper;
import cn.qihangerp.sdk.dou.DouWaybillApiHelper;
import cn.qihangerp.sdk.dou.model.*;
import cn.qihangerp.sdk.dou.request.WaybillApplyRequest;
import cn.qihangerp.sdk.dou.request.WaybillCodeRequest;
import cn.qihangerp.services.dou.DouApiCommon;
import cn.qihangerp.services.dou.request.DouRequest;
import cn.qihangerp.services.dou.request.DouWaybillAccountUpdateRequest;
import cn.qihangerp.services.dou.request.DouWaybillGetBo;
import cn.qihangerp.services.dou.request.ShareSupplierRequest;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.java.Log; import lombok.extern.java.Log;
@ -43,336 +21,89 @@ import java.util.stream.Collectors;
@Log @Log
@AllArgsConstructor @AllArgsConstructor
@RestController @RestController
@RequestMapping("/dou/ewaybill") @RequestMapping("/tao/ewaybill")
public class DouWaybillController extends BaseController { public class TaoWaybillController extends BaseController {
private final DouApiCommon apiCommon; private final TaoApiCommon taoApiCommon;
private final OmsDouWaybillAccountService waybillAccountService;
private final DouOrderService orderService;
private final OShipWaybillService erpShipWaybillService;
private final OOrderService oOrderService;
private final OmsDouLogisticsTemplateService logisticsTemplateService;
@GetMapping(value = "/get_waybill_account_list") @GetMapping(value = "/get_waybill_account_list")
public AjaxResult getWaybillAccountList(Long shopId) throws Exception { public AjaxResult getWaybillAccountList(Long shopId) throws Exception {
List<OmsDouWaybillAccount> list = waybillAccountService.list(
new LambdaQueryWrapper<OmsDouWaybillAccount>() return AjaxResult.error("开源版本不支持电子面单取号功能");
.eq(OmsDouWaybillAccount::getShopId, shopId)
.eq(OmsDouWaybillAccount::getIsShow, 1));
return AjaxResult.success(list);
} }
@RequestMapping(value = "/shareSupplier", method = RequestMethod.POST) // @RequestMapping(value = "/shareSupplier", method = RequestMethod.POST)
public AjaxResult shareSupplier(@RequestBody ShareSupplierRequest params) throws Exception { // public AjaxResult shareSupplier(@RequestBody ShareSupplierRequest params) throws Exception {
if (params.getId() == null || params.getId() <= 0) return AjaxResult.error("参数错误没有Id"); // if (params.getId() == null || params.getId() <= 0) return AjaxResult.error("参数错误没有Id");
if (params.getSupplierIds() == null || params.getSupplierIds().length == 0) return AjaxResult.error("参数错误,没有供应商"); // if (params.getSupplierIds() == null || params.getSupplierIds().length == 0) return AjaxResult.error("参数错误,没有供应商");
OmsDouWaybillAccount account = new OmsDouWaybillAccount(); // OmsDouWaybillAccount account = new OmsDouWaybillAccount();
account.setId(params.getId()); // account.setId(params.getId());
String result = Arrays.stream(params.getSupplierIds()).mapToObj(String::valueOf).collect(Collectors.joining(",")); // String result = Arrays.stream(params.getSupplierIds()).mapToObj(String::valueOf).collect(Collectors.joining(","));
account.setSupplierIds(","+result+","); // account.setSupplierIds(","+result+",");
waybillAccountService.updateById(account); // waybillAccountService.updateById(account);
//
// return AjaxResult.success();
// }
//
// @RequestMapping(value = "/updateAccount", method = RequestMethod.POST)
// public AjaxResult updateAccount(@RequestBody DouWaybillAccountUpdateRequest params) throws Exception {
// if (params.getId() == null || params.getId() <= 0) return AjaxResult.error("参数错误没有Id");
// if (!StringUtils.hasText(params.getName())) return AjaxResult.error("缺少参数");
// if (!StringUtils.hasText(params.getMobile())) return AjaxResult.error("缺少参数");
// if (!StringUtils.hasText(params.getNetsiteName())) return AjaxResult.error("缺少参数");
// if (!StringUtils.hasText(params.getNetsiteCode())) return AjaxResult.error("缺少参数");
//
// OmsDouWaybillAccount account = new OmsDouWaybillAccount();
// account.setId(params.getId());
// account.setNetsiteName(params.getNetsiteName());
// account.setNetsiteCode(params.getNetsiteCode());
// account.setName(params.getName());
// account.setMobile(params.getMobile());
// account.setSellerShopId(params.getSellerShopId());
// waybillAccountService.updateById(account);
//
// return AjaxResult.success();
// }
return AjaxResult.success(); /**
} * 拉取电子面单账号
*
@RequestMapping(value = "/updateAccount", method = RequestMethod.POST) * @param
public AjaxResult updateAccount(@RequestBody DouWaybillAccountUpdateRequest params) throws Exception { * @return
if (params.getId() == null || params.getId() <= 0) return AjaxResult.error("参数错误没有Id"); * @throws Exception
if (!StringUtils.hasText(params.getName())) return AjaxResult.error("缺少参数"); */
if (!StringUtils.hasText(params.getMobile())) return AjaxResult.error("缺少参数");
if (!StringUtils.hasText(params.getNetsiteName())) return AjaxResult.error("缺少参数");
if (!StringUtils.hasText(params.getNetsiteCode())) return AjaxResult.error("缺少参数");
OmsDouWaybillAccount account = new OmsDouWaybillAccount();
account.setId(params.getId());
account.setNetsiteName(params.getNetsiteName());
account.setNetsiteCode(params.getNetsiteCode());
account.setName(params.getName());
account.setMobile(params.getMobile());
account.setSellerShopId(params.getSellerShopId());
waybillAccountService.updateById(account);
return AjaxResult.success();
}
/**
* 拉取电子面单账号
* @param params
* @return
* @throws Exception
*/
@RequestMapping(value = "/pull_waybill_account", method = RequestMethod.POST) @RequestMapping(value = "/pull_waybill_account", method = RequestMethod.POST)
public AjaxResult pullWaybillAccount(@RequestBody DouRequest params) throws Exception { public AjaxResult pullWaybillAccount() throws Exception {
if (params.getShopId() == null || params.getShopId() <= 0) { return AjaxResult.error("开源版本不支持电子面单功能");
return AjaxResult.error(HttpStatus.PARAMS_ERROR, "参数错误没有店铺Id");
}
var checkResult = apiCommon.checkBefore(params.getShopId());
if (checkResult.getCode() != ResultVoEnum.SUCCESS.getIndex()) {
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().getSellerId();
ApiResultVo<Token> token = DouTokenApiHelper.getToken(appKey, appSecret,checkResult.getData().getSellerId());
if(token.getCode()==0) {
accessToken = token.getData().getAccessToken();
}else{
return AjaxResult.error(token.getMsg());
}
ApiResultVo<WaybillAccount> apiResultVo = DouWaybillAccountApiHelper.listWaybillAccount(appKey, appSecret, accessToken);
List<OmsDouWaybillAccount> list = new ArrayList<>();
if(apiResultVo.getCode()==0) {
for (var item : apiResultVo.getList()) {
List<OmsDouLogisticsTemplate> logisticsCode = logisticsTemplateService.getByLogisticsCode(item.getCompany());
if (item.getSenderAddress() != null && item.getSenderAddress().size() > 0) {
for(var sendAddress : item.getSenderAddress()) {
OmsDouWaybillAccount vo = new OmsDouWaybillAccount();
vo.setShopId(params.getShopId());
vo.setSellerId(sellId);
vo.setIsShow(1);
vo.setCompany(item.getCompany());
vo.setCompanyType(item.getCompanyType());
vo.setAmount(Integer.parseInt(item.getAmount()));
vo.setAllocatedQuantity(item.getAllocatedQuantity());
vo.setCancelledQuantity(item.getCancelledQuantity());
vo.setRecycledQuantity(item.getRecycledQuantity());
vo.setNetsiteCode(item.getNetsiteCode());
vo.setNetsiteName(item.getNetsiteName());
vo.setProvinceName(sendAddress.getProvinceName());
vo.setDistrictName(sendAddress.getDistrictName());
vo.setCityName(sendAddress.getCityName());
vo.setStreetName(sendAddress.getStreetName());
vo.setDetailAddress(sendAddress.getDetailAddress());
if(logisticsCode!=null&& logisticsCode.size()>0) {
vo.setTemplateUrl(logisticsCode.get(0).getTemplateUrl());
}
list.add(vo);
}
}
log.info("========组装dou电子面单账户信息==========");
}
waybillAccountService.saveAccountList(params.getShopId(),list);
}
return AjaxResult.success(list);
} }
@PostMapping("/get_waybill_code") @PostMapping("/get_waybill_code")
@ResponseBody @ResponseBody
public AjaxResult getWaybillCode(@RequestBody DouWaybillGetBo req) { public AjaxResult getWaybillCode() {
if (req.getAccountId() == null || req.getAccountId() <= 0) { return AjaxResult.error("开源版本不支持电子面单功能");
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() != ResultVoEnum.SUCCESS.getIndex()) {
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().getSellerId();
ApiResultVo<Token> token = DouTokenApiHelper.getToken(appKey, appSecret,checkResult.getData().getSellerId());
if(token.getCode()==0) {
accessToken = token.getData().getAccessToken();
}else{
return AjaxResult.error(token.getMsg());
}
// 获取电子面单账户信息(包含了发货地址信息)
OmsDouWaybillAccount waybillAccount = waybillAccountService.getById(req.getAccountId());
WaybillCodeRequest request = new WaybillCodeRequest();
request.setLogistics_code(waybillAccount.getCompany());
request.setOrder_channel("1");
WaybillAddressInfo sender = new WaybillAddressInfo();
WaybillAddress address = new WaybillAddress();
address.setCountry_code("CHN");
address.setProvince_name(waybillAccount.getProvinceName());
address.setCity_name(waybillAccount.getCityName());
address.setDistrict_name(waybillAccount.getDistrictName());
address.setStreet_name(waybillAccount.getStreetName());
address.setDetail_address(waybillAccount.getDetailAddress());
sender.setAddress(address);
WaybillContact contact = new WaybillContact();
contact.setName(waybillAccount.getName());
contact.setMobile(waybillAccount.getMobile());
sender.setContact(contact);
request.setSender_info(sender);
// 开始组装订单
List<WaybillOrderInfo> orderInfos=new ArrayList<>();
for(String orderId:req.getIds()){
if(StringUtils.hasText(orderId)){
DouOrder order = orderService.queryDetailByOrderId(orderId);
if(order!=null) {
WaybillOrderInfo orderInfo = new WaybillOrderInfo();
orderInfo.setOrder_id(order.getOrderId());
WaybillAddressInfo receiver = new WaybillAddressInfo();
WaybillAddress address1 = new WaybillAddress();
address1.setCountry_code("CHN");
address1.setProvince_name(order.getProvinceName());
address1.setCity_name(order.getCityName());
address1.setDistrict_name(order.getTownName());
address1.setStreet_name(order.getStreetName());
address1.setDetail_address(order.getMaskPostAddress());
receiver.setAddress(address1);
WaybillContact contact1 = new WaybillContact();
contact1.setName(order.getMaskPostReceiver());
contact1.setMobile("-");
receiver.setContact(contact1);
orderInfo.setReceiver_info(receiver);
//
List<WaybillOrderItem> items=new ArrayList<>();
if(order.getItems()!=null&&order.getItems().size()>0) {
for (var it: order.getItems()) {
WaybillOrderItem item = new WaybillOrderItem();
item.setItem_count(it.getItemNum().intValue());
item.setItem_name(it.getProductName());
item.setItem_specs(it.getSpec());
items.add(item);
}
orderInfo.setItems(items);
}
orderInfos.add(orderInfo);
}
}
}
request.setOrder_infos(orderInfos);
ApiResultVo<WaybillCode> apiResultVo = DouWaybillApiHelper.getWaybillCode(appKey, appSecret, token.getData().getAccessToken(), request);
if(apiResultVo.getCode()==0){
// 保持数据
for(var result: apiResultVo.getList()){
OShipWaybill waybill = new OShipWaybill();
waybill.setShopId(req.getShopId());
waybill.setShopType(EnumShopType.DOU.getIndex());
waybill.setOrderId(result.getOrderId());
waybill.setWaybillCode(result.getTrackNo());
waybill.setLogisticsCode(result.getCompany());
// waybill.setPrintData(result.getPrint_data());
erpShipWaybillService.waybillUpdate(waybill);
log.info("====保存電子面單信息========"+result.getOrderId());
// oOrderService.saveWaybillCode(result.getOrderId(), req.getShopId(), EnumShopType.DOU.getIndex(),result.getTrackNo());
}
}else{
return AjaxResult.error(apiResultVo.getMsg());
}
return success();
} }
@PostMapping("/get_print_data") @PostMapping("/get_print_data")
@ResponseBody @ResponseBody
public AjaxResult getPrintData(@RequestBody DouWaybillGetBo req) { public AjaxResult getPrintData() {
if (req.getShopId() == null || req.getShopId() <= 0) { return AjaxResult.error("开源版本不支持电子面单功能");
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() != 0) {
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().getSellerId();
ApiResultVo<Token> token = DouTokenApiHelper.getToken(appKey, appSecret,checkResult.getData().getSellerId());
if(token.getCode()==0) {
accessToken = token.getData().getAccessToken();
}else{
return AjaxResult.error(token.getMsg());
}
List<OShipWaybill> list = erpShipWaybillService.getListByOrderIds(req.getShopId(), req.getIds());
WaybillApplyRequest request = new WaybillApplyRequest();
List<WaybillApply> waybillApplyList = new ArrayList<>();
if(list!=null && list.size()>0) {
for (var ship:list) {
if(!StringUtils.hasText(ship.getPrintData())) {
WaybillApply dto = new WaybillApply();
dto.setLogistics_code(ship.getLogisticsCode());
dto.setTrack_no(ship.getWaybillCode());
waybillApplyList.add(dto);
}
}
}
request.setWaybill_applies(waybillApplyList);
ApiResultVo<WaybillPrintData> apiResultVo = DouWaybillApiHelper.pullWaybillPrintData(appKey, appSecret, accessToken, request);
if(apiResultVo.getCode()==0){
// 更新数据
for (var item:apiResultVo.getList()) {
OShipWaybill waybillNew = new OShipWaybill();
waybillNew.setPrintData(item.getPrintData());
waybillNew.setUpdateBy("获取打印数据");
waybillNew.setUpdateTime(new Date());
erpShipWaybillService.update(waybillNew,new LambdaQueryWrapper<OShipWaybill>().eq(OShipWaybill::getWaybillCode,item.getTrackNo()));
log.info("====保存電子面單打印信息jd========"+item.getOrderId());
OShipWaybill list1 = list.stream().filter(x -> x.getWaybillCode().equals(item.getTrackNo())).findFirst().get();
if(list1!=null){
list1.setPrintData(item.getPrintData());
}
}
}else{
return AjaxResult.error(apiResultVo.getMsg());
}
return AjaxResult.success(list);
}
@PostMapping("/push_print_success") @PostMapping("/push_print_success")
@ResponseBody @ResponseBody
public AjaxResult pushPrintSuccess(@RequestBody DouWaybillGetBo req) { public AjaxResult pushPrintSuccess() {
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(); return AjaxResult.success();
} }
/** /**
* 发货 * 发货
* @param req *
* @param
* @return * @return
*/ */
@PostMapping("/push_ship_send") @PostMapping("/push_ship_send")
@ResponseBody @ResponseBody
public AjaxResult pushShipSend(@RequestBody DouWaybillGetBo req) { public AjaxResult pushShipSend() {
if (req.getShopId() == null || req.getShopId() <= 0) { return AjaxResult.error("开源版本不支持电子面单发货功能");
return AjaxResult.error(HttpStatus.PARAMS_ERROR, "参数错误没有店铺Id");
}
if (req.getIds() == null || req.getIds().length <= 0) {
return AjaxResult.error(HttpStatus.PARAMS_ERROR, "参数错误,没有选择订单");
}
erpShipWaybillService.pushShipSend(req.getShopId(), req.getIds());
return AjaxResult.success();
} }
} }

View File

@ -84,7 +84,11 @@ public class TaoOrderServiceImpl extends ServiceImpl<TaoOrderMapper, TaoOrder>
@Override @Override
public TaoOrder queryDetailById(Long id) { public TaoOrder queryDetailById(Long id) {
return mapper.selectById(id); TaoOrder taoOrder = mapper.selectById(id);
if(taoOrder!=null){
taoOrder.setItems(itemMapper.selectList(new LambdaQueryWrapper<TaoOrderItem>().eq(TaoOrderItem::getTid,taoOrder.getTid())));
return taoOrder;
}else return null;
} }
@Override @Override

View File

@ -3,7 +3,7 @@ import request from '@/utils/request'
export function getWaybillAccountList(data) { export function getWaybillAccountList(data) {
return request({ return request({
url: '/api/open-api/tao/ewaybill/get_waybill_account_list', url: '/api/open-api/tao/ewaybill/get_waybill_account_list',
method: 'post', method: 'get',
data: data data: data
}) })
} }

View File

@ -43,3 +43,23 @@ export function pushOms(data) {
data: data data: data
}) })
} }
// 分配供应商发货
export function allocateShipmentOrder(data) {
return request({
url: '/api/open-api/tao/order/allocateShipmentOrder',
method: 'post',
data: data
})
}
// 手动发货
export function manualShipmentOrder(data) {
return request({
url: '/api/open-api/tao/order/manualShipment',
method: 'post',
data: data
})
}

View File

@ -41,6 +41,26 @@
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
:disabled="single"
icon="el-icon-download"
size="mini"
@click="handleShip"
>手动发货</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type=""
plain
:disabled="single"
icon="el-icon-download"
size="mini"
@click="allocateShipmentToSupplier"
>分配给供应商发货</el-button>
</el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
type="primary" type="primary"
@ -49,7 +69,7 @@
size="mini" size="mini"
:disabled="multiple" :disabled="multiple"
@click="handleGetEwaybillCode" @click="handleGetEwaybillCode"
>电子面单取号</el-button> >电子面单取号&发货</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
@ -186,14 +206,167 @@
<el-button @click="cancel"> </el-button> <el-button @click="cancel"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
<!-- 打包发货对话框 -->
<el-dialog title="打包发货" :visible.sync="shipOpen" width="1100px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px" >
<el-descriptions title="订单信息">
<el-descriptions-item label="ID">{{form.id}}</el-descriptions-item>
<el-descriptions-item label="订单号">{{form.orderNum}}</el-descriptions-item>
<el-descriptions-item label="店铺">
{{ shopList.find(x=>x.id == form.shopId)?shopList.find(x=>x.id == form.shopId).name:'' }}
<el-tag size="small" v-if="form.shopType === 5">微信小店</el-tag>
</el-descriptions-item>
<el-descriptions-item label="买家留言">
{{form.buyerMemo}}
</el-descriptions-item>
<el-descriptions-item label="备注">
{{form.remark}}
</el-descriptions-item>
<el-descriptions-item label="创建时间">
{{ parseTime(form.createTime) }}
</el-descriptions-item>
<el-descriptions-item label="订单状态">
<el-tag v-if="form.orderStatus === 1" style="margin-bottom: 6px;">待发货</el-tag>
<el-tag v-if="form.orderStatus === 2" style="margin-bottom: 6px;">已发货</el-tag>
<el-tag v-if="form.orderStatus === 3" style="margin-bottom: 6px;">已签收</el-tag>
</el-descriptions-item>
<el-descriptions-item label="退款状态">
<el-tag v-if="form.refundStatus === 1">无售后或售后关闭</el-tag>
<el-tag v-if="form.refundStatus === 2">售后处理中</el-tag>
<el-tag v-if="form.refundStatus === 3">退款中</el-tag>
<el-tag v-if="form.refundStatus === 4">退款成功</el-tag>
</el-descriptions-item>
<el-descriptions-item label="">
<!-- <el-tag v-if="form.shipType === 1" type="danger">供应商代发</el-tag>-->
<!-- <el-tag v-if="form.shipType === 0" type="danger">仓库发货</el-tag>-->
</el-descriptions-item>
<el-descriptions-item label="收件人姓名">{{form.receiverName}}</el-descriptions-item>
<el-descriptions-item label="收件人手机号">{{form.receiverMobile}}</el-descriptions-item>
<el-descriptions-item label="省市区">{{form.province}}{{form.city}}{{form.town}}</el-descriptions-item>
<el-descriptions-item label="详细地址">{{form.address}}</el-descriptions-item>
</el-descriptions>
<el-divider content-position="center">商品明细</el-divider>
<el-table :data="form.items" style="margin-bottom: 10px;">
<!-- <el-table-column type="selection" width="50" align="center" /> -->
<el-table-column label="序号" align="center" type="index" width="50"/>
<el-table-column label="商品图片" prop="goodsImg" width="80">
<template slot-scope="scope">
<el-image style="width: 70px; height: 70px" :src="scope.row.picPath"></el-image>
</template>
</el-table-column>
<el-table-column label="商品标题" prop="title" ></el-table-column>
<el-table-column label="规格" prop="skuPropertiesName" width="350"></el-table-column>
<el-table-column label="sku编码" prop="outerSkuId"></el-table-column>
<!-- <el-table-column label="单价" prop="goodsPrice"></el-table-column>-->
<el-table-column label="数量" prop="num"></el-table-column>
<!-- <el-table-column label="商品金额" prop="itemAmount"></el-table-column> -->
</el-table>
<el-form-item label="包裹尺寸" prop="height">
<el-input type="number" v-model.number="form.length" placeholder="长mm" style="width:90px" /> x
<el-input type="number" v-model.number="form.width" placeholder="宽mm" style="width:90px" /> x
<el-input type="number" v-model.number="form.height" placeholder="高mm" style="width:90px" />
</el-form-item>
<el-form-item label="包裹重量" prop="weight">
<el-input type="number" v-model.number="form.weight" placeholder="请输入包裹重量单位g" style="width:300px" />
</el-form-item>
<el-row>
<el-col>
<el-form-item label="物流公司" prop="shippingCompany">
<!-- <el-input v-model="form.shippingCompany" placeholder="请输入物流公司" style="width:300px" />-->
<el-select v-model="form.shippingCompany" filterable r placeholder="选择快递公司" style="width:300px">
<el-option v-for="item in logisticsList" :key="item.id" :label="item.name" :value="item.id">
<span style="float: left">{{ item.name }}</span>
<span style="float: right; color: #8492a6; font-size: 13px" >{{item.number}}</span>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="物流单号" prop="shippingNumber">
<el-input v-model="form.shippingNumber" placeholder="请输入物流单号" style="width:300px" />
</el-form-item>
<el-form-item label="物流费用" prop="shippingCost">
<el-input v-model="form.shippingCost" placeholder="请输入物流费用" style="width:300px" />
</el-form-item>
<el-form-item label="发货人" prop="shippingMan">
<el-input v-model="form.shippingMan" placeholder="请输入发货人" style="width:300px" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitShipForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<!-- 分配给供应商发货对话框 -->
<el-dialog title="分配给供应商发货" :visible.sync="allocateShipmentOpen" width="1100px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px" >
<el-descriptions title="订单信息">
<el-descriptions-item label="订单号">{{form.orderNum}}</el-descriptions-item>
<el-descriptions-item label="买家留言">
{{form.buyerMemo}}
</el-descriptions-item>
<el-descriptions-item label="备注">
{{form.remark}}
</el-descriptions-item>
<el-descriptions-item label="创建时间">
{{ parseTime(form.createTime) }}
</el-descriptions-item>
<el-descriptions-item label="收件人姓名">{{form.receiverName}}</el-descriptions-item>
<el-descriptions-item label="收件人手机号">{{form.receiverMobile}}</el-descriptions-item>
<el-descriptions-item label="省市区">{{form.province}}{{form.city}}{{form.town}}</el-descriptions-item>
<el-descriptions-item label="详细地址">{{form.address}}</el-descriptions-item>
</el-descriptions>
<el-divider content-position="center">商品明细</el-divider>
<el-table :data="form.items" style="margin-bottom: 10px;">
<!-- <el-table-column type="selection" width="50" align="center" /> -->
<el-table-column label="序号" align="center" type="index" width="50"/>
<el-table-column label="商品图片" prop="goodsImg" width="80">
<template slot-scope="scope">
<el-image style="width: 70px; height: 70px" :src="scope.row.picPath"></el-image>
</template>
</el-table-column>
<el-table-column label="商品标题" prop="title" ></el-table-column>
<el-table-column label="规格" prop="skuPropertiesName" width="350"></el-table-column>
<el-table-column label="sku编码" prop="outerSkuId"></el-table-column>
<!-- <el-table-column label="单价" prop="goodsPrice"></el-table-column>-->
<el-table-column label="数量" prop="num"></el-table-column>
<!-- <el-table-column label="商品金额" prop="itemAmount"></el-table-column> -->
</el-table>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitAllocateShipmentForm">分配给供应商发货</el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
import '@riophae/vue-treeselect/dist/vue-treeselect.css' import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import {listShop} from "@/api/shop/shop"; import {listLogisticsStatus, listShop} from "@/api/shop/shop";
import {listOrder} from "@/api/tao/order"; import {getOrder, listOrder,allocateShipmentOrder,manualShipmentOrder} from "@/api/tao/order";
import { import {
getWaybillAccountList, getWaybillAccountList,
pullWaybillAccount, pullWaybillAccount,
@ -208,6 +381,8 @@ export default {
return { return {
// //
loading: true, loading: true,
shipOpen: false,
allocateShipmentOpen: false,
// //
ids: [], ids: [],
shopList: [], shopList: [],
@ -239,6 +414,7 @@ export default {
// //
form: {}, form: {},
orderList: [], orderList: [],
logisticsList: [],
printerList: [], printerList: [],
deliverList: [], deliverList: [],
// //
@ -270,6 +446,8 @@ export default {
// //
cancel() { cancel() {
this.getCodeOpen = false; this.getCodeOpen = false;
this.shipOpen = false;
this.allocateShipmentOpen = false;
this.reset(); this.reset();
}, },
// //
@ -292,36 +470,12 @@ export default {
}, },
// //
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.ids = selection.map(item => item.tid) this.ids = selection.map(item => item.id)
this.single = selection.length !== 1 this.single = selection.length !== 1
this.multiple = !selection.length this.multiple = !selection.length
}, },
openWs() { openWs() {
const ws = new WebSocket('ws://127.0.0.1:13528'); console.log('开源版本暂不支持')
ws.onopen = () => {
console.log('与打印组件建立连接成功: ');
//
ws.send(JSON.stringify({
requestID: '12345',
cmd: 'getPrinters',
"version": "1.0"
}))
};
let obj = this.$modal;
ws.onmessage = (e) => {
const resp = JSON.parse(e.data || '{}')
if (resp.cmd === 'getPrinters') {
this.printerList = resp.printers
obj.msgSuccess("打印组件连接成功!");
console.log('打印机列表: ', resp.printers);
}
};
//
ws.onerror = function (error) {
obj.msgError("打印组件连接失败!请安装并启动菜鸟云打印组件!");
console.error('WebSocket error:', error);
// alert('WebSocket error occurred. Check the console for more details.');
};
}, },
// //
handleGetEwaybillCode() { handleGetEwaybillCode() {
@ -381,48 +535,7 @@ export default {
getWaybillPrintData({shopId: this.queryParams.shopId, ids: ids}).then(response => { getWaybillPrintData({shopId: this.queryParams.shopId, ids: ids}).then(response => {
console.log("======打印======", response.data) console.log("======打印======", response.data)
if (response.data) { if (response.data) {
const ws = new WebSocket('ws://127.0.0.1:13528'); console.log('===开源版本暂不支持====')
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.');
};
} }
}); });
@ -430,29 +543,69 @@ export default {
}, },
handleShipSend(){ handleShipSend(){
// this.$modal.msgError(""); // this.$modal.msgError("");
pushShipSend({shopId: this.queryParams.shopId, ids: ids}).then(response => { pushShipSend({shopId: this.queryParams.shopId, ids: this.ids}).then(response => {
this.$modal.msgSuccess("发货成功!"); this.$modal.msgSuccess("发货成功!");
this.getList() this.getList()
}) })
}, },
getUUID(len, radix) { //
var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''); allocateShipmentToSupplier(row){
var uuid = [], i; this.reset();
radix = radix || chars.length; const id = row.id || this.ids
if (len) { console.log('======',id)
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix]; getOrder(id).then(response => {
} else { this.form = response.data;
var r; this.allocateShipmentOpen = true;
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-'; // this.detailTitle = "";
uuid[14] = '4'; });
for (i = 0; i < 36; i++) { },
if (!uuid[i]) { //
r = 0 | Math.random() * 16; handleShip(row){
uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r]; this.reset();
} const id = row.id || this.ids
console.log('======',id)
getOrder(id).then(response => {
this.form = response.data;
this.form.length=0
this.form.width=0
this.form.height=0
this.form.weight=0.0
this.form.shippingCost=0.0
listLogisticsStatus({}).then(resp=>{
this.logisticsList = resp.rows
})
this.shipOpen = true;
// this.detailTitle = "";
});
},
//
submitShipForm(){
this.$refs["form"].validate(valid => {
if (valid) {
manualShipmentOrder(this.form).then(resp =>{
this.$modal.msgSuccess("手动发货成功");
this.shipOpen = false
this.getList()
})
} }
} })
return uuid.join(''); },
//
submitAllocateShipmentForm(){
this.$refs["form"].validate(valid => {
if (valid) {
allocateShipmentOrder(this.form).then(resp =>{
if(resp.code==200){
this.$modal.msgSuccess("分配发货成功");
this.allocateShipmentOpen = false
this.getList()
}else{
this.$modal.msgError(resp.msg);
}
})
}
})
} }
} }
}; };