Showing
10 changed files
with
140 additions
and
4 deletions
1 | package com.yohoufo.dal.order; | 1 | package com.yohoufo.dal.order; |
2 | 2 | ||
3 | import com.yohoufo.dal.order.model.DepositOrder; | 3 | import com.yohoufo.dal.order.model.DepositOrder; |
4 | +import org.apache.ibatis.annotations.Param; | ||
4 | 5 | ||
5 | public interface DepositOrderMapper { | 6 | public interface DepositOrderMapper { |
6 | 7 | ||
@@ -9,4 +10,10 @@ public interface DepositOrderMapper { | @@ -9,4 +10,10 @@ public interface DepositOrderMapper { | ||
9 | DepositOrder selectByPrimaryKey(Integer id); | 10 | DepositOrder selectByPrimaryKey(Integer id); |
10 | 11 | ||
11 | int updateByPrimaryKey(DepositOrder record); | 12 | int updateByPrimaryKey(DepositOrder record); |
13 | + | ||
14 | + int updatePayment(DepositOrder order); | ||
15 | + | ||
16 | + int updateStatusByOrderCode(DepositOrder order); | ||
17 | + | ||
18 | + DepositOrder selectByOrderCode(@Param("orderCode")Long orderCode); | ||
12 | } | 19 | } |
@@ -42,4 +42,6 @@ public interface StorageDepositMapper { | @@ -42,4 +42,6 @@ public interface StorageDepositMapper { | ||
42 | 42 | ||
43 | int getDepositOffShelvesCount(@Param("uid") Integer uid, @Param("storageId") Integer storageId); | 43 | int getDepositOffShelvesCount(@Param("uid") Integer uid, @Param("storageId") Integer storageId); |
44 | StorageDeposit selectByDepositCode(@Param("uid") int uid, @Param("depositCode")String depositCode); | 44 | StorageDeposit selectByDepositCode(@Param("uid") int uid, @Param("depositCode")String depositCode); |
45 | + | ||
46 | + int updateStorageStatus(@Param("depositCode")String depositCode, @Param("status")int status); | ||
45 | } | 47 | } |
1 | package com.yohoufo.dal.order.model; | 1 | package com.yohoufo.dal.order.model; |
2 | 2 | ||
3 | import lombok.Builder; | 3 | import lombok.Builder; |
4 | +import lombok.Data; | ||
5 | +import lombok.NoArgsConstructor; | ||
4 | import lombok.ToString; | 6 | import lombok.ToString; |
5 | 7 | ||
6 | import java.math.BigDecimal; | 8 | import java.math.BigDecimal; |
7 | 9 | ||
8 | @ToString | 10 | @ToString |
9 | @Builder | 11 | @Builder |
12 | +@NoArgsConstructor | ||
13 | +@Data | ||
10 | public class DepositOrder { | 14 | public class DepositOrder { |
11 | private Integer id; | 15 | private Integer id; |
12 | 16 | ||
@@ -33,4 +37,6 @@ public class DepositOrder { | @@ -33,4 +37,6 @@ public class DepositOrder { | ||
33 | private BigDecimal contractFee; //违约费用 | 37 | private BigDecimal contractFee; //违约费用 |
34 | 38 | ||
35 | private BigDecimal shipFee; //运费 | 39 | private BigDecimal shipFee; //运费 |
40 | + | ||
41 | + private Integer initStatus; // 修改状态之前应该的状态 | ||
36 | } | 42 | } |
@@ -53,4 +53,25 @@ | @@ -53,4 +53,25 @@ | ||
53 | update_time = #{updateTime,jdbcType=INTEGER} | 53 | update_time = #{updateTime,jdbcType=INTEGER} |
54 | where id = #{id,jdbcType=INTEGER} | 54 | where id = #{id,jdbcType=INTEGER} |
55 | </update> | 55 | </update> |
56 | + | ||
57 | + <update id="updatePayment" parameterType="com.yohoufo.dal.order.model.DepositOrder"> | ||
58 | + update deposit_order | ||
59 | + set payment = #{payment,jdbcType=INTEGER}, | ||
60 | + update_time = #{updateTime,jdbcType=INTEGER} | ||
61 | + where uid = #{uid,jdbcType=INTEGER} AND order_code = #{orderCode,jdbcType=BIGINT} | ||
62 | + </update> | ||
63 | + | ||
64 | + <update id="updateStatusByOrderCode" parameterType="com.yohoufo.dal.order.model.DepositOrder"> | ||
65 | + update deposit_order | ||
66 | + set status = #{status,jdbcType=INTEGER}, | ||
67 | + update_time = #{updateTime,jdbcType=INTEGER} | ||
68 | + where order_code = #{orderCode,jdbcType=BIGINT} AND status = #{initStatus,jdbcType=INTEGER} | ||
69 | + </update> | ||
70 | + | ||
71 | + <select id="selectByOrderCode" resultMap="BaseResultMap"> | ||
72 | + select | ||
73 | + <include refid="Base_Column_List" /> | ||
74 | + from deposit_order | ||
75 | + where order_code = #{orderCode,jdbcType=BIGINT} | ||
76 | + </select> | ||
56 | </mapper> | 77 | </mapper> |
@@ -329,4 +329,10 @@ | @@ -329,4 +329,10 @@ | ||
329 | select <include refid="Base_Column_List" /> from storage_deposit | 329 | select <include refid="Base_Column_List" /> from storage_deposit |
330 | where owner_uid = #{uid} and status = 1 and del_status= 0 AND deposit_code = #{depositCode,jdbcType=VARCHAR} limit 1 | 330 | where owner_uid = #{uid} and status = 1 and del_status= 0 AND deposit_code = #{depositCode,jdbcType=VARCHAR} limit 1 |
331 | </select> | 331 | </select> |
332 | + | ||
333 | + <update id="updateStorageStatus"> | ||
334 | + update storage_deposit | ||
335 | + set status = #{status,jdbcType=INTEGER} ,update_time = unix_timestamp(now()) | ||
336 | + where deposit_code = #{depositCode,jdbcType=VARCHAR} AND del_status = 0 | ||
337 | + </update> | ||
332 | </mapper> | 338 | </mapper> |
@@ -3,6 +3,7 @@ package com.yohoufo.order.service; | @@ -3,6 +3,7 @@ package com.yohoufo.order.service; | ||
3 | 3 | ||
4 | import com.yohobuy.ufo.model.order.bo.DepositDetailBo; | 4 | import com.yohobuy.ufo.model.order.bo.DepositDetailBo; |
5 | import com.yohobuy.ufo.model.order.bo.DepositProductBo; | 5 | import com.yohobuy.ufo.model.order.bo.DepositProductBo; |
6 | +import com.yohobuy.ufo.model.order.constants.StorageDepositStatusEnum; | ||
6 | import com.yohoufo.common.exception.UfoServiceException; | 7 | import com.yohoufo.common.exception.UfoServiceException; |
7 | import com.yohoufo.dal.order.model.StorageDeposit; | 8 | import com.yohoufo.dal.order.model.StorageDeposit; |
8 | 9 | ||
@@ -23,4 +24,5 @@ public interface DepositService { | @@ -23,4 +24,5 @@ public interface DepositService { | ||
23 | int getDepositOffShelvesCount(Integer uid, Integer storageId); | 24 | int getDepositOffShelvesCount(Integer uid, Integer storageId); |
24 | int getRemainDay(Integer uid, String depositCode); | 25 | int getRemainDay(Integer uid, String depositCode); |
25 | 26 | ||
27 | + int changeStorageStatus(String depositCode, int status); | ||
26 | } | 28 | } |
@@ -125,4 +125,20 @@ public class DepositOrderService { | @@ -125,4 +125,20 @@ public class DepositOrderService { | ||
125 | private String getReplacedContent(String content ,Object... params) { | 125 | private String getReplacedContent(String content ,Object... params) { |
126 | return MessageFormatter.arrayFormat(content, params).getMessage(); | 126 | return MessageFormatter.arrayFormat(content, params).getMessage(); |
127 | } | 127 | } |
128 | + | ||
129 | + public void updateByOrderCode(DepositOrder order) { | ||
130 | + depositOrderMapper.updatePayment(order); | ||
131 | + } | ||
132 | + | ||
133 | + public DepositOrder selectByOrderCodeUid(long orderCode, int uid) { | ||
134 | + return null; | ||
135 | + } | ||
136 | + | ||
137 | + public int updateStatusByOrderCode(DepositOrder order) { | ||
138 | + return depositOrderMapper.updateStatusByOrderCode(order); | ||
139 | + } | ||
140 | + | ||
141 | + public DepositOrder selectByOrderCode(Long orderCode) { | ||
142 | + return depositOrderMapper.selectByOrderCode(orderCode); | ||
143 | + } | ||
128 | } | 144 | } |
1 | package com.yohoufo.order.service.impl; | 1 | package com.yohoufo.order.service.impl; |
2 | 2 | ||
3 | +import com.yoho.core.common.utils.DateUtil; | ||
4 | +import com.yoho.error.ServiceError; | ||
5 | +import com.yoho.error.exception.ServiceException; | ||
3 | import com.yohobuy.ufo.model.order.bo.OrderInfo; | 6 | import com.yohobuy.ufo.model.order.bo.OrderInfo; |
7 | +import com.yohobuy.ufo.model.order.common.OrderCodeType; | ||
8 | +import com.yohobuy.ufo.model.order.common.OrderStatus; | ||
9 | +import com.yohobuy.ufo.model.order.constants.StorageDepositStatusEnum; | ||
10 | +import com.yohoufo.dal.order.model.DepositOrder; | ||
11 | +import com.yohoufo.dal.order.model.EntrySellerRechargeOrder; | ||
12 | +import com.yohoufo.dal.order.model.StorageDeposit; | ||
4 | import com.yohoufo.order.model.request.PaymentRequest; | 13 | import com.yohoufo.order.model.request.PaymentRequest; |
5 | import com.yohoufo.order.model.response.PrepayResponse; | 14 | import com.yohoufo.order.model.response.PrepayResponse; |
6 | import com.yohoufo.order.service.AbstractOrderPaymentService; | 15 | import com.yohoufo.order.service.AbstractOrderPaymentService; |
16 | +import com.yohoufo.order.service.DepositService; | ||
17 | +import com.yohoufo.order.service.deposit.DepositOrderService; | ||
18 | +import org.slf4j.Logger; | ||
19 | +import org.slf4j.LoggerFactory; | ||
20 | +import org.springframework.beans.factory.annotation.Autowired; | ||
7 | import org.springframework.stereotype.Service; | 21 | import org.springframework.stereotype.Service; |
8 | 22 | ||
9 | @Service | 23 | @Service |
10 | public class DeposiOrderPaymentService extends AbstractOrderPaymentService { | 24 | public class DeposiOrderPaymentService extends AbstractOrderPaymentService { |
25 | + private final Logger logger = LoggerFactory.getLogger(getClass()); | ||
26 | + | ||
27 | + @Autowired | ||
28 | + private DepositOrderService depositOrderService; | ||
29 | + | ||
30 | + @Autowired | ||
31 | + private DepositService depositService; | ||
32 | + | ||
11 | @Override | 33 | @Override |
12 | public boolean isTimeoutCancelStatus(OrderInfo orderInfo) { | 34 | public boolean isTimeoutCancelStatus(OrderInfo orderInfo) { |
13 | return false; | 35 | return false; |
@@ -15,7 +37,14 @@ public class DeposiOrderPaymentService extends AbstractOrderPaymentService { | @@ -15,7 +37,14 @@ public class DeposiOrderPaymentService extends AbstractOrderPaymentService { | ||
15 | 37 | ||
16 | @Override | 38 | @Override |
17 | public OrderInfo getOrderInfo(long orderCode, int uid) { | 39 | public OrderInfo getOrderInfo(long orderCode, int uid) { |
18 | - return null; | 40 | + DepositOrder order = depositOrderService.selectByOrderCodeUid(orderCode, uid); |
41 | + | ||
42 | + if (order == null){ | ||
43 | + logger.warn("getOrderInfo order not exist, orderCode is {}, uid is {}", orderCode, uid); | ||
44 | + throw new ServiceException(ServiceError.ORDER_NULL); | ||
45 | + } | ||
46 | + | ||
47 | + return buildOrderInfo(order); | ||
19 | } | 48 | } |
20 | 49 | ||
21 | @Override | 50 | @Override |
@@ -25,12 +54,19 @@ public class DeposiOrderPaymentService extends AbstractOrderPaymentService { | @@ -25,12 +54,19 @@ public class DeposiOrderPaymentService extends AbstractOrderPaymentService { | ||
25 | 54 | ||
26 | @Override | 55 | @Override |
27 | public void checkOrderStatus(OrderInfo orderInfo) { | 56 | public void checkOrderStatus(OrderInfo orderInfo) { |
28 | - | 57 | + // 订单不是未付款的状态 |
58 | + if (orderInfo.getStatus() == null || orderInfo.getStatus().intValue() != OrderStatus.WAITING_PAY.getCode()){ | ||
59 | + logger.warn("payment status not allow {}, orderCode is {}, uid is {}", orderInfo.getStatus(), | ||
60 | + orderInfo.getOrderCode(), orderInfo.getUid()); | ||
61 | + throw new ServiceException(ServiceError.ORDER_PAY_NOT_ALLOW); | ||
62 | + } | ||
29 | } | 63 | } |
30 | 64 | ||
31 | @Override | 65 | @Override |
32 | public void updatePayment(OrderInfo orderInfo, int payment) { | 66 | public void updatePayment(OrderInfo orderInfo, int payment) { |
33 | - | 67 | + DepositOrder order = DepositOrder.builder().orderCode(orderInfo.getOrderCode()).uid(orderInfo.getUid()) |
68 | + .payment(payment).updateTime(DateUtil.getCurrentTimeSecond()).build(); | ||
69 | + depositOrderService.updateByOrderCode(order); | ||
34 | } | 70 | } |
35 | 71 | ||
36 | @Override | 72 | @Override |
@@ -45,6 +81,9 @@ public class DeposiOrderPaymentService extends AbstractOrderPaymentService { | @@ -45,6 +81,9 @@ public class DeposiOrderPaymentService extends AbstractOrderPaymentService { | ||
45 | 81 | ||
46 | @Override | 82 | @Override |
47 | public boolean isOrderWaitingPay(OrderInfo orderInfo) { | 83 | public boolean isOrderWaitingPay(OrderInfo orderInfo) { |
84 | + if (orderInfo.getStatus() != null && orderInfo.getStatus().intValue() == OrderStatus.WAITING_PAY.getCode()){ | ||
85 | + return true; | ||
86 | + } | ||
48 | return false; | 87 | return false; |
49 | } | 88 | } |
50 | 89 | ||
@@ -60,11 +99,39 @@ public class DeposiOrderPaymentService extends AbstractOrderPaymentService { | @@ -60,11 +99,39 @@ public class DeposiOrderPaymentService extends AbstractOrderPaymentService { | ||
60 | 99 | ||
61 | @Override | 100 | @Override |
62 | public int updateOrderStatusPaid(OrderInfo orderInfo) { | 101 | public int updateOrderStatusPaid(OrderInfo orderInfo) { |
63 | - return 0; | 102 | + DepositOrder order = DepositOrder.builder().orderCode(orderInfo.getOrderCode()).initStatus(OrderStatus.WAITING_PAY.getCode()) |
103 | + .status(OrderStatus.HAS_PAYED.getCode()).updateTime(DateUtil.getCurrentTimeSecond()).build(); | ||
104 | + | ||
105 | + int result = depositOrderService.updateStatusByOrderCode(order); | ||
106 | + orderInfo.setStatus(OrderStatus.HAS_PAYED.getCode()); | ||
107 | + return result; | ||
64 | } | 108 | } |
65 | 109 | ||
110 | + /** | ||
111 | + * 更新库存表的状态为待拣货状态 | ||
112 | + * @param orderInfo | ||
113 | + */ | ||
66 | @Override | 114 | @Override |
67 | public void processAfterPay(OrderInfo orderInfo) { | 115 | public void processAfterPay(OrderInfo orderInfo) { |
116 | + DepositOrder depositOrder = depositOrderService.selectByOrderCode(orderInfo.getOrderCode()); | ||
117 | + | ||
118 | + depositService.changeStorageStatus(depositOrder.getDepositCode(), StorageDepositStatusEnum.WAITING_QUERY.getCode()); | ||
119 | + } | ||
68 | 120 | ||
121 | + private OrderInfo buildOrderInfo(DepositOrder order) { | ||
122 | + OrderInfo orderInfo = OrderInfo.builder() | ||
123 | + .id(order.getId()) | ||
124 | + .uid(order.getUid()) | ||
125 | + .orderCode(order.getOrderCode()) | ||
126 | + .payment(order.getPayment()) | ||
127 | + .status(order.getStatus()) | ||
128 | + .amount(order.getAmount()) | ||
129 | + .createTime(order.getCreateTime()) | ||
130 | + .orderCodeType(OrderCodeType.STORAGE_MANAGEMENT) | ||
131 | + .sourceStatus(order.getStatus()) | ||
132 | + .payExpireTime(30) | ||
133 | + .build(); | ||
134 | + | ||
135 | + return orderInfo; | ||
69 | } | 136 | } |
70 | } | 137 | } |
@@ -192,6 +192,10 @@ public class DepositServiceImpl implements DepositService { | @@ -192,6 +192,10 @@ public class DepositServiceImpl implements DepositService { | ||
192 | return getRemainDay(sd.getDepositEndTime()); | 192 | return getRemainDay(sd.getDepositEndTime()); |
193 | } | 193 | } |
194 | 194 | ||
195 | + public int changeStorageStatus(String depositCode, int status) { | ||
196 | + return storageDepositMapper.updateStorageStatus(depositCode, status); | ||
197 | + } | ||
198 | + | ||
195 | private String getBackStatusName(Integer code) { | 199 | private String getBackStatusName(Integer code) { |
196 | if (code == null) { | 200 | if (code == null) { |
197 | return ""; | 201 | return ""; |
@@ -103,6 +103,9 @@ public class PaymentServiceImpl implements IPaymentService { | @@ -103,6 +103,9 @@ public class PaymentServiceImpl implements IPaymentService { | ||
103 | MerchantOrderPaymentService merchantOrderPaymentService; | 103 | MerchantOrderPaymentService merchantOrderPaymentService; |
104 | 104 | ||
105 | @Autowired | 105 | @Autowired |
106 | + private DeposiOrderPaymentService deposiOrderPaymentService; | ||
107 | + | ||
108 | + @Autowired | ||
106 | OrderCodeGenerator orderCodeGenerator; | 109 | OrderCodeGenerator orderCodeGenerator; |
107 | 110 | ||
108 | @Autowired | 111 | @Autowired |
@@ -189,6 +192,8 @@ public class PaymentServiceImpl implements IPaymentService { | @@ -189,6 +192,8 @@ public class PaymentServiceImpl implements IPaymentService { | ||
189 | paymentService = this.sellerOrderPaymentService; | 192 | paymentService = this.sellerOrderPaymentService; |
190 | } else if (codeMeta.getType() == OrderCodeType.SELLER_RECHARGE_EARNEST_TYPE.getType()) { | 193 | } else if (codeMeta.getType() == OrderCodeType.SELLER_RECHARGE_EARNEST_TYPE.getType()) { |
191 | paymentService = this.merchantOrderPaymentService; | 194 | paymentService = this.merchantOrderPaymentService; |
195 | + } else if (codeMeta.getType() == OrderCodeType.STORAGE_MANAGEMENT.getType()) { | ||
196 | + paymentService = this.deposiOrderPaymentService; | ||
192 | } | 197 | } |
193 | logger.info("orderCode is {}, type is {}, service is {}", orderCode, codeMeta.getType(), paymentService); | 198 | logger.info("orderCode is {}, type is {}, service is {}", orderCode, codeMeta.getType(), paymentService); |
194 | return paymentService; | 199 | return paymentService; |
-
Please register or login to post a comment