| @@ -91,6 +91,21 @@ public class WxMsgController extends BaseController { | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("推送模板") | |||
| @PostMapping("pushTemp") | |||
| @SystemControllerLog(description = "moban tuisong") | |||
| public ResultData pushTemp(@RequestBody WxTemplateMsg wxTemplateMsg) { | |||
| logger.debug("[" + getIpAddr() + "] WxMsgController::tuisong"); | |||
| if(wxTemplateMsg.getId() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| wxTemplateMsg.updateTenantInfo(getTenantInfo()); | |||
| // if(null == wxTemplateMsg.getOnOff()){ | |||
| // wxTemplateMsg.setOnOff(1); | |||
| // } | |||
| return wxTemplateMsgService.pushTemp(wxTemplateMsg); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| @SystemControllerLog(description = "标签短信-新增") | |||
| @@ -359,6 +359,7 @@ public enum ErrorCode{ | |||
| TEMPLATE_NOT_FOUND(12090, "模板不存在"), | |||
| TEMPLATE_FORMID_NOT_FOUND(12091, "formId不存在"), | |||
| TEMPLATE_DATA_ERROR(12092, "数据格式错误"), | |||
| TEMPLATE_ADD_ERROR(12093, "添加模板错误"), | |||
| /** | |||
| * | |||
| @@ -7,16 +7,16 @@ public enum EnumTemplateType { | |||
| // 1-核销成功消息, 2-核销失败消息 | |||
| VERIFY_SUCCESS(1, "核销成功消息"), // 小程序 | |||
| VERIFY_FAIL(2, "核销失败消息"), // 小程序 | |||
| PRESS_SUCCESS(3, "砍价成功消息"), // 小程序 | |||
| VERIFY_SUCCESS(1, "核销成功消息",""), // 小程序 | |||
| VERIFY_FAIL(2, "核销失败消息",""), // 小程序 | |||
| PRESS_SUCCESS(3, "砍价成功消息",""), // 小程序 | |||
| ACTIVITY_REMIND(4, "活动开始提醒"), // 小程序 | |||
| LIVE_REMIND(5, "直播开播提醒"), // 小程序 | |||
| ACTIVITY_REMIND(4, "活动开始提醒","386"), // 小程序 | |||
| LIVE_REMIND(5, "直播开播提醒","8501"), // 小程序 | |||
| AUDIT_MESSAGE(101, "公众号审核结果通知"), // 公众号 | |||
| VERIFY_RESULT(102, "公众号卡券核销通知"), // 公众号 | |||
| GIFT_MESSAGE(103, "公众号购票成功通知"), // 公众号 | |||
| AUDIT_MESSAGE(101, "公众号审核结果通知",""), // 公众号 | |||
| VERIFY_RESULT(102, "公众号卡券核销通知",""), // 公众号 | |||
| GIFT_MESSAGE(103, "公众号购票成功通知",""), // 公众号 | |||
| ; | |||
| public static EnumTemplateType getEnum(Integer code) { | |||
| @@ -30,10 +30,12 @@ public enum EnumTemplateType { | |||
| private Integer code; | |||
| private String message; | |||
| private String tid; | |||
| EnumTemplateType(Integer code, String message) { | |||
| EnumTemplateType(Integer code, String message, String tid) { | |||
| this.code = code; | |||
| this.message = message; | |||
| this.tid = tid; | |||
| } | |||
| public Integer getCode() { | |||
| @@ -43,4 +45,8 @@ public enum EnumTemplateType { | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| public String getTid() { | |||
| return tid; | |||
| } | |||
| } | |||
| @@ -1,6 +1,7 @@ | |||
| package com.iformall.service; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxTemplateMsg; | |||
| import java.util.List; | |||
| @@ -56,12 +57,7 @@ public interface WxTemplateMsgService { | |||
| * @param id | |||
| */ | |||
| void deleteById(Long id); | |||
| ResultData pushTemp(WxTemplateMsg wxTemplateMsg); | |||
| } | |||
| @@ -28,6 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.scheduling.annotation.Async; | |||
| import org.springframework.stereotype.Service; | |||
| import java.text.DateFormat; | |||
| import java.util.*; | |||
| import java.util.stream.Collectors; | |||
| @@ -128,6 +129,8 @@ public class WxMsgServiceImpl implements WxMsgService { | |||
| //是否立即发送 | |||
| if (wxMsg.getIsright().equals(EnumMsgSend.MSG_SEND_IMMEDIATELY.getCode())) { | |||
| wxMsg.setStatus(EnumMsgStatus.MSG_STATUS_SENDED.getCode()); | |||
| String systemTime = DateUtils.getSystemTime("yyyy-MM-dd HH:mm:ss"); | |||
| wxMsg.setSendtime(systemTime); | |||
| if(wxMsg.getWay() == EnumSendWay.TAG.getCode()){ | |||
| if (wxMsg.getExpectSendNumber().intValue() > 1000) { | |||
| batchSendMsg(wxMsg, wxMsgConfig, null); | |||
| @@ -1,12 +1,24 @@ | |||
| package com.iformall.service.impl; | |||
| import cn.binarywang.wx.miniapp.api.WxMaService; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.google.common.collect.Lists; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.WxTemplateMsg; | |||
| import com.iformall.enums.EnumPayWay; | |||
| import com.iformall.enums.EnumTemplateType; | |||
| import com.iformall.mapper.WxTemplateMsgMapper; | |||
| import com.iformall.service.WxAppinfoService; | |||
| import com.iformall.service.WxTemplateMsgService; | |||
| import com.iformall.service.wechat.FmOpenService; | |||
| import com.iformall.utils.MaUtil; | |||
| import me.chanjar.weixin.common.error.WxErrorException; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -22,6 +34,14 @@ public class WxTemplateMsgServiceImpl implements WxTemplateMsgService { | |||
| @Autowired | |||
| WxTemplateMsgMapper wxTemplateMsgMapper; | |||
| @Autowired | |||
| private boolean isFmOpen; | |||
| @Autowired | |||
| private WxAppinfoService wxAppinfoService; | |||
| @Autowired | |||
| private FmOpenService openService; | |||
| @Override | |||
| public void wxTemplateMsgInit(String tenantId) { | |||
| @@ -85,12 +105,46 @@ public class WxTemplateMsgServiceImpl implements WxTemplateMsgService { | |||
| public void deleteById(Long id) { | |||
| wxTemplateMsgMapper.deleteById(id); | |||
| } | |||
| @Override | |||
| public ResultData pushTemp(WxTemplateMsg wxTemplateMsg) { | |||
| WxTemplateMsg byId = this.getById(wxTemplateMsg.getId()); | |||
| if(byId == null){ | |||
| return new ResultData(ErrorCode.TEMPLATE_NOT_FOUND); | |||
| } | |||
| WxAppinfo appinfo = wxAppinfoService.getCAppInfo(wxTemplateMsg, EnumPayWay.PAY_WAY_WECHAT); | |||
| WxMaService wxMaService = null; | |||
| if(isFmOpen) { | |||
| wxMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appinfo.getAppId()); | |||
| } else { | |||
| WxAppinfo appInfo = wxAppinfoService.getByAppId(appinfo.getAppId()); | |||
| wxMaService = MaUtil.getWeappService(appInfo); | |||
| } | |||
| String s = ""; | |||
| if(byId.getType() == EnumTemplateType.ACTIVITY_REMIND.getCode()){ | |||
| try { | |||
| s = wxMaService.getSubscribeService().addTemplate(EnumTemplateType.ACTIVITY_REMIND.getTid(), | |||
| Lists.newArrayList(13, 5, 12, 1, 11), ""); | |||
| } catch (WxErrorException e) { | |||
| return new ResultData(ErrorCode.TEMPLATE_ADD_ERROR); | |||
| } | |||
| }else if(byId.getType() == EnumTemplateType.LIVE_REMIND.getCode()){ | |||
| try { | |||
| s = wxMaService.getSubscribeService().addTemplate(EnumTemplateType.LIVE_REMIND.getTid(), | |||
| Lists.newArrayList(1, 3, 4, 5),""); | |||
| } catch (WxErrorException e) { | |||
| return new ResultData(ErrorCode.TEMPLATE_ADD_ERROR); | |||
| } | |||
| } | |||
| if(StringUtils.isBlank(s)){ | |||
| return new ResultData(ErrorCode.TEMPLATE_ADD_ERROR); | |||
| } | |||
| byId.setTemplateId(s); | |||
| this.saveOrUpdate(byId); | |||
| return new ResultData(); | |||
| } | |||
| } | |||
| @@ -22,7 +22,7 @@ | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| distinct cc.`id`,cc.`tenant_id`,cc.`parent_tenant_id`,cc.`coupon_id`,cc.`coupon_status`,cc.`type`,cc.`title`,cc.`target_ad`,cc.`business`,cc.`sub_business`,cc.`begin_time`,cc.`end_time`,cc.`status`,cc.`create_date`,cc.`update_date`,cc.`sub_target_id`,cc.qr_code | |||
| distinct cc.`id`,cc.`tenant_id`,cc.`parent_tenant_id`,cc.`coupon_id`,cc.`coupon_status`,cc.`type`,cc.`title`,cc.`target_ad`,cc.`business`,cc.`sub_business`,cc.`show_begin_time`,cc.`begin_time`,cc.`end_time`,cc.`status`,cc.`create_date`,cc.`update_date`,cc.`sub_target_id`,cc.qr_code | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -175,6 +175,7 @@ | |||
| <result column="title" jdbcType="VARCHAR" property="title" /> | |||
| <result column="target_ad" jdbcType="INTEGER" property="targetAd" /> | |||
| <result column="business" jdbcType="VARCHAR" property="business" /> | |||
| <result column="show_begin_time" jdbcType="TIMESTAMP" property="showBeginTime" /> | |||
| <result column="sub_business" jdbcType="INTEGER" property="subBusiness" /> | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||