...
|
...
|
@@ -13,15 +13,19 @@ import com.yohobuy.ufo.model.order.req.DepositOrderComputeReq; |
|
|
import com.yohobuy.ufo.model.order.resp.DepositOrderComputeResp;
|
|
|
import com.yohobuy.ufo.model.order.vo.AddressInfo;
|
|
|
import com.yohoufo.common.exception.UfoServiceException;
|
|
|
import com.yohoufo.common.utils.AddressUtil;
|
|
|
import com.yohoufo.common.utils.StringUtil;
|
|
|
import com.yohoufo.dal.order.*;
|
|
|
import com.yohoufo.dal.order.model.*;
|
|
|
import com.yohoufo.order.convert.GoodsInfoConvertor;
|
|
|
import com.yohoufo.order.model.response.AppraiseAddressResp;
|
|
|
import com.yohoufo.order.model.response.OrderSubmitResponse;
|
|
|
import com.yohoufo.order.service.DepositService;
|
|
|
import com.yohoufo.order.service.IBuyerOrderMetaService;
|
|
|
import com.yohoufo.order.service.IExpressInfoService;
|
|
|
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
...
|
...
|
@@ -30,6 +34,7 @@ import org.springframework.stereotype.Service; |
|
|
import java.math.BigDecimal;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
import java.util.Optional;
|
|
|
|
|
|
/**
|
|
|
* Created by li.ma on 2019/7/9.
|
...
|
...
|
@@ -59,6 +64,9 @@ public class DepositOrderService { |
|
|
@Autowired
|
|
|
private DepositService depositService;
|
|
|
|
|
|
@Autowired
|
|
|
private IExpressInfoService expressInfoService;
|
|
|
|
|
|
/**
|
|
|
* 根据库存货号,计算需要召回的费用
|
|
|
* @param req
|
...
|
...
|
@@ -75,12 +83,14 @@ public class DepositOrderService { |
|
|
|
|
|
GoodsInfo goodsInfo = getGoodsInfo(skup); // 查询购买商品的详细信息
|
|
|
|
|
|
AddressInfo addressInfo = buyerOrderMetaService.getHiddenAddressInfo(req.getUid(), orderCode);
|
|
|
|
|
|
DepositOrderComputeResp.PriceInfo priceInfo = getFeeInfo(orderCode, req.getAddress_id()); // 获取各种费用
|
|
|
addressInfo.setAddress_id(AddressUtil.getDecryptStr(String.valueOf(addressInfo.getAddress_id())));// 加密addressId
|
|
|
|
|
|
setBuyerPrice(orderCode, priceInfo); // 设置入手价
|
|
|
DepositOrderComputeResp.PriceInfo priceInfo = getFeeInfo(orderCode, StringUtils.isEmpty(req.getAddress_id()) ?
|
|
|
String.valueOf(addressInfo.getAddress_id()) : req.getAddress_id(), req.getUid()); // 获取各种费用
|
|
|
|
|
|
AddressInfo addressInfo = buyerOrderMetaService.getHiddenAddressInfo(req.getUid(), orderCode);
|
|
|
setBuyerPrice(orderCode, priceInfo); // 设置入手价
|
|
|
|
|
|
return DepositOrderComputeResp.builder().depositRemainDay(getReplacedContent(DepositOrderComputeResp.DEPOSITREMAINDAY_TIP, depositRemainDay))
|
|
|
.userAddress(addressInfo).priceInfo(priceInfo).goodsInfo(goodsInfo).build();
|
...
|
...
|
@@ -100,7 +110,7 @@ public class DepositOrderService { |
|
|
long orderCode = orderCodeGenerator.generate(OrderCodeType.STORAGE_MANAGEMENT);
|
|
|
|
|
|
int now = (int) (System.currentTimeMillis()/1000);
|
|
|
DepositOrderComputeResp.PriceInfo priceInfo = getFeeInfo(orderCode, req.getAddress_id());
|
|
|
DepositOrderComputeResp.PriceInfo priceInfo = getFeeInfo(orderCode, req.getAddress_id(), req.getUid());
|
|
|
|
|
|
DepositOrder depositOrder = DepositOrder.builder().uid(uid).amount(priceInfo.getAmount())
|
|
|
.contractFee(priceInfo.getContractFee())
|
...
|
...
|
@@ -109,7 +119,10 @@ public class DepositOrderService { |
|
|
.eventType(DepositEventTypeEnum.DEPOSIT_RECALL_FEE.getCode()).orderCode(orderCode).payment(0).status(0).updateTime(now).build();
|
|
|
|
|
|
// TODO 创建召回地址
|
|
|
LOG.info("enter publishRecallAddress begin save getOrderCode {} addressId is {} ", storageDeposit.getOrderCode(), req.getAddress_id());
|
|
|
storageDeposit.getOrderCode();
|
|
|
req.getAddress_id();
|
|
|
LOG.info("enter publishRecallAddress end save getOrderCode {} ", storageDeposit.getOrderCode());
|
|
|
|
|
|
LOG.info("enter publishDepositOrder begin save depositOrder {} ",depositOrder);
|
|
|
int num = depositOrderMapper.insert(depositOrder); // 生成订单数据,insert db
|
...
|
...
|
@@ -197,9 +210,12 @@ public class DepositOrderService { |
|
|
}
|
|
|
|
|
|
// 查询召回所需要的费用
|
|
|
private DepositOrderComputeResp.PriceInfo getFeeInfo(Long orderCode, String addressId) {
|
|
|
private DepositOrderComputeResp.PriceInfo getFeeInfo(Long orderCode, String addressId, int uid) {
|
|
|
|
|
|
AppraiseAddressResp resp = expressInfoService.queryByUserAddress(uid, addressId);
|
|
|
|
|
|
BigDecimal contractFee = new BigDecimal(15); // 违约金
|
|
|
BigDecimal shipFee = new BigDecimal(15); // 运费
|
|
|
BigDecimal shipFee = Optional.ofNullable(resp).map(AppraiseAddressResp::getShipFee).orElse(new BigDecimal(15)); // 运费
|
|
|
BigDecimal amount = contractFee.add(shipFee);
|
|
|
|
|
|
return DepositOrderComputeResp.PriceInfo.builder().contractFee(contractFee).shipFee(shipFee).amount(amount).build();
|
...
|
...
|
|