Authored by sailing-PC\sailing

optimized

... ... @@ -14,7 +14,7 @@ public interface BuyerOrderGoodsMapper {
BuyerOrderGoods selectByPrimaryKey(Integer id);
List<BuyerOrderGoods> selectByOrderCodeList(@Param("uid") int uid, @Param("list") List<Long> orderCodeList);
List<BuyerOrderGoods> selectByOrderCodeList(@Param("uid") Integer uid, @Param("list") List<Long> orderCodeList);
BuyerOrderGoods selectByOrderCode(@Param("uid") int uid, @Param("orderCode") long orderCode);
... ...
... ... @@ -26,9 +26,9 @@ public interface BuyerOrderMapper {
List<BuyerOrder> selectListByUidStatus(@Param("uid") int uid, @Param("status") List<Integer> status,
@Param("offset")Integer offset, @Param("limit")Integer limit);
int selectCntBySellerUidStatus(@Param("uid") int suid, @Param("status") List<Integer> status);
int selectCntBySellerUidStatus(@Param("sellerUid") int suid, @Param("status") List<Integer> status);
List<BuyerOrder> selectListBySellerUidStatus(@Param("uid") int suid, @Param("status") List<Integer> status,
List<BuyerOrder> selectListBySellerUidStatus(@Param("sellerUid") int suid, @Param("status") List<Integer> status,
@Param("offset")Integer offset, @Param("limit")Integer limit);
int updateByPrimaryKey(BuyerOrder record);
... ...
... ... @@ -25,7 +25,9 @@
<include refid="Base_Column_List" />
from buyer_order_goods
where 1=1
and uid = #{uid,jdbcType=INTEGER}
<if test="uid != null">
and uid = #{uid,jdbcType=INTEGER}
</if>
<if test="list != null">
and order_code in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
... ...
package com.yohoufo.order.controller;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.order.common.TabType;
import com.yohoufo.order.request.OrderListRequest;
import com.yohoufo.order.request.OrderRequest;
import com.yohoufo.order.response.OrderDetailInfo;
import com.yohoufo.order.response.OrderListInfoRsp;
import com.yohoufo.order.service.IBuyerOrderService;
import com.yohoufo.order.service.impl.SellerOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.Objects;
@RestController
@RequestMapping(value = "/buyerOrder")
public class BuyerOrderController {
... ... @@ -20,6 +24,8 @@ public class BuyerOrderController {
@Autowired
IBuyerOrderService buyerOrderService;
@Autowired
private SellerOrderService sellerOrderService;
/**
* [购买]订单列表
... ... @@ -38,14 +44,31 @@ public class BuyerOrderController {
@RequestParam(value = "page", required = false, defaultValue = "1") int page,
@RequestParam(value = "limit", required = false, defaultValue = "10") int limit) {
TabType actor = TabType.getTabType(tabType);
if (Objects.isNull(actor)){
return new ApiResponse.ApiResponseBuilder().code(400).message("非法的tab").build();
}
OrderListRequest orderListRequest = OrderListRequest.builder()
.uid(uid)
.type(type)
.page(page)
.limit(limit)
.tabType(tabType)
.actor(actor)
.build();
OrderListInfoRsp orderListInfoRsp = buyerOrderService.getOrderList(orderListRequest);
OrderListInfoRsp orderListInfoRsp;
switch (actor){
case BUY:
orderListInfoRsp = buyerOrderService.getOrderList(orderListRequest);
break;
case SELL:
orderListInfoRsp = sellerOrderService.getOrderList(orderListRequest);
break;
default:
orderListInfoRsp = null;
}
return new ApiResponse.ApiResponseBuilder().code(200).data(orderListInfoRsp).message("订单列表").build();
}
... ...
... ... @@ -2,13 +2,10 @@ package com.yohoufo.order.controller;
import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo;
import com.yohobuy.ufo.model.order.req.SellerOrderComputeReq;
import com.yohobuy.ufo.model.order.req.SellerOrderListReq;
import com.yohobuy.ufo.model.order.req.SellerOrderSubmitReq;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.exception.GatewayException;
import com.yohoufo.order.response.OrderListInfo;
import com.yohoufo.order.response.OrderListInfoRsp;
import com.yohoufo.order.service.SellerOrderService;
import com.yohoufo.order.service.impl.SellerOrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -75,20 +72,5 @@ public class SellerOrderController {
return new ApiResponse.ApiResponseBuilder().data(orderCode).code(200).message("发布成功").build();
}
@RequestMapping(params = "method=ufo.sellerOrder.getOrderList")
@ResponseBody
public ApiResponse getOrderList(@RequestParam(name = "uid", required = true)int uid,
@RequestParam(name = "type", required = true)int type,
@RequestParam(name = "page", required = true)int page,
@RequestParam(name = "limit", required = true)int limit) throws GatewayException {
SellerOrderListReq req = SellerOrderListReq.builder()
.uid(uid).type(type)
.page(page).limit(limit)
.build();
logger.info("in ufo.sellerOrder.getOrderList, req {}", req);
OrderListInfoRsp resp = sellerOrderService.getOrderList(req);
return new ApiResponse.ApiResponseBuilder().data(resp).code(200).message("查询列表成功").build();
}
}
... ...
package com.yohoufo.order.request;
import com.yohoufo.order.common.TabType;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
... ... @@ -20,4 +21,6 @@ public class OrderListRequest {
int limit;
String tabType;
TabType actor;
}
... ...
... ... @@ -4,7 +4,7 @@ import com.yoho.core.dal.datasource.annotation.Database;
import com.yohoufo.common.exception.GatewayException;
import com.yohoufo.order.model.GoodsInfo;
import com.yohoufo.order.model.SellerOrderContext;
import com.yohoufo.order.service.SkupService;
import com.yohoufo.order.service.impl.SkupService;
import com.yohoufo.order.service.impl.SellerAddressService;
import com.yohoufo.order.service.impl.SellerFeeService;
import com.yohoufo.order.service.impl.SellerOrderCreateService;
... ...
package com.yohoufo.order.service;
package com.yohoufo.order.service.impl;
import com.sun.corba.se.spi.ior.IOR;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yoho.service.model.response.UserAddressRspBO;
import com.yohobuy.ufo.model.order.bo.PlatformFee;
import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo;
... ... @@ -10,17 +13,28 @@ import com.yohoufo.common.caller.UfoServiceCaller;
import com.yohoufo.common.exception.GatewayException;
import com.yohoufo.common.utils.BigDecimalHelper;
import com.yohoufo.common.utils.PriceFormater;
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
import com.yohoufo.dal.order.BuyerOrderMapper;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.dal.order.SellerOrderMapper;
import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.dal.order.model.BuyerOrderGoods;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.common.OrderCodeType;
import com.yohoufo.order.common.OrderListType;
import com.yohoufo.order.common.SellerOrderListType;
import com.yohoufo.order.model.AddressInfo;
import com.yohoufo.order.model.GoodsInfo;
import com.yohoufo.order.model.SellerOrderContext;
import com.yohoufo.order.model.dto.PlatformFeeDto;
import com.yohoufo.order.model.dto.SellerOrderComputeResult;
import com.yohoufo.order.request.OrderListRequest;
import com.yohoufo.order.response.OrderListInfo;
import com.yohoufo.order.response.OrderListInfoRsp;
import com.yohoufo.order.service.IOrderListService;
import com.yohoufo.order.service.handler.SellerOrderComputeHandler;
import com.yohoufo.order.service.handler.SellerOrderSubmitHandler;
import com.yohoufo.order.service.impl.AbsOrderListService;
import com.yohoufo.order.service.proxy.UserProxyService;
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
import com.yohoufo.product.model.GoodsSize;
... ... @@ -32,6 +46,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
/**
... ... @@ -39,7 +54,7 @@ import java.util.Objects;
*/
@Service
@Slf4j
public class SellerOrderService {
public class SellerOrderService extends AbsOrderListService implements IOrderListService {
@Autowired
private SellerOrderMapper sellerOrderMapper;
... ... @@ -151,10 +166,6 @@ public class SellerOrderService {
}
public OrderListInfoRsp getOrderList(SellerOrderListReq req){
return null;
}
private GoodsInfo getProductDetail(SellerOrderContext context){
int uid = context.getUid();
... ... @@ -300,7 +311,66 @@ public class SellerOrderService {
return PriceFormater.addCnCurrencySymbol(BigDecimalHelper.formatNumber(fee, BigDecimalHelper.FORMAT_TWOBITAFTERPOINT));
}
@Autowired
BuyerOrderMapper buyerOrderMapper;
@Autowired
BuyerOrderGoodsMapper buyerOrderGoodsMapper;
@Autowired
SellerOrderGoodsMapper sellerOrderGoodsMapper;
@Override
public OrderListInfoRsp getOrderList(OrderListRequest request){
int type;
if ((type=request.getType()) == SellerOrderListType.IN_SALE.getType()){
//todo
log.info("in seller getOrderList");
return null;
}else{
return super.getOrderList(request);
}
}
@Override
protected List<Integer> initOrderListRequest(OrderListRequest request) {
if (request.getUid() < 0){
log.warn("initOrderListRequest uid is {}", request.getUid());
throw new ServiceException(ServiceError.ORDER_UID_IS_EMPTY);
}
SellerOrderListType orderListType = SellerOrderListType.getOrderListType(request.getType());
if (orderListType == null){
log.warn("initOrderListRequest type invalidate, uid is {}, type is {}",request.getUid(), request.getType());
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
}
request.setPage(request.getPage() > 0 ? request.getPage() : 1);
request.setLimit( request.getLimit() > 0 ? request.getLimit() : 10 );
return orderListType.getStatus();
}
@Override
int getTotal(int uid, List<Integer> statusQuery) {
return buyerOrderMapper.selectCntBySellerUidStatus(uid, statusQuery);
}
@Override
List<BuyerOrder> getOrderList(int uid, List<Integer> statusQuery, int offset, int limit){
List<BuyerOrder> buyerOrderList = buyerOrderMapper.selectListBySellerUidStatus(uid, statusQuery, offset, limit);
return buyerOrderList;
}
@Override
List<BuyerOrderGoods> getOrderGoodsList(int uid, List<Long> orderCodeList){
List<BuyerOrderGoods> buyerOrderGoodsList = buyerOrderGoodsMapper.selectByOrderCodeList(null, orderCodeList);
return buyerOrderGoodsList;
}
@Override
List<SellerOrderGoods> getBaseOrderGoodsList(List<Integer> skups){
List<SellerOrderGoods> sellerOrderGoodsList = sellerOrderGoodsMapper.selectBySkups(skups);
return sellerOrderGoodsList;
}
}
... ...
package com.yohoufo.order.service;
package com.yohoufo.order.service.impl;
import com.yoho.core.dal.datasource.annotation.Database;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
... ...
... ... @@ -168,7 +168,7 @@ public class SubmitOrderServiceImpl implements ISubmitOrderService {
private SellerOrder updSellerOrder(OrderBuilder orderBuilder) {
SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(orderBuilder.getSkup());
sellerOrder.setUpdateTime(DateUtil.getCurrentTimeSecond());
sellerOrder.setStatus(SellerOrderStatus.HAS_SELLED.getCode());
//sellerOrder.setStatus(SkupStatus.SELL_OUT.getCode());
sellerOrderMapper.updateByPrimaryKeySelective(sellerOrder);
return sellerOrder;
}
... ...
... ... @@ -2,6 +2,7 @@ package com.yohoufo.order.service;
import com.alibaba.fastjson.JSONObject;
import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo;
import com.yohoufo.order.service.impl.SellerOrderService;
import org.junit.Test;
import java.math.BigDecimal;
... ...