|  |  |  | 
|---|
|  |  |  | <result property="freeConsume" column="free_consume" /> | 
|---|
|  |  |  | <result property="hisConsume" column="his_consume" /> | 
|---|
|  |  |  | <result property="goodsCash" column="goods_cash" /> | 
|---|
|  |  |  | <result property="cardCash" column="card_cash" /> | 
|---|
|  |  |  | <result property="projNum" column="proj_num" /> | 
|---|
|  |  |  | <result property="numberOfPeople" column="number_of_people" /> | 
|---|
|  |  |  | <result property="shopName" column="shop_name" /> | 
|---|
|  |  |  | 
|---|
|  |  |  | c.vip_name, | 
|---|
|  |  |  | e.name as pro_name, | 
|---|
|  |  |  | b.ZK_TOTAL as zk_total, | 
|---|
|  |  |  | a.goods_cash, | 
|---|
|  |  |  | a.his_consume, | 
|---|
|  |  |  | a.free_consume, | 
|---|
|  |  |  | f.su_name meiliao, | 
|---|
|  |  |  | 
|---|
|  |  |  | h.shop_short_name shop_name, | 
|---|
|  |  |  | a.order_type, | 
|---|
|  |  |  | a.achieveType, | 
|---|
|  |  |  | case when a.pay_method = '现金' then goods_cash end goods_cash, | 
|---|
|  |  |  | case when a.pay_method = '划扣' then goods_cash end card_cash, | 
|---|
|  |  |  | j.pay_method | 
|---|
|  |  |  | from | 
|---|
|  |  |  | achieve_new a | 
|---|
|  |  |  | 
|---|
|  |  |  | <select id="selectUserAchieveByTime" resultType="com.matrix.system.app.vo.UserAchieveVo"> | 
|---|
|  |  |  | select | 
|---|
|  |  |  | sale_id id, | 
|---|
|  |  |  | (select ifnull(sum(case b.pay_method when '现金' then goods_cash else 0 end),0) | 
|---|
|  |  |  | (select ifnull(sum(case pay_method when '现金' then goods_cash else 0 end),0) | 
|---|
|  |  |  | from achieve_new a | 
|---|
|  |  |  | inner join sys_order_item b on a.order_item_id=b.ID | 
|---|
|  |  |  | where a.beault_id=#{userId} | 
|---|
|  |  |  | and (date_format(datatime, '%Y-%m-%d') >= date_format(#{startTime}, '%Y-%m-%d') and date_format(#{endTime}, '%Y-%m-%d') >= date_format(datatime, '%Y-%m-%d')) | 
|---|
|  |  |  | ) orderCash, | 
|---|
|  |  |  | (select ifnull(sum(case b.pay_method when '划扣' then goods_cash else 0 end),0) | 
|---|
|  |  |  | (select ifnull(sum(case pay_method when '划扣' then goods_cash else 0 end),0) | 
|---|
|  |  |  | from achieve_new a | 
|---|
|  |  |  | inner join sys_order_item b on a.order_item_id=b.ID | 
|---|
|  |  |  | where  a.beault_id=#{userId} | 
|---|
|  |  |  | and (date_format(datatime, '%Y-%m-%d') >= date_format(#{startTime}, '%Y-%m-%d') and date_format(#{endTime}, '%Y-%m-%d') >= date_format(datatime, '%Y-%m-%d')) | 
|---|
|  |  |  | ) cash, | 
|---|
|  |  |  | 
|---|
|  |  |  | select | 
|---|
|  |  |  | b.su_name name, | 
|---|
|  |  |  | b.su_id id, | 
|---|
|  |  |  | b.su_photo photo, | 
|---|
|  |  |  | sum(IFNULL(a.free_consume,0) + IFNULL(a.his_consume, 0) ) amount, | 
|---|
|  |  |  | c.shop_short_name shopName | 
|---|
|  |  |  | from achieve_new a | 
|---|
|  |  |  | 
|---|
|  |  |  | select | 
|---|
|  |  |  | b.shop_short_name name, | 
|---|
|  |  |  | b.SHOP_IMAG photo, | 
|---|
|  |  |  | sum(IFNULL(a.goods_cash,0)) amount | 
|---|
|  |  |  | from achieve_new a | 
|---|
|  |  |  | left join sys_shop_info b on a.shop_id=b.ID and shop_type!=1 | 
|---|
|  |  |  | sum(IFNULL(a.amount,0)) amount | 
|---|
|  |  |  | from sys_order_flow a | 
|---|
|  |  |  | inner join sys_order c on a.order_id=c.id and c.STATU != '已取消' | 
|---|
|  |  |  | inner join sys_shop_info b on a.shop_id=b.id and shop_type!=1 | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | a.pay_method not in ('储值卡', '欠款') | 
|---|
|  |  |  | <if test="record.companyId != null"> | 
|---|
|  |  |  | and a.company_id=#{record.companyId} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test='record.t1 == "1" and record.datatime != null'> | 
|---|
|  |  |  | and date_format(datatime, '%Y-%m-%d') = date_format(#{record.datatime}, '%Y-%m-%d') | 
|---|
|  |  |  | and date_format(a.create_time, '%Y-%m-%d') = date_format(#{record.datatime}, '%Y-%m-%d') | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test='record.t1 == "2" and record.datatime != null'> | 
|---|
|  |  |  | and date_format(datatime, '%Y-%m') = date_format(#{record.datatime}, '%Y-%m') | 
|---|
|  |  |  | and date_format(a.create_time, '%Y-%m') = date_format(#{record.datatime}, '%Y-%m') | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test='record.t1 == "3" and record.datatime != null'> | 
|---|
|  |  |  | and date_format(datatime, '%Y') = date_format(#{record.datatime}, '%Y') | 
|---|
|  |  |  | and date_format(a.create_time, '%Y') = date_format(#{record.datatime}, '%Y') | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | group by a.shop_id | 
|---|
|  |  |  | order by amount desc, a.shop_id | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!-- 顾问当天下单列表 --> | 
|---|
|  |  |  | <select id="selectSaleManAchieveList" resultMap="AchieveNewMap"> | 
|---|
|  |  |  | select * from achieve_new | 
|---|
|  |  |  | where sale_id=#{saleId} and vip_id=#{vipId} and sale_id=beault_id | 
|---|
|  |  |  | and date_format(datatime, '%Y-%m-%d') = date_format(#{date}, '%Y-%m-%d') | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectBeautyManAchieveList" resultMap="AchieveNewMap"> | 
|---|
|  |  |  | select * from achieve_new | 
|---|
|  |  |  | where beault_id=#{beautyId} and vip_id=#{vipId} | 
|---|
|  |  |  | and date_format(datatime, '%Y-%m-%d') = date_format(#{date}, '%Y-%m-%d') | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <update id="updateAchieveNumOfPeople"> | 
|---|
|  |  |  | <foreach collection="list" item="item" index="index" | 
|---|
|  |  |  | separator=";"> | 
|---|
|  |  |  | update achieve_new set number_of_people=#{num} where id=#{item.id} | 
|---|
|  |  |  | </foreach> | 
|---|
|  |  |  | </update> | 
|---|
|  |  |  | </mapper> | 
|---|