Browse Source

经销商订单物流支持修改类型

cup 3 years ago
parent
commit
5c422a91ce

+ 29 - 10
mp-admin/src/main/java/com/qs/mp/web/controller/api/admin/ChannelOrderMgrController.java

@@ -27,10 +27,7 @@ import com.qs.mp.common.annotation.Log;
 import com.qs.mp.common.core.domain.AjaxResult;
 import com.qs.mp.common.core.page.TableDataInfo;
 import com.qs.mp.common.domain.DeliveryCompany;
-import com.qs.mp.common.enums.BusinessType;
-import com.qs.mp.common.enums.DeliverTypeEnum;
-import com.qs.mp.common.enums.ErrorCodeEnum;
-import com.qs.mp.common.enums.TicketPkgStatusEnum;
+import com.qs.mp.common.enums.*;
 import com.qs.mp.common.service.IDeliveryCompanyService;
 import com.qs.mp.user.domain.UserDeliverOrder;
 import com.qs.mp.user.domain.UserDeliverOrderItem;
@@ -217,10 +214,12 @@ public class ChannelOrderMgrController extends BaseApiController {
 	@Log(title = "经销商订单发货单号修改", businessType = BusinessType.UPDATE)
 	@PostMapping("/ship/update")
 	@ApiOperation(value = "订单发货单号修改" , notes = "在订单发货页面提交")
+	@ApiResponses(
+			@ApiResponse(code = 200, message = "操作成功", response = AjaxResult.class)
+	)
 	@PreAuthorize("@ss.hasPermi('order:channel:ship')")
 	public AjaxResult updateShipInfo(@RequestBody ChannelOrderShipParam shipParam) {
-		if(null == shipParam || StringUtils.isBlank(shipParam.getOrderId())
-			|| null == shipParam.getDeliveryId() || StringUtils.isBlank(shipParam.getDeliveryFlowId())) {
+		if(null == shipParam || StringUtils.isBlank(shipParam.getOrderId())) {
 			return error(ErrorCodeEnum.ERROR_CODE_1001);
 		}
 
@@ -230,10 +229,30 @@ public class ChannelOrderMgrController extends BaseApiController {
 			return error(ErrorCodeEnum.ERROR_CODE_1001);
 		}
 
-		boolean rtn = channelOrderService.update(new LambdaUpdateWrapper<ChannelOrder>()
-				.set(ChannelOrder::getDeliveryId, shipParam.getDeliveryId())
-				.set(ChannelOrder::getDeliveryFlowId, shipParam.getDeliveryFlowId())
-				.eq(ChannelOrder::getOrderId, shipParam.getOrderId()));
+		Integer deliveryType = shipParam.getDeliveryType();
+		if (null == deliveryType) {
+			return error("物流类型参数为空");
+		}
+
+
+		boolean rtn = false;
+		if (DeliverTypeEnum.NO_DELIVER.getValue().equals(deliveryType)) {
+			// 无需物流,设置单号为空,物流公司为空
+			rtn = channelOrderService.update(new LambdaUpdateWrapper<ChannelOrder>()
+					.set(ChannelOrder::getDeliveryId, null)
+					.set(ChannelOrder::getDeliveryFlowId, null)
+					.set(ChannelOrder::getStatus, DeliverOrderStatusEnum.FINISHED)
+					.eq(ChannelOrder::getOrderId, shipParam.getOrderId()));
+
+		} else if (DeliverTypeEnum.DELIVER.getValue().equals(deliveryType)) {
+			// 快递发货,原逻辑
+			rtn = channelOrderService.update(new LambdaUpdateWrapper<ChannelOrder>()
+					.set(ChannelOrder::getDeliveryId, shipParam.getDeliveryId())
+					.set(ChannelOrder::getDeliveryFlowId, shipParam.getDeliveryFlowId())
+					.eq(ChannelOrder::getOrderId, shipParam.getOrderId()));
+		}
+
+
 		return rtn ? AjaxResult.success() : AjaxResult.error("修改失败");
 
 	}