|
@@ -3,6 +3,7 @@ package com.yohoufo.order.service.impl; |
|
@@ -3,6 +3,7 @@ package com.yohoufo.order.service.impl; |
3
|
import com.yoho.error.ServiceError;
|
3
|
import com.yoho.error.ServiceError;
|
4
|
import com.yoho.error.exception.ServiceException;
|
4
|
import com.yoho.error.exception.ServiceException;
|
5
|
import com.yohobuy.ufo.model.order.bo.AppraiseOrderGoodsBo;
|
5
|
import com.yohobuy.ufo.model.order.bo.AppraiseOrderGoodsBo;
|
|
|
6
|
+import com.yohobuy.ufo.model.order.common.OrderAttributes;
|
6
|
import com.yohobuy.ufo.model.order.common.OrderCodeType;
|
7
|
import com.yohobuy.ufo.model.order.common.OrderCodeType;
|
7
|
import com.yohobuy.ufo.model.order.req.AppraiseOrderComputeReq;
|
8
|
import com.yohobuy.ufo.model.order.req.AppraiseOrderComputeReq;
|
8
|
import com.yohobuy.ufo.model.order.req.AppraiseOrderDetailReq;
|
9
|
import com.yohobuy.ufo.model.order.req.AppraiseOrderDetailReq;
|
|
@@ -28,6 +29,10 @@ import org.slf4j.Logger; |
|
@@ -28,6 +29,10 @@ import org.slf4j.Logger; |
28
|
import org.springframework.beans.factory.annotation.Autowired;
|
29
|
import org.springframework.beans.factory.annotation.Autowired;
|
29
|
import org.springframework.stereotype.Service;
|
30
|
import org.springframework.stereotype.Service;
|
30
|
|
31
|
|
|
|
32
|
+import java.util.ArrayList;
|
|
|
33
|
+import java.util.List;
|
|
|
34
|
+import java.util.Objects;
|
|
|
35
|
+
|
31
|
@Service
|
36
|
@Service
|
32
|
public class AppraiseOrderService {
|
37
|
public class AppraiseOrderService {
|
33
|
private final Logger logger = LoggerUtils.getBuyerOrderLogger();
|
38
|
private final Logger logger = LoggerUtils.getBuyerOrderLogger();
|
|
@@ -59,11 +64,40 @@ public class AppraiseOrderService { |
|
@@ -59,11 +64,40 @@ public class AppraiseOrderService { |
59
|
if (productId <= 0){
|
64
|
if (productId <= 0){
|
60
|
throw new UfoServiceException(400, "商品ID错误");
|
65
|
throw new UfoServiceException(400, "商品ID错误");
|
61
|
}
|
66
|
}
|
|
|
67
|
+ int orderType = req.getOrderType();
|
|
|
68
|
+ OrderAttributes orderAttributes = checkOrderType(orderType);
|
|
|
69
|
+ double fee = 0D;
|
|
|
70
|
+ switch (orderAttributes){
|
|
|
71
|
+ case DEPOSITE:{
|
|
|
72
|
+ fee = 15D;
|
|
|
73
|
+ break;
|
|
|
74
|
+ }
|
|
|
75
|
+
|
|
|
76
|
+ case APPRAISE:{
|
|
|
77
|
+ fee = 31D;
|
|
|
78
|
+ break;
|
|
|
79
|
+ }
|
|
|
80
|
+ default:{
|
|
|
81
|
+ throw new UfoServiceException(400, "orderType错误");
|
|
|
82
|
+ }
|
|
|
83
|
+ }
|
62
|
|
84
|
|
63
|
- double fee = 15D;
|
|
|
64
|
return AppraiseOrderComputeResp.builder().fee(String.valueOf(fee)).build();
|
85
|
return AppraiseOrderComputeResp.builder().fee(String.valueOf(fee)).build();
|
65
|
}
|
86
|
}
|
66
|
|
87
|
|
|
|
88
|
+ private static final List<OrderAttributes> legalOrderTypes = new ArrayList<OrderAttributes>(2){
|
|
|
89
|
+ {
|
|
|
90
|
+ add(OrderAttributes.DEPOSITE);
|
|
|
91
|
+ add(OrderAttributes.APPRAISE);
|
|
|
92
|
+ }
|
|
|
93
|
+ };
|
|
|
94
|
+ private OrderAttributes checkOrderType(int orderType){
|
|
|
95
|
+ OrderAttributes oa = OrderAttributes.getOrderAttributes(orderType);
|
|
|
96
|
+ if (Objects.isNull(oa) || !legalOrderTypes.contains(oa)){
|
|
|
97
|
+ throw new UfoServiceException(400, "orderType错误");
|
|
|
98
|
+ }
|
|
|
99
|
+ return oa;
|
|
|
100
|
+ }
|
67
|
|
101
|
|
68
|
|
102
|
|
69
|
|
103
|
|
|
@@ -106,6 +140,7 @@ public class AppraiseOrderService { |
|
@@ -106,6 +140,7 @@ public class AppraiseOrderService { |
106
|
int productId;
|
140
|
int productId;
|
107
|
AddressInfo hiddenBackAddress;
|
141
|
AddressInfo hiddenBackAddress;
|
108
|
AddressInfo noHiddenBackAddress;
|
142
|
AddressInfo noHiddenBackAddress;
|
|
|
143
|
+ OrderAttributes orderAttributes;
|
109
|
}
|
144
|
}
|
110
|
|
145
|
|
111
|
private PreparedNode checkAndAcquire(AppraiseOrderSubmitReq req){
|
146
|
private PreparedNode checkAndAcquire(AppraiseOrderSubmitReq req){
|
|
@@ -117,6 +152,7 @@ public class AppraiseOrderService { |
|
@@ -117,6 +152,7 @@ public class AppraiseOrderService { |
117
|
if (productId <= 0){
|
152
|
if (productId <= 0){
|
118
|
throw new UfoServiceException(400, "商品ID错误");
|
153
|
throw new UfoServiceException(400, "商品ID错误");
|
119
|
}
|
154
|
}
|
|
|
155
|
+ OrderAttributes orderAttributes = OrderAttributes.APPRAISE;
|
120
|
|
156
|
|
121
|
int addressId = AddressUtil.getDecryptStr(req.getAddressId());
|
157
|
int addressId = AddressUtil.getDecryptStr(req.getAddressId());
|
122
|
if (addressId < 0){
|
158
|
if (addressId < 0){
|
|
@@ -139,6 +175,7 @@ public class AppraiseOrderService { |
|
@@ -139,6 +175,7 @@ public class AppraiseOrderService { |
139
|
.productId(productId)
|
175
|
.productId(productId)
|
140
|
.hiddenBackAddress(hiddenBackAddress)
|
176
|
.hiddenBackAddress(hiddenBackAddress)
|
141
|
.noHiddenBackAddress(noHiddenBackAddress)
|
177
|
.noHiddenBackAddress(noHiddenBackAddress)
|
|
|
178
|
+ .orderAttributes(orderAttributes)
|
142
|
.build();
|
179
|
.build();
|
143
|
}
|
180
|
}
|
144
|
|
181
|
|