送货地址bug修复

This commit is contained in:
Jack 2024-12-02 16:20:29 +08:00
parent cb18871f40
commit 953319764f
6 changed files with 98 additions and 53 deletions

View File

@ -64,10 +64,10 @@ public class ShopOrderDeliveryAddressServiceImpl extends BaseServiceImpl<ShopOrd
StandardAddressDTO standardAddressDTO = new StandardAddressDTO();
if ( StrUtil.isBlank(shopOrderDeliveryAddress.getDa_address()) || StrUtil.isBlank(shopOrderDeliveryAddress.getDa_longitude()) || StrUtil.isBlank(shopOrderDeliveryAddress.getDa_latitude())) {
if(StrUtil.isNotBlank(shopOrderDeliveryAddress.getDa_longitude())){
if(StrUtil.isBlank(shopOrderDeliveryAddress.getDa_longitude())){
shopOrderDeliveryAddress.setDa_longitude("0");
}
if(StrUtil.isNotBlank(shopOrderDeliveryAddress.getDa_latitude())){
if(StrUtil.isBlank(shopOrderDeliveryAddress.getDa_latitude())){
shopOrderDeliveryAddress.setDa_latitude("0");
}
standardAddressDTO.setFullAddress(sb.toString());

View File

@ -25,7 +25,7 @@ public class SFExpressApiController {
@ApiOperation(value = "顺丰原因订单取消回调", notes = "顺丰原因订单取消回调")
@RequestMapping(value = "/cancel-order/notify", method = RequestMethod.POST)
public SFExpressApiRes cancelordernotify(@RequestBody String requestBody,@RequestParam(name = "sign") String sign) {
public SFExpressApiRes cancelOrderNotify(@RequestBody String requestBody,@RequestParam(name = "sign") String sign) {
return sfExpressApiService.receiveCancelOrderNotify(requestBody, sign);
}

View File

@ -24,7 +24,6 @@ import com.suisung.mall.common.utils.JsonUtil;
import com.suisung.mall.shop.order.service.ShopOrderBaseService;
import com.suisung.mall.shop.order.service.ShopOrderInfoService;
import com.suisung.mall.shop.sfexpress.service.SFExpressApiService;
import com.suisung.mall.shop.store.service.ShopStoreBaseService;
import com.suisung.mall.shop.store.service.ShopStoreSfOrderService;
import org.apache.commons.codec.binary.Base64;
import org.slf4j.Logger;
@ -139,6 +138,7 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
/**
* 内部顺丰同城订单下单
*
* @param orderId
* @param orderPickupNum
* @return
@ -227,6 +227,7 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
}
// 转换 json 字符串参数
String orderId = params.get("order_id").toString();
String paramJSON = JsonUtil.toJSONString(params);
// 根据参数生成请求签名
@ -243,7 +244,21 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
return new SFExpressApiRes().fail(-1, "顺丰同城:无返回值!");
}
// TODO 更改商品订单状态
// 判断订单的状态是否已经取消了已取消不再执行
ShopStoreSfOrder shopStoreSfOrderExist = shopStoreSfOrderService.getBySfOrderId(orderId);
if (shopStoreSfOrderExist != null && shopStoreSfOrderExist.getSf_order_status() != null
&& (shopStoreSfOrderExist.getSf_order_status().equals(StateCode.SF_ORDER_STATUS_CANCELED) ||
(shopStoreSfOrderExist.getSf_order_status().equals(StateCode.SF_ORDER_STATUS_CANCELING)))) {
return new SFExpressApiRes().success("订单已取消过!");
}
// 更改商城订单状态为已取消注意事务问题
List<String> orderList = new ArrayList<>();
orderList.add(orderId);
Boolean success = shopOrderBaseService.cancel(orderList, null, false);
if (!success) {
return new SFExpressApiRes().fail(-1, "取消订单业务处理失败!");
}
return sfExpressApiRes;
}
@ -423,13 +438,27 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
// 更改顺丰同城订单状态
ShopStoreSfOrder shopStoreSfOrder = toShopStoreSfOrder(jsonData);
// 判断订单的状态是否已经取消了已取消不再执行
ShopStoreSfOrder shopStoreSfOrderExist = shopStoreSfOrderService.getBySfOrderId(shopStoreSfOrder.getShop_order_id());
if (shopStoreSfOrderExist != null && shopStoreSfOrderExist.getSf_order_status() != null
&& (shopStoreSfOrderExist.getSf_order_status().equals(StateCode.SF_ORDER_STATUS_CANCELED) ||
(shopStoreSfOrderExist.getSf_order_status().equals(StateCode.SF_ORDER_STATUS_CANCELING)))) {
return new SFExpressApiRes().success("success");
}
Boolean success = shopStoreSfOrderService.updateShopStoreSfOrderStatus(shopStoreSfOrder);
if (!success) {
return new SFExpressApiRes().fail(-1, "状态处理失败!");
}
// TODO 更改商城订单状态为已取消注意事务问题
// 更改商城订单状态为已取消注意事务问题
List<String> orderList = new ArrayList<>();
orderList.add(shopStoreSfOrder.getShop_order_id());
success = shopOrderBaseService.cancel(orderList, null, false);
if (!success) {
return new SFExpressApiRes().fail(-1, "取消订单业务处理失败!");
}
return new SFExpressApiRes().success("success");
}
@ -608,6 +637,7 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
/**
* 回调结果数据填充顺丰同城订单实例
*
* @param resultJSON
* @return
*/

View File

@ -2845,10 +2845,10 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
if(StrUtil.isNotBlank(shopStoreBase.getStore_address())){
sb.append(shopStoreBase.getStore_address());
}
if(StrUtil.isNotBlank(shopStoreBase.getStore_longitude())){
if(StrUtil.isBlank(shopStoreBase.getStore_longitude())){
shopStoreBase.setStore_longitude("0");
}
if(StrUtil.isNotBlank(shopStoreBase.getStore_latitude())){
if(StrUtil.isBlank(shopStoreBase.getStore_latitude())){
shopStoreBase.setStore_latitude("0");
}
standardAddressDTO.setFullAddress(sb.toString());

View File

@ -4,9 +4,11 @@ import com.suisung.mall.common.api.CommonResult;
import com.suisung.mall.common.api.ResultCode;
import com.suisung.mall.common.domain.UserDto;
import com.suisung.mall.common.exception.ApiException;
import com.suisung.mall.common.exception.ApiUserException;
import com.suisung.mall.common.modules.user.ShopUserDeliveryAddress;
import com.suisung.mall.common.service.impl.BaseControllerImpl;
import com.suisung.mall.common.utils.CheckUtil;
import com.suisung.mall.common.utils.I18nUtil;
import com.suisung.mall.shop.user.service.ShopUserDeliveryAddressService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -39,25 +41,29 @@ public class UserDeliveryAddressController extends BaseControllerImpl {
}
@ApiOperation(value = "保存用户地址", notes = "保存用户地址")
@RequestMapping(value = "/save", method = RequestMethod.GET)
@RequestMapping(value = "/save", method = RequestMethod.POST)
public CommonResult save(ShopUserDeliveryAddress deliveryAddress) {
return userDeliveryAddressService.saveAddress(deliveryAddress);
}
@ApiOperation(value = "删除用户地址", notes = "读取用户地址")
@RequestMapping(value = "/remove", method = RequestMethod.GET)
@ApiOperation(value = "删除用户地址", notes = "删除用户地址")
@RequestMapping(value = "/remove", method = RequestMethod.POST)
public CommonResult remove(@RequestParam(name = "ud_id") Integer ud_id) {
UserDto user = getCurrentUser();
if(user==null){
throw new ApiUserException(I18nUtil._("用户信息异常!"));
}
ShopUserDeliveryAddress deliveryAddress = userDeliveryAddressService.get(ud_id);
if (CheckUtil.checkDataRights(user.getId(), deliveryAddress, ShopUserDeliveryAddress::getUser_id)) {
if (!userDeliveryAddressService.remove(ud_id)) {
return CommonResult.success(ResultCode.FAILED);
}
} else {
if (!CheckUtil.checkDataRights(user.getId(), deliveryAddress, ShopUserDeliveryAddress::getUser_id)) {
throw new ApiException(ResultCode.FORBIDDEN);
}
if (!userDeliveryAddressService.remove(ud_id)) {
return CommonResult.failed(ResultCode.FAILED);
}
return CommonResult.success();
}

View File

@ -17,6 +17,8 @@ import com.suisung.mall.common.modules.user.ShopUserDeliveryAddress;
import com.suisung.mall.common.utils.CheckUtil;
import com.suisung.mall.common.utils.I18nUtil;
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
import com.suisung.mall.shop.config.BaiduUtil;
import com.suisung.mall.shop.entity.LocationBean;
import com.suisung.mall.shop.user.mapper.ShopUserDeliveryAddressMapper;
import com.suisung.mall.shop.user.service.ShopUserDeliveryAddressService;
import org.springframework.stereotype.Service;
@ -127,7 +129,7 @@ public class ShopUserDeliveryAddressServiceImpl extends BaseServiceImpl<ShopUser
throw new ApiException("手机号输入有误");
}
String district_ids = Convert.toStr(getParameter("district_ids")); //
String district_ids = Convert.toStr(getParameter("district_ids")); //
if (StrUtil.isNotBlank(district_ids)) {
int[] district_id_row = StrUtil.splitToInt(district_ids, ",");
deliveryAddress.setUd_province_id(district_id_row[0]);
@ -151,14 +153,22 @@ public class ShopUserDeliveryAddressServiceImpl extends BaseServiceImpl<ShopUser
deliveryAddress.setUd_county(district_info_rows.get(2));
}
// 兼容不同终端 已经无推荐地址情况
String _ud_longitude = deliveryAddress.getUd_longitude();
String _ud_latitude = deliveryAddress.getUd_latitude();
// // 兼容不同终端 已经无推荐地址情况
if (StrUtil.isBlank(deliveryAddress.getUd_longitude()) || StrUtil.isBlank(deliveryAddress.getUd_latitude())) {
String province = StrUtil.isBlank(deliveryAddress.getUd_province()) ? "" : deliveryAddress.getUd_province();
String city = StrUtil.isBlank(deliveryAddress.getUd_city()) ? "" : deliveryAddress.getUd_city();
String county = StrUtil.isBlank(deliveryAddress.getUd_county()) ? "" : deliveryAddress.getUd_county();
String address = StrUtil.isBlank(deliveryAddress.getUd_address()) ? "" : deliveryAddress.getUd_address();
if (StrUtil.isBlank(_ud_longitude) || StrUtil.isNotBlank(_ud_latitude)) {
LocationBean location = BaiduUtil.getLatAndLngByAddress(province + city + county + address);
if (location != null) {
deliveryAddress.setUd_latitude(location.getLng());
deliveryAddress.setUd_longitude(location.getLat());
} else {
deliveryAddress.setUd_latitude("0");
deliveryAddress.setUd_longitude("0");
}
}
if (ud_id > 0) {
ShopUserDeliveryAddress address = get(ud_id);
@ -177,7 +187,7 @@ public class ShopUserDeliveryAddressServiceImpl extends BaseServiceImpl<ShopUser
updateDefaultAddress(ud_id, user_id);
}
if(deliveryAddress.getUd_label()!=null&& deliveryAddress.getUd_label().equals(0)){
if (deliveryAddress.getUd_label() != null && !deliveryAddress.getUd_label().equals(0)) {
// 标签对用户来说是唯一的设置了某个标签其他之前的地址标签要置空
updateAddressLabel(ud_id, user_id, deliveryAddress.getUd_label());
}
@ -264,10 +274,9 @@ public class ShopUserDeliveryAddressServiceImpl extends BaseServiceImpl<ShopUser
QueryWrapper<ShopUserDeliveryAddress> addressQueryWrapper = new QueryWrapper<>();
addressQueryWrapper.eq("user_id", userId).eq("label", updLabel).ne("ud_id", udId);
ShopUserDeliveryAddress deliveryAddress = new ShopUserDeliveryAddress();
deliveryAddress.setUd_label(0);
return edit(deliveryAddress, addressQueryWrapper);
ShopUserDeliveryAddress updDeliveryAddress = new ShopUserDeliveryAddress();
updDeliveryAddress.setUd_label(0);
return edit(updDeliveryAddress, addressQueryWrapper);
}
}