Просмотр исходного кода

[C端用户登录次数统计][新增]:C端用户登录次数统计

release_toaliyun_real
Stormeye.Wu 7 лет назад
Родитель
Сommit
6f602b179c
3 измененных файлов: 202 добавлений и 200 удалений
  1. +11
    -0
      mallinkService/src/main/java/com/simple/domain/po/WxCUser.java
  2. +2
    -0
      mallinkService/src/main/java/com/simple/service/impl/WxCUserServiceImpl.java
  3. +189
    -200
      mallinkService/src/main/resources/mapper/WxCUserMapper.xml

+ 11
- 0
mallinkService/src/main/java/com/simple/domain/po/WxCUser.java Просмотреть файл

@@ -122,6 +122,9 @@ public class WxCUser implements Serializable {
/*纬度**/ /*纬度**/
@io.swagger.annotations.ApiModelProperty(value="纬度",name="latitude") @io.swagger.annotations.ApiModelProperty(value="纬度",name="latitude")
private BigDecimal latitude; private BigDecimal latitude;
/*登录次数**/
@io.swagger.annotations.ApiModelProperty(value="登录次数",name="loginCount")
private Integer loginCount;
//渠道名称 //渠道名称
@Transient @Transient
@@ -297,6 +300,14 @@ public class WxCUser implements Serializable {
this.latitude = latitude; this.latitude = latitude;
} }


public Integer getLoginCount() {
return loginCount;
}

public void setLoginCount(Integer loginCount) {
this.loginCount = loginCount;
}

