微信导粉统计

This commit is contained in:
xiezhijun
2021-02-04 20:12:46 +08:00
parent 2e3f53f2ea
commit 0283eb0a1d
33 changed files with 2923 additions and 256 deletions

View File

@ -111,6 +111,7 @@
<result property="otherPhysicalSigns" column="other_physical_signs" />
<result property="bloodData" column="blood_data" />
<result property="moistureDate" column="moisture_date" />
<result property="remark" column="remark"></result>
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" />
@ -122,7 +123,7 @@
<sql id="selectSysCustomerHealthyVo">
select sch.id, customer_id, conditioning_project_id, sex, age, weight, tall, condiment, other_condiment, cooking_style, cooking_style_rate, wash_vegetables_style, other_wash_vegetables_style, breakfast_type, breakfast_food, lunch_type, dinner, vegetable_rate, common_meat, dinner_time, supper_num, supper_food, diet_hot_and_cold, diet_flavor, vegetables_num, vegetables_rate_type, fruits_num, fruits_time, fruits_rate, rice_num, rice_full, eating_speed, snacks, other_snacks, health_products_flag, health_products_brand, health_products_name, health_products_week_rate, health_products_day_rate, water_num, water_type, water_habit, drinks_num, drink_wine_flag, drink_wine_classify, other_wine_classify, drink_wine_amount, smoke_flag, smoke_rate, second_smoke, work_industry, work_type, defecation_num, other_defecation_num, defecation_time, defecation_shape, defecation_smell, defecation_speed, defecation_color, motion_num, motion_duration, motion_time, aerobic_motion_classify, anaerobic_motion_classify, anaerobic_aerobic_motion_classify, other_motion_classify, motion_field, other_motion_field, sleep_time, sleep_quality, sleep_drug_flag, sleep_drug, stayup_late_flag, stayup_late_week_num, family_illness_history, other_family_illness_history, operation_history, other_operation_history, near_operation_flag, recoverye_situation, long_eat_drug_flag, long_eat_drug_classify, other_long_eat_drug_classify, allergy_flag, allergy_situation, allergen, other_allergen, medical_report, medical_report_name,
position,experience,rebound,difficulty,crux,dishes_ingredient,make_food_type,physical_signs_id,other_physical_signs,blood_data,moisture_date,
position,experience,rebound,difficulty,crux,dishes_ingredient,make_food_type,physical_signs_id,other_physical_signs,blood_data,moisture_date,sch.remark,
sch.create_time, sch.create_by,sch. update_time, sch.update_by, sch.del_flag
</sql>
@ -259,6 +260,7 @@
<if test="otherPhysicalSigns != null">other_physical_signs,</if>
<if test="bloodData != null">blood_data,</if>
<if test="moistureDate != null">moisture_date,</if>
<if test="remark != null">remark,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateTime != null">update_time,</if>
@ -366,6 +368,7 @@
<if test="otherPhysicalSigns != null">#{otherPhysicalSigns},</if>
<if test="bloodData != null">#{bloodData},</if>
<if test="moistureDate != null">#{moistureDate},</if>
<if test="remark != null">#{remark},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateTime != null">#{updateTime},</if>
@ -476,6 +479,7 @@
<if test="otherPhysicalSigns != null">other_physical_signs = #{otherPhysicalSigns},</if>
<if test="bloodData != null">blood_data = #{bloodData},</if>
<if test="moistureDate != null">moisture_date = #{moistureDate},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>

View File

