Authored by Amos_sdy

测试短信发送场景FIRST_ORDER_GET_COUPON

... ... @@ -5,25 +5,5 @@ import java.util.List;
import com.yoho.message.dal.model.UserOpenid;
public interface IUserOpenidDAO {
int deleteByPrimaryKey(Integer id);
int insert(UserOpenid record);
int insertSelective(UserOpenid record);
UserOpenid selectByPrimaryKey(Integer id);
List<UserOpenid> selectByUid(Integer uid);
UserOpenid selectOpenUserByOpenAndRefer(String openId, String referId);
UserOpenid selectOpenUserByUidAndRefer(int uid, int referId);
int updateUserOpenID(String newOpenID, String oldOpenID);
int updateByPrimaryKeySelective(UserOpenid record);
int updateByPrimaryKey(UserOpenid record);
int updateUserOpenIDByUid(UserOpenid record);
}
\ No newline at end of file
... ...
... ... @@ -13,19 +13,6 @@
<sql id="Base_Column_List">
id, uid, open_id, refer_id, bind_time, share_bind, nickname
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap"
parameterType="java.lang.Integer">
select
<include refid="Base_Column_List" />
from user_openid
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectOpenUserByOpenAndRefer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from user_openid
where open_id=#{0} and refer_id=#{1} limit 1
</select>
<select id="selectByUid" resultMap="BaseResultMap"
parameterType="java.lang.Integer">
... ... @@ -34,111 +21,4 @@
from user_openid
where uid = #{uid,jdbcType=INTEGER}
</select>
<select id="selectOpenUserByUidAndRefer" resultMap="BaseResultMap"
parameterType="java.lang.Integer">
select
<include refid="Base_Column_List" />
from user_openid
where uid=#{0} and refer_id=#{1} limit 1
</select>
<insert id="insert" parameterType="com.yoho.wechat.dal.model.UserOpenid">
insert into user_openid (uid, open_id,
refer_id, bind_time,
nickname)
values (#{uid,jdbcType=INTEGER},
#{openId,jdbcType=VARCHAR},
#{referId,jdbcType=SMALLINT}, #{bindTime,jdbcType=INTEGER},
#{nickname,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.yoho.wechat.dal.model.UserOpenid">
insert into user_openid
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="uid != null">
uid,
</if>
<if test="openId != null">
open_id,
</if>
<if test="referId != null">
refer_id,
</if>
<if test="bindTime != null">
bind_time,
</if>
<if test="shareBind != null">
share_bind,
</if>
<if test="nickname != null">
nickname,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="uid != null">
#{uid,jdbcType=INTEGER},
</if>
<if test="openId != null">
#{openId,jdbcType=VARCHAR},
</if>
<if test="referId != null">
#{referId,jdbcType=SMALLINT},
</if>
<if test="bindTime != null">
#{bindTime,jdbcType=INTEGER},
</if>
<if test="shareBind != null">
#{shareBind,jdbcType=CHAR},
</if>
<if test="nickname != null">
#{nickname,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yoho.wechat.dal.model.UserOpenid">
update user_openid
<set>
<if test="uid != null">
uid = #{uid,jdbcType=INTEGER},
</if>
<if test="openId != null">
open_id = #{openId,jdbcType=VARCHAR},
</if>
<if test="referId != null">
refer_id = #{referId,jdbcType=SMALLINT},
</if>
<if test="bindTime != null">
bind_time = #{bindTime,jdbcType=INTEGER},
</if>
<if test="shareBind != null">
share_bind = #{shareBind,jdbcType=CHAR},
</if>
<if test="nickname != null">
nickname = #{nickname,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yoho.wechat.dal.model.UserOpenid">
update user_openid
set uid = #{uid,jdbcType=INTEGER},
open_id = #{openId,jdbcType=VARCHAR},
refer_id = #{referId,jdbcType=SMALLINT},
bind_time = #{bindTime,jdbcType=INTEGER},
share_bind = #{shareBind,jdbcType=CHAR},
nickname = #{nickname,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateUserOpenID">
update user_openid set
open_id = #{0}
where open_id = #{1}
</update>
<update id="updateUserOpenIDByUid" parameterType="com.yoho.wechat.dal.model.UserOpenid">
update user_openid set open_id=#{openId} where uid=#{uid} and refer_id=#{referId}
</update>
</mapper>
\ No newline at end of file
... ...
package com.yoho.yhmessage.sms.util;
import java.io.IOException;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
/**
*
* <Description> 通用工具类<br>
... ... @@ -56,41 +42,4 @@ public class CommonUtils {
return text;
}
}
/**
*
* Description: 生成短链<br>
*
* @author amos.shan<br>
* @taskId <br>
* @param url
* @return <br>
*/
public static String generateShortUrl(String url) {
JSONObject response = new JSONObject();
// 创建HttpClientBuilder
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
// HttpClient
CloseableHttpClient closeableHttpClient = httpClientBuilder.build();
// 调用百度短链API生成短链
HttpPost httpPost = new HttpPost("http://dwz.cn/create.php");
try {
List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
params.add(new BasicNameValuePair("url", url));
httpPost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
HttpResponse httpResponse = closeableHttpClient.execute(httpPost);
if (httpResponse.getStatusLine().getStatusCode() == 200) {
// 获取响应消息实体
HttpEntity entity = httpResponse.getEntity();
// 判断响应实体是否为空
if (entity != null) {
response = JSON.parseObject(EntityUtils.toString(entity, "UTF-8"));
return response.getString("tinyurl");
}
}
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
return null;
}
}
... ...