12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?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.fjhx.sale.mapper.contract.ContractProductMapper">
- <select id="getPage" resultType="com.fjhx.sale.entity.contract.vo.ContractProductVo">
- SELECT
- t1.id,
- t1.contract_id,
- t1.product_id,
- t2.`code` AS contractCode,
- t2.user_name AS userName,
- t2.version AS contractVersion,
- t1.expend_quantity expendQuantity,
- (SELECT create_time FROM claim_contract WHERE contract_id = t2.id ORDER BY create_time DESC LIMIT 1 ) AS claimTime
- FROM
- contract_product t1
- LEFT JOIN contract t2 ON t1.contract_id = t2.id
- ${ew.customSqlSegment}
- </select>
- <select id="getListByIds" resultType="com.fjhx.sale.entity.contract.vo.ContractProductVo">
- SELECT
- t1.id,
- t1.contract_id,
- t1.product_id,
- t2.`code` AS contractCode,
- t2.user_name AS userName,
- t2.version AS contractVersion,
- t1.expend_quantity expendQuantity
- FROM
- contract_product t1
- LEFT JOIN contract t2 ON t1.contract_id = t2.id
- ${ew.customSqlSegment}
- </select>
- <select id="getNoPackContractProductById" resultType="com.fjhx.sale.entity.contract.vo.ContractProductVo">
- SELECT
- *
- FROM
- (
- SELECT
- t1.*,
- t1.`code` AS contractCode,
- t2.quantity AS cpQuantity,
- t2.id AS contractProductId,
- ( SELECT IFNULL( SUM( quantity ), 0 ) FROM pack_detail_product WHERE contract_product_id = t2.id ) AS sumPackQuantity
- FROM
- contract t1
- LEFT JOIN contract_product t2 ON t1.id = t2.contract_id
- <where>
- <if test="customerId neq null and customerId neq '' ">
- buy_corporation_id = #{customerId}
- </if>
- </where>
- ) t1
- WHERE t1.sumPackQuantity < t1.cpQuantity
- <if test="contractIds neq null and contractIds.size() > 0">
- <foreach collection="contractIds" item="contractId" open="AND t1.id IN (" separator="," close=")">
- #{contractId}
- </foreach>
- </if>
- </select>
- </mapper>
|