|
@@ -0,0 +1,311 @@
|
|
|
+<?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.zkqy.business.mapper.SaleAccountsReceivableDetailMapper">
|
|
|
+
|
|
|
+ <resultMap type="com.zkqy.business.domain.SaleAccountsReceivableDetail" id="SaleAccountsReceivableDetailResult">
|
|
|
+ <result property="id" column="id" />
|
|
|
+ <result property="accountingType" column="accounting_type" />
|
|
|
+ <result property="customerId" column="customer_id" />
|
|
|
+ <result property="customName" column="custom_name"/>
|
|
|
+ <result property="accountsReceivableDate" column="accounts_receivable_date" />
|
|
|
+ <result property="saleNo" column="sale_no" />
|
|
|
+ <result property="saleProductNo" column="sale_product_no" />
|
|
|
+ <result property="registrationCollectionId" column="registration_collection_id"/>
|
|
|
+ <result property="productId" column="product_id" />
|
|
|
+ <result property="productName" column="product_name" />
|
|
|
+ <result property="productSpecifications" column="product_specifications" />
|
|
|
+ <result property="productLevel" column="product_level" />
|
|
|
+ <result property="productColour" column="product_colour" />
|
|
|
+ <result property="lotNumber" column="lot_number" />
|
|
|
+ <result property="boxNum" column="box_num" />
|
|
|
+ <result property="weight" column="weight" />
|
|
|
+ <result property="productPrice" column="product_price" />
|
|
|
+ <result property="amountReceivable" column="amount_receivable" />
|
|
|
+ <result property="receivedAmount" column="received_amount" />
|
|
|
+ <result property="amounts" column="amounts" />
|
|
|
+ <result property="paymentMethod" column="payment_method" />
|
|
|
+ <result property="billingType" column="billing_type" />
|
|
|
+ <result property="accountsReceivableRemark" column="accounts_receivable_remark" />
|
|
|
+ <result property="settlementUnit" column="settlement_unit" />
|
|
|
+ <result property="returnReceipt" column="return_receipt" />
|
|
|
+ <result property="returnReceiptDate" column="return_receipt_date" />
|
|
|
+ <result property="returnReceiptRemark" column="return_receipt_remark" />
|
|
|
+ <result property="noticeNumber" column="notice_number" />
|
|
|
+ <result property="status" column="status" />
|
|
|
+ <result property="spare1" column="spare1" />
|
|
|
+ <result property="spare2" column="spare2" />
|
|
|
+ <result property="spare3" column="spare3" />
|
|
|
+ <result property="remark" column="remark" />
|
|
|
+ <result property="createBy" column="create_by" />
|
|
|
+ <result property="createById" column="create_by_id" />
|
|
|
+ <result property="createTime" column="create_time" />
|
|
|
+ <result property="updateBy" column="update_by" />
|
|
|
+ <result property="updateById" column="update_by_id" />
|
|
|
+ <result property="updateTime" column="update_time" />
|
|
|
+ <result property="delFlag" column="del_flag" />
|
|
|
+ <result property="billingFlag" column="billing_flag"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <sql id="selectSaleAccountsReceivableDetailVo">
|
|
|
+ select id, accounting_type, customer_id, accounts_receivable_date, sale_no, sale_product_no, registration_collection_id,product_id, product_name, product_specifications, product_level, product_colour, lot_number, box_num, weight, product_price, amount_receivable, received_amount, amounts, payment_method, billing_type, accounts_receivable_remark, settlement_unit, return_receipt, return_receipt_date, return_receipt_remark, notice_number, status, spare1, spare2, spare3, remark, create_by, create_by_id, create_time, update_by, update_by_id, update_time, del_flag, billing_flag from {DBNAME}.sale_accounts_receivable_detail
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <select id="selectSaleAccountsReceivableDetailList" parameterType="com.zkqy.business.domain.SaleAccountsReceivableDetail" resultMap="SaleAccountsReceivableDetailResult">
|
|
|
+ SELECT
|
|
|
+ sard.*,
|
|
|
+ c.custom_name,
|
|
|
+ csu.customer_name as settlementUnitName,
|
|
|
+ fpi.id as finishedProductInvoiceId,
|
|
|
+ fpi.invoice_number as invoiceNumber,
|
|
|
+ fpi.invoice_type as invoiceType
|
|
|
+ FROM
|
|
|
+ {DBNAME}.sale_accounts_receivable_detail sard
|
|
|
+ LEFT JOIN {DBNAME}.customer c ON sard.customer_id = c.id
|
|
|
+ left join {DBNAME}.customer_settlement_unit csu on csu.id = sard.settlement_unit
|
|
|
+ left join {DBNAME}.finished_product_invoice fpi on sard.id = fpi.accounts_receivable_detail_id and fpi.del_flag = '0'
|
|
|
+ WHERE
|
|
|
+ sard.del_flag = '0'
|
|
|
+ <if test="accountingType != null and accountingType != ''"> and sard.accounting_type = #{accountingType}</if>
|
|
|
+ <if test="customerId != null "> and sard.customer_id = #{customerId}</if>
|
|
|
+ <if test="startTime != null and endTime != null "> and sard.accounts_receivable_date between #{startTime} and #{endTime}</if>
|
|
|
+ <if test="billingType != null and billingType != ''"> and sard.billing_type = #{billingType}</if>
|
|
|
+ <if test="accountsReceivableRemark != null and accountsReceivableRemark != ''"> and sard.accounts_receivable_remark like concat('%', #{accountsReceivableRemark}, '%')</if>
|
|
|
+ <if test="returnReceipt != null and returnReceipt != ''"> and sard.return_receipt = #{returnReceipt}</if>
|
|
|
+ <if test="status != null and status != ''">and sard.status in ( #{status} )</if>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectSaleAccountsReceivableDetailById" parameterType="Long" resultMap="SaleAccountsReceivableDetailResult">
|
|
|
+ <include refid="selectSaleAccountsReceivableDetailVo"/>
|
|
|
+ where id = #{id}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <insert id="insertSaleAccountsReceivableDetail" parameterType="com.zkqy.business.domain.SaleAccountsReceivableDetail" useGeneratedKeys="true" keyProperty="id">
|
|
|
+ insert into {DBNAME}.sale_accounts_receivable_detail
|
|
|
+ <trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
+ <if test="accountingType != null">accounting_type,</if>
|
|
|
+ <if test="customerId != null">customer_id,</if>
|
|
|
+ <if test="accountsReceivableDate != null">accounts_receivable_date,</if>
|
|
|
+ <if test="saleNo != null">sale_no,</if>
|
|
|
+ <if test="saleProductNo != null">sale_product_no,</if>
|
|
|
+ <if test="registrationCollectionId != null">registration_collection_id,</if>
|
|
|
+ <if test="productId != null">product_id,</if>
|
|
|
+ <if test="productName != null">product_name,</if>
|
|
|
+ <if test="productSpecifications != null">product_specifications,</if>
|
|
|
+ <if test="productLevel != null">product_level,</if>
|
|
|
+ <if test="productColour != null">product_colour,</if>
|
|
|
+ <if test="lotNumber != null">lot_number,</if>
|
|
|
+ <if test="boxNum != null">box_num,</if>
|
|
|
+ <if test="weight != null">weight,</if>
|
|
|
+ <if test="productPrice != null">product_price,</if>
|
|
|
+ <if test="amountReceivable != null">amount_receivable,</if>
|
|
|
+ <if test="receivedAmount != null">received_amount,</if>
|
|
|
+ <if test="amounts != null">amounts,</if>
|
|
|
+ <if test="paymentMethod != null">payment_method,</if>
|
|
|
+ <if test="billingType != null">billing_type,</if>
|
|
|
+ <if test="accountsReceivableRemark != null">accounts_receivable_remark,</if>
|
|
|
+ <if test="settlementUnit != null">settlement_unit,</if>
|
|
|
+ <if test="returnReceipt != null">return_receipt,</if>
|
|
|
+ <if test="returnReceiptDate != null">return_receipt_date,</if>
|
|
|
+ <if test="returnReceiptRemark != null">return_receipt_remark,</if>
|
|
|
+ <if test="noticeNumber != null">notice_number,</if>
|
|
|
+ <if test="status != null">status,</if>
|
|
|
+ <if test="spare1 != null">spare1,</if>
|
|
|
+ <if test="spare2 != null">spare2,</if>
|
|
|
+ <if test="spare3 != null">spare3,</if>
|
|
|
+ <if test="remark != null">remark,</if>
|
|
|
+ <if test="createBy != null">create_by,</if>
|
|
|
+ <if test="createById != null">create_by_id,</if>
|
|
|
+ <if test="createTime != null">create_time,</if>
|
|
|
+ del_flag,
|
|
|
+ billing_flag
|
|
|
+ </trim>
|
|
|
+ <trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
+ <if test="accountingType != null">#{accountingType},</if>
|
|
|
+ <if test="customerId != null">#{customerId},</if>
|
|
|
+ <if test="accountsReceivableDate != null">#{accountsReceivableDate},</if>
|
|
|
+ <if test="saleNo != null">#{saleNo},</if>
|
|
|
+ <if test="saleProductNo != null">#{saleProductNo},</if>
|
|
|
+ <if test="registrationCollectionId != null">#{registrationCollectionId},</if>
|
|
|
+ <if test="productId != null">#{productId},</if>
|
|
|
+ <if test="productName != null">#{productName},</if>
|
|
|
+ <if test="productSpecifications != null">#{productSpecifications},</if>
|
|
|
+ <if test="productLevel != null">#{productLevel},</if>
|
|
|
+ <if test="productColour != null">#{productColour},</if>
|
|
|
+ <if test="lotNumber != null">#{lotNumber},</if>
|
|
|
+ <if test="boxNum != null">#{boxNum},</if>
|
|
|
+ <if test="weight != null">#{weight},</if>
|
|
|
+ <if test="productPrice != null">#{productPrice},</if>
|
|
|
+ <if test="amountReceivable != null">#{amountReceivable},</if>
|
|
|
+ <if test="receivedAmount != null">#{receivedAmount},</if>
|
|
|
+ <if test="amounts != null">#{amounts},</if>
|
|
|
+ <if test="paymentMethod != null">#{paymentMethod},</if>
|
|
|
+ <if test="billingType != null">#{billingType},</if>
|
|
|
+ <if test="accountsReceivableRemark != null">#{accountsReceivableRemark},</if>
|
|
|
+ <if test="settlementUnit != null">#{settlementUnit},</if>
|
|
|
+ <if test="returnReceipt != null">#{returnReceipt},</if>
|
|
|
+ <if test="returnReceiptDate != null">#{returnReceiptDate},</if>
|
|
|
+ <if test="returnReceiptRemark != null">#{returnReceiptRemark},</if>
|
|
|
+ <if test="noticeNumber != null">#{noticeNumber},</if>
|
|
|
+ <if test="status != null">#{status},</if>
|
|
|
+ <if test="spare1 != null">#{spare1},</if>
|
|
|
+ <if test="spare2 != null">#{spare2},</if>
|
|
|
+ <if test="spare3 != null">#{spare3},</if>
|
|
|
+ <if test="remark != null">#{remark},</if>
|
|
|
+ <if test="createBy != null">#{createBy},</if>
|
|
|
+ <if test="createById != null">#{createById},</if>
|
|
|
+ <if test="createTime != null">#{createTime},</if>
|
|
|
+ '0',
|
|
|
+ '0'
|
|
|
+ </trim>
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <update id="updateSaleAccountsReceivableDetail" parameterType="com.zkqy.business.domain.SaleAccountsReceivableDetail">
|
|
|
+ update {DBNAME}.sale_accounts_receivable_detail
|
|
|
+ <trim prefix="SET" suffixOverrides=",">
|
|
|
+ <if test="accountingType != null">accounting_type = #{accountingType},</if>
|
|
|
+ <if test="customerId != null">customer_id = #{customerId},</if>
|
|
|
+ <if test="accountsReceivableDate != null">accounts_receivable_date = #{accountsReceivableDate},</if>
|
|
|
+ <if test="saleNo != null">sale_no = #{saleNo},</if>
|
|
|
+ <if test="saleProductNo != null">sale_product_no = #{saleProductNo},</if>
|
|
|
+ <if test="registrationCollectionId != null">registration_collection_id = #{registrationCollectionId},</if>
|
|
|
+ <if test="productId != null">product_id = #{productId},</if>
|
|
|
+ <if test="productName != null">product_name = #{productName},</if>
|
|
|
+ <if test="productSpecifications != null">product_specifications = #{productSpecifications},</if>
|
|
|
+ <if test="productLevel != null">product_level = #{productLevel},</if>
|
|
|
+ <if test="productColour != null">product_colour = #{productColour},</if>
|
|
|
+ <if test="lotNumber != null">lot_number = #{lotNumber},</if>
|
|
|
+ <if test="boxNum != null">box_num = #{boxNum},</if>
|
|
|
+ <if test="weight != null">weight = #{weight},</if>
|
|
|
+ <if test="productPrice != null">product_price = #{productPrice},</if>
|
|
|
+ <if test="amountReceivable != null">amount_receivable = #{amountReceivable},</if>
|
|
|
+ <if test="receivedAmount != null">received_amount = #{receivedAmount},</if>
|
|
|
+ <if test="amounts != null">amounts = #{amounts},</if>
|
|
|
+ <if test="paymentMethod != null">payment_method = #{paymentMethod},</if>
|
|
|
+ <if test="billingType != null">billing_type = #{billingType},</if>
|
|
|
+ <if test="accountsReceivableRemark != null">accounts_receivable_remark = #{accountsReceivableRemark},</if>
|
|
|
+ <if test="settlementUnit != null">settlement_unit = #{settlementUnit},</if>
|
|
|
+ <if test="returnReceipt != null">return_receipt = #{returnReceipt},</if>
|
|
|
+ return_receipt_date = #{returnReceiptDate},
|
|
|
+ <if test="returnReceiptRemark != null">return_receipt_remark = #{returnReceiptRemark},</if>
|
|
|
+ <if test="noticeNumber != null">notice_number = #{noticeNumber},</if>
|
|
|
+ <if test="status != null">status = #{status},</if>
|
|
|
+ <if test="spare1 != null">spare1 = #{spare1},</if>
|
|
|
+ <if test="spare2 != null">spare2 = #{spare2},</if>
|
|
|
+ <if test="spare3 != null">spare3 = #{spare3},</if>
|
|
|
+ <if test="remark != null">remark = #{remark},</if>
|
|
|
+ <if test="updateBy != null">update_by = #{updateBy},</if>
|
|
|
+ <if test="updateById != null">update_by_id = #{updateById},</if>
|
|
|
+ <if test="updateTime != null">update_time = #{updateTime},</if>
|
|
|
+ <if test="billingFlag != null">billing_flag = #{billingFlag},</if>
|
|
|
+ </trim>
|
|
|
+ where id = #{id}
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <delete id="deleteSaleAccountsReceivableDetailById" parameterType="Long">
|
|
|
+ update {DBNAME}.sale_accounts_receivable_detail set del_flag = '2' where id = #{id}
|
|
|
+ </delete>
|
|
|
+
|
|
|
+ <delete id="deleteSaleAccountsReceivableDetailByIds" parameterType="String">
|
|
|
+ update {DBNAME}.sale_accounts_receivable_detail set del_flag = '2' where id in
|
|
|
+ <foreach item="id" collection="array" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </delete>
|
|
|
+
|
|
|
+ <insert id="batchInsertSaleAccountsReceivableDetail">
|
|
|
+ INSERT INTO {DBNAME}.sale_accounts_receivable_detail (
|
|
|
+ accounting_type,
|
|
|
+ customer_id,
|
|
|
+ accounts_receivable_date,
|
|
|
+ sale_no,
|
|
|
+ sale_product_no,
|
|
|
+ registration_collection_id,
|
|
|
+ product_id,
|
|
|
+ product_name,
|
|
|
+ product_specifications,
|
|
|
+ product_level,
|
|
|
+ product_colour,
|
|
|
+ lot_number,
|
|
|
+ box_num,
|
|
|
+ weight,
|
|
|
+ product_price,
|
|
|
+ amount_receivable,
|
|
|
+ received_amount,
|
|
|
+ amounts,
|
|
|
+ payment_method,
|
|
|
+ billing_type,
|
|
|
+ accounts_receivable_remark,
|
|
|
+ settlement_unit,
|
|
|
+ return_receipt,
|
|
|
+ return_receipt_date,
|
|
|
+ return_receipt_remark,
|
|
|
+ notice_number,
|
|
|
+ status,
|
|
|
+ spare1,
|
|
|
+ spare2,
|
|
|
+ spare3,
|
|
|
+ remark,
|
|
|
+ create_by,
|
|
|
+ create_by_id,
|
|
|
+ create_time,
|
|
|
+ del_flag,
|
|
|
+ billing_flag
|
|
|
+ ) VALUES
|
|
|
+ <foreach collection="list" item="item" separator=",">
|
|
|
+ (
|
|
|
+ #{item.accountingType},
|
|
|
+ #{item.customerId},
|
|
|
+ #{item.accountsReceivableDate},
|
|
|
+ #{item.saleNo},
|
|
|
+ #{item.saleProductNo},
|
|
|
+ #{item.registrationCollectionId},
|
|
|
+ #{item.productId},
|
|
|
+ #{item.productName},
|
|
|
+ #{item.productSpecifications},
|
|
|
+ #{item.productLevel},
|
|
|
+ #{item.productColour},
|
|
|
+ #{item.lotNumber},
|
|
|
+ #{item.boxNum},
|
|
|
+ #{item.weight},
|
|
|
+ #{item.productPrice},
|
|
|
+ #{item.amountReceivable},
|
|
|
+ #{item.receivedAmount},
|
|
|
+ #{item.amounts},
|
|
|
+ #{item.paymentMethod},
|
|
|
+ #{item.billingType},
|
|
|
+ #{item.accountsReceivableRemark},
|
|
|
+ #{item.settlementUnit},
|
|
|
+ #{item.returnReceipt},
|
|
|
+ #{item.returnReceiptDate},
|
|
|
+ #{item.returnReceiptRemark},
|
|
|
+ #{item.noticeNumber},
|
|
|
+ #{item.status},
|
|
|
+ #{item.spare1},
|
|
|
+ #{item.spare2},
|
|
|
+ #{item.spare3},
|
|
|
+ #{item.remark},
|
|
|
+ #{item.createBy},
|
|
|
+ #{item.createById},
|
|
|
+ #{item.createTime},
|
|
|
+ '0',
|
|
|
+ '0'
|
|
|
+ )
|
|
|
+ </foreach>
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <select id="selectAccountsReceivableDetailList" parameterType="com.zkqy.business.domain.SaleAccountsReceivableDetail" resultMap="SaleAccountsReceivableDetailResult">
|
|
|
+ <include refid="selectSaleAccountsReceivableDetailVo"></include>
|
|
|
+ where del_flag = '0'
|
|
|
+ <if test="accountingType != null and accountingType != ''"> and accounting_type = #{accountingType}</if>
|
|
|
+ <if test="customerId != null "> and customer_id = #{customerId}</if>
|
|
|
+ <if test="startTime != null and endTime != null "> and accounts_receivable_date between #{startTime} and #{endTime}</if>
|
|
|
+ <if test="billingType != null and billingType != ''"> and billing_type = #{billingType}</if>
|
|
|
+ <if test="accountsReceivableRemark != null and accountsReceivableRemark != ''"> and accounts_receivable_remark like concat('%', #{accountsReceivableRemark}, '%')</if>
|
|
|
+ <if test="returnReceipt != null and returnReceipt != ''"> and return_receipt = #{returnReceipt}</if>
|
|
|
+ <if test="status != null and status != ''">and status in ( #{status} )</if>
|
|
|
+ order by id asc
|
|
|
+ </select>
|
|
|
+
|
|
|
+</mapper>
|