| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397 |
- <?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.ylx.order.mapper.TOrderMapper">
- <resultMap id="getAllMap" type="com.ylx.order.domain.TOrder">
- <id column="c_id" property="cId"/>
- <result column="order_no" property="orderNo"/>
- <result column="atlas_add" property="atlasAdd"/>
- <result column="pay_type" property="payType"/>
- <result column="preferential" property="preferential"/>
- <result column="order_type" property="orderType"/>
- <result column="virtual_order_flag" property="virtualOrderFlag"/>
- <result column="virtual_order_allocation" property="virtualOrderAllocation"/>
- <result column="price_difference" property="priceDifference"/>
- <result column="c_js_id" property="cJsId"/>
- <result column="tape" property="tape"/>
- <result column="dept_id" property="deptId"/>
- <result column="distance" property="distance"/>
- <result column="dept_name" property="deptName"/>
- <result column="order_type" property="orderType"/>
- <result column="price_difference" property="priceDifference"/>
- <result column="new_js_id" property="newJsId"/>
- <result column="fare" property="fare"/>
- <result column="total_price" property="totalPrice"/>
- <result column="parent_no" property="parentNo"/>
- <result column="c_open_id" property="cOpenId"/>
- <result column="timeout_cause" property="timeoutCause"/>
- <result column="coupon_receive_id" property="couponReceiveId"/>
- <result column="c_goods" property="cGoods"
- typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
- <result column="d_total_money" property="dTotalMoney"/>
- <result column="n_status" property="nStatus"/>
- <result column="c_address" property="cAddress"/>
- <result column="c_name" property="cName"/>
- <result column="c_phone" property="cPhone"/>
- <result column="c_note" property="cNote"/>
- <result column="c_time" property="cTime"/>
- <result column="name" property="name"/>
- <result column="address" property="address"/>
- <result column="longitude" property="longitude"/>
- <result column="latitude" property="latitude"/>
- <result column="arrival_longitude" property="arrivalLongitude"/>
- <result column="arrival_latitude" property="arrivalLatitude"/>
- <result column="depart_longitude" property="departLongitude"/>
- <result column="depart_latitude" property="departLatitude"/>
- <result column="arrival_photo" property="arrivalPhoto"/>
- <result column="depart_time" property="departTime"/>
- <result column="c_tj_open_id" property="cTjOpenId"/>
- <result column="old_js_id" property="oldJsId"/>
- <result column="dt_create_time" property="dtCreateTime"/>
- <result column="acceptance_time" property="acceptanceTime"/>
- <result column="reach_time" property="reachTime"/>
- <result column="start_time" property="startTime"/>
- <result column="pay_time" property="payTime"/>
- <result column="end_time" property="endTime"/>
- <result column="reason_refusal" property="reasonRefusal"/>
- <association property="js" javaType="com.ylx.massage.domain.TJs">
- <id column="jsc_id" property="cOpenId"/>
- <result column="jsc_bh_list" property="cBhList"/>
- <result column="jsc_img_list" property="cImgList"
- typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
- <result column="jsn_sex" property="nSex"/>
- <result column="jsc_nick_name" property="cNickName"/>
- <result column="jsc_portrait" property="cPortrait"/>
- <result column="jsc_name" property="cName"/>
- <result column="jsc_phone" property="cPhone"/>
- <result column="jsc_jianjie" property="cJianjie"/>
- <result column="jsn_star" property="nStar"/>
- <result column="jsn_bili" property="nBili"/>
- <result column="jsn_num" property="nNum"/>
- <result column="jsn_status" property="nStatus"/>
- <result column="jsn_status2" property="nStatus2"/>
- <result column="jsn_tong" property="nTong"/>
- <result column="jsc_time" property="cTime"/>
- <result column="jsn_b1" property="nB1"/>
- <result column="jsn_b2" property="nB2"/>
- <result column="jsn_b3" property="nB3"/>
- <result column="jsn_b3" property="nB3"/>
- </association>
- <association property="wxUser" javaType="com.ylx.massage.domain.TWxUser">
- <id column="wxUserc_openid" property="cOpenid"/>
- <result column="wxUsercc_icon" property="cIcon"/>
- <result column="wxc_nick_name" property="cNickName"/>
- </association>
- </resultMap>
- <!-- 查询所有订单(PC端 H5端) -->
- <select id="getAll" resultMap="getAllMap">
- select t_order.c_id,
- t_order.order_no,
- t_order.atlas_add,
- t_order.pay_type,
- t_order.c_js_id,
- t_order.order_type,
- t_order.virtual_order_flag,
- t_order.virtual_order_allocation,
- t_order.price_difference,
- t_order.tape,
- t_order.fare,
- t_order.total_price,
- t_order.parent_no,
- t_order.c_open_id,
- t_order.c_goods,
- t_order.d_total_money,
- t_order.n_status,
- t_order.c_address,
- t_order.c_name,
- t_order.c_phone,
- t_order.c_note,
- t_order.c_time,
- t_order.pay_time,
- t_order.timeout_cause,
- t_order.name,
- t_order.dept_id,
- t_order.dept_name,
- t_order.latitude,
- t_order.longitude,
- t_order.address,
- t_order.c_tj_open_id,
- t_order.dt_create_time,
- t_order.acceptance_time,
- t_order.reach_time,
- t_order.old_js_id,
- t_order.start_time,
- t_order.arrival_longitude,
- t_order.arrival_latitude,
- t_order.depart_longitude,
- t_order.depart_latitude,
- t_order.arrival_photo,
- t_order.depart_time,
- t_order.end_time,
- t_order.preferential,
- t_order.distance,
- t_order.reason_refusal,
- t_js.c_open_id as jsc_open_id,
- t_js.c_bh_list as jsc_bh_list,
- t_js.c_img_list as jsc_img_list,
- t_js.c_sfz_img as jsc_sfz_img,
- t_js.n_sex as jsn_sex,
- t_js.c_nick_name as jsc_nick_name,
- t_js.c_portrait as jsc_portrait,
- t_js.c_name as jsc_name,
- t_js.c_phone as jsc_phone,
- t_js.c_address as jsc_address,
- t_js.c_jianjie as jsc_jianjie,
- t_js.n_star as jsn_star,
- t_js.n_bili as jsn_bili,
- t_js.n_num as jsn_num,
- t_js.n_status as jsn_status,
- t_js.n_status2 as jsn_status2,
- t_js.n_tong as jsn_tong,
- t_js.c_time as jsc_time,
- t_js.n_b1 as jsn_b1,
- t_js.n_b2 as jsn_b2,
- t_js.n_b3 as jsn_b3,
- t_js.dt_create_time as jsdt_create_time,
- t_wx_user.c_openid as wxUserc_openid,
- t_wx_user.c_icon as wxUsercc_icon,
- t_wx_user.c_nick_name as wxc_nick_name
- from t_order
- left join
- t_js on
- t_order.c_js_id = t_js.id
- left join
- t_wx_user on
- t_wx_user.c_openid = t_order.c_open_id
- <where>
- t_order.is_delete = 0 and t_js.is_delete = 0 and t_wx_user.is_delete = 0
- and t_order.n_status != 8 and t_order.n_status != -2 and t_order.n_status != -3
- and t_order.n_status != -1
- <if test="param.cId != null and param.cId != ''">
- and t_order.c_id = #{ param.cId }
- </if>
- <if test="param.cName != null and param.cName != ''">
- and t_order.c_name like concat('%',#{param.cName},'%')
- </if>
- <if test="param.cNickName != null and param.cNickName != ''">
- and t_js.c_nick_name like concat('%',#{param.cNickName},'%')
- </if>
- <if test="param.jsName != null and param.jsName != ''">
- and t_js.c_name like concat('%',#{param.jsName},'%')
- </if>
- <if test="param.jsPhone != null and param.jsPhone != ''">
- and t_js.c_phone like concat('%',#{param.jsPhone},'%')
- </if>
- <if test="param.cPhone != null and param.cPhone != ''">
- and t_order.c_phone = #{param.cPhone}
- </if>
- <if test="param.orderNo != null and param.orderNo != ''">
- and t_order.order_no = #{ param.orderNo }
- </if>
- <!-- 订单状态(-1:待付款 0:待接单 1:已接单 6:已出发 2:已到达 3:服务中 4:待评价 5:已完成
- 7:退单待审核 8:退单审核通过 -2:已取消 -3:已拒绝) -->
- <!--<if test="param.nStatus != null and param.nStatus != 10 and param.nStatus != -10 and param.nStatus != 100">-->
- <!-- and t_order.n_status = #{ param.nStatus }-->
- <!--</if>-->
- <!--<if test="param.nStatus == 10">-->
- <!-- and t_order.n_status in(0,1,2,3)-->
- <!--</if>-->
- <!--<if test="param.nStatus == -10">-->
- <!-- and t_order.n_status in(-2,-3)-->
- <!--</if>-->
- <if test="param.nStatus != null">
- and t_order.n_status = #{ param.nStatus }
- </if>
- <if test="param.wStatus != null">
- and t_order.w_status = #{ param.wStatus }
- </if>
- <if test="param.cJsId != null and param.cJsId != ''">
- and t_order.c_js_id = #{ param.cJsId }
- </if>
- <if test="param.deptId != null and param.deptId != '' and param.deptId != 100">
- and t_order.dept_id = #{ param.deptId }
- </if>
- <if test="param.cOpenId != null and param.cOpenId != ''">
- and t_order.c_open_id = #{ param.cOpenId }
- </if>
- <if test="param.dtCreateTimeBegin != null and param.dtCreateTimeBegin != '' and param.dtCreateTimeTimeEnd != null and param.dtCreateTimeTimeEnd != ''">
- and t_order.dt_create_time between #{ param.dtCreateTimeBegin } and #{ param.dtCreateTimeTimeEnd }
- </if>
- <if test="param.payTimeBegin != null and param.payTimeBegin != '' and param.payTimeEnd != null and param.payTimeEnd != ''">
- and t_order.pay_time between #{param.payTimeBegin} and #{param.payTimeEnd}
- </if>
- </where>
- order by
- t_order.dt_create_time desc
- </select>
- <select id="getOrderNum" resultType="java.lang.Integer">
- SELECT count(1)
- FROM t_order
- WHERE is_delete = 0
- AND c_js_id = #{jsid}
- AND end_time BETWEEN #{startDate} AND #{endDate}
- AND n_status in (4, 5)
- </select>
- <select id="getAddNum" resultType="java.lang.Integer">
- SELECT count(1)
- FROM t_order
- WHERE is_delete = 0
- AND c_js_id = #{jsid}
- AND end_time BETWEEN #{startDate} AND #{endDate}
- AND n_status in (4, 5)
- and order_type = 1
- </select>
- <select id="getUpgradeNum" resultType="java.lang.Integer">
- SELECT count(1)
- FROM t_order
- WHERE is_delete = 0
- AND c_js_id = #{jsid}
- AND end_time BETWEEN #{startDate} AND #{endDate}
- AND n_status in (4, 5)
- and order_type = 2
- </select>
- <select id="getTurnover" resultType="java.math.BigDecimal">
- SELECT sum(total_price)
- FROM t_order
- WHERE is_delete = 0
- AND c_js_id = #{jsid}
- AND end_time BETWEEN #{startDate} AND #{endDate}
- AND n_status in (4, 5)
- </select>
- <select id="getBlock" resultType="com.ylx.massage.domain.vo.HomeBlock">
- SELECT
- DATE_FORMAT( end_time, '%Y-%m' ) AS month,
- SUM( total_price ) AS turnover,
- count(1) orderNum
- FROM
- t_order
- WHERE
- is_delete = 0
- AND end_time IS NOT NULL
- AND end_time BETWEEN #{start} AND #{end}
- AND n_status in (4, 5)
- <if test="deptId != 100 and deptId != ''">
- AND dept_id = #{deptId}
- </if>
- GROUP BY
- month
- ORDER BY
- month;
- </select>
- <select id="callAutoAccount" statementType="CALLABLE">
- {call updateUserBalance(#{hCount, mode=IN, jdbcType=INTEGER}, #{percent, mode=IN, jdbcType=DECIMAL})}
- </select>
- <select id="selectValidOrdersByMerchantAndDate" resultType="com.ylx.order.domain.TOrder">
- SELECT
- appointment_start_time,
- appointment_end_time
- FROM t_order
- WHERE merchant_id = #{merchantId}
- AND project_id = #{projectId}
- AND is_delete = 0
- -- 核心:只查询有效状态的订单 (待派单, 待接单, 待服务, 服务中)
- AND status IN (1, 2, 3, 4)
- -- 性能优化:限定查询当天的数据,避免全表扫描
- AND appointment_start_time >= #{dayStart}
- AND appointment_start_time <= #{dayEnd}
- </select>
- <resultMap id="OrderPageVOResultMap" type="com.ylx.order.domain.vo.merchant.OrderPageVO">
- <id column="id" property="id"/>
- <result column="project_name" property="projectName"/>
- <result column="project_cover" property="projectCover"/>
- <result column="project_duration" property="projectDuration"/>
- <result column="base_price" property="basePrice"/>
- <result column="traffic_fee" property="trafficFee"/>
- <result column="final_amount" property="finalAmount"/>
- <result column="appointment_start_time" property="appointmentStartTime"/>
- <result column="appointment_end_time" property="appointmentEndTime"/>
- <result column="contact_person_name" property="contactPersonName"/>
- <result column="contact_phone_number" property="contactPhoneNumber"/>
- <result column="service_address_detail" property="contactAddressInfo"/>
- <result column="user_latitude" property="userLatitude"/>
- <result column="user_longitude" property="userLongitude"/>
- <result column="status" property="status"/>
- <result column="distance_km" property="distanceKm"/>
- </resultMap>
- <select id="queryMerchantOrderList" resultMap="OrderPageVOResultMap">
- SELECT
- o.id,
- p.project_name,
- p.cover_url AS project_cover,
- p.duration AS project_duration,
- p.base_price,
- o.traffic_fee,
- o.final_amount,
- o.appointment_start_time,
- o.appointment_end_time,
- o.contact_person_name,
- IF(o.contact_phone_number IS NULL, '', CONCAT(SUBSTRING(o.contact_phone_number,1,3), '******', SUBSTRING(o.contact_phone_number,10,2))) AS contactPhoneNumber
- o.service_address_detail,
- o.user_latitude,
- o.user_longitude,
- o.status,
- CASE
- WHEN #{dto.longitude} IS NULL OR #{dto.latitude} IS NULL THEN NULL
- WHEN o.user_longitude IS NULL OR o.user_latitude IS NULL THEN NULL
- WHEN o.user_longitude = 0 OR o.user_latitude = 0 THEN NULL
- ELSE ROUND(ST_Distance_Sphere(POINT(o.user_longitude, o.user_latitude), POINT(#{dto.longitude}, #{dto.latitude})) / 1000, 2)
- END AS distance_km
- FROM t_order o
- LEFT JOIN t_project p ON o.project_id = p.id
- <where>
- o.is_delete = 0
- -- 商户ID
- AND o.merchant_id = #{dto.merchantId}
- -- 创建时间范围
- <if test="dto.startDate != null">
- AND o.create_time >= #{dto.startDate}
- </if>
- <if test="dto.endDate != null">
- AND o.create_time <= #{dto.endDate}
- </if>
- -- 项目名称模糊
- <if test="dto.projectName != null and dto.projectName != ''">
- AND p.project_name LIKE CONCAT('%', #{dto.projectName}, '%')
- </if>
- -- 联系人手机号【修复:订单表字段o,不是项目表p】
- <if test="dto.contactPhoneNumber != null and dto.contactPhoneNumber != ''">
- AND o.contact_phone_number LIKE CONCAT('%', #{dto.contactPhoneNumber}, '%')
- </if>
- -- 订单状态
- <if test="dto.status != null">
- AND o.status = #{dto.status}
- </if>
- -- 是否免交通费
- <if test="dto.isTrafficFree != null">
- <choose>
- <when test="dto.isTrafficFree == 0">
- AND o.traffic_fee = 0
- </when>
- <when test="dto.isTrafficFree == 1">
- AND o.traffic_fee > 0
- </when>
- </choose>
- </if>
- </where>
- ORDER BY o.create_time DESC
- </select>
- </mapper>
|