| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706 |
- <?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.order.dao.AppOrderDao">
- <select id="selectOrderList" 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}
- <if test="orderType!=null">
- and tor.order_type = #{orderType}
- </if>
- <if test="shopId!=null">
- and tor.shop_id = #{shopId}
- </if>
- <if test="status!=null">
- <if test="status == 0">
- and tor.status = 0
- </if>
- <if test="status == 1">
- and tor.status = 1
- </if>
- <if test="status == 2">
- and tor.status = 2
- </if>
- <if test="status == 3">
- and tor.status in (7, 6, 3, 4, 5, 8)
- </if>
- </if>
- </select>
- <insert id="insertOrder" parameterType="com.sqx.modules.order.entity.TbOrder" useGeneratedKeys="true"
- keyProperty="orderId">
- insert into tb_order (coupon_id, user_id, user_name, phone, address, order_number, is_pay, pay_time,
- order_code, order_type, pack_money, errand_money, status, delete_flag, parent_user_id,
- shop_id, parent_id, create_time)
- values (#{couponId}, #{userId}, #{userName}, #{phone}, #{address}, #{orderNumber}, #{isPay}, #{payTime},
- #{orderCode}, #{orderType}, #{packMoney}, #{errandMoney}, #{status}, #{deleteFlag}, #{parentUserId},
- #{shopId}, #{parentId}, #{createTime})
- </insert>
- <select id="selectOrder" resultType="com.sqx.modules.order.entity.TbOrder">
- select tor.*, tu.avatar as avatar, gs.shop_name as shopName, gs.detailed_address as detailedAddress, gs.phone as
- shopPhone,
- ti.rider_user_id as riderUserId, tcu.money as couponMoney,
- pd.trade_no as transactionId
- 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_coupon_user tcu on tor.coupon_id = tcu.id
- left join pay_details pd on pd.order_id = tor.order_number
- where 1 = 1 and tor.is_pay = 1
- <if test="shopName!=null and shopName!=''">
- and gs.shop_name like concat('%',#{shopName},'%')
- </if>
- <if test="userName!=null and userName!=''">
- and tor.user_name like concat('%',#{userName},'%')
- </if>
- <if test="phone!=null and phone!=''">
- and tor.phone like concat('%',#{phone},'%')
- </if>
- <if test="orderNumber!=null and orderNumber!=''">
- and tor.order_number = #{orderNumber}
- </if>
- <if test="status!=null and status!=5">
- and tor.status = #{status}
- </if>
- <if test="status!=null and status==5">
- and tor.status in (5, 8)
- </if>
- <if test="status==null">
- and tor.status in (7, 6, 3, 4, 5, 8)
- </if>
- <if test="shopId!=null">
- and tor.shop_id = #{shopId}
- </if>
- <if test="orderType!=null">
- and tor.order_type = #{orderType}
- </if>
- <if test="transactionId != null and transactionId != ''">
- and pd.trade_no = #{transactionId}
- </if>
- order by tor.pay_time desc, tor.create_time desc
- </select>
- <select id="selectAllOrderAdmin" resultType="com.sqx.modules.order.entity.TbOrder">
- select tor.*, tu.avatar as avatar, gs.shop_name as shopName, gs.detailed_address as detailedAddress, gs.phone as
- shopPhone,
- 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 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
- 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
- left join pay_details pd on pd.order_id = tor.order_number
- 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.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>
- <select id="excelAllOrderAdmin" resultType="com.sqx.modules.order.entity.TbOrder">
- select tor.*, tu.avatar as avatar, gs.shop_name as shopName, gs.detailed_address as detailedAddress, gs.phone as
- shopPhone,
- 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 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
- 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 ( 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="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>
- <select id="excelAllOrderAdminCount" resultType="java.lang.Integer">
- select count(1) 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
- 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>
- <select id="selectOrderByAdmin" resultType="com.sqx.modules.order.entity.TbOrder">
- select tor.*, tu.avatar as avatar, gs.shop_name as shopName from sys_user_shop sus
- left join tb_order tor on sus.shop_id = tor.shop_id
- left join tb_user tu on tor.user_id = tu.user_id
- left join goods_shop gs on tor.shop_id = gs.shop_id
- where 1 = 1 and sus.user_id = #{userId}
- and tor.is_pay = 1
- <if test="userName!=null and userName!=''">
- and tor.user_name like concat('%',#{userName},'%')
- </if>
- <if test="phone!=null and phone!=''">
- and tor.phone like concat('%',#{phone},'%')
- </if>
- <if test="orderNumber!=null and orderNumber!=''">
- and tor.order_number = #{orderNumber}
- </if>
- <if test="status!=null">
- and tor.status = #{status}
- </if>
- <if test="shopId!=null">
- and tor.shop_id = #{shopId}
- </if>
- <if test="orderType!=null">
- and tor.order_type = #{orderType}
- </if>
- order by tor.pay_time desc, tor.create_time desc
- </select>
- <select id="selectCountOrderByUserId" resultType="int">
- select count(*) from tb_order where user_id = #{userId}
- <if test="dateType=='day'">
- and date_format(pay_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
- </if>
- <if test="dateType=='month'">
- and date_format(pay_time,'%Y-%m')=date_format(#{date},'%Y-%m')
- </if>
- <if test="dateType=='year'">
- and date_format(pay_time,'%Y')=date_format(#{date},'%Y')
- </if>
- </select>
- <select id="selectSunMoneyByUserId" resultType="java.math.BigDecimal">
- select ifnull(sum(pay_money), 0) from tb_order where user_id = #{userId}
- <if test="dateType=='day'">
- and date_format(pay_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
- </if>
- <if test="dateType=='month'">
- and date_format(pay_time,'%Y-%m')=date_format(#{date},'%Y-%m')
- </if>
- <if test="dateType=='year'">
- and date_format(pay_time,'%Y')=date_format(#{date},'%Y')
- </if>
- </select>
- <select id="selectOrderDetails" resultType="com.sqx.modules.order.entity.TbOrder">
- select tor.*,
- gs.shop_name as shopName,
- gs.detailed_address as detailedAddress,
- gs.phone as shopPhone,
- tu.nick_name as riderNickName,
- tu.phone as riderPhone
- from tb_order tor
- 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 tu on ti.rider_user_id = tu.user_id
- where tor.user_id = #{userId}
- and tor.status in (7, 6, 3, 4, 5, 8)
- order by pay_time desc
- </select>
- <select id="waitTakeFood" resultType="com.sqx.modules.order.entity.TbOrder">
- select tor.*, tu.avatar as avatar, ti.rider_user_id as riderUserId, gs.shop_name as shopName, gs.shop_cover as
- shopCover, gs.detailed_address as detailedAddress,tu1.phone as riderPhone,gs.phone as shopPhone,ti.indent_state as indentState,
- (select count(*) from tb_order where order_type = 1 and status in (6, 3) and pay_time < tor.pay_time
- and shop_id = tor.shop_id) as countOrder
- from tb_order tor
- left join tb_user tu on tor.user_id = tu.user_id
- left join tb_indent ti on tor.order_id = ti.order_id
- left join goods_shop gs on tor.shop_id = gs.shop_id
- left join tb_user tu1 on ti.rider_user_id = tu1.user_id
- where tor.user_id = #{userId}
- and order_type = #{orderType}
- <if test="status!=null and status!=5">
- and tor.status = #{status}
- </if>
- <if test="status!=null and status==5">
- and tor.status =5
- </if>
- <if test="status==null">
- and tor.status in (0, 7, 6, 3, 4, 5, 8)
- </if>
- order by tor.pay_time desc, tor.create_time desc
- </select>
- <select id="selectCountOrderByTime" resultType="int">
- select count(*)
- from tb_order
- where order_type = 1
- and status = 3
- and pay_time < #{payTime}
- and shop_id = #{shopId}
- </select>
- <update id="deleteCouponByOrderId">
- update tb_order
- set coupon_id = null
- where order_id = #{orderId}
- </update>
- <select id="selectSumMoney" resultType="java.math.BigDecimal">
- select ifnull(sum(pay_money), 0) from tb_order where is_pay=1 and status in (0,3,4,7,6)
- <if test="query.shopId!=null">
- and shop_id=#{query.shopId}
- </if>
- <if test="query.dateType=='day'">
- and date_format(pay_time,'%Y-%m-%d')=date_format(#{query.date},'%Y-%m-%d')
- </if>
- <if test="query.dateType=='month'">
- and date_format(pay_time,'%Y-%m')=date_format(#{query.date},'%Y-%m')
- </if>
- <if test="query.dateType=='year'">
- and date_format(pay_time,'%Y')=date_format(#{query.date},'%Y')
- </if>
- <if test="query.startTime!=null and query.startTime!=''">
- and pay_time>=#{query.startTime}
- </if>
- <if test="query.endTime!=null and query.endTime!=''">
- and pay_time <![CDATA[<=]]> #{query.endTime}
- </if>
- </select>
- <select id="selectCountOrder" resultType="int">
- select count(*) from tb_order where is_pay=1 and status in (0,3,4,7,6)
- <if test="query.shopId!=null">
- and shop_id=#{query.shopId}
- </if>
- <if test="query.dateType=='day'">
- and date_format(pay_time,'%Y-%m-%d')=date_format(#{query.date},'%Y-%m-%d')
- </if>
- <if test="query.dateType=='month'">
- and date_format(pay_time,'%Y-%m')=date_format(#{query.date},'%Y-%m')
- </if>
- <if test="query.dateType=='year'">
- and date_format(pay_time,'%Y')=date_format(#{query.date},'%Y')
- </if>
- <if test="query.startTime!=null and query.startTime!=''">
- and pay_time>=#{query.startTime}
- </if>
- <if test="query.endTime!=null and query.endTime!=''">
- and pay_time <![CDATA[<=]]> #{query.endTime}
- </if>
- </select>
- <update id="updateorderStatus">
- update tb_order
- set status = 4
- where update_time < #{date}
- and status = 3
- </update>
- <select id="selectOrderByTimeList" resultType="com.sqx.modules.order.entity.TbOrder">
- select *
- from tb_order
- where update_time < #{date}
- and status = 3
- </select>
- <select id="selectShoppingTrolley" resultType="com.sqx.modules.order.entity.TbOrder">
- select t.*, gs.shop_name as shopName
- from tb_order t
- left join goods_shop gs on t.shop_id = gs.shop_id
- where t.status = 1
- and t.user_id = #{userId}
- order by t.add_goods_time desc
- </select>
- <select id="selectShoppingTrolleyByShopId" resultType="com.sqx.modules.order.entity.TbOrder">
- select t.*, gs.shop_name as shopName
- from tb_order t
- left join goods_shop gs on t.shop_id = gs.shop_id
- where t.status = 1
- and t.user_id = #{userId}
- and t.shop_id = #{shopId}
- order by t.add_goods_time desc
- </select>
- <select id="selectByOrderId" resultType="com.sqx.modules.order.entity.TbOrder">
- select tor.*,
- ti.indent_id as indentId,
- ti.indent_number as indentNumber,
- ti.rider_user_id as riderUserId,
- ti.indent_state as indentState,
- tu.nick_name as riderNickName,
- tu.avatar as riderAvatar,
- tu.phone as riderPhone,
- e.evaluate_message as evaluateMessage,
- e.shop_reply_message as shopReplyMessage,
- e.score as score,
- e.create_time as eCreateTime,
- tus.avatar as avatar,
- tus.nick_name as userNickName
- from tb_order tor
- left join tb_indent ti on tor.order_id = ti.order_id
- left join tb_user tu on ti.rider_user_id = tu.user_id
- left join tb_user tus on ti.user_id = tus.user_id
- left join evaluate e on tor.order_number = e.order_number
- where tor.order_id = #{orderId}
- </select>
- <select id="selectBuyGoods" 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.order_id = #{orderId}
- and tor.user_id = #{userId}
- </select>
- <select id="selectOverTimeOrder" resultType="com.sqx.modules.order.entity.TbOrder">
- select *
- from tb_order
- where status = 7
- and pay_time < #{overTime}
- </select>
- <select id="selectMakeOrdersList" resultType="com.sqx.modules.order.entity.TbOrder">
- select * from tb_order where status=6 and shop_receiving_time <![CDATA[ <= #{minusMinutes}]]></select>
- <select id="selectCurrentOrderSequenceByShopId" resultType="java.lang.Long">
- select
- order_id
- from
- tb_order
- where
- is_pay = 1
- and shop_id = #{shopId}
- and date(pay_time) = date(#{payTime})
- order by pay_time asc
- </select>
- <select id="countByShopIdAndActivityIdAndUserIdAndCurDate" resultType="java.lang.Integer">
- select
- count(1)
- from
- tb_order o
- left join activity_part_record apr on apr.order_id = o.order_id
- where
- o.shop_id = #{shopId}
- and o.user_id = #{userId}
- and date(o.create_time) = curdate()
- and apr.activity_id = #{activityId}
- and o.is_pay = 1
- <if test="orderId != null">
- and o.order_id != #{orderId}
- </if>
- </select>
- <select id="selectCurWaitReceivingOrderIds" resultType="java.lang.Long">
- select
- order_id
- from
- tb_order
- where
- reservation_flag = '1'
- and `status` = '7'
- and expect_delivery_time <![CDATA[ <= ]]> adddate(now(),interval 30 minute)
- </select>
- <select id="countUnFinishByShopId" resultType="java.lang.Integer">
- select count(order_id)
- from tb_order
- where shop_id = #{shopId} and status in (6, 3)
- </select>
- <select id="countCurDayPayByShopId" resultType="java.lang.Integer">
- select
- count(order_id)
- from
- tb_order
- where
- is_pay = 1
- 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>
- <select id="changeTimeOutOrder" resultType="com.sqx.modules.order.entity.TbOrder">
- SELECT o.*,
- pd.state as state
- FROM `tb_order` o
- LEFT JOIN pay_details pd ON o.order_number = pd.order_id
- WHERE o.`status` = 0
- AND o.time_out IS NOT NULL
- AND #{time} >= o.time_out
- AND pd.state in (0, 2)
- </select>
- </mapper>
|