jyy
2021-01-09 30f2f276ca35cae2bde763c58719f05c572f415b
模板消息推送完善
6 files added
14 files modified
508 ■■■■■ changed files
zq-erp/src/main/java/com/matrix/component/rabbitmq/RabiitMqTemplate.java 1 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/config/RabbitMqConfig.java 8 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/core/tools/rr/GlueFactory.java 23 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/common/constance/AppConstance.java 20 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysProjServicesServiceImpl.java 20 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/bean/ShopWxtemplateMsg.java 89 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopWxtemplateMsgDao.java 2 ●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/MQTaskRouting.java 6 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/VipCreateTask.java 2 ●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/templateMsg/AppointmentSuccess.java 2 ●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/MsgDemo3.java 35 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/Task/TemplateMessageBulder.java 19 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/Task/UniformMsgSentTask.java 120 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/Task/messageBulderDemo/DefaultTemplateMessageBulder.java 99 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/TemplateNameConstance.java 15 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/config/application.properties 2 ●●● patch | view | raw | blame | history
zq-erp/src/main/resources/config/db/increment/20210109.sql 5 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/config/test/application.properties 9 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopWxtemplateMsgDao.xml 30 ●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/templates/views/admin/shop/templateMsg-list.html 1 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/component/rabbitmq/RabiitMqTemplate.java
@@ -84,6 +84,7 @@
                if (task != null) {
                    // 消息内容
                    if (StringUtils.isNotBlank(content)) {
                        LogUtil.info("本次发送消息task.getExchange()="+task.getExchange()+";routingKey="+routingKey+";content="+content);
                        channel.basicPublish(task.getExchange(), routingKey, false, null, content.getBytes());
                    } else {
                        LogUtil.info("本次发送空消息");
zq-erp/src/main/java/com/matrix/config/RabbitMqConfig.java
@@ -5,6 +5,7 @@
import com.matrix.component.rabbitmq.RabiitMqTemplate;
import com.matrix.component.rabbitmq.RabiitMqTemplateFactory;
import com.matrix.system.shopXcx.mqTask.*;
import com.matrix.system.wechart.templateMsg.Task.UniformMsgSentTask;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -48,6 +49,11 @@
        return new TemplateMsgTask();
    }
  @Bean
  UniformMsgSentTask UniformMsgSentTask(){
        return new UniformMsgSentTask();
    }
    @Bean
    OrderOutSotoreTask OrderOutSotoreTask(){
        return new OrderOutSotoreTask();
@@ -67,10 +73,10 @@
        //注册RabbitMq任务
        taskList.add(new MqTask(MQ_EXCHANGE_A + evn, MQTaskRouting.CREATE_VIP + evn, MQTaskRouting.CREATE_VIP + evn, VipCreateTask()));
        taskList.add(new MqTask(MQ_EXCHANGE_A + "cf", MQTaskRouting.CREATE_VIP + evn, MQTaskRouting.CREATE_VIP + evn, null));
        taskList.add(new MqTask(MQ_EXCHANGE_A + evn, MQTaskRouting.CREATE_ORDER + evn,MQTaskRouting.CREATE_ORDER + evn,OrderrCreateTask()));
        taskList.add(new MqTask(MQ_EXCHANGE_A + evn, MQTaskRouting.SEND_TEMPLATE_MSG + evn,MQTaskRouting.SEND_TEMPLATE_MSG + evn, TemplateMsgTask()));
        taskList.add(new MqTask(MQ_EXCHANGE_A + evn, MQTaskRouting.ORDER_OUT_SOTORE + evn,MQTaskRouting.ORDER_OUT_SOTORE + evn, OrderOutSotoreTask()));
        taskList.add(new MqTask(MQ_EXCHANGE_A + evn, MQTaskRouting.SEND_UNIFORM_TEMPLATE_MSG + evn,MQTaskRouting.SEND_UNIFORM_TEMPLATE_MSG + evn, UniformMsgSentTask()));
        rabiitMqTemplate.binding(taskList);
zq-erp/src/main/java/com/matrix/core/tools/rr/GlueFactory.java
@@ -104,4 +104,27 @@
        throw new IllegalArgumentException(">>>>>>>>>>> xxl-glue, loadNewInstance error, instance is null");
    }
    /**
     * 根据字符串获取几个java实例
     * @param codeSource
     * @return
     * @throws Exception
     */
    public Object loadInstance(String codeSource) throws Exception{
        if (codeSource!=null && codeSource.trim().length()>0) {
            Class<?> clazz = groovyClassLoader.parseClass(codeSource);
            if (clazz != null) {
                Object instance = clazz.newInstance();
                if (instance!=null) {
                    this.injectService(instance);
                    return  instance;
                }
            }
        }
        throw new IllegalArgumentException(">>>>>>>>>>> xxl-glue, loadNewInstance error, instance is null");
    }
}
zq-erp/src/main/java/com/matrix/system/common/constance/AppConstance.java
@@ -589,4 +589,24 @@
    public static final String QSFY = "QSFY";
    /**
     * 小程序APPID
     */
    public static final String MINIPROGRAM_APPID = "miniprogramAppid";
    /**
     * 小程序Secret
     */
    public static final String MINIPROGRAM_SECRET = "miniprogramSecret";
    /**
     * 公众号APPID
     */
    public static final String GZH_APPID = "gzhAppId";
}
zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysProjServicesServiceImpl.java
@@ -1,5 +1,7 @@
package com.matrix.system.hive.service.imp;
import com.alibaba.fastjson.JSONObject;
import com.matrix.component.rabbitmq.RabiitMqTemplate;
import com.matrix.core.constance.MatrixConstance;
import com.matrix.core.exception.GlobleException;
import com.matrix.core.pojo.PaginationVO;
@@ -16,9 +18,11 @@
import com.matrix.system.hive.plugin.util.MoneyUtil;
import com.matrix.system.hive.pojo.MyBeauticianCount;
import com.matrix.system.hive.service.*;
import com.matrix.system.shopXcx.mqTask.MQTaskRouting;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -97,6 +101,13 @@
    WarehouseDao warehouseDao;
    @Resource
    private ShoppingGoodsService shoppingGoodsService;
    @Autowired
    private RabiitMqTemplate rabiitMqTemplate;
    @Value("${evn}")
    private String evn;
    /**
     * 新增服务单 jyy
@@ -561,10 +572,15 @@
        if (!projServices.getState().equals(Dictionary.SERVICE_STATU_FWWC)) {
            throw new GlobleException("该服务单状态为" + projServices.getState() + ",不可以进行当前操作!");
        } else {
            projServices.setState(Dictionary.SERVICE_STATU_FFJS);
            projServices.setConsumeTime(new Date());
            return sysProjServicesDao.update(projServices);
            int result=sysProjServicesDao.update(projServices);
            //发送微信公众号提醒
            JSONObject param=new JSONObject();
            param.put("companyId",projServices.getCompanyId());
            param.put("serviceId",projServices.getId());
            rabiitMqTemplate.sendMsg(MQTaskRouting.SEND_UNIFORM_TEMPLATE_MSG+evn,param.toJSONString());
            return result;
        }
    }
zq-erp/src/main/java/com/matrix/system/shopXcx/bean/ShopWxtemplateMsg.java
@@ -40,8 +40,15 @@
     */
    private Integer status;
    /**
     * 模板类型 1,公众号,2,小程序
     */
    private Integer tempType;
    /**
     * 取数模板类
     */
    private String templateClass;
    /**
     * 模板备注
@@ -86,24 +93,76 @@
        }
    }
    public void buildDicMap(Object value) {
        if (value != null) {
            STATUS[] statusArray = STATUS.values();
            for (STATUS s : statusArray) {
                if (s.getCode().equals(value)) {
                    getDicMap().put("status", s.getName());
                }
            }
        }
    }
    public enum TempType {
        MP("公众号", 1),
        APP("小程序", 2);
        private TempType(String name, int code) {
            this.name = name;
            this.code = code;
        }
        private String name;
        private Integer code;
        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }
        public Integer getCode() {
            return code;
        }
        public void setCode(Integer code) {
            this.code = code;
        }
    }
    public void setStatus(Integer status) {
        buildDicMap(status);
        buildDicMap("status");
        if (status != null) {
            STATUS[] statusArray = STATUS.values();
            for (STATUS s : statusArray) {
                if (s.getCode().equals(status)) {
                    getDicMap().put("status", s.getName());
                }
            }
        }
        this.status = status;
    }
    public String getTemplateClass() {
        return templateClass;
    }
    public void setTemplateClass(String templateClass) {
        this.templateClass = templateClass;
    }
    public Integer getTempType() {
        return tempType;
    }
    public void setTempType(Integer tempType) {
        if (tempType != null) {
            TempType[] statusArray = TempType.values();
            for (TempType s : statusArray) {
                if (s.getCode().equals(tempType)) {
                    getDicMap().put("tempType", s.getName());
                }
            }
        }
        this.tempType = tempType;
    }
    public Integer getId() {
        return id;
zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopWxtemplateMsgDao.java
@@ -26,7 +26,7 @@
    
    public int deleteById(Integer id);
    public ShopWxtemplateMsg selectByCode(Integer code);
    public ShopWxtemplateMsg selectByCode(@Param("code") Integer code, @Param("companyId") Long companyId);
    public int deleteByModel(@Param("record") ShopWxtemplateMsg shopWxtemplateMsg);
    
zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/MQTaskRouting.java
@@ -12,6 +12,12 @@
     * 发送微信消息
     */
    String SEND_TEMPLATE_MSG = "SEND_TEMPLATE_MSG";
    /**
     * 发送小程序统一模板消息
     */
    String SEND_UNIFORM_TEMPLATE_MSG = "SEND_UNIFORM_TEMPLATE_MSG";
    /**
     * 订单出库
     */
zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/VipCreateTask.java
@@ -48,7 +48,7 @@
            } else {
                SysVipInfo vipInfo = new SysVipInfo();
                //在备注记下微商城的用户id
                vipInfo.setRemark(userInfo.getOpenId());
                vipInfo.setOpenId(userInfo.getOpenId());
                vipInfo.setAddr(userInfo.getProvince() + " " + userInfo.getCity());
                vipInfo.setPhone(userInfo.getPhoneNumber());
                if (userInfo.getGender() != null) {
zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/templateMsg/AppointmentSuccess.java
@@ -48,7 +48,7 @@
        SysShopInfo shopInfo = shopInfoDao.selectById(onlinebooking.getShopId());
        //获取模板id
        ShopWxtemplateMsg wxtemplateMsg = wxtemplateMsgDao.selectByCode(TemplateMsgType.APPOINTMENT_SUCCESS.getCode());
        ShopWxtemplateMsg wxtemplateMsg = wxtemplateMsgDao.selectByCode(TemplateMsgType.APPOINTMENT_SUCCESS.getCode(), 17L);
        String page = "pages/yuyue/yyInfo?id=" + orderId + "&model=1";
zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/MsgDemo3.java
New file
@@ -0,0 +1,35 @@
package com.matrix.system.wechart.templateMsg;
import com.alibaba.fastjson.JSONObject;
import com.matrix.component.tools.HttpClientUtil;
import com.matrix.core.pojo.AjaxResult;
import com.matrix.system.hive.plugin.util.HttpUtils;
import com.matrix.system.shopXcx.api.WeChatGzhApiTools;
import com.matrix.system.wechart.templateMsg.Task.UniformMsgSentTask;
import com.rabbitmq.client.Delivery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.io.IOException;
@Controller
@RequestMapping(value = "test3")
public class MsgDemo3 {
    @Autowired
    UniformMsgSentTask uniformMsgSentTask;
    @RequestMapping("/template")
    @ResponseBody
    public AjaxResult template() throws IOException {
        uniformMsgSentTask.handle(null,null);
        return AjaxResult.buildSuccessInstance("1");
    }
}
zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/Task/TemplateMessageBulder.java
New file
@@ -0,0 +1,19 @@
package com.matrix.system.wechart.templateMsg.Task;
import com.matrix.system.wechart.templateMsg.UniformMsgPojo;
import java.util.Map;
/**
 * 动态构建消息主体内容
 * @author jyy
 *
 */
public interface TemplateMessageBulder {
    /**
     *  * 返回的map中 如果包含错误消息用error属性来表示
     * @param param
     * @return
     */
    Map buildMsg(Map param);
}
zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/Task/UniformMsgSentTask.java
New file
@@ -0,0 +1,120 @@
package com.matrix.system.wechart.templateMsg.Task;
import com.alibaba.fastjson.JSONObject;
import com.matrix.biz.bean.BizUser;
import com.matrix.biz.service.BizUserService;
import com.matrix.component.tools.HttpClientUtil;
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.tools.LogUtil;
import com.matrix.core.tools.rr.GlueFactory;
import com.matrix.system.common.bean.BusParameterSettings;
import com.matrix.system.common.constance.AppConstance;
import com.matrix.system.common.dao.BusParameterSettingsDao;
import com.matrix.system.constance.Dictionary;
import com.matrix.system.hive.bean.SysProjServices;
import com.matrix.system.hive.bean.SysVipInfo;
import com.matrix.system.hive.dao.SysProjServicesDao;
import com.matrix.system.hive.dao.SysShopInfoDao;
import com.matrix.system.hive.dao.SysVipInfoDao;
import com.matrix.system.shopXcx.api.WeChatGzhApiTools;
import com.matrix.system.shopXcx.bean.ShopWxtemplateMsg;
import com.matrix.system.shopXcx.dao.ShopWxtemplateMsgDao;
import com.matrix.system.wechart.templateMsg.GzhTemplateMessagePojo;
import com.matrix.system.wechart.templateMsg.TemplateNameConstance;
import com.matrix.system.wechart.templateMsg.UniformMsgPojo;
import com.rabbitmq.client.DeliverCallback;
import com.rabbitmq.client.Delivery;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
 * 小程序统一消息模板消息发送提醒
 * @author jyy
 */
@Component
public class UniformMsgSentTask implements DeliverCallback {
    @Autowired
    private ShopWxtemplateMsgDao shopWxtemplateMsgDao;
    @Autowired
    private BusParameterSettingsDao busParameterSettingsDao;
    /**
     * 发送模板消息需要传JSONO字符串作为格式
     * 例如:{"companyId":17}
     * companyId 是必须属性
     * @param consumerTag
     * @param message
     * @throws IOException
     */
    @Override
    public void handle(String consumerTag, Delivery message) throws IOException {
        try {
            String messages = new String(message.getBody(), "UTF-8");
            JSONObject messageJsonParam=JSONObject.parseObject(messages);
            if(!messageJsonParam.containsKey("companyId")){
                LogUtil.error("小程序消息推送参数格式异常发送模板消息需要传JSONO字符串作为格式 例如:{\"companyId\":17} companyId 是必须属性");
                return;
            }
            Long companyId = Long.parseLong( messageJsonParam.get("companyId").toString());
            //获取公司微信配置参数
            BusParameterSettings xcxAppId = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.MINIPROGRAM_APPID, companyId);
            BusParameterSettings xcxSecret = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.MINIPROGRAM_SECRET, companyId);
            BusParameterSettings gzhAppid = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.GZH_APPID, companyId);
            //获取消息模板
            ShopWxtemplateMsg template = shopWxtemplateMsgDao.selectByCode(TemplateNameConstance.GZH_YYTX,companyId);
            //校验参数
            if(xcxAppId==null||xcxSecret==null||gzhAppid==null||template==null){
                LogUtil.error("小程序消息推送配置缺失xcxAppId="+xcxAppId+";xcxSecret="+xcxSecret+";gzhAppid="+gzhAppid+";template="+template);
                return;
            }
            //获取模板动态构建类
            TemplateMessageBulder templateMessageBulder = (TemplateMessageBulder) GlueFactory.getInstance().loadInstance(template.getTemplateClass());
            //为模板动态类装备必要的参数
            Map<String, Object> bulderParam = new HashedMap();
            bulderParam.put("gzhAppid", gzhAppid.getParamValue());
            bulderParam.put("template_id", template.getUuid());
            bulderParam.put("messageJsonParam", messageJsonParam);
            //调用模板计算出消息体
            Map msgResult = templateMessageBulder.buildMsg(bulderParam);
            if(msgResult.containsKey("error")){
                //错误消息处理
                LogUtil.error("模板消息发送失败:"+msgResult.get("error"));
                return;
            }else{
                //正常返回消息
                List msgList = (List) msgResult.get("msgList");
                //获取acceToken
                String ACCESS_TOKEN = WeChatGzhApiTools.getAccessToken(xcxAppId.getParamValue(), xcxSecret.getParamValue());
                String url = "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token=ACCESS_TOKEN".replaceAll("ACCESS_TOKEN", ACCESS_TOKEN);
                for (Object msg : msgList) {
                    UniformMsgPojo uniformMsgPojo = (UniformMsgPojo) msg;
                    //推送消息到微信
                    JSONObject result = HttpClientUtil.sendPostWithJson(url, JSONObject.toJSON(uniformMsgPojo).toString());
                    //微信返回值
                    LogUtil.debug("微信小程序模板消息推送结果:" + result.toString());
                }
            }
        } catch (Exception e) {
            LogUtil.error("消费者执行异常", e);
        }
    }
}
zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/Task/messageBulderDemo/DefaultTemplateMessageBulder.java
New file
@@ -0,0 +1,99 @@
package com.matrix.system.wechart.templateMsg.Task.messageBulderDemo;
import com.alibaba.fastjson.JSONObject;
import com.matrix.biz.bean.BizUser;
import com.matrix.biz.dao.BizUserDao;
import com.matrix.core.tools.DateUtil;
import com.matrix.core.tools.StringUtils;
import com.matrix.system.hive.bean.SysBeauticianState;
import com.matrix.system.hive.bean.SysProjServices;
import com.matrix.system.hive.bean.SysVipInfo;
import com.matrix.system.hive.dao.SysBeauticianStateDao;
import com.matrix.system.hive.dao.SysProjServicesDao;
import com.matrix.system.hive.dao.SysVipInfoDao;
import com.matrix.system.wechart.templateMsg.GzhTemplateMessagePojo;
import com.matrix.system.wechart.templateMsg.Task.TemplateMessageBulder;
import com.matrix.system.wechart.templateMsg.UniformMsgPojo;
import io.swagger.models.auth.In;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * 某个公司客户的定制消息模板
 */
