Merge branch 'master' of gitee.com:darlk/ShengTangManage into develop

This commit is contained in:
huangdeliang
2021-07-14 18:09:43 +08:00
41 changed files with 1307 additions and 95 deletions

View File

@ -28,6 +28,7 @@
<result property="assistantDietitian" column="assistant_dietitian"/>
<result property="afterDietitian" column="after_dietitian"/>
<result property="salesman" column="salesman"/>
<result property="onSaleId" column="on_sale_id" />
<association property="dietitianName" column="{id=main_dietitian}" select="selectUserName"/>
<association property="assDietitianName" column="{id=assistant_dietitian}" select="selectUserName"/>
@ -40,14 +41,23 @@
</select>
<sql id="selectSysCustomerVo">
select id, name, phone, email, fans_time, fans_channel, address, pay_date, start_date, purchase_num, pay_total, main_dietitian, assistant_dietitian, after_dietitian, salesman, charge_person, follow_status, create_time, create_by, update_time, update_by, channel_id from sys_customer
select id, name, phone, email, fans_time, fans_channel, address, pay_date, start_date, purchase_num, pay_total, main_dietitian, assistant_dietitian, after_dietitian, salesman, on_sale_id, charge_person, follow_status, create_time, create_by, update_time, update_by, channel_id from sys_customer
</sql>
<sql id="searchLoginUserId">
<if test="loginUserId != null">
and (
sc.main_dietitian = #{loginUserId} or sc.assistant_dietitian = #{loginUserId} or sc.after_dietitian = #{loginUserId} or sc.salesman = #{loginUserId}
or sc.on_sale_id = #{loginUserId}
)
</if>
</sql>
<select id="selectSysCustomerList" parameterType="SysCustomer" resultMap="SysCustomerResult">
select
sc.id, sc.name, sc.phone, sc.email, sc.fans_time, sc.fans_channel, sc.address, sc.pay_date, sc.start_date,
sc.purchase_num, sc.pay_total, sc.main_dietitian,
sc.assistant_dietitian, sc.after_dietitian, sc.salesman, sc.charge_person, sc.follow_status,
sc.assistant_dietitian, sc.after_dietitian, sc.on_sale_id, sc.salesman, sc.charge_person, sc.follow_status,
sc.create_time,sc.channel_id
from sys_customer sc
left join sys_customer_healthy as sch
@ -60,6 +70,7 @@
<if test="mainDietitian == 0">and (isnull(sc.main_dietitian) or sc.main_dietitian=0)</if>
<if test="salesman != null and salesman != ''">and sc.salesman = #{salesman}</if>
<if test="salesman == 0">and (isnull(sc.salesman) or sc.salesman=0)</if>
<if test="onSaleId != null">and sc.on_sale_id = #{onSaleId}</if>
<if test="afterDietitian != null and afterDietitian != ''">and sc.after_dietitian = #{afterDietitian}</if>
<if test="afterDietitian == 0">and (isnull(sc.after_dietitian) or sc.after_dietitian=0)</if>
<if test="assistantDietitian != null and assistantDietitian != ''">and sc.assistant_dietitian =
@ -82,6 +93,9 @@
</foreach>
)
</if>
<include refid="searchLoginUserId">
<property name="loginUserId" value="#{loginUserId}"/>
</include>
order by sc.create_time desc
</select>
@ -107,6 +121,7 @@
<if test="assistantDietitian != null">assistant_dietitian,</if>
<if test="afterDietitian != null">after_dietitian,</if>
<if test="salesman != null">salesman,</if>
<if test="onSaleId != null">on_sale_id,</if>
<if test="chargePerson != null">charge_person,</if>
<if test="followStatus != null">follow_status,</if>
<if test="createTime != null">create_time,</if>
@ -130,6 +145,7 @@
<if test="assistantDietitian != null">#{assistantDietitian},</if>
<if test="afterDietitian != null">#{afterDietitian},</if>
<if test="salesman != null">#{salesman},</if>
<if test="onSaleId != null">#{onSaleId},</if>
<if test="chargePerson != null">#{chargePerson},</if>
<if test="followStatus != null">#{followStatus},</if>
<if test="createTime != null">#{createTime},</if>
@ -157,6 +173,7 @@
<if test="assistantDietitian != null">assistant_dietitian = #{assistantDietitian},</if>
<if test="afterDietitian != null">after_dietitian = #{afterDietitian},</if>
<if test="salesman != null">salesman = #{salesman},</if>
<if test="onSaleId != null">on_sale_id = #{onSaleId},</if>
<if test="chargePerson != null">charge_person = #{chargePerson},</if>
<if test="followStatus != null">follow_status = #{followStatus},</if>
<if test="createTime != null">create_time = #{createTime},</if>

