|
|
@@ -92,8 +92,8 @@
|
|
|
tiu.user_name as riderNickName,tiu.phone as riderPhone,ti.indent_id as indentId,ti.is_rider as isRider,
|
|
|
ti.rider_user_id as riderUserId, tcu.money as couponMoney,
|
|
|
apr.discount_amount as activityDiscountAmount, ai.title activityTitle,tiu.rider_station_id as riderStationId,
|
|
|
- (select rs.station_name from rider_station rs where rs.id =tiu.rider_station_id ) as stationName,
|
|
|
(select st.shop_type_name from shop_type st where st.id =gs.shop_type_id ) as shopTypeName,
|
|
|
+ (case when tcu.shop_id =0 then '平台' else gs2.shop_name end) as couponTypeRemark,
|
|
|
pd.trade_no as transactionId
|
|
|
from tb_order tor
|
|
|
left join tb_user tu on tor.user_id = tu.user_id
|
|
|
@@ -103,6 +103,7 @@
|
|
|
left join tb_coupon_user tcu on tor.coupon_id = tcu.id
|
|
|
left join activity_part_record apr on apr.order_id = tor.order_id
|
|
|
left join activity ai on ai.id = apr.activity_id
|
|
|
+ left join goods_shop gs2 on gs2.shop_id=tcu.shop_id
|
|
|
left join pay_details pd on pd.order_id = tor.order_number
|
|
|
where 1 = 1
|
|
|
<if test="query.riderPhone!=null and query.riderPhone!=''">
|
|
|
@@ -159,6 +160,12 @@
|
|
|
<if test="query.transactionId != null and query.transactionId != ''">
|
|
|
and pd.trade_no = #{query.transactionId}
|
|
|
</if>
|
|
|
+ <if test='query.couponType== "0" '>
|
|
|
+ and tcu.shop_id =0
|
|
|
+ </if>
|
|
|
+ <if test='query.couponType== "1"'>
|
|
|
+ and tcu.shop_id !=0
|
|
|
+ </if>
|
|
|
order by tor.pay_time desc, tor.create_time desc
|
|
|
</select>
|
|
|
|
|
|
@@ -168,7 +175,9 @@
|
|
|
tiu.nick_name as riderNickName,tiu.phone as riderPhone,ti.indent_id as indentId,ti.is_rider as isRider,
|
|
|
ti.rider_user_id as riderUserId, tcu.money as couponMoney,
|
|
|
apr.discount_amount as activityDiscountAmount, ai.title activityTitle,ogg.detail,ogg.sumPrice,
|
|
|
- (select rs.station_name from rider_station rs where rs.id =tiu.rider_station_id ) as stationName
|
|
|
+ (select rs.station_name from rider_station rs where rs.id =tiu.rider_station_id ) as stationName,
|
|
|
+ (select st.shop_type_name from shop_type st where st.id =gs.shop_type_id ) as shopTypeName,
|
|
|
+ (case when tcu.shop_id =0 then '平台' else gs2.shop_name end) as couponTypeRemark
|
|
|
from tb_order tor
|
|
|
left join tb_user tu on tor.user_id = tu.user_id
|
|
|
left join goods_shop gs on tor.shop_id = gs.shop_id
|
|
|
@@ -179,48 +188,64 @@
|
|
|
left join activity ai on ai.id = apr.activity_id
|
|
|
left join ( select @a:=0,order_id ,group_concat(@a:=@a+1,".商品名:",goods_name,",数量:",goods_num,",规格:",sku_message) detail,sum(goods_num*goods_price) sumPrice from order_goods og group by order_id
|
|
|
) ogg on ogg.order_id =tor.order_id
|
|
|
+ left join goods_shop gs2 on gs2.shop_id=tcu.shop_id
|
|
|
where 1 = 1
|
|
|
- <if test="riderPhone!=null and riderPhone!=''">
|
|
|
- and tiu.phone =#{riderPhone}
|
|
|
+ <if test="query.riderPhone!=null and query.riderPhone!=''">
|
|
|
+ and tiu.phone =#{query.riderPhone}
|
|
|
</if>
|
|
|
- <if test="shopName!=null and shopName!=''">
|
|
|
- and gs.shop_name like concat('%',#{shopName},'%')
|
|
|
+ <if test="query.shopName!=null and query.shopName!=''">
|
|
|
+ and gs.shop_name like concat('%',#{query.shopName},'%')
|
|
|
</if>
|
|
|
- <if test="userName!=null and userName!=''">
|
|
|
- and tor.user_name like concat('%',#{userName},'%')
|
|
|
+ <if test="query.userName!=null and query.userName!=''">
|
|
|
+ and tor.user_name like concat('%',#{query.userName},'%')
|
|
|
</if>
|
|
|
- <if test="phone!=null and phone!=''">
|
|
|
- and tor.phone like concat('%',#{phone},'%')
|
|
|
+ <if test="query.phone!=null and query.phone!=''">
|
|
|
+ and tor.phone like concat('%',#{query.phone},'%')
|
|
|
</if>
|
|
|
- <if test="orderNumber!=null and orderNumber!=''">
|
|
|
- and tor.order_number = #{orderNumber}
|
|
|
+ <if test="query.orderNumber!=null and query.orderNumber!=''">
|
|
|
+ and tor.order_number = #{query.orderNumber}
|
|
|
</if>
|
|
|
- <if test="status!=null and status!=-1 and status!=1">
|
|
|
- and tor.status = #{status}
|
|
|
+ <if test="query.status!=null and query.status!=-1 and query.status!=1">
|
|
|
+ and tor.status = #{query.status}
|
|
|
</if>
|
|
|
- <if test="status!=null and status==1">
|
|
|
+ <if test="query.status!=null and query.status==1">
|
|
|
and tor.status in (1,2)
|
|
|
</if>
|
|
|
- <if test="shopId!=null">
|
|
|
- and tor.shop_id = #{shopId}
|
|
|
+ <if test="query.shopId!=null">
|
|
|
+ and tor.shop_id = #{query.shopId}
|
|
|
</if>
|
|
|
- <if test="orderType!=null">
|
|
|
- and tor.order_type_extra = #{orderType}
|
|
|
+ <if test="query.orderType!=null">
|
|
|
+ and tor.order_type_extra = #{query.orderType}
|
|
|
+ </if>
|
|
|
+ <if test="query.indentStatus != null and query.indentStatus != ''">
|
|
|
+ and ti.indent_state = #{query.indentStatus}
|
|
|
+ </if>
|
|
|
+ <if test="query.reservationFlag != null and query.reservationFlag !=''">
|
|
|
+ and tor.reservation_flag = #{query.reservationFlag}
|
|
|
+ </if>
|
|
|
+ <if test="query.startTime!=null and query.startTime!=''">
|
|
|
+ and date_format(tor.create_time,'%Y-%m-%d') >= date_format(#{query.startTime},'%Y-%m-%d')
|
|
|
+ </if>
|
|
|
+ <if test="query.endTime!=null and query.endTime!='' ">
|
|
|
+ and date_format(tor.create_time,'%Y-%m-%d') <= date_format(#{query.endTime},'%Y-%m-%d')
|
|
|
+ </if>
|
|
|
+ <if test="query.payStartTime != null and query.payStartTime != ''">
|
|
|
+ and date_format(tor.pay_time,'%Y-%m-%d') >= date_format(#{query.payStartTime},'%Y-%m-%d')
|
|
|
</if>
|
|
|
- <if test="startTime!=null and startTime!=''">
|
|
|
- and date_format(tor.create_time,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
|
|
|
+ <if test="query.payEndTime != null and query.payEndTime != '' ">
|
|
|
+ and date_format(tor.pay_time,'%Y-%m-%d') <= date_format(#{query.payEndTime},'%Y-%m-%d')
|
|
|
</if>
|
|
|
- <if test="endTime!=null and endTime!='' ">
|
|
|
- and date_format(tor.create_time,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d')
|
|
|
+ <if test="query.riderStationId!=null and query.riderStationId!=''">
|
|
|
+ and tiu.rider_station_id=#{query.riderStationId}
|
|
|
</if>
|
|
|
- <if test="payStartTime != null and payStartTime != ''">
|
|
|
- and date_format(tor.pay_time,'%Y-%m-%d') >= date_format(#{payStartTime},'%Y-%m-%d')
|
|
|
+ <if test="query.shopTypeId!=null and query.shopTypeId!=''">
|
|
|
+ and gs.shop_type_id=#{query.shopTypeId}
|
|
|
</if>
|
|
|
- <if test="payEndTime != null and payEndTime != '' ">
|
|
|
- and date_format(tor.pay_time,'%Y-%m-%d') <= date_format(#{payEndTime},'%Y-%m-%d')
|
|
|
+ <if test='query.couponType== "0" '>
|
|
|
+ and tcu.shop_id =0
|
|
|
</if>
|
|
|
- <if test="riderStationId!=null and riderStationId!=''">
|
|
|
- and tiu.rider_station_id=#{riderStationId}
|
|
|
+ <if test='query.couponType== "1"'>
|
|
|
+ and tcu.shop_id !=0
|
|
|
</if>
|
|
|
order by tor.pay_time desc, tor.create_time desc
|
|
|
</select>
|
|
|
@@ -231,48 +256,64 @@
|
|
|
left join goods_shop gs on tor.shop_id = gs.shop_id
|
|
|
left join tb_indent ti on tor.order_id = ti.order_id
|
|
|
left join tb_user tiu on tiu.user_id = ti.rider_user_id
|
|
|
+ left join tb_coupon_user tcu on tor.coupon_id = tcu.id
|
|
|
where 1 = 1
|
|
|
- <if test="riderPhone!=null and riderPhone!=''">
|
|
|
- and tiu.phone =#{riderPhone}
|
|
|
+ <if test="query.riderPhone!=null and query.riderPhone!=''">
|
|
|
+ and tiu.phone =#{query.riderPhone}
|
|
|
</if>
|
|
|
- <if test="shopName!=null and shopName!=''">
|
|
|
- and gs.shop_name like concat('%',#{shopName},'%')
|
|
|
+ <if test="query.shopName!=null and query.shopName!=''">
|
|
|
+ and gs.shop_name like concat('%',#{query.shopName},'%')
|
|
|
</if>
|
|
|
- <if test="userName!=null and userName!=''">
|
|
|
- and tor.user_name like concat('%',#{userName},'%')
|
|
|
+ <if test="query.userName!=null and query.userName!=''">
|
|
|
+ and tor.user_name like concat('%',#{query.userName},'%')
|
|
|
</if>
|
|
|
- <if test="phone!=null and phone!=''">
|
|
|
- and tor.phone like concat('%',#{phone},'%')
|
|
|
+ <if test="query.phone!=null and query.phone!=''">
|
|
|
+ and tor.phone like concat('%',#{query.phone},'%')
|
|
|
</if>
|
|
|
- <if test="orderNumber!=null and orderNumber!=''">
|
|
|
- and tor.order_number = #{orderNumber}
|
|
|
+ <if test="query.orderNumber!=null and query.orderNumber!=''">
|
|
|
+ and tor.order_number = #{query.orderNumber}
|
|
|
</if>
|
|
|
- <if test="status!=null and status!=-1 and status!=1">
|
|
|
- and tor.status = #{status}
|
|
|
+ <if test="query.status!=null and query.status!=-1 and query.status!=1">
|
|
|
+ and tor.status = #{query.status}
|
|
|
</if>
|
|
|
- <if test="status!=null and status==1">
|
|
|
+ <if test="query.status!=null and query.status==1">
|
|
|
and tor.status in (1,2)
|
|
|
</if>
|
|
|
- <if test="shopId!=null">
|
|
|
- and tor.shop_id = #{shopId}
|
|
|
+ <if test="query.shopId!=null">
|
|
|
+ and tor.shop_id = #{query.shopId}
|
|
|
</if>
|
|
|
- <if test="orderType!=null">
|
|
|
- and tor.order_type_extra = #{orderType}
|
|
|
+ <if test="query.orderType!=null">
|
|
|
+ and tor.order_type_extra = #{query.orderType}
|
|
|
+ </if>
|
|
|
+ <if test="query.indentStatus != null and query.indentStatus != ''">
|
|
|
+ and ti.indent_state = #{query.indentStatus}
|
|
|
+ </if>
|
|
|
+ <if test="query.reservationFlag != null and query.reservationFlag !=''">
|
|
|
+ and tor.reservation_flag = #{query.reservationFlag}
|
|
|
</if>
|
|
|
- <if test="startTime!=null and startTime!=''">
|
|
|
- and date_format(tor.create_time,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
|
|
|
+ <if test="query.startTime!=null and query.startTime!=''">
|
|
|
+ and date_format(tor.create_time,'%Y-%m-%d') >= date_format(#{query.startTime},'%Y-%m-%d')
|
|
|
</if>
|
|
|
- <if test="endTime!=null and endTime!='' ">
|
|
|
- and date_format(tor.create_time,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d')
|
|
|
+ <if test="query.endTime!=null and query.endTime!='' ">
|
|
|
+ and date_format(tor.create_time,'%Y-%m-%d') <= date_format(#{query.endTime},'%Y-%m-%d')
|
|
|
</if>
|
|
|
- <if test="payStartTime != null and payStartTime != ''">
|
|
|
- and date_format(tor.pay_time,'%Y-%m-%d') >= date_format(#{payStartTime},'%Y-%m-%d')
|
|
|
+ <if test="query.payStartTime != null and query.payStartTime != ''">
|
|
|
+ and date_format(tor.pay_time,'%Y-%m-%d') >= date_format(#{query.payStartTime},'%Y-%m-%d')
|
|
|
</if>
|
|
|
- <if test="payEndTime != null and payEndTime != '' ">
|
|
|
- and date_format(tor.pay_time,'%Y-%m-%d') <= date_format(#{payEndTime},'%Y-%m-%d')
|
|
|
+ <if test="query.payEndTime != null and query.payEndTime != '' ">
|
|
|
+ and date_format(tor.pay_time,'%Y-%m-%d') <= date_format(#{query.payEndTime},'%Y-%m-%d')
|
|
|
</if>
|
|
|
- <if test="riderStationId!=null and riderStationId!=''">
|
|
|
- and tiu.rider_station_id=#{riderStationId}
|
|
|
+ <if test="query.riderStationId!=null and query.riderStationId!=''">
|
|
|
+ and tiu.rider_station_id=#{query.riderStationId}
|
|
|
+ </if>
|
|
|
+ <if test="query.shopTypeId!=null and query.shopTypeId!=''">
|
|
|
+ and gs.shop_type_id=#{query.shopTypeId}
|
|
|
+ </if>
|
|
|
+ <if test='query.couponType== "0" '>
|
|
|
+ and tcu.shop_id =0
|
|
|
+ </if>
|
|
|
+ <if test='query.couponType== "1"'>
|
|
|
+ and tcu.shop_id !=0
|
|
|
</if>
|
|
|
order by tor.pay_time desc, tor.create_time desc
|
|
|
</select>
|
|
|
@@ -363,13 +404,12 @@
|
|
|
and tor.status = #{status}
|
|
|
</if>
|
|
|
<if test="status!=null and status==5">
|
|
|
- and tor.status in (5, 8)
|
|
|
+ and tor.status =8
|
|
|
</if>
|
|
|
<if test="status==null">
|
|
|
- and tor.status in (0, 7, 6, 3, 4, 5, 8)
|
|
|
+ and tor.status in (0, 7, 6, 3, 4, 8)
|
|
|
</if>
|
|
|
order by tor.pay_time desc, tor.create_time desc
|
|
|
-
|
|
|
</select>
|
|
|
|
|
|
|
|
|
@@ -571,5 +611,86 @@
|
|
|
and shop_id = #{shopId}
|
|
|
and date(pay_time) = date(#{payTime})
|
|
|
</select>
|
|
|
+ <select id="selectOrderPage" resultType="com.sqx.modules.order.entity.TbOrder">
|
|
|
+ select tor.*, gs.shop_name as shopName, gs.detailed_address as detailedAddress, gs.shop_lng as shopLng,
|
|
|
+ gs.shop_lat as shopLat, gs.phone as shopPhone,
|
|
|
+ gs.errand_money as errandMoney, gs.exempt_min_money as exemptMinMoney, gs.minimum_delivery as minimumDelivery,
|
|
|
+ gs.distribution_distance as distributionDistance
|
|
|
+ from tb_order tor left join goods_shop gs on tor.shop_id = gs.shop_id
|
|
|
+ where tor.user_id = #{userId}
|
|
|
+ and tor.order_id = #{orderId}
|
|
|
+
|
|
|
+ </select>
|
|
|
+ <select id="selectAllOrderTotalPrice" resultType="java.math.BigDecimal">
|
|
|
+ select SUM(tor.pay_money) as totalPrice
|
|
|
+ from tb_order tor
|
|
|
+ left join tb_user tu on tor.user_id = tu.user_id
|
|
|
+ left join goods_shop gs on tor.shop_id = gs.shop_id
|
|
|
+ left join tb_indent ti on tor.order_id = ti.order_id
|
|
|
+ left join tb_user tiu on tiu.user_id = ti.rider_user_id
|
|
|
+ left join tb_coupon_user tcu on tor.coupon_id = tcu.id
|
|
|
+ left join activity_part_record apr on apr.order_id = tor.order_id
|
|
|
+ left join activity ai on ai.id = apr.activity_id
|
|
|
+ left join goods_shop gs2 on gs2.shop_id=tcu.shop_id
|
|
|
+ where 1 = 1
|
|
|
+ <if test="query.riderPhone!=null and query.riderPhone!=''">
|
|
|
+ and tiu.phone =#{query.riderPhone}
|
|
|
+ </if>
|
|
|
+ <if test="query.shopName!=null and query.shopName!=''">
|
|
|
+ and gs.shop_name like concat('%',#{query.shopName},'%')
|
|
|
+ </if>
|
|
|
+ <if test="query.userName!=null and query.userName!=''">
|
|
|
+ and tor.user_name like concat('%',#{query.userName},'%')
|
|
|
+ </if>
|
|
|
+ <if test="query.phone!=null and query.phone!=''">
|
|
|
+ and tor.phone like concat('%',#{query.phone},'%')
|
|
|
+ </if>
|
|
|
+ <if test="query.orderNumber!=null and query.orderNumber!=''">
|
|
|
+ and tor.order_number = #{query.orderNumber}
|
|
|
+ </if>
|
|
|
+ <if test="query.status!=null and query.status!=-1 and query.status!=1">
|
|
|
+ and tor.status = #{query.status}
|
|
|
+ </if>
|
|
|
+ <if test="query.status!=null and query.status==1">
|
|
|
+ and tor.status in (1,2)
|
|
|
+ </if>
|
|
|
+ <if test="query.shopId!=null">
|
|
|
+ and tor.shop_id = #{query.shopId}
|
|
|
+ </if>
|
|
|
+ <if test="query.orderType!=null">
|
|
|
+ and tor.order_type_extra = #{query.orderType}
|
|
|
+ </if>
|
|
|
+ <if test="query.indentStatus != null and query.indentStatus != ''">
|
|
|
+ and ti.indent_state = #{query.indentStatus}
|
|
|
+ </if>
|
|
|
+ <if test="query.reservationFlag != null and query.reservationFlag !=''">
|
|
|
+ and tor.reservation_flag = #{query.reservationFlag}
|
|
|
+ </if>
|
|
|
+ <if test="query.startTime!=null and query.startTime!=''">
|
|
|
+ and date_format(tor.create_time,'%Y-%m-%d') >= date_format(#{query.startTime},'%Y-%m-%d')
|
|
|
+ </if>
|
|
|
+ <if test="query.endTime!=null and query.endTime!='' ">
|
|
|
+ and date_format(tor.create_time,'%Y-%m-%d') <= date_format(#{query.endTime},'%Y-%m-%d')
|
|
|
+ </if>
|
|
|
+ <if test="query.payStartTime != null and query.payStartTime != ''">
|
|
|
+ and date_format(tor.pay_time,'%Y-%m-%d') >= date_format(#{query.payStartTime},'%Y-%m-%d')
|
|
|
+ </if>
|
|
|
+ <if test="query.payEndTime != null and query.payEndTime != '' ">
|
|
|
+ and date_format(tor.pay_time,'%Y-%m-%d') <= date_format(#{query.payEndTime},'%Y-%m-%d')
|
|
|
+ </if>
|
|
|
+ <if test="query.riderStationId!=null and query.riderStationId!=''">
|
|
|
+ and tiu.rider_station_id=#{query.riderStationId}
|
|
|
+ </if>
|
|
|
+ <if test="query.shopTypeId!=null and query.shopTypeId!=''">
|
|
|
+ and gs.shop_type_id=#{query.shopTypeId}
|
|
|
+ </if>
|
|
|
+ <if test='query.couponType== "0" '>
|
|
|
+ and tcu.shop_id =0
|
|
|
+ </if>
|
|
|
+ <if test='query.couponType== "1"'>
|
|
|
+ and tcu.shop_id !=0
|
|
|
+ </if>
|
|
|
+ order by tor.pay_time desc, tor.create_time desc
|
|
|
+ </select>
|
|
|
|
|
|
</mapper>
|