<?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.ruoyi.oa.mapper.OaBusinessMapper">

    <resultMap type="com.ruoyi.oa.domain.OaBusiness" id="OaBusinessResult">
        <result property="businessId" column="business_id"/>
        <result property="name" column="name"/>
        <result property="customerId" column="customer_id"/>
        <result property="followUpStatus" column="follow_up_status"/>
        <result property="contactLastTime" column="contact_last_time"/>
        <result property="contactNextTime" column="contact_next_time"/>
        <result property="ownerUserId" column="owner_user_id"/>
        <result property="statusTypeId" column="status_type_id"/>
        <result property="statusId" column="status_id"/>
        <result property="endStatus" column="end_status"/>
        <result property="dealTime" column="deal_time"/>
        <result property="totalProductPrice" column="total_product_price"/>
        <result property="discountPercent" column="discount_percent"/>
        <result property="totalPrice" column="total_price"/>
        <result property="remark" column="remark"/>
        <result property="createBy" column="create_by"/>
        <result property="updateBy" column="update_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
        <result property="endRemark" column="end_remark"/>
        <result property="delFlag" column="del_flag"/>
    </resultMap>
    <update id="setFollow">
        update oa_business set follow_up_status = 1 where business_id=#{businessId}
    </update>

    <delete id="deleteBusinessById">
        delete from oa_business where
       business_id=#{businessId}
    </delete>


    <select id="getBusinessProducts" resultType="com.ruoyi.oa.domain.vo.OaProductVo">
        select op.product_id, op.product_name, op.product_number, op.unit, op.price, op.status, op.category_id, op.description, op.del_flag
        from oa_business ob
        left join oa_business_product obp on ob.business_id = obp.business_id
        left join oa_product op on obp.product_id = op.product_id
            ${ew.getCustomSqlSegment}
    </select>

    <select id="getBusinessByCustomerId" resultType="com.ruoyi.oa.domain.vo.OaBusinessVo">
        select * from oa_business
         <where >
             customerId=#{customerId}
         </where>
    </select>


</mapper>
