Commit 161e8bdce9d1d5881643b25ca363d69d79fdb52a
1 parent
c8e3c096
增加订单日志,区分订单超时状态为接单超时和支付超时
Showing
43 changed files
with
908 additions
and
183 deletions
b2c-orders-client/src/main/java/com/b2c/orders/client/domain/dto/request/PayOrderRequestDto.java
... | ... | @@ -17,6 +17,9 @@ public class PayOrderRequestDto extends BaseRequestDto { |
17 | 17 | @ApiParam(value = "买家id", required = true) |
18 | 18 | @NotNull(message = "买家id不能为空") |
19 | 19 | private Long buyerId; |
20 | + @ApiParam(value = "支付方式", required = true) | |
21 | + @NotNull(message = "支付方式不能为空") | |
22 | + private Integer payType; | |
20 | 23 | |
21 | 24 | public Long getOrderId() { |
22 | 25 | return orderId; |
... | ... | @@ -34,4 +37,12 @@ public class PayOrderRequestDto extends BaseRequestDto { |
34 | 37 | this.buyerId = buyerId; |
35 | 38 | } |
36 | 39 | |
40 | + public Integer getPayType() { | |
41 | + return payType; | |
42 | + } | |
43 | + | |
44 | + public void setPayType(Integer payType) { | |
45 | + this.payType = payType; | |
46 | + } | |
47 | + | |
37 | 48 | } |
... | ... |
b2c-orders-client/src/main/java/com/b2c/orders/client/domain/dto/request/ProductDto.java deleted
100644 → 0
b2c-orders-client/src/main/java/com/b2c/orders/client/domain/dto/request/SellerConfirmRequestDto.java
... | ... | @@ -2,6 +2,8 @@ package com.b2c.orders.client.domain.dto.request; |
2 | 2 | |
3 | 3 | import javax.validation.constraints.NotNull; |
4 | 4 | |
5 | +import io.swagger.annotations.ApiParam; | |
6 | + | |
5 | 7 | public class SellerConfirmRequestDto extends BaseRequestDto { |
6 | 8 | |
7 | 9 | /** |
... | ... | @@ -9,10 +11,10 @@ public class SellerConfirmRequestDto extends BaseRequestDto { |
9 | 11 | */ |
10 | 12 | private static final long serialVersionUID = -6873506335794369709L; |
11 | 13 | |
12 | -// @ApiParam(value = "订单id", required = true) | |
14 | + @ApiParam(value = "订单id", required = true) | |
13 | 15 | @NotNull(message = "订单id不能为空") |
14 | 16 | private Long orderId; |
15 | -// @ApiParam(value = "商家id", required = true) | |
17 | + @ApiParam(value = "商家id", required = true) | |
16 | 18 | @NotNull(message = "商家id不能为空") |
17 | 19 | private Long sellerId; |
18 | 20 | |
... | ... |
b2c-orders-client/src/main/java/com/b2c/orders/client/domain/dto/request/SubmitOrderRequestDto.java
1 | 1 | package com.b2c.orders.client.domain.dto.request; |
2 | 2 | |
3 | 3 | import java.io.Serializable; |
4 | -import java.util.Date; | |
5 | 4 | import java.util.List; |
6 | 5 | |
7 | -import com.b2c.orders.enums.DeliveryType; | |
8 | -import com.b2c.orders.enums.PayType; | |
9 | - | |
10 | 6 | import io.swagger.annotations.ApiParam; |
11 | 7 | |
12 | 8 | public class SubmitOrderRequestDto implements Serializable { |
... | ... |
b2c-orders-client/src/main/java/com/b2c/orders/client/domain/dto/request/TakeOrderRequestDto.java
b2c-orders-client/src/main/java/com/b2c/orders/enums/Action.java
... | ... | @@ -4,7 +4,46 @@ import com.fasterxml.jackson.annotation.JsonValue; |
4 | 4 | |
5 | 5 | public enum Action { |
6 | 6 | |
7 | - BUYER_PLACE_ORDER(10, "买家下单"); | |
7 | + /** | |
8 | + * 买家下单 | |
9 | + */ | |
10 | + BUYER_PLACE_ORDER(10, "买家下单"), | |
11 | + /** | |
12 | + * 商家接单 | |
13 | + */ | |
14 | + SELLER_TAKEN(20, "卖家接单"), | |
15 | + /** | |
16 | + * 买家付款 | |
17 | + */ | |
18 | + BUYER_PAY(30, "买家付款"), | |
19 | + /** | |
20 | + * 买家去人收货 | |
21 | + */ | |
22 | + BUYER_CONFIRM(40, "买家确认收货"), | |
23 | + /** | |
24 | + * 商家确认收款 | |
25 | + */ | |
26 | + SELLER_CONFIRM(50, "商家确认收款"), | |
27 | + /** | |
28 | + * 系统确认收货、收款 | |
29 | + */ | |
30 | + SYSTEM_CONFIRM(60, "系统确认收款、收货"), | |
31 | + /** | |
32 | + * 商家拒绝接单 | |
33 | + */ | |
34 | + SELLER_REFUSE(70, "商家拒绝接单"), | |
35 | + /** | |
36 | + * 买家取消订单 | |
37 | + */ | |
38 | + BUYER_CANCEL(80, "买家取消订单"), | |
39 | + /** | |
40 | + * 商家接单超时 | |
41 | + */ | |
42 | + TAKEN_TIMEOUT(90, "接单超时"), | |
43 | + /** | |
44 | + * 买家付款超时 | |
45 | + */ | |
46 | + PAYMENT_TIMEOUT(100, "支付超时"); | |
8 | 47 | |
9 | 48 | private int index; |
10 | 49 | private String name; |
... | ... | @@ -27,7 +66,7 @@ public enum Action { |
27 | 66 | return c; |
28 | 67 | } |
29 | 68 | } |
30 | - return null; | |
69 | + throw new IllegalArgumentException("未知的订单操作行为"); | |
31 | 70 | } |
32 | 71 | |
33 | 72 | } |
... | ... |
b2c-orders-client/src/main/java/com/b2c/orders/enums/OrderStatus.java
... | ... | @@ -26,21 +26,25 @@ public enum OrderStatus { |
26 | 26 | */ |
27 | 27 | PendingDelivery(25), |
28 | 28 | /** |
29 | - * 已过期 | |
29 | + * 接单已过期 | |
30 | 30 | */ |
31 | - Timeout(30, false), | |
31 | + TakenTimeout(30, false), | |
32 | + /** | |
33 | + * 支付超时 | |
34 | + */ | |
35 | + PaymentTimeout(35, false), | |
32 | 36 | /** |
33 | 37 | * 已拒绝 |
34 | 38 | */ |
35 | - Refused(35, false), | |
39 | + Refused(40, false), | |
36 | 40 | /** |
37 | 41 | * 已取消 |
38 | 42 | */ |
39 | - Canceled(40, false), | |
43 | + Canceled(45, false), | |
40 | 44 | /** |
41 | 45 | * 已完成 |
42 | 46 | */ |
43 | - Completed(45, false); | |
47 | + Completed(50, false); | |
44 | 48 | |
45 | 49 | /** 是否活动(运行中)状态 */ |
46 | 50 | private boolean isRuningStatus = true; |
... | ... |
b2c-orders-client/src/main/java/com/b2c/orders/enums/PayStatus.java
... | ... | @@ -32,7 +32,7 @@ public enum PayStatus { |
32 | 32 | this.index = index; |
33 | 33 | } |
34 | 34 | |
35 | - public static PayStatus getPayStatus(Integer index) { | |
35 | + public static PayStatus getPayStatus(int index) { | |
36 | 36 | for (PayStatus c : PayStatus.values()) { |
37 | 37 | if (c.getIndex() == index) { |
38 | 38 | return c; |
... | ... | @@ -47,7 +47,7 @@ public enum PayStatus { |
47 | 47 | * @param payStatus |
48 | 48 | * @return |
49 | 49 | */ |
50 | - public static boolean isPayWait(Integer payStatus) { | |
50 | + public static boolean isPayWait(int payStatus) { | |
51 | 51 | return getPayStatus(payStatus) == PayWait; |
52 | 52 | } |
53 | 53 | |
... | ... | @@ -57,7 +57,7 @@ public enum PayStatus { |
57 | 57 | * @param payStatus |
58 | 58 | * @return |
59 | 59 | */ |
60 | - public static boolean isPaid(Integer payStatus) { | |
60 | + public static boolean isPaid(int payStatus) { | |
61 | 61 | return getPayStatus(payStatus) == Paid; |
62 | 62 | } |
63 | 63 | } |
64 | 64 | \ No newline at end of file |
... | ... |
b2c-orders-client/src/main/java/com/b2c/orders/enums/UserType.java
... | ... | @@ -18,33 +18,33 @@ public enum UserType { |
18 | 18 | SELLER(20, "卖家", "【卖家】"), |
19 | 19 | |
20 | 20 | /** 地利后台系统用户 */ |
21 | - SYSTEM(30L, "系统", "【系统】"); | |
21 | + SYSTEM(30, "系统", "【系统】"); | |
22 | 22 | |
23 | - private long index; | |
23 | + private int index; | |
24 | 24 | private String name; |
25 | 25 | private String prefix; |
26 | 26 | |
27 | - public static UserType get(long index) { | |
27 | + public static UserType get(int index) { | |
28 | 28 | for (UserType c : UserType.values()) { |
29 | 29 | if (c.getIndex() == index) { |
30 | 30 | return c; |
31 | 31 | } |
32 | 32 | } |
33 | - return null; | |
33 | + throw new IllegalArgumentException("未知的用户类型"); | |
34 | 34 | } |
35 | 35 | |
36 | - private UserType(long index, String name, String prefix) { | |
36 | + private UserType(int index, String name, String prefix) { | |
37 | 37 | this.index = index; |
38 | 38 | this.name = name; |
39 | 39 | this.prefix = prefix; |
40 | 40 | } |
41 | 41 | |
42 | 42 | @JsonValue |
43 | - public long getIndex() { | |
43 | + public int getIndex() { | |
44 | 44 | return index; |
45 | 45 | } |
46 | 46 | |
47 | - public void setIndex(long index) { | |
47 | + public void setIndex(int index) { | |
48 | 48 | this.index = index; |
49 | 49 | } |
50 | 50 | |
... | ... |
b2c-orders-commons/src/main/java/com/b2c/orders/commons/constant/Constant.java
... | ... | @@ -13,9 +13,17 @@ public class Constant { |
13 | 13 | /** |
14 | 14 | * 商家未接单,订单超时时间 |
15 | 15 | */ |
16 | - public static final int ORDER_TAKE_TIMEOUT_SECONDS = 24 * 60 * 60; | |
16 | + public static final int ORDER_TAKEN_TIMEOUT_SECONDS = 24 * 60 * 60; | |
17 | 17 | /** |
18 | 18 | * 买家未支付,订单超时时间 |
19 | 19 | */ |
20 | - public static final int ORDER_PAY_TIMEOUT_SECONDS = 24 * 60 * 60; | |
20 | + public static final int ORDER_PAYMENT_TIMEOUT_SECONDS = 24 * 60 * 60; | |
21 | + /** | |
22 | + * 买家超过{@link ORDER_CONFIRM_TIMEOUT_SECONDS}秒没有确认收货或者卖家超过{@link ORDER_CONFIRM_TIMEOUT_SECONDS}没有确认收款,dtms调用接口地址自动确认收货、收款 | |
23 | + */ | |
24 | + public static final String ORDER_CONFIRM_TIMEOUT_CALL_URL = "http://orders.zandeapp.com/api/dtms/confirm"; | |
25 | + /** | |
26 | + * 买家超过这个时间(单位:秒)没有确认收货或者卖家超过这个时间(单位:秒)没有确认收款,dtms调用{@link ORDER_CONFIRM_TIMEOUT_CALL_URL}订单接口确认收货、收款 | |
27 | + */ | |
28 | + public static final int ORDER_CONFIRM_TIMEOUT_SECONDS = 24 * 60 * 60; | |
21 | 29 | } |
... | ... |
b2c-orders-dao/src/main/java/com/b2c/orders/dao/OrderLogDao.java
0 → 100644
b2c-orders-dao/src/main/java/com/b2c/orders/dao/impl/OrderDaoBean.java
... | ... | @@ -17,7 +17,7 @@ public class OrderDaoBean extends BaseDaoImpl<Order> implements OrderDao { |
17 | 17 | |
18 | 18 | @Override |
19 | 19 | public boolean save(Order entity) { |
20 | - if (super.save(entity)) { | |
20 | + if (!super.save(entity)) { | |
21 | 21 | return false; |
22 | 22 | } |
23 | 23 | for (OrderItem item : entity.getOrderItems()) { |
... | ... |
b2c-orders-dao/src/main/java/com/b2c/orders/dao/impl/OrderLogDaoBean.java
0 → 100644
1 | +package com.b2c.orders.dao.impl; | |
2 | + | |
3 | +import org.springframework.stereotype.Repository; | |
4 | + | |
5 | +import com.b2c.orders.dao.OrderLogDao; | |
6 | +import com.b2c.orders.domain.OrderLog; | |
7 | +import com.diligrp.website.util.dao.impl.BaseDaoImpl; | |
8 | + | |
9 | +@Repository | |
10 | +public class OrderLogDaoBean extends BaseDaoImpl<OrderLog> implements OrderLogDao { | |
11 | + | |
12 | +} | |
... | ... |
b2c-orders-dao/src/main/java/com/b2c/orders/dao/utils/ActionTypeHandler.java
0 → 100644
1 | +package com.b2c.orders.dao.utils; | |
2 | + | |
3 | +import java.sql.CallableStatement; | |
4 | +import java.sql.PreparedStatement; | |
5 | +import java.sql.ResultSet; | |
6 | +import java.sql.SQLException; | |
7 | + | |
8 | +import org.apache.ibatis.type.BaseTypeHandler; | |
9 | +import org.apache.ibatis.type.JdbcType; | |
10 | + | |
11 | +import com.b2c.orders.enums.Action; | |
12 | + | |
13 | +public class ActionTypeHandler extends BaseTypeHandler<Action> { | |
14 | + | |
15 | + @Override | |
16 | + public void setNonNullParameter(PreparedStatement ps, int i, Action parameter, JdbcType jdbcType) | |
17 | + throws SQLException { | |
18 | + ps.setInt(i, parameter.getIndex()); | |
19 | + } | |
20 | + | |
21 | + @Override | |
22 | + public Action getNullableResult(ResultSet rs, String columnName) throws SQLException { | |
23 | + if (rs.wasNull()) { | |
24 | + return null; | |
25 | + } | |
26 | + int value = rs.getInt(columnName); | |
27 | + return Action.get(value); | |
28 | + } | |
29 | + | |
30 | + @Override | |
31 | + public Action getNullableResult(ResultSet rs, int columnIndex) throws SQLException { | |
32 | + if (rs.wasNull()) { | |
33 | + return null; | |
34 | + } | |
35 | + int value = rs.getInt(columnIndex); | |
36 | + return Action.get(value); | |
37 | + } | |
38 | + | |
39 | + @Override | |
40 | + public Action getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { | |
41 | + if (cs.wasNull()) { | |
42 | + return null; | |
43 | + } | |
44 | + int value = cs.getInt(columnIndex); | |
45 | + return Action.get(value); | |
46 | + } | |
47 | + | |
48 | +} | |
... | ... |
b2c-orders-dao/src/main/java/com/b2c/orders/dao/utils/DeliveryTypeTypeHandler.java
0 → 100644
1 | +package com.b2c.orders.dao.utils; | |
2 | + | |
3 | +import java.sql.CallableStatement; | |
4 | +import java.sql.PreparedStatement; | |
5 | +import java.sql.ResultSet; | |
6 | +import java.sql.SQLException; | |
7 | + | |
8 | +import org.apache.ibatis.type.BaseTypeHandler; | |
9 | +import org.apache.ibatis.type.JdbcType; | |
10 | + | |
11 | +import com.b2c.orders.enums.DeliveryType; | |
12 | + | |
13 | +public class DeliveryTypeTypeHandler extends BaseTypeHandler<DeliveryType> { | |
14 | + | |
15 | + @Override | |
16 | + public void setNonNullParameter(PreparedStatement ps, int i, DeliveryType parameter, JdbcType jdbcType) | |
17 | + throws SQLException { | |
18 | + ps.setInt(i, parameter.getIndex()); | |
19 | + } | |
20 | + | |
21 | + @Override | |
22 | + public DeliveryType getNullableResult(ResultSet rs, String columnName) throws SQLException { | |
23 | + if (rs.wasNull()) { | |
24 | + return null; | |
25 | + } | |
26 | + int value = rs.getInt(columnName); | |
27 | + return DeliveryType.getDeliveryType(value); | |
28 | + } | |
29 | + | |
30 | + @Override | |
31 | + public DeliveryType getNullableResult(ResultSet rs, int columnIndex) throws SQLException { | |
32 | + if (rs.wasNull()) { | |
33 | + return null; | |
34 | + } | |
35 | + int value = rs.getInt(columnIndex); | |
36 | + return DeliveryType.getDeliveryType(value); | |
37 | + } | |
38 | + | |
39 | + @Override | |
40 | + public DeliveryType getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { | |
41 | + if (cs.wasNull()) { | |
42 | + return null; | |
43 | + } | |
44 | + int value = cs.getInt(columnIndex); | |
45 | + return DeliveryType.getDeliveryType(value); | |
46 | + } | |
47 | + | |
48 | +} | |
... | ... |
b2c-orders-dao/src/main/java/com/b2c/orders/dao/utils/OrderStatusTypeHandler.java
0 → 100644
1 | +package com.b2c.orders.dao.utils; | |
2 | + | |
3 | +import java.sql.CallableStatement; | |
4 | +import java.sql.PreparedStatement; | |
5 | +import java.sql.ResultSet; | |
6 | +import java.sql.SQLException; | |
7 | + | |
8 | +import org.apache.ibatis.type.BaseTypeHandler; | |
9 | +import org.apache.ibatis.type.JdbcType; | |
10 | + | |
11 | +import com.b2c.orders.enums.OrderStatus; | |
12 | + | |
13 | +public class OrderStatusTypeHandler extends BaseTypeHandler<OrderStatus> { | |
14 | + | |
15 | + @Override | |
16 | + public void setNonNullParameter(PreparedStatement ps, int i, OrderStatus parameter, JdbcType jdbcType) | |
17 | + throws SQLException { | |
18 | + ps.setInt(i, parameter.getIndex()); | |
19 | + } | |
20 | + | |
21 | + @Override | |
22 | + public OrderStatus getNullableResult(ResultSet rs, String columnName) throws SQLException { | |
23 | + if (rs.wasNull()) { | |
24 | + return null; | |
25 | + } | |
26 | + int value = rs.getInt(columnName); | |
27 | + return OrderStatus.getOrderStatus(value); | |
28 | + } | |
29 | + | |
30 | + @Override | |
31 | + public OrderStatus getNullableResult(ResultSet rs, int columnIndex) throws SQLException { | |
32 | + if (rs.wasNull()) { | |
33 | + return null; | |
34 | + } | |
35 | + int value = rs.getInt(columnIndex); | |
36 | + return OrderStatus.getOrderStatus(value); | |
37 | + } | |
38 | + | |
39 | + @Override | |
40 | + public OrderStatus getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { | |
41 | + if (cs.wasNull()) { | |
42 | + return null; | |
43 | + } | |
44 | + int value = cs.getInt(columnIndex); | |
45 | + return OrderStatus.getOrderStatus(value); | |
46 | + } | |
47 | + | |
48 | +} | |
... | ... |
b2c-orders-dao/src/main/java/com/b2c/orders/dao/utils/PayStatusTypeHandler.java
0 → 100644
1 | +package com.b2c.orders.dao.utils; | |
2 | + | |
3 | +import java.sql.CallableStatement; | |
4 | +import java.sql.PreparedStatement; | |
5 | +import java.sql.ResultSet; | |
6 | +import java.sql.SQLException; | |
7 | + | |
8 | +import org.apache.ibatis.type.BaseTypeHandler; | |
9 | +import org.apache.ibatis.type.JdbcType; | |
10 | + | |
11 | +import com.b2c.orders.enums.PayStatus; | |
12 | + | |
13 | +public class PayStatusTypeHandler extends BaseTypeHandler<PayStatus> { | |
14 | + | |
15 | + @Override | |
16 | + public void setNonNullParameter(PreparedStatement ps, int i, PayStatus parameter, JdbcType jdbcType) | |
17 | + throws SQLException { | |
18 | + ps.setInt(i, parameter.getIndex()); | |
19 | + } | |
20 | + | |
21 | + @Override | |
22 | + public PayStatus getNullableResult(ResultSet rs, String columnName) throws SQLException { | |
23 | + if (rs.wasNull()) { | |
24 | + return null; | |
25 | + } | |
26 | + int value = rs.getInt(columnName); | |
27 | + return PayStatus.getPayStatus(value); | |
28 | + } | |
29 | + | |
30 | + @Override | |
31 | + public PayStatus getNullableResult(ResultSet rs, int columnIndex) throws SQLException { | |
32 | + if (rs.wasNull()) { | |
33 | + return null; | |
34 | + } | |
35 | + int value = rs.getInt(columnIndex); | |
36 | + return PayStatus.getPayStatus(value); | |
37 | + } | |
38 | + | |
39 | + @Override | |
40 | + public PayStatus getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { | |
41 | + if (cs.wasNull()) { | |
42 | + return null; | |
43 | + } | |
44 | + int value = cs.getInt(columnIndex); | |
45 | + return PayStatus.getPayStatus(value); | |
46 | + } | |
47 | + | |
48 | +} | |
... | ... |
b2c-orders-dao/src/main/java/com/b2c/orders/dao/utils/UserTypeTypeHandler.java
0 → 100644
1 | +package com.b2c.orders.dao.utils; | |
2 | + | |
3 | +import java.sql.CallableStatement; | |
4 | +import java.sql.PreparedStatement; | |
5 | +import java.sql.ResultSet; | |
6 | +import java.sql.SQLException; | |
7 | + | |
8 | +import org.apache.ibatis.type.BaseTypeHandler; | |
9 | +import org.apache.ibatis.type.JdbcType; | |
10 | + | |
11 | +import com.b2c.orders.enums.UserType; | |
12 | + | |
13 | +public class UserTypeTypeHandler extends BaseTypeHandler<UserType> { | |
14 | + | |
15 | + @Override | |
16 | + public void setNonNullParameter(PreparedStatement ps, int i, UserType parameter, JdbcType jdbcType) | |
17 | + throws SQLException { | |
18 | + ps.setInt(i, parameter.getIndex()); | |
19 | + } | |
20 | + | |
21 | + @Override | |
22 | + public UserType getNullableResult(ResultSet rs, String columnName) throws SQLException { | |
23 | + if (rs.wasNull()) { | |
24 | + return null; | |
25 | + } | |
26 | + int value = rs.getInt(columnName); | |
27 | + return UserType.get(value); | |
28 | + } | |
29 | + | |
30 | + @Override | |
31 | + public UserType getNullableResult(ResultSet rs, int columnIndex) throws SQLException { | |
32 | + if (rs.wasNull()) { | |
33 | + return null; | |
34 | + } | |
35 | + int value = rs.getInt(columnIndex); | |
36 | + return UserType.get(value); | |
37 | + } | |
38 | + | |
39 | + @Override | |
40 | + public UserType getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { | |
41 | + if (cs.wasNull()) { | |
42 | + return null; | |
43 | + } | |
44 | + int value = cs.getInt(columnIndex); | |
45 | + return UserType.get(value); | |
46 | + } | |
47 | + | |
48 | +} | |
... | ... |
b2c-orders-dao/src/main/resources/spring-dao.xml
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | 2 | <beans xmlns="http://www.springframework.org/schema/beans" |
3 | - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" | |
4 | - xmlns:aop="http://www.springframework.org/schema/aop" | |
5 | - xsi:schemaLocation="http://www.springframework.org/schema/beans | |
6 | - http://www.springframework.org/schema/beans/spring-beans.xsd | |
7 | - http://www.springframework.org/schema/context | |
8 | - http://www.springframework.org/schema/context/spring-context.xsd | |
9 | - http://www.springframework.org/schema/aop | |
10 | - http://www.springframework.org/schema/aop/spring-aop.xsd" | |
11 | - default-autowire="byName"> | |
3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" | |
4 | + xmlns:context="http://www.springframework.org/schema/context" | |
5 | + xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:tx="http://www.springframework.org/schema/tx" | |
6 | + xmlns:util="http://www.springframework.org/schema/util" xmlns:jee="http://www.springframework.org/schema/jee" | |
7 | + xmlns:jms="http://www.springframework.org/schema/jms" | |
8 | + xsi:schemaLocation="http://www.springframework.org/schema/beans | |
9 | + http://www.springframework.org/schema/beans/spring-beans.xsd | |
10 | + http://www.springframework.org/schema/aop | |
11 | + http://www.springframework.org/schema/aop/spring-aop-4.3.xsd | |
12 | + http://www.springframework.org/schema/context | |
13 | + http://www.springframework.org/schema/context/spring-context-4.3.xsd | |
14 | + http://www.springframework.org/schema/tx | |
15 | + http://www.springframework.org/schema/tx/spring-tx-4.3.xsd | |
16 | + http://www.springframework.org/schema/util | |
17 | + http://www.springframework.org/schema/util/spring-util-4.3.xsd | |
18 | + http://www.springframework.org/schema/jee | |
19 | + http://www.springframework.org/schema/jee/spring-jee-4.3.xsd | |
20 | + http://www.springframework.org/schema/jms | |
21 | + http://www.springframework.org/schema/jms/spring-jms-4.3.xsd | |
22 | + http://www.springframework.org/schema/data/jpa | |
23 | + http://www.springframework.org/schema/data/jpa/spring-jpa-1.8.xsd"> | |
12 | 24 | |
13 | 25 | <context:component-scan base-package="com.b2c.orders.dao" /> |
14 | 26 | |
... | ... | @@ -63,5 +75,7 @@ |
63 | 75 | <bean id="sqlTemplate" class="org.mybatis.spring.SqlSessionTemplate"> |
64 | 76 | <constructor-arg index="0" ref="sessionFactory" /> |
65 | 77 | </bean> |
66 | - | |
78 | + | |
79 | + <tx:annotation-driven transaction-manager="transactionManager" /> | |
80 | + | |
67 | 81 | </beans> |
68 | 82 | \ No newline at end of file |
... | ... |
b2c-orders-dao/src/main/resources/sqlmap-config.xml
... | ... | @@ -21,6 +21,7 @@ |
21 | 21 | <!-- 全局别名设置,在映射文件中只需写别名,而不必写出整个类路径 --> |
22 | 22 | <typeAliases> |
23 | 23 | <typeAlias type="com.b2c.orders.domain.OrderMaxid" alias="orderMaxid" /> |
24 | + <typeAlias type="com.b2c.orders.domain.OrderLog" alias="OrderLog" /> | |
24 | 25 | <typeAlias type="com.diligrp.website.util.dao.BaseQuery" |
25 | 26 | alias="Query" /> |
26 | 27 | </typeAliases> |
... | ... | @@ -33,6 +34,7 @@ |
33 | 34 | <mappers> |
34 | 35 | <mapper resource="sqlmap/OrderMaxid.xml" /> |
35 | 36 | <mapper resource="sqlmap/OrderMapper.xml" /> |
37 | + <mapper resource="sqlmap/OrderLogMapper.xml" /> | |
36 | 38 | <mapper resource="sqlmap/OrderItemMapper.xml" /> |
37 | 39 | </mappers> |
38 | 40 | |
... | ... |
b2c-orders-dao/src/main/resources/sqlmap/OrderLogMapper.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8" ?> | |
2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |
3 | +<mapper namespace="com.b2c.orders.dao.impl.OrderLogDaoBean"> | |
4 | + <resultMap id="OrderRM" type="OrderLog"> | |
5 | + <id property="id" column="id" /> | |
6 | + <result property="action" column="action" /> | |
7 | + <result property="actionTime" column="action_time" /> | |
8 | + <result property="userId" column="user_id" /> | |
9 | + <result property="userType" column="user_type" /> | |
10 | + <result property="orderId" column="order_id" /> | |
11 | + <result property="description" column="description" /> | |
12 | + </resultMap> | |
13 | + | |
14 | + <sql id="selectCondition"> | |
15 | + <if test="param != null"> | |
16 | + <if test="param.id != null and param.id != ''"> | |
17 | + and id = #{param.id} | |
18 | + </if> | |
19 | + <if test="param.action != null and param.action != ''"> | |
20 | + and action = #{param.action} | |
21 | + </if> | |
22 | + <if test="param.actionBeginTime != null and param.actionBeginTime != ''"> | |
23 | + <![CDATA[and action_time >= #{param.actionBeginTime}]]> | |
24 | + </if> | |
25 | + <if test="param.actionEndTime != null and param.actionEndTime != ''"> | |
26 | + <![CDATA[and action_time <= #{param.actionEndTime}]]> | |
27 | + </if> | |
28 | + <if test="param.userId != null and param.userId != ''"> | |
29 | + and user_id = #{param.userId} | |
30 | + </if> | |
31 | + <if test="param.userType != null and param.userType != ''"> | |
32 | + and user_type = #{param.userType} | |
33 | + </if> | |
34 | + </if> | |
35 | + </sql> | |
36 | + | |
37 | + <insert id="save" parameterType="OrderLog"> | |
38 | + <![CDATA[ | |
39 | + INSERT INTO t_order_log( | |
40 | + id, | |
41 | + action, | |
42 | + user_id, | |
43 | + user_type, | |
44 | + order_id, | |
45 | + description | |
46 | + ) VALUES( | |
47 | + #{id}, | |
48 | + #{action}, | |
49 | + #{userId}, | |
50 | + #{userType}, | |
51 | + #{orderId}, | |
52 | + #{description} | |
53 | + ) | |
54 | + ]]> | |
55 | + </insert> | |
56 | + | |
57 | + | |
58 | + <select id="countByCondition" parameterType="Query" resultType="Long"> | |
59 | + <![CDATA[ | |
60 | + SELECT count(1) FROM t_order_log where 1=1 | |
61 | + ]]> | |
62 | + <include refid="selectCondition" /> | |
63 | + </select> | |
64 | + | |
65 | + <select id="listByCondition" parameterType="Query" resultMap="OrderRM"> | |
66 | + <![CDATA[ | |
67 | + SELECT | |
68 | + id | |
69 | + ,action | |
70 | + ,action_time | |
71 | + ,user_id | |
72 | + ,user_type | |
73 | + ,order_id | |
74 | + ,description | |
75 | + FROM t_order_log where 1=1 | |
76 | + ]]> | |
77 | + <include refid="selectCondition" /> | |
78 | + order by id desc | |
79 | + <![CDATA[ | |
80 | + limit #{startRow},#{pageSize} | |
81 | + ]]> | |
82 | + </select> | |
83 | + | |
84 | +</mapper> | |
0 | 85 | \ No newline at end of file |
... | ... |
b2c-orders-dao/src/main/resources/sqlmap/OrderMapper.xml
1 | 1 | <?xml version="1.0" encoding="UTF-8" ?> |
2 | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
3 | 3 | <mapper namespace="com.b2c.orders.dao.impl.OrderDaoBean"> |
4 | - <resultMap id="OrderRM" type="com.b2c.orders.domain.Order"> | |
4 | + <resultMap id="OrderLogRM" type="com.b2c.orders.domain.Order"> | |
5 | 5 | <id property="id" column="id" /> |
6 | 6 | <result property="buyerId" column="buyer_id" /> |
7 | 7 | <result property="sellerId" column="seller_id" /> |
... | ... | @@ -153,7 +153,7 @@ |
153 | 153 | <include refid="selectCondition" /> |
154 | 154 | </select> |
155 | 155 | |
156 | - <select id="listByCondition" parameterType="Query" resultMap="OrderRM"> | |
156 | + <select id="listByCondition" parameterType="Query" resultMap="OrderLogRM"> | |
157 | 157 | <![CDATA[ |
158 | 158 | SELECT |
159 | 159 | id |
... | ... |
b2c-orders-dao/src/main/resources/sqlmap/OrderMaxid.xml
... | ... | @@ -35,7 +35,7 @@ |
35 | 35 | </sql> |
36 | 36 | |
37 | 37 | <!-- 插入order_maxid记录 --> |
38 | - <insert id="insertEntry" parameterType="com.b2c.orders.domain.OrderMaxid"> | |
38 | + <insert id="insertEntry" parameterType="Maxid"> | |
39 | 39 | <![CDATA[ |
40 | 40 | INSERT INTO order_maxid (id,id_type,id_value,memo,version_num) |
41 | 41 | VALUES (#{id},#{idType},#{idValue},#{memo},#{versionNum}) |
... | ... | @@ -55,13 +55,13 @@ |
55 | 55 | </delete> |
56 | 56 | |
57 | 57 | <!-- 删除,通过条件 --> |
58 | - <update id="deleteByCondtion" parameterType="com.b2c.orders.domain.OrderMaxid"> | |
58 | + <update id="deleteByCondtion" parameterType="Maxid"> | |
59 | 59 | <![CDATA[DELETE FROM order_maxid]]> |
60 | 60 | <include refid="QUERY_WHERE_CLAUSE" /> |
61 | 61 | </update> |
62 | 62 | |
63 | 63 | <!-- 修改记录通过主键 --> |
64 | - <update id="updateByKey" parameterType="com.b2c.orders.domain.OrderMaxid"> | |
64 | + <update id="updateByKey" parameterType="Maxid"> | |
65 | 65 | <![CDATA[UPDATE order_maxid]]> |
66 | 66 | <include refid="UPDATE_COLUMN_SET" /> |
67 | 67 | <![CDATA[WHERE id = #{id} AND version_num = #{versionNum}]]> |
... | ... | @@ -69,7 +69,7 @@ |
69 | 69 | |
70 | 70 | <!-- 查询,通过主键IN(array) --> |
71 | 71 | <select id="selectEntryArray" parameterType="java.lang.reflect.Array" |
72 | - resultType="com.b2c.orders.domain.OrderMaxid"> | |
72 | + resultType="Maxid"> | |
73 | 73 | <![CDATA[SELECT]]> |
74 | 74 | <include refid="QUERY_COLUMN_LIST" /> |
75 | 75 | <include refid="QUERY_FROM_TABLE" /> |
... | ... | @@ -81,8 +81,8 @@ |
81 | 81 | </select> |
82 | 82 | |
83 | 83 | <!-- 查询,通过条件 --> |
84 | - <select id="selectEntryList" parameterType="com.b2c.orders.domain.OrderMaxid" | |
85 | - resultType="com.b2c.orders.domain.OrderMaxid"> | |
84 | + <select id="selectEntryList" parameterType="Maxid" | |
85 | + resultType="Maxid"> | |
86 | 86 | <![CDATA[SELECT]]> |
87 | 87 | <include refid="QUERY_COLUMN_LIST" /> |
88 | 88 | <include refid="QUERY_FROM_TABLE" /> |
... | ... | @@ -90,7 +90,7 @@ |
90 | 90 | </select> |
91 | 91 | |
92 | 92 | <!-- 总数查询,通过条件 --> |
93 | - <select id="selectEntryListCount" parameterType="com.b2c.orders.domain.OrderMaxid" | |
93 | + <select id="selectEntryListCount" parameterType="Maxid" | |
94 | 94 | resultType="int"> |
95 | 95 | <![CDATA[SELECT COUNT(id) AS dataCount]]> |
96 | 96 | <include refid="QUERY_FROM_TABLE" /> |
... | ... |
b2c-orders-domain/pom.xml
... | ... | @@ -28,10 +28,8 @@ |
28 | 28 | <artifactId>guava</artifactId> |
29 | 29 | </dependency> |
30 | 30 | <!-- https://mvnrepository.com/artifact/cglib/cglib --> |
31 | - <!-- <dependency> | |
32 | - <groupId>cglib</groupId> | |
33 | - <artifactId>cglib</artifactId> | |
34 | - </dependency> --> | |
31 | + <!-- <dependency> <groupId>cglib</groupId> <artifactId>cglib</artifactId> | |
32 | + </dependency> --> | |
35 | 33 | <dependency> |
36 | 34 | <groupId>commons-lang</groupId> |
37 | 35 | <artifactId>commons-lang</artifactId> |
... | ... | @@ -41,5 +39,16 @@ |
41 | 39 | <artifactId>b2c-orders-rpc</artifactId> |
42 | 40 | <version>${project.parent.version}</version> |
43 | 41 | </dependency> |
42 | + <dependency> | |
43 | + <groupId>org.springframework</groupId> | |
44 | + <artifactId>spring-webmvc</artifactId> | |
45 | + <scope>provided</scope> | |
46 | + <exclusions> | |
47 | + <exclusion> | |
48 | + <groupId>commons-logging</groupId> | |
49 | + <artifactId>commons-logging</artifactId> | |
50 | + </exclusion> | |
51 | + </exclusions> | |
52 | + </dependency> | |
44 | 53 | </dependencies> |
45 | 54 | </project> |
46 | 55 | \ No newline at end of file |
... | ... |
b2c-orders-domain/src/main/java/com/b2c/orders/domain/Order.java
... | ... | @@ -107,19 +107,19 @@ public class Order extends BaseDomain { |
107 | 107 | * |
108 | 108 | * @param vo |
109 | 109 | * 订单属性 |
110 | - * @throws ParseException | |
110 | + * @throws ParseException | |
111 | 111 | */ |
112 | 112 | public void submit(SubmitOrderRequestDto vo, OrderIdGenerator idGenerator) throws ParseException { |
113 | 113 | Long orderId = idGenerator.getOrdersNewSeqNo(); |
114 | 114 | this.setId(orderId); |
115 | 115 | this.buyerId = vo.getBuyerId(); |
116 | + this.sellerId = vo.getSellerId(); | |
116 | 117 | this.buyerMemo = vo.getBuyerMemo(); |
117 | 118 | DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
118 | 119 | if (!TextUtils.isEmpty(vo.getDeliveryTime())) { |
119 | 120 | this.deliveryTime = df.parse(vo.getDeliveryTime()); |
120 | 121 | } |
121 | 122 | this.deliveryType = DeliveryType.getDeliveryType(vo.getDeliveryType()); |
122 | - this.payType = PayType.getPayType(vo.getPayType()); | |
123 | 123 | this.payStatus = PayStatus.PayWait; |
124 | 124 | this.orderStatus = OrderStatus.PendingTake; |
125 | 125 | if (!TextUtils.isEmpty(vo.getReservationTime())) { |
... | ... | @@ -148,6 +148,7 @@ public class Order extends BaseDomain { |
148 | 148 | orderItems.add(orderItem); |
149 | 149 | totalPrice += orderItemDto.getSkuPrice(); |
150 | 150 | } |
151 | + this.orderItems = orderItems; | |
151 | 152 | this.totalPrice = totalPrice; |
152 | 153 | } |
153 | 154 | |
... | ... | @@ -182,15 +183,16 @@ public class Order extends BaseDomain { |
182 | 183 | /** |
183 | 184 | * 买家支付 |
184 | 185 | * |
186 | + * @param payType | |
187 | + * TODO | |
188 | + * | |
185 | 189 | * @throws OrderException |
186 | 190 | */ |
187 | - public void pay() throws OrderException { | |
191 | + public void pay(PayType payType) throws OrderException { | |
188 | 192 | if (!this.orderStatus.equals(OrderStatus.PendingPayment)) { |
189 | 193 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "当前订单状态不允许支付"); |
190 | 194 | } |
191 | - if (!this.payType.equals(PayType.Online)) { | |
192 | - throw new OrderException(ApplicationException.DATA_EXCEPTION, "订单支付类型不是线上付款"); | |
193 | - } | |
195 | + this.payType = payType; | |
194 | 196 | this.payStatus = PayStatus.Paid; |
195 | 197 | this.payTime = new Date(); |
196 | 198 | if (this.deliveryType.equals(DeliveryType.Delivery)) { |
... | ... | @@ -229,11 +231,18 @@ public class Order extends BaseDomain { |
229 | 231 | this.orderStatus = OrderStatus.Canceled; |
230 | 232 | } |
231 | 233 | |
232 | - public void timeout() throws OrderException { | |
233 | - if (!this.orderStatus.equals(OrderStatus.PendingTake) && !this.orderStatus.equals(OrderStatus.PendingPayment)) { | |
234 | - throw new OrderException(OrderException.ORDER_STATUS_FLOW_EXCEPTION, "当前状态不能设置订单超时"); | |
234 | + public void takenTimeout() throws OrderException { | |
235 | + if (this.orderStatus.equals(OrderStatus.PendingTake)) { | |
236 | + throw new OrderException(ApplicationException.DATA_EXCEPTION, "当前状态不能设置支付超时"); | |
237 | + } | |
238 | + this.orderStatus = OrderStatus.TakenTimeout; | |
239 | + } | |
240 | + | |
241 | + public void paymentTimeout() throws OrderException { | |
242 | + if (this.orderStatus.equals(OrderStatus.PendingPayment)) { | |
243 | + throw new OrderException(ApplicationException.DATA_EXCEPTION, "当前状态不能设置接单超时"); | |
235 | 244 | } |
236 | - this.orderStatus = OrderStatus.Timeout; | |
245 | + this.orderStatus = OrderStatus.PaymentTimeout; | |
237 | 246 | } |
238 | 247 | |
239 | 248 | public boolean isCanCancel() { |
... | ... |
b2c-orders-domain/src/main/java/com/b2c/orders/domain/OrderLog.java
b2c-orders-manager/src/main/java/com/b2c/orders/manager/OrderManager.java
1 | 1 | package com.b2c.orders.manager; |
2 | 2 | |
3 | 3 | import com.b2c.orders.client.domain.dto.request.SubmitOrderRequestDto; |
4 | +import com.b2c.orders.commons.constant.Constant; | |
4 | 5 | import com.b2c.orders.commons.exceptions.OrderException; |
5 | 6 | import com.b2c.orders.commons.exceptions.OrderRepositoryException; |
6 | -import com.b2c.orders.rpc.exception.DtmsRpcException; | |
7 | +import com.b2c.orders.enums.PayType; | |
8 | +import com.b2c.orders.rpc.exception.DtmsRPCException; | |
7 | 9 | |
8 | 10 | public interface OrderManager { |
9 | 11 | /** |
... | ... | @@ -11,10 +13,10 @@ public interface OrderManager { |
11 | 13 | * |
12 | 14 | * @param orderVo |
13 | 15 | * 订单属性 |
14 | - * @throws DtmsRpcException | |
15 | - * @throws OrderException | |
16 | + * @throws DtmsRPCException | |
17 | + * @throws OrderException | |
16 | 18 | */ |
17 | - void submit(SubmitOrderRequestDto orderVo) throws DtmsRpcException, OrderException; | |
19 | + void submit(SubmitOrderRequestDto orderVo) throws DtmsRPCException, OrderException; | |
18 | 20 | |
19 | 21 | /** |
20 | 22 | * 接单 |
... | ... | @@ -27,9 +29,10 @@ public interface OrderManager { |
27 | 29 | * TODO |
28 | 30 | * @throws OrderException |
29 | 31 | * @throws OrderRepositoryException |
30 | - * @throws DtmsRpcException | |
32 | + * @throws DtmsRPCException | |
31 | 33 | */ |
32 | - void take(Long orderId, Long sellerId, Long totalPrice) throws OrderException, OrderRepositoryException, DtmsRpcException; | |
34 | + void take(Long orderId, Long sellerId, Long totalPrice) | |
35 | + throws OrderException, OrderRepositoryException, DtmsRPCException; | |
33 | 36 | |
34 | 37 | /** |
35 | 38 | * 支付 |
... | ... | @@ -38,10 +41,14 @@ public interface OrderManager { |
38 | 41 | * 订单id |
39 | 42 | * @param buyerId |
40 | 43 | * 买家id |
44 | + * @param payType | |
45 | + * TODO | |
41 | 46 | * @throws OrderRepositoryException |
42 | 47 | * @throws OrderException |
48 | + * @throws DtmsRPCException | |
43 | 49 | */ |
44 | - void pay(Long orderId, Long buyerId) throws OrderRepositoryException, OrderException; | |
50 | + void pay(Long orderId, Long buyerId, PayType payType) | |
51 | + throws OrderRepositoryException, OrderException, DtmsRPCException; | |
45 | 52 | |
46 | 53 | /** |
47 | 54 | * 买家确认收货 |
... | ... | @@ -99,15 +106,25 @@ public interface OrderManager { |
99 | 106 | * @throws OrderRepositoryException |
100 | 107 | * @throws OrderException |
101 | 108 | */ |
102 | - void timeout(Long orderId) throws OrderRepositoryException, OrderException; | |
109 | + void takenTimeout(Long orderId) throws OrderRepositoryException, OrderException; | |
103 | 110 | |
104 | 111 | /** |
105 | - * 商家24小时没有确认收款或者买家24小时没确认收货由dtms确认收款、收货(需求文档要求商家确认收款或者买家确认收货则订单完成) | |
112 | + * 商家{@link Constant.ORDER_CONFIRM_TIMEOUT_SECONDS}秒没有确认收款或者买家{@link Constant.ORDER_CONFIRM_TIMEOUT_SECONDS}秒没确认收货由dtms确认收款、收货(需求文档要求商家确认收款或者买家确认收货则订单完成) | |
106 | 113 | * |
107 | 114 | * @param orderId |
108 | 115 | * 订单id |
109 | - * @throws OrderRepositoryException | |
110 | - * @throws OrderException | |
116 | + * @throws OrderRepositoryException | |
117 | + * @throws OrderException | |
111 | 118 | */ |
112 | 119 | void dtmsConfirm(Long orderId) throws OrderRepositoryException, OrderException; |
120 | + | |
121 | + /** | |
122 | + * 买家付款超时 | |
123 | + * | |
124 | + * @param orderId | |
125 | + * 订单id | |
126 | + * @throws OrderRepositoryException | |
127 | + * @throws OrderException | |
128 | + */ | |
129 | + void paymentTimeout(Long orderId) throws OrderRepositoryException, OrderException; | |
113 | 130 | } |
... | ... |
b2c-orders-manager/src/main/java/com/b2c/orders/manager/impl/OrderManagerBean.java
... | ... | @@ -9,10 +9,8 @@ import org.springframework.stereotype.Component; |
9 | 9 | import org.springframework.transaction.annotation.Propagation; |
10 | 10 | import org.springframework.transaction.annotation.Transactional; |
11 | 11 | |
12 | -import com.alibaba.fastjson.JSON; | |
13 | 12 | import com.b2c.dtms.client.domain.dto.request.DtmsProduceRequestDto; |
14 | 13 | import com.b2c.dtms.common.enums.dtms.DtmsMessageType; |
15 | -import com.b2c.orders.client.domain.dto.request.DtmsTimeoutRequestDto; | |
16 | 14 | import com.b2c.orders.client.domain.dto.request.SubmitOrderRequestDto; |
17 | 15 | import com.b2c.orders.commons.constant.Constant; |
18 | 16 | import com.b2c.orders.commons.exceptions.ApplicationException; |
... | ... | @@ -20,12 +18,19 @@ import com.b2c.orders.commons.exceptions.OrderException; |
20 | 18 | import com.b2c.orders.commons.exceptions.OrderRepositoryException; |
21 | 19 | import com.b2c.orders.commons.utils.OrderIdGenerator; |
22 | 20 | import com.b2c.orders.dao.OrderDao; |
21 | +import com.b2c.orders.dao.OrderLogDao; | |
23 | 22 | import com.b2c.orders.domain.Order; |
23 | +import com.b2c.orders.domain.OrderLog; | |
24 | +import com.b2c.orders.enums.Action; | |
25 | +import com.b2c.orders.enums.PayStatus; | |
26 | +import com.b2c.orders.enums.PayType; | |
27 | +import com.b2c.orders.enums.UserType; | |
24 | 28 | import com.b2c.orders.manager.OrderManager; |
29 | +import com.b2c.orders.rpc.BuyerAccountService; | |
25 | 30 | import com.b2c.orders.rpc.DtmsRPCService; |
26 | -import com.b2c.orders.rpc.exception.DtmsRpcException; | |
31 | +import com.b2c.orders.rpc.exception.DtmsRPCException; | |
27 | 32 | |
28 | -@Transactional(propagation = Propagation.REQUIRED) | |
33 | +@Transactional(propagation = Propagation.REQUIRED, rollbackFor = ApplicationException.class) | |
29 | 34 | @Component |
30 | 35 | public class OrderManagerBean implements OrderManager { |
31 | 36 | |
... | ... | @@ -37,9 +42,13 @@ public class OrderManagerBean implements OrderManager { |
37 | 42 | private OrderIdGenerator IdGenerator; |
38 | 43 | @Autowired |
39 | 44 | private DtmsRPCService dtmsService; |
45 | + @Autowired | |
46 | + private BuyerAccountService userAccountService; | |
47 | + @Autowired | |
48 | + private OrderLogDao orderLogDao; | |
40 | 49 | |
41 | 50 | @Override |
42 | - public void submit(SubmitOrderRequestDto orderVo) throws DtmsRpcException, OrderException { | |
51 | + public void submit(SubmitOrderRequestDto orderVo) throws DtmsRPCException, OrderException { | |
43 | 52 | Order po = new Order(); |
44 | 53 | try { |
45 | 54 | po.submit(orderVo, this.IdGenerator); |
... | ... | @@ -48,20 +57,20 @@ public class OrderManagerBean implements OrderManager { |
48 | 57 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "提交订单失败"); |
49 | 58 | } |
50 | 59 | this.orderDao.save(po); |
51 | - DtmsProduceRequestDto request = new DtmsProduceRequestDto(); | |
52 | - request.setBizId(po.getId().toString()); | |
53 | - request.setCallUrl(Constant.ORDER_TAKE_TIMEOUT_CALL_URL); | |
54 | - DtmsTimeoutRequestDto param = new DtmsTimeoutRequestDto(); | |
55 | - param.setOrderId(po.getId()); | |
56 | - request.setContent(JSON.toJSONString(param)); | |
57 | - request.setDelaySeconds(Constant.ORDER_TAKE_TIMEOUT_SECONDS); | |
58 | - request.setType(DtmsMessageType.Timer.code()); | |
59 | - this.dtmsService.produceDtmsMessage(request); | |
60 | + // 添加订单日志 | |
61 | + OrderLog log = new OrderLog(); | |
62 | + log.setAction(Action.BUYER_PLACE_ORDER); | |
63 | + log.setOrderId(po.getId()); | |
64 | + log.setUserId(po.getBuyerId()); | |
65 | + log.setUserType(UserType.BUYER); | |
66 | + this.orderLogDao.save(log); | |
67 | + // 发送dtms消息 | |
68 | + this.dtmsService.sendOrderTakenTimeoutDtms(po.getId()); | |
60 | 69 | } |
61 | 70 | |
62 | 71 | @Override |
63 | 72 | public void take(Long orderId, Long sellerId, Long totalPrice) |
64 | - throws OrderException, OrderRepositoryException, DtmsRpcException { | |
73 | + throws OrderException, OrderRepositoryException, DtmsRPCException { | |
65 | 74 | Order po = this.orderDao.getById(orderId); |
66 | 75 | if (po == null) { |
67 | 76 | throw new OrderRepositoryException(OrderRepositoryException.ENTITY_NOT_FOUND, |
... | ... | @@ -75,20 +84,21 @@ public class OrderManagerBean implements OrderManager { |
75 | 84 | } |
76 | 85 | po.take(totalPrice); |
77 | 86 | this.orderDao.update(po); |
78 | - DtmsProduceRequestDto request = new DtmsProduceRequestDto(); | |
79 | - request.setBizId(po.getId().toString()); | |
80 | - request.setCallUrl(Constant.ORDER_PAY_TIMEOUT_CALL_URL); | |
81 | - DtmsTimeoutRequestDto param = new DtmsTimeoutRequestDto(); | |
82 | - param.setOrderId(po.getId()); | |
83 | - request.setContent(JSON.toJSONString(param)); | |
84 | - request.setDelaySeconds(Constant.ORDER_PAY_TIMEOUT_SECONDS); | |
85 | - request.setType(DtmsMessageType.Timer.code()); | |
86 | - this.dtmsService.produceDtmsMessage(request); | |
87 | + // 增加订单日志 | |
88 | + OrderLog log = new OrderLog(); | |
89 | + log.setAction(Action.SELLER_TAKEN); | |
90 | + log.setOrderId(orderId); | |
91 | + log.setUserId(sellerId); | |
92 | + log.setUserType(UserType.SELLER); | |
93 | + this.orderLogDao.save(log); | |
94 | + // 发送dtms订单支付超时消息 | |
95 | + this.dtmsService.sendOrderPayTimeoutDtms(orderId); | |
87 | 96 | |
88 | 97 | } |
89 | 98 | |
90 | 99 | @Override |
91 | - public void pay(Long orderId, Long buyerId) throws OrderRepositoryException, OrderException { | |
100 | + public void pay(Long orderId, Long buyerId, PayType payType) | |
101 | + throws OrderRepositoryException, OrderException, DtmsRPCException { | |
92 | 102 | Order po = this.orderDao.getById(orderId); |
93 | 103 | if (po == null) { |
94 | 104 | throw new OrderRepositoryException(OrderRepositoryException.ENTITY_NOT_FOUND, |
... | ... | @@ -100,8 +110,18 @@ public class OrderManagerBean implements OrderManager { |
100 | 110 | if (!po.getBuyerId().equals(buyerId)) { |
101 | 111 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "订单的卖家信息不符,不能支付"); |
102 | 112 | } |
103 | - po.pay(); | |
113 | + po.pay(payType); | |
104 | 114 | this.orderDao.update(po); |
115 | + OrderLog log = new OrderLog(); | |
116 | + log.setAction(Action.BUYER_PAY); | |
117 | + log.setOrderId(orderId); | |
118 | + log.setUserId(buyerId); | |
119 | + log.setUserType(UserType.BUYER); | |
120 | + this.orderLogDao.save(log); | |
121 | + this.dtmsService.sendOrderConfirmDtms(orderId); | |
122 | + if (payType.equals(PayType.Online)) { | |
123 | + this.userAccountService.lockBalance(buyerId, po.getShopId(), po.getRealTotalPrice()); | |
124 | + } | |
105 | 125 | } |
106 | 126 | |
107 | 127 | @Override |
... | ... | @@ -119,6 +139,13 @@ public class OrderManagerBean implements OrderManager { |
119 | 139 | } |
120 | 140 | po.confirm(); |
121 | 141 | this.orderDao.update(po); |
142 | + OrderLog log = new OrderLog(); | |
143 | + log.setAction(Action.BUYER_CONFIRM); | |
144 | + log.setOrderId(orderId); | |
145 | + log.setUserId(buyerId); | |
146 | + log.setUserType(UserType.BUYER); | |
147 | + this.orderLogDao.save(log); | |
148 | + this.userAccountService.debit(buyerId, po.getShopId(), po.getRealTotalPrice()); | |
122 | 149 | } |
123 | 150 | |
124 | 151 | @Override |
... | ... | @@ -136,6 +163,13 @@ public class OrderManagerBean implements OrderManager { |
136 | 163 | } |
137 | 164 | po.confirm(); |
138 | 165 | this.orderDao.update(po); |
166 | + OrderLog log = new OrderLog(); | |
167 | + log.setAction(Action.SELLER_CONFIRM); | |
168 | + log.setOrderId(orderId); | |
169 | + log.setUserId(sellerId); | |
170 | + log.setUserType(UserType.SELLER); | |
171 | + this.orderLogDao.save(log); | |
172 | + this.userAccountService.debit(po.getBuyerId(), po.getShopId(), po.getRealTotalPrice()); | |
139 | 173 | } |
140 | 174 | |
141 | 175 | @Override |
... | ... | @@ -153,7 +187,12 @@ public class OrderManagerBean implements OrderManager { |
153 | 187 | } |
154 | 188 | po.refuse(); |
155 | 189 | this.orderDao.update(po); |
156 | - | |
190 | + OrderLog log = new OrderLog(); | |
191 | + log.setAction(Action.SELLER_REFUSE); | |
192 | + log.setOrderId(orderId); | |
193 | + log.setUserId(sellerId); | |
194 | + log.setUserType(UserType.SELLER); | |
195 | + this.orderLogDao.save(log); | |
157 | 196 | } |
158 | 197 | |
159 | 198 | @Override |
... | ... | @@ -171,17 +210,58 @@ public class OrderManagerBean implements OrderManager { |
171 | 210 | } |
172 | 211 | po.cancel(); |
173 | 212 | this.orderDao.update(po); |
213 | + OrderLog log = new OrderLog(); | |
214 | + log.setAction(Action.BUYER_CANCEL); | |
215 | + log.setOrderId(orderId); | |
216 | + log.setUserId(buyerId); | |
217 | + log.setUserType(UserType.BUYER); | |
218 | + log.setDescription("买家取消订单"); | |
219 | + this.orderLogDao.save(log); | |
220 | + if (po.getPayStatus().equals(PayStatus.Paid)) { | |
221 | + this.userAccountService.unlockBalance(buyerId, po.getShopId(), po.getRealTotalPrice()); | |
222 | + } | |
223 | + } | |
224 | + | |
225 | + @Override | |
226 | + public void takenTimeout(Long orderId) throws OrderRepositoryException, OrderException { | |
227 | + Order po = this.orderDao.getById(orderId); | |
228 | + if (po == null) { | |
229 | + throw new OrderRepositoryException(OrderRepositoryException.ENTITY_NOT_FOUND, | |
230 | + String.format("未找到id为%s的订单", orderId)); | |
231 | + } | |
232 | + try { | |
233 | + po.takenTimeout(); | |
234 | + } catch (OrderException e) { | |
235 | + throw e; | |
236 | + } | |
237 | + this.orderDao.update(po); | |
238 | + OrderLog log = new OrderLog(); | |
239 | + log.setAction(Action.TAKEN_TIMEOUT); | |
240 | + log.setDescription("商家接单超时"); | |
241 | + log.setOrderId(orderId); | |
242 | + log.setUserType(UserType.SYSTEM); | |
243 | + this.orderLogDao.save(log); | |
174 | 244 | } |
175 | 245 | |
176 | 246 | @Override |
177 | - public void timeout(Long orderId) throws OrderRepositoryException, OrderException { | |
247 | + public void paymentTimeout(Long orderId) throws OrderRepositoryException, OrderException { | |
178 | 248 | Order po = this.orderDao.getById(orderId); |
179 | 249 | if (po == null) { |
180 | 250 | throw new OrderRepositoryException(OrderRepositoryException.ENTITY_NOT_FOUND, |
181 | 251 | String.format("未找到id为%s的订单", orderId)); |
182 | 252 | } |
183 | - po.timeout(); | |
253 | + try { | |
254 | + po.paymentTimeout(); | |
255 | + } catch (OrderException e) { | |
256 | + throw e; | |
257 | + } | |
184 | 258 | this.orderDao.update(po); |
259 | + OrderLog log = new OrderLog(); | |
260 | + log.setAction(Action.PAYMENT_TIMEOUT); | |
261 | + log.setDescription("买家付款超时"); | |
262 | + log.setOrderId(orderId); | |
263 | + log.setUserType(UserType.SYSTEM); | |
264 | + this.orderLogDao.save(log); | |
185 | 265 | } |
186 | 266 | |
187 | 267 | @Override |
... | ... | @@ -191,8 +271,21 @@ public class OrderManagerBean implements OrderManager { |
191 | 271 | throw new OrderRepositoryException(OrderRepositoryException.ENTITY_NOT_FOUND, |
192 | 272 | String.format("未找到id为%s的订单", orderId)); |
193 | 273 | } |
194 | - po.confirm(); | |
274 | + try { | |
275 | + po.confirm(); | |
276 | + } catch (OrderException e) { | |
277 | + throw e; | |
278 | + } | |
195 | 279 | this.orderDao.update(po); |
280 | + OrderLog log = new OrderLog(); | |
281 | + log.setAction(Action.SYSTEM_CONFIRM); | |
282 | + log.setDescription("买家确认收货超时或商家确认收款超时,系统自动确认收货、收款"); | |
283 | + log.setOrderId(orderId); | |
284 | + log.setUserType(UserType.SYSTEM); | |
285 | + this.orderLogDao.save(log); | |
286 | + if (po.getPayType().equals(PayType.Online)) { | |
287 | + this.userAccountService.debit(po.getBuyerId(), po.getShopId(), po.getRealTotalPrice()); | |
288 | + } | |
196 | 289 | } |
197 | 290 | |
198 | 291 | } |
... | ... |
b2c-orders-rpc/pom.xml
... | ... | @@ -19,5 +19,9 @@ |
19 | 19 | <artifactId>dtms-client</artifactId> |
20 | 20 | <version>0.0.1-SNAPSHOT</version> |
21 | 21 | </dependency> |
22 | + <dependency> | |
23 | + <groupId>org.springframework</groupId> | |
24 | + <artifactId>spring-beans</artifactId> | |
25 | + </dependency> | |
22 | 26 | </dependencies> |
23 | 27 | </project> |
24 | 28 | \ No newline at end of file |
... | ... |
b2c-orders-rpc/src/main/java/com/b2c/orders/rpc/BuyerAccountService.java
0 → 100644
1 | +package com.b2c.orders.rpc; | |
2 | + | |
3 | +public interface BuyerAccountService { | |
4 | + | |
5 | + /** | |
6 | + * 锁定买家账户余额 | |
7 | + * | |
8 | + * @param buyerId | |
9 | + * 买家id | |
10 | + * @param shopId | |
11 | + * 店铺id | |
12 | + * @param amount | |
13 | + * 锁定金额 | |
14 | + */ | |
15 | + void lockBalance(Long buyerId, Long shopId, Long amount); | |
16 | + | |
17 | + /** | |
18 | + * 买家账户扣款 | |
19 | + * | |
20 | + * @param buyerId | |
21 | + * 买家id | |
22 | + * @param shopId | |
23 | + * 店铺id | |
24 | + * @param amount | |
25 | + * 扣款金额 | |
26 | + */ | |
27 | + void debit(Long buyerId, Long shopId, Long amount); | |
28 | + | |
29 | + /** | |
30 | + * 解除买家账户锁定 | |
31 | + * | |
32 | + * @param buyerId | |
33 | + * 买家id | |
34 | + * @param shopId | |
35 | + * 店铺id | |
36 | + * @param amount | |
37 | + * 解除锁定金额 | |
38 | + */ | |
39 | + void unlockBalance(Long buyerId, Long shopId, Long amount); | |
40 | +} | |
... | ... |
b2c-orders-rpc/src/main/java/com/b2c/orders/rpc/DtmsRPCService.java
1 | 1 | package com.b2c.orders.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.rpc.exception.DtmsRPCException; | |
5 | 5 | |
6 | 6 | public interface DtmsRPCService { |
7 | 7 | |
8 | - void produceDtmsMessage(DtmsProduceRequestDto request) throws DtmsRpcException; | |
8 | + void produceDtmsMessage(DtmsProduceRequestDto request) throws DtmsRPCException; | |
9 | + | |
10 | + void sendOrderTakenTimeoutDtms(Long orderId) throws DtmsRPCException; | |
11 | + | |
12 | + void sendOrderPayTimeoutDtms(Long orderId) throws DtmsRPCException; | |
13 | + | |
14 | + void sendOrderConfirmDtms(Long orderId) throws DtmsRPCException; | |
9 | 15 | |
10 | 16 | } |
... | ... |
b2c-orders-rpc/src/main/java/com/b2c/orders/rpc/annotations/RPCService.java
0 → 100644
1 | +package com.b2c.orders.rpc.annotations; | |
2 | + | |
3 | +import java.lang.annotation.ElementType; | |
4 | +import java.lang.annotation.Target; | |
5 | + | |
6 | +@Target({ ElementType.FIELD, ElementType.METHOD }) | |
7 | +public @interface RPCService { | |
8 | + | |
9 | + Class<?> value() default Object.class; | |
10 | + | |
11 | + String beanName() default ""; | |
12 | + | |
13 | + String method() default ""; | |
14 | +} | |
... | ... |
b2c-orders-rpc/src/main/java/com/b2c/orders/rpc/exception/DtmsRpcException.java renamed to b2c-orders-rpc/src/main/java/com/b2c/orders/rpc/exception/DtmsRPCException.java
... | ... | @@ -2,35 +2,35 @@ package com.b2c.orders.rpc.exception; |
2 | 2 | |
3 | 3 | import com.b2c.orders.commons.exceptions.ApplicationException; |
4 | 4 | |
5 | -public class DtmsRpcException extends ApplicationException { | |
5 | +public class DtmsRPCException extends ApplicationException { | |
6 | 6 | |
7 | 7 | /** |
8 | 8 | * |
9 | 9 | */ |
10 | 10 | private static final long serialVersionUID = 6485664433664748337L; |
11 | 11 | |
12 | - public DtmsRpcException(int code, String message, Throwable cause, boolean enableSuppression, | |
12 | + public DtmsRPCException(int code, String message, Throwable cause, boolean enableSuppression, | |
13 | 13 | boolean writableStackTrace) { |
14 | 14 | super(code, message, cause, enableSuppression, writableStackTrace); |
15 | 15 | // TODO Auto-generated constructor stub |
16 | 16 | } |
17 | 17 | |
18 | - public DtmsRpcException(int code, String message, Throwable cause) { | |
18 | + public DtmsRPCException(int code, String message, Throwable cause) { | |
19 | 19 | super(code, message, cause); |
20 | 20 | // TODO Auto-generated constructor stub |
21 | 21 | } |
22 | 22 | |
23 | - public DtmsRpcException(int code, String message) { | |
23 | + public DtmsRPCException(int code, String message) { | |
24 | 24 | super(code, message); |
25 | 25 | // TODO Auto-generated constructor stub |
26 | 26 | } |
27 | 27 | |
28 | - public DtmsRpcException(int code, Throwable cause) { | |
28 | + public DtmsRPCException(int code, Throwable cause) { | |
29 | 29 | super(code, cause); |
30 | 30 | // TODO Auto-generated constructor stub |
31 | 31 | } |
32 | 32 | |
33 | - public DtmsRpcException(int code) { | |
33 | + public DtmsRPCException(int code) { | |
34 | 34 | super(code); |
35 | 35 | // TODO Auto-generated constructor stub |
36 | 36 | } |
... | ... |
b2c-orders-rpc/src/main/java/com/b2c/orders/rpc/impl/BuyerAccountServiceBean.java
0 → 100644
1 | +package com.b2c.orders.rpc.impl; | |
2 | + | |
3 | +import org.slf4j.Logger; | |
4 | +import org.slf4j.LoggerFactory; | |
5 | + | |
6 | +import com.b2c.orders.rpc.BuyerAccountService; | |
7 | + | |
8 | +public class BuyerAccountServiceBean implements BuyerAccountService { | |
9 | + | |
10 | + private static final Logger LOG = LoggerFactory.getLogger(BuyerAccountServiceBean.class); | |
11 | + | |
12 | + @Override | |
13 | + public void lockBalance(Long userId, Long shopId, Long amount) { | |
14 | + LOG.error("lockBalance方法还没实现"); | |
15 | + } | |
16 | + | |
17 | + @Override | |
18 | + public void debit(Long buyerId, Long shopId, Long realTotalPrice) { | |
19 | + LOG.error("debit方法还没实现"); | |
20 | + } | |
21 | + | |
22 | + @Override | |
23 | + public void unlockBalance(Long buyerId, Long shopId, Long realTotalPrice) { | |
24 | + LOG.error("unlockBalance方法还没实现"); | |
25 | + } | |
26 | + | |
27 | +} | |
... | ... |
b2c-orders-rpc/src/main/java/com/b2c/orders/rpc/impl/DtmsRPCServiceBean.java
... | ... | @@ -3,26 +3,56 @@ package com.b2c.orders.rpc.impl; |
3 | 3 | import com.b2c.dtms.client.DtmsClient; |
4 | 4 | import com.b2c.dtms.client.domain.dto.request.DtmsProduceRequestDto; |
5 | 5 | import com.b2c.dtms.client.domain.dto.response.DtmsResponseDto; |
6 | -import com.b2c.dtms.common.enums.dtms.HandleCode; | |
6 | +import com.b2c.dtms.common.enums.dtms.DtmsMessageType; | |
7 | +import com.b2c.orders.commons.constant.Constant; | |
7 | 8 | import com.b2c.orders.commons.exceptions.ApplicationException; |
8 | 9 | import com.b2c.orders.rpc.DtmsRPCService; |
9 | -import com.b2c.orders.rpc.exception.DtmsRpcException; | |
10 | +import com.b2c.orders.rpc.exception.DtmsRPCException; | |
10 | 11 | |
11 | 12 | public class DtmsRPCServiceBean implements DtmsRPCService { |
12 | 13 | |
13 | - private DtmsClient dtmsClient = new DtmsClient(); | |
14 | + private DtmsClient dtmsClient; | |
15 | + | |
16 | + public DtmsRPCServiceBean(String baseUrl, String token) { | |
17 | + this.dtmsClient = new DtmsClient(baseUrl, token); | |
18 | + } | |
14 | 19 | |
15 | 20 | @Override |
16 | - public void produceDtmsMessage(DtmsProduceRequestDto request) throws DtmsRpcException { | |
17 | - DtmsResponseDto response = this.dtmsClient.produceMessage(request); | |
18 | - String code = response.getCode(); | |
19 | - if (code.equals(HandleCode.FAILED.code())) { | |
20 | - throw new DtmsRpcException(ApplicationException.DATA_EXCEPTION, "创建dtms消息失败"); | |
21 | - } | |
22 | - if (code.equals(HandleCode.SUCCESS)) { | |
23 | - return; | |
21 | + public void produceDtmsMessage(DtmsProduceRequestDto request) throws DtmsRPCException { | |
22 | + DtmsResponseDto response = this.dtmsClient.getDtmsService().produceMessage(request); | |
23 | + if (response.getCode().equals(DtmsResponseDto.CODE_FAILED)) { | |
24 | + throw new DtmsRPCException(ApplicationException.DATA_EXCEPTION, "创建dtms消息失败"); | |
24 | 25 | } |
25 | - throw new DtmsRpcException(ApplicationException.DATA_EXCEPTION, "未知的返回类型"); | |
26 | + } | |
27 | + | |
28 | + @Override | |
29 | + public void sendOrderPayTimeoutDtms(Long orderId) throws DtmsRPCException { | |
30 | + DtmsProduceRequestDto request = new DtmsProduceRequestDto(); | |
31 | + request.setBizId(orderId.toString()); | |
32 | + request.setCallUrl(Constant.ORDER_PAY_TIMEOUT_CALL_URL); | |
33 | + request.setDelaySeconds(Constant.ORDER_PAYMENT_TIMEOUT_SECONDS); | |
34 | + request.setType(DtmsMessageType.Timer.code()); | |
35 | + this.produceDtmsMessage(request); | |
36 | + } | |
37 | + | |
38 | + @Override | |
39 | + public void sendOrderConfirmDtms(Long id) throws DtmsRPCException { | |
40 | + DtmsProduceRequestDto request = new DtmsProduceRequestDto(); | |
41 | + request.setBizId(id.toString()); | |
42 | + request.setCallUrl(Constant.ORDER_CONFIRM_TIMEOUT_CALL_URL); | |
43 | + request.setDelaySeconds(Constant.ORDER_CONFIRM_TIMEOUT_SECONDS); | |
44 | + request.setType(DtmsMessageType.Timer.code()); | |
45 | + this.produceDtmsMessage(request); | |
46 | + } | |
47 | + | |
48 | + @Override | |
49 | + public void sendOrderTakenTimeoutDtms(Long orderId) throws DtmsRPCException { | |
50 | + DtmsProduceRequestDto request = new DtmsProduceRequestDto(); | |
51 | + request.setBizId(orderId.toString()); | |
52 | + request.setCallUrl(Constant.ORDER_TAKE_TIMEOUT_CALL_URL); | |
53 | + request.setDelaySeconds(Constant.ORDER_TAKEN_TIMEOUT_SECONDS); | |
54 | + request.setType(DtmsMessageType.Timer.code()); | |
55 | + this.produceDtmsMessage(request); | |
26 | 56 | } |
27 | 57 | |
28 | 58 | } |
... | ... |
b2c-orders-rpc/src/main/resources/rpc.properties
0 → 100644
b2c-orders-web/src/main/resources/spring-rpc.xml renamed to b2c-orders-rpc/src/main/resources/spring-rpc.xml
... | ... | @@ -14,6 +14,11 @@ |
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="dtmsRPCService" class="com.b2c.orders.rpc.impl.DtmsRPCServiceBean"> | |
18 | + <constructor-arg name="baseUrl" value="${dtms.baseUrl}" /> | |
19 | + <constructor-arg name="token" value="${dtms.token}" /> | |
20 | + </bean> | |
21 | + | |
22 | + <bean id="buyerAccountService" class="com.b2c.orders.rpc.impl.BuyerAccountServiceBean" /> | |
18 | 23 | |
19 | 24 | </beans> |
20 | 25 | \ No newline at end of file |
... | ... |
b2c-orders-service/src/main/java/com/b2c/orders/service/OrderService.java
1 | 1 | package com.b2c.orders.service; |
2 | 2 | |
3 | 3 | import com.b2c.orders.client.domain.dto.request.SubmitOrderRequestDto; |
4 | +import com.b2c.orders.commons.constant.Constant; | |
4 | 5 | import com.b2c.orders.commons.exceptions.OrderException; |
5 | 6 | import com.b2c.orders.commons.exceptions.OrderRepositoryException; |
6 | -import com.b2c.orders.rpc.exception.DtmsRpcException; | |
7 | +import com.b2c.orders.enums.PayType; | |
8 | +import com.b2c.orders.rpc.exception.DtmsRPCException; | |
7 | 9 | |
8 | 10 | public interface OrderService { |
9 | 11 | |
... | ... | @@ -12,10 +14,10 @@ public interface OrderService { |
12 | 14 | * |
13 | 15 | * @param order |
14 | 16 | * 订单id |
15 | - * @throws DtmsRpcException | |
16 | - * @throws OrderException | |
17 | + * @throws DtmsRPCException | |
18 | + * @throws OrderException | |
17 | 19 | */ |
18 | - void submit(SubmitOrderRequestDto order) throws DtmsRpcException, OrderException; | |
20 | + void submit(SubmitOrderRequestDto order) throws DtmsRPCException, OrderException; | |
19 | 21 | |
20 | 22 | /** |
21 | 23 | * 商家接单 |
... | ... | @@ -28,9 +30,10 @@ public interface OrderService { |
28 | 30 | * TODO |
29 | 31 | * @throws OrderRepositoryException |
30 | 32 | * @throws OrderException |
31 | - * @throws DtmsRpcException | |
33 | + * @throws DtmsRPCException | |
32 | 34 | */ |
33 | - void take(Long orderId, Long sellerId, Long totalPrice) throws OrderException, OrderRepositoryException, DtmsRpcException; | |
35 | + void take(Long orderId, Long sellerId, Long totalPrice) | |
36 | + throws OrderException, OrderRepositoryException, DtmsRPCException; | |
34 | 37 | |
35 | 38 | /** |
36 | 39 | * 买家支付 |
... | ... | @@ -39,10 +42,14 @@ public interface OrderService { |
39 | 42 | * 订单id |
40 | 43 | * @param buyerId |
41 | 44 | * 买家id |
45 | + * @param payType | |
46 | + * TODO | |
42 | 47 | * @throws OrderException |
43 | 48 | * @throws OrderRepositoryException |
49 | + * @throws DtmsRPCException | |
44 | 50 | */ |
45 | - void pay(Long orderId, Long buyerId) throws OrderRepositoryException, OrderException; | |
51 | + void pay(Long orderId, Long buyerId, PayType payType) | |
52 | + throws OrderRepositoryException, OrderException, DtmsRPCException; | |
46 | 53 | |
47 | 54 | /** |
48 | 55 | * 买家确认收货 |
... | ... | @@ -93,22 +100,31 @@ public interface OrderService { |
93 | 100 | void cancel(Long orderId, Long buyerId) throws OrderRepositoryException, OrderException; |
94 | 101 | |
95 | 102 | /** |
96 | - * 商家24小时未接单,订单超时 | |
103 | + * 商家{@link Constant.ORDER_TAKEN_TIMEOUT_SECONDS}秒未接单,订单超时 | |
97 | 104 | * |
98 | 105 | * @param orderId |
99 | 106 | * 订单id |
100 | 107 | * @throws OrderException |
101 | 108 | * @throws OrderRepositoryException |
102 | 109 | */ |
103 | - void timeout(Long orderId) throws OrderRepositoryException, OrderException; | |
110 | + void takenTimeout(Long orderId) throws OrderRepositoryException, OrderException; | |
111 | + | |
112 | + /** | |
113 | + * 买家{@link Constant.ORDER_PAYMENT_TIMEOUT_SECONDS}未支付,订单超时 | |
114 | + * | |
115 | + * @param orderId | |
116 | + * @throws OrderRepositoryException | |
117 | + */ | |
118 | + void paymentTimeout(Long orderId) throws OrderRepositoryException; | |
104 | 119 | |
105 | 120 | /** |
106 | 121 | * 商家24小时没有确认收款或者买家24小时没确认收货由dtms确认收款、收货(需求文档要求商家确认收款或者买家确认收货则订单完成) |
107 | 122 | * |
108 | 123 | * @param orderId |
109 | 124 | * 订单id |
110 | - * @throws OrderException | |
111 | - * @throws OrderRepositoryException | |
125 | + * @throws OrderException | |
126 | + * @throws OrderRepositoryException | |
112 | 127 | */ |
113 | 128 | void dtmsConfirm(Long orderId) throws OrderRepositoryException, OrderException; |
129 | + | |
114 | 130 | } |
... | ... |
b2c-orders-service/src/main/java/com/b2c/orders/service/impl/OrderServiceBean.java
1 | 1 | package com.b2c.orders.service.impl; |
2 | 2 | |
3 | +import org.slf4j.Logger; | |
4 | +import org.slf4j.LoggerFactory; | |
3 | 5 | import org.springframework.beans.factory.annotation.Autowired; |
4 | 6 | import org.springframework.stereotype.Service; |
5 | 7 | import org.springframework.transaction.annotation.Propagation; |
... | ... | @@ -9,31 +11,35 @@ import com.b2c.orders.client.domain.dto.request.SubmitOrderRequestDto; |
9 | 11 | import com.b2c.orders.commons.exceptions.ApplicationException; |
10 | 12 | import com.b2c.orders.commons.exceptions.OrderException; |
11 | 13 | import com.b2c.orders.commons.exceptions.OrderRepositoryException; |
14 | +import com.b2c.orders.enums.PayType; | |
12 | 15 | import com.b2c.orders.manager.OrderManager; |
13 | -import com.b2c.orders.rpc.exception.DtmsRpcException; | |
16 | +import com.b2c.orders.rpc.exception.DtmsRPCException; | |
14 | 17 | import com.b2c.orders.service.OrderService; |
15 | 18 | |
16 | 19 | @Service |
17 | 20 | @Transactional(propagation = Propagation.REQUIRED, rollbackFor = ApplicationException.class) |
18 | 21 | public class OrderServiceBean implements OrderService { |
19 | 22 | |
23 | + private static final Logger LOG = LoggerFactory.getLogger(OrderServiceBean.class); | |
24 | + | |
20 | 25 | @Autowired |
21 | 26 | private OrderManager orderManager; |
22 | 27 | |
23 | 28 | @Override |
24 | - public void submit(SubmitOrderRequestDto order) throws DtmsRpcException, OrderException { | |
29 | + public void submit(SubmitOrderRequestDto order) throws DtmsRPCException, OrderException { | |
25 | 30 | this.orderManager.submit(order); |
26 | 31 | } |
27 | 32 | |
28 | 33 | @Override |
29 | 34 | public void take(Long orderId, Long sellerId, Long totalPrice) |
30 | - throws OrderException, OrderRepositoryException, DtmsRpcException { | |
35 | + throws OrderException, OrderRepositoryException, DtmsRPCException { | |
31 | 36 | this.orderManager.take(orderId, sellerId, totalPrice); |
32 | 37 | } |
33 | 38 | |
34 | 39 | @Override |
35 | - public void pay(Long orderId, Long buyerId) throws OrderRepositoryException, OrderException { | |
36 | - this.orderManager.pay(orderId, buyerId); | |
40 | + public void pay(Long orderId, Long buyerId, PayType payType) | |
41 | + throws OrderRepositoryException, OrderException, DtmsRPCException { | |
42 | + this.orderManager.pay(orderId, buyerId, payType); | |
37 | 43 | } |
38 | 44 | |
39 | 45 | @Override |
... | ... | @@ -57,8 +63,21 @@ public class OrderServiceBean implements OrderService { |
57 | 63 | } |
58 | 64 | |
59 | 65 | @Override |
60 | - public void timeout(Long orderId) throws OrderRepositoryException, OrderException { | |
61 | - this.orderManager.timeout(orderId); | |
66 | + public void takenTimeout(Long orderId) throws OrderRepositoryException { | |
67 | + try { | |
68 | + this.orderManager.takenTimeout(orderId); | |
69 | + } catch (OrderException e) { | |
70 | + LOG.debug(e.getMessage(), e); | |
71 | + } | |
72 | + } | |
73 | + | |
74 | + @Override | |
75 | + public void paymentTimeout(Long orderId) throws OrderRepositoryException { | |
76 | + try { | |
77 | + this.orderManager.paymentTimeout(orderId); | |
78 | + } catch (OrderException e) { | |
79 | + LOG.debug(e.getMessage(), e); | |
80 | + } | |
62 | 81 | } |
63 | 82 | |
64 | 83 | @Override |
... | ... |
b2c-orders-web/src/main/java/com/b2c/orders/web/restful/OrderRestController.java
... | ... | @@ -26,7 +26,7 @@ import com.b2c.orders.client.domain.dto.response.BaseResponseDto; |
26 | 26 | import com.b2c.orders.client.domain.dto.response.OrderListResponseDto; |
27 | 27 | import com.b2c.orders.client.domain.dto.response.SubmitOrderResponseDto; |
28 | 28 | import com.b2c.orders.commons.exceptions.ApplicationException; |
29 | -import com.b2c.orders.rpc.exception.DtmsRpcException; | |
29 | +import com.b2c.orders.enums.PayType; | |
30 | 30 | import com.b2c.orders.service.OrderService; |
31 | 31 | |
32 | 32 | import io.swagger.annotations.Api; |
... | ... | @@ -73,7 +73,7 @@ public class OrderRestController { |
73 | 73 | public BaseResponseDto pay(@RequestBody @Valid PayOrderRequestDto request, BindingResult br) { |
74 | 74 | BaseResponseDto dto = new BaseResponseDto(); |
75 | 75 | try { |
76 | - this.orderService.pay(request.getOrderId(), request.getBuyerId()); | |
76 | + this.orderService.pay(request.getOrderId(), request.getBuyerId(), PayType.getPayType(request.getPayType())); | |
77 | 77 | dto.setCode(BaseResponseDto.RESPONSE_CODE_SUCCESS); |
78 | 78 | dto.setSuccess(true); |
79 | 79 | } catch (ApplicationException e) { |
... | ... | @@ -155,7 +155,7 @@ public class OrderRestController { |
155 | 155 | public DtmsCallBackReturn dtmsTimeout(@RequestBody @Valid DtmsTimeoutRequestDto request, BindingResult br) { |
156 | 156 | DtmsCallBackReturn response = new DtmsCallBackReturn(); |
157 | 157 | try { |
158 | - this.orderService.timeout(request.getOrderId()); | |
158 | + this.orderService.takenTimeout(request.getOrderId()); | |
159 | 159 | response.setCode(HandleCode.SUCCESS.code()); |
160 | 160 | } catch (ApplicationException e) { |
161 | 161 | response.setCode(HandleCode.FAILED.code()); |
... | ... |
b2c-orders-web/src/main/resources/spring.xml
... | ... | @@ -13,10 +13,7 @@ |
13 | 13 | http://www.springframework.org/schema/cache |
14 | 14 | http://www.springframework.org/schema/cache/spring-cache-4.3.xsd" |
15 | 15 | default-lazy-init="true"> |
16 | - <context:component-scan base-package="com.b2c.orders"> | |
17 | - <!-- <context:exclude-filter type="annotation" | |
18 | - expression="org.springframework.stereotype.Controller" /> --> | |
19 | - </context:component-scan> | |
16 | + <context:component-scan base-package="com.b2c.orders" /> | |
20 | 17 | <context:annotation-config /> |
21 | 18 | |
22 | 19 | <!-- <cache:annotation-driven cache-manager="cacheManager" key-generator="cacheKeyGenerator" |
... | ... | @@ -34,6 +31,7 @@ |
34 | 31 | <value>classpath:conf/important.properties</value> |
35 | 32 | <value>classpath:conf/orders-production.properties</value> |
36 | 33 | <value>classpath:conf/manage.properties</value> |
34 | + <value>classpath:rpc.properties</value> | |
37 | 35 | </list> |
38 | 36 | </property> |
39 | 37 | </bean> |
... | ... | @@ -55,8 +53,8 @@ |
55 | 53 | |
56 | 54 | <!-- <import resource="classpath*:spring-config-service.xml"/> --> |
57 | 55 | <import resource="classpath*:springmvc-config.xml" /> |
58 | - <import resource="classpath*:spring-dao.xml"/> | |
59 | - <import resource="classpath*:spring-rpc.xml"/> | |
56 | + <import resource="classpath*:spring-dao.xml" /> | |
57 | + <import resource="classpath*:spring-rpc.xml" /> | |
60 | 58 | <!-- <import resource="classpath*:spring-redis.xml"/> --> |
61 | 59 | <!-- <import resource="classpath*:spring-website-redis.xml"/> --> |
62 | 60 | <!-- <import resource="classpath*:spring-config-dtms-forOrdersWeb.xml"/> --> |
... | ... |
b2c-orders-web/src/test/java/TestCase.java
0 → 100644
1 | +import static org.junit.Assert.*; | |
2 | + | |
3 | +import java.text.SimpleDateFormat; | |
4 | +import java.util.Date; | |
5 | + | |
6 | +import org.junit.Test; | |
7 | + | |
8 | +public class TestCase { | |
9 | + | |
10 | + @Test | |
11 | + public void test() { | |
12 | + System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(1481360497951L))); | |
13 | + } | |
14 | + | |
15 | +} | |
... | ... |
pom.xml
... | ... | @@ -7,26 +7,7 @@ |
7 | 7 | <packaging>pom</packaging> |
8 | 8 | |
9 | 9 | <properties> |
10 | - <jdk.version>1.7</jdk.version> | |
11 | - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
12 | - <maven.compiler.encoding>UTF-8</maven.compiler.encoding> | |
13 | - <spring.version>4.3.2.RELEASE</spring.version> | |
14 | - <aspectj.version>1.6.11</aspectj.version> | |
15 | - <jackson.version>2.8.5</jackson.version> | |
16 | - <slf4j.version>1.7.21</slf4j.version> | |
17 | - <logback.version>1.1.3</logback.version> | |
18 | - <titan.devlop.version>0.0.3-SNAPSHOT</titan.devlop.version> | |
19 | - <titan.product.version>0.0.3-SNAPSHOT</titan.product.version> | |
20 | - <orders.client.sdk.version>1.1.0-SNAPSHOT</orders.client.sdk.version> | |
21 | - <srvce.client.sdk.version>1.4-SNAPSHOT</srvce.client.sdk.version> | |
22 | - <user.client.devlop.version>0.0.1-SNAPSHOT</user.client.devlop.version> | |
23 | - <user.client.product.version>0.0.3-SNAPSHOT</user.client.product.version> | |
24 | - <fastjson.version>1.2.7</fastjson.version> | |
25 | - <mybatis.version>3.2.5</mybatis.version> | |
26 | - <guava.version>20.0</guava.version> | |
27 | - <pnr-shop-develop.version>0.0.1-SNAPSHOT</pnr-shop-develop.version> | |
28 | - <pnr-shop-product.version>0.0.1-SNAPSHOT</pnr-shop-product.version> | |
29 | - <lombox.version>1.16.10</lombox.version> | |
10 | + | |
30 | 11 | <orders.cache.main.key>1n4j_orders:data</orders.cache.main.key> |
31 | 12 | <!--订单获系统缓存开关 --> |
32 | 13 | <orders.cache.enabled>true</orders.cache.enabled> |
... | ... | @@ -48,6 +29,29 @@ |
48 | 29 | <project.static.path>http://static.1n4j.com/static</project.static.path> |
49 | 30 | <!-- 订单请求和响应参数 --> |
50 | 31 | <orders.paramLog.enabled>true</orders.paramLog.enabled> |
32 | + <dtms.baseUrl>http://dtms.zandeapp.com:8080</dtms.baseUrl> | |
33 | + <dtms.token></dtms.token> | |
34 | + | |
35 | + <jdk.version>1.7</jdk.version> | |
36 | + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
37 | + <maven.compiler.encoding>UTF-8</maven.compiler.encoding> | |
38 | + <spring.version>4.3.2.RELEASE</spring.version> | |
39 | + <aspectj.version>1.6.11</aspectj.version> | |
40 | + <jackson.version>2.8.5</jackson.version> | |
41 | + <slf4j.version>1.7.21</slf4j.version> | |
42 | + <logback.version>1.1.3</logback.version> | |
43 | + <titan.devlop.version>0.0.3-SNAPSHOT</titan.devlop.version> | |
44 | + <titan.product.version>0.0.3-SNAPSHOT</titan.product.version> | |
45 | + <orders.client.sdk.version>1.1.0-SNAPSHOT</orders.client.sdk.version> | |
46 | + <srvce.client.sdk.version>1.4-SNAPSHOT</srvce.client.sdk.version> | |
47 | + <user.client.devlop.version>0.0.1-SNAPSHOT</user.client.devlop.version> | |
48 | + <user.client.product.version>0.0.3-SNAPSHOT</user.client.product.version> | |
49 | + <fastjson.version>1.2.7</fastjson.version> | |
50 | + <mybatis.version>3.2.5</mybatis.version> | |
51 | + <guava.version>20.0</guava.version> | |
52 | + <pnr-shop-develop.version>0.0.1-SNAPSHOT</pnr-shop-develop.version> | |
53 | + <pnr-shop-product.version>0.0.1-SNAPSHOT</pnr-shop-product.version> | |
54 | + <lombox.version>1.16.10</lombox.version> | |
51 | 55 | <mariadb-java-client.version>1.5.5</mariadb-java-client.version> |
52 | 56 | <aspectjweaver.version>1.7.2</aspectjweaver.version> |
53 | 57 | <woodstox.version>4.4.1</woodstox.version> |
... | ... | @@ -75,10 +79,6 @@ |
75 | 79 | </exclusion> |
76 | 80 | <exclusion> |
77 | 81 | <groupId>org.springframework</groupId> |
78 | - <artifactId>spring-beans</artifactId> | |
79 | - </exclusion> | |
80 | - <exclusion> | |
81 | - <groupId>org.springframework</groupId> | |
82 | 82 | <artifactId>spring-context</artifactId> |
83 | 83 | </exclusion> |
84 | 84 | <exclusion> |
... | ... | @@ -271,6 +271,11 @@ |
271 | 271 | </dependency> |
272 | 272 | <dependency> |
273 | 273 | <groupId>org.springframework</groupId> |
274 | + <artifactId>spring-beans</artifactId> | |
275 | + <version>${spring.version}</version> | |
276 | + </dependency> | |
277 | + <dependency> | |
278 | + <groupId>org.springframework</groupId> | |
274 | 279 | <artifactId>spring-tx</artifactId> |
275 | 280 | <version>${spring.version}</version> |
276 | 281 | </dependency> |
... | ... | @@ -402,7 +407,7 @@ |
402 | 407 | <dependency> |
403 | 408 | <groupId>junit</groupId> |
404 | 409 | <artifactId>junit</artifactId> |
405 | - <version>4.5</version> | |
410 | + <version>4.11</version> | |
406 | 411 | <scope>test</scope> |
407 | 412 | </dependency> |
408 | 413 | <!-- if you enable @AspectJ style AOP in spring. --> |
... | ... | @@ -463,7 +468,7 @@ |
463 | 468 | <profiles> |
464 | 469 | <profile> |
465 | 470 | <!-- 开发环境 --> |
466 | - <id>develop</id> | |
471 | + <id>dev</id> | |
467 | 472 | <!-- 默认 --> |
468 | 473 | <activation> |
469 | 474 | <activeByDefault>true</activeByDefault> |
... | ... | @@ -471,14 +476,14 @@ |
471 | 476 | <properties> |
472 | 477 | <!-- 数据库 --> |
473 | 478 | <orders.jdbc.driver>org.mariadb.jdbc.Driver</orders.jdbc.driver> |
474 | - <orders.jdbc.url>jdbc:mariadb://127.0.0.1:3306/b2c_orders?characterEncoding=UTF-8</orders.jdbc.url> | |
479 | + <orders.jdbc.url>jdbc:mariadb://10.28.11.162:3306/orders?characterEncoding=UTF-8</orders.jdbc.url> | |
475 | 480 | <orders.jdbc.username>root</orders.jdbc.username> |
476 | 481 | <orders.jdbc.password>123456</orders.jdbc.password> |
477 | 482 | <!-- 日志 --> |
478 | 483 | <orders.log.level>INFO</orders.log.level> |
479 | 484 | <orders.log.dtms.level>INFO</orders.log.dtms.level> |
480 | 485 | <!--redis --> |
481 | - <project.redis.host1>10.28.10.208</project.redis.host1> | |
486 | + <project.redis.host1>10.28.11.205</project.redis.host1> | |
482 | 487 | <project.redis.port1>6379</project.redis.port1> |
483 | 488 | <!--订单系统短信通知开关 --> |
484 | 489 | <orders.sms.enabled>true</orders.sms.enabled> |
... | ... | @@ -488,7 +493,7 @@ |
488 | 493 | <!-- 店铺接口签名 --> |
489 | 494 | <orders.rpc.shopClient.sign>FzZGZxd2VycXdlYXNzZHZzdnp4Y3Z</orders.rpc.shopClient.sign> |
490 | 495 | <!-- 消息中心配置 --> |
491 | - <mq.namesrvAddr>10.28.10.209:9876;10.28.10.149:9876</mq.namesrvAddr> | |
496 | + <mq.namesrvAddr>10.28.11.158:9876</mq.namesrvAddr> | |
492 | 497 | <mq.producerGroup>orders</mq.producerGroup> |
493 | 498 | </properties> |
494 | 499 | </profile> |
... | ... |