瀏覽代碼

关闭订单

he2802 3 年之前
父節點
當前提交
b5b4b8e16f

+ 10 - 1
zhongzheng-api/src/main/java/com/zhongzheng/controller/inform/InformUserController.java

@@ -33,7 +33,7 @@ import io.swagger.annotations.ApiOperation;
 
 /**
  * 通知绑定学员Controller
- * 
+ *
  * @author ruoyi
  * @date 2021-12-16
  */
@@ -85,5 +85,14 @@ public class InformUserController extends BaseController {
         return toAjax(iInformUserService.updateByEditBo(bo) ? 1 : 0);
     }
 
+    @ApiOperation("标记全部已读")
+    @Log(title = "标记全部已读", businessType = BusinessType.UPDATE)
+    @PostMapping("/updateAllRead")
+    public AjaxResult<Void> updateAllRead(@RequestBody InformUserEditBo bo) {
+        ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
+        bo.setUserId(loginUser.getUser().getUserId());
+        return toAjax(iInformUserService.updateAllRead(bo) ? 1 : 0);
+    }
+
 
 }

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/inform/bo/InformUserQueryBo.java

@@ -6,6 +6,7 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 
 import java.util.Date;
+import java.util.List;
 import java.util.Map;
 import java.util.HashMap;
 
@@ -84,4 +85,6 @@ public class InformUserQueryBo extends BaseEntity {
 	/** 班级ID */
 	@ApiModelProperty("班级ID")
 	private Long gradeId;
+
+	private List<Integer> systemStatusList;
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/inform/service/IInformUserService.java

@@ -56,4 +56,6 @@ public interface IInformUserService extends IService<InformUser> {
     List<ExamUserApplyVo> listUserApply();
 
 	InformUserVo queryByIdUser(Long id, Long userId);
+
+	Boolean updateAllRead(InformUserEditBo bo);
 }

+ 40 - 3
zhongzheng-system/src/main/java/com/zhongzheng/modules/inform/service/impl/InformUserServiceImpl.java

@@ -1,10 +1,13 @@
 package com.zhongzheng.modules.inform.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.lang.Validator;
 import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.modules.exam.vo.ExamUserApplyVo;
 import com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo;
+import com.zhongzheng.modules.grade.domain.ClassGradeUser;
 import com.zhongzheng.modules.grade.mapper.ClassGradeUserMapper;
 import com.zhongzheng.modules.grade.vo.ClassGradeUserGoodsVo;
 import com.zhongzheng.modules.inform.bo.InformQueryBo;
@@ -75,15 +78,15 @@ public class InformUserServiceImpl extends ServiceImpl<InformUserMapper, InformU
     @Override
     public List<InformUserVo> queryList(InformUserQueryBo bo) {
         LambdaQueryWrapper<InformUser> lqw = Wrappers.lambdaQuery();
-        List<Long> status = new ArrayList<>();
+  /*      List<Long> status = new ArrayList<>();
         status.add(1L);
-        status.add(2L);
+        status.add(2L);*/
         lqw.eq(bo.getUserId() != null, InformUser::getUserId, bo.getUserId());
         lqw.eq(bo.getSendTime() != null, InformUser::getSendTime, bo.getSendTime());
         lqw.eq(bo.getSendStatus() != null, InformUser::getSendStatus, bo.getSendStatus());
         lqw.eq(bo.getReceiptStatus() != null, InformUser::getReceiptStatus, bo.getReceiptStatus());
         lqw.eq( InformUser::getSendStatus, 1);
-        lqw.in( InformUser::getSystemStatus, status);
+        lqw.in( bo.getSystemStatusList() != null,InformUser::getSystemStatus, bo.getSystemStatusList());
         lqw.orderByDesc(InformUser::getSendTime);
         List<InformUserVo> informUserVos = entity2Vo(this.list(lqw));
         for (InformUserVo informUserVo : informUserVos) {
@@ -198,4 +201,38 @@ public class InformUserServiceImpl extends ServiceImpl<InformUserMapper, InformU
         }
         return informUserVo;
     }
+
+    /**
+     * 修改所有未读为已读
+     * @param bo
+     * @return
+     */
+    @Override
+    public Boolean updateAllRead(InformUserEditBo bo) {
+        //系统通知
+        if (bo.getSystemStatus()==1) {
+            LambdaUpdateWrapper<InformUser> objectLambdaUpdateWrapper = Wrappers.lambdaUpdate();
+            objectLambdaUpdateWrapper.eq(InformUser::getUserId, bo.getUserId());
+            objectLambdaUpdateWrapper.eq(InformUser::getSystemStatus, bo.getSystemStatus());
+            objectLambdaUpdateWrapper.eq(InformUser::getReceiptStatus, 0);
+            objectLambdaUpdateWrapper.eq(InformUser::getSendStatus, 1);
+
+            objectLambdaUpdateWrapper.set(InformUser::getReceiptStatus, 1);
+            objectLambdaUpdateWrapper.set(InformUser::getUpdateTime, DateUtils.getNowTime());
+            this.update(null, objectLambdaUpdateWrapper);
+        }
+        //教务通知
+        if (bo.getSystemStatus()==2) {
+            LambdaUpdateWrapper<InformUser> objectLambdaUpdateWrapper = Wrappers.lambdaUpdate();
+            objectLambdaUpdateWrapper.eq(InformUser::getUserId, bo.getUserId());
+            objectLambdaUpdateWrapper.eq(InformUser::getSystemStatus, bo.getSystemStatus());
+            objectLambdaUpdateWrapper.eq(InformUser::getReceiptStatus, 0);
+            objectLambdaUpdateWrapper.eq(InformUser::getSendStatus, 1);
+
+            objectLambdaUpdateWrapper.set(InformUser::getReceiptStatus, 1);
+            objectLambdaUpdateWrapper.set(InformUser::getUpdateTime, DateUtils.getNowTime());
+            this.update(null, objectLambdaUpdateWrapper);
+        }
+        return true;
+    }
 }

