<?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.stylefeng.guns.modular.system.dao.TOrderMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.TOrder">
|
<id column="id" property="id" />
|
<result column="user_id" property="userId" />
|
<result column="shipment_date" property="shipmentDate" />
|
<result column="state" property="state" />
|
<result column="city" property="city" />
|
<result column="port" property="port" />
|
<result column="accessorial" property="accessorial" />
|
<result column="accessorial_str" property="accessorialStr" />
|
<result column="delivery_str" property="deliveryStr" />
|
<result column="startLon" property="startLon" />
|
<result column="startLat" property="startLat" />
|
<result column="s_name" property="sName" />
|
<result column="s_email" property="sEmail" />
|
<result column="s_phone" property="sPhone" />
|
<result column="delivery_date" property="deliveryDate" />
|
<result column="type" property="type" />
|
<result column="zip_code" property="zipCode" />
|
<result column="warehouse" property="warehouse" />
|
<result column="company_id" property="companyId" />
|
<result column="e_address" property="eAddress" />
|
<result column="e_city" property="eCity" />
|
<result column="e_state" property="eState" />
|
<result column="e_zip_code" property="eZipCode" />
|
<result column="e_zip_z" property="eZipZ" />
|
<result column="e_company_name" property="eCompanyName" />
|
<result column="e_name" property="eName" />
|
<result column="e_email" property="eEmail" />
|
<result column="e_phone" property="ePhone" />
|
<result column="exam_site" property="examSite" />
|
<result column="s_driverId" property="sDriverid" />
|
<result column="s_driverId_one" property="sDriverIdOne" />
|
<result column="e_driverId" property="eDriverid" />
|
<result column="e_driverId_one" property="eDriverIdOne" />
|
<result column="status" property="status" />
|
<result column="invoice_number" property="invoiceNumber" />
|
<result column="allTotal" property="allTotal" />
|
<result column="paid" property="paid" />
|
<result column="pay_time" property="payTime" />
|
<result column="pay_status" property="payStatus" />
|
<result column="pay_money" property="payMoney" />
|
<result column="success_time" property="successTime" />
|
<result column="send_to_customer" property="sendToCustomer" />
|
<result column="remark" property="remark" />
|
<result column="pay_info_state" property="payInfoState" />
|
<result column="pay_audit" property="payAudit" />
|
<result column="order_ok_time" property="orderOkTime" />
|
<result column="order_type" property="orderType" />
|
<result column="carriers_id" property="carriersId" />
|
<result column="carriers_pay_status" property="carriersPayStatus" />
|
<result column="pay_carriers_time" property="payCarriersTime" />
|
</resultMap>
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
id, user_id, shipment_date, state, city, port, accessorial, accessorial_str, startLon, startLat, s_name, s_email, s_phone, delivery_date, type, zip_code, warehouse, company_id, e_address, e_city, e_state, e_zip_code, e_zip_z, e_company_name, e_name, e_email, e_phone, exam_site, s_driverId, e_driverId, status, create_time
|
</sql>
|
<insert id="addOrderFile">
|
insert into t_order_file (id,
|
order_id,
|
file,
|
name,
|
create_time
|
) value (null ,#{orderId},#{url},#{name},now())
|
</insert>
|
<insert id="saveLonLat">
|
insert into t_order_lonlat(id,orderId,lon,lat) value (null,#{id},#{lon},#{lat})
|
</insert>
|
|
<update id="agreePay">
|
update t_order set pay_audit =1 where id=#{number}
|
</update>
|
|
<update id="noAgreePay">
|
update t_order set pay_audit =2,remark=#{remark} where id=#{number}
|
</update>
|
|
<update id="agreeOfPayment">
|
update t_order set pay_status =1 where id =#{number}
|
</update>
|
|
<select id="getReceivable" resultType="com.stylefeng.guns.modular.system.model.ReceivableVo">
|
select t1.id,t1.create_time invoiceDate,t1.company_id userId,sum(t1.pay_money) as total,t2.name userName from t_order t1 left join t_company t2 on t1.company_id=t2.id
|
where t1.status !=0
|
<if test="name !=null and name !=''">
|
and t2.name like concat("%",#{name},"%")
|
</if>
|
group by t1.company_id
|
</select>
|
|
<select id="getTwentyDay" resultType="java.lang.Double">
|
select sum(pay_money) from t_order where company_id = #{userId} and success_time between #{time1} and #{time}
|
</select>
|
|
<select id="getNineDay" resultType="java.lang.Double">
|
select sum(pay_money) from t_order where company_id = #{userId} and #{time3} > pay_time
|
</select>
|
|
<select id="getPayList" resultType="com.stylefeng.guns.modular.system.model.ShouldPayVo">
|
select t1.id,t1.success_time billDate,t1.carriers_id userId,sum(t1.pay_money) as total,
|
t2.company_name userName from t_order t1 left join t_carriers t2 on t1.carriers_id=t2.id
|
where t1.status !=0
|
<if test="name !=null and name !=''">
|
and t2.company_name like concat("%",#{name},"%")
|
</if>
|
group by t1.carriers_id
|
</select>
|
<select id="getTwentyDayPay" resultType="java.lang.Double">
|
select sum(t1.pay_money*(t2.commission/100)) from t_order t1 LEFT JOIN t_carriers t2 on t1.carriers_id = t2 .id where t1.carriers_id = #{userId} and t1.pay_carriers_time between #{time1} and #{time}
|
</select>
|
<select id="getNineDayPay" resultType="java.lang.Double">
|
select sum(t1.pay_money*(t2.commission/100)) from t_order t1 LEFT JOIN t_carriers t2 on t1.carriers_id = t2 .id where t1.carriers_id = #{userId} and #{time3} > t1.pay_carriers_time
|
</select>
|
<select id="listOfReceivables" resultType="com.stylefeng.guns.modular.system.model.ReceivablesList">
|
select t1.invoice_number invoiceNumber,t1.id orderId,t1.user_id userId,t1.pay_money total,t1.pay_time invoicesTime,t2.company_name userName
|
from t_order t1 LEFT JOIN t_user t2 on t1.user_id=t2.id
|
where t1.status = 1
|
<if test="sTime !=null ">
|
and t1.pay_time between #{sTime} and #{eTime}
|
</if>
|
<if test="name !=null and name !='' ">
|
and t2.company_name like concat("%",#{name},"%")
|
</if>
|
<if test="invoicesId !=null and invoicesId !='' ">
|
and t1.id =#{invoicesId}
|
</if>
|
<if test="orderId !=null and orderId !='' ">
|
and t1.id =#{orderId}
|
</if>
|
<if test="state !=null and state !='' and state==1 ">
|
and t1.pay_status > t1.paid=0
|
</if>
|
<if test="state !=null and state !='' and state==2 ">
|
and t1.pay_money = 1
|
</if>
|
|
</select>
|
<select id="getPayStatus" resultType="java.lang.Integer">
|
select id from t_order where pay_status =1
|
</select>
|
<select id="listOfPay" resultType="com.stylefeng.guns.modular.system.model.PayList">
|
select t1.id orderId,t1.carriers_id companyId,t2.company_name companyName,t1.pay_carriers_time billTime,t1.pay_time dueDate,t1.carriers_pay_status paystatus,t1.pay_audit payAudit,(t1.pay_money*(t2.commission/100) ) as total FROM t_order t1 LEFT JOIN t_carriers t2 on t1.carriers_id =t2.id
|
where t1.status = 1
|
<if test="sTime !=null">
|
and t1.pay_carriers_time between #{sTime} and #{eTime}
|
</if>
|
<if test="name !=null and name != ''">
|
and t2.company_name like concat("%",#{name},"%")
|
</if>
|
<if test="billId !=null and billId != ''">
|
and t1.id =#{billId}
|
</if>
|
<if test="orderId !=null and orderId != ''">
|
and t1.id =#{orderId}
|
</if>
|
<if test="state !=null and state !='' and state==1 ">
|
and t1.carriers_pay_status =0
|
</if>
|
<if test="state !=null and state !='' and state==2 ">
|
and t1.carriers_pay_status =1
|
</if>
|
</select>
|
<select id="getIndexTotal" resultType="java.math.BigDecimal">
|
select sum(allTotal-pay_money) from t_order where `status` !=0
|
</select>
|
<select id="getOrderListOne" resultType="com.stylefeng.guns.modular.system.model.OrderListVo">
|
SELECT
|
t1.id orderId,
|
t2.container_number container,
|
t3.company_name customerName,
|
t4.address port,
|
t1.shipment_date pickupDate,
|
t1.delivery_date deliveryDate,
|
t1.status status,
|
t1.e_address destination
|
FROM
|
t_order t1
|
LEFT JOIN t_goods t2 ON t1.id = t2.order_id
|
LEFT JOIN t_user t3 on t1.user_id =t3.id
|
LEFT JOIN t_port t4 on t1.`port` = t4.id
|
LEFT JOIN t_group t5 on t3.group_id = t5.id
|
where t1.company_id = #{companyId} and t1.order_type=#{type}
|
<if test="sTime !=null">
|
and (t1.shipment_date between #{sTime} and #{eTime} or t1.delivery_date between #{sTime} and #{eTime})
|
</if>
|
<if test="customerName !=null and customerName !=''">
|
and (t3.id = #{customerName} or t3.company_name like concat("%",#{customerName},"%"))
|
</if>
|
<if test="id !=null and id !='' ">
|
and t1.id =#{id}
|
</if>
|
<if test="groupId !=null and groupId !=''">
|
and t5.id =#{groupId}
|
</if>
|
<if test="saleId !=null and saleId !=''">
|
and t5.sales_id =#{saleId}
|
</if>
|
<if test="state !=null and state !=''">
|
and t1.status =#{state}
|
</if>
|
GROUP BY
|
t1.id
|
|
|
</select>
|
<select id="getCompanyIncome" resultType="java.lang.Double">
|
select sum(pay_money) from t_order where pay_status=1 and company_id=#{companyId}
|
<if test="sTime !=null">
|
and success_time BETWEEN #{sTime} and #{eTime}
|
</if>
|
</select>
|
<select id="getOrderListIndex" resultType="com.stylefeng.guns.modular.system.model.vo.OrderInfoVo">
|
select t7.phone phone,CONCAT(t2.`name`,t3.`name`) start,1 type,t1.id orderId,t1.status,CONCAT(t1.e_address,t4.name,t5.name,t1.e_zip_code) end,t1.shipment_date pickUpTime,t6.container_number ccontainerNumber,t1.type sendType from t_order t1
|
left JOIN t_port t2 on t1.`port` = t2.id
|
LEFT JOIN t_country t3 on t2.city =t3.id
|
left JOIN t_country t4 on t1.e_city =t4.id
|
left JOIN t_country t5 on t1.e_state = t5.id
|
LEFT JOIN t_goods t6 on t6.order_id = t1.id
|
left join t_user t7 on t1.user_id = t7.id
|
where (t1.s_driverId = #{id} or t1.s_driverId_one=#{id} or t1.e_driverId_one = #{id} or t1.e_driverId = #{id} )
|
<if test="containerNo !=null and containerNo !=''">
|
and t6.container_number like concat("%",#{containerNo},"%")
|
</if>
|
<if test="sTime !=null">
|
and t1.shipment_date between #{sTime} and #{eTime}
|
</if>
|
<if test="type ==1">
|
and t1.status !=1
|
</if>
|
<if test="type !=1">
|
and t1.status =1
|
</if>
|
<!-- union all-->
|
<!-- select t7.phone phone, CONCAT(t2.`name`,t3.`name`) start,2 type,t1.id orderId,t1.status,CONCAT(t1.e_address,t4.name,t5.name,t1.e_zip_code) end,t1.shipment_date pickUpTime,t6.container_number ccontainerNumber ,t1.type sendType from t_order t1-->
|
<!-- left JOIN t_port t2 on t1.`port` = t2.id-->
|
<!-- LEFT JOIN t_country t3 on t2.city =t3.id-->
|
<!-- left JOIN t_country t4 on t1.e_city =t4.id-->
|
<!-- left JOIN t_country t5 on t1.e_state = t5.id-->
|
<!-- LEFT JOIN t_goods t6 on t6.order_id = t1.id-->
|
<!-- left join t_user t7 on t1.user_id = t7.id-->
|
<!-- where (t1.s_driverId_one = #{id} )-->
|
<!-- <if test="containerNo !=null and containerNo !=''">-->
|
<!-- and t6.container_number like concat("%",#{containerNo},"%")-->
|
<!-- </if>-->
|
<!-- <if test="sTime !=null">-->
|
<!-- and t1.shipment_date between #{sTime} and #{eTime}-->
|
<!-- </if>-->
|
<!-- <if test="type ==1">-->
|
<!-- and t1.status !=1-->
|
<!-- </if>-->
|
<!-- <if test="type !=1">-->
|
<!-- and t1.status =1-->
|
<!-- </if>-->
|
<!-- union all-->
|
<!-- select t7.phone phone, CONCAT(t2.`name`,t3.`name`) start,3 type,t1.id orderId,t1.status,CONCAT(t1.e_address,t4.name,t5.name,t1.e_zip_code) end,t1.shipment_date pickUpTime,t6.container_number ccontainerNumber,t1.type sendType from t_order t1-->
|
<!-- left JOIN t_port t2 on t1.`port` = t2.id-->
|
<!-- LEFT JOIN t_country t3 on t2.city =t3.id-->
|
<!-- left JOIN t_country t4 on t1.e_city =t4.id-->
|
<!-- left JOIN t_country t5 on t1.e_state = t5.id-->
|
<!-- LEFT JOIN t_goods t6 on t6.order_id = t1.id-->
|
<!-- left join t_user t7 on t1.user_id = t7.id-->
|
<!-- where ( t1.e_driverId_one = #{id})-->
|
<!-- <if test="containerNo !=null and containerNo !=''">-->
|
<!-- and t6.container_number like concat("%",#{containerNo},"%")-->
|
<!-- </if>-->
|
<!-- <if test="sTime !=null">-->
|
<!-- and t1.shipment_date between #{sTime} and #{eTime}-->
|
<!-- </if>-->
|
<!-- <if test="type ==1">-->
|
<!-- and t1.status !=1-->
|
<!-- </if>-->
|
<!-- <if test="type !=1">-->
|
<!-- and t1.status =1-->
|
<!-- </if>-->
|
<!-- union all-->
|
<!-- select t7.phone phone, CONCAT(t2.`name`,t3.`name`) start,4 type,t1.id orderId,t1.status,CONCAT(t1.e_address,t4.name,t5.name,t1.e_zip_code) end,t1.shipment_date pickUpTime,t6.container_number ccontainerNumber ,t1.type sendType from t_order t1-->
|
<!-- left JOIN t_port t2 on t1.`port` = t2.id-->
|
<!-- LEFT JOIN t_country t3 on t2.city =t3.id-->
|
<!-- left JOIN t_country t4 on t1.e_city =t4.id-->
|
<!-- left JOIN t_country t5 on t1.e_state = t5.id-->
|
<!-- LEFT JOIN t_goods t6 on t6.order_id = t1.id-->
|
<!-- left join t_user t7 on t1.user_id = t7.id-->
|
<!-- where ( t1.e_driverId = #{id} )-->
|
<!-- <if test="containerNo !=null and containerNo !=''">-->
|
<!-- and t6.container_number like concat("%",#{containerNo},"%")-->
|
<!-- </if>-->
|
<!-- <if test="sTime !=null">-->
|
<!-- and t1.shipment_date between #{sTime} and #{eTime}-->
|
<!-- </if>-->
|
<!-- <if test="type ==1">-->
|
<!-- and t1.status !=1-->
|
<!-- </if>-->
|
<!-- <if test="type !=1">-->
|
<!-- and t1.status =1-->
|
<!-- </if>-->
|
</select>
|
<select id="getLonLat" resultType="java.util.Map">
|
select lon,lat from t_order_lonlat where orderId =#{orderId}
|
</select>
|
|
</mapper>
|