|
|
@@ -1093,15 +1093,16 @@ left join (select x1.order_no,max(create_time) create_time,max(transaction_amoun
|
|
|
(select x.order_no,x.create_time,x.transaction_amount from t_order_bill_new x right join (select order_no, max(create_time) maxTime from t_order_bill_new group by order_no)y
|
|
|
on x.order_no=y.order_no and x.create_time=y.maxTime)x1 group by x1.order_no ) f on o.order_no = f.order_no
|
|
|
left join ( select order_no , sum(amount) invoiceAmount from t_order_invoice where status = 2 group by order_no ) g on o.order_no = g.order_no
|
|
|
-where delete_sign != 1 and outsource= #{o.outsource,jdbcType=INTEGER}
|
|
|
+where delete_sign != 1 and (approval = 0 or 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>
|
|
|
- and (approval = 0 or approval = 2)
|
|
|
- and o.finance_id = #{o.financeId,jdbcType=VARCHAR}
|
|
|
+ <if test="o.financeId != null and o.financeId != """>
|
|
|
+ and d.finance_id = #{o.financeId,jdbcType=VARCHAR}
|
|
|
+ </if>
|
|
|
<if test="o.orderStatus != null and o.orderStatus != """>
|
|
|
and o.order_status = #{o.orderStatus,jdbcType=INTEGER}
|
|
|
</if>
|
|
|
@@ -1111,10 +1112,9 @@ where delete_sign != 1 and outsource= #{o.outsource,jdbcType=INTEGER}
|
|
|
<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.liquidationStatus != """>
|
|
|
+ <if test="o.liquidationStatus != null">
|
|
|
and o.liquidation_status = #{o.liquidationStatus,jdbcType=INTEGER}
|
|
|
</if>
|
|
|
-
|
|
|
<if test="o.orderNo != null and o.orderNo != """>
|
|
|
and o.order_no = #{o.orderNo,jdbcType=VARCHAR}
|
|
|
</if>
|
|
|
@@ -1127,27 +1127,32 @@ where delete_sign != 1 and outsource= #{o.outsource,jdbcType=INTEGER}
|
|
|
<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 f.create_time between #{c,jdbcType=VARCHAR} and #{d,jdbcType=VARCHAR}
|
|
|
+ </if>
|
|
|
order by o.liquidation_status, o.sign_time desc
|
|
|
<if test="page_sql != null">
|
|
|
${page_sql}
|
|
|
</if>
|
|
|
</select>
|
|
|
<select id="financeCount" parameterType="Map" resultType="java.lang.Integer">
|
|
|
- select count(*)
|
|
|
- from t_order_new o
|
|
|
- left join `user` u on o.buyer_id = u.id
|
|
|
- left join admin a on o.salesman_id = a.id
|
|
|
- left join (select sum(transaction_amount) as amount ,order_no from t_order_bill_new
|
|
|
- group by order_no ) b on b.order_no = o.order_no
|
|
|
- where delete_sign != 1 and outsource= #{o.outsource,jdbcType=INTEGER}
|
|
|
+ select count(*) from t_order_new o left join `user` u on o.buyer_id = u.id left join admin a on o.salesman_id = a.id
|
|
|
+ left join (select sum(transaction_amount) as amount ,order_no from t_order_bill_new group by order_no ) b on b.order_no = o.order_no
|
|
|
+ left join department d on o.order_dep = d.id left join (select x1.order_no,max(create_time) create_time,max(transaction_amount)transaction_amount from
|
|
|
+(select x.order_no,x.create_time,x.transaction_amount from t_order_bill_new x right join (select order_no, max(create_time) maxTime from t_order_bill_new group by order_no)y
|
|
|
+ on x.order_no=y.order_no and x.create_time=y.maxTime)x1 group by x1.order_no ) f on o.order_no = f.order_no
|
|
|
+ where delete_sign != 1 and (approval = 0 or 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>
|
|
|
- and (approval = 0 or approval = 2)
|
|
|
- and o.finance_id = #{o.financeId,jdbcType=VARCHAR}
|
|
|
+ <if test="o.financeId != null and o.financeId != """>
|
|
|
+ and d.finance_id = #{o.financeId,jdbcType=VARCHAR}
|
|
|
+ </if>
|
|
|
<if test="o.orderStatus != null and o.orderStatus != """>
|
|
|
and o.order_status = #{o.orderStatus,jdbcType=INTEGER}
|
|
|
</if>
|
|
|
@@ -1157,7 +1162,7 @@ where delete_sign != 1 and outsource= #{o.outsource,jdbcType=INTEGER}
|
|
|
<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.liquidationStatus != """>
|
|
|
+ <if test="o.liquidationStatus != null">
|
|
|
and o.liquidation_status = #{o.liquidationStatus,jdbcType=INTEGER}
|
|
|
</if>
|
|
|
|
|
|
@@ -1173,6 +1178,11 @@ where delete_sign != 1 and outsource= #{o.outsource,jdbcType=INTEGER}
|
|
|
<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 f.create_time between #{c,jdbcType=VARCHAR} and #{d,jdbcType=VARCHAR}
|
|
|
+ </if>
|
|
|
</select>
|
|
|
<!-- 通过订单编号获得订单的负责人(营销员) -->
|
|
|
<select id="getSaleIdByOno" parameterType="java.lang.String" resultType="com.goafanti.order.bo.TOrderNewBo">
|
|
|
@@ -1186,7 +1196,7 @@ where delete_sign != 1 and outsource= #{o.outsource,jdbcType=INTEGER}
|
|
|
select
|
|
|
a.order_no as orderNo,a.create_time as createTime, date_format(a.sign_time,'%Y-%m-%d' ) as signDate,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.name as salesmanName,dep.name as depName,d.name as financeName
|
|
|
+ a.liquidation_status as liquidationStatus,a.approval,c.name as salesmanName,dep.name as depName,g.name as financeName
|
|
|
<if test="specially == 2">
|
|
|
,f.name as initiateName ,e.reason ,date_format(e.create_time,'%Y-%m-%d' ) as backDate,e.id as backId
|
|
|
</if>
|
|
|
@@ -1196,6 +1206,7 @@ where delete_sign != 1 and outsource= #{o.outsource,jdbcType=INTEGER}
|
|
|
from t_order_new a left join `user` b on a.buyer_id=b.id
|
|
|
left join admin c on a.salesman_id=c.id
|
|
|
left join department dep on a.order_dep=dep.id
|
|
|
+ left join admin g on dep.finance_id=g.id
|
|
|
left join admin d on a.finance_id=d.id
|
|
|
<if test="specially == 2">
|
|
|
left join (select * from t_order_back a where back_status=0) e on a.order_no=e.order_no
|
|
|
@@ -1413,7 +1424,7 @@ where super_id is null ) e on e.order_no=a.order_no
|
|
|
</select>
|
|
|
|
|
|
<select id="getOrderNewDetail" parameterType="java.lang.String" resultType="com.goafanti.order.bo.TOrderNewBo">
|
|
|
- select
|
|
|
+ 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,
|
|
|
@@ -1423,10 +1434,11 @@ where super_id is null ) e on e.order_no=a.order_no
|
|
|
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,a.additional_order additionalOrder
|
|
|
- from t_order_new a left join `user` b on a.buyer_id=b.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 (select * from t_order_back a where back_status=0) e on a.order_no=e.order_no
|
|
|
+ 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 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}
|
|
|
</select>
|
|
|
@@ -1497,7 +1509,10 @@ where super_id is null ) e on e.order_no=a.order_no
|
|
|
</select>
|
|
|
<update id="updateFinance" parameterType="string">
|
|
|
update t_order_new set finance_id= #{newFinance,jdbcType=VARCHAR}
|
|
|
- where order_no= #{orderNo,jdbcType=VARCHAR}
|
|
|
+ where order_no in
|
|
|
+ <foreach close=")" collection="orderNos" item="orderNo" open="(" separator=",">
|
|
|
+ #{orderNo}
|
|
|
+ </foreach>
|
|
|
and finance_id= #{aid,jdbcType=VARCHAR}
|
|
|
</update>
|
|
|
<select id="checkContractNo" resultType="java.lang.Integer">
|
|
|
@@ -1509,15 +1524,16 @@ where super_id is null ) e on e.order_no=a.order_no
|
|
|
select sum(b.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 ( select sum(transaction_amount) as amount , order_no from t_order_bill_new group by order_no ) b on b.order_no = o.order_no
|
|
|
- where delete_sign != 1 and outsource= #{outsource,jdbcType=INTEGER}
|
|
|
+ where delete_sign != 1 and (approval = 0 or approval = 2) and outsource= #{outsource,jdbcType=INTEGER}
|
|
|
<if test="processStatus == 3">
|
|
|
and o.process_status = #{processStatus,jdbcType=INTEGER}
|
|
|
</if>
|
|
|
<if test="processStatus == 4">
|
|
|
and o.process_status >= #{processStatus,jdbcType=INTEGER}
|
|
|
</if>
|
|
|
- and (approval = 0 or approval = 2)
|
|
|
- and o.finance_id = #{financeId,jdbcType=VARCHAR}
|
|
|
+ <if test="financeId != null and financeId != """>
|
|
|
+ and d.finance_id = #{financeId,jdbcType=VARCHAR}
|
|
|
+ </if>
|
|
|
<if test="orderStatus != null and orderStatus != """>
|
|
|
and o.order_status = #{orderStatus,jdbcType=INTEGER}
|
|
|
</if>
|
|
|
@@ -1527,7 +1543,7 @@ where super_id is null ) e on e.order_no=a.order_no
|
|
|
<if test="contractNo != null and contractNo != """>
|
|
|
and o.contract_no like CONCAT('%',#{contractNo,jdbcType=VARCHAR},'%')
|
|
|
</if>
|
|
|
- <if test="liquidationStatus != null and liquidationStatus != """>
|
|
|
+ <if test="liquidationStatus != null ">
|
|
|
and o.liquidation_status = #{liquidationStatus,jdbcType=INTEGER}
|
|
|
</if>
|
|
|
|
|
|
@@ -1550,4 +1566,8 @@ where super_id is null ) e on e.order_no=a.order_no
|
|
|
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 !=1 and salesman_id= #{aid}
|
|
|
+ </update>
|
|
|
</mapper>
|