@Component
public class DefaultTemplateMessageBulder implements TemplateMessageBulder {
    @Autowired
    SysProjServicesDao projServicesDao;
    @Autowired
    SysVipInfoDao vipInfoDao;
    @Autowired
    private SysBeauticianStateDao beauticianStateDao;
    @Override
    public Map buildMsg(Map param) {
        //返回参数
        Map builParam=new HashedMap();
        //获取基础公共参数
        String gzhAppid= (String) param.get("gzhAppid");
        String template_id= (String) param.get("template_id");
        //触发点传送的json参数
        JSONObject messageJsonParam= (JSONObject) param.get("messageJsonParam");
        Long serviceId= (Long) messageJsonParam.get("serviceId");
        //构建消息主体
        SysProjServices sysProjServices = projServicesDao.selectById(serviceId);
        //补充服务单扩展信息===============
        List<SysBeauticianState> beauticianStateList = beauticianStateDao.selectBySerIds(sysProjServices.getId());
        SysVipInfo vipInfo=vipInfoDao.selectById(sysProjServices.getVipId());
        String touser= vipInfo.getOpenId();
        if(StringUtils.isBlank(touser)){
            builParam.put("error","未获取到"+vipInfo.getVipName()+"用户小程序openid");
            return builParam;
        }
        String time= DateUtil.dateFormatStr(sysProjServices.getConsumeTime(),DateUtil.DATE_FORMAT_MM);
        List msgList=new ArrayList();
        //如果一个项目存在多个护理项目则发送多次消息
        for (SysBeauticianState beauticianState:beauticianStateList){
            UniformMsgPojo uniformMsgPojo=new UniformMsgPojo();
            GzhTemplateMessagePojo messagePojo=new GzhTemplateMessagePojo();
            uniformMsgPojo.setTouser(touser);
            messagePojo.setTemplate_id(template_id);
            messagePojo.setAppid(gzhAppid);
            //个性参数设置
            Integer suplerTimes= beauticianState.getProjUse().getSurplusCount();
            messagePojo.setFirst("尊敬的:"+vipInfo.getVipName(),"#453454");
            messagePojo.setKeyWord(beauticianState.getProjInfo().getName(),"#453454");
            messagePojo.setKeyWord(time,"#453454");
            messagePojo.setRemark("您的护理项目剩余"+suplerTimes+"次。","#453454");
            uniformMsgPojo.setMp_template_msg(messagePojo);
            msgList.add(uniformMsgPojo);
        }
        builParam.put("msgList",msgList);
        return builParam;
    }
}
zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/TemplateNameConstance.java
New file
@@ -0,0 +1,15 @@
package com.matrix.system.wechart.templateMsg;
/**
 * 模板code定义常量
 * @author  jyy
 */
