فهرست منبع

Merge remote-tracking branch 'origin/dev' into dev

yangdamao 1 سال پیش
والد
کامیت
fee0877f28

+ 10 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/schedule/ScheduleController.java

@@ -5,6 +5,7 @@ import com.zhongzheng.common.core.domain.AjaxResult;
 import com.zhongzheng.framework.web.service.AsyncService;
 import com.zhongzheng.framework.web.service.WxLoginService;
 import com.zhongzheng.modules.exam.bo.ExamApplyQueryBo;
+import com.zhongzheng.modules.order.service.IOrderHandleService;
 import com.zhongzheng.modules.polyv.service.IPolyvLiveService;
 import com.zhongzheng.modules.schedule.service.IScheduleService;
 import com.zhongzheng.modules.user.bo.UserQueryBo;
@@ -43,6 +44,8 @@ public class ScheduleController extends BaseController {
 
     private final WxLoginService wxLoginService;
 
+    private final IOrderHandleService iOrderHandleService;
+
     /**
      * 商品购买发送消息
      * @return
@@ -458,4 +461,11 @@ public class ScheduleController extends BaseController {
         iScheduleService.usbUserDownload();
         return AjaxResult.success();
     }
+
+    @ApiOperation("经办订单超时关闭")
+    @GetMapping("/order/closeOverHandle")
+    public AjaxResult closeOverHandle(){
+        iOrderHandleService.overTimeCloseOrder();
+        return AjaxResult.success();
+    }
 }

+ 17 - 1
zhongzheng-api/src/main/java/com/zhongzheng/controller/order/OrderHandleController.java

@@ -1,15 +1,20 @@
 package com.zhongzheng.controller.order;
 
+import java.math.BigDecimal;
 import java.util.List;
 import java.util.Arrays;
 import java.util.Map;
 
 import cn.hutool.core.lang.Validator;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.zhongzheng.common.core.domain.model.LoginUser;
+import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.SecurityUtils;
 import com.zhongzheng.common.utils.ServletUtils;
 import com.zhongzheng.framework.web.service.WxTokenService;
 import com.zhongzheng.modules.order.bo.*;
+import com.zhongzheng.modules.order.domain.OrderHandle;
 import com.zhongzheng.modules.order.service.IOrderHandleService;
 import com.zhongzheng.modules.order.service.IOrderService;
 import com.zhongzheng.modules.order.vo.OrderHandleGoodsVo;
@@ -87,7 +92,18 @@ public class OrderHandleController extends BaseController {
     public AjaxResult<String> add(@RequestBody OrderHandleAddBo bo) {
         ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
         bo.setCreateUserId(loginUser.getUser().getUserId());
-        return AjaxResult.success("录单单号",iOrderHandleService.submitOrder(bo));
+        String handleOrderSn = iOrderHandleService.createOrder(bo);
+        OrderHandle orderHandle = iOrderHandleService.queryBySn(handleOrderSn);
+        if (orderHandle.getPayPrice().compareTo(BigDecimal.ZERO) == 0) {
+            LambdaUpdateWrapper<OrderHandle> objectLambdaUpdateWrapper = Wrappers.lambdaUpdate();
+            objectLambdaUpdateWrapper.eq(OrderHandle::getId, orderHandle.getId());
+            objectLambdaUpdateWrapper.set(OrderHandle::getUpdateTime, DateUtils.getNowTime());
+            objectLambdaUpdateWrapper.set(OrderHandle::getPayTime, DateUtils.getNowTime());
+            objectLambdaUpdateWrapper.set(OrderHandle::getPayStatus, 1);
+            objectLambdaUpdateWrapper.set(OrderHandle::getPayType, 1);
+            iOrderHandleService.update(null, objectLambdaUpdateWrapper);
+        }
+        return AjaxResult.success("录单单号",handleOrderSn);
     }
 
     /**

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/mapper/OrderHandleMapper.java

@@ -16,7 +16,7 @@ import java.util.List;
  */
 public interface OrderHandleMapper extends BaseMapper<OrderHandle> {
 
-    List<OrderHandleVo> selectList(OrderHandleQueryBo bo);
+    List<OrderHandleVo> selectOrderList(OrderHandleQueryBo bo);
 
     List<OrderHandleGoodsVo> selectOrderGoodsList(OrderHandleQueryBo bo);
 

+ 2 - 2
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/IOrderHandleService.java

@@ -44,14 +44,14 @@ public interface IOrderHandleService extends IService<OrderHandle> {
 	 */
 	String insertByAddBo(OrderHandleAddBo bo);
 
-	String submitOrder(OrderHandleAddBo bo);
-
 	String createOrder(OrderHandleAddBo bo);
 
 	Map<String, String> resumePayOrder(OrderHandleAddBo bo);
 
 	Boolean closeOrder(OrderHandleAddBo bo);
 
+	Boolean overTimeCloseOrder();
+
 	/**
 	 * 根据编辑业务对象修改经办录单
 	 * @param bo 经办录单编辑业务对象

+ 12 - 20
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderHandleServiceImpl.java

@@ -116,7 +116,7 @@ public class OrderHandleServiceImpl extends ServiceImpl<OrderHandleMapper, Order
 
     @Override
     public List<OrderHandleVo> selectList(OrderHandleQueryBo bo) {
-        List<OrderHandleVo> orderHandleVos = baseMapper.selectList(bo);
+        List<OrderHandleVo> orderHandleVos = baseMapper.selectOrderList(bo);
         if (CollectionUtils.isEmpty(orderHandleVos)) {
             return new ArrayList<>();
         }
@@ -256,21 +256,6 @@ public class OrderHandleServiceImpl extends ServiceImpl<OrderHandleMapper, Order
         return null;
     }
 
-    @Override
-    public String submitOrder(OrderHandleAddBo bo) {
-        String handleOrderSn = createOrder(bo);
-        OrderHandle orderHandle = queryBySn(handleOrderSn);
-        if (orderHandle.getPayPrice().compareTo(BigDecimal.ZERO) == 0) {
-            LambdaUpdateWrapper<OrderHandle> objectLambdaUpdateWrapper = Wrappers.lambdaUpdate();
-            objectLambdaUpdateWrapper.eq(OrderHandle::getId, orderHandle.getId());
-            objectLambdaUpdateWrapper.set(OrderHandle::getUpdateTime, DateUtils.getNowTime());
-            objectLambdaUpdateWrapper.set(OrderHandle::getPayTime, DateUtils.getNowTime());
-            objectLambdaUpdateWrapper.set(OrderHandle::getPayStatus, 1);
-            objectLambdaUpdateWrapper.set(OrderHandle::getPayType, 1);
-            this.update(null, objectLambdaUpdateWrapper);
-        }
-        return handleOrderSn;
-    }
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -368,9 +353,6 @@ public class OrderHandleServiceImpl extends ServiceImpl<OrderHandleMapper, Order
         if (Validator.isEmpty(orderHandle)) {
             throw new CustomException("录单单号不存在");
         }
-        if (orderHandle.getCreateUserId() != bo.getCreateUserId()) {
-            throw new CustomException("非法操作");
-        }
         if (orderHandle.getPayStatus() != 0) {
             throw new CustomException("非待支付状态");
         }
@@ -388,7 +370,17 @@ public class OrderHandleServiceImpl extends ServiceImpl<OrderHandleMapper, Order
             editBo.setOrderStatus(-1);
             iOrderService.updateByEditBo(editBo);
         }
+        return true;
+    }
 
+    @Override
+    public Boolean overTimeCloseOrder() {
+        List<OrderHandle> list = this.list(new LambdaQueryWrapper<OrderHandle>().eq(OrderHandle::getPayStatus, 0).lt(OrderHandle::getOverTime,DateUtils.getNowTime()));
+        for(OrderHandle orderHandle : list){
+            OrderHandleAddBo addBo = new OrderHandleAddBo();
+            addBo.setHandleOrderSn(orderHandle.getHandleOrderSn());
+            closeOrder(addBo);
+        }
         return true;
     }
 
@@ -492,7 +484,7 @@ public class OrderHandleServiceImpl extends ServiceImpl<OrderHandleMapper, Order
 
     @Override
     public OrderHandleStatisticsVo statistics(OrderHandleQueryBo bo) {
-        List<OrderHandleVo> orderHandleVos = baseMapper.selectList(bo);
+        List<OrderHandleVo> orderHandleVos = baseMapper.selectOrderList(bo);
         BigDecimal payPrice = orderHandleVos.stream().filter(x -> ObjectUtils.isNotNull(x.getOrderPrice())).map(OrderHandleVo::getOrderPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
         BigDecimal refundPrice = orderHandleVos.stream().filter(x -> ObjectUtils.isNotNull(x.getRefundPrice())).map(OrderHandleVo::getRefundPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
         BigDecimal orderPrice = payPrice.subtract(refundPrice);

+ 22 - 7
zhongzheng-system/src/main/resources/mapper/modules/order/OrderHandleMapper.xml

@@ -20,7 +20,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="goodsType" column="goods_type"/>
     </resultMap>
 
-    <select id="selectList" parameterType="com.zhongzheng.modules.order.bo.OrderHandleQueryBo" resultType="com.zhongzheng.modules.order.vo.OrderHandleVo">
+
+    <resultMap type="com.zhongzheng.modules.order.vo.OrderHandleGoodsVo" id="OrderHandleGoodsVoResult">
+        <result property="realname" column="realname"/>
+        <result property="telPhone" column="telphone" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
+        <result property="idCard" column="id_card" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
+        <result property="goodsName" column="goods_name"/>
+        <result property="year" column="year"/>
+        <result property="goodsRealPrice" column="goods_real_price"/>
+        <result property="orderGoodsId" column="order_goods_id"/>
+        <result property="userId" column="user_id"/>
+        <result property="gradeId" column="grade_id"/>
+        <result property="goodsId" column="goods_id"/>
+        <result property="subjectNames" column="subject_names"/>
+    </resultMap>
+
+    <select id="selectOrderList" parameterType="com.zhongzheng.modules.order.bo.OrderHandleQueryBo" resultType="com.zhongzheng.modules.order.vo.OrderHandleVo">
         SELECT  u.*,
         (select count( DISTINCT o.user_id ) from `order` o  where  u.handle_order_sn = o.handle_order_sn) user_num,
         (select count( DISTINCT og.goods_id ) from `order` o  LEFT JOIN order_goods og ON o.order_sn = og.order_sn where  u.handle_order_sn = o.handle_order_sn) goods_num,
@@ -40,7 +55,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             AND oh.education_type_id = #{educationTypeId}
         </if>
         <if test="searchKey != null and searchKey != ''">
-            AND (oh.create_username like concat('%', #{searchKey}, '%') or oh.handle_order_sn = #{searchKey})
+            AND (select count(*) from `order` o left JOIN `user` u  on o.user_id = u.user_id left JOIN order_goods og on o.order_sn = og.order_sn LEFT JOIN goods g on og.goods_id = g.goods_id where  o.handle_order_sn = oh.handle_order_sn and (u.realname like concat('%', #{searchKey}, '%') or (u.id_card = #{searchKey,typeHandler=com.zhongzheng.common.type.EncryptHandler}) or (g.goods_name like concat('%', #{searchKey}, '%'))))>0
         </if>
         <if test="goodsType != null">
             AND oh.goods_type = #{goodsType}
@@ -51,16 +66,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="handleOrderSn != null and handleOrderSn != ''">
             AND oh.handle_order_sn = #{handleOrderSn}
         </if>
-        <if test="refundStatus != null and refundStatus != ''">
+        <if test="refundStatus != null">
             AND oh.refund_status = #{refundStatus}
         </if>
         <if test="startTime != null and startTime != ''">
-            AND oh.check_time &gt;= #{refundStatus}
+            AND oh.check_time &gt;= #{startTime}
         </if>
         <if test="endTime != null and endTime != ''">
-            AND oh.check_time &lt;= #{refundStatus}
+            AND oh.check_time &lt;= #{endTime}
         </if>
-        <if test="payStatus != null and payStatus != ''">
+        <if test="payStatus != null">
             AND oh.pay_status = #{payStatus}
         </if>)u
         LEFT JOIN course_education_type cet ON u.education_type_id = cet.id
@@ -91,7 +106,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         ORDER BY u.create_time DESC
     </select>
 
-    <select id="selectOrderGoodsList" parameterType="com.zhongzheng.modules.order.bo.OrderHandleQueryBo" resultType="com.zhongzheng.modules.order.vo.OrderHandleGoodsVo">
+    <select id="selectOrderGoodsList" parameterType="com.zhongzheng.modules.order.bo.OrderHandleQueryBo" resultMap="OrderHandleGoodsVoResult">
         SELECT
             u.realname,
             u.id_card,