Authored by mingdan.ge

Merge branch 'dev_new_yoho_190718' into test6.9.9

package com.yoho.unions.dal;
import com.yoho.unions.dal.model.UnionUicRegister;
import org.apache.ibatis.annotations.Param;
import java.util.Set;
public interface UnionUicRegisterMapper {
int deleteByPrimaryKey(Integer uid);
int insert(UnionUicRegister record);
int insertSelective(UnionUicRegister record);
UnionUicRegister selectByPrimaryKey(Integer uid);
Set<Integer> selectByUids(@Param("list") Set<Integer> uids);
int updateByPrimaryKeySelective(UnionUicRegister record);
int updateByPrimaryKey(UnionUicRegister record);
}
\ No newline at end of file
... ...
package com.yoho.unions.dal.model;
public class UnionUicRegister {
private int uid;
private String mobile;
private String businessLine;
private String udid;
private String ip;
private String source;
private String sessionKey;
private String sendCouponStatus;
private String inviteCode;
private String registerType;
//位置信息
private String longitude;//经度
private String latitude;//纬度
private String fromPage;//来源页
public Integer getUid() {
return uid;
}
public void setUid(Integer uid) {
this.uid = uid;
}
public void setUid(int uid) {
this.uid = uid;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getBusinessLine() {
return businessLine;
}
public void setBusinessLine(String businessLine) {
this.businessLine = businessLine;
}
public String getUdid() {
return udid;
}
public void setUdid(String udid) {
this.udid = udid;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public String getSessionKey() {
return sessionKey;
}
public void setSessionKey(String sessionKey) {
this.sessionKey = sessionKey;
}
public String getSendCouponStatus() {
return sendCouponStatus;
}
public void setSendCouponStatus(String sendCouponStatus) {
this.sendCouponStatus = sendCouponStatus;
}
public String getInviteCode() {
return inviteCode;
}
public void setInviteCode(String inviteCode) {
this.inviteCode = inviteCode;
}
public String getRegisterType() {
return registerType;
}
public void setRegisterType(String registerType) {
this.registerType = registerType;
}
public String getLongitude() {
return longitude;
}
public void setLongitude(String longitude) {
this.longitude = longitude;
}
public String getLatitude() {
return latitude;
}
public void setLatitude(String latitude) {
this.latitude = latitude;
}
public String getFromPage() {
return fromPage;
}
public void setFromPage(String fromPage) {
this.fromPage = fromPage;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip == null ? null : ip.trim();
}
}
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.yoho.unions.dal.UnionUicRegisterMapper" >
<resultMap id="BaseResultMap" type="com.yoho.unions.dal.model.UnionUicRegister" >
<id column="uid" property="uid" jdbcType="INTEGER" />
<result column="udid" property="udid" jdbcType="INTEGER" />
<result column="invite_code" property="inviteCode" jdbcType="VARCHAR" />
<result column="ip" property="ip" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
uid, udid, invite_code, ip
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from union_uic_register
where uid = #{uid,jdbcType=INTEGER}
</select>
<select id="selectByUids" resultType="java.lang.Integer" parameterType="java.lang.Integer" >
select uid
from union_uic_register
where uid in
<foreach collection="list" item="uid" close=")" open="(" separator=",">
#{uid}
</foreach>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from union_uic_register
where uid = #{uid,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yoho.unions.dal.model.UnionUicRegister" >
insert into union_uic_register (uid, udid, invite_code,
ip)
values (#{uid,jdbcType=INTEGER}, #{udid,jdbcType=INTEGER}, #{inviteCode,jdbcType=VARCHAR},
#{ip,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.yoho.unions.dal.model.UnionUicRegister" >
insert into union_uic_register
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="uid != null" >
uid,
</if>
<if test="udid != null" >
udid,
</if>
<if test="inviteCode != null" >
invite_code,
</if>
<if test="ip != null" >
ip,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="uid != null" >
#{uid,jdbcType=INTEGER},
</if>
<if test="udid != null" >
#{udid,jdbcType=INTEGER},
</if>
<if test="inviteCode != null" >
#{inviteCode,jdbcType=VARCHAR},
</if>
<if test="ip != null" >
#{ip,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yoho.unions.dal.model.UnionUicRegister" >
update union_uic_register
<set >
<if test="udid != null" >
udid = #{udid,jdbcType=INTEGER},
</if>
<if test="inviteCode != null" >
invite_code = #{inviteCode,jdbcType=VARCHAR},
</if>
<if test="ip != null" >
ip = #{ip,jdbcType=VARCHAR},
</if>
</set>
where uid = #{uid,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yoho.unions.dal.model.UnionUicRegister" >
update union_uic_register
set udid = #{udid,jdbcType=INTEGER},
invite_code = #{inviteCode,jdbcType=VARCHAR},
ip = #{ip,jdbcType=VARCHAR}
where uid = #{uid,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
... ...
package com.yoho.unions.server.mqconsumer;
import com.alibaba.fastjson.JSONObject;
import com.yoho.core.rabbitmq.YhConsumer;
import com.yoho.unions.dal.UnionUicRegisterMapper;
import com.yoho.unions.dal.model.UnionUicRegister;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 消费uic的用户注册消息uic.registerMessage(消息为promotion消费发新客券的)
* to 获取设备首次注册的用户
* Created by mingdan.ge on 2019/7/23.
*/
@Component
public class UnionUicRegisterConsumer implements YhConsumer {
private Logger logger = LoggerFactory.getLogger(UnionUicRegisterConsumer.class);
@Autowired
UnionUicRegisterMapper unionUicRegisterMapper;
@Override
public void handleMessage(Object o) throws Exception{
logger.info("UnionUicRegisterConsumer,handleMessage {}", o);
try {
if (null == o) {
return;
}
UnionUicRegister register =JSONObject.parseObject(o.toString(),UnionUicRegister.class);
// RegisterMessageBO jsonObject =JSONObject.parseObject(o.toString(),RegisterMessageBO.class);
if (register != null&&register.getSendCouponStatus().equals("Y")) {
//设备首次注册,记录注册用户
unionUicRegisterMapper.insert(register);
}
} catch (Exception e) {
logger.warn("UnionUicRegisterConsumer,handleMessage fail! obj is {}, e is {}",o,e);
}
}
}
... ...
... ... @@ -112,6 +112,8 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
@Autowired
UnionShareYohoUserMapper unionShareYohoUserMapper;
@Autowired
UnionUicRegisterMapper unionUicRegisterMapper;
@Autowired
SendMessageHelper sendMessageHelper;
@Autowired
... ... @@ -675,8 +677,9 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
/**
* 给报名的邀请人发奖励
* */
public void joinInviteActivity(List<AppYohoCpsNewUid> appYohoCpsNewUids, Set<Integer> newUids, List<UnionShareOrdersActivity> activities) {
//过滤掉非新用户(会员提供新用户标识) TODO
public void joinInviteActivity(List<AppYohoCpsNewUid> appYohoCpsNewUids, Set<Integer> uids, List<UnionShareOrdersActivity> activities) {
//过滤掉非新用户(会员提供新用户标识)
Set<Integer> newUids = unionUicRegisterMapper.selectByUids(uids);
if (CollectionUtils.isEmpty(newUids)||CollectionUtils.isEmpty(appYohoCpsNewUids)||CollectionUtils.isEmpty(activities)) {
return;
... ... @@ -694,7 +697,6 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
}
@Database(ForceMaster=true)
public boolean tryJoinInviteActivity(UnionShareOrdersActivity activity,AppYohoCpsNewUid appYohoCpsNewUid) {
//1、判断是否符合活动条件
... ... @@ -718,7 +720,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
int now = DateUtil.getCurrentTimeSeconds();
int beginTime = DateUtil.getLastDayStartInt(appYohoCpsNewUid.getCreateTime(), 0);
int endTime = DateUtil.getLastDayEndInt(appYohoCpsNewUid.getCreateTime(), 0);
//4、记录邀请
//4、判断当日邀请数是否已达最大值,达到则不发奖励,且不记录
int maxInviteNum = configReader.getInt(UNION_MAX_INVITE_NUM, 2500);
int count = unionShareYohoUserMapper.selectCountOfDate(appYohoCpsNewUid.getInviterUid(), beginTime, endTime);
if (count >= maxInviteNum) {
... ... @@ -728,6 +730,8 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
if (userInfoRspBO == null) {
return false;
}
//记录邀请
UnionShareYohoUser unionShareYohoUser = new UnionShareYohoUser();
unionShareYohoUser.setDate(appYohoCpsNewUid.getCreateTime());
unionShareYohoUser.setCreateTime(now);
... ... @@ -1270,7 +1274,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
throw new ServiceException(ServiceError.UNION_HAS_APPLY_ERROR);
}
// 校验姓名
if (!ChineseNameUtils.checkName(req.getName())) {
if (req.getName() != null && !ChineseNameUtils.checkName(req.getName())) {
throw new ServiceException(ServiceError.UNION_CHINESE_NAME_ERROR);
}
req.setSocialMediaList(filterSocialMedia(req.getSocialMediaList()));
... ... @@ -1384,6 +1388,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
}
void sendBankCardToErp(UnionShareUserBank card) {
logger.info("sendBankCardToErp.send mq,topic is {},card is {}.",BANKCARD_TOPIC,card);
yhProducer.send(BANKCARD_TOPIC, card);
}
... ...
... ... @@ -101,6 +101,7 @@ datasources:
- com.yoho.unions.dal.UnionCallbackOrderMapper
- com.yoho.unions.dal.UnionShareUserIdentityCardMapper
- com.yoho.unions.dal.UnionShareYohoUserMapper
- com.yoho.unions.dal.UnionUicRegisterMapper
... ...
... ... @@ -17,6 +17,9 @@ consumer:
- class: com.yoho.unions.server.mqconsumer.UnionFansRelationConsumer
topic: bigdata.union.fansRelation
- class: com.yoho.unions.server.mqconsumer.UnionUicRegisterConsumer
topic: uic.registerMessage
producer:
- address: 192.168.102.45:5672
producers:
... ...
... ... @@ -93,6 +93,7 @@ datasources:
- com.yoho.unions.dal.UnionCallbackOrderMapper
- com.yoho.unions.dal.UnionShareUserIdentityCardMapper
- com.yoho.unions.dal.UnionShareYohoUserMapper
- com.yoho.unions.dal.UnionUicRegisterMapper
bigdata_yh_unions:
servers:
... ...
... ... @@ -18,6 +18,9 @@ consumer:
- class: com.yoho.unions.server.mqconsumer.UnionFansRelationConsumer
topic: bigdata.union.fansRelation
- class: com.yoho.unions.server.mqconsumer.UnionUicRegisterConsumer
topic: uic.registerMessage
producer:
- address: ${rabbit_common}
username: ${rabbit_common_user}
... ...