@ -0,0 +1,126 @@
<?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.stdiet.custom.mapper.SysWxDistributionMapper">
<resultMap type="SysWxDistribution" id="SysWxDistributionResult">
<result property="id" column="id" />
<result property="userId" column="user_id" />
<result property="saleGroupId" column="sale_group_id" />
<result property="accountId" column="account_id" />
<result property="wechatAccount" column="wechat_account" />
<result property="wechatAccountType" column="wechat_account_type" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
<result property="delFlag" column="del_flag" />
<!-- 非持久化字段 -->
<result property="userName" column="user_name"></result>
<result property="account" column="account"></result>
<result property="wxNickName" column="wx_nick_name"></result>
<result property="wxAccount" column="wx_account"></result>
<result property="saleGroup" column="sale_group"></result>
</resultMap>
<sql id="selectSysWxDistributionVo">
select id, user_id, sale_group_id, account_id, wechat_account, wechat_account_type, create_time, create_by, update_time, update_by, del_flag from sys_wx_distribution
</sql>
<sql id="selectSysWxDistributionVoExtended">
SELECT swd.id, swd.user_id, swd.sale_group_id, swd.account_id, swd.wechat_account,swd.create_time,
su.nick_name as user_name,acc.dict_label as account,asg.dict_label as sale_group,
swsa.wx_nick_name,swsa.wx_account
FROM sys_wx_distribution AS swd
lEFT JOIN sys_wx_sale_account swsa ON swsa.id = swd.wechat_account and swsa.del_flag = 0
LEFT JOIN sys_user su ON su.user_id = swd.user_id AND su.del_flag = 0
LEFT JOIN (SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'fan_channel') AS acc ON acc.dict_value = swd.account_id
LEFT JOIN (SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'sale_group') AS asg ON asg.dict_value = swd.sale_group_id
where swd.del_flag = 0
</sql>
<select id="selectSysWxDistributionList" parameterType="SysWxDistribution" resultMap="SysWxDistributionResult">
<include refid="selectSysWxDistributionVoExtended"/>
<if test="userId != null"> and swd.user_id = #{userId}</if>
<if test="saleGroupId != null"> and swd.sale_group_id = #{saleGroupId}</if>
<if test="accountId != null"> and swd.account_id = #{accountId}</if>
ORDER BY swd.id DESC
</select>
<select id="selectSysWxDistributionById" parameterType="Long" resultMap="SysWxDistributionResult">
<include refid="selectSysWxDistributionVo"/>
where id = #{id} and del_flag = 0
</select>
<insert id="insertSysWxDistribution" parameterType="SysWxDistribution" useGeneratedKeys="true" keyProperty="id">
insert into sys_wx_distribution
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userId != null">user_id,</if>
<if test="saleGroupId != null">sale_group_id,</if>
<if test="accountId != null">account_id,</if>
<if test="wechatAccount != null">wechat_account,</if>
<if test="wechatAccountType != null">wechat_account_type,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="delFlag != null">del_flag,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null">#{userId},</if>
<if test="saleGroupId != null">#{saleGroupId},</if>
<if test="accountId != null">#{accountId},</if>
<if test="wechatAccount != null">#{wechatAccount},</if>
<if test="wechatAccountType != null">#{wechatAccountType},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="delFlag != null">#{delFlag},</if>
</trim>
</insert>
<update id="updateSysWxDistribution" parameterType="SysWxDistribution">
update sys_wx_distribution
<trim prefix="SET" suffixOverrides=",">
<if test="userId != null">user_id = #{userId},</if>
<if test="saleGroupId != null">sale_group_id = #{saleGroupId},</if>
<if test="accountId != null">account_id = #{accountId},</if>
<if test="wechatAccount != null">wechat_account = #{wechatAccount},</if>
<if test="wechatAccountType != null">wechat_account_type = #{wechatAccountType},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
</trim>
where id = #{id}
</update>
<update id="deleteSysWxDistributionById" parameterType="Long">
update sys_wx_distribution set del_flag = 1 where id = #{id}
</update>
<update id="deleteSysWxDistributionByIds" parameterType="String">
update sys_wx_distribution set del_flag = 1 where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<!-- 根据微信号ID查询分配记录 -->
<select id="selectWxDistributionByWxId" parameterType="Long" resultMap="SysWxDistributionResult">
<include refid="selectSysWxDistributionVo"/>
where wechat_account = #{wxId} and del_flag = 0 limit 1
</select>
<!-- 根据用户ID查询被分配的微信号 -->
<select id="selectDistributionWxByUserId" parameterType="Long" resultMap="SysWxDistributionResult">
SELECT swd.id, swd.user_id, swd.sale_group_id, swd.account_id, swd.wechat_account,swd.create_time,
swsa.wx_nick_name,swsa.wx_account
FROM sys_wx_distribution AS swd
lEFT JOIN sys_wx_sale_account swsa ON swsa.id = swd.wechat_account and swsa.del_flag = 0
where swd.del_flag = 0 and swd.user_id = #{userId} order by swd.id asc
</select>
</mapper>

