Commit 35d874ef authored by Junling Bu's avatar Junling Bu
Browse files

chore: 删除微信模板实现(微信官方已经不支持)

parent fa51b868
......@@ -71,7 +71,7 @@ litemall = Spring Boot后端 + Vue管理员前端 + 微信小程序用户前端
* 品牌列表、品牌详情
* 新品首发、人气推荐
* 优惠券列表、优惠券选择
* 团购(团购业务有待完善)
* 团购
* 搜索
* 商品详情、商品评价、商品分享
* 购物车
......
......@@ -82,20 +82,6 @@ litemall:
accessKeyId: xxx
accessKeySecret: xxx
# 微信模版通知配置
# 微信模版用于通知客户或者运营者,注意配置格式;template-name,template-templateId 请参考 NotifyType 枚举值
wx:
enable: false
template:
- name: paySucceed
templateId: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- name: captcha
templateId: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- name: ship
templateId: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- name: refund
templateId: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# 快鸟物流查询配置
express:
enable: false
......
......@@ -636,42 +636,6 @@ litemall:
例如“你好,验证码是{code},时间是{code1}"。开发者可以查看`AliyunSmsSender`类的`sendWithTemplate`方法的
源代码即可理解。如果觉得不合理,可以自行调整相关代码。
#### 1.4.5.7 微信通知配置
微信通知是微信上收到的服务通知。
在litemall-core模块的`application-core.yml`文件中配置微信通知服务:
```
litemall:
notify:
# 微信模版通知配置
# 微信模版用于通知客户或者运营者,注意配置格式;template-name,template-templateId 请参考 NotifyType 枚举值
wx:
enable: false
template:
- name: paySucceed
templateId: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- name: captcha
templateId: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- name: ship
templateId: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- name: refund
templateId: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
```
配置方式:
1. 微信公众平台申请,然后在`模板消息`中设置四个场景的微信模板;
2. 开发者在配置文件设置`enable`的值`true`,然后其他信息设置
微信公众平台中所设置模板ID。
应用场景:
目前微信通知场景只支持支付成功、验证码、订单发送、退款成功四种情况。
以后可能需要继续优化扩展。
验证配置成功:
这里没有实现测试类,因为微信通知需要小程序前端的formId作为参数,因此需要
小商城前端配合。开发者可以在实际场景中DBEUG看看。
#### 1.4.5.8 物流配置
物流配置是查询商品物流信息,这里主要是基于[第三方快递鸟服务](http://www.kdniao.com/api-track)。
......
......@@ -19,7 +19,6 @@ public class NotifyService {
private SmsSender smsSender;
private List<Map<String, String>> smsTemplate = new ArrayList<>();
private WxTemplateSender wxTemplateSender;
private List<Map<String, String>> wxTemplate = new ArrayList<>();
public boolean isMailEnable() {
......@@ -30,10 +29,6 @@ public class NotifyService {
return smsSender != null;
}
public boolean isWxEnable() {
return wxTemplateSender != null;
}
/**
* 短信消息通知
*
......@@ -84,43 +79,6 @@ public class NotifyService {
return smsSender.sendWithTemplate(phoneNumber, getTemplateId(notifyType, smsTemplate), 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);
}
/**
* 微信模版消息通知,带跳转
* <p>
* 该方法会尝试从数据库获取缓存的FormId去发送消息
*
* @param touser 接收者openId
* @param notifyType 通知类别,通过该枚举值在配置文件中获取相应的模版ID
* @param params 通知模版内容里的参数,类似"您的验证码为{1}"中{1}的值
* @param page 点击消息跳转的页面
*/
@Async
public void notifyWxTemplate(String touser, NotifyType notifyType, String[] params, String page) {
if (wxTemplateSender == null)
return;
String templateId = getTemplateId(notifyType, wxTemplate);
wxTemplateSender.sendWechatMsg(touser, templateId, params, page);
}
/**
* 邮件消息通知,
* 接收者在spring.mail.sendto中指定
......@@ -171,10 +129,6 @@ public class NotifyService {
this.smsTemplate = smsTemplate;
}
public void setWxTemplateSender(WxTemplateSender wxTemplateSender) {
this.wxTemplateSender = wxTemplateSender;
}
public void setWxTemplate(List<Map<String, String>> wxTemplate) {
this.wxTemplate = wxTemplate;
}
......
package org.linlinjava.litemall.core.notify;
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaTemplateData;
import cn.binarywang.wx.miniapp.bean.WxMaTemplateMessage;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.linlinjava.litemall.db.domain.LitemallUserFormid;
import org.linlinjava.litemall.db.service.LitemallUserFormIdService;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.List;
/**
* 微信模版消息通知
*/
public class WxTemplateSender {
private final Log logger = LogFactory.getLog(WxTemplateSender.class);
@Autowired
private WxMaService wxMaService;
@Autowired
private LitemallUserFormIdService formIdService;
/**
* 发送微信消息(模板消息),不带跳转
*
* @param touser 用户 OpenID
* @param templatId 模板消息ID
* @param parms 详细内容
*/
public void sendWechatMsg(String touser, String templatId, String[] parms) {
sendMsg(touser, templatId, parms, "", "", "");
}
/**
* 发送微信消息(模板消息),带跳转
*
* @param touser 用户 OpenID
* @param templatId 模板消息ID
* @param parms 详细内容
* @param page 跳转页面
*/
public void sendWechatMsg(String touser, String templatId, String[] parms, String page) {
sendMsg(touser, templatId, parms, page, "", "");
}
private void sendMsg(String touser, String templatId, String[] parms, String page, String color,
String emphasisKeyword) {
LitemallUserFormid userFormid = formIdService.queryByOpenId(touser);
if (userFormid == null)
return;
WxMaTemplateMessage msg = new WxMaTemplateMessage();
msg.setTemplateId(templatId);
msg.setToUser(touser);
msg.setFormId(userFormid.getFormid());
msg.setPage(page);
msg.setColor(color);
msg.setEmphasisKeyword(emphasisKeyword);
msg.setData(createMsgData(parms));
try {
wxMaService.getMsgService().sendTemplateMsg(msg);
if (formIdService.updateUserFormId(userFormid) == 0) {
logger.warn("更新数据已失效");
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
private List<WxMaTemplateData> createMsgData(String[] parms) {
List<WxMaTemplateData> dataList = new ArrayList<WxMaTemplateData>();
for (int i = 1; i <= parms.length; i++) {
dataList.add(new WxMaTemplateData("keyword" + i, parms[i - 1]));
}
return dataList;
}
}
......@@ -4,7 +4,6 @@ import com.github.qcloudsms.SmsSingleSender;
import org.linlinjava.litemall.core.notify.AliyunSmsSender;
import org.linlinjava.litemall.core.notify.NotifyService;
import org.linlinjava.litemall.core.notify.TencentSmsSender;
import org.linlinjava.litemall.core.notify.WxTemplateSender;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
......@@ -46,11 +45,6 @@ public class NotifyAutoConfiguration {
notifyService.setSmsTemplate(smsConfig.getTemplate());
}
NotifyProperties.Wx wxConfig = properties.getWx();
if (wxConfig.isEnable()) {
notifyService.setWxTemplateSender(wxTemplateSender());
notifyService.setWxTemplate(wxConfig.getTemplate());
}
return notifyService;
}
......@@ -75,12 +69,6 @@ public class NotifyAutoConfiguration {
return mailSender;
}
@Bean
public WxTemplateSender wxTemplateSender() {
WxTemplateSender wxTemplateSender = new WxTemplateSender();
return wxTemplateSender;
}
@Bean
public TencentSmsSender tencentSmsSender() {
NotifyProperties.Sms smsConfig = properties.getSms();
......
......@@ -10,7 +10,6 @@ import java.util.Map;
public class NotifyProperties {
private Mail mail;
private Sms sms;
private Wx wx;
public Mail getMail() {
return mail;
......@@ -28,14 +27,6 @@ public class NotifyProperties {
this.sms = sms;
}
public Wx getWx() {
return wx;
}
public void setWx(Wx wx) {
this.wx = wx;
}
public static class Mail {
private boolean enable;
private String host;
......@@ -209,25 +200,4 @@ public class NotifyProperties {
}
}
public static class Wx {
private boolean enable;
private List<Map<String, String>> template = new ArrayList<>();
public boolean isEnable() {
return enable;
}
public void setEnable(boolean enable) {
this.enable = enable;
}
public List<Map<String, String>> getTemplate() {
return template;
}
public void setTemplate(List<Map<String, String>> template) {
this.template = template;
}
}
}
......@@ -46,21 +46,6 @@ litemall:
accessKeyId: xxx
accessKeySecret: xxx
# 微信模版通知配置
# 微信模版用于通知客户或者运营者,注意配置格式;template-name,template-templateId 请参考 NotifyType 枚举值
wx:
enable: false
template:
- name: paySucceed
templateId: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- name: captcha
templateId: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- name: ship
templateId: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- name: refund
templateId: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# 快鸟物流查询配置
express:
enable: false
......
......@@ -150,10 +150,6 @@
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
</table>
<table tableName="litemall_user_formid">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
</table>
<table tableName="litemall_groupon_rules">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
</table>
......
......@@ -316,14 +316,6 @@ INSERT INTO `litemall_user` VALUES (1,'user123','$2a$10$lTu9qi0hr19OC800Db.eludF
/*!40000 ALTER TABLE `litemall_user` ENABLE KEYS */;
UNLOCK TABLES;
 
--
-- Dumping data for table `litemall_user_formid`
--
LOCK TABLES `litemall_user_formid` WRITE;
/*!40000 ALTER TABLE `litemall_user_formid` DISABLE KEYS */;
/*!40000 ALTER TABLE `litemall_user_formid` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
 
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
......@@ -753,26 +753,6 @@ CREATE TABLE `litemall_user` (
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COMMENT='用户表';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `litemall_user_formid`
--
DROP TABLE IF EXISTS `litemall_user_formid`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `litemall_user_formid` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`formId` varchar(63) NOT NULL COMMENT '缓存的FormId',
`isprepay` tinyint(1) NOT NULL COMMENT '是FormId还是prepayId',
`useAmount` int(2) NOT NULL COMMENT '可用次数,fromId为1,prepay为3,用1次减1',
`expire_time` datetime NOT NULL COMMENT '过期时间,腾讯规定为7天',
`openId` varchar(63) NOT NULL COMMENT '微信登录openid',
`add_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`deleted` tinyint(1) DEFAULT '0' COMMENT '逻辑删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
......
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
*/
LitemallUserFormid selectOneByExample(LitemallUserFormidExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user_formid
*
* @mbg.generated
*/
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
*/
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
*/
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
*/
LitemallUserFormid selectByPrimaryKeyWithLogicalDelete(@Param("id") Integer id, @Param("andLogicalDeleted") boolean andLogicalDeleted);
/**
* 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);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user_formid
*
* @mbg.generated
*/
int logicalDeleteByExample(@Param("example") LitemallUserFormidExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user_formid
*
* @mbg.generated
*/
int logicalDeleteByPrimaryKey(Integer id);
}
\ No newline at end of file
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());
example.setOrderByClause("add_time desc");
return formidMapper.selectOneByExample(example);
}
/**
* 更新或删除FormId
*
* @param userFormid
*/
public int updateUserFormId(LitemallUserFormid userFormid) {
//更新或者删除缓存
if (userFormid.getIsprepay() && userFormid.getUseamount() > 1) {
userFormid.setUseamount(userFormid.getUseamount() - 1);
userFormid.setUpdateTime(LocalDateTime.now());
return formidMapper.updateByPrimaryKey(userFormid);
} else {
return formidMapper.deleteByPrimaryKey(userFormid.getId());
}
}
/**
* 添加一个 FormId
*
* @param userFormid
*/
public void addUserFormid(LitemallUserFormid userFormid) {
userFormid.setAddTime(LocalDateTime.now());
userFormid.setUpdateTime(LocalDateTime.now());
formidMapper.insertSelective(userFormid);
}
}
<?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" />
<result column="add_time" jdbcType="TIMESTAMP" property="addTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="deleted" jdbcType="BIT" property="deleted" />
</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, add_time, update_time, deleted
</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.
-->
select
<if test="example.distinct">
distinct
</if>
<choose>
<when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=",">
${column.aliasedEscapedColumnName}
</foreach>
</when>
<otherwise>
<include refid="Base_Column_List" />
</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="selectByPrimaryKeyWithLogicalDelete" parameterType="map" 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}
and deleted =
<choose>
<when test="andLogicalDeleted">
1
</when>
<otherwise>
0
</otherwise>
</choose>
</select>
<select id="selectByPrimaryKeySelective" parameterType="map" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<choose>
<when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=",">
${column.aliasedEscapedColumnName}
</foreach>
</when>
<otherwise>
<include refid="Base_Column_List" />
</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, add_time,
update_time, deleted)
values (#{formid,jdbcType=VARCHAR}, #{isprepay,jdbcType=BIT}, #{useamount,jdbcType=INTEGER},
#{expireTime,jdbcType=TIMESTAMP}, #{openid,jdbcType=VARCHAR}, #{addTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP}, #{deleted,jdbcType=BIT})
</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>
<if test="addTime != null">
add_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="deleted != null">
deleted,
</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>
<if test="addTime != null">
#{addTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="deleted != null">
#{deleted,jdbcType=BIT},
</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>
<if test="record.addTime != null">
add_time = #{record.addTime,jdbcType=TIMESTAMP},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
</if>
<if test="record.deleted != null">
deleted = #{record.deleted,jdbcType=BIT},
</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},
add_time = #{record.addTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
deleted = #{record.deleted,jdbcType=BIT}
<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>
<if test="addTime != null">
add_time = #{addTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="deleted != null">
deleted = #{deleted,jdbcType=BIT},
</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},
add_time = #{addTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
deleted = #{deleted,jdbcType=BIT}
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.
-->
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.
-->
select
<choose>
<when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=",">
${column.aliasedEscapedColumnName}
</foreach>
</when>
<otherwise>
<include refid="Base_Column_List" />
</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>
<update id="logicalDeleteByExample" parameterType="map">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update litemall_user_formid set deleted = 1
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="logicalDeleteByPrimaryKey" parameterType="java.lang.Integer">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update litemall_user_formid set deleted = 1
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
......@@ -371,8 +371,6 @@ export function feedbackAdd(data) {
const FootprintList='wx/footprint/list'; //足迹列表
const FootprintDelete='wx/footprint/delete'; //删除足迹
const UserFormIdCreate='wx/formid/create'; //用户FromId,用于发送模版消息
const GrouponList='wx/groupon/list'; //团购列表
export function grouponList(query) {
return request({
......
......@@ -91,8 +91,6 @@ public class WxOrderService {
@Autowired
private NotifyService notifyService;
@Autowired
private LitemallUserFormIdService formIdService;
@Autowired
private LitemallGrouponRulesService grouponRulesService;
@Autowired
private LitemallGrouponService grouponService;
......@@ -588,18 +586,6 @@ public class WxOrderService {
orderRequest.setSpbillCreateIp(IpUtil.getIpAddr(request));
result = wxPayService.createOrder(orderRequest);
//缓存prepayID用于后续模版通知
String prepayId = result.getPackageValue();
prepayId = prepayId.replace("prepay_id=", "");
LitemallUserFormid userFormid = new LitemallUserFormid();
userFormid.setOpenid(user.getWeixinOpenid());
userFormid.setFormid(prepayId);
userFormid.setIsprepay(true);
userFormid.setUseamount(3);
userFormid.setExpireTime(LocalDateTime.now().plusDays(7));
formIdService.addUserFormid(userFormid);
} catch (Exception e) {
e.printStackTrace();
return ResponseUtil.fail(ORDER_PAY_FAIL, "订单不能支付");
......@@ -778,8 +764,6 @@ public class WxOrderService {
order.getAddress()
};
notifyService.notifyWxTemplate(result.getOpenid(), NotifyType.PAY_SUCCEED, parms, "pages/index/index?orderId=" + order.getId());
// 取消订单超时未支付任务
taskService.removeTask(new OrderUnpaidTask(order.getId()));
......
package org.linlinjava.litemall.wx.web;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
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.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
@RestController
@RequestMapping("/wx/formid")
@Validated
public class WxUserFormId {
private final Log logger = LogFactory.getLog(WxUserFormId.class);
@Autowired
private LitemallUserService userService;
@Autowired
private LitemallUserFormIdService formIdService;
@GetMapping("create")
public Object create(@LoginUser Integer userId, @NotNull String formId) {
if (userId == null) {
return ResponseUtil.unlogin();
}
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();
}
}
......@@ -81,8 +81,6 @@ module.exports = {
FootprintList: WxApiRoot + 'footprint/list', //足迹列表
FootprintDelete: WxApiRoot + 'footprint/delete', //删除足迹
UserFormIdCreate: WxApiRoot + 'formid/create', //用户FromId,用于发送模版消息
GroupOnList: WxApiRoot + 'groupon/list', //团购列表
GroupOnMy: WxApiRoot + 'groupon/my', //团购API-我的团购
GroupOnDetail: WxApiRoot + 'groupon/detail', //团购API-详情
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment