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
package com.yohoufo.dal.order;
import com.yohoufo.dal.order.model.DepositOrder;
import org.apache.ibatis.annotations.Param;
public interface DepositOrderMapper {
... ... @@ -9,4 +10,10 @@ public interface DepositOrderMapper {
DepositOrder selectByPrimaryKey(Integer id);
int updateByPrimaryKey(DepositOrder record);
int updatePayment(DepositOrder order);
int updateStatusByOrderCode(DepositOrder order);
DepositOrder selectByOrderCode(@Param("orderCode")Long orderCode);
}
\ No newline at end of file
... ...
... ... @@ -44,4 +44,5 @@ public interface StorageDepositMapper {
StorageDeposit selectByDepositCode(@Param("uid") int uid, @Param("depositCode")String depositCode);
List<StorageDeposit> getDepositOffs(@Param("uid") Integer uid, @Param("storageId") Integer storageId, @Param("count") Integer count);
int updateStorageStatus(@Param("depositCode")String depositCode, @Param("status")int status);
}
\ No newline at end of file
... ...
package com.yohoufo.dal.order.model;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import java.math.BigDecimal;
@ToString
@Builder
@NoArgsConstructor
@Data
public class DepositOrder {
private Integer id;
... ... @@ -33,4 +37,6 @@ public class DepositOrder {
private BigDecimal contractFee; //违约费用
private BigDecimal shipFee; //运费
private Integer initStatus; // 修改状态之前应该的状态
}
\ No newline at end of file
... ...
... ... @@ -53,4 +53,25 @@
update_time = #{updateTime,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updatePayment" parameterType="com.yohoufo.dal.order.model.DepositOrder">
update deposit_order
set payment = #{payment,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=INTEGER}
where uid = #{uid,jdbcType=INTEGER} AND order_code = #{orderCode,jdbcType=BIGINT}
</update>
<update id="updateStatusByOrderCode" parameterType="com.yohoufo.dal.order.model.DepositOrder">
update deposit_order
set status = #{status,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=INTEGER}
where order_code = #{orderCode,jdbcType=BIGINT} AND status = #{initStatus,jdbcType=INTEGER}
</update>
<select id="selectByOrderCode" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from deposit_order
where order_code = #{orderCode,jdbcType=BIGINT}
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -334,4 +334,10 @@
select <include refid="Base_Column_List" /> from storage_deposit
where owner_uid = #{uid} and status = 1 and del_status= 0 AND deposit_code = #{depositCode,jdbcType=VARCHAR} limit 1
</select>
<update id="updateStorageStatus">
update storage_deposit
set status = #{status,jdbcType=INTEGER} ,update_time = unix_timestamp(now())
where deposit_code = #{depositCode,jdbcType=VARCHAR} AND del_status = 0
</update>
</mapper>
\ No newline at end of file
... ...
... ... @@ -3,6 +3,7 @@ package com.yohoufo.order.service;
import com.yohobuy.ufo.model.order.bo.DepositDetailBo;
import com.yohobuy.ufo.model.order.bo.DepositProductBo;
import com.yohobuy.ufo.model.order.constants.StorageDepositStatusEnum;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.dal.order.model.StorageDeposit;
... ... @@ -36,4 +37,6 @@ public interface DepositService {
int getDepositOffShelvesCount(Integer uid, Integer storageId);
// 剩余存储天数
int getRemainDay(Integer uid, String depositCode);
int changeStorageStatus(String depositCode, int status);
}
... ...
... ... @@ -26,6 +26,7 @@ import com.yohoufo.dal.order.model.StorageDeposit;
import com.yohoufo.dal.order.StorageDepositMapper;
import com.yohoufo.order.convert.GoodsInfoConvertor;
import com.yohoufo.order.model.response.OrderSubmitResponse;
import com.yohoufo.order.service.DepositService;
import com.yohoufo.order.service.IBuyerOrderMetaService;
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
import org.apache.commons.collections.CollectionUtils;
... ... @@ -63,6 +64,9 @@ public class DepositOrderService {
@Autowired
private OrderCodeGenerator orderCodeGenerator;
@Autowired
private DepositService depositService;
/**
* 根据库存货号,计算需要召回的费用
* @param req
... ... @@ -75,7 +79,7 @@ public class DepositOrderService {
Integer depositEndTime = storageDeposit.getDepositEndTime();
int depositRemainDay = 45;
if (null != depositEndTime) {
depositRemainDay = (depositEndTime - DateUtil.getCurrentTimeSecond()) / 24 * 60 * 60;
depositRemainDay = depositService.getRemainDay(req.getUid(), req.getDepositCode());
}
Integer skup = storageDeposit.getSkup();
... ... @@ -125,4 +129,20 @@ public class DepositOrderService {
private String getReplacedContent(String content ,Object... params) {
return MessageFormatter.arrayFormat(content, params).getMessage();
}
public void updateByOrderCode(DepositOrder order) {
depositOrderMapper.updatePayment(order);
}
public DepositOrder selectByOrderCodeUid(long orderCode, int uid) {
return null;
}
public int updateStatusByOrderCode(DepositOrder order) {
return depositOrderMapper.updateStatusByOrderCode(order);
}
public DepositOrder selectByOrderCode(Long orderCode) {
return depositOrderMapper.selectByOrderCode(orderCode);
}
}
... ...
package com.yohoufo.order.service.impl;
import com.yoho.core.common.utils.DateUtil;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.bo.OrderInfo;
import com.yohobuy.ufo.model.order.common.OrderCodeType;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.constants.StorageDepositStatusEnum;
import com.yohoufo.dal.order.model.DepositOrder;
import com.yohoufo.dal.order.model.EntrySellerRechargeOrder;
import com.yohoufo.dal.order.model.StorageDeposit;
import com.yohoufo.order.model.request.PaymentRequest;
import com.yohoufo.order.model.response.PrepayResponse;
import com.yohoufo.order.service.AbstractOrderPaymentService;
import com.yohoufo.order.service.DepositService;
import com.yohoufo.order.service.deposit.DepositOrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class DeposiOrderPaymentService extends AbstractOrderPaymentService {
private final Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private DepositOrderService depositOrderService;
@Autowired
private DepositService depositService;
@Override
public boolean isTimeoutCancelStatus(OrderInfo orderInfo) {
return false;
... ... @@ -15,7 +37,14 @@ public class DeposiOrderPaymentService extends AbstractOrderPaymentService {
@Override
public OrderInfo getOrderInfo(long orderCode, int uid) {
return null;
DepositOrder order = depositOrderService.selectByOrderCodeUid(orderCode, uid);
if (order == null){
logger.warn("getOrderInfo order not exist, orderCode is {}, uid is {}", orderCode, uid);
throw new ServiceException(ServiceError.ORDER_NULL);
}
return buildOrderInfo(order);
}
@Override
... ... @@ -25,12 +54,19 @@ public class DeposiOrderPaymentService extends AbstractOrderPaymentService {
@Override
public void checkOrderStatus(OrderInfo orderInfo) {
// 订单不是未付款的状态
if (orderInfo.getStatus() == null || orderInfo.getStatus().intValue() != OrderStatus.WAITING_PAY.getCode()){
logger.warn("payment status not allow {}, orderCode is {}, uid is {}", orderInfo.getStatus(),
orderInfo.getOrderCode(), orderInfo.getUid());
throw new ServiceException(ServiceError.ORDER_PAY_NOT_ALLOW);
}
}
@Override
public void updatePayment(OrderInfo orderInfo, int payment) {
DepositOrder order = DepositOrder.builder().orderCode(orderInfo.getOrderCode()).uid(orderInfo.getUid())
.payment(payment).updateTime(DateUtil.getCurrentTimeSecond()).build();
depositOrderService.updateByOrderCode(order);
}
@Override
... ... @@ -45,6 +81,9 @@ public class DeposiOrderPaymentService extends AbstractOrderPaymentService {
@Override
public boolean isOrderWaitingPay(OrderInfo orderInfo) {
if (orderInfo.getStatus() != null && orderInfo.getStatus().intValue() == OrderStatus.WAITING_PAY.getCode()){
return true;
}
return false;
}
... ... @@ -60,11 +99,39 @@ public class DeposiOrderPaymentService extends AbstractOrderPaymentService {
@Override
public int updateOrderStatusPaid(OrderInfo orderInfo) {
return 0;
DepositOrder order = DepositOrder.builder().orderCode(orderInfo.getOrderCode()).initStatus(OrderStatus.WAITING_PAY.getCode())
.status(OrderStatus.HAS_PAYED.getCode()).updateTime(DateUtil.getCurrentTimeSecond()).build();
int result = depositOrderService.updateStatusByOrderCode(order);
orderInfo.setStatus(OrderStatus.HAS_PAYED.getCode());
return result;
}
/**
* 更新库存表的状态为待拣货状态
* @param orderInfo
*/
@Override
public void processAfterPay(OrderInfo orderInfo) {
DepositOrder depositOrder = depositOrderService.selectByOrderCode(orderInfo.getOrderCode());
depositService.changeStorageStatus(depositOrder.getDepositCode(), StorageDepositStatusEnum.WAITING_QUERY.getCode());
}
private OrderInfo buildOrderInfo(DepositOrder order) {
OrderInfo orderInfo = OrderInfo.builder()
.id(order.getId())
.uid(order.getUid())
.orderCode(order.getOrderCode())
.payment(order.getPayment())
.status(order.getStatus())
.amount(order.getAmount())
.createTime(order.getCreateTime())
.orderCodeType(OrderCodeType.STORAGE_MANAGEMENT)
.sourceStatus(order.getStatus())
.payExpireTime(30)
.build();
return orderInfo;
}
}
... ...
... ... @@ -248,6 +248,10 @@ public class DepositServiceImpl implements DepositService {
return getRemainDay(sd.getDepositEndTime());
}
public int changeStorageStatus(String depositCode, int status) {
return storageDepositMapper.updateStorageStatus(depositCode, status);
}
private String getBackStatusName(Integer code) {
if (code == null) {
return "";
... ...
... ... @@ -103,6 +103,9 @@ public class PaymentServiceImpl implements IPaymentService {
MerchantOrderPaymentService merchantOrderPaymentService;
@Autowired
private DeposiOrderPaymentService deposiOrderPaymentService;
@Autowired
OrderCodeGenerator orderCodeGenerator;
@Autowired
... ... @@ -189,6 +192,8 @@ public class PaymentServiceImpl implements IPaymentService {
paymentService = this.sellerOrderPaymentService;
} else if (codeMeta.getType() == OrderCodeType.SELLER_RECHARGE_EARNEST_TYPE.getType()) {
paymentService = this.merchantOrderPaymentService;
} else if (codeMeta.getType() == OrderCodeType.STORAGE_MANAGEMENT.getType()) {
paymentService = this.deposiOrderPaymentService;
}
logger.info("orderCode is {}, type is {}, service is {}", orderCode, codeMeta.getType(), paymentService);
return paymentService;
... ...