public interface TemplateNameConstance {
      /**
       * 公众号预约提醒
       */
      Integer GZH_YYTX=10000;
}
zq-erp/src/main/resources/config/application.properties
@@ -1,4 +1,4 @@
evn=dev
evn=devbb
server.port=8080
zq-erp/src/main/resources/config/db/increment/20210109.sql
New file
@@ -0,0 +1,5 @@
ALTER TABLE `shop_wxtemplate_msg`
ADD COLUMN `temp_type`  int(2) NULL COMMENT ' 模板类型 1,公众号,2,小程序' AFTER `code`,
ADD COLUMN `template_class`  longtext NULL COMMENT '取数模板类' AFTER `temp_type`;
zq-erp/src/main/resources/config/test/application.properties
@@ -1,12 +1,13 @@
evn=dev
evn=tyytest
server.port=8080
#线上测试环境
spring.datasource.username=chuhuan
spring.datasource.password=chuhuan
spring.datasource.url=jdbc:mysql://119.3.52.84:3306/hive_plus_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&transformedBitIsBoolean=true&serverTimezone=GMT%2B8
spring.datasource.username=ct_test
spring.datasource.password=123456
spring.datasource.url=jdbc:mysql://120.27.238.55:3306/hive_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&transformedBitIsBoolean=true&serverTimezone=GMT%2B8
zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopWxtemplateMsgDao.xml
@@ -16,6 +16,8 @@
            <result property="remark" column="remark" />
            <result property="companyId" column="company_id" />
            <result property="code" column="code" />
            <result property="tempType" column="temp_type" />
            <result property="templateClass" column="template_class" />
    </resultMap>
    
