<?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.DemandMapper" >
  <resultMap id="BaseResultMap" type="com.goafanti.common.model.Demand" >
    <id column="id" property="id" jdbcType="VARCHAR" />
    <result column="serial_number" property="serialNumber" jdbcType="INTEGER" />
    <result column="data_category" property="dataCategory" jdbcType="INTEGER" />
    <result column="name" property="name" jdbcType="VARCHAR" />
    <result column="keyword" property="keyword" jdbcType="VARCHAR" />
    <result column="info_sources" property="infoSources" jdbcType="INTEGER" />
    <result column="industry_category_a" property="industryCategoryA" jdbcType="INTEGER" />
    <result column="industry_category_b" property="industryCategoryB" jdbcType="INTEGER" />
    <result column="industry_category_c" property="industryCategoryC" jdbcType="INTEGER" />
    <result column="demand_type" property="demandType" jdbcType="INTEGER" />
    <result column="problem_des" property="problemDes" jdbcType="LONGVARCHAR" />
    <result column="technical_requirements" property="technicalRequirements" jdbcType="VARCHAR" />
    <result column="picture_url" property="pictureUrl" jdbcType="LONGVARCHAR" />
    <result column="text_file_url" property="textFileUrl" jdbcType="VARCHAR" />
    <result column="video_url" property="videoUrl" jdbcType="VARCHAR" />
    <result column="fixed_budget" property="fixedBudget" jdbcType="DECIMAL" />
    <result column="fixed_cycle" property="fixedCycle" jdbcType="VARCHAR" />
    <result column="people_number" property="peopleNumber" jdbcType="INTEGER" />
    <result column="fixed_scheme" property="fixedScheme" jdbcType="VARCHAR" />
    <result column="cost_escrow" property="costEscrow" jdbcType="DECIMAL" />
    <result column="budget_cost" property="budgetCost" jdbcType="DECIMAL" />
    <result column="validity_period" property="validityPeriod" jdbcType="TIMESTAMP" />
    <result column="employer_id" property="employerId" jdbcType="VARCHAR" />
    <result column="employer_name" property="employerName" jdbcType="VARCHAR" />
    <result column="employer_address" property="employerAddress" jdbcType="VARCHAR" />
    <result column="employer_contacts" property="employerContacts" jdbcType="VARCHAR" />
    <result column="employer_contacts_mobile" property="employerContactsMobile" jdbcType="VARCHAR" />
    <result column="employer_contacts_mailbox" property="employerContactsMailbox" jdbcType="VARCHAR" />
    <result column="contacts" property="contacts" jdbcType="VARCHAR" />
    <result column="status" property="status" jdbcType="INTEGER" />
    <result column="release_status" property="releaseStatus" jdbcType="INTEGER" />
    <result column="release_date" property="releaseDate" jdbcType="TIMESTAMP" />
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
    <result column="principal_id" property="principalId" jdbcType="VARCHAR" />
    <result column="deleted_sign" property="deletedSign" jdbcType="INTEGER" />
    <result column="audit_status" property="auditStatus" jdbcType="INTEGER" />
    <result column="tech_broker_id" property="techBrokerId" jdbcType="VARCHAR" />
    <result column="boutique" property="boutique" jdbcType="INTEGER" />
    <result column="uid" property="uid" jdbcType="VARCHAR" />
    <result column="urgent_days" property="urgentDays" jdbcType="INTEGER" />
    <result column="urgent_money" property="urgentMoney" jdbcType="DECIMAL" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, serial_number, data_category, name, keyword, info_sources, industry_category_a, 
    industry_category_b, industry_category_c, demand_type, problem_des, technical_requirements, 
    picture_url, text_file_url, video_url, fixed_budget, fixed_cycle, people_number, 
    fixed_scheme, cost_escrow, budget_cost, validity_period, employer_id, employer_name, 
    employer_address, employer_contacts, employer_contacts_mobile, employer_contacts_mailbox, 
    contacts, status, release_status, release_date, create_time, principal_id, deleted_sign,
    audit_status, tech_broker_id,boutique,urgent_money,urgent_days
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select 
    <include refid="Base_Column_List" />
    from demand
    where id = #{id,jdbcType=VARCHAR}
  </select>
  <select id="selectAppByPrimaryKey" resultType="com.goafanti.demand.bo.DemandListBo" parameterType="java.lang.String" >
    	select 
    d.id, d.serial_number AS serialNumber, d.data_category AS dataCategory, d.name, d.keyword, d.info_sources AS infoSources, d.industry_category_a AS industryCategoryA, 
    d.industry_category_b AS industryCategoryB, d.industry_category_c AS industryCategoryC, d.demand_type AS demandType, d.problem_des AS problemDes, d.technical_requirements AS technicalRequirements, 
    d.picture_url AS pictureUrl, d.text_file_url AS textFileUrl, d.video_url AS videoUrl, d.fixed_budget AS fixedBudget, d.fixed_cycle AS fixedCycle, d.people_number AS peopleNumber, 
    d.fixed_scheme AS fixedScheme, d.cost_escrow AS costEscrow, d.budget_cost AS budgetCost, d.validity_period as validityPeriod, d.employer_id AS employerId, d.employer_name AS employerName, 
    d.employer_address AS employerAddress, d.employer_contacts AS employerContacts, d.employer_contacts_mobile AS employerContactsMobile, d.employer_contacts_mailbox AS employerContactsMailbox, 
    d.contacts, d.status, d.release_status AS releaseStatus, d.release_date AS releaseDate , d.create_time AS createTime, d.principal_id AS principalId, d.deleted_sign AS deletedSign,
    d.audit_status AS auditStatus, d.tech_broker_id AS techBrokerId,d.boutique,d.urgent_money AS urgentMoney,d.urgent_days as urgentDays
    ,ifnull(t.x,0) as orderIntentionCount,ifnull(t2.x,0) as orderCount,j.easemob_name as easemobName,d.contacts,d.contact_mobile as contactMobile
    from demand d
    left join jpush_easemob_account j on d.employer_id=j.uid
    left join (select count(0) as x,tl.commodity_id from t_order tr
				left join t_order_detail tl on tl.order_no=tr.order_no
				where order_status != 4
				group by  tl.commodity_id) t on d.id=t.commodity_id
    left join (select count(0) as x,tl.commodity_id from t_order tr
				left join t_order_detail tl on tl.order_no=tr.order_no
				where tr.order_status != 4 and tr.order_status != 0
				group by  tl.commodity_id ) t2 on d.id=t2.commodity_id 
    where d.id =  #{id,jdbcType=VARCHAR}
	</select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
    delete from demand
    where id = #{id,jdbcType=VARCHAR}
  </delete>
  <insert id="insert" parameterType="com.goafanti.common.model.Demand" >
    insert into demand (id, serial_number, data_category, 
      name, keyword, info_sources, 
      industry_category_a, industry_category_b, industry_category_c, 
      demand_type, problem_des, technical_requirements, 
      picture_url, text_file_url, video_url, 
      fixed_budget, fixed_cycle, people_number, 
      fixed_scheme, cost_escrow, budget_cost, 
      validity_period, employer_id, employer_name, 
      employer_address, employer_contacts, employer_contacts_mobile, 
      employer_contacts_mailbox, contacts, status, 
      release_status, release_date, create_time, 
      principal_id, deleted_sign, audit_status, tech_broker_id,boutique,remark,urgent_days,urgent_money,contact_mobile,crowd_cost,
      is_hot,is_urgent,research_type)
    values (#{id,jdbcType=VARCHAR}, #{serialNumber,jdbcType=INTEGER}, #{dataCategory,jdbcType=INTEGER}, 
      #{name,jdbcType=VARCHAR}, #{keyword,jdbcType=VARCHAR}, #{infoSources,jdbcType=INTEGER}, 
      #{industryCategoryA,jdbcType=INTEGER}, #{industryCategoryB,jdbcType=INTEGER}, #{industryCategoryC,jdbcType=INTEGER}, 
      #{demandType,jdbcType=INTEGER}, #{problemDes,jdbcType=VARCHAR}, #{technicalRequirements,jdbcType=VARCHAR}, 
      #{pictureUrl,jdbcType=LONGVARCHAR}, #{textFileUrl,jdbcType=VARCHAR}, #{videoUrl,jdbcType=VARCHAR}, 
      #{fixedBudget,jdbcType=DECIMAL}, #{fixedCycle,jdbcType=VARCHAR}, #{peopleNumber,jdbcType=INTEGER}, 
      #{fixedScheme,jdbcType=VARCHAR}, #{costEscrow,jdbcType=DECIMAL}, #{budgetCost,jdbcType=DECIMAL}, 
      #{validityPeriod,jdbcType=TIMESTAMP}, #{employerId,jdbcType=VARCHAR}, #{employerName,jdbcType=VARCHAR}, 
      #{employerAddress,jdbcType=VARCHAR}, #{employerContacts,jdbcType=VARCHAR}, #{employerContactsMobile,jdbcType=VARCHAR}, 
      #{employerContactsMailbox,jdbcType=VARCHAR}, #{contacts,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, 
      #{releaseStatus,jdbcType=INTEGER}, #{releaseDate,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP}, 
      #{principalId,jdbcType=VARCHAR}, #{deletedSign,jdbcType=INTEGER}, #{auditStatus,jdbcType=INTEGER},
      #{techBrokerId,jdbcType=VARCHAR},#{boutique,jdbcType=INTEGER},#{remark,jdbcType=VARCHAR},#{urgentDays,jdbcType=VARCHAR},#{urgentMoney,jdbcType=VARCHAR},#{contactMobile,jdbcType=VARCHAR},#{crowdCost,jdbcType=DECIMAL},
      #{isHot,jdbcType=INTEGER},#{isUrgent,jdbcType=INTEGER},#{researchType,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="com.goafanti.common.model.Demand" >
    insert into demand
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="serialNumber != null" >
        serial_number,
      </if>
      <if test="dataCategory != null" >
        data_category,
      </if>
      <if test="name != null" >
        name,
      </if>
      <if test="keyword != null" >
        keyword,
      </if>
      <if test="infoSources != null" >
        info_sources,
      </if>
      <if test="industryCategoryA != null" >
        industry_category_a,
      </if>
      <if test="industryCategoryB != null" >
        industry_category_b,
      </if>
      <if test="industryCategoryC != null" >
        industry_category_c,
      </if>
      <if test="demandType != null" >
        demand_type,
      </if>
      <if test="problemDes != null" >
        problem_des,
      </if>
      <if test="technicalRequirements != null" >
        technical_requirements,
      </if>
      <if test="pictureUrl != null" >
        picture_url,
      </if>
      <if test="textFileUrl != null" >
        text_file_url,
      </if>
      <if test="videoUrl != null" >
        video_url,
      </if>
      <if test="fixedBudget != null" >
        fixed_budget,
      </if>
      <if test="fixedCycle != null" >
        fixed_cycle,
      </if>
      <if test="peopleNumber != null" >
        people_number,
      </if>
      <if test="fixedScheme != null" >
        fixed_scheme,
      </if>
      <if test="costEscrow != null" >
        cost_escrow,
      </if>
      <if test="budgetCost != null" >
        budget_cost,
      </if>
      <if test="validityPeriod != null" >
        validity_period,
      </if>
      <if test="employerId != null" >
        employer_id,
      </if>
      <if test="employerName != null" >
        employer_name,
      </if>
      <if test="employerAddress != null" >
        employer_address,
      </if>
      <if test="employerContacts != null" >
        employer_contacts,
      </if>
      <if test="employerContactsMobile != null" >
        employer_contacts_mobile,
      </if>
      <if test="employerContactsMailbox != null" >
        employer_contacts_mailbox,
      </if>
      <if test="contacts != null" >
        contacts,
      </if>
      <if test="status != null" >
        status,
      </if>
      <if test="releaseStatus != null" >
        release_status,
      </if>
      <if test="releaseDate != null" >
        release_date,
      </if>
      <if test="createTime != null" >
        create_time,
      </if>
      <if test="principalId != null" >
        principal_id,
      </if>
      <if test="deletedSign != null" >
        deleted_sign,
      </if>
      <if test="auditStatus != null" >
        audit_status,
      </if>
      <if test="techBrokerId != null" >
        tech_broker_id,
      </if>
      <if test="boutique != null" >
        boutique,
      </if>
      <if test="remark != null" >
        remark,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="serialNumber != null" >
        #{serialNumber,jdbcType=INTEGER},
      </if>
      <if test="dataCategory != null" >
        #{dataCategory,jdbcType=INTEGER},
      </if>
      <if test="name != null" >
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="keyword != null" >
        #{keyword,jdbcType=VARCHAR},
      </if>
      <if test="infoSources != null" >
        #{infoSources,jdbcType=INTEGER},
      </if>
      <if test="industryCategoryA != null" >
        #{industryCategoryA,jdbcType=INTEGER},
      </if>
      <if test="industryCategoryB != null" >
        #{industryCategoryB,jdbcType=INTEGER},
      </if>
      <if test="industryCategoryC != null" >
        #{industryCategoryC,jdbcType=INTEGER},
      </if>
      <if test="demandType != null" >
        #{demandType,jdbcType=INTEGER},
      </if>
      <if test="problemDes != null" >
        #{problemDes,jdbcType=VARCHAR},
      </if>
      <if test="technicalRequirements != null" >
        #{technicalRequirements,jdbcType=VARCHAR},
      </if>
      <if test="pictureUrl != null" >
        #{pictureUrl,jdbcType=LONGVARCHAR},
      </if>
      <if test="textFileUrl != null" >
        #{textFileUrl,jdbcType=VARCHAR},
      </if>
      <if test="videoUrl != null" >
        #{videoUrl,jdbcType=VARCHAR},
      </if>
      <if test="fixedBudget != null" >
        #{fixedBudget,jdbcType=DECIMAL},
      </if>
      <if test="fixedCycle != null" >
        #{fixedCycle,jdbcType=VARCHAR},
      </if>
      <if test="peopleNumber != null" >
        #{peopleNumber,jdbcType=INTEGER},
      </if>
      <if test="fixedScheme != null" >
        #{fixedScheme,jdbcType=VARCHAR},
      </if>
      <if test="costEscrow != null" >
        #{costEscrow,jdbcType=DECIMAL},
      </if>
      <if test="budgetCost != null" >
        #{budgetCost,jdbcType=DECIMAL},
      </if>
      <if test="validityPeriod != null" >
        #{validityPeriod,jdbcType=TIMESTAMP},
      </if>
      <if test="employerId != null" >
        #{employerId,jdbcType=VARCHAR},
      </if>
      <if test="employerName != null" >
        #{employerName,jdbcType=VARCHAR},
      </if>
      <if test="employerAddress != null" >
        #{employerAddress,jdbcType=VARCHAR},
      </if>
      <if test="employerContacts != null" >
        #{employerContacts,jdbcType=VARCHAR},
      </if>
      <if test="employerContactsMobile != null" >
        #{employerContactsMobile,jdbcType=VARCHAR},
      </if>
      <if test="employerContactsMailbox != null" >
        #{employerContactsMailbox,jdbcType=VARCHAR},
      </if>
      <if test="contacts != null" >
        #{contacts,jdbcType=INTEGER},
      </if>
      <if test="status != null" >
        #{status,jdbcType=INTEGER},
      </if>
      <if test="releaseStatus != null" >
        #{releaseStatus,jdbcType=INTEGER},
      </if>
      <if test="releaseDate != null" >
        #{releaseDate,jdbcType=TIMESTAMP},
      </if>
      <if test="createTime != null" >
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="principalId != null" >
        #{principalId,jdbcType=VARCHAR},
      </if>
      <if test="deletedSign != null" >
        #{deletedSign,jdbcType=INTEGER},
      </if>
      <if test="auditStatus != null" >
        #{auditStatus,jdbcType=INTEGER},
      </if>
      <if test="techBrokerId != null" >
        #{techBrokerId,jdbcType=VARCHAR},
      </if>
      <if test="boutique != null" >
        #{boutique,jdbcType=INTEGER},
      </if>
      <if test="remark != null" >
        #{remark,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.Demand" >
    update demand
    <set >
      <if test="serialNumber != null" >
        serial_number = #{serialNumber,jdbcType=INTEGER},
      </if>
      <if test="dataCategory != null" >
        data_category = #{dataCategory,jdbcType=INTEGER},
      </if>
      <if test="name != null" >
        name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="keyword != null" >
        keyword = #{keyword,jdbcType=VARCHAR},
      </if>
      <if test="infoSources != null" >
        info_sources = #{infoSources,jdbcType=INTEGER},
      </if>
      <if test="industryCategoryA != null" >
        industry_category_a = #{industryCategoryA,jdbcType=INTEGER},
      </if>
      <if test="industryCategoryB != null" >
        industry_category_b = #{industryCategoryB,jdbcType=INTEGER},
      </if>
      <if test="industryCategoryC != null" >
        industry_category_c = #{industryCategoryC,jdbcType=INTEGER},
      </if>
      <if test="demandType != null" >
        demand_type = #{demandType,jdbcType=INTEGER},
      </if>
      <if test="problemDes != null" >
        problem_des = #{problemDes,jdbcType=VARCHAR},
      </if>
      <if test="technicalRequirements != null" >
        technical_requirements = #{technicalRequirements,jdbcType=VARCHAR},
      </if>
      <if test="pictureUrl != null" >
        picture_url = #{pictureUrl,jdbcType=LONGVARCHAR},
      </if>
      <if test="textFileUrl != null" >
        text_file_url = #{textFileUrl,jdbcType=VARCHAR},
      </if>
      <if test="videoUrl != null" >
        video_url = #{videoUrl,jdbcType=VARCHAR},
      </if>
      <if test="fixedBudget != null" >
        fixed_budget = #{fixedBudget,jdbcType=DECIMAL},
      </if>
      <if test="fixedCycle != null" >
        fixed_cycle = #{fixedCycle,jdbcType=VARCHAR},
      </if>
      <if test="peopleNumber != null" >
        people_number = #{peopleNumber,jdbcType=INTEGER},
      </if>
      <if test="fixedScheme != null" >
        fixed_scheme = #{fixedScheme,jdbcType=VARCHAR},
      </if>
      <if test="costEscrow != null" >
        cost_escrow = #{costEscrow,jdbcType=DECIMAL},
      </if>
      <if test="budgetCost != null" >
        budget_cost = #{budgetCost,jdbcType=DECIMAL},
      </if>
      <if test="validityPeriod != null" >
        validity_period = #{validityPeriod,jdbcType=TIMESTAMP},
      </if>
      <if test="employerId != null" >
        employer_id = #{employerId,jdbcType=VARCHAR},
      </if>
      <if test="employerName != null" >
        employer_name = #{employerName,jdbcType=VARCHAR},
      </if>
      <if test="employerAddress != null" >
        employer_address = #{employerAddress,jdbcType=VARCHAR},
      </if>
      <if test="employerContacts != null" >
        employer_contacts = #{employerContacts,jdbcType=VARCHAR},
      </if>
      <if test="employerContactsMobile != null" >
        employer_contacts_mobile = #{employerContactsMobile,jdbcType=VARCHAR},
      </if>
      <if test="employerContactsMailbox != null" >
        employer_contacts_mailbox = #{employerContactsMailbox,jdbcType=VARCHAR},
      </if>
      <if test="contacts != null" >
        contacts = #{contacts,jdbcType=VARCHAR},
      </if>   
      <if test="contactMobile  != null" >
        contact_mobile  = #{contactMobile ,jdbcType=VARCHAR},
      </if>
      <if test="status != null" >
        status = #{status,jdbcType=INTEGER},
      </if>
      <if test="releaseStatus != null" >
        release_status = #{releaseStatus,jdbcType=INTEGER},
      </if>
      <if test="releaseDate != null" >
        release_date = #{releaseDate,jdbcType=TIMESTAMP},
      </if>
      <if test="createTime != null" >
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="principalId != null" >
        principal_id = #{principalId,jdbcType=VARCHAR},
      </if>
      <if test="deletedSign != null" >
        deleted_sign = #{deletedSign,jdbcType=INTEGER},
      </if>
      <if test="auditStatus != null" >
        audit_status = #{auditStatus,jdbcType=INTEGER},
      </if>
      <if test="techBrokerId != null" >
        tech_broker_id = #{techBrokerId,jdbcType=VARCHAR},
      </if>
      <if test="boutique != null">
      	boutique = #{boutique,jdbcType=INTEGER},
      </if>
      <if test="remark != null" >
        remark = #{remark,jdbcType=VARCHAR},
      </if>
      <if test="isUrgent != null">
      	is_urgent = #{isUrgent,jdbcType=INTEGER},
      </if>
      <if test="urgentDays != null" >
        urgent_days = #{urgentDays,jdbcType=INTEGER},
      </if>
      <if test="urgentMoney != null" >
        urgent_money = #{urgentMoney,jdbcType=VARCHAR}, 
      </if>
      <if test="researchType != null">
      	research_type = #{researchType,jdbcType=VARCHAR},
      </if>
      <if test="crowdCost!=null">
      crowd_cost=#{crowdCost,jdbcType=DECIMAL},
      </if>
      <if test="isHot!=null">
      is_hot=#{isHot,jdbcType=INTEGER}
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.Demand" >
    update demand
    set serial_number = #{serialNumber,jdbcType=INTEGER},
      data_category = #{dataCategory,jdbcType=INTEGER},
      name = #{name,jdbcType=VARCHAR},
      keyword = #{keyword,jdbcType=VARCHAR},
      info_sources = #{infoSources,jdbcType=INTEGER},
      industry_category_a = #{industryCategoryA,jdbcType=INTEGER},
      industry_category_b = #{industryCategoryB,jdbcType=INTEGER},
      industry_category_c = #{industryCategoryC,jdbcType=INTEGER},
      demand_type = #{demandType,jdbcType=INTEGER},
      problem_des = #{problemDes,jdbcType=VARCHAR},
      technical_requirements = #{technicalRequirements,jdbcType=VARCHAR},
      picture_url = #{pictureUrl,jdbcType=LONGVARCHAR},
      text_file_url = #{textFileUrl,jdbcType=VARCHAR},
      video_url = #{videoUrl,jdbcType=VARCHAR},
      fixed_budget = #{fixedBudget,jdbcType=DECIMAL},
      fixed_cycle = #{fixedCycle,jdbcType=VARCHAR},
      people_number = #{peopleNumber,jdbcType=INTEGER},
      fixed_scheme = #{fixedScheme,jdbcType=VARCHAR},
      cost_escrow = #{costEscrow,jdbcType=DECIMAL},
      budget_cost = #{budgetCost,jdbcType=DECIMAL},
      validity_period = #{validityPeriod,jdbcType=TIMESTAMP},
      employer_id = #{employerId,jdbcType=VARCHAR},
      employer_name = #{employerName,jdbcType=VARCHAR},
      employer_address = #{employerAddress,jdbcType=VARCHAR},
      employer_contacts = #{employerContacts,jdbcType=VARCHAR},
      employer_contacts_mobile = #{employerContactsMobile,jdbcType=VARCHAR},
      employer_contacts_mailbox = #{employerContactsMailbox,jdbcType=VARCHAR},
      contacts = #{contacts,jdbcType=INTEGER},
      status = #{status,jdbcType=INTEGER},
      release_status = #{releaseStatus,jdbcType=INTEGER},
      release_date = #{releaseDate,jdbcType=TIMESTAMP},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      principal_id = #{principalId,jdbcType=VARCHAR},
      deleted_sign = #{deletedSign,jdbcType=INTEGER},
      audit_status = #{auditStatus,jdbcType=INTEGER},
      tech_broker_id = #{techBrokerId,jdbcType=VARCHAR},
      boutique = #{boutique,jdbcType=INTEGER}
    where id = #{id,jdbcType=VARCHAR}
  </update>

  <select id="findAppDemandListByPage" parameterType="String" resultType="com.goafanti.demand.bo.DemandListBo">
  	select 
	  d.id, d.serial_number as serialNumber, d.data_category as dataCategory, d.boutique,
	  d.name, d.keyword, d.demand_type as demandType, d.industry_category_a as industryCategoryA, d.industry_category_b as industryCategoryB, d.industry_category_c as industryCategoryC,
	  d.validity_period as validityPeriod, d.status, d.release_status as releaseStatus, 
	  d.release_date as releaseDate, d.employer_id as employerId, d.audit_status as auditStatus,t.city as cityname,
	  d.urgent_money as urgentMoney,d.urgent_days as  urgentDays,d.employer_address as employerAddress,d.problem_des as problemDes,ifnull(t.countInterest,0) as countInterest,g.name as industryCategory1,g2.name as industryCategory2
	from  demand d 
	left join  user_identity t on d.employer_id=t.uid
	left join	field_glossory g on d.industry_category_a=g.id
	left join	field_glossory g2 on d.industry_category_b=g2.id
	left join (select count(0)  as countInterest ,demand_id from demand_interest 
				group by demand_id) t on d.id=t.demand_id
	where d.deleted_sign = 0 
	and d.audit_status=3
	<if test="employerId != null">
	and d.employer_id = #{employerId, jdbcType=VARCHAR}
	</if>
	<if test="serialNumber != null">
		and  d.serial_number = #{serialNumber,jdbcType=INTEGER}
	</if>
	<if test="auditStatus != null">
		and  d.audit_status = #{auditStatus,jdbcType=INTEGER}
	</if>
	<if test="name != null">
		and  d.name like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
	</if>
	<if test="keyword != null">
		and  d.keyword like "%"#{keyword,jdbcType=VARCHAR}"%"
	</if>
	<if test="demandType != null">
		and  d.demand_type = #{demandType,jdbcType=INTEGER}
	</if>
	<if test="industryCategoryA != null">
		and  d.industry_category_a = #{industryCategoryA,jdbcType=INTEGER}
	</if>
	<if test="status != null">
		and  d.status = #{status,jdbcType=VARCHAR}
	</if>
	<if test="releaseStatus != null">
		and  d.release_status = #{releaseStatus,jdbcType=VARCHAR}
	</if>
	<if test="vStart != null">
	   and d.validity_period <![CDATA[ >= ]]> #{vStart,jdbcType=TIMESTAMP}
	</if>
	<if test="vEnd != null">
	   and d.validity_period <![CDATA[ < ]]> #{vEnd,jdbcType=TIMESTAMP}
	</if>
	<if test="rStart != null">
       and	d.release_date <![CDATA[ >= ]]> #{rStart,jdbcType=TIMESTAMP}
	</if>
	<if test="rEnd != null">
	   and d.release_date <![CDATA[ < ]]> #{rEnd,jdbcType=TIMESTAMP}
	</if>
  	order by d.boutique desc
  	<if test="page_sql!=null">
		${page_sql}
	</if>
  </select>
  
  <select id="findAppDemandCount" parameterType="String" resultType="java.lang.Integer">
  		select count(1)
	from  demand d 
	where d.deleted_sign = 0 
	<if test="employerId != null">
	and d.employer_id = #{employerId, jdbcType=VARCHAR}
	</if>
	<if test="serialNumber != null">
		and  d.serial_number = #{serialNumber,jdbcType=INTEGER}
	</if>
	<if test="auditStatus != null">
		and  d.audit_status = #{auditStatus,jdbcType=INTEGER}
	</if>
	<if test="industryCategoryA != null">
		and  d.industry_category_a = #{industryCategoryA,jdbcType=INTEGER}
	</if>
	<if test="name != null">
		and  d.name like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
	</if>
	<if test="keyword != null">
		and  d.keyword like "%"#{keyword,jdbcType=VARCHAR}"%"
	</if>
	<if test="demandType != null">
		and  d.demand_type = #{demandType,jdbcType=INTEGER}
	</if>
	<if test="status != null">
		and  d.status = #{status,jdbcType=VARCHAR}
	</if>
	<if test="releaseStatus != null">
		and  d.release_status = #{releaseStatus,jdbcType=VARCHAR}
	</if>
	<if test="vStart != null">
	   and d.validity_period <![CDATA[ >= ]]> #{vStart,jdbcType=TIMESTAMP}
	</if>
	<if test="vEnd != null">
	   and d.validity_period <![CDATA[ < ]]> #{vEnd,jdbcType=TIMESTAMP}
	</if>
	<if test="rStart != null">
       and	d.release_date <![CDATA[ >= ]]> #{rStart,jdbcType=TIMESTAMP}
	</if>
	<if test="rEnd != null">
	   and  d.release_date <![CDATA[ < ]]> #{rEnd,jdbcType=TIMESTAMP}
	</if>
  </select>
  
  <update id="batchDeleteByPrimaryKey" parameterType="java.util.List">
  	update demand set deleted_sign = 1
  	where  id in 
	<foreach item="item"  collection="list" open="(" separator="," close=")">
		#{item}
	</foreach>
  </update>
  
  <insert id="insertBatch" parameterType="com.goafanti.common.model.Demand">
    insert into demand 
    	(id, deleted_sign, audit_status, 
    	status, release_status, create_time, 
    	keyword, data_category, name,
    	demand_type, problem_des, employer_name,
    	employer_contacts, employer_contacts_mobile, employer_contacts_mailbox, info_sources,tech_broker_id,remark,urgent_days ,urgent_money,is_hot)
    values 
    <foreach item="item" index="index" collection="list" separator=",">
      (
      	#{item.id,jdbcType=VARCHAR}, #{item.deletedSign,jdbcType=INTEGER}, #{item.auditStatus,jdbcType=INTEGER},
      	#{item.status,jdbcType=INTEGER}, #{item.releaseStatus,jdbcType=INTEGER}, #{item.createTime,jdbcType=TIMESTAMP},
      	#{item.keyword,jdbcType=VARCHAR}, #{item.dataCategory,jdbcType=INTEGER}, #{item.name,jdbcType=VARCHAR},
      	#{item.demandType,jdbcType=INTEGER}, #{item.problemDes,jdbcType=VARCHAR}, #{item.employerName,jdbcType=VARCHAR},
      	#{item.employerContacts,jdbcType=VARCHAR}, #{item.employerContactsMobile,jdbcType=VARCHAR}, #{item.employerContactsMailbox,jdbcType=VARCHAR},
      	#{item.infoSources,jdbcType=INTEGER},#{item.techBrokerId,jdbcType=VARCHAR},#{item.remark,jdbcType=VARCHAR},,#{item.urgentDays,jdbcType=VARCHAR},#{item.urgentMoney,jdbcType=VARCHAR},#{isHot,jdbcType=INTEGER}
      )
    </foreach>
  </insert>
  
  <select id="findUserPortalDemandDetail" parameterType="java.lang.String" resultType="com.goafanti.portal.bo.DemandPortalDetailBo">
  	SELECT
		d.id,
		d.name,
		d.keyword,
		d.validity_period as validityPeriod,
		d.industry_category_a AS industryCategoryA,
		d.picture_url as pictureUrl,
		d.employer_contacts_mobile as employerContactsMobile,
		d.data_category as dataCategory,
		fg.name AS industryCategoryAS,
		fgg.name AS industryCategorBS,
		d.budget_cost AS budgetCost,
		d.problem_des AS problemDes,
		dg.name AS province,
		dgg.name AS city,
		interest.id as interestId,
		d.employer_name as employerName,
		u.lvl as level,
		d.is_hot as isHot
	FROM
		demand d
	LEFT JOIN `user` u on u.id = d.employer_id
	LEFT JOIN user_identity ui on ui.uid = d.employer_id
	LEFT JOIN district_glossory dg ON dg.id = ui.province
	LEFT JOIN district_glossory dgg ON dgg.id = ui.city
	LEFT JOIN field_glossory fg on fg.id = d.industry_category_a
	LEFT JOIN field_glossory fgg on fgg.id = d.industry_category_b
	LEFT JOIN demand_interest interest on interest.demand_id = d.id and interest.uid = #{uid,jdbcType=VARCHAR}
	WHERE
		d.id = #{id,jdbcType=VARCHAR}
  </select>
  
  <select id="findOrgPortalDemandDetail" parameterType="java.lang.String" resultType="com.goafanti.portal.bo.DemandPortalDetailBo">
  	SELECT
		d.id,
		d.name,
		d.keyword,
		d.picture_url as pictureUrl,
		d.validity_period as validityPeriod,
		d.employer_contacts_mobile as employerContactsMobile,
		d.data_category as dataCategory,
		d.industry_category_a AS industryCategoryA,
		fg.name AS industryCategoryAS,
		fgg.name AS industryCategoryBS,
		d.budget_cost AS budgetCost,
		d.problem_des AS problemDes,
		dg.name AS province,
		dgg.name AS city,
		interest.id as interestId,
		d.employer_name as employerName,
		u.lvl as level
	FROM
		demand d
	LEFT JOIN `user` u on u.id = d.employer_id
	LEFT JOIN organization_identity oi on oi.uid = d.employer_id
	LEFT JOIN district_glossory dg ON dg.id = oi.licence_province
	LEFT JOIN district_glossory dgg ON dgg.id = oi.licence_city
	LEFT JOIN field_glossory fg on fg.id = d.industry_category_a
	LEFT JOIN field_glossory fgg on fgg.id = d.industry_category_b
	LEFT JOIN demand_interest interest on interest.demand_id = d.id and interest.uid = #{uid,jdbcType=VARCHAR}
	WHERE
		d.id = #{id,jdbcType=VARCHAR}
  </select>
<select id="selectDemandListByPage" resultType="com.goafanti.demand.bo.DemandListBo">
		select
			a.id,
			a.serial_number as serialNumber,
			a.name,
			a.status,
			a.demand_type as demandType,
			a.audit_status as auditStatus,
			a.create_time as createTime,
			a.release_date as releaseDate,
			a.budget_cost as budgetCost,
			b.identify_name as employerName,
			a.is_hot as isHot,
			a.is_urgent as isUrgent
		from demand a left join user b on a.employer_id = b.id 
		where a.deleted_sign = 0
		<if test="employerId != null">
			and a.employer_id = #{employerId,jdbcType=VARCHAR}
		</if>
		<if test="startDate != null">
			and a.create_time <![CDATA[ >= ]]> #{startDate,jdbcType=TIMESTAMP}
		</if>
		<if test="endDate != null">
			and a.create_time <![CDATA[ <= ]]> #{endDate,jdbcType=TIMESTAMP}
		</if>
		<if test="name != null">
			and a.name like concat('%',#{name,jdbcType=VARCHAR},'%')
		</if>
		<if test="demandType != null">
			and a.demand_type = #{demandType,jdbcType=INTEGER}
		</if>
		<if test="auditStatus != null">
			and a.audit_status = #{auditStatus,jdbcType=INTEGER}
		</if>
		<if test="status != null">
			and a.status = #{status,jdbcType=INTEGER}
		</if>
		<if test="identifyName != null">
			and b.identify_name like concat('%',#{identifyName,jdbcType=VARCHAR},'%')
		</if>
		order by a.release_date desc
		<if test="page_sql!=null">
			${page_sql}
		</if>
	</select>
	<select id="selectDemandListCount" resultType="java.lang.Integer">
		select
			count(0)
		from demand a left join user b on a.employer_id = b.id 
		where a.deleted_sign = 0
		<if test="employerId != null">
			and a.employer_id = #{employerId,jdbcType=VARCHAR}
		</if>
		<if test="startDate != null">
			and a.create_time <![CDATA[ >= ]]> #{startDate,jdbcType=TIMESTAMP}
		</if>
		<if test="endDate != null">
			and a.create_time <![CDATA[ <= ]]> #{endDate,jdbcType=TIMESTAMP}
		</if>
		<if test="name != null">
			and a.name like concat('%',#{name,jdbcType=VARCHAR},'%')
		</if>
		<if test="demandType != null">
			and a.demand_type = #{demandType,jdbcType=INTEGER}
		</if>
		<if test="auditStatus != null">
			and a.audit_status = #{auditStatus,jdbcType=INTEGER}
		</if>
		<if test="status != null">
			and a.status = #{status,jdbcType=INTEGER}
		</if>
		<if test="identifyName != null">
			and b.identify_name like concat('%',#{identifyName,jdbcType=VARCHAR},'%')
		</if>
	</select>
  
	<select id="countInterest" resultType="Integer">
	select count(0)
	from demand_interest
	where demand_id = #{demandId,jdbcType=VARCHAR}
	</select> 
	
  <select id="findAppMyDemandListByPage" parameterType="String" resultType="com.goafanti.demand.bo.DemandListBo">
  	select 
	  d.id, d.boutique,d.name, d.audit_status as auditStatus,ifnull(t.x,0) as orderCount,
	  d.release_date as releaseDate,d.create_time as createTime,ifnull(i.y,0) as countInterest
	from  demand d 
	left join (select count(0) as x,tl.commodity_id from t_order tr
				left join t_order_detail tl on tl.order_no=tr.order_no
				where tr.order_status != 4 and tr.order_status != 0
				group by  tl.commodity_id ) t on d.id=t.commodity_id
	left join (select count(0) as y,demand_id from demand_interest
				group by demand_id ) i on d.id=i.demand_id	
	where d.deleted_sign = 0 
	<if test="employerId != null">
	and d.employer_id = #{employerId, jdbcType=VARCHAR}
	</if>
	order by d.serial_number desc
  	<if test="page_sql!=null">
		${page_sql}
	</if>
  </select>
  
  <select id="findAppMyDemandCount" parameterType="String" resultType="java.lang.Integer">
  	select count(1)
	from  demand d 
	where d.deleted_sign = 0 
	<if test="employerId != null">
		and d.employer_id = #{employerId, jdbcType=VARCHAR}
	</if>
  </select>
  
  <select id="selectDemandDetail" resultType="com.goafanti.demand.bo.DemandDetailBo" parameterType="java.lang.String" >
	select
		id,
		name,
		problem_des as problemDes,
		industry_category_a as industryCategoryA,
		industry_category_b as industryCategoryB,
		industry_category_c as industryCategoryC,
		demand_type as demandType,
		research_type as researchType,
		budget_cost as budgetCost,
		crowd_cost as crowdCost,
		is_hot as isHot,
		is_urgent as isUrgent,
		urgent_money as urgentMoney,
		urgent_days as urgentDays,
		status,
		keyword,
		picture_url as pictureUrl,
		audit_status as auditStatus,
		audit_info as auditInfo
	from
		demand
	where id = #{id,jdbcType=VARCHAR}
  </select>
 
	<select id="findAppNewsInterestByPage" parameterType="String" resultType="com.goafanti.demand.bo.ObjectInterestListBo">
  	select	n.id,n.title as name,n.create_time as createTime
	from news_interest ni
	LEFT  join news n on ni.new_id=n.id
	where ni.uid=#{uid,jdbcType=VARCHAR}
	order by createTime desc
  	<if test="page_sql!=null">
		${page_sql}
	</if>
  </select>
  
  <select id="findAppNewsInterestCount" parameterType="String" resultType="java.lang.Integer">
  		select count(1)
	from news_interest ni
	LEFT  join news n on ni.new_id=n.id
	where ni.uid=#{uid,jdbcType=VARCHAR}
	</select>
	
	<select id="findAppUserInterestByPage" parameterType="String" resultType="com.goafanti.demand.bo.ObjectInterestListBo">
  	select y.uid as id,y.username as name ,t.create_time as createTime
	from user_interest t
	left join  user_identity y on t.to_uid=y.uid
	where expert=1  
	and from_uid=#{uid,jdbcType=VARCHAR}
  	<if test="page_sql!=null">
		${page_sql}
	</if>
  </select>
  
  <select id="findAppUserInterestCount" parameterType="String" resultType="java.lang.Integer">
  	select count(1)
	from user_interest t
	left join  user_identity y on t.to_uid=y.uid
	where expert=1  
	and  from_uid=#{uid,jdbcType=VARCHAR}
	</select>
	
	<select id="findAppCounselorInterestByPage" parameterType="String" resultType="com.goafanti.demand.bo.ObjectInterestListBo">
  	select y.uid as id,y.username as name ,t.create_time as createTime
	from user_interest t
	left join  user_identity y on t.to_uid=y.uid
	where expert=2  
	and from_uid=#{uid,jdbcType=VARCHAR}
  	<if test="page_sql!=null">
		${page_sql}
	</if>
  </select>
  
  <select id="findAppCounselorInterestCount" parameterType="String" resultType="java.lang.Integer">
  	select count(1)
	from user_interest t
	left join  user_identity y on t.to_uid=y.uid
	where  expert=2  
	and from_uid=#{uid,jdbcType=VARCHAR}
	</select>
	
	<select id="findAppDemandInterestByPage"  resultType="com.goafanti.demand.bo.ObjectInterestListBo">
  	select d.id ,d.name,t.create_time as createTime
	from demand_interest t
	left join  demand d on t.demand_id=d.id
	where  t.uid=#{uid,jdbcType=VARCHAR}
  	<if test="page_sql!=null">
		${page_sql}
	</if>
  </select>
  
  <select id="findAppDemandInterestCount" parameterType="String" resultType="java.lang.Integer">
  	select count(1)
	from demand_interest t
	left join  demand d on t.demand_id=d.id
	where  uid=#{uid,jdbcType=VARCHAR}
	</select>
	
	<select id="findAppAchievementInterestByPage" parameterType="String" resultType="com.goafanti.demand.bo.ObjectInterestListBo">
  	select a.id ,a.name,t.create_time as createTime
	from achievement_interest t
	left join  achievement a on t.achievement_id=a.id
	where  t.uid=#{uid,jdbcType=VARCHAR}
  	<if test="page_sql!=null">
		${page_sql}
	</if>
  </select>
  
  <select id="findAppAchievementInterestCount" parameterType="String" resultType="java.lang.Integer">
  	select count(1)
	from achievement_interest t
	left join  achievement a on t.achievement_id=a.id
	where  t.uid=#{uid,jdbcType=VARCHAR}
	</select>
	
	<select id="findAppProjectInterestByPage" parameterType="String" resultType="com.goafanti.demand.bo.ObjectInterestListBo">
  	 select b.id ,b.bname as name,t.uid,t.create_time as createTime
	from project_interest t
	left join business_project  b on t.project_id=b.id
	where  t.uid=#{uid,jdbcType=VARCHAR}
  	<if test="page_sql!=null">
		${page_sql}
	</if>
  </select>
  
  <select id="findAppProjectInterestCount" parameterType="String" resultType="java.lang.Integer">
  	select count(1)
	from project_interest t
	left join business_project  b on t.project_id=b.id
	where  t.uid=#{uid,jdbcType=VARCHAR}
	</select>

  <select id="getAppHomeRecommended" resultType="com.goafanti.demand.bo.DemandRecommended">
	  		select dp.demand_id as id,d.name,d.demand_type as demandType,d.problem_des as introduction,d.picture_url as pictureUrl,
		d.urgent_days as urgentDays,d.urgent_money as urgentMoney,d.industry_category_a as industryCategoryA,
		d.industry_category_b as industryCategoryB,f1.name as fieldA,f2.name as fieldB,d.boutique
		from demand_publish dp 
		left join demand d on dp.demand_id = d.id
		left join field_glossory f1 on d.industry_category_a=f1.id
		left join field_glossory f2 on d.industry_category_b=f2.id
	where
		dp.publish_client = '1'
		and dp.publish_page = 'W01'
	order by
		dp.if_top,
		dp.top_number,
		dp.show_number asc limit 0,
		6
  </select>
  <select id="selectRecentDemand" resultType="com.goafanti.demand.bo.DemandListBo">
 select d.name,employer_name as employerName,d.id ,data_category as dataCategory,release_date as releaseDate,demand_type as demandType,budget_cost as budgetCost 
 ,fg.name as industryCategory1,fgg.name as industryCategory2,problem_des as problemDes
 from demand d 
     left join aft.industry_category  fg  on fg.id=d.industry_category_a
    left join aft.industry_category fgg  on fgg.id=d.industry_category_b
  left join branch_information branchInfo on INSTR(#{1},branchInfo.domain_name)>0
left join demand_publish dp on dp.demand_id=d.id and dp.publish_platform=branchInfo.id
 where audit_status=2 and info_sources=1 and dp.demand_id=d.id and dp.publish_platform=branchInfo.id  and instr(dp.publish_page,#{2})>0
 order by  release_date  desc limit #{0}
  </select>
  

   <select id="selectCompanyDemand" resultType="com.goafanti.demand.bo.DemandListBo">
 select d.name,picture_url as pictureUrl,d.id ,data_category as dataCategory
 from demand d  
   left join branch_information branchInfo on INSTR(#{1},branchInfo.domain_name)>0
left join demand_publish dp on dp.demand_id=d.id and dp.publish_platform=branchInfo.id
 where d.demand_type=0 and info_sources=1 and d.audit_status=2  and dp.demand_id=d.id and dp.publish_platform=branchInfo.id and instr(dp.publish_page,#{2})>0
  order by  release_date  desc limit #{0}
  </select>
  
  
   <select id="getUrgentDemand" resultType="com.goafanti.demand.bo.DemandListBo">
 select name,release_date as releaseDate,d.id,problem_des as problemDes,research_type as researchType,budget_cost as fundForPersonnel,crowd_cost as fundForCrowd,demand_type as demandType,
 data_category as dataCategory,validity_period as validityPeriod
  from demand d  
    left join branch_information branchInfo on INSTR(#{1},branchInfo.domain_name)>0
left join demand_publish dp on dp.demand_id=d.id and dp.publish_platform=branchInfo.id
  where d.is_urgent=1 and d.audit_status=2 and info_sources=1 and dp.demand_id=d.id and dp.publish_platform=branchInfo.id and instr(dp.publish_page,#{2})>0
   order by  release_date  desc limit #{0}
  </select>
  
  <select id="getHotDemand" resultType="com.goafanti.demand.bo.DemandListBo">
 select d.name,release_date as releaseDate,d.id,problem_des as problemDes,
 research_type as researchType,budget_cost as fundForPersonnel,crowd_cost as fundForCrowd,demand_type as demandType,
 fg.name as industryCategory1,fgg.name as industryCategory2,d.picture_url as pictureUrl,
 data_category as dataCategory,validity_period as validityPeriod
  from demand d 
      left join aft.industry_category  fg  on fg.id=d.industry_category_a
    left join aft.industry_category fgg  on fgg.id=d.industry_category_b
      left join branch_information branchInfo on INSTR(#{1},branchInfo.domain_name)>0
left join demand_publish dp on dp.demand_id=d.id and dp.publish_platform=branchInfo.id
   where d.is_hot=1 and d.audit_status=2 and info_sources=1 and dp.demand_id=d.id and dp.publish_platform=branchInfo.id and instr(dp.publish_page,#{2})>0
    order by  release_date  desc limit #{0}
  </select>
  
   <select id="getAreaDemand" resultType="com.goafanti.demand.bo.DemandListBo">
select name,picture_url as pictureUrl ,problem_des as problemDes , data_category as dataCategory,d.id from demand d 
       left join branch_information branchInfo on INSTR(#{1},branchInfo.domain_name)>0
left join demand_publish dp on dp.demand_id=d.id and dp.publish_platform=branchInfo.id
  where d.demand_type=4 and d.audit_status=2 and info_sources=1  and dp.demand_id=d.id and dp.publish_platform=branchInfo.id and instr(dp.publish_page,#{2})>0
  order by  release_date  desc limit #{0}
  </select>
  
   <select id="getProLearnStudyDemand" resultType="com.goafanti.demand.bo.DemandListBo">
    select d.name as name,picture_url as pictureUrl ,problem_des as problemDes,employer_name as employerName,d.id,fg.name as industryCategory1,data_category as dataCategory,fgg.name as industryCategory2 from demand d  
    left join aft.industry_category  fg  on fg.id=d.industry_category_a
    left join aft.industry_category fgg  on fgg.id=d.industry_category_b
           left join branch_information branchInfo on INSTR(#{1},branchInfo.domain_name)>0
left join demand_publish dp on dp.demand_id=d.id and dp.publish_platform=branchInfo.id 
 where d.demand_type=2 and d.audit_status=2 and info_sources=1  and dp.demand_id=d.id and dp.publish_platform=branchInfo.id and instr(dp.publish_page,#{2})>0
 order by  release_date  desc limit #{0}
  </select>
   <select id="getFundCrowdDemand" resultType="com.goafanti.demand.bo.DemandListBo">
  select d.name,picture_url as pictureUrl ,problem_des as problemDes ,d.id,crowd_cost as fundForCrowd,data_category as dataCategory,research_type as researchType from demand d  
             left join branch_information branchInfo on INSTR(#{1},branchInfo.domain_name)>0
left join demand_publish dp on dp.demand_id=d.id and dp.publish_platform=branchInfo.id 
  where d.demand_type=3 and d.audit_status=2 and info_sources=1 and dp.demand_id=d.id and dp.publish_platform=branchInfo.id and instr(dp.publish_page,#{2})>0
  order by  release_date 
   desc limit #{0}
  </select>
  
   <select id="getPersonnelDemand" resultType="com.goafanti.demand.bo.DemandListBo">
  select d.name,picture_url as pictureUrl ,problem_des as problemDes ,d.id,data_category as dataCategory,budget_cost as fundForPersonnel from demand d  
 left join branch_information branchInfo on INSTR(#{1},branchInfo.domain_name)>0
left join demand_publish dp on dp.demand_id=d.id and dp.publish_platform=branchInfo.id 
  where d.demand_type=5 and d.audit_status=2 and info_sources=1 and dp.demand_id=d.id and dp.publish_platform=branchInfo.id and instr(dp.publish_page,#{2})>0
  order by  release_date  desc limit #{0}
  </select>
  
 <select id="getDemandDetail" resultType="com.goafanti.demand.bo.DemandListBo">
  select d.name,d.budget_cost as budgetCost,d.validity_period as validityPeriod,data_category as dataCategory,d.picture_url as pictureUrl,problem_des as problemDes,
  fg.name as industryCategory1,fgg.name as industryCategory2
   from demand d
  left join aft.industry_category  fg  on fg.id=d.industry_category_a
    left join aft.industry_category fgg  on fgg.id=d.industry_category_b
    where d.id=#{0}
  </select>
  <select id="getBoutiqueDemandList" resultType="com.goafanti.demand.bo.DemandListBo">
 select d.id,d.name,picture_url as picture_url,data_category as dataCategory,problem_des as problemDes
 from demand d
 left join branch_information branchInfo on INSTR(#{1},branchInfo.domain_name)>0
left join demand_publish dp on dp.demand_id=d.id and dp.publish_platform=branchInfo.id 
where info_sources=1 and d.boutique=1 and  dp.demand_id=d.id and dp.publish_platform=branchInfo.id and instr(dp.publish_page,#{2})>0
order by release_date desc limit #{0}
  </select> 
  
  <select id="listMyDemand" resultType="com.goafanti.portal.bo.DemandSearchListBo">
	select
		id,
		serial_number as serialNumber,
		name,
		demand_type as demandType,
		audit_status as auditStatus,
		create_time as createTime
	from
		demand
	where
		info_sources=1 and
		employer_id = #{uid,jdbcType=VARCHAR}
	<if test="status != null">
		and status = #{status,jdbcType=INTEGER}
	</if>
	<if test="name != null">
		and name = #{name,jdbcType=VARCHAR}
	</if>
	<if test="startDate != null">
		and create_time <![CDATA[ > ]]>  #{startDate,jdbcType=VARCHAR}
	</if>
	<if test="endDate != null">
		and create_time <![CDATA[ < ]]>  #{endDate,jdbcType=VARCHAR}
	</if>
  </select>
  
    <select id="searchDemandList" resultType="com.goafanti.demand.bo.DemandListBo">
  select a.name,a.id,create_time as createTime ,picture_url as pictureUrl,data_category as dataCategory,is_hot as isHot,demand_type as demandType,
  industry_category_a as industryCategoryA,industry_category_b as industryCategoryB,ic.name as industryCategory1,icc.name as industryCategory2
   from demand a
  left join industry_category ic on ic.id=a.industry_category_a
  left join industry_category icc on icc.id=a.industry_category_b
  where info_sources=1 and audit_status=2
  <if test="industryCategoryA!=null">
 and a.industry_category_a =#{industryCategoryA,jdbcType=INTEGER}
  </if>
  <if test="industryCategoryB!=null">
  and a.industry_category_b=#{industryCategoryB,jdbcType=INTEGER}
  </if>
  <if test="name !=null">
  and a.name like concat("%",#{name,jdbcType=VARCHAR},"%")
  </if>
  order by a.release_date
  <if test="page_sql !=null">
  	${page_sql}
  </if>
  </select>
      <select id="searchDemandCount" resultType="java.lang.Integer">
  select count(0) from demand a
  where info_sources=1 and audit_status=2
  <if test="industryCategoryA!=null">
 and a.industry_category_a =#{industryCategoryA,jdbcType=INTEGER}
  </if>
  <if test="industryCategoryB!=null">
  and a.industry_category_b=#{industryCategoryB,jdbcType=INTEGER}
  </if>
  <if test="name !=null">
  and a.name like concat("%",#{name,jdbcType=VARCHAR},"%")
  </if>
  </select>
  </mapper>