+ 14 - 4
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderServiceImpl.java

@@ -31,12 +31,10 @@ import com.zhongzheng.modules.order.bo.*;
 import com.zhongzheng.modules.order.domain.Order;
 import com.zhongzheng.modules.order.domain.OrderGoods;
 import com.zhongzheng.modules.order.domain.OrderInput;
+import com.zhongzheng.modules.order.domain.OrderPay;
 import com.zhongzheng.modules.order.mapper.OrderMapper;
 import com.zhongzheng.modules.order.service.*;
-import com.zhongzheng.modules.order.vo.OrderGoodsVo;
-import com.zhongzheng.modules.order.vo.OrderInputVo;
-import com.zhongzheng.modules.order.vo.OrderListVo;
-import com.zhongzheng.modules.order.vo.OrderVo;
+import com.zhongzheng.modules.order.vo.*;
 import com.zhongzheng.modules.user.service.IUserService;
 import com.zhongzheng.modules.user.vo.UserVo;
 import com.zhongzheng.modules.wx.service.IWxPayService;
@@ -910,6 +908,18 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             throw new CustomException("无法继续支付");
         }
         UserVo userVo = iUserService.queryById(bo.getUserId());
+        //关闭PC未支付订单
+        OrderPayQueryBo payQueryBo = new OrderPayQueryBo();
+        payQueryBo.setOrderSn(bo.getOrderSn());
+        payQueryBo.setStatus(0);
+        List<OrderPayVo> noPayList = iOrderPayService.queryList(payQueryBo);
+        for(OrderPayVo item : noPayList){
+            iWxPayService.closeWxPcOrder(item.getPaySn());
+            item.setStatus(1);
+            OrderPay update = BeanUtil.toBean(item, OrderPay.class);
+            update.setUpdateTime(DateUtils.getNowTime());
+            iOrderPayService.updateById(update);
+        }
         //生成支付单号
         String pay_no = DateUtils.getPayOrderSn();
         OrderPayAddBo payAddBo = new OrderPayAddBo();

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/wx/service/IWxPayService.java

@@ -43,4 +43,6 @@ public interface IWxPayService {
 
 	OrderGoods setServiceTime(OrderGoods g);
 
+	boolean closeWxPcOrder(String out_trade_no);
+
 }

+ 14 - 2
zhongzheng-system/src/main/java/com/zhongzheng/modules/wx/service/impl/WxPayServiceImpl.java

@@ -408,8 +408,6 @@ public class WxPayServiceImpl implements IWxPayService {
                     //给用户增加商品考试次数前培次数
                     updateUserExamGoods(g, order);
                     joinLockGrade(order.getOrderSn(), g.getGoodsId(), g.getOrderGoodsId());
-
-
                 }
             }
 
@@ -451,6 +449,20 @@ public class WxPayServiceImpl implements IWxPayService {
         return g;
     }
 
+    @Override
+    public boolean closeWxPcOrder(String out_trade_no) {
+        WxSmallConfig config = new WxSmallConfig(appid, mchid, key);
+        try {
+            WXPay wxpay = new WXPay(config);
+            Map<String, String> reqData = new HashMap<>();
+            reqData.put("out_trade_no",out_trade_no);
+            wxpay.closeOrder(reqData);
+        }catch (Exception e) {
+
+        }
+        return true;
+    }
+
     @Override
     public void updateUserExamGoods(OrderGoods g, Order order) {
         GoodsVo goodsVo = iGoodsService.queryById(g.getGoodsId());