| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536 |
- <?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.goafanti.common.dao.TOrderMidMapper">
- <resultMap id="BaseResultMap" type="com.goafanti.common.model.TOrderMid">
- <id column="id" jdbcType="INTEGER" property="id" />
- <result column="order_no" jdbcType="VARCHAR" property="orderNo" />
- <result column="salesman_id" jdbcType="VARCHAR" property="salesmanId" />
- <result column="finance_id" jdbcType="VARCHAR" property="financeId" />
- <result column="salesman_name" jdbcType="VARCHAR" property="salesmanName" />
- <result column="finance_name" jdbcType="VARCHAR" property="financeName" />
- <result column="final_receivables" jdbcType="DECIMAL" property="finalReceivables" />
- <result column="final_Receivables_time" jdbcType="TIMESTAMP" property="finalReceivablesTime" />
- <result column="invoice_amount" jdbcType="DECIMAL" property="invoiceAmount" />
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
- <result column="buyer_name" jdbcType="VARCHAR" property="buyerName" />
- <result column="order_receivables" jdbcType="DECIMAL" property="orderReceivables" />
- <result column="order_arrears" jdbcType="DECIMAL" property="orderArrears" />
- <result column="payment_amount" jdbcType="DECIMAL" property="paymentAmount" />
- <result column="cost_amount" jdbcType="DECIMAL" property="costAmount" />
- <result column="dep_name" jdbcType="VARCHAR" property="depName" />
- <result column="province_name" jdbcType="VARCHAR" property="provinceName" />
- <result column="legal_affairs" jdbcType="INTEGER" property="legalAffairs" />
- <result column="dun_start_time" jdbcType="TIMESTAMP" property="dunStartTime" />
- <result column="legal_affairs_type" jdbcType="INTEGER" property="legalAffairsType" />
- <result column="operation_time" jdbcType="DATE" property="operationTime" />
- <result column="legal_affairs_status" jdbcType="INTEGER" property="legalAffairsStatus" />
- </resultMap>
- <sql id="Base_Column_List">
- id, order_no, salesman_id, finance_id, salesman_name, finance_name, final_receivables,
- final_Receivables_time, invoice_amount, create_time, buyer_name, order_receivables,
- order_arrears, payment_amount, cost_amount, dep_name, province_name, legal_affairs,
- dun_start_time, legal_affairs_type, operation_time, legal_affairs_status
- </sql>
- <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List" />
- from t_order_mid
- where id = #{id,jdbcType=INTEGER}
- </select>
- <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
- delete from t_order_mid
- where id = #{id,jdbcType=INTEGER}
- </delete>
- <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.TOrderMid" useGeneratedKeys="true">
- insert into t_order_mid (order_no, salesman_id, finance_id,
- salesman_name, finance_name, final_receivables,
- final_Receivables_time, invoice_amount,
- create_time, buyer_name, order_receivables,
- order_arrears, payment_amount, cost_amount,
- dep_name, province_name, legal_affairs,
- dun_start_time, legal_affairs_type, operation_time,
- legal_affairs_status)
- values (#{orderNo,jdbcType=VARCHAR}, #{salesmanId,jdbcType=VARCHAR}, #{financeId,jdbcType=VARCHAR},
- #{salesmanName,jdbcType=VARCHAR}, #{financeName,jdbcType=VARCHAR}, #{finalReceivables,jdbcType=DECIMAL},
- #{finalReceivablesTime,jdbcType=TIMESTAMP}, #{invoiceAmount,jdbcType=DECIMAL},
- #{createTime,jdbcType=TIMESTAMP}, #{buyerName,jdbcType=VARCHAR}, #{orderReceivables,jdbcType=DECIMAL},
- #{orderArrears,jdbcType=DECIMAL}, #{paymentAmount,jdbcType=DECIMAL}, #{costAmount,jdbcType=DECIMAL},
- #{depName,jdbcType=VARCHAR}, #{provinceName,jdbcType=VARCHAR}, #{legalAffairs,jdbcType=INTEGER},
- #{dunStartTime,jdbcType=TIMESTAMP}, #{legalAffairsType,jdbcType=INTEGER}, #{operationTime,jdbcType=DATE},
- #{legalAffairsStatus,jdbcType=INTEGER})
- </insert>
- <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.TOrderMid" useGeneratedKeys="true">
- insert into t_order_mid
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="orderNo != null">
- order_no,
- </if>
- <if test="salesmanId != null">
- salesman_id,
- </if>
- <if test="financeId != null">
- finance_id,
- </if>
- <if test="salesmanName != null">
- salesman_name,
- </if>
- <if test="financeName != null">
- finance_name,
- </if>
- <if test="finalReceivables != null">
- final_receivables,
- </if>
- <if test="finalReceivablesTime != null">
- final_Receivables_time,
- </if>
- <if test="invoiceAmount != null">
- invoice_amount,
- </if>
- <if test="createTime != null">
- create_time,
- </if>
- <if test="buyerName != null">
- buyer_name,
- </if>
- <if test="orderReceivables != null">
- order_receivables,
- </if>
- <if test="orderArrears != null">
- order_arrears,
- </if>
- <if test="paymentAmount != null">
- payment_amount,
- </if>
- <if test="costAmount != null">
- cost_amount,
- </if>
- <if test="depName != null">
- dep_name,
- </if>
- <if test="provinceName != null">
- province_name,
- </if>
- <if test="legalAffairs != null">
- legal_affairs,
- </if>
- <if test="dunStartTime != null">
- dun_start_time,
- </if>
- <if test="legalAffairsType != null">
- legal_affairs_type,
- </if>
- <if test="operationTime != null">
- operation_time,
- </if>
- <if test="legalAffairsStatus != null">
- legal_affairs_status,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="orderNo != null">
- #{orderNo,jdbcType=VARCHAR},
- </if>
- <if test="salesmanId != null">
- #{salesmanId,jdbcType=VARCHAR},
- </if>
- <if test="financeId != null">
- #{financeId,jdbcType=VARCHAR},
- </if>
- <if test="salesmanName != null">
- #{salesmanName,jdbcType=VARCHAR},
- </if>
- <if test="financeName != null">
- #{financeName,jdbcType=VARCHAR},
- </if>
- <if test="finalReceivables != null">
- #{finalReceivables,jdbcType=DECIMAL},
- </if>
- <if test="finalReceivablesTime != null">
- #{finalReceivablesTime,jdbcType=TIMESTAMP},
- </if>
- <if test="invoiceAmount != null">
- #{invoiceAmount,jdbcType=DECIMAL},
- </if>
- <if test="createTime != null">
- #{createTime,jdbcType=TIMESTAMP},
- </if>
- <if test="buyerName != null">
- #{buyerName,jdbcType=VARCHAR},
- </if>
- <if test="orderReceivables != null">
- #{orderReceivables,jdbcType=DECIMAL},
- </if>
- <if test="orderArrears != null">
- #{orderArrears,jdbcType=DECIMAL},
- </if>
- <if test="paymentAmount != null">
- #{paymentAmount,jdbcType=DECIMAL},
- </if>
- <if test="costAmount != null">
- #{costAmount,jdbcType=DECIMAL},
- </if>
- <if test="depName != null">
- #{depName,jdbcType=VARCHAR},
- </if>
- <if test="provinceName != null">
- #{provinceName,jdbcType=VARCHAR},
- </if>
- <if test="legalAffairs != null">
- #{legalAffairs,jdbcType=INTEGER},
- </if>
- <if test="dunStartTime != null">
- #{dunStartTime,jdbcType=TIMESTAMP},
- </if>
- <if test="legalAffairsType != null">
- #{legalAffairsType,jdbcType=INTEGER},
- </if>
- <if test="operationTime != null">
- #{operationTime,jdbcType=DATE},
- </if>
- <if test="legalAffairsStatus != null">
- #{legalAffairsStatus,jdbcType=INTEGER},
- </if>
- </trim>
- </insert>
- <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.TOrderMid">
- update t_order_mid
- <set>
- <if test="orderNo != null">
- order_no = #{orderNo,jdbcType=VARCHAR},
- </if>
- <if test="salesmanId != null">
- salesman_id = #{salesmanId,jdbcType=VARCHAR},
- </if>
- <if test="financeId != null">
- finance_id = #{financeId,jdbcType=VARCHAR},
- </if>
- <if test="salesmanName != null">
- salesman_name = #{salesmanName,jdbcType=VARCHAR},
- </if>
- <if test="financeName != null">
- finance_name = #{financeName,jdbcType=VARCHAR},
- </if>
- <if test="finalReceivables != null">
- final_receivables = #{finalReceivables,jdbcType=DECIMAL},
- </if>
- <if test="finalReceivablesTime != null">
- final_Receivables_time = #{finalReceivablesTime,jdbcType=TIMESTAMP},
- </if>
- <if test="invoiceAmount != null">
- invoice_amount = #{invoiceAmount,jdbcType=DECIMAL},
- </if>
- <if test="createTime != null">
- create_time = #{createTime,jdbcType=TIMESTAMP},
- </if>
- <if test="buyerName != null">
- buyer_name = #{buyerName,jdbcType=VARCHAR},
- </if>
- <if test="orderReceivables != null">
- order_receivables = #{orderReceivables,jdbcType=DECIMAL},
- </if>
- <if test="orderArrears != null">
- order_arrears = #{orderArrears,jdbcType=DECIMAL},
- </if>
- <if test="paymentAmount != null">
- payment_amount = #{paymentAmount,jdbcType=DECIMAL},
- </if>
- <if test="costAmount != null">
- cost_amount = #{costAmount,jdbcType=DECIMAL},
- </if>
- <if test="depName != null">
- dep_name = #{depName,jdbcType=VARCHAR},
- </if>
- <if test="provinceName != null">
- province_name = #{provinceName,jdbcType=VARCHAR},
- </if>
- <if test="legalAffairs != null">
- legal_affairs = #{legalAffairs,jdbcType=INTEGER},
- </if>
- <if test="dunStartTime != null">
- dun_start_time = #{dunStartTime,jdbcType=TIMESTAMP},
- </if>
- <if test="legalAffairsType != null">
- legal_affairs_type = #{legalAffairsType,jdbcType=INTEGER},
- </if>
- <if test="operationTime != null">
- operation_time = #{operationTime,jdbcType=DATE},
- </if>
- <if test="legalAffairsStatus != null">
- legal_affairs_status = #{legalAffairsStatus,jdbcType=INTEGER},
- </if>
- </set>
- where id = #{id,jdbcType=INTEGER}
- </update>
- <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.TOrderMid">
- update t_order_mid
- set order_no = #{orderNo,jdbcType=VARCHAR},
- salesman_id = #{salesmanId,jdbcType=VARCHAR},
- finance_id = #{financeId,jdbcType=VARCHAR},
- salesman_name = #{salesmanName,jdbcType=VARCHAR},
- finance_name = #{financeName,jdbcType=VARCHAR},
- final_receivables = #{finalReceivables,jdbcType=DECIMAL},
- final_Receivables_time = #{finalReceivablesTime,jdbcType=TIMESTAMP},
- invoice_amount = #{invoiceAmount,jdbcType=DECIMAL},
- create_time = #{createTime,jdbcType=TIMESTAMP},
- buyer_name = #{buyerName,jdbcType=VARCHAR},
- order_receivables = #{orderReceivables,jdbcType=DECIMAL},
- order_arrears = #{orderArrears,jdbcType=DECIMAL},
- payment_amount = #{paymentAmount,jdbcType=DECIMAL},
- cost_amount = #{costAmount,jdbcType=DECIMAL},
- dep_name = #{depName,jdbcType=VARCHAR},
- province_name = #{provinceName,jdbcType=VARCHAR},
- legal_affairs = #{legalAffairs,jdbcType=INTEGER},
- dun_start_time = #{dunStartTime,jdbcType=TIMESTAMP},
- legal_affairs_type = #{legalAffairsType,jdbcType=INTEGER},
- operation_time = #{operationTime,jdbcType=DATE},
- legal_affairs_status = #{legalAffairsStatus,jdbcType=INTEGER}
- where id = #{id,jdbcType=INTEGER}
- </update>
- <select id="selectByOrderNo" resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List" />
- from t_order_mid
- where order_no = #{id,jdbcType=INTEGER}
- </select>
- <update id="updateSalesmanId">
- update t_order_mid a ,admin b set a.salesman_id=#{transferId},a.salesman_name=b.name
- where b.id=#{transferId} and a.salesman_id=#{aid}
- </update>
- <update id="updateFinanceId">
- update t_order_new a ,t_order_mid b,admin c set b.finance_id=#{financeId},b.finance_name=c.name
- where a.order_dep=#{id} and a.order_no=b.order_no and c.id= #{financeId}
- </update>
- <update id="updatefinalReceivables">
- update t_order_mid set final_receivables= #{amount},`final_Receivables_time`= #{receivablesTime},
- order_arrears=if(order_arrears- #{amount} < 0,0,order_arrears- #{amount})
- where order_no= #{orderNo}
- </update>
- <update id="updateInvoice">
- update t_order_mid m,(select order_no,sum(amount)amount from t_order_invoice where status=2 group by order_no)b
- set m.invoice_amount=b.amount where m.order_no= #{orderNo} and m.order_no=b.order_no
- </update>
- <update id="addOrderReceivables">
- update t_order_mid set order_receivables=order_receivables+#{money},
- order_arrears=order_arrears+#{money}
- where order_no=#{orderNo}
- </update>
- <select id="selectDepNameByDepid" resultType="java.lang.String">
- select name from department where id= #{orderDep}
- </select>
- <update id="updateCostAmount">
- update t_order_task a ,t_order_mid b
- <set>
- <if test="cost !=null">
- b.cost_amount= #{cost},
- </if>
- <if test="payment !=null">
- b.payment_amount= #{payment},
- </if>
- </set>
- where a.order_no=b.order_no and a.id= #{tid}
- </update>
- <update id="updateAddCostAmount">
- update t_order_task a ,t_order_mid b
- <set>
- <if test="cost !=null">
- b.cost_amount= b.cost_amount+#{cost},
- </if>
- </set>
- where a.order_no=b.order_no and a.id= #{tid}
- </update>
- <update id="updateByOrderNo">
- update t_order_mid
- <set>
- <if test="salesmanId != null">
- salesman_id = #{salesmanId,jdbcType=VARCHAR},
- </if>
- <if test="financeId != null">
- finance_id = #{financeId,jdbcType=VARCHAR},
- </if>
- <if test="salesmanName != null">
- salesman_name = #{salesmanName,jdbcType=VARCHAR},
- </if>
- <if test="financeName != null">
- finance_name = #{financeName,jdbcType=VARCHAR},
- </if>
- <if test="finalReceivables != null">
- final_receivables = #{finalReceivables,jdbcType=DECIMAL},
- </if>
- <if test="finalReceivablesTime != null">
- final_Receivables_time = #{finalReceivablesTime,jdbcType=TIMESTAMP},
- </if>
- <if test="invoiceAmount != null">
- invoice_amount = #{invoiceAmount,jdbcType=DECIMAL},
- </if>
- <if test="createTime != null">
- create_time = #{createTime,jdbcType=TIMESTAMP},
- </if>
- <if test="buyerName != null">
- buyer_name = #{buyerName,jdbcType=VARCHAR},
- </if>
- <if test="orderReceivables != null">
- order_receivables = #{orderReceivables,jdbcType=DECIMAL},
- </if>
- <if test="orderArrears != null">
- order_arrears = #{orderArrears,jdbcType=DECIMAL},
- </if>
- <if test="paymentAmount != null">
- payment_amount = #{paymentAmount,jdbcType=DECIMAL},
- </if>
- <if test="costAmount != null">
- cost_amount = #{costAmount,jdbcType=DECIMAL},
- </if>
- <if test="depName != null">
- dep_name = #{depName,jdbcType=VARCHAR},
- </if>
- <if test="provinceName != null">
- province_name = #{provinceName,jdbcType=VARCHAR},
- </if>
- <if test="legalAffairs != null">
- legal_affairs = #{legalAffairs,jdbcType=INTEGER},
- </if>
- <if test="dunStartTime != null">
- dun_start_time = #{dunStartTime,jdbcType=TIMESTAMP},
- </if>
- <if test="legalAffairsType != null">
- legal_affairs_type = #{legalAffairsType,jdbcType=INTEGER},
- </if>
- <if test="operationTime != null">
- operation_time = #{operationTime,jdbcType=DATE},
- </if>
- <if test="legalAffairsStatus != null">
- legal_affairs_status = #{legalAffairsStatus,jdbcType=INTEGER},
- </if>
- </set>
- where order_no = #{orderNo,jdbcType=VARCHAR}
- </update>
- <select id="legalAffairsOrderList" resultType="com.goafanti.order.bo.OutOrderLegalAffairsListBo">
- select a.order_no orderNo,a.contract_no contractNo,b.buyer_name buyerName,b.salesman_name salesmanName,b.dep_name depName,
- a.total_amount totalAmount ,a.settlement_amount settlementAmount ,b.order_receivables orderReceivables,b.legal_affairs legalAffairs,
- b.order_arrears orderArrears,b.dun_start_time dunStartTime,date_format(b.dun_start_time,'%Y-%m-%d %H:%i:%S')dunStartTimes
- <if test="type==1 or type==2 or type==3">
- ,b.operation_time operationTime,date_format(b.operation_time,'%Y-%m-%d')operationDate,b.legal_affairs_type `type`
- </if>
- from t_order_new a left join t_order_mid b on a.order_no =b.order_no
- <if test="shiro == 2">
- left join admin c on a.salesman_id =c.id
- </if>
- where 1=1 and a.delete_sign in (0,2)
- <if test="type==1 or type==2 or type==3">
- and b.legal_affairs =1
- and b.legal_affairs_type = (#{type}-1)
- </if>
- <if test="type==0">
- and b.order_receivables >0
- </if>
- <if test="status != null">
- and b.legal_affairs_status = #{status}
- </if>
- <if test="shiro==1">
- and a.order_type in
- <foreach close=")" collection="deps" item="dep" open="(" separator=",">
- #{dep}
- </foreach>
- </if>
- <if test="shiro ==2">
- and c.superior_id = #{sid}
- </if>
- <if test="userName != null">
- and b.buyer_name like concat('%',#{userName},'%')
- </if>
- <if test="legalAffairs != null">
- and b.legal_affairs = #{legalAffairs}
- </if>
- <if test="contractNo != null">
- and a.contract_no like concat('%',#{contractNo},'%')
- </if>
- <if test="aid != null">
- and b.salesman_id = #{aid}
- </if>
- <if test="depId != null">
- and a.order_dep = #{depId}
- </if>
- <if test="type==0">
- <if test="startTime != null and endTime != null">
- and b.dun_start_time between #{startTime} and #{endTime}
- </if>
- </if>
- <if test="type==1 or type==2 or type==3">
- <if test="startTime != null and endTime != null">
- and b.operation_time between #{startTime} and #{endTime}
- </if>
- </if>
- order by b.dun_start_time
- <if test="page_sql != null">
- ${page_sql}
- </if>
- </select>
- <select id="legalAffairsOrderCount" resultType="integer">
- select count(*)
- from t_order_new a left join t_order_mid b on a.order_no =b.order_no
- <if test="type==3">
- left join t_order_legal_affairs d on a.order_no=d.order_no
- </if>
- <if test="shiro == 2">
- left join admin c on a.salesman_id =c.id
- </if>
- where 1=1 and a.delete_sign in (0,2)
- <if test="type==1 or type==2 or type==3">
- and b.legal_affairs =1
- and b.legal_affairs_type = (#{type}-1)
- </if>
- <if test="type==0">
- and b.order_receivables >0
- </if>
- <if test="status != null">
- and b.legal_affairs_status = #{status}
- </if>
- <if test="shiro==1">
- and a.order_type in
- <foreach close=")" collection="deps" item="dep" open="(" separator=",">
- #{dep}
- </foreach>
- </if>
- <if test="shiro ==2">
- and c.superior_id = #{sid}
- </if>
- <if test="userName != null">
- and b.buyer_name like concat('%',#{userName},'%')
- </if>
- <if test="legalAffairs != null">
- and b.legal_affairs = #{legalAffairs}
- </if>
- <if test="contractNo != null">
- and a.contract_no like concat('%',#{contractNo},'%')
- </if>
- <if test="aid != null">
- and b.salesman_id = #{aid}
- </if>
- <if test="depId != null">
- and a.order_dep = #{depId}
- </if>
- <if test="type==0">
- <if test="startTime != null and endTime != null">
- and b.dun_start_time between #{startTime} and #{endTime}
- </if>
- </if>
- <if test="type==1 or type==2 or type==3">
- <if test="startTime != null and endTime != null">
- and b.operation_time between #{startTime} and #{endTime}
- </if>
- </if>
- </select>
- <update id="updateByList">
- update t_order_mid
- set legal_affairs=1,legal_affairs_type =0
- where order_no in(
- <foreach collection="list" index="index" item="item" separator=",">
- #{item}
- </foreach>
- )
- </update>
- </mapper>
|