@@ -32,6 +34,8 @@
            <result property="remark" column="remark" />
            <result property="companyId" column="company_id" />
        <result property="code" column="code" />
        <result property="tempType" column="temp_type" />
        <result property="templateClass" column="template_class" />
    </resultMap>
    
    <!-- 字段sql -->
@@ -46,7 +50,9 @@
            status,
            remark,
            company_id,
            code
            code,
            temp_type,
            template_class
    </sql>
    
    <!-- 属性sql -->
@@ -61,9 +67,10 @@
            #{item.status},
            #{item.remark},
            #{item.companyId},
            #{item.code}
            #{item.code},
            #{item.tempType},
            #{item.templateClass}
    </sql>
    <!-- where sql -->
    <sql id="where_sql">
         
@@ -86,6 +93,12 @@
            <if test="(record.companyId!=null and record.companyId!='') or  (record.companyId!='' and record.companyId==0)  ">
                and company_id  = #{record.companyId} 
            </if>
                <if test="(record.tempType!=null and record.tempType!='') or  (record.tempType!='' and record.tempType==0)  ">
                and tempType  = #{record.tempType}
            </if>
        </if>
         
    </sql>
@@ -140,6 +153,10 @@
            <if test="_parameter.containsKey('code')">
                code = #{code},
            </if>
            <if test="_parameter.containsKey('temp_type')">
                temp_type = #{tempType},
            </if>
        </set>
        WHERE id=#{id} 
    </update> 
@@ -167,6 +184,11 @@
            <if test="record.code != null and record.code != '' ">
                code  = #{record.code},
            </if>
            <if test="record.tempType != null and record.tempType != '' ">
                temp_type  = #{record.tempType},
            </if>
        </set>
        WHERE id=#{record.id} 
    </update>
@@ -248,7 +270,7 @@
        select
        <include refid="columns" ></include>
        from shop_wxtemplate_msg
        where  code=#{code}
        where  code=#{code} and company_id=#{companyId}
    </select>
zq-erp/src/main/resources/templates/views/admin/shop/templateMsg-list.html
@@ -86,6 +86,7 @@
                    <th data-field="name">名称</th>
                    <th data-field="uuid">模板ID</th>
                    <th data-field="dicMap.status">是否启用</th>
                    <th data-field="dicMap.tempType">模板类型</th>
                    <th data-field="remark">备注</th>
                </tr>
                </thead>