优化配送方式
This commit is contained in:
parent
85d06fc9b0
commit
8314d2d202
@ -23,7 +23,7 @@ public class SseEmitterUtil {
|
|||||||
*/
|
*/
|
||||||
public static SseEmitter connect(String channel) {
|
public static SseEmitter connect(String channel) {
|
||||||
//设置超时时间,0表示不过期。默认30秒,超过时间未完成会抛出异常:AsyncRequestTimeoutException
|
//设置超时时间,0表示不过期。默认30秒,超过时间未完成会抛出异常:AsyncRequestTimeoutException
|
||||||
SseEmitter sseEmitter = new SseEmitter(1200000L); // 20分钟
|
SseEmitter sseEmitter = new SseEmitter(1800000L); // 30分钟
|
||||||
try {
|
try {
|
||||||
//注册回调:完成、失败、超时
|
//注册回调:完成、失败、超时
|
||||||
sseEmitter.onCompletion(completionCallBack(channel));
|
sseEmitter.onCompletion(completionCallBack(channel));
|
||||||
|
|||||||
@ -83,6 +83,7 @@ secure:
|
|||||||
- "/shop/sf-express/cancel-order/notify"
|
- "/shop/sf-express/cancel-order/notify"
|
||||||
- "/shop/sf-express/rider-order-status/notify"
|
- "/shop/sf-express/rider-order-status/notify"
|
||||||
- "/shop/sf-express/order-complete/notify"
|
- "/shop/sf-express/order-complete/notify"
|
||||||
|
- "/mobile/shop/sf-express/order/status/listening/**"
|
||||||
- "/admin/shop/open/**"
|
- "/admin/shop/open/**"
|
||||||
- "/admin/account/open/**"
|
- "/admin/account/open/**"
|
||||||
- "/esProduct/**"
|
- "/esProduct/**"
|
||||||
|
|||||||
@ -72,7 +72,7 @@ public class UserReturnController extends BaseControllerImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "取消退款订单", notes = "取消退款订单")
|
@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) {
|
public CommonResult cancel(@RequestParam(name = "return_id") String return_id) {
|
||||||
return shopOrderReturnService.cancel(return_id);
|
return shopOrderReturnService.cancel(return_id);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1265,6 +1265,8 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
|||||||
Map checkout_row = new HashMap();
|
Map checkout_row = new HashMap();
|
||||||
// 配送方式:5-门店自提;10-普通快递;16-同城配送;
|
// 配送方式:5-门店自提;10-普通快递;16-同城配送;
|
||||||
Integer delivery_type_id = getParameter("delivery_type_id", StateCode.DELIVERY_TYPE_SAME_CITY);
|
Integer delivery_type_id = getParameter("delivery_type_id", StateCode.DELIVERY_TYPE_SAME_CITY);
|
||||||
|
logger.debug("提交订单时,配送方式 delivery_type_id:{}",delivery_type_id);
|
||||||
|
|
||||||
if (getParameter("checkout_row") == null) {
|
if (getParameter("checkout_row") == null) {
|
||||||
Date cur_date = new Date();
|
Date cur_date = new Date();
|
||||||
checkout_row.put("payment_type_id", StateCode.PAYMENT_TYPE_ONLINE);
|
checkout_row.put("payment_type_id", StateCode.PAYMENT_TYPE_ONLINE);
|
||||||
@ -1294,7 +1296,8 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
|||||||
if (ifcart > 0) {
|
if (ifcart > 0) {
|
||||||
// 从购物车走
|
// 从购物车走
|
||||||
QueryWrapper<ShopUserCart> cartQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<ShopUserCart> 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) {
|
if (checked_store > 0) {
|
||||||
cartQueryWrapper.eq("store_id", checked_store);
|
cartQueryWrapper.eq("store_id", checked_store);
|
||||||
}
|
}
|
||||||
@ -1353,6 +1356,8 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
|||||||
cart_data.put("src_order_id", src_order_id);
|
cart_data.put("src_order_id", src_order_id);
|
||||||
//订单类型:线上、线下
|
//订单类型:线上、线下
|
||||||
cart_data.put("order_type", order_type);
|
cart_data.put("order_type", order_type);
|
||||||
|
// 配送方式
|
||||||
|
cart_data.put("delivery_type_id", delivery_type_id);
|
||||||
|
|
||||||
// 修改为distributor_user_id
|
// 修改为distributor_user_id
|
||||||
Integer distributor_user_id = getParameter("distributor_user_id", Integer.class);
|
Integer distributor_user_id = getParameter("distributor_user_id", Integer.class);
|
||||||
@ -8393,7 +8398,6 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
|||||||
// 7位数取单号,位数不够向左补0
|
// 7位数取单号,位数不够向左补0
|
||||||
String orderPickupNumStr = String.format("%07d", orderPickupNum);
|
String orderPickupNumStr = String.format("%07d", orderPickupNum);
|
||||||
sfCreateOrderReq.setOrder_sequence(orderPickupNumStr); //拣货编号
|
sfCreateOrderReq.setOrder_sequence(orderPickupNumStr); //拣货编号
|
||||||
// sfCreateOrderReq.setRemark(shopStoreInfo.getOrder_message);
|
|
||||||
sfCreateOrderReq.setVersion(19);
|
sfCreateOrderReq.setVersion(19);
|
||||||
sfCreateOrderReq.setReturn_flag(511);
|
sfCreateOrderReq.setReturn_flag(511);
|
||||||
|
|
||||||
|
|||||||
@ -19,16 +19,20 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
@Api(tags = "顺丰同城C端")
|
@Api(tags = "顺丰同城C端")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/mobile/shop/sf-express")
|
@RequestMapping("/mobile/shop/sf-express")
|
||||||
public class SFExpressController {
|
public class SFExpressController {
|
||||||
|
private final ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
@Resource
|
@Resource
|
||||||
private SFExpressApiService sfExpressApiService;
|
private SFExpressApiService sfExpressApiService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ShopStoreSfOrderService shopStoreSfOrderService;
|
private ShopStoreSfOrderService shopStoreSfOrderService;
|
||||||
|
|
||||||
@ -90,24 +94,77 @@ public class SFExpressController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 顺丰同城订单状态监听 SSE 服务
|
* 顺丰同城订单状态监听 SSE 服务
|
||||||
|
*
|
||||||
* @param channel
|
* @param channel
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@CrossOrigin(allowCredentials = "true")
|
@CrossOrigin(allowCredentials = "true")
|
||||||
@GetMapping(value = "/order/status/listening", produces = "text/event-stream;charset=UTF-8")
|
@GetMapping(value = "/order/status/listening", produces = "text/event-stream;charset=UTF-8")
|
||||||
public SseEmitter sfOrderStatusSseConn(@RequestParam(value = "channel", required = true) String channel) {
|
public SseEmitter sfOrderStatusSseConn(@RequestParam(value = "channel") String channel) {
|
||||||
return SseEmitterUtil.connect(channel);
|
return SseEmitterUtil.connect(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关闭顺丰同城订单状态监听 SSE 服务
|
* 关闭顺丰同城订单状态监听 SSE 服务
|
||||||
|
*
|
||||||
* @param channel
|
* @param channel
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@CrossOrigin(allowCredentials = "true")
|
@CrossOrigin(allowCredentials = "true")
|
||||||
@GetMapping(value ="/order/status/listening/close")
|
@GetMapping(value = "/order/status/listening/close")
|
||||||
public CommonResult sfOrderStatusSseClose(@RequestParam(name = "channel") String channel) {
|
public CommonResult sfOrderStatusSseClose(@RequestParam(name = "channel") String channel) {
|
||||||
SseEmitterUtil.removeChannel(channel);
|
SseEmitterUtil.removeChannel(channel);
|
||||||
return CommonResult.success();
|
return CommonResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 顺丰同城订单状态监听 SSE 服务(测试)
|
||||||
|
*
|
||||||
|
* @param channel
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@CrossOrigin(allowCredentials = "true")
|
||||||
|
@GetMapping(value = "/order/status/listening/dev", produces = "text/event-stream;charset=UTF-8")
|
||||||
|
public SseEmitter sfOrderStatusSseConnDev(@RequestParam(value = "channel") String channel) {
|
||||||
|
SseEmitter sseEmitter = SseEmitterUtil.connect(channel);
|
||||||
|
|
||||||
|
List<String> 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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -644,6 +644,10 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
|
|||||||
throw new ApiException(I18nUtil._("状态处理失败!"));
|
throw new ApiException(I18nUtil._("状态处理失败!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 注:状态更改之后,给 SSE 监听服务发送更改的数据
|
||||||
|
// logger.debug("准备发送SSE消息...");
|
||||||
|
SseEmitterUtil.sendMessage(shopStoreSfOrder.getSf_order_id(), jsonData);
|
||||||
|
|
||||||
return new SFExpressApiRes().success("success");
|
return new SFExpressApiRes().success("success");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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.pojo.vo.ProductVo;
|
||||||
import com.suisung.mall.shop.product.service.*;
|
import com.suisung.mall.shop.product.service.*;
|
||||||
import com.suisung.mall.shop.store.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.mapper.ShopUserCartMapper;
|
||||||
import com.suisung.mall.shop.user.service.ShopUserCartService;
|
import com.suisung.mall.shop.user.service.ShopUserCartService;
|
||||||
import com.suisung.mall.shop.user.service.ShopUserDeliveryAddressService;
|
import com.suisung.mall.shop.user.service.ShopUserDeliveryAddressService;
|
||||||
import com.suisung.mall.shop.user.service.ShopUserVoucherService;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@ -77,6 +80,8 @@ import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser;
|
|||||||
@Service
|
@Service
|
||||||
public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper, ShopUserCart> implements ShopUserCartService {
|
public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper, ShopUserCart> 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_BUY = 1; //购买
|
||||||
private final static Integer CART_TYPE_POINT = 2; //赠品
|
private final static Integer CART_TYPE_POINT = 2; //赠品
|
||||||
private final static Integer CART_TYPE_GIFT = 3; //积分兑换
|
private final static Integer CART_TYPE_GIFT = 3; //积分兑换
|
||||||
@ -548,6 +553,8 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
|||||||
// 默认同城配送
|
// 默认同城配送
|
||||||
delivery_type_id = StateCode.DELIVERY_TYPE_SAME_CITY;
|
delivery_type_id = StateCode.DELIVERY_TYPE_SAME_CITY;
|
||||||
}
|
}
|
||||||
|
data.put("delivery_type_id", delivery_type_id);
|
||||||
|
//logger.debug("checkout 的配送方式:{}",delivery_type_id);
|
||||||
|
|
||||||
if_chain = chain_id != null && chain_id != 0;
|
if_chain = chain_id != null && chain_id != 0;
|
||||||
Long product_id = null;
|
Long product_id = null;
|
||||||
@ -564,7 +571,7 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
|||||||
// 从购物车进来
|
// 从购物车进来
|
||||||
QueryWrapper<ShopUserCart> cartQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<ShopUserCart> cartQueryWrapper = new QueryWrapper<>();
|
||||||
cartQueryWrapper.eq("user_id", user_id)
|
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);
|
.eq("cart_select", 1);
|
||||||
|
|
||||||
Integer checked_store = getParameter("checked_store", Integer.class);
|
Integer checked_store = getParameter("checked_store", Integer.class);
|
||||||
@ -756,8 +763,10 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
|||||||
if (CollUtil.isNotEmpty(delivery_address_row) && CheckUtil.isNotEmpty(district_id)) {
|
if (CollUtil.isNotEmpty(delivery_address_row) && CheckUtil.isNotEmpty(district_id)) {
|
||||||
// 计算邮费情况
|
// 计算邮费情况
|
||||||
if (Convert.toBool(is_delivery)) {
|
if (Convert.toBool(is_delivery)) {
|
||||||
|
data.put("delivery_type_id", delivery_type_id);
|
||||||
// 重要:配送运费校验和计算(涉及的东西比较多)
|
// 重要:配送运费校验和计算(涉及的东西比较多)
|
||||||
calTransportFreight(data, district_id);
|
calTransportFreight(data, district_id);
|
||||||
|
// logger.debug("checkout 计算配送费时的配送方式:{}",delivery_type_id);
|
||||||
// 订单地址和金额不在配送范围,抛出异常提示
|
// 订单地址和金额不在配送范围,抛出异常提示
|
||||||
// tryCalTransportFreight(data, district_id,true);
|
// tryCalTransportFreight(data, district_id,true);
|
||||||
data.put("has_stock", data.get("can_delivery")); // 是否有货
|
data.put("has_stock", data.get("can_delivery")); // 是否有货
|
||||||
@ -1262,9 +1271,9 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
|||||||
|
|
||||||
// 配送方式(ENUM):5-自提;10-快递;16-同城配送;
|
// 配送方式(ENUM):5-自提;10-快递;16-同城配送;
|
||||||
List<Integer> allowTransportIds = new ArrayList<Integer>() {{
|
List<Integer> allowTransportIds = new ArrayList<Integer>() {{
|
||||||
add(5);
|
add(StateCode.DELIVERY_TYPE_SELF_PICK_UP);
|
||||||
add(10);
|
add(StateCode.DELIVERY_TYPE_EXP);
|
||||||
add(16);
|
add(StateCode.DELIVERY_TYPE_SAME_CITY);
|
||||||
}}; //允许的配送方式
|
}}; //允许的配送方式
|
||||||
|
|
||||||
// 关键金额数据,对方竟然没有备注清楚!!!
|
// 关键金额数据,对方竟然没有备注清楚!!!
|
||||||
@ -2227,7 +2236,6 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 可自提的门店信息
|
// 可自提的门店信息
|
||||||
|
|
||||||
List chain_info = CollUtil.isNotEmpty(chain_id_row) && ObjectUtil.isNotNull(chain_row) ? Convert.toList(chain_row) : new ArrayList<>();
|
List chain_info = CollUtil.isNotEmpty(chain_id_row) && ObjectUtil.isNotNull(chain_row) ? Convert.toList(chain_row) : new ArrayList<>();
|
||||||
data_rows.put("chain_info", chain_info);
|
data_rows.put("chain_info", chain_info);
|
||||||
|
|
||||||
@ -2478,6 +2486,7 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
|||||||
boolean can_delivery = true;
|
boolean can_delivery = true;
|
||||||
// 配送方式 5-门店自取;10-普通快递;16-同城配送;
|
// 配送方式 5-门店自取;10-普通快递;16-同城配送;
|
||||||
Integer delivery_type_id = Convert.toInt(cart_data.get("delivery_type_id"), StateCode.DELIVERY_TYPE_SAME_CITY);
|
Integer delivery_type_id = Convert.toInt(cart_data.get("delivery_type_id"), StateCode.DELIVERY_TYPE_SAME_CITY);
|
||||||
|
// logger.debug("计算运费方法中,配送方式 delivery_type_id:{}",delivery_type_id);
|
||||||
|
|
||||||
// 同城配送运费计算分支
|
// 同城配送运费计算分支
|
||||||
if (delivery_type_id == StateCode.DELIVERY_TYPE_SAME_CITY) {
|
if (delivery_type_id == StateCode.DELIVERY_TYPE_SAME_CITY) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user