|
|
@@ -47,6 +47,7 @@
|
|
|
<result column="sales_type" jdbcType="INTEGER" property="salesType" />
|
|
|
<result column="channel_id" jdbcType="VARCHAR" property="channelId" />
|
|
|
<result column="other" jdbcType="VARCHAR" property="other" />
|
|
|
+ <result column="user_type" jdbcType="INTEGER" property="userType" />
|
|
|
</resultMap>
|
|
|
<sql id="Base_Column_List">
|
|
|
order_no, order_type, creater, create_time, update_time, buyer_id, first_amount,
|
|
|
@@ -56,7 +57,7 @@
|
|
|
contract_type, contacts, contact_mobile, legal_person, legal_person_tel, proof_count,
|
|
|
proof_aid, proof_time, proof_status, order_dep, outsource, additional_order, primary_order,
|
|
|
old_salesman_id, back_status, agreement_url, new_user, service_content, sales_type,
|
|
|
- channel_id, other
|
|
|
+ channel_id, other, user_type
|
|
|
</sql>
|
|
|
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
|
|
|
select
|
|
|
@@ -83,8 +84,8 @@
|
|
|
order_dep, outsource, additional_order,
|
|
|
primary_order, old_salesman_id, back_status,
|
|
|
agreement_url, new_user, service_content,
|
|
|
- sales_type, channel_id, other
|
|
|
- )
|
|
|
+ sales_type, channel_id, other,
|
|
|
+ user_type)
|
|
|
values (#{orderNo,jdbcType=VARCHAR}, #{orderType,jdbcType=INTEGER}, #{creater,jdbcType=VARCHAR},
|
|
|
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{buyerId,jdbcType=VARCHAR},
|
|
|
#{firstAmount,jdbcType=DECIMAL}, #{totalAmount,jdbcType=DECIMAL}, #{settlementAmount,jdbcType=DECIMAL},
|
|
|
@@ -99,8 +100,8 @@
|
|
|
#{orderDep,jdbcType=VARCHAR}, #{outsource,jdbcType=INTEGER}, #{additionalOrder,jdbcType=VARCHAR},
|
|
|
#{primaryOrder,jdbcType=VARCHAR}, #{oldSalesmanId,jdbcType=VARCHAR}, #{backStatus,jdbcType=INTEGER},
|
|
|
#{agreementUrl,jdbcType=VARCHAR}, #{newUser,jdbcType=INTEGER}, #{serviceContent,jdbcType=VARCHAR},
|
|
|
- #{salesType,jdbcType=INTEGER}, #{channelId,jdbcType=VARCHAR}, #{other,jdbcType=VARCHAR}
|
|
|
- )
|
|
|
+ #{salesType,jdbcType=INTEGER}, #{channelId,jdbcType=VARCHAR}, #{other,jdbcType=VARCHAR},
|
|
|
+ #{userType,jdbcType=INTEGER})
|
|
|
</insert>
|
|
|
<insert id="insertSelective" parameterType="com.goafanti.common.model.TOrderNew">
|
|
|
insert into t_order_new
|
|
|
@@ -240,6 +241,9 @@
|
|
|
<if test="other != null">
|
|
|
other,
|
|
|
</if>
|
|
|
+ <if test="userType != null">
|
|
|
+ user_type,
|
|
|
+ </if>
|
|
|
</trim>
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
<if test="orderNo != null">
|
|
|
@@ -377,6 +381,9 @@
|
|
|
<if test="other != null">
|
|
|
#{other,jdbcType=VARCHAR},
|
|
|
</if>
|
|
|
+ <if test="userType != null">
|
|
|
+ #{userType,jdbcType=INTEGER},
|
|
|
+ </if>
|
|
|
</trim>
|
|
|
</insert>
|
|
|
<update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.TOrderNew">
|
|
|
@@ -514,6 +521,9 @@
|
|
|
<if test="other != null">
|
|
|
other = #{other,jdbcType=VARCHAR},
|
|
|
</if>
|
|
|
+ <if test="userType != null">
|
|
|
+ user_type = #{userType,jdbcType=INTEGER},
|
|
|
+ </if>
|
|
|
</set>
|
|
|
where order_no = #{orderNo,jdbcType=VARCHAR}
|
|
|
</update>
|
|
|
@@ -562,7 +572,8 @@
|
|
|
service_content = #{serviceContent,jdbcType=VARCHAR},
|
|
|
sales_type = #{salesType,jdbcType=INTEGER},
|
|
|
channel_id = #{channelId,jdbcType=VARCHAR},
|
|
|
- other = #{other,jdbcType=VARCHAR}
|
|
|
+ other = #{other,jdbcType=VARCHAR},
|
|
|
+ user_type = #{userType,jdbcType=INTEGER}
|
|
|
where order_no = #{orderNo,jdbcType=VARCHAR}
|
|
|
</update>
|
|
|
|
|
|
@@ -1270,25 +1281,25 @@ left join department d on o.order_dep = d.id left join t_order_mid a on o.orde
|
|
|
</select>
|
|
|
|
|
|
<select id="getOrderNewDetail" parameterType="java.lang.String" resultType="com.goafanti.order.bo.TOrderNewBo">
|
|
|
- select
|
|
|
- a.order_no as orderNo, a.order_type as orderType, a.creater, a.create_time as createTime,a.update_time as updateTime, a.buyer_id as buyerId,
|
|
|
- a.first_amount as firstAmount,a.total_amount as totalAmount, a.settlement_amount as settlementAmount, order_status as orderStatus,
|
|
|
- a.liquidation_status as liquidationStatus, a.process_status as processStatus, a.project_status as projectStatus, a.approval,a.sales_type salesType,
|
|
|
- a.order_remarks as orderRemarks, a.delete_sign as deleteSign, a.salesman_id as salesmanId, a.finance_id as financeId, technician_id as technicianId,
|
|
|
- a.sign_time as signTime, a.settlement_time as settlementTime, a.contract_no as contractNo, a.contract_type as contractType, a.contacts,
|
|
|
- a.contact_mobile as contactMobile, a.legal_person as legalPerson, a.legal_person_tel as legalPersonTel, a.proof_count as proofCount,
|
|
|
- a.proof_aid as proofAid,contract_picture_url as contractPictureUrl, c.name as salesmanName,dep.name as depName,d.name as financeName,
|
|
|
- c.contact_mobile as salesmanMobile,d.contact_mobile as financeMobile,b.username as userName ,b.nickname as nickname ,e.back_status as backStatus,f.name as initiateName,
|
|
|
- e.reason,date_format(e.create_time,'%Y-%m-%d') as backDate,a.buyer_id as uid,a.order_dep as orderDep, g.location_province as locationProvince,
|
|
|
- g.location_city as locationCity,g.location_area locationArea,g.postal_address postalAddress,outsource,a.primary_order primaryOrder,a.agreement_url agreementUrl,
|
|
|
- h.name NowFinance,h.contact_mobile NowFinanceMobile,a.additional_order additionalOrder,i.name as oldSalesmanName, i.contact_mobile oldSalesmanMobile,
|
|
|
- a.service_content serviceContent
|
|
|
+ select
|
|
|
+ a.order_no as orderNo, a.order_type as orderType, a.creater, a.create_time as createTime,a.update_time as updateTime, a.buyer_id as buyerId,a.other,
|
|
|
+ a.first_amount as firstAmount,a.total_amount as totalAmount, a.settlement_amount as settlementAmount, order_status as orderStatus,a.user_type userType,
|
|
|
+ a.liquidation_status as liquidationStatus, a.process_status as processStatus, a.project_status as projectStatus, a.approval,a.sales_type salesType,
|
|
|
+ a.order_remarks as orderRemarks, a.delete_sign as deleteSign, a.salesman_id as salesmanId, a.finance_id as financeId, technician_id as technicianId,
|
|
|
+ a.sign_time as signTime, a.settlement_time as settlementTime, a.contract_no as contractNo, a.contract_type as contractType, a.contacts,a.channel_id channelId,
|
|
|
+ a.contact_mobile as contactMobile, a.legal_person as legalPerson, a.legal_person_tel as legalPersonTel, a.proof_count as proofCount,
|
|
|
+ a.proof_aid as proofAid,contract_picture_url as contractPictureUrl, c.name as salesmanName,dep.name as depName,d.name as financeName,
|
|
|
+ c.contact_mobile as salesmanMobile,d.contact_mobile as financeMobile,b.username as userName ,b.nickname as nickname ,e.back_status as backStatus,f.name as initiateName,
|
|
|
+ e.reason,date_format(e.create_time,'%Y-%m-%d') as backDate,a.buyer_id as uid,a.order_dep as orderDep, g.location_province as locationProvince,
|
|
|
+ g.location_city as locationCity,g.location_area locationArea,g.postal_address postalAddress,outsource,a.primary_order primaryOrder,a.agreement_url agreementUrl,
|
|
|
+ h.name NowFinance,h.contact_mobile NowFinanceMobile,a.additional_order additionalOrder,i.name as oldSalesmanName, i.contact_mobile oldSalesmanMobile,
|
|
|
+ a.service_content serviceContent
|
|
|
from t_order_new a left join `user` b on a.buyer_id=b.id left join admin i on a.old_salesman_id=i.id
|
|
|
- left join admin c on a.salesman_id=c.id left join department dep on a.order_dep=dep.id
|
|
|
- left join admin d on a.finance_id=d.id left join admin h on dep.finance_id=h.id
|
|
|
- left join (select * from t_order_back a where back_status=0) e on a.order_no=e.order_no
|
|
|
- left join admin f on e.initiate=f.id left join organization_identity g on a.buyer_id=g.uid
|
|
|
- where a.order_no = #{orderNo,jdbcType=VARCHAR}
|
|
|
+ left join admin c on a.salesman_id=c.id left join department dep on a.order_dep=dep.id
|
|
|
+ left join admin d on a.finance_id=d.id left join admin h on dep.finance_id=h.id
|
|
|
+ left join t_order_back e on a.order_no=e.order_no and e.back_status=0
|
|
|
+ left join admin f on e.initiate=f.id left join organization_identity g on a.buyer_id=g.uid
|
|
|
+ where a.order_no = #{orderNo,jdbcType=VARCHAR}
|
|
|
</select>
|
|
|
|
|
|
|
|
|
@@ -1365,402 +1376,4 @@ left join department d on o.order_dep = d.id left join t_order_mid a on o.orde
|
|
|
</foreach>
|
|
|
and finance_id= #{aid,jdbcType=VARCHAR}
|
|
|
</update>
|
|
|
- <select id="checkContractNo" resultType="java.lang.Integer">
|
|
|
- select count(contract_no) from t_order_new
|
|
|
- where contract_no= #{0}
|
|
|
- </select>
|
|
|
-
|
|
|
- <select id="countTotalAndActually" parameterType="Map" resultType="java.util.Map">
|
|
|
- select sum(o.settlement_amount) actuallyTotalAmount,sum(o.total_amount) signTotalAmount from t_order_new o
|
|
|
- left join department d on o.order_dep=d.id left join `user` u on o.buyer_id = u.id left join t_order_mid a on o.order_no=a.order_no
|
|
|
- where o.delete_sign in(0,2,3) and (o.approval = 0 or o.approval = 2) and outsource= #{o.outsource,jdbcType=INTEGER}
|
|
|
- <if test="o.processStatus == 3">
|
|
|
- and o.process_status = #{o.processStatus,jdbcType=INTEGER}
|
|
|
- </if>
|
|
|
- <if test="o.processStatus == 4">
|
|
|
- and o.process_status >= #{o.processStatus,jdbcType=INTEGER}
|
|
|
- </if>
|
|
|
- <if test="o.processStatus == 9">
|
|
|
- and o.back_status = 3
|
|
|
- </if>
|
|
|
- <if test="fids != null and fids.size() > 0">
|
|
|
- and d.finance_id in
|
|
|
- <foreach close=")" collection="fids" index="" item="item" open="(" separator=",">
|
|
|
- #{item}
|
|
|
- </foreach>
|
|
|
- </if>
|
|
|
- <if test="o.orderStatus != null and o.orderStatus != """>
|
|
|
- and (o.order_status >= #{o.orderStatus,jdbcType=INTEGER} or o.back_status=3)
|
|
|
- </if>
|
|
|
- <if test="o.departmentId != null and o.departmentId != """>
|
|
|
- and o.order_dep = #{o.departmentId,jdbcType=INTEGER}
|
|
|
- </if>
|
|
|
- <if test="o.contractNo != null and o.contractNo != """>
|
|
|
- and o.contract_no like CONCAT('%',#{o.contractNo,jdbcType=VARCHAR},'%')
|
|
|
- </if>
|
|
|
- <if test="o.liquidationStatus != null">
|
|
|
- and o.liquidation_status = #{o.liquidationStatus,jdbcType=INTEGER}
|
|
|
- </if>
|
|
|
- <if test="o.amountStatus == 0">
|
|
|
- and o.total_amount < 10
|
|
|
- </if>
|
|
|
- <if test="o.amountStatus == 1">
|
|
|
- and o.total_amount between 10 and 20
|
|
|
- </if>
|
|
|
- <if test="o.amountStatus == 2">
|
|
|
- and o.total_amount between 20 and 30
|
|
|
- </if>
|
|
|
- <if test="o.amountStatus == 3">
|
|
|
- and o.total_amount between 30 and 40
|
|
|
- </if>
|
|
|
- <if test="o.amountStatus == 4">
|
|
|
- and o.total_amount > 40
|
|
|
- </if>
|
|
|
- <if test="o.orderNo != null and o.orderNo != """>
|
|
|
- and o.order_no = #{o.orderNo,jdbcType=VARCHAR}
|
|
|
- </if>
|
|
|
- <if test="o.buyerName != null and o.buyerName != """>
|
|
|
- <bind name="n" value="'%' + o.buyerName + '%'" />
|
|
|
- and u.nickname like #{n,jdbcType=VARCHAR}
|
|
|
- </if>
|
|
|
- <if test="o.startTime != null and o.startTime != "" and o.endTime != null and o.endTime != """>
|
|
|
- <bind name="a" value="o.startTime + ' 00:00:00'" />
|
|
|
- <bind name="b" value="o.endTime + ' 23:59:59'" />
|
|
|
- and o.create_time between #{a,jdbcType=VARCHAR} and #{b,jdbcType=VARCHAR}
|
|
|
- </if>
|
|
|
- <if test="o.startFinalReceivablesTime != null and o.startFinalReceivablesTime != "" and o.endFinalReceivablesTime != null and o.endFinalReceivablesTime != """>
|
|
|
- <bind name="c" value="o.startFinalReceivablesTime + ' 00:00:00'" />
|
|
|
- <bind name="d" value="o.endFinalReceivablesTime + ' 23:59:59'" />
|
|
|
- and a.final_Receivables_time between #{c,jdbcType=VARCHAR} and #{d,jdbcType=VARCHAR}
|
|
|
- </if>
|
|
|
- </select>
|
|
|
-
|
|
|
- <select id="getLastPayment" resultType="com.goafanti.common.model.TOrderBillNew">
|
|
|
- select date_format(create_time, '%Y-%m-%d %H:%i:%s') createTimes,transaction_amount transactionAmount from t_order_bill_new
|
|
|
- where order_no= #{orderNo}
|
|
|
- order by create_time desc limit 1;
|
|
|
- </select>
|
|
|
- <update id="updateSalesmanId">
|
|
|
- update t_order_new set salesman_id= #{transferId},old_salesman_id= #{aid}
|
|
|
- where delete_sign in(0,2,3) and salesman_id= #{aid}
|
|
|
- </update>
|
|
|
-
|
|
|
- <select id="selectUsedOrderByOrder" resultType="com.goafanti.order.bo.TOrderNewBo">
|
|
|
- select
|
|
|
- a.order_no as orderNo, a.order_type as orderType, a.creater, a.create_time as createTime,a.update_time as updateTime, a.buyer_id as buyerId,
|
|
|
- a.first_amount as firstAmount,a.total_amount as totalAmount, a.settlement_amount as settlementAmount, order_status as orderStatus,
|
|
|
- a.liquidation_status as liquidationStatus, a.process_status as processStatus, a.project_status as projectStatus, a.approval,
|
|
|
- a.order_remarks as orderRemarks, a.delete_sign as deleteSign, a.salesman_id as salesmanId, a.finance_id as financeId, technician_id as technicianId,
|
|
|
- a.sign_time as signTime, a.settlement_time as settlementTime, a.contract_no as contractNo, a.contract_type as contractType, a.contacts,
|
|
|
- a.contact_mobile as contactMobile, a.legal_person as legalPerson, a.legal_person_tel as legalPersonTel, a.proof_count as proofCount,
|
|
|
- a.proof_aid as proofAid,contract_picture_url as contractPictureUrl, c.name as salesmanName,dep.name as depName,d.name as financeName,
|
|
|
- c.contact_mobile as salesmanMobile,d.contact_mobile as financeMobile,b.nickname as userName ,e.back_status as backStatus,f.name as initiateName,
|
|
|
- e.reason,date_format(e.create_time,'%Y-%m-%d') as backDate,a.buyer_id as uid,a.order_dep as orderDep, g.location_province as locationProvince,
|
|
|
- g.location_city as locationCity,g.location_area locationArea,g.postal_address postalAddress,outsource,a.primary_order primaryOrder,
|
|
|
- h.name NowFinance,h.contact_mobile NowFinanceMobile,a.additional_order additionalOrder,i.name as oldSalesmanName, i.contact_mobile oldSalesmanMobile
|
|
|
- from new_order_change noc left join t_order_new a on noc.used_order=a.order_no left join `user` b on a.buyer_id=b.id left join admin i on a.old_salesman_id=i.id
|
|
|
- left join admin c on a.salesman_id=c.id left join department dep on a.order_dep=dep.id left join admin d on a.finance_id=d.id
|
|
|
- left join admin h on dep.finance_id=h.id left join (select * from t_order_back a where back_status=0) e on a.order_no=e.order_no
|
|
|
- left join admin f on e.initiate=f.id left join organization_identity g on a.buyer_id=g.uid
|
|
|
- where noc.order_no= #{orderNo} order by noc.create_time
|
|
|
- </select>
|
|
|
-
|
|
|
- <update id="updaterefund" parameterType="com.goafanti.common.model.TOrderNew">
|
|
|
- update t_order_new set settlement_amount=settlement_amount-#{refundAmount,jdbcType=DECIMAL},
|
|
|
- refund_amount=#{refundAmount,jdbcType=DECIMAL} where order_no=#{orderNo}
|
|
|
- </update>
|
|
|
-
|
|
|
- <select id="selectArrearsDunListByPage" resultType="com.goafanti.order.bo.OutArrearsDunListBo">
|
|
|
- select a.id, b.contract_no contractNo,a.order_no as orderNo,c.nickname as userName,tm.salesman_name as salesmanName,
|
|
|
- b.project_status projectStatus, b.total_amount as totalAmount,b.liquidation_status as liquidationStatus,a.`type`,
|
|
|
- b.settlement_amount as settlementAmount, a.order_receivables orderReceivables,a.order_arrears as orderArrears,
|
|
|
- b.order_status as orderStatus, date_format(a.start_time, '%Y-%m-%d %H:%i:%s') as startDate,dep.name as depName,
|
|
|
- date_format(b.sign_time,'%Y-%m-%d') as signDate,a.dun_status dunStatus,x.commodity_name commodityName
|
|
|
- from t_arrears_dun a
|
|
|
- left join (select order_no ,commodity_name from t_order_task where main =1)x on a.order_no =x.order_no
|
|
|
- left join t_order_new b on a.order_no=b.order_no left join `user` c on b.buyer_id=c.id
|
|
|
- left join t_order_mid tm on b.order_no=tm.order_no left join department dep on b.order_dep=dep.id
|
|
|
- where b.delete_sign in(0,2,3) and dun_status in (1,2,3)
|
|
|
- <if test="shiroType == 1 and fid !=null">
|
|
|
- and tm.finance_id= #{fid,jdbcType=VARCHAR}
|
|
|
- </if>
|
|
|
- <if test="shiroType == 2 and fid !=null">
|
|
|
- and tm.finance_id in (select id from admin where superior_id= #{fid,jdbcType=VARCHAR})
|
|
|
- </if>
|
|
|
- <if test="name != null">
|
|
|
- and c.nickname like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
|
|
|
- </if>
|
|
|
- <if test="adminName != null">
|
|
|
- and tm.salesman_name like CONCAT('%',#{adminName,jdbcType=VARCHAR},'%')
|
|
|
- </if>
|
|
|
- <if test="orderNo != null">
|
|
|
- and a.order_no like CONCAT('%',#{orderNo,jdbcType=VARCHAR},'%')
|
|
|
- </if>
|
|
|
- <if test="contractNo != null">
|
|
|
- and b.contract_no like CONCAT('%',#{contractNo,jdbcType=VARCHAR},'%')
|
|
|
- </if>
|
|
|
- <if test="depId != null">
|
|
|
- and b.order_dep= #{depId,jdbcType=VARCHAR}
|
|
|
- </if>
|
|
|
- <if test="shiroType !=3 and aid != null">
|
|
|
- and b.salesman_id= #{aid,jdbcType=VARCHAR}
|
|
|
- </if>
|
|
|
- <if test="starTime !=null and endTime !=null">
|
|
|
- and b.sign_time between #{starTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
|
|
|
- </if>
|
|
|
- <if test="tStarTime !=null and tEndTime !=null">
|
|
|
- and a.start_time between #{tStarTime,jdbcType=VARCHAR} and #{tEndTime,jdbcType=VARCHAR}
|
|
|
- </if>
|
|
|
- order by dun_status,a.start_time desc
|
|
|
- <if test="page_sql!=null">
|
|
|
- ${page_sql}
|
|
|
- </if>
|
|
|
- </select>
|
|
|
- <select id="selectArrearsDunListByCount" resultType="java.lang.Integer">
|
|
|
- select count(*) from t_arrears_dun a
|
|
|
- left join t_order_new b on a.order_no=b.order_no left join `user` c on b.buyer_id=c.id
|
|
|
- left join t_order_mid tm on b.order_no=tm.order_no left join department dep on b.order_dep=dep.id
|
|
|
- where b.delete_sign in(0,2,3) and dun_status in (1,2,3)
|
|
|
- <if test="shiroType == 1 and fid !=null">
|
|
|
- and tm.finance_id= #{fid,jdbcType=VARCHAR}
|
|
|
- </if>
|
|
|
- <if test="shiroType == 2 and fid !=null">
|
|
|
- and tm.finance_id in (select id from admin where superior_id= #{fid,jdbcType=VARCHAR})
|
|
|
- </if>
|
|
|
- <if test="shiroType !=3 and aid != null">
|
|
|
- and b.salesman_id= #{aid,jdbcType=VARCHAR}
|
|
|
- </if>
|
|
|
- <if test="name != null">
|
|
|
- and c.nickname like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
|
|
|
- </if>
|
|
|
- <if test="adminName != null">
|
|
|
- and tm.salesman_name like CONCAT('%',#{adminName,jdbcType=VARCHAR},'%')
|
|
|
- </if>
|
|
|
- <if test="orderNo != null">
|
|
|
- and a.order_no like CONCAT('%',#{orderNo,jdbcType=VARCHAR},'%')
|
|
|
- </if>
|
|
|
- <if test="depId != null">
|
|
|
- and b.order_dep= #{depId,jdbcType=VARCHAR}
|
|
|
- </if>
|
|
|
- <if test="aid != null">
|
|
|
- and b.salesman_id= #{aid,jdbcType=VARCHAR}
|
|
|
- </if>
|
|
|
- <if test="starTime !=null and endTime !=null">
|
|
|
- and b.sign_time between #{starTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
|
|
|
- </if>
|
|
|
- <if test="tStarTime !=null and tEndTime !=null">
|
|
|
- and a.start_time between #{tStarTime,jdbcType=VARCHAR} and #{tEndTime,jdbcType=VARCHAR}
|
|
|
- </if>
|
|
|
- </select>
|
|
|
- <select id="selectByUidAndNewUser" resultType="java.math.BigDecimal">
|
|
|
- select total_amount from t_order_new
|
|
|
- where process_status >4 and buyer_id = #{uid}
|
|
|
- and salesman_id =#{aid}
|
|
|
- and new_user = #{newUser}
|
|
|
- and create_time between #{date} and #{now}
|
|
|
- </select>
|
|
|
- <select id="statisticsList" resultType="com.goafanti.order.bo.outStatisticsList">
|
|
|
- select z.id,z.province,z.counts,z.quantity,z.total
|
|
|
- from (select y.id,y.province,count(aid)counts,sum(quantity)quantity,sum(total)total
|
|
|
- from (select x.id,x.province,x.aid,sum(quantity)quantity, sum(x.total)total
|
|
|
- from (select d.id,d.name province,a.order_no,a.salesman_id aid,
|
|
|
- if(a.total_amount>0.5,1,if(a.total_amount>0 and a.order_type=1,0.5,0))quantity,
|
|
|
- a.total_amount total
|
|
|
- from t_order_new a left join admin b on a.salesman_id =b.id
|
|
|
- left join department c on b.department_id =c.id left join district_glossory d on c.province =d.id
|
|
|
- where a.process_status >4 and a.delete_sign in(0,2)
|
|
|
- <if test="depId !=null">
|
|
|
- and b.department_id = #{depId}
|
|
|
- </if>
|
|
|
- <if test="province !=null">
|
|
|
- and c.province = #{province}
|
|
|
- </if>
|
|
|
- <if test="startCreate !=null and endCreate !=null">
|
|
|
- and a.create_time between #{startCreate} and #{endCreate}
|
|
|
- </if>
|
|
|
- <if test="startSign !=null and endSign !=null">
|
|
|
- and a.sign_time between #{startSign} and #{endSign}
|
|
|
- </if>
|
|
|
- )x group by x.id,x.province,x.aid)y group by y.id,y.province)z
|
|
|
- order by
|
|
|
- <if test="sort ==0">
|
|
|
- total
|
|
|
- </if>
|
|
|
- <if test="sort ==1">
|
|
|
- quantity
|
|
|
- </if>
|
|
|
- <if test="sort ==2">
|
|
|
- counts
|
|
|
- </if>
|
|
|
- desc
|
|
|
- </select>
|
|
|
- <select id="provinceStatisticsList" resultType="com.goafanti.order.bo.outProvinceStatisticsList">
|
|
|
- select z.depName,z.aid,z.name,z.quantity,z.total
|
|
|
- from ( select x.depName,x.aid,x.name,sum(quantity)quantity,sum(total)total
|
|
|
- from ( select c.name depName,a.order_no,b.id aid,b.name name,
|
|
|
- if(a.total_amount>0.5,1,if(a.total_amount>0 and a.order_type=1,0.5,0))quantity,
|
|
|
- a.total_amount total
|
|
|
- from t_order_new a left join admin b on a.salesman_id =b.id
|
|
|
- left join department c on b.department_id =c.id left join district_glossory d on c.province =d.id
|
|
|
- where a.process_status >4 and a.delete_sign in(0,2)
|
|
|
- <if test="depId !=null">
|
|
|
- and b.department_id = #{depId}
|
|
|
- </if>
|
|
|
- <if test="province !=null">
|
|
|
- and c.province = #{province}
|
|
|
- </if>
|
|
|
- <if test="startCreate !=null and endCreate !=null">
|
|
|
- and a.create_time between #{startCreate} and #{endCreate}
|
|
|
- </if>
|
|
|
- <if test="startSign !=null and endSign !=null">
|
|
|
- and a.sign_time between #{startSign} and #{endSign}
|
|
|
- </if>
|
|
|
- )x group by x.depName,x.aid,x.name )z order by
|
|
|
- <if test="sort ==0">
|
|
|
- total
|
|
|
- </if>
|
|
|
- <if test="sort ==1">
|
|
|
- quantity
|
|
|
- </if>
|
|
|
- desc
|
|
|
- </select>
|
|
|
- <select id="selectOrderByuid" resultType="java.util.Map">
|
|
|
- select order_no orderNo,contract_no contractNo
|
|
|
- from t_order_new where delete_sign in (0,2) and buyer_id = #{uid}
|
|
|
- </select>
|
|
|
- <select id="orderSalesSource" resultType="com.goafanti.order.bo.OutOrderSalesSource">
|
|
|
- select y.province,dg.name ,y.total_amount totalAmount,y.counts,y.dhxkf,y.dhxkf/y.counts dhxkfl,
|
|
|
- y.dhzdzy,y.dhzdzy/y.counts dhzdzyl,y.wl,y.wl/y.counts wll,
|
|
|
- y.qd,y.qd/y.counts qdl,y.zjs,y.zjs/y.counts zjsl,y.qt,y.qt/y.counts qtl,
|
|
|
- y.gxfg,y.gxfg/y.counts gxfgl,y.qtfg,y.qtfg/y.counts qtfgl
|
|
|
- from (select x.province,sum(x.total_amount)total_amount,sum(x.counts)counts,
|
|
|
- sum(x.dhxkf)dhxkf,sum(x.dhzdzy)dhzdzy,sum(x.wl)wl,sum(x.qd)qd, sum(x.zjs)zjs, sum(x.qt)qt,
|
|
|
- sum(x.gxfg)gxfg, sum(x.qtfg)qtfg
|
|
|
- from ( select b.province ,1 counts,a.total_amount,a.sales_type ,
|
|
|
- case a.sales_type when 0 then 1 else 0 end dhxkf,
|
|
|
- case a.sales_type when 1 then 1 else 0 end dhzdzy,
|
|
|
- case a.sales_type when 2 then 1 else 0 end wl,
|
|
|
- case a.sales_type when 3 then 1 else 0 end qd,
|
|
|
- case a.sales_type when 4 then 1 else 0 end zjs,
|
|
|
- case a.sales_type when 5 then 1 else 0 end qt,
|
|
|
- case a.sales_type when 6 then 1 else 0 end gxfg,
|
|
|
- case a.sales_type when 7 then 1 else 0 end qtfg
|
|
|
- from t_order_new a left join department b on a.order_dep =b.id
|
|
|
- where a.delete_sign in (0,2) and a.process_status > 0 and a.approval in (0,1,2)
|
|
|
- <if test=" startDate !=null and endDate != null">
|
|
|
- and a.create_time between #{startDate} and #{endDate}
|
|
|
- </if>
|
|
|
- <if test=" depId !=null">
|
|
|
- and a.order_dep= #{depId}
|
|
|
- </if>
|
|
|
- <if test=" province !=null">
|
|
|
- and b.province = #{province}
|
|
|
- </if>
|
|
|
- )x group by x.province)y left join district_glossory dg on y.province=dg.id
|
|
|
- <if test=" sort ==0">
|
|
|
- order by y.total_amount desc
|
|
|
- </if>
|
|
|
- <if test=" sort ==1">
|
|
|
- order by y.counts desc
|
|
|
- </if>
|
|
|
- </select>
|
|
|
-
|
|
|
- <select id="selectstatisticsOrderListPage" resultType="com.goafanti.order.bo.TOrderNewBo">
|
|
|
- select a.order_no as orderNo,a.create_time as createTime, date_format(a.sign_time,'%Y-%m-%d' ) as signDate,a.delete_sign deleteSign,
|
|
|
- a.contract_no as contractNo, b.nickname as userName ,a.process_status as processStatus,a.total_amount as totalAmount,
|
|
|
- a.order_status as orderStatus, a.liquidation_status as liquidationStatus,a.approval,c.salesman_name as salesmanName,c.project_type projectType,
|
|
|
- dep.name as depName,c.finance_name as financeName,c.invoice_amount invoiceAmount,a.settlement_amount settlementAmount,
|
|
|
- a.sales_type salesType, a.channel_id channelId ,a.other
|
|
|
- from t_order_new a left join `user` b on a.buyer_id=b.id left join t_order_mid c on a.order_no=c.order_no
|
|
|
- left join department dep on a.order_dep=dep.id
|
|
|
- where a.delete_sign in(0,2) and a.process_status >0 and a.approval in (0,1,2)
|
|
|
- <if test="province !=null ">
|
|
|
- and dep.province = #{province}
|
|
|
- </if>
|
|
|
- <if test="salesType !=null ">
|
|
|
- and a.sales_type = #{salesType}
|
|
|
- </if>
|
|
|
- <if test="orderNo != null">
|
|
|
- and a.order_no like CONCAT('%',#{orderNo,jdbcType=VARCHAR},'%')
|
|
|
- </if>
|
|
|
- <if test="name != null">
|
|
|
- and b.nickname like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
|
|
|
- </if>
|
|
|
- <if test="contractNo != null">
|
|
|
- and a.contract_no like CONCAT('%',#{contractNo,jdbcType=VARCHAR},'%')
|
|
|
- </if>
|
|
|
- <if test="liquidationStatus != null">
|
|
|
- and a.liquidation_status = #{liquidationStatus,jdbcType=INTEGER}
|
|
|
- </if>
|
|
|
- <if test="approval ==0">
|
|
|
- and a.approval = 0
|
|
|
- </if>
|
|
|
- <if test="approval ==1">
|
|
|
- and a.approval in (1,2)
|
|
|
- </if>
|
|
|
- <if test="amountStatus == 0">
|
|
|
- and a.total_amount < 10
|
|
|
- </if>
|
|
|
- <if test="amountStatus == 1">
|
|
|
- and a.total_amount between 10 and 20
|
|
|
- </if>
|
|
|
- <if test="amountStatus == 2">
|
|
|
- and a.total_amount between 20 and 30
|
|
|
- </if>
|
|
|
- <if test="amountStatus == 3">
|
|
|
- and a.total_amount between 30 and 40
|
|
|
- </if>
|
|
|
- <if test="amountStatus == 4">
|
|
|
- and a.total_amount > 40
|
|
|
- </if>
|
|
|
- order by a.create_time desc
|
|
|
- <if test="page_sql!=null">
|
|
|
- ${page_sql}
|
|
|
- </if>
|
|
|
- </select>
|
|
|
- <select id="selectstatisticsOrderListCount" resultType="integer">
|
|
|
- select count(*)
|
|
|
- from t_order_new a left join `user` b on a.buyer_id=b.id left join t_order_mid c on a.order_no=c.order_no
|
|
|
- left join department dep on a.order_dep=dep.id
|
|
|
- where a.delete_sign in(0,2) and a.process_status >0 and a.approval in (0,1,2)
|
|
|
- <if test="province !=null ">
|
|
|
- and dep.province = #{province}
|
|
|
- </if>
|
|
|
- <if test="salesType !=null ">
|
|
|
- and a.sales_type = #{salesType}
|
|
|
- </if>
|
|
|
- <if test="orderNo != null">
|
|
|
- and a.order_no like CONCAT('%',#{orderNo,jdbcType=VARCHAR},'%')
|
|
|
- </if>
|
|
|
- <if test="name != null">
|
|
|
- and b.nickname like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
|
|
|
- </if>
|
|
|
- <if test="contractNo != null">
|
|
|
- and a.contract_no like CONCAT('%',#{contractNo,jdbcType=VARCHAR},'%')
|
|
|
- </if>
|
|
|
- <if test="liquidationStatus != null">
|
|
|
- and a.liquidation_status = #{liquidationStatus,jdbcType=INTEGER}
|
|
|
- </if>
|
|
|
- <if test="approval ==0">
|
|
|
- and a.approval = 0
|
|
|
- </if>
|
|
|
- <if test="approval ==1">
|
|
|
- and a.approval in (1,2)
|
|
|
- </if>
|
|
|
- <if test="amountStatus == 0">
|
|
|
- and a.total_amount < 10
|
|
|
- </if>
|
|
|
- <if test="amountStatus == 1">
|
|
|
- and a.total_amount between 10 and 20
|
|
|
- </if>
|
|
|
- <if test="amountStatus == 2">
|
|
|
- and a.total_amount between 20 and 30
|
|
|
- </if>
|
|
|
- <if test="amountStatus == 3">
|
|
|
- and a.total_amount between 30 and 40
|
|
|
- </if>
|
|
|
- <if test="amountStatus == 4">
|
|
|
- and a.total_amount > 40
|
|
|
- </if>
|
|
|
- </select>
|
|
|
</mapper>
|