<?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.OrderManageMapper">
|
|
<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,SUM(f.money) as orderMoney,SUM(f.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
|
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_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="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 like concat('%',#{name} ,'%')
|
</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=" partnerIds != null and partnerIds.size() != 0">
|
AND c.partner_id in
|
<foreach collection="partnerIds" index="index" item="id" separator="," open="(" close=")">
|
#{id}
|
</foreach>
|
</if>
|
<if test="townIds != null">
|
AND k.township_id in
|
<foreach collection="townIds" index="index" item="tid" separator="," open="(" close=")">
|
#{tid}
|
</foreach>
|
</if>
|
GROUP BY a.order_id
|
order by a.create_time desc
|
</select>
|
<select id="queryOrderByTownIdApiList" 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,m.receive_time as receiveTime,
|
m.complete_time as completeTime,
|
m.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,
|
m.orderMoney as orderMoney,m.orderWeight AS orderWeight,
|
m.order_fast_flag as orderFastFlag,
|
m.mark_code as markCode,
|
IFNULL(m.mark_read,0) as markRead,
|
d.partner_id as partnerId,
|
IFNULL(c.del_flag,0) as delFlag
|
FROM xzx_order_info a
|
LEFT JOIN ( select SUM(f.money) as orderMoney,SUM(f.weight) AS orderWeight,b.order_id,
|
b.complete_time,b.cancel_reason_name,b.receive_time,b.order_fast_flag,b.mark_code,b.mark_read
|
from
|
xzx_order_detail_info b
|
LEFT JOIN xzx_order_item_info f ON f.order_id = b.order_id
|
where 1=1 group by b.order_id
|
)m ON m.order_id=a.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
|
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 like concat('%',#{name} ,'%')
|
</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="townIds != null and townIds.size()>0">
|
AND a.town_id in
|
<foreach collection="townIds" index="index" item="id" separator="," open="(" close=")">
|
#{id}
|
</foreach>
|
</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>
|
|
|
</mapper>
|