ソースを参照

watero母亲节活动

wangxiaoming 6 年 前
コミット
3bbb31ff24
24 ファイル変更1665 行追加25 行削除
  1. 112 0
      watero-common-core/src/main/java/com/iamberry/wechat/core/entity/mothMovable/MothMovable.java
  2. 52 0
      watero-common-core/src/main/java/com/iamberry/wechat/core/entity/mothMovable/MothPopularity.java
  3. 62 0
      watero-common-core/src/main/java/com/iamberry/wechat/core/entity/stati/AcceStatistics.java
  4. 24 4
      watero-common-tool/src/main/java/com/iamberry/wechat/file/FileUtils.java
  5. 88 0
      watero-common-tool/src/main/java/com/iamberry/wechat/tools/DownloadWXCodeUtil.java
  6. 202 19
      watero-common-tool/src/main/java/com/iamberry/wechat/tools/ImageUtils.java
  7. 3 1
      watero-common-tool/src/main/java/com/iamberry/wechat/tools/NameUtils.java
  8. 64 0
      watero-common-tool/src/main/java/com/iamberry/wechat/tools/PosterNumUtils.java
  9. 2 0
      watero-common-tool/src/main/java/com/iamberry/wechat/tools/ResultInfo.java
  10. 50 0
      watero-wechat-interface/src/main/java/com/iamberry/wechat/face/mothMovable/MothMovableService.java
  11. 43 0
      watero-wechat-interface/src/main/java/com/iamberry/wechat/face/mothMovable/MothPopularityService.java
  12. 44 0
      watero-wechat-interface/src/main/java/com/iamberry/wechat/face/stati/AcceStatisticsService.java
  13. 44 0
      watero-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/AcceStatisticsMapper.java
  14. 51 0
      watero-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/MothMovableMapper.java
  15. 43 0
      watero-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/MothPopularityMapper.java
  16. 79 0
      watero-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/acceStatisticsMapper.xml
  17. 116 0
      watero-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/mothMovableMapper.xml
  18. 71 0
      watero-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/mothPopularityMapper.xml
  19. 202 0
      watero-wechat-service/src/main/java/com/iamberry/wechat/service/mothMovable/MothMovableServiceImpl.java
  20. 70 0
      watero-wechat-service/src/main/java/com/iamberry/wechat/service/mothMovable/MothPopularityServiceImpl.java
  21. 61 0
      watero-wechat-service/src/main/java/com/iamberry/wechat/service/stati/AcceStatisticsServiceImpl.java
  22. 43 1
      watero-wechat-service/src/main/java/com/iamberry/wechat/service/wechat/WeChatServiceImpl.java
  23. 127 0
      watero-wechat-web/src/main/java/com/iamberry/wechat/handles/mothMovable/MothMovableHandler.java
  24. 12 0
      watero-wechat-web/src/main/resources/iamberry-wechat-service-mybatis.xml

+ 112 - 0
watero-common-core/src/main/java/com/iamberry/wechat/core/entity/mothMovable/MothMovable.java

@@ -0,0 +1,112 @@
+package com.iamberry.wechat.core.entity.mothMovable;
+
+import  java.util.Date;
+import  java.io.Serializable;
+/**
+ *  活动生成图片的内容类
+ * @author xm
+ * @Date 2019-04-25
+ */
+public class MothMovable  implements  Serializable{
+    private static final long serialVersionUID = -4585576166130986541L;
+    //参与id
+    private Integer mothMovaId;
+    //参与openid
+    private String mothMovaOpenId;
+    //头像url
+    private String mothMovaHead;
+    //文字
+    private String mothMovaText;
+    //分享url连接   二维码连接
+    private String mothMovaShareUrl;
+    //背景图
+    private Integer mothMovaBackType;
+    //生成后图片的地址
+    private String mothMovaImgUrl;
+    //生成优惠券ID
+    private String couponItemId;
+    //创建时间'
+    private Date mothMovaCreateTime;
+
+    private String userNickname;
+
+    public Integer getMothMovaId(){
+        return mothMovaId;
+    }
+
+    public void setMothMovaId(Integer  mothMovaId){
+        this.mothMovaId=mothMovaId;
+    }
+
+    public String getMothMovaOpenId() {
+        return mothMovaOpenId;
+    }
+
+    public void setMothMovaOpenId(String mothMovaOpenId) {
+        this.mothMovaOpenId = mothMovaOpenId;
+    }
+
+    public String getMothMovaHead(){
+        return mothMovaHead;
+    }
+
+    public void setMothMovaHead(String  mothMovaHead){
+        this.mothMovaHead=mothMovaHead;
+    }
+
+    public String getMothMovaText(){
+        return mothMovaText;
+    }
+
+    public void setMothMovaText(String  mothMovaText){
+        this.mothMovaText=mothMovaText;
+    }
+
+    public String getMothMovaShareUrl(){
+        return mothMovaShareUrl;
+    }
+
+    public void setMothMovaShareUrl(String  mothMovaShareUrl){
+        this.mothMovaShareUrl=mothMovaShareUrl;
+    }
+
+    public Integer getMothMovaBackType() {
+        return mothMovaBackType;
+    }
+
+    public void setMothMovaBackType(Integer mothMovaBackType) {
+        this.mothMovaBackType = mothMovaBackType;
+    }
+
+    public String getMothMovaImgUrl(){
+        return mothMovaImgUrl;
+    }
+
+    public void setMothMovaImgUrl(String  mothMovaImgUrl){
+        this.mothMovaImgUrl=mothMovaImgUrl;
+    }
+
+    public String getCouponItemId(){
+        return couponItemId;
+    }
+
+    public void setCouponItemId(String  couponItemId){
+        this.couponItemId=couponItemId;
+    }
+
+    public Date getMothMovaCreateTime(){
+        return mothMovaCreateTime;
+    }
+
+    public void setMothMovaCreateTime(Date  mothMovaCreateTime){
+        this.mothMovaCreateTime=mothMovaCreateTime;
+    }
+
+    public String getUserNickname() {
+        return userNickname;
+    }
+
+    public void setUserNickname(String userNickname) {
+        this.userNickname = userNickname;
+    }
+}

+ 52 - 0
watero-common-core/src/main/java/com/iamberry/wechat/core/entity/mothMovable/MothPopularity.java

@@ -0,0 +1,52 @@
+package com.iamberry.wechat.core.entity.mothMovable;
+
+import  java.util.Date;
+import  java.io.Serializable;
+/**
+ *  活动生成二维码,关注人数统计类
+ * @author xm
+ * @Date 2019-04-25
+ */
+public class MothPopularity  implements  Serializable{
+    private static final long serialVersionUID = -8999752808377647488L;
+    //Id
+    private Integer mothPopuId;
+    //活动图片id
+    private Integer mothMovaId;
+    //扫描二维码openid
+    private String mothPopuOpenId;
+    //创建时间'
+    private Date mothPopuCreateTime;
+
+    public Integer getMothPopuId(){
+        return mothPopuId;
+    }
+
+    public void setMothPopuId(Integer  mothPopuId){
+        this.mothPopuId=mothPopuId;
+    }
+
+    public Integer getMothMovaId(){
+        return mothMovaId;
+    }
+
+    public void setMothMovaId(Integer  mothMovaId){
+        this.mothMovaId=mothMovaId;
+    }
+
+    public String getMothPopuOpenId() {
+        return mothPopuOpenId;
+    }
+
+    public void setMothPopuOpenId(String mothPopuOpenId) {
+        this.mothPopuOpenId = mothPopuOpenId;
+    }
+
+    public Date getMothPopuCreateTime(){
+        return mothPopuCreateTime;
+    }
+
+    public void setMothPopuCreateTime(Date  mothPopuCreateTime){
+        this.mothPopuCreateTime=mothPopuCreateTime;
+    }
+}

+ 62 - 0
watero-common-core/src/main/java/com/iamberry/wechat/core/entity/stati/AcceStatistics.java

