|
@@ -7,6 +7,7 @@ import com.caimei365.order.mapper.BaseMapper;
|
|
|
import com.caimei365.order.mapper.OrderCommonMapper;
|
|
|
import com.caimei365.order.mapper.ShipMapper;
|
|
|
import com.caimei365.order.model.ResponseJson;
|
|
|
+import com.caimei365.order.model.dto.LogisticsBatchDto;
|
|
|
import com.caimei365.order.model.dto.LogisticsDto;
|
|
|
import com.caimei365.order.model.po.LogisticsBatchPo;
|
|
|
import com.caimei365.order.model.po.LogisticsInformationPo;
|
|
@@ -168,7 +169,7 @@ public class ShipServiceImpl implements ShipService {
|
|
|
* @param logisticsDto {
|
|
|
* shopOrderId: 子订单Id,
|
|
|
* note: 备注信息,
|
|
|
- * image: 图片备注以||隔开,
|
|
|
+ * image: 图片备注以##隔开,
|
|
|
* logistics:[ // 物流信息
|
|
|
* {number:'45646464646',logisticsCompanyName:'顺丰物流',logisticsCompanyCode:'物流英文代码'},
|
|
|
* {number:'45646464646',logisticsCompanyName:'顺丰物流',logisticsCompanyCode:'物流英文代码'}
|
|
@@ -180,9 +181,9 @@ public class ShipServiceImpl implements ShipService {
|
|
|
* }
|
|
|
*/
|
|
|
@Override
|
|
|
- public ResponseJson<Integer> addLogistics(LogisticsDto logisticsDto) {
|
|
|
- JSONArray logistics = null;
|
|
|
- JSONArray products = null;
|
|
|
+ public ResponseJson<Integer> addDelivery(LogisticsDto logisticsDto) {
|
|
|
+ JSONArray logistics;
|
|
|
+ JSONArray products;
|
|
|
try {
|
|
|
logistics = parseArray(logisticsDto.getLogistics());
|
|
|
products = parseArray(logisticsDto.getProducts());
|
|
@@ -438,6 +439,125 @@ public class ShipServiceImpl implements ShipService {
|
|
|
recordVo.setNotShippedNum(orderProduct.getNotOutStore() - actualCancelNum);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 供应商撤销发货
|
|
|
+ *
|
|
|
+ * @param logisticsBatchId 发货物流批次Id
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson<Void> cancelDelivery(Integer logisticsBatchId) {
|
|
|
+ // 发货物流批次
|
|
|
+ LogisticsBatchVo logisticsBatch = shipMapper.getLogisticsBatchById(logisticsBatchId);
|
|
|
+ if (null == logisticsBatch) {
|
|
|
+ return ResponseJson.error("物流异常,logisticsBatchID:" + logisticsBatchId, null);
|
|
|
+ }
|
|
|
+ // 获取发货物流记录
|
|
|
+ List<LogisticsRecordVo> recordList = orderCommonMapper.getLogisticsRecord(logisticsBatch.getShopOrderId(), logisticsBatch.getId());
|
|
|
+ // 本批次发货数量
|
|
|
+ int num = 0;
|
|
|
+ for (LogisticsRecordVo logisticsRecord : recordList) {
|
|
|
+ num += logisticsRecord.getNum();
|
|
|
+ // 订单商品修改
|
|
|
+ OrderProductVo orderProduct = shipMapper.getOrderProductById(logisticsRecord.getOrderProductId());
|
|
|
+ int notOutStore = orderProduct.getNotOutStore() + logisticsRecord.getNum();
|
|
|
+ // 保存订单商品未出库数量
|
|
|
+ shipMapper.updateNotOutStore(orderProduct.getOrderProductId(), notOutStore);
|
|
|
+ }
|
|
|
+ ShopOrderVo shopOrder = shipMapper.getShopOrder(logisticsBatch.getShopOrderId());
|
|
|
+ if (null == shopOrder) {
|
|
|
+ return ResponseJson.error("订单异常,shopOrderId:" + logisticsBatch.getShopOrderId(), null);
|
|
|
+ }
|
|
|
+ // 子订单修改
|
|
|
+ int outStoreNum = shopOrder.getOutStoreNum() - num;
|
|
|
+ shopOrder.setOutStoreNum(outStoreNum);
|
|
|
+ int productNum = shopOrder.getPresentNum() + shopOrder.getItemCount();
|
|
|
+ if (productNum > shopOrder.getOutStoreNum() && shopOrder.getOutStoreNum() > 0) {
|
|
|
+ shopOrder.setSendOutStatus(2);
|
|
|
+ } else if (productNum == shopOrder.getOutStoreNum()) {
|
|
|
+ shopOrder.setSendOutStatus(3);
|
|
|
+ } else if (shopOrder.getOutStoreNum() == 0) {
|
|
|
+ shopOrder.setSendOutStatus(1);
|
|
|
+ } else {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return ResponseJson.error("发货数量异常", null);
|
|
|
+ }
|
|
|
+ // 修改子订单
|
|
|
+ shipMapper.updateShopOrderShip(shopOrder.getShopOrderId(), shopOrder.getOutStoreNum(), shopOrder.getOutStoreTimes(), shopOrder.getSendOutStatus());
|
|
|
+ // 修改主订单发货状态
|
|
|
+ setMainOrderStatus(shopOrder);
|
|
|
+ // 撤销发货
|
|
|
+ shipMapper.deleteLogisticsBatchByBatchId(logisticsBatchId);
|
|
|
+ shipMapper.deleteLogisticsRecordByBatchId(logisticsBatchId);
|
|
|
+ shipMapper.deleteLogisticsInfoByBatchId(logisticsBatchId);
|
|
|
+ return ResponseJson.success(null);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发货记录-添加物流
|
|
|
+ *
|
|
|
+ * @param logisticsBatchDto {
|
|
|
+ * logisticsBatchId: 发货批次表Id,
|
|
|
+ * remark: 备注,
|
|
|
+ * remarkImage: 图片备注,
|
|
|
+ * logistics:[ // 物流信息
|
|
|
+ * {number:'45646464646',logisticsCompanyName:'顺丰物流',logisticsCompanyCode:'物流英文代码'},
|
|
|
+ * {number:'45646464646',logisticsCompanyName:'顺丰物流',logisticsCompanyCode:'物流英文代码'}
|
|
|
+ * ]
|
|
|
+ * }
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson<Void> addLogisticsInfo(LogisticsBatchDto logisticsBatchDto) {
|
|
|
+ // 发货物流批次
|
|
|
+ LogisticsBatchVo logisticsBatch = shipMapper.getLogisticsBatchById(logisticsBatchDto.getLogisticsBatchId());
|
|
|
+ if (null == logisticsBatch) {
|
|
|
+ return ResponseJson.error("物流批次异常,logisticsBatchID:" + logisticsBatchDto.getLogisticsBatchId(), null);
|
|
|
+ }
|
|
|
+ /* logistics:[ // 物流跟踪信息
|
|
|
+ * {number:'45646464646',logisticsCompanyName:'顺丰物流',logisticsCompanyCode:'物流英文代码'},
|
|
|
+ * {number:'45646464646',logisticsCompanyName:'顺丰物流',logisticsCompanyCode:'物流英文代码'}]
|
|
|
+ */
|
|
|
+ JSONArray logistics;
|
|
|
+ try {
|
|
|
+ logistics = parseArray(logisticsBatchDto.getLogistics());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info("发货参数:" + logisticsBatchDto.toString());
|
|
|
+ log.error("【添加物流】>>>发货参数解析异常try-catch:", e);
|
|
|
+ return ResponseJson.error("添加物流参数解析异常!", null);
|
|
|
+ }
|
|
|
+ if (logistics.isEmpty()) {
|
|
|
+ return ResponseJson.error("添加物流参数异常!", null);
|
|
|
+ }
|
|
|
+ Date date = new Date();
|
|
|
+ for (Object logisticObj: logistics) {
|
|
|
+ JSONObject logistic = (JSONObject) logisticObj;
|
|
|
+ String number = (String) logistic.get("number");
|
|
|
+ String logisticsCompanyName = (String) logistic.get("logisticsCompanyName");
|
|
|
+ String logisticsCompanyCode = (String) logistic.get("logisticsCompanyCode");
|
|
|
+ if (StringUtils.isBlank(number) || StringUtils.isBlank(logisticsCompanyName) || StringUtils.isBlank(logisticsCompanyCode)) {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return ResponseJson.error("物流信息参数异常!", null);
|
|
|
+ }
|
|
|
+ LogisticsInformationPo logisticsInformation = new LogisticsInformationPo();
|
|
|
+ logisticsInformation.setLogisticsBatchId(logisticsBatch.getId());
|
|
|
+ logisticsInformation.setType("1");
|
|
|
+ logisticsInformation.setShopOrderId(logisticsBatch.getShopOrderId());
|
|
|
+ logisticsInformation.setOrderId(logisticsBatch.getOrderId());
|
|
|
+ logisticsInformation.setNu(number);
|
|
|
+ logisticsInformation.setLogisticsCompanyName(logisticsCompanyName);
|
|
|
+ logisticsInformation.setLogisticsCompanyCode(logisticsCompanyCode);
|
|
|
+ logisticsInformation.setShopId(logisticsBatch.getShopId());
|
|
|
+ logisticsInformation.setUpdateDate(date);
|
|
|
+ // 保存 物流跟踪信息
|
|
|
+ shipMapper.insertLogisticsInformation(logisticsInformation);
|
|
|
+ }
|
|
|
+ logisticsBatch.setId(logisticsBatchDto.getLogisticsBatchId());
|
|
|
+ logisticsBatch.setRemarkImage(logisticsBatchDto.getRemarkImage());
|
|
|
+ logisticsBatch.setRemark(logisticsBatchDto.getRemark());
|
|
|
+ // 更新物流批次
|
|
|
+ shipMapper.updateLogisticsBatchRemark(logisticsBatch);
|
|
|
+ return ResponseJson.success(null);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 供应商查看物流
|
|
|
*
|
|
@@ -496,58 +616,7 @@ public class ShipServiceImpl implements ShipService {
|
|
|
return ResponseJson.success(null);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 供应商撤销发货
|
|
|
- *
|
|
|
- * @param logisticsBatchId 发货物流批次Id
|
|
|
- */
|
|
|
- @Override
|
|
|
- public ResponseJson<Void> cancelDelivery(Integer logisticsBatchId) {
|
|
|
- // 发货物流批次
|
|
|
- LogisticsBatchVo logisticsBatch = shipMapper.getLogisticsBatchById(logisticsBatchId);
|
|
|
- if (null == logisticsBatch) {
|
|
|
- return ResponseJson.error("物流异常,logisticsBatchID:" + logisticsBatchId, null);
|
|
|
- }
|
|
|
- // 获取发货物流记录
|
|
|
- List<LogisticsRecordVo> recordList = orderCommonMapper.getLogisticsRecord(logisticsBatch.getShopOrderId(), logisticsBatch.getId());
|
|
|
- // 本批次发货数量
|
|
|
- int num = 0;
|
|
|
- for (LogisticsRecordVo logisticsRecord : recordList) {
|
|
|
- num += logisticsRecord.getNum();
|
|
|
- // 订单商品修改
|
|
|
- OrderProductVo orderProduct = shipMapper.getOrderProductById(logisticsRecord.getOrderProductId());
|
|
|
- int notOutStore = orderProduct.getNotOutStore() + logisticsRecord.getNum();
|
|
|
- // 保存订单商品未出库数量
|
|
|
- shipMapper.updateNotOutStore(orderProduct.getOrderProductId(), notOutStore);
|
|
|
- }
|
|
|
- ShopOrderVo shopOrder = shipMapper.getShopOrder(logisticsBatch.getShopOrderId());
|
|
|
- if (null == shopOrder) {
|
|
|
- return ResponseJson.error("订单异常,shopOrderId:" + logisticsBatch.getShopOrderId(), null);
|
|
|
- }
|
|
|
- // 子订单修改
|
|
|
- int outStoreNum = shopOrder.getOutStoreNum() - num;
|
|
|
- shopOrder.setOutStoreNum(outStoreNum);
|
|
|
- int productNum = shopOrder.getPresentNum() + shopOrder.getItemCount();
|
|
|
- if (productNum > shopOrder.getOutStoreNum() && shopOrder.getOutStoreNum() > 0) {
|
|
|
- shopOrder.setSendOutStatus(2);
|
|
|
- } else if (productNum == shopOrder.getOutStoreNum()) {
|
|
|
- shopOrder.setSendOutStatus(3);
|
|
|
- } else if (shopOrder.getOutStoreNum() == 0) {
|
|
|
- shopOrder.setSendOutStatus(1);
|
|
|
- } else {
|
|
|
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
- return ResponseJson.error("发货数量异常", null);
|
|
|
- }
|
|
|
- // 修改子订单
|
|
|
- shipMapper.updateShopOrderShip(shopOrder.getShopOrderId(), shopOrder.getOutStoreNum(), shopOrder.getOutStoreTimes(), shopOrder.getSendOutStatus());
|
|
|
- // 修改主订单发货状态
|
|
|
- setMainOrderStatus(shopOrder);
|
|
|
- // 撤销发货
|
|
|
- shipMapper.deleteLogisticsBatchByBatchId(logisticsBatchId);
|
|
|
- shipMapper.deleteLogisticsRecordByBatchId(logisticsBatchId);
|
|
|
- shipMapper.deleteLogisticsInfoByBatchId(logisticsBatchId);
|
|
|
- return ResponseJson.success(null);
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|