View File

@ -0,0 +1,133 @@
<?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.stdiet.custom.mapper.SysWxFanStatisticsMapper">
<resultMap type="SysWxFanStatistics" id="SysWxFanStatisticsResult">
<result property="id" column="id" />
<result property="wxId" column="wx_id" />
<result property="fanTime" column="fan_time" />
<result property="fanNum" column="fan_num" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
<result property="delFlag" column="del_flag" />
<!-- 非持久化字段 -->
<result property="saleGroupId" column="sale_group_id"></result>
<result property="userId" column="user_id"></result>
<result property="userName" column="user_name"></result>
<result property="account" column="account"></result>
<result property="saleGroup" column="sale_group"></result>
<result property="wxNickName" column="wx_nick_name"></result>
<result property="wxAccount" column="wx_account"></result>
</resultMap>
<sql id="selectSysWxFanStatisticsVo">
select id, wx_id, fan_time, fan_num, create_time, create_by, update_time, update_by, del_flag from sys_wx_fan_statistics
</sql>
<sql id="selectSysWxFanStatisticsVoExtended">
select
swfs.id, swfs.wx_id, swfs.fan_time, swfs.fan_num, swfs.create_time, swfs.create_by, swfs.update_time, swfs.update_by, swfs.del_flag,
su.nick_name as user_name,acc.dict_label as account,asg.dict_label as sale_group,swsa.wx_nick_name,swsa.wx_account,swd.sale_group_id
from sys_wx_fan_statistics swfs
left join sys_wx_sale_account swsa on swsa.id = swfs.wx_id and swsa.del_flag = 0
left join sys_wx_distribution swd on swd.wechat_account = swfs.wx_id and swd.del_flag = 0
left join sys_user su on su.user_id = swd.user_id and su.del_flag = 0
LEFT JOIN (SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'fan_channel') AS acc ON acc.dict_value = swd.account_id
LEFT JOIN (SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'sale_group') AS asg ON asg.dict_value = swd.sale_group_id
</sql>
<select id="selectSysWxFanStatisticsList" parameterType="SysWxFanStatistics" resultMap="SysWxFanStatisticsResult">
<include refid="selectSysWxFanStatisticsVoExtended"/> where swfs.del_flag = 0
<if test="fanTime != null ">and swfs.fan_time = #{fanTime}</if>
<if test="userId != null">and su.user_id = #{userId}</if>
<if test="sortFlag == null or sortFlag == 0">
order by swfs.id desc
</if>
<if test="sortFlag != null and sortFlag == 1">
order by swd.sale_group_id asc,swd.user_id asc
</if>
</select>
<!-- 查询总进粉数量 -->
<select id="selectFanNumCount" parameterType="SysWxFanStatistics" resultType="int">
select ifnull(sum(swfs.fan_num),0) from sys_wx_fan_statistics swfs
left join sys_wx_distribution swd on swd.wechat_account = swfs.wx_id and swd.del_flag = 0
left join sys_user su on su.user_id = swd.user_id and su.del_flag = 0
where swfs.del_flag = 0
<if test="fanTime != null ">and swfs.fan_time = #{fanTime}</if>
<if test="userId != null">and su.user_id = #{userId}</if>
</select>
<select id="selectSysWxFanStatisticsById" parameterType="Long" resultMap="SysWxFanStatisticsResult">
<include refid="selectSysWxFanStatisticsVo"/>
where id = #{id} and del_flag = 0
</select>
<insert id="insertSysWxFanStatistics" parameterType="SysWxFanStatistics" useGeneratedKeys="true" keyProperty="id">
insert into sys_wx_fan_statistics
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="wxId != null">wx_id,</if>
<if test="fanTime != null">fan_time,</if>
<if test="fanNum != null">fan_num,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="delFlag != null">del_flag,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="wxId != null">#{wxId},</if>
<if test="fanTime != null">#{fanTime},</if>
<if test="fanNum != null">#{fanNum},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="delFlag != null">#{delFlag},</if>
</trim>
</insert>
<update id="updateSysWxFanStatistics" parameterType="SysWxFanStatistics">
update sys_wx_fan_statistics
<trim prefix="SET" suffixOverrides=",">
<if test="wxId != null">wx_id = #{wxId},</if>
<if test="fanTime != null">fan_time = #{fanTime},</if>
<if test="fanNum != null">fan_num = #{fanNum},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
</trim>
where id = #{id}
</update>
<update id="deleteSysWxFanStatisticsById" parameterType="Long">
update sys_wx_fan_statistics set del_flag = 1 where id = #{id}
</update>
<update id="deleteSysWxFanStatisticsByIds" parameterType="String">
update sys_wx_fan_statistics set del_flag = 1 where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<select id="getWxFanStatisticsByUserIdAndFanTime" parameterType="SysWxFanStatistics" resultMap="SysWxFanStatisticsResult">
select swfs.id, swfs.wx_id, swfs.fan_time, swfs.fan_num, swfs.create_time, swfs.create_by, swfs.update_time, swfs.update_by, swfs.del_flag
from sys_wx_fan_statistics swfs
left join sys_wx_distribution swd on swd.wechat_account = swfs.wx_id and swd.del_flag = 0
where swfs.del_flag = 0
<if test="userId != null">and swd.user_id = #{userId} </if>
<if test="fanTime != null"> and swfs.fan_time = #{fanTime}</if>
<if test="wxId != null">and swfs.wx_id = #{wxId}</if>
</select>
</mapper>

