|
|
@@ -717,4 +717,183 @@
|
|
|
</if>
|
|
|
</if>
|
|
|
</select>
|
|
|
+ <select id="selectStatisticsOrderProjectList" resultType="com.goafanti.order.bo.OutOrderProject">
|
|
|
+ SELECT a.order_no as orderNo, a.order_type orderType,a.sales_type as salesType,b.service_type AS serviceType,
|
|
|
+ a.liquidation_status as liquidationStatus,b2.big_customer as bigCustomer, b.dun_node_content as dunNodeContent,
|
|
|
+ b.project_type as projectType, a.total_amount as totalAmount,a.approval ,a.sign_time as signTime,
|
|
|
+ a.create_time as createTime,b.buyer_name as buyerName,a.contract_no as contractNo, d2.cname htlx,
|
|
|
+ b.order_receivables orderReceivables,a.refund_amount refundAmount,a.settlement_amount as settlementAmount,
|
|
|
+ b.invoice_amount as invicueAmount, b.cost_amount as costAmount,b.payment_amount as paymentAmount,
|
|
|
+ b.finance_name as financeName,b.salesman_name as salesmanName, e.commodity_name as commodityName,ttm.service_year as serviceYear,
|
|
|
+ ttm.service_life as serviceLife,ttm.year_sum as yearSum,e.task_distribution_time as taskDistributionTime ,e.commodity_quantity as commodityQuantity,
|
|
|
+ e3.cost_amount as costAmount,e.project_status as projectStatus,e.task_start_time as taskStartTime,e.task_end_time as taskEndTime,
|
|
|
+ e.receiver_name as receiverName ,'技术组' jsz,t1.cb restatement,a.order_status orderStatus,e.satisfaction_degree satisfactionDegree,
|
|
|
+ e.task_comment taskComment,'核算比例' hsbl,a.order_status orderStatus,t1.counts changeType,t1.tdtk refundType,a3.name depName,a4.name as province
|
|
|
+ from t_order_new a left join t_order_mid b on a.order_no =b.order_no
|
|
|
+ left join admin a2 on a.salesman_id=a2.id left join department a3 on a2.department_id=a3.id
|
|
|
+ left join district_glossory a4 on a3.province=a4.id left join user_mid b2 on a.buyer_id=b2.uid
|
|
|
+ left join t_order_task c on a.order_no =c.order_no and c.main =1
|
|
|
+ left join business_project d on c.commodity_id =d.id left join business_category d2 on d.cid =d2.id
|
|
|
+ left join t_order_task e on a.order_no =e.order_no and e.split_status in (0,2)
|
|
|
+ left join admin e2 on e.task_receiver=e2.id left join t_task_mid e3 on e.id=e3.tid
|
|
|
+ left join t_task_member ttm on e.id =ttm.tid
|
|
|
+ left join (SELECT order_no ,count(*)counts,sum(if(`type`=0,1,0))tdtk,sum(if(`type`=4,1,0))cb
|
|
|
+ from new_order_change group by order_no ) t1 on a.order_no =t1.order_no
|
|
|
+ <include refid="selectStatisticsOrderProjectSql"/>
|
|
|
+ <if test="page_sql!=null">
|
|
|
+ ${page_sql}
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+ <sql id="selectStatisticsOrderProjectSql">
|
|
|
+ <if test="dunType !=null">
|
|
|
+ left join new_order_dun nod on e.id=nod.tid
|
|
|
+ </if>
|
|
|
+ where a.process_status >6 and a.delete_sign in (0,2)
|
|
|
+ <if test="orderNo !=null">
|
|
|
+ and a.order_no like CONCAT('%',#{orderNo},'%')
|
|
|
+ </if>
|
|
|
+ <if test="contractNo !=null">
|
|
|
+ and a.contract_no like CONCAT('%',#{contractNo},'%')
|
|
|
+ </if>
|
|
|
+ <if test="userName !=null">
|
|
|
+ and b.buyer_name like CONCAT('%',#{userName},'%')
|
|
|
+ </if>
|
|
|
+ <if test="businessCategory !=null">
|
|
|
+ and d2.id = #{businessCategory}
|
|
|
+ </if>
|
|
|
+ <if test="projectName !=null">
|
|
|
+ and e.commodity_name like CONCAT('%',#{projectName},'%')
|
|
|
+ </if>
|
|
|
+ <if test="orderAmountType==1">
|
|
|
+ and a.total_amount < 10
|
|
|
+ </if>
|
|
|
+ <if test="orderAmountType==2">
|
|
|
+ and a.total_amount >= 10 and a.total_amount < 20
|
|
|
+ </if>
|
|
|
+ <if test="orderAmountType==3">
|
|
|
+ and a.total_amount >= 20 and a.total_amount < 30
|
|
|
+ </if>
|
|
|
+ <if test="orderAmountType==4">
|
|
|
+ and a.total_amount >= 30 and a.total_amount < 40
|
|
|
+ </if>
|
|
|
+ <if test="orderAmountType==5">
|
|
|
+ and a.total_amount >= 40
|
|
|
+ </if>
|
|
|
+ <if test="depId !=null">
|
|
|
+ and a3.id = #{depId}
|
|
|
+ </if>
|
|
|
+ <if test="liabilitiesDepId !=null">
|
|
|
+ and e2.department_id = #{liabilitiesDepId}
|
|
|
+ </if>
|
|
|
+ <if test="declarationBatch !=null">
|
|
|
+ and e.declaration_batch = #{declarationBatch}
|
|
|
+ </if>
|
|
|
+ <if test="projectAmountType==1">
|
|
|
+ and e.commodity_price < 1
|
|
|
+ </if>
|
|
|
+ <if test="projectAmountType==2">
|
|
|
+ and e.commodity_price >= 1 and e.commodity_price < 5
|
|
|
+ </if>
|
|
|
+ <if test="projectAmountType==3">
|
|
|
+ and e.commodity_price >= 5 and e.commodity_price < 10
|
|
|
+ </if>
|
|
|
+ <if test="projectAmountType==4">
|
|
|
+ and e.commodity_price >= 10 and e.commodity_price < 20
|
|
|
+ </if>
|
|
|
+ <if test="projectAmountType==5">
|
|
|
+ and e.commodity_price >= 20
|
|
|
+ </if>
|
|
|
+ <if test="projectStatus !=null">
|
|
|
+ and e.project_status = #{projectStatus}
|
|
|
+ </if>
|
|
|
+ <if test="satisfactionDegree !=null">
|
|
|
+ and e.satisfaction_degree = #{satisfactionDegree}
|
|
|
+ </if>
|
|
|
+ <if test="startDate !=null and endDate !=null">
|
|
|
+ and a.create_time BETWEEN #{startDate} and #{endDate}
|
|
|
+ </if>
|
|
|
+ <if test="signStartDate !=null and signEndDate !=null">
|
|
|
+ and a.sign_time BETWEEN #{signStartDate} and #{signEndDate}
|
|
|
+ </if>
|
|
|
+ <if test="projectStartDate !=null and projectEndDate !=null">
|
|
|
+ and e.task_distribution_time BETWEEN #{projectStartDate} and #{projectEndDate}
|
|
|
+ </if>
|
|
|
+ <if test="salesType !=null">
|
|
|
+ and a.sales_type = #{salesType}
|
|
|
+ </if>
|
|
|
+ <if test="serviceType !=null">
|
|
|
+ and find_in_set(b.service_type,#{serviceType})
|
|
|
+ </if>
|
|
|
+ <if test="liquidationStatus !=null">
|
|
|
+ and a.liquidation_status = #{liquidationStatus}
|
|
|
+ </if>
|
|
|
+ <if test="dunType !=null">
|
|
|
+ and nod.dun_type = #{dunType}
|
|
|
+ </if>
|
|
|
+ <if test="province !=null">
|
|
|
+ and a4.id = #{province}
|
|
|
+ </if>
|
|
|
+ <if test="salesmanId !=null">
|
|
|
+ and a.salesman_id = #{salesmanId}
|
|
|
+ </if>
|
|
|
+ <if test="financeId !=null">
|
|
|
+ and a.finance_id = #{financeId}
|
|
|
+ </if>
|
|
|
+ <if test="techId !=null">
|
|
|
+ and e.task_receiver =#{techId}
|
|
|
+ </if>
|
|
|
+ <if test="approval ==0">
|
|
|
+ and a.approval = 0
|
|
|
+ </if>
|
|
|
+ <if test="approval ==1">
|
|
|
+ and a.approval > 0
|
|
|
+ </if>
|
|
|
+ <if test="projectType !=null">
|
|
|
+ and b.project_type = #{projectType}
|
|
|
+ </if>
|
|
|
+ <if test="bigCustomer !=null">
|
|
|
+ and b2.big_customer = #{bigCustomer}
|
|
|
+ </if>
|
|
|
+ <if test="restatement ==0">
|
|
|
+ and t1.cb = 0
|
|
|
+ </if>
|
|
|
+ <if test="restatement ==1">
|
|
|
+ and t1.cb > 0
|
|
|
+ </if>
|
|
|
+ <if test="changeType ==0">
|
|
|
+ and t1.counts is null
|
|
|
+ </if>
|
|
|
+ <if test="changeType ==1">
|
|
|
+ and t1.counts >0
|
|
|
+ </if>
|
|
|
+ <if test="refundType ==0">
|
|
|
+ and (t1.tdtk = 0 or t1.tdtk is null)
|
|
|
+ </if>
|
|
|
+ <if test="refundType ==1">
|
|
|
+ and t1.tdtk >0
|
|
|
+ </if>
|
|
|
+ <if test="orderType ==0">
|
|
|
+ and a.order_type in(0,2)
|
|
|
+ </if>
|
|
|
+ <if test="orderType ==1">
|
|
|
+ and a.order_type in(1)
|
|
|
+ </if>
|
|
|
+ <if test="projectCompleteStartTime !=null and projectCompleteEndTime !=null">
|
|
|
+ and e.task_end_time BETWEEN #{projectCompleteStartTime} and #{projectCompleteEndTime}
|
|
|
+ </if>
|
|
|
+ </sql>
|
|
|
+ <select id="selectStatisticsOrderProjectCount" resultType="java.lang.Integer">
|
|
|
+ SELECT count(*)
|
|
|
+ from t_order_new a left join t_order_mid b on a.order_no =b.order_no
|
|
|
+ left join admin a2 on a.salesman_id=a2.id left join department a3 on a2.department_id=a3.id
|
|
|
+ left join district_glossory a4 on a3.province=a4.id left join user_mid b2 on a.buyer_id=b2.uid
|
|
|
+ left join t_order_task c on a.order_no =c.order_no and c.main =1
|
|
|
+ left join business_project d on c.commodity_id =d.id left join business_category d2 on d.cid =d2.id
|
|
|
+ left join t_order_task e on a.order_no =e.order_no and e.split_status in (0,2)
|
|
|
+ left join admin e2 on e.task_receiver=e2.id left join t_task_mid e3 on e.id=e3.tid
|
|
|
+ left join t_task_member ttm on e.id =ttm.tid
|
|
|
+ left join (SELECT order_no ,count(*)counts,sum(if(`type`=0,1,0))tdtk,sum(if(`type`=4,1,0))cb
|
|
|
+ from new_order_change group by order_no ) t1 on a.order_no =t1.order_no
|
|
|
+ <include refid="selectStatisticsOrderProjectSql"/>
|
|
|
+ </select>
|
|
|
</mapper>
|