Authored by caoyan

订单管理

... ... @@ -27,7 +27,11 @@
<artifactId>product-service-model</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.yoho.ufo.model</groupId>
<artifactId>order-service-model</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
... ...
... ... @@ -2,10 +2,17 @@ package com.yoho.order.dal;
import java.util.List;
import com.yoho.order.model.BuyerOrder;
import com.yohobuy.ufo.model.order.req.BuyerOrderListReq;
/**
* Created by caoyan on 2018/9/12.
*/
public interface BuyerOrderMapper {
int selectCountByStatus(List<Byte> statusList);
int selectTotalByCondition(BuyerOrderListReq req);
List<BuyerOrder> selectByCondition(BuyerOrderListReq req);
}
... ...
... ... @@ -47,7 +47,7 @@
</sql>
<select id="selectTotalByCondition" resultType="java.lang.Integer"
parameterType="com.yoho.order.model.BuyerOrder">
parameterType="com.yohobuy.ufo.model.order.req.BuyerOrderListReq">
select count(1)
from buyer_order
where 1=1
... ... @@ -55,7 +55,7 @@
</select>
<select id="selectByCondition" resultMap="BaseResultMap"
parameterType="com.yoho.order.model.BuyerOrder">
parameterType="com.yohobuy.ufo.model.order.req.BuyerOrderListReq">
select <include refid="Base_Column_List" />
from buyer_order
where 1=1
... ...
... ... @@ -2,16 +2,20 @@ package com.yoho.ufo.order.controller;
import java.util.Map;
import com.yoho.ufo.service.model.ApiResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yoho.ufo.order.service.IBuyerOrderService;
import com.yoho.ufo.service.model.ApiResponse;
import com.yohobuy.ufo.model.order.req.BuyerOrderListReq;
import com.yohobuy.ufo.model.order.resp.BuyerOrderResp;
import com.yohobuy.ufo.model.order.resp.PageResponseBO;
@RestController
@RequestMapping(value = "/sellerOrder")
@RequestMapping(value = "/buyerOrder")
public class BuyerOrderController {
private static final Logger LOGGER = LoggerFactory.getLogger(BuyerOrderController.class);
... ... @@ -25,4 +29,11 @@ public class BuyerOrderController {
Map<String, Integer> map = buyerOrderService.getCountByJudgeStatus();
return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(map).build();
}
@RequestMapping(value = "/queryOrderList")
public ApiResponse queryOrderList(BuyerOrderListReq req) {
LOGGER.info("queryOrderList in. req is {}", req);
PageResponseBO<BuyerOrderResp> result = buyerOrderService.queryOrderList(req);
return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(result).build();
}
}
... ...
... ... @@ -2,10 +2,16 @@ package com.yoho.ufo.order.service;
import java.util.Map;
import com.yohobuy.ufo.model.order.req.BuyerOrderListReq;
import com.yohobuy.ufo.model.order.resp.BuyerOrderResp;
import com.yohobuy.ufo.model.order.resp.PageResponseBO;
/**
* @author caoyan
* @date 2018/9/13
*/
public interface IBuyerOrderService {
Map<String, Integer> getCountByJudgeStatus();
PageResponseBO<BuyerOrderResp> queryOrderList(BuyerOrderListReq req);
}
... ...
... ... @@ -3,6 +3,7 @@ package com.yoho.ufo.order.service.impl;
import java.util.List;
import java.util.Map;
import org.apache.commons.collections.CollectionUtils;
import org.elasticsearch.common.collect.Lists;
import org.elasticsearch.common.collect.Maps;
import org.slf4j.Logger;
... ... @@ -10,9 +11,14 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yoho.core.common.utils.DateUtil;
import com.yoho.order.dal.BuyerOrderMapper;
import com.yoho.order.model.BuyerOrder;
import com.yoho.ufo.order.constant.Constant;
import com.yoho.ufo.order.service.IBuyerOrderService;
import com.yohobuy.ufo.model.order.req.BuyerOrderListReq;
import com.yohobuy.ufo.model.order.resp.BuyerOrderResp;
import com.yohobuy.ufo.model.order.resp.PageResponseBO;
/**
* @author caoyan
... ... @@ -43,5 +49,36 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
return resultMap;
}
public PageResponseBO<BuyerOrderResp> queryOrderList(BuyerOrderListReq req) {
int total = buyerOrderMapper.selectTotalByCondition(req);
if(total == 0) {
return null;
}
List<BuyerOrder> orderList = buyerOrderMapper.selectByCondition(req);
if(CollectionUtils.isEmpty(orderList)) {
return null;
}
List<BuyerOrderResp> respList = Lists.newArrayList();
for(BuyerOrder item : orderList) {
BuyerOrderResp resp = new BuyerOrderResp();
resp.setOrderCode(item.getOrderCode());
resp.setStatus(item.getStatus());
resp.setCreateTimeStr(DateUtil.long2DateStr(item.getCreateTime()*1000, "yyyy-MM-dd HH:mm:ss"));
respList.add(resp);
}
PageResponseBO<BuyerOrderResp> result=new PageResponseBO<>();
result.setList(respList);
result.setPage(req.getPage());
result.setSize(req.getSize());
result.setTotal(total);
return result;
}
}
... ...