View File

@ -95,28 +95,97 @@
</if>
</sql>
<sql id="searchLoginUserId">
<if test="loginUserId != null">
and (
sc.main_dietitian = #{loginUserId} or sc.assistant_dietitian = #{loginUserId} or sc.after_dietitian = #{loginUserId} or sc.salesman = #{loginUserId}
or o.pre_sale_id = #{loginUserId} or o.on_sale_id = #{loginUserId} or o.after_sale_id = #{loginUserId} or o.nutritionist_id = #{loginUserId} or
o.nutri_assis_id = #{loginUserId}
)
</if>
</sql>
<select id="selectAllOrderAmount" parameterType="SysOrder" resultType="BigDecimal">
SELECT SUM(amount) FROM sys_order
SELECT SUM(amount) FROM sys_order o LEFT JOIN sys_customer sc ON sc.id = o.cus_id
<where>
<if test="orderId != null and orderId != ''">and order_id = #{orderId}</if>
<if test="orderId != null and orderId != ''">and o.order_id = #{orderId}</if>
<if test="customer != null and customer != ''">
and (customer like concat('%',#{customer},'%') or phone like concat('%',#{customer},'%'))
and (o.customer like concat('%',#{customer},'%') or o.phone like concat('%',#{customer},'%'))
</if>
<if test="accRange != null">
and account_id in
and o.account_id in
<foreach collection="accRange" separator="," item="acc" open="(" close=")" >
#{acc}
</foreach>
</if>
<if test="cusId != null and cusId != ''">and cus_id = #{cusId}</if>
<if test="cusId != null and cusId != ''">and o.cus_id = #{cusId}</if>
<!-- <if test="phone != null and phone != ''">and phone = #{phone}</if>-->
<if test="status != null ">and o.status = #{status}</if>
<if test="payTypeId != null ">and o.pay_type_id = #{payTypeId}</if>
<if test="preSaleId != null ">and o.pre_sale_id = #{preSaleId}</if>
<if test="pushPreSaleId != null ">and o.push_pre_sale_id = #{pushPreSaleId}</if>
<if test="onSaleId != null">
and o.on_sale_id = #{onSaleId}
</if>
<if test="afterSaleId != null ">and o.after_sale_id = #{afterSaleId}</if>
<if test="nutritionistId != null ">and o.nutritionist_id = #{nutritionistId}</if>
<if test="nutriAssisId != null ">and o.nutri_assis_id = #{nutriAssisId}</if>
<if test="accountId != null ">and o.account_id = #{accountId}</if>
<if test="plannerId != null ">and o.planner_id = #{plannerId}</if>
<if test="plannerAssisId != null ">and o.planner_assis_id = #{plannerAssisId}</if>
<if test="operatorId != null ">and o.operator_id = #{operatorId}</if>
<if test="operatorAssisId != null ">and o.operator_assis_id = #{operatorAssisId}</if>
<if test="recommender != null and recommender != ''">and o.recommender = #{recommender}</if>
<if test="beginTime != null and beginTime != ''">and date_format(o.order_time,'%y%m%d') &gt;=
date_format(#{beginTime},'%y%m%d')
</if>
<if test="endTime != null and endTime != ''">and date_format(o.order_time,'%y%m%d') &lt;=
date_format(#{endTime},'%y%m%d')
</if>
<if test="serveTimeId != null ">and o.serve_time_id = #{serveTimeId}</if>
<if test="reviewStatus != null ">and o.review_status = #{reviewStatus}</if>
<if test="amountFlag != null">
<if test="amountFlag == 0">
and o.amount >= 0
</if>
<if test="amountFlag == 1">
and 0 > o.amount
</if>
</if>
<include refid="searchOrderType">
<property name="reviewStatus" value="#{searchOrderTypeArray}"/>
</include>
<include refid="searchLoginUserId">
<property name="loginUserId" value="#{loginUserId}"/>
</include>
<if test="true">and o.del_flag = 0</if>
<!-- 计算总额时需要除去二开售后提成单 -->
AND o.after_sale_commiss_order = 0
</where>
</select>
<select id="selectSysOrderList" parameterType="SysOrder" resultMap="SysOrderResult">
<include refid="selectSysOrderVo"/>
<where>
<if test="orderId != null and orderId != ''">and sc.order_id = #{orderId}</if>
<if test="customer != null and customer != ''">
and (sc.name like concat('%',#{customer},'%') or sc.phone like concat('%',#{customer},'%'))
</if>
<if test="accRange != null">
and account_id in
<foreach collection="accRange" separator="," item="acc" open="(" close=")">
#{acc}
</foreach>
</if>
<if test="cusId != null and cusId != ''">and cus_id = #{cusId}</if>
<if test="phone != null and phone != ''">and sc.phone = #{phone}</if>
<if test="status != null ">and status = #{status}</if>
<if test="payTypeId != null ">and pay_type_id = #{payTypeId}</if>
<if test="preSaleId != null ">and pre_sale_id = #{preSaleId}</if>
<if test="pushPreSaleId != null ">and push_pre_sale_id = #{pushPreSaleId}</if>
<if test="onSaleId != null">
and on_sale_id = #{onSaleId}
and o.on_sale_id = #{onSaleId}
</if>
<if test="preSaleId != null ">and pre_sale_id = #{preSaleId}</if>
<if test="afterSaleId != null ">and after_sale_id = #{afterSaleId}</if>
<if test="nutritionistId != null ">and nutritionist_id = #{nutritionistId}</if>
<if test="nutriAssisId != null ">and nutri_assis_id = #{nutriAssisId}</if>
@ -145,61 +214,8 @@
<include refid="searchOrderType">
<property name="reviewStatus" value="#{searchOrderTypeArray}"/>
</include>
<if test="true">and del_flag = 0</if>
<!-- 计算总额时需要除去二开售后提成单 -->
AND after_sale_commiss_order = 0
</where>
</select>
<select id="selectSysOrderList" parameterType="SysOrder" resultMap="SysOrderResult">
<include refid="selectSysOrderVo"/>
<where>
<if test="orderId != null and orderId != ''">and order_id = #{orderId}</if>
<if test="customer != null and customer != ''">
and (sc.name like concat('%',#{customer},'%') or sc.phone like concat('%',#{customer},'%'))
</if>
<if test="accRange != null">
and account_id in
<foreach collection="accRange" separator="," item="acc" open="(" close=")">
#{acc}
</foreach>
</if>
<if test="cusId != null and cusId != ''">and cus_id = #{cusId}</if>
<if test="phone != null and phone != ''">and sc.phone = #{phone}</if>
<if test="status != null ">and status = #{status}</if>
<if test="payTypeId != null ">and pay_type_id = #{payTypeId}</if>
<if test="pushPreSaleId != null ">and push_pre_sale_id = #{pushPreSaleId}</if>
<if test="onSaleId != null">
and on_sale_id = #{onSaleId}
</if>
<if test="preSaleId != null ">and pre_sale_id = #{preSaleId}</if>
<if test="afterSaleId != null ">and after_sale_id = #{afterSaleId}</if>
<if test="nutritionistId != null ">and nutritionist_id = #{nutritionistId}</if>
<if test="nutriAssisId != null ">and nutri_assis_id = #{nutriAssisId}</if>
<if test="accountId != null ">and account_id = #{accountId}</if>
<if test="plannerId != null ">and planner_id = #{plannerId}</if>
<if test="plannerAssisId != null ">and planner_assis_id = #{plannerAssisId}</if>
<if test="operatorId != null ">and operator_id = #{operatorId}</if>
<if test="operatorAssisId != null ">and operator_assis_id = #{operatorAssisId}</if>
<if test="recommender != null and recommender != ''">and recommender = #{recommender}</if>
<if test="beginTime != null and beginTime != ''">and date_format(order_time,'%y%m%d') &gt;=
date_format(#{beginTime},'%y%m%d')
</if>
<if test="endTime != null and endTime != ''">and date_format(order_time,'%y%m%d') &lt;=
date_format(#{endTime},'%y%m%d')
</if>
<if test="serveTimeId != null ">and serve_time_id = #{serveTimeId}</if>
<if test="reviewStatus != null ">and review_status = #{reviewStatus}</if>
<if test="amountFlag != null">
<if test="amountFlag == 0">
and amount >= 0
</if>
<if test="amountFlag == 1">
and 0 > amount
</if>
</if>
<include refid="searchOrderType">
<property name="reviewStatus" value="#{searchOrderTypeArray}"/>
<include refid="searchLoginUserId">
<property name="loginUserId" value="#{loginUserId}"/>
</include>
<if test="true">and o.del_flag = 0</if>
</where>

View File

@ -25,6 +25,7 @@
<result property="outId" column="out_id"/>
<result property="subSend" column="sub_send"/>
<result property="smsSend" column="sms_send"/>
<result property="totalNumDay" column="total_num_day" />
<!-- 非持久化字段 -->
<!-- <result property="customerId" column="cus_id"></result>&lt;!&ndash; 客户ID &ndash;&gt;-->
<result property="customer" column="customer"/><!-- 客户姓名 -->
@ -41,7 +42,7 @@
<sql id="selectSysRecipesPlanVo">
select id, order_id, cus_id, out_id, start_date, end_date, start_num_day, end_num_day, recipes_id, send_flag, send_time, pause_date, create_time, create_by, update_time, update_by, del_flag, review_status, sub_send, sms_send, subscribed, remark
select id, order_id, cus_id, out_id, start_date, end_date, start_num_day, end_num_day, recipes_id, send_flag, send_time, pause_date, create_time, create_by, update_time, update_by, del_flag, review_status, sub_send, sms_send, subscribed, remark,total_num_day
from sys_recipes_plan
</sql>
@ -96,6 +97,7 @@
<if test="delFlag != null">del_flag,</if>
<if test="reviewStatus != null">review_status,</if>
<if test="type != null">type,</if>
<if test="totalNumDay != null">total_num_day,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderId != null">#{orderId},</if>
@ -116,6 +118,7 @@
<if test="delFlag != null">#{delFlag},</if>
<if test="reviewStatus != null">#{reviewStatus},</if>
<if test="type != null">#{type},</if>
<if test="totalNumDay != null">#{totalNumDay},</if>
</trim>
</insert>
@ -144,6 +147,7 @@
<if test="subSend != null">sub_send = #{subSend},</if>
<if test="smsSend != null">sms_send = #{smsSend},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="totalNumDay != null">total_num_day = #{totalNumDay},</if>
</trim>
where id = #{id} and del_flag = 0
</update>
@ -226,7 +230,7 @@
<!-- 根据订单ID查询食谱计划 -->
<select id="selectPlanListByOrderId" parameterType="SysRecipesPlan" resultMap="SysRecipesPlanResult">
SELECT srp.id,srp.order_id,sr.customer,sr.phone, srp.start_date,srp.end_date,srp.send_flag,srp.send_time
SELECT srp.id,srp.order_id,sr.customer,sr.phone, srp.start_date,srp.end_date,srp.send_flag,srp.send_time,srp.total_num_day
FROM sys_recipes_plan srp
LEFT JOIN sys_order sr ON sr.order_id = srp.order_id
WHERE srp.del_flag = 0 AND sr.del_flag = 0 AND srp.order_id = #{orderId}

View File

@ -0,0 +1,104 @@
<?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.SysWxBannerImageMapper">
<resultMap type="SysWxBannerImage" id="SysWxBannerImageResult">
<result property="id" column="id" />
<result property="title" column="title" />
<result property="content" column="content" />
<result property="bannerUrl" column="banner_url" />
<result property="jumpUrl" column="jump_url" />
<result property="showFlag" column="show_flag" />
<result property="orderNum" column="order_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" />
</resultMap>
<sql id="selectSysWxBannerImageVo">
select id, title, content, banner_url, jump_url, show_flag, order_num, create_time, create_by, update_time, update_by, del_flag from sys_wx_banner_image
</sql>
<select id="selectSysWxBannerImageList" parameterType="SysWxBannerImage" resultMap="SysWxBannerImageResult">
<include refid="selectSysWxBannerImageVo"/> where del_flag = 0
</select>
<select id="selectSysWxBannerImageById" parameterType="Long" resultMap="SysWxBannerImageResult">
<include refid="selectSysWxBannerImageVo"/>
where id = #{id} and del_flag = 0
</select>
<insert id="insertSysWxBannerImage" parameterType="SysWxBannerImage" useGeneratedKeys="true" keyProperty="id">
insert into sys_wx_banner_image
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="title != null">title,</if>
<if test="content != null">content,</if>
<if test="bannerUrl != null">banner_url,</if>
<if test="jumpUrl != null">jump_url,</if>
<if test="showFlag != null">show_flag,</if>
<if test="orderNum != null">order_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="title != null">#{title},</if>
<if test="content != null">#{content},</if>
<if test="bannerUrl != null">#{bannerUrl},</if>
<if test="jumpUrl != null">#{jumpUrl},</if>
<if test="showFlag != null">#{showFlag},</if>
<if test="orderNum != null">#{orderNum},</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="updateSysWxBannerImage" parameterType="SysWxBannerImage">
update sys_wx_banner_image
<trim prefix="SET" suffixOverrides=",">
<if test="title != null">title = #{title},</if>
<if test="content != null">content = #{content},</if>
<if test="bannerUrl != null">banner_url = #{bannerUrl},</if>
<if test="jumpUrl != null">jump_url = #{jumpUrl},</if>
<if test="showFlag != null">show_flag = #{showFlag},</if>
<if test="orderNum != null">order_num = #{orderNum},</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="deleteSysWxBannerImageById" parameterType="Long">
update sys_wx_banner_image set del_flag = 1 where id = #{id}
</update>
<update id="deleteSysWxBannerImageByIds" parameterType="String">
update sys_wx_banner_image set del_flag = 1 where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<!-- 按照优先级顺序获取banner图 -->
<select id="getBannerListOrderByOrderNum" parameterType="SysWxBannerImage" resultType="com.stdiet.custom.dto.response.BannerResponse">
select title, content, banner_url as bannerUrl, jump_url as jumpUrl from sys_wx_banner_image
where del_flag = 0
<if test="showFlag != null">
and show_flag = #{showFlag}
</if>
order by order_num desc
</select>
</mapper>

View File

@ -21,6 +21,7 @@
<result property="updateTime" column="update_time"/>
<result property="remark" column="remark"/>
<result property="language" column="language"/>
<result property="healthManifesto" column="health_manifesto" />
</resultMap>
<sql id="selectSysWxUserInfoVo">
@ -75,6 +76,7 @@
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
<if test="language != null">language,</if>
<if test="healthManifesto != null">health_manifesto,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="openid != null">#{openid},</if>
@ -93,6 +95,7 @@
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
<if test="language != null">#{language},</if>
<if test="healthManifesto != null">#{healthManifesto},</if>
</trim>
</insert>
@ -114,6 +117,7 @@
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="language != null">language = #{language},</if>
<if test="healthManifesto != null">health_manifesto = #{healthManifesto},</if>
</trim>
where openid = #{openid}
</update>
@ -140,4 +144,9 @@
update sys_wx_user_info set cus_id = null where openid = #{openid}
</update>
<!-- 根据客户ID更新健康减脂宣言 -->
<update id="updateHealthManifestoByCusId" parameterType="SysWxUserInfo">
update sys_wx_user_info set health_manifesto = #{healthManifesto} where cus_id = #{cusId}
</update>
</mapper>

View File

@ -38,6 +38,8 @@
<result property="targetWeight" column="target_weight" />
<result property="executionScore" column="execution_score" />
<result property="comment" column="comment" />
<result property="thumbsupNum" column="thumbsup_num" />
<result property="healthManifesto" column="health_manifesto" />
<result property="delFlag" column="del_flag" />
<!-- 非持久字段 -->
<result property="customerName" column="customer_name"></result>
@ -71,6 +73,8 @@
<result property="targetWeight" column="target_weight" />
<result property="executionScore" column="execution_score" />
<result property="comment" column="comment" />
<result property="thumbsupNum" column="thumbsup_num" />
<result property="healthManifesto" column="health_manifesto" />
</resultMap>
<sql id="selectSysWxUserLogVo">
@ -168,6 +172,8 @@
<if test="targetWeight != null">target_weight,</if>
<if test="executionScore != null">execution_score,</if>
<if test="comment != null">comment,</if>
<if test="thumbsupNum != null">thumbsup_num,</if>
<if test="healthManifesto != null">health_manifesto,</if>
<if test="delFlag != null">del_flag,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
@ -202,6 +208,8 @@
<if test="targetWeight != null">target_weight = #{targetWeight},</if>
<if test="executionScore != null">execution_score = #{executionScore},</if>
<if test="comment != null">comment = #{comment},</if>
<if test="thumbsupNum != null">#{thumbsupNum},</if>
<if test="healthManifesto != null">#{healthManifesto},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
</trim>
</insert>
@ -240,6 +248,8 @@
<if test="targetWeight != null">target_weight = #{targetWeight},</if>
<if test="executionScore != null">execution_score = #{executionScore},</if>
<if test="comment != null">comment = #{comment},</if>
<if test="thumbsupNum != null">thumbsup_num = #{thumbsupNum},</if>
<if test="healthManifesto != null">health_manifesto = #{healthManifesto},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
</trim>
where id = #{id}
@ -307,4 +317,48 @@
order by wxlog.log_time desc
</select>
<resultMap id="punchReponseMap" type="com.stdiet.custom.dto.response.CommunityPunchReponse">
<result property="openid" column="openid" />
<result property="cusId" column="cus_id"/>
<result property="nickName" column="nick_name"/>
<result property="avatarUrl" column="avatar_url"/>
<result property="logTime" column="log_time"/>
<result property="weight" column="weight"/>
<result property="comment" column="comment"/>
<result property="thumbsupNum" column="thumbsup_num"/>
<result property="healthManifesto" column="health_manifesto"/>
<!-- 查询最近五天体重 -->
<association property="recentWeight" column="{cusId=cus_id,logTime=log_time}" select="getRecentWeight"/>
</resultMap>
<!-- 查询打卡社区内容 -->
<select id="getCommunityPunch" resultMap="punchReponseMap" parameterType="SysWxUserLog">
select wxinfo.openid,wxinfo.cus_id,wxinfo.nick_name,wxinfo.avatar_url,wxlog.log_time,wxlog.weight,wxlog.comment,wxlog.thumbsup_num,wxlog.health_manifesto from sys_wx_user_log wxlog
left join sys_wx_user_info wxinfo on wxinfo.openid = wxlog.openid
where wxlog.del_flag = 0
order by wxlog.log_time desc
</select>
<!-- 查询最近一周的打卡体重 -->
<select id="getRecentWeight" resultType="Map">
select DATE_FORMAT(wxlog.log_time,'%Y-%m-%d') as logTime,wxlog.weight as weight from sys_wx_user_log wxlog
left join sys_wx_user_info wxinfo on wxinfo.openid = wxlog.openid
where wxlog.del_flag = 0 and wxinfo.cus_id = #{cusId} and #{logTime} >= wxlog.log_time
order by wxlog.log_time desc limit 7
</select>
<!-- 根据客户ID查询总共打卡次数 -->
<select id="getPunchTotalNum" parameterType="SysWxUserLog" resultType="int">
select count(1) from sys_wx_user_log wxlog
left join sys_wx_user_info wxinfo on wxinfo.openid = wxlog.openid
where wxlog.del_flag = 0 and wxinfo.cus_id = #{customerId}
</select>
<!-- 查询打卡社区总共几个人在打卡 -->
<select id="getPunchCustomerTotalNum" resultType="int">
select count(1) from (select openid from sys_wx_user_log wxlog where wxlog.del_flag = 0 group by openid) num_table
</select>
</mapper>