| <?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.matrix.system.hive.dao.AchieveNewDao"> | 
|     <!-- 定义AchieveNew 的复杂关联map --> | 
|     <resultMap type="com.matrix.system.hive.bean.AchieveNew" id="AchieveNewMap"> | 
|         <id property="id" column="id" /> | 
|         <result property="saleId" column="sale_id" /> | 
|         <result property="beaultId" column="beault_id" /> | 
|         <result property="shopId" column="shop_id" /> | 
|         <result property="datatime" column="datatime" /> | 
|         <result property="orderId" column="order_id" /> | 
|         <result property="orderItemId" column="order_item_id" /> | 
|         <result property="shoppingGoodsId" column="shopping_goods_id" /> | 
|         <result property="serviceOrderId" column="service_order_id" /> | 
|         <result property="vipId" column="vip_id" /> | 
|         <result property="freeConsume" column="free_consume" /> | 
|         <result property="hisConsume" column="his_consume" /> | 
|         <result property="consume" column="consume" /> | 
|         <result property="cardCash" column="card_cash" /> | 
|         <result property="projCash" column="proj_cash" /> | 
|         <result property="goodsCash" column="goods_cash" /> | 
|         <result property="projNum" column="proj_num" /> | 
|         <result property="numberOfPeople" column="number_of_people" /> | 
|         <result property="shopName" column="shop_name" /> | 
|         <result property="projTime" column="proj_time" /> | 
|         <result property="remark" column="remark" /> | 
|         <result property="orderType" column="order_type" /> | 
|         <result property="projPercentage" column="proj_percentage" /> | 
|         <result property="t1" column="t1" /> | 
|         <result property="t2" column="t2" /> | 
|         <result property="t3" column="t3" /> | 
|         <result property="t4" column="t4" /> | 
|         <result property="t5" column="t5" /> | 
|         <result property="t6" column="t6" /> | 
|         <result property="t8" column="t8" /> | 
|         <result property="t9" column="t9" /> | 
|         <result property="companyId" column="company_id" /> | 
|   | 
|         <result property="year" column="year" /> | 
|         <result property="month" column="month" /> | 
|         <result property="orderNo" column="order_no" /> | 
|         <result property="levelName" column="level_name" /> | 
|         <result property="vipName" column="vip_name" /> | 
|         <result property="proName" column="pro_name" /> | 
|         <result property="guwen" column="guwen" /> | 
|         <result property="meiliao" column="meiliao" /> | 
|         <result property="zkTotal" column="zk_total" /> | 
|   | 
|         <result property="arriveCnt" column="arrive_cnt" /> | 
|   | 
|   | 
|   | 
|     </resultMap> | 
|   | 
|     <select id="findDayFlow" resultMap="AchieveNewMap"> | 
|         select | 
|         a.datatime, | 
|         YEAR (a.datatime) year, | 
|         MONTH (a.datatime) month, | 
|         DAY(a.datatime) | 
|         day, | 
|         IFNULL(b.order_no,l.SERVICE_NO) as order_no, | 
|         d.level_name, | 
|         c.vip_name, | 
|         e.name as pro_name, | 
|         a.card_cash, | 
|         (IFNULL(a.card_cash,0) +IFNULL(a.proj_cash,0) + IFNULL(a.goods_cash,0) | 
|         ) as zk_total, | 
|         a.proj_cash, | 
|         a.goods_cash, | 
|         a.card_cash, | 
|         a.consume, | 
|         a.his_consume, | 
|         a.free_consume, | 
|         f.su_name meiliao, | 
|         g.su_name guwen, | 
|         a.proj_percentage, | 
|         a.number_of_people, | 
|         a.proj_num, | 
|         a.proj_time, | 
|         i.name as module_subName, | 
|         h.SHOP_NAME shop_name, | 
|         a.order_type | 
|         from | 
|         achieve_new a | 
|         left join sys_order b on a.order_id=b.id | 
|         left join sys_vip_info c on a.vip_id=c.id | 
|         left join sys_vip_level d on c.LEVEL_ID=d.id | 
|         left join shopping_goods e on a.shopping_goods_id=e.id | 
|         LEFT JOIN sys_users f on a.beault_id=f.su_id | 
|         LEFT JOIN sys_users g on a.sale_id = g.su_id | 
|         LEFT JOIN sys_shop_info h ON a.SHOP_ID = h.ID | 
|         LEFT JOIN shopping_goods_category i ON e.cate_id = i.id | 
|         left join sys_proj_services l on a.service_order_id=l.id | 
|         <where> | 
|             <if test="record!=null"> | 
|                 <if | 
|                     test="(record.shopId!=null and record.shopId!='') or  (record.shopId!='' and record.shopId==0)  "> | 
|                     and a.shop_id = #{record.shopId} | 
|                 </if> | 
|                 <if test="record.year != null and record.year !='' "> | 
|                     and YEAR (a.datatime) = #{record.year} | 
|                 </if> | 
|                 <if test="record.month != null and record.month !='' "> | 
|                     and MONTH (a.datatime) = #{record.month} | 
|                 </if> | 
|                 <if test="record.day != null  and record.day !=''  "> | 
|                     and DAY(a.datatime) = #{record.day} | 
|                 </if> | 
|                 <if test="(record.beginTime!=null  )"> | 
|                     and a.datatime <![CDATA[ > ]]>  #{record.beginTime} | 
|                 </if> | 
|                 <if test="(record.endTime!=null  )"> | 
|                     and a.datatime <![CDATA[ < ]]> #{record.endTime} | 
|                 </if> | 
|                 <if test="record.beaultId != null and record.beaultId !='' "> | 
|                     and    a.beault_id = #{record.beaultId} | 
|                 </if> | 
|                 <if test="record.companyId != null and record.companyId !='' "> | 
|                     and    a.company_id = #{record.companyId} | 
|                 </if> | 
|                 <if test="record.beaultId != null and record.beaultId !='' "> | 
|                     and    a.beault_id = #{record.beaultId} | 
|                 </if> | 
|                 <if test="record.vipQueryKey != null and record.vipQueryKey != ''  "> | 
|                     and c.VIP_NAME like concat('%',#{record.vipQueryKey},'%') | 
|                     or (c.VIP_NO like concat('%',#{record.vipQueryKey},'%') | 
|                     or c.PHONE like concat('%',#{record.vipQueryKey},'%') | 
|                     ) | 
|                 </if> | 
|             </if> | 
|         </where> | 
|         <if test="pageVo !=null"><!-- 判断pageVo对象是否为空 --> | 
|             <if test="pageVo.sort !=null  and pageVo.order !=null"> | 
|                 order by | 
|                 ${pageVo.sort} ${pageVo.order} | 
|             </if> | 
|             <if test="pageVo.offset >=0  and pageVo.limit >0"> | 
|                 limit | 
|                 #{pageVo.offset},#{pageVo.limit} | 
|             </if> | 
|         </if> | 
|   | 
|   | 
|     </select> | 
|     <select id="findDayFlowTotal" | 
|         resultType="java.lang.Integer"> | 
|         select count(*) | 
|         from | 
|         achieve_new a | 
|         left join sys_order b on a.order_id=b.id | 
|         left join sys_vip_info c on a.vip_id=c.id | 
|         left join sys_vip_level d on c.LEVEL_ID=d.id | 
|         left join shopping_goods e on a.shopping_goods_id=e.id | 
|         LEFT JOIN sys_users f on a.beault_id=f.su_id | 
|         LEFT JOIN sys_users g on a.sale_id = g.su_id | 
|         LEFT JOIN sys_shop_info h ON a.SHOP_ID = h.ID | 
|         LEFT JOIN shopping_goods_category i ON e.cate_id = i.id | 
|         left join sys_proj_services l on a.service_order_id=l.id | 
|         <where> | 
|             <if test="record!=null"> | 
|                 <if | 
|                     test="(record.shopId!=null and record.shopId!='') or  (record.shopId!='' and record.shopId==0)  "> | 
|                     and a.shop_id = #{record.shopId} | 
|                 </if> | 
|                 <if test="record.year != null and record.year !='' "> | 
|                     and YEAR (a.datatime) = #{record.year} | 
|                 </if> | 
|                 <if test="record.month != null and record.month !='' "> | 
|                     and MONTH (a.datatime) = #{record.month} | 
|                 </if> | 
|                 <if test="record.day != null   and record.day !='' "> | 
|                     and DAY(a.datatime) = #{record.day} | 
|                 </if> | 
|                 <if test="record.beginTime!=null "> | 
|                     and a.datatime <![CDATA[ > ]]>  #{record.beginTime} | 
|                 </if> | 
|                 <if test="record.endTime!=null"> | 
|                     and a.datatime <![CDATA[ < ]]> #{record.endTime} | 
|                 </if> | 
|                 <if test="record.companyId != null and record.companyId !='' "> | 
|                     and    a.company_id = #{record.companyId} | 
|                 </if> | 
|                 <if test="record.beaultId != null and record.beaultId !='' "> | 
|                     and    a.beault_id = #{record.beaultId} | 
|                 </if> | 
|                 <if test="record.vipQueryKey != null and record.vipQueryKey != ''  "> | 
|                     and c.VIP_NAME like concat('%',#{record.vipQueryKey},'%') | 
|                     or (c.VIP_NO like concat('%',#{record.vipQueryKey},'%') | 
|                     or c.PHONE like concat('%',#{record.vipQueryKey},'%') | 
|                     ) | 
|                 </if> | 
|             </if> | 
|         </where> | 
|     </select> | 
|   | 
|   | 
|   | 
|   | 
|     <select id="findSumDailyInfoNew" resultMap="AchieveNewMap"> | 
|         select | 
|         YEAR (a.datatime) year, | 
|         MONTH (a.datatime) month, | 
|         DAY(a.datatime) day, | 
|         SUM(a.card_cash) as card_cash , | 
|         SUM((IFNULL(a.card_cash,0) +IFNULL(a.proj_cash,0) + IFNULL(a.goods_cash,0) ) )as zk_total, | 
|         SUM(a.proj_cash) as proj_cash, | 
|         SUM(a.goods_cash) as goods_cash, | 
|         SUM(a.card_cash) as card_cash, | 
|         SUM(a.consume) as consume, | 
|         SUM(a.his_consume) as his_consume, | 
|         SUM(a.free_consume) as free_consume, | 
|         SUM(a.proj_percentage) as proj_percentage, | 
|         SUM(a.number_of_people) as number_of_people, | 
|         SUM(a.proj_num) as proj_num, | 
|         SUM(a.proj_time) as proj_time, | 
|         h.SHOP_NAME shop_name, | 
|         a.shop_id | 
|         from | 
|         achieve_new a | 
|         left join sys_order b on a.order_id=b.id | 
|         left join sys_vip_info c on a.vip_id=c.id | 
|         left join sys_vip_level d on c.LEVEL_ID=d.id | 
|         left join shopping_goods e on a.shopping_goods_id=e.id | 
|         LEFT JOIN sys_users f on a.beault_id=f.su_id | 
|         LEFT JOIN sys_users g on a.sale_id = g.su_id | 
|         LEFT JOIN sys_shop_info h ON a.SHOP_ID = h.ID | 
|         LEFT JOIN shopping_goods_category i ON e.cate_id = i.id | 
|         LEFT JOIN shopping_goods_category j ON i.parent_id = j.id | 
|         left join sys_proj_services l on a.service_order_id=l.id | 
|         <where> | 
|             <if test="record!=null"> | 
|                 <if | 
|                     test="(record.shopId!=null and record.shopId!='') or  (record.shopId!='' and record.shopId==0)  "> | 
|                     and a.shop_id = #{record.shopId} | 
|                 </if> | 
|                 <if test="record.year != null and record.year !='' "> | 
|                     and YEAR (a.datatime) = #{record.year} | 
|                 </if> | 
|                 <if test="record.month != null and record.month !='' "> | 
|                     and MONTH (a.datatime) = #{record.month} | 
|                 </if> | 
|                 <if test="record.day != null   and record.day !='' "> | 
|                     and DAY(a.datatime) = #{record.day} | 
|                 </if> | 
|                 <if test="record.beginTime!=null "> | 
|                     and a.datatime <![CDATA[ > ]]>  #{record.beginTime} | 
|                 </if> | 
|                 <if test="record.endTime!=null"> | 
|                     and a.datatime <![CDATA[ < ]]> #{record.endTime} | 
|                 </if> | 
|                 <if test="record.companyId != null and record.companyId !='' "> | 
|                     and    a.company_id = #{record.companyId} | 
|                 </if> | 
|             </if> | 
|         </where> | 
|         group by a.shop_id , DATE_FORMAT(a.datatime, '%Y-%m-%d') | 
|         <if test="pageVo !=null"><!-- 判断pageVo对象是否为空 --> | 
|             <if test="pageVo.sort !=null  and pageVo.order !=null"> | 
|                 order by | 
|                 ${pageVo.sort} ${pageVo.order} | 
|             </if> | 
|         </if> | 
|   | 
|     </select> | 
|   | 
|   | 
|   | 
|   | 
|   | 
|   | 
|     <!-- 定义AchieveNew 的简单map ,本map不添加其他的关联属性 --> | 
|     <resultMap type="com.matrix.system.hive.bean.AchieveNew" id="AchieveNewSimpleMap"> | 
|         <id property="id" column="id" /> | 
|         <result property="saleId" column="sale_id" /> | 
|         <result property="beaultId" column="beault_id" /> | 
|         <result property="shopId" column="shop_id" /> | 
|         <result property="datatime" column="datatime" /> | 
|         <result property="orderId" column="order_id" /> | 
|         <result property="orderItemId" column="order_item_id" /> | 
|         <result property="shoppingGoodsId" column="shopping_goods_id" /> | 
|         <result property="serviceOrderId" column="service_order_id" /> | 
|         <result property="vipId" column="vip_id" /> | 
|         <result property="freeConsume" column="free_consume" /> | 
|         <result property="hisConsume" column="his_consume" /> | 
|         <result property="consume" column="consume" /> | 
|         <result property="cardCash" column="card_cash" /> | 
|         <result property="projCash" column="proj_cash" /> | 
|         <result property="goodsCash" column="goods_cash" /> | 
|         <result property="projNum" column="proj_num" /> | 
|         <result property="numberOfPeople" column="number_of_people" /> | 
|         <result property="shopName" column="shop_name" /> | 
|         <result property="projTime" column="proj_time" /> | 
|         <result property="remark" column="remark" /> | 
|         <result property="orderType" column="order_type" /> | 
|         <result property="projPercentage" column="proj_percentage" /> | 
|         <result property="t1" column="t1" /> | 
|         <result property="t2" column="t2" /> | 
|         <result property="t3" column="t3" /> | 
|         <result property="t4" column="t4" /> | 
|         <result property="t5" column="t5" /> | 
|         <result property="t6" column="t6" /> | 
|         <result property="t8" column="t8" /> | 
|         <result property="t9" column="t9" /> | 
|         <result property="companyId" column="company_id" /> | 
|     </resultMap> | 
|   | 
|     <!-- 字段sql --> | 
|     <sql id="columns"> | 
|         id, | 
|         sale_id, | 
|         beault_id, | 
|         shop_id, | 
|         datatime, | 
|         order_id, | 
|         order_item_id, | 
|         shopping_goods_id, | 
|         service_order_id, | 
|         vip_id, | 
|         free_consume, | 
|         his_consume, | 
|         consume, | 
|         card_cash, | 
|         proj_cash, | 
|         goods_cash, | 
|         proj_num, | 
|         number_of_people, | 
|         shop_name, | 
|         proj_time, | 
|         remark, | 
|         order_type, | 
|         proj_percentage, | 
|         t1, | 
|         t2, | 
|         t3, | 
|         t4, | 
|         t5, | 
|         t6, | 
|         t8, | 
|         t9, | 
|         company_id | 
|     </sql> | 
|   | 
|     <!-- 属性sql --> | 
|     <sql id="propertys"> | 
|         #{item.id}, | 
|         #{item.saleId}, | 
|         #{item.beaultId}, | 
|         #{item.shopId}, | 
|         #{item.datatime}, | 
|         #{item.orderId}, | 
|         #{item.orderItemId}, | 
|         #{item.shoppingGoodsId}, | 
|         #{item.serviceOrderId}, | 
|         #{item.vipId}, | 
|         #{item.freeConsume}, | 
|         #{item.hisConsume}, | 
|         #{item.consume}, | 
|         #{item.cardCash}, | 
|         #{item.projCash}, | 
|         #{item.goodsCash}, | 
|         #{item.projNum}, | 
|         #{item.numberOfPeople}, | 
|         #{item.shopName}, | 
|         #{item.projTime}, | 
|         #{item.remark}, | 
|         #{item.orderType}, | 
|         #{item.projPercentage}, | 
|         #{item.t1}, | 
|         #{item.t2}, | 
|         #{item.t3}, | 
|         #{item.t4}, | 
|         #{item.t5}, | 
|         #{item.t6}, | 
|         #{item.t8}, | 
|         #{item.t9}, | 
|         #{item.companyId} | 
|     </sql> | 
|   | 
|     <!-- where sql --> | 
|     <sql id="where_sql"> | 
|   | 
|         <if test="record!=null"> | 
|             <if | 
|                 test="(record.id!=null and record.id!='') or  (record.id!='' and record.id==0)  "> | 
|                 and id = #{record.id} | 
|             </if> | 
|             <if test="record.companyId != null and record.companyId !='' "> | 
|                 and company_id = #{record.companyId} | 
|             </if> | 
|             <if | 
|                 test="(record.saleId!=null and record.saleId!='') or  (record.saleId!='' and record.saleId==0)  "> | 
|                 and sale_id = #{record.saleId} | 
|             </if> | 
|             <if | 
|                 test="(record.beaultId!=null and record.beaultId!='') or  (record.beaultId!='' and record.beaultId==0)  "> | 
|                 and beault_id = #{record.beaultId} | 
|             </if> | 
|             <if | 
|                 test="(record.shopId!=null and record.shopId!='') or  (record.shopId!='' and record.shopId==0)  "> | 
|                 and shop_id = #{record.shopId} | 
|             </if> | 
|             <if | 
|                 test="(record.datatime!=null and record.datatime!='') or  (record.datatime!='' and record.datatime==0)  "> | 
|                 and datatime = #{record.datatime} | 
|             </if> | 
|             <if | 
|                 test="(record.orderId!=null and record.orderId!='') or  (record.orderId!='' and record.orderId==0)  "> | 
|                 and order_id = #{record.orderId} | 
|             </if> | 
|             <if | 
|                 test="(record.orderItemId!=null and record.orderItemId!='') or  (record.orderItemId!='' and record.orderItemId==0)  "> | 
|                 and order_item_id = #{record.orderItemId} | 
|             </if> | 
|             <if | 
|                 test="(record.shoppingGoodsId!=null and record.shoppingGoodsId!='') or  (record.shoppingGoodsId!='' and record.shoppingGoodsId==0)  "> | 
|                 and shopping_goods_id = #{record.shoppingGoodsId} | 
|             </if> | 
|             <if | 
|                 test="(record.serviceOrderId!=null and record.serviceOrderId!='') or  (record.serviceOrderId!='' and record.serviceOrderId==0)  "> | 
|                 and service_order_id = #{record.serviceOrderId} | 
|             </if> | 
|             <if | 
|                 test="(record.vipId!=null and record.vipId!='') or  (record.vipId!='' and record.vipId==0)  "> | 
|                 and vip_id = #{record.vipId} | 
|             </if> | 
|             <if | 
|                 test="(record.freeConsume!=null and record.freeConsume!='') or  (record.freeConsume!='' and record.freeConsume==0)  "> | 
|                 and free_consume = #{record.freeConsume} | 
|             </if> | 
|             <if | 
|                 test="(record.hisConsume!=null and record.hisConsume!='') or  (record.hisConsume!='' and record.hisConsume==0)  "> | 
|                 and his_consume = #{record.hisConsume} | 
|             </if> | 
|             <if | 
|                 test="(record.consume!=null and record.consume!='') or  (record.consume!='' and record.consume==0)  "> | 
|                 and consume = #{record.consume} | 
|             </if> | 
|             <if | 
|                 test="(record.cardCash!=null and record.cardCash!='') or  (record.cardCash!='' and record.cardCash==0)  "> | 
|                 and card_cash = #{record.cardCash} | 
|             </if> | 
|             <if | 
|                 test="(record.projCash!=null and record.projCash!='') or  (record.projCash!='' and record.projCash==0)  "> | 
|                 and proj_cash = #{record.projCash} | 
|             </if> | 
|             <if | 
|                 test="(record.goodsCash!=null and record.goodsCash!='') or  (record.goodsCash!='' and record.goodsCash==0)  "> | 
|                 and goods_cash = #{record.goodsCash} | 
|             </if> | 
|             <if | 
|                 test="(record.projNum!=null and record.projNum!='') or  (record.projNum!='' and record.projNum==0)  "> | 
|                 and proj_num = #{record.projNum} | 
|             </if> | 
|             <if | 
|                 test="(record.numberOfPeople!=null and record.numberOfPeople!='') or  (record.numberOfPeople!='' and record.numberOfPeople==0)  "> | 
|                 and number_of_people = #{record.numberOfPeople} | 
|             </if> | 
|             <if | 
|                 test="(record.shopName!=null and record.shopName!='') or  (record.shopName!='' and record.shopName==0)  "> | 
|                 and shop_name = #{record.shopName} | 
|             </if> | 
|             <if | 
|                 test="(record.projTime!=null and record.projTime!='') or  (record.projTime!='' and record.projTime==0)  "> | 
|                 and proj_time = #{record.projTime} | 
|             </if> | 
|             <if | 
|                 test="(record.remark!=null and record.remark!='') or  (record.remark!='' and record.remark==0)  "> | 
|                 and remark = #{record.remark} | 
|             </if> | 
|             <if | 
|                 test="(record.orderType!=null and record.orderType!='') or  (record.orderType!='' and record.orderType==0)  "> | 
|                 and order_type = #{record.orderType} | 
|             </if> | 
|             <if | 
|                 test="(record.projPercentage!=null and record.projPercentage!='') or  (record.projPercentage!='' and record.projPercentage==0)  "> | 
|                 and proj_percentage = #{record.projPercentage} | 
|             </if> | 
|             <if | 
|                 test="(record.t1!=null and record.t1!='') or  (record.t1!='' and record.t1==0)  "> | 
|                 and t1 = #{record.t1} | 
|             </if> | 
|             <if | 
|                 test="(record.t2!=null and record.t2!='') or  (record.t2!='' and record.t2==0)  "> | 
|                 and t2 = #{record.t2} | 
|             </if> | 
|             <if | 
|                 test="(record.t3!=null and record.t3!='') or  (record.t3!='' and record.t3==0)  "> | 
|                 and t3 = #{record.t3} | 
|             </if> | 
|             <if | 
|                 test="(record.t4!=null and record.t4!='') or  (record.t4!='' and record.t4==0)  "> | 
|                 and t4 = #{record.t4} | 
|             </if> | 
|             <if | 
|                 test="(record.t5!=null and record.t5!='') or  (record.t5!='' and record.t5==0)  "> | 
|                 and t5 = #{record.t5} | 
|             </if> | 
|             <if | 
|                 test="(record.t6!=null and record.t6!='') or  (record.t6!='' and record.t6==0)  "> | 
|                 and t6 = #{record.t6} | 
|             </if> | 
|             <if | 
|                 test="(record.t8!=null and record.t8!='') or  (record.t8!='' and record.t8==0)  "> | 
|                 and t8 = #{record.t8} | 
|             </if> | 
|             <if | 
|                 test="(record.t9!=null and record.t9!='') or  (record.t9!='' and record.t9==0)  "> | 
|                 and t9 = #{record.t9} | 
|             </if> | 
|         </if> | 
|   | 
|     </sql> | 
|   | 
|     <!-- 插入方法 --> | 
|     <insert id="insert" parameterType="com.matrix.system.hive.bean.AchieveNew" | 
|         useGeneratedKeys="true" keyProperty="item.id"> | 
|         INSERT INTO achieve_new ( | 
|         <include refid="columns"></include> | 
|         ) | 
|         VALUES ( | 
|         <include refid="propertys"></include> | 
|         ) | 
|     </insert> | 
|   | 
|   | 
|   | 
|     <!-- 批量插入 --> | 
|     <insert id="batchInsert" parameterType="java.util.List"> | 
|         INSERT INTO achieve_new ( | 
|         <include refid="columns"></include> | 
|         ) | 
|         VALUES | 
|         <foreach collection="list" item="item" index="index" | 
|             separator=","> | 
|             ( | 
|             <include refid="propertys"></include> | 
|             ) | 
|         </foreach> | 
|     </insert> | 
|   | 
|   | 
|   | 
|   | 
|   | 
|     <!-- 根据Map更新 部分更新 --> | 
|     <update id="updateByMap" parameterType="java.util.HashMap"> | 
|         UPDATE achieve_new | 
|         <set> | 
|             <if test="_parameter.containsKey('saleId')"> | 
|                 sale_id = #{saleId}, | 
|             </if> | 
|             <if test="_parameter.containsKey('beaultId')"> | 
|                 beault_id = #{beaultId}, | 
|             </if> | 
|             <if test="_parameter.containsKey('shopId')"> | 
|                 shop_id = #{shopId}, | 
|             </if> | 
|             <if test="_parameter.containsKey('datatime')"> | 
|                 datatime = #{datatime}, | 
|             </if> | 
|             <if test="_parameter.containsKey('orderId')"> | 
|                 order_id = #{orderId}, | 
|             </if> | 
|             <if test="_parameter.containsKey('orderItemId')"> | 
|                 order_item_id = #{orderItemId}, | 
|             </if> | 
|             <if test="_parameter.containsKey('shoppingGoodsId')"> | 
|                 shopping_goods_id = #{shoppingGoodsId}, | 
|             </if> | 
|             <if test="_parameter.containsKey('serviceOrderId')"> | 
|                 service_order_id = #{serviceOrderId}, | 
|             </if> | 
|             <if test="_parameter.containsKey('vipId')"> | 
|                 vip_id = #{vipId}, | 
|             </if> | 
|             <if test="_parameter.containsKey('freeConsume')"> | 
|                 free_consume = #{freeConsume}, | 
|             </if> | 
|             <if test="_parameter.containsKey('hisConsume')"> | 
|                 his_consume = #{hisConsume}, | 
|             </if> | 
|             <if test="_parameter.containsKey('consume')"> | 
|                 consume = #{consume}, | 
|             </if> | 
|             <if test="_parameter.containsKey('cardCash')"> | 
|                 card_cash = #{cardCash}, | 
|             </if> | 
|             <if test="_parameter.containsKey('projCash')"> | 
|                 proj_cash = #{projCash}, | 
|             </if> | 
|             <if test="_parameter.containsKey('goodsCash')"> | 
|                 goods_cash = #{goodsCash}, | 
|             </if> | 
|             <if test="_parameter.containsKey('projNum')"> | 
|                 proj_num = #{projNum}, | 
|             </if> | 
|             <if test="_parameter.containsKey('numberOfPeople')"> | 
|                 number_of_people = #{numberOfPeople}, | 
|             </if> | 
|             <if test="_parameter.containsKey('shopName')"> | 
|                 shop_name = #{shopName}, | 
|             </if> | 
|             <if test="_parameter.containsKey('projTime')"> | 
|                 proj_time = #{projTime}, | 
|             </if> | 
|             <if test="_parameter.containsKey('remark')"> | 
|                 remark = #{remark}, | 
|             </if> | 
|             <if test="_parameter.containsKey('orderType')"> | 
|                 order_type = #{orderType}, | 
|             </if> | 
|             <if test="_parameter.containsKey('projPercentage')"> | 
|                 proj_percentage = #{projPercentage}, | 
|             </if> | 
|             <if test="_parameter.containsKey('t1')"> | 
|                 t1 = #{t1}, | 
|             </if> | 
|             <if test="_parameter.containsKey('t2')"> | 
|                 t2 = #{t2}, | 
|             </if> | 
|             <if test="_parameter.containsKey('t3')"> | 
|                 t3 = #{t3}, | 
|             </if> | 
|             <if test="_parameter.containsKey('t4')"> | 
|                 t4 = #{t4}, | 
|             </if> | 
|             <if test="_parameter.containsKey('t5')"> | 
|                 t5 = #{t5}, | 
|             </if> | 
|             <if test="_parameter.containsKey('t6')"> | 
|                 t6 = #{t6}, | 
|             </if> | 
|             <if test="_parameter.containsKey('t8')"> | 
|                 t8 = #{t8}, | 
|             </if> | 
|             <if test="_parameter.containsKey('t9')"> | 
|                 t9 = #{t9}, | 
|             </if> | 
|         </set> | 
|         WHERE id=#{id} | 
|     </update> | 
|   | 
|   | 
|     <!-- 根据对象更新 部分更新 --> | 
|     <update id="updateAchieveTime" > | 
|         UPDATE achieve_new set datatime = #{record.datatime} | 
|         <where> | 
|             <if | 
|                 test="(record.id!=null and record.id!='') or  (record.id!='' and record.id==0)  "> | 
|                 and id = #{record.id} | 
|             </if> | 
|             <if | 
|                 test="(record.orderId!=null and record.orderId!='') or  (record.orderId!='' and record.orderId==0)  "> | 
|                 and order_id = #{record.orderId} | 
|             </if> | 
|             <if | 
|                 test="(record.serviceOrderId!=null and record.serviceOrderId!='') or  (record.serviceOrderId!='' and record.serviceOrderId==0)  "> | 
|                 and service_order_id = #{record.serviceOrderId} | 
|             </if> | 
|         </where> | 
|   | 
|   | 
|     </update> | 
|     <update id="updateByModel" > | 
|         UPDATE achieve_new | 
|         <set> | 
|             <if test="record.saleId != null "> | 
|                 sale_id = #{record.saleId}, | 
|             </if> | 
|             <if test="record.beaultId != null "> | 
|                 beault_id = #{record.beaultId}, | 
|             </if> | 
|             <if test="record.shopId != null "> | 
|                 shop_id = #{record.shopId}, | 
|             </if> | 
|             <if test="record.datatime != null "> | 
|                 datatime = #{record.datatime}, | 
|             </if> | 
|             <if test="record.orderId != null "> | 
|                 order_id = #{record.orderId}, | 
|             </if> | 
|             <if test="record.orderItemId != null "> | 
|                 order_item_id = #{record.orderItemId}, | 
|             </if> | 
|             <if test="record.shoppingGoodsId != null "> | 
|                 shopping_goods_id = #{record.shoppingGoodsId}, | 
|             </if> | 
|             <if test="record.serviceOrderId != null "> | 
|                 service_order_id = #{record.serviceOrderId}, | 
|             </if> | 
|             <if test="record.vipId != null "> | 
|                 vip_id = #{record.vipId}, | 
|             </if> | 
|             <if | 
|                 test="record.freeConsume != null and record.freeConsume != '' "> | 
|                 free_consume = #{record.freeConsume}, | 
|             </if> | 
|             <if test="record.hisConsume != null "> | 
|                 his_consume = #{record.hisConsume}, | 
|             </if> | 
|             <if test="record.consume != null "> | 
|                 consume = #{record.consume}, | 
|             </if> | 
|             <if test="record.cardCash != null "> | 
|                 card_cash = #{record.cardCash}, | 
|             </if> | 
|             <if test="record.projCash != null "> | 
|                 proj_cash = #{record.projCash}, | 
|             </if> | 
|             <if test="record.goodsCash != null "> | 
|                 goods_cash = #{record.goodsCash}, | 
|             </if> | 
|             <if test="record.projNum != null "> | 
|                 proj_num = #{record.projNum}, | 
|             </if> | 
|             <if test="record.numberOfPeople != null "> | 
|                 number_of_people = #{record.numberOfPeople}, | 
|             </if> | 
|             <if test="record.shopName != null and record.shopName != '' "> | 
|                 shop_name = #{record.shopName}, | 
|             </if> | 
|             <if test="record.projTime != null "> | 
|                 proj_time = #{record.projTime}, | 
|             </if> | 
|             <if test="record.remark != null and record.remark != '' "> | 
|                 remark = #{record.remark}, | 
|             </if> | 
|             <if test="record.orderType != null and record.orderType != '' "> | 
|                 order_type = #{record.orderType}, | 
|             </if> | 
|             <if test="record.projPercentage != null "> | 
|                 proj_percentage = #{record.projPercentage}, | 
|             </if> | 
|             <if test="record.t1 != null and record.t1 != '' "> | 
|                 t1 = #{record.t1}, | 
|             </if> | 
|             <if test="record.t2 != null and record.t2 != '' "> | 
|                 t2 = #{record.t2}, | 
|             </if> | 
|             <if test="record.t3 != null and record.t3 != '' "> | 
|                 t3 = #{record.t3}, | 
|             </if> | 
|             <if test="record.t4 != null and record.t4 != '' "> | 
|                 t4 = #{record.t4}, | 
|             </if> | 
|             <if test="record.t5 != null and record.t5 != '' "> | 
|                 t5 = #{record.t5}, | 
|             </if> | 
|             <if test="record.t6 != null and record.t6 != '' "> | 
|                 t6 = #{record.t6}, | 
|             </if> | 
|             <if test="record.t8 != null and record.t8 != '' "> | 
|                 t8 = #{record.t8}, | 
|             </if> | 
|             <if test="record.t9 != null and record.t9 != '' "> | 
|                 t9 = #{record.t9}, | 
|             </if> | 
|         </set> | 
|         WHERE id=#{record.id} | 
|     </update> | 
|   | 
|     <!-- 批量删除 --> | 
|     <delete id="deleteByIds" parameterType="java.util.List"> | 
|         delete from achieve_new where id in | 
|         <foreach collection="list" index="index" item="item" open="(" | 
|             separator="," close=")"> | 
|             #{item} | 
|         </foreach> | 
|     </delete> | 
|   | 
|     <!-- 根据id删除 --> | 
|     <delete id="deleteById" > | 
|         DELETE FROM achieve_new | 
|         where id=#{id} | 
|     </delete> | 
|   | 
|     <!-- 根据对象删除 --> | 
|     <delete id="deleteByModel" > | 
|         DELETE FROM achieve_new | 
|         where 1=1 | 
|         <include refid="where_sql"></include> | 
|     </delete> | 
|   | 
|   | 
|   | 
|     <!-- 分页查询 --> | 
|     <select id="selectInPage" resultMap="AchieveNewMap"> | 
|         select | 
|         <include refid="columns"></include> | 
|         from achieve_new | 
|         where 1=1 | 
|         <include refid="where_sql"></include> | 
|         <if test="pageVo !=null"><!-- 判断pageVo对象是否为空 --> | 
|             <if test="pageVo.sort !=null  and pageVo.order !=null"> | 
|                 order by | 
|                 ${pageVo.sort} ${pageVo.order} | 
|             </if> | 
|             <if test="pageVo.offset >=0  and pageVo.limit >0"> | 
|                 limit | 
|                 #{pageVo.offset},#{pageVo.limit} | 
|             </if> | 
|         </if> | 
|     </select> | 
|   | 
|     <!-- 查询总条数 --> | 
|     <select id="selectTotalRecord" | 
|         resultType="java.lang.Integer"> | 
|         select count(*) | 
|         from achieve_new | 
|         where 1=1 | 
|         <include refid="where_sql"></include> | 
|     </select> | 
|   | 
|     <!-- 根据id查询 --> | 
|     <select id="selectById" resultMap="AchieveNewMap"> | 
|         select | 
|         <include refid="columns"></include> | 
|         from achieve_new | 
|         where id=#{id} | 
|     </select> | 
|   | 
|   | 
|     <!-- 根据id 锁表查询 --> | 
|     <select id="selectForUpdate" resultMap="AchieveNewMap"> | 
|         select | 
|         <include refid="columns"></include> | 
|         from achieve_new | 
|         where id=#{id} | 
|         for update | 
|     </select> | 
|   | 
|   | 
|   | 
|     <!-- 根据对象查询 --> | 
|     <select id="selectByModel" resultMap="AchieveNewMap"> | 
|         select | 
|         <include refid="columns"></include> | 
|         from achieve_new | 
|         where 1=1 | 
|         <include refid="where_sql"></include> | 
|     </select> | 
|   | 
|   | 
|     <select id="selectVipConsumeStatisticsList" resultMap="AchieveNewMap"> | 
|         select | 
|             a.VIP_NAME, | 
|             a.PHONE t9, | 
|             GROUP_CONCAT(DISTINCT e.su_name) meiliao, | 
|             d.cnt arrive_cnt, | 
|             sum(b.buyConsume) goods_cash, | 
|             sum(b.freeConsume) free_consume, | 
|             sum(b.hisConsume) his_consume | 
|         from sys_vip_info a | 
|         inner join ( | 
|             select vip_id,datatime, sum(a.free_consume) freeConsume, sum(a.his_consume) hisConsume, sum(IFNULL(goods_cash, 0) + IFNULL(card_cash, 0)) buyConsume from achieve_new a group by vip_id | 
|         ) b on a.ID = b.vip_id | 
|         inner join ( | 
|             select vip_id, count(1) cnt from ( | 
|                                          select vip_id, date_format(datatime, '%Y-%m-%d') | 
|                                          from achieve_new | 
|                                          group by date_format(datatime, '%Y-%m-%d'), vip_id | 
|                                      ) c group by vip_id | 
|             ) d on a.ID=d.vip_id | 
|   | 
|         left join sys_users e on find_in_set(e.su_id, a.BEATUY_ID) | 
|         where 1=1 | 
|         <if test="record.vipName != null and record.vipName !=''"> | 
|             and (a.vip_name like CONCAT(CONCAT('%', #{record.vipName}), '%') or a.vip_no=#{record.vipName} or a.phone = #{record.vipName}) | 
|         </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(b.datatime, '%Y-%m-%d') >= date_format(#{record.endTime}, '%Y-%m-%d') | 
|         </if> | 
|         <if test="record.beaultId != null and record.beaultId!=''"> | 
|             and FIND_IN_SET(#{record.beaultId}, a.BEATUY_ID) | 
|         </if> | 
|         <if test='record.t1 == "on"'> | 
|             and a.BEATUY_ID is not null | 
|         </if> | 
|         group by a.PHONE | 
|         <if test="pageVo !=null"><!-- 判断pageVo对象是否为空 --> | 
|             <if test="pageVo.sort !=null  and pageVo.order !=null"> | 
|                 order by | 
|                 ${pageVo.sort} ${pageVo.order} | 
|             </if> | 
|             <if test="pageVo.offset >=0  and pageVo.limit >0"> | 
|                 limit | 
|                 #{pageVo.offset},#{pageVo.limit} | 
|             </if> | 
|         </if> | 
|     </select> | 
|   | 
|     <select id="selectVipConsumeStatisticsTotal" resultType="java.lang.Integer"> | 
|         select count(1) | 
|         from sys_vip_info a | 
|         inner join ( | 
|         select vip_id,datatime, sum(a.free_consume) freeConsume, sum(a.his_consume) hisConsume, sum(IFNULL(goods_cash, 0) + IFNULL(card_cash, 0)) buyConsume from achieve_new a group by vip_id | 
|         ) b on a.ID = b.vip_id | 
|         inner join ( | 
|         select vip_id, count(1) cnt from ( | 
|         select vip_id, date_format(datatime, '%Y-%m-%d') | 
|         from achieve_new | 
|         group by date_format(datatime, '%Y-%m-%d'), vip_id | 
|         ) c group by vip_id | 
|         ) d on a.ID=d.vip_id | 
|   | 
|         left join sys_users e on find_in_set(e.su_id, a.BEATUY_ID) | 
|         where 1=1 | 
|         <if test="record.vipName != null and record.vipName !=''"> | 
|             and (a.vip_name like CONCAT(CONCAT('%', #{record.vipName}), '%') or a.vip_no=#{record.vipName} or a.phone = #{record.vipName}) | 
|         </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(b.datatime, '%Y-%m-%d') >= date_format(#{record.endTime}, '%Y-%m-%d') | 
|         </if> | 
|         <if test="record.beaultId != null and record.beaultId!=''"> | 
|             and FIND_IN_SET(#{record.beaultId}, a.BEATUY_ID) | 
|         </if> | 
|         <if test='record.t1 == "on"'> | 
|             and a.BEATUY_ID is not null | 
|         </if> | 
|     </select> | 
|   | 
|   | 
|     <select id="selectUserAchieveByTime" resultType="com.matrix.system.app.vo.UserAchieveVo"> | 
|         select | 
|             sale_id id, | 
|             sum(IFNULL(proj_cash,0) + IFNULL(goods_cash,0) + IFNULL(card_cash,0) + IFNULL(consume, 0) + IFNULL(b.arrears, 0)) orderCash, | 
|             sum(IFNULL(proj_cash,0) + IFNULL(goods_cash,0) + IFNULL(card_cash,0) + IFNULL(b.arrears, 0)) cash, | 
|             sum(IFNULL(consume, 0)) cardUse, | 
|             sum(IFNULL(his_consume, 0)) hisConsume, | 
|             sum(IFNULL(free_consume, 0)) freeConsume, | 
|             sum(IFNULL(proj_percentage, 0)) projCommission | 
|         from achieve_new a | 
|         left join sys_order b on a.sale_id=b.STAFF_ID and (date_format(b.ORDER_TIME, '%Y-%m-%d') >= date_format(#{startTime}, '%Y-%m-%d') and date_format(#{endTime}, '%Y-%m-%d') >= date_format(b.ORDER_TIME, '%Y-%m-%d')) | 
|         where sale_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')) | 
|     </select> | 
|   | 
|     <select id="selectApiOrderItemAchieve" resultType="com.matrix.system.app.vo.OrderDetailAchieveItemVo"> | 
|         select | 
|             b.su_name name, | 
|             IFNULL(a.card_cash, 0) + IFNULL(a.proj_cash, 0) + IFNULL(a.goods_cash, 0) achieve | 
|         from achieve_new a | 
|         inner join sys_users b on (a.beault_id=b.su_id or a.sale_id = b.su_id) | 
|         where a.order_item_id=#{itemId} and order_type = '订单' | 
|     </select> | 
|   | 
|     <select id="selectShopConsumeAchieveRanking" resultType="com.matrix.system.app.vo.RankingVo"> | 
|         select | 
|             b.shop_short_name name, | 
|             b.SHOP_IMAG photo, | 
|             sum(IFNULL(a.free_consume,0) + IFNULL(a.consume,0) + IFNULL(a.his_consume,0)) amount | 
|         from achieve_new a | 
|         left join sys_shop_info b on a.shop_id=b.ID | 
|         <where> | 
|             <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') | 
|             </if> | 
|             <if test='record.t1 == "2" and record.datatime != null'> | 
|                 and date_format(datatime, '%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') | 
|             </if> | 
|         </where> | 
|         group by a.shop_id | 
|         order by amount desc, a.shop_id | 
|     </select> | 
|   | 
|     <select id="selectBeauticianConsumeAchieveRanking" resultType="com.matrix.system.app.vo.RankingVo"> | 
|         select | 
|             b.su_name name, | 
|             b.su_id id, | 
|             sum(IFNULL(a.free_consume,0) + IFNULL(a.his_consume, 0) + IFNULL(a.consume, 0)) amount, | 
|             c.shop_short_name shopName | 
|         from achieve_new a | 
|         inner join sys_users b on a.beault_id=b.su_id | 
|         left join sys_shop_info c on a.shop_id=c.ID | 
|         <where> | 
|             a.order_type='服务单' | 
|             <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.t1 == "1" and record.datatime != null'> | 
|                 and date_format(datatime, '%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') | 
|             </if> | 
|             <if test='record.t1 == "3" and record.datatime != null'> | 
|                 and date_format(datatime, '%Y') = date_format(#{record.datatime}, '%Y') | 
|             </if> | 
|         </where> | 
|         group by a.beault_id | 
|         order by amount desc | 
|     </select> | 
| </mapper> |