diff --git a/mall-common/src/main/java/com/suisung/mall/common/utils/SseEmitterUtil.java b/mall-common/src/main/java/com/suisung/mall/common/utils/SseEmitterUtil.java index bdd5cdec..2b2bf007 100644 --- a/mall-common/src/main/java/com/suisung/mall/common/utils/SseEmitterUtil.java +++ b/mall-common/src/main/java/com/suisung/mall/common/utils/SseEmitterUtil.java @@ -23,7 +23,7 @@ public class SseEmitterUtil { */ public static SseEmitter connect(String channel) { //设置超时时间,0表示不过期。默认30秒,超过时间未完成会抛出异常:AsyncRequestTimeoutException - SseEmitter sseEmitter = new SseEmitter(1200000L); // 20分钟 + SseEmitter sseEmitter = new SseEmitter(1800000L); // 30分钟 try { //注册回调:完成、失败、超时 sseEmitter.onCompletion(completionCallBack(channel)); diff --git a/mall-gateway/src/main/resources/application.yml b/mall-gateway/src/main/resources/application.yml index a462424f..0d2e73f5 100644 --- a/mall-gateway/src/main/resources/application.yml +++ b/mall-gateway/src/main/resources/application.yml @@ -83,6 +83,7 @@ secure: - "/shop/sf-express/cancel-order/notify" - "/shop/sf-express/rider-order-status/notify" - "/shop/sf-express/order-complete/notify" + - "/mobile/shop/sf-express/order/status/listening/**" - "/admin/shop/open/**" - "/admin/account/open/**" - "/esProduct/**" diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/order/controller/mobile/UserReturnController.java b/mall-shop/src/main/java/com/suisung/mall/shop/order/controller/mobile/UserReturnController.java index 9f45d5e5..94b68551 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/order/controller/mobile/UserReturnController.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/order/controller/mobile/UserReturnController.java @@ -72,7 +72,7 @@ public class UserReturnController extends BaseControllerImpl { } @ApiOperation(value = "取消退款订单", notes = "取消退款订单") - @RequestMapping(value = "/cancel", method = RequestMethod.GET) + @RequestMapping(value = "/cancel", method = {RequestMethod.GET, RequestMethod.POST}) public CommonResult cancel(@RequestParam(name = "return_id") String return_id) { return shopOrderReturnService.cancel(return_id); } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/order/service/impl/ShopOrderBaseServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/order/service/impl/ShopOrderBaseServiceImpl.java index dd0cfe2e..597d947c 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/order/service/impl/ShopOrderBaseServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/order/service/impl/ShopOrderBaseServiceImpl.java @@ -1265,6 +1265,8 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl 0) { // 从购物车走 QueryWrapper cartQueryWrapper = new QueryWrapper<>(); - cartQueryWrapper.eq("chain_id", chain_id).eq("user_id", user_id).eq("cart_select", 1).gt("cart_quantity", 0); + cartQueryWrapper.eq("user_id", user_id).eq("cart_select", 1).gt("cart_quantity", 0); + // .eq("chain_id", chain_id) TODO update 2024-12-23 蓝驰要求 if (checked_store > 0) { cartQueryWrapper.eq("store_id", checked_store); } @@ -1353,6 +1356,8 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl messages = new ArrayList<>(); + messages.add("{'sf_order_id':'JS10000000000','shop_id':3256895871000,'order_status':1,'status_desc':'下单成功','rider_name':'齐景全','rider_phone':'188115000','rider_lng':'116.359337','rider_lat':'40.020761','push_time':1606060800}"); + messages.add("{'sf_order_id':'JS10000000000','shop_id':3256895871000,'order_status':10,'status_desc':'配送员接单','rider_name':'齐景全','rider_phone':'188115000','rider_lng':'116.359347','rider_lat':'40.020770','push_time':1606061801}"); + messages.add("{'sf_order_id':'JS10000000000','shop_id':3256895871000,'order_status':12,'status_desc':'配送员到店','rider_name':'齐景全','rider_phone':'188115000','rider_lng':'116.359357','rider_lat':'40.020771','push_time':1606062800}"); + messages.add("{'sf_order_id':'JS10000000000','shop_id':3256895871000,'order_status':15,'status_desc':'配送员配送中','rider_name':'齐景全','rider_phone':'188115000','rider_lng':'116.359367','rider_lat':'40.020781','push_time':1606360800}"); + messages.add("{'sf_order_id':'JS10000000000','shop_id':3256895871000,'order_status':17,'status_desc':'配送员妥投完单','rider_name':'齐景全','rider_phone':'188115000','rider_lng':'116.359377','rider_lat':'40.020791','push_time':1604060800}"); + messages.add("{'sf_order_id':'JS10000000000','shop_id':3256895871000,'order_status':22,'status_desc':'配送员撤单','rider_name':'齐景全','rider_phone':'188115000','rider_lng':'116.359387','rider_lat':'40.020811','push_time':1606560800}"); + messages.add("{'sf_order_id':'JS10000000000','shop_id':3256895871000,'order_status':91,'status_desc':'骑士上报异常','rider_name':'齐景全','rider_phone':'188115000','rider_lng':'116.359397','rider_lat':'40.020911','push_time':1606760800}"); + messages.add("{'sf_order_id':'JS10000000000','shop_id':3256895871000,'order_status':31,'status_desc':'订单取消中','rider_name':'齐景全','rider_phone':'188115000','rider_lng':'116.359417','rider_lat':'40.020941','push_time':1606960800}"); + messages.add("{'sf_order_id':'JS10000000000','shop_id':3256895871000,'order_status':2,'status_desc':'订单已取消','rider_name':'齐景全','rider_phone':'188115000','rider_lng':'116.3593427','rider_lat':'40.020961','push_time':1608060800}"); + + executor.execute(() -> { + try { + for (String msg : messages) { + Thread.sleep(1000); + SseEmitterUtil.sendMessage(channel, msg); + Thread.sleep(2000); + } + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + }); + + + return sseEmitter; + } + + /** + * 关闭顺丰同城订单状态监听 SSE 服务(测试) + * + * @param channel + * @return + */ + @CrossOrigin(allowCredentials = "true") + @GetMapping(value = "/order/status/listening/close/dev") + public CommonResult sfOrderStatusSseCloseDev(@RequestParam(name = "channel") String channel) { + SseEmitterUtil.removeChannel(channel); + return CommonResult.success(); + } } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/sfexpress/service/impl/SFExpressApiServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/sfexpress/service/impl/SFExpressApiServiceImpl.java index abeb7078..cafa61fb 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/sfexpress/service/impl/SFExpressApiServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/sfexpress/service/impl/SFExpressApiServiceImpl.java @@ -644,6 +644,10 @@ public class SFExpressApiServiceImpl implements SFExpressApiService { throw new ApiException(I18nUtil._("状态处理失败!")); } + // 注:状态更改之后,给 SSE 监听服务发送更改的数据 + // logger.debug("准备发送SSE消息..."); + SseEmitterUtil.sendMessage(shopStoreSfOrder.getSf_order_id(), jsonData); + return new SFExpressApiRes().success("success"); } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/user/service/impl/ShopUserCartServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/user/service/impl/ShopUserCartServiceImpl.java index a338eeaa..a5c25373 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/user/service/impl/ShopUserCartServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/user/service/impl/ShopUserCartServiceImpl.java @@ -48,10 +48,13 @@ import com.suisung.mall.shop.product.pojo.vo.FixOrderVo; import com.suisung.mall.shop.product.pojo.vo.ProductVo; import com.suisung.mall.shop.product.service.*; import com.suisung.mall.shop.store.service.*; +import com.suisung.mall.shop.store.service.impl.ShopStorePrinterLogServiceImpl; import com.suisung.mall.shop.user.mapper.ShopUserCartMapper; import com.suisung.mall.shop.user.service.ShopUserCartService; import com.suisung.mall.shop.user.service.ShopUserDeliveryAddressService; import com.suisung.mall.shop.user.service.ShopUserVoucherService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -77,6 +80,8 @@ import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser; @Service public class ShopUserCartServiceImpl extends BaseServiceImpl implements ShopUserCartService { + private static final Logger logger = LoggerFactory.getLogger(ShopUserCartServiceImpl.class); + private final static Integer CART_TYPE_BUY = 1; //购买 private final static Integer CART_TYPE_POINT = 2; //赠品 private final static Integer CART_TYPE_GIFT = 3; //积分兑换 @@ -548,6 +553,8 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl cartQueryWrapper = new QueryWrapper<>(); cartQueryWrapper.eq("user_id", user_id) - .eq("chain_id", chain_id) + //.eq("chain_id", chain_id) TODO update 2024-12-23 蓝驰要求 .eq("cart_select", 1); Integer checked_store = getParameter("checked_store", Integer.class); @@ -756,8 +763,10 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl allowTransportIds = new ArrayList() {{ - add(5); - add(10); - add(16); + add(StateCode.DELIVERY_TYPE_SELF_PICK_UP); + add(StateCode.DELIVERY_TYPE_EXP); + add(StateCode.DELIVERY_TYPE_SAME_CITY); }}; //允许的配送方式 // 关键金额数据,对方竟然没有备注清楚!!! @@ -2227,7 +2236,6 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl(); data_rows.put("chain_info", chain_info); @@ -2478,6 +2486,7 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl