|
@@ -210,7 +210,7 @@ public class AwaitSendController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 打单发货
|
|
|
+ * 打单发货,兼容多台打印机并发打印
|
|
|
* @param post
|
|
|
* @param orderId
|
|
|
* @param salesId
|
|
@@ -224,9 +224,12 @@ public class AwaitSendController {
|
|
|
@RequestParam("orderId") String orderId,
|
|
|
@RequestParam("salesId") Integer salesId,
|
|
|
HttpServletRequest request) {
|
|
|
+ // 检查订单状态
|
|
|
SalesOrder salesOrderInfo = salesOrderService.getSalesOrderById(salesId);
|
|
|
- // 替换
|
|
|
- post = salesOrderInfo.getSalesPostFirm();
|
|
|
+ if (salesOrderInfo.getSalesShippingStatus() != 11) {
|
|
|
+ return ResponseJson.getFAILURE().addResponseKeyValue("error","订单状态非通知配货,无法打印");
|
|
|
+ }
|
|
|
+ // 检查仓库的发货人信息
|
|
|
StoreShip storeShip = null;
|
|
|
if(salesOrderInfo.getSalesStoreId() != null){
|
|
|
storeShip = storeShipService.getStoreShipByStoreId(salesOrderInfo.getSalesStoreId());
|
|
@@ -238,14 +241,16 @@ public class AwaitSendController {
|
|
|
/*
|
|
|
* 组装数据
|
|
|
*/
|
|
|
+ post = salesOrderInfo.getSalesPostFirm();
|
|
|
EOrderRequestData eOrderRequestData = new EOrderRequestData();
|
|
|
eOrderRequestData.ShipperCode = (post);
|
|
|
- eOrderRequestData.OrderCode = (UUID.randomUUID().toString().replace("-", ""));
|
|
|
+ // 传递订单到第三方平台进行操作,如果出现当前订单打印失败了需要重新的,需要更改我们系统订单号
|
|
|
+ eOrderRequestData.OrderCode = salesOrderInfo.getSalesOrderId();
|
|
|
eOrderRequestData.PayType = (3);
|
|
|
eOrderRequestData.ExpType = ("1");
|
|
|
eOrderRequestData.Cost = (0.00);
|
|
|
eOrderRequestData.OtherCost = (0.0);
|
|
|
- eOrderRequestData.Remark = salesId + "-" + orderId;
|
|
|
+ eOrderRequestData.Remark = salesId.toString();
|
|
|
// 不同的快递公司需要做不同的处理
|
|
|
if (post.equalsIgnoreCase("EMS")) {
|
|
|
// 省内EMS
|
|
@@ -275,7 +280,6 @@ public class AwaitSendController {
|
|
|
eOrderRequestData.ExpType = ("3");
|
|
|
eOrderRequestData.ShipperCode = "DBL";
|
|
|
}
|
|
|
- LOGGER.info( "===salesId:" + salesId + "快递方式:" + post+ "订单编号:"+ orderId);
|
|
|
// 收件人信息
|
|
|
String[] addrs = salesOrderInfo.getSalesAddressInfo().split(" ");
|
|
|
if (addrs.length <= 3) {
|
|
@@ -318,13 +322,6 @@ public class AwaitSendController {
|
|
|
// 整个产品的重量
|
|
|
Double colorIsWeight = 0.00;
|
|
|
StringBuilder goodName = new StringBuilder();
|
|
|
- // 2018-12-21 增加打印面单需求:判断是否为维修机
|
|
|
- /*if (salesOrderInfo.getSalesCustomerId() != null) {
|
|
|
- CustomerInfo customerInfo = customerService.getCustomerInfo(salesOrderInfo.getSalesCustomerId());
|
|
|
- if (customerInfo != null && customerInfo.getCustomerIsSolve() != null && customerInfo.getCustomerIsSolve() == 4) {
|
|
|
- goodName.append("【原机返回】");
|
|
|
- }
|
|
|
- }*/
|
|
|
int Goodsquantity = 0;
|
|
|
for (SalesOrderItem temp : items) {
|
|
|
goodName.append(temp.getProductAbbreviation())
|
|
@@ -349,23 +346,24 @@ public class AwaitSendController {
|
|
|
eOrderRequestData.Quantity = (1);
|
|
|
eOrderRequestData.IsReturnPrintTemplate = (1);
|
|
|
try {
|
|
|
+ // 向第三方系统【快递鸟】提交订单数据,第三方系统会检测订单是否重复
|
|
|
String json = OrderUtils.orderOnlineByJson(eOrderRequestData);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(json);
|
|
|
boolean flag = jsonObject.getBoolean("Success");
|
|
|
if (flag) {
|
|
|
// 替换产品名称
|
|
|
json = json.replace(uuid, goodName.toString());
|
|
|
- // 获取电子面单成功
|
|
|
- String code = jsonObject.getJSONObject("Order").getString("LogisticCode");
|
|
|
-
|
|
|
- // 订单发货
|
|
|
+ // 订单发货 : 仅针对已经通知通知配货的订单(如果已发货,此处不修改对应的订单数据)
|
|
|
SalesOrder salesOrder = new SalesOrder();
|
|
|
- //salesOrder.setSalesPostFirm(eOrderRequestData.ShipperCode);
|
|
|
- salesOrder.setSalesPostNum(code);
|
|
|
+ salesOrder.setSalesPostNum(jsonObject.getJSONObject("Order").getString("LogisticCode"));
|
|
|
salesOrder.setSalesShippingStatus(1);
|
|
|
salesOrder.setSalesSendTime(new Date());
|
|
|
salesOrder.setSalesId(salesId);
|
|
|
- salesOrderService.updateSalesOrder(salesOrder);
|
|
|
+ salesOrder.setSalesOldOrderStatus(11);
|
|
|
+ Integer res = salesOrderService.updateSalesOrder(salesOrder);
|
|
|
+ if (res == null || res <= 0) {
|
|
|
+ return ResponseJson.getFAILURE().addResponseKeyValue("error", "订单状态非通知配货,无法打印");
|
|
|
+ }
|
|
|
// 保存HTML
|
|
|
String filePath = request.getServletContext().getRealPath("/common/");
|
|
|
File dir = new File(filePath + File.separator + "send_order");
|