Authored by Lixiaodi

Merge branch 'test6.9.8' of http://git.yoho.cn/ufo/yohoufo-fore into test6.9.8

# Conflicts:
#	dal/src/main/java/com/yohoufo/dal/order/StorageDepositMapper.java
#	order/src/main/java/com/yohoufo/order/service/DepositService.java
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 }
@@ -44,4 +44,5 @@ public interface StorageDepositMapper { @@ -44,4 +44,5 @@ public interface StorageDepositMapper {
44 StorageDeposit selectByDepositCode(@Param("uid") int uid, @Param("depositCode")String depositCode); 44 StorageDeposit selectByDepositCode(@Param("uid") int uid, @Param("depositCode")String depositCode);
45 45
46 List<StorageDeposit> getDepositOffs(@Param("uid") Integer uid, @Param("storageId") Integer storageId, @Param("count") Integer count); 46 List<StorageDeposit> getDepositOffs(@Param("uid") Integer uid, @Param("storageId") Integer storageId, @Param("count") Integer count);
  47 + int updateStorageStatus(@Param("depositCode")String depositCode, @Param("status")int status);
47 } 48 }
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>
@@ -334,4 +334,10 @@ @@ -334,4 +334,10 @@
334 select <include refid="Base_Column_List" /> from storage_deposit 334 select <include refid="Base_Column_List" /> from storage_deposit
335 where owner_uid = #{uid} and status = 1 and del_status= 0 AND deposit_code = #{depositCode,jdbcType=VARCHAR} limit 1 335 where owner_uid = #{uid} and status = 1 and del_status= 0 AND deposit_code = #{depositCode,jdbcType=VARCHAR} limit 1
336 </select> 336 </select>
  337 +
  338 + <update id="updateStorageStatus">
  339 + update storage_deposit
  340 + set status = #{status,jdbcType=INTEGER} ,update_time = unix_timestamp(now())
  341 + where deposit_code = #{depositCode,jdbcType=VARCHAR} AND del_status = 0
  342 + </update>
337 </mapper> 343 </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
@@ -36,4 +37,6 @@ public interface DepositService { @@ -36,4 +37,6 @@ public interface DepositService {
36 int getDepositOffShelvesCount(Integer uid, Integer storageId); 37 int getDepositOffShelvesCount(Integer uid, Integer storageId);
37 // 剩余存储天数 38 // 剩余存储天数
38 int getRemainDay(Integer uid, String depositCode); 39 int getRemainDay(Integer uid, String depositCode);
  40 +
  41 + int changeStorageStatus(String depositCode, int status);
39 } 42 }
@@ -26,6 +26,7 @@ import com.yohoufo.dal.order.model.StorageDeposit; @@ -26,6 +26,7 @@ import com.yohoufo.dal.order.model.StorageDeposit;
26 import com.yohoufo.dal.order.StorageDepositMapper; 26 import com.yohoufo.dal.order.StorageDepositMapper;
27 import com.yohoufo.order.convert.GoodsInfoConvertor; 27 import com.yohoufo.order.convert.GoodsInfoConvertor;
28 import com.yohoufo.order.model.response.OrderSubmitResponse; 28 import com.yohoufo.order.model.response.OrderSubmitResponse;
  29 +import com.yohoufo.order.service.DepositService;
29 import com.yohoufo.order.service.IBuyerOrderMetaService; 30 import com.yohoufo.order.service.IBuyerOrderMetaService;
30 import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; 31 import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
31 import org.apache.commons.collections.CollectionUtils; 32 import org.apache.commons.collections.CollectionUtils;
@@ -63,6 +64,9 @@ public class DepositOrderService { @@ -63,6 +64,9 @@ public class DepositOrderService {
63 @Autowired 64 @Autowired
64 private OrderCodeGenerator orderCodeGenerator; 65 private OrderCodeGenerator orderCodeGenerator;
65 66
  67 + @Autowired
  68 + private DepositService depositService;
  69 +
66 /** 70 /**
67 * 根据库存货号,计算需要召回的费用 71 * 根据库存货号,计算需要召回的费用
68 * @param req 72 * @param req
@@ -75,7 +79,7 @@ public class DepositOrderService { @@ -75,7 +79,7 @@ public class DepositOrderService {
75 Integer depositEndTime = storageDeposit.getDepositEndTime(); 79 Integer depositEndTime = storageDeposit.getDepositEndTime();
76 int depositRemainDay = 45; 80 int depositRemainDay = 45;
77 if (null != depositEndTime) { 81 if (null != depositEndTime) {
78 - depositRemainDay = (depositEndTime - DateUtil.getCurrentTimeSecond()) / 24 * 60 * 60; 82 + depositRemainDay = depositService.getRemainDay(req.getUid(), req.getDepositCode());
79 } 83 }
80 84
81 Integer skup = storageDeposit.getSkup(); 85 Integer skup = storageDeposit.getSkup();
@@ -125,4 +129,20 @@ public class DepositOrderService { @@ -125,4 +129,20 @@ public class DepositOrderService {
125 private String getReplacedContent(String content ,Object... params) { 129 private String getReplacedContent(String content ,Object... params) {
126 return MessageFormatter.arrayFormat(content, params).getMessage(); 130 return MessageFormatter.arrayFormat(content, params).getMessage();
127 } 131 }
  132 +
  133 + public void updateByOrderCode(DepositOrder order) {
  134 + depositOrderMapper.updatePayment(order);
  135 + }
  136 +
  137 + public DepositOrder selectByOrderCodeUid(long orderCode, int uid) {
  138 + return null;
  139 + }
  140 +
  141 + public int updateStatusByOrderCode(DepositOrder order) {
  142 + return depositOrderMapper.updateStatusByOrderCode(order);
  143 + }
  144 +
  145 + public DepositOrder selectByOrderCode(Long orderCode) {
  146 + return depositOrderMapper.selectByOrderCode(orderCode);
  147 + }
128 } 148 }
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 }
@@ -248,6 +248,10 @@ public class DepositServiceImpl implements DepositService { @@ -248,6 +248,10 @@ public class DepositServiceImpl implements DepositService {
248 return getRemainDay(sd.getDepositEndTime()); 248 return getRemainDay(sd.getDepositEndTime());
249 } 249 }
250 250
  251 + public int changeStorageStatus(String depositCode, int status) {
  252 + return storageDepositMapper.updateStorageStatus(depositCode, status);
  253 + }
  254 +
251 private String getBackStatusName(Integer code) { 255 private String getBackStatusName(Integer code) {
252 if (code == null) { 256 if (code == null) {
253 return ""; 257 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;