Authored by mali

召回详情

... ... @@ -16,4 +16,11 @@ public interface DepositOrderMapper {
int updateStatusByOrderCode(DepositOrder order);
DepositOrder selectByOrderCode(@Param("orderCode")Long orderCode);
/**
* 查看支付成功的召回订单,可能没有
* @param depositCode
* @return
*/
DepositOrder selectByDepositCode(@Param("depositCode")String depositCode, @Param("eventType")Integer eventType);
}
\ No newline at end of file
... ...
... ... @@ -41,7 +41,14 @@ public interface StorageDepositMapper {
int sale(@Param("uid") Integer uid, @Param("skup") Integer skup, @Param("orderCode") long orderCode);
int getDepositOffShelvesCount(@Param("uid") Integer uid, @Param("storageId") Integer storageId);
StorageDeposit selectByDepositCode(@Param("uid") int uid, @Param("depositCode")String depositCode);
/**
* 查看在库状态的库存
* @param uid
* @param depositCode
* @return
*/
StorageDeposit selectByDepositCode(@Param("uid") int uid, @Param("depositCode")String depositCode, @Param("statusList")List<Integer> statusList);
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);
... ...
... ... @@ -74,4 +74,11 @@
from deposit_order
where order_code = #{orderCode,jdbcType=BIGINT}
</select>
<select id="selectByDepositCode" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from deposit_order
where deposit_code = #{depositCode,jdbcType=VARCHAR} AND status = 1 AND event_type = #{eventType,jdbcType=INTEGER} limit 1
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -332,7 +332,12 @@
<select id="selectByDepositCode" resultMap="BaseResultMap">
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
where owner_uid = #{uid} and del_status= 0 AND deposit_code = #{depositCode,jdbcType=VARCHAR}
AND status in
<foreach collection="statusList" close=")" item="status" open="(" separator=",">
#{status}
</foreach>
limit 1
</select>
<update id="updateStorageStatus">
... ...
... ... @@ -39,8 +39,10 @@ public class DepositOrderController {
@RequestMapping(params = "method=ufo.deposit.computeRecall")
@ResponseBody
public ApiResponse computePublishPrd(@RequestParam(name = "uid", required = true)int uid,
@RequestParam(name = "deposit_code", required = true)String depositCode) throws GatewayException {
DepositOrderComputeReq req = DepositOrderComputeReq.builder().uid(uid).depositCode(depositCode).build();
@RequestParam(name = "deposit_code", required = true)String depositCode,
@RequestParam(name="address_id")String addressId) throws GatewayException {
DepositOrderComputeReq req = DepositOrderComputeReq.builder().uid(uid)
.address_id(addressId).depositCode(depositCode).build();
LOG.info("in ufo.deposit.computeRecall, req {}", req);
DepositOrderComputeResp resp = depositOrderService.computePublishPrd(req);
... ... @@ -55,16 +57,39 @@ public class DepositOrderController {
* @param price
* @return
* @throws GatewayException
* http://java-yohoufo-fore.test3.ingress.dev.yohocorp.com/ufo-gateway/?debug=XYZ&method=ufo.deposit.publishDepositOrder&uid=500031974&deposit_code=56257845
*/
@RequestMapping(params = "method=ufo.deposit.publishDepositOrder")
@ResponseBody
public ApiResponse publishDepositOrder(@RequestParam(name = "uid", required = true)int uid,
@RequestParam(name = "deposit_code", required = true)String depositCode) throws GatewayException {
DepositOrderComputeReq req = DepositOrderComputeReq.builder().uid(uid).depositCode(depositCode).build();
@RequestParam(name = "deposit_code", required = true)String depositCode,
@RequestParam(name="address_id")String addressId) throws GatewayException {
DepositOrderComputeReq req = DepositOrderComputeReq.builder().uid(uid)
.address_id(addressId).depositCode(depositCode).build();
LOG.info("in ufo.deposit.publishDepositOrder, req {}", req);
OrderSubmitResponse resp = depositOrderService.publishDepositOrder(req);
return new ApiResponse.ApiResponseBuilder().code(200).data(resp).message("创建成功").build();
}
/**
* 召回订单详情
* @param uid
* @param deposit_code 库存货号
* @return
* @throws GatewayException
* http://java-yohoufo-fore.test3.ingress.dev.yohocorp.com/ufo-gateway/?debug=XYZ&method=ufo.deposit.orderInfo&uid=500031974&deposit_code=56257845
*/
@RequestMapping(params = "method=ufo.deposit.orderInfo")
@ResponseBody
public ApiResponse depositOrderInfo(@RequestParam(name = "uid", required = true)int uid,
@RequestParam(name = "deposit_code", required = true)String depositCode) throws GatewayException {
DepositOrderComputeReq req = DepositOrderComputeReq.builder().uid(uid).depositCode(depositCode).build();
LOG.info("in ufo.deposit.orderInfo, req {}", req);
DepositOrderComputeResp resp = depositOrderService.depositOrderInfo(req);
return new ApiResponse.ApiResponseBuilder().code(200).data(resp).message("查询成功").build();
}
}
... ...
... ... @@ -40,4 +40,11 @@ public interface DepositService {
int getRemainDay(Integer uid, String depositCode);
int changeStorageStatus(String depositCode, int status);
/**
* Do 转 Vo
* @param storageDeposit
* @return
*/
DepositDetailBo convert(StorageDeposit storageDeposit);
}
... ...
... ... @@ -3,23 +3,19 @@ package com.yohoufo.order.service.deposit;
import com.google.common.collect.Lists;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.bo.DepositDetailBo;
import com.yohobuy.ufo.model.order.bo.GoodsInfo;
import com.yohobuy.ufo.model.order.common.OrderCodeType;
import com.yohobuy.ufo.model.order.constants.DepositEventTypeEnum;
import com.yohobuy.ufo.model.order.constants.OrderConstant;
import com.yohobuy.ufo.model.order.constants.StorageDepositStatusEnum;
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.StringUtil;
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
import com.yohoufo.dal.order.DepositOrderMapper;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.dal.order.StorageDepositMapper;
import com.yohoufo.dal.order.model.BuyerOrderGoods;
import com.yohoufo.dal.order.model.DepositOrder;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.dal.order.model.StorageDeposit;
import com.yohoufo.dal.order.*;
import com.yohoufo.dal.order.model.*;
import com.yohoufo.order.convert.GoodsInfoConvertor;
import com.yohoufo.order.model.response.OrderSubmitResponse;
import com.yohoufo.order.service.DepositService;
... ... @@ -33,6 +29,7 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
/**
* Created by li.ma on 2019/7/9.
... ... @@ -51,7 +48,7 @@ public class DepositOrderService {
private SellerOrderGoodsMapper sellerOrderGoodsMapper;
@Autowired
private BuyerOrderGoodsMapper buyerOrderGoodsMapper;
private BuyerOrderMapper buyerOrderMapper;
@Autowired
private IBuyerOrderMetaService buyerOrderMetaService;
... ... @@ -68,42 +65,42 @@ public class DepositOrderService {
* @return
*/
public DepositOrderComputeResp computePublishPrd(DepositOrderComputeReq req) {
StorageDeposit storageDeposit = checkStorageDeposit(req); // 不存在的时候有异常
StorageDeposit storageDeposit = checkStorageDeposit(req,
Lists.newArrayList(StorageDepositStatusEnum.HAS_IN.getCode())); // 不存在的时候有异常
int depositRemainDay = depositService.getRemainDay(req.getUid(), req.getDepositCode()); // 还可存放多久 单位天
Integer skup = storageDeposit.getSkup();
Long orderCode = storageDeposit.getOrderCode();
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
GoodsInfo goodsInfo = null;
if (null != sellerOrderGoods) {
goodsInfo = GoodsInfoConvertor.SellerOrderGoods2GoodsInfo(sellerOrderGoods);
}
List<BuyerOrderGoods> buyerOrderGoodses = buyerOrderGoodsMapper.selectBySkups(Lists.newArrayList(skup));
DepositOrderComputeResp.PriceInfo priceInfo = getFeeInfo(orderCode);
if (CollectionUtils.isNotEmpty(buyerOrderGoodses)) {
priceInfo.setGoodPrice(buyerOrderGoodses.get(0).getGoodsAmount());
}
GoodsInfo goodsInfo = getGoodsInfo(skup); // 查询购买商品的详细信息
DepositOrderComputeResp.PriceInfo priceInfo = getFeeInfo(orderCode, req.getAddress_id()); // 获取各种费用
AddressInfo addressInfo = buyerOrderMetaService.getAddressInfo(req.getUid(), orderCode);
setBuyerPrice(orderCode, priceInfo); // 设置入手价
AddressInfo addressInfo = buyerOrderMetaService.getHiddenAddressInfo(req.getUid(), orderCode);
return DepositOrderComputeResp.builder().depositRemainDay(getReplacedContent(DepositOrderComputeResp.DEPOSITREMAINDAY_TIP, depositRemainDay))
.userAddress(addressInfo).priceInfo(priceInfo).goodsInfo(goodsInfo).build();
}
public OrderSubmitResponse publishDepositOrder(DepositOrderComputeReq req) {
Integer uid = req.getUid();
if (uid == null || uid <= 0){
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
}
checkStorageDeposit(req);
StorageDeposit storageDeposit = checkStorageDeposit(req,
Lists.newArrayList(StorageDepositStatusEnum.HAS_IN.getCode())); //查看在库状态的库存
long orderCode = orderCodeGenerator.generate(OrderCodeType.STORAGE_MANAGEMENT);
int now = (int) (System.currentTimeMillis()/1000);
DepositOrderComputeResp.PriceInfo priceInfo = getFeeInfo(orderCode);
DepositOrderComputeResp.PriceInfo priceInfo = getFeeInfo(orderCode, req.getAddress_id());
DepositOrder depositOrder = DepositOrder.builder().uid(uid).amount(priceInfo.getAmount())
.contractFee(priceInfo.getContractFee())
... ... @@ -111,6 +108,9 @@ public class DepositOrderService {
.createTime(now).depositCode(req.getDepositCode())
.eventType(DepositEventTypeEnum.DEPOSIT_RECALL_FEE.getCode()).orderCode(orderCode).payment(0).status(0).updateTime(now).build();
// TODO 创建召回地址
storageDeposit.getOrderCode();
LOG.info("enter publishDepositOrder begin save depositOrder {} ",depositOrder);
int num = depositOrderMapper.insert(depositOrder); // 生成订单数据,insert db
LOG.info("enter publishDepositOrder end save depositOrder {} ,num {}",depositOrder, num);
... ... @@ -118,18 +118,83 @@ public class DepositOrderService {
return OrderSubmitResponse.builder().orderCode(orderCode).paymentStatus(OrderConstant.N_STR).build();
}
private StorageDeposit checkStorageDeposit(DepositOrderComputeReq req) {
StorageDeposit storageDeposit = storageDepositMapper.selectByDepositCode(req.getUid(), req.getDepositCode());
if (null == storageDeposit || null == storageDeposit.getSkup() || null == storageDeposit.getOrderCode()) {
LOG.warn("storageDepositMapper.selectByDepositCode not exist, req is {}", req);
throw new UfoServiceException(400, "在库状态的库存不存在");
public void updateByOrderCode(DepositOrder order) {
depositOrderMapper.updatePayment(order);
}
return storageDeposit;
public DepositOrder selectByOrderCodeUid(long orderCode, int uid) {
return depositOrderMapper.selectByOrderCode(orderCode);
}
public int updateStatusByOrderCode(DepositOrder order) {
return depositOrderMapper.updateStatusByOrderCode(order);
}
public DepositOrder selectByOrderCode(Long orderCode) {
return depositOrderMapper.selectByOrderCode(orderCode);
}
/**
* 查询召回订单详情
* @param req
* @return
*/
public DepositOrderComputeResp depositOrderInfo(DepositOrderComputeReq req) {
StorageDeposit storageDeposit = checkStorageDeposit(req,
Lists.newArrayList(StorageDepositStatusEnum.WAITING_QUERY.getCode(), StorageDepositStatusEnum.WAITING_OUT.getCode())); // 不存在的时候有异常
DepositDetailBo depositDetailBo = depositService.convert(storageDeposit);
AddressInfo addressInfo = buyerOrderMetaService.getHiddenAddressInfo(req.getUid(), storageDeposit.getOrderCode());
GoodsInfo goodsInfo = getGoodsInfo(storageDeposit.getSkup()); // 查询购买商品的详细信息
DepositOrderComputeResp.PriceInfo priceInfo = getOrderFeeInfo(req.getDepositCode()); // 获取各种费用
setBuyerPrice(storageDeposit.getOrderCode(), priceInfo); // 设置入手价
return DepositOrderComputeResp.builder().userAddress(addressInfo).priceInfo(priceInfo).goodsInfo(goodsInfo).depositDetailBo(depositDetailBo).build();
}
/**
* 查询召回订单的各种详情
* @param depositCode
* @return
*/
private DepositOrderComputeResp.PriceInfo getOrderFeeInfo(String depositCode) {
DepositOrderComputeResp.PriceInfo priceInfo = DepositOrderComputeResp.PriceInfo.builder().build();
DepositOrder depositOrder = depositOrderMapper.selectByDepositCode(depositCode, DepositEventTypeEnum.DEPOSIT_RECALL_FEE.getCode()); // 自动到期之后寄回的,没有订单
if (Objects.isNull(depositOrder)) {
return DepositOrderComputeResp.PriceInfo.builder().build();
}
return DepositOrderComputeResp.PriceInfo.builder().amount(depositOrder.getAmount())
.contractFee(depositOrder.getContractFee())
.shipFee(depositOrder.getShipFee()).build();
}
private void setBuyerPrice(Long orderCode, DepositOrderComputeResp.PriceInfo priceInfo) {
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
if (!Objects.isNull(buyerOrder)) {
priceInfo.setGoodPrice(buyerOrder.getAmount());
}
}
private GoodsInfo getGoodsInfo(Integer skup) {
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
GoodsInfo goodsInfo = null;
if (null != sellerOrderGoods) {
goodsInfo = GoodsInfoConvertor.SellerOrderGoods2GoodsInfo(sellerOrderGoods);
}
return goodsInfo;
}
// 查询召回所需要的费用
private DepositOrderComputeResp.PriceInfo getFeeInfo(Long orderCode) {
private DepositOrderComputeResp.PriceInfo getFeeInfo(Long orderCode, String addressId) {
BigDecimal contractFee = new BigDecimal(15); // 违约金
BigDecimal shipFee = new BigDecimal(15); // 运费
BigDecimal amount = contractFee.add(shipFee);
... ... @@ -141,19 +206,13 @@ public class DepositOrderService {
return StringUtil.getReplacedContent(content, params);
}
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);
private StorageDeposit checkStorageDeposit(DepositOrderComputeReq req, List<Integer> statusList) {
StorageDeposit storageDeposit = storageDepositMapper.selectByDepositCode(req.getUid(), req.getDepositCode(), statusList);
if (null == storageDeposit || null == storageDeposit.getSkup() || null == storageDeposit.getOrderCode()) {
LOG.warn("storageDepositMapper.selectByDepositCode not exist, req is {}", req);
throw new UfoServiceException(400, "在库状态的库存不存在");
}
public DepositOrder selectByOrderCode(Long orderCode) {
return depositOrderMapper.selectByOrderCode(orderCode);
return storageDeposit;
}
}
... ...
... ... @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.yohobuy.ufo.model.order.bo.ButtonShowBo;
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.yohobuy.ufo.model.order.resp.PageResp;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
... ... @@ -19,10 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
... ... @@ -273,6 +271,26 @@ public class DepositServiceImpl implements DepositService {
return storageDepositMapper.updateStorageStatus(depositCode, status);
}
/**
* Do 转 Vo
* @param storageDeposit
* @return
*/
public DepositDetailBo convert(StorageDeposit storageDeposit) {
if (Objects.isNull(storageDeposit)) {
return DepositDetailBo.builder().build();
}
return DepositDetailBo.builder()
.orderCode(storageDeposit.getOrderCode())
.depositCode(storageDeposit.getDepositCode())
.skup(storageDeposit.getSkup())
.status(storageDeposit.getStatus())
.depositStatusName(StorageDepositStatusEnum.getAppStatusNameByCode(storageDeposit.getStatus()))
.depositDescName(StorageDepositStatusEnum.getAppStatusDescByCode(storageDeposit.getStatus()))
.build();
}
private String getBackStatusName(Integer code) {
if (code == null) {
return "";
... ...