finance3-SysClientInfoMapper

<?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.chinasoft.mybatis.dao.SysClientInfoMapper">
  <resultMap id="BaseResultMap" type="SysClientInfo">
    <!--
      WARNING - @mbg.generated
    -->
    <id column="id" jdbcType="BIGINT" property="id"/>
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="phone" jdbcType="VARCHAR" property="phone" />
    <result column="client_expense" jdbcType="DOUBLE" property="clientExpense" />
    <result column="contract_money" jdbcType="DOUBLE" property="contractMoney" />
    <result column="contract_number" jdbcType="INTEGER" property="contractNumber" />
    <result column="create_name" jdbcType="VARCHAR" property="createName" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  </resultMap>

  <select id="selectClientInfo" resultType="SysClientInfo">
      SELECT
      sc.id ,
      sc.name,
      sc.phone,
      sc.create_name,
      sc.create_time,
      conex.*
      FROM sys_client AS sc
      LEFT JOIN
      (select
      cl.*,
      ex.client_name,
      ex.client_expense
      from
      (select
      sum(con.money) AS contract_money,
      con.associated_customers,
      COUNT(con.associated_customers) AS contract_number
      from
      sys_contract as con
      GROUP BY con.associated_customers) as cl
      left JOIN
      (select
      client_name ,
      sum(expense) AS client_expense
      from sys_client_expense
      GROUP BY client_name) as ex
      on cl.associated_customers=ex.client_name) as conex
      on sc.name = conex.associated_customers
        <where>
          <if test="clientInfo.getName()!=''">
            sc.name LIKE CONCAT('%',#{clientInfo.name},'%')
          </if>
          <if test="clientInfo.getCreateName()!=''">
            OR sc.create_name LIKE CONCAT('%',#{clientInfo.name},'%')
          </if>
          <if test="clientInfo.getName()!=''">
            OR sc.phone LIKE CONCAT('%',#{clientInfo.name},'%')
          </if>
        </where>
    ORDER BY
    sc.id
    DESC
  </select>


</mapper>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值