Commit 03338362059f292e4f2dc2429b0480d09f37a888
1 parent
d6fdb787
优化项目代码
Showing
61 changed files
with
1343 additions
and
736 deletions
b2c-orders-client/pom.xml
b2c-orders-client/src/main/java/com/b2c/orders/domain/client/dto/request/BuyerConfirmRequestDto.java
b2c-orders-client/src/main/java/com/b2c/orders/domain/client/dto/request/PayOrderRequestDto.java
b2c-orders-client/src/main/java/com/b2c/orders/domain/client/dto/request/SubmitOrderRequestDto.java
... | ... | @@ -26,6 +26,10 @@ public class SubmitOrderRequestDto implements Serializable { |
26 | 26 | private String receiverName; |
27 | 27 | @ApiModelProperty("送货地址") |
28 | 28 | private String deliveryAddress; |
29 | + @ApiModelProperty("城市id") | |
30 | + private Long cityId; | |
31 | + @ApiModelProperty("城市名称") | |
32 | + private String cityName; | |
29 | 33 | @ApiModelProperty("收货人电话") |
30 | 34 | private String receiverPhoneNumber; |
31 | 35 | @ApiModelProperty(value = "提货时间") |
... | ... | @@ -89,6 +93,22 @@ public class SubmitOrderRequestDto implements Serializable { |
89 | 93 | this.deliveryAddress = deliveryAddress; |
90 | 94 | } |
91 | 95 | |
96 | + public Long getCityId() { | |
97 | + return cityId; | |
98 | + } | |
99 | + | |
100 | + public void setCityId(Long cityId) { | |
101 | + this.cityId = cityId; | |
102 | + } | |
103 | + | |
104 | + public String getCityName() { | |
105 | + return cityName; | |
106 | + } | |
107 | + | |
108 | + public void setCityName(String cityName) { | |
109 | + this.cityName = cityName; | |
110 | + } | |
111 | + | |
92 | 112 | public String getReceiverPhoneNumber() { |
93 | 113 | return receiverPhoneNumber; |
94 | 114 | } |
... | ... |
b2c-orders-client/src/main/java/com/b2c/orders/domain/client/dto/response/ApiPageDataResponse.java
... | ... | @@ -2,6 +2,8 @@ package com.b2c.orders.domain.client.dto.response; |
2 | 2 | |
3 | 3 | import java.util.List; |
4 | 4 | |
5 | +import io.swagger.annotations.ApiModelProperty; | |
6 | + | |
5 | 7 | public class ApiPageDataResponse<T> extends ApiResponse { |
6 | 8 | |
7 | 9 | /** |
... | ... | @@ -12,26 +14,31 @@ public class ApiPageDataResponse<T> extends ApiResponse { |
12 | 14 | /** |
13 | 15 | * 总页数 |
14 | 16 | */ |
17 | + @ApiModelProperty("总页数") | |
15 | 18 | private int totalPage; |
16 | 19 | |
17 | 20 | /** |
18 | 21 | * 总数量 |
19 | 22 | */ |
23 | + @ApiModelProperty("总数量") | |
20 | 24 | private int totalSize; |
21 | 25 | |
22 | 26 | /** |
23 | 27 | * 当前页 |
24 | 28 | */ |
29 | + @ApiModelProperty("当前页") | |
25 | 30 | private int currentPage; |
26 | 31 | |
27 | 32 | /** |
28 | 33 | * 每页数量 |
29 | 34 | */ |
35 | + @ApiModelProperty("每页数量") | |
30 | 36 | private int pageSize; |
31 | 37 | |
32 | 38 | /** |
33 | 39 | * 数据集合 |
34 | 40 | */ |
41 | + @ApiModelProperty("数据集合") | |
35 | 42 | private List<T> list; |
36 | 43 | |
37 | 44 | public int getTotalPage() { |
... | ... |
b2c-orders-client/src/main/java/com/b2c/orders/domain/client/dto/response/OrderDetailResponseDto.java
... | ... | @@ -9,6 +9,10 @@ public class OrderDetailResponseDto implements Serializable { |
9 | 9 | */ |
10 | 10 | private static final long serialVersionUID = 2572442090886362100L; |
11 | 11 | |
12 | + /** | |
13 | + * 订单id | |
14 | + */ | |
15 | + private Long id; | |
12 | 16 | /** 配送类型 */ |
13 | 17 | private Integer deliveryType; |
14 | 18 | /** 订单状态 */ |
... | ... | @@ -37,6 +41,27 @@ public class OrderDetailResponseDto implements Serializable { |
37 | 41 | * 实际价格,有商家接单后修改 |
38 | 42 | */ |
39 | 43 | private Long realTotalPrice; |
44 | + /** | |
45 | + * 收货人姓名 | |
46 | + */ | |
47 | + private String receiverName; | |
48 | + /** | |
49 | + * 收货人电话 | |
50 | + */ | |
51 | + private String receiverPhoneNumber; | |
52 | + /** | |
53 | + * 城市id | |
54 | + */ | |
55 | + private Long cityId; | |
56 | + private String cityName; | |
57 | + | |
58 | + public Long getId() { | |
59 | + return id; | |
60 | + } | |
61 | + | |
62 | + public void setId(Long id) { | |
63 | + this.id = id; | |
64 | + } | |
40 | 65 | |
41 | 66 | public Integer getDeliveryType() { |
42 | 67 | return deliveryType; |
... | ... | @@ -126,4 +151,36 @@ public class OrderDetailResponseDto implements Serializable { |
126 | 151 | this.realTotalPrice = realTotalPrice; |
127 | 152 | } |
128 | 153 | |
154 | + public String getReceiverName() { | |
155 | + return receiverName; | |
156 | + } | |
157 | + | |
158 | + public void setReceiverName(String receiverName) { | |
159 | + this.receiverName = receiverName; | |
160 | + } | |
161 | + | |
162 | + public String getReceiverPhoneNumber() { | |
163 | + return receiverPhoneNumber; | |
164 | + } | |
165 | + | |
166 | + public void setReceiverPhoneNumber(String receiverPhoneNumber) { | |
167 | + this.receiverPhoneNumber = receiverPhoneNumber; | |
168 | + } | |
169 | + | |
170 | + public Long getCityId() { | |
171 | + return cityId; | |
172 | + } | |
173 | + | |
174 | + public void setCityId(Long cityId) { | |
175 | + this.cityId = cityId; | |
176 | + } | |
177 | + | |
178 | + public String getCityName() { | |
179 | + return cityName; | |
180 | + } | |
181 | + | |
182 | + public void setCityName(String cityName) { | |
183 | + this.cityName = cityName; | |
184 | + } | |
185 | + | |
129 | 186 | } |
... | ... |
b2c-orders-client/src/main/java/com/b2c/orders/domain/client/dto/response/OrderItemResponseDto.java
1 | 1 | package com.b2c.orders.domain.client.dto.response; |
2 | 2 | |
3 | +import java.io.Serializable; | |
4 | + | |
3 | 5 | import com.fasterxml.jackson.annotation.JsonInclude; |
4 | 6 | import com.fasterxml.jackson.annotation.JsonInclude.Include; |
5 | 7 | |
8 | +import io.swagger.annotations.ApiModelProperty; | |
9 | + | |
6 | 10 | @JsonInclude(Include.NON_EMPTY) |
7 | -public class OrderItemResponseDto { | |
11 | +public class OrderItemResponseDto implements Serializable { | |
8 | 12 | |
13 | + @ApiModelProperty("订单id") | |
9 | 14 | private Long orderId; |
15 | + @ApiModelProperty("商品id") | |
10 | 16 | private Long productId; |
17 | + @ApiModelProperty("商品sku") | |
11 | 18 | private String sku; |
19 | + @ApiModelProperty("sku标题") | |
12 | 20 | private String skuTitle; |
21 | + @ApiModelProperty("sku属性") | |
13 | 22 | private String skuAttributes; |
14 | - private Integer skuNum; | |
23 | + @ApiModelProperty("sku价格") | |
15 | 24 | private Long skuPrice; |
25 | + @ApiModelProperty("sku图片") | |
16 | 26 | private String skuPicture; |
27 | + @ApiModelProperty("sku单位") | |
17 | 28 | private String priceUnit; |
29 | + @ApiModelProperty("购买数量") | |
30 | + private Integer amount; | |
18 | 31 | |
19 | 32 | public Long getOrderId() { |
20 | 33 | return orderId; |
... | ... | @@ -56,14 +69,6 @@ public class OrderItemResponseDto { |
56 | 69 | this.skuAttributes = skuAttributes; |
57 | 70 | } |
58 | 71 | |
59 | - public Integer getSkuNum() { | |
60 | - return skuNum; | |
61 | - } | |
62 | - | |
63 | - public void setSkuNum(Integer skuNum) { | |
64 | - this.skuNum = skuNum; | |
65 | - } | |
66 | - | |
67 | 72 | public Long getSkuPrice() { |
68 | 73 | return skuPrice; |
69 | 74 | } |
... | ... | @@ -87,4 +92,13 @@ public class OrderItemResponseDto { |
87 | 92 | public void setPriceUnit(String priceUnit) { |
88 | 93 | this.priceUnit = priceUnit; |
89 | 94 | } |
95 | + | |
96 | + public Integer getAmount() { | |
97 | + return amount; | |
98 | + } | |
99 | + | |
100 | + public void setAmount(Integer amount) { | |
101 | + this.amount = amount; | |
102 | + } | |
103 | + | |
90 | 104 | } |
... | ... |
b2c-orders-client/src/main/java/com/b2c/orders/domain/client/dto/response/OrderListResponseDto.java
1 | 1 | package com.b2c.orders.domain.client.dto.response; |
2 | 2 | |
3 | -import java.util.Date; | |
4 | 3 | import java.util.List; |
5 | 4 | |
6 | -import com.b2c.orders.enums.DeliveryType; | |
7 | -import com.b2c.orders.enums.OrderStatus; | |
8 | -import com.b2c.orders.enums.PayStatus; | |
9 | -import com.b2c.orders.enums.PayType; | |
10 | -import com.fasterxml.jackson.annotation.JsonFormat; | |
11 | 5 | import com.fasterxml.jackson.annotation.JsonInclude; |
12 | 6 | import com.fasterxml.jackson.annotation.JsonInclude.Include; |
13 | 7 | |
8 | +import io.swagger.annotations.ApiModelProperty; | |
9 | + | |
14 | 10 | @JsonInclude(Include.NON_EMPTY) |
15 | 11 | public class OrderListResponseDto { |
16 | 12 | |
13 | + @ApiModelProperty("订单id") | |
14 | + private Long id; | |
17 | 15 | /** |
18 | 16 | * 店铺id |
19 | 17 | */ |
18 | + @ApiModelProperty("店铺id") | |
20 | 19 | private Long shopId; |
21 | 20 | /** |
22 | 21 | * 商家id |
23 | 22 | */ |
23 | + @ApiModelProperty("商家id") | |
24 | 24 | private Long sellerId; |
25 | 25 | /** |
26 | 26 | * 用户id |
27 | 27 | */ |
28 | + @ApiModelProperty("用户id") | |
28 | 29 | private Long buyerId; |
29 | - /** 配送类型 */ | |
30 | - private DeliveryType deliveryType; | |
31 | - /** 订单状态 */ | |
32 | - private OrderStatus orderStatus; | |
33 | - /** 支付状态 */ | |
34 | - private PayStatus payStatus; | |
35 | - /** 买家备注说明 */ | |
30 | + /** | |
31 | + * 配送类型 | |
32 | + */ | |
33 | + @ApiModelProperty("配送类型,10上门自提,20送货上门") | |
34 | + private Integer deliveryType; | |
35 | + /** | |
36 | + * 订单状态 | |
37 | + */ | |
38 | + @ApiModelProperty("订单状态,10待接单,15已接单待付款,20待自提,25待送货,30接单已过期,35支付超时,40已拒绝,45已取消,50已完成") | |
39 | + private Integer orderStatus; | |
40 | + /** | |
41 | + * 支付状态 | |
42 | + */ | |
43 | + @ApiModelProperty("支付状态,10未付款,20已付款") | |
44 | + private Integer payStatus; | |
45 | + /** | |
46 | + * 买家备注说明 | |
47 | + */ | |
48 | + @ApiModelProperty("买家备注说明") | |
36 | 49 | private String buyerMemo; |
37 | - /** 支付时间 */ | |
38 | - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |
39 | - private Date payTime; | |
50 | + /** | |
51 | + * 支付时间 | |
52 | + */ | |
53 | + @ApiModelProperty("支付时间") | |
54 | + private String payTime; | |
40 | 55 | /** |
41 | 56 | * 送货时间 |
42 | 57 | */ |
43 | - private Date deliveryTime; | |
44 | - /** 提货时间 */ | |
45 | - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |
46 | - private Date reservationTime; | |
47 | - /** 买家确认收货时间 */ | |
48 | - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |
49 | - private Date buyerConfirmTime; | |
50 | - /** 订单提交时间 */ | |
51 | - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |
52 | - private Date submitTime; | |
53 | - /** 支付类型 */ | |
54 | - private PayType payType; | |
55 | - /** 总金额 */ | |
58 | + @ApiModelProperty("送货时间") | |
59 | + private String deliveryTime; | |
60 | + /** | |
61 | + * 提货时间 | |
62 | + */ | |
63 | + @ApiModelProperty("提货时间") | |
64 | + private String reservationTime; | |
65 | + /** | |
66 | + * 买家确认收货时间 | |
67 | + */ | |
68 | + @ApiModelProperty("买家确认收货时间") | |
69 | + private String buyerConfirmTime; | |
70 | + /** | |
71 | + * 订单提交时间 | |
72 | + */ | |
73 | + @ApiModelProperty("订单提交时间") | |
74 | + private String submitTime; | |
75 | + /** | |
76 | + * 支付类型 | |
77 | + */ | |
78 | + @ApiModelProperty("支付类型") | |
79 | + private Integer payType; | |
80 | + /** | |
81 | + * 总金额 | |
82 | + */ | |
83 | + @ApiModelProperty("总金额") | |
56 | 84 | private Long totalPrice; |
57 | 85 | /** |
58 | 86 | * 接单后修改的价格 |
59 | 87 | */ |
88 | + @ApiModelProperty("接单后修改的价格") | |
60 | 89 | private Long realTotalPrice; |
61 | 90 | /** |
62 | 91 | * 订单项 |
63 | 92 | */ |
93 | + @ApiModelProperty("订单项") | |
64 | 94 | private List<OrderItemResponseDto> orderItems; |
65 | 95 | |
96 | + public Long getId() { | |
97 | + return id; | |
98 | + } | |
99 | + | |
100 | + public void setId(Long id) { | |
101 | + this.id = id; | |
102 | + } | |
103 | + | |
66 | 104 | public Long getShopId() { |
67 | 105 | return shopId; |
68 | 106 | } |
... | ... | @@ -87,27 +125,27 @@ public class OrderListResponseDto { |
87 | 125 | this.buyerId = buyerId; |
88 | 126 | } |
89 | 127 | |
90 | - public DeliveryType getDeliveryType() { | |
128 | + public Integer getDeliveryType() { | |
91 | 129 | return deliveryType; |
92 | 130 | } |
93 | 131 | |
94 | - public void setDeliveryType(DeliveryType deliveryType) { | |
132 | + public void setDeliveryType(Integer deliveryType) { | |
95 | 133 | this.deliveryType = deliveryType; |
96 | 134 | } |
97 | 135 | |
98 | - public OrderStatus getOrderStatus() { | |
136 | + public Integer getOrderStatus() { | |
99 | 137 | return orderStatus; |
100 | 138 | } |
101 | 139 | |
102 | - public void setOrderStatus(OrderStatus orderStatus) { | |
140 | + public void setOrderStatus(Integer orderStatus) { | |
103 | 141 | this.orderStatus = orderStatus; |
104 | 142 | } |
105 | 143 | |
106 | - public PayStatus getPayStatus() { | |
144 | + public Integer getPayStatus() { | |
107 | 145 | return payStatus; |
108 | 146 | } |
109 | 147 | |
110 | - public void setPayStatus(PayStatus payStatus) { | |
148 | + public void setPayStatus(Integer payStatus) { | |
111 | 149 | this.payStatus = payStatus; |
112 | 150 | } |
113 | 151 | |
... | ... | @@ -119,51 +157,51 @@ public class OrderListResponseDto { |
119 | 157 | this.buyerMemo = buyerMemo; |
120 | 158 | } |
121 | 159 | |
122 | - public Date getPayTime() { | |
160 | + public String getPayTime() { | |
123 | 161 | return payTime; |
124 | 162 | } |
125 | 163 | |
126 | - public void setPayTime(Date payTime) { | |
164 | + public void setPayTime(String payTime) { | |
127 | 165 | this.payTime = payTime; |
128 | 166 | } |
129 | 167 | |
130 | - public Date getDeliveryTime() { | |
168 | + public String getDeliveryTime() { | |
131 | 169 | return deliveryTime; |
132 | 170 | } |
133 | 171 | |
134 | - public void setDeliveryTime(Date deliveryTime) { | |
172 | + public void setDeliveryTime(String deliveryTime) { | |
135 | 173 | this.deliveryTime = deliveryTime; |
136 | 174 | } |
137 | 175 | |
138 | - public Date getReservationTime() { | |
176 | + public String getReservationTime() { | |
139 | 177 | return reservationTime; |
140 | 178 | } |
141 | 179 | |
142 | - public void setReservationTime(Date reservationTime) { | |
180 | + public void setReservationTime(String reservationTime) { | |
143 | 181 | this.reservationTime = reservationTime; |
144 | 182 | } |
145 | 183 | |
146 | - public Date getBuyerConfirmTime() { | |
184 | + public String getBuyerConfirmTime() { | |
147 | 185 | return buyerConfirmTime; |
148 | 186 | } |
149 | 187 | |
150 | - public void setBuyerConfirmTime(Date buyerConfirmTime) { | |
188 | + public void setBuyerConfirmTime(String buyerConfirmTime) { | |
151 | 189 | this.buyerConfirmTime = buyerConfirmTime; |
152 | 190 | } |
153 | 191 | |
154 | - public Date getSubmitTime() { | |
192 | + public String getSubmitTime() { | |
155 | 193 | return submitTime; |
156 | 194 | } |
157 | 195 | |
158 | - public void setSubmitTime(Date submitTime) { | |
196 | + public void setSubmitTime(String submitTime) { | |
159 | 197 | this.submitTime = submitTime; |
160 | 198 | } |
161 | 199 | |
162 | - public PayType getPayType() { | |
200 | + public Integer getPayType() { | |
163 | 201 | return payType; |
164 | 202 | } |
165 | 203 | |
166 | - public void setPayType(PayType payType) { | |
204 | + public void setPayType(Integer payType) { | |
167 | 205 | this.payType = payType; |
168 | 206 | } |
169 | 207 | |
... | ... |
b2c-orders-client/src/main/java/com/b2c/orders/domain/client/dto/response/SubmitOrderResponseDto.java
0 → 100644
1 | +package com.b2c.orders.domain.client.dto.response; | |
2 | + | |
3 | +import java.io.Serializable; | |
4 | + | |
5 | +public class SubmitOrderResponseDto implements Serializable { | |
6 | + | |
7 | + /** | |
8 | + * | |
9 | + */ | |
10 | + private static final long serialVersionUID = 7346584805399232189L; | |
11 | + | |
12 | + private Long orderId; | |
13 | + | |
14 | + public Long getOrderId() { | |
15 | + return orderId; | |
16 | + } | |
17 | + | |
18 | + public void setOrderId(Long orderId) { | |
19 | + this.orderId = orderId; | |
20 | + } | |
21 | + | |
22 | +} | |
... | ... |
b2c-orders-client/src/main/java/com/b2c/orders/domain/client/service/OrderService.java
... | ... | @@ -15,6 +15,7 @@ import com.b2c.orders.domain.client.dto.response.ApiPageDataResponse; |
15 | 15 | import com.b2c.orders.domain.client.dto.response.ApiResponse; |
16 | 16 | import com.b2c.orders.domain.client.dto.response.OrderDetailResponseDto; |
17 | 17 | import com.b2c.orders.domain.client.dto.response.OrderListResponseDto; |
18 | +import com.b2c.orders.domain.client.dto.response.SubmitOrderResponseDto; | |
18 | 19 | |
19 | 20 | public interface OrderService { |
20 | 21 | |
... | ... | @@ -24,7 +25,7 @@ public interface OrderService { |
24 | 25 | * @param order |
25 | 26 | * @return |
26 | 27 | */ |
27 | - ApiResponse submit(SubmitOrderRequestDto request); | |
28 | + ApiDataResponse<SubmitOrderResponseDto> submit(SubmitOrderRequestDto request); | |
28 | 29 | |
29 | 30 | /** |
30 | 31 | * 卖家接单 |
... | ... |
b2c-orders-client/src/main/java/com/b2c/orders/domain/client/service/impl/OrderServiceBean.java
... | ... | @@ -19,6 +19,7 @@ import com.b2c.orders.domain.client.dto.response.ApiPageDataResponse; |
19 | 19 | import com.b2c.orders.domain.client.dto.response.ApiResponse; |
20 | 20 | import com.b2c.orders.domain.client.dto.response.OrderDetailResponseDto; |
21 | 21 | import com.b2c.orders.domain.client.dto.response.OrderListResponseDto; |
22 | +import com.b2c.orders.domain.client.dto.response.SubmitOrderResponseDto; | |
22 | 23 | import com.b2c.orders.domain.client.service.OrderService; |
23 | 24 | import com.fasterxml.jackson.databind.ObjectMapper; |
24 | 25 | |
... | ... | @@ -36,9 +37,10 @@ public class OrderServiceBean implements OrderService { |
36 | 37 | this.baseUrl = baseUrl; |
37 | 38 | } |
38 | 39 | |
40 | + @SuppressWarnings("unchecked") | |
39 | 41 | @Override |
40 | - public ApiResponse submit(SubmitOrderRequestDto request) { | |
41 | - ApiResponse response = new ApiResponse(); | |
42 | + public ApiDataResponse<SubmitOrderResponseDto> submit(SubmitOrderRequestDto request) { | |
43 | + ApiDataResponse<SubmitOrderResponseDto> response = new ApiDataResponse<>(); | |
42 | 44 | try { |
43 | 45 | ObjectMapper mapper = new ObjectMapper(); |
44 | 46 | String json = mapper.writeValueAsString(request); |
... | ... |
b2c-orders-commons/src/main/java/com/b2c/orders/commons/constant/MqTopic.java
0 → 100644
1 | +package com.b2c.orders.commons.constant; | |
2 | + | |
3 | +/** | |
4 | + * 订单发送短信和站内信--转发中心专用 | |
5 | + * 使用这类topic消息内容必须含orderId,因为该类消息是以orderId排序的(相同的orderId不同的消息接受顺序和发送顺序严格一至) | |
6 | + */ | |
7 | +public enum MqTopic { | |
8 | + | |
9 | + /** 订单mqtopic */ | |
10 | + ORDER_MQ_TOPIC("ORDER_MQ_TOPIC"), ORDER_MQ_TAG("ORDER_MQ_TAG"); | |
11 | + | |
12 | + // 成员变量 | |
13 | + private String code; | |
14 | + | |
15 | + // 构造方法 | |
16 | + private MqTopic(String code) { | |
17 | + this.code = code; | |
18 | + } | |
19 | + | |
20 | + public String getCode() { | |
21 | + return code; | |
22 | + } | |
23 | + | |
24 | + public void setCode(String code) { | |
25 | + this.code = code; | |
26 | + } | |
27 | +} | |
0 | 28 | \ No newline at end of file |
... | ... |
b2c-orders-commons/src/main/java/com/b2c/orders/commons/exceptions/OrderMQException.java
0 → 100644
1 | +package com.b2c.orders.commons.exceptions; | |
2 | + | |
3 | +public class OrderMQException extends ApplicationException { | |
4 | + | |
5 | + /** | |
6 | + * | |
7 | + */ | |
8 | + private static final long serialVersionUID = 5578718387413556904L; | |
9 | + | |
10 | + public OrderMQException(int code) { | |
11 | + super(code); | |
12 | + // TODO Auto-generated constructor stub | |
13 | + } | |
14 | + | |
15 | + public OrderMQException(int code, String message, Throwable cause, boolean enableSuppression, | |
16 | + boolean writableStackTrace) { | |
17 | + super(code, message, cause, enableSuppression, writableStackTrace); | |
18 | + // TODO Auto-generated constructor stub | |
19 | + } | |
20 | + | |
21 | + public OrderMQException(int code, String message, Throwable cause) { | |
22 | + super(code, message, cause); | |
23 | + // TODO Auto-generated constructor stub | |
24 | + } | |
25 | + | |
26 | + public OrderMQException(int code, String message) { | |
27 | + super(code, message); | |
28 | + // TODO Auto-generated constructor stub | |
29 | + } | |
30 | + | |
31 | + public OrderMQException(int code, Throwable cause) { | |
32 | + super(code, cause); | |
33 | + // TODO Auto-generated constructor stub | |
34 | + } | |
35 | + | |
36 | +} | |
... | ... |
b2c-orders-dao/src/main/java/com/b2c/orders/dao/BuyerDao.java deleted
100644 → 0
1 | -package com.b2c.orders.dao; | |
2 | - | |
3 | -import com.b2c.orders.commons.exceptions.BuyerException; | |
4 | -import com.b2c.orders.commons.exceptions.ShopBuyerException; | |
5 | -import com.b2c.orders.domain.Buyer; | |
6 | - | |
7 | -public interface BuyerDao { | |
8 | - | |
9 | - Buyer findByBuyerShopId(Long buyerShopId) throws BuyerException, ShopBuyerException; | |
10 | -} |
b2c-orders-dao/src/main/java/com/b2c/orders/dao/SellerDao.java deleted
100644 → 0
1 | -package com.b2c.orders.dao; | |
2 | - | |
3 | -import com.b2c.orders.commons.exceptions.SellerException; | |
4 | -import com.b2c.orders.commons.exceptions.ShopBuyerException; | |
5 | -import com.b2c.orders.domain.Seller; | |
6 | - | |
7 | -public interface SellerDao { | |
8 | - | |
9 | - Seller findByBuyerShopId(Long buyerShopId) throws SellerException, ShopBuyerException; | |
10 | -} |
b2c-orders-dao/src/main/java/com/b2c/orders/dao/ShopBuyerDao.java deleted
100644 → 0
1 | -package com.b2c.orders.dao; | |
2 | - | |
3 | -import com.b2c.myapp.common.api.shopBuyer.output.ShopBuyerKeyOutput; | |
4 | -import com.b2c.orders.commons.exceptions.ShopBuyerException; | |
5 | - | |
6 | -public interface ShopBuyerDao { | |
7 | - | |
8 | - ShopBuyerKeyOutput findByShopBuyerId(Long shopBuyerId) throws ShopBuyerException; | |
9 | -} |
b2c-orders-dao/src/main/java/com/b2c/orders/dao/ShopDao.java deleted
100644 → 0
1 | -package com.b2c.orders.dao; | |
2 | - | |
3 | -import com.b2c.orders.commons.exceptions.ShopBuyerException; | |
4 | -import com.b2c.orders.commons.exceptions.ShopException; | |
5 | -import com.b2c.orders.domain.Shop; | |
6 | - | |
7 | -public interface ShopDao { | |
8 | - | |
9 | - Shop findByBuyerShopId(Long shopBuyerId) throws ShopException, ShopBuyerException; | |
10 | -} |
b2c-orders-dao/src/main/java/com/b2c/orders/dao/impl/BuyerDaoBean.java deleted
100644 → 0
1 | -package com.b2c.orders.dao.impl; | |
2 | - | |
3 | -import org.springframework.beans.factory.annotation.Autowired; | |
4 | -import org.springframework.stereotype.Repository; | |
5 | - | |
6 | -import com.b2c.myapp.common.api.buyerInfo.output.BuyerInfoOutput; | |
7 | -import com.b2c.myapp.common.api.shopBuyer.output.ShopBuyerKeyOutput; | |
8 | -import com.b2c.myapp.common.utils.BaseOutput; | |
9 | -import com.b2c.myapp.sdk.MyAppClient; | |
10 | -import com.b2c.myapp.sdk.service.BuyerInfoService; | |
11 | -import com.b2c.orders.commons.cache.impl.CacheManagerBean; | |
12 | -import com.b2c.orders.commons.exceptions.ApplicationException; | |
13 | -import com.b2c.orders.commons.exceptions.BuyerException; | |
14 | -import com.b2c.orders.commons.exceptions.ShopBuyerException; | |
15 | -import com.b2c.orders.dao.BuyerDao; | |
16 | -import com.b2c.orders.dao.ShopBuyerDao; | |
17 | -import com.b2c.orders.domain.Buyer; | |
18 | - | |
19 | -@Repository | |
20 | -public class BuyerDaoBean implements BuyerDao { | |
21 | - | |
22 | - private static final String BUYER_CACHE_KEY = "b2c_redis_buyer_"; | |
23 | - | |
24 | - @Autowired | |
25 | - private CacheManagerBean cacheManager; | |
26 | - @Autowired | |
27 | - private MyAppClient myAppClient; | |
28 | - @Autowired | |
29 | - private ShopBuyerDao shopBuyerDao; | |
30 | - | |
31 | - @Override | |
32 | - public Buyer findByBuyerShopId(Long shopBuyerId) throws BuyerException, ShopBuyerException { | |
33 | - ShopBuyerKeyOutput output = this.shopBuyerDao.findByShopBuyerId(shopBuyerId); | |
34 | - if (output == null) { | |
35 | - return null; | |
36 | - } | |
37 | - String key = BUYER_CACHE_KEY + output.getBuyerId(); | |
38 | - Buyer buyer = this.cacheManager.get(key, Buyer.class); | |
39 | - BuyerInfoService bis = this.myAppClient.getBuyerInfoService(); | |
40 | - BaseOutput<BuyerInfoOutput> bo = bis.getBuyerInfoById(output.getBuyerId()); | |
41 | - if (bo == null || !bo.getCode().equals("200")) { | |
42 | - throw new BuyerException(ApplicationException.DATA_EXCEPTION, "获取买家信息失败"); | |
43 | - } | |
44 | - BuyerInfoOutput bio = bo.getData(); | |
45 | - buyer = new Buyer(); | |
46 | - buyer.setId(bio.getId()); | |
47 | - buyer.setName(bio.getAccountName()); | |
48 | - buyer.setPhoneNumber(bio.getMobilePhone()); | |
49 | - this.cacheManager.put(key, buyer); | |
50 | - return buyer; | |
51 | - } | |
52 | - | |
53 | -} |
b2c-orders-dao/src/main/java/com/b2c/orders/dao/impl/SellerDaoBean.java deleted
100644 → 0
1 | -package com.b2c.orders.dao.impl; | |
2 | - | |
3 | -import org.springframework.beans.factory.annotation.Autowired; | |
4 | -import org.springframework.stereotype.Repository; | |
5 | - | |
6 | -import com.b2c.myapp.common.api.sellerInfo.output.SellerInfoOutput; | |
7 | -import com.b2c.myapp.common.api.shopBuyer.output.ShopBuyerKeyOutput; | |
8 | -import com.b2c.myapp.common.utils.BaseOutput; | |
9 | -import com.b2c.myapp.sdk.MyAppClient; | |
10 | -import com.b2c.myapp.sdk.service.SellerInfoService; | |
11 | -import com.b2c.orders.commons.cache.impl.CacheManagerBean; | |
12 | -import com.b2c.orders.commons.exceptions.ApplicationException; | |
13 | -import com.b2c.orders.commons.exceptions.SellerException; | |
14 | -import com.b2c.orders.commons.exceptions.ShopBuyerException; | |
15 | -import com.b2c.orders.dao.SellerDao; | |
16 | -import com.b2c.orders.dao.ShopBuyerDao; | |
17 | -import com.b2c.orders.domain.Seller; | |
18 | - | |
19 | -@Repository | |
20 | -public class SellerDaoBean implements SellerDao { | |
21 | - | |
22 | - private static final String SELLER_CACHE_KEY = "b2c_redis_seller_"; | |
23 | - | |
24 | - @Autowired | |
25 | - private MyAppClient myAppClient; | |
26 | - @Autowired | |
27 | - private CacheManagerBean cacheManager; | |
28 | - @Autowired | |
29 | - private ShopBuyerDao shopBuyerDao; | |
30 | - | |
31 | - @Override | |
32 | - public Seller findByBuyerShopId(Long shopBuyerId) throws SellerException, ShopBuyerException { | |
33 | - ShopBuyerKeyOutput output = this.shopBuyerDao.findByShopBuyerId(shopBuyerId); | |
34 | - if (output == null) { | |
35 | - return null; | |
36 | - } | |
37 | - String key = SELLER_CACHE_KEY + output.getSellerId(); | |
38 | - Seller seller = this.cacheManager.get(key, Seller.class); | |
39 | - if (seller != null) { | |
40 | - return seller; | |
41 | - } | |
42 | - SellerInfoService sis = this.myAppClient.getSellerInfoService(); | |
43 | - BaseOutput<SellerInfoOutput> bo = sis.getSellerInfoById(output.getSellerId()); | |
44 | - if (bo == null || !bo.getCode().equals("200")) { | |
45 | - throw new SellerException(ApplicationException.DATA_EXCEPTION, "获取卖家信息失败"); | |
46 | - } | |
47 | - SellerInfoOutput sio = bo.getData(); | |
48 | - seller = new Seller(); | |
49 | - seller.setId(sio.getId()); | |
50 | - seller.setName(sio.getAccountName()); | |
51 | - seller.setPhoneNumber(sio.getMobilePhone()); | |
52 | - this.cacheManager.put(key, seller); | |
53 | - return seller; | |
54 | - } | |
55 | - | |
56 | -} |
b2c-orders-dao/src/main/java/com/b2c/orders/dao/impl/ShopBuyerDaoBean.java deleted
100644 → 0
1 | -package com.b2c.orders.dao.impl; | |
2 | - | |
3 | -import org.springframework.beans.factory.annotation.Autowired; | |
4 | -import org.springframework.stereotype.Repository; | |
5 | - | |
6 | -import com.b2c.myapp.common.api.shopBuyer.output.ShopBuyerKeyOutput; | |
7 | -import com.b2c.myapp.common.utils.BaseOutput; | |
8 | -import com.b2c.myapp.sdk.MyAppClient; | |
9 | -import com.b2c.myapp.sdk.service.ShopBuyerService; | |
10 | -import com.b2c.orders.commons.cache.impl.CacheManagerBean; | |
11 | -import com.b2c.orders.commons.exceptions.ApplicationException; | |
12 | -import com.b2c.orders.commons.exceptions.ShopBuyerException; | |
13 | -import com.b2c.orders.dao.ShopBuyerDao; | |
14 | - | |
15 | -@Repository | |
16 | -public class ShopBuyerDaoBean implements ShopBuyerDao { | |
17 | - | |
18 | - private static final String SHOP_BUYER_CACHE_KEY = "b2c_redis_shop_buyer_"; | |
19 | - | |
20 | - @Autowired | |
21 | - private MyAppClient myAppClient; | |
22 | - @Autowired | |
23 | - private CacheManagerBean cacheManager; | |
24 | - | |
25 | - @Override | |
26 | - public ShopBuyerKeyOutput findByShopBuyerId(Long buyerShopId) throws ShopBuyerException { | |
27 | - ShopBuyerService sbs = this.myAppClient.getShopBuyerService(); | |
28 | - String key = SHOP_BUYER_CACHE_KEY + buyerShopId; | |
29 | - ShopBuyerKeyOutput output = this.cacheManager.get(key, ShopBuyerKeyOutput.class); | |
30 | - if (output == null) { | |
31 | - BaseOutput<ShopBuyerKeyOutput> response = sbs.getShopBuyerKeys(buyerShopId); | |
32 | - if (response == null || !response.getCode().equals("200")) { | |
33 | - throw new ShopBuyerException(ApplicationException.DATA_EXCEPTION, "获取卖家信息失败"); | |
34 | - } | |
35 | - output = response.getData(); | |
36 | - if (output != null) { | |
37 | - this.cacheManager.put(key, output); | |
38 | - } | |
39 | - } | |
40 | - return output; | |
41 | - } | |
42 | - | |
43 | -} |
b2c-orders-dao/src/main/java/com/b2c/orders/dao/impl/ShopDaoBean.java deleted
100644 → 0
1 | -package com.b2c.orders.dao.impl; | |
2 | - | |
3 | -import org.slf4j.Logger; | |
4 | -import org.slf4j.LoggerFactory; | |
5 | -import org.springframework.beans.factory.annotation.Autowired; | |
6 | -import org.springframework.stereotype.Repository; | |
7 | - | |
8 | -import com.b2c.myapp.common.api.shop.output.ShopOutput; | |
9 | -import com.b2c.myapp.common.api.shopBuyer.output.ShopBuyerKeyOutput; | |
10 | -import com.b2c.myapp.common.utils.BaseOutput; | |
11 | -import com.b2c.myapp.sdk.MyAppClient; | |
12 | -import com.b2c.myapp.sdk.service.ShopInfoService; | |
13 | -import com.b2c.orders.commons.cache.impl.CacheManagerBean; | |
14 | -import com.b2c.orders.commons.exceptions.ApplicationException; | |
15 | -import com.b2c.orders.commons.exceptions.ShopBuyerException; | |
16 | -import com.b2c.orders.commons.exceptions.ShopException; | |
17 | -import com.b2c.orders.dao.ShopBuyerDao; | |
18 | -import com.b2c.orders.dao.ShopDao; | |
19 | -import com.b2c.orders.domain.Shop; | |
20 | - | |
21 | -@Repository | |
22 | -public class ShopDaoBean implements ShopDao { | |
23 | - | |
24 | - private static final Logger LOG = LoggerFactory.getLogger(ShopDaoBean.class); | |
25 | - private static final String SHOP_CACHE_KEY = "b2c_redis_shop_"; | |
26 | - | |
27 | - @Autowired | |
28 | - private CacheManagerBean cacheManager; | |
29 | - @Autowired | |
30 | - private ShopBuyerDao shopBuyerDao; | |
31 | - @Autowired | |
32 | - private MyAppClient myAppClient; | |
33 | - | |
34 | - @Override | |
35 | - public Shop findByBuyerShopId(Long shopBuyerId) throws ShopException, ShopBuyerException { | |
36 | - ShopBuyerKeyOutput sbkOutput = this.shopBuyerDao.findByShopBuyerId(shopBuyerId); | |
37 | - if (sbkOutput == null) { | |
38 | - return null; | |
39 | - } | |
40 | - String key = SHOP_CACHE_KEY + sbkOutput.getShopId(); | |
41 | - Shop shop = this.cacheManager.get(key, Shop.class); | |
42 | - if (shop != null) { | |
43 | - return shop; | |
44 | - } | |
45 | - ShopInfoService sis = this.myAppClient.getShopInfoService(); | |
46 | - BaseOutput<ShopOutput> shopResponse = sis.getShopByShopId(sbkOutput.getShopId()); | |
47 | - if (shopResponse == null || !shopResponse.getCode().equals("200")) { | |
48 | - LOG.error( | |
49 | - String.format("调用店铺接口失败,ShopInfoService,Method:getShopByShopId,params:%s", sbkOutput.getShopId())); | |
50 | - throw new ShopException(ApplicationException.DATA_EXCEPTION, "获取店铺信息失败"); | |
51 | - } | |
52 | - ShopOutput rpcShop = shopResponse.getData(); | |
53 | - shop = new Shop(); | |
54 | - shop.setId(rpcShop.getId()); | |
55 | - shop.setName(rpcShop.getShopName()); | |
56 | - shop.setShopAddress(rpcShop.getAddressDetail()); | |
57 | - shop.setShopPhoneNumber(rpcShop.getServiceTel()); | |
58 | - shop.setFreeShippingPrice(rpcShop.getFreeShippingPrice()); | |
59 | - shop.setPostage(rpcShop.getPostage()); | |
60 | - this.cacheManager.put(key, shop); | |
61 | - return shop; | |
62 | - } | |
63 | - | |
64 | -} |
b2c-orders-dao/src/main/resources/sqlmap/OrderMapper.xml
... | ... | @@ -36,6 +36,8 @@ |
36 | 36 | <result property="shopPhoneNumber" column="shop_phone_number" /> |
37 | 37 | <result property="shopAddress" column="shop_address" /> |
38 | 38 | <result property="tradeName" column="trade_name" /> |
39 | + <result property="cityId" column="city_id" /> | |
40 | + <result property="cityName" column="city_name" /> | |
39 | 41 | <collection property="orderItems" column="id" |
40 | 42 | select="com.b2c.orders.dao.impl.OrderItemDaoBean.findByOrderId" /> |
41 | 43 | </resultMap> |
... | ... | @@ -72,6 +74,8 @@ |
72 | 74 | ,t1.shop_phone_number |
73 | 75 | ,t1.shop_address |
74 | 76 | ,t1.trade_name |
77 | + ,t1.city_id | |
78 | + ,t1.city_name | |
75 | 79 | </sql> |
76 | 80 | |
77 | 81 | <sql id="selectCondition"> |
... | ... | @@ -213,7 +217,9 @@ |
213 | 217 | receiver_phone_number, |
214 | 218 | pay_type, |
215 | 219 | total_price, |
216 | - trade_name | |
220 | + trade_name, | |
221 | + city_id, | |
222 | + city_name | |
217 | 223 | ) VALUES( |
218 | 224 | #{id}, |
219 | 225 | #{buyerId}, |
... | ... | @@ -238,7 +244,9 @@ |
238 | 244 | #{receiverPhoneNumber}, |
239 | 245 | #{payType}, |
240 | 246 | #{totalPrice}, |
241 | - #{tradeName} | |
247 | + #{tradeName}, | |
248 | + #{cityId}, | |
249 | + #{cityName} | |
242 | 250 | ) |
243 | 251 | ]]> |
244 | 252 | </insert> |
... | ... |
b2c-orders-domain/pom.xml
... | ... | @@ -12,12 +12,12 @@ |
12 | 12 | <dependency> |
13 | 13 | <groupId>${project.groupId}</groupId> |
14 | 14 | <artifactId>b2c-orders-commons</artifactId> |
15 | - <version>${project.version}</version> | |
15 | + <version>${project.parent.version}</version> | |
16 | 16 | </dependency> |
17 | 17 | <dependency> |
18 | 18 | <groupId>${project.groupId}</groupId> |
19 | 19 | <artifactId>b2c-orders-client</artifactId> |
20 | - <version>${project.version}</version> | |
20 | + <version>0.0.3-SNAPSHOT</version> | |
21 | 21 | </dependency> |
22 | 22 | <dependency> |
23 | 23 | <groupId>org.projectlombok</groupId> |
... | ... |
b2c-orders-domain/src/main/java/com/b2c/orders/domain/Buyer.java deleted
100644 → 0
b2c-orders-domain/src/main/java/com/b2c/orders/domain/Order.java
... | ... | @@ -7,8 +7,6 @@ package com.b2c.orders.domain; |
7 | 7 | import java.util.Date; |
8 | 8 | import java.util.List; |
9 | 9 | |
10 | -import com.b2c.orders.commons.exceptions.ApplicationException; | |
11 | -import com.b2c.orders.commons.exceptions.OrderException; | |
12 | 10 | import com.b2c.orders.enums.DeliveryType; |
13 | 11 | import com.b2c.orders.enums.OrderStatus; |
14 | 12 | import com.b2c.orders.enums.PayStatus; |
... | ... | @@ -53,6 +51,14 @@ public class Order extends BaseDomain { |
53 | 51 | private String sellerName; |
54 | 52 | private String sellerPhoneNumber; |
55 | 53 | /** |
54 | + * 城市id | |
55 | + */ | |
56 | + private Long cityId; | |
57 | + /** | |
58 | + * 城市名称 | |
59 | + */ | |
60 | + private String cityName; | |
61 | + /** | |
56 | 62 | * 市场id |
57 | 63 | */ |
58 | 64 | private Long marketId; |
... | ... | @@ -122,110 +128,6 @@ public class Order extends BaseDomain { |
122 | 128 | */ |
123 | 129 | private List<OrderItem> orderItems; |
124 | 130 | |
125 | - /** | |
126 | - * 商家接单 | |
127 | - * | |
128 | - * @param totalPrice | |
129 | - * 订单总价(根据需求文档,商家接单接单需要手动修改订单价格) | |
130 | - * | |
131 | - * @throws OrderException | |
132 | - */ | |
133 | - public void take(Long totalPrice) throws OrderException { | |
134 | - if (!this.orderStatus.equals(OrderStatus.PendingTake)) { | |
135 | - throw new OrderException(OrderException.ORDER_STATUS_FLOW_EXCEPTION, "订单状态流转顺序异常"); | |
136 | - } | |
137 | - this.orderStatus = OrderStatus.PendingPayment; | |
138 | - this.payStatus = PayStatus.PayWait; | |
139 | - this.realTotalPrice = totalPrice; | |
140 | - } | |
141 | - | |
142 | - /** | |
143 | - * 买家支付 | |
144 | - * | |
145 | - * @param payType | |
146 | - * TODO | |
147 | - * | |
148 | - * @throws OrderException | |
149 | - */ | |
150 | - public void pay(PayType payType) throws OrderException { | |
151 | - if (!this.orderStatus.equals(OrderStatus.PendingPayment)) { | |
152 | - throw new OrderException(ApplicationException.DATA_EXCEPTION, "当前订单状态不允许支付"); | |
153 | - } | |
154 | - this.payType = payType; | |
155 | - this.payStatus = PayStatus.Paid; | |
156 | - this.payTime = new Date(); | |
157 | - if (this.deliveryType.equals(DeliveryType.Delivery)) { | |
158 | - this.orderStatus = OrderStatus.PendingDelivery; | |
159 | - } else if (this.deliveryType.equals(DeliveryType.Self)) { | |
160 | - this.orderStatus = OrderStatus.PendingStoreMention; | |
161 | - } else { | |
162 | - throw new OrderException(ApplicationException.DATA_EXCEPTION, "未知的支付类型"); | |
163 | - } | |
164 | - } | |
165 | - | |
166 | - /** | |
167 | - * 商家确认收款或买家确认收货 | |
168 | - * | |
169 | - * @throws OrderException | |
170 | - */ | |
171 | - public void confirm() throws OrderException { | |
172 | - if (!this.orderStatus.equals(OrderStatus.PendingDelivery) | |
173 | - && !this.orderStatus.equals(OrderStatus.PendingStoreMention)) { | |
174 | - throw new OrderException(OrderException.ORDER_STATUS_FLOW_EXCEPTION, "当前订单状态不能确认收货"); | |
175 | - } | |
176 | - this.orderStatus = OrderStatus.Completed; | |
177 | - } | |
178 | - | |
179 | - /** | |
180 | - * 拒绝接单 | |
181 | - * | |
182 | - * @param refuseReason | |
183 | - * @throws OrderException | |
184 | - */ | |
185 | - public void refuse(String refuseReason) throws OrderException { | |
186 | - if (!this.orderStatus.equals(OrderStatus.PendingTake)) { | |
187 | - throw new OrderException(OrderException.ORDER_STATUS_FLOW_EXCEPTION, "当前订单状态不能拒绝接单"); | |
188 | - } | |
189 | - this.orderStatus = OrderStatus.Refused; | |
190 | - this.statusInReason = refuseReason; | |
191 | - } | |
192 | - | |
193 | - /** | |
194 | - * 取消订单 | |
195 | - * | |
196 | - * @throws OrderException | |
197 | - */ | |
198 | - public void cancel() throws OrderException { | |
199 | - if (!this.isCanCancel()) { | |
200 | - throw new OrderException(OrderException.ORDER_STATUS_FLOW_EXCEPTION, "当前状态不能被取消"); | |
201 | - } | |
202 | - this.orderStatus = OrderStatus.Canceled; | |
203 | - } | |
204 | - | |
205 | - /** | |
206 | - * 接单超时 | |
207 | - * | |
208 | - * @throws OrderException | |
209 | - */ | |
210 | - public void takenTimeout() throws OrderException { | |
211 | - if (!this.orderStatus.equals(OrderStatus.PendingTake)) { | |
212 | - throw new OrderException(ApplicationException.DATA_EXCEPTION, "当前状态不能设置接单超时"); | |
213 | - } | |
214 | - this.orderStatus = OrderStatus.TakenTimeout; | |
215 | - } | |
216 | - | |
217 | - /** | |
218 | - * 支付超时 | |
219 | - * | |
220 | - * @throws OrderException | |
221 | - */ | |
222 | - public void paymentTimeout() throws OrderException { | |
223 | - if (!this.orderStatus.equals(OrderStatus.PendingPayment)) { | |
224 | - throw new OrderException(ApplicationException.DATA_EXCEPTION, "当前状态不能设置接单超时"); | |
225 | - } | |
226 | - this.orderStatus = OrderStatus.PaymentTimeout; | |
227 | - } | |
228 | - | |
229 | 131 | @JsonIgnore |
230 | 132 | public boolean isCanCancel() { |
231 | 133 | if (this.orderStatus.equals(OrderStatus.PendingTake)) { |
... | ... |
b2c-orders-domain/src/main/java/com/b2c/orders/domain/Seller.java deleted
100644 → 0
1 | -package com.b2c.orders.domain; | |
2 | - | |
3 | -import java.io.Serializable; | |
4 | - | |
5 | -import lombok.Data; | |
6 | - | |
7 | -@Data | |
8 | -public class Seller implements Serializable { | |
9 | - | |
10 | - /** | |
11 | - * | |
12 | - */ | |
13 | - private static final long serialVersionUID = 7404217578749853392L; | |
14 | - | |
15 | - private Long id; | |
16 | - private String name; | |
17 | - private String phoneNumber; | |
18 | -} |
b2c-orders-domain/src/main/java/com/b2c/orders/domain/Shop.java deleted
100644 → 0
b2c-orders-domain/src/main/java/com/b2c/orders/domain/vo/OrderItemVo.java
0 → 100644
1 | +package com.b2c.orders.domain.vo; | |
2 | + | |
3 | +import com.b2c.orders.domain.rpc.Product; | |
4 | + | |
5 | +public class OrderItemVo { | |
6 | + | |
7 | + private Integer amount; | |
8 | + private Product product; | |
9 | + | |
10 | + public Integer getAmount() { | |
11 | + return amount; | |
12 | + } | |
13 | + | |
14 | + public void setAmount(Integer amount) { | |
15 | + this.amount = amount; | |
16 | + } | |
17 | + | |
18 | + public Product getProduct() { | |
19 | + return product; | |
20 | + } | |
21 | + | |
22 | + public void setProduct(Product product) { | |
23 | + this.product = product; | |
24 | + } | |
25 | + | |
26 | +} | |
... | ... |
b2c-orders-domain/src/main/java/com/b2c/orders/domain/vo/OrderVo.java
0 → 100644
1 | +package com.b2c.orders.domain.vo; | |
2 | + | |
3 | +import java.util.List; | |
4 | + | |
5 | +import com.b2c.orders.domain.rpc.Buyer; | |
6 | +import com.b2c.orders.domain.rpc.Seller; | |
7 | +import com.b2c.orders.domain.rpc.Shop; | |
8 | + | |
9 | +public class OrderVo { | |
10 | + | |
11 | + private Buyer buyer; | |
12 | + private Seller seller; | |
13 | + private Shop shop; | |
14 | + private Long shopBuyerId; | |
15 | + private Long marketId; | |
16 | + private Integer deliveryType; | |
17 | + private String buyerMemo; | |
18 | + private String deliveryTime; | |
19 | + private String receiverName; | |
20 | + private String deliveryAddress; | |
21 | + private Long cityId; | |
22 | + private String cityName; | |
23 | + private String receiverPhoneNumber; | |
24 | + private String reservationTime; | |
25 | + private List<OrderItemVo> orderItems; | |
26 | + | |
27 | + public Buyer getBuyer() { | |
28 | + return buyer; | |
29 | + } | |
30 | + | |
31 | + public void setBuyer(Buyer buyer) { | |
32 | + this.buyer = buyer; | |
33 | + } | |
34 | + | |
35 | + public Seller getSeller() { | |
36 | + return seller; | |
37 | + } | |
38 | + | |
39 | + public void setSeller(Seller seller) { | |
40 | + this.seller = seller; | |
41 | + } | |
42 | + | |
43 | + public Shop getShop() { | |
44 | + return shop; | |
45 | + } | |
46 | + | |
47 | + public void setShop(Shop shop) { | |
48 | + this.shop = shop; | |
49 | + } | |
50 | + | |
51 | + public Long getShopBuyerId() { | |
52 | + return shopBuyerId; | |
53 | + } | |
54 | + | |
55 | + public void setShopBuyerId(Long shopBuyerId) { | |
56 | + this.shopBuyerId = shopBuyerId; | |
57 | + } | |
58 | + | |
59 | + public Long getMarketId() { | |
60 | + return marketId; | |
61 | + } | |
62 | + | |
63 | + public void setMarketId(Long marketId) { | |
64 | + this.marketId = marketId; | |
65 | + } | |
66 | + | |
67 | + public Integer getDeliveryType() { | |
68 | + return deliveryType; | |
69 | + } | |
70 | + | |
71 | + public void setDeliveryType(Integer deliveryType) { | |
72 | + this.deliveryType = deliveryType; | |
73 | + } | |
74 | + | |
75 | + public String getBuyerMemo() { | |
76 | + return buyerMemo; | |
77 | + } | |
78 | + | |
79 | + public void setBuyerMemo(String buyerMemo) { | |
80 | + this.buyerMemo = buyerMemo; | |
81 | + } | |
82 | + | |
83 | + public String getDeliveryTime() { | |
84 | + return deliveryTime; | |
85 | + } | |
86 | + | |
87 | + public void setDeliveryTime(String deliveryTime) { | |
88 | + this.deliveryTime = deliveryTime; | |
89 | + } | |
90 | + | |
91 | + public String getReceiverName() { | |
92 | + return receiverName; | |
93 | + } | |
94 | + | |
95 | + public void setReceiverName(String receiverName) { | |
96 | + this.receiverName = receiverName; | |
97 | + } | |
98 | + | |
99 | + public String getDeliveryAddress() { | |
100 | + return deliveryAddress; | |
101 | + } | |
102 | + | |
103 | + public void setDeliveryAddress(String deliveryAddress) { | |
104 | + this.deliveryAddress = deliveryAddress; | |
105 | + } | |
106 | + | |
107 | + public Long getCityId() { | |
108 | + return cityId; | |
109 | + } | |
110 | + | |
111 | + public void setCityId(Long cityId) { | |
112 | + this.cityId = cityId; | |
113 | + } | |
114 | + | |
115 | + public String getCityName() { | |
116 | + return cityName; | |
117 | + } | |
118 | + | |
119 | + public void setCityName(String cityName) { | |
120 | + this.cityName = cityName; | |
121 | + } | |
122 | + | |
123 | + public String getReceiverPhoneNumber() { | |
124 | + return receiverPhoneNumber; | |
125 | + } | |
126 | + | |
127 | + public void setReceiverPhoneNumber(String receiverPhoneNumber) { | |
128 | + this.receiverPhoneNumber = receiverPhoneNumber; | |
129 | + } | |
130 | + | |
131 | + public String getReservationTime() { | |
132 | + return reservationTime; | |
133 | + } | |
134 | + | |
135 | + public void setReservationTime(String reservationTime) { | |
136 | + this.reservationTime = reservationTime; | |
137 | + } | |
138 | + | |
139 | + public List<OrderItemVo> getOrderItems() { | |
140 | + return orderItems; | |
141 | + } | |
142 | + | |
143 | + public void setOrderItems(List<OrderItemVo> orderItems) { | |
144 | + this.orderItems = orderItems; | |
145 | + } | |
146 | + | |
147 | +} | |
... | ... |
b2c-orders-manager/src/main/java/com/b2c/orders/manager/OrderManager.java
... | ... | @@ -9,10 +9,10 @@ import com.b2c.orders.commons.exceptions.SellerException; |
9 | 9 | import com.b2c.orders.commons.exceptions.ShopBuyerException; |
10 | 10 | import com.b2c.orders.commons.exceptions.ShopException; |
11 | 11 | import com.b2c.orders.domain.Order; |
12 | -import com.b2c.orders.domain.client.dto.request.SubmitOrderRequestDto; | |
12 | +import com.b2c.orders.domain.vo.OrderVo; | |
13 | 13 | import com.b2c.orders.enums.PayType; |
14 | 14 | import com.b2c.orders.enums.UserType; |
15 | -import com.b2c.orders.rpc.exception.DtmsRPCException; | |
15 | +import com.b2c.orders.service.rpc.exception.DtmsRPCException; | |
16 | 16 | import com.diligrp.website.util.dao.BaseQuery; |
17 | 17 | import com.diligrp.website.util.web.PageTemplate; |
18 | 18 | |
... | ... | @@ -22,6 +22,7 @@ public interface OrderManager { |
22 | 22 | * |
23 | 23 | * @param orderVo |
24 | 24 | * 订单属性 |
25 | + * @return TODO | |
25 | 26 | * @throws DtmsRPCException |
26 | 27 | * @throws OrderException |
27 | 28 | * @throws ProductException |
... | ... | @@ -30,7 +31,7 @@ public interface OrderManager { |
30 | 31 | * @throws ShopBuyerException |
31 | 32 | * @throws ShopException |
32 | 33 | */ |
33 | - void submit(SubmitOrderRequestDto orderVo) throws DtmsRPCException, OrderException, ProductException, | |
34 | + Long submit(OrderVo orderVo) throws DtmsRPCException, OrderException, ProductException, | |
34 | 35 | SellerException, BuyerException, ShopException, ShopBuyerException; |
35 | 36 | |
36 | 37 | /** |
... | ... | @@ -77,8 +78,9 @@ public interface OrderManager { |
77 | 78 | * 买家id |
78 | 79 | * @throws OrderRepositoryException |
79 | 80 | * @throws OrderException |
81 | + * @throws DtmsRPCException | |
80 | 82 | */ |
81 | - void buyerConfirm(Long orderId, Long shopBuyerId) throws OrderRepositoryException, OrderException; | |
83 | + void buyerConfirm(Long orderId, Long shopBuyerId) throws OrderRepositoryException, OrderException, DtmsRPCException; | |
82 | 84 | |
83 | 85 | /** |
84 | 86 | * 商家确认收款 |
... | ... | @@ -89,8 +91,9 @@ public interface OrderManager { |
89 | 91 | * 商家id |
90 | 92 | * @throws OrderRepositoryException |
91 | 93 | * @throws OrderException |
94 | + * @throws DtmsRPCException | |
92 | 95 | */ |
93 | - void sellerConfirm(Long orderId, Long sellerId) throws OrderRepositoryException, OrderException; | |
96 | + void sellerConfirm(Long orderId, Long sellerId) throws OrderRepositoryException, OrderException, DtmsRPCException; | |
94 | 97 | |
95 | 98 | /** |
96 | 99 | * 商家拒绝接单 |
... | ... | @@ -103,8 +106,9 @@ public interface OrderManager { |
103 | 106 | * TODO |
104 | 107 | * @throws OrderRepositoryException |
105 | 108 | * @throws OrderException |
109 | + * @throws DtmsRPCException | |
106 | 110 | */ |
107 | - void refuse(Long orderId, Long sellerId, String refuseReason) throws OrderRepositoryException, OrderException; | |
111 | + void refuse(Long orderId, Long sellerId, String refuseReason) throws OrderRepositoryException, OrderException, DtmsRPCException; | |
108 | 112 | |
109 | 113 | /** |
110 | 114 | * 取消订单 |
... | ... | @@ -115,8 +119,9 @@ public interface OrderManager { |
115 | 119 | * 买家id |
116 | 120 | * @throws OrderRepositoryException |
117 | 121 | * @throws OrderException |
122 | + * @throws DtmsRPCException | |
118 | 123 | */ |
119 | - void cancel(Long orderId, Long shopBuyerId) throws OrderRepositoryException, OrderException; | |
124 | + void cancel(Long orderId, Long shopBuyerId) throws OrderRepositoryException, OrderException, DtmsRPCException; | |
120 | 125 | |
121 | 126 | /** |
122 | 127 | * 订单超时 |
... | ... | @@ -145,8 +150,9 @@ public interface OrderManager { |
145 | 150 | * 订单id |
146 | 151 | * @throws OrderRepositoryException |
147 | 152 | * @throws OrderException |
153 | + * @throws DtmsRPCException | |
148 | 154 | */ |
149 | - void paymentTimeout(Long orderId) throws OrderRepositoryException, OrderException; | |
155 | + void paymentTimeout(Long orderId) throws OrderRepositoryException, OrderException, DtmsRPCException; | |
150 | 156 | |
151 | 157 | /** |
152 | 158 | * 订单详情 |
... | ... |
b2c-orders-manager/src/main/java/com/b2c/orders/manager/impl/BuyerManagerBean.java deleted
100644 → 0
1 | -package com.b2c.orders.manager.impl; | |
2 | - | |
3 | -import org.springframework.beans.factory.annotation.Autowired; | |
4 | -import org.springframework.cglib.beans.BeanCopier; | |
5 | -import org.springframework.stereotype.Component; | |
6 | - | |
7 | -import com.b2c.myapp.common.api.foundTrade.input.FoundTradeInput; | |
8 | -import com.b2c.myapp.common.api.foundTrade.input.FoundTradeSaveInput; | |
9 | -import com.b2c.myapp.common.enums.TradeType; | |
10 | -import com.b2c.myapp.sdk.MyAppClient; | |
11 | -import com.b2c.orders.manager.BuyerManager; | |
12 | -import com.b2c.orders.rpc.param.DebitParam; | |
13 | -import com.b2c.orders.rpc.param.LockBalanceParam; | |
14 | -import com.b2c.orders.rpc.param.UnlockBalanceParam; | |
15 | - | |
16 | -@Component | |
17 | -public class BuyerManagerBean implements BuyerManager { | |
18 | - | |
19 | - @Autowired | |
20 | - private MyAppClient myAppClient; | |
21 | - | |
22 | - @Override | |
23 | - public void lockBalance(LockBalanceParam param) { | |
24 | - FoundTradeSaveInput rpcParam = new FoundTradeSaveInput(); | |
25 | - BeanCopier copier = BeanCopier.create(LockBalanceParam.class, FoundTradeSaveInput.class, false); | |
26 | - copier.copy(param, rpcParam, null); | |
27 | - rpcParam.setTradeType(TradeType.Freeze); | |
28 | - this.myAppClient.getFoundTradeService().foundTrade(rpcParam); | |
29 | - } | |
30 | - | |
31 | - @Override | |
32 | - public void debit(DebitParam param) { | |
33 | - FoundTradeSaveInput rpcParam = new FoundTradeSaveInput(); | |
34 | - BeanCopier copier = BeanCopier.create(DebitParam.class, FoundTradeSaveInput.class, false); | |
35 | - copier.copy(param, rpcParam, null); | |
36 | - rpcParam.setTradeType(TradeType.Consume); | |
37 | - this.myAppClient.getFoundTradeService().foundTrade(rpcParam); | |
38 | - } | |
39 | - | |
40 | - @Override | |
41 | - public void unlockBalance(UnlockBalanceParam param) { | |
42 | - FoundTradeSaveInput rpcParam = new FoundTradeSaveInput(); | |
43 | - BeanCopier copier = BeanCopier.create(UnlockBalanceParam.class, FoundTradeInput.class, false); | |
44 | - copier.copy(param, rpcParam, null); | |
45 | - rpcParam.setTradeType(TradeType.Unfreeze); | |
46 | - this.myAppClient.getFoundTradeService().foundTrade(rpcParam); | |
47 | - } | |
48 | - | |
49 | -} |
b2c-orders-manager/src/main/java/com/b2c/orders/manager/impl/OrderManagerBean.java
... | ... | @@ -4,6 +4,7 @@ import java.text.DateFormat; |
4 | 4 | import java.text.ParseException; |
5 | 5 | import java.text.SimpleDateFormat; |
6 | 6 | import java.util.ArrayList; |
7 | +import java.util.Date; | |
7 | 8 | import java.util.LinkedHashSet; |
8 | 9 | import java.util.List; |
9 | 10 | import java.util.Set; |
... | ... | @@ -25,34 +26,31 @@ import com.b2c.orders.commons.exceptions.SellerException; |
25 | 26 | import com.b2c.orders.commons.exceptions.ShopBuyerException; |
26 | 27 | import com.b2c.orders.commons.exceptions.ShopException; |
27 | 28 | import com.b2c.orders.commons.utils.OrderIdGenerator; |
28 | -import com.b2c.orders.dao.BuyerDao; | |
29 | 29 | import com.b2c.orders.dao.OrderDao; |
30 | 30 | import com.b2c.orders.dao.OrderLogDao; |
31 | -import com.b2c.orders.dao.ProductDao; | |
32 | -import com.b2c.orders.dao.SellerDao; | |
33 | -import com.b2c.orders.dao.ShopDao; | |
34 | -import com.b2c.orders.domain.Buyer; | |
35 | 31 | import com.b2c.orders.domain.Order; |
36 | 32 | import com.b2c.orders.domain.OrderItem; |
37 | 33 | import com.b2c.orders.domain.OrderLog; |
38 | -import com.b2c.orders.domain.Seller; | |
39 | -import com.b2c.orders.domain.Shop; | |
40 | -import com.b2c.orders.domain.client.dto.request.OrderItemDto; | |
41 | -import com.b2c.orders.domain.client.dto.request.SubmitOrderRequestDto; | |
34 | +import com.b2c.orders.domain.rpc.Buyer; | |
42 | 35 | import com.b2c.orders.domain.rpc.Product; |
36 | +import com.b2c.orders.domain.rpc.Seller; | |
37 | +import com.b2c.orders.domain.rpc.Shop; | |
38 | +import com.b2c.orders.domain.vo.OrderItemVo; | |
39 | +import com.b2c.orders.domain.vo.OrderVo; | |
43 | 40 | import com.b2c.orders.enums.Action; |
44 | 41 | import com.b2c.orders.enums.DeliveryType; |
45 | 42 | import com.b2c.orders.enums.OrderStatus; |
46 | 43 | import com.b2c.orders.enums.PayStatus; |
47 | 44 | import com.b2c.orders.enums.PayType; |
48 | 45 | import com.b2c.orders.enums.UserType; |
49 | -import com.b2c.orders.manager.BuyerManager; | |
50 | 46 | import com.b2c.orders.manager.OrderManager; |
51 | -import com.b2c.orders.rpc.DtmsRPCService; | |
52 | -import com.b2c.orders.rpc.exception.DtmsRPCException; | |
53 | -import com.b2c.orders.rpc.param.DebitParam; | |
54 | -import com.b2c.orders.rpc.param.LockBalanceParam; | |
55 | -import com.b2c.orders.rpc.param.UnlockBalanceParam; | |
47 | +import com.b2c.orders.service.rpc.DtmsRPCService; | |
48 | +import com.b2c.orders.service.rpc.ShopBuyerRPCService; | |
49 | +import com.b2c.orders.service.rpc.exception.DtmsRPCException; | |
50 | +import com.b2c.orders.service.rpc.param.DebitParam; | |
51 | +import com.b2c.orders.service.rpc.param.LockBalanceParam; | |
52 | +import com.b2c.orders.service.rpc.param.OrderMQDto; | |
53 | +import com.b2c.orders.service.rpc.param.UnlockBalanceParam; | |
56 | 54 | import com.diligrp.website.util.dao.BaseQuery; |
57 | 55 | import com.diligrp.website.util.web.PageTemplate; |
58 | 56 | |
... | ... | @@ -67,41 +65,35 @@ public class OrderManagerBean implements OrderManager { |
67 | 65 | @Autowired |
68 | 66 | private OrderIdGenerator idGenerator; |
69 | 67 | @Autowired |
70 | - private DtmsRPCService dtmsService; | |
68 | + private DtmsRPCService dtmsRPC; | |
71 | 69 | @Autowired |
72 | - private OrderLogDao orderLogDao; | |
73 | - @Autowired | |
74 | - private ProductDao productDao; | |
75 | - @Autowired | |
76 | - private BuyerDao buyerDao; | |
70 | + private ShopBuyerRPCService shopBuyerRPC; | |
77 | 71 | @Autowired |
78 | - private SellerDao sellerDao; | |
79 | - @Autowired | |
80 | - private ShopDao shopDao; | |
81 | - @Autowired | |
82 | - private BuyerManager buyerManager; | |
72 | + private OrderLogDao orderLogDao; | |
83 | 73 | |
84 | 74 | @Override |
85 | - public void submit(SubmitOrderRequestDto orderVo) throws DtmsRPCException, OrderException, ProductException, | |
86 | - SellerException, BuyerException, ShopException, ShopBuyerException { | |
75 | + public Long submit(OrderVo orderVo) throws DtmsRPCException, OrderException, ProductException, SellerException, | |
76 | + BuyerException, ShopException, ShopBuyerException { | |
87 | 77 | Order po = new Order(); |
88 | 78 | try { |
89 | 79 | Long orderId = idGenerator.getOrdersNewSeqNo(); |
90 | 80 | po.setId(orderId); |
91 | 81 | po.setShopBuyerId(orderVo.getShopBuyerId()); |
92 | - Buyer buyer = this.buyerDao.findByBuyerShopId(orderVo.getShopBuyerId()); | |
82 | + Buyer buyer = orderVo.getBuyer(); | |
93 | 83 | po.setBuyerId(buyer.getId()); |
94 | 84 | po.setBuyerName(buyer.getName()); |
95 | 85 | po.setBuyerPhoneNumber(buyer.getPhoneNumber()); |
96 | - Seller seller = this.sellerDao.findByBuyerShopId(orderVo.getShopBuyerId()); | |
86 | + Seller seller = orderVo.getSeller(); | |
97 | 87 | po.setSellerId(seller.getId()); |
98 | 88 | po.setSellerName(seller.getName()); |
99 | 89 | po.setSellerPhoneNumber(seller.getPhoneNumber()); |
100 | - Shop shop = this.shopDao.findByBuyerShopId(orderVo.getShopBuyerId()); | |
90 | + Shop shop = orderVo.getShop(); | |
101 | 91 | po.setShopId(shop.getId()); |
102 | 92 | po.setShopName(shop.getName()); |
103 | 93 | po.setShopAddress(shop.getShopAddress()); |
104 | 94 | po.setShopPhoneNumber(shop.getShopPhoneNumber()); |
95 | + po.setCityId(orderVo.getCityId()); | |
96 | + po.setCityName(orderVo.getCityName()); | |
105 | 97 | po.setMarketId(orderVo.getMarketId()); |
106 | 98 | po.setBuyerMemo(orderVo.getBuyerMemo()); |
107 | 99 | DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
... | ... | @@ -128,25 +120,25 @@ public class OrderManagerBean implements OrderManager { |
128 | 120 | int itemIdx = 1; |
129 | 121 | Set<String> productNameSet = new LinkedHashSet<>(); |
130 | 122 | StringBuilder sb = new StringBuilder(); |
131 | - for (OrderItemDto orderItemDto : orderVo.getOrderItems()) { | |
123 | + for (OrderItemVo orderItemVo : orderVo.getOrderItems()) { | |
132 | 124 | Long orderItemId = idGenerator.getOrdersItemNewSeqNo(orderId, itemIdx++); |
133 | 125 | OrderItem orderItem = new OrderItem(); |
134 | 126 | orderItem.setId(orderItemId); |
135 | 127 | orderItem.setOrderId(orderId); |
136 | 128 | orderItem.setShopId(shop.getId()); |
137 | - orderItem.setAmount(orderItemDto.getAmount()); | |
138 | - Product product = this.productDao.findBySku(orderItemDto.getSku()); | |
129 | + orderItem.setAmount(orderItemVo.getAmount()); | |
130 | + Product product = orderItemVo.getProduct(); | |
139 | 131 | productNameSet.add(product.getName()); |
140 | 132 | orderItem.setProductId(product.getId()); |
141 | 133 | orderItem.setProductName(product.getName()); |
142 | - orderItem.setSku(orderItemDto.getSku()); | |
134 | + orderItem.setSku(product.getSku()); | |
143 | 135 | orderItem.setSkuAttributes(product.getSkuAttributes()); |
144 | 136 | orderItem.setSkuPicture(product.getSkuPicture()); |
145 | 137 | orderItem.setSkuPrice(product.getSkuPrice()); |
146 | 138 | orderItem.setSkuTitle(product.getSkuTitle()); |
147 | 139 | orderItem.setPriceUnit(product.getPriceUnit()); |
148 | 140 | orderItems.add(orderItem); |
149 | - totalPrice += product.getSkuPrice() * orderItemDto.getAmount(); | |
141 | + totalPrice += product.getSkuPrice() * orderItemVo.getAmount(); | |
150 | 142 | } |
151 | 143 | for (String productName : productNameSet) { |
152 | 144 | sb.append(productName).append("+"); |
... | ... | @@ -168,7 +160,9 @@ public class OrderManagerBean implements OrderManager { |
168 | 160 | log.setUserType(UserType.BUYER); |
169 | 161 | this.orderLogDao.save(log); |
170 | 162 | // 发送dtms消息 |
171 | - this.dtmsService.sendOrderTakenTimeoutDtms(po.getId()); | |
163 | + this.dtmsRPC.sendOrderTakenTimeoutDtms(po.getId()); | |
164 | + // this.notifyUser(po); | |
165 | + return po.getId(); | |
172 | 166 | } |
173 | 167 | |
174 | 168 | @Override |
... | ... | @@ -187,9 +181,14 @@ public class OrderManagerBean implements OrderManager { |
187 | 181 | } |
188 | 182 | OrderLog log = new OrderLog(); |
189 | 183 | log.setPreviousStatus(po.getOrderStatus()); |
190 | - po.take(totalPrice); | |
184 | + if (!po.getOrderStatus().equals(OrderStatus.PendingTake)) { | |
185 | + throw new OrderException(OrderException.ORDER_STATUS_FLOW_EXCEPTION, "订单状态流转顺序异常"); | |
186 | + } | |
187 | + po.setOrderStatus(OrderStatus.PendingPayment); | |
188 | + po.setPayStatus(PayStatus.PayWait); | |
189 | + po.setRealTotalPrice(totalPrice); | |
191 | 190 | log.setCurrentStatus(po.getOrderStatus()); |
192 | - Shop shop = this.shopDao.findByBuyerShopId(po.getShopBuyerId()); | |
191 | + Shop shop = this.shopBuyerRPC.findShopByBuyerShopId(po.getShopBuyerId()); | |
193 | 192 | Long shippingPrice = shop.getFreeShippingPrice(); |
194 | 193 | if (shippingPrice != null && shippingPrice > 0 && shippingPrice < totalPrice) { |
195 | 194 | po.setPostage(shop.getPostage()); |
... | ... | @@ -202,8 +201,17 @@ public class OrderManagerBean implements OrderManager { |
202 | 201 | log.setUserType(UserType.SELLER); |
203 | 202 | this.orderLogDao.save(log); |
204 | 203 | // 发送dtms订单支付超时消息 |
205 | - this.dtmsService.sendOrderPayTimeoutDtms(orderId); | |
204 | + this.dtmsRPC.sendOrderPayTimeoutDtms(orderId); | |
205 | + this.notifyUser(po); | |
206 | + } | |
206 | 207 | |
208 | + private void notifyUser(Order order) throws DtmsRPCException { | |
209 | + OrderMQDto orderDto = new OrderMQDto(); | |
210 | + orderDto.setBuyerId(order.getBuyerId()); | |
211 | + orderDto.setId(order.getId()); | |
212 | + orderDto.setOrderStatus(order.getOrderStatus().getIndex()); | |
213 | + orderDto.setSellerId(order.getSellerId()); | |
214 | + this.dtmsRPC.sendMQDtmsMessage(orderDto); | |
207 | 215 | } |
208 | 216 | |
209 | 217 | @Override |
... | ... | @@ -222,7 +230,19 @@ public class OrderManagerBean implements OrderManager { |
222 | 230 | } |
223 | 231 | OrderLog log = new OrderLog(); |
224 | 232 | log.setPreviousStatus(po.getOrderStatus()); |
225 | - po.pay(payType); | |
233 | + if (!po.getOrderStatus().equals(OrderStatus.PendingPayment)) { | |
234 | + throw new OrderException(ApplicationException.DATA_EXCEPTION, "当前订单状态不允许支付"); | |
235 | + } | |
236 | + po.setPayType(payType); | |
237 | + po.setPayStatus(PayStatus.Paid); | |
238 | + po.setPayTime(new Date()); | |
239 | + if (po.getDeliveryType().equals(DeliveryType.Delivery)) { | |
240 | + po.setOrderStatus(OrderStatus.PendingDelivery); | |
241 | + } else if (po.getDeliveryType().equals(DeliveryType.Self)) { | |
242 | + po.setOrderStatus(OrderStatus.PendingStoreMention); | |
243 | + } else { | |
244 | + throw new OrderException(ApplicationException.DATA_EXCEPTION, "未知的支付类型"); | |
245 | + } | |
226 | 246 | log.setCurrentStatus(po.getOrderStatus()); |
227 | 247 | this.orderDao.update(po); |
228 | 248 | log.setAction(Action.BUYER_PAY); |
... | ... | @@ -230,19 +250,21 @@ public class OrderManagerBean implements OrderManager { |
230 | 250 | log.setUserId(shopBuyerId); |
231 | 251 | log.setUserType(UserType.BUYER); |
232 | 252 | this.orderLogDao.save(log); |
233 | - this.dtmsService.sendOrderConfirmDtms(orderId); | |
253 | + this.dtmsRPC.sendOrderConfirmDtms(orderId); | |
234 | 254 | if (payType.equals(PayType.Online)) { |
235 | 255 | LockBalanceParam param = new LockBalanceParam(); |
236 | 256 | param.setOrderId(orderId); |
237 | 257 | param.setShopBuyerId(shopBuyerId); |
238 | 258 | param.setTradeName(po.getTradeName()); |
239 | 259 | param.setTradePrice(po.getRealTotalPrice()); |
240 | - this.buyerManager.lockBalance(param); | |
260 | + this.shopBuyerRPC.lockBalance(param); | |
241 | 261 | } |
262 | + this.notifyUser(po); | |
242 | 263 | } |
243 | 264 | |
244 | 265 | @Override |
245 | - public void buyerConfirm(Long orderId, Long shopBuyerId) throws OrderRepositoryException, OrderException { | |
266 | + public void buyerConfirm(Long orderId, Long shopBuyerId) | |
267 | + throws OrderRepositoryException, OrderException, DtmsRPCException { | |
246 | 268 | Order po = this.orderDao.getById(orderId); |
247 | 269 | if (po == null) { |
248 | 270 | throw new OrderRepositoryException(OrderRepositoryException.ENTITY_NOT_FOUND, |
... | ... | @@ -256,7 +278,11 @@ public class OrderManagerBean implements OrderManager { |
256 | 278 | } |
257 | 279 | OrderLog log = new OrderLog(); |
258 | 280 | log.setPreviousStatus(po.getOrderStatus()); |
259 | - po.confirm(); | |
281 | + if (!po.getOrderStatus().equals(OrderStatus.PendingDelivery) | |
282 | + && !po.getOrderStatus().equals(OrderStatus.PendingStoreMention)) { | |
283 | + throw new OrderException(OrderException.ORDER_STATUS_FLOW_EXCEPTION, "当前订单状态不能确认收货"); | |
284 | + } | |
285 | + po.setOrderStatus(OrderStatus.Completed); | |
260 | 286 | log.setCurrentStatus(po.getOrderStatus()); |
261 | 287 | this.orderDao.update(po); |
262 | 288 | log.setAction(Action.BUYER_CONFIRM); |
... | ... | @@ -269,11 +295,13 @@ public class OrderManagerBean implements OrderManager { |
269 | 295 | param.setShopBuyerId(shopBuyerId); |
270 | 296 | param.setTradeName(po.getTradeName()); |
271 | 297 | param.setTradePrice(po.getRealTotalPrice()); |
272 | - this.buyerManager.debit(param); | |
298 | + this.shopBuyerRPC.debit(param); | |
299 | + this.notifyUser(po); | |
273 | 300 | } |
274 | 301 | |
275 | 302 | @Override |
276 | - public void sellerConfirm(Long orderId, Long sellerId) throws OrderRepositoryException, OrderException { | |
303 | + public void sellerConfirm(Long orderId, Long sellerId) | |
304 | + throws OrderRepositoryException, OrderException, DtmsRPCException { | |
277 | 305 | Order po = this.orderDao.getById(orderId); |
278 | 306 | if (po == null) { |
279 | 307 | throw new OrderRepositoryException(OrderRepositoryException.ENTITY_NOT_FOUND, |
... | ... | @@ -287,7 +315,11 @@ public class OrderManagerBean implements OrderManager { |
287 | 315 | } |
288 | 316 | OrderLog log = new OrderLog(); |
289 | 317 | log.setPreviousStatus(po.getOrderStatus()); |
290 | - po.confirm(); | |
318 | + if (!po.getOrderStatus().equals(OrderStatus.PendingDelivery) | |
319 | + && !po.getOrderStatus().equals(OrderStatus.PendingStoreMention)) { | |
320 | + throw new OrderException(OrderException.ORDER_STATUS_FLOW_EXCEPTION, "当前订单状态不能确认收货"); | |
321 | + } | |
322 | + po.setOrderStatus(OrderStatus.Completed); | |
291 | 323 | log.setPreviousStatus(po.getOrderStatus()); |
292 | 324 | this.orderDao.update(po); |
293 | 325 | log.setAction(Action.SELLER_CONFIRM); |
... | ... | @@ -300,12 +332,13 @@ public class OrderManagerBean implements OrderManager { |
300 | 332 | param.setShopBuyerId(po.getShopBuyerId()); |
301 | 333 | param.setTradeName(po.getTradeName()); |
302 | 334 | param.setTradePrice(po.getRealTotalPrice()); |
303 | - this.buyerManager.debit(param); | |
335 | + this.shopBuyerRPC.debit(param); | |
336 | + this.notifyUser(po); | |
304 | 337 | } |
305 | 338 | |
306 | 339 | @Override |
307 | 340 | public void refuse(Long orderId, Long sellerId, String refuseReason) |
308 | - throws OrderRepositoryException, OrderException { | |
341 | + throws OrderRepositoryException, OrderException, DtmsRPCException { | |
309 | 342 | Order po = this.orderDao.getById(orderId); |
310 | 343 | if (po == null) { |
311 | 344 | throw new OrderRepositoryException(OrderRepositoryException.ENTITY_NOT_FOUND, |
... | ... | @@ -319,7 +352,11 @@ public class OrderManagerBean implements OrderManager { |
319 | 352 | } |
320 | 353 | OrderLog log = new OrderLog(); |
321 | 354 | log.setPreviousStatus(po.getOrderStatus()); |
322 | - po.refuse(refuseReason); | |
355 | + if (!po.getOrderStatus().equals(OrderStatus.PendingTake)) { | |
356 | + throw new OrderException(OrderException.ORDER_STATUS_FLOW_EXCEPTION, "当前订单状态不能拒绝接单"); | |
357 | + } | |
358 | + po.setOrderStatus(OrderStatus.Refused); | |
359 | + po.setStatusInReason(refuseReason); | |
323 | 360 | log.setPreviousStatus(po.getOrderStatus()); |
324 | 361 | this.orderDao.update(po); |
325 | 362 | log.setAction(Action.SELLER_REFUSE); |
... | ... | @@ -327,10 +364,12 @@ public class OrderManagerBean implements OrderManager { |
327 | 364 | log.setUserId(sellerId); |
328 | 365 | log.setUserType(UserType.SELLER); |
329 | 366 | this.orderLogDao.save(log); |
367 | + this.notifyUser(po); | |
330 | 368 | } |
331 | 369 | |
332 | 370 | @Override |
333 | - public void cancel(Long orderId, Long shopBuyerId) throws OrderRepositoryException, OrderException { | |
371 | + public void cancel(Long orderId, Long shopBuyerId) | |
372 | + throws OrderRepositoryException, OrderException, DtmsRPCException { | |
334 | 373 | Order po = this.orderDao.getById(orderId); |
335 | 374 | if (po == null) { |
336 | 375 | throw new OrderRepositoryException(OrderRepositoryException.ENTITY_NOT_FOUND, |
... | ... | @@ -344,7 +383,10 @@ public class OrderManagerBean implements OrderManager { |
344 | 383 | } |
345 | 384 | OrderLog log = new OrderLog(); |
346 | 385 | log.setPreviousStatus(po.getOrderStatus()); |
347 | - po.cancel(); | |
386 | + if (!po.isCanCancel()) { | |
387 | + throw new OrderException(OrderException.ORDER_STATUS_FLOW_EXCEPTION, "当前状态不能被取消"); | |
388 | + } | |
389 | + po.setOrderStatus(OrderStatus.Canceled); | |
348 | 390 | log.setCurrentStatus(po.getOrderStatus()); |
349 | 391 | this.orderDao.update(po); |
350 | 392 | log.setAction(Action.BUYER_CANCEL); |
... | ... | @@ -355,8 +397,9 @@ public class OrderManagerBean implements OrderManager { |
355 | 397 | this.orderLogDao.save(log); |
356 | 398 | if (po.getPayStatus() != null && po.getPayStatus().equals(PayStatus.Paid)) { |
357 | 399 | UnlockBalanceParam param = new UnlockBalanceParam(); |
358 | - this.buyerManager.unlockBalance(param); | |
400 | + this.shopBuyerRPC.unlockBalance(param); | |
359 | 401 | } |
402 | + this.notifyUser(po); | |
360 | 403 | } |
361 | 404 | |
362 | 405 | @Override |
... | ... | @@ -368,7 +411,10 @@ public class OrderManagerBean implements OrderManager { |
368 | 411 | } |
369 | 412 | OrderLog log = new OrderLog(); |
370 | 413 | log.setPreviousStatus(po.getOrderStatus()); |
371 | - po.takenTimeout(); | |
414 | + if (!po.getOrderStatus().equals(OrderStatus.PendingTake)) { | |
415 | + throw new OrderException(ApplicationException.DATA_EXCEPTION, "当前状态不能设置接单超时"); | |
416 | + } | |
417 | + po.setOrderStatus(OrderStatus.TakenTimeout); | |
372 | 418 | log.setCurrentStatus(po.getOrderStatus()); |
373 | 419 | this.orderDao.update(po); |
374 | 420 | log.setAction(Action.TAKEN_TIMEOUT); |
... | ... | @@ -379,7 +425,7 @@ public class OrderManagerBean implements OrderManager { |
379 | 425 | } |
380 | 426 | |
381 | 427 | @Override |
382 | - public void paymentTimeout(Long orderId) throws OrderRepositoryException, OrderException { | |
428 | + public void paymentTimeout(Long orderId) throws OrderRepositoryException, OrderException, DtmsRPCException { | |
383 | 429 | Order po = this.orderDao.getById(orderId); |
384 | 430 | if (po == null) { |
385 | 431 | throw new OrderRepositoryException(OrderRepositoryException.ENTITY_NOT_FOUND, |
... | ... | @@ -387,7 +433,10 @@ public class OrderManagerBean implements OrderManager { |
387 | 433 | } |
388 | 434 | OrderLog log = new OrderLog(); |
389 | 435 | log.setPreviousStatus(po.getOrderStatus()); |
390 | - po.paymentTimeout(); | |
436 | + if (!po.getOrderStatus().equals(OrderStatus.PendingPayment)) { | |
437 | + throw new OrderException(ApplicationException.DATA_EXCEPTION, "当前状态不能设置接单超时"); | |
438 | + } | |
439 | + po.setOrderStatus(OrderStatus.PaymentTimeout); | |
391 | 440 | log.setCurrentStatus(po.getOrderStatus()); |
392 | 441 | this.orderDao.update(po); |
393 | 442 | log.setAction(Action.PAYMENT_TIMEOUT); |
... | ... | @@ -395,6 +444,7 @@ public class OrderManagerBean implements OrderManager { |
395 | 444 | log.setOrderId(orderId); |
396 | 445 | log.setUserType(UserType.SYSTEM); |
397 | 446 | this.orderLogDao.save(log); |
447 | + this.notifyUser(po); | |
398 | 448 | } |
399 | 449 | |
400 | 450 | @Override |
... | ... | @@ -406,7 +456,11 @@ public class OrderManagerBean implements OrderManager { |
406 | 456 | } |
407 | 457 | OrderLog log = new OrderLog(); |
408 | 458 | log.setPreviousStatus(po.getOrderStatus()); |
409 | - po.confirm(); | |
459 | + if (!po.getOrderStatus().equals(OrderStatus.PendingDelivery) | |
460 | + && !po.getOrderStatus().equals(OrderStatus.PendingStoreMention)) { | |
461 | + throw new OrderException(OrderException.ORDER_STATUS_FLOW_EXCEPTION, "当前订单状态不能确认收货"); | |
462 | + } | |
463 | + po.setOrderStatus(OrderStatus.Completed); | |
410 | 464 | log.setCurrentStatus(po.getOrderStatus()); |
411 | 465 | this.orderDao.update(po); |
412 | 466 | log.setAction(Action.SYSTEM_CONFIRM); |
... | ... | @@ -415,7 +469,7 @@ public class OrderManagerBean implements OrderManager { |
415 | 469 | log.setUserType(UserType.SYSTEM); |
416 | 470 | this.orderLogDao.save(log); |
417 | 471 | if (po.getPayType().equals(PayType.Online)) { |
418 | - this.buyerManager.debit(null); | |
472 | + this.shopBuyerRPC.debit(null); | |
419 | 473 | } |
420 | 474 | } |
421 | 475 | |
... | ... |
b2c-orders-rpc/src/main/java/com/b2c/orders/domain/rpc/Buyer.java
0 → 100644
1 | +package com.b2c.orders.domain.rpc; | |
2 | + | |
3 | +public class Buyer { | |
4 | + | |
5 | + private Long id; | |
6 | + private String name; | |
7 | + private String phoneNumber; | |
8 | + | |
9 | + public Long getId() { | |
10 | + return id; | |
11 | + } | |
12 | + | |
13 | + public void setId(Long id) { | |
14 | + this.id = id; | |
15 | + } | |
16 | + | |
17 | + public String getName() { | |
18 | + return name; | |
19 | + } | |
20 | + | |
21 | + public void setName(String name) { | |
22 | + this.name = name; | |
23 | + } | |
24 | + | |
25 | + public String getPhoneNumber() { | |
26 | + return phoneNumber; | |
27 | + } | |
28 | + | |
29 | + public void setPhoneNumber(String phoneNumber) { | |
30 | + this.phoneNumber = phoneNumber; | |
31 | + } | |
32 | +} | |
... | ... |
b2c-orders-rpc/src/main/java/com/b2c/orders/domain/rpc/Product.java
b2c-orders-rpc/src/main/java/com/b2c/orders/domain/rpc/Seller.java
0 → 100644
1 | +package com.b2c.orders.domain.rpc; | |
2 | + | |
3 | +import java.io.Serializable; | |
4 | + | |
5 | +public class Seller implements Serializable { | |
6 | + | |
7 | + /** | |
8 | + * | |
9 | + */ | |
10 | + private static final long serialVersionUID = 7404217578749853392L; | |
11 | + | |
12 | + private Long id; | |
13 | + private String name; | |
14 | + private String phoneNumber; | |
15 | + | |
16 | + public Long getId() { | |
17 | + return id; | |
18 | + } | |
19 | + | |
20 | + public void setId(Long id) { | |
21 | + this.id = id; | |
22 | + } | |
23 | + | |
24 | + public String getName() { | |
25 | + return name; | |
26 | + } | |
27 | + | |
28 | + public void setName(String name) { | |
29 | + this.name = name; | |
30 | + } | |
31 | + | |
32 | + public String getPhoneNumber() { | |
33 | + return phoneNumber; | |
34 | + } | |
35 | + | |
36 | + public void setPhoneNumber(String phoneNumber) { | |
37 | + this.phoneNumber = phoneNumber; | |
38 | + } | |
39 | + | |
40 | +} | |
... | ... |
b2c-orders-rpc/src/main/java/com/b2c/orders/domain/rpc/Shop.java
0 → 100644
1 | +package com.b2c.orders.domain.rpc; | |
2 | + | |
3 | +public class Shop { | |
4 | + | |
5 | + private Long id; | |
6 | + private String name; | |
7 | + private String shopPhoneNumber; | |
8 | + private String shopAddress; | |
9 | + private Long freeShippingPrice; | |
10 | + private Long postage; | |
11 | + | |
12 | + public Long getId() { | |
13 | + return id; | |
14 | + } | |
15 | + | |
16 | + public void setId(Long id) { | |
17 | + this.id = id; | |
18 | + } | |
19 | + | |
20 | + public String getName() { | |
21 | + return name; | |
22 | + } | |
23 | + | |
24 | + public void setName(String name) { | |
25 | + this.name = name; | |
26 | + } | |
27 | + | |
28 | + public String getShopPhoneNumber() { | |
29 | + return shopPhoneNumber; | |
30 | + } | |
31 | + | |
32 | + public void setShopPhoneNumber(String shopPhoneNumber) { | |
33 | + this.shopPhoneNumber = shopPhoneNumber; | |
34 | + } | |
35 | + | |
36 | + public String getShopAddress() { | |
37 | + return shopAddress; | |
38 | + } | |
39 | + | |
40 | + public void setShopAddress(String shopAddress) { | |
41 | + this.shopAddress = shopAddress; | |
42 | + } | |
43 | + | |
44 | + public Long getFreeShippingPrice() { | |
45 | + return freeShippingPrice; | |
46 | + } | |
47 | + | |
48 | + public void setFreeShippingPrice(Long freeShippingPrice) { | |
49 | + this.freeShippingPrice = freeShippingPrice; | |
50 | + } | |
51 | + | |
52 | + public Long getPostage() { | |
53 | + return postage; | |
54 | + } | |
55 | + | |
56 | + public void setPostage(Long postage) { | |
57 | + this.postage = postage; | |
58 | + } | |
59 | +} | |
... | ... |
b2c-orders-rpc/src/main/java/com/b2c/orders/rpc/DtmsRPCService.java renamed to b2c-orders-rpc/src/main/java/com/b2c/orders/service/rpc/DtmsRPCService.java
1 | -package com.b2c.orders.rpc; | |
1 | +package com.b2c.orders.service.rpc; | |
2 | 2 | |
3 | 3 | import com.b2c.dtms.client.domain.dto.request.DtmsProduceRequestDto; |
4 | -import com.b2c.orders.rpc.exception.DtmsRPCException; | |
4 | +import com.b2c.orders.service.rpc.exception.DtmsRPCException; | |
5 | +import com.b2c.orders.service.rpc.param.OrderMQDto; | |
5 | 6 | |
6 | 7 | public interface DtmsRPCService { |
7 | 8 | |
8 | 9 | void produceDtmsMessage(DtmsProduceRequestDto request) throws DtmsRPCException; |
9 | - | |
10 | + | |
10 | 11 | void sendOrderTakenTimeoutDtms(Long orderId) throws DtmsRPCException; |
11 | 12 | |
12 | 13 | void sendOrderPayTimeoutDtms(Long orderId) throws DtmsRPCException; |
13 | 14 | |
14 | 15 | void sendOrderConfirmDtms(Long orderId) throws DtmsRPCException; |
16 | + | |
17 | + void sendMQDtmsMessage(OrderMQDto orderDto) throws DtmsRPCException; | |
15 | 18 | |
16 | 19 | } |
... | ... |
b2c-orders-dao/src/main/java/com/b2c/orders/dao/ProductDao.java renamed to b2c-orders-rpc/src/main/java/com/b2c/orders/service/rpc/ProductRPCService.java
1 | -package com.b2c.orders.dao; | |
1 | +package com.b2c.orders.service.rpc; | |
2 | 2 | |
3 | 3 | import com.b2c.orders.commons.exceptions.ProductException; |
4 | 4 | import com.b2c.orders.domain.rpc.Product; |
5 | 5 | |
6 | -public interface ProductDao { | |
6 | +public interface ProductRPCService { | |
7 | 7 | |
8 | 8 | Product findById(Long id); |
9 | 9 | |
... | ... |
b2c-orders-manager/src/main/java/com/b2c/orders/manager/BuyerManager.java renamed to b2c-orders-rpc/src/main/java/com/b2c/orders/service/rpc/ShopBuyerRPCService.java
1 | -package com.b2c.orders.manager; | |
1 | +package com.b2c.orders.service.rpc; | |
2 | 2 | |
3 | -import com.b2c.orders.rpc.param.DebitParam; | |
4 | -import com.b2c.orders.rpc.param.LockBalanceParam; | |
5 | -import com.b2c.orders.rpc.param.UnlockBalanceParam; | |
3 | +import com.b2c.myapp.common.api.shopBuyer.output.ShopBuyerKeyOutput; | |
4 | +import com.b2c.orders.commons.exceptions.BuyerException; | |
5 | +import com.b2c.orders.commons.exceptions.SellerException; | |
6 | +import com.b2c.orders.commons.exceptions.ShopBuyerException; | |
7 | +import com.b2c.orders.commons.exceptions.ShopException; | |
8 | +import com.b2c.orders.domain.rpc.Buyer; | |
9 | +import com.b2c.orders.domain.rpc.Seller; | |
10 | +import com.b2c.orders.domain.rpc.Shop; | |
11 | +import com.b2c.orders.service.rpc.param.DebitParam; | |
12 | +import com.b2c.orders.service.rpc.param.LockBalanceParam; | |
13 | +import com.b2c.orders.service.rpc.param.UnlockBalanceParam; | |
6 | 14 | |
7 | -public interface BuyerManager { | |
15 | +public interface ShopBuyerRPCService { | |
16 | + | |
17 | + ShopBuyerKeyOutput findByShopBuyerId(Long shopBuyerId) throws ShopBuyerException; | |
18 | + | |
19 | + Buyer findBuyerByBuyerShopId(Long buyerShopId) throws BuyerException, ShopBuyerException; | |
20 | + | |
21 | + Seller findSellerByBuyerShopId(Long buyerShopId) throws SellerException, ShopBuyerException; | |
22 | + | |
23 | + Shop findShopByBuyerShopId(Long shopBuyerId) throws ShopException, ShopBuyerException; | |
8 | 24 | |
9 | 25 | /** |
10 | 26 | * 锁定买家账户余额 |
... | ... |
b2c-orders-rpc/src/main/java/com/b2c/orders/rpc/SystemConfigRPCService.java renamed to b2c-orders-rpc/src/main/java/com/b2c/orders/service/rpc/SystemConfigRPCService.java
b2c-orders-rpc/src/main/java/com/b2c/orders/rpc/annotations/RPCService.java renamed to b2c-orders-rpc/src/main/java/com/b2c/orders/service/rpc/annotations/RPCService.java
b2c-orders-rpc/src/main/java/com/b2c/orders/rpc/exception/DtmsRPCException.java renamed to b2c-orders-rpc/src/main/java/com/b2c/orders/service/rpc/exception/DtmsRPCException.java
b2c-orders-rpc/src/main/java/com/b2c/orders/rpc/impl/DtmsRPCServiceBean.java renamed to b2c-orders-rpc/src/main/java/com/b2c/orders/service/rpc/impl/DtmsRPCServiceBean.java
1 | -package com.b2c.orders.rpc.impl; | |
1 | +package com.b2c.orders.service.rpc.impl; | |
2 | + | |
3 | +import org.slf4j.Logger; | |
4 | +import org.slf4j.LoggerFactory; | |
5 | +import org.springframework.util.StringUtils; | |
2 | 6 | |
3 | -import com.b2c.dtms.client.DtmsClient; | |
4 | 7 | import com.b2c.dtms.client.domain.dto.request.DtmsProduceRequestDto; |
5 | 8 | import com.b2c.dtms.client.domain.dto.response.DtmsResponseDto; |
9 | +import com.b2c.dtms.client.service.DtmsService; | |
10 | +import com.b2c.dtms.common.enums.dtms.DtmsMessageTopic; | |
6 | 11 | import com.b2c.dtms.common.enums.dtms.DtmsMessageType; |
7 | 12 | import com.b2c.orders.commons.exceptions.ApplicationException; |
8 | -import com.b2c.orders.rpc.DtmsRPCService; | |
9 | -import com.b2c.orders.rpc.SystemConfigRPCService; | |
10 | -import com.b2c.orders.rpc.exception.DtmsRPCException; | |
13 | +import com.b2c.orders.service.rpc.DtmsRPCService; | |
14 | +import com.b2c.orders.service.rpc.SystemConfigRPCService; | |
15 | +import com.b2c.orders.service.rpc.exception.DtmsRPCException; | |
16 | +import com.b2c.orders.service.rpc.param.OrderMQDto; | |
17 | +import com.fasterxml.jackson.core.JsonProcessingException; | |
18 | +import com.fasterxml.jackson.databind.ObjectMapper; | |
11 | 19 | |
12 | 20 | public class DtmsRPCServiceBean implements DtmsRPCService { |
13 | 21 | |
14 | - private DtmsClient dtmsClient; | |
22 | + private static final Logger LOG = LoggerFactory.getLogger(DtmsRPCServiceBean.class); | |
23 | + private static final ObjectMapper MAPPER = new ObjectMapper(); | |
24 | + private DtmsService dtmsService; | |
15 | 25 | private SystemConfigRPCService systemConfigService; |
26 | + private String topic; | |
27 | + private String tag; | |
16 | 28 | |
17 | - public DtmsRPCServiceBean(String baseUrl, String token, SystemConfigRPCService systemConfigService) { | |
18 | - this.dtmsClient = new DtmsClient(baseUrl, token); | |
29 | + public DtmsRPCServiceBean(DtmsService dtmsService, SystemConfigRPCService systemConfigService) { | |
30 | + this.dtmsService = dtmsService; | |
19 | 31 | this.systemConfigService = systemConfigService; |
20 | 32 | } |
21 | 33 | |
34 | + public String getTopic() { | |
35 | + return topic; | |
36 | + } | |
37 | + | |
38 | + public void setTopic(String topic) { | |
39 | + this.topic = topic; | |
40 | + } | |
41 | + | |
42 | + public String getTag() { | |
43 | + return tag; | |
44 | + } | |
45 | + | |
46 | + public void setTag(String tag) { | |
47 | + this.tag = tag; | |
48 | + } | |
49 | + | |
22 | 50 | @Override |
23 | 51 | public void produceDtmsMessage(DtmsProduceRequestDto request) throws DtmsRPCException { |
24 | - DtmsResponseDto response = this.dtmsClient.getDtmsService().produceMessage(request); | |
52 | + DtmsResponseDto response = this.dtmsService.produceMessage(request); | |
25 | 53 | if (response.getCode().equals(DtmsResponseDto.CODE_FAILED)) { |
26 | 54 | throw new DtmsRPCException(ApplicationException.DATA_EXCEPTION, "创建dtms消息失败"); |
27 | 55 | } |
... | ... | @@ -34,6 +62,7 @@ public class DtmsRPCServiceBean implements DtmsRPCService { |
34 | 62 | request.setCallUrl(this.systemConfigService.getOrderPaymentTimeoutCallUrl()); |
35 | 63 | request.setDelaySeconds(this.systemConfigService.getOrderPaymentTimeoutSeconds()); |
36 | 64 | request.setType(DtmsMessageType.Timer.code()); |
65 | + request.setTopic(DtmsMessageTopic.CallUrl.code()); | |
37 | 66 | this.produceDtmsMessage(request); |
38 | 67 | } |
39 | 68 | |
... | ... | @@ -44,6 +73,7 @@ public class DtmsRPCServiceBean implements DtmsRPCService { |
44 | 73 | request.setCallUrl(this.systemConfigService.getOrderConfirmTimeoutCallUrl()); |
45 | 74 | request.setDelaySeconds(this.systemConfigService.getOrderConfirmTimeoutSeconds()); |
46 | 75 | request.setType(DtmsMessageType.Timer.code()); |
76 | + request.setTopic(DtmsMessageTopic.CallUrl.code()); | |
47 | 77 | this.produceDtmsMessage(request); |
48 | 78 | } |
49 | 79 | |
... | ... | @@ -54,6 +84,29 @@ public class DtmsRPCServiceBean implements DtmsRPCService { |
54 | 84 | request.setCallUrl(this.systemConfigService.getOrderTakenTimeoutCallUrl()); |
55 | 85 | request.setDelaySeconds(this.systemConfigService.getOrderTakenTimeoutSeconds()); |
56 | 86 | request.setType(DtmsMessageType.Timer.code()); |
87 | + request.setTopic(DtmsMessageTopic.CallUrl.code()); | |
88 | + this.produceDtmsMessage(request); | |
89 | + } | |
90 | + | |
91 | + @Override | |
92 | + public void sendMQDtmsMessage(OrderMQDto orderDto) throws DtmsRPCException { | |
93 | + DtmsProduceRequestDto request = new DtmsProduceRequestDto(); | |
94 | + request.setBizId(orderDto.getId().toString()); | |
95 | + request.setTopic(DtmsMessageTopic.SendMq.code()); | |
96 | + request.setDelaySeconds(60); | |
97 | + request.setType(DtmsMessageType.Timer.code()); | |
98 | + if (StringUtils.isEmpty(orderDto.getTopic())) { | |
99 | + orderDto.setTopic(this.topic); | |
100 | + } | |
101 | + if (StringUtils.isEmpty(orderDto.getTag())) { | |
102 | + orderDto.setTag(this.tag); | |
103 | + } | |
104 | + try { | |
105 | + request.setContent(MAPPER.writeValueAsString(orderDto)); | |
106 | + } catch (JsonProcessingException e) { | |
107 | + LOG.error(e.getMessage(), e); | |
108 | + throw new DtmsRPCException(ApplicationException.DATA_EXCEPTION, "创建dtms消息失败"); | |
109 | + } | |
57 | 110 | this.produceDtmsMessage(request); |
58 | 111 | } |
59 | 112 | |
... | ... |
b2c-orders-dao/src/main/java/com/b2c/orders/dao/impl/ProductDaoBean.java renamed to b2c-orders-rpc/src/main/java/com/b2c/orders/service/rpc/impl/ProductRPCServiceImpl.java
1 | -package com.b2c.orders.dao.impl; | |
1 | +package com.b2c.orders.service.rpc.impl; | |
2 | 2 | |
3 | 3 | import java.util.Arrays; |
4 | 4 | import java.util.HashMap; |
... | ... | @@ -9,21 +9,21 @@ import org.apache.commons.collections.MapUtils; |
9 | 9 | import org.slf4j.Logger; |
10 | 10 | import org.slf4j.LoggerFactory; |
11 | 11 | import org.springframework.beans.factory.annotation.Autowired; |
12 | -import org.springframework.stereotype.Repository; | |
12 | +import org.springframework.stereotype.Service; | |
13 | 13 | |
14 | 14 | import com.b2c.orders.commons.exceptions.ApplicationException; |
15 | 15 | import com.b2c.orders.commons.exceptions.ProductException; |
16 | 16 | import com.b2c.orders.commons.utils.CollectionUtils; |
17 | -import com.b2c.orders.dao.ProductDao; | |
18 | 17 | import com.b2c.orders.domain.rpc.Product; |
18 | +import com.b2c.orders.service.rpc.ProductRPCService; | |
19 | 19 | import com.diligrp.titan.sdk.TitanClient; |
20 | 20 | import com.diligrp.titan.sdk.output.BaseOutput; |
21 | 21 | import com.diligrp.titan.sdk.service.ProductService; |
22 | 22 | |
23 | -@Repository | |
24 | -public class ProductDaoBean implements ProductDao { | |
23 | +@Service | |
24 | +public class ProductRPCServiceImpl implements ProductRPCService { | |
25 | 25 | |
26 | - private static final Logger LOG = LoggerFactory.getLogger(ProductDaoBean.class); | |
26 | + private static final Logger LOG = LoggerFactory.getLogger(ProductRPCServiceImpl.class); | |
27 | 27 | private static final Map<Integer, String> SKU_UNIT_MAP = new HashMap<>(); |
28 | 28 | |
29 | 29 | @Autowired |
... | ... |
b2c-orders-rpc/src/main/java/com/b2c/orders/service/rpc/impl/ShopBuyerRPCServiceImpl.java
0 → 100644
1 | +package com.b2c.orders.service.rpc.impl; | |
2 | + | |
3 | +import org.slf4j.Logger; | |
4 | +import org.slf4j.LoggerFactory; | |
5 | +import org.springframework.beans.factory.annotation.Autowired; | |
6 | +import org.springframework.cglib.beans.BeanCopier; | |
7 | +import org.springframework.stereotype.Service; | |
8 | + | |
9 | +import com.b2c.myapp.common.api.buyerInfo.output.BuyerInfoOutput; | |
10 | +import com.b2c.myapp.common.api.fundTrade.input.FundTradeSaveInput; | |
11 | +import com.b2c.myapp.common.api.sellerInfo.output.SellerInfoOutput; | |
12 | +import com.b2c.myapp.common.api.shop.output.ShopOutput; | |
13 | +import com.b2c.myapp.common.api.shopBuyer.output.ShopBuyerKeyOutput; | |
14 | +import com.b2c.myapp.common.enums.TradeType; | |
15 | +import com.b2c.myapp.common.utils.BaseOutput; | |
16 | +import com.b2c.myapp.sdk.service.BuyerInfoService; | |
17 | +import com.b2c.myapp.sdk.service.FundTradeService; | |
18 | +import com.b2c.myapp.sdk.service.SellerInfoService; | |
19 | +import com.b2c.myapp.sdk.service.ShopBuyerService; | |
20 | +import com.b2c.myapp.sdk.service.ShopInfoService; | |
21 | +import com.b2c.orders.commons.cache.impl.CacheManagerBean; | |
22 | +import com.b2c.orders.commons.exceptions.ApplicationException; | |
23 | +import com.b2c.orders.commons.exceptions.BuyerException; | |
24 | +import com.b2c.orders.commons.exceptions.SellerException; | |
25 | +import com.b2c.orders.commons.exceptions.ShopBuyerException; | |
26 | +import com.b2c.orders.commons.exceptions.ShopException; | |
27 | +import com.b2c.orders.domain.rpc.Buyer; | |
28 | +import com.b2c.orders.domain.rpc.Seller; | |
29 | +import com.b2c.orders.domain.rpc.Shop; | |
30 | +import com.b2c.orders.service.rpc.ShopBuyerRPCService; | |
31 | +import com.b2c.orders.service.rpc.param.DebitParam; | |
32 | +import com.b2c.orders.service.rpc.param.LockBalanceParam; | |
33 | +import com.b2c.orders.service.rpc.param.UnlockBalanceParam; | |
34 | + | |
35 | +@Service | |
36 | +public class ShopBuyerRPCServiceImpl implements ShopBuyerRPCService { | |
37 | + | |
38 | + private static final Logger LOG = LoggerFactory.getLogger(ShopBuyerRPCServiceImpl.class); | |
39 | + private static final String SHOP_BUYER_CACHE_KEY = "b2c_redis_shop_buyer_"; | |
40 | + private static final String BUYER_CACHE_KEY = "b2c_redis_buyer_"; | |
41 | + private static final String SELLER_CACHE_KEY = "b2c_redis_seller_"; | |
42 | + private static final String SHOP_CACHE_KEY = "b2c_redis_shop_"; | |
43 | + private static final int EXPIRE_SECONDS = 60 * 30; | |
44 | + | |
45 | + @Autowired | |
46 | + private ShopBuyerService shopBuyerService; | |
47 | + @Autowired | |
48 | + private BuyerInfoService buyerInfoService; | |
49 | + @Autowired | |
50 | + private SellerInfoService sellerInfoService; | |
51 | + @Autowired | |
52 | + private ShopInfoService shopInfoService; | |
53 | + @Autowired | |
54 | + private FundTradeService fundTradeService; | |
55 | + @Autowired | |
56 | + private CacheManagerBean cacheManager; | |
57 | + | |
58 | + @Override | |
59 | + public ShopBuyerKeyOutput findByShopBuyerId(Long buyerShopId) throws ShopBuyerException { | |
60 | + String key = SHOP_BUYER_CACHE_KEY + buyerShopId; | |
61 | + ShopBuyerKeyOutput output = this.cacheManager.get(key, ShopBuyerKeyOutput.class); | |
62 | + if (output == null) { | |
63 | + BaseOutput<ShopBuyerKeyOutput> response = this.shopBuyerService.getShopBuyerKeys(buyerShopId); | |
64 | + if (response == null || !response.getCode().equals("200")) { | |
65 | + throw new ShopBuyerException(ApplicationException.DATA_EXCEPTION, "获取卖家信息失败"); | |
66 | + } | |
67 | + output = response.getData(); | |
68 | + if (output != null) { | |
69 | + this.cacheManager.put(key, output, EXPIRE_SECONDS); | |
70 | + } | |
71 | + } | |
72 | + return output; | |
73 | + } | |
74 | + | |
75 | + @Override | |
76 | + public Buyer findBuyerByBuyerShopId(Long shopBuyerId) throws BuyerException, ShopBuyerException { | |
77 | + ShopBuyerKeyOutput output = this.findByShopBuyerId(shopBuyerId); | |
78 | + if (output == null) { | |
79 | + return null; | |
80 | + } | |
81 | + String key = BUYER_CACHE_KEY + output.getBuyerId(); | |
82 | + Buyer buyer = this.cacheManager.get(key, Buyer.class); | |
83 | + BaseOutput<BuyerInfoOutput> bo = this.buyerInfoService.getBuyerInfoById(output.getBuyerId()); | |
84 | + if (bo == null || !bo.getCode().equals("200")) { | |
85 | + throw new BuyerException(ApplicationException.DATA_EXCEPTION, "获取买家信息失败"); | |
86 | + } | |
87 | + BuyerInfoOutput bio = bo.getData(); | |
88 | + buyer = new Buyer(); | |
89 | + buyer.setId(bio.getId()); | |
90 | + buyer.setName(bio.getAccountName()); | |
91 | + buyer.setPhoneNumber(bio.getMobilePhone()); | |
92 | + this.cacheManager.put(key, buyer, EXPIRE_SECONDS); | |
93 | + return buyer; | |
94 | + } | |
95 | + | |
96 | + @Override | |
97 | + public Seller findSellerByBuyerShopId(Long shopBuyerId) throws SellerException, ShopBuyerException { | |
98 | + ShopBuyerKeyOutput output = this.findByShopBuyerId(shopBuyerId); | |
99 | + if (output == null) { | |
100 | + return null; | |
101 | + } | |
102 | + String key = SELLER_CACHE_KEY + output.getSellerId(); | |
103 | + Seller seller = this.cacheManager.get(key, Seller.class); | |
104 | + if (seller != null) { | |
105 | + return seller; | |
106 | + } | |
107 | + BaseOutput<SellerInfoOutput> bo = this.sellerInfoService.getSellerInfoById(output.getSellerId()); | |
108 | + if (bo == null || !bo.getCode().equals("200")) { | |
109 | + throw new SellerException(ApplicationException.DATA_EXCEPTION, "获取卖家信息失败"); | |
110 | + } | |
111 | + SellerInfoOutput sio = bo.getData(); | |
112 | + seller = new Seller(); | |
113 | + seller.setId(sio.getId()); | |
114 | + seller.setName(sio.getAccountName()); | |
115 | + seller.setPhoneNumber(sio.getMobilePhone()); | |
116 | + this.cacheManager.put(key, seller); | |
117 | + return seller; | |
118 | + } | |
119 | + | |
120 | + @Override | |
121 | + public Shop findShopByBuyerShopId(Long shopBuyerId) throws ShopException, ShopBuyerException { | |
122 | + ShopBuyerKeyOutput sbkOutput = this.findByShopBuyerId(shopBuyerId); | |
123 | + if (sbkOutput == null) { | |
124 | + return null; | |
125 | + } | |
126 | + String key = SHOP_CACHE_KEY + sbkOutput.getShopId(); | |
127 | + Shop shop = this.cacheManager.get(key, Shop.class); | |
128 | + if (shop != null) { | |
129 | + return shop; | |
130 | + } | |
131 | + BaseOutput<ShopOutput> shopResponse = this.shopInfoService.getShopByShopId(sbkOutput.getShopId()); | |
132 | + if (shopResponse == null || !shopResponse.getCode().equals("200")) { | |
133 | + LOG.error( | |
134 | + String.format("调用店铺接口失败,ShopInfoService,Method:getShopByShopId,params:%s", sbkOutput.getShopId())); | |
135 | + throw new ShopException(ApplicationException.DATA_EXCEPTION, "获取店铺信息失败"); | |
136 | + } | |
137 | + ShopOutput rpcShop = shopResponse.getData(); | |
138 | + shop = new Shop(); | |
139 | + shop.setId(rpcShop.getId()); | |
140 | + shop.setName(rpcShop.getShopName()); | |
141 | + shop.setShopAddress(rpcShop.getAddressDetail()); | |
142 | + shop.setShopPhoneNumber(rpcShop.getServiceTel()); | |
143 | + shop.setFreeShippingPrice(rpcShop.getFreeShippingPrice()); | |
144 | + shop.setPostage(rpcShop.getPostage()); | |
145 | + this.cacheManager.put(key, shop, EXPIRE_SECONDS); | |
146 | + return shop; | |
147 | + } | |
148 | + | |
149 | + @Override | |
150 | + public void lockBalance(LockBalanceParam param) { | |
151 | + FundTradeSaveInput rpcParam = new FundTradeSaveInput(); | |
152 | + BeanCopier copier = BeanCopier.create(LockBalanceParam.class, FundTradeSaveInput.class, false); | |
153 | + copier.copy(param, rpcParam, null); | |
154 | + rpcParam.setTradeType(TradeType.Freeze); | |
155 | + this.fundTradeService.fundTrade(rpcParam); | |
156 | + } | |
157 | + | |
158 | + @Override | |
159 | + public void debit(DebitParam param) { | |
160 | + FundTradeSaveInput rpcParam = new FundTradeSaveInput(); | |
161 | + BeanCopier copier = BeanCopier.create(DebitParam.class, FundTradeSaveInput.class, false); | |
162 | + copier.copy(param, rpcParam, null); | |
163 | + rpcParam.setTradeType(TradeType.Consume); | |
164 | + this.fundTradeService.fundTrade(rpcParam); | |
165 | + } | |
166 | + | |
167 | + @Override | |
168 | + public void unlockBalance(UnlockBalanceParam param) { | |
169 | + FundTradeSaveInput rpcParam = new FundTradeSaveInput(); | |
170 | + BeanCopier copier = BeanCopier.create(UnlockBalanceParam.class, FundTradeSaveInput.class, false); | |
171 | + copier.copy(param, rpcParam, null); | |
172 | + rpcParam.setTradeType(TradeType.Unfreeze); | |
173 | + this.fundTradeService.fundTrade(rpcParam); | |
174 | + } | |
175 | +} | |
... | ... |
b2c-orders-rpc/src/main/java/com/b2c/orders/rpc/impl/SystemConfigRPCServiceBean.java renamed to b2c-orders-rpc/src/main/java/com/b2c/orders/service/rpc/impl/SystemConfigRPCServiceBean.java
1 | -package com.b2c.orders.rpc.impl; | |
1 | +package com.b2c.orders.service.rpc.impl; | |
2 | 2 | |
3 | 3 | import org.springframework.util.StringUtils; |
4 | 4 | |
5 | 5 | import com.b2c.orders.commons.cache.CacheManager; |
6 | 6 | import com.b2c.orders.commons.constant.Constant; |
7 | -import com.b2c.orders.rpc.SystemConfigRPCService; | |
7 | +import com.b2c.orders.service.rpc.SystemConfigRPCService; | |
8 | 8 | import com.diligrp.website.web.interfaces.domain.output.BaseResp; |
9 | 9 | import com.diligrp.website.web.interfaces.domain.output.SysConfigResp; |
10 | 10 | import com.diligrp.website.web.interfaces.service.SysConfigService; |
... | ... |
b2c-orders-rpc/src/main/java/com/b2c/orders/rpc/param/DebitParam.java renamed to b2c-orders-rpc/src/main/java/com/b2c/orders/service/rpc/param/DebitParam.java
b2c-orders-rpc/src/main/java/com/b2c/orders/rpc/param/LockBalanceParam.java renamed to b2c-orders-rpc/src/main/java/com/b2c/orders/service/rpc/param/LockBalanceParam.java
b2c-orders-rpc/src/main/java/com/b2c/orders/service/rpc/param/OrderMQDto.java
0 → 100644
1 | +package com.b2c.orders.service.rpc.param; | |
2 | + | |
3 | +import java.io.Serializable; | |
4 | + | |
5 | +public class OrderMQDto implements Serializable { | |
6 | + | |
7 | + /** | |
8 | + * | |
9 | + */ | |
10 | + private static final long serialVersionUID = -3480299779174220938L; | |
11 | + | |
12 | + private String topic; | |
13 | + private String tag; | |
14 | + private Long id; | |
15 | + private Long buyerId; | |
16 | + private Long sellerId; | |
17 | + private Integer orderStatus; | |
18 | + | |
19 | + public String getTopic() { | |
20 | + return topic; | |
21 | + } | |
22 | + | |
23 | + public void setTopic(String topic) { | |
24 | + this.topic = topic; | |
25 | + } | |
26 | + | |
27 | + public String getTag() { | |
28 | + return tag; | |
29 | + } | |
30 | + | |
31 | + public void setTag(String tag) { | |
32 | + this.tag = tag; | |
33 | + } | |
34 | + | |
35 | + public Long getId() { | |
36 | + return id; | |
37 | + } | |
38 | + | |
39 | + public void setId(Long id) { | |
40 | + this.id = id; | |
41 | + } | |
42 | + | |
43 | + public Long getBuyerId() { | |
44 | + return buyerId; | |
45 | + } | |
46 | + | |
47 | + public void setBuyerId(Long buyerId) { | |
48 | + this.buyerId = buyerId; | |
49 | + } | |
50 | + | |
51 | + public Long getSellerId() { | |
52 | + return sellerId; | |
53 | + } | |
54 | + | |
55 | + public void setSellerId(Long sellerId) { | |
56 | + this.sellerId = sellerId; | |
57 | + } | |
58 | + | |
59 | + public Integer getOrderStatus() { | |
60 | + return orderStatus; | |
61 | + } | |
62 | + | |
63 | + public void setOrderStatus(Integer orderStatus) { | |
64 | + this.orderStatus = orderStatus; | |
65 | + } | |
66 | + | |
67 | +} | |
... | ... |
b2c-orders-rpc/src/main/java/com/b2c/orders/rpc/param/UnlockBalanceParam.java renamed to b2c-orders-rpc/src/main/java/com/b2c/orders/service/rpc/param/UnlockBalanceParam.java
b2c-orders-rpc/src/main/resources/spring-rpc.xml
... | ... | @@ -14,11 +14,21 @@ |
14 | 14 | http://www.springframework.org/schema/cache/spring-cache-4.3.xsd" |
15 | 15 | default-lazy-init="true"> |
16 | 16 | |
17 | - <bean id="dtmsRPCService" class="com.b2c.orders.rpc.impl.DtmsRPCServiceBean"> | |
17 | + <bean id="dtmsClient" class="com.b2c.dtms.client.DtmsClient"> | |
18 | 18 | <constructor-arg name="baseUrl" value="${dtms.baseUrl}" /> |
19 | 19 | <constructor-arg name="token" value="${dtms.token}" /> |
20 | 20 | </bean> |
21 | 21 | |
22 | + <bean id="dtmsService" class="com.b2c.dtms.client.service.DtmsService" | |
23 | + factory-bean="dtmsClient" factory-method="getDtmsService" /> | |
24 | + | |
25 | + <bean id="dtmsRPCService" class="com.b2c.orders.service.rpc.impl.DtmsRPCServiceBean"> | |
26 | + <constructor-arg name="dtmsService" ref="dtmsService" /> | |
27 | + <constructor-arg name="systemConfigService" ref="systemConfigRPCService" /> | |
28 | + <property name="topic" value="${mq.orders.topic}" /> | |
29 | + <property name="tag" value="=${mq.orders.tag}" /> | |
30 | + </bean> | |
31 | + | |
22 | 32 | <bean id="titanClient" class="com.diligrp.titan.sdk.TitanClient"> |
23 | 33 | <constructor-arg index="0" value="111" type="java.lang.String" /> |
24 | 34 | <constructor-arg index="1" value="111" type="java.lang.String" /> |
... | ... | @@ -31,6 +41,21 @@ |
31 | 41 | <constructor-arg name="baseUrl" value="http://www.zandeapp.com" /> |
32 | 42 | </bean> |
33 | 43 | |
44 | + <bean id="shopBuyerService" class="com.b2c.myapp.sdk.service.ShopBuyerService" | |
45 | + factory-bean="myAppClient" factory-method="getShopBuyerService" /> | |
46 | + | |
47 | + <bean id="buyerInfoService" class="com.b2c.myapp.sdk.service.BuyerInfoService" | |
48 | + factory-bean="myAppClient" factory-method="getBuyerInfoService" /> | |
49 | + | |
50 | + <bean id="sellerInfoService" class="com.b2c.myapp.sdk.service.SellerInfoService" | |
51 | + factory-bean="myAppClient" factory-method="getSellerInfoService" /> | |
52 | + | |
53 | + <bean id="shopInfoService" class="com.b2c.myapp.sdk.service.ShopInfoService" | |
54 | + factory-bean="myAppClient" factory-method="getShopInfoService" /> | |
55 | + | |
56 | + <bean id="fundTradeService" class="com.b2c.myapp.sdk.service.FundTradeService" | |
57 | + factory-bean="myAppClient" factory-method="getFundTradeService" /> | |
58 | + | |
34 | 59 | <bean id="websiteClient" class="com.diligrp.website.web.interfaces.WebsiteClient"> |
35 | 60 | <constructor-arg name="token" value="${manweb.token}" /> |
36 | 61 | <constructor-arg name="baseUrl" value="${manweb.baseUrl}" /> |
... | ... | @@ -54,7 +79,8 @@ |
54 | 79 | <constructor-arg name="jedisUtils" ref="jedisUtils" /> |
55 | 80 | </bean> |
56 | 81 | |
57 | - <bean id="systemConfigRPCService" class="com.b2c.orders.rpc.impl.SystemConfigRPCServiceBean"> | |
82 | + <bean id="systemConfigRPCService" | |
83 | + class="com.b2c.orders.service.rpc.impl.SystemConfigRPCServiceBean"> | |
58 | 84 | <constructor-arg name="sysConfigService" ref="sysConfigService" /> |
59 | 85 | <constructor-arg name="constant" ref="constant" /> |
60 | 86 | <constructor-arg name="cacheManager" ref="cacheManager" /> |
... | ... |
b2c-orders-service/pom.xml
... | ... | @@ -12,7 +12,12 @@ |
12 | 12 | <dependency> |
13 | 13 | <groupId>${project.groupId}</groupId> |
14 | 14 | <artifactId>b2c-orders-manager</artifactId> |
15 | - <version>${project.version}</version> | |
15 | + <version>${project.parent.version}</version> | |
16 | + </dependency> | |
17 | + <dependency> | |
18 | + <groupId>${project.groupId}</groupId> | |
19 | + <artifactId>b2c-orders-rpc</artifactId> | |
20 | + <version>${project.parent.version}</version> | |
16 | 21 | </dependency> |
17 | 22 | </dependencies> |
18 | 23 | </project> |
19 | 24 | \ No newline at end of file |
... | ... |
b2c-orders-service/src/main/java/com/b2c/orders/service/OrderService.java
... | ... | @@ -9,10 +9,10 @@ import com.b2c.orders.commons.exceptions.SellerException; |
9 | 9 | import com.b2c.orders.commons.exceptions.ShopBuyerException; |
10 | 10 | import com.b2c.orders.commons.exceptions.ShopException; |
11 | 11 | import com.b2c.orders.domain.Order; |
12 | -import com.b2c.orders.domain.client.dto.request.SubmitOrderRequestDto; | |
12 | +import com.b2c.orders.domain.vo.OrderVo; | |
13 | 13 | import com.b2c.orders.enums.PayType; |
14 | 14 | import com.b2c.orders.enums.UserType; |
15 | -import com.b2c.orders.rpc.exception.DtmsRPCException; | |
15 | +import com.b2c.orders.service.rpc.exception.DtmsRPCException; | |
16 | 16 | import com.diligrp.website.util.dao.BaseQuery; |
17 | 17 | import com.diligrp.website.util.web.PageTemplate; |
18 | 18 | |
... | ... | @@ -23,6 +23,7 @@ public interface OrderService { |
23 | 23 | * |
24 | 24 | * @param order |
25 | 25 | * 订单id |
26 | + * @return | |
26 | 27 | * @throws DtmsRPCException |
27 | 28 | * @throws OrderException |
28 | 29 | * @throws ProductException |
... | ... | @@ -31,7 +32,7 @@ public interface OrderService { |
31 | 32 | * @throws ShopBuyerException |
32 | 33 | * @throws ShopException |
33 | 34 | */ |
34 | - void submit(SubmitOrderRequestDto order) throws DtmsRPCException, OrderException, ProductException, SellerException, | |
35 | + Long submit(OrderVo order) throws DtmsRPCException, OrderException, ProductException, SellerException, | |
35 | 36 | BuyerException, ShopException, ShopBuyerException; |
36 | 37 | |
37 | 38 | /** |
... | ... | @@ -78,8 +79,9 @@ public interface OrderService { |
78 | 79 | * 买家id |
79 | 80 | * @throws OrderException |
80 | 81 | * @throws OrderRepositoryException |
82 | + * @throws DtmsRPCException | |
81 | 83 | */ |
82 | - void buyerConfirm(Long orderId, Long shopBuyerId) throws OrderRepositoryException, OrderException; | |
84 | + void buyerConfirm(Long orderId, Long shopBuyerId) throws OrderRepositoryException, OrderException, DtmsRPCException; | |
83 | 85 | |
84 | 86 | /** |
85 | 87 | * 商家确认收款 |
... | ... | @@ -90,8 +92,9 @@ public interface OrderService { |
90 | 92 | * 卖家id |
91 | 93 | * @throws OrderException |
92 | 94 | * @throws OrderRepositoryException |
95 | + * @throws DtmsRPCException | |
93 | 96 | */ |
94 | - void sellerConfirm(Long orderId, Long sellerId) throws OrderRepositoryException, OrderException; | |
97 | + void sellerConfirm(Long orderId, Long sellerId) throws OrderRepositoryException, OrderException, DtmsRPCException; | |
95 | 98 | |
96 | 99 | /** |
97 | 100 | * 商家拒绝接单 |
... | ... | @@ -104,8 +107,9 @@ public interface OrderService { |
104 | 107 | * TODO |
105 | 108 | * @throws OrderException |
106 | 109 | * @throws OrderRepositoryException |
110 | + * @throws DtmsRPCException | |
107 | 111 | */ |
108 | - void refuse(Long orderId, Long sellerId, String refuseReason) throws OrderRepositoryException, OrderException; | |
112 | + void refuse(Long orderId, Long sellerId, String refuseReason) throws OrderRepositoryException, OrderException, DtmsRPCException; | |
109 | 113 | |
110 | 114 | /** |
111 | 115 | * 买家取消订单 |
... | ... | @@ -116,8 +120,9 @@ public interface OrderService { |
116 | 120 | * 买家id |
117 | 121 | * @throws OrderException |
118 | 122 | * @throws OrderRepositoryException |
123 | + * @throws DtmsRPCException | |
119 | 124 | */ |
120 | - void cancel(Long orderId, Long shopBuyerId) throws OrderRepositoryException, OrderException; | |
125 | + void cancel(Long orderId, Long shopBuyerId) throws OrderRepositoryException, OrderException, DtmsRPCException; | |
121 | 126 | |
122 | 127 | /** |
123 | 128 | * 商家{@link Constant.ORDER_TAKEN_TIMEOUT_SECONDS}秒未接单,订单超时 |
... | ... | @@ -134,8 +139,9 @@ public interface OrderService { |
134 | 139 | * |
135 | 140 | * @param orderId |
136 | 141 | * @throws OrderRepositoryException |
142 | + * @throws DtmsRPCException | |
137 | 143 | */ |
138 | - void paymentTimeout(Long orderId) throws OrderRepositoryException; | |
144 | + void paymentTimeout(Long orderId) throws OrderRepositoryException, DtmsRPCException; | |
139 | 145 | |
140 | 146 | /** |
141 | 147 | * 商家24小时没有确认收款或者买家24小时没确认收货由dtms确认收款、收货(需求文档要求商家确认收款或者买家确认收货则订单完成) |
... | ... |
b2c-orders-service/src/main/java/com/b2c/orders/service/impl/OrderServiceBean.java
... | ... | @@ -16,12 +16,12 @@ import com.b2c.orders.commons.exceptions.SellerException; |
16 | 16 | import com.b2c.orders.commons.exceptions.ShopBuyerException; |
17 | 17 | import com.b2c.orders.commons.exceptions.ShopException; |
18 | 18 | import com.b2c.orders.domain.Order; |
19 | -import com.b2c.orders.domain.client.dto.request.SubmitOrderRequestDto; | |
19 | +import com.b2c.orders.domain.vo.OrderVo; | |
20 | 20 | import com.b2c.orders.enums.PayType; |
21 | 21 | import com.b2c.orders.enums.UserType; |
22 | 22 | import com.b2c.orders.manager.OrderManager; |
23 | -import com.b2c.orders.rpc.exception.DtmsRPCException; | |
24 | 23 | import com.b2c.orders.service.OrderService; |
24 | +import com.b2c.orders.service.rpc.exception.DtmsRPCException; | |
25 | 25 | import com.diligrp.website.util.dao.BaseQuery; |
26 | 26 | import com.diligrp.website.util.web.PageTemplate; |
27 | 27 | |
... | ... | @@ -35,9 +35,10 @@ public class OrderServiceBean implements OrderService { |
35 | 35 | private OrderManager orderManager; |
36 | 36 | |
37 | 37 | @Override |
38 | - public void submit(SubmitOrderRequestDto order) throws DtmsRPCException, OrderException, ProductException, | |
39 | - SellerException, BuyerException, ShopException, ShopBuyerException { | |
40 | - this.orderManager.submit(order); | |
38 | + public Long submit(OrderVo order) throws DtmsRPCException, OrderException, ProductException, SellerException, | |
39 | + BuyerException, ShopException, ShopBuyerException { | |
40 | + Long orderId = this.orderManager.submit(order); | |
41 | + return orderId; | |
41 | 42 | } |
42 | 43 | |
43 | 44 | @Override |
... | ... | @@ -53,23 +54,26 @@ public class OrderServiceBean implements OrderService { |
53 | 54 | } |
54 | 55 | |
55 | 56 | @Override |
56 | - public void buyerConfirm(Long orderId, Long shopBuyerId) throws OrderRepositoryException, OrderException { | |
57 | + public void buyerConfirm(Long orderId, Long shopBuyerId) | |
58 | + throws OrderRepositoryException, OrderException, DtmsRPCException { | |
57 | 59 | this.orderManager.buyerConfirm(orderId, shopBuyerId); |
58 | 60 | } |
59 | 61 | |
60 | 62 | @Override |
61 | - public void sellerConfirm(Long orderId, Long sellerId) throws OrderRepositoryException, OrderException { | |
63 | + public void sellerConfirm(Long orderId, Long sellerId) | |
64 | + throws OrderRepositoryException, OrderException, DtmsRPCException { | |
62 | 65 | this.orderManager.sellerConfirm(orderId, sellerId); |
63 | 66 | } |
64 | 67 | |
65 | 68 | @Override |
66 | 69 | public void refuse(Long orderId, Long sellerId, String refuseReason) |
67 | - throws OrderRepositoryException, OrderException { | |
70 | + throws OrderRepositoryException, OrderException, DtmsRPCException { | |
68 | 71 | this.orderManager.refuse(orderId, sellerId, refuseReason); |
69 | 72 | } |
70 | 73 | |
71 | 74 | @Override |
72 | - public void cancel(Long orderId, Long shopBuyerId) throws OrderRepositoryException, OrderException { | |
75 | + public void cancel(Long orderId, Long shopBuyerId) | |
76 | + throws OrderRepositoryException, OrderException, DtmsRPCException { | |
73 | 77 | this.orderManager.cancel(orderId, shopBuyerId); |
74 | 78 | } |
75 | 79 | |
... | ... | @@ -83,7 +87,7 @@ public class OrderServiceBean implements OrderService { |
83 | 87 | } |
84 | 88 | |
85 | 89 | @Override |
86 | - public void paymentTimeout(Long orderId) throws OrderRepositoryException { | |
90 | + public void paymentTimeout(Long orderId) throws OrderRepositoryException, DtmsRPCException { | |
87 | 91 | try { |
88 | 92 | this.orderManager.paymentTimeout(orderId); |
89 | 93 | } catch (OrderException e) { |
... | ... |
b2c-orders-web/pom.xml
... | ... | @@ -11,6 +11,21 @@ |
11 | 11 | |
12 | 12 | <dependencies> |
13 | 13 | <dependency> |
14 | + <groupId>org.springframework</groupId> | |
15 | + <artifactId>spring-webmvc</artifactId> | |
16 | + </dependency> | |
17 | + <!--后台user --> | |
18 | + <dependency> | |
19 | + <groupId>com.b2c.manage</groupId> | |
20 | + <artifactId>diligrp-manage-sdk</artifactId> | |
21 | + <exclusions> | |
22 | + <exclusion> | |
23 | + <groupId>org.apache.hbase</groupId> | |
24 | + <artifactId>hbase-client</artifactId> | |
25 | + </exclusion> | |
26 | + </exclusions> | |
27 | + </dependency> | |
28 | + <dependency> | |
14 | 29 | <groupId>org.aspectj</groupId> |
15 | 30 | <artifactId>aspectjweaver</artifactId> |
16 | 31 | </dependency> |
... | ... | @@ -126,11 +141,6 @@ |
126 | 141 | <artifactId>junit</artifactId> |
127 | 142 | <scope>test</scope> |
128 | 143 | </dependency> |
129 | - <dependency> | |
130 | - <groupId>javax.servlet</groupId> | |
131 | - <artifactId>servlet-api</artifactId> | |
132 | - <scope>provided</scope> | |
133 | - </dependency> | |
134 | 144 | |
135 | 145 | <dependency> |
136 | 146 | <groupId>commons-lang</groupId> |
... | ... |
b2c-orders-web/src/main/java/com/b2c/orders/web/controller/OrderController.java
... | ... | @@ -6,7 +6,6 @@ import java.util.Map; |
6 | 6 | |
7 | 7 | import org.springframework.beans.factory.annotation.Autowired; |
8 | 8 | import org.springframework.stereotype.Controller; |
9 | -import org.springframework.web.bind.annotation.ModelAttribute; | |
10 | 9 | import org.springframework.web.bind.annotation.RequestMapping; |
11 | 10 | import org.springframework.web.bind.annotation.RequestMethod; |
12 | 11 | import org.springframework.web.bind.annotation.RequestParam; |
... | ... |
b2c-orders-web/src/main/java/com/b2c/orders/web/restful/OrderRestController.java
... | ... | @@ -3,7 +3,9 @@ package com.b2c.orders.web.restful; |
3 | 3 | import java.text.DateFormat; |
4 | 4 | import java.text.SimpleDateFormat; |
5 | 5 | import java.util.ArrayList; |
6 | +import java.util.LinkedHashSet; | |
6 | 7 | import java.util.List; |
8 | +import java.util.Set; | |
7 | 9 | |
8 | 10 | import javax.validation.Valid; |
9 | 11 | |
... | ... | @@ -28,6 +30,7 @@ import com.b2c.orders.domain.OrderItem; |
28 | 30 | import com.b2c.orders.domain.client.dto.request.BuyerCancelRequestDto; |
29 | 31 | import com.b2c.orders.domain.client.dto.request.BuyerConfirmRequestDto; |
30 | 32 | import com.b2c.orders.domain.client.dto.request.OrderDetailRequestDto; |
33 | +import com.b2c.orders.domain.client.dto.request.OrderItemDto; | |
31 | 34 | import com.b2c.orders.domain.client.dto.request.OrderListRequestDto; |
32 | 35 | import com.b2c.orders.domain.client.dto.request.OrderRemoveRequestDto; |
33 | 36 | import com.b2c.orders.domain.client.dto.request.PayOrderRequestDto; |
... | ... | @@ -41,9 +44,18 @@ import com.b2c.orders.domain.client.dto.response.ApiResponse; |
41 | 44 | import com.b2c.orders.domain.client.dto.response.OrderDetailResponseDto; |
42 | 45 | import com.b2c.orders.domain.client.dto.response.OrderItemResponseDto; |
43 | 46 | import com.b2c.orders.domain.client.dto.response.OrderListResponseDto; |
47 | +import com.b2c.orders.domain.client.dto.response.SubmitOrderResponseDto; | |
48 | +import com.b2c.orders.domain.rpc.Buyer; | |
49 | +import com.b2c.orders.domain.rpc.Product; | |
50 | +import com.b2c.orders.domain.rpc.Seller; | |
51 | +import com.b2c.orders.domain.rpc.Shop; | |
52 | +import com.b2c.orders.domain.vo.OrderItemVo; | |
53 | +import com.b2c.orders.domain.vo.OrderVo; | |
44 | 54 | import com.b2c.orders.enums.PayType; |
45 | 55 | import com.b2c.orders.enums.UserType; |
46 | 56 | import com.b2c.orders.service.OrderService; |
57 | +import com.b2c.orders.service.rpc.ProductRPCService; | |
58 | +import com.b2c.orders.service.rpc.ShopBuyerRPCService; | |
47 | 59 | import com.diligrp.website.util.dao.BaseQuery; |
48 | 60 | import com.diligrp.website.util.web.PageTemplate; |
49 | 61 | |
... | ... | @@ -55,17 +67,51 @@ import io.swagger.annotations.ApiOperation; |
55 | 67 | @RequestMapping("/api") |
56 | 68 | public class OrderRestController { |
57 | 69 | |
58 | - private BeanCopier orderCopier = BeanCopier.create(Order.class, OrderListResponseDto.class, false); | |
59 | 70 | private BeanCopier orderItemCopier = BeanCopier.create(OrderItem.class, OrderItemResponseDto.class, false); |
60 | 71 | @Autowired |
61 | 72 | private OrderService orderService; |
73 | + @Autowired | |
74 | + private ShopBuyerRPCService shopBuyerRPC; | |
75 | + @Autowired | |
76 | + private ProductRPCService productRPC; | |
62 | 77 | |
63 | 78 | @ApiOperation("提交订单") |
64 | 79 | @RequestMapping(value = "/submit", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) |
65 | - public ApiResponse submit(@RequestBody @Valid SubmitOrderRequestDto order, BindingResult br) { | |
66 | - ApiResponse dto = new ApiResponse(); | |
80 | + public ApiDataResponse<SubmitOrderResponseDto> submit(@RequestBody @Valid SubmitOrderRequestDto order, | |
81 | + BindingResult br) { | |
82 | + ApiDataResponse<SubmitOrderResponseDto> dto = new ApiDataResponse<>(); | |
67 | 83 | try { |
68 | - this.orderService.submit(order); | |
84 | + OrderVo vo = new OrderVo(); | |
85 | + Buyer buyer = this.shopBuyerRPC.findBuyerByBuyerShopId(order.getShopBuyerId()); | |
86 | + vo.setBuyer(buyer); | |
87 | + Seller seller = this.shopBuyerRPC.findSellerByBuyerShopId(order.getShopBuyerId()); | |
88 | + vo.setSeller(seller); | |
89 | + Shop shop = this.shopBuyerRPC.findShopByBuyerShopId(order.getShopBuyerId()); | |
90 | + vo.setShop(shop); | |
91 | + vo.setBuyerMemo(order.getBuyerMemo()); | |
92 | + vo.setCityId(order.getCityId()); | |
93 | + vo.setCityName(order.getCityName()); | |
94 | + vo.setDeliveryAddress(order.getDeliveryAddress()); | |
95 | + vo.setDeliveryTime(order.getDeliveryTime()); | |
96 | + vo.setDeliveryType(order.getDeliveryType()); | |
97 | + vo.setMarketId(order.getMarketId()); | |
98 | + vo.setReceiverName(order.getReceiverName()); | |
99 | + vo.setReceiverPhoneNumber(order.getReceiverPhoneNumber()); | |
100 | + vo.setReservationTime(order.getReservationTime()); | |
101 | + vo.setShopBuyerId(order.getShopBuyerId()); | |
102 | + List<OrderItemVo> orderItems = new ArrayList<>(order.getOrderItems().size()); | |
103 | + for (OrderItemDto orderItemDto : order.getOrderItems()) { | |
104 | + OrderItemVo orderItemVo = new OrderItemVo(); | |
105 | + orderItemVo.setAmount(orderItemDto.getAmount()); | |
106 | + Product product = this.productRPC.findBySku(orderItemDto.getSku()); | |
107 | + orderItemVo.setProduct(product); | |
108 | + orderItems.add(orderItemVo); | |
109 | + } | |
110 | + vo.setOrderItems(orderItems); | |
111 | + Long orderId = this.orderService.submit(vo); | |
112 | + SubmitOrderResponseDto data = new SubmitOrderResponseDto(); | |
113 | + data.setOrderId(orderId); | |
114 | + dto.setData(data); | |
69 | 115 | dto.setCode(ApiResponse.RESPONSE_CODE_SUCCESS); |
70 | 116 | dto.setSuccess(true); |
71 | 117 | } catch (ApplicationException e) { |
... | ... | @@ -236,9 +282,41 @@ public class OrderRestController { |
236 | 282 | List<Order> orderList = (List<Order>) page.getList(); |
237 | 283 | if (!CollectionUtils.isEmpty(orderList)) { |
238 | 284 | List<OrderListResponseDto> orderDtoList = new ArrayList<>(orderList.size()); |
285 | + DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
239 | 286 | for (Order order : orderList) { |
240 | 287 | OrderListResponseDto orderDto = new OrderListResponseDto(); |
241 | - this.orderCopier.copy(order, orderDto, null); | |
288 | + if (order.getBuyerConfirmTime() != null) { | |
289 | + orderDto.setBuyerConfirmTime(df.format(order.getBuyerConfirmTime())); | |
290 | + } | |
291 | + orderDto.setBuyerId(order.getBuyerId()); | |
292 | + orderDto.setBuyerMemo(order.getBuyerMemo()); | |
293 | + if (order.getDeliveryTime() != null) { | |
294 | + orderDto.setDeliveryTime(df.format(order.getDeliveryTime())); | |
295 | + } | |
296 | + if (order.getDeliveryType() != null) { | |
297 | + orderDto.setDeliveryType(order.getDeliveryType().getIndex()); | |
298 | + } | |
299 | + orderDto.setId(order.getId()); | |
300 | + if (order.getOrderStatus() != null) { | |
301 | + orderDto.setOrderStatus(order.getOrderStatus().getIndex()); | |
302 | + } | |
303 | + if (order.getPayStatus() != null) { | |
304 | + orderDto.setPayStatus(order.getPayStatus().getIndex()); | |
305 | + } | |
306 | + if (order.getPayTime() != null) { | |
307 | + orderDto.setPayTime(df.format(order.getPayTime())); | |
308 | + } | |
309 | + if (order.getPayType() != null) { | |
310 | + orderDto.setPayType(order.getPayType().getIndex()); | |
311 | + } | |
312 | + orderDto.setRealTotalPrice(order.getRealTotalPrice()); | |
313 | + if (order.getReservationTime() != null) { | |
314 | + orderDto.setReservationTime(df.format(order.getReservationTime())); | |
315 | + } | |
316 | + orderDto.setSellerId(order.getSellerId()); | |
317 | + orderDto.setShopId(order.getShopId()); | |
318 | + orderDto.setSubmitTime(df.format(order.getSubmitTime())); | |
319 | + orderDto.setTotalPrice(order.getTotalPrice()); | |
242 | 320 | if (!CollectionUtils.isEmpty(order.getOrderItems())) { |
243 | 321 | List<OrderItemResponseDto> orderItemDtoList = new ArrayList<>(order.getOrderItems().size()); |
244 | 322 | for (OrderItem orderItem : order.getOrderItems()) { |
... | ... |
b2c-orders-web/src/main/resources/conf/manage.properties
... | ... | @@ -10,4 +10,11 @@ manage.excludes=${conf.manage.excludes} |
10 | 10 | #当前系统的标记 |
11 | 11 | manage.system=${conf.manage.system} |
12 | 12 | #是否开启权限接入点爬取 |
13 | -mange.spider=${conf.manage.spider} | |
14 | 13 | \ No newline at end of file |
14 | +mange.spider=${conf.manage.spider} | |
15 | + | |
16 | +# redis | |
17 | +redis.host1=${redis.host} | |
18 | +redis.port1=${project.redis.port1} | |
19 | +reids.maxIdle=500 | |
20 | +redis.maxWaitMillis=1000 | |
21 | +redis.testOnBorrow=true | |
15 | 22 | \ No newline at end of file |
... | ... |
b2c-orders-web/src/main/resources/log4j.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8" ?> | |
2 | +<!DOCTYPE log4j:configuration PUBLIC | |
3 | + "-//APACHE//DTD LOG4J 1.2//EN" "http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd"> | |
4 | +<log4j:configuration> | |
5 | + <appender name="ConsoleAppender" class="org.apache.log4j.ConsoleAppender"> | |
6 | + <layout class="org.apache.log4j.PatternLayout"> | |
7 | + <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss}:%p %c{1} - %m%n" /> | |
8 | + </layout> | |
9 | + </appender> | |
10 | + | |
11 | + | |
12 | + <appender name="LOG_SYSTEM" class="org.apache.log4j.DailyRollingFileAppender"> | |
13 | + <param name="Encoding" value="UTF-8"/> | |
14 | + <param name="Append" value="true" /> | |
15 | + <!--<param name="BufferedIO" value="true" />--> | |
16 | + <!--<param name="BufferSize" value="8192" />--> | |
17 | + <param name="File" value="/diliapp/logs/log_system.log"/> | |
18 | + <param name="DatePattern" value="'.'yyyy-MM-dd" /> | |
19 | + <layout class="org.apache.log4j.PatternLayout"> | |
20 | + <param name="ConversionPattern" value="[%p] [%d] [%r] [%c] - %m %n"/> | |
21 | + </layout> | |
22 | + </appender> | |
23 | + | |
24 | + <category name="LOG_SYSTEM" additivity="false"> | |
25 | + <priority value="INFO"/> | |
26 | + <appender-ref ref="LOG_SYSTEM"/> | |
27 | + </category> | |
28 | + | |
29 | + | |
30 | + <root> | |
31 | + <priority value="debug" /> | |
32 | + <appender-ref ref="ConsoleAppender" /> | |
33 | + <!--<appender-ref ref="LOG_SYSTEM" />--> | |
34 | + </root> | |
35 | +</log4j:configuration> | |
0 | 36 | \ No newline at end of file |
... | ... |
b2c-orders-web/src/main/webapp/WEB-INF/web.xml
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | 2 | <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
3 | - xmlns="http://java.sun.com/xml/ns/javaee" | |
4 | - xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" | |
5 | - id="WebApp_ID" version="3.0"> | |
3 | + xmlns="http://java.sun.com/xml/ns/javaee" | |
4 | + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" | |
5 | + id="WebApp_ID" version="3.0"> | |
6 | 6 | |
7 | 7 | <display-name>b2c-orders</display-name> |
8 | 8 | |
... | ... | @@ -11,82 +11,72 @@ |
11 | 11 | <param-value>orders.webapp.root</param-value> |
12 | 12 | </context-param> |
13 | 13 | |
14 | - <!--<context-param> | |
15 | - <param-name>contextConfigLocation</param-name> | |
16 | - <param-value>classpath:spring.xml</param-value> | |
17 | - </context-param> | |
18 | - | |
19 | - <listener> | |
20 | - <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> | |
21 | - </listener> --> | |
14 | + <!--<context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring.xml</param-value> | |
15 | + </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> | |
16 | + </listener> --> | |
22 | 17 | |
23 | 18 | <servlet> |
24 | 19 | <servlet-name>springmvc</servlet-name> |
25 | 20 | <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> |
26 | 21 | <init-param> |
27 | - <param-name>contextConfigLocation</param-name> | |
28 | - <param-value>classpath:spring.xml</param-value> | |
22 | + <param-name>contextConfigLocation</param-name> | |
23 | + <param-value>classpath:spring.xml</param-value> | |
29 | 24 | </init-param> |
30 | - <load-on-startup>1</load-on-startup> | |
25 | + <load-on-startup>1</load-on-startup> | |
31 | 26 | </servlet> |
32 | 27 | |
33 | 28 | <servlet-mapping> |
34 | 29 | <servlet-name>springmvc</servlet-name> |
35 | 30 | <url-pattern>/</url-pattern> |
36 | 31 | </servlet-mapping> |
37 | - | |
32 | + | |
38 | 33 | <servlet-mapping> |
39 | - <servlet-name>springmvc</servlet-name> | |
40 | - <url-pattern>/swagger-resources</url-pattern> | |
41 | - </servlet-mapping> | |
34 | + <servlet-name>springmvc</servlet-name> | |
35 | + <url-pattern>/swagger-resources</url-pattern> | |
36 | + </servlet-mapping> | |
37 | + | |
38 | + <!-- <filter> <filter-name>EncodingFilter</filter-name> <filter-class>com.diligrp.orders.web.interceptor.OrdersCharacterEncodingFilter</filter-class> | |
39 | + <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> | |
40 | + </init-param> </filter> --> | |
41 | + | |
42 | + <filter> | |
43 | + <filter-name>characterEncodingFilter</filter-name> | |
44 | + <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> | |
45 | + <init-param> | |
46 | + <param-name>encoding</param-name> | |
47 | + <param-value>UTF-8</param-value> | |
48 | + </init-param> | |
49 | + <init-param> | |
50 | + <param-name>forceEncoding</param-name> | |
51 | + <param-value>true</param-value> | |
52 | + </init-param> | |
53 | + </filter> | |
54 | + <filter-mapping> | |
55 | + <filter-name>characterEncodingFilter</filter-name> | |
56 | + <url-pattern>/*</url-pattern> | |
57 | + </filter-mapping> | |
42 | 58 | |
43 | - <!-- <filter> | |
44 | - <filter-name>EncodingFilter</filter-name> | |
45 | - <filter-class>com.diligrp.orders.web.interceptor.OrdersCharacterEncodingFilter</filter-class> | |
46 | - <init-param> | |
47 | - <param-name>encoding</param-name> | |
48 | - <param-value>UTF-8</param-value> | |
49 | - </init-param> | |
50 | - </filter> --> | |
51 | - | |
52 | - <filter> | |
53 | - <filter-name>characterEncodingFilter</filter-name> | |
54 | - <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> | |
55 | - <init-param> | |
56 | - <param-name>encoding</param-name> | |
57 | - <param-value>UTF-8</param-value> | |
58 | - </init-param> | |
59 | - <init-param> | |
60 | - <param-name>forceEncoding</param-name> | |
61 | - <param-value>true</param-value> | |
62 | - </init-param> | |
63 | - </filter> | |
64 | - <filter-mapping> | |
65 | - <filter-name>characterEncodingFilter</filter-name> | |
66 | - <url-pattern>/*</url-pattern> | |
67 | - </filter-mapping> | |
68 | - | |
69 | 59 | <filter> |
70 | 60 | <filter-name>HiddenHttpMethodFilter</filter-name> |
71 | 61 | <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class> |
72 | 62 | </filter> |
73 | - <!-- <filter-mapping> | |
74 | - <filter-name>EncodingFilter</filter-name> | |
75 | - <servlet-name>springmvc</servlet-name> | |
76 | - </filter-mapping> --> | |
77 | - <!-- <filter-mapping> | |
78 | - <filter-name>HiddenHttpMethodFilter</filter-name> | |
79 | - <servlet-name>springmvc</servlet-name> | |
80 | - </filter-mapping> --> | |
63 | + <!-- <filter-mapping> <filter-name>EncodingFilter</filter-name> <servlet-name>springmvc</servlet-name> | |
64 | + </filter-mapping> --> | |
65 | + <!-- <filter-mapping> <filter-name>HiddenHttpMethodFilter</filter-name> | |
66 | + <servlet-name>springmvc</servlet-name> </filter-mapping> --> | |
81 | 67 | |
82 | 68 | <!--统一管理平台权限管理配置 --> |
83 | - <!-- <filter> | |
84 | - <filter-name>sessionFilter</filter-name> | |
85 | - <filter-class>com.diligrp.manage.sdk.session.SessionFilter</filter-class> | |
86 | - </filter> | |
87 | - <filter-mapping> | |
88 | - <filter-name>sessionFilter</filter-name> | |
89 | - <url-pattern>*</url-pattern> | |
90 | - </filter-mapping> --> | |
69 | + <filter> | |
70 | + <filter-name>sessionFilter</filter-name> | |
71 | + <filter-class>com.diligrp.manage.sdk.session.SessionFilter</filter-class> | |
72 | + <init-param> | |
73 | + <param-name>confPath</param-name> | |
74 | + <param-value>conf/manage.properties</param-value> | |
75 | + </init-param> | |
76 | + </filter> | |
77 | + <filter-mapping> | |
78 | + <filter-name>sessionFilter</filter-name> | |
79 | + <url-pattern>*</url-pattern> | |
80 | + </filter-mapping> | |
91 | 81 | |
92 | 82 | </web-app> |
93 | 83 | \ No newline at end of file |
... | ... |
pom.xml
... | ... | @@ -25,13 +25,12 @@ |
25 | 25 | <conf.manage.spider>true</conf.manage.spider> |
26 | 26 | <conf.manage.system>orders</conf.manage.system> |
27 | 27 | <conf.manage.domain>http://manage.zandeapp.com/</conf.manage.domain> |
28 | - <!--系统url并未以.do结尾,因此需要使用如下方式的正则表达式 --> | |
29 | - <conf.manage.includes>^/.*</conf.manage.includes> | |
30 | 28 | <!--打包编码 --> |
31 | 29 | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
32 | 30 | <orders.contextPath>http://orders.zandeapp.com</orders.contextPath> |
33 | 31 | <!--权限拦截器在处理导出文件时会出错,导致文件打不开,比如Excel,因此对于导出,跳过拦截 --> |
34 | - <conf.manage.excludes>^/noAccess.do$,^/welcome.do$,^/loginControl/.*,^/api/.*,^/cleanCache$,^/assets/.*,^/orderSelf/export/.*,^/monitor,^/druid/*,^/orderPrint/export/*</conf.manage.excludes> | |
32 | + <conf.manage.includes>^/*</conf.manage.includes> | |
33 | + <conf.manage.excludes>^/noAccess.do$,^/welcome.do$,^/loginControl/.*,^/api/.*,^/cleanCache$,^/assets/.*,^/orderSelf/export/.*,^/monitor,^/druid/*,^/orderPrint/export/*,^/swagger*,^/images/*,^/v2/api-docs,^/configuration/*</conf.manage.excludes> | |
35 | 34 | <!-- 域名信息 --> |
36 | 35 | <conf.domain.name>zandeapp.com</conf.domain.name> |
37 | 36 | <!-- 静态资源地址 --> |
... | ... | @@ -52,6 +51,8 @@ |
52 | 51 | <redis.timeout>30000</redis.timeout> |
53 | 52 | <redis.testOnBorrow>true</redis.testOnBorrow> |
54 | 53 | <redis.testOnReturn>true</redis.testOnReturn> |
54 | + <mq.orders.topic>ORDER_MQ_TOPIC</mq.orders.topic> | |
55 | + <mq.orders.tag>ORDER_MQ_TAG</mq.orders.tag> | |
55 | 56 | |
56 | 57 | <jdk.version>1.7</jdk.version> |
57 | 58 | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
... | ... | @@ -81,11 +82,6 @@ |
81 | 82 | <dependencyManagement> |
82 | 83 | <dependencies> |
83 | 84 | <dependency> |
84 | - <groupId>com.b2c.website.web</groupId> | |
85 | - <artifactId>diligrp-website-api</artifactId> | |
86 | - <version>1.0.5-SNAPSHOT</version> | |
87 | - </dependency> | |
88 | - <dependency> | |
89 | 85 | <groupId>com.b2c.dtms</groupId> |
90 | 86 | <artifactId>dtms-client</artifactId> |
91 | 87 | <version>0.0.2-SNAPSHOT</version> |
... | ... | @@ -254,7 +250,7 @@ |
254 | 250 | </dependency> |
255 | 251 | <!--后台user --> |
256 | 252 | <dependency> |
257 | - <groupId>com.yqyw.manage</groupId> | |
253 | + <groupId>com.b2c.manage</groupId> | |
258 | 254 | <artifactId>diligrp-manage-sdk</artifactId> |
259 | 255 | <version>0.0.3-SNAPSHOT</version> |
260 | 256 | <exclusions> |
... | ... | @@ -270,18 +266,6 @@ |
270 | 266 | <artifactId>diligrp-store-sdk</artifactId> |
271 | 267 | <version>0.0.1-SNAPSHOT</version> |
272 | 268 | </dependency> |
273 | - <!-- 消息中心/待办事项 --> | |
274 | - <dependency> | |
275 | - <groupId>com.yqyw.messageCenter.sdk</groupId> | |
276 | - <artifactId>diligrp-messageCenter-sdk</artifactId> | |
277 | - <version>0.0.4-SNAPSHOT</version> | |
278 | - <exclusions> | |
279 | - <exclusion> | |
280 | - <groupId>velocity</groupId> | |
281 | - <artifactId>velocity-dep</artifactId> | |
282 | - </exclusion> | |
283 | - </exclusions> | |
284 | - </dependency> | |
285 | 269 | <!-- 店铺API --> |
286 | 270 | <dependency> |
287 | 271 | <groupId>com.yqyw.shop</groupId> |
... | ... |