907 lines
No EOL
32 KiB
XML
907 lines
No EOL
32 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.orders.dao.OrdersDao">
|
|
<select id="selectMyOrder" resultType="com.sqx.modules.orders.response.MyOrderResponse">
|
|
SELECT
|
|
o.orders_id,
|
|
o.money,
|
|
t.service_name as serviceName,
|
|
o.state,
|
|
t.my_level as myLevel,
|
|
t.homepage_img as homepageImg,
|
|
o.province,
|
|
o.city,
|
|
t.is_need_bucket as isNeedBucket,
|
|
o.district,
|
|
o.details_address,
|
|
o.is_update_bucket as isUpdateBucket,
|
|
o.update_time,
|
|
o.order_taking_id,
|
|
u.user_id,
|
|
u.user_name,
|
|
u.avatar,
|
|
o.rate,
|
|
o.zhi_rate as zhiRate,
|
|
o.zhi_user_id as zhiUserId,
|
|
o.fei_user_id as feiUserId,
|
|
o.no_code_finish_img as noCodeFinishImg,
|
|
o.fei_rate as feiRate,
|
|
o.ping_rate as pingRate,
|
|
(select count(*) from taking_commnt c where c.orders_id=o.orders_id and c.user_id=#{userId}) as commentCount,
|
|
t.game_id as gameName,
|
|
o.order_number,
|
|
o.pay_money,
|
|
t.classify,
|
|
t.unit,
|
|
o.code,
|
|
o.start_img,
|
|
o.end_img,
|
|
o.is_shopping as isShopping,
|
|
o.sku_id as skuId,
|
|
o.detail_json as detailJson,
|
|
o.is_transfer as isTransfer,
|
|
o.coupon_id as couponId,
|
|
o.coupon_money as couponMoney,
|
|
o.laundry_id as laundryId,
|
|
o.laundry_name as laundryName,
|
|
o.laundry_money as laundryMoney,
|
|
t.id as orderTakingId
|
|
FROM
|
|
orders o
|
|
LEFT JOIN order_taking t ON o.order_taking_id = t.id
|
|
LEFT JOIN tb_user u ON u.user_id = o.order_taking_user_id
|
|
WHERE
|
|
o.orders_type = 1 and o.isdelete=0 and o.orders_id is not null
|
|
AND o.user_id = #{userId}
|
|
<if test="status!=null and status!=''">
|
|
and o.state=#{status}
|
|
</if>
|
|
<if test="isShopping!=null">
|
|
and o.is_shopping=#{isShopping}
|
|
<if test="isShopping==1">
|
|
and t.status = 0 and t.id is not null
|
|
</if>
|
|
</if>
|
|
<if test="isShopping==null">
|
|
and (o.is_shopping is null or o.is_shopping=2)
|
|
</if>
|
|
order by o.create_time desc
|
|
</select>
|
|
|
|
<select id="selectOrderList" resultType="com.sqx.modules.orders.response.MyOrderResponse">
|
|
select * from (
|
|
SELECT
|
|
o.orders_id,
|
|
t.service_name as serviceName,
|
|
o.state,
|
|
t.my_level as myLevel,
|
|
t.homepage_img as homepageImg,
|
|
o.province,
|
|
o.city,
|
|
o.district,
|
|
o.is_update_bucket as isUpdateBucket,
|
|
o.no_code_finish_img as noCodeFinishImg,
|
|
o.details_address,
|
|
o.update_time,
|
|
o.order_taking_id,
|
|
u.user_id,
|
|
u.user_name,
|
|
u.avatar,
|
|
(select phone from tb_user tu where tu.user_id = o.user_id )as phone,
|
|
o.rate,
|
|
o.zhi_rate as zhiRate,
|
|
o.zhi_user_id as zhiUserId,
|
|
o.fei_user_id as feiUserId,
|
|
o.fei_rate as feiRate,
|
|
o.ping_rate as pingRate,
|
|
t.game_id as gameName,
|
|
o.order_number,
|
|
o.pay_money,
|
|
t.classify,
|
|
t.unit,
|
|
o.code,
|
|
o.start_img,
|
|
o.end_img,
|
|
o.start_time as startTime,
|
|
o.is_shopping as isShopping,
|
|
o.sku_id as skuId,
|
|
o.detail_json as detailJson,
|
|
o.is_transfer as isTransfer,
|
|
o.coupon_id as couponId,
|
|
o.coupon_money as couponMoney,
|
|
o.create_time,
|
|
o.laundry_id as laundryId,
|
|
o.laundry_money as laundryMoney,
|
|
o.laundry_name as laundryName,
|
|
(st_distance (point (o.longitude, o.latitude),point(#{longitude},#{latitude}) ) *111195) as distance,
|
|
t.id as orderTakingId
|
|
FROM
|
|
orders o
|
|
LEFT JOIN order_taking t ON o.order_taking_id = t.id
|
|
LEFT JOIN tb_user u ON u.user_id = o.order_taking_user_id
|
|
WHERE
|
|
o.orders_type = 1 and o.isdelete=0 and o.orders_id is not null and o.state=4
|
|
<if test="laundryId!=null">
|
|
and o.laundry_id=#{laundryId}
|
|
</if>
|
|
) a
|
|
<if test="createTime==1">
|
|
<if test="distance==1">
|
|
order by distance asc,create_time asc
|
|
</if>
|
|
<if test="distance==2">
|
|
order by distance desc,create_time asc
|
|
</if>
|
|
<if test="distance==''">
|
|
order by create_time asc
|
|
</if>
|
|
</if>
|
|
<if test="createTime==2">
|
|
<if test="distance==1">
|
|
order by distance asc,create_time desc
|
|
</if>
|
|
<if test="distance==2">
|
|
order by distance desc,create_time desc
|
|
</if>
|
|
<if test="distance==''">
|
|
order by create_time asc
|
|
</if>
|
|
</if>
|
|
<if test="createTime=='' and distance==1">
|
|
order by distance asc
|
|
</if>
|
|
<if test="createTime=='' and distance==2">
|
|
order by distance desc
|
|
</if>
|
|
</select>
|
|
|
|
|
|
<select id="queryOrdersAll" resultType="com.sqx.modules.orders.response.OrderAllResponse">
|
|
SELECT
|
|
o.orders_id,
|
|
t.service_name as serviceName,
|
|
o.orders_no,
|
|
o.province,
|
|
o.city,
|
|
o.is_update_bucket as isUpdateBucket,
|
|
o.no_code_finish_img as noCodeFinishImg,
|
|
o.district,
|
|
o.details_address,
|
|
o.name,
|
|
o.phone,
|
|
o.start_time,
|
|
o.order_taking_id,
|
|
o.pay_money,
|
|
o.state,
|
|
o.create_time,
|
|
o.orders_type,
|
|
o.remarks,
|
|
o.order_number,
|
|
o.vip_details_id,
|
|
o.rate,
|
|
o.zhi_rate as zhiRate,
|
|
o.zhi_user_id as zhiUserId,
|
|
o.fei_user_id as feiUserId,
|
|
o.fei_rate as feiRate,
|
|
o.ping_rate as pingRate,
|
|
u.user_name,
|
|
u.avatar,
|
|
o.order_score,
|
|
o.user_id,
|
|
o.code,
|
|
t.old_money as oldMoney,
|
|
t.money,
|
|
t.classify,
|
|
t.unit,
|
|
t.my_level,
|
|
o.start_img,
|
|
o.end_img,
|
|
o.is_transfer,
|
|
o.is_shopping as isShopping,
|
|
o.sku_id as skuId,
|
|
o.detail_json as detailJson,
|
|
o.coupon_id as couponId,
|
|
o.coupon_money as couponMoney,
|
|
o.laundry_id as laundryId,
|
|
o.laundry_name as laundryName,
|
|
o.laundry_money as laundryMoney,
|
|
ordersUser.user_name as ordersUserName,
|
|
(select user_name from tb_user u2 where u2.user_id=o.zhi_user_id) as zhiUserName,
|
|
(select user_name from tb_user u2 where u2.user_id=o.fei_user_id) as feiUserName,
|
|
(select laundry_user_id from laundry l where laundry_id = o.laundry_id) as laundryUserId,
|
|
t.member_money as memberMoney
|
|
FROM
|
|
orders o
|
|
LEFT JOIN order_taking t ON o.order_taking_id = t.id
|
|
LEFT JOIN tb_user u ON u.user_id = o.order_taking_user_id
|
|
left join tb_user ordersUser on ordersUser.user_id=o.user_id
|
|
WHERE o.isdelete=0
|
|
<if test="type!=null">
|
|
and o.orders_type=#{type}
|
|
</if>
|
|
<if test="status!=null">
|
|
and o.state=#{status}
|
|
</if>
|
|
<if test="name!=null and name!=''">
|
|
and u.user_name like #{name}
|
|
</if>
|
|
<if test="userId!=null">
|
|
and o.user_id=#{userId}
|
|
</if>
|
|
<if test="orderTakingUserId!=null">
|
|
and o.order_taking_user_id=#{orderTakingUserId}
|
|
</if>
|
|
<if test="laundryId!=null">
|
|
and o.laundry_id=#{laundryId}
|
|
</if>
|
|
<if test="ordersNo!=null and ordersNo!=''">
|
|
and o.orders_no like #{ordersNo}
|
|
</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>
|
|
order by o.create_time desc
|
|
</select>
|
|
|
|
|
|
<select id="ordersListExcel" resultType="com.sqx.modules.orders.response.OrderAllResponse">
|
|
SELECT
|
|
o.orders_id,
|
|
t.service_name as serviceName,
|
|
o.orders_no,
|
|
o.province,
|
|
o.city,
|
|
o.district,
|
|
o.details_address,
|
|
o.name,
|
|
o.phone,
|
|
o.start_time,
|
|
o.order_taking_id,
|
|
o.pay_money,
|
|
o.state,
|
|
o.create_time,
|
|
o.orders_type,
|
|
o.remarks,
|
|
o.order_number,
|
|
o.vip_details_id,
|
|
o.rate,
|
|
o.zhi_rate as zhiRate,
|
|
o.zhi_user_id as zhiUserId,
|
|
o.fei_user_id as feiUserId,
|
|
o.fei_rate as feiRate,
|
|
o.ping_rate as pingRate,
|
|
u.user_name,
|
|
u.avatar,
|
|
o.order_score,
|
|
o.user_id,
|
|
o.code,
|
|
t.old_money as oldMoney,
|
|
t.money,
|
|
t.classify,
|
|
t.unit,
|
|
t.my_level,
|
|
o.start_img,
|
|
o.end_img,
|
|
o.is_shopping as isShopping,
|
|
o.sku_id as skuId,
|
|
o.detail_json as detailJson,
|
|
o.is_transfer as isTransfer,
|
|
o.coupon_id as couponId,
|
|
o.coupon_money as couponMoney,
|
|
o.laundry_id as laundryId,
|
|
o.laundry_money as laundryMoney,
|
|
o.laundry_name as laundryName,
|
|
ordersUser.user_name as ordersUserName,
|
|
(select user_name from tb_user u2 where u2.user_id=o.zhi_user_id) as zhiUserName,
|
|
(select user_name from tb_user u2 where u2.user_id=o.fei_user_id) as feiUserName,
|
|
t.member_money as memberMoney
|
|
FROM
|
|
orders o
|
|
LEFT JOIN order_taking t ON o.order_taking_id = t.id
|
|
LEFT JOIN tb_user u ON u.user_id = o.order_taking_user_id
|
|
left join tb_user ordersUser on ordersUser.user_id=o.user_id
|
|
WHERE o.isdelete=0
|
|
<if test="type!=null">
|
|
and o.orders_type=#{type}
|
|
</if>
|
|
<if test="status!=null">
|
|
and o.state=#{status}
|
|
</if>
|
|
<if test="name!=null and name!=''">
|
|
and u.user_name like #{name}
|
|
</if>
|
|
<if test="userId!=null">
|
|
and o.user_id=#{userId}
|
|
</if>
|
|
<if test="laundryId!=null">
|
|
and o.laundry_id=#{laundryId}
|
|
</if>
|
|
<if test="ordersNo!=null and ordersNo!=''">
|
|
and o.orders_no like #{ordersNo}
|
|
</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>
|
|
order by o.create_time desc
|
|
</select>
|
|
|
|
<select id="selectMyTakeOrders" resultType="Map">
|
|
select o.orders_id as ordersId,o.state,o.create_time as createTime,o.pay_money as payMoney,o.user_id as
|
|
ordersUserId,ot.classify,ot.unit,
|
|
u.user_name as userName,u.avatar,o.order_number as orderNumber,o.remarks,o.orders_no as ordersNo,ot.old_money as
|
|
oldMoney,
|
|
o.province,
|
|
ot.service_name as serviceName,
|
|
o.city,
|
|
o.is_update_bucket as isUpdateBucket,
|
|
o.district,
|
|
o.details_address as detailsAddress,
|
|
o.name,
|
|
o.phone,
|
|
o.rate,
|
|
o.code,
|
|
o.start_img as startImg,
|
|
o.end_img as endImg,
|
|
o.zhi_rate as zhiRate,
|
|
o.no_code_finish_img as noCodeFinishImg,
|
|
o.zhi_user_id as zhiUserId,
|
|
o.fei_user_id as feiUserId,
|
|
o.fei_rate as feiRate,
|
|
o.ping_rate as pingRate,
|
|
ot.my_level as myLevel,
|
|
ot.homepage_img as homepageImg,
|
|
o.start_time as startTime,
|
|
o.is_shopping as isShopping,
|
|
o.sku_id as skuId,
|
|
o.detail_json as detailJson,
|
|
o.is_transfer as isTransfer,
|
|
o.coupon_id as couponId,
|
|
o.coupon_money as couponMoney,
|
|
o.laundry_id as laundryId,
|
|
o.laundry_money as laundryMoney,
|
|
o.laundry_name as laundryName,
|
|
ot.game_id as gameName,ot.id as orderTakingId,
|
|
u.bucket as bucket
|
|
from orders o
|
|
left join order_taking ot on ot.id=o.order_taking_id
|
|
left join tb_user u on u.user_id=o.user_id
|
|
where o.order_taking_user_id=#{userId} and o.orders_type=1 and o.isdelete=0
|
|
<if test="status!=null and status!=0">
|
|
and o.state=#{status}
|
|
</if>
|
|
<if test="status==null or status==0">
|
|
and o.state in (1,2,3,5)
|
|
</if>
|
|
order by o.create_time desc
|
|
</select>
|
|
|
|
|
|
<select id="selectOrdersCountAndMoney" resultType="Map">
|
|
select sum(money) as money, count(*) as counts
|
|
from user_money_details
|
|
where title like '订单完成:%'
|
|
and user_id = #{userId}
|
|
and `type` = 1
|
|
and date_format(create_time, '%Y-%m-%d') = date_format(now(), '%Y-%m-%d')
|
|
</select>
|
|
|
|
|
|
<select id="selectNowDayOrders" resultType="Map">
|
|
select o.orders_id as ordersId,
|
|
o.state,
|
|
o.create_time as createTime,
|
|
o.pay_money as payMoney,
|
|
o.user_id as
|
|
ordersUserId,
|
|
ot.service_name as serviceName,
|
|
ot.classify,
|
|
ot.unit,
|
|
u.user_name as userName,
|
|
u.avatar,
|
|
o.order_number as orderNumber,
|
|
o.remarks,
|
|
o.orders_no as ordersNo,
|
|
ot.old_money as
|
|
oldMoney,
|
|
o.province,
|
|
o.city,
|
|
o.is_update_bucket as isUpdateBucket,
|
|
o.district,
|
|
o.no_code_finish_img as noCodeFinishImg,
|
|
o.details_address as detailsAddress,
|
|
o.name,
|
|
o.phone,
|
|
o.rate,
|
|
o.code,
|
|
o.start_img as startImg,
|
|
o.end_img as endImg,
|
|
o.zhi_rate as zhiRate,
|
|
o.zhi_user_id as zhiUserId,
|
|
o.fei_user_id as feiUserId,
|
|
o.fei_rate as feiRate,
|
|
o.ping_rate as pingRate,
|
|
ot.my_level as myLevel,
|
|
ot.homepage_img as homepageImg,
|
|
o.start_time as startTime,
|
|
ot.game_id as gameName,
|
|
o.is_shopping as isShopping,
|
|
o.sku_id as skuId,
|
|
o.detail_json as detailJson,
|
|
o.is_transfer as isTransfer,
|
|
o.coupon_id as couponId,
|
|
o.coupon_money as couponMoney,
|
|
o.laundry_id as laundryId,
|
|
o.laundry_name as laundryName,
|
|
o.laundry_money as laundryMoney,
|
|
ot.id as orderTakingId
|
|
from orders o
|
|
left join order_taking ot on ot.id = o.order_taking_id
|
|
left join tb_user u on u.user_id = o.user_id
|
|
where o.order_taking_user_id = #{userId}
|
|
and o.orders_type = 1
|
|
and o.isdelete = 0
|
|
and o.state in (1, 5)
|
|
and (date_format(o.start_time, '%Y-%m-%d') = date_format(now(), '%Y-%m-%d') or o.start_time = '立即配送')
|
|
order by o.start_time asc
|
|
</select>
|
|
|
|
|
|
<select id="selectMyOrdersCount" resultType="Integer">
|
|
select count(*)
|
|
from orders
|
|
where user_id = #{userId}
|
|
and date_format(create_time, '%Y-%m') = date_format(#{time}, '%Y-%m')
|
|
and `state` = 2
|
|
</select>
|
|
|
|
<select id="selectTakeOrdersCount" resultType="Integer">
|
|
select count(*)
|
|
from orders
|
|
where order_taking_user_id = #{userId}
|
|
and date_format(create_time, '%Y-%m') = date_format(#{time}, '%Y-%m')
|
|
and `state` = 2
|
|
</select>
|
|
|
|
<select id="countOrdersByCreateTime" resultType="Integer">
|
|
select count(*) from orders where state in (1,2,3,4)
|
|
<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="sumOrdersByCreateTime" resultType="Double">
|
|
select sum(pay_money) from orders where `state` in (1,2,3,4)
|
|
<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="incomeAnalysisOrders" resultType="Map">
|
|
select o.orders_id as orderId, o.is_update_bucket as isUpdateBucket,u.user_name as userName,u.user_id as
|
|
userId,t.classify,t.unit,
|
|
pay_money as payMoney,u.create_time as createTime,t.old_money as money,o.code
|
|
from orders o
|
|
left join tb_user u on u.user_id=o.user_id
|
|
left join order_taking t on t.id=o.order_taking_id
|
|
where o.state=2 and t.id is not null
|
|
<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>
|
|
order by o.create_time desc
|
|
</select>
|
|
|
|
<select id="selectOrdersMoneyByUserId" resultType="BigDecimal">
|
|
select ifnull(sum(money),0.00) from user_money_details where `type`=1 and (title like '%订单完成%' or title like
|
|
'%接单完成%') and user_id =#{userId}
|
|
<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="selectOrdersCountByUserId" resultType="Integer">
|
|
select count(*) from orders where order_taking_user_id=#{userId} and
|
|
state in (1,2,3)
|
|
<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="selectOrderScoreByUserId" resultType="BigDecimal">
|
|
select ifnull(avg(score), 0)
|
|
from taking_commnt
|
|
where orders_id in (select orders_id from orders where order_taking_user_id = #{userId})
|
|
<if test="startTime!=null and startTime!='' and (endTime==null or endTime=='')">
|
|
and date_format(create_time,'%Y-%m-%d') >= #{startTime}
|
|
</if>
|
|
<if test="endTime!=null and endTime!='' and (startTime==null or startTime=='')">
|
|
and date_format(create_time,'%Y-%m-%d') <= #{endTime}
|
|
</if>
|
|
order by create_time desc
|
|
</select>
|
|
|
|
<select id="selectOrdersRefundMoneyByUserId" resultType="BigDecimal">
|
|
select ifnull(sum(pay_money),0.00) from orders o
|
|
where o.order_taking_user_id=#{userId} and o.state=3
|
|
<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>
|
|
</select>
|
|
|
|
<select id="selectOrdersRefundCountByUserId" resultType="Integer">
|
|
select count(*) from orders where order_taking_user_id=#{userId} and
|
|
state=#{status}
|
|
<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="getOrdersRemind" resultType="Integer">
|
|
select count(*)
|
|
from orders
|
|
where order_taking_user_id = #{userId}
|
|
and is_remind = 0
|
|
</select>
|
|
|
|
<update id="updateOrdersIsRemind">
|
|
update orders
|
|
set is_remind=1
|
|
where order_taking_user_id = #{userId}
|
|
</update>
|
|
|
|
|
|
<select id="selectTeamOrdersList" resultType="Map">
|
|
select o.orders_id as ordersId,o.state,o.create_time as createTime,o.pay_money as payMoney,o.user_id as
|
|
ordersUserId,ot.classify,ot.unit,o.code,
|
|
u.user_name as userName,u.avatar,o.order_number as orderNumber,o.remarks,o.orders_no as ordersNo,ot.old_money as
|
|
oldMoney,
|
|
o.start_img as startImg,
|
|
o.is_update_bucket as isUpdateBucket,
|
|
ot.service_name as serviceName,
|
|
o.end_img as endImg,
|
|
o.coupon_id as couponId,
|
|
o.coupon_money as couponMoney,
|
|
o.is_shopping as isShopping,
|
|
o.sku_id as skuId,
|
|
o.detail_json as detailJson,
|
|
o.is_transfer as isTransfer,
|
|
o.coupon_id as couponId,
|
|
o.coupon_money as couponMoney,
|
|
o.laundry_id as laundryId,
|
|
o.laundry_name as laundryName,
|
|
o.laundry_money as laundryMoney,
|
|
g.game_name as gameName,g.game_img as gameImg,ot.id as orderTakingId,o.zhi_rate as zhiRate,o.fei_rate as feiRate
|
|
from orders o
|
|
left join order_taking ot on ot.id=o.order_taking_id
|
|
left join game g on g.id=ot.game_id
|
|
left join tb_user u on u.user_id=o.user_id
|
|
where o.orders_type=1
|
|
<if test="status!=null and status!=0">
|
|
and o.state=#{status}
|
|
</if>
|
|
<if test="type==1">
|
|
and o.zhi_user_id=#{userId}
|
|
</if>
|
|
<if test="type==2">
|
|
and o.fei_user_id=#{userId}
|
|
</if>
|
|
order by o.create_time desc
|
|
</select>
|
|
|
|
<select id="selectOrdersMoneyCountByUserId" resultType="Double">
|
|
select
|
|
<if test="type==1">
|
|
ifnull(sum(zhi_rate),0.00)
|
|
</if>
|
|
<if test="type==2">
|
|
ifnull(sum(fei_rate),0.00)
|
|
</if>
|
|
from orders
|
|
where state=2
|
|
<if test="type==1">
|
|
and zhi_user_id=#{userId}
|
|
</if>
|
|
<if test="type==2">
|
|
and fei_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 in (select invitation_code from tb_user where inviter_code=#{invitationCode})
|
|
</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.zhi_rate),0.00) from orders o where
|
|
o.user_id = u.user_id and o.state=2 and zhi_user_id=#{userId} ) as money,
|
|
</if>
|
|
<if test="type==2">
|
|
(select ifnull(sum(o.fei_rate),0.00) from orders o where
|
|
o.user_id = u.user_id and o.state=2 and fei_user_id=#{userId} ) as money,
|
|
</if>
|
|
ifnull(um.money, 0.00) as balance
|
|
from tb_user u
|
|
left join user_money um on u.user_id = um.user_id
|
|
where
|
|
<if test="type==1">
|
|
inviter_code=#{invitationCode}
|
|
</if>
|
|
<if test="type==2">
|
|
inviter_code in (select invitation_code from tb_user where inviter_code=#{invitationCode})
|
|
</if>
|
|
) a order by money desc
|
|
</select>
|
|
|
|
<select id="selectTeamUserList2" resultType="Map">
|
|
select *
|
|
from (
|
|
select u.user_id AS userId,
|
|
u.user_name AS userName,
|
|
u.avatar,
|
|
u.create_time AS createTime,
|
|
o.money,
|
|
ifnull(um.money, 0.00) as balance
|
|
from (
|
|
SELECT ifnull(sum(fei_rate), 0.00) as money, user_id
|
|
FROM orders
|
|
WHERE state = 2
|
|
and fei_user_id = #{userId}
|
|
GROUP BY user_id) o
|
|
left join tb_user u on u.user_id = o.user_id
|
|
left join user_money um on u.user_id = um.user_id
|
|
) a
|
|
order by money desc
|
|
</select>
|
|
|
|
|
|
<select id="selectNewestOrders" resultType="Map">
|
|
select o.orders_id as ordersId,
|
|
u1.avatar,
|
|
u1.user_name as userName,
|
|
o.create_time as createTime
|
|
from orders o
|
|
left join tb_user u1 on u1.user_id = o.user_id
|
|
where o.state in (1, 2, 4, 5)
|
|
order by o.create_time desc limit 5
|
|
</select>
|
|
|
|
|
|
<select id="selectSumMoney" resultType="java.math.BigDecimal">
|
|
select ifnull(sum(rate), 0) from orders where order_taking_user_id = #{userId} and state in (1,2,5)
|
|
<if test="startTime!=null and startTime!=''">
|
|
and date_format(end_time,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="endTime!=null and endTime!=''">
|
|
and date_format(end_time,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d')
|
|
</if>
|
|
</select>
|
|
|
|
<select id="selectEstimationSumMoneyBy" resultType="java.math.BigDecimal">
|
|
select ifnull(sum(rate), 0) from orders where order_taking_user_id = #{userId} and state in (1,2,5)
|
|
<if test="time!=null and time!='' and type==1">
|
|
and date_format(end_time,'%Y-%m-%d') >= date_format(#{time},'%Y-%m-%d')
|
|
</if>
|
|
<if test="time!=null and time!='' and type==2">
|
|
and date_format(end_time,'%Y-%m') >= date_format(#{time},'%Y-%m')
|
|
</if>
|
|
<if test="time!=null and time!='' and type==3">
|
|
and date_format(end_time,'%Y') >= date_format(#{time},'%Y')
|
|
</if>
|
|
</select>
|
|
<select id="getMoney" resultType="java.math.BigDecimal">
|
|
select sum(pay_money) from orders where 1=1
|
|
<if test="laundryId!=null">
|
|
and laundry_id=#{laundryId}
|
|
</if>
|
|
<if test="state!=null">
|
|
and `state` = #{state}
|
|
</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="orderCount" resultType="java.lang.Integer">
|
|
select count(*) from orders where 1=1
|
|
<if test="laundryId!=null">
|
|
and laundry_id=#{laundryId}
|
|
</if>
|
|
<if test="state!=null">
|
|
and `state` = #{state}
|
|
</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="selectLaundryMoneyStatistics" resultType="Map">
|
|
select * from (
|
|
select l.laundry_id as laundryId,l.laundry_name as laundryName,
|
|
(select ifnull(sum(o.laundry_money),0.00) from orders o where o.laundry_id=l.laundry_id) as money
|
|
from laundry l
|
|
where 1=1
|
|
<if test="laundryName!=null and laundryName!=''">
|
|
l.laundry_name like concat('%',#{laundryName},'%')
|
|
</if>
|
|
) a order by money desc
|
|
</select>
|
|
|
|
<select id="selectLaundryMoneyByLaundryId" resultType="BigDecimal">
|
|
select ifnull(sum(laundry_money), 0.00)
|
|
from orders
|
|
where laundry_id = #{laundryId}
|
|
and status = 2
|
|
</select>
|
|
|
|
<select id="cleanOrdersByTime" resultType="com.sqx.modules.orders.entity.Orders">
|
|
select *
|
|
from orders
|
|
where state = 4
|
|
and date_format(date_add(pay_time, interval #{time} minute), '%Y-%m-%d %H:%i:%S') <=
|
|
date_format(now(), '%Y-%m-%d %H:%i:%S')
|
|
</select>
|
|
|
|
<update id="updateOrdersStateByCreateTime">
|
|
update orders
|
|
set state=3
|
|
where state = 0
|
|
and date_format(date_add(create_time, interval #{time} minute), '%Y-%m-%d %H:%i:%S') <=
|
|
date_format(now(), '%Y-%m-%d %H:%i:%S')
|
|
</update>
|
|
|
|
<select id="selectOrdersCount" resultType="Integer">
|
|
select count(*) from orders where 1=1
|
|
<if test="status!=null">
|
|
and state=#{status}
|
|
</if>
|
|
<if test="ordersType!=null">
|
|
and orders_type=#{ordersType}
|
|
</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="selectOrdersMoney" resultType="Double">
|
|
select ifnull(sum(pay_money),0.00) from orders where 1=1
|
|
<if test="status!=null">
|
|
and state=#{status}
|
|
</if>
|
|
<if test="ordersType!=null">
|
|
and orders_type=#{ordersType}
|
|
</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="sumOrderBucketCount" resultType="java.lang.Integer">
|
|
select ifnull(sum(order_number), 0)
|
|
from orders
|
|
where state = 2
|
|
and order_taking_user_id = #{userId}
|
|
</select>
|
|
<select id="getUserBucketCount" resultType="java.lang.Integer">
|
|
SELECT IFNULL(SUM(order_number), 0)
|
|
FROM orders o
|
|
WHERE o.`order_taking_user_id` = #{userId}
|
|
AND o.`state` = 2
|
|
</select>
|
|
<select id="getUserBucket" resultType="java.util.HashMap">
|
|
SELECT *
|
|
FROM (
|
|
SELECT u.user_id as userId,
|
|
u.`user_name` as userName,
|
|
u.avatar,
|
|
(SELECT IFNULL(SUM(order_number), 0)
|
|
FROM orders o
|
|
WHERE u.`user_id` = o.`order_taking_user_id`
|
|
AND o.`state` = 2
|
|
<if test="flag==1">
|
|
and date_format(o.create_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
|
|
</if>
|
|
<if test="flag==2">
|
|
and date_format(o.create_time,'%Y-%m')=date_format(#{date},'%Y-%m')
|
|
</if>
|
|
<if test="flag==3">
|
|
and date_format(o.create_time,'%Y')=date_format(#{date},'%Y')
|
|
</if>
|
|
|
|
|
|
) AS bucketCount
|
|
FROM tb_user u
|
|
) t1
|
|
WHERE t1.bucketCount > 0
|
|
ORDER BY bucketCount DESC
|
|
|
|
|
|
</select>
|
|
<select id="selectOrdersNumber" resultType="Integer">
|
|
select ifnull(sum(order_number),0) from orders where 1=1
|
|
<if test="status!=null">
|
|
and state=#{status}
|
|
</if>
|
|
<if test="ordersType!=null">
|
|
and orders_type=#{ordersType}
|
|
</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>
|
|
</mapper> |