Bladeren bron

1.订单超时未支付 没有进入悔拍状态
3.资产·珍品 "status":1 竞拍中,查询不到数据
4.后台订单详情的接口缺少两个字段 支付时间和订单状态
5.订单详情接口,已发货,缺少物流信息
6.成交订单支付 需要一个地址id

hr~ 1 maand geleden
bovenliggende
commit
bdd1c0bb58

+ 31 - 3
poyee-order/src/main/java/com/tzy/controller/LotOrderController.java

@@ -10,6 +10,7 @@ import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
+import springfox.documentation.annotations.ApiIgnore;
 
 import java.util.List;
 
@@ -33,6 +34,7 @@ public class LotOrderController {
 
         return OutDTO.error500("创建订单失败");
     }
+
     //app拍品订单列表查询
     @PostMapping("/list")
     @ResponseBody
@@ -76,13 +78,13 @@ public class LotOrderController {
     @GetMapping("/updateOrderStatus/{orderNo}/{status}")
     @ApiVersion(1.0)
     @ApiOperation("修改订单状态(mock支付 签署确认书) 支付status传入101 模拟按钮签署确认书 传入 103")
-    public OutDTO updateOrderStatus(@PathVariable("orderNo") String orderNo, @PathVariable("status")Integer status) {
-        lotOrderService.updateOrderStatus(orderNo,status);
+    public OutDTO updateOrderStatus(@PathVariable("orderNo") String orderNo, @PathVariable("status") Integer status,
+                                    @RequestParam("addressId") Integer addressId) {
+        lotOrderService.updateOrderStatus(orderNo, status, addressId);
         return OutDTO.ok();
     }
 
 
-
     @PostMapping("/confirm")
     @ApiVersion(1.0)
     @ApiOperation("确认订单收货")
@@ -90,4 +92,30 @@ public class LotOrderController {
         lotOrderService.confirm(lotOrderConfirmRequest);
         return OutDTO.ok();
     }
+
+    @GetMapping("/queryExpireOrder")
+    @ApiIgnore
+    @ApiVersion(1.0)
+    @ApiOperation("查找过期订单")
+    public OutDTO queryExpireOrder() {
+        List<LotOrder> lotOrders = lotOrderService.queryExpireOrder();
+        return OutDTO.ok().put("lotOrders", lotOrders);
+    }
+
+    @GetMapping("/batchTimeoutUnpaidOrders")
+    @ApiIgnore
+    @ApiVersion(1.0)
+    @ApiOperation("批量设置未支付过期订单为超时")
+    public OutDTO batchTimeoutUnpaidOrders() {
+        int count = lotOrderService.batchTimeoutUnpaidOrders();
+        return OutDTO.ok().put("count", count);
+    }
+
+    @GetMapping("/queryPaidOrdersLastThreeDays")
+    @ApiVersion(1.0)
+    @ApiOperation("查询近三天已支付订单")
+    public OutDTO queryPaidOrdersLastThreeDays() {
+        List<LotOrder> lotOrders = lotOrderService.queryPaidOrdersLastThreeDays();
+        return OutDTO.ok().put("lotOrders", lotOrders);
+    }
 }

+ 6 - 1
poyee-order/src/main/java/com/tzy/entity/LotOrder.java

@@ -1,5 +1,8 @@
 package com.tzy.entity;
 
+import com.alibaba.fastjson.annotation.JSONField;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.tzy.dto.LogisticsDTO;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -37,7 +40,7 @@ public class LotOrder {
     @ApiModelProperty("用户id")
     private Long userId;
     //订单状态
-    @ApiModelProperty("订单状态:100待支付,101待确认、103待发货、104已发货,105已完成")
+    @ApiModelProperty("订单状态:100待支付,101待确认、103待发货、104已发货,105已完成 106 已超时")
     private Integer status;
     //订单金额(单位:分)
     @ApiModelProperty("订单金额(单位:分)")
@@ -73,4 +76,6 @@ public class LotOrder {
     @ApiModelProperty("倒计时")
     private Long timestamp;
 
+    @ApiModelProperty("物流信息")
+    private LogisticsDTO logisticsDTO;
 }

+ 7 - 1
poyee-order/src/main/java/com/tzy/mapper/LotOrderMapper.java

@@ -13,7 +13,13 @@ public interface LotOrderMapper {
     LotOrder selectLotOrderById(Long id);
     List<LotOrder> selectLotOrder(LotOrder lotOrder);
     int findOrderByStatus(@Param("orderNo") String orderNo, @Param("status") Integer status);
-    int updateOrderStatus(@Param("orderNo") String orderNo, @Param("status") Integer status);
+    int updateOrderStatus(LotOrder lotOrder);
 
     int orderConfirm(@Param("orderNo") String orderNo);
+
+    List<LotOrder> queryExpireOrder();
+
+    int batchTimeoutUnpaidOrders();
+
+    List<LotOrder> queryPaidOrdersLastThreeDays();
 }

+ 7 - 1
poyee-order/src/main/java/com/tzy/service/LotOrderService.java

@@ -15,7 +15,13 @@ public interface LotOrderService {
 
     LogisticsDTO logisticsInfo(String orderNo);
 
-    void updateOrderStatus(String orderNo,Integer status);
+    void updateOrderStatus(String orderNo, Integer status, Integer addressId);
 
     void confirm(LotOrderConfirmRequest lotOrderConfirmRequest);
+
+    List<LotOrder> queryExpireOrder();
+
+    int batchTimeoutUnpaidOrders();
+
+    List<LotOrder> queryPaidOrdersLastThreeDays();
 }

+ 42 - 4
poyee-order/src/main/java/com/tzy/service/impl/LotOrderServiceImpl.java

@@ -65,6 +65,8 @@ public class LotOrderServiceImpl implements LotOrderService {
     public LotOrder getLotOrderById(Long id) {
         LotOrder lotOrder = lotOrderMapper.selectLotOrderById(id);
         fillTimestamp(lotOrder);
+        LogisticsDTO logisticsDTO = logisticsInfo(lotOrder.getOrderNo());
+        lotOrder.setLogisticsDTO(logisticsDTO);
         return lotOrder;
     }
 
@@ -115,9 +117,23 @@ public class LotOrderServiceImpl implements LotOrderService {
     }
 
     @Override
-    public void updateOrderStatus(String orderNo,Integer status) {
-        //跳过确认书 直接支付
-        int i = lotOrderMapper.updateOrderStatus(orderNo, status);
+    public void updateOrderStatus(String orderNo, Integer status, Integer addressId) {
+        LotOrder lotOrder = new LotOrder();
+        lotOrder.setOrderNo(orderNo);
+        if (status == 102) {
+            List<LotOrder> lotOrders = lotOrderMapper.selectLotOrder(lotOrder);
+            if (lotOrders == null || lotOrders.isEmpty()) {
+                throw new ServiceException(500, "订单不存在");
+            }
+            LotOrder updateOrder = lotOrders.get(0);
+            updateOrder.setShippingAddressId(Long.valueOf(addressId));
+            updateLotOrderAddress(updateOrder);
+        }
+        lotOrder.setStatus(status);
+        if (status == 101) {
+            lotOrder.setPayTime(DateUtils.getNowDate());
+        }
+        int i = lotOrderMapper.updateOrderStatus(lotOrder);
         if (i <=0) {
             throw new ServiceException(500, "订单不存在");
         }
@@ -125,6 +141,28 @@ public class LotOrderServiceImpl implements LotOrderService {
 
     @Override
     public void confirm(LotOrderConfirmRequest lotOrderConfirmRequest) {
-        lotOrderMapper.updateOrderStatus(lotOrderConfirmRequest.getOrderNo(), 103);
+        LotOrder lotOrder = new LotOrder();
+        lotOrder.setOrderNo(lotOrderConfirmRequest.getOrderNo());
+        lotOrder.setStatus(103);
+        lotOrderMapper.updateOrderStatus(lotOrder);
+    }
+
+    @Override
+    public List<LotOrder> queryExpireOrder() {
+        List<LotOrder> lotOrders = lotOrderMapper.queryExpireOrder();
+        fillTimestamp(lotOrders);
+        return lotOrders;
+    }
+
+    @Override
+    public int batchTimeoutUnpaidOrders() {
+        return lotOrderMapper.batchTimeoutUnpaidOrders();
+    }
+
+    @Override
+    public List<LotOrder> queryPaidOrdersLastThreeDays() {
+        List<LotOrder> lotOrders = lotOrderMapper.queryPaidOrdersLastThreeDays();
+        fillTimestamp(lotOrders);
+        return lotOrders;
     }
 }

+ 30 - 2
poyee-order/src/main/resources/mapper/LotOrderMapper.xml

@@ -8,7 +8,7 @@
         <result column="order_no" property="orderNo"/>
         <result column="auction_name" property="auctionName"/>
         <result column="lot_name" property="lotName"/>
-        <result column="user_id" property="lotId"/>
+        <result column="user_id" property="userId"/>
         <result column="status" property="status"/>
         <result column="payment_amount" property="paymentAmount"/>
         <result  column="merchant_id" property="merchantId"/>
@@ -66,9 +66,37 @@
         select <include refid="selectLotOrderSql"/>  from lot_order_info where order_no=#{orderNo} and status=#{status}
     </select>
     <update id="updateOrderStatus">
-        update lot_order_info set status=#{status} where order_no=#{orderNo}
+        update lot_order_info
+        <set>
+            status=#{status}
+            <if test="payTime != null">
+                ,pay_time=#{payTime}
+            </if>
+        </set>
+        where order_no=#{orderNo}
     </update>
     <update id="orderConfirm">
         update lot_order_info set status=104 where order_no=#{orderNo} and status=104
     </update>
+    <select id="queryExpireOrder" resultMap="lotOrderResultMap">
+        <include refid="selectLotOrderSql"/>
+        where status = 100
+          and expire_time is not null
+          and expire_time &lt; now()
+        order by expire_time asc
+    </select>
+    <update id="batchTimeoutUnpaidOrders">
+        update lot_order_info
+        set status = 106
+        where status = 100
+          and expire_time is not null
+          and expire_time &lt; now()
+    </update>
+    <select id="queryPaidOrdersLastThreeDays" resultMap="lotOrderResultMap">
+        <include refid="selectLotOrderSql"/>
+        where status in (101,102,103,104,105)
+          and pay_time is not null
+          and pay_time &gt;= now() - interval '3 day'
+        order by pay_time desc
+    </select>
 </mapper>