123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?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.ContractMapper">
- <select id="getPage" resultType="com.fjhx.sale.entity.contract.vo.ContractVo">
- select
- *
- from contract
- ${ew.customSqlSegment}
- </select>
- <select id="getNoPackContractByCustomerId" resultType="com.fjhx.sale.entity.contract.vo.ContractVo">
- SELECT
- *
- FROM
- (
- SELECT
- t1.*,
- t2.quantity AS cpQuantity,
- ( 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
- AND t1.`status` >=30
- AND t1.`status` <999
- GROUP BY t1.id
- </select>
- <select id="getNoPackContractProductById" resultType="com.fjhx.sale.entity.contract.vo.ContractVo">
- SELECT
- *
- FROM
- (
- SELECT
- t1.*,
- 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
- AND t1.id = #{contractId}
- </select>
- </mapper>
|