商家异常订单手动发货功能新增
This commit is contained in:
parent
1112033ed8
commit
20cab88cf9
@ -67,6 +67,9 @@ public class ShopOrderBase implements Serializable {
|
||||
@ApiModelProperty(value = "订单状态(LIST):2011-待订单审核;2013-待财务审核;2020-待配货/待出库审核;2030-待发货;2040-已发货/待收货确认;2060-已完成/已签收;2070-已取消/已作废;")
|
||||
private Integer order_state_id;
|
||||
|
||||
@ApiModelProperty(value = "异常订单操作流程,0-可操作自行发货,1-可操作订单完成,2-订单完成不可操作")
|
||||
private String operate_flag;
|
||||
|
||||
// @ApiModelProperty(value = "easy支付id存储")
|
||||
// private String easy_pay_id;
|
||||
|
||||
|
||||
@ -93,4 +93,6 @@ public class MchOrderInfoDTO implements Serializable {
|
||||
private Integer distance;
|
||||
@ApiModelProperty(value = "是否禁止退款:1-是;2-否;")
|
||||
private Integer is_deny_return;
|
||||
@ApiModelProperty(value = "异常订单操作流程,0-可操作自行发货,1-可操作订单完成,2-订单完成不可操作")
|
||||
private String operate_flag;
|
||||
}
|
||||
|
||||
@ -15,6 +15,7 @@ import com.suisung.mall.common.modules.order.*;
|
||||
import com.suisung.mall.common.modules.order.dto.MchOrderInfoDTO;
|
||||
import com.suisung.mall.common.service.impl.BaseControllerImpl;
|
||||
import com.suisung.mall.common.utils.CheckUtil;
|
||||
import com.suisung.mall.common.utils.ContextUtil;
|
||||
import com.suisung.mall.common.utils.I18nUtil;
|
||||
import com.suisung.mall.shop.order.service.*;
|
||||
import io.swagger.annotations.Api;
|
||||
@ -308,7 +309,7 @@ public class ShopOrderBaseController extends BaseControllerImpl {
|
||||
@RequestMapping(value = "/mch/order/list", method = RequestMethod.POST)
|
||||
public CommonResult selectMchOrderPageList(@RequestBody JSONObject params) {
|
||||
// === 用户验证 ===
|
||||
UserDto userDto = getCurrentUser();
|
||||
UserDto userDto = ContextUtil.getCurrentUser();
|
||||
if (userDto == null) {
|
||||
return CommonResult.failed(ResultCode.NEED_LOGIN);
|
||||
}
|
||||
|
||||
@ -106,6 +106,18 @@ public class SFExpressController {
|
||||
return sfExpressApiService.notifyProductReady(params);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "商家自行发货", notes = "商家自行发货,顺丰不接单导致异常订单之后商家自行配送,手动发货")
|
||||
@RequestMapping(value = "/selDelivery", method = RequestMethod.POST)
|
||||
public CommonResult selDelivery(@RequestParam(name = "order_id", defaultValue = "") String orderId) {
|
||||
return sfExpressApiService.selDelivery(orderId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "商家配送完成", notes = "商家配送完成,顺丰不接单导致异常订单之后商家自行配送,手动配送完成")
|
||||
@RequestMapping(value = "/selFinishOrder", method = RequestMethod.POST)
|
||||
public CommonResult selFinishOrder(@RequestParam(name = "order_id", defaultValue = "") String orderId) {
|
||||
return sfExpressApiService.selFinishOrder(orderId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 顺丰同城订单状态监听 SSE 服务
|
||||
*
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
|
||||
package com.suisung.mall.shop.sfexpress.service;
|
||||
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.pojo.res.ThirdApiRes;
|
||||
import org.springframework.data.util.Pair;
|
||||
|
||||
@ -186,4 +187,20 @@ public interface SFExpressApiService {
|
||||
// * @return
|
||||
// */
|
||||
// void pushMessageToStoreEmployee(Integer storeId, String orderId, String message, String payloadJson);
|
||||
|
||||
/**
|
||||
* 商家自行配送发货
|
||||
* @param orderId
|
||||
* @return
|
||||
*/
|
||||
CommonResult selDelivery( String orderId);
|
||||
|
||||
/**
|
||||
* 商家手动完成订单
|
||||
* @param shopOrderId
|
||||
* @return
|
||||
*/
|
||||
CommonResult selFinishOrder(String shopOrderId);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -16,10 +16,13 @@ import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.api.StateCode;
|
||||
import com.suisung.mall.common.constant.CommonConstant;
|
||||
import com.suisung.mall.common.constant.SFExpressConstant;
|
||||
import com.suisung.mall.common.domain.UserDto;
|
||||
import com.suisung.mall.common.exception.ApiException;
|
||||
import com.suisung.mall.common.modules.order.ShopOrderBase;
|
||||
import com.suisung.mall.common.modules.order.ShopOrderItem;
|
||||
import com.suisung.mall.common.modules.store.ShopMchEntry;
|
||||
import com.suisung.mall.common.modules.store.ShopStoreSameCityTransportBase;
|
||||
@ -1069,6 +1072,7 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
|
||||
return new ThirdApiRes().success("success");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 接收顺丰订单完成回调
|
||||
*
|
||||
@ -1160,9 +1164,92 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
|
||||
return new ThirdApiRes().success("success");
|
||||
}
|
||||
|
||||
/**
|
||||
* 自行发货
|
||||
* @param orderId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public CommonResult selDelivery(String orderId) {
|
||||
ShopOrderBase shopOrderBase = checkedOrder(orderId);
|
||||
if(!shopOrderBase.getOperate_flag().equals("0")){
|
||||
return CommonResult.failed("该状态不允许发货操作");
|
||||
}
|
||||
Pair<Boolean, String> pair= wxOrderShippingService.uploadShippingInfoToWx(2,shopOrderBase.getOrder_id());
|
||||
if(pair.getFirst()){
|
||||
//完成订单后修改订单异常操作流程进入完成订单环节
|
||||
shopOrderBase.setOperate_flag("1");
|
||||
shopOrderBaseService.updateById(shopOrderBase);
|
||||
//出库扣减思迅库存star
|
||||
// RMK 第三方数据同步相关:redis 给这个商品减去对应的库存
|
||||
QueryWrapper<ShopOrderItem> itemQueryWrapper = new QueryWrapper<>();
|
||||
itemQueryWrapper.eq("order_id", orderId);
|
||||
List<ShopOrderItem> order_item_rows = shopOrderItemService.find(itemQueryWrapper);
|
||||
if(!order_item_rows.isEmpty()){
|
||||
for (ShopOrderItem shopOrderItem : order_item_rows) {
|
||||
Map<String, Integer> stockDeltaMap = new HashMap<>();
|
||||
String item_src_id= shopOrderItem.getItem_src_id();
|
||||
Integer order_item_quantity=shopOrderItem.getOrder_item_quantity();
|
||||
stockDeltaMap.put(item_src_id + "-" + shopOrderItem.getOrder_id(), -order_item_quantity);
|
||||
syncThirdDataService.incrProductStockToRedis(stockDeltaMap);
|
||||
}
|
||||
}
|
||||
//出库扣减思迅库存end
|
||||
}
|
||||
return CommonResult.success("操作成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 商家自行配送完成订单
|
||||
* @param shopOrderId
|
||||
*/
|
||||
public CommonResult selFinishOrder(String shopOrderId) {
|
||||
Integer orderStatus = StateCode.ORDER_STATE_RECEIVED; //已签收
|
||||
ShopOrderBase shopOrderBase = checkedOrder(shopOrderId);
|
||||
if(!shopOrderBase.getOperate_flag().equals("1")){
|
||||
return CommonResult.failed("该状态不允许完成订单操作");
|
||||
}
|
||||
// 送达后,发出催促微信用户确认收货通知 (同城配送不能调用微信的确认收货)
|
||||
wxOrderShippingService.notifyConfirmReceive(shopOrderBase.getOrder_id());
|
||||
shopOrderInfoService.changeOrderStatus(shopOrderId, orderStatus, 0, 0);
|
||||
//完成订单后修改订单异常操作流程
|
||||
shopOrderBase.setOperate_flag("2");
|
||||
shopOrderBaseService.updateById(shopOrderBase);
|
||||
return CommonResult.success("操作成功");
|
||||
}
|
||||
|
||||
|
||||
// 私有方法
|
||||
|
||||
/**
|
||||
* 校验订单是否正确
|
||||
* @param shopOrderId
|
||||
* @return
|
||||
*/
|
||||
private ShopOrderBase checkedOrder(String shopOrderId){
|
||||
if(StringUtils.isBlank(shopOrderId)){
|
||||
logger.info("订单号不能为空");
|
||||
throw new ApiException("订单号不能为空");
|
||||
}
|
||||
UserDto userDto= ContextUtil.getCurrentUser();
|
||||
if(userDto==null){
|
||||
logger.info("用户不能为空");
|
||||
throw new ApiException("用户不能为空");
|
||||
}
|
||||
if(userDto.getRole_id()!=2){
|
||||
throw new ApiException("用户无权限");
|
||||
}
|
||||
QueryWrapper<ShopOrderBase> shopOrderBaseQueryWrapper = new QueryWrapper<>();
|
||||
shopOrderBaseQueryWrapper.eq("order_id", shopOrderId);
|
||||
shopOrderBaseQueryWrapper.eq("store_id", Integer.valueOf(userDto.getStore_id()));
|
||||
List<ShopOrderBase> shopOrderBaseList= shopOrderBaseService.list(shopOrderBaseQueryWrapper);
|
||||
if(shopOrderBaseList.isEmpty()){
|
||||
logger.info("订单号不存在");
|
||||
throw new ApiException("订单号不存在");
|
||||
}
|
||||
return shopOrderBaseList.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成顺丰同城请求签名,参考官网:https://commit-openic.sf-express.com/#/apidoc
|
||||
*
|
||||
@ -1218,4 +1305,6 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
|
||||
|
||||
return JSONUtil.toBean(resultJSON, ShopStoreSfOrder.class);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -578,6 +578,7 @@
|
||||
<result property="order_shipping_fee_inner" column="order_shipping_fee_inner"/>
|
||||
<result property="lkl_fee" column="lkl_fee"/>
|
||||
<result property="packing_fee" column="packing_fee"/>
|
||||
<result property="operate_flag" column="operate_flag"/>
|
||||
<!--总计优惠金额 order_discount_amount + order_voucher_price + order_points_fee + order_adjust_fee-->
|
||||
<result property="total_discount_amount" column="total_discount_amount"/>
|
||||
<result property="order_income_amount" column="order_income_amount"/>
|
||||
@ -769,6 +770,7 @@
|
||||
ob.order_payment_amount,
|
||||
ob.currency_id,
|
||||
ob.order_state_id,
|
||||
ob.operate_flag,
|
||||
ST_Distance_Sphere(
|
||||
POINT(sb.store_longitude, sb.store_latitude),
|
||||
POINT(oda.da_longitude, oda.da_latitude)
|
||||
|
||||
3
sql/shop/dev/20251022_ddl.sql
Normal file
3
sql/shop/dev/20251022_ddl.sql
Normal file
@ -0,0 +1,3 @@
|
||||
alter table shop_order_base add column operate_flag varchar(1) not null default '0' comment '异常订单操作流程,0-可操作自行发货,1-可操作订单完成,2-订单完成不可操作';
|
||||
|
||||
update shop_order_base set operate_flag='2';
|
||||
Loading…
Reference in New Issue
Block a user