Browse Source

服务器添加支持微信FormId缓存,用于营销或者非用户操作期间通过模版消息通知用户

Menethil 7 years ago
parent
commit
0aeb3678e1

+ 20 - 3
litemall-core/src/main/java/org/linlinjava/litemall/core/notify/NotifyService.java

@@ -73,19 +73,36 @@ public class NotifyService {
     /**
      * 微信模版消息通知
      *
-     * @param token      通过wxMAService获取token或者通过url请求token
      * @param touser     接收者openId
      * @param formId     表单ID或者 prepayId
      * @param notifyType 通知类别,通过该枚举值在配置文件中获取相应的模版ID
      * @param params     通知模版内容里的参数,类似"您的验证码为{1}"中{1}的值
      */
     @Async
-    public void notifyWxTemplate(String token, String touser, String formId, NotifyType notifyType, String[] params) {
+    public void notifyWxTemplate(String touser, String formId, NotifyType notifyType, String[] params) {
         if (wxTemplateSender == null)
             return;
 
         String templateId = getTemplateId(notifyType, wxTemplate);
-        wxTemplateSender.sendWechatMsg(token, touser, templateId, formId, "", "", params);
+        wxTemplateSender.sendWechatMsg(touser, templateId, formId, "", "", params);
+    }
+
+    /**
+     * 微信模版消息通知
+     * <p>
+     * 该方法会尝试从数据库获取缓存的FormId去发送消息
+     *
+     * @param touser     接收者openId
+     * @param notifyType 通知类别,通过该枚举值在配置文件中获取相应的模版ID
+     * @param params     通知模版内容里的参数,类似"您的验证码为{1}"中{1}的值
+     */
+    @Async
+    public void notifyWxTemplate(String touser, NotifyType notifyType, String[] params) {
+        if (wxTemplateSender == null)
+            return;
+
+        String templateId = getTemplateId(notifyType, wxTemplate);
+        wxTemplateSender.sendWechatMsg(touser, templateId, params);
     }
 
     /**

+ 28 - 4
litemall-core/src/main/java/org/linlinjava/litemall/core/notify/WxTemplateSender.java

@@ -1,8 +1,10 @@
 package org.linlinjava.litemall.core.notify;
 
+import cn.binarywang.wx.miniapp.api.WxMaService;
 import org.json.JSONObject;
+import org.linlinjava.litemall.db.domain.LitemallUserFormid;
+import org.linlinjava.litemall.db.service.LitemallUserFormIdService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
 
 import javax.net.ssl.*;
 import java.io.BufferedReader;
@@ -19,6 +21,27 @@ import java.security.cert.X509Certificate;
  * 微信模版消息通知
  */
 public class WxTemplateSender {
+    @Autowired
+    WxMaService wxMaService;
+
+    @Autowired
+    LitemallUserFormIdService formIdService;
+
+    /**
+     * 发送微信消息(模板消息)
+     *
+     * @param touser    用户 OpenID
+     * @param templatId 模板消息ID
+     * @param parms     详细内容
+     */
+    public void sendWechatMsg(String touser, String templatId, String[] parms) {
+        LitemallUserFormid userFormid = formIdService.queryByOpenId(touser);
+        if (userFormid == null)
+            return;
+        sendWechatMsg(touser, templatId, userFormid.getFormid(), "", "", parms);
+
+        formIdService.delUserFormid(userFormid.getId());
+    }
 
     /**
      * 发送微信消息(模板消息)
@@ -31,9 +54,9 @@ public class WxTemplateSender {
      * @param parms     详细内容
      * @return
      */
-    public String sendWechatMsg(String token, String touser, String templatId, String formId, String clickurl, String topcolor, String[] parms) {
+    public String sendWechatMsg(String touser, String templatId, String formId, String clickurl, String topcolor, String[] parms) {
         try {
-            String tmpurl = "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=" + token;
+            String tmpurl = "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=" + wxMaService.getAccessToken();
             JSONObject json = new JSONObject();
             json.put("touser", touser);
             json.put("template_id", templatId);
@@ -57,6 +80,7 @@ public class WxTemplateSender {
 
     /**
      * 根据参数生成对应的 json 数据
+     *
      * @param parms
      * @return
      */
@@ -64,7 +88,7 @@ public class WxTemplateSender {
         JSONObject json = new JSONObject();
         for (int i = 1; i <= parms.length; i++) {
             JSONObject json2 = new JSONObject();
-            json2.put("value", parms[i-1]);
+            json2.put("value", parms[i - 1]);
 
             json.put("keyword" + i, json2);
         }

+ 1 - 2
litemall-core/src/test/java/org/linlinjava/litemall/core/WxTemplateTest.java

@@ -21,11 +21,10 @@ public class WxTemplateTest {
 
     @Test
     public void testPaySucceed() {
-        String token = "xx";
         String touser = "xx";
         String formId = "";
         String[] params = new String[]{"xxx"};
-        notifyService.notifyWxTemplate(token, touser, formId, NotifyType.PAY_SUCCEED, params);
+        notifyService.notifyWxTemplate(touser, formId, NotifyType.PAY_SUCCEED, params);
         try {
             Thread.sleep(5000);
         } catch (InterruptedException e) {

+ 46 - 34
litemall-db/mybatis-generator/generatorConfig.xml

@@ -20,7 +20,7 @@
         <!-- 查询单条数据插件 -->
         <plugin type="com.itfsw.mybatis.generator.plugins.SelectOneByExamplePlugin"/>
         <!-- 查询结果选择性返回插件 -->
-        <plugin type="com.itfsw.mybatis.generator.plugins.SelectSelectivePlugin" />
+        <plugin type="com.itfsw.mybatis.generator.plugins.SelectSelectivePlugin"/>
         <!-- Example Criteria 增强插件 -->
         <plugin type="com.itfsw.mybatis.generator.plugins.ExampleEnhancedPlugin"/>
         <!-- 数据Model属性对应Column获取插件 -->
@@ -47,77 +47,81 @@
         <jdbcConnection driverClass="com.mysql.jdbc.Driver"
                         connectionURL="jdbc:mysql://127.0.0.1:3306/litemall?useUnicode=true&amp;characterEncoding=UTF-8&amp;serverTimezone=UTC&amp;verifyServerCertificate=false&amp;useSSL=false"
                         userId="litemall"
-                        password="litemall123456" />
+                        password="litemall123456"/>
 
 
-        <javaModelGenerator targetPackage="org.linlinjava.litemall.db.domain" targetProject="src/main/java" />
-        <sqlMapGenerator targetPackage="org.linlinjava.litemall.db.dao" targetProject="src/main/resources" />
-        <javaClientGenerator type="XMLMAPPER" targetPackage="org.linlinjava.litemall.db.dao" targetProject="src/main/java" />
+        <javaModelGenerator targetPackage="org.linlinjava.litemall.db.domain" targetProject="src/main/java"/>
+        <sqlMapGenerator targetPackage="org.linlinjava.litemall.db.dao" targetProject="src/main/resources"/>
+        <javaClientGenerator type="XMLMAPPER" targetPackage="org.linlinjava.litemall.db.dao"
+                             targetProject="src/main/java"/>
         <!--表名-->
         <table tableName="litemall_ad">
-            <generatedKey column="id" sqlStatement="MySql" identity="true" />
+            <generatedKey column="id" sqlStatement="MySql" identity="true"/>
             <columnOverride javaType="java.time.LocalDateTime" column="start_time"/>
             <columnOverride javaType="java.time.LocalDateTime" column="end_time"/>
             <columnOverride javaType="java.time.LocalDateTime" column="add_time"/>
         </table>
         <table tableName="litemall_address">
-            <generatedKey column="id" sqlStatement="MySql" identity="true" />
+            <generatedKey column="id" sqlStatement="MySql" identity="true"/>
             <columnOverride javaType="java.time.LocalDateTime" column="add_time"/>
         </table>
         <table tableName="litemall_admin">
-            <generatedKey column="id" sqlStatement="MySql" identity="true" />
+            <generatedKey column="id" sqlStatement="MySql" identity="true"/>
             <columnOverride javaType="java.time.LocalDateTime" column="last_login_time"/>
             <columnOverride javaType="java.time.LocalDateTime" column="add_time"/>
         </table>
         <table tableName="litemall_brand">
-            <generatedKey column="id" sqlStatement="MySql" identity="true" />
+            <generatedKey column="id" sqlStatement="MySql" identity="true"/>
             <columnOverride javaType="java.time.LocalDateTime" column="add_time"/>
         </table>
         <table tableName="litemall_cart">
-            <generatedKey column="id" sqlStatement="MySql" identity="true" />
-            <columnOverride column="specifications" javaType="java.lang.String[]" typeHandler="org.linlinjava.litemall.db.mybatis.JsonStringArrayTypeHandler"/>
+            <generatedKey column="id" sqlStatement="MySql" identity="true"/>
+            <columnOverride column="specifications" javaType="java.lang.String[]"
+                            typeHandler="org.linlinjava.litemall.db.mybatis.JsonStringArrayTypeHandler"/>
             <columnOverride javaType="java.time.LocalDateTime" column="add_time"/>
         </table>
         <table tableName="litemall_category">
-            <generatedKey column="id" sqlStatement="MySql" identity="true" />
+            <generatedKey column="id" sqlStatement="MySql" identity="true"/>
             <columnOverride javaType="java.time.LocalDateTime" column="add_time"/>
         </table>
         <table tableName="litemall_collect">
-            <generatedKey column="id" sqlStatement="MySql" identity="true" />
+            <generatedKey column="id" sqlStatement="MySql" identity="true"/>
             <columnOverride javaType="java.time.LocalDateTime" column="add_time"/>
         </table>
         <table tableName="litemall_comment">
-            <generatedKey column="id" sqlStatement="MySql" identity="true" />
+            <generatedKey column="id" sqlStatement="MySql" identity="true"/>
             <columnOverride javaType="java.time.LocalDateTime" column="add_time"/>
-            <columnOverride column="pic_urls" javaType="java.lang.String[]" typeHandler="org.linlinjava.litemall.db.mybatis.JsonStringArrayTypeHandler"/>
+            <columnOverride column="pic_urls" javaType="java.lang.String[]"
+                            typeHandler="org.linlinjava.litemall.db.mybatis.JsonStringArrayTypeHandler"/>
         </table>
         <table tableName="litemall_footprint">
-            <generatedKey column="id" sqlStatement="MySql" identity="true" />
+            <generatedKey column="id" sqlStatement="MySql" identity="true"/>
             <columnOverride javaType="java.time.LocalDateTime" column="add_time"/>
         </table>
         <table tableName="litemall_goods">
-            <generatedKey column="id" sqlStatement="MySql" identity="true" />
+            <generatedKey column="id" sqlStatement="MySql" identity="true"/>
             <columnOverride javaType="java.time.LocalDateTime" column="add_time"/>
-            <columnOverride column="gallery" javaType="java.lang.String[]" typeHandler="org.linlinjava.litemall.db.mybatis.JsonStringArrayTypeHandler"/>
+            <columnOverride column="gallery" javaType="java.lang.String[]"
+                            typeHandler="org.linlinjava.litemall.db.mybatis.JsonStringArrayTypeHandler"/>
         </table>
         <table tableName="litemall_goods_attribute">
-            <generatedKey column="id" sqlStatement="MySql" identity="true" />
+            <generatedKey column="id" sqlStatement="MySql" identity="true"/>
             <columnOverride javaType="java.time.LocalDateTime" column="add_time"/>
         </table>
         <table tableName="litemall_goods_specification">
-            <generatedKey column="id" sqlStatement="MySql" identity="true" />
+            <generatedKey column="id" sqlStatement="MySql" identity="true"/>
             <columnOverride javaType="java.time.LocalDateTime" column="add_time"/>
         </table>
         <table tableName="litemall_issue">
-            <generatedKey column="id" sqlStatement="MySql" identity="true" />
+            <generatedKey column="id" sqlStatement="MySql" identity="true"/>
             <columnOverride javaType="java.time.LocalDateTime" column="add_time"/>
         </table>
         <table tableName="litemall_keyword">
-            <generatedKey column="id" sqlStatement="MySql" identity="true" />
+            <generatedKey column="id" sqlStatement="MySql" identity="true"/>
             <columnOverride javaType="java.time.LocalDateTime" column="add_time"/>
         </table>
         <table tableName="litemall_order">
-            <generatedKey column="id" sqlStatement="MySql" identity="true" />
+            <generatedKey column="id" sqlStatement="MySql" identity="true"/>
             <columnOverride javaType="java.time.LocalDateTime" column="add_time"/>
             <columnOverride javaType="java.time.LocalDateTime" column="pay_time"/>
             <columnOverride javaType="java.time.LocalDateTime" column="ship_time"/>
@@ -125,40 +129,48 @@
             <columnOverride javaType="java.time.LocalDateTime" column="end_time"/>
         </table>
         <table tableName="litemall_order_goods">
-            <generatedKey column="id" sqlStatement="MySql" identity="true" />
-            <columnOverride column="specifications" javaType="java.lang.String[]" typeHandler="org.linlinjava.litemall.db.mybatis.JsonStringArrayTypeHandler"/>
+            <generatedKey column="id" sqlStatement="MySql" identity="true"/>
+            <columnOverride column="specifications" javaType="java.lang.String[]"
+                            typeHandler="org.linlinjava.litemall.db.mybatis.JsonStringArrayTypeHandler"/>
             <columnOverride javaType="java.time.LocalDateTime" column="add_time"/>
         </table>
         <table tableName="litemall_product">
-            <generatedKey column="id" sqlStatement="MySql" identity="true" />
-            <columnOverride column="specifications" javaType="java.lang.String[]" typeHandler="org.linlinjava.litemall.db.mybatis.JsonStringArrayTypeHandler"/>
+            <generatedKey column="id" sqlStatement="MySql" identity="true"/>
+            <columnOverride column="specifications" javaType="java.lang.String[]"
+                            typeHandler="org.linlinjava.litemall.db.mybatis.JsonStringArrayTypeHandler"/>
             <columnOverride javaType="java.time.LocalDateTime" column="add_time"/>
         </table>
         <table tableName="litemall_region">
-            <generatedKey column="id" sqlStatement="MySql" identity="true" />
+            <generatedKey column="id" sqlStatement="MySql" identity="true"/>
         </table>
         <table tableName="litemall_search_history">
-            <generatedKey column="id" sqlStatement="MySql" identity="true" />
+            <generatedKey column="id" sqlStatement="MySql" identity="true"/>
             <columnOverride javaType="java.time.LocalDateTime" column="add_time"/>
         </table>
         <table tableName="litemall_storage">
-            <generatedKey column="id" sqlStatement="MySql" identity="true" />
+            <generatedKey column="id" sqlStatement="MySql" identity="true"/>
             <columnOverride javaType="java.time.LocalDateTime" column="modified"/>
             <columnOverride javaType="java.time.LocalDateTime" column="add_time"/>
         </table>
         <table tableName="litemall_topic">
-            <generatedKey column="id" sqlStatement="MySql" identity="true" />
-            <columnOverride column="goods" javaType="java.lang.Integer[]" typeHandler="org.linlinjava.litemall.db.mybatis.JsonIntegerArrayTypeHandler"/>
+            <generatedKey column="id" sqlStatement="MySql" identity="true"/>
+            <columnOverride column="goods" javaType="java.lang.Integer[]"
+                            typeHandler="org.linlinjava.litemall.db.mybatis.JsonIntegerArrayTypeHandler"/>
             <columnOverride javaType="java.time.LocalDateTime" column="add_time"/>
         </table>
         <table tableName="litemall_user">
-            <generatedKey column="id" sqlStatement="MySql" identity="true" />
+            <generatedKey column="id" sqlStatement="MySql" identity="true"/>
             <columnOverride javaType="java.time.LocalDate" column="birthday"/>
             <columnOverride javaType="java.time.LocalDateTime" column="last_login_time"/>
             <columnOverride javaType="java.time.LocalDateTime" column="add_time"/>
         </table>
         <table tableName="litemall_system">
-            <generatedKey column="id" sqlStatement="MySql" identity="true" />
+            <generatedKey column="id" sqlStatement="MySql" identity="true"/>
+        </table>
+
+        <table tableName="litemall_user_formid">
+            <generatedKey column="id" sqlStatement="MySql" identity="true"/>
+            <columnOverride javaType="java.time.LocalDateTime" column="expire_time"/>
         </table>
     </context>
 </generatorConfiguration>

+ 132 - 0
litemall-db/src/main/java/org/linlinjava/litemall/db/dao/LitemallUserFormidMapper.java

@@ -0,0 +1,132 @@
+package org.linlinjava.litemall.db.dao;
+
+import java.util.List;
+import org.apache.ibatis.annotations.Param;
+import org.linlinjava.litemall.db.domain.LitemallUserFormid;
+import org.linlinjava.litemall.db.domain.LitemallUserFormidExample;
+
+public interface LitemallUserFormidMapper {
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     */
+    long countByExample(LitemallUserFormidExample example);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     */
+    int deleteByExample(LitemallUserFormidExample example);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     */
+    int deleteByPrimaryKey(Integer id);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     */
+    int insert(LitemallUserFormid record);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     */
+    int insertSelective(LitemallUserFormid record);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     * @project https://github.com/itfsw/mybatis-generator-plugin
+     */
+    LitemallUserFormid selectOneByExample(LitemallUserFormidExample example);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     * @project https://github.com/itfsw/mybatis-generator-plugin
+     */
+    LitemallUserFormid selectOneByExampleSelective(@Param("example") LitemallUserFormidExample example, @Param("selective") LitemallUserFormid.Column ... selective);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     * @project https://github.com/itfsw/mybatis-generator-plugin
+     */
+    List<LitemallUserFormid> selectByExampleSelective(@Param("example") LitemallUserFormidExample example, @Param("selective") LitemallUserFormid.Column ... selective);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     */
+    List<LitemallUserFormid> selectByExample(LitemallUserFormidExample example);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     * @project https://github.com/itfsw/mybatis-generator-plugin
+     */
+    LitemallUserFormid selectByPrimaryKeySelective(@Param("id") Integer id, @Param("selective") LitemallUserFormid.Column ... selective);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     */
+    LitemallUserFormid selectByPrimaryKey(Integer id);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     */
+    int updateByExampleSelective(@Param("record") LitemallUserFormid record, @Param("example") LitemallUserFormidExample example);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     */
+    int updateByExample(@Param("record") LitemallUserFormid record, @Param("example") LitemallUserFormidExample example);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     */
+    int updateByPrimaryKeySelective(LitemallUserFormid record);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     */
+    int updateByPrimaryKey(LitemallUserFormid record);
+}

+ 409 - 0
litemall-db/src/main/java/org/linlinjava/litemall/db/domain/LitemallUserFormid.java

@@ -0,0 +1,409 @@
+package org.linlinjava.litemall.db.domain;
+
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+public class LitemallUserFormid {
+    /**
+     *
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database column litemall_user_formid.id
+     *
+     * @mbg.generated
+     */
+    private Integer id;
+
+    /**
+     *
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database column litemall_user_formid.formId
+     *
+     * @mbg.generated
+     */
+    private String formid;
+
+    /**
+     *
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database column litemall_user_formid.isprepay
+     *
+     * @mbg.generated
+     */
+    private Boolean isprepay;
+
+    /**
+     *
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database column litemall_user_formid.useAmount
+     *
+     * @mbg.generated
+     */
+    private Integer useamount;
+
+    /**
+     *
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database column litemall_user_formid.expire_time
+     *
+     * @mbg.generated
+     */
+    private LocalDateTime expireTime;
+
+    /**
+     *
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database column litemall_user_formid.openId
+     *
+     * @mbg.generated
+     */
+    private String openid;
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method returns the value of the database column litemall_user_formid.id
+     *
+     * @return the value of litemall_user_formid.id
+     *
+     * @mbg.generated
+     */
+    public Integer getId() {
+        return id;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method sets the value of the database column litemall_user_formid.id
+     *
+     * @param id the value for litemall_user_formid.id
+     *
+     * @mbg.generated
+     */
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method returns the value of the database column litemall_user_formid.formId
+     *
+     * @return the value of litemall_user_formid.formId
+     *
+     * @mbg.generated
+     */
+    public String getFormid() {
+        return formid;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method sets the value of the database column litemall_user_formid.formId
+     *
+     * @param formid the value for litemall_user_formid.formId
+     *
+     * @mbg.generated
+     */
+    public void setFormid(String formid) {
+        this.formid = formid;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method returns the value of the database column litemall_user_formid.isprepay
+     *
+     * @return the value of litemall_user_formid.isprepay
+     *
+     * @mbg.generated
+     */
+    public Boolean getIsprepay() {
+        return isprepay;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method sets the value of the database column litemall_user_formid.isprepay
+     *
+     * @param isprepay the value for litemall_user_formid.isprepay
+     *
+     * @mbg.generated
+     */
+    public void setIsprepay(Boolean isprepay) {
+        this.isprepay = isprepay;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method returns the value of the database column litemall_user_formid.useAmount
+     *
+     * @return the value of litemall_user_formid.useAmount
+     *
+     * @mbg.generated
+     */
+    public Integer getUseamount() {
+        return useamount;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method sets the value of the database column litemall_user_formid.useAmount
+     *
+     * @param useamount the value for litemall_user_formid.useAmount
+     *
+     * @mbg.generated
+     */
+    public void setUseamount(Integer useamount) {
+        this.useamount = useamount;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method returns the value of the database column litemall_user_formid.expire_time
+     *
+     * @return the value of litemall_user_formid.expire_time
+     *
+     * @mbg.generated
+     */
+    public LocalDateTime getExpireTime() {
+        return expireTime;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method sets the value of the database column litemall_user_formid.expire_time
+     *
+     * @param expireTime the value for litemall_user_formid.expire_time
+     *
+     * @mbg.generated
+     */
+    public void setExpireTime(LocalDateTime expireTime) {
+        this.expireTime = expireTime;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method returns the value of the database column litemall_user_formid.openId
+     *
+     * @return the value of litemall_user_formid.openId
+     *
+     * @mbg.generated
+     */
+    public String getOpenid() {
+        return openid;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method sets the value of the database column litemall_user_formid.openId
+     *
+     * @param openid the value for litemall_user_formid.openId
+     *
+     * @mbg.generated
+     */
+    public void setOpenid(String openid) {
+        this.openid = openid;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     */
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", id=").append(id);
+        sb.append(", formid=").append(formid);
+        sb.append(", isprepay=").append(isprepay);
+        sb.append(", useamount=").append(useamount);
+        sb.append(", expireTime=").append(expireTime);
+        sb.append(", openid=").append(openid);
+        sb.append("]");
+        return sb.toString();
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     */
+    @Override
+    public boolean equals(Object that) {
+        if (this == that) {
+            return true;
+        }
+        if (that == null) {
+            return false;
+        }
+        if (getClass() != that.getClass()) {
+            return false;
+        }
+        LitemallUserFormid other = (LitemallUserFormid) that;
+        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
+            && (this.getFormid() == null ? other.getFormid() == null : this.getFormid().equals(other.getFormid()))
+            && (this.getIsprepay() == null ? other.getIsprepay() == null : this.getIsprepay().equals(other.getIsprepay()))
+            && (this.getUseamount() == null ? other.getUseamount() == null : this.getUseamount().equals(other.getUseamount()))
+            && (this.getExpireTime() == null ? other.getExpireTime() == null : this.getExpireTime().equals(other.getExpireTime()))
+            && (this.getOpenid() == null ? other.getOpenid() == null : this.getOpenid().equals(other.getOpenid()));
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     */
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
+        result = prime * result + ((getFormid() == null) ? 0 : getFormid().hashCode());
+        result = prime * result + ((getIsprepay() == null) ? 0 : getIsprepay().hashCode());
+        result = prime * result + ((getUseamount() == null) ? 0 : getUseamount().hashCode());
+        result = prime * result + ((getExpireTime() == null) ? 0 : getExpireTime().hashCode());
+        result = prime * result + ((getOpenid() == null) ? 0 : getOpenid().hashCode());
+        return result;
+    }
+
+    /**
+     * This enum was generated by MyBatis Generator.
+     * This enum corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     * @project https://github.com/itfsw/mybatis-generator-plugin
+     */
+    public enum Column {
+        id("id", "id", "INTEGER"),
+        formid("formId", "formid", "VARCHAR"),
+        isprepay("isprepay", "isprepay", "BIT"),
+        useamount("useAmount", "useamount", "INTEGER"),
+        expireTime("expire_time", "expireTime", "TIMESTAMP"),
+        openid("openId", "openid", "VARCHAR");
+
+        /**
+         * This field was generated by MyBatis Generator.
+         * This field corresponds to the database table litemall_user_formid
+         *
+         * @mbg.generated
+         * @project https://github.com/itfsw/mybatis-generator-plugin
+         */
+        private final String column;
+
+        /**
+         * This field was generated by MyBatis Generator.
+         * This field corresponds to the database table litemall_user_formid
+         *
+         * @mbg.generated
+         * @project https://github.com/itfsw/mybatis-generator-plugin
+         */
+        private final String javaProperty;
+
+        /**
+         * This field was generated by MyBatis Generator.
+         * This field corresponds to the database table litemall_user_formid
+         *
+         * @mbg.generated
+         * @project https://github.com/itfsw/mybatis-generator-plugin
+         */
+        private final String jdbcType;
+
+        /**
+         * This method was generated by MyBatis Generator.
+         * This method corresponds to the database table litemall_user_formid
+         *
+         * @mbg.generated
+         * @project https://github.com/itfsw/mybatis-generator-plugin
+         */
+        public String value() {
+            return this.column;
+        }
+
+        /**
+         * This method was generated by MyBatis Generator.
+         * This method corresponds to the database table litemall_user_formid
+         *
+         * @mbg.generated
+         * @project https://github.com/itfsw/mybatis-generator-plugin
+         */
+        public String getValue() {
+            return this.column;
+        }
+
+        /**
+         * This method was generated by MyBatis Generator.
+         * This method corresponds to the database table litemall_user_formid
+         *
+         * @mbg.generated
+         * @project https://github.com/itfsw/mybatis-generator-plugin
+         */
+        public String getJavaProperty() {
+            return this.javaProperty;
+        }
+
+        /**
+         * This method was generated by MyBatis Generator.
+         * This method corresponds to the database table litemall_user_formid
+         *
+         * @mbg.generated
+         * @project https://github.com/itfsw/mybatis-generator-plugin
+         */
+        public String getJdbcType() {
+            return this.jdbcType;
+        }
+
+        /**
+         * This method was generated by MyBatis Generator.
+         * This method corresponds to the database table litemall_user_formid
+         *
+         * @mbg.generated
+         * @project https://github.com/itfsw/mybatis-generator-plugin
+         */
+        Column(String column, String javaProperty, String jdbcType) {
+            this.column = column;
+            this.javaProperty = javaProperty;
+            this.jdbcType = jdbcType;
+        }
+
+        /**
+         * This method was generated by MyBatis Generator.
+         * This method corresponds to the database table litemall_user_formid
+         *
+         * @mbg.generated
+         * @project https://github.com/itfsw/mybatis-generator-plugin
+         */
+        public String desc() {
+            return this.column + " DESC";
+        }
+
+        /**
+         * This method was generated by MyBatis Generator.
+         * This method corresponds to the database table litemall_user_formid
+         *
+         * @mbg.generated
+         * @project https://github.com/itfsw/mybatis-generator-plugin
+         */
+        public String asc() {
+            return this.column + " ASC";
+        }
+
+        /**
+         * This method was generated by MyBatis Generator.
+         * This method corresponds to the database table litemall_user_formid
+         *
+         * @mbg.generated
+         * @project https://github.com/itfsw/mybatis-generator-plugin
+         */
+        public static Column[] excludes(Column ... excludes) {
+            ArrayList<Column> columns = new ArrayList<>(Arrays.asList(Column.values()));
+            if (excludes != null && excludes.length > 0) {
+                columns.removeAll(new ArrayList<>(Arrays.asList(excludes)));
+            }
+            return columns.toArray(new Column[]{});
+        }
+    }
+}

+ 773 - 0
litemall-db/src/main/java/org/linlinjava/litemall/db/domain/LitemallUserFormidExample.java

@@ -0,0 +1,773 @@
+package org.linlinjava.litemall.db.domain;
+
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.List;
+
+public class LitemallUserFormidExample {
+    /**
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     */
+    protected String orderByClause;
+
+    /**
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     */
+    protected boolean distinct;
+
+    /**
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     */
+    protected List<Criteria> oredCriteria;
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     */
+    public LitemallUserFormidExample() {
+        oredCriteria = new ArrayList<Criteria>();
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     */
+    public void setOrderByClause(String orderByClause) {
+        this.orderByClause = orderByClause;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     */
+    public String getOrderByClause() {
+        return orderByClause;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     */
+    public void setDistinct(boolean distinct) {
+        this.distinct = distinct;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     */
+    public boolean isDistinct() {
+        return distinct;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     */
+    public List<Criteria> getOredCriteria() {
+        return oredCriteria;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     */
+    public void or(Criteria criteria) {
+        oredCriteria.add(criteria);
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     */
+    public Criteria or() {
+        Criteria criteria = createCriteriaInternal();
+        oredCriteria.add(criteria);
+        return criteria;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     * @project https://github.com/itfsw/mybatis-generator-plugin
+     */
+    public LitemallUserFormidExample orderBy(String orderByClause) {
+        this.setOrderByClause(orderByClause);
+        return this;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     * @project https://github.com/itfsw/mybatis-generator-plugin
+     */
+    public LitemallUserFormidExample orderBy(String ... orderByClauses) {
+        StringBuffer sb = new StringBuffer();
+        for (int i = 0; i < orderByClauses.length; i++) {
+            sb.append(orderByClauses[i]);
+            if (i < orderByClauses.length - 1) {
+                sb.append(" , ");
+            }
+        }
+        this.setOrderByClause(sb.toString());
+        return this;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     */
+    public Criteria createCriteria() {
+        Criteria criteria = createCriteriaInternal();
+        if (oredCriteria.size() == 0) {
+            oredCriteria.add(criteria);
+        }
+        return criteria;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     */
+    protected Criteria createCriteriaInternal() {
+        Criteria criteria = new Criteria(this);
+        return criteria;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     */
+    public void clear() {
+        oredCriteria.clear();
+        orderByClause = null;
+        distinct = false;
+    }
+
+    /**
+     * This class was generated by MyBatis Generator.
+     * This class corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     */
+    protected abstract static class GeneratedCriteria {
+        protected List<Criterion> criteria;
+
+        protected GeneratedCriteria() {
+            super();
+            criteria = new ArrayList<Criterion>();
+        }
+
+        public boolean isValid() {
+            return criteria.size() > 0;
+        }
+
+        public List<Criterion> getAllCriteria() {
+            return criteria;
+        }
+
+        public List<Criterion> getCriteria() {
+            return criteria;
+        }
+
+        protected void addCriterion(String condition) {
+            if (condition == null) {
+                throw new RuntimeException("Value for condition cannot be null");
+            }
+            criteria.add(new Criterion(condition));
+        }
+
+        protected void addCriterion(String condition, Object value, String property) {
+            if (value == null) {
+                throw new RuntimeException("Value for " + property + " cannot be null");
+            }
+            criteria.add(new Criterion(condition, value));
+        }
+
+        protected void addCriterion(String condition, Object value1, Object value2, String property) {
+            if (value1 == null || value2 == null) {
+                throw new RuntimeException("Between values for " + property + " cannot be null");
+            }
+            criteria.add(new Criterion(condition, value1, value2));
+        }
+
+        public Criteria andIdIsNull() {
+            addCriterion("id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdIsNotNull() {
+            addCriterion("id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdEqualTo(Integer value) {
+            addCriterion("id =", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdNotEqualTo(Integer value) {
+            addCriterion("id <>", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdGreaterThan(Integer value) {
+            addCriterion("id >", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdGreaterThanOrEqualTo(Integer value) {
+            addCriterion("id >=", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdLessThan(Integer value) {
+            addCriterion("id <", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdLessThanOrEqualTo(Integer value) {
+            addCriterion("id <=", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdIn(List<Integer> values) {
+            addCriterion("id in", values, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdNotIn(List<Integer> values) {
+            addCriterion("id not in", values, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdBetween(Integer value1, Integer value2) {
+            addCriterion("id between", value1, value2, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdNotBetween(Integer value1, Integer value2) {
+            addCriterion("id not between", value1, value2, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andFormidIsNull() {
+            addCriterion("formId is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andFormidIsNotNull() {
+            addCriterion("formId is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andFormidEqualTo(String value) {
+            addCriterion("formId =", value, "formid");
+            return (Criteria) this;
+        }
+
+        public Criteria andFormidNotEqualTo(String value) {
+            addCriterion("formId <>", value, "formid");
+            return (Criteria) this;
+        }
+
+        public Criteria andFormidGreaterThan(String value) {
+            addCriterion("formId >", value, "formid");
+            return (Criteria) this;
+        }
+
+        public Criteria andFormidGreaterThanOrEqualTo(String value) {
+            addCriterion("formId >=", value, "formid");
+            return (Criteria) this;
+        }
+
+        public Criteria andFormidLessThan(String value) {
+            addCriterion("formId <", value, "formid");
+            return (Criteria) this;
+        }
+
+        public Criteria andFormidLessThanOrEqualTo(String value) {
+            addCriterion("formId <=", value, "formid");
+            return (Criteria) this;
+        }
+
+        public Criteria andFormidLike(String value) {
+            addCriterion("formId like", value, "formid");
+            return (Criteria) this;
+        }
+
+        public Criteria andFormidNotLike(String value) {
+            addCriterion("formId not like", value, "formid");
+            return (Criteria) this;
+        }
+
+        public Criteria andFormidIn(List<String> values) {
+            addCriterion("formId in", values, "formid");
+            return (Criteria) this;
+        }
+
+        public Criteria andFormidNotIn(List<String> values) {
+            addCriterion("formId not in", values, "formid");
+            return (Criteria) this;
+        }
+
+        public Criteria andFormidBetween(String value1, String value2) {
+            addCriterion("formId between", value1, value2, "formid");
+            return (Criteria) this;
+        }
+
+        public Criteria andFormidNotBetween(String value1, String value2) {
+            addCriterion("formId not between", value1, value2, "formid");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsprepayIsNull() {
+            addCriterion("isprepay is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsprepayIsNotNull() {
+            addCriterion("isprepay is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsprepayEqualTo(Boolean value) {
+            addCriterion("isprepay =", value, "isprepay");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsprepayNotEqualTo(Boolean value) {
+            addCriterion("isprepay <>", value, "isprepay");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsprepayGreaterThan(Boolean value) {
+            addCriterion("isprepay >", value, "isprepay");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsprepayGreaterThanOrEqualTo(Boolean value) {
+            addCriterion("isprepay >=", value, "isprepay");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsprepayLessThan(Boolean value) {
+            addCriterion("isprepay <", value, "isprepay");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsprepayLessThanOrEqualTo(Boolean value) {
+            addCriterion("isprepay <=", value, "isprepay");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsprepayIn(List<Boolean> values) {
+            addCriterion("isprepay in", values, "isprepay");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsprepayNotIn(List<Boolean> values) {
+            addCriterion("isprepay not in", values, "isprepay");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsprepayBetween(Boolean value1, Boolean value2) {
+            addCriterion("isprepay between", value1, value2, "isprepay");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsprepayNotBetween(Boolean value1, Boolean value2) {
+            addCriterion("isprepay not between", value1, value2, "isprepay");
+            return (Criteria) this;
+        }
+
+        public Criteria andUseamountIsNull() {
+            addCriterion("useAmount is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andUseamountIsNotNull() {
+            addCriterion("useAmount is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andUseamountEqualTo(Integer value) {
+            addCriterion("useAmount =", value, "useamount");
+            return (Criteria) this;
+        }
+
+        public Criteria andUseamountNotEqualTo(Integer value) {
+            addCriterion("useAmount <>", value, "useamount");
+            return (Criteria) this;
+        }
+
+        public Criteria andUseamountGreaterThan(Integer value) {
+            addCriterion("useAmount >", value, "useamount");
+            return (Criteria) this;
+        }
+
+        public Criteria andUseamountGreaterThanOrEqualTo(Integer value) {
+            addCriterion("useAmount >=", value, "useamount");
+            return (Criteria) this;
+        }
+
+        public Criteria andUseamountLessThan(Integer value) {
+            addCriterion("useAmount <", value, "useamount");
+            return (Criteria) this;
+        }
+
+        public Criteria andUseamountLessThanOrEqualTo(Integer value) {
+            addCriterion("useAmount <=", value, "useamount");
+            return (Criteria) this;
+        }
+
+        public Criteria andUseamountIn(List<Integer> values) {
+            addCriterion("useAmount in", values, "useamount");
+            return (Criteria) this;
+        }
+
+        public Criteria andUseamountNotIn(List<Integer> values) {
+            addCriterion("useAmount not in", values, "useamount");
+            return (Criteria) this;
+        }
+
+        public Criteria andUseamountBetween(Integer value1, Integer value2) {
+            addCriterion("useAmount between", value1, value2, "useamount");
+            return (Criteria) this;
+        }
+
+        public Criteria andUseamountNotBetween(Integer value1, Integer value2) {
+            addCriterion("useAmount not between", value1, value2, "useamount");
+            return (Criteria) this;
+        }
+
+        public Criteria andExpireTimeIsNull() {
+            addCriterion("expire_time is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andExpireTimeIsNotNull() {
+            addCriterion("expire_time is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andExpireTimeEqualTo(LocalDateTime value) {
+            addCriterion("expire_time =", value, "expireTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andExpireTimeNotEqualTo(LocalDateTime value) {
+            addCriterion("expire_time <>", value, "expireTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andExpireTimeGreaterThan(LocalDateTime value) {
+            addCriterion("expire_time >", value, "expireTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andExpireTimeGreaterThanOrEqualTo(LocalDateTime value) {
+            addCriterion("expire_time >=", value, "expireTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andExpireTimeLessThan(LocalDateTime value) {
+            addCriterion("expire_time <", value, "expireTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andExpireTimeLessThanOrEqualTo(LocalDateTime value) {
+            addCriterion("expire_time <=", value, "expireTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andExpireTimeIn(List<LocalDateTime> values) {
+            addCriterion("expire_time in", values, "expireTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andExpireTimeNotIn(List<LocalDateTime> values) {
+            addCriterion("expire_time not in", values, "expireTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andExpireTimeBetween(LocalDateTime value1, LocalDateTime value2) {
+            addCriterion("expire_time between", value1, value2, "expireTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andExpireTimeNotBetween(LocalDateTime value1, LocalDateTime value2) {
+            addCriterion("expire_time not between", value1, value2, "expireTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andOpenidIsNull() {
+            addCriterion("openId is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andOpenidIsNotNull() {
+            addCriterion("openId is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andOpenidEqualTo(String value) {
+            addCriterion("openId =", value, "openid");
+            return (Criteria) this;
+        }
+
+        public Criteria andOpenidNotEqualTo(String value) {
+            addCriterion("openId <>", value, "openid");
+            return (Criteria) this;
+        }
+
+        public Criteria andOpenidGreaterThan(String value) {
+            addCriterion("openId >", value, "openid");
+            return (Criteria) this;
+        }
+
+        public Criteria andOpenidGreaterThanOrEqualTo(String value) {
+            addCriterion("openId >=", value, "openid");
+            return (Criteria) this;
+        }
+
+        public Criteria andOpenidLessThan(String value) {
+            addCriterion("openId <", value, "openid");
+            return (Criteria) this;
+        }
+
+        public Criteria andOpenidLessThanOrEqualTo(String value) {
+            addCriterion("openId <=", value, "openid");
+            return (Criteria) this;
+        }
+
+        public Criteria andOpenidLike(String value) {
+            addCriterion("openId like", value, "openid");
+            return (Criteria) this;
+        }
+
+        public Criteria andOpenidNotLike(String value) {
+            addCriterion("openId not like", value, "openid");
+            return (Criteria) this;
+        }
+
+        public Criteria andOpenidIn(List<String> values) {
+            addCriterion("openId in", values, "openid");
+            return (Criteria) this;
+        }
+
+        public Criteria andOpenidNotIn(List<String> values) {
+            addCriterion("openId not in", values, "openid");
+            return (Criteria) this;
+        }
+
+        public Criteria andOpenidBetween(String value1, String value2) {
+            addCriterion("openId between", value1, value2, "openid");
+            return (Criteria) this;
+        }
+
+        public Criteria andOpenidNotBetween(String value1, String value2) {
+            addCriterion("openId not between", value1, value2, "openid");
+            return (Criteria) this;
+        }
+    }
+
+    /**
+     * This class was generated by MyBatis Generator.
+     * This class corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated do_not_delete_during_merge
+     */
+    public static class Criteria extends GeneratedCriteria {
+        /**
+         * This field was generated by MyBatis Generator.
+         * This field corresponds to the database table litemall_user_formid
+         *
+         * @mbg.generated
+         * @project https://github.com/itfsw/mybatis-generator-plugin
+         */
+        private LitemallUserFormidExample example;
+
+        /**
+         * This method was generated by MyBatis Generator.
+         * This method corresponds to the database table litemall_user_formid
+         *
+         * @mbg.generated
+         * @project https://github.com/itfsw/mybatis-generator-plugin
+         */
+        protected Criteria(LitemallUserFormidExample example) {
+            super();
+            this.example = example;
+        }
+
+        /**
+         * This method was generated by MyBatis Generator.
+         * This method corresponds to the database table litemall_user_formid
+         *
+         * @mbg.generated
+         * @project https://github.com/itfsw/mybatis-generator-plugin
+         */
+        public LitemallUserFormidExample example() {
+            return this.example;
+        }
+
+        /**
+         * This method was generated by MyBatis Generator.
+         * This method corresponds to the database table litemall_user_formid
+         *
+         * @mbg.generated
+         * @project https://github.com/itfsw/mybatis-generator-plugin
+         */
+        public Criteria andIf(boolean ifAdd, ICriteriaAdd add) {
+            if (ifAdd) {
+                add.add(this);
+            }
+            return this;
+        }
+
+        /**
+         * This interface was generated by MyBatis Generator.
+         * This interface corresponds to the database table litemall_user_formid
+         *
+         * @mbg.generated
+         * @project https://github.com/itfsw/mybatis-generator-plugin
+         */
+        public interface ICriteriaAdd {
+            /**
+             * This method was generated by MyBatis Generator.
+             * This method corresponds to the database table litemall_user_formid
+             *
+             * @mbg.generated
+             * @project https://github.com/itfsw/mybatis-generator-plugin
+             */
+            Criteria add(Criteria add);
+        }
+    }
+
+    /**
+     * This class was generated by MyBatis Generator.
+     * This class corresponds to the database table litemall_user_formid
+     *
+     * @mbg.generated
+     */
+    public static class Criterion {
+        private String condition;
+
+        private Object value;
+
+        private Object secondValue;
+
+        private boolean noValue;
+
+        private boolean singleValue;
+
+        private boolean betweenValue;
+
+        private boolean listValue;
+
+        private String typeHandler;
+
+        public String getCondition() {
+            return condition;
+        }
+
+        public Object getValue() {
+            return value;
+        }
+
+        public Object getSecondValue() {
+            return secondValue;
+        }
+
+        public boolean isNoValue() {
+            return noValue;
+        }
+
+        public boolean isSingleValue() {
+            return singleValue;
+        }
+
+        public boolean isBetweenValue() {
+            return betweenValue;
+        }
+
+        public boolean isListValue() {
+            return listValue;
+        }
+
+        public String getTypeHandler() {
+            return typeHandler;
+        }
+
+        protected Criterion(String condition) {
+            super();
+            this.condition = condition;
+            this.typeHandler = null;
+            this.noValue = true;
+        }
+
+        protected Criterion(String condition, Object value, String typeHandler) {
+            super();
+            this.condition = condition;
+            this.value = value;
+            this.typeHandler = typeHandler;
+            if (value instanceof List<?>) {
+                this.listValue = true;
+            } else {
+                this.singleValue = true;
+            }
+        }
+
+        protected Criterion(String condition, Object value) {
+            this(condition, value, null);
+        }
+
+        protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
+            super();
+            this.condition = condition;
+            this.value = value;
+            this.secondValue = secondValue;
+            this.typeHandler = typeHandler;
+            this.betweenValue = true;
+        }
+
+        protected Criterion(String condition, Object value, Object secondValue) {
+            this(condition, value, secondValue, null);
+        }
+    }
+}

+ 46 - 0
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallUserFormIdService.java

@@ -0,0 +1,46 @@
+package org.linlinjava.litemall.db.service;
+
+import org.linlinjava.litemall.db.dao.LitemallUserFormidMapper;
+import org.linlinjava.litemall.db.domain.LitemallUserFormid;
+import org.linlinjava.litemall.db.domain.LitemallUserFormidExample;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.time.LocalDateTime;
+
+@Service
+public class LitemallUserFormIdService {
+    @Resource
+    private LitemallUserFormidMapper formidMapper;
+
+    /**
+     * 查找是否有可用的FormId
+     *
+     * @param openId
+     * @return
+     */
+    public LitemallUserFormid queryByOpenId(String openId) {
+        LitemallUserFormidExample example = new LitemallUserFormidExample();
+        //符合找到该用户记录,且可用次数大于1,且还未过期
+        example.or().andOpenidEqualTo(openId).andExpireTimeGreaterThan(LocalDateTime.now());
+        return formidMapper.selectOneByExample(example);
+    }
+
+    /**
+     * 添加一个 FormId
+     *
+     * @param userFormid
+     */
+    public void addUserFormid(LitemallUserFormid userFormid) {
+        formidMapper.insertSelective(userFormid);
+    }
+
+    /**
+     * 删除一个 FormId
+     *
+     * @param userFormidId
+     */
+    public void delUserFormid(Integer userFormidId) {
+        formidMapper.deleteByPrimaryKey(userFormidId);
+    }
+}

+ 377 - 0
litemall-db/src/main/resources/org/linlinjava/litemall/db/dao/LitemallUserFormidMapper.xml

@@ -0,0 +1,377 @@
+<?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="org.linlinjava.litemall.db.dao.LitemallUserFormidMapper">
+  <resultMap id="BaseResultMap" type="org.linlinjava.litemall.db.domain.LitemallUserFormid">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+    <id column="id" jdbcType="INTEGER" property="id" />
+    <result column="formId" jdbcType="VARCHAR" property="formid" />
+    <result column="isprepay" jdbcType="BIT" property="isprepay" />
+    <result column="useAmount" jdbcType="INTEGER" property="useamount" />
+    <result column="expire_time" jdbcType="TIMESTAMP" property="expireTime" />
+    <result column="openId" jdbcType="VARCHAR" property="openid" />
+  </resultMap>
+  <sql id="Example_Where_Clause">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+    <where>
+      <foreach collection="oredCriteria" item="criteria" separator="or">
+        <if test="criteria.valid">
+          <trim prefix="(" prefixOverrides="and" suffix=")">
+            <foreach collection="criteria.criteria" item="criterion">
+              <choose>
+                <when test="criterion.noValue">
+                  and ${criterion.condition}
+                </when>
+                <when test="criterion.singleValue">
+                  and ${criterion.condition} #{criterion.value}
+                </when>
+                <when test="criterion.betweenValue">
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                </when>
+                <when test="criterion.listValue">
+                  and ${criterion.condition}
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
+                    #{listItem}
+                  </foreach>
+                </when>
+              </choose>
+            </foreach>
+          </trim>
+        </if>
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Update_By_Example_Where_Clause">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+    <where>
+      <foreach collection="example.oredCriteria" item="criteria" separator="or">
+        <if test="criteria.valid">
+          <trim prefix="(" prefixOverrides="and" suffix=")">
+            <foreach collection="criteria.criteria" item="criterion">
+              <choose>
+                <when test="criterion.noValue">
+                  and ${criterion.condition}
+                </when>
+                <when test="criterion.singleValue">
+                  and ${criterion.condition} #{criterion.value}
+                </when>
+                <when test="criterion.betweenValue">
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                </when>
+                <when test="criterion.listValue">
+                  and ${criterion.condition}
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
+                    #{listItem}
+                  </foreach>
+                </when>
+              </choose>
+            </foreach>
+          </trim>
+        </if>
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Base_Column_List">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+    id, formId, isprepay, useAmount, expire_time, openId
+  </sql>
+  <select id="selectByExample" parameterType="org.linlinjava.litemall.db.domain.LitemallUserFormidExample" resultMap="BaseResultMap">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+    select
+    <if test="distinct">
+      distinct
+    </if>
+    <include refid="Base_Column_List" />
+    from litemall_user_formid
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+    <if test="orderByClause != null">
+      order by ${orderByClause}
+    </if>
+  </select>
+  <select id="selectByExampleSelective" parameterType="map" resultMap="BaseResultMap">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      @project https://github.com/itfsw/mybatis-generator-plugin
+    -->
+    select
+    <if test="example.distinct">
+      distinct
+    </if>
+    <choose>
+      <when test="selective != null and selective.length &gt; 0">
+        <foreach collection="selective" item="column" separator=",">
+          ${column.value}
+        </foreach>
+      </when>
+      <otherwise>
+        id, formId, isprepay, useAmount, expire_time, openId
+      </otherwise>
+    </choose>
+    from litemall_user_formid
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+    <if test="example.orderByClause != null">
+      order by ${example.orderByClause}
+    </if>
+  </select>
+  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+    select 
+    <include refid="Base_Column_List" />
+    from litemall_user_formid
+    where id = #{id,jdbcType=INTEGER}
+  </select>
+  <select id="selectByPrimaryKeySelective" parameterType="map" resultMap="BaseResultMap">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      @project https://github.com/itfsw/mybatis-generator-plugin
+    -->
+    select
+    <choose>
+      <when test="selective != null and selective.length &gt; 0">
+        <foreach collection="selective" item="column" separator=",">
+          ${column.value}
+        </foreach>
+      </when>
+      <otherwise>
+        id, formId, isprepay, useAmount, expire_time, openId
+      </otherwise>
+    </choose>
+    from litemall_user_formid
+    where id = #{id,jdbcType=INTEGER}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+    delete from litemall_user_formid
+    where id = #{id,jdbcType=INTEGER}
+  </delete>
+  <delete id="deleteByExample" parameterType="org.linlinjava.litemall.db.domain.LitemallUserFormidExample">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+    delete from litemall_user_formid
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </delete>
+  <insert id="insert" parameterType="org.linlinjava.litemall.db.domain.LitemallUserFormid">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
+      SELECT LAST_INSERT_ID()
+    </selectKey>
+    insert into litemall_user_formid (formId, isprepay, useAmount, 
+      expire_time, openId)
+    values (#{formid,jdbcType=VARCHAR}, #{isprepay,jdbcType=BIT}, #{useamount,jdbcType=INTEGER}, 
+      #{expireTime,jdbcType=TIMESTAMP}, #{openid,jdbcType=VARCHAR})
+  </insert>
+  <insert id="insertSelective" parameterType="org.linlinjava.litemall.db.domain.LitemallUserFormid">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
+      SELECT LAST_INSERT_ID()
+    </selectKey>
+    insert into litemall_user_formid
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="formid != null">
+        formId,
+      </if>
+      <if test="isprepay != null">
+        isprepay,
+      </if>
+      <if test="useamount != null">
+        useAmount,
+      </if>
+      <if test="expireTime != null">
+        expire_time,
+      </if>
+      <if test="openid != null">
+        openId,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="formid != null">
+        #{formid,jdbcType=VARCHAR},
+      </if>
+      <if test="isprepay != null">
+        #{isprepay,jdbcType=BIT},
+      </if>
+      <if test="useamount != null">
+        #{useamount,jdbcType=INTEGER},
+      </if>
+      <if test="expireTime != null">
+        #{expireTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="openid != null">
+        #{openid,jdbcType=VARCHAR},
+      </if>
+    </trim>
+  </insert>
+  <select id="countByExample" parameterType="org.linlinjava.litemall.db.domain.LitemallUserFormidExample" resultType="java.lang.Long">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+    select count(*) from litemall_user_formid
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </select>
+  <update id="updateByExampleSelective" parameterType="map">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+    update litemall_user_formid
+    <set>
+      <if test="record.id != null">
+        id = #{record.id,jdbcType=INTEGER},
+      </if>
+      <if test="record.formid != null">
+        formId = #{record.formid,jdbcType=VARCHAR},
+      </if>
+      <if test="record.isprepay != null">
+        isprepay = #{record.isprepay,jdbcType=BIT},
+      </if>
+      <if test="record.useamount != null">
+        useAmount = #{record.useamount,jdbcType=INTEGER},
+      </if>
+      <if test="record.expireTime != null">
+        expire_time = #{record.expireTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="record.openid != null">
+        openId = #{record.openid,jdbcType=VARCHAR},
+      </if>
+    </set>
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByExample" parameterType="map">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+    update litemall_user_formid
+    set id = #{record.id,jdbcType=INTEGER},
+      formId = #{record.formid,jdbcType=VARCHAR},
+      isprepay = #{record.isprepay,jdbcType=BIT},
+      useAmount = #{record.useamount,jdbcType=INTEGER},
+      expire_time = #{record.expireTime,jdbcType=TIMESTAMP},
+      openId = #{record.openid,jdbcType=VARCHAR}
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByPrimaryKeySelective" parameterType="org.linlinjava.litemall.db.domain.LitemallUserFormid">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+    update litemall_user_formid
+    <set>
+      <if test="formid != null">
+        formId = #{formid,jdbcType=VARCHAR},
+      </if>
+      <if test="isprepay != null">
+        isprepay = #{isprepay,jdbcType=BIT},
+      </if>
+      <if test="useamount != null">
+        useAmount = #{useamount,jdbcType=INTEGER},
+      </if>
+      <if test="expireTime != null">
+        expire_time = #{expireTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="openid != null">
+        openId = #{openid,jdbcType=VARCHAR},
+      </if>
+    </set>
+    where id = #{id,jdbcType=INTEGER}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="org.linlinjava.litemall.db.domain.LitemallUserFormid">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+    update litemall_user_formid
+    set formId = #{formid,jdbcType=VARCHAR},
+      isprepay = #{isprepay,jdbcType=BIT},
+      useAmount = #{useamount,jdbcType=INTEGER},
+      expire_time = #{expireTime,jdbcType=TIMESTAMP},
+      openId = #{openid,jdbcType=VARCHAR}
+    where id = #{id,jdbcType=INTEGER}
+  </update>
+  <select id="selectOneByExample" parameterType="org.linlinjava.litemall.db.domain.LitemallUserFormidExample" resultMap="BaseResultMap">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      @project https://github.com/itfsw/mybatis-generator-plugin
+    -->
+    select
+    <include refid="Base_Column_List" />
+    from litemall_user_formid
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+    <if test="orderByClause != null">
+      order by ${orderByClause}
+    </if>
+    limit 1
+  </select>
+  <select id="selectOneByExampleSelective" parameterType="map" resultMap="BaseResultMap">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      @project https://github.com/itfsw/mybatis-generator-plugin
+    -->
+    select
+    <choose>
+      <when test="selective != null and selective.length &gt; 0">
+        <foreach collection="selective" item="column" separator=",">
+          ${column.value}
+        </foreach>
+      </when>
+      <otherwise>
+        id, formId, isprepay, useAmount, expire_time, openId
+      </otherwise>
+    </choose>
+    from litemall_user_formid
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+    <if test="example.orderByClause != null">
+      order by ${example.orderByClause}
+    </if>
+    limit 1
+  </select>
+</mapper>

+ 45 - 0
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxUserFormId.java

@@ -0,0 +1,45 @@
+package org.linlinjava.litemall.wx.web;
+
+import org.linlinjava.litemall.core.util.ResponseUtil;
+import org.linlinjava.litemall.db.domain.LitemallUser;
+import org.linlinjava.litemall.db.domain.LitemallUserFormid;
+import org.linlinjava.litemall.db.service.LitemallUserFormIdService;
+import org.linlinjava.litemall.db.service.LitemallUserService;
+import org.linlinjava.litemall.wx.annotation.LoginUser;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.time.LocalDateTime;
+
+@RestController
+@RequestMapping("/wx/formid")
+public class WxUserFormId {
+    @Autowired
+    LitemallUserService userService;
+
+    @Autowired
+    LitemallUserFormIdService formIdService;
+
+    @GetMapping("create")
+    public Object create(@LoginUser Integer userId, String formId) {
+        if (userId == null) {
+            return ResponseUtil.unlogin();
+        }
+
+        if (formId == null) {
+            return ResponseUtil.badArgument();
+        }
+
+        LitemallUser user = userService.findById(userId);
+        LitemallUserFormid userFormid = new LitemallUserFormid();
+        userFormid.setOpenid(user.getWeixinOpenid());
+        userFormid.setFormid(formId);
+        userFormid.setIsprepay(false);
+        userFormid.setUseamount(1);
+        userFormid.setExpireTime(LocalDateTime.now().plusDays(7));
+        formIdService.addUserFormid(userFormid);
+        return ResponseUtil.ok();
+    }
+}