2076 lines
90 KiB
XML
2076 lines
90 KiB
XML
<?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.sqx.modules.artificer.dao.OrdersDao">
|
|
|
|
<insert id="insertOrders" useGeneratedKeys="true" keyProperty="ordersId" parameterType="com.sqx.modules.artificer.entity.Orders">
|
|
INSERT INTO orders
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="null != artificerId ">
|
|
artificer_id,
|
|
</if>
|
|
<if test="null != userId ">
|
|
user_id,
|
|
</if>
|
|
<if test="null != serveTime and '' != serveTime">
|
|
serve_time,
|
|
</if>
|
|
<if test="null != phone and '' != phone">
|
|
phone,
|
|
</if>
|
|
<if test="null != address and '' != address">
|
|
address,
|
|
</if>
|
|
<if test="null != remark and '' != remark">
|
|
remark,
|
|
</if>
|
|
<if test="null != payMoney ">
|
|
pay_money,
|
|
</if>
|
|
<if test="null != ordersNo and '' != ordersNo">
|
|
orders_no,
|
|
</if>
|
|
<if test="null != payTime and '' != payTime">
|
|
pay_time,
|
|
</if>
|
|
<if test="null != payWay ">
|
|
pay_way,
|
|
</if>
|
|
<if test="null != status ">
|
|
status,
|
|
</if>
|
|
<if test="null != createTime and '' != createTime">
|
|
create_time,
|
|
</if>
|
|
<if test="null != artificerMoney ">
|
|
artificer_money,
|
|
</if>
|
|
<if test="null != longitude and '' != longitude">
|
|
longitude,
|
|
</if>
|
|
<if test="null != latitude and '' != latitude">
|
|
latitude,
|
|
</if>
|
|
<if test="null != sumMoney ">
|
|
sum_money,
|
|
</if>
|
|
<if test="null != addNum">
|
|
add_num,
|
|
</if>
|
|
<if test="null != addTime and '' != addTime">
|
|
add_time,
|
|
</if>
|
|
<if test="null != taxiMoney ">
|
|
taxi_money,
|
|
</if>
|
|
<if test="null != parentId ">
|
|
parent_id,
|
|
</if>
|
|
<if test="null != startTime and '' != startTime">
|
|
start_time,
|
|
</if>
|
|
<if test="null != couponId ">
|
|
coupon_id,
|
|
</if>
|
|
<if test="null != couponName and '' != couponName">
|
|
coupon_name,
|
|
</if>
|
|
<if test="null != couponMoney ">
|
|
coupon_money,
|
|
</if>
|
|
<if test="null != addArtificerMoney ">
|
|
add_artificer_money,
|
|
</if>
|
|
<if test="null != addMoney ">
|
|
add_money,
|
|
</if>
|
|
<if test="null != price ">
|
|
price,
|
|
</if>
|
|
<if test="null != sumArtificerMoney ">
|
|
sum_artificer_money,
|
|
</if>
|
|
<if test="null != isSend ">
|
|
is_send,
|
|
</if>
|
|
<if test="null != endTime and '' != endTime">
|
|
end_time,
|
|
</if>
|
|
<if test="null != userName and '' != userName">
|
|
user_name,
|
|
</if>
|
|
<if test="null != oneUserMoney ">
|
|
one_user_money,
|
|
</if>
|
|
<if test="null != oneUserId ">
|
|
one_user_id,
|
|
</if>
|
|
<if test="null != oneUserName and '' != oneUserName">
|
|
one_user_name,
|
|
</if>
|
|
<if test="null != oneArtificerMoney ">
|
|
one_artificer_money,
|
|
</if>
|
|
<if test="null != oneArtificerUserId ">
|
|
one_artificer_user_id,
|
|
</if>
|
|
<if test="null != oneArtificerUserName and '' != oneArtificerUserName">
|
|
one_artificer_user_name,
|
|
</if>
|
|
<if test="null != pingMoney ">
|
|
ping_money,
|
|
</if>
|
|
<if test="null != massageTypeId ">
|
|
massage_type_id,
|
|
</if>
|
|
<if test="null != overTimeOrders ">
|
|
over_time_orders,
|
|
</if>
|
|
<if test="null != endTimes and '' != endTimes">
|
|
end_times,
|
|
</if>
|
|
<if test="null != tripWay and '' != tripWay">
|
|
trip_way,
|
|
</if>
|
|
<if test="null != userPackageId and '' != userPackageId">
|
|
user_package_id,
|
|
</if>
|
|
<if test="null != km and '' != km">
|
|
km
|
|
</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="null != artificerId ">
|
|
#{artificerId},
|
|
</if>
|
|
<if test="null != userId ">
|
|
#{userId},
|
|
</if>
|
|
<if test="null != serveTime and '' != serveTime">
|
|
#{serveTime},
|
|
</if>
|
|
<if test="null != phone and '' != phone">
|
|
#{phone},
|
|
</if>
|
|
<if test="null != address and '' != address">
|
|
#{address},
|
|
</if>
|
|
<if test="null != remark and '' != remark">
|
|
#{remark},
|
|
</if>
|
|
<if test="null != payMoney ">
|
|
#{payMoney},
|
|
</if>
|
|
<if test="null != ordersNo and '' != ordersNo">
|
|
#{ordersNo},
|
|
</if>
|
|
<if test="null != payTime and '' != payTime">
|
|
#{payTime},
|
|
</if>
|
|
<if test="null != payWay ">
|
|
#{payWay},
|
|
</if>
|
|
<if test="null != status ">
|
|
#{status},
|
|
</if>
|
|
<if test="null != createTime and '' != createTime">
|
|
#{createTime},
|
|
</if>
|
|
<if test="null != artificerMoney ">
|
|
#{artificerMoney},
|
|
</if>
|
|
<if test="null != longitude and '' != longitude">
|
|
#{longitude},
|
|
</if>
|
|
<if test="null != latitude and '' != latitude">
|
|
#{latitude},
|
|
</if>
|
|
<if test="null != sumMoney ">
|
|
#{sumMoney},
|
|
</if>
|
|
<if test="null != addNum ">
|
|
#{addNum},
|
|
</if>
|
|
<if test="null != addTime and '' != addTime">
|
|
#{addTime},
|
|
</if>
|
|
<if test="null != taxiMoney ">
|
|
#{taxiMoney},
|
|
</if>
|
|
<if test="null != parentId ">
|
|
#{parentId},
|
|
</if>
|
|
<if test="null != startTime and '' != startTime">
|
|
#{startTime},
|
|
</if>
|
|
<if test="null != couponId ">
|
|
#{couponId},
|
|
</if>
|
|
<if test="null != couponName and '' != couponName">
|
|
#{couponName},
|
|
</if>
|
|
<if test="null != couponMoney ">
|
|
#{couponMoney},
|
|
</if>
|
|
<if test="null != addArtificerMoney ">
|
|
#{addArtificerMoney},
|
|
</if>
|
|
<if test="null != addMoney ">
|
|
#{addMoney},
|
|
</if>
|
|
<if test="null != price ">
|
|
#{price},
|
|
</if>
|
|
<if test="null != sumArtificerMoney ">
|
|
#{sumArtificerMoney},
|
|
</if>
|
|
<if test="null != isSend ">
|
|
#{isSend},
|
|
</if>
|
|
<if test="null != endTime and '' != endTime">
|
|
#{endTime},
|
|
</if>
|
|
<if test="null != userName and '' != userName">
|
|
#{userName},
|
|
</if>
|
|
<if test="null != oneUserMoney ">
|
|
#{oneUserMoney},
|
|
</if>
|
|
<if test="null != oneUserId ">
|
|
#{oneUserId},
|
|
</if>
|
|
<if test="null != oneUserName and '' != oneUserName">
|
|
#{oneUserName},
|
|
</if>
|
|
<if test="null != oneArtificerMoney ">
|
|
#{oneArtificerMoney},
|
|
</if>
|
|
<if test="null != oneArtificerUserId ">
|
|
#{oneArtificerUserId},
|
|
</if>
|
|
<if test="null != oneArtificerUserName and '' != oneArtificerUserName">
|
|
#{oneArtificerUserName},
|
|
</if>
|
|
<if test="null != pingMoney ">
|
|
#{pingMoney},
|
|
</if>
|
|
<if test="null != massageTypeId ">
|
|
#{massageTypeId},
|
|
</if>
|
|
<if test="null != overTimeOrders ">
|
|
#{overTimeOrders},
|
|
</if>
|
|
<if test="null != endTimes and '' != endTimes">
|
|
#{endTimes},
|
|
</if>
|
|
<if test="null != tripWay and '' != tripWay">
|
|
#{tripWay},
|
|
</if>
|
|
<if test="null != userPackageId and '' != userPackageId">
|
|
#{userPackageId},
|
|
</if>
|
|
<if test="null != km and '' != km">
|
|
#{km}
|
|
</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<select id="selectOrdersList" resultType="com.sqx.modules.artificer.entity.Orders">
|
|
select o.*,a.artificer_name as artificerName,a.artificer_img as artificerImg,
|
|
a.user_id as artificerUserId,c.consortia_name as shopName,c.address as shopAddress,
|
|
c.phone as shopPhone
|
|
from orders o
|
|
left join artificer a on a.artificer_id=o.artificer_id
|
|
left join tb_user u on u.user_id=o.user_id
|
|
left join consortia c on c.consortia_id=o.consortia_id
|
|
where 1=1
|
|
<if test="userPackageId!=null">
|
|
and o.user_package_id = #{userPackageId}
|
|
</if>
|
|
<if test="classifyId!=null and classifyId!=''">
|
|
and o.orders_id in (select orders_id from orders_massage where massage_id in (select massage_type_id from massage_type where classify_id=#{classifyId} ))
|
|
</if>
|
|
<if test="title!=null and title!=''">
|
|
and o.orders_id in (select orders_id from orders_massage where massage_id in (select massage_type_id from massage_type where title like concat('%',#{title},'%') ))
|
|
</if>
|
|
<if test="userId!=null">
|
|
and o.user_id=#{userId}
|
|
</if>
|
|
<if test="shopId!=null">
|
|
and o.shop_user_id=#{shopId}
|
|
</if>
|
|
<if test="status!=null and status!=0 and status!=-1 and status!=2">
|
|
and o.status=#{status}
|
|
</if>
|
|
<if test="status!=null and status==2">
|
|
and o.status in (2,9)
|
|
</if>
|
|
<if test="status!=null and status==-1">
|
|
and o.status in (3,5)
|
|
</if>
|
|
<if test="overTimeOrders!=null and overTimeOrders!=0">
|
|
and o.over_time_orders=#{overTimeOrders}
|
|
</if>
|
|
<if test="warning!=null and warning==1">
|
|
and o.warning = #{warning}
|
|
</if>
|
|
<if test="warning!=null and warning==2">
|
|
and o.warning = null
|
|
</if>
|
|
<if test="city!=null and city!=''">
|
|
and o.address like concat('%',#{city},'%')
|
|
</if>
|
|
<if test="userName!=null and userName!=''">
|
|
and o.user_name like concat('%',#{userName},'%')
|
|
</if>
|
|
<if test="shopName!=null and shopName!=''">
|
|
and c.consortia_name like concat('%',#{shopName},'%')
|
|
</if>
|
|
<if test="phone!=null and phone!=''">
|
|
and o.phone like concat('%',#{phone},'%')
|
|
</if>
|
|
<if test="artificerId!=null and artificerId!=''">
|
|
and o.artificer_id = #{artificerId}
|
|
</if>
|
|
<if test="parentId!=null">
|
|
and o.parent_id = #{parentId}
|
|
</if>
|
|
<if test="parentId==null">
|
|
and o.parent_id = 0
|
|
</if>
|
|
<if test="ordersNo!=null and ordersNo!=''">
|
|
and o.orders_no = #{ordersNo}
|
|
</if>
|
|
<if test="artificerName!=null and artificerName!=''">
|
|
and a.artificer_name like concat('%',#{artificerName},'%')
|
|
</if>
|
|
<if test="oneUserName!=null and oneUserName!=''">
|
|
and o.one_user_name like concat('%',#{oneUserName},'%')
|
|
</if>
|
|
<if test="oneArtificerUserName!=null and oneArtificerUserName!=''">
|
|
and o.one_artificer_user_name like concat('%',#{oneArtificerUserName},'%')
|
|
</if>
|
|
<if test="startServeTime!=null and startServeTime!=''">
|
|
and date_format(o.serve_time,'%Y-%m-%d') >= date_format(#{startServeTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="endServeTime!=null and endServeTime!=''">
|
|
and date_format(o.serve_time,'%Y-%m-%d') <= date_format(#{endServeTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="startTime!=null and startTime!=''">
|
|
and date_format(o.create_time,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="endTime!=null and endTime!=''">
|
|
and date_format(o.create_time,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="isAdd!=null and isAdd!=0">
|
|
<if test="isAdd==1">
|
|
and o.add_num>0
|
|
</if>
|
|
<if test="isAdd==2">
|
|
and (o.add_num=0 or o.add_num is null)
|
|
</if>
|
|
</if>
|
|
order by o.create_time desc
|
|
</select>
|
|
|
|
<select id="selectAppOrdersList" resultType="com.sqx.modules.artificer.entity.Orders">
|
|
select o1.*,
|
|
(case when o1.status = 4
|
|
then o1.pay_money + ifnull(o1.add_money,0)
|
|
else o1.pay_money + ifnull(o1.add_money,0) + ifnull(o2.pay_money,0) + ifnull(o2.add_money,0) + ifnull(o3.pay_money,0) + ifnull(o3.add_money,0)
|
|
end) as pay_money_total,
|
|
(case when o1.status = 4
|
|
then o1.artificer_money + ifnull(o1.add_artificer_money,0)
|
|
else o1.artificer_money + ifnull(o1.add_artificer_money,0) + ifnull(o2.artificer_money,0) + ifnull(o2.add_artificer_money,0) + ifnull(o3.artificer_money,0) + ifnull(o3.add_artificer_money,0)
|
|
end) as artificer_money_total,
|
|
a.artificer_name as artificerName,a.artificer_img as artificerImg,
|
|
a.user_id as artificerUserId,c.consortia_name as shopName,c.address as shopAddress,
|
|
c.phone as shopPhone
|
|
from orders o1
|
|
left join orders o2 on o1.old_orders_id = o2.orders_id and o2.status != 4
|
|
left join orders o3 on o2.old_orders_id = o3.orders_id and o3.status != 4
|
|
left join artificer a on a.artificer_id=o1.artificer_id
|
|
left join tb_user u on u.user_id=o1.user_id
|
|
left join consortia c on c.consortia_id=o1.consortia_id
|
|
where o1.old_orders_id is not null
|
|
and o1.status not in (4,11,15)
|
|
<if test="userPackageId!=null">
|
|
and (o2.user_package_id = #{userPackageId} or o3.user_package_id = #{userPackageId})
|
|
</if>
|
|
<if test="userId!=null">
|
|
and o1.user_id=#{userId}
|
|
</if>
|
|
<if test="status!=null and status!=0 and status!=-1 and status!=2">
|
|
and o1.status=#{status}
|
|
</if>
|
|
<if test="status!=null and status==2">
|
|
and o1.status in (2,9)
|
|
</if>
|
|
union all
|
|
select o1.*,
|
|
(o1.pay_money + ifnull(o1.add_money,0)) as pay_money_total,
|
|
(o1.artificer_money + ifnull(o1.add_artificer_money,0)) as artificer_money_total,
|
|
a.artificer_name as artificerName,a.artificer_img as artificerImg,
|
|
a.user_id as artificerUserId,c.consortia_name as shopName,c.address as shopAddress,
|
|
c.phone as shopPhone
|
|
from orders o1
|
|
left join artificer a on a.artificer_id=o1.artificer_id
|
|
left join tb_user u on u.user_id=o1.user_id
|
|
left join consortia c on c.consortia_id=o1.consortia_id
|
|
where o1.parent_id = 0
|
|
and o1.old_orders_id is null
|
|
and o1.orders_id not in (
|
|
select orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
)
|
|
and o1.orders_id not in (
|
|
select old_orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
)
|
|
<if test="userPackageId!=null">
|
|
and o1.user_package_id = #{userPackageId}
|
|
</if>
|
|
<if test="userId!=null">
|
|
and o1.user_id=#{userId}
|
|
</if>
|
|
<if test="status!=null and status!=0 and status!=-1 and status!=2">
|
|
and o1.status=#{status}
|
|
</if>
|
|
<if test="status!=null and status==2">
|
|
and o1.status in (2,9)
|
|
</if>
|
|
order by serve_time desc
|
|
</select>
|
|
|
|
<select id="excelOrdersList" resultType="com.sqx.modules.artificer.entity.Orders">
|
|
select o.*,a.artificer_name as artificerName,a.artificer_img as artificerImg,
|
|
a.user_id as artificerUserId,c.consortia_name as shopName,c.address as shopAddress,
|
|
c.phone as shopPhone
|
|
from orders o
|
|
left join artificer a on a.artificer_id=o.artificer_id
|
|
left join tb_user u on u.user_id=o.user_id
|
|
left join consortia c on c.consortia_id=o.consortia_id
|
|
where 1=1
|
|
<if test="classifyId!=null and classifyId!=''">
|
|
and o.orders_id in (select orders_id from orders_massage where massage_id in (select massage_type_id from massage_type where classify_id=#{classifyId} ))
|
|
</if>
|
|
<if test="title!=null and title!=''">
|
|
and o.orders_id in (select orders_id from orders_massage where massage_id in (select massage_type_id from massage_type where title like concat('%',#{title},'%') ))
|
|
</if>
|
|
<if test="userId!=null">
|
|
and o.user_id=#{userId}
|
|
</if>
|
|
<if test="shopId!=null">
|
|
and o.shop_user_id=#{shopId}
|
|
</if>
|
|
<if test="status!=null and status!=0 and status!=-1">
|
|
and o.status=#{status}
|
|
</if>
|
|
<if test="status!=null and status==-1">
|
|
and o.status in (3,5)
|
|
</if>
|
|
<if test="overTimeOrders!=null and overTimeOrders!=0">
|
|
and o.over_time_orders=#{overTimeOrders}
|
|
</if>
|
|
<if test="warning!=null and warning==1">
|
|
and o.warning = #{warning}
|
|
</if>
|
|
<if test="warning!=null and warning==2">
|
|
and o.warning = null
|
|
</if>
|
|
<if test="city!=null and city!=''">
|
|
and o.address like concat('%',#{city},'%')
|
|
</if>
|
|
<if test="userName!=null and userName!=''">
|
|
and o.user_name like concat('%',#{userName},'%')
|
|
</if>
|
|
<if test="shopName!=null and shopName!=''">
|
|
and c.consortia_name like concat('%',#{shopName},'%')
|
|
</if>
|
|
<if test="phone!=null and phone!=''">
|
|
and o.phone like concat('%',#{phone},'%')
|
|
</if>
|
|
<if test="artificerId!=null and artificerId!=''">
|
|
and o.artificer_id = #{artificerId}
|
|
</if>
|
|
<if test="parentId!=null">
|
|
and o.parent_id = #{parentId}
|
|
</if>
|
|
<if test="parentId==null">
|
|
and o.parent_id = 0
|
|
</if>
|
|
<if test="ordersNo!=null and ordersNo!=''">
|
|
and o.orders_no = #{ordersNo}
|
|
</if>
|
|
<if test="artificerName!=null and artificerName!=''">
|
|
and a.artificer_name like concat('%',#{artificerName},'%')
|
|
</if>
|
|
<if test="oneUserName!=null and oneUserName!=''">
|
|
and o.one_user_name like concat('%',#{oneUserName},'%')
|
|
</if>
|
|
<if test="oneArtificerUserName!=null and oneArtificerUserName!=''">
|
|
and o.one_artificer_user_name like concat('%',#{oneArtificerUserName},'%')
|
|
</if>
|
|
<if test="startServeTime!=null and startServeTime!=''">
|
|
and date_format(o.serve_time,'%Y-%m-%d') >= date_format(#{startServeTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="endServeTime!=null and endServeTime!=''">
|
|
and date_format(o.serve_time,'%Y-%m-%d') <= date_format(#{endServeTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="startTime!=null and startTime!=''">
|
|
and date_format(o.create_time,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="endTime!=null and endTime!=''">
|
|
and date_format(o.create_time,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="isAdd!=null and isAdd!=0">
|
|
<if test="isAdd==1">
|
|
and o.add_num>0
|
|
</if>
|
|
<if test="isAdd==2">
|
|
and (o.add_num=0 or o.add_num is null)
|
|
</if>
|
|
</if>
|
|
order by o.create_time desc
|
|
</select>
|
|
|
|
<select id="selectOrdersMoney" resultType="BigDecimal">
|
|
select
|
|
<if test="status==1 || status==2 || status==3">
|
|
ifnull(sum(pay_money),0.00)
|
|
</if>
|
|
<if test="status==4">
|
|
ifnull(sum(pay_money),0.00)-ifnull(sum(artificer_money),0.00)
|
|
</if>
|
|
from orders where 1=1
|
|
<if test="status!=null">
|
|
<if test="status==1">
|
|
and status in (2,3,5)
|
|
</if>
|
|
<if test="status==2">
|
|
and status=2
|
|
</if>
|
|
<if test="status==3">
|
|
and status in (3,5)
|
|
</if>
|
|
<if test="status==4">
|
|
and status in (2,3,5)
|
|
</if>
|
|
</if>
|
|
<if test="time!=null and time!='' and type==1">
|
|
and date_format(pay_time,'%Y-%m-%d') >= date_format(#{time},'%Y-%m-%d')
|
|
</if>
|
|
<if test="time!=null and time!='' and type==2">
|
|
and date_format(pay_time,'%Y-%m') >= date_format(#{time},'%Y-%m')
|
|
</if>
|
|
<if test="time!=null and time!='' and type==3">
|
|
and date_format(pay_time,'%Y') >= date_format(#{time},'%Y')
|
|
</if>
|
|
</select>
|
|
|
|
<!-- 数据统计-技师订单总收益-->
|
|
<select id="selectSumOrdersMoney" resultType="java.math.BigDecimal">
|
|
select IFNULL(SUM(artificer_money_total),0) AS currentEarnings
|
|
from (
|
|
select (case when o.status = 4
|
|
then o.artificer_money + ifnull(o.add_artificer_money,0)
|
|
else o.artificer_money + ifnull(o.add_artificer_money,0) + ifnull(o2.artificer_money,0) + ifnull(o2.add_artificer_money,0) + ifnull(o3.artificer_money,0) + ifnull(o3.add_artificer_money,0)
|
|
end) as artificer_money_total
|
|
from orders o
|
|
left join orders o2 on o.old_orders_id = o2.orders_id and o2.status != 4
|
|
left join orders o3 on o2.old_orders_id = o3.orders_id and o3.status != 4
|
|
where o.artificer_id = #{userId}
|
|
and o.old_orders_id is not null
|
|
and o.status not in (4,11,15)
|
|
<if test="startTime!=null and startTime!=''">
|
|
and date_format(o.end_times,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="endTime!=null and endTime!=''">
|
|
and date_format(o.end_times,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d')
|
|
</if>
|
|
and o.status in (3,5)
|
|
union all
|
|
select o.artificer_money + ifnull(o.add_artificer_money,0) as artificer_money_total
|
|
from orders o
|
|
where o.artificer_id = #{userId}
|
|
and o.parent_id = 0
|
|
and o.old_orders_id is null
|
|
and o.orders_id not in (
|
|
select orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
)
|
|
and o.orders_id not in (
|
|
select old_orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
)
|
|
<if test="startTime!=null and startTime!=''">
|
|
and date_format(o.end_times,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="endTime!=null and endTime!=''">
|
|
and date_format(o.end_times,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d')
|
|
</if>
|
|
and o.status in (3,5)
|
|
) t
|
|
</select>
|
|
|
|
<select id="selectSumMoneyMonth" resultType="java.math.BigDecimal">
|
|
select ifnull(sum(sum_artificer_money), 0) from orders where artificer_id = #{userId} and status in (3,5)
|
|
and date_format(pay_time,'%Y-%m') = date_format(#{time},'%Y-%m')
|
|
</select>
|
|
|
|
<select id="selectEstimationSumMoneyBy" resultType="java.math.BigDecimal">
|
|
select ifnull(sum(sum_artificer_money), 0) from orders where artificer_id = #{userId} and status in (3,5)
|
|
<if test="time!=null and time!='' and type==1">
|
|
and date_format(pay_time,'%Y-%m-%d') >= date_format(#{time},'%Y-%m-%d')
|
|
</if>
|
|
<if test="time!=null and time!='' and type==2">
|
|
and date_format(pay_time,'%Y-%m') >= date_format(#{time},'%Y-%m')
|
|
</if>
|
|
<if test="time!=null and time!='' and type==3">
|
|
and date_format(pay_time,'%Y') >= date_format(#{time},'%Y')
|
|
</if>
|
|
</select>
|
|
|
|
|
|
<select id="selectCountOrderNum" resultType="int">
|
|
select ifnull(sum(massage_num), 0) as num
|
|
from orders
|
|
where artificer_id = #{userId}
|
|
and status in (3,5,15)
|
|
and ifnull(is_supplement,0) in (0,2)
|
|
<if test="startTime!=null and startTime!=''">
|
|
and date_format(end_times,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="endTime!=null and endTime!=''">
|
|
and date_format(end_times,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d')
|
|
</if>
|
|
</select>
|
|
|
|
<select id="selectCountOrders" resultType="Integer">
|
|
select count(*) from orders
|
|
where 1=1
|
|
<if test="status!=null">
|
|
and status=#{status}
|
|
</if>
|
|
<if test="time!=null and time!='' and type==1">
|
|
and date_format(create_time,'%Y-%m-%d') >= date_format(#{time},'%Y-%m-%d')
|
|
</if>
|
|
<if test="time!=null and time!='' and type==2">
|
|
and date_format(create_time,'%Y-%m') >= date_format(#{time},'%Y-%m')
|
|
</if>
|
|
<if test="time!=null and time!='' and type==3">
|
|
and date_format(create_time,'%Y') >= date_format(#{time},'%Y')
|
|
</if>
|
|
</select>
|
|
|
|
<select id="selectCountOrderByUserId" resultType="int">
|
|
select count(*) from orders where user_id = #{userId} and parent_id = 0
|
|
and date_format(create_time,'%Y-%m') >= date_format(#{time},'%Y-%m')
|
|
<if test="status!=null">
|
|
and status = #{status}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="selectCountOrder" resultType="int">
|
|
select count(*) from orders where artificer_id = #{userId} and parent_id = 0
|
|
<if test="status!=null">
|
|
and status = #{status}
|
|
</if>
|
|
<if test="status==null">
|
|
and status in (2,3,5,6,7,8,9,10)
|
|
</if>
|
|
<if test="startTime!=null and startTime!=''">
|
|
and date_format(create_time,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="endTime!=null and endTime!=''">
|
|
and date_format(create_time,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d')
|
|
</if>
|
|
</select>
|
|
|
|
<select id="selectTodayOrder" resultType="com.sqx.modules.artificer.entity.Orders">
|
|
select o.*,
|
|
(case when o.user_package_detail_id is null then m.title else bl.title end ) as title,
|
|
(case when o.user_package_detail_id is null then m.massage_img else bl.massage_img end ) as massageImg,
|
|
now() > DATE_ADD(STR_TO_DATE(o.serve_time, '%Y-%m-%d %H:%i'), INTERVAL #{minutes} MINUTE) as is_can_supplement,
|
|
(case when o.status = 4
|
|
then o.artificer_money + ifnull(o.add_artificer_money,0)
|
|
else o.artificer_money + ifnull(o.add_artificer_money,0) + ifnull(o2.artificer_money,0) + ifnull(o2.add_artificer_money,0) + ifnull(o3.artificer_money,0) + ifnull(o3.add_artificer_money,0)
|
|
end) as artificer_money_total
|
|
from orders o
|
|
left join orders o2 on o.old_orders_id = o2.orders_id and o2.status != 4
|
|
left join orders o3 on o2.old_orders_id = o3.orders_id and o3.status != 4
|
|
left join orders_massage om on om.orders_id=o.orders_id
|
|
left join massage_type m on m.massage_type_id=om.massage_id
|
|
LEFT JOIN bl_user_package_detail bl ON bl.id = om.massage_id
|
|
where o.artificer_id = #{artificerId}
|
|
and o.old_orders_id is not null
|
|
and o.status not in (11,15)
|
|
<if test="type==1">
|
|
and date_format(o.serve_time,'%Y-%m-%d %H:%i') >= date_format(DATE_ADD(now(), INTERVAL -12 HOUR),'%Y-%m-%d %H:%i')
|
|
and date_format(o.serve_time,'%Y-%m-%d %H:%i') <= date_format(DATE_ADD(now(), INTERVAL 24 HOUR),'%Y-%m-%d %H:%i')
|
|
and o.pay_time is not null
|
|
and o.status in (2,3,4,5,6,7,8,9)
|
|
</if>
|
|
<if test="type==2">
|
|
and o.status in (2,6,7,8,9)
|
|
and o.pay_time is not null
|
|
<if test="startTime!=null and startTime!=''">
|
|
and date_format(o.serve_time,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="endTime!=null and endTime!=''">
|
|
and date_format(o.serve_time,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d')
|
|
</if>
|
|
</if>
|
|
<if test="type==3">
|
|
and o.status in (3,5)
|
|
<if test="startTime!=null and startTime!=''">
|
|
and date_format(o.serve_time,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="endTime!=null and endTime!=''">
|
|
and date_format(o.serve_time,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d')
|
|
</if>
|
|
</if>
|
|
<if test="type==4">
|
|
and o.status in (2,3,4,5,6,7,8)
|
|
and o.pay_time is not null
|
|
<if test="startTime!=null and startTime!=''">
|
|
and date_format(o.serve_time,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="endTime!=null and endTime!=''">
|
|
and date_format(o.serve_time,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d')
|
|
</if>
|
|
</if>
|
|
<if test="type==5">
|
|
and date_format(o.serve_time,'%Y-%m-%d') = date_format(now(),'%Y-%m-%d') and o.status=2
|
|
</if>
|
|
union all
|
|
select o.*,
|
|
(case when o.user_package_detail_id is null then m.title else bl.title end ) as title,
|
|
(case when o.user_package_detail_id is null then m.massage_img else bl.massage_img end ) as massageImg,
|
|
now() > DATE_ADD(STR_TO_DATE(o.serve_time, '%Y-%m-%d %H:%i'), INTERVAL #{minutes} MINUTE) as is_can_supplement,
|
|
o.artificer_money + ifnull(o.add_artificer_money,0) as artificer_money_total
|
|
from orders o
|
|
left join orders_massage om on om.orders_id=o.orders_id
|
|
left join massage_type m on m.massage_type_id=om.massage_id
|
|
LEFT JOIN bl_user_package_detail bl ON bl.id = om.massage_id
|
|
where o.artificer_id = #{artificerId}
|
|
and o.parent_id = 0
|
|
and o.old_orders_id is null
|
|
and o.orders_id not in (
|
|
select orders_id from orders
|
|
where old_orders_id is not null
|
|
and pay_time is not null
|
|
)
|
|
and o.orders_id not in (
|
|
select old_orders_id from orders
|
|
where old_orders_id is not null
|
|
and pay_time is not null
|
|
)
|
|
<if test="type==1">
|
|
and date_format(o.serve_time,'%Y-%m-%d %H:%i') >= date_format(DATE_ADD(now(), INTERVAL -12 HOUR),'%Y-%m-%d %H:%i')
|
|
and date_format(o.serve_time,'%Y-%m-%d %H:%i') <= date_format(DATE_ADD(now(), INTERVAL 24 HOUR),'%Y-%m-%d %H:%i')
|
|
and o.status in (2,3,4,5,6,7,8,9)
|
|
and o.pay_time is not null
|
|
</if>
|
|
<if test="type==2">
|
|
and o.status in (2,6,7,8,9)
|
|
and o.pay_time is not null
|
|
<if test="startTime!=null and startTime!=''">
|
|
and date_format(o.serve_time,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="endTime!=null and endTime!=''">
|
|
and date_format(o.serve_time,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d')
|
|
</if>
|
|
</if>
|
|
<if test="type==3">
|
|
and o.status in (3,5)
|
|
<if test="startTime!=null and startTime!=''">
|
|
and date_format(o.serve_time,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="endTime!=null and endTime!=''">
|
|
and date_format(o.serve_time,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d')
|
|
</if>
|
|
</if>
|
|
<if test="type==4">
|
|
and o.status in (2,3,4,5,6,7,8,9)
|
|
and o.pay_time is not null
|
|
<if test="startTime!=null and startTime!=''">
|
|
and date_format(o.serve_time,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="endTime!=null and endTime!=''">
|
|
and date_format(o.serve_time,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d')
|
|
</if>
|
|
</if>
|
|
<if test="type==5">
|
|
and date_format(o.serve_time,'%Y-%m-%d') = date_format(now(),'%Y-%m-%d') and o.status=2
|
|
</if>
|
|
order by serve_time desc, orders_id desc
|
|
</select>
|
|
|
|
<select id="selectDividedIntoDetails" resultType="com.sqx.modules.artificer.entity.Orders">
|
|
select o.*,
|
|
o.price + ifnull(o.add_price,0) as price_total,
|
|
(case when o.user_package_detail_id is null then m.title else bl.title end ) as title,
|
|
(case when o.user_package_detail_id is null then m.massage_img else bl.massage_img end ) as massageImg,
|
|
(case when o.status = 4
|
|
then o.artificer_money + ifnull(o.add_artificer_money,0)
|
|
else o.artificer_money + ifnull(o.add_artificer_money,0) + ifnull(o2.artificer_money,0) + ifnull(o2.add_artificer_money,0) + ifnull(o3.artificer_money,0) + ifnull(o3.add_artificer_money,0)
|
|
end) as artificer_money_total
|
|
from orders o
|
|
left join orders o2 on o.old_orders_id = o2.orders_id and o2.status != 4
|
|
left join orders o3 on o2.old_orders_id = o3.orders_id and o3.status != 4
|
|
left join orders_massage om on om.orders_id=o.orders_id
|
|
left join massage_type m on m.massage_type_id=om.massage_id
|
|
LEFT JOIN bl_user_package_detail bl ON bl.id = om.massage_id
|
|
where o.old_orders_id is not null
|
|
and o.status not in (4,11,15)
|
|
<if test="artificerId!=null and artificerId!=''">
|
|
and o.artificer_id = #{artificerId}
|
|
</if>
|
|
<if test="startTime!=null and startTime!=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') >= #{startTime}
|
|
</if>
|
|
<if test="endTime!=null and endTime!=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') <= #{endTime}
|
|
</if>
|
|
<if test="isSfwc != null and isSfwc == 0">
|
|
and ifnull(o.add_num,0) = 0
|
|
</if>
|
|
<if test="isSfwc != null and isSfwc == 1">
|
|
and o.add_num > 0
|
|
</if>
|
|
and o.status in (3,5)
|
|
union all
|
|
select o.*,
|
|
o.price + ifnull(o.add_price,0) as price_total,
|
|
(case when o.user_package_detail_id is null then m.title else bl.title end ) as title,
|
|
(case when o.user_package_detail_id is null then m.massage_img else bl.massage_img end ) as massageImg,
|
|
o.artificer_money + ifnull(o.add_artificer_money,0) as artificer_money_total
|
|
from orders o
|
|
left join orders_massage om on om.orders_id=o.orders_id
|
|
left join massage_type m on m.massage_type_id=om.massage_id
|
|
LEFT JOIN bl_user_package_detail bl ON bl.id = om.massage_id
|
|
where o.artificer_id = #{artificerId}
|
|
and o.parent_id = 0
|
|
and o.old_orders_id is null
|
|
and o.orders_id not in (
|
|
select orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
)
|
|
and o.orders_id not in (
|
|
select old_orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
)
|
|
<if test="startTime!=null and startTime!=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') >= #{startTime}
|
|
</if>
|
|
<if test="endTime!=null and endTime!=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') <= #{endTime}
|
|
</if>
|
|
<if test="isSfwc != null and isSfwc == 0">
|
|
and ifnull(o.add_num,0) = 0
|
|
</if>
|
|
<if test="isSfwc != null and isSfwc == 1">
|
|
and o.add_num > 0
|
|
</if>
|
|
and o.status in (3,5)
|
|
order by serve_time desc
|
|
</select>
|
|
|
|
<select id="selectArtificerOrder" resultType="com.sqx.modules.artificer.entity.Orders">
|
|
select o.*,a.artificer_name as artificerName,a.artificer_img as artificerImg,a.user_id as artificerUserId
|
|
from orders o
|
|
left join artificer a on a.artificer_id=o.artificer_id
|
|
left join tb_user u on u.user_id=o.user_id
|
|
where o.parent_id = 0
|
|
<if test="userId!=null">
|
|
and o.artificer_id=#{userId}
|
|
</if>
|
|
<if test="status!=null and status!=0">
|
|
and o.status=#{status}
|
|
</if>
|
|
<if test="status==null or status==0">
|
|
and o.status!=1
|
|
</if>
|
|
order by o.create_time desc
|
|
</select>
|
|
|
|
<select id="selectOrdersCountByUnderway" resultType="int">
|
|
select count(*) from orders where status=2 and artificer_id=#{artificerId}
|
|
</select>
|
|
|
|
|
|
<select id="selectTeamOrdersList" resultType="Map">
|
|
select o.*,a.artificer_name as artificerName,a.artificer_img as artificerImg,a.user_id as artificerUserId
|
|
from orders o
|
|
left join artificer a on a.artificer_id=o.artificer_id
|
|
left join tb_user u on u.user_id=o.user_id
|
|
where 1=1
|
|
<if test="status!=null and status!=0">
|
|
and o.status=#{status}
|
|
</if>
|
|
<if test="type==1">
|
|
and o.one_user_id=#{userId}
|
|
</if>
|
|
<if test="type==2">
|
|
and o.one_artificer_user_id=#{userId}
|
|
</if>
|
|
order by o.create_time desc
|
|
</select>
|
|
|
|
<select id="selectOrdersMoneyCountByUserId" resultType="Double">
|
|
select
|
|
<if test="type==1">
|
|
ifnull(sum(one_user_money),0.00)
|
|
</if>
|
|
<if test="type==2">
|
|
ifnull(sum(one_artificer_money),0.00)
|
|
</if>
|
|
from orders
|
|
where status in (3,5)
|
|
<if test="type==1">
|
|
and one_user_id=#{userId}
|
|
</if>
|
|
<if test="type==2">
|
|
and one_artificer_user_id=#{userId}
|
|
</if>
|
|
<if test="time!=null">
|
|
and end_time like concat('%',#{time},'%')
|
|
</if>
|
|
</select>
|
|
|
|
<select id="selectUserCountByInvitationCode" resultType="Integer">
|
|
select count(*) from tb_user
|
|
where
|
|
<if test="type==1">
|
|
inviter_code=#{invitationCode}
|
|
</if>
|
|
<if test="type==2">
|
|
inviter_code=#{invitationCode} and is_authentication=2
|
|
</if>
|
|
</select>
|
|
|
|
<select id="selectTeamUserList" resultType="Map">
|
|
select * from (
|
|
select u.user_id as userId,u.user_name as userName,u.avatar,u.create_time as createTime,
|
|
<if test="type==1">
|
|
(select ifnull(sum(o.one_user_money),0.00) from orders o where
|
|
o.user_id = u.user_id and o.status in (3,5) and one_user_id=#{userId} ) as money
|
|
</if>
|
|
<if test="type==2">
|
|
(select ifnull(sum(o.one_artificer_money),0.00) from orders o where
|
|
o.artificer_id = (select artificer_id from artificer a where a.user_id=u.user_id) and o.status in (3,5) and one_artificer_user_id=#{userId} ) as money
|
|
</if>
|
|
from tb_user u
|
|
where
|
|
<if test="type==1">
|
|
u.inviter_code=#{invitationCode}
|
|
</if>
|
|
<if test="type==2">
|
|
u.inviter_code=#{invitationCode} and u.is_authentication=2
|
|
</if>
|
|
) a order by money desc
|
|
</select>
|
|
|
|
<select id="selectOrdersByEndTime" resultType="com.sqx.modules.artificer.entity.Orders">
|
|
select * from orders where DATE_SUB( end_time, INTERVAL #{minute} MINUTE )<=now() and status=6 and is_send is null
|
|
</select>
|
|
|
|
<select id="selectOrdersCountStatisticsByYear" resultType="Integer">
|
|
select count(*) from orders
|
|
where 1=1
|
|
<if test="status!=null and status!=0">
|
|
and status=#{status}
|
|
</if>
|
|
<if test="flag!=null and flag==1">
|
|
and date_format(create_time,'%Y-%m-%d')=date_format(#{time},'%Y-%m-%d')
|
|
</if>
|
|
<if test="flag!=null and flag==2">
|
|
and date_format(create_time,'%Y-%m')=date_format(#{time},'%Y-%m')
|
|
</if>
|
|
<if test="flag!=null and flag==3">
|
|
and date_format(create_time,'%Y')=date_format(#{time},'%Y')
|
|
</if>
|
|
</select>
|
|
|
|
<select id="selectArtificerOrdersList" resultType="com.sqx.modules.artificer.entity.Orders">
|
|
select o.*,a.artificer_name as artificerName,u.phone as artificerPhone,a.address as artificerAddress,
|
|
a.longitude as artificerLongitude,a.latitude as artificerLatitude
|
|
from orders o
|
|
left join artificer a on a.artificer_id=o.artificer_id
|
|
left join tb_user u on u.user_id=a.user_id
|
|
where o.status in (6,7,8)
|
|
<if test="artificerName!=null and artificerName!=''">
|
|
and a.artificer_name like concat('%',#{artificerName},'%')
|
|
</if>
|
|
<if test="artificerPhone!=null and artificerPhone!=''">
|
|
and u.phone = #{artificerPhone}
|
|
</if>
|
|
<if test="userName!=null and userName!=''">
|
|
and o.user_name like concat('%',#{userName},'%')
|
|
</if>
|
|
<if test="phone!=null and phone!=''">
|
|
and o.phone = #{phone}
|
|
</if>
|
|
<if test="overTimeOrders!=null and overTimeOrders!=0">
|
|
and o.over_time_orders=#{overTimeOrders}
|
|
</if>
|
|
<if test="warning!=null and warning==1">
|
|
and o.warning = #{warning}
|
|
</if>
|
|
<if test="warning!=null and warning==2">
|
|
and o.warning = null
|
|
</if>
|
|
order by o.warning=1 desc,o.create_time desc
|
|
</select>
|
|
|
|
<update id="updateOrdersWarning">
|
|
update orders set warning=1 where now()>= DATE_ADD( end_time, INTERVAL #{time} MINUTE ) and status=6 and warning is null
|
|
</update>
|
|
|
|
<select id="selectOrdersStatusByTime" resultType="com.sqx.modules.artificer.entity.Orders">
|
|
select * from orders where now()>= DATE_ADD( create_time, INTERVAL #{time} MINUTE ) and status=1
|
|
</select>
|
|
|
|
<select id="selectNotAcceptedOrders" resultType="com.sqx.modules.artificer.entity.Orders">
|
|
select * from orders where now()>= DATE_ADD( serve_time, INTERVAL #{time} MINUTE ) and status in (2,9)
|
|
</select>
|
|
|
|
<select id="selectShopMoney" resultType="Map">
|
|
select ifnull(sum(o.shop_money),0.00) as money,o.shop_user_name as userName,o.shop_user_id as userId
|
|
from orders o
|
|
left join tb_user u on u.user_id=o.shop_user_id
|
|
where u.user_id is not null
|
|
<if test="userName!=null and userName!=''">
|
|
and o.shop_user_name like concat('%',#{userName},'%')
|
|
</if>
|
|
<if test="phone!=null and phone!=''">
|
|
and u.phone like concat('%',#{phone},'%')
|
|
</if>
|
|
<if test="flag!=null and flag==1">
|
|
and date_format(o.create_time,'%Y-%m-%d')=date_format(#{time},'%Y-%m-%d')
|
|
</if>
|
|
<if test="flag!=null and flag==2">
|
|
and date_format(o.create_time,'%Y-%m')=date_format(#{time},'%Y-%m')
|
|
</if>
|
|
<if test="flag!=null and flag==3">
|
|
and date_format(o.create_time,'%Y')=date_format(#{time},'%Y')
|
|
</if>
|
|
group by o.shop_user_id
|
|
order by money desc
|
|
</select>
|
|
|
|
<select id="selectOneUserMoney" resultType="Map">
|
|
select ifnull(sum(o.one_user_money),0.00) as money,o.one_user_name as userName,o.one_user_id as userId
|
|
from orders o
|
|
left join tb_user u on u.user_id=o.one_user_id
|
|
where u.user_id is not null
|
|
<if test="userName!=null and userName!=''">
|
|
and o.one_user_name like concat('%',#{userName},'%')
|
|
</if>
|
|
<if test="phone!=null and phone!=''">
|
|
and u.phone like concat('%',#{phone},'%')
|
|
</if>
|
|
<if test="flag!=null and flag==1">
|
|
and date_format(o.create_time,'%Y-%m-%d')=date_format(#{time},'%Y-%m-%d')
|
|
</if>
|
|
<if test="flag!=null and flag==2">
|
|
and date_format(o.create_time,'%Y-%m')=date_format(#{time},'%Y-%m')
|
|
</if>
|
|
<if test="flag!=null and flag==3">
|
|
and date_format(o.create_time,'%Y')=date_format(#{time},'%Y')
|
|
</if>
|
|
group by o.one_user_id
|
|
order by money desc
|
|
</select>
|
|
|
|
<select id="selectOneArtificerMoney" resultType="Map">
|
|
select ifnull(sum(o.one_artificer_money),0.00) as money,o.one_artificer_user_name as userName,o.one_artificer_user_id as userId
|
|
from orders o
|
|
left join tb_user u on u.user_id=o.one_artificer_user_id
|
|
where u.user_id is not null
|
|
<if test="userName!=null and userName!=''">
|
|
and o.one_artificer_user_name like concat('%',#{userName},'%')
|
|
</if>
|
|
<if test="phone!=null and phone!=''">
|
|
and u.phone like concat('%',#{phone},'%')
|
|
</if>
|
|
<if test="flag!=null and flag==1">
|
|
and date_format(o.create_time,'%Y-%m-%d')=date_format(#{time},'%Y-%m-%d')
|
|
</if>
|
|
<if test="flag!=null and flag==2">
|
|
and date_format(o.create_time,'%Y-%m')=date_format(#{time},'%Y-%m')
|
|
</if>
|
|
<if test="flag!=null and flag==3">
|
|
and date_format(o.create_time,'%Y')=date_format(#{time},'%Y')
|
|
</if>
|
|
group by o.one_artificer_user_id
|
|
order by money desc
|
|
</select>
|
|
|
|
<select id="selectArtificerMoney" resultType="Map">
|
|
select ifnull(sum(o.sum_artificer_money),0.00) as money,a.artificer_name as userName,a.user_id as userId
|
|
from orders o
|
|
left join artificer a on a.artificer_id=o.artificer_id
|
|
left join tb_user u on u.user_id=a.user_id
|
|
where u.user_id is not null
|
|
<if test="userName!=null and userName!=''">
|
|
and o.artificer_name like concat('%',#{userName},'%')
|
|
</if>
|
|
<if test="phone!=null and phone!=''">
|
|
and u.phone like concat('%',#{phone},'%')
|
|
</if>
|
|
<if test="flag!=null and flag==1">
|
|
and date_format(o.create_time,'%Y-%m-%d')=date_format(#{time},'%Y-%m-%d')
|
|
</if>
|
|
<if test="flag!=null and flag==2">
|
|
and date_format(o.create_time,'%Y-%m')=date_format(#{time},'%Y-%m')
|
|
</if>
|
|
<if test="flag!=null and flag==3">
|
|
and date_format(o.create_time,'%Y')=date_format(#{time},'%Y')
|
|
</if>
|
|
group by o.one_artificer_user_id
|
|
order by money desc
|
|
</select>
|
|
|
|
<select id="selectNewUserOrdersCount" resultType="Map">
|
|
select u.user_id as userId,u.user_name as userName,u.phone,u.create_time as createTime,
|
|
(select count(*) from orders o where o.user_id=u.user_id and status in (3,5)) as counts from tb_user u
|
|
where date_format(DATE_ADD( u.create_time, INTERVAL 7 day ),'%Y-%m-%d')>=date_format(now(),'%Y-%m-%d')
|
|
<if test="userName!=null and userName!=''">
|
|
and u.user_name like concat('%',#{userName},'%')
|
|
</if>
|
|
<if test="phone!=null and phone!=''">
|
|
and u.phone like concat('%',#{phone},'%')
|
|
</if>
|
|
order by counts
|
|
</select>
|
|
|
|
<select id="selectNewUserOrdersRate" resultType="Double">
|
|
select counts / userCount
|
|
from (SELECT count(*) AS userCount,
|
|
sum((
|
|
SELECT count(*)
|
|
FROM orders o
|
|
WHERE o.user_id = u.user_id
|
|
AND STATUS IN (3, 5))) AS counts
|
|
FROM tb_user u
|
|
WHERE date_format(DATE_ADD(u.create_time, INTERVAL 7 DAY ), '%Y-%m-%d') >= date_format(now(),'%Y-%m-%d')) a
|
|
</select>
|
|
<!--当期业绩-->
|
|
<select id="selectOrdersArtificerIntegralAchievement" resultType="java.lang.Integer">
|
|
select IFNULL(SUM(price_total),0) AS currentAchievement
|
|
from (
|
|
select o.*,
|
|
(
|
|
(case when o.is_supplement in (1,3,4) then 0 else o.price end) + ifnull(o.add_price,0)
|
|
+ ifnull((case when o2.is_supplement in (1,3,4) then 0 else o2.price end),0) + ifnull(o2.add_price,0)
|
|
+ ifnull((case when o3.is_supplement in (1,3,4) then 0 else o3.price end),0) + ifnull(o3.add_price,0)
|
|
) as price_total
|
|
from orders o
|
|
left join orders o2 on o.old_orders_id = o2.orders_id and o2.status != 4
|
|
left join orders o3 on o2.old_orders_id = o3.orders_id and o3.status != 4
|
|
left join orders_massage om on om.orders_id=o.orders_id
|
|
left join massage_type m on m.massage_type_id=om.massage_id
|
|
LEFT JOIN bl_user_package_detail bl ON bl.id = om.massage_id
|
|
where o.artificer_id = #{artificerId}
|
|
and o.old_orders_id is not null
|
|
and o.status not in (4,11,15)
|
|
<if test="startDate!=null and startDate !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') >= #{startDate}
|
|
</if>
|
|
<if test="endDate!=null and endDate !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') <= #{endDate}
|
|
</if>
|
|
and o.status in (3,5)
|
|
union all
|
|
select o.*,
|
|
o.price + ifnull(o.add_price,0) as price_total
|
|
from orders o
|
|
left join orders_massage om on om.orders_id=o.orders_id
|
|
where o.artificer_id = #{artificerId}
|
|
and o.parent_id = 0
|
|
and o.old_orders_id is null
|
|
and o.orders_id not in (
|
|
select orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
)
|
|
and o.orders_id not in (
|
|
select old_orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
)
|
|
<if test="startDate!=null and startDate !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') >= #{startDate}
|
|
</if>
|
|
<if test="endDate!=null and endDate !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') <= #{endDate}
|
|
</if>
|
|
and o.status in (3,5)
|
|
) t
|
|
</select>
|
|
<!--当期收益-->
|
|
<select id="selectOrdersArtificerIntegralEarnings" resultType="java.math.BigDecimal">
|
|
select IFNULL(SUM(artificer_money_total),0) AS currentEarnings
|
|
from (
|
|
select (case when o.status = 4
|
|
then o.artificer_money + ifnull(o.add_artificer_money,0)
|
|
else o.artificer_money + ifnull(o.add_artificer_money,0) + ifnull(o2.artificer_money,0) + ifnull(o2.add_artificer_money,0) + ifnull(o3.artificer_money,0) + ifnull(o3.add_artificer_money,0)
|
|
end) as artificer_money_total
|
|
from orders o
|
|
left join orders o2 on o.old_orders_id = o2.orders_id and o2.status != 4
|
|
left join orders o3 on o2.old_orders_id = o3.orders_id and o3.status != 4
|
|
where o.artificer_id = #{artificerId}
|
|
and o.old_orders_id is not null
|
|
and o.status not in (4,11,15)
|
|
<if test="startDate!=null and startDate !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') >= #{startDate}
|
|
</if>
|
|
<if test="endDate!=null and endDate !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') <= #{endDate}
|
|
</if>
|
|
and o.status in (3,5)
|
|
union all
|
|
select o.artificer_money + ifnull(o.add_artificer_money,0) as artificer_money_total
|
|
from orders o
|
|
where o.artificer_id = #{artificerId}
|
|
and o.parent_id = 0
|
|
and o.old_orders_id is null
|
|
and o.orders_id not in (
|
|
select orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
)
|
|
and o.orders_id not in (
|
|
select old_orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
)
|
|
<if test="startDate!=null and startDate !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') >= #{startDate}
|
|
</if>
|
|
<if test="endDate!=null and endDate !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') <= #{endDate}
|
|
</if>
|
|
and o.status in (3,5)
|
|
) t
|
|
</select>
|
|
<!--当期项目收益-->
|
|
<select id="selectOrdersArtificerIntegralProjectEarnings" resultType="java.math.BigDecimal">
|
|
select IFNULL(SUM(project_benefits_total),0) AS projectBenefits
|
|
from (
|
|
select
|
|
ifnull(o.project_benefits,0) + ifnull(o.add_project_benefits,0) - ifnull(o.shop_money,0) - ifnull(o.one_artificer_money,0)
|
|
+ ifnull(o2.project_benefits,0) + ifnull(o2.add_project_benefits,0) - ifnull(o2.shop_money,0) - ifnull(o2.one_artificer_money,0)
|
|
+ ifnull(o3.project_benefits,0) + ifnull(o3.add_project_benefits,0) - ifnull(o3.shop_money,0) - ifnull(o3.one_artificer_money,0)
|
|
as project_benefits_total
|
|
from orders o
|
|
left join orders o2 on o.old_orders_id = o2.orders_id and o2.status != 4
|
|
left join orders o3 on o2.old_orders_id = o3.orders_id and o3.status != 4
|
|
where o.artificer_id = #{artificerId}
|
|
and o.old_orders_id is not null
|
|
and o.status not in (4,11,15)
|
|
<if test="startDate!=null and startDate !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') >= #{startDate}
|
|
</if>
|
|
<if test="endDate!=null and endDate !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') <= #{endDate}
|
|
</if>
|
|
and o.status in (3,5)
|
|
union all
|
|
select ifnull(o.project_benefits,0) + ifnull(o.add_project_benefits,0) - ifnull(o.shop_money,0) - ifnull(o.one_artificer_money,0) as project_benefits_total
|
|
from orders o
|
|
where o.artificer_id = #{artificerId}
|
|
and o.parent_id = 0
|
|
and o.old_orders_id is null
|
|
and o.orders_id not in (
|
|
select orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
)
|
|
and o.orders_id not in (
|
|
select old_orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
)
|
|
<if test="startDate!=null and startDate !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') >= #{startDate}
|
|
</if>
|
|
<if test="endDate!=null and endDate !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') <= #{endDate}
|
|
</if>
|
|
and o.status in (3,5)
|
|
) t
|
|
</select>
|
|
<!-- 订单数-->
|
|
<select id="selectOrdersArtificerIntegral" resultType="java.lang.String">
|
|
select IFNULL( count(*),'0') AS currentPeriodOrdersSum
|
|
from (
|
|
select (case when o.status = 4
|
|
then o.artificer_money + ifnull(o.add_artificer_money,0)
|
|
else o.artificer_money + ifnull(o.add_artificer_money,0) + ifnull(o2.artificer_money,0) + ifnull(o2.add_artificer_money,0) + ifnull(o3.artificer_money,0) + ifnull(o3.add_artificer_money,0)
|
|
end) as artificer_money_total
|
|
from orders o
|
|
left join orders o2 on o.old_orders_id = o2.orders_id and o2.status != 4
|
|
left join orders o3 on o2.old_orders_id = o3.orders_id and o3.status != 4
|
|
where o.artificer_id = #{artificerId}
|
|
and o.old_orders_id is not null
|
|
and o.status not in (4,11,15)
|
|
<if test="startDate!=null and startDate !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d') >= date_format(#{startDate},'%Y-%m-%d')
|
|
</if>
|
|
<if test="endDate!=null and endDate !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d') <= date_format(#{endDate},'%Y-%m-%d')
|
|
</if>
|
|
and o.status in (3,5)
|
|
union all
|
|
select o.artificer_money + ifnull(o.add_artificer_money,0) as artificer_money_total
|
|
from orders o
|
|
where o.artificer_id = #{artificerId}
|
|
and o.parent_id = 0
|
|
and o.old_orders_id is null
|
|
and o.orders_id not in (
|
|
select orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
)
|
|
and o.orders_id not in (
|
|
select old_orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
)
|
|
<if test="startDate!=null and startDate !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d') >= date_format(#{startDate},'%Y-%m-%d')
|
|
</if>
|
|
<if test="endDate!=null and endDate !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d') <= date_format(#{endDate},'%Y-%m-%d')
|
|
</if>
|
|
and o.status in (3,5)
|
|
) t
|
|
</select>
|
|
<!-- 加钟率-->
|
|
<select id="selectOrdersArtificerIntegraladdNum" resultType="java.lang.String">
|
|
select IFNULL(count(*),0) AS currentPeriodAddBellsSum
|
|
from (
|
|
select o.*
|
|
from orders o
|
|
left join orders o2 on o.old_orders_id = o2.orders_id and o2.status != 4
|
|
left join orders o3 on o2.old_orders_id = o3.orders_id and o3.status != 4
|
|
where o.artificer_id = #{artificerId}
|
|
and o.old_orders_id is not null
|
|
and o.status not in (4,11,15)
|
|
and o.add_num > 0
|
|
<if test="startDate!=null and startDate !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') >= #{startDate}
|
|
</if>
|
|
<if test="endDate!=null and endDate !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') <= #{endDate}
|
|
</if>
|
|
and o.status in (3,5)
|
|
union all
|
|
select o.*
|
|
from orders o
|
|
where o.artificer_id = #{artificerId}
|
|
and o.parent_id = 0
|
|
and o.old_orders_id is null
|
|
and o.orders_id not in (
|
|
select orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
)
|
|
and o.orders_id not in (
|
|
select old_orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
)
|
|
and o.add_num > 0
|
|
<if test="startDate!=null and startDate !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') >= #{startDate}
|
|
</if>
|
|
<if test="endDate!=null and endDate !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') <= #{endDate}
|
|
</if>
|
|
and o.status in (3,5)
|
|
) t
|
|
</select>
|
|
<!-- 加钟金额-->
|
|
<select id="selectOrdersArtificerAddMoney" resultType="java.math.BigDecimal">
|
|
select
|
|
IFNULL(SUM(artificer_money),0) AS currentPeriodAddMoneySum
|
|
from (
|
|
select o.*
|
|
from orders o
|
|
left join orders o2 on o.old_orders_id = o2.orders_id and o2.status != 4
|
|
left join orders o3 on o2.old_orders_id = o3.orders_id and o3.status != 4
|
|
where o.artificer_id = #{artificerId}
|
|
and o.old_orders_id is not null
|
|
and o.status not in (4,11,15)
|
|
and o.add_num > 0
|
|
<if test="startDate!=null and startDate !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') >= #{startDate}
|
|
</if>
|
|
<if test="endDate!=null and endDate !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') <= #{endDate}
|
|
</if>
|
|
and o.status in (3,5)
|
|
union all
|
|
select o.*
|
|
from orders o
|
|
where o.artificer_id = #{artificerId}
|
|
and o.parent_id = 0
|
|
and o.old_orders_id is null
|
|
and o.orders_id not in (
|
|
select orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
)
|
|
and o.orders_id not in (
|
|
select old_orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
)
|
|
and o.add_num > 0
|
|
<if test="startDate!=null and startDate !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') >= #{startDate}
|
|
</if>
|
|
<if test="endDate!=null and endDate !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') <= #{endDate}
|
|
</if>
|
|
and o.status in (3,5)
|
|
) t
|
|
</select>
|
|
<!-- 充值率-->
|
|
<select id="selectOrdersCurrentPeriodRechargeSum" resultType="java.lang.String">
|
|
select IFNULL( count(*),'0') AS currentPeriodRechargeSum
|
|
from (
|
|
select o.*,
|
|
(case when o.user_package_detail_id is null then m.title else bl.title end ) as title,
|
|
(case when o.user_package_detail_id is null then m.massage_img else bl.massage_img end ) as massageImg,
|
|
(case when o.status = 4
|
|
then o.artificer_money + ifnull(o.add_artificer_money,0)
|
|
else o.artificer_money + ifnull(o.add_artificer_money,0) + ifnull(o2.artificer_money,0) +
|
|
ifnull(o2.add_artificer_money,0) + ifnull(o3.artificer_money,0) + ifnull(o3.add_artificer_money,0)
|
|
end) as artificer_money_total
|
|
from orders o
|
|
left join orders o2 on o.old_orders_id = o2.orders_id and o2.status != 4
|
|
left join orders o3 on o2.old_orders_id = o3.orders_id and o3.status != 4
|
|
left join orders_massage om on om.orders_id=o.orders_id
|
|
left join massage_type m on m.massage_type_id=om.massage_id
|
|
LEFT JOIN bl_user_package_detail bl ON bl.id = om.massage_id
|
|
where o.artificer_id = #{artificerId}
|
|
and o.old_orders_id is not null
|
|
and o.status not in (4,11,15)
|
|
<if test="startDate!=null and startDate !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') >= #{startDate}
|
|
</if>
|
|
<if test="endDate!=null and endDate !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') <= #{endDate}
|
|
</if>
|
|
<if test="isSfwc != null and isSfwc == 0">
|
|
and o.orders_id not in (select distinct orders_id from user_recharge where artificer_id = #{artificerId} and
|
|
type = '2' and orders_id is not null)
|
|
and (
|
|
case when o2.orders_id is not null then
|
|
o2.orders_id not in (select distinct orders_id from user_recharge where artificer_id = #{artificerId} and
|
|
type = '2' and orders_id is not null)
|
|
else 1=1 end)
|
|
and (
|
|
case when o3.orders_id is not null then
|
|
o3.orders_id not in (select distinct orders_id from user_recharge where artificer_id = #{artificerId} and
|
|
type = '2' and orders_id is not null)
|
|
else 1=1 end)
|
|
</if>
|
|
<if test="isSfwc != null and isSfwc == 1">
|
|
and (o.orders_id in (select distinct orders_id from user_recharge where artificer_id = #{artificerId} and
|
|
type = '2' and orders_id is not null)
|
|
or o2.orders_id in (select distinct orders_id from user_recharge where artificer_id = #{artificerId} and
|
|
type = '2' and orders_id is not null)
|
|
or o3.orders_id in (select distinct orders_id from user_recharge where artificer_id = #{artificerId} and
|
|
type = '2' and orders_id is not null)
|
|
)
|
|
</if>
|
|
and o.status in (3,5)
|
|
union all
|
|
select o.*,
|
|
(case when o.user_package_detail_id is null then m.title else bl.title end ) as title,
|
|
(case when o.user_package_detail_id is null then m.massage_img else bl.massage_img end ) as massageImg,
|
|
o.artificer_money + ifnull(o.add_artificer_money,0) as artificer_money_total
|
|
from orders o
|
|
left join orders_massage om on om.orders_id=o.orders_id
|
|
left join massage_type m on m.massage_type_id=om.massage_id
|
|
LEFT JOIN bl_user_package_detail bl ON bl.id = om.massage_id
|
|
where o.artificer_id = #{artificerId}
|
|
and o.parent_id = 0
|
|
and o.old_orders_id is null
|
|
and o.orders_id not in (
|
|
select orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
)
|
|
and o.orders_id not in (
|
|
select old_orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
)
|
|
<if test="startDate!=null and startDate !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') >= #{startDate}
|
|
</if>
|
|
<if test="endDate!=null and endDate !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') <= #{endDate}
|
|
</if>
|
|
<if test="isSfwc != null and isSfwc == 0">
|
|
and o.orders_id not in (select distinct orders_id from user_recharge where artificer_id = #{artificerId} and
|
|
type = '2' and orders_id is not null)
|
|
</if>
|
|
<if test="isSfwc != null and isSfwc == 1">
|
|
and o.orders_id in (select distinct orders_id from user_recharge where artificer_id = #{artificerId} and
|
|
type = '2' and orders_id is not null)
|
|
</if>
|
|
and o.status in (3,5)
|
|
) t
|
|
</select>
|
|
<!-- 充值金额-->
|
|
<select id="selectOrdersRechargeMoney" resultType="java.math.BigDecimal">
|
|
select IFNULL(sum(money),0) AS currentPeriodRechargeMoney
|
|
from user_money_details t
|
|
inner join artificer a on a.user_id=t.user_id
|
|
where t.classify = 4
|
|
and t.state = 2
|
|
<if test="startDate!=null and startDate !=''">
|
|
and date_format(t.create_time,'%Y-%m-%d %H:%i:%s') >= #{startDate}
|
|
</if>
|
|
<if test="endDate!=null and endDate !=''">
|
|
and date_format(t.create_time,'%Y-%m-%d %H:%i:%s') <= #{endDate}
|
|
</if>
|
|
<if test="artificerId!=null and artificerId !=''">
|
|
and a.artificer_id = #{artificerId}
|
|
</if>
|
|
</select>
|
|
<!-- 储值积分数-->
|
|
<select id="selectOrdersStoredValueIntegral" resultType="java.lang.String">
|
|
SELECT
|
|
IFNULL( SUM(user_recharge ),'0') AS storedValueIntegral
|
|
FROM
|
|
user_recharge
|
|
where artificer_id=#{artificerId}
|
|
and create_time BETWEEN #{startDate} and #{endDate}
|
|
and type = 2
|
|
</select>
|
|
<!-- 线积分数-->
|
|
<select id="selectOnlineCredits" resultType="java.lang.String">
|
|
SELECT
|
|
IFNULL( SUM(user_recharge ),'0') AS onlineCredits
|
|
FROM
|
|
user_recharge
|
|
where artificer_id=#{artificerId}
|
|
and create_time BETWEEN #{startDate} and #{endDate}
|
|
and type = 1
|
|
</select>
|
|
<!-- 打车费用-->
|
|
<select id="selectTaxiMoney" resultType="java.lang.String">
|
|
SELECT
|
|
IFNULL( SUM(taxi_money ),'0') AS taxiMoney
|
|
FROM
|
|
orders
|
|
where artificer_id=#{artificerId}
|
|
and create_time BETWEEN #{startDate} and #{endDate}
|
|
</select>
|
|
<!--当期收益-->
|
|
<select id="earnings" resultType="java.lang.String">
|
|
select
|
|
IFNULL( SUM(o.artificer_money ),'0.00') AS currentPerformance
|
|
from orders o
|
|
left join artificer a on a.artificer_id=o.artificer_id
|
|
left join tb_user u on u.user_id=o.user_id
|
|
left join consortia c on c.consortia_id=o.consortia_id
|
|
where o.artificer_id=#{artificerId}
|
|
and o.end_times BETWEEN #{startDate} and #{endDate}
|
|
and o.status in (3,5,15)
|
|
</select>
|
|
<!--在线时长-->
|
|
<select id="selectOrdersZxscNum" resultType="java.lang.String">
|
|
select IFNULL( SUM(user_recharge),0) AS zxsc from bl_user_zxsc
|
|
where artificer_id = #{artificerId}
|
|
<if test="startTime!=null and startTime!=''">
|
|
and create_time >= #{startTime}
|
|
</if>
|
|
<if test="startTime!=null and startTime!=''">
|
|
and create_time <= #{endTime}
|
|
</if>
|
|
|
|
</select>
|
|
|
|
<select id="selectTjpriceList" resultType="java.lang.String">
|
|
select
|
|
IFNULL( SUM(o.price ),'0.00') AS currentPerformance
|
|
from orders o
|
|
where o.artificer_id=#{artificerId}
|
|
and o.end_times BETWEEN #{startTime} and #{endTime}
|
|
and o.status in (3,5,15)
|
|
</select>
|
|
|
|
<select id="getDangqiList" resultType="com.sqx.modules.artificer.entity.Orders">
|
|
select a.*,b.massage_img from orders a
|
|
left join massage_type b on a.massage_type_id = b.massage_type_id
|
|
where a.status in (3,5,15)
|
|
and a.artificer_id = ${userId}
|
|
and a.end_times BETWEEN #{startTime} and #{endTime} and a.parent_id = 0
|
|
order by serve_time desc
|
|
</select>
|
|
|
|
<select id="getJiazhongList" resultType="com.sqx.modules.artificer.entity.Orders">
|
|
select a.*,b.massage_img from orders a
|
|
left join massage_type b on a.massage_type_id = b.massage_type_id
|
|
where a.status in (3,5,15)
|
|
and a.artificer_id = ${userId}
|
|
and a.end_times BETWEEN #{startTime} and #{endTime} and a.parent_id = 0
|
|
<if test="isSfwc != null and isSfwc == 0">
|
|
and (a.add_num = 0 or a.add_num is null)
|
|
</if>
|
|
<if test="isSfwc != null and isSfwc == 1">
|
|
and a.add_num > 0
|
|
</if>
|
|
</select>
|
|
|
|
<select id="getChongzhiList" resultType="com.sqx.modules.artificer.entity.Orders">
|
|
select o.*,
|
|
(case when o.user_package_detail_id is null then m.title else bl.title end ) as title,
|
|
(case when o.user_package_detail_id is null then m.massage_img else bl.massage_img end ) as massageImg,
|
|
(
|
|
(case when o.is_supplement in (1,3,4) then 0 else o.price end) + ifnull(o.add_price,0)
|
|
+ ifnull((case when o2.is_supplement in (1,3,4) then 0 else o2.price end),0) + ifnull(o2.add_price,0)
|
|
+ ifnull((case when o3.is_supplement in (1,3,4) then 0 else o3.price end),0) + ifnull(o3.add_price,0)
|
|
) as price_total,
|
|
(case when o.status = 4
|
|
then o.artificer_money + ifnull(o.add_artificer_money,0)
|
|
else o.artificer_money + ifnull(o.add_artificer_money,0) + ifnull(o2.artificer_money,0) + ifnull(o2.add_artificer_money,0) + ifnull(o3.artificer_money,0) + ifnull(o3.add_artificer_money,0)
|
|
end) as artificer_money_total
|
|
from orders o
|
|
left join orders o2 on o.old_orders_id = o2.orders_id and o2.status != 4
|
|
left join orders o3 on o2.old_orders_id = o3.orders_id and o3.status != 4
|
|
left join orders_massage om on om.orders_id=o.orders_id
|
|
left join massage_type m on m.massage_type_id=om.massage_id
|
|
LEFT JOIN bl_user_package_detail bl ON bl.id = om.massage_id
|
|
where o.artificer_id = #{artificerId}
|
|
and o.old_orders_id is not null
|
|
and o.status not in (4,11,15)
|
|
<if test="startTime!=null and startTime!=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') >= #{startTime}
|
|
</if>
|
|
<if test="endTime!=null and endTime!=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') <= #{endTime}
|
|
</if>
|
|
<if test="isSfwc != null and isSfwc == 0">
|
|
and o.orders_id not in (select distinct orders_id from user_recharge where artificer_id = #{artificerId} and type = '2' and orders_id is not null)
|
|
and (
|
|
case when o2.orders_id is not null then
|
|
o2.orders_id not in (select distinct orders_id from user_recharge where artificer_id = #{artificerId} and type = '2' and orders_id is not null)
|
|
else 1=1 end)
|
|
and (
|
|
case when o3.orders_id is not null then
|
|
o3.orders_id not in (select distinct orders_id from user_recharge where artificer_id = #{artificerId} and type = '2' and orders_id is not null)
|
|
else 1=1 end)
|
|
</if>
|
|
<if test="isSfwc != null and isSfwc == 1">
|
|
and (o.orders_id in (select distinct orders_id from user_recharge where artificer_id = #{artificerId} and type = '2' and orders_id is not null)
|
|
or o2.orders_id in (select distinct orders_id from user_recharge where artificer_id = #{artificerId} and type = '2' and orders_id is not null)
|
|
or o3.orders_id in (select distinct orders_id from user_recharge where artificer_id = #{artificerId} and type = '2' and orders_id is not null)
|
|
)
|
|
</if>
|
|
and o.status in (3,5)
|
|
union all
|
|
select o.*,
|
|
(case when o.user_package_detail_id is null then m.title else bl.title end ) as title,
|
|
(case when o.user_package_detail_id is null then m.massage_img else bl.massage_img end ) as massageImg,
|
|
o.price + ifnull(o.add_price,0) as price_total,
|
|
o.artificer_money + ifnull(o.add_artificer_money,0) as artificer_money_total
|
|
from orders o
|
|
left join orders_massage om on om.orders_id=o.orders_id
|
|
left join massage_type m on m.massage_type_id=om.massage_id
|
|
LEFT JOIN bl_user_package_detail bl ON bl.id = om.massage_id
|
|
where o.artificer_id = #{artificerId}
|
|
and o.parent_id = 0
|
|
and o.old_orders_id is null
|
|
and o.orders_id not in (
|
|
select orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
)
|
|
and o.orders_id not in (
|
|
select old_orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
)
|
|
<if test="startTime!=null and startTime!=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') >= #{startTime}
|
|
</if>
|
|
<if test="endTime!=null and endTime!=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') <= #{endTime}
|
|
</if>
|
|
<if test="isSfwc != null and isSfwc == 0">
|
|
and o.orders_id not in (select distinct orders_id from user_recharge where artificer_id = #{artificerId} and type = '2' and orders_id is not null)
|
|
</if>
|
|
<if test="isSfwc != null and isSfwc == 1">
|
|
and o.orders_id in (select distinct orders_id from user_recharge where artificer_id = #{artificerId} and type = '2' and orders_id is not null)
|
|
</if>
|
|
and o.status in (3,5)
|
|
order by serve_time desc
|
|
</select>
|
|
<!-- 获取业绩积分-->
|
|
<select id="getYjjfList" resultType="com.sqx.modules.artificer.entity.Orders">
|
|
select t.*,price_total AS jifen
|
|
from (
|
|
select o.*,
|
|
(case when o.status = 4
|
|
then o.artificer_money + ifnull(o.add_artificer_money,0)
|
|
else o.artificer_money + ifnull(o.add_artificer_money,0) + ifnull(o2.artificer_money,0) +
|
|
ifnull(o2.add_artificer_money,0) + ifnull(o3.artificer_money,0) + ifnull(o3.add_artificer_money,0)
|
|
end) as artificer_money_total,
|
|
o.price + ifnull(o.add_price,0) as price_total,bl.massage_img as massageImg
|
|
from orders o
|
|
left join orders o2 on o.old_orders_id = o2.orders_id and o2.status != 4
|
|
left join orders o3 on o2.old_orders_id = o3.orders_id and o3.status != 4
|
|
left join orders_massage om on om.orders_id=o.orders_id
|
|
left join massage_type m on m.massage_type_id=om.massage_id
|
|
LEFT JOIN bl_user_package_detail bl ON bl.id = om.massage_id
|
|
where o.artificer_id = ${userId}
|
|
and o.old_orders_id is not null
|
|
and o.status not in (4,11,15)
|
|
<if test="startTime!=null and startTime !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') >= #{startTime}
|
|
</if>
|
|
<if test="endTime!=null and endTime !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') <= #{endTime}
|
|
</if>
|
|
and o.status in (3,5)
|
|
union all
|
|
select o.*,
|
|
o.artificer_money + ifnull(o.add_artificer_money,0) as artificer_money_total,
|
|
o.price + ifnull(o.add_price,0) as price_total ,mt.massage_img as messageImg
|
|
from orders o
|
|
left join orders_massage om on om.orders_id=o.orders_id
|
|
left join massage_type mt on o.massage_type_id = mt.massage_type_id
|
|
where o.artificer_id = ${userId}
|
|
and o.parent_id = 0
|
|
and o.old_orders_id is null
|
|
and o.orders_id not in (
|
|
select orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
)
|
|
and o.orders_id not in (
|
|
select old_orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
)
|
|
<if test="startTime!=null and startTime !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') >= #{startTime}
|
|
</if>
|
|
<if test="endTime!=null and endTime !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') <= #{endTime}
|
|
</if>
|
|
and o.status in (3,5)
|
|
) t
|
|
order by t.serve_time desc
|
|
</select>
|
|
<!-- 获取储值积分(为他充值的)-->
|
|
<select id="getCzjfList" resultType="com.sqx.modules.artificer.entity.Orders">
|
|
select id,user_recharge as jifen,create_time as jftime
|
|
from user_recharge
|
|
where type = 2
|
|
and orders_id is null
|
|
and artificer_id = ${userId}
|
|
and create_time BETWEEN #{startTime} and #{endTime}
|
|
</select>
|
|
<!-- 获取订单充值积分-->
|
|
<select id="getDdczList" resultType="com.sqx.modules.artificer.entity.Orders">
|
|
select id,user_recharge as jifen,create_time as jftime
|
|
from user_recharge
|
|
where type = 2
|
|
and orders_id is not null
|
|
and artificer_id =${userId}
|
|
and create_time BETWEEN #{startTime} and #{endTime}
|
|
</select>
|
|
<!-- 获取在线时长积分-->
|
|
<select id="getZxscList" resultType="com.sqx.modules.artificer.entity.Orders">
|
|
select id,sum(user_recharge) as jifen,DATE_FORMAT(create_time,'%Y-%m-%d') as jftime
|
|
from user_recharge
|
|
where type = 1
|
|
and artificer_id =${userId}
|
|
and create_time BETWEEN #{startTime} and #{endTime}
|
|
GROUP BY DATE_FORMAT(create_time,'%Y-%m-%d')
|
|
</select>
|
|
|
|
<select id="getParentOrders" resultType="com.sqx.modules.artificer.entity.Orders">
|
|
select o.*
|
|
from orders o
|
|
where parent_id = #{parentId}
|
|
</select>
|
|
|
|
<select id="getNewOrdersByOld" resultType="com.sqx.modules.artificer.entity.Orders">
|
|
select o.*
|
|
from orders o
|
|
where old_orders_id = #{ordersId}
|
|
</select>
|
|
|
|
<select id="selectSumRefund" resultType="java.math.BigDecimal">
|
|
select IFNULL(SUM(artificer_money),0) AS currentEarnings
|
|
from (
|
|
select o.*
|
|
from orders o
|
|
where o.artificer_id =${artificerId}
|
|
<if test="startTime!=null and startTime!=''">
|
|
and date_format(create_time,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="endTime!=null and endTime!=''">
|
|
and date_format(create_time,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d')
|
|
</if>
|
|
and o.status = 4
|
|
and o.pay_time is not null
|
|
) t
|
|
</select>
|
|
|
|
<select id="selectArtificerMoneyList" resultType="Map">
|
|
select artificerId,artificerName,sum(ddsl) as ddsl,sum(sy) as sy,sum(yj) as yj,sum(zxsc) as zxsc,sum(jzl) as jzl,sum(czl) as czl,sum(jf) as jf
|
|
from (
|
|
select artificerId,artificerName,IFNULL(count(*),0) AS ddsl,IFNULL(sum(artificer_money_total),0) AS sy,IFNULL(SUM(price_total),0) yj,0 zxsc,0 jzl,0 czl,0 jf
|
|
from (
|
|
select a.artificer_id as artificerId,a.artificer_name as artificerName,
|
|
(case when o.status = 4
|
|
then o.artificer_money + ifnull(o.add_artificer_money,0)
|
|
else o.artificer_money + ifnull(o.add_artificer_money,0) + ifnull(o2.artificer_money,0) + ifnull(o2.add_artificer_money,0) + ifnull(o3.artificer_money,0) + ifnull(o3.add_artificer_money,0)
|
|
end) as artificer_money_total,
|
|
((case when o.is_supplement in (1,3,4) then 0 else o.price end) + ifnull(o.add_price,0)
|
|
+ ifnull((case when o2.is_supplement in (1,3,4) then 0 else o2.price end),0) + ifnull(o2.add_price,0)
|
|
+ ifnull((case when o3.is_supplement in (1,3,4) then 0 else o3.price end),0) + ifnull(o3.add_price,0)
|
|
) as price_total
|
|
from artificer a
|
|
inner join tb_user b on a.user_id = b.user_id
|
|
inner join orders o on a.artificer_id = o.artificer_id
|
|
left join orders o2 on o.old_orders_id = o2.orders_id and o2.status != 4
|
|
left join orders o3 on o2.old_orders_id = o3.orders_id and o3.status != 4
|
|
where o.old_orders_id is not null
|
|
and o.status in (3,5)
|
|
<if test="startTime!=null and startTime !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="endTime!=null and endTime !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="status!=null and status==1">
|
|
and b.status = 1
|
|
</if>
|
|
<if test="status!=null and status==2">
|
|
and b.status in (2,3)
|
|
</if>
|
|
union all
|
|
select a.artificer_id as artificerId,a.artificer_name as artificerName,
|
|
o.artificer_money + ifnull(o.add_artificer_money,0) as artificer_money_total,
|
|
o.price + ifnull(o.add_price,0) as price_total
|
|
from artificer a
|
|
inner join tb_user b on a.user_id = b.user_id
|
|
inner join orders o on a.artificer_id = o.artificer_id
|
|
where o.parent_id = 0
|
|
and o.status in (3,5)
|
|
and o.old_orders_id is null
|
|
and o.orders_id not in (
|
|
select orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
)
|
|
and o.orders_id not in (
|
|
select old_orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
)
|
|
<if test="startTime!=null and startTime !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="endTime!=null and endTime !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="status!=null and status==1">
|
|
and b.status = 1
|
|
</if>
|
|
<if test="status!=null and status==2">
|
|
and b.status in (2,3)
|
|
</if>
|
|
) t
|
|
group by artificerId,artificerName
|
|
union all
|
|
select a.artificer_id as artificerId,a.artificer_name as artificerName,0 ddsl,0 sy,0 yj,IFNULL(SUM(user_recharge),0) zxsc,0 jzl,0 czl,0 jf
|
|
from artificer a
|
|
inner join tb_user b on a.user_id = b.user_id
|
|
inner join bl_user_zxsc c on a.artificer_id = c.artificer_id
|
|
<where>
|
|
<if test="startTime!=null and startTime!=''">
|
|
and date_format(c.end_times,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="endTime!=null and endTime!=''">
|
|
and date_format(c.end_times,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="status!=null and status==1">
|
|
and b.status = 1
|
|
</if>
|
|
<if test="status!=null and status==2">
|
|
and b.status in (2,3)
|
|
</if>
|
|
</where>
|
|
group by a.artificer_id,a.artificer_name
|
|
union all
|
|
select a.artificer_id as artificerId,a.artificer_name as artificerName,0 ddsl,0 sy,0 yj,0 zxsc,IFNULL(SUM(artificer_money),0) jzl,0 czl,0 jf
|
|
from artificer a
|
|
inner join tb_user b on a.user_id = b.user_id
|
|
inner join orders o on a.artificer_id = o.artificer_id
|
|
where o.status in (3,5)
|
|
and o.add_num > 0
|
|
<if test="startTime!=null and startTime !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="endTime!=null and endTime !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') <= date_format(#{endTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="status!=null and status==1">
|
|
and b.status = 1
|
|
</if>
|
|
<if test="status!=null and status==2">
|
|
and b.status in (2,3)
|
|
</if>
|
|
group by a.artificer_id,a.artificer_name
|
|
union all
|
|
select a.artificer_id as artificerId,a.artificer_name as artificerName,0 ddsl,0 sy,0 yj,0 zxsc,0 jzl,IFNULL(sum(money),0) AS czl,0 jf
|
|
from artificer a
|
|
inner join tb_user b on a.user_id = b.user_id
|
|
inner join user_money_details c on b.user_id=c.user_id
|
|
where c.classify = 4
|
|
and c.state = 2
|
|
<if test="startTime!=null and startTime !=''">
|
|
and date_format(c.create_time,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="endTime!=null and endTime !=''">
|
|
and date_format(c.create_time,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="status!=null and status==1">
|
|
and b.status = 1
|
|
</if>
|
|
<if test="status!=null and status==2">
|
|
and b.status in (2,3)
|
|
</if>
|
|
group by a.artificer_id,a.artificer_name
|
|
union all
|
|
select a.artificer_id as artificerId,a.artificer_name as artificerName,
|
|
0 ddsl,0 sy,0 yj,0 zxsc,0 jzl,0 AS czl,
|
|
sum(case when c.type = 1 then IFNULL(c.integral,0) else -IFNULL(c.integral,0) end) AS jf
|
|
from artificer a
|
|
inner join tb_user b on a.user_id = b.user_id
|
|
inner join bl_artificer_integral_statistics c on a.artificer_id = c.artificer_id
|
|
<where>
|
|
<if test="startTime!=null and startTime!=''">
|
|
and date_format(c.create_time,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="endTime!=null and endTime!=''">
|
|
and date_format(c.create_time,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="status!=null and status==1">
|
|
and b.status = 1
|
|
</if>
|
|
<if test="status!=null and status==2">
|
|
and b.status in (2,3)
|
|
</if>
|
|
</where>
|
|
group BY a.artificer_id,a.artificer_name
|
|
) tt
|
|
group by artificerId,artificerName
|
|
<if test="by!=null and by==1">
|
|
order by ddsl asc
|
|
</if>
|
|
<if test="by!=null and by==2">
|
|
order by ddsl desc
|
|
</if>
|
|
<if test="by!=null and by==3">
|
|
order by sy asc
|
|
</if>
|
|
<if test="by!=null and by==4">
|
|
order by sy desc
|
|
</if>
|
|
<if test="by!=null and by==5">
|
|
order by yj asc
|
|
</if>
|
|
<if test="by!=null and by==6">
|
|
order by yj desc
|
|
</if>
|
|
<if test="by!=null and by==7">
|
|
order by zxsc asc
|
|
</if>
|
|
<if test="by!=null and by==8">
|
|
order by zxsc desc
|
|
</if>
|
|
<if test="by!=null and by==9">
|
|
order by jzl asc
|
|
</if>
|
|
<if test="by!=null and by==10">
|
|
order by jzl desc
|
|
</if>
|
|
<if test="by!=null and by==11">
|
|
order by czl asc
|
|
</if>
|
|
<if test="by!=null and by==12">
|
|
order by czl desc
|
|
</if>
|
|
<if test="by!=null and by==13">
|
|
order by jf asc
|
|
</if>
|
|
<if test="by!=null and by==14">
|
|
order by jf desc
|
|
</if>
|
|
</select>
|
|
|
|
<select id="getOrdersMoneyById" resultType="com.sqx.modules.artificer.entity.Orders">
|
|
select o.artificer_id,o.orders_no,o.end_times,
|
|
(case when o.status = 4
|
|
then o.artificer_money + ifnull(o.add_artificer_money,0)
|
|
else o.artificer_money + ifnull(o.add_artificer_money,0) + ifnull(o2.artificer_money,0) +
|
|
ifnull(o2.add_artificer_money,0) + ifnull(o3.artificer_money,0) + ifnull(o3.add_artificer_money,0)
|
|
end) as artificer_money_total,
|
|
o.price,m.classify_id,
|
|
ifnull(o.add_price,0) as add_price,bl.classify_id as add_classify_id
|
|
from orders o
|
|
left join orders o2 on o.old_orders_id = o2.orders_id and o2.status != 4
|
|
left join orders o3 on o2.old_orders_id = o3.orders_id and o3.status != 4
|
|
left join massage_type m on m.massage_type_id = o.massage_type_id
|
|
LEFT JOIN massage_type bl ON bl.massage_type_id = o.add_massage_type_id
|
|
where o.orders_id = #{ordersId}
|
|
and o.old_orders_id is not null
|
|
and o.status in (3,5)
|
|
union all
|
|
select o.artificer_id,o.orders_no,o.end_times,
|
|
o.artificer_money + ifnull(o.add_artificer_money,0) as artificer_money_total,
|
|
o.price,m.classify_id,
|
|
ifnull(o.add_price,0) as add_price,bl.classify_id as add_classify_id
|
|
from orders o
|
|
left join massage_type m on m.massage_type_id = o.massage_type_id
|
|
LEFT JOIN massage_type bl ON bl.massage_type_id = o.add_massage_type_id
|
|
where o.orders_id = #{ordersId}
|
|
and o.parent_id = 0
|
|
and o.old_orders_id is null
|
|
and o.orders_id not in (
|
|
select orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
)
|
|
and o.orders_id not in (
|
|
select old_orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
)
|
|
and o.status in (3,5)
|
|
</select>
|
|
|
|
</mapper> |