View File

@ -6,82 +6,99 @@
<resultMap type="SysWxSaleAccount" id="SysWxSaleAccountResult">
<result property="id" column="id" />
<result property="nickName" column="nick_name" />
<result property="accountId" column="account_id" />
<result property="wxId" column="wx_id" />
<result property="phone" column="phone" />
<result property="wxNickName" column="wx_nick_name" />
<result property="wxAccount" column="wx_account" />
<result property="wxPhone" column="wx_phone" />
<result property="wxCodeUrl" column="wx_code_url" />
<result property="remark" column="remark" />
<result property="imgUrl" column="img_url" />
<result property="count" column="count" />
<result property="mediaId" column="media_id" />
<result property="wxType" column="wx_type" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
<result property="delFlag" column="del_flag" />
</resultMap>
<sql id="selectSysWxSaleAccountVo">
select id, nick_name, account_id, wx_id, phone, remark, img_url, count, media_id from sys_wx_sale_account
select id, wx_nick_name, wx_account, wx_phone, wx_code_url, remark, wx_type, create_time, create_by, update_time, update_by, del_flag from sys_wx_sale_account
</sql>
<select id="selectSysWxSaleAccountList" parameterType="SysWxSaleAccount" resultMap="SysWxSaleAccountResult">
<include refid="selectSysWxSaleAccountVo"/>
<where>
<if test="nickName != null and nickName != ''"> and nick_name like concat('%', #{nickName}, '%')</if>
<if test="accountId != null "> and account_id = #{accountId}</if>
<if test="phone != null and phone != ''"> and phone = #{phone}</if>
</where>
<include refid="selectSysWxSaleAccountVo"/> where del_flag = 0
<if test="wxNickName != null and wxNickName != ''"> and wx_nick_name like concat('%', #{wxNickName}, '%')</if>
<if test="wxAccount != null and wxAccount != ''"> and wx_account like concat('%', #{wxAccount}, '%')</if>
<if test="wxPhone != null and wxPhone != ''"> and wx_phone like concat('%', #{wxPhone}, '%')</if>
</select>
<select id="selectSysWxSaleAccountById" parameterType="Long" resultMap="SysWxSaleAccountResult">
<include refid="selectSysWxSaleAccountVo"/>
where id = #{id}
where id = #{id} and del_flag = 0
</select>
<insert id="insertSysWxSaleAccount" parameterType="SysWxSaleAccount" useGeneratedKeys="true" keyProperty="id">
insert into sys_wx_sale_account
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="nickName != null">nick_name,</if>
<if test="accountId != null">account_id,</if>
<if test="wxId != null">wx_id,</if>
<if test="phone != null">phone,</if>
<if test="wxNickName != null">wx_nick_name,</if>
<if test="wxAccount != null">wx_account,</if>
<if test="wxPhone != null">wx_phone,</if>
<if test="wxCodeUrl != null">wx_code_url,</if>
<if test="remark != null">remark,</if>
<if test="imgUrl != null">img_url,</if>
<if test="count != null">count,</if>
<if test="mediaId != null">media_id,</if>
<if test="wxType != null">wx_type,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="delFlag != null">del_flag,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="nickName != null">#{nickName},</if>
<if test="accountId != null">#{accountId},</if>
<if test="wxId != null">#{wxId},</if>
<if test="phone != null">#{phone},</if>
<if test="wxNickName != null">#{wxNickName},</if>
<if test="wxAccount != null">#{wxAccount},</if>
<if test="wxPhone != null">#{wxPhone},</if>
<if test="wxCodeUrl != null">#{wxCodeUrl},</if>
<if test="remark != null">#{remark},</if>
<if test="imgUrl != null">#{imgUrl},</if>
<if test="count != null">#{count},</if>
<if test="mediaId != null">#{mediaId},</if>
<if test="wxType != null">#{wxType},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="delFlag != null">#{delFlag},</if>
</trim>
</insert>
<update id="updateSysWxSaleAccount" parameterType="SysWxSaleAccount">
update sys_wx_sale_account
<trim prefix="SET" suffixOverrides=",">
<if test="nickName != null">nick_name = #{nickName},</if>
<if test="accountId != null">account_id = #{accountId},</if>
<if test="wxId != null">wx_id = #{wxId},</if>
<if test="phone != null">phone = #{phone},</if>
<if test="wxNickName != null">wx_nick_name = #{wxNickName},</if>
<if test="wxAccount != null">wx_account = #{wxAccount},</if>
<if test="wxPhone != null">wx_phone = #{wxPhone},</if>
<if test="wxCodeUrl != null">wx_code_url = #{wxCodeUrl},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="imgUrl != null">img_url = #{imgUrl},</if>
<if test="count != null">count = #{count},</if>
<if test="mediaId != null">media_id = #{mediaId},</if>
<if test="wxType != null">wx_type = #{wxType},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteSysWxSaleAccountById" parameterType="Long">
delete from sys_wx_sale_account where id = #{id}
</delete>
<update id="deleteSysWxSaleAccountById" parameterType="Long">
update sys_wx_sale_account set del_flag = 1 where id = #{id}
</update>
<delete id="deleteSysWxSaleAccountByIds" parameterType="String">
delete from sys_wx_sale_account where id in
<update id="deleteSysWxSaleAccountByIds" parameterType="String">
update sys_wx_sale_account set del_flag = 1 where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</update>
<select id="selectWxAccountByAccountOrPhone" parameterType="SysWxSaleAccount" resultMap="SysWxSaleAccountResult">
<include refid="selectSysWxSaleAccountVo"/> where del_flag = 0
<if test="wxAccount != null and wxAccount != ''"> and wx_account = #{wxAccount}</if>
<if test="wxPhone != null and wxPhone != ''"> and wx_phone = #{wxPhone} </if>
limit 1
</select>
</mapper>