mirror of
https://gitee.com/elegant_wings/dbd-meeting.git
synced 2025-06-21 17:09:36 +08:00
公众号模板消息推送
This commit is contained in:
parent
758e300281
commit
3468062706
@ -58,7 +58,7 @@ public class RepairController extends BaseController {
|
||||
@PostMapping("flow/start")
|
||||
public R startFlow(@RequestBody RepairDTO repairDTO) {
|
||||
Long userId = getLoginStaffId();
|
||||
if (!repairService.submitCheck(userId.toString())) return R.error("报修过于频繁,请稍后再试.");
|
||||
//if (!repairService.submitCheck(userId.toString())) return R.error("报修过于频繁,请稍后再试.");
|
||||
String result = repairService.handleFlow(repairDTO.getRepair(), userId, repairDTO.getFiles(), null, null);
|
||||
return IRepairService.OK.equals(result) ? R.ok() : R.error(result);
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class RepairRemind extends BaseEntity<RepairRemind> {
|
||||
private Date readTime;
|
||||
|
||||
/**
|
||||
* 扩展1
|
||||
* 扩展1 值 1,需要微信推送模板消息, 3 推送成功 5,推送失败
|
||||
*/
|
||||
private String ext1;
|
||||
|
||||
@ -76,4 +76,15 @@ public class RepairRemind extends BaseEntity<RepairRemind> {
|
||||
this.setCreateTime(createTime);
|
||||
}
|
||||
|
||||
public RepairRemind(Long repairId, Long userId, String content, Long createBy, Date createTime, String ext1) {
|
||||
this.typeId = 0;
|
||||
this.repairId = repairId;
|
||||
this.userId = userId;
|
||||
this.content = content;
|
||||
this.read = 0;
|
||||
this.setDeleteFlag(0);
|
||||
this.setCreateBy(createBy + "");
|
||||
this.setCreateTime(createTime);
|
||||
this.ext1 = ext1;
|
||||
}
|
||||
}
|
||||
|
@ -79,4 +79,11 @@ public interface IcsCustomerStaffMapper extends BaseMapper<IcsCustomerStaff> {
|
||||
|
||||
IcsCustomerStaff selectUserByMobileAndParkId(@Param("mobile") String phoneNumber, @Param("parkId") String parkId);
|
||||
|
||||
/**
|
||||
* 绑定用户的微信公众号openid
|
||||
* @param mobile 手机号
|
||||
* @param openid 微信公众号openid
|
||||
* @return
|
||||
*/
|
||||
int updateGzhOpenid(@Param("mobile") String mobile,@Param("openid") String openid);
|
||||
}
|
||||
|
@ -93,4 +93,17 @@ public interface RepairRemindMapper {
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteRepairRemindByIds(String[] ids);
|
||||
|
||||
/**
|
||||
* 获取待推送的提醒
|
||||
*/
|
||||
List<RepairRemind> getWxPushRepairRemind();
|
||||
|
||||
/**
|
||||
* 推送后更新提醒消息
|
||||
* @param state
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
int afterWxPush(@Param("state") String state, @Param("ids") List<Long> ids);
|
||||
}
|
@ -63,6 +63,7 @@ public interface IIcsCustomerStaffService extends IService<IcsCustomerStaff> {
|
||||
|
||||
/**
|
||||
* 检查手机号码是否唯一
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String checkMobileUnique(String mobile);
|
||||
@ -82,7 +83,7 @@ public interface IIcsCustomerStaffService extends IService<IcsCustomerStaff> {
|
||||
|
||||
List<IcsCustomerStaff> selectCustomerStaffList(IcsCustomerStaff icsCustomerStaff);
|
||||
|
||||
String importCustomerStaff(List<IcsCustomerStaff> userList,Long customerId);
|
||||
String importCustomerStaff(List<IcsCustomerStaff> userList, Long customerId);
|
||||
|
||||
List<IcsCustomerStaff> getUserList(IcsCustomerStaff customerStaff);
|
||||
|
||||
@ -92,7 +93,14 @@ public interface IIcsCustomerStaffService extends IService<IcsCustomerStaff> {
|
||||
|
||||
List<IcsCustomerStaff> selectUserListByType(String phone);
|
||||
|
||||
|
||||
/**
|
||||
* 绑定用户的微信公众号openid
|
||||
*
|
||||
* @param mobile 手机号
|
||||
* @param openid 微信公众号openid
|
||||
* @return
|
||||
*/
|
||||
int updateGzhOpenid(String mobile, String openid);
|
||||
|
||||
// IcsCustomerStaff selectUserByMobileAndParkId(String phoneNumber, String parkId);
|
||||
}
|
||||
|
@ -75,4 +75,18 @@ public interface IRepairRemindService {
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteRepairRemindByIds(String ids);
|
||||
|
||||
/**
|
||||
* 获取待推送微信公众号的提醒
|
||||
*/
|
||||
List<RepairRemind> getWxPushRepairRemind();
|
||||
|
||||
/**
|
||||
* 微信公众号推送后更新提醒消息
|
||||
*
|
||||
* @param success 推送成功的id
|
||||
* @param failed 推送失败的id
|
||||
* @return
|
||||
*/
|
||||
int afterWxPush(List<Long> success, List<Long> failed);
|
||||
}
|
||||
|
@ -351,4 +351,8 @@ public class IcsCustomerStaffServiceImpl extends ServiceImpl<IcsCustomerStaffMap
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateGzhOpenid(String mobile, String openid) {
|
||||
return icsCustomerStaffMapper.updateGzhOpenid(mobile, openid);
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
package com.ics.admin.service;
|
||||
package com.ics.admin.service.impl;
|
||||
|
||||
import com.ics.admin.domain.RepairHis;
|
||||
import com.ics.admin.domain.RepairHisLog;
|
||||
import com.ics.admin.mapper.RepairHisLogMapper;
|
||||
import com.ics.admin.mapper.RepairHisMapper;
|
||||
import com.ics.admin.service.IRepairHisService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -8,6 +8,7 @@ import com.ics.admin.service.IRepairRemindService;
|
||||
import com.ics.common.utils.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@ -117,4 +118,22 @@ public class RepairRemindServiceImpl implements IRepairRemindService {
|
||||
String[] idsArray = StrUtil.split(ids,",");
|
||||
return repairRemindMapper.deleteRepairRemindByIds(idsArray);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RepairRemind> getWxPushRepairRemind() {
|
||||
return repairRemindMapper.getWxPushRepairRemind();
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public int afterWxPush(List<Long> success, List<Long> failed) {
|
||||
int a = 0, b = 0;
|
||||
if (success != null && success.size() > 0) {
|
||||
a = repairRemindMapper.afterWxPush("3", success);
|
||||
}
|
||||
if (failed != null && failed.size() > 0) {
|
||||
b = repairRemindMapper.afterWxPush("5", failed);
|
||||
}
|
||||
return a + b;
|
||||
}
|
||||
}
|
||||
|
@ -218,61 +218,62 @@ public class RepairServiceImpl implements IRepairService {
|
||||
Date now = new Date();
|
||||
String remind = repair.getAddress() + "/" + repair.getFloor() + " " + repair.getRoom() + " / " + repair.getTypeName();
|
||||
if (from == 0) {//报修
|
||||
if (to == 1)
|
||||
if (to == 1) {
|
||||
//提醒派单员
|
||||
rList.add(new RepairRemind(0L, nextUser.getId(), String.format(repairRemindContent.getP1(), remind), currentUser.getId(), now));
|
||||
//提醒楼层管理员
|
||||
rList.add(new RepairRemind(0L, adminId, String.format(repairRemindContent.getFloor01(), remind), currentUser.getId(), now));
|
||||
rList.add(new RepairRemind(0L, nextUser.getId(), String.format(repairRemindContent.getP1(), remind), currentUser.getId(), now, "1"));
|
||||
//提醒楼层管理员
|
||||
rList.add(new RepairRemind(0L, adminId, String.format(repairRemindContent.getFloor01(), remind), currentUser.getId(), now, "1"));
|
||||
}
|
||||
if (to == 5)
|
||||
//提醒维修工
|
||||
rList.add(new RepairRemind(0L, nextUser.getId(), String.format(repairRemindContent.getW1(), remind), currentUser.getId(), now));
|
||||
rList.add(new RepairRemind(0L, nextUser.getId(), String.format(repairRemindContent.getW1(), remind), currentUser.getId(), now, "1"));
|
||||
} else if (from == 1) {//派单
|
||||
if (to == 5) {
|
||||
//提醒维修工
|
||||
rList.add(new RepairRemind(repair.getId(), nextUser.getId(), String.format(repairRemindContent.getW1(), remind), currentUser.getId(), now));
|
||||
rList.add(new RepairRemind(repair.getId(), nextUser.getId(), String.format(repairRemindContent.getW1(), remind), currentUser.getId(), now, "1"));
|
||||
//提醒发起人
|
||||
rList.add(new RepairRemind(repair.getId(), Long.valueOf(repair.getCreateBy()), String.format(repairRemindContent.getR15(), remind), currentUser.getId(), now));
|
||||
//提醒楼层管理员
|
||||
rList.add(new RepairRemind(repair.getId(), adminId, String.format(repairRemindContent.getFloor15(), remind), currentUser.getId(), now));
|
||||
rList.add(new RepairRemind(repair.getId(), adminId, String.format(repairRemindContent.getFloor15(), remind), currentUser.getId(), now, "1"));
|
||||
}
|
||||
if (to == 3) {
|
||||
//提醒管理员
|
||||
rList.add(new RepairRemind(repair.getId(), nextUser.getId(), String.format(repairRemindContent.getM1(), remind, StringUtils.isBlank(content) ? "" : content), currentUser.getId(), now));
|
||||
rList.add(new RepairRemind(repair.getId(), nextUser.getId(), String.format(repairRemindContent.getM1(), remind, StringUtils.isBlank(content) ? "" : content), currentUser.getId(), now, "1"));
|
||||
//提醒发起人
|
||||
rList.add(new RepairRemind(repair.getId(), Long.valueOf(repair.getCreateBy()), String.format(repairRemindContent.getR1(), remind), currentUser.getId(), now));
|
||||
rList.add(new RepairRemind(repair.getId(), Long.valueOf(repair.getCreateBy()), String.format(repairRemindContent.getR1(), remind), currentUser.getId(), now, "1"));
|
||||
}
|
||||
if (to == 11) {
|
||||
//提醒发起人
|
||||
rList.add(new RepairRemind(repair.getId(), Long.valueOf(repair.getCreateBy()), String.format(repairRemindContent.getR2(), remind, StringUtils.isBlank(content) ? "" : content), currentUser.getId(), now));
|
||||
//提醒楼层管理员
|
||||
rList.add(new RepairRemind(repair.getId(), adminId, String.format(repairRemindContent.getFloor111(), remind, StringUtils.isBlank(content) ? "" : content), currentUser.getId(), now));
|
||||
rList.add(new RepairRemind(repair.getId(), adminId, String.format(repairRemindContent.getFloor111(), remind, StringUtils.isBlank(content) ? "" : content), currentUser.getId(), now, "1"));
|
||||
}
|
||||
} else if (from == 3) {//重新派单
|
||||
//提醒派单员
|
||||
rList.add(new RepairRemind(repair.getId(), nextUser.getId(), String.format(repairRemindContent.getP2(), remind), currentUser.getId(), now));
|
||||
rList.add(new RepairRemind(repair.getId(), nextUser.getId(), String.format(repairRemindContent.getP2(), remind), currentUser.getId(), now, "1"));
|
||||
//提醒楼层管理员
|
||||
rList.add(new RepairRemind(repair.getId(), adminId, String.format(repairRemindContent.getFloor31(), remind), currentUser.getId(), now));
|
||||
rList.add(new RepairRemind(repair.getId(), adminId, String.format(repairRemindContent.getFloor31(), remind), currentUser.getId(), now, "1"));
|
||||
} else if (from == 5) {//修理工是否接收
|
||||
if (to == 1) {
|
||||
//提醒派单员
|
||||
rList.add(new RepairRemind(repair.getId(), nextUser.getId(), String.format(repairRemindContent.getP3(), remind, currentUser.getUsername(), StringUtils.isBlank(content) ? "" : content), currentUser.getId(), now));
|
||||
rList.add(new RepairRemind(repair.getId(), nextUser.getId(), String.format(repairRemindContent.getP3(), remind, currentUser.getUsername(), StringUtils.isBlank(content) ? "" : content), currentUser.getId(), now, "1"));
|
||||
//提醒发起人
|
||||
rList.add(new RepairRemind(repair.getId(), Long.valueOf(repair.getCreateBy()), String.format(repairRemindContent.getR3(), remind), currentUser.getId(), now));
|
||||
//提醒楼层管理员
|
||||
rList.add(new RepairRemind(repair.getId(), adminId, String.format(repairRemindContent.getFloor51(), remind, currentUser.getUsername()), currentUser.getId(), now));
|
||||
rList.add(new RepairRemind(repair.getId(), adminId, String.format(repairRemindContent.getFloor51(), remind, currentUser.getUsername()), currentUser.getId(), now, "1"));
|
||||
}
|
||||
if (to == 7) {
|
||||
//提醒发起人
|
||||
rList.add(new RepairRemind(repair.getId(), Long.valueOf(repair.getCreateBy()), String.format(repairRemindContent.getR4(), remind, nextUser.getUsername()), currentUser.getId(), now));
|
||||
//提醒楼层管理员
|
||||
rList.add(new RepairRemind(repair.getId(), adminId, String.format(repairRemindContent.getFloor57(), remind), currentUser.getId(), now));
|
||||
rList.add(new RepairRemind(repair.getId(), adminId, String.format(repairRemindContent.getFloor57(), remind), currentUser.getId(), now, "1"));
|
||||
}
|
||||
} else if (from == 7) {//修理反馈
|
||||
//提醒发起人
|
||||
rList.add(new RepairRemind(repair.getId(), Long.valueOf(repair.getCreateBy()), String.format(repairRemindContent.getR5(), remind), currentUser.getId(), now));
|
||||
//提醒楼层管理员
|
||||
String result = repair.getResolve() == 0 ? "未解决" : "已解决";
|
||||
rList.add(new RepairRemind(repair.getId(), adminId, String.format(repairRemindContent.getFloor79(), remind, result), currentUser.getId(), now));
|
||||
rList.add(new RepairRemind(repair.getId(), adminId, String.format(repairRemindContent.getFloor79(), remind, result), currentUser.getId(), now, "1"));
|
||||
}
|
||||
return rList;
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="deleteFlag" column="delete_flag" />
|
||||
<result property="icsCustomerId" column="ics_customer_id" />
|
||||
<result property="openid" column="openid" />
|
||||
<result property="gzhOpenid" column="gzh_openid" />
|
||||
<result property="avatar" column="avatar" />
|
||||
<result property="gender" column="gender" />
|
||||
<result property="status" column="status" />
|
||||
@ -38,7 +39,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectIcsCustomerStaffVo">
|
||||
SELECT id, username, mobile, create_by, create_time, update_by,name,photo,address,email,degree,urgent, update_time, delete_flag, ics_customer_id, openid, avatar, gender, status, park_id,card_no, visit_time,
|
||||
SELECT id, username, mobile, create_by, create_time, update_by,name,photo,address,email,degree,urgent, update_time, delete_flag, ics_customer_id, openid, gzh_openid, avatar, gender, status, park_id,card_no, visit_time,
|
||||
leave_time,visit_content,to_name,to_phone,to_customer,to_customer_id,data_type,park_id,tenant_id
|
||||
FROM ics_customer_staff
|
||||
</sql>
|
||||
@ -86,6 +87,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="deleteFlag != null ">delete_flag,</if>
|
||||
<if test="icsCustomerId != null ">ics_customer_id,</if>
|
||||
<if test="openid != null and openid != ''">openid,</if>
|
||||
<if test="gzhOpenid != null and gzhOpenid != ''">gzh_openid,</if>
|
||||
<if test="avatar != null and avatar != ''">avatar,</if>
|
||||
<if test="gender != null and gender != ''">gender,</if>
|
||||
<if test="status != null and status != ''">status,</if>
|
||||
@ -118,6 +120,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="deleteFlag != null ">#{deleteFlag},</if>
|
||||
<if test="icsCustomerId != null ">#{icsCustomerId},</if>
|
||||
<if test="openid != null and openid != ''">#{openid},</if>
|
||||
<if test="gzhOpenid != null and gzhOpenid != ''">#{gzhOpenid},</if>
|
||||
<if test="avatar != null and avatar != ''">#{avatar},</if>
|
||||
<if test="gender != null and gender != ''">#{gender},</if>
|
||||
<if test="status != null and status != ''">#{status},</if>
|
||||
@ -153,6 +156,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="deleteFlag != null ">delete_flag = #{deleteFlag},</if>
|
||||
<if test="icsCustomerId != null ">ics_customer_id = #{icsCustomerId},</if>
|
||||
<if test="openid != null and openid != ''">openid = #{openid},</if>
|
||||
<if test="gzhOpenid != null and gzhOpenid != ''">gzh_openid=#{gzhOpenid},</if>
|
||||
<if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
|
||||
<if test="gender != null and gender != ''">gender = #{gender},</if>
|
||||
<if test="status != null and status != ''">status = #{status},</if>
|
||||
@ -218,5 +222,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<include refid="selectIcsCustomerStaffVo"/> where mobile = #{mobile} and park_id = #{parkId}
|
||||
</select>
|
||||
|
||||
<!-- 绑定用户的微信公众号openid -->
|
||||
<update id="updateGzhOpenid">
|
||||
<![CDATA[
|
||||
update ics_customer_staff set gzh_openid= #{openid} where mobile = #{mobile} and delete_flag=0 and data_type is not null and data_type<>'1'
|
||||
]]>
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
@ -9,7 +9,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="addressId" column="address_id" />
|
||||
<result property="name" column="name" />
|
||||
<result property="bm" column="bm" />
|
||||
<result property="adminId" column="admin_Id" />
|
||||
<result property="adminId" column="admin_id" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="ext1" column="ext1" />
|
||||
<result property="ext2" column="ext2" />
|
||||
|
@ -129,4 +129,17 @@
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="getWxPushRepairRemind" parameterType="RepairRemind" resultMap="RepairRemindResult">
|
||||
<include refid="selectRepairRemindVo"/>
|
||||
where delete_flag=0 and ext1='1'
|
||||
</select>
|
||||
|
||||
<update id="afterWxPush">
|
||||
update ics_repair_remind set ext1 = #{state} where id in
|
||||
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
|
||||
</mapper>
|
@ -58,6 +58,9 @@ public class IcsCustomerStaff extends BaseEntity<IcsCustomerStaff> {
|
||||
/** 微信openid */
|
||||
private String openid;
|
||||
|
||||
/** 微信公众号openid */
|
||||
private String gzhOpenid;
|
||||
|
||||
/** 用户头像 */
|
||||
private String avatar;
|
||||
|
||||
|
@ -24,7 +24,7 @@ public class MyParkLineHandler implements TenantLineHandler {
|
||||
"sys_sn", "sys_user_role", "sys_dept", "ics_customer_contract_room", "ics_park", "ics_apply_room", "ics_customer_contract_refund_room", "ics_apply_park_file",
|
||||
"ics_apply_settle_file", "ics_apply_move_in_file", "ics_activity","ics_customer_staff","tb_customer_ticket","tb_reservation","tb_reservation_person",
|
||||
"tb_room_content","tb_room_item","tb_room_item_by_room","tb_room_serve_by_room","tb_room_serve","tb_equipment","tb_staff_customer",
|
||||
"tb_room_equipment","tb_room_record","tb_room_serve","tb_showroom","tb_showroom_record","tb_ticket","tb_user_equipment","tb_visitor_person","ics_repair","ics_repair_remind"
|
||||
"tb_room_equipment","tb_room_record","tb_room_serve","tb_showroom","tb_showroom_record","tb_ticket","tb_user_equipment","tb_visitor_person","ics_repair","ics_repair_remind","ics_repair_address_floor"
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -24,7 +24,7 @@ public class MyTenantLineHandler implements TenantLineHandler {
|
||||
"sys_sn", "sys_user_role", "ics_customer_contract_room", "ics_apply_room", "ics_customer_contract_refund_room", "ics_apply_park_file",
|
||||
"ics_apply_settle_file", "ics_apply_move_in_file", "ics_activity","ics_customer_staff","tb_customer_ticket","tb_reservation","tb_reservation_person",
|
||||
"tb_room_content","tb_room_item","tb_room_item_by_room","tb_room_serve_by_room","tb_room_serve","tb_equipment","tb_staff_customer",
|
||||
"tb_room_equipment","tb_room_record","tb_room_serve","tb_showroom","tb_showroom_record","tb_ticket","tb_user_equipment","tb_visitor_person","ics_repair","ics_repair_remind"
|
||||
"tb_room_equipment","tb_room_record","tb_room_serve","tb_showroom","tb_showroom_record","tb_ticket","tb_user_equipment","tb_visitor_person","ics_repair","ics_repair_remind","ics_repair_address_floor"
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,128 @@
|
||||
package com.ics.controller.mobile;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ics.admin.service.IIcsCustomerStaffService;
|
||||
import com.ics.common.utils.StringUtils;
|
||||
import com.ics.service.RepairRemindPushService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.wf.jwtp.annotation.Ignore;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
/**
|
||||
* 微信公众号openid 绑定手机号
|
||||
* created at 2024-9-7 12:17
|
||||
*
|
||||
* @author lujiang
|
||||
* @version 1.0.0
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/wxbind")
|
||||
public class WxBindController {
|
||||
|
||||
@Value("${webchatGZH.appid}")
|
||||
private String appid;
|
||||
|
||||
@Value("${webchatGZH.secret}")
|
||||
private String secret;
|
||||
|
||||
@Value("${webchatGZH.access}")
|
||||
private String access;
|
||||
|
||||
private static String html;
|
||||
|
||||
@Autowired
|
||||
private IIcsCustomerStaffService customerStaffService;
|
||||
|
||||
@Autowired
|
||||
private RepairRemindPushService repairRemindPushService;
|
||||
|
||||
|
||||
//微信公众号网页授权地址
|
||||
private final static String OAUTH2_URL = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=%s&redirect_uri=%s&response_type=code&scope=snsapi_base&state=sh0907#wechat_redirect";
|
||||
|
||||
private final static String OAUTH2_TOKEN = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code";
|
||||
|
||||
/**
|
||||
* 网页授权引导
|
||||
*/
|
||||
@Ignore
|
||||
@RequestMapping("/index")
|
||||
public void index(HttpServletResponse response) throws IOException {
|
||||
String redirectUrl = access + "/wxbind/page";
|
||||
String encodedUrl = URLEncoder.encode(redirectUrl, "UTF-8");
|
||||
String url = String.format(OAUTH2_URL, appid, encodedUrl);
|
||||
response.sendRedirect(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取公众号openid,返回输入手机号绑定页面
|
||||
*/
|
||||
@Ignore
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/page", produces = "text/html;charset=utf-8")
|
||||
public String page(String code, String state) {
|
||||
if (!"sh0907".equals(state)) return "";
|
||||
String url = String.format(OAUTH2_TOKEN, appid, secret, code);
|
||||
JSONObject result = SmallWxOkHttp.sendGet(url, null);
|
||||
String openid = result.getString("openid");
|
||||
String page = readHtml();
|
||||
String submitUrl = access + "/wxbind/bind";//绑定按钮的提交地址
|
||||
return String.format(page, submitUrl, openid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定手机号
|
||||
*
|
||||
* @param phone 手机号
|
||||
* @param openid 公众号openid
|
||||
* @return
|
||||
*/
|
||||
@Ignore
|
||||
@ResponseBody
|
||||
@PostMapping(value = "/bind", produces = "text/html;charset=utf-8")
|
||||
public String bind(String phone, String openid) {
|
||||
String resultHtml = "<html><body><h1>%s</h1></body></html>";
|
||||
int row = customerStaffService.updateGzhOpenid(phone, openid);
|
||||
return String.format(resultHtml, row > 0 ? "绑定成功" : "绑定失败");
|
||||
}
|
||||
|
||||
|
||||
@Ignore
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/send", produces = "text/html;charset=utf-8")
|
||||
public String send() {
|
||||
return repairRemindPushService.pushWxTemplateMsg()+"";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取绑定页面
|
||||
*/
|
||||
private static String readHtml() {
|
||||
if (StringUtils.isNotBlank(html)) return html;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
ClassPathResource resource = new ClassPathResource("phoneBind.html");
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(resource.getInputStream()))) {
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
sb.append(line);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
html = sb.toString();
|
||||
return html;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.ics.service;
|
||||
|
||||
public interface RepairRemindPushService {
|
||||
|
||||
/**
|
||||
* 发送微信模板消息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int pushWxTemplateMsg();
|
||||
|
||||
}
|
@ -0,0 +1,142 @@
|
||||
package com.ics.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ics.admin.domain.RepairRemind;
|
||||
import com.ics.admin.service.IIcsCustomerStaffService;
|
||||
import com.ics.admin.service.IRepairRemindService;
|
||||
import com.ics.common.core.domain.IcsCustomerStaff;
|
||||
import com.ics.common.utils.DateUtils;
|
||||
import com.ics.common.utils.StringUtils;
|
||||
import com.ics.controller.mobile.SmallWxOkHttp;
|
||||
import com.ics.service.RepairRemindPushService;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* created at 2024-9-7 22:42
|
||||
*
|
||||
* @author lujiang
|
||||
* @version 1.0.0
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Service
|
||||
public class RepairRemindPushServiceImpl implements RepairRemindPushService {
|
||||
@Autowired
|
||||
private IRepairRemindService repairRemindService;
|
||||
|
||||
@Autowired
|
||||
private IIcsCustomerStaffService customerStaffService;
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
|
||||
@Value("${webchatGZH.templateId}")
|
||||
private String templateId;
|
||||
|
||||
@Value("${webchatGZH.appid}")
|
||||
private String appid;
|
||||
|
||||
@Value("${webchatGZH.secret}")
|
||||
private String secret;
|
||||
|
||||
private final static String SEND_URL = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=%s";
|
||||
|
||||
private final static String WX_SMALL_APP_ID = "wxe043ce243cd9de5b"; //小程序id
|
||||
|
||||
private final static String WX_SMALL_APP_PAGE = "/pages/index/index"; //小程序页面
|
||||
|
||||
|
||||
private String getAccessToken() {
|
||||
String key = "webchatGZH";
|
||||
// 从缓存获取微信公众号 AccessToken
|
||||
String accessToken = redisTemplate.opsForValue().get(key);
|
||||
if (StringUtils.isBlank(accessToken)) {
|
||||
accessToken = SmallWxOkHttp.getAccessToken(appid, secret);
|
||||
redisTemplate.opsForValue().set(key, accessToken, 6000, TimeUnit.SECONDS);
|
||||
}
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int pushWxTemplateMsg() {
|
||||
String accessToken = getAccessToken();
|
||||
String url = String.format(SEND_URL, accessToken);
|
||||
List<RepairRemind> list = repairRemindService.getWxPushRepairRemind();
|
||||
List<Long> success = new ArrayList<>();
|
||||
List<Long> failed = new ArrayList<>();
|
||||
|
||||
for (RepairRemind repairRemind : list) {
|
||||
IcsCustomerStaff customerStaff = customerStaffService.selectIcsCustomerStaffById(repairRemind.getUserId());
|
||||
if (customerStaff == null || StringUtils.isBlank(customerStaff.getGzhOpenid())) {
|
||||
failed.add(repairRemind.getId());
|
||||
} else {
|
||||
String openid = customerStaff.getGzhOpenid();
|
||||
String time = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, repairRemind.getCreateTime());
|
||||
String content = repairRemind.getContent();
|
||||
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("touser", openid);
|
||||
param.put("template_id", templateId);
|
||||
param.put("touser", openid);
|
||||
|
||||
// JSONObject miniprogram = new JSONObject();
|
||||
// miniprogram.put("appid", WX_SMALL_APP_ID);
|
||||
// miniprogram.put("pagepath", WX_SMALL_APP_PAGE);
|
||||
// param.put("miniprogram", miniprogram);
|
||||
|
||||
|
||||
JSONObject dataTime = new JSONObject();
|
||||
dataTime.put("value", time);
|
||||
JSONObject msg = new JSONObject();
|
||||
msg.put("value", content);
|
||||
|
||||
JSONObject data = new JSONObject();
|
||||
data.put("time38", dataTime);
|
||||
data.put("thing37", msg);
|
||||
param.put("data", data);
|
||||
JSONObject result = send(url, JSON.toJSONString(param));
|
||||
if (result == null || result.getInteger("errcode") == null || result.getInteger("errcode") != 0) {
|
||||
failed.add(repairRemind.getId());
|
||||
} else {
|
||||
success.add(repairRemind.getId());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return repairRemindService.afterWxPush(success, failed);
|
||||
}
|
||||
|
||||
|
||||
private static JSONObject send(String url, String param) {
|
||||
OkHttpClient client = new OkHttpClient().newBuilder().build();
|
||||
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), param);
|
||||
Request request = new Request.Builder().post(body).url(url).build();
|
||||
Call call = client.newCall(request);
|
||||
//返回请求结果
|
||||
try {
|
||||
Response response = call.execute();
|
||||
String resultStr = response.body().string();
|
||||
System.out.println(resultStr);
|
||||
return JSON.parseObject(resultStr);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.ics.task;
|
||||
|
||||
import com.ics.common.utils.spring.SpringUtils;
|
||||
import com.ics.service.RepairRemindPushService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* created at 2024-9-8 0:07
|
||||
*
|
||||
* @author lujiang
|
||||
* @version 1.0.0
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@Service("repairRemindPushTask")
|
||||
public class RepairRemindPushTask {
|
||||
/**
|
||||
* 工单提醒推送公众号
|
||||
*/
|
||||
public void remindPush() {
|
||||
RepairRemindPushService repairRemindPushService = SpringUtils.getBean(RepairRemindPushService.class);
|
||||
int num = repairRemindPushService.pushWxTemplateMsg();
|
||||
log.info("推送公众号" + num + "个工单提醒");
|
||||
}
|
||||
}
|
@ -53,7 +53,7 @@ spring:
|
||||
enabled: true
|
||||
statViewServlet:
|
||||
enabled: true
|
||||
# 设置白名单,不填则允许所有访问
|
||||
# 设置白名单,不填则允许所有访问.
|
||||
allow:
|
||||
url-pattern: /monitor/druid/*
|
||||
filter:
|
||||
@ -72,8 +72,8 @@ dfs:
|
||||
#path: /Users/lihongyuan/IdeaProjects/saas-ics/ics/
|
||||
# domain: http://222.184.49.22:9227
|
||||
# path: D:/ruoyi/uploadPath
|
||||
domain: http://192.168.0.11:9227
|
||||
path: F:/ruoyi/uploadPath
|
||||
domain: http://127.0.0.1:9227
|
||||
path: E:/ruoyi/uploadPath
|
||||
|
||||
# 公众号配置(必填)
|
||||
wx:
|
||||
@ -142,3 +142,9 @@ weixin:
|
||||
key: CHANGYANGKONGGUhenanjianandianzi # APIv3密钥
|
||||
domain: https://api.mch.weixin.qq.com # 微信服务器地址
|
||||
notify-domain: http://b8pyta.natappfree.cc # 回调,自己的回调地址
|
||||
|
||||
webchatGZH: #微信公众号用户绑定及模板消息推送相关配置
|
||||
appid: wxf164eab7ad1d9075
|
||||
secret: 199fc64445882192ae798816d949be0d
|
||||
access: https://company.haxy.com.cn:4443/shoot-hand #pc后端访问地址
|
||||
templateId: 3VU7ZY8RgiR9hcPysc34y-S2PxKQU2JrIT8v_mhkuic #模板消息模板id
|
||||
|
@ -132,3 +132,9 @@ weixin:
|
||||
key: CHANGYANGKONGGUhenanjianandianzi # APIv3密钥
|
||||
domain: https://api.mch.weixin.qq.com # 微信服务器地址
|
||||
notify-domain: http://b8pyta.natappfree.cc # 回调,自己的回调地址
|
||||
|
||||
webchatGZH: #微信公众号用户绑定及模板消息推送相关配置
|
||||
appid: wxf164eab7ad1d9075
|
||||
secret: 199fc64445882192ae798816d949be0d
|
||||
access: https://company.haxy.com.cn:4443/shoot-hand #pc后端访问地址
|
||||
templateId: 3VU7ZY8RgiR9hcPysc34y-S2PxKQU2JrIT8v_mhkuic #模板消息模板id
|
@ -132,3 +132,9 @@ weixin:
|
||||
key: CHANGYANGKONGGUhenanjianandianzi # APIv3密钥
|
||||
domain: https://api.mch.weixin.qq.com # 微信服务器地址
|
||||
notify-domain: http://b8pyta.natappfree.cc # 回调,自己的回调地址
|
||||
|
||||
webchatGZH: #微信公众号用户绑定及模板消息推送相关配置
|
||||
appid: wx88c3ba1d01b33b8b
|
||||
secret: db375b6db9c7b87b1daa48375b45731e
|
||||
access: https://baoxiu.jsgdha.com/shoot-hand #pc后端访问地址
|
||||
templateId: 4jgtzPfyX546n5ZDPHbN69YSSFf8NSOQUDJuPb6bYwA #模板消息模板id
|
96
shoot-hand/ics-web/src/main/resources/phoneBind.html
Normal file
96
shoot-hand/ics-web/src/main/resources/phoneBind.html
Normal file
@ -0,0 +1,96 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh_CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>工作人员绑定</title>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.login {
|
||||
|
||||
height: 30.5rem;
|
||||
background-color: white;
|
||||
margin: 0rem;
|
||||
}
|
||||
|
||||
.login_top {
|
||||
color: white;
|
||||
border-radius: 0.5rem 0.5rem 0 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.login_top {
|
||||
color: dodgerblue;
|
||||
}
|
||||
|
||||
.login_bottom {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.login_bottom .input {
|
||||
width: 17.5rem;
|
||||
height: 2.5rem;
|
||||
margin-top: 5rem;
|
||||
padding-left: 0.6rem;
|
||||
border-radius: 0.6rem;
|
||||
border: 0.1rem solid silver;
|
||||
outline: none;
|
||||
color: reb(107, 107, 107);
|
||||
}
|
||||
|
||||
.login_bottom button {
|
||||
width: 18rem;
|
||||
height: 2.8rem;
|
||||
color: white;
|
||||
margin-top: 2rem;
|
||||
border-radius: 0.6rem;
|
||||
border: none;
|
||||
background: #3490bf;
|
||||
margin-top: 3.6rem;
|
||||
}
|
||||
|
||||
.login_bottom p span {
|
||||
margin-top: 2rem;
|
||||
color: red;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="box">
|
||||
<div class="login">
|
||||
<div class="login_top">
|
||||
<br/>
|
||||
<h2>绑定手机号</h2>
|
||||
</div>
|
||||
<div class="login_bottom">
|
||||
<form action="%s" method="post" id="frm">
|
||||
<input type="text" name="phone" id="phone" maxlength="11" class="input" placeholder="请输入手机号"/>
|
||||
<input type="hidden" name="openid" value="%s">
|
||||
</form>
|
||||
<button onclick="check()">绑定</button>
|
||||
<p>
|
||||
<span id="info"></span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
function check() {
|
||||
const phoneNumber = document.getElementById("phone").value;
|
||||
console.log(phoneNumber);
|
||||
const result=/^1\d{10}$/.test(phoneNumber);
|
||||
if(result){
|
||||
document.getElementById("frm").submit();
|
||||
}else{
|
||||
document.getElementById("info").innerText="手机号无效";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user