@@ -0,0 +1,62 @@
+package com.iamberry.wechat.core.entity.stati;
+
+import  java.util.Date;
+import  java.io.Serializable;
+/**
+ *  访问统计类
+ * @author xm
+ * @Date 2019-04-25
+ */
+public class AcceStatistics  implements  Serializable{
+    private static final long serialVersionUID = 5854289691788139716L;
+    //id
+    private Integer acceStatId;
+    //访问类型 1:19年母亲节
+    private Integer acceStatType;
+    //访问openId
+    private String acceStatOpenId;
+    //创建时间'
+    private Date acceStatCreateTime;
+
+    private Date judgeTime;
+
+    public Integer getAcceStatId(){
+        return acceStatId;
+    }
+
+    public void setAcceStatId(Integer  acceStatId){
+        this.acceStatId=acceStatId;
+    }
+
+    public Integer getAcceStatType(){
+        return acceStatType;
+    }
+
+    public void setAcceStatType(Integer  acceStatType){
+        this.acceStatType=acceStatType;
+    }
+
+    public String getAcceStatOpenId() {
+        return acceStatOpenId;
+    }
+
+    public void setAcceStatOpenId(String acceStatOpenId) {
+        this.acceStatOpenId = acceStatOpenId;
+    }
+
+    public Date getAcceStatCreateTime(){
+        return acceStatCreateTime;
+    }
+
+    public void setAcceStatCreateTime(Date  acceStatCreateTime){
+        this.acceStatCreateTime=acceStatCreateTime;
+    }
+
+    public Date getJudgeTime() {
+        return judgeTime;
+    }
+
+    public void setJudgeTime(Date judgeTime) {
+        this.judgeTime = judgeTime;
+    }
+}

+ 24 - 4
watero-common-tool/src/main/java/com/iamberry/wechat/file/FileUtils.java

@@ -1,9 +1,6 @@
 package com.iamberry.wechat.file;
 
-import java.io.File;
-import java.io.FilePermission;
-import java.io.IOException;
-import java.io.InputStream;
+import java.io.*;
 import java.security.SecureRandom;
 import java.util.Date;
 import java.util.UUID;
@@ -160,4 +157,27 @@ public class FileUtils {
 		}
 		return null;
 	}
+
+	/**复制文件的方法*/
+	public static void copyFile(String oldPath, String newPath) {
+		try {
+			int bytesum = 0;
+			int byteread = 0;
+			File oldfile = new File(oldPath);
+			if (oldfile.exists()) { //文件存在时
+				InputStream inStream = new FileInputStream(oldPath); //读入原文件
+				FileOutputStream fs = new FileOutputStream(newPath);
+				byte[] buffer = new byte[1444];
+				while ((byteread = inStream.read(buffer)) != -1) {
+					bytesum += byteread; //字节数 文件大小
+					fs.write(buffer, 0, byteread);
+				}
+				inStream.close();
+				fs.close();
+			}
+		} catch (Exception e) {
+			System.out.println("复制单个文件操作出错");
+			e.printStackTrace();
+		}
+	}
 }

+ 88 - 0
watero-common-tool/src/main/java/com/iamberry/wechat/tools/DownloadWXCodeUtil.java

