Authored by caoyan

订单管理

... ... @@ -28,11 +28,6 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.yoho.ufo.model</groupId>
<artifactId>order-service-model</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.yoho.ufo</groupId>
<artifactId>ufo-platform-common</artifactId>
</dependency>
... ...
... ... @@ -2,6 +2,11 @@ package com.yoho.order.dal;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.yoho.order.model.BuyerOrder;
import com.yoho.order.model.BuyerOrderReq;
/**
* Created by caoyan on 2018/9/12.
*/
... ... @@ -9,7 +14,7 @@ public interface BuyerOrderMapper {
int selectCountByStatus(List<Byte> statusList);
// int selectTotalByCondition(BuyerOrderListReq req);
int selectTotalByCondition(@Param("buyerOrderReq") BuyerOrderReq req);
// List<BuyerOrder> selectByCondition(BuyerOrderListReq req);
List<BuyerOrder> selectByCondition(@Param("buyerOrderReq") BuyerOrderReq req);
}
... ...
... ... @@ -38,29 +38,29 @@
</select>
<sql id="Query_Order_Sql" >
<if test="statusList != null and statusList.size() > 0">
<if test="buyerOrderReq.statusList != null and buyerOrderReq.statusList.size() > 0">
and status in
<foreach collection="statusList" item="status" open="(" close=")" separator=",">
<foreach collection="buyerOrderReq.statusList" item="status" open="(" close=")" separator=",">
#{status}
</foreach>
</if>
</sql>
<select id="selectTotalByCondition" resultType="java.lang.Integer">
<select id="selectTotalByCondition" resultType="java.lang.Integer" parameterType="com.yoho.order.model.BuyerOrderReq">
select count(1)
from buyer_order
where 1=1
<include refid="Query_Order_Sql" />
</select>
<select id="selectByCondition" resultMap="BaseResultMap">
<select id="selectByCondition" resultMap="BaseResultMap" parameterType="com.yoho.order.model.BuyerOrderReq">
select <include refid="Base_Column_List" />
from buyer_order
where 1=1
<include refid="Query_Order_Sql" />
order by create_time desc
<if test="start!=null and size != null">
limit #{start},#{size}
<if test="buyerOrderReq.start!=null and buyerOrderReq.size != null">
limit #{buyerOrderReq.start},#{buyerOrderReq.size}
</if>
</select>
... ...
... ... @@ -8,8 +8,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yoho.order.model.BuyerOrderReq;
import com.yoho.ufo.order.service.IBuyerOrderService;
import com.yoho.ufo.service.model.ApiResponse;
import com.yoho.ufo.service.model.PageResponseBO;
import com.yohobuy.ufo.model.order.resp.BuyerOrderResp;
@RestController
@RequestMapping(value = "/buyerOrder")
... ... @@ -27,10 +30,10 @@ public class BuyerOrderController {
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();
// }
@RequestMapping(value = "/queryOrderList")
public ApiResponse queryOrderList(BuyerOrderReq 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,6 +2,10 @@ package com.yoho.ufo.order.service;
import java.util.Map;
import com.yoho.order.model.BuyerOrderReq;
import com.yoho.ufo.service.model.PageResponseBO;
import com.yohobuy.ufo.model.order.resp.BuyerOrderResp;
/**
* @author caoyan
* @date 2018/9/13
... ... @@ -9,5 +13,5 @@ import java.util.Map;
public interface IBuyerOrderService {
Map<String, Integer> getCountByJudgeStatus();
// PageResponseBO<BuyerOrderResp> queryOrderList(BuyerOrderListReq req);
PageResponseBO<BuyerOrderResp> queryOrderList(BuyerOrderReq req);
}
... ...
... ... @@ -14,11 +14,11 @@ 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.order.model.BuyerOrderReq;
import com.yoho.ufo.order.constant.Constant;
import com.yoho.ufo.order.service.IBuyerOrderService;
import com.yohobuy.ufo.model.order.req.BuyerOrderListReq;
import com.yoho.ufo.service.model.PageResponseBO;
import com.yohobuy.ufo.model.order.resp.BuyerOrderResp;
import com.yohobuy.ufo.model.order.resp.PageResponseBO;
/**
* @author caoyan
... ... @@ -50,36 +50,35 @@ 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;
public PageResponseBO<BuyerOrderResp> queryOrderList(BuyerOrderReq 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;
}
}
... ...