|  |  |  | 
|---|
|  |  |  | and date_format(a.create_time, '%Y') = date_format(#{record.datatime}, '%Y') | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test='record.t1 == "4" and record.datatime != null'> | 
|---|
|  |  |  | and date_format(datatime, '%Y-%m-%d %u') = date_format(#{record.datatime}, '%Y-%m-%d %u') | 
|---|
|  |  |  | and date_format(a.create_time, '%Y-%m-%d %u') = date_format(#{record.datatime}, '%Y-%m-%d %u') | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | group by a.shop_id | 
|---|
|  |  |  | 
|---|
|  |  |  | group by a.beault_id | 
|---|
|  |  |  | order by amount desc | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectDailyBeautyList" resultType="com.matrix.system.hive.vo.DailyBeautyListVo"> | 
|---|
|  |  |  | select | 
|---|
|  |  |  | date_format(b.datatime, '%Y-%m-%d') datatime, | 
|---|
|  |  |  | a.su_id, | 
|---|
|  |  |  | a.su_name beautyName, | 
|---|
|  |  |  | c.id vipId, | 
|---|
|  |  |  | c.VIP_NAME, | 
|---|
|  |  |  | c.arrival_way, | 
|---|
|  |  |  | case when c.BEATUY_ID=a.su_id then 1 else 0 end isAppoint, | 
|---|
|  |  |  | (select count(distinct date_format(n.datatime, '%Y-%m-%d')) from achieve_new n | 
|---|
|  |  |  | where date_format(b.datatime, '%Y-%m') = date_format(n.datatime, '%Y-%m') and n.vip_id=c.ID | 
|---|
|  |  |  | group by date_format(n.datatime, '%Y-%m'))arriveCnt, | 
|---|
|  |  |  | (select count(1) from sys_order o where o.statu in ('欠款', '已付款') and o.VIP_ID=c.id)  orderCnt, | 
|---|
|  |  |  | (select group_concat(distinct q.pay_method) payMethod from sys_order p | 
|---|
|  |  |  | inner join sys_order_flow q on p.ID=q.ORDER_ID | 
|---|
|  |  |  | inner join achieve_new o on o.order_id=p.id | 
|---|
|  |  |  | where date_format(pay_time, '%Y-%m-%d') = date_format(b.datatime, '%Y-%m-%d') and o.beault_id=a.su_id and c.ID=q.vip_id and p.STATU in ('欠款', '已付款') | 
|---|
|  |  |  | group by p.VIP_ID) payMethods, | 
|---|
|  |  |  | (select sum(amount) from sys_order_flow x | 
|---|
|  |  |  | inner join achieve_new y on x.order_id=y.order_id | 
|---|
|  |  |  | where x.pay_method='团购' and date_format(x.create_time, '%Y-%m-%d') = date_format(b.datatime, '%Y-%m-%d') | 
|---|
|  |  |  | and y.beault_id=a.su_id and x.vip_id=c.id ) teamPay, | 
|---|
|  |  |  | (select sum(m.ZK_PRICE) from sys_order_item m | 
|---|
|  |  |  | inner join achieve_new n on n.ORDER_ID=m.order_id | 
|---|
|  |  |  | where date_format(m.create_time, '%Y-%m-%d') = date_format(b.datatime, '%Y-%m-%d') | 
|---|
|  |  |  | and m.type in ('套餐', '项目') and n.beault_id=a.su_id) tcAndProjCash, | 
|---|
|  |  |  | (select sum(m.ZK_PRICE) from sys_order_item m | 
|---|
|  |  |  | inner join achieve_new n on n.ORDER_ID=m.order_id | 
|---|
|  |  |  | where date_format(m.create_time, '%Y-%m-%d') = date_format(b.datatime, '%Y-%m-%d') | 
|---|
|  |  |  | and m.type in ('家居产品') and n.beault_id=a.su_id) productCash, | 
|---|
|  |  |  | (select sum(m.ZK_PRICE) from sys_order_item m | 
|---|
|  |  |  | inner join achieve_new n on n.ORDER_ID=m.order_id | 
|---|
|  |  |  | where date_format(m.create_time, '%Y-%m-%d') = date_format(b.datatime, '%Y-%m-%d') | 
|---|
|  |  |  | and m.type in ('充值卡') and n.beault_id=a.su_id) cardCash, | 
|---|
|  |  |  | (select sum(amount) from sys_order_flow x | 
|---|
|  |  |  | inner join achieve_new y on x.order_id=y.order_id | 
|---|
|  |  |  | where x.pay_method='储值卡' and date_format(x.create_time, '%Y-%m-%d') = date_format(b.datatime, '%Y-%m-%d') | 
|---|
|  |  |  | and y.beault_id=a.su_id and x.vip_id=c.id) cardPay, | 
|---|
|  |  |  | (select sum(amount) from sys_order_flow x | 
|---|
|  |  |  | inner join achieve_new y on x.order_id=y.order_id | 
|---|
|  |  |  | where x.pay_method not in ('储值卡','欠款') and date_format(x.create_time, '%Y-%m-%d') = date_format(b.datatime, '%Y-%m-%d') | 
|---|
|  |  |  | and y.beault_id=a.su_id and x.vip_id=c.id) cashPay, | 
|---|
|  |  |  | (select sum(e.goods_cash) from achieve_new e | 
|---|
|  |  |  | inner join shopping_goods f on e.shopping_goods_id=f.id and f.is_cooperate=1 | 
|---|
|  |  |  | where e.order_type='订单' and date_format(e.datatime, '%Y-%m-%d') = date_format(b.datatime, '%Y-%m-%d') | 
|---|
|  |  |  | and e.beault_id=a.su_id and e.vip_id=c.id) cooperateProj, | 
|---|
|  |  |  | sum(proj_percentage) ticheng, | 
|---|
|  |  |  | sum(IFNULL(free_consume,0) + IFNULL(his_consume,0)) consume, | 
|---|
|  |  |  | (select count(1) from achieve_new z where z.beault_id=a.su_id and c.id=z.vip_id and z.order_type='服务单' group by z.beault_id,z.vip_id) projCnt | 
|---|
|  |  |  | from sys_users a | 
|---|
|  |  |  | left join achieve_new b on a.su_id=b.beault_id | 
|---|
|  |  |  | left join sys_vip_info c on b.vip_id=c.ID | 
|---|
|  |  |  | where 1=1 | 
|---|
|  |  |  | <if test="record.companyId != null"> | 
|---|
|  |  |  | and a.company_id=#{record.companyId} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="record.shopId != null"> | 
|---|
|  |  |  | and a.shop_id=#{record.shopId} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="record.beginTime != null"> | 
|---|
|  |  |  | and date_format(b.datatime, '%Y-%m-%d') > date_format(#{record.beginTime}, '%Y-%m-%d') | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="record.endTime != null"> | 
|---|
|  |  |  | and date_format(#{record.endTime}, '%Y-%m-%d') > date_format(b.datatime, '%Y-%m-%d') | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="record.beaultId != null"> | 
|---|
|  |  |  | and a.su_id=#{record.beaultId} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="record.vipQueryKey != null and record.vipQueryKey != ''"> | 
|---|
|  |  |  | and c.vip_name like concat('%', #{record.vipQueryKey}, '%') | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="record.beginTime == null and record.endTime == null"> | 
|---|
|  |  |  | and date_format(b.datatime, '%Y-%m') = date_format(now(), '%Y-%m') | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | group by date_format(b.datatime, '%Y-%m-%d'), a.su_id, c.ID | 
|---|
|  |  |  | <if test="pageVo !=null"><!-- 判断pageVo对象是否为空 --> | 
|---|
|  |  |  | order by date_format(b.datatime, '%Y-%m-%d') desc, a.su_id | 
|---|
|  |  |  | <if test="pageVo.offset >=0  and pageVo.limit >0"> | 
|---|
|  |  |  | limit | 
|---|
|  |  |  | #{pageVo.offset},#{pageVo.limit} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectDailyBeautyListTotal" resultType="java.lang.Integer"> | 
|---|
|  |  |  | select count(1) from ( | 
|---|
|  |  |  | select | 
|---|
|  |  |  | date_format(b.datatime, '%Y-%m-%d') datatime, | 
|---|
|  |  |  | a.su_id, | 
|---|
|  |  |  | a.su_name, | 
|---|
|  |  |  | c.id vipId, | 
|---|
|  |  |  | c.VIP_NAME, | 
|---|
|  |  |  | c.arrival_way, | 
|---|
|  |  |  | sum(proj_percentage) ticheng, | 
|---|
|  |  |  | sum(IFNULL(free_consume,0) + IFNULL(his_consume,0)) consume | 
|---|
|  |  |  | from sys_users a | 
|---|
|  |  |  | left join achieve_new b on a.su_id=b.beault_id | 
|---|
|  |  |  | left join sys_vip_info c on b.vip_id=c.ID | 
|---|
|  |  |  | where 1=1 | 
|---|
|  |  |  | <if test="record.companyId != null"> | 
|---|
|  |  |  | and a.company_id=#{record.companyId} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="record.shopId != null"> | 
|---|
|  |  |  | and a.shop_id=#{record.shopId} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="record.beginTime != null"> | 
|---|
|  |  |  | and date_format(b.datatime, '%Y-%m-%d') > date_format(#{record.beginTime}, '%Y-%m-%d') | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="record.endTime != null"> | 
|---|
|  |  |  | and date_format(#{record.endTime}, '%Y-%m-%d') > date_format(b.datatime, '%Y-%m-%d') | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="record.beaultId != null"> | 
|---|
|  |  |  | and a.su_id=#{record.beaultId} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="record.vipQueryKey != null and record.vipQueryKey != ''"> | 
|---|
|  |  |  | and c.vip_name like concat('%', #{record.vipQueryKey}, '%') | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="record.beginTime == null and record.endTime == null"> | 
|---|
|  |  |  | and date_format(b.datatime, '%Y-%m') = date_format(now(), '%Y-%m') | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | group by date_format(b.datatime, '%Y-%m-%d'), a.su_id, c.ID | 
|---|
|  |  |  | ) a | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectPlInfoByVipIdAndDate" resultType="java.lang.String"> | 
|---|
|  |  |  | select group_concat(concat(name,'*', bb)) | 
|---|
|  |  |  | from (select l.name name, 0+CAST(sum(n.amount) as char) bb from sys_out_store m | 
|---|
|  |  |  | inner join sys_out_store_item n on m.id=n.OUT_STORE_ID | 
|---|
|  |  |  | inner join shopping_goods l on n.SKU_ID=l.id | 
|---|
|  |  |  | where m.SERVICE_ID in (select distinct service_order_id from achieve_new where date_format(datatime, '%Y-%m-%d') = date_format(#{datatime}, '%Y-%m-%d') and vip_id=#{vipId}) | 
|---|
|  |  |  | group by l.id) a | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | </mapper> | 
|---|