| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394 |
- <?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.TemporaryReceivablesMapper">
- <resultMap id="BaseResultMap" type="com.goafanti.common.model.TemporaryReceivables">
- <id column="id" jdbcType="INTEGER" property="id" />
- <result column="order_no" jdbcType="VARCHAR" property="orderNo" />
- <result column="corporate_name" jdbcType="VARCHAR" property="corporateName" />
- <result column="amount" jdbcType="DECIMAL" property="amount" />
- <result column="receivables_time" jdbcType="TIMESTAMP" property="receivablesTime" />
- <result column="aid" jdbcType="VARCHAR" property="aid" />
- <result column="remarks" jdbcType="VARCHAR" property="remarks" />
- <result column="status" jdbcType="INTEGER" property="status" />
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
- <result column="financial_pay_no" jdbcType="VARCHAR" property="financialPayNo" />
- <result column="merge_Status" jdbcType="INTEGER" property="mergeStatus" />
- </resultMap>
- <sql id="Base_Column_List">
- id, order_no, corporate_name, amount, receivables_time, aid, remarks, `status`, create_time,
- financial_pay_no, merge_Status
- </sql>
- <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List" />
- from temporary_receivables
- where id = #{id,jdbcType=INTEGER}
- </select>
- <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
- delete from temporary_receivables
- where id = #{id,jdbcType=INTEGER}
- </delete>
- <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.TemporaryReceivables" useGeneratedKeys="true">
- insert into temporary_receivables (order_no, corporate_name, amount,
- receivables_time, aid, remarks,
- `status`, create_time, financial_pay_no,
- merge_Status)
- values (#{orderNo,jdbcType=VARCHAR}, #{corporateName,jdbcType=VARCHAR}, #{amount,jdbcType=DECIMAL},
- #{receivablesTime,jdbcType=TIMESTAMP}, #{aid,jdbcType=VARCHAR}, #{remarks,jdbcType=VARCHAR},
- #{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{financialPayNo,jdbcType=VARCHAR},
- #{mergeStatus,jdbcType=INTEGER})
- </insert>
- <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.TemporaryReceivables" useGeneratedKeys="true">
- insert into temporary_receivables
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="orderNo != null">
- order_no,
- </if>
- <if test="corporateName != null">
- corporate_name,
- </if>
- <if test="amount != null">
- amount,
- </if>
- <if test="receivablesTime != null">
- receivables_time,
- </if>
- <if test="aid != null">
- aid,
- </if>
- <if test="remarks != null">
- remarks,
- </if>
- <if test="status != null">
- `status`,
- </if>
- <if test="createTime != null">
- create_time,
- </if>
- <if test="financialPayNo != null">
- financial_pay_no,
- </if>
- <if test="mergeStatus != null">
- merge_Status,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="orderNo != null">
- #{orderNo,jdbcType=VARCHAR},
- </if>
- <if test="corporateName != null">
- #{corporateName,jdbcType=VARCHAR},
- </if>
- <if test="amount != null">
- #{amount,jdbcType=DECIMAL},
- </if>
- <if test="receivablesTime != null">
- #{receivablesTime,jdbcType=TIMESTAMP},
- </if>
- <if test="aid != null">
- #{aid,jdbcType=VARCHAR},
- </if>
- <if test="remarks != null">
- #{remarks,jdbcType=VARCHAR},
- </if>
- <if test="status != null">
- #{status,jdbcType=INTEGER},
- </if>
- <if test="createTime != null">
- #{createTime,jdbcType=TIMESTAMP},
- </if>
- <if test="financialPayNo != null">
- #{financialPayNo,jdbcType=VARCHAR},
- </if>
- <if test="mergeStatus != null">
- #{mergeStatus,jdbcType=INTEGER},
- </if>
- </trim>
- </insert>
- <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.TemporaryReceivables">
- update temporary_receivables
- <set>
- <if test="orderNo != null">
- order_no = #{orderNo,jdbcType=VARCHAR},
- </if>
- <if test="corporateName != null">
- corporate_name = #{corporateName,jdbcType=VARCHAR},
- </if>
- <if test="amount != null">
- amount = #{amount,jdbcType=DECIMAL},
- </if>
- <if test="receivablesTime != null">
- receivables_time = #{receivablesTime,jdbcType=TIMESTAMP},
- </if>
- <if test="aid != null">
- aid = #{aid,jdbcType=VARCHAR},
- </if>
- <if test="remarks != null">
- remarks = #{remarks,jdbcType=VARCHAR},
- </if>
- <if test="status != null">
- `status` = #{status,jdbcType=INTEGER},
- </if>
- <if test="createTime != null">
- create_time = #{createTime,jdbcType=TIMESTAMP},
- </if>
- <if test="financialPayNo != null">
- financial_pay_no = #{financialPayNo,jdbcType=VARCHAR},
- </if>
- <if test="mergeStatus != null">
- merge_Status = #{mergeStatus,jdbcType=INTEGER},
- </if>
- </set>
- where id = #{id,jdbcType=INTEGER}
- </update>
- <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.TemporaryReceivables">
- update temporary_receivables
- set order_no = #{orderNo,jdbcType=VARCHAR},
- corporate_name = #{corporateName,jdbcType=VARCHAR},
- amount = #{amount,jdbcType=DECIMAL},
- receivables_time = #{receivablesTime,jdbcType=TIMESTAMP},
- aid = #{aid,jdbcType=VARCHAR},
- remarks = #{remarks,jdbcType=VARCHAR},
- `status` = #{status,jdbcType=INTEGER},
- create_time = #{createTime,jdbcType=TIMESTAMP},
- financial_pay_no = #{financialPayNo,jdbcType=VARCHAR},
- merge_Status = #{mergeStatus,jdbcType=INTEGER}
- where id = #{id,jdbcType=INTEGER}
- </update>
- <delete id="deleteByids" parameterType="java.util.List">
- delete from temporary_receivables
- where id in
- <foreach close=")" collection="list" index="index" item="item" open="(" separator=",">
- #{item}
- </foreach>
- </delete>
- <delete id="deleteByaid" parameterType="java.lang.String">
- delete from temporary_receivables
- where aid = #{aid}
- </delete>
- <delete id="deleteNormalByaid">
- delete from temporary_receivables
- where aid = #{aid} and status < 2
- </delete>
- <select id="selectByaid" resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List" />
- from temporary_receivables
- where aid = #{aid}
- and merge_status= #{mergeStatus}
- </select>
- <select id="selectReceivablesList" parameterType="java.lang.String" resultType="com.goafanti.order.bo.ReceivablesListBo">
- select a.id,a.order_no orderNo,b.contract_no contractNo,a.corporate_name corporateName,c.nickname,
- b.total_amount totalAmount,d.name depName,a.status ,b.settlement_amount settlementAmount,
- a.financial_pay_no financialPayNo,a.amount,date_format(a.receivables_time, '%Y-%m-%d')receivablesTimes,
- date_format(a.create_time, '%Y-%m-%d %H:%i:%S')createTimes,a.remarks,c.username
- from temporary_receivables 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 department d on b.order_dep=d.id left join admin e on b.salesman_id=e.id
- where 1=1
- <if test="aid != null">
- and a.aid= #{aid}
- </if>
- <if test="mergeStatus != null">
- and merge_status = #{mergeStatus}
- </if>
- <if test="contractNo != null">
- and b.contract_no like concat('%',#{contractNo},'%')
- </if>
- <if test="orderNo != null">
- and a.order_no = #{orderNo}
- </if>
- <if test="adminName != null">
- and e.name like concat('%',#{adminName},'%')
- </if>
- <if test="nickname != null">
- and c.nickname like concat('%',#{nickname},'%')
- </if>
- <if test="corporateName != null">
- and a.corporate_name like concat('%',#{corporateName},'%')
- </if>
- <if test="orderDeps != null">
- and b.order_dep in
- <foreach close=")" collection="orderDeps" item="depId" open="(" separator=",">
- #{depId}
- </foreach>
- </if>
- <if test="adminDeps != null">
- and e.department_id in
- <foreach close=")" collection="adminDeps" item="depId" open="(" separator=",">
- #{depId}
- </foreach>
- </if>
- <if test="status != null">
- and a.status= #{status}
- </if>
- order by a.status desc,b.contract_no,a.create_time desc
- <if test="page_sql!=null">
- ${page_sql}
- </if>
- </select>
- <select id="selectReceivablesCount" resultType="java.lang.Integer">
- select count(*) from temporary_receivables 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 department d on b.order_dep=d.id
- left join admin e on b.salesman_id=e.id
- where 1=1
- <if test="aid != null">
- and a.aid= #{aid}
- </if>
- <if test="mergeStatus != null">
- and merge_status = #{mergeStatus}
- </if>
- <if test="contractNo != null">
- and b.contract_no like concat('%',#{contractNo},'%')
- </if>
- <if test="orderNo != null">
- and a.order_no = #{orderNo}
- </if>
- <if test="adminName != null">
- and e.name like concat('%',#{adminName},'%')
- </if>
- <if test="nickname != null">
- and c.nickname like concat('%',#{nickname},'%')
- </if>
- <if test="corporateName != null">
- and a.corporate_name like concat('%',#{corporateName},'%')
- </if>
- <if test="orderDeps != null">
- and b.order_dep in
- <foreach close=")" collection="orderDeps" item="depId" open="(" separator=",">
- #{depId}
- </foreach>
- </if>
- <if test="adminDeps != null">
- and e.department_id in
- <foreach close=")" collection="adminDeps" item="depId" open="(" separator=",">
- #{depId}
- </foreach>
- </if>
- <if test="status != null">
- and a.status= #{status}
- </if>
- </select>
- <select id="getCountlistReceivablesAmount" parameterType="Map" resultType="java.lang.String">
- select ifnull(sum(a.amount),0) amount from temporary_receivables 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 department d on b.order_dep=d.id left join admin e on b.salesman_id=e.id
- where 1=1
- <if test="aid != null">
- and a.aid= #{aid}
- </if>
- <if test="contractNo != null">
- and b.contract_no like concat('%',#{contractNo},'%')
- </if>
- <if test="orderNo != null">
- and a.order_no = #{orderNo}
- </if>
- <if test="adminName != null">
- and b.salesman_id like concat('%',#{adminName},'%')
- </if>
- <if test="nickname != null">
- and c.nickname like concat('%',#{nickname},'%')
- </if>
- <if test="corporateName != null">
- and a.corporate_name like concat('%',#{corporateName},'%')
- </if>
- <if test="mergeStatus != null">
- and a.merge_status = #{mergeStatus}
- </if>
- <if test="orderDeps != null">
- and b.order_dep in
- <foreach close=")" collection="orderDeps" item="depId" open="(" separator=",">
- #{depId}
- </foreach>
- </if>
- <if test="adminDeps != null">
- and e.department_id in
- <foreach close=")" collection="adminDeps" item="depId" open="(" separator=",">
- #{depId}
- </foreach>
- </if>
- <if test="status != null">
- and a.status= #{status}
- </if>
- </select>
- <select id="getCountlistReceivablesTotalAmount" parameterType="Map" resultType="java.lang.String">
- select ifnull(sum(x.total_amount),0) from (select b.order_no,b.total_amount from temporary_receivables 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 department d on b.order_dep=d.id
- left join admin e on b.salesman_id=e.id
- where 1=1
- <if test="aid != null">
- and a.aid= #{aid}
- </if>
- <if test="contractNo != null">
- and b.contract_no like concat('%',#{contractNo},'%')
- </if>
- <if test="orderNo != null">
- and a.order_no = #{orderNo}
- </if>
- <if test="adminName != null">
- and b.salesman_id like concat('%',#{adminName},'%')
- </if>
- <if test="nickname != null">
- and c.nickname like concat('%',#{nickname},'%')
- </if>
- <if test="corporateName != null">
- and a.corporate_name like concat('%',#{corporateName},'%')
- </if>
- <if test="mergeStatus != null">
- and a.merge_status = #{mergeStatus}
- </if>
- <if test="orderDeps != null">
- and b.order_dep in
- <foreach close=")" collection="orderDeps" item="depId" open="(" separator=",">
- #{depId}
- </foreach>
- </if>
- <if test="adminDeps != null">
- and e.department_id in
- <foreach close=")" collection="adminDeps" item="depId" open="(" separator=",">
- #{depId}
- </foreach>
- </if>
- <if test="status != null">
- and a.status= #{status}
- </if>
- group by b.order_no)x
- </select>
- <insert id="insertBatch" parameterType="com.goafanti.common.model.TemporaryReceivables">
- insert into temporary_receivables (id, order_no, corporate_name, amount, receivables_time,
- aid, remarks, status, create_time, financial_pay_no) values
- <foreach item="item" index="index" collection="list" separator=",">
- (#{item.id,jdbcType=INTEGER}, #{item.orderNo,jdbcType=VARCHAR}, #{item.corporateName,jdbcType=VARCHAR},
- #{item.amount,jdbcType=DECIMAL}, #{item.receivablesTime,jdbcType=TIMESTAMP}, #{item.aid,jdbcType=VARCHAR},
- #{item.remarks,jdbcType=VARCHAR}, #{item.status,jdbcType=INTEGER}, #{item.createTime,jdbcType=TIMESTAMP},
- #{item.financialPayNo,jdbcType=VARCHAR})
- </foreach>
- </insert>
- <update id="updateRepeatOrderNo" >
- update temporary_receivables x ,(select a.order_no,a.amount,a.receivables_time,a.nickname
- from (select a.order_no,a.corporate_name,a.amount,a.receivables_time,b.nickname,count(1) counts
- from temporary_receivables a left join (select x1.order_no,y1.nickname from t_order_new x1
- left join user y1 on x1.buyer_id=y1.id )b on a.order_no=b.order_no where a.corporate_name=b.nickname
- group by a.order_no,a.corporate_name,a.amount,a.receivables_time)a where a.counts>1 )y set x.status=1
- where x.order_no=y.order_no and x.amount=y.amount and x.receivables_time=y.receivables_time
- and x.corporate_name=y.nickname and x.aid= #{aid}
- </update>
- <select id="selectReceivablesNumberRepeats" parameterType="com.goafanti.common.model.TemporaryReceivables" resultType="java.lang.Integer">
- select count(*) from t_order_bill_new a left join user b on a.payer_id=b.id
- where a.order_no= #{orderNo}
- and b.nickname= #{corporateName}
- and a.transaction_amount= #{amount}
- and a.financial_pay_time= #{receivablesTime}
- </select>
- <select id="waitngMerge">
- update temporary_receivables
- set merge_Status=1
- where id in
- <foreach close=")" collection="list" item="id" open="(" separator=",">
- #{id}
- </foreach>
- </select>
- </mapper>
|