diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/OrderController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/OrderController.java index 4972413..f0f5e96 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/OrderController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/OrderController.java @@ -1,5 +1,6 @@ package com.chaozhanggui.system.cashierservice.controller; +import cn.hutool.core.date.DateUtil; import com.alibaba.fastjson.JSONObject; import com.chaozhanggui.system.cashierservice.entity.OrderVo; import com.chaozhanggui.system.cashierservice.entity.vo.CartVo; @@ -10,6 +11,9 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.sql.Timestamp; +import java.util.Date; + @CrossOrigin(origins = "*") @RestController @Slf4j @@ -113,9 +117,13 @@ public class OrderController { @GetMapping("/findOrder") public Result findOrder(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName, @RequestHeader("clientType") String clientType, @RequestParam("shopId") Integer shopId, - @RequestParam("status") String status,@RequestParam("orderNo") String orderNo,@RequestParam(value = "page", required = false, defaultValue = "1") Integer page, + @RequestParam("status") String status, + @RequestParam(value = "orderNo", required = false) String orderNo, + @RequestParam(value = "startTime", required = false) String startTime, + @RequestParam(value = "endTime", required = false) String endTime, + @RequestParam(value = "page", required = false, defaultValue = "1") Integer page, @RequestParam(value = "size", required = false, defaultValue = "1") Integer size){ - return orderService.findOrder(shopId,status,page,size,orderNo); + return orderService.findOrder(shopId,status,page,size,orderNo, DateUtil.parse(startTime), DateUtil.parse(endTime)); } @GetMapping("/orderDetail") diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbOrderInfoMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbOrderInfoMapper.java index 837a81c..caab1dd 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbOrderInfoMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbOrderInfoMapper.java @@ -7,6 +7,8 @@ import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Component; +import java.sql.Timestamp; +import java.util.Date; import java.util.List; import java.util.Map; @@ -31,7 +33,7 @@ public interface TbOrderInfoMapper { List selectAllByStatus(String status); List selectAllByShop(@Param("shopId") Integer shopId, @Param("orderType") String orderType, - @Param("day") String day, @Param("orderNo") String orderNo); + @Param("day") String day, @Param("orderNo") String orderNo, Long startTime, Long endTime); TbOrderInfo selectByTradeAndMasterId(@Param("day")String day, @Param("masterId")String masterId, @Param("shopId")Integer shopId); @@ -45,4 +47,4 @@ public interface TbOrderInfoMapper { Map selectByOrderId(String orderId); List selectSkuByOrderId(String orderId); -} \ No newline at end of file +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java index 50675dd..3abaf0e 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java @@ -1,5 +1,7 @@ package com.chaozhanggui.system.cashierservice.service; +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.http.HttpRequest; import com.alibaba.fastjson.JSON; @@ -22,6 +24,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; +import java.sql.Timestamp; import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; @@ -868,8 +871,16 @@ public class OrderService { } - public Result findOrder(Integer shopId, String status, Integer page, Integer size, String orderNo) { - String day = DateUtils.getDay(); + public Result findOrder(Integer shopId, String status, Integer page, Integer size, String orderNo, + Date startTime, Date endTime) { + + String day = null; + if (startTime == null && endTime == null) { + startTime = DateUtil.beginOfDay(DateUtil.date()); + endTime = DateUtil.endOfDay(DateUtil.date()); + day = DateUtils.getDay(); + } + PageHelperUtil.startPage(page, size); String orderType = ""; if (StringUtils.isNotEmpty(status)) { @@ -881,7 +892,8 @@ public class OrderService { } log.info("orderType:" + orderType); log.info("status:" + status); - List list = tbOrderInfoMapper.selectAllByShop(shopId, orderType, day, orderNo); + List list = tbOrderInfoMapper.selectAllByShop(shopId, orderType, day, orderNo, + startTime == null ? null : startTime.getTime(), endTime == null ? null : endTime.getTime()); for (OrderPo orderInfo : list) { if (StringUtils.isEmpty(orderInfo.getImgUrl())) { @@ -894,7 +906,7 @@ public class OrderService { } orderInfo.setSkuInfos(skuInfoPos); orderInfo.setZdNo("POS"); - orderInfo.setNames(orderInfo.getProductName().split(",")); + orderInfo.setNames(orderInfo.getProductName() == null ? new String[]{""} : orderInfo.getProductName().split(",")); } PageInfo pageInfo = new PageInfo(list); log.info("获取订单:{}", JSONUtil.toJSONString(pageInfo)); diff --git a/src/main/resources/mapper/TbOrderInfoMapper.xml b/src/main/resources/mapper/TbOrderInfoMapper.xml index 0872593..d2e85f5 100644 --- a/src/main/resources/mapper/TbOrderInfoMapper.xml +++ b/src/main/resources/mapper/TbOrderInfoMapper.xml @@ -51,11 +51,11 @@ - id, order_no, settlement_amount, pack_fee, origin_amount, product_amount, amount, - refund_amount, pay_type, pay_amount, order_amount, freight_amount, discount_ratio, - discount_amount, table_id, small_change, send_type, order_type, product_type, status, - billing_id, merchant_id, shop_id, is_vip, member_id, user_id, product_score, deduct_score, - user_coupon_id, user_coupon_amount, refund_able, paid_time, is_effect, is_group, + id, order_no, settlement_amount, pack_fee, origin_amount, product_amount, amount, + refund_amount, pay_type, pay_amount, order_amount, freight_amount, discount_ratio, + discount_amount, table_id, small_change, send_type, order_type, product_type, status, + billing_id, merchant_id, shop_id, is_vip, member_id, user_id, product_score, deduct_score, + user_coupon_id, user_coupon_amount, refund_able, paid_time, is_effect, is_group, updated_at, `system_time`, created_at, is_accepted, pay_order_no,trade_day,`source`,remark,master_id,`table_name`,out_number - \ No newline at end of file +