瀏覽代碼

公众号消息模板管理

jk-GitHub-coder 4 年之前
父節點
當前提交
76d559ef69

+ 30 - 4
YijiaRestful/src/main/java/com/platform/yijia/controller/IntegralShoppingMallController.java

@@ -51,6 +51,8 @@ public class IntegralShoppingMallController {
     private IntegralRuleService integralRuleService;
     @Resource
     private IntegralShopPicService integralShopPicService;
+    @Resource
+    private GzhNewsTemplateService gzhNewsTemplateService;
 
     //获取积分商城轮播图片
     @RequestMapping(value = "/getIntegralShopPicInfoList", method = RequestMethod.GET)
@@ -223,10 +225,15 @@ public class IntegralShoppingMallController {
                             wxMpTemplate.add(new WxMpTemplateData("keyword5", orderSumIntegral));
                             wxMpTemplate.add(new WxMpTemplateData("remark",
                                     "截止至" + new SimpleDateFormat(" yyyy年MM月dd日HH时mm分").format(new Date())+",您在"+stationName+"的积分值还剩余 "+surplusPoints+" 分"));
-                            String templateId = "9EWrreI-P8r4xDgoOcczC4jHt1v0HEjKzkgVRDzoNXA";  //积分兑换成功通知模板
-                            wxPushUtil.push(gzhAppId, gzhAppSecret, templateId, request.getOpenId(), wxMpTemplate);
-                            resultData=ResultData.success(CodeMsg.SUCCESS);
-
+                            //String templateId = "9EWrreI-P8r4xDgoOcczC4jHt1v0HEjKzkgVRDzoNXA";  //积分兑换成功通知模板
+                            GzhNewsTemplate gzhNewsTemplate = new GzhNewsTemplate();
+                            gzhNewsTemplate.setStationId(request.getStationId());
+                            gzhNewsTemplate.setTemplateType("2");
+                            GzhNewsTemplate gzhNewsTemplateInfo = gzhNewsTemplateService.getGzhNewsTemplate(gzhNewsTemplate);
+                            if(gzhNewsTemplateInfo !=null && gzhNewsTemplateInfo.getTemplateId() !=null){
+                                wxPushUtil.push(gzhAppId, gzhAppSecret, gzhNewsTemplateInfo.getTemplateId(), request.getOpenId(), wxMpTemplate);
+                                resultData=ResultData.success(CodeMsg.SUCCESS);
+                            }
                             //打印机打印小票
                             List<Map<String, Object>> stationPrinterList = stationService.getStationPrinterList(request.getStationId());
                             if(stationPrinterList != null && stationPrinterList.get(0).get("integralPrintFlag").toString().equals("1")){
@@ -268,6 +275,25 @@ public class IntegralShoppingMallController {
         return gson.toJson(resultData);
     }
 
+    //获取公众号消息模板
+//    @RequestMapping(value = "/getGzhNewsTemplate", method = RequestMethod.GET)
+//    @ResponseBody
+//    public String getGzhNewsTemplate(@RequestParam Integer stationId, String templateType){
+//        Gson gson =new Gson();
+//        //返回结果集
+//        ResultData resultData = null;
+//        if(stationId !=null){
+//            GzhNewsTemplate gzhNewsTemplate = new GzhNewsTemplate();
+//            gzhNewsTemplate.setStationId(stationId);
+//            gzhNewsTemplate.setTemplateType(templateType);
+//            GzhNewsTemplate gzhNewsTemplate1 = gzhNewsTemplateService.getGzhNewsTemplate(gzhNewsTemplate);
+//            resultData=ResultData.success(gzhNewsTemplate1);
+//        }else {
+//            resultData=ResultData.success(CodeMsg.REQUEST_FAIL);
+//        }
+//        return gson.toJson(resultData);
+//    }
+
     //获取用户积分订单列表
     @RequestMapping(value = "/getUserIntegralOrderList", method = RequestMethod.GET)
     @ResponseBody

+ 11 - 2
YijiaRestful/src/main/java/com/platform/yijia/controller/PayController.java

@@ -48,6 +48,8 @@ public class PayController {
     private RedisCacheUtil redisCacheUtil;
     @Resource
     private WxPushUtil wxPushUtil;
+    @Resource
+    private GzhNewsTemplateService gzhNewsTemplateService;
 
     /***
      * 微信子商户支付接口
@@ -1099,8 +1101,15 @@ public class PayController {
                     wxMpTemplate.add(new WxMpTemplateData("From", stationName));
                     wxMpTemplate.add(new WxMpTemplateData("remark",
                             "截止至" + new SimpleDateFormat(" yyyy年MM月dd日HH时mm分").format(new Date())+",您在"+stationName+"的可用积分为 "+surplusIntegral.toString()+" 分"));
-                    String templateId = "G9tN--a3tGM5BN3otqZr73b4ErQCYWISSgyshbTqLYc";  //积分兑换成功通知模板
-                    wxPushUtil.push(gzhAppId, gzhAppSecret, templateId, blogOpenId, wxMpTemplate);  //oJR5R6r4EJhaORFcPap70r_mtFZo
+//                    String templateId = "G9tN--a3tGM5BN3otqZr73b4ErQCYWISSgyshbTqLYc";  //积分兑换成功通知模板
+//                    wxPushUtil.push(gzhAppId, gzhAppSecret, templateId, blogOpenId, wxMpTemplate);  //oJR5R6r4EJhaORFcPap70r_mtFZo
+                    GzhNewsTemplate gzhNewsTemplate = new GzhNewsTemplate();
+                    gzhNewsTemplate.setStationId(stationId);
+                    gzhNewsTemplate.setTemplateType("1");
+                    GzhNewsTemplate gzhNewsTemplateInfo = gzhNewsTemplateService.getGzhNewsTemplate(gzhNewsTemplate);
+                    if(gzhNewsTemplateInfo !=null && gzhNewsTemplateInfo.getTemplateId() !=null){
+                        wxPushUtil.push(gzhAppId, gzhAppSecret, gzhNewsTemplateInfo.getTemplateId(), blogOpenId, wxMpTemplate);
+                    }
                 }
 
             }

+ 9 - 0
YijiaRestful/src/main/java/com/platform/yijia/dao/GzhNewsTemplateMapper.java

@@ -0,0 +1,9 @@
+package com.platform.yijia.dao;
+
+import com.platform.yijia.pojo.GzhNewsTemplate;
+
+public interface GzhNewsTemplateMapper {
+
+    //获取公众号消息模板
+    GzhNewsTemplate getGzhNewsTemplate(GzhNewsTemplate gzhNewsTemplate);
+}

+ 16 - 0
YijiaRestful/src/main/java/com/platform/yijia/pojo/GzhNewsTemplate.java

@@ -0,0 +1,16 @@
+package com.platform.yijia.pojo;
+
+import lombok.Data;
+
+/***
+ * 公众号消息模板
+ */
+@Data
+public class GzhNewsTemplate {
+    private Integer id;
+    private String templateName;        //模板名称
+    private String templateType;        //模板类型
+    private String templateId;      //模板ID
+    private Integer stationId;      //油站ID
+    private String appId;       //公众号AppID
+}

+ 8 - 0
YijiaRestful/src/main/java/com/platform/yijia/service/GzhNewsTemplateService.java

@@ -0,0 +1,8 @@
+package com.platform.yijia.service;
+
+import com.platform.yijia.pojo.GzhNewsTemplate;
+
+public interface GzhNewsTemplateService {
+    //获取公众号消息模板
+    GzhNewsTemplate getGzhNewsTemplate(GzhNewsTemplate gzhNewsTemplate);
+}

+ 20 - 0
YijiaRestful/src/main/java/com/platform/yijia/service/impl/GzhNewsTemplateServiceImpl.java

@@ -0,0 +1,20 @@
+package com.platform.yijia.service.impl;
+
+import com.platform.yijia.dao.GzhNewsTemplateMapper;
+import com.platform.yijia.pojo.GzhNewsTemplate;
+import com.platform.yijia.service.GzhNewsTemplateService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+@Service("gzhNewsTemplateService")
+public class GzhNewsTemplateServiceImpl implements GzhNewsTemplateService {
+    @Resource
+    private GzhNewsTemplateMapper gzhNewsTemplateMapper;
+
+    //获取公众号消息模板
+    @Override
+    public GzhNewsTemplate getGzhNewsTemplate(GzhNewsTemplate gzhNewsTemplate) {
+        return gzhNewsTemplateMapper.getGzhNewsTemplate(gzhNewsTemplate);
+    }
+}

+ 36 - 0
YijiaRestful/src/main/resources/mapper/GzhNewsTemplateMapper.xml

@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.platform.yijia.dao.GzhNewsTemplateMapper">
+  <!--公众号消息模板返回结果-->
+  <resultMap id="BaseResultMap" type="com.platform.yijia.pojo.GzhNewsTemplate">
+      <id     column="id"                      jdbcType="INTEGER" property="id" />
+      <result column="template_name"           jdbcType="VARCHAR" property="templateName" />
+      <result column="template_type"           jdbcType="VARCHAR" property="templateType" />
+      <result column="temlate_id"              jdbcType="VARCHAR" property="templateId" />
+      <result column="station_id"              jdbcType="INTEGER" property="stationId" />
+      <result column="app_id"                  jdbcType="INTEGER" property="appId" />
+  </resultMap>
+
+
+  <!--查询公众号消息模板规则信息-->
+  <select id="getGzhNewsTemplate" resultMap="BaseResultMap" parameterType="com.platform.yijia.pojo.GzhNewsTemplate">
+    SELECT
+        T1.id,
+        T1.template_name,
+        T1.template_type,
+        T1.temlate_id,
+        T1.station_id,
+        T1.app_id
+    FROM
+        gzh_news_template AS T1
+    <where>
+          <if test="stationId !=null and stationId !=''">
+             T1.station_id = #{stationId}
+          </if>
+        <if test="templateType !=null and templateType !=''">
+            AND T1.template_type = #{templateType}
+        </if>
+    </where>
+  </select>
+
+</mapper>