|
@@ -2,6 +2,7 @@ package cn.lili.modules.order.order.entity.dos;
|
2
|
2
|
|
3
|
3
|
import cn.hutool.core.collection.CollUtil;
|
4
|
4
|
import cn.hutool.json.JSONUtil;
|
|
5
|
+import cn.lili.common.exception.ServiceException;
|
5
|
6
|
import cn.lili.common.utils.BeanUtil;
|
6
|
7
|
import cn.lili.common.utils.SnowFlake;
|
7
|
8
|
import cn.lili.common.utils.StringUtils;
|
|
@@ -23,6 +24,8 @@ import lombok.NoArgsConstructor;
|
23
|
24
|
|
24
|
25
|
import java.util.stream.Collectors;
|
25
|
26
|
|
|
27
|
+import static cn.lili.common.enums.ResultCode.GOODS_ERROR;
|
|
28
|
+
|
26
|
29
|
/**
|
27
|
30
|
* 子订单
|
28
|
31
|
*
|
|
@@ -158,16 +161,22 @@ public class OrderItem extends BaseEntity {
|
158
|
161
|
/**
|
159
|
162
|
* @return 商品名称
|
160
|
163
|
*/
|
161
|
|
- public String getGoodsShortName(){
|
|
164
|
+ public String goodsShortName(){
|
162
|
165
|
return goodsName.substring(0, StringUtils.findFirstIdxAlphabetNumber(goodsName));
|
163
|
166
|
}
|
164
|
167
|
|
165
|
168
|
/**
|
166
|
169
|
* @return 商品货号
|
167
|
170
|
*/
|
168
|
|
- public String getGoodsCode(){
|
|
171
|
+ public String goodCode(){
|
169
|
172
|
int i = StringUtils.findFirstIdxAlphabetNumber(goodsName);
|
170
|
|
- int endIdx = goodsName.indexOf(" ");
|
|
173
|
+ if (i == goodsName.length() - 1){
|
|
174
|
+ return goodsName;
|
|
175
|
+ }
|
|
176
|
+ int endIdx = goodsName.lastIndexOf(" ");
|
|
177
|
+ if(i >= endIdx){
|
|
178
|
+ throw new ServiceException(GOODS_ERROR, "商品名称货号格式不正确");
|
|
179
|
+ }
|
171
|
180
|
return goodsName.substring(i, endIdx == -1 ? goodsName.length() : endIdx);
|
172
|
181
|
}
|
173
|
182
|
|