<?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.xzx.gc.order.mapper.OrderMapper">
|
|
<resultMap id="OrderMap" type="com.xzx.gc.model.order.OrderInfoVo">
|
<result column="address_id" jdbcType="INTEGER" property="addressId"/>
|
<result column="order_id" jdbcType="VARCHAR" property="orderId"/>
|
<result column="order_status" jdbcType="VARCHAR" property="orderStatus"/>
|
<result column="order_second_status" jdbcType="VARCHAR" property="orderSecondStatus"/>
|
<result column="order_type" jdbcType="VARCHAR" property="orderType"/>
|
<result column="reserve_time" jdbcType="VARCHAR" property="reserveTime"/>
|
<result column="create_user_id" jdbcType="VARCHAR" property="createUserId"/>
|
<result column="cancel_user_id" jdbcType="VARCHAR" property="cancelUserId"/>
|
<result column="create_time" jdbcType="VARCHAR" property="createTime"/>
|
<result column="create_user_name" jdbcType="VARCHAR" property="createUserName"/>
|
<result column="receive_time" jdbcType="VARCHAR" property="receiveTime"/>
|
<result column="order_pic" jdbcType="VARCHAR" property="orderPic"/>
|
<result column="storage_money" jdbcType="VARCHAR" property="storageMoney"/>
|
<result column="receiver_name" jdbcType="VARCHAR" property="receiverName"/>
|
<result column="receiver_phone" jdbcType="VARCHAR" property="receiverPhone"/>
|
<result column="take_phone_pic" jdbcType="VARCHAR" property="takePhonePic"/>
|
<result column="cancel_user_phone" jdbcType="VARCHAR" property="cancelUserPhone"/>
|
<result column="cancel_user_name" jdbcType="VARCHAR" property="cancelUserName"/>
|
<result column="storage_user_id" jdbcType="VARCHAR" property="storageUserId"/>
|
<result column="storage_user_name" jdbcType="VARCHAR" property="storageUserName"/>
|
<result column="storage_user_phone" jdbcType="VARCHAR" property="storageUserPhone"/>
|
<result column="rela_phone" jdbcType="VARCHAR" property="relaPhone"/>
|
<result column="rela_name" jdbcType="VARCHAR" property="relaName"/>
|
<result column="cancel_reason_code" jdbcType="VARCHAR" property="cancelReasonCode"/>
|
<result column="cancel_reason_name" jdbcType="VARCHAR" property="cancelReasonName"/>
|
<result column="item_type" jdbcType="VARCHAR" property="itemType"/>
|
<result column="item_type_name" jdbcType="VARCHAR" property="itemTypeName"/>
|
<result column="address_area" jdbcType="VARCHAR" property="addressArea"/>
|
<result column="second_price" jdbcType="VARCHAR" property="secondPrice"/>
|
<result column="create_type" property="type"/>
|
<result column="store_id" property="storeId"/>
|
<result column="receive_time" property="receiveTime"/>
|
<result column="complete_time" property="completeTime"/>
|
<result column="address_id" property="addressId"/>
|
<result column="town_id" property="townId"/>
|
<result column="home_service_id" property="homeServiceId"/>
|
<result column="order_fast_flag" property="orderFastFlag"/>
|
<result column="home_appliance_id" property="homeApplianceId"/>
|
<result column="change_receiver_flag" property="changeReceiverFlag"/>
|
</resultMap>
|
|
<resultMap id="StorageInfoMap" type="com.xzx.gc.model.order.OrderStorageVo">
|
<result column="storage_id" jdbcType="INTEGER" property="storageId"/>
|
<result column="order_id" jdbcType="VARCHAR" property="orderId"/>
|
<result column="storage_money" jdbcType="VARCHAR" property="storageMoney"/>
|
<result column="recycle_money" jdbcType="VARCHAR" property="recycleMoney"/>
|
<result column="receiver_name" jdbcType="VARCHAR" property="receiverName"/>
|
<result column="receiver_phone" jdbcType="VARCHAR" property="receiverPhone"/>
|
<result column="storage_user_id" jdbcType="VARCHAR" property="storageUserId"/>
|
<result column="storage_user_name" jdbcType="VARCHAR" property="storageUserName"/>
|
<result column="storage_user_phone" jdbcType="VARCHAR" property="storageUserPhone"/>
|
<result column="storage_time" jdbcType="VARCHAR" property="storageTime"/>
|
<result column="receiver_avatar" jdbcType="VARCHAR" property="receiverAvatar"/>
|
<result column="sys_storage_id" property="sysStorageId"/>
|
<result column="sys_storage_type" property="sysStorageType"/>
|
</resultMap>
|
|
<resultMap id="OrderItemMap" type="com.xzx.gc.model.order.OrderItemVo">
|
<result column="order_id" jdbcType="VARCHAR" property="orderId"/>
|
<result column="item_type" jdbcType="VARCHAR" property="itemType"/>
|
<result column="item_type_name" jdbcType="VARCHAR" property="itemTypeName"/>
|
<result column="second_price" jdbcType="VARCHAR" property="secondPrice"/>
|
</resultMap>
|
|
<resultMap id="reserveTimeMap" type="com.xzx.gc.model.order.OrderReserveTimeVo">
|
<result column="start_time" jdbcType="VARCHAR" property="startTime"/>
|
<result column="end_time" jdbcType="VARCHAR" property="endTime"/>
|
<result column="time_interval" jdbcType="VARCHAR" property="timeInterval"/>
|
</resultMap>
|
|
<resultMap id="UserInfoMap" type="com.xzx.gc.model.user.UserInfoVo">
|
<result column="nick_name" jdbcType="VARCHAR" property="nickName"/>
|
<result column="user_type" jdbcType="VARCHAR" property="userType"/>
|
<result column="user_id" jdbcType="INTEGER" property="userId"/>
|
<result column="mobile_phone" jdbcType="VARCHAR" property="mobilePhone"/>
|
</resultMap>
|
<resultMap id="ConfigInfoMap" type="com.xzx.gc.model.system.ConfigInfoVo">
|
<result column="config_type_name" jdbcType="VARCHAR" property="configTypeName"/>
|
<result column="config_value" jdbcType="VARCHAR" property="configValue"/>
|
<result column="config_value_name" jdbcType="VARCHAR" property="configValueName"/>
|
</resultMap>
|
|
<!-- 订单基本信息增加 -->
|
<insert id="orderInfoAdd" parameterType="java.util.Map">
|
insert into xzx_order_info(order_id,address,order_status,order_type,reserve_time,
|
create_user_id,create_time,rela_phone,longitude,latitude,address_area,rela_name,town_id,create_type,del_flag,store_id,receiver,house_number,unit_name,house_name)
|
values (#{orderId},#{address},#{orderStatus},#{orderType},#{reserveTime},#{createUserId},
|
#{createTime},#{relaPhone},#{longitude},#{latitude},#{addressArea},#{relaName},
|
#{townId},#{createType},#{delFlag},#{storeId},#{receiver},#{houseNumber} ,#{unitName} ,#{houseName} )
|
</insert>
|
|
<!-- 订单详情增加 -->
|
<insert id="orderDetailAdd" parameterType="java.util.Map">
|
insert into xzx_order_detail_info(order_id,remark,create_user_name,mobile_phone,reserve_time,
|
receive_time,order_pic,address_id,weight,amount,money,storage_money,receiver_name,take_phone_pic,receiver_phone,home_service_id,home_appliance_id)
|
values (#{orderId},#{remark},#{createUserName},#{mobilePhone},#{reserveTime},#{receiveTime},
|
#{orderPic},#{addressId},#{weight},#{amount},#{money},#{storageMoney},#{receiverName},#{takePhonePic},#{receiverPhone},#{homeServiceId} ,#{homeApplianceId} )
|
</insert>
|
|
<!-- 订单物品增加 -->
|
<insert id="orderItemAdd" parameterType="java.util.Map">
|
insert into xzx_order_item_info(order_id,item_type,weight,amount,money,price)
|
values (#{orderId},#{itemType},#{weight},#{amount},#{money},#{price})
|
</insert>
|
|
<!-- 订单物品查询 -->
|
<select id="orderItemQuery" parameterType="java.util.Map" resultMap="OrderItemMap">
|
select a.order_id,a.item_type,a.weight,a.amount,a.money
|
from xzx_order_item_info a
|
where a.order_id=#{orderId}
|
<if test="itemType!=null and itemType!=''">
|
and a.item_type=#{itemType}
|
</if>
|
</select>
|
|
<!-- 订单物品更新 -->
|
<update id="orderItemUpdate" parameterType="java.util.Map">
|
update xzx_order_item_info
|
set weight=#{weight},amount=#{amount},money=#{money}
|
<if test="price != null and price != ''">
|
,price=#{price}
|
</if>
|
where order_id=#{orderId} and item_type=#{itemType}
|
</update>
|
|
|
<!-- 订单列表查询 -->
|
<select id="orderListQuery" parameterType="java.util.Map" resultMap="OrderMap">
|
select distinct
|
a.order_id,
|
a.town_id,
|
a.address,
|
a.order_status,
|
a.order_type,
|
a.reserve_time,
|
a.create_user_id,
|
a.receiver,
|
a.create_time,
|
a.rela_phone,
|
a.longitude,
|
a.latitude,
|
a.cancel_user_id,
|
a.address_area,
|
a.rela_name,
|
a.order_second_status,
|
a.create_type,
|
a.store_id,
|
d.take_phone_pic,
|
d.storage_user_id,
|
d.storage_user_name,
|
d.storage_user_phone,
|
d.remark,
|
d.receiver_name,
|
d.receiver_phone,
|
d.complete_time,
|
c.config_value_name "cancel_reason_name",
|
d.receive_time,
|
d.cancel_reason_name "cancelReason",
|
d.address_id,
|
d.order_fast_flag,
|
d.home_service_id,
|
d.note,
|
d.home_appliance_id,
|
d.change_receiver_flag
|
<if test="latitude!=null and latitude!='' and longitude!=null and longitude!=''">
|
,ROUND(lat_lng_distance(#{latitude}, #{longitude}, a.latitude, a.longitude), 3) as distance
|
</if>
|
from xzx_order_info a
|
left join xzx_user_other_info b on a.receiver=b.user_id and b.del_flag=0 and b.is_prohibit=0
|
inner join xzx_order_detail_info d on a.order_id=d.order_id
|
left join xzx_sys_config_info c on d.cancel_reason_code=c.config_value and c.config_type_code='CANCEL_REASON'
|
where 1=1
|
<if test="orderTypeList != null and orderTypeList.size()>0">
|
and a.order_type in
|
<foreach collection="orderTypeList" index="index" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
<if test="receiver == null || receiver == ''">
|
<choose>
|
<when test="fenceIds != null">
|
and ( b.partner_id=#{partnerId} or a.town_id in
|
<foreach collection="fenceIds" item="id" index="index" open="(" close=")" separator=",">
|
#{id}
|
</foreach>
|
)
|
</when>
|
<when test="townId != null and townId != '' and orderStatus==1 and storeId==null">
|
and find_in_set(a.town_id,#{townId})
|
</when>
|
<when test="townId != null and townId != '' and orderStatus==1 and storeId!=null">
|
and (find_in_set(a.town_id,#{townId}) or a.store_id=#{storeId})
|
</when>
|
</choose>
|
</if>
|
|
<choose>
|
<when test="userType==1 and orderStatus==4">
|
and (a.order_status=4 or a.order_status=5 or a.order_status=7)
|
</when>
|
<when test="userType==2 and orderStatus==4">
|
and (a.order_status=4 or a.order_status=7)
|
</when>
|
<otherwise>
|
<if test="orderStatus!=null and orderStatus!=''">
|
and a.order_status=#{orderStatus}
|
</if>
|
</otherwise>
|
</choose>
|
|
<if test="createUserId!=null and createUserId!=''">
|
and a.create_user_id=#{createUserId}
|
</if>
|
<if test="receiver!=null and receiver!=''">
|
and a.receiver=#{receiver}
|
</if>
|
<if test="isRecentThreeDays==1">
|
and DATE_FORMAT(a.create_time,'%Y-%m-%d')>date_sub(CURRENT_DATE(), interval 3 day)
|
</if>
|
|
<if test="isRecentThreeDays==2">
|
and DATE_FORMAT(a.create_time,'%Y-%m-%d')=CURRENT_DATE()
|
</if>
|
|
<if test="isRecentThreeDays==3">
|
and DATE_FORMAT(a.create_time,'%Y-%m-%d')>date_sub(CURRENT_DATE(), interval 1 week)
|
</if>
|
|
<if test="isRecentThreeDays==4">
|
and DATE_FORMAT(a.create_time,'%Y-%m-%d')>date_sub(CURRENT_DATE(), interval 1 month)
|
</if>
|
|
<if test="keyword != null and keyword != ''">
|
and (a.rela_phone like concat('%',#{keyword},'%') or a.rela_name like concat('%',#{keyword},'%') or b.name like concat('%',#{keyword},'%') or d.receiver_phone like concat('%',#{keyword},'%'))
|
</if>
|
|
<if test="orderMethod==1">
|
and a.create_type=2
|
</if>
|
<if test="orderMethod==2">
|
and a.create_type=3
|
</if>
|
|
<choose>
|
<when test="latitude!=null and latitude!='' and longitude!=null and longitude!='' and orderStatus==1">
|
order by distance asc,a.create_time desc
|
</when>
|
<otherwise>
|
order by a.create_time desc
|
</otherwise>
|
</choose>
|
|
</select>
|
|
|
<select id="orderListQueryForAdmin" parameterType="java.util.Map" resultMap="OrderMap">
|
select distinct
|
a.order_id,
|
a.town_id,
|
a.address,
|
a.order_status,
|
a.order_type,
|
a.reserve_time,
|
a.create_user_id,
|
a.receiver,
|
a.create_time,
|
a.rela_phone,
|
a.longitude,
|
a.latitude,
|
a.cancel_user_id,
|
a.address_area,
|
a.rela_name,
|
a.order_second_status,
|
a.create_type,
|
a.store_id,
|
d.take_phone_pic,
|
d.storage_user_id,
|
d.storage_user_name,
|
d.storage_user_phone,
|
d.remark,
|
d.receiver_name,
|
d.receiver_phone,
|
d.complete_time,
|
c.config_value_name "cancel_reason_name",
|
d.receive_time,
|
d.cancel_reason_name "cancelReason",
|
d.address_id,
|
d.order_fast_flag,
|
d.home_service_id,
|
d.note,
|
d.home_appliance_id,
|
d.change_receiver_flag
|
<if test="latitude!=null and latitude!='' and longitude!=null and longitude!=''">
|
,ROUND(lat_lng_distance(#{latitude}, #{longitude}, a.latitude, a.longitude), 3) as distance
|
</if>
|
from xzx_order_info a
|
left join xzx_user_other_info b on a.receiver=b.user_id and b.del_flag=0 and b.is_prohibit=0
|
inner join xzx_order_detail_info d on a.order_id=d.order_id
|
left join xzx_sys_config_info c on d.cancel_reason_code=c.config_value and c.config_type_code='CANCEL_REASON'
|
where 1=1
|
<if test="orderTypeList != null and orderTypeList.size()>0">
|
and a.order_type in
|
<foreach collection="orderTypeList" index="index" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
<if test="receiver == null || receiver == ''">
|
<choose>
|
<when test="fenceIds != null">
|
and ( b.partner_id=#{partnerId} or a.town_id in
|
<foreach collection="fenceIds" item="id" index="index" open="(" close=")" separator=",">
|
#{id}
|
</foreach>
|
)
|
</when>
|
<when test="townId != null and townId != '' and orderStatus==1 and storeId==null">
|
and find_in_set(a.town_id,#{townId})
|
</when>
|
<when test="townId != null and townId != '' and orderStatus==1 and storeId!=null">
|
and (find_in_set(a.town_id,#{townId}) or a.store_id=#{storeId})
|
</when>
|
</choose>
|
</if>
|
|
<choose>
|
<when test="userType==1 and orderStatus==4">
|
and (a.order_status=4 or a.order_status=5 or a.order_status=7)
|
</when>
|
<when test="userType==2 and orderStatus==4">
|
and (a.order_status=4 or a.order_status=7)
|
</when>
|
<otherwise>
|
<if test="orderStatus!=null and orderStatus!=''">
|
and a.order_status=#{orderStatus}
|
</if>
|
</otherwise>
|
</choose>
|
|
<if test="createUserId!=null and createUserId!=''">
|
and a.create_user_id=#{createUserId}
|
</if>
|
<if test="receiver!=null and receiver!=''">
|
and a.receiver=#{receiver}
|
</if>
|
<if test="isRecentThreeDays==1">
|
and DATE_FORMAT(a.create_time,'%Y-%m-%d')>date_sub(CURRENT_DATE(), interval 3 day)
|
</if>
|
|
<if test="isRecentThreeDays==2">
|
and DATE_FORMAT(a.create_time,'%Y-%m-%d')=CURRENT_DATE()
|
</if>
|
|
<if test="isRecentThreeDays==3">
|
and DATE_FORMAT(a.create_time,'%Y-%m-%d')>date_sub(CURRENT_DATE(), interval 1 week)
|
</if>
|
|
<if test="isRecentThreeDays==4">
|
and DATE_FORMAT(a.create_time,'%Y-%m-%d')>date_sub(CURRENT_DATE(), interval 1 month)
|
</if>
|
|
<if test="keyword != null and keyword != ''">
|
and (a.rela_phone like concat('%',#{keyword},'%') or a.rela_name like concat('%',#{keyword},'%') or b.name like concat('%',#{keyword},'%') or d.receiver_phone like concat('%',#{keyword},'%'))
|
</if>
|
|
<if test="orderMethod==1">
|
and a.create_type=2
|
</if>
|
<if test="orderMethod==2">
|
and a.create_type=3
|
</if>
|
|
<choose>
|
<when test="latitude!=null and latitude!='' and longitude!=null and longitude!='' and orderStatus==1">
|
order by distance asc,a.create_time desc
|
</when>
|
<otherwise>
|
order by a.create_time desc
|
</otherwise>
|
</choose>
|
|
</select>
|
|
|
|
<!-- 各个状态下的订单数 -->
|
<select id="orderListCount" parameterType="java.util.Map" resultType="String">
|
select count(*)
|
from xzx_order_info
|
where 1=1
|
<if test="orderType!=null and orderType!=''">
|
and order_type=#{orderType}
|
</if>
|
<if test="orderStatus!=null and orderStatus!='' and orderStatus=='4'">
|
and (order_status='4' or order_status='5')
|
</if>
|
<if test="createUserId!=null and createUserId!=''">
|
and create_user_id=#{createUserId}
|
</if>
|
<if test="receiver!=null and receiver!=''">
|
and receiver=#{receiver}
|
</if>
|
</select>
|
|
<!--统计普通用户订单信息-->
|
<select id="statNormalUserOrder" parameterType="com.xzx.gc.model.order.OrderInfoReq" resultType="java.util.HashMap">
|
select
|
(
|
case
|
b.order_status
|
when '1' then 'djdCount'
|
when '2' then 'fwzCount'
|
when '3' then 'dqrCount'
|
when '4' then 'drkCount'
|
when '5' then 'wcCount'
|
when '6' then 'cancelCount'
|
when '7' then 'recyleingCount'
|
else ''
|
end) as orderStatus,
|
b.orderNum
|
from
|
(
|
select
|
a.order_status,count(a.order_id) as orderNum
|
from
|
xzx_order_info a
|
where
|
a.create_user_id=#{createUserId}
|
group by
|
a.order_status
|
) b
|
</select>
|
<!--统计员工用户订单信息-->
|
<select id="statStaffUserOrder" parameterType="com.xzx.gc.model.order.OrderInfoReq" resultType="java.util.HashMap">
|
select
|
(
|
case
|
b.order_status
|
when '1' then 'djdCount'
|
when '2' then 'fwzCount'
|
when '3' then 'dqrCount'
|
when '4' then 'drkCount'
|
when '5' then 'wcCount'
|
when '6' then 'cancelCount'
|
when '7' then 'recyleingCount'
|
else ''
|
end) as orderStatus,
|
b.orderNum
|
from
|
(
|
select
|
a.order_status,count(a.order_id) as orderNum
|
from
|
xzx_order_info a
|
where
|
a.receiver=#{receiver}
|
|
group by
|
a.order_status
|
) b
|
|
</select>
|
|
|
<!--订单详情查询-->
|
<select id="orderDetailQuery" parameterType="java.util.Map" resultMap="OrderMap">
|
SELECT
|
a.order_id,
|
a.town_id,
|
a.address,
|
a.address_area,
|
a.order_status,
|
a.order_type,
|
a.reserve_time,
|
a.create_user_id,
|
a.receiver,
|
a.create_time,
|
a.rela_phone,
|
a.longitude,
|
a.latitude,
|
d.remark,
|
d.create_user_name,
|
d.receive_time,
|
d.order_pic,
|
d.amount,
|
d.money,
|
d.receiver_name,
|
d.take_phone_pic,
|
d.receiver_phone,
|
d.cancel_user_name,
|
d.cancel_user_phone,
|
a.rela_name,
|
a.order_second_status,
|
d.cancel_reason_code,
|
d.cancel_reason_name,
|
a.store_id,
|
d.address_id,
|
d.home_service_id,
|
d.note,
|
d.home_appliance_id
|
FROM
|
xzx_order_info a
|
INNER JOIN xzx_order_detail_info d ON a.order_id = d.order_id
|
WHERE
|
a.order_id = #{orderId}
|
</select>
|
|
<!-- 订单取消原因更新 -->
|
<update id="updateOrderCancelReason" parameterType="java.util.Map">
|
update xzx_order_detail_info
|
set cancel_reason_code=#{cancelReasonCode}
|
<if test="cancelReasonName != null and cancelReasonName != ''">
|
,cancel_reason_name=#{cancelReasonName}
|
</if>
|
|
where order_id=#{orderId}
|
</update>
|
|
<!-- 订单基本信息更新 -->
|
<update id="updateOrderDetailInfo" parameterType="java.util.Map">
|
update xzx_order_detail_info
|
<trim prefix="set" suffixOverrides=",">
|
<if test="remark!= null and remark!=''">remark=#{remark},</if>
|
<if test="reserveTime!= null and reserveTime!=''">reserve_time=#{reserveTime},</if>
|
<if test="receiveTime!= null and receiveTime!=''">receive_time=#{receiveTime},</if>
|
<if test="addressId!= null and addressId!=''">address_id=#{addressId},</if>
|
<if test="weight!=null and weight!=''">weight=#{weight},</if>
|
<if test="amount!=null and amount!=''">amount=#{amount},</if>
|
<if test="money!=null and money!=''">money=#{money},</if>
|
<if test="storageMoney!=null and storageMoney!=''">storage_money=#{storageMoney},</if>
|
<if test="receiverName!=null and receiverName!=''">receiver_name=#{receiverName},</if>
|
<if test="receiverPhone!=null and receiverPhone!=''">receiver_phone=#{receiverPhone},</if>
|
<if test="cancelUserName!=null and cancelUserName!=''">cancel_user_name=#{cancelUserName},</if>
|
<if test="cancelUserPhone!=null and cancelUserPhone!=''">cancel_user_phone=#{cancelUserPhone},</if>
|
<if test="storageUserId!=null and storageUserId!=''">storage_user_id=#{storageUserId},</if>
|
<if test="storageUserName!=null and storageUserName!=''">storage_user_name=#{storageUserName},</if>
|
<if test="storageUserPhone!=null and storageUserPhone!=''">storage_user_phone=#{storageUserPhone},</if>
|
<if test="cancelReasonCode!=null and cancelReasonCode!=''">cancel_reason_code=#{cancelReasonCode},</if>
|
<if test="cancelReasonName!=null and cancelReasonName!=''">cancel_reason_name=#{cancelReasonName},</if>
|
<if test="completeTime!=null and completeTime!=''">complete_time=#{completeTime},</if>
|
<if test="cancelTime != null and cancelTime != ''">cancel_time=#{cancelTime} ,</if>
|
</trim>
|
where order_id=#{orderId}
|
</update>
|
|
|
<!-- 订单详细信息更新 -->
|
<update id="updateOrderInfo" parameterType="java.util.Map">
|
update xzx_order_info
|
<trim prefix="set" suffixOverrides=",">
|
<if test="address!= null and address!=''">address=#{address},</if>
|
<if test="orderStatus!= null and orderStatus!=''">order_status=#{orderStatus},</if>
|
<if test="orderType!= null and orderType!=''">order_type=#{orderType},</if>
|
<if test="reserveTime!= null and reserveTime!=''">reserve_time=#{reserveTime},</if>
|
<if test="createUserId!=null and createUserId!=''">create_user_id=#{createUserId},</if>
|
<if test="receiver!=null and receiver!='' ">receiver=#{receiver},</if>
|
<if test="cancelUserId!=null and cancelUserId!=''">cancel_user_id=#{cancelUserId},</if>
|
<if test="traceId != null and traceId != ''">trace_id=#{traceId} ,</if>
|
</trim>
|
where order_id=#{orderId}
|
</update>
|
|
|
<!--回收员的入库订单物品统计汇总-->
|
<select id="prepareStorageOrderList" parameterType="java.util.Map" resultType="String">
|
select a.order_id
|
from xzx_order_info a
|
where
|
1=1
|
<choose>
|
<when test="clientType==2">
|
and a.order_status=7
|
</when>
|
<when test="clientType==3">
|
and a.order_status='4'
|
</when>
|
</choose>
|
and a.receiver=(select receiver from xzx_order_info where order_id=#{orderId})
|
</select>
|
|
<!--回收员的服务中订单-->
|
<select id="fwOrderList" parameterType="java.util.Map" resultType="String">
|
select a.order_id
|
from xzx_order_info a
|
where
|
1=1
|
and a.order_status=2
|
and a.receiver=(select receiver from xzx_order_info where order_id=#{orderId})
|
</select>
|
|
<select id="fwOrderListByUserId" parameterType="java.util.Map" resultType="String">
|
select a.order_id
|
from xzx_order_info a
|
where
|
1=1
|
and a.order_status=2
|
and a.receiver=#{receiver}
|
</select>
|
|
|
<!-- 查询接单员用户信息 -->
|
<select id="queryUserInfo" parameterType="map" resultMap="UserInfoMap">
|
select d.user_id,d.mobile_phone,d.avatar,d.nick_name,d.sex,d.birthday,d.user_type
|
from xzx_user_info d
|
where d.user_id=(select receiver from xzx_order_info where order_id=#{orderId})
|
</select>
|
|
<!-- 入库基本信息增加 -->
|
<insert id="orderStorageInfoAdd" parameterType="java.util.Map">
|
insert into xzx_order_storage_info(storage_id,order_id,storage_user_id,storage_user_name,
|
storage_user_phone,storage_time,storage_money,recycle_money,receiver,receiver_name,receiver_phone,receiver_avatar,storage_status)
|
values (#{storageId},#{orderId},#{storageUserId},#{storageUserName},#{storageUserPhone},#{storageTime},
|
#{storageMoney},#{recycleMoney},#{receiver},#{receiverName},#{receiverPhone},#{receiverAvatar},#{storageStatus})
|
|
</insert>
|
|
<!-- 入库列表查询 -->
|
<select id="orderStorageListQuery" parameterType="java.util.Map" resultMap="StorageInfoMap">
|
select storage_id,order_id,storage_user_id,storage_user_name,
|
storage_user_phone,storage_time,storage_money,recycle_money,
|
receiver,receiver_name,receiver_phone,receiver_avatar,sys_storage_id,sys_storage_type
|
from xzx_order_storage_info
|
where 1=1
|
<if test="storageUserId!=null and storageUserId!=''">
|
and storage_user_id=#{storageUserId}
|
</if>
|
<if test="storageId!=null and storageId!=''">
|
and storage_id=#{storageId}
|
</if>
|
and storage_status=#{storageStatus}
|
</select>
|
|
<!-- 入库明细查询 -->
|
<select id="orderStorageDetailQuery" parameterType="java.util.Map" resultMap="OrderItemMap">
|
select a.*,b.title item_type_name
|
from xzx_order_storage_detail a
|
<choose>
|
<when test="type==0">
|
left JOIN xzx_sys_environmental_info b on a.item_type=b.item_type and b.del_flag=0 and b.parent_id is not null and b.city_id=#{townId}
|
</when>
|
<otherwise>
|
left JOIN xzx_package_goods_info b on a.item_type=b.item_type and b.del_flag=0 and b.parent_id is not null and b.package_id=#{townId}
|
</otherwise>
|
</choose>
|
where storage_id=#{storageId}
|
<if test="flag!=null and flag!=''">
|
and flag=#{flag}
|
</if>
|
</select>
|
|
<!-- 获取预约时间配置 -->
|
<select id="reserveTimeConfigQuery" parameterType="java.util.Map" resultMap="reserveTimeMap">
|
select a.start_time,a.end_time,a.time_interval
|
from xzx_sys_service_time_config a
|
</select>
|
|
<!-- 配置信息查询 -->
|
<select id="queryConfigInfo" parameterType="com.xzx.gc.model.system.ConfigInfoReq" resultMap="ConfigInfoMap">
|
select config_type_name,config_value,config_value_name
|
from xzx_sys_config_info
|
where 1=1
|
<if test="configTypeCode!=null and configTypeCode!=''">
|
and config_type_code=#{configTypeCode}
|
</if>
|
<if test="configValue!=null and configValue!=''">
|
and config_value=#{configValue}
|
</if>
|
|
</select>
|
<select id="customerFind" resultType="com.xzx.gc.order.dto.OrderCustomDto">
|
SELECT
|
a.order_id "orderId",
|
a.rela_name "relaName",
|
a.rela_phone "relaPhone",
|
a.address,
|
a.address_area "addressArea",
|
a.longitude,
|
a.latitude,
|
b.address_id "addressId",
|
a.order_id "orderId"
|
FROM
|
xzx_order_info a
|
INNER JOIN xzx_order_detail_info b ON a.order_id = b.order_id
|
WHERE
|
a.create_type = 2
|
AND a.receiver=#{userId}
|
AND a.del_flag =0
|
AND a.order_id IN
|
(SELECT max(order_id) FROM xzx_order_info group by create_user_id)
|
ORDER BY a.create_time desc
|
|
</select>
|
<select id="findOrderWithCustome" resultType="com.xzx.gc.order.dto.CustomOrderDto">
|
SELECT a.order_id "orderId",b.storage_money "storageMoney",a.receiver from xzx_order_info a
|
inner JOIN xzx_order_detail_info b on a.order_id=b.order_id
|
WHERE FIND_IN_SET(a.order_id,#{orderIdString}) and a.create_type=2
|
|
</select>
|
<select id="findSumWeight" resultType="java.math.BigDecimal">
|
SELECT sum(CAST(IFNULL(b.weight,0) as DECIMAL(9,3))) from xzx_order_info a
|
inner JOIN xzx_order_item_info b
|
on a.order_id=b.order_id
|
WHERE a.create_user_id=#{userId} and a.order_status in('4','5','7');
|
</select>
|
|
<select id="findSumMoney" resultType="java.math.BigDecimal">
|
SELECT sum(CAST(IFNULL(b.money,0) as DECIMAL(9,3))) from xzx_order_info a
|
inner JOIN xzx_order_detail_info b
|
on a.order_id=b.order_id
|
WHERE a.create_user_id=#{userId} and a.order_status in('4','5','7');
|
</select>
|
|
|
|
|
|
<select id="findDetailByReceiverAndStatus" resultType="com.xzx.gc.entity.OrderInfo">
|
SELECT
|
a.order_id "orderId",
|
a.town_id "townId",
|
a.create_user_id "createUserId",
|
a.order_status "orderStatus",
|
a.trace_id "traceId",
|
b.money,
|
b.complete_time "completeTime",
|
a.create_time "createTime",
|
a.store_id "storeId"
|
FROM
|
xzx_order_info a
|
INNER JOIN xzx_order_detail_info b ON a.order_id = b.order_id
|
WHERE
|
a.order_type = '1'
|
AND a.order_status = #{orderStatus}
|
AND a.receiver = #{receiver}
|
order by b.complete_time desc
|
</select>
|
|
<select id="findByAddressId" resultType="com.xzx.gc.order.dto.OrderCustomDto">
|
SELECT
|
a.order_id "orderId",
|
a.rela_name "relaName",
|
a.rela_phone "relaPhone",
|
a.address,
|
a.address_area "addressArea",
|
a.longitude,
|
a.latitude,
|
b.address_id "addressId",
|
a.order_id "orderId"
|
FROM
|
xzx_order_info a
|
INNER JOIN xzx_order_detail_info b ON a.order_id = b.order_id
|
WHERE
|
b.address_id=#{addressId}
|
</select>
|
<select id="findWithLonNull" resultType="com.xzx.gc.order.dto.OrderCustomDto">
|
SELECT
|
a.order_id "orderId",
|
a.rela_name "relaName",
|
a.rela_phone "relaPhone",
|
a.address,
|
a.address_area "addressArea",
|
a.longitude,
|
a.latitude,
|
b.address_id "addressId",
|
a.order_id "orderId"
|
FROM
|
xzx_order_info a
|
INNER JOIN xzx_order_detail_info b ON a.order_id = b.order_id
|
WHERE
|
a.longitude is null or a.longitude='0'
|
</select>
|
<select id="findOrderByTime" resultType="com.xzx.gc.entity.OrderInfo">
|
SELECT
|
a.order_id "orderId",
|
b.complete_time "completeTime",
|
CONCAT( c.address_area, c.detail_address ) "address",
|
a.trace_id "traceId"
|
FROM
|
xzx_order_info a
|
INNER JOIN xzx_order_detail_info b ON a.order_id = b.order_id
|
INNER JOIN xzx_user_address_info c ON b.address_id = c.address_id
|
WHERE
|
a.receiver = #{receiverId}
|
AND DATE_FORMAT( b.complete_time,'%Y-%m-%d')=#{time}
|
AND a.order_status IN ( '4', '5', '7' )
|
and a.create_type!=2
|
|
</select>
|
<select id="findByIds" resultType="com.xzx.gc.entity.OrderInfo">
|
SELECT
|
a.order_id "orderId",
|
a.create_user_id "createUserId",
|
b.complete_time "completeTime",
|
c.regist_time "registTime",
|
c.mobile_phone "createMobile",
|
b.address_id "addressId"
|
FROM
|
xzx_order_info a
|
inner join xzx_user_info c on a.create_user_id=c.user_id and c.del_flag=0 and is_prohibit=0
|
INNER JOIN xzx_order_detail_info b ON a.order_id = b.order_id
|
WHERE
|
a.order_id in
|
<foreach collection="array" item="id" index="index" open="(" close=")" separator=",">
|
#{id}
|
</foreach>
|
|
order by a.create_time asc
|
|
</select>
|
<select id="findWorkOrder" resultType="com.xzx.gc.entity.ReceiveClock">
|
SELECT
|
a.receiver "userId",c.`name` ,c.mobile_phone "mobile",min(b.complete_time) "workTime",max(b.complete_time) "closeTime"
|
FROM
|
xzx_order_info a
|
inner JOIN xzx_order_detail_info b on a.order_id=b.order_id
|
left join xzx_user_other_info c on a.receiver=c.user_id and c.del_flag=0
|
WHERE
|
a.order_status IN ( '4', '5', '7' ) and
|
TO_DAYS( b.complete_time ) = TO_DAYS( NOW( ) )
|
GROUP BY a.receiver
|
|
</select>
|
|
<select id="findPartnerId" resultType="com.xzx.gc.entity.OrderInfo">
|
SELECT
|
a.order_id "orderId",
|
a.create_time "createTime",
|
b.partner_id "partnerId",
|
c.money
|
FROM
|
xzx_order_info a
|
LEFT JOIN xzx_order_detail_info c on a.order_id=c.order_id
|
LEFT JOIN xzx_partner_fence b ON a.town_id = b.fence_id
|
</select>
|
<select id="findPartnerIdByTime" resultType="com.xzx.gc.entity.OrderInfo">
|
SELECT
|
a.order_id "orderId",
|
a.create_time "createTime",
|
b.partner_id "partnerId",
|
c.money
|
FROM
|
xzx_order_info a
|
LEFT JOIN xzx_order_detail_info c on a.order_id=c.order_id
|
LEFT JOIN xzx_partner_fence b ON a.town_id = b.fence_id
|
AND b.del_flag = 0
|
where
|
DATE_FORMAT(a.create_time,'%Y-%m-%d')=date_sub(CURRENT_DATE(), interval 1 day)
|
</select>
|
<select id="queryMoneyByOrderId" resultType="java.lang.String">
|
select IFNULL(sum(money),0) from xzx_order_item_info where order_id=#{orderId}
|
</select>
|
<select id="findById" resultType="com.xzx.gc.entity.OrderInfo">
|
select * from xzx_order_info where order_id=#{orderId}
|
</select>
|
<select id="findSumWeightAndMoney" resultType="com.xzx.gc.model.order.OrderStatistic">
|
SELECT
|
sum( IFNULL( weight, 0 ) ) as sumWeight,
|
sum( IFNULL( money, 0 ) ) as sumMoney
|
FROM
|
xzx_order_detail_info
|
WHERE
|
order_id IN
|
<foreach collection="orderIds" index="index" item="id" separator="," open="(" close=")">
|
#{id}
|
</foreach>
|
</select>
|
|
<select id="queryStorageMoneyDetailApi" resultType="com.xzx.gc.model.admin.PayRequestInfoModel">
|
select a.order_id as orderId,c.complete_time as completeTime,
|
sum(b.money) as money,sum(b.weight) as weight,
|
a.create_time as createTime,a.rela_phone as phone from xzx_order_info a
|
left join xzx_order_detail_info c on a.order_id=c.order_id
|
left join xzx_order_item_info b on a.order_id=b.order_id
|
where a.del_flag=0
|
and a.order_status in (4,5)
|
and a.order_id=c.order_id
|
and a.order_id in
|
<foreach collection="orderIds" index="index" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
group by a.order_id
|
</select>
|
|
<select id="queryMoneyAndWeightByOrderIds" resultType="java.util.HashMap" parameterType="java.util.List">
|
select
|
IFNULL(sum(b.money),0) as money,IFNULL(sum(b.weight),0) as weight
|
from xzx_order_info a
|
left join xzx_order_detail_info c on a.order_id=c.order_id
|
left join xzx_order_item_info b on a.order_id=b.order_id
|
where a.del_flag=0
|
and a.order_status in (4,5)
|
and a.order_id=c.order_id
|
and a.order_id in
|
<foreach collection="orderIds" index="index" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
group by a.order_id
|
</select>
|
|
<select id="quotaDetail" parameterType="com.xzx.gc.model.admin.StorageUserModel" resultType="com.xzx.gc.model.admin.StorageUserModel">
|
select IFNULL(sum(c.money),0) as money,IFNULL(sum(c.weight),0) as weight,b.receive_time as storageTime from xzx_order_info a
|
left join xzx_order_detail_info b on a.order_id=b.order_id
|
left join xzx_order_item_info c on a.order_id=c.order_id
|
where a.receiver=#{userId} and c.order_id is not null
|
<if test="startTime!= null and startTime!=''">
|
and b.receive_time<![CDATA[>= ]]>#{startTime}
|
</if>
|
<if test="endTime!= null and endTime!=''">
|
and b.receive_time<![CDATA[<= ]]>#{endTime}
|
</if>
|
group by a.order_id
|
</select>
|
|
<select id="queryOrderByPhone" resultType="com.xzx.gc.model.admin.OrderModel">
|
select * from xzx_order_info where rela_phone=#{phone} and order_status in (1,2) and del_flag=0
|
</select>
|
|
<insert id="addOrderInfoApi">
|
|
INSERT INTO `xzx_order_info`
|
(`order_id`, `address`, `order_status`,
|
`order_second_status`, `order_type`, `address_area`,
|
`reserve_time`, `create_user_id`, `receiver`,
|
`cancel_user_id`, `create_time`, `rela_phone`,
|
`rela_name`, `longitude`, `latitude`, `town_id`,
|
`create_type`, `del_flag`, `store_id`)
|
VALUES (#{orderId}, #{detailAddress}, #{orderStatus},
|
NULL, '1', #{addressArea},
|
#{reserveTime}, #{createUserId}, NULL,
|
NULL, SYSDATE(), #{mobilePhone},
|
#{nickName}, #{longitude}, #{latitude}, #{townshipId},
|
'3', '0', #{storeId})
|
</insert>
|
|
|
<select id="queryUserOrderApiList" resultType="com.xzx.gc.model.admin.OrderModel">
|
select a.order_id,a.create_time,sum(b.weight) ,sum(b.money) from xzx_order_info a
|
left join xzx_order_item_info b on a.order_id=b.order_id
|
where a.order_status in ('4','5','7')
|
and a.create_user_id=#{userId}
|
group by a.order_id
|
</select>
|
|
<select id="queryStaticDataToday" resultType="map">
|
SELECT
|
IFNULL(e.weight, 0) AS weight,
|
IFNULL(e.money, 0) AS money,
|
a.title as config_value_name
|
FROM xzx_sys_environmental_info a
|
LEFT JOIN (
|
SELECT
|
SUM(b.money) as money,
|
SUM(b.weight) as weight,
|
b.item_type,
|
b.flag
|
FROM xzx_order_storage_info c
|
LEFT JOIN xzx_order_storage_detail b ON c.storage_id = b.storage_id
|
WHERE b.flag = #{flag}
|
|
<if test="startTime != null and startTime != ''">
|
and c.storage_time BETWEEN #{startTime} AND #{endTime}
|
</if>
|
|
<if test="receiverphone != null and receiverphone != ''">
|
and c.receiver_phone=#{receiverphone}
|
</if>
|
GROUP BY b.item_type
|
) e ON e.item_type = a.item_type
|
WHERE a.del_flag = 0 and a.parent_id is NOT NULL;
|
</select>
|
<select id="queryOrderIdsByStorageId" resultType="java.lang.String">
|
SELECT order_id
|
FROM xzx_order_storage_info
|
where storage_id = #{storageId}
|
</select>
|
<select id="queryCuserOrderByUserIdCount1" resultType="java.util.Map">
|
SELECT
|
count(a.order_id) as count,
|
(select count(b.order_id)
|
from xzx_order_info b
|
where b.order_status = 3 and b.create_user_id = #{userId}) as count1
|
FROM xzx_order_info a
|
WHERE a.create_user_id = #{userId} and a.order_status in (4, 5, 7)
|
</select>
|
<select id="queryOrderByOrderId" resultType="java.lang.String">
|
select receiver
|
from xzx_order_info
|
WHERE order_id = #{orderId}
|
</select>
|
<select id="queryUserIdByOrderId" resultType="java.lang.String">
|
select create_user_id
|
from xzx_order_info
|
WHERE order_id = #{orderId}
|
</select>
|
<select id="queryOrderPageByOrderno" resultType="map">
|
SELECT a.address, a.address_area, a.order_type, a.order_status,a.create_time,
|
a.rela_name as relaName,b.*,e.item_type, e.cweight AS cweight, e.camount as camount,
|
e.cmoney as cmoney, e.title as title,a.reserve_time as reserveTime,b.address_id as addressId
|
FROM xzx_order_info a
|
LEFT JOIN xzx_order_detail_info b ON a.order_id=b.order_id
|
LEFT JOIN(
|
select c.item_type, c.weight AS cweight, c.amount as camount,c.order_id,
|
c.money as cmoney,d.title FROM xzx_order_item_info c
|
LEFT JOIN xzx_sys_environmental_info d ON c.item_type = d.item_type
|
WHERE c.money>0
|
)e on a.order_id = e.order_id
|
WHERE a.order_id = #{orderNo}
|
group by e.item_type
|
|
</select>
|
<select id="queryOrderList" resultType="map">
|
SELECT
|
a.order_id,
|
a.create_time,
|
a.reserve_time,
|
a.order_type,
|
a.order_status,
|
c.nick_name,
|
c.name,
|
a.rela_name,
|
b.money,
|
SUM(f.weight) AS weight
|
FROM xzx_order_info a
|
LEFT JOIN xzx_order_detail_info b ON a.order_id = b.order_id
|
LEFT JOIN xzx_user_other_info c ON a.receiver = c.user_id
|
LEFT JOIN xzx_order_item_info f ON a.order_id = f.order_id
|
WHERE 1 = 1
|
|
<if test="orderStatus != null and orderStatus != ''">
|
AND a.order_status=#{orderStatus}
|
</if>
|
|
<if test="startTime != null and startTime != ''">
|
AND a.create_time BETWEEN #{startTime} AND #{endTime}
|
</if>
|
|
<if test="orderType != null and orderType != ''">
|
AND a.order_type = #{orderType}
|
</if>
|
|
<if test="name != null and name != ''">
|
AND c.name = #{name}
|
</if>
|
|
<if test="mobilePhone != null and mobilePhone != ''">
|
AND c.mobile_phone = #{mobilePhone}
|
</if>
|
GROUP BY a.create_time desc
|
</select>
|
<select id="queryOrderApiList" resultType="com.xzx.gc.model.admin.OrderModel">
|
SELECT
|
a.order_id AS orderId,
|
a.create_time AS createTime,
|
a.reserve_time AS reserveTime,
|
a.order_type AS orderType,
|
a.rela_phone AS relaPhone,
|
b.receive_time AS receiveTime,
|
b.complete_time AS completeTime,
|
b.cancel_reason_name AS cancelReasonName,
|
a.order_status AS orderStatus,
|
IFNULL( d.nick_name, c.nick_name ) AS nickName,
|
c.NAME AS NAME,
|
d.mobile_phone AS mobilePhone,
|
a.rela_name AS relaName,
|
b.money AS orderMoney,
|
b.weight AS orderWeight,
|
IFNULL( b.mark_read, 0 ) AS markRead,
|
b.order_fast_flag AS orderFastFlag,
|
b.mark_code AS markCode,
|
d.partner_id AS partnerId,
|
IFNULL( c.del_flag, 0 ) AS delFlag,
|
b.home_service_id AS homeServiceId,
|
b.note
|
FROM
|
xzx_order_info a
|
LEFT JOIN xzx_order_detail_info b ON a.order_id = b.order_id
|
LEFT JOIN xzx_user_info d ON a.create_user_id = d.user_id
|
LEFT JOIN xzx_user_other_info c ON a.receiver = c.user_id
|
LEFT JOIN xzx_user_info e ON a.receiver = e.user_id
|
LEFT JOIN xzx_order_item_info f ON a.order_id = f.order_id
|
LEFT JOIN xzx_user_address_info k ON b.address_id=k.address_id
|
WHERE 1 = 1
|
<if test="orderType != null and orderType != ''">
|
and a.order_type=#{orderType}
|
</if>
|
<if test="orderStatus != null and orderStatus != ''">
|
AND a.order_status=#{orderStatus}
|
</if>
|
|
<if test="startTime != null and startTime != ''">
|
AND a.create_time BETWEEN #{startTime} AND #{endTime}
|
</if>
|
|
<if test="orderType != null and orderType != ''">
|
AND a.order_type = #{orderType}
|
</if>
|
|
<if test="name != null and name != ''">
|
<choose>
|
<when test="orderType != null and orderType != '' and orderType==3">
|
AND (e.name like concat('%',#{name} ,'%') or e.mobile_phone like concat('%',#{name} ,'%'))
|
</when>
|
<otherwise>
|
AND (c.name like concat('%',#{name} ,'%') or c.mobile_phone like concat('%',#{name} ,'%'))
|
</otherwise>
|
</choose>
|
</if>
|
|
<if test="mobilePhone != null and mobilePhone != ''">
|
AND (d.mobile_phone like concat('%',#{mobilePhone} ,'%') or d.nick_name = #{nickName} or a.rela_phone like concat('%',#{mobilePhone} ,'%'))
|
</if>
|
|
<if test="orderId != null and orderId != ''">
|
AND a.order_id like concat('%',#{orderId} ,'%')
|
</if>
|
|
<if test="createType != null and createType != ''">
|
AND a.create_type = #{createType}
|
</if>
|
|
|
<if test="partnerId != null and partnerId != '' and townIds != null and townIds.size()>0">
|
AND (c.partner_id=#{partnerId} or (a.town_id in
|
<foreach collection="townIds" index="index" item="id" separator="," open="(" close=")">
|
#{id}
|
</foreach>
|
and a.order_type in ('1','2')))
|
</if>
|
|
<if test="partnerId != null and partnerId != '' and (townIds == null or townIds.size()==0)">
|
AND (c.partner_id=#{partnerId})
|
</if>
|
|
GROUP BY a.order_id
|
order by a.create_time desc
|
</select>
|
<select id="queryTownIdsByPartnerIds" parameterType="java.util.List" resultType="java.lang.String">
|
select distinct fence_id from xzx_partner_fence where 1=1
|
<if test=" partnerIds != null and partnerIds.size() != 0">
|
AND partner_id in
|
<foreach collection="partnerIds" index="index" item="id" separator="," open="(" close=")">
|
#{id}
|
</foreach>
|
</if>
|
</select>
|
<select id="queryStatusByCuserId" resultType="map">
|
SELECT
|
COUNT(*) as count,
|
a.order_status as orderStatus
|
FROM xzx_order_info a
|
WHERE a.receiver = #{userId}
|
GROUP BY a.order_status
|
</select>
|
<select id="queryOrderByPartnerId" resultType="java.lang.String">
|
select a.town_id
|
from xzx_order_info a
|
where a.order_id = #{orderId}
|
</select>
|
<update id="updateOrderStatus">
|
update xzx_order_info
|
<set>
|
<if test="orderStatus != null and orderStatus != ''">
|
order_status=#{orderStatus},
|
</if>
|
|
<if test="receiveId != null and receiveId != ''">
|
receiver=#{receiveId},
|
</if>
|
</set>
|
where order_id=#{orderId}
|
</update>
|
<update id="updateApirecByOrderId">
|
update xzx_order_info
|
set receiver = #{receiveId}, order_status = 2, trace_id = #{trid}
|
where order_id = #{orderId}
|
</update>
|
<update id="updateApirecDetailByOrderId">
|
update xzx_order_detail_info
|
set receive_time = SYSDATE(), receiver_phone = #{mobilePhone}, receiver_name = #{name}
|
where order_id = #{orderId}
|
</update>
|
<update id="updateOrderStatus1">
|
update xzx_order_info
|
set order_status = #{orderStatus}
|
where order_id = #{orderId}
|
</update>
|
<update id="updateOrderDetailReData">
|
update xzx_order_detail_info
|
set cancel_reason_name = #{cancelReasonName}
|
where order_id = #{orderId}
|
</update>
|
<select id="queryOrderReNum" resultType="java.lang.String">
|
select count(order_id)
|
from xzx_order_info
|
where del_flag = 0 and receiver = #{userId} and order_status = 2
|
</select>
|
<select id="queryStorageApiList" resultType="map">
|
select
|
a.storage_id as storageId,
|
IFNULL(x.name,a.storage_user_name) as storageName,
|
a.storage_user_phone as storageUserPhone,
|
(select user_type
|
from xzx_user_other_info
|
where user_id = receiver) as userType,
|
receiver_name as receiverName,
|
receiver as receiver,
|
receiver_phone as receiverPhone,
|
storage_time as storageTime,
|
IFNULL(a.recycle_weight,'0') as recycleWeight,
|
IFNULL(a.storage_weight,'0') as storageWeight,
|
IFNULL(a.storage_money,'0') as storageMoney,
|
IFNULL(a.recycle_money,'0') as recycleMoney,
|
x.del_flag as delFlag,
|
IFNULL(y.create_time,'-') as batchTime,
|
y.vehicle_id as vehicleId,
|
y.batch_no as batchNo,
|
y.emptyWeight as emptyWeight,
|
y.batchWeight as batchWeight,
|
IFNULL((select z.storage_name
|
from xzx_sys_storage z
|
where a.sys_storage_id = z.id and a.sys_storage_type=1),(select m.partner_name from xzx_city_partner m where m.id=x.partner_id and a.sys_storage_type=2)) as sysStorageName,
|
(select m.partner_name from xzx_city_partner m where m.id=x.partner_id) as partnerName
|
from xzx_order_storage_info a
|
LEFT JOIN (
|
select f.create_time,b.order_id,b.vehicle_id,b.batch_no,b.weight as batchWeight,f.weight as emptyWeight from xzx_user_vehicle_info f
|
LEFT JOIN xzx_order_batch_info b ON f.id=b.vehicle_id
|
WHERE f.id=b.vehicle_id GROUP BY b.order_id
|
)y ON y.order_id = a.order_id
|
left join xzx_user_other_info x on x.user_id = a.storage_user_id
|
where 1 = 1
|
<if test="orderStatus != null and orderStatus != ''">
|
AND a.storage_status = #{storageStatus}
|
</if>
|
<if test="storageStatus != null and storageStatus != ''">
|
AND a.storage_status = #{storageStatus}
|
</if>
|
<if test="startTime != null and startTime != ''">
|
AND a.storage_time >= #{startTime}
|
</if>
|
<if test="endTime != null and endTime != ''">
|
AND a.storage_time <= #{endTime}
|
</if>
|
<if test="name != null and name != ''">
|
AND (a.receiver_name like concat('%',#{name} ,'%') or a.receiver_phone like concat('%',#{name} ,'%') or
|
a.storage_id like concat('%',#{name} ,'%') )
|
</if>
|
|
<if test=" partnerIds != null and partnerIds.size() != 0">
|
AND x.partner_id in
|
<foreach collection="partnerIds" index="index" item="id" separator="," open="(" close=")">
|
#{id}
|
</foreach>
|
</if>
|
group by a.storage_id
|
order by a.storage_time desc
|
</select>
|
<select id="queryStorageDetailApiList" resultType="map">
|
SELECT a.order_id as orderid,a.create_time as createtime,
|
c.name as name,c.mobile_phone as mobilephone,SUM(f.money) as ordermoney,SUM(f.weight) AS orderweight
|
FROM xzx_order_info a
|
LEFT JOIN xzx_order_detail_info b ON a.order_id = b.order_id
|
LEFT JOIN xzx_user_other_info c ON a.receiver = c.user_id
|
LEFT JOIN xzx_order_item_info f ON a.order_id = f.order_id
|
WHERE 1=1
|
<if test="orderIds != null and orderIds.size() != 0">
|
AND a.order_id in
|
<foreach collection="orderIds" index="index" item="id" separator="," open="(" close=")">
|
#{id}
|
</foreach>
|
</if>
|
|
GROUP BY a.order_id desc
|
</select>
|
<select id="queryStroageDetailPageByOrderno" resultType="map">
|
select
|
IFNULL(sum(a.money),0) as recyclemoney,
|
IFNULL(sum(a.weight),0) as recycleweight,
|
d.title,
|
IFNULL((SELECT c.money
|
from xzx_order_storage_detail c
|
where a.item_type = c.item_type and c.flag=1
|
<if test="storageId != null and storageId != ''">
|
AND c.storage_id =#{storageId}
|
</if>
|
group by item_type),0) as storagemoney,
|
IFNULL((SELECT c.weight
|
from xzx_order_storage_detail c
|
where a.item_type = c.item_type and c.flag=1
|
<if test="storageId != null and storageId != ''">
|
AND c.storage_id =#{storageId}
|
</if>
|
group by item_type),0) as storageweight
|
from xzx_order_item_info a
|
LEFT JOIN (select f.township_id,e.order_id from xzx_order_detail_info e
|
LEFT JOIN xzx_user_address_info f on f.address_id=e.address_id
|
)m ON a.order_id=m.order_id
|
LEFT JOIN xzx_sys_environmental_info d ON d.item_type = a.item_type and m.township_id=d.city_id
|
where 1 = 1 AND a.money<![CDATA[> ]]>0 and a.weight<![CDATA[> ]]>0
|
<if test="orderIds != null and orderIds.size() != 0">
|
AND a.order_id in
|
<foreach collection="orderIds" index="index" item="id" separator="," open="(" close=")">
|
#{id}
|
</foreach>
|
</if>
|
GROUP BY a.item_type
|
</select>
|
<select id="queryProvince" resultType="com.xzx.gc.model.admin.SysAddressLevelModel">
|
select
|
level_1_id as level1Id,
|
level_1_name as level1Name
|
from xzx_sys_address_level_info
|
where 1 = 1
|
group by level_1_id
|
</select>
|
<select id="queryCityByProvinceId" resultType="com.xzx.gc.model.admin.SysAddressLevelModel">
|
select
|
level_2_id as level2Id,
|
level_2_name as level2Name
|
from xzx_sys_address_level_info
|
where 1 = 1 and level_1_id = #{provinceId}
|
group by level_2_id
|
</select>
|
<select id="queryTownShipByCityId" resultType="com.xzx.gc.model.admin.SysAddressLevelModel">
|
select
|
level_3_id as level3Id,
|
level_3_name as level3Name
|
from xzx_sys_address_level_info
|
where 1 = 1 and level_2_id = #{cityId}
|
group by level_3_id
|
</select>
|
|
<update id="updateOrderReserveTime">
|
update xzx_order_detail_info
|
set reserve_time = #{reserveDate},receive_time=null,receiver_name=null
|
where order_id = #{orderId}
|
</update>
|
|
<update id="updateOrderInfoReserveTime">
|
update xzx_order_info
|
set reserve_time = #{reserveDate},order_status=1,receiver=null
|
where order_id = #{orderId}
|
</update>
|
|
<delete id="updateOrderDetailByNo">
|
update xzx_order_detail_info set mark_read='1' where order_id=#{orderId}
|
</delete>
|
|
<select id="receiverStatsitic" resultType="com.xzx.gc.model.order.ReceiverStatsiticResDTO">
|
SELECT
|
c.NAME as name,
|
date_format(a.create_time,'%Y-%m-%d') AS time,
|
b.reserve_time AS reserveTime,
|
b.receive_time AS receiveTime,
|
a.order_status AS orderStatus,
|
b.complete_time AS completeTime ,
|
d.id as complaintId,
|
b.weight,
|
c.del_flag as "delFlag"
|
FROM
|
xzx_order_info a
|
INNER JOIN xzx_order_detail_info b ON a.order_id = b.order_id
|
LEFT JOIN xzx_order_complaint d ON b.order_id = d.order_id
|
INNER JOIN xzx_user_other_info c ON a.receiver = c.user_id
|
WHERE
|
1 = 1
|
<if test="key != null and key != ''">
|
and (c.name like concat("%",#{key} ,"%") or c.mobile_phone like concat("%",#{key} ,"%"))
|
</if>
|
<if test="partnerId != null and partnerId != ''">
|
and c.partner_id=#{partnerId}
|
</if>
|
<choose>
|
<when test="type==1">
|
<if test="startTime != null and startTime != ''">
|
and date_format(a.create_time,'%Y-%m-%d') >= #{startTime}
|
</if>
|
<if test="endTime != null and endTime != ''">
|
and date_format(a.create_time,'%Y-%m-%d') <= #{endTime}
|
</if>
|
</when>
|
<when test="type==2">
|
and date_format(a.create_time,'%Y') = #{year}
|
</when>
|
<when test="type==3">
|
and date_format(a.create_time,'%Y-%m') = concat(#{year},'-',#{month})
|
</when>
|
<otherwise>
|
|
</otherwise>
|
</choose>
|
</select>
|
<select id="ordergatherList" resultType="com.xzx.gc.model.user.UserGatherOrderRes">
|
select
|
a.order_id as "orderId",
|
concat(ifnull(a.unit_name,''),ifnull(a.house_number,'')) as "detailAddress",
|
a.address,
|
a.rela_name as "name",
|
a.create_user_id as "userId",
|
a.create_time as "createTime",
|
a.order_second_status "orderSecondStatus",
|
c.complete_time as "completeTime",
|
b.avatar
|
from xzx_order_info a
|
left join xzx_order_detail_info c on a.order_id=c.order_id
|
inner join xzx_user_info b on a.create_user_id=b.user_id
|
where a.order_type='3' and a.receiver=#{userId}
|
<choose>
|
<when test="orderStatus != null and orderStatus != ''">
|
and a.order_status=#{orderStatus}
|
</when>
|
</choose>
|
|
<if test="fliterType==1">
|
and DATE_FORMAT(a.create_time,'%Y-%m-%d')=CURRENT_DATE()
|
</if>
|
<if test="latitude != null and latitude != ''">
|
and ROUND(lat_lng_distance(#{latitude}, #{longitude}, a.latitude, a.longitude), 3)<=0.5
|
</if>
|
order by a.create_time desc
|
</select>
|
|
|
<select id="findServiceOrderByUserIdAndStatus" resultType="com.xzx.gc.entity.OrderInfo">
|
SELECT
|
a.order_id "orderId",
|
a.create_user_id "createUserId",
|
b.complete_time "completeTime",
|
b.receive_time "receiveTime"
|
FROM
|
xzx_order_info a
|
INNER JOIN xzx_order_detail_info b ON a.order_id = b.order_id
|
where a.receiver=#{userId} and a.order_status in
|
<foreach collection="status" index="index" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
|
</select>
|
|
<!-- 订单列表查询 -->
|
<select id="queryForHomeAppliance" parameterType="java.util.Map" resultMap="OrderMap">
|
select distinct
|
a.order_id,
|
a.town_id,
|
a.address,
|
a.order_status,
|
a.order_type,
|
a.reserve_time,
|
a.create_user_id,
|
a.receiver,
|
a.create_time,
|
a.rela_phone,
|
a.longitude,
|
a.latitude,
|
a.cancel_user_id,
|
a.address_area,
|
a.rela_name,
|
a.order_second_status,
|
a.create_type,
|
a.store_id,
|
d.take_phone_pic,
|
d.storage_user_id,
|
d.storage_user_name,
|
d.storage_user_phone,
|
d.remark,
|
d.receiver_name,
|
d.receiver_phone,
|
d.complete_time,
|
c.config_value_name "cancel_reason_name",
|
d.receive_time,
|
d.cancel_reason_name "cancelReason",
|
d.address_id,
|
d.order_fast_flag,
|
d.home_service_id,
|
d.note,
|
d.home_appliance_id,
|
d.change_receiver_flag
|
<if test="latitude!=null and latitude!='' and longitude!=null and longitude!=''">
|
,ROUND(lat_lng_distance(#{latitude}, #{longitude}, a.latitude, a.longitude), 3) as distance
|
</if>
|
from xzx_order_info a
|
left join xzx_user_other_info b on a.receiver=b.user_id and b.del_flag=0 and b.is_prohibit=0
|
inner join xzx_order_detail_info d on a.order_id=d.order_id
|
left join xzx_sys_config_info c on d.cancel_reason_code=c.config_value and c.config_type_code='CANCEL_REASON'
|
where a.order_type='5' and a.town_id=#{townId}
|
<choose>
|
<when test="orderStatus==4">
|
and (a.order_status=4 or a.order_status=7)
|
</when>
|
<otherwise>
|
<if test="orderStatus!=null and orderStatus!=''">
|
and a.order_status=#{orderStatus}
|
</if>
|
</otherwise>
|
</choose>
|
|
<if test="orderStatus != null and orderStatus != '' and orderStatus!=1">
|
and a.receiver=#{receiver}
|
</if>
|
|
<choose>
|
<when test="latitude!=null and latitude!='' and longitude!=null and longitude!='' and orderStatus==1">
|
order by distance asc,a.create_time desc
|
</when>
|
<otherwise>
|
order by a.create_time desc
|
</otherwise>
|
</choose>
|
|
</select>
|
<select id="findListOrderReceiveTime" resultType="com.xzx.gc.entity.OrderInfo">
|
SELECT
|
a.create_user_id as createUserId
|
FROM
|
xzx_order_info a
|
INNER JOIN xzx_order_detail_info b ON a.order_id = b.order_id
|
WHERE
|
a.order_status = '2' and a.receiver=#{receiver}
|
ORDER BY
|
b.receive_time ASC
|
</select>
|
|
|
</mapper>
|