public static enum Field public static enum Field
{ {
Id_ASC("`id` ASC"),Id_DESC("`id` DESC") Id_ASC("`id` ASC"),Id_DESC("`id` DESC")


+ 2
- 0
mallinkService/src/main/java/com/simple/service/impl/WxCUserServiceImpl.java Просмотреть файл

@@ -46,10 +46,12 @@ public class WxCUserServiceImpl implements WxCUserService {
//record.setId(UUID.randomUUID().toString().replaceAll("-", "")); //record.setId(UUID.randomUUID().toString().replaceAll("-", ""));
final IdWorker idWorker = IdWorker.get(); final IdWorker idWorker = IdWorker.get();
user.setId(idWorker.nextId()); user.setId(idWorker.nextId());
user.setLoginCount(1);
user.setCreateDate(curr); user.setCreateDate(curr);
user.setUpdateDate(curr); user.setUpdateDate(curr);
ret = wxCUserMapper.insertSelective(user); ret = wxCUserMapper.insertSelective(user);
} else { } else {
user.setLoginCount(user.getLoginCount() + 1);
user.setUpdateDate(curr); user.setUpdateDate(curr);
ret =wxCUserMapper.updateByPrimaryKeySelective(user); ret =wxCUserMapper.updateByPrimaryKeySelective(user);
} }


+ 189
- 200
mallinkService/src/main/resources/mapper/WxCUserMapper.xml Просмотреть файл

@@ -1,214 +1,203 @@
<?xml version="1.0" encoding="UTF-8"?> <?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"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.simple.mapper.WxCUserMapper"> <mapper namespace="com.simple.mapper.WxCUserMapper">
<resultMap id="BaseResultMap" type="com.simple.domain.po.WxCUser">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
<result column="open_id" jdbcType="VARCHAR" property="openId" />
<result column="union_id" jdbcType="VARCHAR" property="unionId" />
<result column="nick_name" jdbcType="VARCHAR" property="nickName" />
<result column="gender" jdbcType="INTEGER" property="gender" />
<result column="avatar_url" jdbcType="VARCHAR" property="avatarUrl" />
<result column="phone" jdbcType="VARCHAR" property="phone" />
<result column="pure_phone" jdbcType="VARCHAR" property="purePhone" />
<result column="city" jdbcType="VARCHAR" property="city" />
<result column="province" jdbcType="VARCHAR" property="province" />
<result column="language" jdbcType="VARCHAR" property="language" />
<result column="country_code" jdbcType="VARCHAR" property="countryCode" />
<result column="register_ip" jdbcType="VARCHAR" property="registerIp" />
<result column="verify_code_phone" jdbcType="VARCHAR" property="verifyCodePhone" />
<result column="qrcode_source" jdbcType="VARCHAR" property="qrcodeSource" />
<result column="scene" jdbcType="VARCHAR" property="scene" />
<result column="scene_address" jdbcType="VARCHAR" property="sceneAddress" />
<result column="session_key" jdbcType="VARCHAR" property="sessionKey" />
<result column="score" jdbcType="INTEGER" property="score" />
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
<result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
<result column="app_id" jdbcType="VARCHAR" property="appId" />
<result column="token" jdbcType="VARCHAR" property="token" />
<result column="expire_time" jdbcType="TIMESTAMP" property="expireTime" />
</resultMap>
<sql id="allColumns">
`id`,`tenant_id`,`open_id`,`union_id`,`nick_name`,`gender`,`avatar_url`,`phone`,`pure_phone`,`city`,`province`,`language`,`country_code`,`register_ip`,`verify_code_phone`,`qrcode_source`,`scene`,`scene_address`,`session_key`,`score`,`update_date`,`create_date`,`app_id`,`token`,`expire_time`
</sql>
<resultMap id="BaseResultMap" type="com.simple.domain.po.WxCUser">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
<result column="open_id" jdbcType="VARCHAR" property="openId"/>
<result column="union_id" jdbcType="VARCHAR" property="unionId"/>
<result column="nick_name" jdbcType="VARCHAR" property="nickName"/>
<result column="gender" jdbcType="INTEGER" property="gender"/>
<result column="avatar_url" jdbcType="VARCHAR" property="avatarUrl"/>
<result column="phone" jdbcType="VARCHAR" property="phone"/>
<result column="pure_phone" jdbcType="VARCHAR" property="purePhone"/>
<result column="city" jdbcType="VARCHAR" property="city"/>
<result column="province" jdbcType="VARCHAR" property="province"/>
<result column="language" jdbcType="VARCHAR" property="language"/>
<result column="country_code" jdbcType="VARCHAR" property="countryCode"/>
<result column="register_ip" jdbcType="VARCHAR" property="registerIp"/>
<result column="verify_code_phone" jdbcType="VARCHAR" property="verifyCodePhone"/>
<result column="qrcode_source" jdbcType="VARCHAR" property="qrcodeSource"/>
<result column="scene" jdbcType="VARCHAR" property="scene"/>
<result column="scene_address" jdbcType="VARCHAR" property="sceneAddress"/>
<result column="session_key" jdbcType="VARCHAR" property="sessionKey"/>
<result column="score" jdbcType="INTEGER" property="score"/>
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
<result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
<result column="app_id" jdbcType="VARCHAR" property="appId"/>
<result column="token" jdbcType="VARCHAR" property="token"/>
<result column="expire_time" jdbcType="TIMESTAMP" property="expireTime"/>
<result column="latitude" jdbcType="DECIMAL" property="latitude"/>
<result column="longitude" jdbcType="DECIMAL" property="longitude"/>
<result column="login_count" jdbcType="INTEGER" property="loginCount"/>
</resultMap>


<sql id="dynamicWhereConditions">
where 1 = 1
<if test=" null != id ">
and `id` = #{id}
</if>
<if test=" null != tenantId ">
and `tenant_id` like concat('%', #{tenantId},'%')
</if>
<if test=" null != openId ">
and `open_id` like concat('%', #{openId},'%')
</if>
<if test=" null != unionId ">
and `union_id` like concat('%', #{unionId},'%')
</if>
<if test=" null != nickName ">
and `nick_name` like concat('%', #{nickName},'%')
</if>
<if test=" null != gender ">
and `gender` = #{gender}
</if>
<if test=" null != avatarUrl ">
and `avatar_url` like concat('%', #{avatarUrl},'%')
</if>
<if test=" null != phone ">
and `phone` like concat('%', #{phone},'%')
</if>
<if test=" null != purePhone ">
and `pure_phone` like concat('%', #{purePhone},'%')
</if>
<if test=" null != city ">
and `city` like concat('%', #{city},'%')
</if>
<if test=" null != province ">
and `province` like concat('%', #{province},'%')
</if>
<if test=" null != language ">
and `language` like concat('%', #{language},'%')
</if>
<if test=" null != countryCode ">
and `country_code` like concat('%', #{countryCode},'%')
</if>
<if test=" null != registerIp ">
and `register_ip` like concat('%', #{registerIp},'%')
</if>
<if test=" null != verifyCodePhone ">
and `verify_code_phone` like concat('%', #{verifyCodePhone},'%')
</if>
<if test=" null != qrcodeSource ">
and `qrcode_source` like concat('%', #{qrcodeSource},'%')
</if>
<if test=" null != scene ">
and `scene` like concat('%', #{scene},'%')
</if>
<if test=" null != sceneAddress ">
and `scene_address` like concat('%', #{sceneAddress},'%')
</if>
<if test=" null != sessionKey ">
and `session_key` like concat('%', #{sessionKey},'%')
</if>
<if test=" null != score ">
and `score` = #{score}
</if>
<if test=" null != updateDate ">
and `update_date` = #{updateDate}
</if>
<if test=" null != createDate ">
and `create_date` = #{createDate}
</if>
<if test=" null != appId ">
and `app_id` like concat('%', #{appId},'%')
</if>
<if test=" null != token ">
and `token` like concat('%', #{token},'%')
</if>
<if test=" null != expireTime ">
and `expire_time` = #{expireTime}
</if>
<if test=" null != ids ">
and id in
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
#{idItem}
</foreach>
</if>
<if test=" null != sortColumns"> order by ${sortColumns} </if>
<sql id="allColumns">
`id`,`tenant_id`,`open_id`,`union_id`,`nick_name`,`gender`,`avatar_url`,`phone`,`pure_phone`,`city`,`province`,`language`,`country_code`,`register_ip`,`verify_code_phone`,`qrcode_source`,`scene`,`scene_address`,`session_key`,`score`,`update_date`,`create_date`,`app_id`,`token`,`expire_time`,`latitude`, `longitude`, `login_count`
</sql> </sql>
<select id="findList" parameterType="com.simple.domain.po.WxCUser" resultMap="BaseResultMap">
select <include refid="allColumns" /> from wx_c_user
<include refid="dynamicWhereConditions" />
</select>


<select id="findByOpenId" parameterType="com.simple.domain.po.WxCUser" resultMap="BaseResultMap">
<sql id="dynamicWhereConditions">
where 1 = 1

<if test=" null != id ">
and `id` = #{id}
</if>

<if test=" null != tenantId ">
and `tenant_id` like concat('%', #{tenantId},'%')
</if>

<if test=" null != openId ">
and `open_id` like concat('%', #{openId},'%')
</if>

<if test=" null != unionId ">
and `union_id` like concat('%', #{unionId},'%')
</if>

<if test=" null != nickName ">
and `nick_name` like concat('%', #{nickName},'%')
</if>

<if test=" null != gender ">
and `gender` = #{gender}
</if>

<if test=" null != avatarUrl ">
and `avatar_url` like concat('%', #{avatarUrl},'%')
</if>

<if test=" null != phone ">
and `phone` like concat('%', #{phone},'%')
</if>

<if test=" null != purePhone ">
and `pure_phone` like concat('%', #{purePhone},'%')
</if>

<if test=" null != city ">
and `city` like concat('%', #{city},'%')
</if>

<if test=" null != province ">
and `province` like concat('%', #{province},'%')
</if>

<if test=" null != language ">
and `language` like concat('%', #{language},'%')
</if>

<if test=" null != countryCode ">
and `country_code` like concat('%', #{countryCode},'%')
</if>

<if test=" null != registerIp ">
and `register_ip` like concat('%', #{registerIp},'%')
</if>

<if test=" null != verifyCodePhone ">
and `verify_code_phone` like concat('%', #{verifyCodePhone},'%')
</if>

<if test=" null != qrcodeSource ">
and `qrcode_source` like concat('%', #{qrcodeSource},'%')
</if>

<if test=" null != scene ">
and `scene` like concat('%', #{scene},'%')
</if>

<if test=" null != sceneAddress ">
and `scene_address` like concat('%', #{sceneAddress},'%')
</if>

<if test=" null != sessionKey ">
and `session_key` like concat('%', #{sessionKey},'%')
</if>

<if test=" null != score ">
and `score` = #{score}
</if>

<if test=" null != updateDate ">
and `update_date` = #{updateDate}
</if>

<if test=" null != createDate ">
and `create_date` = #{createDate}
</if>

<if test=" null != appId ">
and `app_id` like concat('%', #{appId},'%')
</if>

<if test=" null != token ">
and `token` like concat('%', #{token},'%')
</if>

<if test=" null != expireTime ">
and `expire_time` = #{expireTime}
</if>
<if test=" null != latitude ">
and `latitude` = #{latitude}
</if>
<if test=" null != longitude ">
and `longitude` = #{longitude}
</if>
<if test=" null != loginCount ">
and `login_count` = #{loginCount}
</if>
<if test=" null != ids ">
and id in
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
#{idItem}
</foreach>
</if>
<if test=" null != sortColumns">order by ${sortColumns}</if>
</sql>

<select id="findList" parameterType="com.simple.domain.po.WxCUser" resultMap="BaseResultMap">
select
<include refid="allColumns"/>
from wx_c_user
<include refid="dynamicWhereConditions"/>
</select>

<select id="findByOpenId" parameterType="com.simple.domain.po.WxCUser" resultMap="BaseResultMap">
select * from wx_c_user select * from wx_c_user
where `app_id` = #{appId} and `open_id` = #{openId} where `app_id` = #{appId} and `open_id` = #{openId}
</select> </select>


<select id="findByToken" resultMap="BaseResultMap">
<select id="findByToken" resultMap="BaseResultMap">
select * from wx_c_user select * from wx_c_user
where `token` = #{token} where `token` = #{token}
</select> </select>
<select id="findCount" parameterType="com.simple.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
select count(id) from wx_c_user where 1=1
<if test=" null != sex ">
and gender =#{sex}
</if>
<if test=" null != startTime ">
and create_date &gt;= #{startTime}
</if>
<if test=" null != endTime">
and create_date &lt; #{endTime}
</if>
<if test="null != tenantId">
and tenant_id =#{tenantId}
</if>
</select>
<select id ="listByChannel" resultMap="BaseResultMap" parameterType="java.util.List">
select id,nick_name,phone,create_date,scene_address from wx_c_user where 1=1
<if test =" sceneList!= null ">
and scene_address in
<foreach collection="sceneList" index="index" item="scene" open="(" separator="," close=")">
#{scene}
</foreach>
</if>
</select>
<select id="findCount" parameterType="com.simple.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
select count(id) from wx_c_user where 1=1
<if test=" null != sex ">
and gender =#{sex}
</if>
<if test=" null != startTime ">
and create_date &gt;= #{startTime}
</if>
<if test=" null != endTime">
and create_date &lt; #{endTime}
</if>
<if test="null != tenantId">
and tenant_id =#{tenantId}
</if>
</select>
<select id="listByChannel" resultMap="BaseResultMap" parameterType="java.util.List">
select id,nick_name,phone,create_date,scene_address from wx_c_user where 1=1
<if test=" sceneList!= null ">
and scene_address in
<foreach collection="sceneList" index="index" item="scene" open="(" separator="," close=")">
#{scene}
</foreach>
</if>
</select>
</mapper> </mapper>

Загрузка…
Отмена
Сохранить