ソースを参照

Merge branch 'master' of ssh://192.168.8.213:10022/miaxis/twzd

Althars123 3 年 前
コミット
699890cdb0

+ 10 - 0
twzd-admin/src/main/java/com/miaxis/pc/controller/wx/WxMenuController.java

@@ -90,4 +90,14 @@ public class WxMenuController extends BaseController {
         return wxMenuService.removeMenuByIds(ids);
     }
 
+    /**
+     * 一键更新公众号菜单
+     */
+    @GetMapping("/sendMenu")
+    @ApiOperation("一键更新公众号菜单--手动修改数据库操作")
+    public Response sendMenu(){
+        return wxMenuService.sendMenuBySql();
+    }
+
+
 }

+ 7 - 0
twzd-service/src/main/java/com/miaxis/wx/service/IWxMenuService.java

@@ -45,4 +45,11 @@ public interface IWxMenuService extends IService<WxMenu> {
      * @return
      */
     Response removeMenuByIds(Long[] ids);
+
+    /**
+     * 一键发送数据库菜单
+     * @return
+     */
+    Response sendMenuBySql();
+
 }

+ 10 - 0
twzd-service/src/main/java/com/miaxis/wx/service/impl/WxMenuServiceImpl.java

@@ -127,6 +127,16 @@ public class WxMenuServiceImpl extends ServiceImpl<WxMenuMapper, WxMenu> impleme
         }
     }
 
+    /**
+     * 一键发送数据库菜单
+     * @return
+     */
+    @Override
+    public Response sendMenuBySql() {
+        sendMenu();
+        return Response.success();
+    }
+
 
     /**
      * 发送菜单至微信

+ 29 - 14
twzd-service/src/main/java/com/miaxis/wx/service/impl/WxMessageEvenServiceImpl.java

@@ -135,32 +135,41 @@ public class WxMessageEvenServiceImpl implements IWxMessageEvenService {
                 FileUtil.file(ticketPath+fromUserName+"_img.jpg"),
                 ImgUtil.read(FileUtil.file(ticketPath+fromUserName+".jpg")), //水印图片
                 0, //x坐标修正值。 默认在中间,偏移量相对于中间偏移
-                -360, //y坐标修正值。 默认在中间,偏移量相对于中间偏移
+                -340, //y坐标修正值。 默认在中间,偏移量相对于中间偏移
                 1.0f
         );
 
+        ImgUtil.pressText(
+                FileUtil.file(ticketPath+fromUserName+"_img.jpg"),
+                FileUtil.file(ticketPath+fromUserName+"_text1.jpg"),
+                userInfo.getString("nickname"), Color.black, //文字
+                new Font("黑体", Font.BOLD, 30), //字体
+                0, //x坐标修正值。 默认在中间,偏移量相对于中间偏移
+                -500, //y坐标修正值。 默认在中间,偏移量相对于中间偏移
+                1.0f//透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
+        );
+
         DateTime date = DateUtil.date();
         Date newDate = DateUtil.offsetDay(date, 3);
         String dateStr = DateUtil.format(newDate, "yyyy-MM-dd");
         log.info(dateStr);
 
-        String text = userInfo.getString("nickname")+"  此二维码有效期至:"+dateStr;
         ImgUtil.pressText(
-                FileUtil.file(ticketPath+fromUserName+"_img.jpg"),
-                FileUtil.file(ticketPath+fromUserName+"_text.jpg"),
-                text, Color.red, //文字
-                new Font("黑体", Font.BOLD, 30), //字体
+                FileUtil.file(ticketPath+fromUserName+"_text1.jpg"),
+                FileUtil.file(ticketPath+fromUserName+"_text2.jpg"),
+                "二维码有效期至:"+dateStr, Color.black, //文字
+                new Font("黑体", Font.BOLD, 28), //字体
                 0, //x坐标修正值。 默认在中间,偏移量相对于中间偏移
-                400, //y坐标修正值。 默认在中间,偏移量相对于中间偏移
-                0.8f//透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
+                -80, //y坐标修正值。 默认在中间,偏移量相对于中间偏移
+                1.0f//透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
         );
 
 
         try {
-            File textFile = new File(ticketPath + fromUserName+"_text.jpg");
+            File textTwoFile = new File(ticketPath + fromUserName+"_text2.jpg");
             //上传素材
             String path = mediaUpload + token + "&type=image";
-            String result = HttpUtils.connectHttpsByPost(path,textFile);
+            String result = HttpUtils.connectHttpsByPost(path,textTwoFile);
             result = result.replaceAll("[\\\\]", "");
             JSONObject resultJSON = JSONObject.parseObject(result);
             log.info("------result:" + resultJSON);
@@ -171,7 +180,8 @@ public class WxMessageEvenServiceImpl implements IWxMessageEvenService {
 
             //删除服务器文件
             File imgFile = new File(ticketPath + fromUserName+"_img.jpg");
-            if (ticketFile.exists() && imgFile.exists() && textFile.exists()) {
+            File textOneFile = new File(ticketPath + fromUserName+"_text1.jpg");
+            if (ticketFile.exists() && imgFile.exists() && textOneFile.exists() && textTwoFile.exists()) {
                 if (ticketFile.delete()) {
                     log.info("删除:" + ticketFile.getName() + "成功!");
                 } else {
@@ -182,10 +192,15 @@ public class WxMessageEvenServiceImpl implements IWxMessageEvenService {
                 } else {
                     log.info("删除:" + imgFile.getName() + "失败!");
                 }
-                if (textFile.delete()) {
-                    log.info("删除:" + textFile.getName() + "成功!");
+                if (textOneFile.delete()) {
+                    log.info("删除:" + textOneFile.getName() + "成功!");
+                } else {
+                    log.info("删除:" + textOneFile.getName() + "失败!");
+                }
+                if (textTwoFile.delete()) {
+                    log.info("删除:" + textTwoFile.getName() + "成功!");
                 } else {
-                    log.info("删除:" + textFile.getName() + "失败!");
+                    log.info("删除:" + textTwoFile.getName() + "失败!");
                 }
             }