|
@@ -1,704 +0,0 @@
|
|
|
-<?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.iamberry.rst.service.customer.mapper.CustomerBasicMapper" >
|
|
|
- <select id="listCustomerBasic" resultType="CustomerBasicInfo" parameterType="CustomerBasicInfo">
|
|
|
- SELECT
|
|
|
- bi.customer_id customerId,
|
|
|
- bi.customer_name customerName,
|
|
|
- bi.customer_industry customerIndustry,
|
|
|
- bi.customer_type customerType,
|
|
|
- bi.cooperative_state cooperativeState,
|
|
|
- bi.customer_province_code customerProvinceCode,
|
|
|
- bi.customer_city_code customerCityCode,
|
|
|
- bi.customer_address customerAddress,
|
|
|
- bi.customer_status customerStatus,
|
|
|
- bi.create_date createDate,
|
|
|
- bi.update_date updateDate,
|
|
|
- bi.id_create_by idCreateBy,
|
|
|
- bi.customer_remarks customerRemarks,
|
|
|
- sa.admin_name adminName,
|
|
|
- ap.province provinceName,
|
|
|
- ac.city cityName
|
|
|
- from tb_rst_customer_basic_info bi
|
|
|
- LEFT JOIN tb_rst_sys_admin sa on bi.id_create_by = sa.admin_id
|
|
|
- LEFT JOIN tb_rst_address_province ap on ap.division_code = bi.customer_province_code
|
|
|
- LEFT JOIN tb_rst_address_city ac on ac.division_code = bi.customer_city_code
|
|
|
- LEFT JOIN tb_rst_docked_contact_info ci on ci.customer_id = bi.customer_id
|
|
|
- <where>
|
|
|
- <if test="customerName != null and customerName!='' ">
|
|
|
- bi.customer_name like CONCAT('%',#{customerName},'%')
|
|
|
- </if>
|
|
|
- <if test="customerIndustry != null and customerIndustry!='' ">
|
|
|
- AND bi.customer_industry = #{customerIndustry}
|
|
|
- </if>
|
|
|
- <if test="customerType != null and customerType!='' ">
|
|
|
- AND bi.customer_type = #{customerType}
|
|
|
- </if>
|
|
|
- <if test="cooperativeState != null and cooperativeState!='' ">
|
|
|
- AND bi.cooperative_state = #{cooperativeState}
|
|
|
- </if>
|
|
|
- <if test="customerProvinceCode != null and customerProvinceCode!='' ">
|
|
|
- AND bi.customer_province_code = #{customerProvinceCode}
|
|
|
- </if>
|
|
|
- <if test="customerCityCode != null and customerCityCode!='' ">
|
|
|
- AND bi.customer_city_code = #{customerCityCode}
|
|
|
- </if>
|
|
|
- <if test="customerAddress != null and customerAddress!='' ">
|
|
|
- AND bi.customer_address = #{customerAddress}
|
|
|
- </if>
|
|
|
- <if test="customerStatus != null and customerStatus!='' ">
|
|
|
- AND bi.customer_status = #{customerStatus}
|
|
|
- </if>
|
|
|
- <if test="isLookAll != null and isLookAll!='' and isLookAll == 2 ">
|
|
|
- AND bi.id_create_by = #{idCreateBy}
|
|
|
- </if>
|
|
|
- <if test="contactPhone != null and contactPhone!='' ">
|
|
|
- AND ci.contact_phone = #{contactPhone}
|
|
|
- </if>
|
|
|
- <if test="contactName != null and contactName!='' ">
|
|
|
- AND ci.contact_name = #{contactName}
|
|
|
- </if>
|
|
|
- <if test="contactEmail != null and contactEmail!='' ">
|
|
|
- AND ci.contact_email = #{contactEmail}
|
|
|
- </if>
|
|
|
- <if test="isSelectAll != null and isSelectAll == 2 ">
|
|
|
- AND bi.customer_status = #{isSelectAll}
|
|
|
- </if>
|
|
|
- </where>
|
|
|
- GROUP BY bi.customer_id
|
|
|
- ORDER BY bi.create_date DESC
|
|
|
- </select>
|
|
|
-
|
|
|
-
|
|
|
- <select id="getCustomerBasic" resultType="CustomerBasicInfo" parameterType="CustomerBasicInfo">
|
|
|
- SELECT
|
|
|
- bi.customer_id customerId,
|
|
|
- bi.customer_name customerName,
|
|
|
- bi.customer_industry customerIndustry,
|
|
|
- bi.customer_type customerType,
|
|
|
- bi.cooperative_state cooperativeState,
|
|
|
- bi.customer_province_code customerProvinceCode,
|
|
|
- bi.customer_city_code customerCityCode,
|
|
|
- bi.customer_address customerAddress,
|
|
|
- bi.customer_status customerStatus,
|
|
|
- bi.create_date createDate,
|
|
|
- bi.update_date updateDate,
|
|
|
- bi.id_create_by idCreateBy,
|
|
|
- bi.customer_remarks customerRemarks,
|
|
|
- ap.province provinceName,
|
|
|
- ac.city cityName
|
|
|
- from tb_rst_customer_basic_info bi
|
|
|
- LEFT JOIN tb_rst_address_province ap on ap.division_code = bi.customer_province_code
|
|
|
- LEFT JOIN tb_rst_address_city ac on ac.division_code = bi.customer_city_code
|
|
|
- <where>
|
|
|
- <if test="customerId != null and customerId!='' ">
|
|
|
- bi.customer_id = #{customerId}
|
|
|
- </if>
|
|
|
- </where>
|
|
|
- </select>
|
|
|
-
|
|
|
- <update id="updateState" parameterType="CustomerBasicInfo">
|
|
|
- UPDATE tb_rst_customer_basic_info
|
|
|
- <set >
|
|
|
- <if test="customerStatus != null" >
|
|
|
- customer_status = #{customerStatus,jdbcType=INTEGER}
|
|
|
- </if>
|
|
|
- </set>
|
|
|
- where customer_id = #{customerId,jdbcType=INTEGER}
|
|
|
- </update>
|
|
|
-
|
|
|
-
|
|
|
- <select id="getBillingInfo" resultType="BillingInfo" parameterType="BillingInfo">
|
|
|
- SELECT
|
|
|
- billing_id as billingId,
|
|
|
- customer_id as customerId,
|
|
|
- account_opening_branch as accountOpeningBranch,
|
|
|
- account_name as accountName,
|
|
|
- account_num as accountNum,
|
|
|
- receivables_name as receivablesName,
|
|
|
- receivables_phone as receivablesPhone,
|
|
|
- create_date as createDate,
|
|
|
- account_type as accountType
|
|
|
- from tb_rst_billing_info
|
|
|
- <where>
|
|
|
- <if test="customerId != null and customerId !='' ">
|
|
|
- customer_id = #{customerId}
|
|
|
- </if>
|
|
|
- </where>
|
|
|
- </select>
|
|
|
-
|
|
|
- <select id="getOpeningInfo" resultType="TicketOpeningInfo" parameterType="TicketOpeningInfo">
|
|
|
- SELECT
|
|
|
- ticket_opening_id as ticketOpeningId,
|
|
|
- customer_id as customerId,
|
|
|
- ticket_type as ticketType,
|
|
|
- account_opening_branch as accountOpeningBranch,
|
|
|
- ticket_opening_account as ticketOpeningAccount,
|
|
|
- enterprise_name as enterpriseName,
|
|
|
- taxpayer_identification_num as taxpayerIdentificationNum,
|
|
|
- ticket_opening_phone as ticketOpeningPhone,
|
|
|
- enterprise_address as enterpriseAddress,
|
|
|
- create_date as createDate
|
|
|
- from tb_rst_ticket_opening_info
|
|
|
- <where>
|
|
|
- <if test="customerId != null and customerId !='' ">
|
|
|
- customer_id = #{customerId}
|
|
|
- </if>
|
|
|
- </where>
|
|
|
- </select>
|
|
|
-
|
|
|
- <select id="listDockedContactInfo" resultType="DockedContactInfo" parameterType="DockedContactInfo">
|
|
|
- SELECT
|
|
|
- docked_contact_id as dockedContactId,
|
|
|
- customer_id as customerId,
|
|
|
- contact_name as contactName,
|
|
|
- contact_phone as contactPhone,
|
|
|
- contact_type as contactType,
|
|
|
- contact_email as contactEmail,
|
|
|
- create_date as createDate
|
|
|
- from tb_rst_docked_contact_info
|
|
|
- <where>
|
|
|
- <if test="customerId != null and customerId !='' ">
|
|
|
- customer_id = #{customerId}
|
|
|
- </if>
|
|
|
- </where>
|
|
|
- </select>
|
|
|
-
|
|
|
- <select id="listChannelSaleInfo" resultType="ChannelSaleInfo" parameterType="ChannelSaleInfo">
|
|
|
- SELECT
|
|
|
- si.channel_sale_id as channelSaleId,
|
|
|
- si.customer_id as customerId,
|
|
|
- si.channel_division_id as channelDivisionId,
|
|
|
- si.promoting_products as promotingProducts,
|
|
|
- si.supply_price as supplyPrice,
|
|
|
- si.account_period as account_period,
|
|
|
- si.create_date as createDate,
|
|
|
- di.channel_category as channelCategory,
|
|
|
- di.channel_type as channelType,
|
|
|
- di.channel_name as channelName
|
|
|
- from tb_rst_channel_sale_info si
|
|
|
- LEFT JOIN tb_rst_channel_division_info di ON si.channel_division_id = di.channel_division_id
|
|
|
- where
|
|
|
- si.customer_id = #{customerId}
|
|
|
- </select>
|
|
|
-
|
|
|
- <resultMap type="ChannelDivisionInfo" id="listChannelDivisionMap">
|
|
|
- <id property="channelDivisionId" column="channel_division_id"/>
|
|
|
- <result property="channelCategory" column="channel_category" />
|
|
|
- <result property="channelType" column="channel_type" />
|
|
|
- <result property="channelName" column="channel_name" />
|
|
|
- <result property="channelCode" column="channel_code" />
|
|
|
- <result property="receivablesPhone" column="receivables_phone" />
|
|
|
- <result property="createDate" column="create_date" />
|
|
|
- <collection property="listChannelSaleInfo" column="channel_division_id" ofType="ChannelDivisionInfo" select="listSaleInfoByChannelDivisionId"/>
|
|
|
- </resultMap>
|
|
|
- <select id="listChannelDivisionInfo" resultMap="listChannelDivisionMap" parameterType="ChannelDivisionInfo">
|
|
|
- SELECT
|
|
|
- channel_division_id,
|
|
|
- channel_category,
|
|
|
- channel_type,
|
|
|
- channel_name,
|
|
|
- channel_code,
|
|
|
- create_date
|
|
|
- FROM tb_rst_channel_division_info
|
|
|
- WHERE
|
|
|
- customer_id = #{customerId}
|
|
|
- </select>
|
|
|
- <select id="listSaleInfoByChannelDivisionId" resultType="ChannelSaleInfo" parameterType="java.lang.Integer">
|
|
|
- SELECT
|
|
|
- si.channel_sale_id AS channelSaleId,
|
|
|
- si.customer_id AS customerId,
|
|
|
- si.channel_division_id AS channelDivisionId,
|
|
|
- si.promoting_products AS promotingProducts,
|
|
|
- si.supply_price AS supplyPrice,
|
|
|
- si.account_period AS account_period,
|
|
|
- si.create_date AS createDate
|
|
|
- FROM
|
|
|
- tb_rst_channel_sale_info si
|
|
|
- WHERE
|
|
|
- si.channel_division_id= #{channelDivisionId}
|
|
|
- </select>
|
|
|
-
|
|
|
-
|
|
|
- <!--映射结果集 start-->
|
|
|
- <!--客户基本信息结果映射-->
|
|
|
- <resultMap type="com.iamberry.rst.core.customer.CustomerBasicInfo" id="customerBasicInfoResult">
|
|
|
- <id property="customerId" column="customer_id"/>
|
|
|
- <result property="customerName" column="customer_name" />
|
|
|
- <result property="customerIndustry" column="customer_industry" />
|
|
|
- <result property="customerType" column="customer_type" />
|
|
|
- <result property="cooperativeState" column="cooperative_state" />
|
|
|
- <result property="customerProvinceCode" column="customer_province_code" />
|
|
|
- <result property="customerCityCode" column="customer_city_code" />
|
|
|
- <result property="customerAddress" column="customer_address" />
|
|
|
- <result property="customerStatus" column="customer_status" />
|
|
|
- <result property="createDate" column="create_date" />
|
|
|
- <result property="updateDate" column="update_date" />
|
|
|
- <result property="idCreateBy" column="id_create_by" />
|
|
|
- <result property="customerRemarks" column="customer_remarks" />
|
|
|
- </resultMap>
|
|
|
- <!--对接联系人信息结果映射-->
|
|
|
- <resultMap type="com.iamberry.rst.core.customer.DockedContactInfo" id="dockedContactInfoResult">
|
|
|
- <id property="dockedContactId" column="docked_contact_id"/>
|
|
|
- <result property="contactName" column="contact_name" />
|
|
|
- <result property="contactPhone" column="contact_phone" />
|
|
|
- <result property="contactType" column="contact_type" />
|
|
|
- <result property="contactEmail" column="contact_email" />
|
|
|
- <result property="createDate" column="create_date" />
|
|
|
- </resultMap>
|
|
|
- <!--客户渠道销售信息结果映射-->
|
|
|
- <resultMap type="com.iamberry.rst.core.customer.ChannelSaleInfo" id="channelSaleInfoResult">
|
|
|
- <id property="channelSaleId" column="channel_sale_id"/>
|
|
|
- <result property="channelName" column="channel_name" />
|
|
|
- <result property="channelDivisionId" column="channel_division_id" />
|
|
|
- <result property="promotingProducts" column="promoting_products" />
|
|
|
- <result property="supplyPrice" column="supply_price" />
|
|
|
- <result property="accountPeriod" column="account_period" />
|
|
|
- <result property="createDate" column="create_date" />
|
|
|
- </resultMap>
|
|
|
- <!--付款/退款信息结果映射-->
|
|
|
- <resultMap type="com.iamberry.rst.core.customer.BillingInfo" id="billingInfoResult">
|
|
|
- <id property="billingId" column="billing_id"/>
|
|
|
- <result property="accountOpeningBranch" column="account_opening_branch" />
|
|
|
- <result property="accountName" column="account_name" />
|
|
|
- <result property="accountNum" column="account_num" />
|
|
|
- <result property="receivablesName" column="receivables_name" />
|
|
|
- <result property="receivablesPhone" column="receivables_phone" />
|
|
|
- <result property="createDate" column="create_date" />
|
|
|
- </resultMap>
|
|
|
- <!--开票信息结果映射-->
|
|
|
- <resultMap type="com.iamberry.rst.core.customer.TicketOpeningInfo" id="ticketOpeningInfoResult">
|
|
|
- <id property="ticketOpeningId" column="ticket_opening_id"/>
|
|
|
- <result property="ticketType" column="ticket_type" />
|
|
|
- <result property="accountOpeningBranch" column="account_opening_branch" />
|
|
|
- <result property="ticketOpeningAccount" column="ticket_opening_account" />
|
|
|
- <result property="enterpriseName" column="enterprise_name" />
|
|
|
- <result property="taxpayerIdentificationNum" column="taxpayer_identification_num" />
|
|
|
- <result property="ticketOpeningPhone" column="ticket_opening_phone" />
|
|
|
- <result property="enterpriseAddress" column="enterprise_address" />
|
|
|
- <result property="createDate" column="create_date" />
|
|
|
- </resultMap>
|
|
|
- <!--查询所有省份映射-->
|
|
|
- <resultMap type="com.iamberry.rst.core.address.Province" id="queryProvinceResult">
|
|
|
- <id property="provinceId" column="province_id"/>
|
|
|
- <!--<result property="provinceNum" column="divisionCode" />-->
|
|
|
- <result property="province" column="province" />
|
|
|
- </resultMap>
|
|
|
- <!--根据省份代号查询所有城市映射-->
|
|
|
- <resultMap type="com.iamberry.rst.core.address.City" id="queryCityResult">
|
|
|
- <id property="cityId" column="city_id"/>
|
|
|
- <!--<result property="cityNum" column="city_number" />-->
|
|
|
- <result property="city" column="city" />
|
|
|
- <!--<result property="provinceNum" column="provinceid" />-->
|
|
|
- </resultMap>
|
|
|
- <!--根据城市代号查询所有区/县映射-->
|
|
|
- <resultMap type="com.iamberry.rst.core.address.District" id="queryDistrictResult">
|
|
|
- <id property="districtId" column="district_id"/>
|
|
|
- <!--<result property="cityNum" column="city_number" />-->
|
|
|
- <result property="district" column="district" />
|
|
|
- <!--<result property="provinceNum" column="provinceid" />-->
|
|
|
- </resultMap>
|
|
|
- <!--查询所有渠道类别-->
|
|
|
- <resultMap type="com.iamberry.rst.core.customer.ChannelDivisionInfo" id="queryChannelCategoryResult">
|
|
|
- <result property="channelCategory" column="channel_category" />
|
|
|
- <result property="channelName" column="channel_categoryId" />
|
|
|
- </resultMap>
|
|
|
- <!--根据渠道类别查询渠道类型-->
|
|
|
- <resultMap type="com.iamberry.rst.core.customer.ChannelDivisionInfo" id="queryChannelTypeResult">
|
|
|
- <!--<id property="channelDivisionId" column="channel_division_id"/>-->
|
|
|
- <result property="channelType" column="channel_type" />
|
|
|
- <result property="channelName" column="channel_categoryId" />
|
|
|
- </resultMap>
|
|
|
- <!--查询销售产品-->
|
|
|
- <resultMap type="com.iamberry.rst.core.order.Product" id="queryPromotingProductsResult">
|
|
|
- <id property="productId" column="product_id"/>
|
|
|
- <result property="productName" column="product_name" />
|
|
|
- </resultMap>
|
|
|
- <!--查询销售产品价格-->
|
|
|
- <resultMap type="com.iamberry.rst.core.order.ProductColor" id="querySupplyPriceResult">
|
|
|
- <result property="colorId" column="supply_product_id" />
|
|
|
- <result property="colorPrice" column="supply_product_price" />
|
|
|
- </resultMap>
|
|
|
- <!--映射结果集 end-->
|
|
|
-
|
|
|
- <!--新增部分 start-->
|
|
|
- <!-- 添加客户基本信息 -->
|
|
|
- <insert id="saveCustomerBasicInfo" parameterType="CustomerBasicInfo" useGeneratedKeys="true" keyProperty="customerId">
|
|
|
- INSERT INTO
|
|
|
- tb_rst_customer_basic_info
|
|
|
- (
|
|
|
- customer_name, customer_industry, customer_type, cooperative_state, customer_province_code,customer_city_code,
|
|
|
- customer_address, customer_status, create_date, update_date,id_create_by,customer_remarks
|
|
|
- )
|
|
|
- VALUES
|
|
|
- (
|
|
|
- #{customerName},#{customerIndustry},#{customerType},#{cooperativeState},#{customerProvinceCode},#{customerCityCode},
|
|
|
- #{customerAddress},#{customerStatus},NOW(),NOW(),#{idCreateBy},#{customerRemarks}
|
|
|
- )
|
|
|
- </insert>
|
|
|
-
|
|
|
- <!-- 添加对接联系人信息 -->
|
|
|
- <insert id="saveDockedContactInfo" parameterType="DockedContactInfo">
|
|
|
- INSERT INTO
|
|
|
- tb_rst_docked_contact_info
|
|
|
- (
|
|
|
- customer_id, contact_name, contact_phone, contact_type, contact_email,create_date
|
|
|
- )
|
|
|
- VALUES
|
|
|
- (
|
|
|
- #{customerId},#{contactName},#{contactPhone},#{contactType},#{contactEmail},NOW()
|
|
|
- )
|
|
|
- </insert>
|
|
|
-
|
|
|
- <!-- 添加客户销售渠道备案信息(渠道表) -->
|
|
|
- <insert id="saveChannelDivisionInfo" parameterType="ChannelSaleInfo" useGeneratedKeys="true" keyProperty="channelDivisionId">
|
|
|
- INSERT INTO
|
|
|
- tb_rst_channel_division_info
|
|
|
- (
|
|
|
- customer_id, channel_category, channel_type, channel_name, channel_code,create_date
|
|
|
- )
|
|
|
- VALUES
|
|
|
- (
|
|
|
- #{customerId},#{channelCategory},#{channelType},#{channelName},#{channelCode},NOW()
|
|
|
- )
|
|
|
- </insert>
|
|
|
-
|
|
|
- <!-- 添加客户销售渠道备案信息(产品表) -->
|
|
|
- <insert id="saveChannelSaleInfo" parameterType="ChannelSaleInfo">
|
|
|
- INSERT INTO
|
|
|
- tb_rst_channel_sale_info
|
|
|
- (
|
|
|
- customer_id, channel_division_id, channel_name, promoting_products, supply_price,account_period,create_date
|
|
|
- )
|
|
|
- VALUES
|
|
|
- (
|
|
|
- #{customerId},#{channelDivisionId},#{channelName},#{promotingProducts},#{supplyPrice},#{accountPeriod},NOW()
|
|
|
- )
|
|
|
- </insert>
|
|
|
-
|
|
|
- <!-- 添加付款/退款信息 -->
|
|
|
- <insert id="saveBillingInfo" parameterType="BillingInfo">
|
|
|
- INSERT INTO
|
|
|
- tb_rst_billing_info
|
|
|
- (
|
|
|
- customer_id, account_opening_branch, account_name, account_num, receivables_name,receivables_phone,create_date,account_type
|
|
|
- )
|
|
|
- VALUES
|
|
|
- (
|
|
|
- #{customerId},#{accountOpeningBranch},#{accountName},#{accountNum},#{receivablesName},#{receivablesPhone},NOW(),#{accountType}
|
|
|
- )
|
|
|
- </insert>
|
|
|
-
|
|
|
- <!-- 添加对开票信息 -->
|
|
|
- <insert id="saveTicketOpeningInfo" parameterType="TicketOpeningInfo">
|
|
|
- INSERT INTO
|
|
|
- tb_rst_ticket_opening_info
|
|
|
- (
|
|
|
- customer_id, ticket_type, account_opening_branch, ticket_opening_account, enterprise_name,
|
|
|
- taxpayer_identification_num,ticket_opening_phone, enterprise_address, create_date
|
|
|
- )
|
|
|
- VALUES
|
|
|
- (
|
|
|
- #{customerId},#{ticketType},#{accountOpeningBranch},#{ticketOpeningAccount},#{enterpriseName},
|
|
|
- #{taxpayerIdentificationNum},#{ticketOpeningPhone},#{enterpriseAddress},NOW()
|
|
|
- )
|
|
|
- </insert>
|
|
|
- <!--新增部分 end-->
|
|
|
-
|
|
|
- <!--查询客户信息部分 start-->
|
|
|
- <!-- 根据客户id查询客户基本信息 -->
|
|
|
- <select id="queryCustomerBasicInfoByCustomerId" parameterType="Integer" resultMap="customerBasicInfoResult">
|
|
|
- SELECT * FROM tb_rst_customer_basic_info t WHERE t.customer_id = #{id}
|
|
|
- </select>
|
|
|
- <!-- 根据客户id查询对接联系人信息 -->
|
|
|
- <select id="queryDockedContactInfoListByCustomerId" parameterType="Integer" resultMap="dockedContactInfoResult">
|
|
|
- SELECT
|
|
|
- t.docked_contact_id,
|
|
|
- t.contact_name,
|
|
|
- t.contact_phone,
|
|
|
- t.contact_type,
|
|
|
- t.contact_email,
|
|
|
- t.create_date
|
|
|
- FROM
|
|
|
- tb_rst_docked_contact_info t
|
|
|
- WHERE
|
|
|
- t.customer_id = #{id}
|
|
|
- </select>
|
|
|
- <!-- 根据客户id查询客户销售渠道备案信息 -->
|
|
|
- <!--查询渠道名称是否存在-->
|
|
|
- <select id="queryIsExsitChannelNameChannelName" parameterType="ChannelSaleInfo" resultType="java.lang.String">
|
|
|
- SELECT
|
|
|
- IFNULL(max(t.channel_division_id),0)
|
|
|
- FROM
|
|
|
- tb_rst_channel_division_info t
|
|
|
- WHERE
|
|
|
- t.channel_name = #{channelName}
|
|
|
- AND
|
|
|
- t.channel_category = #{channelCategory}
|
|
|
- AND
|
|
|
- t.channel_type = #{channelType}
|
|
|
- AND
|
|
|
- t.customer_id = #{customerId}
|
|
|
- </select>
|
|
|
- <select id="queryChannelSaleInfoListByCustomerId" parameterType="Integer" resultMap="channelSaleInfoResult">
|
|
|
- SELECT
|
|
|
- t.channel_sale_id,
|
|
|
- t.channel_name,
|
|
|
- t.channel_division_id,
|
|
|
- t.promoting_products,
|
|
|
- t.supply_price,
|
|
|
- t.account_period,
|
|
|
- t.create_date
|
|
|
- FROM
|
|
|
- tb_rst_channel_sale_info t
|
|
|
- WHERE
|
|
|
- t.customer_id = #{id}
|
|
|
- </select>
|
|
|
- <!-- 根据客户id查询客户付款/退款信息 -->
|
|
|
- <select id="queryBillingInfoByCustomerId" parameterType="Integer" resultMap="billingInfoResult">
|
|
|
- SELECT
|
|
|
- t.billing_id,
|
|
|
- t.account_opening_branch,
|
|
|
- t.account_name,
|
|
|
- t.account_num,
|
|
|
- t.receivables_name,
|
|
|
- t.receivables_phone,
|
|
|
- t.create_date,
|
|
|
- t.account_type
|
|
|
- FROM
|
|
|
- tb_rst_billing_info t
|
|
|
- WHERE
|
|
|
- t.customer_id = #{id}
|
|
|
- </select>
|
|
|
- <!-- 根据客户id查询客户开票信息 -->
|
|
|
- <select id="queryTicketOpeningInfoByCustomerId" parameterType="Integer" resultMap="ticketOpeningInfoResult">
|
|
|
- SELECT
|
|
|
- t.ticket_opening_id,
|
|
|
- t.ticket_type,
|
|
|
- t.account_opening_branch,
|
|
|
- t.ticket_opening_account,
|
|
|
- t.enterprise_name,
|
|
|
- t.taxpayer_identification_num,
|
|
|
- t.ticket_opening_phone,
|
|
|
- t.enterprise_address,
|
|
|
- t.create_date
|
|
|
- FROM
|
|
|
- tb_rst_ticket_opening_info t
|
|
|
- WHERE
|
|
|
- t.customer_id = #{id}
|
|
|
- </select>
|
|
|
- <!--查询客户信息部分 end-->
|
|
|
- <!--查询所有省份-->
|
|
|
- <select id="queryProvinceList" parameterType="java.lang.String" resultMap="queryProvinceResult">
|
|
|
- SELECT
|
|
|
- t.province_id,
|
|
|
- t.province,
|
|
|
- t.division_code
|
|
|
- FROM
|
|
|
- tb_rst_address_province t
|
|
|
- ORDER BY
|
|
|
- t.province_id ASC
|
|
|
- </select>
|
|
|
- <!--根据省份代号查询所有城市-->
|
|
|
- <select id="queryCityList" parameterType="java.lang.String" resultMap="queryCityResult">
|
|
|
- SELECT
|
|
|
- t.city_id,
|
|
|
- t.city,
|
|
|
- t.division_code
|
|
|
- FROM
|
|
|
- tb_rst_address_city t
|
|
|
- WHERE
|
|
|
- t.province_id = #{id}
|
|
|
- ORDER BY
|
|
|
- t.city_id ASC
|
|
|
- </select>
|
|
|
- <!--根据省份代号查询所有区/县-->
|
|
|
- <select id="queryDistrictList" parameterType="java.lang.String" resultMap="queryDistrictResult">
|
|
|
- SELECT
|
|
|
- t.district_id,
|
|
|
- t.district,
|
|
|
- t.division_code
|
|
|
- FROM
|
|
|
- tb_rst_address_district t
|
|
|
- WHERE
|
|
|
- t.city_id = #{id}
|
|
|
- ORDER BY
|
|
|
- t.district_id ASC
|
|
|
- </select>
|
|
|
- <!--查询所有渠道类别-->
|
|
|
- <select id="queryChannelCategoryList" parameterType="java.lang.String" resultMap="queryChannelCategoryResult">
|
|
|
- SELECT
|
|
|
- DISTINCT (t.channel_category),
|
|
|
- CASE
|
|
|
- WHEN t.channel_category = 1 THEN '电商'
|
|
|
- WHEN t.channel_category = 2 THEN '特殊渠道'
|
|
|
- WHEN t.channel_category = 3 THEN '线下'
|
|
|
- WHEN t.channel_category = 4 THEN '海外'
|
|
|
- END AS 'channel_categoryId'
|
|
|
- FROM
|
|
|
- tb_rst_channel_division_info t
|
|
|
- ORDER BY
|
|
|
- t.channel_division_id ASC
|
|
|
- </select>
|
|
|
- <!--根据渠道类别查询渠道类型-->
|
|
|
- <select id="queryChannelTypeList" parameterType="java.lang.String" resultMap="queryChannelTypeResult">
|
|
|
- SELECT
|
|
|
- /*t.channel_division_id,*/
|
|
|
- DISTINCT (t.channel_type),
|
|
|
- CASE
|
|
|
- WHEN t.channel_category = 1 THEN '电商'
|
|
|
- WHEN t.channel_category = 2 THEN '特殊渠道'
|
|
|
- WHEN t.channel_category = 3 THEN '线下'
|
|
|
- ELSE '海外'
|
|
|
- END AS 'channel_categoryId'
|
|
|
- FROM
|
|
|
- tb_rst_channel_division_info t
|
|
|
- WHERE
|
|
|
- t.channel_category = #{id}
|
|
|
- ORDER BY
|
|
|
- t.channel_division_id ASC
|
|
|
- </select>
|
|
|
- <!--查询销售产品-->
|
|
|
- <select id="queryPromotingProductsList" parameterType="java.lang.String" resultMap="queryPromotingProductsResult">
|
|
|
- SELECT
|
|
|
- t.product_id,
|
|
|
- t.product_name
|
|
|
- FROM
|
|
|
- tb_rst_product_info t
|
|
|
- WHERE
|
|
|
- t.product_wholesale = '1'
|
|
|
- ORDER BY
|
|
|
- t.product_id ASC
|
|
|
- </select>
|
|
|
- <!--查询销售产品价格-->
|
|
|
- <!-- /*SELECT
|
|
|
- t.color_id,
|
|
|
- t.color_price
|
|
|
- FROM
|
|
|
- tb_rst_product_color t
|
|
|
- WHERE
|
|
|
- t.color_product_id = #{id}
|
|
|
- ORDER BY
|
|
|
- t.color_id ASC*/-->
|
|
|
- <select id="querySupplyPriceList" parameterType="java.lang.String" resultMap="querySupplyPriceResult">
|
|
|
- SELECT
|
|
|
- t.supply_product_id,
|
|
|
- t.supply_product_price
|
|
|
- FROM
|
|
|
- tb_rst_supply_product_info t
|
|
|
- WHERE
|
|
|
- t.supply_product_id = #{id}
|
|
|
- AND
|
|
|
- t.supply_price_status = '1'
|
|
|
- ORDER BY
|
|
|
- t.supply_product_id ASC
|
|
|
- </select>
|
|
|
-
|
|
|
- <update id="updateCustomerBasic" parameterType="CustomerBasicInfo">
|
|
|
- UPDATE tb_rst_customer_basic_info
|
|
|
- <set >
|
|
|
- <if test="customerName != null and customerName !='' " >
|
|
|
- customer_name = #{customerName},
|
|
|
- </if>
|
|
|
- <if test="customerIndustry != null and customerIndustry !='' " >
|
|
|
- customer_industry = #{customerIndustry},
|
|
|
- </if>
|
|
|
- <if test="customerType != null and customerType !='' " >
|
|
|
- customer_type = #{customerType},
|
|
|
- </if>
|
|
|
- <if test="cooperativeState != null and cooperativeState !='' " >
|
|
|
- cooperative_state = #{cooperativeState},
|
|
|
- </if>
|
|
|
- <if test="customerProvinceCode != null and customerProvinceCode !='' " >
|
|
|
- customer_province_code = #{customerProvinceCode},
|
|
|
- </if>
|
|
|
- <if test="customerCityCode != null and customerCityCode !='' " >
|
|
|
- customer_city_code = #{customerCityCode},
|
|
|
- </if>
|
|
|
- <if test="customerAddress != null and customerAddress !='' " >
|
|
|
- customer_address = #{customerAddress},
|
|
|
- </if>
|
|
|
- <if test="customerStatus != null and customerStatus !='' " >
|
|
|
- customer_status = #{customerStatus},
|
|
|
- </if>
|
|
|
- <if test="updateDate != null and updateDate !='' " >
|
|
|
- update_date = #{updateDate},
|
|
|
- </if>
|
|
|
- <if test="customerRemarks != null and customerRemarks !='' " >
|
|
|
- customer_remarks = #{customerRemarks}
|
|
|
- </if>
|
|
|
- </set>
|
|
|
- where customer_id = #{customerId}
|
|
|
- </update>
|
|
|
-
|
|
|
- <update id="updateBillingInfo" parameterType="BillingInfo">
|
|
|
- UPDATE tb_rst_billing_info
|
|
|
- <set >
|
|
|
- <if test="accountOpeningBranch != null and accountOpeningBranch !='' " >
|
|
|
- account_opening_branch = #{accountOpeningBranch},
|
|
|
- </if>
|
|
|
- <if test="accountName != null and accountName !='' " >
|
|
|
- account_name = #{accountName},
|
|
|
- </if>
|
|
|
- <if test="accountNum != null and accountNum !='' " >
|
|
|
- account_num = #{accountNum},
|
|
|
- </if>
|
|
|
- <if test="receivablesName != null and receivablesName !='' " >
|
|
|
- receivables_name = #{receivablesName},
|
|
|
- </if>
|
|
|
- <if test="receivablesPhone != null and receivablesPhone !='' " >
|
|
|
- receivables_phone = #{receivablesPhone},
|
|
|
- </if>
|
|
|
- <if test="accountType != null and accountType !='' " >
|
|
|
- account_type = #{accountType}
|
|
|
- </if>
|
|
|
- </set>
|
|
|
- where customer_id = #{customerId}
|
|
|
- </update>
|
|
|
-
|
|
|
- <update id="updateOpeningInfo" parameterType="TicketOpeningInfo">
|
|
|
- UPDATE tb_rst_ticket_opening_info
|
|
|
- <set>
|
|
|
- <if test="ticketType != null and ticketType !='' " >
|
|
|
- ticket_type = #{ticketType},
|
|
|
- </if>
|
|
|
- <if test="accountOpeningBranch != null and accountOpeningBranch !='' " >
|
|
|
- account_opening_branch = #{accountOpeningBranch},
|
|
|
- </if>
|
|
|
- <if test="ticketOpeningAccount != null and ticketOpeningAccount !='' " >
|
|
|
- ticket_opening_account = #{ticketOpeningAccount},
|
|
|
- </if>
|
|
|
- <if test="enterpriseName != null and enterpriseName !='' " >
|
|
|
- enterprise_name = #{enterpriseName},
|
|
|
- </if>
|
|
|
- <if test="taxpayerIdentificationNum != null and taxpayerIdentificationNum !='' " >
|
|
|
- taxpayer_identification_num = #{taxpayerIdentificationNum},
|
|
|
- </if>
|
|
|
- <if test="ticketOpeningPhone != null and ticketOpeningPhone !='' " >
|
|
|
- ticket_opening_phone = #{ticketOpeningPhone},
|
|
|
- </if>
|
|
|
- <if test="enterpriseAddress != null and enterpriseAddress !='' " >
|
|
|
- enterprise_address = #{enterpriseAddress}
|
|
|
- </if>
|
|
|
- </set>
|
|
|
- where customer_id = #{customerId}
|
|
|
- </update>
|
|
|
-
|
|
|
- <delete id="deleteContactInfo" parameterType="Integer">
|
|
|
- DELETE FROM tb_rst_docked_contact_info WHERE customer_id = #{customerId}
|
|
|
- </delete>
|
|
|
- <delete id="deleteSaleInfo" parameterType="Integer">
|
|
|
- DELETE FROM tb_rst_channel_sale_info WHERE customer_id = #{customerId}
|
|
|
- </delete>
|
|
|
- <delete id="deleteDivisionInfo" parameterType="Integer">
|
|
|
- DELETE FROM tb_rst_channel_division_info WHERE channel_division_id = #{channelDivisionId}
|
|
|
- </delete>
|
|
|
-
|
|
|
- <select id="getLowestPrice" parameterType="LowestPriceInfo" resultType="LowestPriceInfo">
|
|
|
- select * from tb_rst_lowest_price_info
|
|
|
- where
|
|
|
- product_id = #{productId}
|
|
|
- AND
|
|
|
- channel_division_id = #{channelDivisionId}
|
|
|
- </select>
|
|
|
-</mapper>
|