Merge branch 'main' into dev
This commit is contained in:
commit
bb9f905303
@ -0,0 +1,53 @@
|
||||
package com.suisung.mall.common.modules.order;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 预约订单任务表
|
||||
* </p>
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("shop_order_booking")
|
||||
@ApiModel(value = "ShopOrderBooking对象", description = "预约订单任务表")
|
||||
public class ShopOrderBooking implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "自增Id")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "订单Id")
|
||||
private String order_id;
|
||||
|
||||
@ApiModelProperty(value = "Redis 任务键")
|
||||
private String task_key;
|
||||
|
||||
@ApiModelProperty(value = "执行时间戳(秒)")
|
||||
private Long run_at;
|
||||
|
||||
@ApiModelProperty(value = "预约送达时间戳(秒)")
|
||||
private Long booking_at;
|
||||
|
||||
@ApiModelProperty(value = "状态:1-有效(任务待执行);2-无效(任务已执行);")
|
||||
private Integer status = 1;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date created_at;
|
||||
|
||||
@ApiModelProperty(value = "更改时间")
|
||||
private Date updated_at;
|
||||
}
|
||||
@ -213,6 +213,9 @@ public class ShopOrderInfo implements Serializable {
|
||||
@ApiModelProperty(value = "预约送达截止时间,格式如:yyyy-MM-dd HH:mm:ss")
|
||||
private Date booking_end_time;
|
||||
|
||||
@ApiModelProperty(value = "预订单到达时间戳(秒)")
|
||||
private Long booking_at;
|
||||
|
||||
@ApiModelProperty(value = "新建时间")
|
||||
private Date created_at;
|
||||
|
||||
|
||||
@ -173,7 +173,7 @@ public class OrderPayedListener {
|
||||
|
||||
}
|
||||
|
||||
// 处理异常,不抛出,以免影响到主流程
|
||||
// 发送过推送消息,处理异常,不抛出,以免影响到主流程
|
||||
try {
|
||||
// 检查是否已发送过推送消息(幂等性检查)
|
||||
String pushFlagKey = RedisConstant.New_Order_Push_Flag_Key + orderId;
|
||||
|
||||
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2025. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.suisung.mall.shop.order.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.suisung.mall.common.modules.order.ShopOrderBooking;
|
||||
|
||||
public interface ShopOrderBookingMapper extends BaseMapper<ShopOrderBooking> {
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2025. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.suisung.mall.shop.order.service;
|
||||
|
||||
import com.suisung.mall.common.modules.order.ShopOrderBooking;
|
||||
import com.suisung.mall.core.web.service.IBaseService;
|
||||
|
||||
public interface ShopOrderBookingService extends IBaseService<ShopOrderBooking> {
|
||||
|
||||
|
||||
}
|
||||
@ -6638,6 +6638,7 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
||||
Date bookingEndTime = DateTimeUtils.tryParseDateTimeToDate(Convert.toStr(cart_data.get("booking_end_time")));
|
||||
if (CommonConstant.Order_Booking_State_YY.equals(bookingState) && bookingBeginTime != null && bookingEndTime != null) {
|
||||
info_row.setBooking_state(bookingState);
|
||||
info_row.setBooking_at(bookingBeginTime.getTime() / 1000); // 预订单到达时间戳(秒)
|
||||
info_row.setBooking_begin_time(bookingBeginTime);
|
||||
info_row.setBooking_end_time(bookingEndTime);
|
||||
}
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) 2025. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.suisung.mall.shop.order.service.impl;
|
||||
|
||||
import com.suisung.mall.common.modules.order.ShopOrderBooking;
|
||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||
import com.suisung.mall.shop.order.mapper.ShopOrderBookingMapper;
|
||||
import com.suisung.mall.shop.order.service.ShopOrderBookingService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ShopOrderBookingServiceImpl extends BaseServiceImpl<ShopOrderBookingMapper, ShopOrderBooking> implements ShopOrderBookingService {
|
||||
|
||||
}
|
||||
@ -440,7 +440,7 @@ public class ShopOrderInfoServiceImpl extends BaseServiceImpl<ShopOrderInfoMappe
|
||||
}
|
||||
|
||||
Integer times = orderInfo.getOrder_picked_notice_count() == null ? 0 : orderInfo.getOrder_picked_notice_count();
|
||||
if (times > 3) {
|
||||
if (times > 5) {
|
||||
return CommonResult.success("已通知配送人员,请稍候");
|
||||
}
|
||||
|
||||
@ -827,45 +827,55 @@ public class ShopOrderInfoServiceImpl extends BaseServiceImpl<ShopOrderInfoMappe
|
||||
* @param bookingState 预约配送状态
|
||||
* @param bookingBeginTimeStr 预约开始时间
|
||||
* @param bookingEndTimeStr 预约截止时间
|
||||
* @return
|
||||
* @return 验证结果Pair,第一个元素表示是否通过验证,第二个元素为提示信息
|
||||
*/
|
||||
@Override
|
||||
public Pair<Boolean, String> checkBookingOrderArgs(Integer storeId, Integer bookingState, String bookingBeginTimeStr, String bookingEndTimeStr) {
|
||||
// 1. 必填参数检查
|
||||
if (CheckUtil.isEmpty(storeId) || CheckUtil.isEmpty(bookingState)) {
|
||||
return Pair.of(false, "[预约订单校验] 缺少必要参数");
|
||||
}
|
||||
|
||||
// 2. 预约状态检查
|
||||
if (!CommonConstant.Order_Booking_State_YY.equals(bookingState)) {
|
||||
return Pair.of(true, "[预约订单校验] 非预订单,跳过验证");
|
||||
}
|
||||
|
||||
// 3. 时间格式检查
|
||||
if (StrUtil.hasBlank(bookingBeginTimeStr, bookingEndTimeStr)) {
|
||||
return Pair.of(false, "[预约订单校验] 预约时间不能为空");
|
||||
}
|
||||
|
||||
Date bookingBeginTime = DateTimeUtils.tryParseDateTimeToDate(bookingBeginTimeStr);
|
||||
Date bookingEndTime = DateTimeUtils.tryParseDateTimeToDate(bookingEndTimeStr);
|
||||
if (bookingBeginTime == null || bookingBeginTime == null) {
|
||||
if (bookingBeginTime == null || bookingEndTime == null) {
|
||||
return Pair.of(false, "[预约订单校验] 预约时间格式有误");
|
||||
}
|
||||
|
||||
// 验证开始时间是否早于结束时间
|
||||
// 4. 时间逻辑检查 - 开始时间不能晚于结束时间
|
||||
if (bookingBeginTime.after(bookingEndTime)) {
|
||||
return Pair.of(false, "[预约订单校验] 开始时间不能晚于截止时间");
|
||||
}
|
||||
|
||||
// 判断预约订单开始时间是否在店铺的营业时间段里?
|
||||
// 5. 店铺信息检查
|
||||
ShopStoreInfo shopStoreInfo = shopStoreInfoService.getShopStoreInfoByStoreId(storeId);
|
||||
if (shopStoreInfo == null) {
|
||||
return Pair.of(false, "[预约订单校验] 店铺信息有误");
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(shopStoreInfo.getStore_opening_hours()) || StrUtil.isBlank(shopStoreInfo.getStore_close_hours())) {
|
||||
return Pair.of(false, "[预约订单校验] 店铺营业时间未设置");
|
||||
return Pair.of(false, "[预约订单校验] 店铺营业时间未设置,请联系商家");
|
||||
}
|
||||
|
||||
// 6. 店铺营业时间检查
|
||||
if (!DateTimeUtils.isTimeInRange(shopStoreInfo.getStore_opening_hours(), shopStoreInfo.getStore_close_hours(), bookingBeginTime)) {
|
||||
return Pair.of(false, "[预约订单校验] 预约时间不在店铺营业时间内");
|
||||
return Pair.of(false, "[预约订单校验] 请在店铺营业时间内预约下单");
|
||||
}
|
||||
|
||||
// 7. 预约时间范围检查 - 仅能预约45分钟后的订单
|
||||
Date fortyFiveMinutesLater = DateUtil.offsetMinute(new Date(), 45);
|
||||
if (!bookingBeginTime.after(fortyFiveMinutesLater)) {
|
||||
return Pair.of(false, "[预约订单校验] 仅能预约45分后的订单");
|
||||
}
|
||||
|
||||
return Pair.of(true, "[预约订单校验] 成功");
|
||||
|
||||
@ -33,7 +33,7 @@ public class SFExpressAdminController {
|
||||
|
||||
@ApiOperation(value = "创建顺丰同城店铺", notes = "创建顺丰同城店铺")
|
||||
@RequestMapping(value = "/create-shop", method = RequestMethod.POST)
|
||||
public CommonResult createSfExpressShopNotify(@RequestBody JSONObject requestBody) {
|
||||
public CommonResult createSfExpressShop(@RequestBody JSONObject requestBody) {
|
||||
Pair<Boolean, String> result = sfExpressApiService.createSfExpressShop(requestBody.getLong("mch_id"), requestBody.getInt("store_id"));
|
||||
if (result.getFirst()) {
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
@ -42,4 +42,26 @@ public class SFExpressAdminController {
|
||||
}
|
||||
return CommonResult.failed(result.getSecond());
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "创建顺丰同城店铺", notes = "创建顺丰同城店铺")
|
||||
@RequestMapping(value = "/create-shop-inner", method = RequestMethod.POST)
|
||||
public CommonResult createSfExpressShopNotify(@RequestBody JSONObject requestBody) {
|
||||
Pair<Boolean, String> result = sfExpressApiService.createSfExpressShopInner(
|
||||
requestBody.getInt("store_id"),
|
||||
requestBody.getStr("shop_name"),
|
||||
requestBody.getStr("city_name"),
|
||||
requestBody.getStr("shop_address"),
|
||||
requestBody.getStr("contact_name"),
|
||||
requestBody.getStr("contact_phone"),
|
||||
requestBody.getStr("longitude"),
|
||||
requestBody.getStr("latitude")
|
||||
);
|
||||
if (result.getFirst()) {
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("shop_id", result.getSecond());
|
||||
return CommonResult.success(data, "创建成功!");
|
||||
}
|
||||
return CommonResult.failed(result.getSecond());
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,6 +42,23 @@ public interface SFExpressApiService {
|
||||
Pair<Boolean, String> createSfExpressShop(Integer storeId, String shopName, String cityName, String shopAddress, String contactName, String contactPhone, String longitude, String latitude);
|
||||
|
||||
|
||||
/**
|
||||
* 创建顺丰同城(普通型)店铺(直调顺丰同城的接口,脱离我们的业务)
|
||||
*
|
||||
* @param storeId 商家门店ID
|
||||
* @param shopName 店名
|
||||
* @param cityName 城市
|
||||
* @param shopAddress 店铺详细地址
|
||||
* @param contactName 店铺联系人
|
||||
* @param contactPhone 店铺电话
|
||||
* @param longitude 经度
|
||||
* @param latitude 纬度
|
||||
* @return Pair<Boolean, String> 第一个元素表示是否成功,第二个元素表示结果信息或错误信息
|
||||
*/
|
||||
Pair<Boolean, String> createSfExpressShopInner(Integer storeId, String shopName, String cityName,
|
||||
String shopAddress, String contactName, String contactPhone,
|
||||
String longitude, String latitude);
|
||||
|
||||
/**
|
||||
* 创建顺丰同城店铺-连锁店铺回调
|
||||
*
|
||||
@ -190,13 +207,15 @@ public interface SFExpressApiService {
|
||||
|
||||
/**
|
||||
* 商家自行配送发货
|
||||
*
|
||||
* @param orderId
|
||||
* @return
|
||||
*/
|
||||
CommonResult selDelivery( String orderId);
|
||||
CommonResult selDelivery(String orderId);
|
||||
|
||||
/**
|
||||
* 商家手动完成订单
|
||||
*
|
||||
* @param shopOrderId
|
||||
* @return
|
||||
*/
|
||||
|
||||
@ -24,7 +24,6 @@ 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.product.ShopProductItem;
|
||||
import com.suisung.mall.common.modules.store.ShopMchEntry;
|
||||
import com.suisung.mall.common.modules.store.ShopStoreSameCityTransportBase;
|
||||
import com.suisung.mall.common.modules.store.ShopStoreSfOrder;
|
||||
@ -37,7 +36,6 @@ import com.suisung.mall.shop.order.service.ShopOrderBaseService;
|
||||
import com.suisung.mall.shop.order.service.ShopOrderInfoService;
|
||||
import com.suisung.mall.shop.order.service.ShopOrderItemService;
|
||||
import com.suisung.mall.shop.order.service.ShopOrderReturnService;
|
||||
import com.suisung.mall.shop.product.service.ShopProductItemService;
|
||||
import com.suisung.mall.shop.sfexpress.service.SFExpressApiService;
|
||||
import com.suisung.mall.shop.store.service.ShopMchEntryService;
|
||||
import com.suisung.mall.shop.store.service.ShopStoreSameCityTransportBaseService;
|
||||
@ -59,8 +57,6 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.suisung.mall.common.utils.I18nUtil._;
|
||||
|
||||
@Service
|
||||
public class SFExpressApiServiceImpl implements SFExpressApiService {
|
||||
private static final Logger logger = LoggerFactory.getLogger(SFExpressApiServiceImpl.class);
|
||||
@ -116,9 +112,6 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
|
||||
@Autowired
|
||||
private ShopOrderItemService shopOrderItemService;
|
||||
|
||||
@Autowired
|
||||
private ShopProductItemService shopProductItemService;
|
||||
|
||||
/**
|
||||
* 创建顺丰同店铺-连锁店铺
|
||||
*
|
||||
@ -346,6 +339,84 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建顺丰同城(普通型)店铺(直调顺丰同城的接口,脱离我们的业务)
|
||||
*
|
||||
* @param storeId 商家门店ID
|
||||
* @param shopName 店名
|
||||
* @param cityName 城市
|
||||
* @param shopAddress 店铺详细地址
|
||||
* @param contactName 店铺联系人
|
||||
* @param contactPhone 店铺电话
|
||||
* @param longitude 经度
|
||||
* @param latitude 纬度
|
||||
* @return Pair<Boolean, String> 第一个元素表示是否成功,第二个元素表示结果信息或错误信息
|
||||
*/
|
||||
@Override
|
||||
public Pair<Boolean, String> createSfExpressShopInner(Integer storeId, String shopName, String cityName,
|
||||
String shopAddress, String contactName, String contactPhone,
|
||||
String longitude, String latitude) {
|
||||
logger.info("开始创建顺丰同城店铺, storeId: {}", storeId);
|
||||
|
||||
try {
|
||||
// 1. 验证必要参数
|
||||
if (CheckUtil.isEmpty(storeId) || StringUtils.isAnyBlank(shopName, shopAddress, contactName, contactPhone)) {
|
||||
logger.error("创建顺丰店铺,缺少必要参数!storeId:{},shopName:{},shopAddress:{},contactName:{},contactPhone:{}", storeId, shopName, shopAddress, contactName, contactPhone);
|
||||
return Pair.of(false, "创建顺丰店铺,缺少必要参数!");
|
||||
}
|
||||
|
||||
// 4. 构建请求参数
|
||||
Map<String, Object> params = buildCommonParams();
|
||||
params.put("supplier_id", supplierId); // 店铺所属商家id
|
||||
params.put("out_shop_id", storeId); // 外部店铺ID
|
||||
params.put("shop_name", shopName); // 店铺名称
|
||||
params.put("city_name", cityName); // 城市名称
|
||||
params.put("shop_product_types", "33"); // 33:便利店
|
||||
params.put("shop_type", 1); // 店铺类型: 1-普通型 2-平台型
|
||||
params.put("shop_address", shopAddress); // 店铺地址
|
||||
params.put("longitude", longitude); // 经度
|
||||
params.put("latitude", latitude); // 纬度
|
||||
params.put("shop_contact_name", contactName); // 联系人姓名
|
||||
params.put("shop_contact_phone", contactPhone); // 联系电话
|
||||
|
||||
logger.debug("开始创建顺丰店铺,参数:{}", params);
|
||||
|
||||
// 5. 发送请求到顺丰接口
|
||||
String paramJSON = JsonUtil.toJSONString(params);
|
||||
String sendUrl = buildUrl("createShop", paramJSON);
|
||||
String responseStr = HttpUtil.post(sendUrl, paramJSON);
|
||||
logger.debug("创建顺丰店铺结果:{}", responseStr);
|
||||
if (StrUtil.isBlank(responseStr)) {
|
||||
logger.error("创建顺丰店铺异常,无返回值!");
|
||||
return Pair.of(false, "创建顺丰店铺异常,无返回值!");
|
||||
}
|
||||
|
||||
ThirdApiRes apiRes = JSONUtil.toBean(responseStr, ThirdApiRes.class);
|
||||
if (apiRes == null) {
|
||||
logger.error("创建顺丰店铺异常,返回值有误!!");
|
||||
return Pair.of(false, "创建顺丰店铺异常,返回值有误!");
|
||||
}
|
||||
|
||||
// 6. 检查接口调用结果
|
||||
if (!apiRes.getError_code().equals(0) || apiRes.getResult() == null) {
|
||||
String errMsg = apiRes.getError_code().equals(0) ? "创建顺丰店铺失败!" : "创建顺丰店铺失败: " + apiRes.getError_msg();
|
||||
logger.error("创建顺丰店铺失败: {}", errMsg);
|
||||
return Pair.of(false, errMsg);
|
||||
}
|
||||
|
||||
// 7. 提取顺丰店铺ID并更新数据库
|
||||
JSONObject result = (JSONObject) apiRes.getResult();
|
||||
String sfShopId = result.getStr("shop_id");
|
||||
|
||||
logger.info("成功创建顺丰店铺,店铺ID: {}", sfShopId);
|
||||
return Pair.of(true, sfShopId);
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("创建顺丰同城店铺时发生异常: ", e);
|
||||
return Pair.of(false, "创建顺丰同城店铺时发生异常: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建顺丰同城店铺异步通知回调
|
||||
*
|
||||
@ -1027,17 +1098,14 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
|
||||
//出库扣减思迅库存star
|
||||
// RMK 第三方数据同步相关:redis 给这个商品减去对应的库存
|
||||
QueryWrapper<ShopOrderItem> itemQueryWrapper = new QueryWrapper<>();
|
||||
String order_id=shopStoreSfOrder.getShop_order_id();
|
||||
String order_id = shopStoreSfOrder.getShop_order_id();
|
||||
itemQueryWrapper.eq("order_id", order_id);
|
||||
List<ShopOrderItem> order_item_rows = shopOrderItemService.find(itemQueryWrapper);
|
||||
if(picking(order_item_rows)){
|
||||
logger.info("顺丰发货商品扣减库存成功");
|
||||
}
|
||||
if(!order_item_rows.isEmpty()){
|
||||
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();
|
||||
String item_src_id = shopOrderItem.getItem_src_id();
|
||||
Integer order_item_quantity = shopOrderItem.getOrder_item_quantity();
|
||||
stockDeltaMap.put(item_src_id + "-" + shopStoreSfOrder.getShop_order_id(), -order_item_quantity);
|
||||
syncThirdDataService.incrProductStockToRedis(stockDeltaMap);
|
||||
}
|
||||
@ -1176,17 +1244,18 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
|
||||
|
||||
/**
|
||||
* 自行发货
|
||||
*
|
||||
* @param orderId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public CommonResult selDelivery(String orderId) {
|
||||
ShopOrderBase shopOrderBase = checkedOrder(orderId);
|
||||
if(!shopOrderBase.getOperate_flag().equals("0")){
|
||||
if (!shopOrderBase.getOperate_flag().equals("0")) {
|
||||
return CommonResult.failed("该状态不允许发货操作");
|
||||
}
|
||||
Pair<Boolean, String> pair= wxOrderShippingService.uploadShippingInfoToWx(2,shopOrderBase.getOrder_id());
|
||||
if(pair.getFirst()){
|
||||
Pair<Boolean, String> pair = wxOrderShippingService.uploadShippingInfoToWx(2, shopOrderBase.getOrder_id());
|
||||
if (pair.getFirst()) {
|
||||
//完成订单后修改订单异常操作流程进入完成订单环节
|
||||
shopOrderBase.setOperate_flag("1");
|
||||
shopOrderBaseService.updateById(shopOrderBase);
|
||||
@ -1195,14 +1264,11 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
|
||||
QueryWrapper<ShopOrderItem> itemQueryWrapper = new QueryWrapper<>();
|
||||
itemQueryWrapper.eq("order_id", orderId);
|
||||
List<ShopOrderItem> order_item_rows = shopOrderItemService.find(itemQueryWrapper);
|
||||
if(picking(order_item_rows)){
|
||||
logger.info("自行发货商品扣减库存成功");
|
||||
}
|
||||
if(!order_item_rows.isEmpty()){
|
||||
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();
|
||||
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);
|
||||
}
|
||||
@ -1215,13 +1281,13 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
|
||||
|
||||
/**
|
||||
* 商家自行配送完成订单
|
||||
*
|
||||
* @param shopOrderId
|
||||
*/
|
||||
@Override
|
||||
public CommonResult selFinishOrder(String shopOrderId) {
|
||||
Integer orderStatus = StateCode.ORDER_STATE_RECEIVED; //已签收
|
||||
ShopOrderBase shopOrderBase = checkedOrder(shopOrderId);
|
||||
if(!shopOrderBase.getOperate_flag().equals("1")){
|
||||
if (!shopOrderBase.getOperate_flag().equals("1")) {
|
||||
return CommonResult.failed("该状态不允许完成订单操作");
|
||||
}
|
||||
// 送达后,发出催促微信用户确认收货通知 (同城配送不能调用微信的确认收货)
|
||||
@ -1233,62 +1299,33 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
|
||||
return CommonResult.success("操作成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据订单列表扣除商品库存
|
||||
* @param order_item_rows
|
||||
* @return
|
||||
*/
|
||||
public boolean picking(List<ShopOrderItem> order_item_rows){
|
||||
logger.info("出库商品扣除库存--开始");
|
||||
List<ShopProductItem> updateProductItems = new ArrayList<>();
|
||||
for (ShopOrderItem shopOrderItem : order_item_rows) {
|
||||
Long item_id = Long.valueOf(shopOrderItem.getItem_src_id());
|
||||
ShopProductItem productItem = shopProductItemService.get(item_id);
|
||||
if (productItem == null) {
|
||||
throw new ApiException(String.format(_("SKU【%s】不存在!"), item_id));
|
||||
}
|
||||
Integer item_change_quantity=shopOrderItem.getOrder_item_quantity()*-1;
|
||||
Integer quantity = productItem.getItem_quantity() + item_change_quantity;
|
||||
if (quantity.compareTo(0) < 0) {
|
||||
quantity = 0;
|
||||
}
|
||||
productItem.setItem_quantity(quantity);
|
||||
//防止负数
|
||||
Integer tmp_quantity = productItem.getItem_quantity_frozen() + item_change_quantity.intValue();
|
||||
if (tmp_quantity.compareTo(0) < 0) {
|
||||
tmp_quantity = 0;
|
||||
}
|
||||
productItem.setItem_quantity_frozen(tmp_quantity);
|
||||
updateProductItems.add(productItem);
|
||||
}
|
||||
return shopProductItemService.updateBatchById(updateProductItems,updateProductItems.size());
|
||||
}
|
||||
|
||||
// 私有方法
|
||||
|
||||
/**
|
||||
* 校验订单是否正确
|
||||
*
|
||||
* @param shopOrderId
|
||||
* @return
|
||||
*/
|
||||
private ShopOrderBase checkedOrder(String shopOrderId){
|
||||
if(StringUtils.isBlank(shopOrderId)){
|
||||
private ShopOrderBase checkedOrder(String shopOrderId) {
|
||||
if (StringUtils.isBlank(shopOrderId)) {
|
||||
logger.info("订单号不能为空");
|
||||
throw new ApiException("订单号不能为空");
|
||||
}
|
||||
UserDto userDto= ContextUtil.getCurrentUser();
|
||||
if(userDto==null){
|
||||
UserDto userDto = ContextUtil.getCurrentUser();
|
||||
if (userDto == null) {
|
||||
logger.info("用户不能为空");
|
||||
throw new ApiException("用户不能为空");
|
||||
}
|
||||
if(userDto.getRole_id()!=2){
|
||||
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()){
|
||||
List<ShopOrderBase> shopOrderBaseList = shopOrderBaseService.list(shopOrderBaseQueryWrapper);
|
||||
if (shopOrderBaseList.isEmpty()) {
|
||||
logger.info("订单号不存在");
|
||||
throw new ApiException("订单号不存在");
|
||||
}
|
||||
|
||||
@ -184,8 +184,8 @@ feieyun:
|
||||
sf-express:
|
||||
# 顺丰同城 api 接口配置
|
||||
dev_id: 1715091463
|
||||
# 桂平顺丰平台商家id
|
||||
supplier_id: 2273453450129
|
||||
# 桂平顺丰平台商家id 2273453450129
|
||||
supplier_id: 2269768012593
|
||||
appid: 1715091463
|
||||
appkey: 47466ae69c530f831395e1bc405639fb
|
||||
# dev_id: 1715091463
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.suisung.mall.shop.order.mapper.ShopOrderBookingMapper">
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
*
|
||||
</sql>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue
Block a user