This commit is contained in:
1378012178@qq.com 2025-07-24 14:23:16 +08:00
commit bbe90c7203
1 changed files with 73 additions and 0 deletions

View File

@ -1,6 +1,7 @@
package com.nu.modules.orgapplyinfo.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -12,15 +13,24 @@ import com.nu.modules.orgapplyinfo.entity.OrgApplyInfo;
import com.nu.modules.orgapplyinfo.entity.OrgApplyInfoApiEntity;
import com.nu.modules.orgapplyinfo.mapper.OrgApplyInfoMapper;
import com.nu.modules.orgapplyinfo.service.IOrgApplyInfoService;
import com.nu.modules.weixin.utils.TemplateMessageSender;
import com.nu.modules.weixin.utils.WechatMiniProgramUtils;
import com.nu.utils.DictUtils;
import com.nu.utils.RabbitMQUtil;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.DateUtils;
import org.jeecg.modules.base.service.BaseCommonService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
import java.util.*;
@ -39,6 +49,9 @@ public class OrgApplyInfoServiceImpl extends ServiceImpl<OrgApplyInfoMapper, Org
@Autowired
private RabbitMQUtil rabbitMQUtil;
@Autowired
private BaseCommonService baseCommonService;
@Override
public OrgApplyInfoApiEntity insert(OrgApplyInfoApiEntity orgApplyInfoApiEntity) {
OrgApplyInfo orgApplyInfo = new OrgApplyInfo();
@ -218,6 +231,10 @@ public class OrgApplyInfoServiceImpl extends ServiceImpl<OrgApplyInfoMapper, Org
orgApplyInfo.setModifyStatus("0");
//将机构的构建状态置为加盟合同
orgApplyInfo.setBuildStatus("3");
//推送机构信息变更申请消息小程序
sendOrgAuthInfo(orgApplyInfo.getOpenId(),orgApplyInfo.getId(),"1",orgApplyInfo.getComName());
}
//审批完成后的平台搭建流程合同上传并提交状态
if ("contractSubmit".equals(orgApplyInfo.getBuildStatus())) {
@ -225,12 +242,68 @@ public class OrgApplyInfoServiceImpl extends ServiceImpl<OrgApplyInfoMapper, Org
//将buildStatus置为平台搭建状态
orgApplyInfo.setBuildStatus("4");
}
//审核驳回
if(StringUtils.equals("3", orgApplyInfo.getStatus())){
//推送机构信息变更申请消息小程序
sendOrgAuthInfo(orgApplyInfo.getOpenId(),orgApplyInfo.getId(),"2",orgApplyInfo.getComName());
}
//机构加盟审批流程
baseMapper.updateById(orgApplyInfo);
}
}
//小程序订阅推送模板信息
public Result sendOrgAuthInfo(String openId, String id, String type, String comName){
try {
// 1. 获取access token
String accessToken = WechatMiniProgramUtils.getAccessToken();
// 2. 准备模板消息数据
String templateId = "CJ6NDNV4mTTyOdYhbksyA_YjDORVemJRmzEVAUZMBis";
String page = "pages/index/index"; // 点击消息跳转的页面
Map<String, Object> data = new HashMap<>();
String content = comName + "审核结果";
String auditStatus = "";
if(StringUtils.equals("1", type)){
auditStatus = "审核通过";
}else if(StringUtils.equals("2", type)){
auditStatus = "审核驳回";
}
data.put("thing5", content); // 对应模板中的字段
data.put("phrase6", auditStatus);
data.put("date2", DateUtils.now());
// 3. 发送模板消息
String resInfo = TemplateMessageSender.sendTemplateMessage( accessToken, openId, templateId, page, data);
if(com.alibaba.cloud.commons.lang.StringUtils.equals(resInfo,"error")){
baseCommonService.addLog("机构加盟审核,发送通知失败-发送消息异常56 " +resInfo, CommonConstant.LOG_TYPE_2, 1);
return Result.error("发送消息异常");
}
JSONObject jsonObject = new JSONObject(resInfo);
boolean success = jsonObject.getInt("errcode") == 0;
if (success) {
// OrgApplyInfo orgApplyInfo = new OrgApplyInfo();
// orgApplyInfo.setId(id);
// orgApplyInfo.setBuildStatus("6");
// baseMapper.updateById(orgApplyInfo);
System.out.println("模板消息发送成功");
baseCommonService.addLog("机构加盟审核,发送通知成功 " , CommonConstant.LOG_TYPE_2, 1);
return Result.ok("发送消息成功");
} else {
baseCommonService.addLog("机构加盟审核,发送通知失败-发送消息异常68 " +resInfo , CommonConstant.LOG_TYPE_2, 1);
System.out.println("模板消息发送失败");
return Result.error("发送消息异常");
}
} catch (Exception e) {
e.printStackTrace();
return Result.error("发送消息异常");
}
}
@Override
public void submitContract(OrgApplyInfo orgApplyInfo) {
//先保存数据 将构建状态置为平台搭建