You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
3.7 KiB

<?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.daqing.financial.crms.dao.CustomerAppletDao">
<insert id="saveCustomerIdAndUserId">
INSERT INTO crms_customer_user (customer_id, user_id, type) VALUES (#{customerId}, #{userId}, #{type})
</insert>
<select id="getCustomerStatus" resultType="integer">
SELECT COUNT(cu.id) FROM crms_customer_user AS cu
INNER JOIN crms_customer AS c
ON cu.customer_id = c.id
WHERE c.del_or_not = 0
AND cu.user_id = #{userId} AND cu.type = #{type}
</select>
<select id="getCustomerId" resultType="integer">
SELECT cu.customer_id FROM crms_customer_user AS cu
INNER JOIN crms_customer AS c
ON cu.customer_id = c.id
WHERE c.del_or_not = 0
AND cu.user_id = #{userId} AND cu.type = #{type}
</select>
<!-- 更新客户基本信息 -->
<update id="updateCustomer" parameterType="com.daqing.framework.domain.crms.CustomerEntity">
UPDATE crms_customer
SET name = #{customer.name},addr = #{customer.addr},phone = #{customer.phone},motify_time = #{customer.motifyTime}
WHERE id = #{customer.id}
</update>
<!-- 获取企业类型客户的id -->
<select id="getCompanyId" parameterType="integer" resultType="integer">
SELECT id FROM crms_company_customer WHERE customer_id = #{customerId}
</select>
<!-- 申请记录 -->
<select id="getApplicationRecord" resultType="com.daqing.framework.domain.crms.ext.ApplicationRecordPO">
SELECT l.id AS id,a.create_time AS apply_date,a.amount_wide AS amount_wide,a.apply_time AS apply_time,l.status AS audit_status,
a.apply_amount AS apply_amount,b.business_status AS business_status
FROM dg_apply_amount_info AS a
LEFT JOIN dg_business_process_status AS b
ON a.id = b.business_id
LEFT JOIN dg_apply_amount_list AS l
ON l.business_id = a.id
WHERE a.company_id = #{companyId}
<if test="status == null or (status != 0 and status != 1 and status != 2 and status != 3 and status != 4 and status != 5)">
AND (b.business_status = 2 OR l.status IN (1,2,3,4,5))
</if>
<if test="status == 0">
AND b.business_status = 2
</if>
<if test="status == 1 or status == 2 or status == 3 or status == 4 or status == 5">
AND l.status = #{status}
</if>
AND l.role_id = 58
</select>
<!-- 获取已申请成功的额度 -->
<select id="getApplyMount" parameterType="integer" resultType="com.daqing.framework.domain.crms.ext.ApplicationRecordPO">
SELECT a.apply_amount AS apply_amount
FROM dg_apply_amount_info AS a
LEFT JOIN dg_business_process_status AS b
ON a.id = b.business_id
WHERE a.company_id = #{companyId}
AND b.business_status = 2
</select>
<select id="businessUnderwayCount" parameterType="integer" resultType="integer">
SELECT COUNT(a.id)
FROM dg_apply_amount_info AS a
INNER JOIN dg_business_process_status AS b
ON a.id = b.business_id
WHERE a.company_id = #{companyId}
AND b.business_status = 1
</select>
<!-- 获取申请记录详情 -->
<select id="getApplyDetail" parameterType="integer" resultType="com.daqing.framework.domain.crms.ext.ApplyDetailPO">
SELECT l.status AS audit_status,l.apply_content AS remark,b.business_status AS business_status
FROM dg_apply_amount_list AS l
LEFT JOIN dg_business_process_status AS b
ON l.business_id = b.business_id
WHERE l.id = #{id}
</select>
</mapper>