| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863 |
- <?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.errand.dao.TbIndentDao">
- <select id="findNewIndent" resultType="com.sqx.modules.errand.entity.TbIndent">
- select * from (
- select ti.*,
- (st_distance (point (ti.shop_lng,ti.shop_lat),point(#{riderLng},#{riderLat}) ) *111195) AS distancess,
- (st_distance (point (ti.user_lng,ti.user_lat),point(#{riderLng},#{riderLat}) ) *111195) AS distancessd
- from tb_indent ti
- where ti.indent_state = 2
- ) a
- where 1=1
- <if test="distances!=null and distances!=''">
- and ((distancess is not null and distancess <= #{distances}) or (distancess is null and distancessd <=
- #{distances}))
- </if>
- <if test="indentType!=null and indentType!=''">
- and indent_type = #{indentType}
- </if>
- order by create_time desc
- </select>
- <select id="findNewIndentByDistances" resultType="com.sqx.modules.errand.entity.TbIndent">
- select * from (
- select ti.*,
- (st_distance (point (ti.shop_lng,ti.shop_lat),point(#{queryDTO.riderLng},#{queryDTO.riderLat}) ) * 111195) AS distancess,
- (st_distance (point (ti.user_lng,ti.user_lat),point(#{queryDTO.riderLng},#{queryDTO.riderLat}) ) * 111195) AS distancessd
- from tb_indent ti
- where ti.indent_state = 2
- ) a
- <where>
- <if test="queryDTO.distances!= null">
- and ((distancess is not null and distancess <= #{queryDTO.distances}) or (distancess is null and distancessd <= #{queryDTO.distances}))
- </if>
- <if test="queryDTO.indentType != null and queryDTO.indentType != ''">
- and indent_type = #{queryDTO.indentType}
- </if>
- <if test="queryDTO.buyType != null and queryDTO.buyType != ''">
- and buy_type = #{queryDTO.buyType}
- </if>
- <if test="queryDTO.shopId != null">
- and shop_id = #{queryDTO.shopId}
- </if>
- </where>
- order by create_time desc
- </select>
- <select id="findNewIndentByDistancesGroupByShop" resultType="com.sqx.modules.errand.vo.ShopWaitAcceptOrderVO">
- select shop_id, shop_name, count(indent_id) as countOfWaitAccept from (
- select
- shop_id, shop_name, indent_id,
- (st_distance(point(shop_lng,shop_lat), point(#{queryDTO.riderLng}, #{queryDTO.riderLat})) * 111195) AS distancess,
- (st_distance(point(user_lng,user_lat), point(#{queryDTO.riderLng}, #{queryDTO.riderLat})) * 111195) AS distancessd
- from
- tb_indent
- where indent_state = 2
- ) a
- <where>
- <if test="queryDTO.distances!= null">
- and ((distancess is not null and distancess <= #{queryDTO.distances}) or (distancess is null and distancessd <= #{queryDTO.distances}))
- </if>
- <if test="queryDTO.indentType != null and queryDTO.indentType != ''">
- and indent_type = #{queryDTO.indentType}
- </if>
- <if test="queryDTO.buyType != null and queryDTO.buyType != ''">
- and buy_type = #{queryDTO.buyType}
- </if>
- <if test="queryDTO.shopId != null">
- and shop_id = #{queryDTO.shopId}
- </if>
- </where>
- group by
- shop_id, shop_name
- order by
- distancess asc
- </select>
- <select id="findNewIndentcity" resultType="com.sqx.modules.errand.entity.TbIndent">
- select * from (
- select ti.*,
- (st_distance (point (ti.shop_lng,ti.shop_lat),point(#{riderLng},#{riderLat}) ) *111195) AS distancess,
- (st_distance (point (ti.user_lng,ti.user_lat),point(#{riderLng},#{riderLat}) ) *111195) AS distancessd
- from tb_indent ti
- where ti.indent_state = 2
- ) a
- where
- user_city like concat('%',#{address},'%')
- <if test="indentType!=null and indentType!=''">
- and indent_type = #{indentType}
- </if>
- order by distancess asc
- </select>
- <select id="findNewIndentByCity" resultType="com.sqx.modules.errand.entity.TbIndent">
- select * from (
- select ti.*,
- (st_distance (point (ti.shop_lng,ti.shop_lat),point(#{queryDTO.riderLng},#{queryDTO.riderLat}) ) * 111195) AS distancess,
- (st_distance (point (ti.user_lng,ti.user_lat),point(#{queryDTO.riderLng},#{queryDTO.riderLat}) ) * 111195) AS distancessd
- from tb_indent ti
- where ti.indent_state = 2
- ) a
- where
- user_city like concat('%',#{queryDTO.city},'%')
- <if test="queryDTO.indentType!=null and queryDTO.indentType!=''">
- and indent_type = #{queryDTO.indentType}
- </if>
- <if test="queryDTO.buyType != null and queryDTO.buyType != ''">
- and buy_type = #{queryDTO.buyType}
- </if>
- <if test="queryDTO.shopId != null">
- and shop_id = #{queryDTO.shopId}
- </if>
- order by distancess asc
- </select>
- <select id="findNewIndentByCityGroupByShop" resultType="com.sqx.modules.errand.vo.ShopWaitAcceptOrderVO">
- select
- shop_id, shop_name, count(indent_id) as countOfWaitAccept,
- (st_distance_sphere (point (shop_lng,shop_lat),point(115.82770500,28.70783200))) AS distancess
- from
- tb_indent
- where
- indent_state = 2
- and shop_city like concat('%',#{queryDTO.city},'%')
- <if test="queryDTO.indentType!=null and queryDTO.indentType!=''">
- and indent_type = #{queryDTO.indentType}
- </if>
- <if test="queryDTO.buyType != null and queryDTO.buyType != ''">
- and buy_type = #{queryDTO.buyType}
- </if>
- <if test="queryDTO.shopId != null">
- and shop_id = #{queryDTO.shopId}
- </if>
- group by
- shop_id, shop_name, shop_lng, shop_lat
- order by
- distancess asc
- </select>
- <select id="findIndentByNumber" resultType="com.sqx.modules.errand.entity.TbIndent">
- select *
- from tb_indent
- where indent_number = #{indentNumber}
- </select>
- <select id="findIndentByOrderId" resultType="com.sqx.modules.errand.entity.TbIndent">
- select *
- from tb_indent
- where order_id = #{orderId}
- </select>
- <select id="selectIndentByRiderUserCount" resultType="Integer">
- select count(*)
- from tb_indent
- where rider_user_id=#{riderUserId} and indent_state in (3,4)
- </select>
- <update id="indentReceiv">
- update tb_indent
- set indent_state = #{state},
- rider_user_id = #{userId},
- receiving_time = #{format}
- where indent_number = #{indentNumber}
- </update>
- <update id="indentReceiving">
- update tb_indent
- set indent_state = 3,
- rider_user_id = #{userId},
- receiving_time = #{format}
- where indent_number = #{indentNumber}
- </update>
- <update id="orderIndentReceiv">
- update tb_indent
- set indent_state = #{state},
- rider_user_id = #{userId},
- receiving_time = #{format}
- where order_id = #{orderId}
- </update>
- <update id="orderIndentReceiving">
- update tb_indent
- set indent_state = 3,
- rider_user_id = #{userId},
- receiving_time = #{format}
- where order_id = #{orderId}
- </update>
- <select id="findRiderIndent" resultType="com.sqx.modules.errand.entity.TbIndent">
- select * from tb_indent where rider_user_id = #{userId}
- <if test="indentState!=''">
- <if test="indentState==0">
- and indent_state = 0
- </if>
- <if test="indentState==2">
- and indent_state = 2
- </if>
- <if test="indentState==3">
- and indent_state = 3
- </if>
- <if test="indentState==4">
- and indent_state = 4
- </if>
- <if test="indentState==5">
- and indent_state = 5
- </if>
- <if test="indentState==6">
- and indent_state = 6
- </if>
- <if test="indentState==8 or indentState==9 or indentState==10">
- and (indent_state = 8 or indent_state = 9 or indent_state = 10)
- </if>
- </if>
- order by receiving_time desc
- </select>
- <select id="indentRiderMessage" resultType="com.sqx.modules.errand.entity.TbIndent">
- select ti.*,
- (st_distance(point(ti.shop_lng, ti.shop_lat), point(#{riderLng}, #{riderLat})) * 111195) AS distancess,
- (st_distance(point(ti.user_lng, ti.user_lat), point(#{riderLng}, #{riderLat})) * 111195) AS distancessd,
- u.nick_name as nickName,
- u.phone as phone,
- u.avatar as avatar
- from tb_indent ti
- left join tb_user u on ti.user_id = u.user_id
- where indent_number = #{indentNumber}
- </select>
- <select id="indentMessageByOrderId" resultType="com.sqx.modules.errand.entity.TbIndent">
- select ti.*,
- (st_distance(point(ti.shop_lng, ti.shop_lat), point(#{riderLng}, #{riderLat})) * 111195) AS distancess,
- (st_distance(point(ti.user_lng, ti.user_lat), point(#{riderLng}, #{riderLat})) * 111195) AS distancessd,
- u.nick_name as nickName,
- u.phone as phone,
- u.avatar as avatar
- from tb_indent ti
- left join tb_user u on ti.user_id = u.user_id
- where order_id = #{orderId}
- </select>
- <update id="riderCancleIndent">
- update tb_indent
- set indent_state = 2,
- receiving_time = null,
- rider_user_id = null
- where rider_user_id = #{riderUserId}
- and indent_number = #{indentNumber}
- </update>
- <update id="updateRiderCashDeposit">
- update tb_user
- set cash_deposit = #{cashDeposit}
- where user_id = #{userId}
- </update>
- <update id="riderDelivery">
- update tb_indent
- set indent_state = 6,
- finish_time = #{date}
- where indent_id = #{indentId}
- </update>
- <select id="selectIndentByIndentNumber" resultType="com.sqx.modules.errand.entity.TbIndent">
- select ti.*, t.nick_name as nickName, t.avatar
- from tb_indent ti
- LEFT JOIN tb_user t on ti.user_id = t.user_id
- where indent_number = #{indentNumber}
- </select>
- <update id="updateRiderBalance">
- update tb_user
- set balance = #{balance}
- where user_id = #{userId}
- </update>
- <update id="userDelivery">
- update tb_indent
- set indent_state = 6,
- finish_time = #{date}
- where user_id = #{userId}
- and indent_number = #{indentNumber}
- </update>
- <select id="findallIndent" resultType="com.sqx.modules.errand.entity.TbIndent">
- select i.*,
- ru.nick_name as riderNickName, ru.phone as riderPhone
- from tb_indent i
- LEFT JOIN tb_user ru on i.rider_user_id = ru.user_id
- where 1 = 1
- <if test="riderPhone!=null and riderPhone!=''">
- and ru.phone = #{riderPhone}
- </if>
- <if test="userId!=null">
- and i.user_id = #{userId}
- </if>
- <if test="riderUserId!=null">
- and i.rider_user_id = #{riderUserId}
- </if>
- <if test="shopId!=null">
- and i.shop_id = #{shopId}
- </if>
- <if test="indentType!=null">
- and i.indent_type=#{indentType}
- </if>
- <if test="indentType==null">
- and i.indent_type in (1, 2, 3, 4)
- </if>
- <if test="ordersNo!=null and ordersNo!=''">
- and i.indent_number=#{ordersNo}
- </if>
- <if test="status!=null">
- and i.indent_state=#{status}
- </if>
- order by i.create_time desc
- </select>
- <update id="updateDefault">
- update errand_address
- set address_default = "0"
- where user_id = #{userId}
- </update>
- <insert id="addUserAddress" useGeneratedKeys="true" keyProperty="addressId"
- parameterType="com.sqx.modules.errand.entity.ErrandAddress">
- insert into errand_address (user_id, user_name, user_phone, address, address_detail, address_longitude,
- address_latitude, create_time, delete_flag, address_default)
- values (#{userId}, #{userName}, #{userPhone}, #{address}, #{addressDetail}, #{addressLongitude},
- #{addressLatitude}, #{createTime}, "0", #{addressDefault})
- </insert>
- <update id="updateAddress">
- update errand_address set
- update_time = #{updatetime},
- <if test="userName!=null and userName!=''">
- user_name= #{userName},
- </if>
- <if test="userPhone!=null and userPhone!=''">
- user_phone = #{userPhone},
- </if>
- <if test="address!=null and address!=''">
- address = #{address},
- </if>
- <if test="addressDetail!=null and addressDetail!=''">
- address_detail = #{addressDetail},
- </if>
- <if test="lng!=null and lng!=''">
- address_longitude = #{lng},
- </if>
- <if test="lat!=null and lat!=''">
- address_latitude = #{lat},
- </if>
- <if test="addressDefault!=null and addressDefault!=''">
- address_default = #{addressDefault}
- </if>
- where user_id = #{userId} and address_id = #{addressId}
- </update>
- <select id="findUserAddress" resultType="com.sqx.modules.errand.entity.ErrandAddress">
- select *
- from errand_address
- where user_id = #{userId}
- and delete_flag = "0"
- </select>
- <select id="findAddressById" resultType="com.sqx.modules.errand.entity.ErrandAddress">
- select *
- from errand_address
- where user_id = #{userId}
- and address_id = #{addressId}
- </select>
- <update id="addDefaultAddress">
- update errand_address
- set address_default = "1"
- where user_id = #{userId}
- and address_id = #{addressId}
- </update>
- <update id="delUserAddress">
- update errand_address
- set delete_flag = "1"
- where user_id = #{userId}
- and address_id = #{addressId}
- </update>
- <select id="findRed" resultType="com.sqx.modules.errand.entity.ErrandRedPacket">
- select *
- from errand_user_red_packet
- where red_packet_id = #{redPacketId}
- </select>
- <update id="delRedPacket">
- update errand_user_red_packet
- set delete_flag = "1"
- where red_packet_id = #{redPacketId}
- </update>
- <select id="findAllIndent" resultType="com.sqx.modules.errand.entity.TbIndent">
- select i.*, t.nick_name as nickName, t.avatar as avatar , r.red_packet_amount as redPacketAmount,
- ru.nick_name as riderNickName, ru.phone as riderPhone,
- from tb_indent i
- LEFT JOIN tb_user t on i.user_id = t.user_id
- LEFT JOIN tb_user ru on i.rider_user_id = ru.user_id
- LEFT JOIN errand_user_red_packet r on i.red_packet_id = r.red_packet_id where indent_type = #{indentType}
- <if test="phone!=null and phone!=''">
- and user_phone = #{phone}
- </if>
- <if test="riderPhone!=null and riderPhone!=''">
- and ru.phone = #{riderPhone}
- </if>
- <if test="indentState==0">
- and indent_state in (0, 1, 2, 3 ,4 ,5 ,6 ,8 ,10)
- </if>
- <if test="indentState==1">
- and indent_state = 0
- </if>
- <if test="indentState==2">
- and indent_state = 2
- </if>
- <if test="indentState==3">
- and indent_state in (3, 4, 5)
- </if>
- <if test="indentState==4">
- and indent_state = 6
- </if>
- <if test="indentState==5">
- and indent_state in (1, 8, 10)
- </if>
- <if test="dateType=='day'">
- and date_format(i.create_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
- </if>
- <if test="dateType=='month'">
- and date_format(i.create_time,'%Y-%m')=date_format(#{date},'%Y-%m')
- </if>
- <if test="dateType=='year'">
- and date_format(i.create_time,'%Y')=date_format(#{date},'%Y')
- </if>
- order by i.create_time desc
- </select>
- <select id="findAllIndents" resultType="com.sqx.modules.errand.entity.TbIndent">
- select i.*, t.nick_name as nickName, t.avatar as avatar ,
- ru.nick_name as riderNickName, ru.phone as riderPhone,
- r.red_packet_amount as redPacketAmount from tb_indent i
- LEFT JOIN tb_user t on i.user_id = t.user_id
- LEFT JOIN tb_user ru on i.rider_user_id = ru.user_id
- LEFT JOIN errand_user_red_packet r on i.red_packet_id = r.red_packet_id where indent_type = #{indentType}
- <if test="phone!=null and phone!=''">
- and user_phone = #{phone}
- </if>
- <if test="riderPhone!=null and riderPhone!=''">
- and ru.phone = #{riderPhone}
- </if>
- <if test="indentState==0">
- and indent_state in (0, 1, 2, 3 ,4 ,5 ,6 ,8 ,10)
- </if>
- <if test="indentState!=0">
- and indent_state = #{indentState}
- </if>
- <if test="dateType=='day'">
- and date_format(i.create_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
- </if>
- <if test="dateType=='month'">
- and date_format(i.create_time,'%Y-%m')=date_format(#{date},'%Y-%m')
- </if>
- <if test="dateType=='year'">
- and date_format(i.create_time,'%Y')=date_format(#{date},'%Y')
- </if>
- order by i.create_time desc
- </select>
- <select id="IndentCenter" resultType="com.sqx.modules.errand.entity.TbIndent">
- select i.*, u.nick_name as nickName, u.phone as phone from tb_indent i left join tb_user u on u.user_id =
- i.rider_user_id where 1 = 1
- <if test="indentType!=null and indentType!=''">
- and indent_type = #{indentType}
- </if>
- <if test="indentNumber!=null and indentNumber!=''">
- and indent_number = #{indentNumber}
- </if>
- <if test="indentState!=null and indentState!=''">
- and indent_state = #{indentState}
- </if>
- <if test="indentState==null or indentState==''">
- and indent_state in (3,4,5,6)
- </if>
- <if test="dateType=='day'">
- and date_format(i.create_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
- </if>
- <if test="dateType=='month'">
- and date_format(i.create_time,'%Y-%m')=date_format(#{date},'%Y-%m')
- </if>
- <if test="dateType=='year'">
- and date_format(i.create_time,'%Y')=date_format(#{date},'%Y')
- </if>
- <if test="phone!=null and phone!=''">
- and u.phone like concat('%',#{phone},'%')
- </if>
- order by i.create_time desc
- </select>
- <update id="updateIndentState">
- update tb_indent
- set indent_state = #{indentState}
- where indent_number = #{indentNumber}
- </update>
- <update id="adminSoldOutIndent">
- update tb_indent
- set indent_state = 10
- where indent_number = #{indentNumber}
- </update>
- <select id="billMoney" resultType="java.math.BigDecimal">
- select ifnull(sum(indent_money),0) from tb_indent where indent_state in (2, 3, 4, 6)
- <if test="dateType=='day'">
- and date_format(create_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
- </if>
- <if test="dateType=='month'">
- and date_format(create_time,'%Y-%m')=date_format(#{date},'%Y-%m')
- </if>
- <if test="dateType=='year'">
- and date_format(create_time,'%Y')=date_format(#{date},'%Y')
- </if>
- </select>
- <select id="receivingMoney" resultType="java.math.BigDecimal">
- select ifnull(sum(indent_money),0) from tb_indent where indent_state in (3, 4, 6)
- <if test="dateType=='day'">
- and date_format(create_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
- </if>
- <if test="dateType=='month'">
- and date_format(create_time,'%Y-%m')=date_format(#{date},'%Y-%m')
- </if>
- <if test="dateType=='year'">
- and date_format(create_time,'%Y')=date_format(#{date},'%Y')
- </if>
- </select>
- <select id="billCount" resultType="int">
- select count(*) from tb_indent
- where indent_state in (2, 3, 4, 6)
- <if test="dateType=='day'">
- and date_format(create_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
- </if>
- <if test="dateType=='month'">
- and date_format(create_time,'%Y-%m')=date_format(#{date},'%Y-%m')
- </if>
- <if test="dateType=='year'">
- and date_format(create_time,'%Y')=date_format(#{date},'%Y')
- </if>
- </select>
- <select id="reveivingCount" resultType="int">
- select count(*) from tb_indent where indent_state in (3, 4, 6)
- <if test="dateType=='day'">
- and date_format(create_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
- </if>
- <if test="dateType=='month'">
- and date_format(create_time,'%Y-%m')=date_format(#{date},'%Y-%m')
- </if>
- <if test="dateType=='year'">
- and date_format(create_time,'%Y')=date_format(#{date},'%Y')
- </if>
- </select>
- <select id="taskAnalysisMoney" resultType="com.sqx.modules.errand.entity.TbIndent">
- select s.indent_type,t.nick_name as nickName,u.nick_name as riderNickName, s.create_time, s.platform_money,
- s.user_id, s.rider_user_id from tb_indent s
- left join tb_user t on s.user_id = t.user_id
- left join tb_user u on s.rider_user_id = u.user_id
- where indent_state = "6"
- <if test="dateType=='day'">
- and date_format(s.create_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
- </if>
- <if test="dateType=='month'">
- and date_format(s.create_time,'%Y-%m')=date_format(#{date},'%Y-%m')
- </if>
- <if test="dateType=='year'">
- and date_format(s.create_time,'%Y')=date_format(#{date},'%Y')
- </if>
- <if test="indentState!=null and indentState!=''">
- and s.indent_state = #{status}
- </if>
- order by s.create_time desc
- </select>
- <select id="findAllCount" resultType="int">
- select count(*)
- from tb_user
- where status = "1"
- </select>
- <select id="findDayAddUser" resultType="int">
- select count(*)
- from tb_user
- where status = "1"
- and create_time > #{date}
- </select>
- <select id="findMonthAddUser" resultType="int">
- select count(*)
- from tb_user
- where status = "1"
- and create_time > #{date}
- </select>
- <select id="findYearAddUser" resultType="int">
- select count(*)
- from tb_user
- where status = "1"
- and create_time > #{date}
- </select>
- <select id="findDayIncome" resultType="java.math.BigDecimal">
- select ifnull(sum(platform_money), 0)
- from tb_indent
- where indent_state = "6"
- and create_time > #{date}
- </select>
- <select id="findMonthIncome" resultType="java.math.BigDecimal">
- select ifnull(sum(platform_money), 0)
- from tb_indent
- where indent_state = "6"
- and create_time > #{date}
- </select>
- <select id="findYearIncome" resultType="java.math.BigDecimal">
- select ifnull(sum(platform_money), 0)
- from tb_indent
- where indent_state = "6"
- and create_time > #{date}
- </select>
- <select id="findIndentCount" resultType="int">
- select count(*)
- from tb_indent
- where indent_state = "6"
- </select>
- <select id="selectOrderByStatus" resultType="int">
- select count(*) from tb_indent where 1 = 1
- <if test="status!=null">
- and indent_state = #{status}
- </if>
- <if test="dateType=='day'">
- and date_format(create_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
- </if>
- <if test="dateType=='month'">
- and date_format(create_time,'%Y-%m')=date_format(#{date},'%Y-%m')
- </if>
- <if test="dateType=='year'">
- and date_format(create_time,'%Y')=date_format(#{date},'%Y')
- </if>
- </select>
- <select id="findAdminIncomeday" resultType="java.math.BigDecimal">
- select ifnull(sum(rider_money),0) from tb_indent where rider_user_id = #{userId} and indent_state = "6"
- <if test="dateType=='day'">
- and date_format(finish_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
- </if>
- <if test="dateType=='month'">
- and date_format(finish_time,'%Y-%m')=date_format(#{date},'%Y-%m')
- </if>
- <if test="dateType=='year'">
- and date_format(finish_time,'%Y')=date_format(#{date},'%Y')
- </if>
- </select>
- <select id="findPrepayMoney" resultType="java.math.BigDecimal">
- select ifnull(sum(prepay_money),0) from tb_indent where rider_user_id = #{userId} and indent_state = "6"
- <if test="dateType=='day'">
- and date_format(finish_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
- </if>
- <if test="dateType=='month'">
- and date_format(finish_time,'%Y-%m')=date_format(#{date},'%Y-%m')
- </if>
- <if test="dateType=='year'">
- and date_format(finish_time,'%Y')=date_format(#{date},'%Y')
- </if>
- </select>
- <select id="findAdminIndentCount" resultType="int">
- select count(*) from tb_indent where rider_user_id = #{userId} and indent_state = "6"
- <if test="dateType=='day'">
- and date_format(finish_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
- </if>
- <if test="dateType=='month'">
- and date_format(finish_time,'%Y-%m')=date_format(#{date},'%Y-%m')
- </if>
- <if test="dateType=='year'">
- and date_format(finish_time,'%Y')=date_format(#{date},'%Y')
- </if>
- </select>
- <select id="selectIndentById" resultType="com.sqx.modules.errand.entity.TbIndent">
- select * from tb_indent where rider_user_id = #{userId} and indent_state = "6"
- <if test="dateType=='day'">
- and date_format(finish_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
- </if>
- <if test="dateType=='month'">
- and date_format(finish_time,'%Y-%m')=date_format(#{date},'%Y-%m')
- </if>
- <if test="dateType=='year'">
- and date_format(finish_time,'%Y')=date_format(#{date},'%Y')
- </if>
- order by create_time desc
- </select>
- <select id="findUserIndent" resultType="com.sqx.modules.errand.entity.TbIndent">
- select t.*,(select count(*) from errand_evaluate e where e.user_id=#{userId} and t.indent_number=e.indent_number) as evaluateMessage
- from tb_indent t where t.user_id = #{userId} and t.indent_type != 5
- <if test="indentState==1">
- and t.indent_state in ("0", "2", "3", "4", "6", "8", "9", "10")
- </if>
- <if test="indentState==2">
- and t.indent_state = "0"
- </if>
- <if test="indentState==3">
- and t.indent_state = "2"
- </if>
- <if test="indentState==4">
- and t.indent_state = "3"
- </if>
- <if test="indentState==5">
- and t.indent_state = "4"
- </if>
- <if test="indentState==6">
- and t.indent_state = "6"
- </if>
- <if test="indentState==7">
- and t.indent_state in ("8", "9", "10")
- </if>
- order by t.create_time desc
- </select>
- <select id="indentMessage" resultType="com.sqx.modules.errand.entity.TbIndent">
- select i.*,
- r.red_packet_amount as redPacketAmount,
- u.nick_name as riderNickName,
- u.phone as phone,
- u.avatar as avatar
- from tb_indent i
- left join tb_user u on i.rider_user_id = u.user_id
- left join errand_user_red_packet r on i.red_packet_id = r.red_packet_id
- where indent_number = #{indentNumber}
- </select>
- <select id="find5KmRider" resultType="com.sqx.modules.app.entity.UserEntity">
- SELECT *
- FROM tb_user
- WHERE (st_distance(point(station_lng, station_lat), point(#{lng}, #{lat})) * 111195) < 50000
- and user_type = "2"
- and on_line_flag = "1"
- </select>
- <update id="updateCoordinate">
- update tb_user
- set station_lng = #{lng},
- station_lat = #{lat}
- where user_id = #{userId}
- </update>
- <select id="findUserInfoById" resultType="com.sqx.modules.app.entity.UserEntity">
- select *
- from tb_user
- where user_id = #{userId}
- </select>
- <select id="findAllRedPacket" resultType="com.sqx.modules.errand.entity.ErrandRedPacket">
- select *
- from errand_user_red_packet
- where user_id = #{userId}
- and delete_flag = "0"
- and expiration_time > #{expirationTime}
- </select>
- <!--获取可用红包-->
- <select id="findRedPacket" resultType="com.sqx.modules.errand.entity.ErrandRedPacket">
- select *
- from errand_user_red_packet
- where user_id = #{userId}
- and (red_packet_type = "0" or red_packet_type = #{indentType})
- and minimum_amount <= #{indentBasicsMoney}
- and expiration_time > #{expirationTime}
- and delete_flag = "0"
- order by create_time desc
- </select>
- <update id="userCancleIndent">
- update tb_indent
- set indent_state = "8",
- cancel_indent_time = #{cancelIndentTime}
- where user_id = #{userId}
- and indent_number = #{indentNumber}
- </update>
- <update id="updateRedPaclet">
- update errand_user_red_packet
- set delete_flag = "0"
- where red_packet_id = #{redPacketId}
- </update>
- <select id="selectIndentList" resultType="com.sqx.modules.errand.entity.TbIndent">
- select *
- from tb_indent
- where rider_user_id = #{userId}
- and indent_state in (3, 4)
- </select>
- <select id="selectSendOrder" resultType="com.sqx.modules.errand.entity.TbIndent">
- select *
- from tb_indent
- where indent_state = 2
- and indent_type in (1, 2, 3, 5)
- and create_time < #{date}
- </select>
- <select id="selectRiderByDictance" resultType="Long">
- select user_id
- from (
- SELECT t.user_id,
- (select count(*) from tb_indent i
- where i.rider_user_id=t.user_id and i.indent_state in (3,4)) as ordersCount ,
- (st_distance(point(t.station_lat, t.station_lng), point(#{userLat}, #{userLng})) *
- 111195) AS distance
- FROM tb_user t
- WHERE t.on_line_flag = 1
- and t.cash_deposit >= #{cashDeposit}
- and user_id not in (select rider_user_id from tb_indent where indent_state in (3, 4))
- ) a
- where distance < #{distance} and ordersCount < #{maxNum}
- order by distance asc limit 1
- </select>
- <!--
- 现在根据订单地址,查出了距离该位置最近的骑手
- 但是还要再加一个条件:要查出距离该订单最近的,没有进行中的订单的骑手
- 判断骑手是否有订单在进行中:indent_state in (3, 4)
- select * from (
- SELECT
- t.user_id,
- ti.indent_id,
- (st_distance (point (t.station_lat, t.station_lng),point (34.16351, 108.65161)) * 111195) AS distance
- FROM
- tb_user t
- LEFT JOIN tb_indent ti ON t.user_id = ti.rider_user_id
- WHERE
- ti.indent_state NOT IN (3, 4) and t.on_line_flag = 1
- ) a where distance<100000 order by distance asc limit 1
- ====================================
- select tu.user_id, (st_distance (point (station_lat, station_lng), point(#{userLat},#{userLng}) ) *111195) as distance
- from tb_user tu where ((st_distance (point (station_lat, station_lng), point(#{userLat},#{userLng}) ) *111195)) < #{distance}
- order by distance asc limit 1
- -->
- </mapper>
|