|
|
@@ -12,6 +12,7 @@ package com.yami.shop.api.controller;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import com.alibaba.excel.util.StringUtils;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.yami.shop.bean.app.dto.*;
|
|
|
import com.yami.shop.bean.app.param.*;
|
|
|
@@ -121,6 +122,7 @@ public class OrderController {
|
|
|
|
|
|
// 订单的地址信息
|
|
|
UserAddr userAddr = userAddrService.getUserAddrByUserId(orderParam.getAddrId(), userId);
|
|
|
+ validateGuizhouAddress(userAddr);
|
|
|
UserAddrDto userAddrDto = mapperFacade.map(userAddr, UserAddrDto.class);
|
|
|
// 组装获取用户提交的购物车商品项
|
|
|
OrderItemParam orderItem = orderParam.getOrderItem();
|
|
|
@@ -400,4 +402,28 @@ public class OrderController {
|
|
|
orderPayInfoParam.setTotalScore(totalScore);
|
|
|
return ResponseEntity.ok(orderPayInfoParam);
|
|
|
}
|
|
|
+
|
|
|
+ private void validateGuizhouAddress(UserAddr userAddr) {
|
|
|
+ if (userAddr == null) {
|
|
|
+ throw new GlobalException("请选择收货地址");
|
|
|
+ }
|
|
|
+ String fullAddress = safeString(userAddr.getProvince())
|
|
|
+ + safeString(userAddr.getCity())
|
|
|
+ + safeString(userAddr.getArea())
|
|
|
+ + safeString(userAddr.getAddr())
|
|
|
+ + safeString(userAddr.getAddress())
|
|
|
+ + safeString(userAddr.getAddressName())
|
|
|
+ + safeString(userAddr.getAddrDetail());
|
|
|
+ if (!containsGuizhou(userAddr.getProvince()) && !containsGuizhou(fullAddress)) {
|
|
|
+ throw new GlobalException("仅支持贵州省收货地址下单");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean containsGuizhou(String text) {
|
|
|
+ return text != null && text.contains("贵州");
|
|
|
+ }
|
|
|
+
|
|
|
+ private String safeString(String text) {
|
|
|
+ return text == null ? "" : text;
|
|
|
+ }
|
|
|
}
|