@@ -0,0 +1,88 @@
+package com.iamberry.wechat.tools;
+
+import javax.imageio.ImageIO;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+
+public class DownloadWXCodeUtil {
+    /**
+     * 下载微信二维码
+     * @param urlString
+     * @param filename 存储名称
+     * @param savePath  路径
+     * @param width 宽度
+     * @param height 高度
+     * @throws Exception
+     */
+    public static void download(String urlString, String filename,String savePath,int width,int height) throws Exception {
+
+        // 输出的文件流
+        File sf=new File(savePath);
+        if(!sf.exists()){
+            sf.mkdirs();
+        }
+        // 构造URL
+        URL url = new URL(urlString);
+        // 打开连接
+        URLConnection con = url.openConnection();
+        //设置请求超时为5s
+        con.setConnectTimeout(5*1000);
+        // 输入流
+        InputStream is = con.getInputStream();
+
+        BufferedImage bi = ImageIO.read(is);
+        ImageIO.write(bi, "png", new File(savePath+filename));
+
+//        JPEGImageDecoder decoderFile = JPEGCodec.createJPEGDecoder(is);
+//        BufferedImage image = decoderFile.decodeAsBufferedImage();
+
+//        Image srcImg = image;
+//        image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+//        image.getGraphics().drawImage(srcImg.getScaledInstance(width, height, Image.SCALE_SMOOTH), 0,0, null);
+//        ImageIO.write(image, "JPEG", new File(savePath+filename));
+        is.close();
+    }
+
+    /**
+     * 下载微信二维码
+     * @param url
+     * @param filename
+     * @param savePath
+     * @param width
+     * @param height
+     * @param isCircular 是否为圆
+     */
+    public static void downloadByNIO2(String url,  String filename,String savePath,int width,int height,boolean isCircular) {
+        try (InputStream ins = new URL(url).openStream()) {
+            BufferedImage bi = ImageIO.read(ins);
+            if(isCircular){
+                int w = width;
+                int h = height;
+                BufferedImage output = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
+                Graphics2D g2 = output.createGraphics();
+                output = g2.getDeviceConfiguration().createCompatibleImage(w, h, Transparency.TRANSLUCENT);
+                g2.dispose();
+                g2 = output.createGraphics();
+                g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+                g2.fillRoundRect(0, 0,w, h, 720, 720);
+                g2.setComposite(AlphaComposite.SrcIn);
+                g2.drawImage(bi, 0, 0, w, h, null);
+                g2.dispose();
+                ImageIO.write(output, "png", new File(savePath+filename));
+            }else{
+                Image srcImg = bi;
+                bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+                bi.getGraphics().drawImage(srcImg.getScaledInstance(width, height, Image.SCALE_SMOOTH), 0,0, null);
+                ImageIO.write(bi, "png", new File(savePath+filename));
+            }
+            ins.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+}

+ 202 - 19
watero-common-tool/src/main/java/com/iamberry/wechat/tools/ImageUtils.java

@@ -1,19 +1,18 @@
 package com.iamberry.wechat.tools;
-import java.awt.AlphaComposite;
-import java.awt.Color;
-import java.awt.Font;
-import java.awt.Graphics2D;
-import java.awt.Image;
+
+import com.mortennobel.imagescaling.ResampleFilters;
+import com.mortennobel.imagescaling.ResampleOp;
+
+import javax.imageio.ImageIO;
+import java.awt.*;
 import java.awt.geom.AffineTransform;
 import java.awt.image.AffineTransformOp;
 import java.awt.image.BufferedImage;
 import java.io.File;
 import java.io.IOException;
-
-import javax.imageio.ImageIO;
-
-import com.mortennobel.imagescaling.ResampleFilters;
-import com.mortennobel.imagescaling.ResampleOp;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * 图片工具类, 图片水印,文字水印,缩放,补白等 <br>
@@ -66,6 +65,198 @@ public final class ImageUtils {
             }
     }
 
+    public static void main(String[] args) throws IOException {
+//    	long l = System.currentTimeMillis();
+//    	reSize("D://abcdefgj1.jpg", 0.5, 0.5);
+//    	pressImage("D://Test.jpg", "D://test111.jpg", 350, 500, 1);
+        // 设置水印
+//    	press("D://Test.jpg", "D://test111.jpg", "深圳爱贝源科技有限公司", 350, 100, 350, 500);
+//    	System.out.println(System.currentTimeMillis() - l);
+        // resize("C://pic//4.jpg", 1000, 500, true);'
+
+
+        String newImg = "E:\\java-work\\iamberry-watero\\watero-wechat-web\\target\\watero-wechat-web-1.0.0\\common\\images\\movable\\1.jpg";
+        String headImg = "E:\\java-work\\iamberry-watero\\watero-wechat-web\\target\\watero-wechat-web-1.0.0\\common\\images\\movable\\7a7620fb_head.jpg";
+        String codeImg = "E:\\java-work\\iamberry-watero\\watero-wechat-web\\target\\watero-wechat-web-1.0.0\\common\\images\\movable\\7a7620fb_code.jpg";
+        String text = "小茗同学";
+        String alltext = "慈母手中线,\n游子身上衣。\n临行密密缝,\n意恐迟迟归。\n谁言寸草心,\n报得三春晖!";
+//        String alltext = "You are the best mom thatsdafsadasfsadsaf a son ever had.\nSometimes it may not seem like it, but I really do love you.God could not be everywhere and therefore he made mothers.";
+
+
+        try {
+            ImageUtils.pressPost(newImg,
+                    headImg,PosterNumUtils.HEAD_X,PosterNumUtils.HEAD_Y,
+                    codeImg,PosterNumUtils.CODE_X,PosterNumUtils.CODE_Y,
+                    text,PosterNumUtils.TEXT_X,PosterNumUtils.TEXT_Y,new Color(221,106,140),PosterNumUtils.TEXT_FONT_SIZE,
+                    alltext,PosterNumUtils.TEXT_CONTENT_X,PosterNumUtils.TEXT_CONTENT_Y,new Color(0,0,0),PosterNumUtils.TEXT_CONTENT_FONT_SIZE
+            );
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+//        String ENCODE = "utf-8";
+//        String name = java.net.URLDecoder.decode( "%E5%B0%8F%E8%8C%97%E5%90%8C%E5%AD%A6", ENCODE);
+//
+//        System.out.println(name);
+
+    }
+
+    /**
+     * 生成海报
+     */
+    public static void pressPost(String targetImg,
+                                 String srcImg1, int imgx1, int imgy1,
+                                 String srcImg2, int imgx2, int imgy2,
+                                 String headText, int x, int y,Color xyColorName,int xySizeNum,
+                                 String pressText, int m, int n,Color mnColorName,int mnSizeNum
+    ) throws Exception{
+        float alpha = 1;
+
+        File file = new File(targetImg);
+        Image image = ImageIO.read(file);
+
+        int width = image.getWidth(null);
+        int height = image.getHeight(null);
+        BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+        Graphics2D g = bufferedImage.createGraphics();
+        g.drawImage(image, 0, 0, width, height, null);
+
+        //居中水印文字
+        customContenText(g,width,height,headText,"微软雅黑",xySizeNum,xyColorName,Font.PLAIN,x,y);
+
+        //水印内容
+        List<String> strList = new ArrayList<>();
+        String strs[] = pressText.split("\n");
+        for (String s : strs) {
+            strList.addAll(getStrArr(s));
+        }
+        for (String strCon :  strList) {    //循环行生成文本
+            customText(g,width,height,strCon,"微软雅黑",mnSizeNum,mnColorName,Font.PLAIN,m,n);
+            n += PosterNumUtils.FONT_LINE_SPACING;
+        }
+
+        Image tarImage = ImageIO.read(new File(srcImg1));
+        g.drawImage(tarImage, imgx1, imgy1, tarImage.getWidth(null), tarImage.getHeight(null), null); // 水印文件结束
+
+        Image tarImage2 = ImageIO.read(new File(srcImg2));
+        g.drawImage(tarImage2, imgx2, imgy2, tarImage2.getWidth(null), tarImage2.getHeight(null), null); // 水印文件结束
+
+        g.dispose();
+        ImageIO.write(bufferedImage, targetImg.substring(targetImg.lastIndexOf(".") + 1), file);
+    }
+
+    /**
+     *  单行文字转为多行,每行字符数量为 FONT_NUMBER
+     * @param text
+     * @return
+     */
+    public static List<String> getStrArr(String text){
+        if(text == null){
+            return new ArrayList<>();
+        }
+        int i = 0,num=0;
+        List<String> strList = new ArrayList<>();
+        StringBuffer temp = new StringBuffer();
+        while (text.length() > num){
+            if(i >= PosterNumUtils.FONT_NUMBER){
+                strList.add(temp.toString());
+                temp = new StringBuffer();
+                i = 0;
+            }
+            char c = text.charAt(num); // 调用字符串的charAt()方法取得第一个字符就是了
+            String x = String.valueOf(c);
+            boolean isWarp = false;
+            try {
+                String newString = new String(x.getBytes("GB2312"), "ISO-8859-1");
+                i+=newString.length();
+                if(32 == c){    //英文状态下,本行字母写不下,换行
+                    String later = text.substring(num,text.length());
+                    if(later.indexOf(" ") > -1 && later.indexOf(" ",later.indexOf(" ")+1) > 1){
+                        String a = later.substring(0,later.indexOf(" ",later.indexOf(" ")+1));   //str.indexOf("a", str.indexOf("a")+1)
+                        if((a.length()+i) >  PosterNumUtils.FONT_NUMBER){
+                            strList.add(temp.toString());
+                            temp = new StringBuffer();
+                            i = 0;
+                            isWarp = true;
+                        }
+                    }
+                }
+            } catch (UnsupportedEncodingException e) {
+                e.printStackTrace();
+            }
+            if(!isWarp){
+                temp.append(c);
+            }
+            num++;
+        }
+        strList.add(temp.toString());
+        return strList;
+    }
+
+    /**
+     * 添加文字水印 -- 居中
+     * @param g
+     * @param width 图片宽
+     * @param height 图片高
+     * @param pressText 大小
+     * @param fontName 字体
+     * @param fontSize 大小
+     * @param color 颜色
+     * @param fontStyle 加粗 Font.PLAIN
+     * @param x -1 为居中    不为-1 就是左边距
+     * @param y -1 为居中    不为-1 就是上边距
+     */
+    public static void customContenText(Graphics2D g, int width, int height,String pressText, String fontName, int fontSize, Color color,int fontStyle, int x, int y) {
+        try {
+            g.setFont(new Font(fontName, fontStyle, fontSize));
+            g.setColor(color);
+            FontMetrics fm = g.getFontMetrics();
+            int stringWidth = fm.stringWidth(pressText);
+            int stringAscent = fm.getAscent();
+            int stringDescent = fm.getDescent ();
+            if(x == -1){
+                x = width / 2 - stringWidth / 2;
+            }
+            if(y == -1){
+                y = height / 2 + (stringAscent - stringDescent) / 2;
+            }
+            g.drawString(pressText, x, y);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 添加文字水印
+     * 定位
+     */
+    public static void customText(Graphics2D g, int width, int height,String pressText, String fontName, int fontSize, Color color,int fontStyle, int x, int y) {
+        try {
+            float alpha = 1;
+            g.setFont(new Font(fontName, fontStyle, fontSize));
+            g.setColor(color);
+            g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha));
+
+            int width_1 = fontSize * getLength(pressText);
+            int height_1 = fontSize;
+            int widthDiff = width - width_1;
+            int heightDiff = height - height_1;
+            if(x < 0){
+                x = widthDiff / 2;
+            }else if(x > widthDiff){
+                x = widthDiff;
+            }
+            if(y < 0){
+                y = heightDiff / 2;
+            }else if(y > heightDiff){
+                y = heightDiff;
+            }
+            g.drawString(pressText, x, y + height_1);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+
     /**
      * 添加文字水印
      * @param targetImg 目标图片路径,如:C://myPictrue//1.jpg
@@ -217,13 +408,5 @@ public final class ImageUtils {
         	return false;
         }
     }
-    public static void main(String[] args) throws IOException {
-    	long l = System.currentTimeMillis();
-//    	reSize("D://abcdefgj1.jpg", 0.5, 0.5);
-//    	pressImage("D://Test.jpg", "D://test111.jpg", 350, 500, 1);
-    	// 设置水印
-    	press("D://Test.jpg", "D://test111.jpg", "深圳爱贝源科技有限公司", 350, 100, 350, 500);
-    	System.out.println(System.currentTimeMillis() - l);
-        // resize("C://pic//4.jpg", 1000, 500, true);
-    }
+
 }

+ 3 - 1
watero-common-tool/src/main/java/com/iamberry/wechat/tools/NameUtils.java

@@ -55,8 +55,10 @@ public class NameUtils {
 	public static String get_token_url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=TOKEN";
 	// 二维码图片链接
 	public static String show_qrcode_url = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=";
-	// 临时二维码
+	// 临时二维码	QR_SCENE为临时的整型参数值,
 	public static String QR_SCENE = "{\"expire_seconds\": %s, \"action_name\": \"QR_SCENE\", \"action_info\": {\"scene\": {\"scene_id\": %s}}}";
+	// 临时二维码	 QR_STR_SCENE为临时的字符串参数值
+	public static String QR_SCENE_STR = "{\"expire_seconds\": %s, \"action_name\": \"QR_STR_SCENE\", \"action_info\": {\"scene\": {\"scene_str\": \"%s\"}}}";
 	//  永久二维码
 	public static String QR_LIMIT_STR_SCENE = "{\"action_name\": \"QR_LIMIT_STR_SCENE\", \"action_info\": {\"scene\": {\"scene_str\": \"%s\"}}}";
 	// 获取用户信息

+ 64 - 0
watero-common-tool/src/main/java/com/iamberry/wechat/tools/PosterNumUtils.java

@@ -0,0 +1,64 @@
+package com.iamberry.wechat.tools;
+
+
+import org.omg.CORBA.INTERNAL;
+import org.springframework.stereotype.Component;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+@Component
+public class PosterNumUtils {
+    //背景色集合
+    private static Map<Integer,String> map = new HashMap<>();
+
+    public static final String IMG_PATH = "common/images/movable/";
+    public static final String OLD_IMG_PATH = "common/images/movable/ditu.jpg";
+
+    /*二维码大小*/
+    public static final int CODE_WIDTH = 106;
+    public static final int CODE_HEIGHT = 106;
+
+    /*头像大小*/
+    public static final int HEAD_WIDTH = 132;
+    public static final int HEAD_HEIGHT = 132;
+
+    /*文字位置 -- 昵称*/
+    public static final int TEXT_X = -1; //居中
+    public static final int TEXT_Y = 208;
+    public static final int TEXT_FONT_SIZE = 30;
+
+    /*文字位置 -- 文本 - 起始位置*/
+    public static final int TEXT_CONTENT_X = 170; //居中
+    public static final int TEXT_CONTENT_Y = 270;
+    public static final int TEXT_CONTENT_FONT_SIZE = 26;
+
+    /*每行文字字符限制数量,中文算两个字符,所以只能是双数*/
+    public static final int FONT_NUMBER = 28;
+
+    //每行间距 - 行距
+    public static final int FONT_LINE_SPACING = 71;
+
+    /*头像位置*/
+    public static final int HEAD_X = 309;
+    public static final int HEAD_Y = 38;
+
+    /*二维码位置*/
+    public static final int CODE_X = 620;
+    public static final int CODE_Y = 1077;
+
+    static {
+        map.put(1,"1.jpg");  //1号背景
+        map.put(2,"2.jpg");  //2
+        map.put(3,"3.jpg");  //3
+        map.put(4,"4.jpg");  //4
+        map.put(5,"5.jpg");  //5
+    }
+
+    public static String  getBackPath(Integer type){
+        return "back/"+map.get(type);
+    }
+
+
+}

+ 2 - 0
watero-common-tool/src/main/java/com/iamberry/wechat/tools/ResultInfo.java

@@ -30,6 +30,8 @@ public class ResultInfo {
 	public  static String lostMemberInfo="";
 
 	public  static String barCodePrefix="MACHINE_QR_CODE";
+	public  static String barCodeMothMovable="MOTH_MOVABLE_CODE#";	//母亲节活动,  MOTH_MOVABLE_CODE#1,
+	public  static String barCode="qrscene_";
 	/**
 	 * 初始化代理商信息openid成功前缀
 	 */

+ 50 - 0
watero-wechat-interface/src/main/java/com/iamberry/wechat/face/mothMovable/MothMovableService.java

@@ -0,0 +1,50 @@
+package com.iamberry.wechat.face.mothMovable;
+
+import com.iamberry.wechat.core.entity.mothMovable.MothMovable;
+
+import java.util.List;
+
+/**
+ *  活动生成图片的内容接口
+ * @author xm
+ * @Date 2019-04-25
+ */
+public interface MothMovableService {
+    /**
+     * 获取集合
+     * @param  mothMovable
+     * @return List
+     */
+    List<MothMovable> getMothMovableList(MothMovable  mothMovable);
+    /**
+     * 查询单条数据
+     * @param  id
+     * @return  mothMovable
+     */
+    MothMovable  getMothMovableById(Integer  id);
+    /**
+     * 增加数据
+     * @param  mothMovable
+     * @return Integer
+     */
+    Integer  save(MothMovable  mothMovable,String rootPath);
+    /**
+     * 修改数据
+     * @param  mothMovable
+     * @return Integer
+     */
+    Integer  update(MothMovable  mothMovable);
+    /**
+     * 删除数据
+     * @param  id
+     * @return Integer
+     */
+    Integer  delete(Integer  id);
+
+    /**
+     * 用户扫描,参与活动生成的临时二维码
+     * @param
+     * @return Integer
+     */
+    Integer  scanInfo(Integer  mothMovaId,String openId);
+}

+ 43 - 0
watero-wechat-interface/src/main/java/com/iamberry/wechat/face/mothMovable/MothPopularityService.java

@@ -0,0 +1,43 @@
+package com.iamberry.wechat.face.mothMovable;
+
+import com.iamberry.wechat.core.entity.mothMovable.MothPopularity;
+
+import java.util.List;
+
+/**
+ *  活动生成二维码,关注人数统计接口
+ * @author xm
+ * @Date 2019-04-25
+ */
+public interface MothPopularityService {
+    /**
+     * 获取集合
+     * @param  mothPopularity
+     * @return List
+     */
+    List<MothPopularity> getMothPopularityList(MothPopularity  mothPopularity);
+    /**
+     * 查询单条数据
+     * @param  id
+     * @return  mothPopularity
+     */
+    MothPopularity  getMothPopularityById(Integer  id);
+    /**
+     * 增加数据
+     * @param  mothPopularity
+     * @return Integer
+     */
+    Integer  save(MothPopularity  mothPopularity);
+    /**
+     * 修改数据
+     * @param  mothPopularity
+     * @return Integer
+     */
+    Integer  update(MothPopularity  mothPopularity);
+    /**
+     * 删除数据
+     * @param  id
+     * @return Integer
+     */
+    Integer  delete(Integer  id);
+}

+ 44 - 0
watero-wechat-interface/src/main/java/com/iamberry/wechat/face/stati/AcceStatisticsService.java

@@ -0,0 +1,44 @@
+package com.iamberry.wechat.face.stati;
+
+import com.iamberry.wechat.core.entity.stati.AcceStatistics;
+
+import java.util.List;
+
+/**
+ *  访问统计接口
+ * @author xm
+ * @Date 2019-04-25
+ */
+public interface AcceStatisticsService {
+    /**
+     * 获取集合
+     * @param  acceStatistics
+     * @return List
+     */
+    List<AcceStatistics> getAcceStatisticsList(AcceStatistics  acceStatistics);
+    /**
+     * 查询单条数据
+     * @param  id
+     * @return  acceStatistics
+     */
+    AcceStatistics  getAcceStatisticsById(Integer  id);
+    /**
+     * 增加数据
+     * @param  acceStatistics
+     * @return Integer
+     */
+    Integer  save(AcceStatistics  acceStatistics);
+    /**
+     * 修改数据
+     * @param  acceStatistics
+     * @return Integer
+     */
+    Integer  update(AcceStatistics  acceStatistics);
+
+    /**
+     * 获取该用户在0点-24点之前是否已经添加过
+     * @param  acceStatistics
+     * @return Integer
+     */
+    Integer  getAcceStatiCount(AcceStatistics  acceStatistics);
+}

+ 44 - 0
watero-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/AcceStatisticsMapper.java

@@ -0,0 +1,44 @@
+package com.iamberry.wechat.service.mapper;
+
+import com.iamberry.wechat.core.entity.stati.AcceStatistics;
+
+import java.util.List;
+
+/**
+ *  访问统计接口
+ * @author xm
+ * @Date 2019-04-25
+ */
+public interface AcceStatisticsMapper {
+    /**
+     * 获取集合
+     * @param  acceStatistics
+     * @return List
+     */
+    List<AcceStatistics> getAcceStatisticsList(AcceStatistics  acceStatistics);
+    /**
+     * 查询单条数据
+     * @param  id
+     * @return  acceStatistics
+     */
+    AcceStatistics  getAcceStatisticsById(Integer  id);
+    /**
+     * 增加数据
+     * @param  acceStatistics
+     * @return Integer
+     */
+    Integer  save(AcceStatistics  acceStatistics);
+    /**
+     * 修改数据
+     * @param  acceStatistics
+     * @return Integer
+     */
+    Integer  update(AcceStatistics  acceStatistics);
+    /**
+     * 获取该用户在0点-24点之前是否已经添加过
+     * @param  acceStatistics
+     * @return Integer
+     */
+    Integer  getAcceStatiCount(AcceStatistics  acceStatistics);
+
+}

+ 51 - 0
watero-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/MothMovableMapper.java

@@ -0,0 +1,51 @@
+package com.iamberry.wechat.service.mapper;
+
+import com.iamberry.wechat.core.entity.mothMovable.MothMovable;
+
+import java.util.List;
+
+/**
+ *  活动生成二维码,关注人数统计接口
+ * @author xm
+ * @Date 2019-04-25
+ */
+public interface MothMovableMapper {
+    /**
+     * 获取集合
+     * @param  mothMovable
+     * @return List
+     */
+    List<MothMovable>  getMothMovableList(MothMovable  mothMovable);
+
+    /**
+     * 获取数量
+     * @param  mothMovable
+     * @return List
+     */
+    Integer  getNum(MothMovable  mothMovable);
+
+    /**
+     * 查询单条数据
+     * @param  id
+     * @return  mothMovable
+     */
+    MothMovable  getMothMovableById(Integer  id);
+    /**
+     * 增加数据
+     * @param  mothMovable
+     * @return Integer
+     */
+    Integer  save(MothMovable mothMovable);
+    /**
+     * 修改数据
+     * @param  mothMovable
+     * @return Integer
+     */
+    Integer  update(MothMovable  mothMovable);
+    /**
+     * 删除数据
+     * @param  id
+     * @return Integer
+     */
+    Integer  delete(Integer  id);
+}

+ 43 - 0
watero-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/MothPopularityMapper.java

@@ -0,0 +1,43 @@
+package com.iamberry.wechat.service.mapper;
+
+import com.iamberry.wechat.core.entity.mothMovable.MothPopularity;
+
+import java.util.List;
+
+/**
+ *  活动生成二维码,关注人数统计接口
+ * @author xm
+ * @Date 2019-04-25
+ */
+public interface MothPopularityMapper {
+    /**
+     * 获取集合
+     * @param  mothPopularity
+     * @return List
+     */
+    List<MothPopularity> getMothPopularityList(MothPopularity  mothPopularity);
+    /**
+     * 查询单条数据
+     * @param  id
+     * @return  mothPopularity
+     */
+    MothPopularity  getMothPopularityById(Integer  id);
+    /**
+     * 增加数据
+     * @param  mothPopularity
+     * @return Integer
+     */
+    Integer  save(MothPopularity  mothPopularity);
+    /**
+     * 修改数据
+     * @param  mothPopularity
+     * @return Integer
+     */
+    Integer  update(MothPopularity  mothPopularity);
+    /**
+     * 删除数据
+     * @param  id
+     * @return Integer
+     */
+    Integer  delete(Integer  id);
+}

+ 79 - 0
watero-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/acceStatisticsMapper.xml

@@ -0,0 +1,79 @@
+<?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.iamberry.wechat.service.mapper.AcceStatisticsMapper">
+    <resultMap  id="BaseResultMap" type="AcceStatistics" >
+        <result    column="acce_stat_id"    property="acceStatId" />
+        <result    column="acce_stat_type"    property="acceStatType" />
+        <result    column="acce_stat_open_id"    property="acceStatOpenId" />
+        <result    column="acce_stat_create_time"    property="acceStatCreateTime" />
+    </resultMap>
+    <sql    id="Base_List" >
+        t.acce_stat_id,
+        t.acce_stat_type,
+        t.acce_stat_open_id,
+        t.acce_stat_create_time
+    </sql>
+    <select id="getAcceStatisticsList" resultMap="BaseResultMap" parameterType="AcceStatistics" >
+        select
+        <include refid="Base_List" />
+        from tb_iamberry_access_statistics t
+        <where>
+            <if test="acceStatId != null ">
+                AND t.acce_stat_id = #{acceStatId}
+            </if >
+            <if test="acceStatType != null ">
+                AND t.acce_stat_type = #{acceStatType}
+            </if >
+            <if test="acceStatOpenId != null ">
+                AND t.acce_stat_open_id = #{acceStatOpenId}
+            </if >
+        </where>
+    </select>
+    <select id="getAcceStatisticsById" resultMap="BaseResultMap" parameterType="Integer" >
+        select
+        <include refid="Base_List" />
+        from tb_iamberry_access_statistics t
+        where t.acce_stat_id= #{acceStatId}
+    </select>
+    <insert id="save" parameterType="AcceStatistics" >
+        insert into
+        tb_iamberry_access_statistics
+        (
+        acce_stat_id,
+        acce_stat_type,
+        acce_stat_open_id
+        )
+        values
+        (
+        #{acceStatId},
+        #{acceStatType},
+        #{acceStatOpenId}
+        )
+    </insert>
+    <update id="update" parameterType="AcceStatistics" >
+        update
+        tb_iamberry_access_statistics
+        <set >
+            <if test="acceStatType != null ">
+                acce_stat_type = #{acceStatType},
+            </if >
+            <if test="acceStatOpenId != null ">
+                acce_stat_open_id = #{acceStatOpenId},
+            </if >
+        </set >
+        where acce_stat_id= #{acceStatId}
+    </update>
+
+    <select id="getAcceStatiCount" resultType="Integer" parameterType="AcceStatistics" >
+        SELECT
+          COUNT(t.acce_stat_id)
+        FROM
+          tb_iamberry_access_statistics t
+        WHERE
+          date_format(t.acce_stat_create_time,'%Y-%m-%d') = date_format(#{acceStatCreateTime},'%Y-%m-%d')
+        AND t.acce_stat_open_id = #{acceStatOpenId}
+        AND t.acce_stat_type = #{acceStatType}
+    </select>
+
+
+</mapper>

+ 116 - 0
watero-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/mothMovableMapper.xml

@@ -0,0 +1,116 @@
+<?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.iamberry.wechat.service.mapper.MothMovableMapper">
+    <resultMap  id="BaseResultMap" type="MothMovable" >
+        <result    column="moth_mova_id"    property="mothMovaId" />
+        <result    column="moth_mova_open_id"    property="mothMovaOpenId" />
+        <result    column="moth_mova_head"    property="mothMovaHead" />
+        <result    column="moth_mova_text"    property="mothMovaText" />
+        <result    column="moth_mova_share_url"    property="mothMovaShareUrl" />
+        <result    column="moth_mova_back_type"    property="mothMovaBackType" />
+        <result    column="moth_mova_img_url"    property="mothMovaImgUrl" />
+        <result    column="coupon_item_id"    property="couponItemId" />
+        <result    column="moth_mova_create_time"    property="mothMovaCreateTime" />
+    </resultMap>
+    <sql    id="Base_List" >
+        t.moth_mova_id,
+        t.moth_mova_open_id,
+        t.moth_mova_head,
+        t.moth_mova_text,
+        t.moth_mova_share_url,
+        t.moth_mova_back_type,
+        t.moth_mova_img_url,
+        t.coupon_item_id,
+        t.moth_mova_create_time
+    </sql>
+    <select id="getMothMovableList" resultMap="BaseResultMap" parameterType="MothMovable" >
+        select
+        <include refid="Base_List" />
+        from tb_iamberry_mother_movable t
+        <where>
+            <if test="mothMovaId != null ">
+                AND t.moth_mova_id = #{mothMovaId}
+            </if >
+            <if test="mothMovaOpenId != null and mothMovaOpenId != ''">
+                AND t.moth_mova_open_id = #{mothMovaOpenId}
+            </if >
+            <if test="mothMovaBackType != null and mothMovaBackType != ''">
+                AND t.moth_mova_back_type = #{mothMovaBackType}
+            </if >
+            <if test="couponItemId != null and couponItemId != ''">
+                AND t.coupon_item_id = #{couponItemId}
+            </if >
+        </where>
+    </select>
+
+    <select id="getNum" resultType="Integer" parameterType="MothMovable" >
+        select
+	    COUNT(t.moth_mova_id)
+        from tb_iamberry_mother_movable t
+    </select>
+
+    <select id="getMothMovableById" resultMap="BaseResultMap" parameterType="Integer" >
+        select
+        <include refid="Base_List" />
+        from tb_iamberry_mother_movable t
+        where t.moth_mova_id= #{mothMovaId}
+    </select>
+    <insert id="save" parameterType="MothMovable" >
+        insert into
+        tb_iamberry_mother_movable
+        (
+        moth_mova_id,
+        moth_mova_open_id,
+        moth_mova_head,
+        moth_mova_text,
+        moth_mova_share_url,
+        moth_mova_back_type,
+        moth_mova_img_url,
+        coupon_item_id
+        )
+        values
+        (
+        #{mothMovaId},
+        #{mothMovaOpenId},
+        #{mothMovaHead},
+        #{mothMovaText},
+        #{mothMovaShareUrl},
+        #{mothMovaBackType},
+        #{mothMovaImgUrl},
+        #{couponItemId}
+        )
+    </insert>
+    <update id="update" parameterType="MothMovable" >
+        update
+        tb_iamberry_mother_movable
+        <set >
+            <if test="mothMovaOpenId != null ">
+                moth_mova_open_id = #{mothMovaOpenId},
+            </if >
+            <if test="mothMovaHead != null and mothMovaHead != ''">
+                moth_mova_head = #{mothMovaHead},
+            </if >
+            <if test="mothMovaText != null and mothMovaText != ''">
+                moth_mova_text = #{mothMovaText},
+            </if >
+            <if test="mothMovaShareUrl != null and mothMovaShareUrl != ''">
+                moth_mova_share_url = #{mothMovaShareUrl},
+            </if >
+            <if test="mothMovaBackType != null and mothMovaBackType != ''">
+                moth_mova_back_type = #{mothMovaBackType},
+            </if >
+            <if test="mothMovaImgUrl != null and mothMovaImgUrl != ''">
+                moth_mova_img_url = #{mothMovaImgUrl},
+            </if >
+            <if test="couponItemId != null and couponItemId != ''">
+                coupon_item_id = #{couponItemId},
+            </if >
+        </set >
+        where moth_mova_id= #{mothMovaId}
+    </update>
+    <delete id="delete" parameterType="Integer" >
+        delete FROM
+        tb_iamberry_mother_movable
+        where moth_mova_id=#{mothMovaId}
+    </delete>
+</mapper>

+ 71 - 0
watero-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/mothPopularityMapper.xml

@@ -0,0 +1,71 @@
+<?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.iamberry.wechat.service.mapper.MothPopularityMapper">
+    <resultMap  id="BaseResultMap" type="MothPopularity" >
+        <result    column="moth_popu_id"    property="mothPopuId" />
+        <result    column="moth_mova_id"    property="mothMovaId" />
+        <result    column="moth_popu_open_id"    property="mothPopuOpenId" />
+        <result    column="moth_popu_create_time"    property="mothPopuCreateTime" />
+    </resultMap>
+    <sql    id="Base_List" >
+        t.moth_popu_id,
+        t.moth_mova_id,
+        t.moth_popu_open_id,
+        t.moth_popu_create_time
+    </sql>
+    <select id="getMothPopularityList" resultMap="BaseResultMap" parameterType="MothPopularity" >
+        select
+        <include refid="Base_List" />
+        from tb_iamberry_mother_popularity t
+        <where>
+            <if test="mothPopuId != null ">
+                AND t.moth_popu_id = #{mothPopuId}
+            </if >
+            <if test="mothMovaId != null ">
+                AND t.moth_mova_id = #{mothMovaId}
+            </if >
+            <if test="mothPopuOpenId != null ">
+                AND t.moth_popu_open_id = #{mothPopuOpenId}
+            </if >
+        </where>
+    </select>
+    <select id="getMothPopularityById" resultMap="BaseResultMap" parameterType="Integer" >
+        select
+        <include refid="Base_List" />
+        from tb_iamberry_mother_popularity t
+        where t.moth_popu_id= #{mothPopuId}
+    </select>
+    <insert id="save" parameterType="MothPopularity" >
+        insert into
+        tb_iamberry_mother_popularity
+        (
+        moth_popu_id,
+        moth_mova_id,
+        moth_popu_open_id
+        )
+        values
+        (
+        #{mothPopuId},
+        #{mothMovaId},
+        #{mothPopuOpenId}
+        )
+    </insert>
+    <update id="update" parameterType="MothPopularity" >
+        update
+        tb_iamberry_mother_popularity
+        <set >
+            <if test="mothMovaId != null ">
+                moth_mova_id = #{mothMovaId},
+            </if >
+            <if test="mothPopuOpenId != null ">
+                moth_popu_open_id = #{mothPopuOpenId},
+            </if >
+        </set >
+        where moth_popu_id= #{mothPopuId}
+    </update>
+    <delete id="delete" parameterType="Integer" >
+        delete FROM
+        tb_iamberry_mother_popularity
+        where moth_popu_id=#{mothPopuId}
+    </delete>
+</mapper>

+ 202 - 0
watero-wechat-service/src/main/java/com/iamberry/wechat/service/mothMovable/MothMovableServiceImpl.java

@@ -0,0 +1,202 @@
+package com.iamberry.wechat.service.mothMovable;
+
+import com.iamberry.wechat.core.entity.coupon.CouponItem;
+import com.iamberry.wechat.core.entity.coupon.CouponType;
+import com.iamberry.wechat.core.entity.mothMovable.MothMovable;
+import com.iamberry.wechat.core.entity.mothMovable.MothPopularity;
+import com.iamberry.wechat.core.entity.wx.QRCJson;
+import com.iamberry.wechat.face.admin.SystemService;
+import com.iamberry.wechat.face.mothMovable.MothMovableService;
+import com.iamberry.wechat.file.FileUtils;
+import com.iamberry.wechat.service.mapper.CouponItemMapper;
+import com.iamberry.wechat.service.mapper.CouponTypeMapper;
+import com.iamberry.wechat.service.mapper.MothMovableMapper;
+import com.iamberry.wechat.service.mapper.MothPopularityMapper;
+import com.iamberry.wechat.tools.*;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.awt.*;
+import java.io.File;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+/**
+ *  活动生成图片的内容接口
+ * @author xm
+ * @Date 2019-04-25
+ */
+@Service
+public class MothMovableServiceImpl  implements MothMovableService {
+
+    @Autowired
+    private MothMovableMapper mothMovableMapper;
+    @Autowired
+    private MothPopularityMapper mothPopularityMapper;
+    @Autowired
+    private CouponTypeMapper couponTypeMapper;
+    @Autowired
+    private CouponItemMapper couponItemMapper;
+    @Autowired
+    private SystemService systemService;
+
+    /**
+     * 获取集合
+     * @param  mothMovable
+     * @return List
+     */
+    @Override
+    public List<MothMovable> getMothMovableList(MothMovable  mothMovable){
+        return  mothMovableMapper.getMothMovableList(mothMovable);
+    }
+    /**
+     * 查询单条数据
+     * @param  id
+     * @return  mothMovable
+     */
+    @Override
+    public  MothMovable  getMothMovableById(Integer  id){
+        return  mothMovableMapper.getMothMovableById(id);
+    }
+    /**
+     * 增加数据
+     * @param  mothMovable
+     * @return Integer
+     */
+    @Override
+    @Transactional
+    public  Integer  save(MothMovable  mothMovable,String rootPath){
+        //生成优惠券 -- 每位参加活动的人,发送wateroT1-T2滤芯优惠券  ,优惠券限7天内使用,否则实效
+        // 成功参与征集的用户,赠送wateroT1/T2滤芯优惠券,共50个,先到先得
+        Integer flag = 0 ;
+        String uuidStr = "";
+
+        String begin = systemService.selectOneShopRuleByIdDynamic(238).getRuleDesc();
+        Integer num = Integer.valueOf(begin);
+
+        MothMovable mm1 = new MothMovable();
+        Integer allNum = mothMovableMapper.getNum(mm1);
+        if(allNum <= num){
+            //创建优惠券
+            Integer couponId = 10000;
+            CouponType couponType = couponTypeMapper.getCouponTypeById(couponId);
+            Calendar calendar = Calendar.getInstance();
+            calendar.add(Calendar.DATE, 7);  //有效期三个月
+            CouponItem couponItem = new CouponItem();
+            uuidStr = StrUtils.getUUID();
+            couponItem.setCouponItemId(uuidStr);
+            couponItem.setCouponItemUseropenid(mothMovable.getMothMovaOpenId());
+            couponItem.setCouponId(couponId);
+            couponItem.setCouponReceiveDate(new Date());
+            couponItem.setCouponUseEndDate(calendar.getTime());
+            couponItem.setCouponUseStatus(1);
+            couponItem.setCouponItemRemark(couponType.getCouponRemark());
+            flag = couponItemMapper.insertCouponItem(couponItem);
+            if(flag < 1){
+                throw new RuntimeException("创建优惠券失败");
+            }
+        }
+
+        boolean fl = false;
+        //生成图片
+        try {
+            fl = geneImg(mothMovable,rootPath);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        if(fl){
+            //添加数据
+            mothMovable.setCouponItemId(uuidStr);
+            flag = mothMovableMapper.save(mothMovable);
+            if(flag < 1){
+                throw new RuntimeException("添加活动数据失败");
+            }
+        }else{
+            throw new RuntimeException("生成图片失败");
+        }
+        return flag;
+    }
+
+
+    /**
+     *  生成图片
+     * @param mothMovable
+     * @param rootPath  根目录
+     * @return
+     */
+    private boolean geneImg(MothMovable mothMovable,String rootPath)throws Exception{
+        //  ****/common/images/movable/
+        String uuid = UUID.randomUUID().toString().substring(0,8);
+        String codeName  = uuid + "_code.jpg";
+        String headName  = uuid + "_head.jpg";
+        String imgName  = uuid + "_img.jpg";
+        String path  = rootPath + PosterNumUtils.IMG_PATH;
+
+        File targetFile = new File(path);
+        if (!targetFile.exists()) {
+            targetFile.mkdirs();
+        }
+
+        //生成机器二维码
+        String json = String.format(NameUtils.QR_SCENE_STR, 2592000, ResultInfo.barCodeMothMovable + mothMovable.getMothMovaOpenId());
+        QRCJson qrc = WeixinUtil.createQrcode(json);
+
+       /*下载二维码*/
+        DownloadWXCodeUtil.downloadByNIO2(qrc.getUrl(),codeName,path,PosterNumUtils.CODE_WIDTH,PosterNumUtils.CODE_HEIGHT,false);
+        DownloadWXCodeUtil.downloadByNIO2(mothMovable.getMothMovaHead(),headName,path,PosterNumUtils.HEAD_WIDTH,PosterNumUtils.HEAD_HEIGHT,true);
+
+        /*海报位置*/
+        String newImg = path+imgName;
+		/*二维码位置*/
+        String codeImg = path + codeName;
+		/*头像位置*/
+        String headImg = path + headName;
+
+		/*复制海报*/ //common/images/activity/ditu.jpg
+        String oldImgPath = path + PosterNumUtils.getBackPath(mothMovable.getMothMovaBackType());
+        FileUtils.copyFile(oldImgPath,newImg);
+
+        mothMovable.setMothMovaImgUrl(PosterNumUtils.IMG_PATH + imgName);
+        mothMovable.setMothMovaShareUrl(qrc.getUrl());
+
+			  /*添加文字*/
+        ImageUtils.pressPost(newImg,
+                headImg,PosterNumUtils.HEAD_X,PosterNumUtils.HEAD_Y,
+                codeImg,PosterNumUtils.CODE_X,PosterNumUtils.CODE_Y,
+                mothMovable.getUserNickname(),PosterNumUtils.TEXT_X,PosterNumUtils.TEXT_Y,new Color(221,106,140),PosterNumUtils.TEXT_FONT_SIZE,
+                mothMovable.getMothMovaText(),PosterNumUtils.TEXT_CONTENT_X,PosterNumUtils.TEXT_CONTENT_Y,new Color(0,0,0),PosterNumUtils.TEXT_CONTENT_FONT_SIZE
+        );
+        return true;
+    }
+
+    /**
+     * 修改数据
+     * @param  mothMovable
+     * @return Integer
+     */
+    @Override
+    public  Integer  update(MothMovable  mothMovable){
+        return  mothMovableMapper.update(mothMovable);
+    }
+    /**
+     * 删除数据
+     * @param  id
+     * @return Integer
+     */
+    @Override
+    public  Integer  delete(Integer  id){
+        return  mothMovableMapper.delete(id);
+    }
+
+    @Override
+    public Integer scanInfo(Integer mothMovaId, String openId) {
+        MothPopularity mothPopularity = new MothPopularity();
+        mothPopularity.setMothPopuId(mothMovaId);
+        mothPopularity.setMothPopuOpenId(openId);
+        return mothPopularityMapper.save(mothPopularity);
+    }
+}

+ 70 - 0
watero-wechat-service/src/main/java/com/iamberry/wechat/service/mothMovable/MothPopularityServiceImpl.java

@@ -0,0 +1,70 @@
+package com.iamberry.wechat.service.mothMovable;
+
+import com.iamberry.wechat.core.entity.mothMovable.MothPopularity;
+import com.iamberry.wechat.face.mothMovable.MothPopularityService;
+//import com.iamberry.wechat.service.mapper.MothMovableMapper;
+import com.iamberry.wechat.service.mapper.MothPopularityMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ *  活动生成二维码,关注人数统计接口
+ * @author xm
+ * @Date 2019-04-25
+ */
+@Service
+public class MothPopularityServiceImpl  implements MothPopularityService {
+    @Autowired
+    private MothPopularityMapper mothPopularityMapper;
+
+//    @Autowired
+//    private MothMovableMapper mothMovableMapper;
+
+    /**
+     * 获取集合
+     * @param  mothPopularity
+     * @return List
+     */
+    @Override
+    public List<MothPopularity> getMothPopularityList(MothPopularity  mothPopularity){
+        return  mothPopularityMapper.getMothPopularityList(mothPopularity);
+    }
+    /**
+     * 查询单条数据
+     * @param  id
+     * @return  mothPopularity
+     */
+    @Override
+    public  MothPopularity  getMothPopularityById(Integer  id){
+        return  mothPopularityMapper.getMothPopularityById(id);
+    }
+    /**
+     * 增加数据
+     * @param  mothPopularity
+     * @return Integer
+     */
+    @Override
+    public  Integer  save(MothPopularity  mothPopularity){
+        return  mothPopularityMapper.save(mothPopularity);
+    }
+    /**
+     * 修改数据
+     * @param  mothPopularity
+     * @return Integer
+     */
+    @Override
+    public  Integer  update(MothPopularity  mothPopularity){
+        return  mothPopularityMapper.update(mothPopularity);
+    }
+    /**
+     * 删除数据
+     * @param  id
+     * @return Integer
+     */
+    @Override
+    public  Integer  delete(Integer  id){
+        return  mothPopularityMapper.delete(id);
+    }
+}

+ 61 - 0
watero-wechat-service/src/main/java/com/iamberry/wechat/service/stati/AcceStatisticsServiceImpl.java

@@ -0,0 +1,61 @@
+package com.iamberry.wechat.service.stati;
+
+import com.iamberry.wechat.core.entity.stati.AcceStatistics;
+import com.iamberry.wechat.face.stati.AcceStatisticsService;
+import com.iamberry.wechat.service.mapper.AcceStatisticsMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ *  访问统计接口
+ * @author xm
+ * @Date 2019-04-25
+ */
+@Service
+public class AcceStatisticsServiceImpl  implements AcceStatisticsService {
+    @Autowired
+    private AcceStatisticsMapper acceStatisticsMapper;
+    /**
+     * 获取集合
+     * @param  acceStatistics
+     * @return List
+     */
+    @Override
+    public List<AcceStatistics> getAcceStatisticsList(AcceStatistics  acceStatistics){
+        return  acceStatisticsMapper.getAcceStatisticsList(acceStatistics);
+    }
+    /**
+     * 查询单条数据
+     * @param  id
+     * @return  acceStatistics
+     */
+    @Override
+    public  AcceStatistics  getAcceStatisticsById(Integer  id){
+        return  acceStatisticsMapper.getAcceStatisticsById(id);
+    }
+    /**
+     * 增加数据
+     * @param  acceStatistics
+     * @return Integer
+     */
+    @Override
+    public  Integer  save(AcceStatistics  acceStatistics){
+        return  acceStatisticsMapper.save(acceStatistics);
+    }
+    /**
+     * 修改数据
+     * @param  acceStatistics
+     * @return Integer
+     */
+    @Override
+    public  Integer  update(AcceStatistics  acceStatistics){
+        return  acceStatisticsMapper.update(acceStatistics);
+    }
+
+    @Override
+    public Integer getAcceStatiCount(AcceStatistics acceStatistics) {
+        return  acceStatisticsMapper.getAcceStatiCount(acceStatistics);
+    }
+}

+ 43 - 1
watero-wechat-service/src/main/java/com/iamberry/wechat/service/wechat/WeChatServiceImpl.java

@@ -10,6 +10,7 @@ import com.iamberry.wechat.core.entity.activity.ActivityDate;
 import com.iamberry.wechat.core.entity.admin.FullReduction;
 import com.iamberry.wechat.service.ActivityUtil;
 import com.iamberry.wechat.service.member.dao.MemberDao;
+import com.iamberry.wechat.service.mothMovable.MothMovableServiceImpl;
 import com.iamberry.wechat.tools.*;
 import net.sf.json.JSONObject;
 
@@ -80,6 +81,8 @@ public class WeChatServiceImpl implements WeChatService {
 	private MemberDao memberDao;
 	@Autowired
 	private ActivityUtil activityUtil;
+	@Autowired
+	private MothMovableServiceImpl mothMovableService;
 	/**
 	 * 处理微信发来的请求
 	 * @return
@@ -178,7 +181,13 @@ public class WeChatServiceImpl implements WeChatService {
 							return status.getCountext();
 						}
 						respContent = status.getCountext();
-					} else {
+					} else if(eventKey.indexOf(ResultInfo.barCodeMothMovable) != -1){
+						Status status = scannQrcodeMothMovable(requestMap, fromUserName,false);
+						if (status.isFlag()) {
+							return status.getCountext();
+						}
+						respContent = status.getCountext();
+					}else {
 						// 已关注用户扫描二维码事件
 						int flag = subUserScannQrcodeEvent(requestMap, fromUserName);
 						if (flag == 1) {
@@ -207,6 +216,12 @@ public class WeChatServiceImpl implements WeChatService {
 								return status.getCountext();
 							}
 							respContent = status.getCountext();
+						}else if(eventKey.indexOf(ResultInfo.barCodeMothMovable) != -1){
+							Status status = scannQrcodeMothMovable(requestMap, fromUserName,false);
+							if (status.isFlag()) {
+								return status.getCountext();
+							}
+							respContent = status.getCountext();
 						} else {
 							//未关注用户扫描二维码关注事件处理
 							Status status = scannQRcodeSub(requestMap, fromUserName);
@@ -294,6 +309,33 @@ public class WeChatServiceImpl implements WeChatService {
 	}
 
 	/**
+	 * 母亲节活动扫码进入
+	 * @param requestMap
+	 */
+	public Status scannQrcodeMothMovable(Map<String, String> requestMap, String fromUserName,Boolean isSubscription) {
+		Status status = new Status();
+		String senceid = requestMap.get("EventKey");//场景值
+
+		Member member = refreshUserInfo(fromUserName);
+
+		senceid = senceid.replaceAll(ResultInfo.barCodeMothMovable,"");//替换标识前的字符串
+		if(!isSubscription){
+			senceid = senceid.replaceAll(ResultInfo.barCode,"");
+		}
+
+		Integer mothMovaId = Integer.valueOf(senceid);
+		Integer flag = mothMovableService.scanInfo(mothMovaId,member.getUserOpenid());
+		if(flag < 1){
+			status.setCountext("");
+			status.setFlag(false);
+		}else{
+			status.setCountext("");
+			status.setFlag(false);
+		}
+		return status;
+	}
+
+	/**
 	 * 扫码进入赠送礼品信息页面(未关注)
 	 * @param requestMap
 	 * @param fromUserName

+ 127 - 0
watero-wechat-web/src/main/java/com/iamberry/wechat/handles/mothMovable/MothMovableHandler.java

@@ -0,0 +1,127 @@
+package com.iamberry.wechat.handles.mothMovable;
+
+import com.iamberry.wechat.core.entity.ResultMsg;
+import com.iamberry.wechat.core.entity.WechatUtils;
+import com.iamberry.wechat.core.entity.member.Member;
+import com.iamberry.wechat.core.entity.mothMovable.MothMovable;
+import com.iamberry.wechat.core.entity.stati.AcceStatistics;
+import com.iamberry.wechat.face.member.MemberService;
+import com.iamberry.wechat.face.mothMovable.MothMovableService;
+import com.iamberry.wechat.face.stati.AcceStatisticsService;
+import com.iamberry.wechat.tools.ResultInfo;
+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.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * xm
+ * 母亲节活动
+ * @Date 2019
+ */
+@Controller
+@RequestMapping("/wechat/moth_movable")
+public class MothMovableHandler {
+    private final static String ENCODE = "utf-8";
+
+    @Autowired
+    private MothMovableService mothMovableService;
+    @Autowired
+    private MemberService memberService;
+    @Autowired
+    private AcceStatisticsService acceStatisticsService;
+
+    /**
+     * 获取二维码
+     * @return
+     * @throws Exception
+     */
+    @ResponseBody
+    @RequestMapping(value = "/save_movable", method = RequestMethod.POST)
+    public ResultMsg saveMvable( HttpServletResponse response,HttpServletRequest request,MothMovable mothMovable) throws Exception {
+        long x = System.currentTimeMillis();
+        ResultMsg msg = new ResultMsg();
+
+        Member member = WechatUtils.getUserBySession(request);
+        member = memberService.getMemberByUserOpenId(member.getUserOpenid());
+
+        if(mothMovable.getMothMovaBackType() == null){
+            return new ResultMsg(false,  ResultMsg.ERROR, "未选择背景图片",null);
+        }
+
+        if(mothMovable.getMothMovaText() == null || "".equals(mothMovable.getMothMovaText())){
+            return new ResultMsg(false,  ResultMsg.ERROR, "未输入文字",null);
+        }
+        if(mothMovable.getMothMovaText().length() > 200){
+            return new ResultMsg(false,  ResultMsg.ERROR, "文字超出限制",null);
+        }
+
+        MothMovable mothM = new MothMovable();
+        mothM.setMothMovaOpenId(member.getUserOpenid());
+        List<MothMovable>mothMovableList = mothMovableService.getMothMovableList(mothM);
+        if(mothMovableList != null && mothMovableList.size() > 0 ){
+            return new ResultMsg(false,  ResultMsg.ERROR, "已经生成过活动图片了,请刷新页面",null);
+        }
+
+        String realPath = request.getSession().getServletContext().getRealPath("/");
+
+        mothMovable.setMothMovaOpenId(member.getUserOpenid());
+        mothMovable.setMothMovaHead(member.getUserHead());
+
+        String name = java.net.URLDecoder.decode( member.getUserNickname(), ENCODE);
+        mothMovable.setUserNickname(name);
+        try {
+            Integer falg = mothMovableService.save(mothMovable,realPath);
+        }catch (Exception e){
+            return new ResultMsg(false,  ResultMsg.ERROR, e.getMessage(),null);
+        }
+        msg.setResultCode(ResultInfo.SUCCESSCODE);
+        msg.setData(mothMovable);
+        msg.setStatus(true);
+        long y = System.currentTimeMillis();
+        System.out.println("响应时间:"+ (y-x));
+        return msg;
+    }
+
+    /**
+     * 获取自己生成图片
+     * @return
+     * @throws Exception
+     */
+    @ResponseBody
+    @RequestMapping(value = "/get_moth", method = RequestMethod.POST)
+    public ResultMsg getMoth( HttpServletResponse response,HttpServletRequest request) throws Exception {
+        ResultMsg msg = new ResultMsg();
+
+        Member member = WechatUtils.getUserBySession(request);
+
+        //进入活动的UV埋点
+        AcceStatistics acceStatistics = new AcceStatistics();
+        acceStatistics.setAcceStatOpenId(member.getUserOpenid());
+        acceStatistics.setAcceStatType(1);
+        acceStatistics.setJudgeTime(new Date());
+        Integer count = acceStatisticsService.getAcceStatiCount(acceStatistics);
+        if(count < 0){  //添加UV访问
+            Integer flag = acceStatisticsService.save(acceStatistics);
+        }
+
+        MothMovable mothMovable = new MothMovable();
+        mothMovable.setMothMovaOpenId(member.getUserOpenid());
+        List<MothMovable>  mothMovableList = mothMovableService.getMothMovableList(mothMovable);
+        if(mothMovableList == null || mothMovableList.size() < 1){  //未参与活动
+            return new ResultMsg(false,  ResultMsg.ERROR, "未参与活动,请参与活动!",null);
+        }
+        mothMovable = mothMovableList.get(0);
+        msg.setData(mothMovable);
+        msg.setResultCode(ResultInfo.SUCCESSCODE);
+        msg.setStatus(true);
+        return msg;
+    }
+
+}

+ 12 - 0
watero-wechat-web/src/main/resources/iamberry-wechat-service-mybatis.xml

@@ -231,6 +231,12 @@
 		<!--首页热销产品-->
 		<typeAlias type="com.iamberry.wechat.core.entity.product.IndexProduct" alias="IndexProduct"/>
 
+		<!--访问统计-->
+		<typeAlias type="com.iamberry.wechat.core.entity.stati.AcceStatistics" alias="AcceStatistics"/>
+		<!--母亲节活动-->
+		<typeAlias type="com.iamberry.wechat.core.entity.mothMovable.MothMovable" alias="MothMovable"/>
+		<typeAlias type="com.iamberry.wechat.core.entity.mothMovable.MothPopularity" alias="MothPopularity"/>
+
 		<package name="com.iamberry.wechat.core.entity.rent"/>
 	</typeAliases>
 	<mappers>
@@ -324,5 +330,11 @@
 		<!--首页热销产品-->
 		<mapper resource="com/iamberry/wechat/service/mapper/indexProductMapper.xml"/>
 
+		<!--访问统计-->
+		<mapper resource="com/iamberry/wechat/service/mapper/acceStatisticsMapper.xml"/>
+		<!--母亲节活动-->
+		<mapper resource="com/iamberry/wechat/service/mapper/mothMovableMapper.xml"/>
+		<mapper resource="com/iamberry/wechat/service/mapper/mothPopularityMapper.xml"/>
+
 	</mappers>
 </configuration>