From bc8ab2ccb801ece9f2638098e8acd07f3ef1978d Mon Sep 17 00:00:00 2001 From: zhubaomin <zhubaomin> Date: 星期五, 30 八月 2024 20:35:09 +0800 Subject: [PATCH] 2024-08-30 朱宝民 解决获取水卡列表接口错误,无虚拟卡时不显示空对象 --- pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeClientCardMapper.xml | 1225 +++++++++++++++++++++++++++++---------------------------- 1 files changed, 625 insertions(+), 600 deletions(-) diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeClientCardMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeClientCardMapper.xml index d34f935..c947dc6 100644 --- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeClientCardMapper.xml +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeClientCardMapper.xml @@ -1,628 +1,653 @@ <?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.dy.pipIrrGlobal.daoSe.SeClientCardMapper"> - <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoSe.SeClientCard"> - <!--@mbg.generated--> - <!--@Table se_client_card--> - <id column="id" jdbcType="BIGINT" property="id" /> - <result column="protocol" jdbcType="VARCHAR" property="protocol" /> - <result column="cardAddr" jdbcType="VARCHAR" property="cardaddr" /> - <result column="cardNum" jdbcType="BIGINT" property="cardnum" /> - <result column="clientId" jdbcType="BIGINT" property="clientid" /> - <result column="money" jdbcType="FLOAT" property="money" /> - <result column="state" jdbcType="TINYINT" property="state" /> - <result column="original_card_id" jdbcType="BIGINT" property="originalCardId"/> - <result column="createDt" jdbcType="TIMESTAMP" property="createdt" /> - <result column="replaceDt" jdbcType="TIMESTAMP" property="replacedt" /> - <result column="rechargeDt" jdbcType="TIMESTAMP" property="rechargedt" /> - <result column="lossDtDt" jdbcType="TIMESTAMP" property="lossdtdt" /> - <result column="cancelDt" jdbcType="TIMESTAMP" property="canceldt" /> - <result column="unlockDt" jdbcType="TIMESTAMP" property="unlockdt" /> - <result column="reversalDt" jdbcType="TIMESTAMP" property="reversaldt" /> - <result column="refundDt" jdbcType="TIMESTAMP" property="refunddt" /> - <result column="consumeDt" jdbcType="TIMESTAMP" property="consumedt" /> - <result column="lastOper" jdbcType="TINYINT" property="lastoper" /> - <result column="remarks" jdbcType="VARCHAR" property="remarks" /> - </resultMap> - <sql id="Base_Column_List"> - <!--@mbg.generated--> - id, protocol, cardAddr, cardNum, clientId, money, `state`, original_card_id, createDt, replaceDt, rechargeDt, - lossDtDt, cancelDt, unlockDt, reversalDt, refundDt, consumeDt, lastOper, remarks - </sql> - <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> - <!--@mbg.generated--> - select - <include refid="Base_Column_List" /> - from se_client_card - where id = #{id,jdbcType=BIGINT} - </select> - <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> - <!--@mbg.generated--> - delete from se_client_card - where id = #{id,jdbcType=BIGINT} - </delete> - - <!--渚濇嵁姘村崱鍦板潃鑾峰彇姘村崱缂栧彿锛�12鏈�19鏃ュ簾寮冿級--> - <select id="getCardIdByAddr" resultType="java.lang.Long"> - SELECT id AS cardId FROM se_client_card WHERE cardAddr = #{cardAddr} - </select> - - <!--鏍规嵁姘村崱缂栧彿鑾峰彇姘村崱琛ㄤ富閿紙12鏈�19鏃ユ坊鍔犲悗搴熷純锛�--> - <select id="getCardIdByNum" resultType="java.lang.Long"> - SELECT id AS cardId FROM se_client_card WHERE cardNum = #{cardNum} - </select> - - <!--鏍规嵁姘村崱缂栧彿鑾峰彇姘村崱琛ㄤ富閿強鍐滄埛缂栧彿--> - <select id="getCardIdAndClientNum" resultType="java.util.Map"> - <!-- SELECT id AS cardId, clientNum FROM se_client_card WHERE cardNum = #{cardNum}--> - SELECT - card.id AS cardId, - cli.clientNum, - cli.id AS clientId, - protocol - FROM se_client_card card - INNER JOIN se_client cli ON card.clientId = cli.id - WHERE card.cardNum = #{cardNum} - </select> - - <!-- 鏍规嵁姘村崱缂栧彿鑾峰彇姘村崱瀵瑰簲鐨勫啘鎴穒d鍜屽鍚� --> - <select id="getClientIdAndNameByCardAddrAndCardNo" resultType="java.util.Map"> - SELECT - cli.id AS clientId, - cli.name AS clientName - FROM se_client_card card - INNER JOIN se_client cli ON card.clientId = cli.id - WHERE card.cardAddr = #{cardAddr} and card.cardNum = #{cardNum} - </select> - - - <!-- 鏍规嵁姘村崱缂栧彿鑾峰彇姘村崱 --> - <select id="getCardsByAddrAndNum" resultType="com.dy.pipIrrGlobal.voSe.VoCardInfo1"> - SELECT - id, - money - FROM se_client_card - WHERE cardAddr = #{cardAddr} and cardNum = #{cardNum} - </select> - - <!--鏍规嵁琛屾斂鍖哄垝涓叉ā绯婃煡璇㈡按鍗$紪鍙�--> - <select id="getCardNumOfMax" resultType="java.lang.String"> - SELECT cardNum - FROM se_client_card - WHERE cardNum LIKE CONCAT(#{areaCode},'%') - ORDER BY cardNum desc - LIMIT 0,1 - </select> - - <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.dy.pipIrrGlobal.pojoSe.SeClientCard"> - <!--@mbg.generated--> - insert into se_client_card (id, protocol, cardAddr, cardNum, clientId, - money, `state`, original_card_id, createDt, - replaceDt, rechargeDt, lossDtDt, - cancelDt, unlockDt, reversalDt, refundDt, - consumeDt, lastOper, remarks - ) - values (#{id,jdbcType=BIGINT}, #{protocol,jdbcType=VARCHAR}, #{cardaddr,jdbcType=VARCHAR}, #{cardnum,jdbcType=BIGINT}, #{clientid,jdbcType=BIGINT}, - #{money,jdbcType=FLOAT}, #{state,jdbcType=TINYINT}, #{originalCardId,jdbcType=BIGINT}, #{createdt,jdbcType=TIMESTAMP}, - #{replacedt,jdbcType=TIMESTAMP}, #{rechargedt,jdbcType=TIMESTAMP}, #{lossdtdt,jdbcType=TIMESTAMP}, - #{canceldt,jdbcType=TIMESTAMP}, #{unlockdt,jdbcType=TIMESTAMP}, #{reversaldt,jdbcType=TIMESTAMP}, - #{refunddt,jdbcType=TIMESTAMP}, #{consumedt,jdbcType=TIMESTAMP}, #{lastoper,jdbcType=TINYINT}, #{remarks,jdbcType=VARCHAR} - ) - - </insert> - <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.dy.pipIrrGlobal.pojoSe.SeClientCard" useGeneratedKeys="true"> - <!--@mbg.generated--> - insert into se_client_card - <trim prefix="(" suffix=")" suffixOverrides=","> - <if test="id != null"> + <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoSe.SeClientCard"> + <!--@mbg.generated--> + <!--@Table se_client_card--> + <id column="id" jdbcType="BIGINT" property="id"/> + <result column="protocol" jdbcType="VARCHAR" property="protocol"/> + <result column="cardAddr" jdbcType="VARCHAR" property="cardaddr"/> + <result column="cardNum" jdbcType="BIGINT" property="cardnum"/> + <result column="clientId" jdbcType="BIGINT" property="clientid"/> + <result column="money" jdbcType="FLOAT" property="money"/> + <result column="state" jdbcType="TINYINT" property="state"/> + <result column="original_card_id" jdbcType="BIGINT" property="originalCardId"/> + <result column="createDt" jdbcType="TIMESTAMP" property="createdt"/> + <result column="replaceDt" jdbcType="TIMESTAMP" property="replacedt"/> + <result column="rechargeDt" jdbcType="TIMESTAMP" property="rechargedt"/> + <result column="lossDtDt" jdbcType="TIMESTAMP" property="lossdtdt"/> + <result column="cancelDt" jdbcType="TIMESTAMP" property="canceldt"/> + <result column="unlockDt" jdbcType="TIMESTAMP" property="unlockdt"/> + <result column="reversalDt" jdbcType="TIMESTAMP" property="reversaldt"/> + <result column="refundDt" jdbcType="TIMESTAMP" property="refunddt"/> + <result column="consumeDt" jdbcType="TIMESTAMP" property="consumedt"/> + <result column="lastOper" jdbcType="TINYINT" property="lastoper"/> + <result column="remarks" jdbcType="VARCHAR" property="remarks"/> + </resultMap> + <sql id="Base_Column_List"> + <!--@mbg.generated--> id, - </if> - <if test="protocol != null"> protocol, - </if> - <if test="cardaddr != null"> cardAddr, - </if> - <if test="cardnum != null"> cardNum, - </if> - <if test="clientid != null"> clientId, - </if> - <if test="money != null"> money, - </if> - <if test="state != null"> `state`, - </if> - <if test="originalCardId != null"> original_card_id, - </if> - <if test="createdt != null"> createDt, - </if> - <if test="replacedt != null"> replaceDt, - </if> - <if test="rechargedt != null"> rechargeDt, - </if> - <if test="lossdtdt != null"> lossDtDt, - </if> - <if test="canceldt != null"> cancelDt, - </if> - <if test="unlockdt != null"> unlockDt, - </if> - <if test="reversaldt != null"> reversalDt, - </if> - <if test="refunddt != null"> refundDt, - </if> - <if test="consumedt != null"> consumeDt, - </if> - <if test="lastoper != null"> lastOper, - </if> - <if test="remarks != null"> - remarks, - </if> - </trim> - <trim prefix="values (" suffix=")" suffixOverrides=","> - <if test="id != null"> - #{id,jdbcType=BIGINT}, - </if> - <if test="protocol != null"> - #{protocol,jdbcType=VARCHAR}, - </if> - <if test="cardaddr != null"> - #{cardaddr,jdbcType=VARCHAR}, - </if> - <if test="cardnum != null"> - #{cardnum,jdbcType=BIGINT}, - </if> - <if test="clientid != null"> - #{clientid,jdbcType=BIGINT}, - </if> - <if test="money != null"> - #{money,jdbcType=FLOAT}, - </if> - <if test="state != null"> - #{state,jdbcType=TINYINT}, - </if> - <if test="originalCardId != null"> - #{originalCardId,jdbcType=BIGINT}, - </if> - <if test="createdt != null"> - #{createdt,jdbcType=TIMESTAMP}, - </if> - <if test="replacedt != null"> - #{replacedt,jdbcType=TIMESTAMP}, - </if> - <if test="rechargedt != null"> - #{rechargedt,jdbcType=TIMESTAMP}, - </if> - <if test="lossdtdt != null"> - #{lossdtdt,jdbcType=TIMESTAMP}, - </if> - <if test="canceldt != null"> - #{canceldt,jdbcType=TIMESTAMP}, - </if> - <if test="unlockdt != null"> - #{unlockdt,jdbcType=TIMESTAMP}, - </if> - <if test="reversaldt != null"> - #{reversaldt,jdbcType=TIMESTAMP}, - </if> - <if test="refunddt != null"> - #{refunddt,jdbcType=TIMESTAMP}, - </if> - <if test="consumedt != null"> - #{consumedt,jdbcType=TIMESTAMP}, - </if> - <if test="lastoper != null"> - #{lastoper,jdbcType=TINYINT}, - </if> - <if test="remarks != null"> - #{remarks,jdbcType=VARCHAR}, - </if> - </trim> - </insert> - <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoSe.SeClientCard"> - <!--@mbg.generated--> - update se_client_card - <set> - <if test="protocol != null"> - protocol = #{protocol,jdbcType=VARCHAR}, - </if> - <if test="cardaddr != null"> - cardAddr = #{cardaddr,jdbcType=VARCHAR}, - </if> - <if test="cardnum != null"> - cardNum = #{cardnum,jdbcType=BIGINT}, - </if> - <if test="clientid != null"> - clientId = #{clientid,jdbcType=BIGINT}, - </if> - <if test="money != null"> - money = #{money,jdbcType=FLOAT}, - </if> - <if test="state != null"> - `state` = #{state,jdbcType=TINYINT}, - </if> - <if test="originalCardId != null"> - `original_card_id` = #{originalCardId,jdbcType=BIGINT}, - </if> - <if test="createdt != null"> - createDt = #{createdt,jdbcType=TIMESTAMP}, - </if> - <if test="replacedt != null"> - replaceDt = #{replacedt,jdbcType=TIMESTAMP}, - </if> - <if test="rechargedt != null"> - rechargeDt = #{rechargedt,jdbcType=TIMESTAMP}, - </if> - <if test="lossdtdt != null"> - lossDtDt = #{lossdtdt,jdbcType=TIMESTAMP}, - </if> - <if test="canceldt != null"> - cancelDt = #{canceldt,jdbcType=TIMESTAMP}, - </if> - <if test="unlockdt != null"> - unlockDt = #{unlockdt,jdbcType=TIMESTAMP}, - </if> - <if test="reversaldt != null"> - reversalDt = #{reversaldt,jdbcType=TIMESTAMP}, - </if> - <if test="refunddt != null"> - refundDt = #{refunddt,jdbcType=TIMESTAMP}, - </if> - <if test="consumedt != null"> - consumeDt = #{consumedt,jdbcType=TIMESTAMP}, - </if> - <if test="lastoper != null"> - lastOper = #{lastoper,jdbcType=TINYINT}, - </if> - <if test="remarks != null"> - remarks = #{remarks,jdbcType=VARCHAR}, - </if> - </set> - where id = #{id,jdbcType=BIGINT} - </update> - <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoSe.SeClientCard"> - <!--@mbg.generated--> - update se_client_card - set protocol = #{protocol,jdbcType=VARCHAR}, - cardAddr = #{cardaddr,jdbcType=VARCHAR}, - cardNum = #{cardnum,jdbcType=BIGINT}, - clientId = #{clientid,jdbcType=BIGINT}, - money = #{money,jdbcType=FLOAT}, - `state` = #{state,jdbcType=TINYINT}, - original_card_id = #{originalCardId,jdbcType=BIGINT}, - createDt = #{createdt,jdbcType=TIMESTAMP}, - replaceDt = #{replacedt,jdbcType=TIMESTAMP}, - rechargeDt = #{rechargedt,jdbcType=TIMESTAMP}, - lossDtDt = #{lossdtdt,jdbcType=TIMESTAMP}, - cancelDt = #{canceldt,jdbcType=TIMESTAMP}, - unlockDt = #{unlockdt,jdbcType=TIMESTAMP}, - reversalDt = #{reversaldt,jdbcType=TIMESTAMP}, - refundDt = #{refunddt,jdbcType=TIMESTAMP}, - consumeDt = #{consumedt,jdbcType=TIMESTAMP}, - lastOper = #{lastoper,jdbcType=TINYINT}, - remarks = #{remarks,jdbcType=VARCHAR} - where id = #{id,jdbcType=BIGINT} - </update> - <update id="updateMoney" > - update se_client_card - set money = #{money,jdbcType=FLOAT} - where id = #{id,jdbcType=BIGINT} - </update> - <!--鏍规嵁鍐滄埛涓婚敭鑾峰彇姘村崱鍒楄〃锛堢墿鐞嗗崱+铏氭嫙鍗★級--> - <select id="getCardInfoByClientId" resultType="com.dy.pipIrrGlobal.voSe.VoCardInfo"> - SELECT - * - FROM - (SELECT - '鐗╃悊鍗�' AS cardType, - clientCard.cardNum AS CardNum, - clientCard.money AS Money, - (CASE - WHEN clientCard.state = 1 THEN '姝e父' - WHEN clientCard.state = 2 THEN '宸叉敞閿�' - ELSE '宸叉寕澶�' - END) AS State - FROM se_client client - LEFT JOIN se_client_card clientCard ON clientCard.clientId = client.id - WHERE client.id = #{clientId,jdbcType=BIGINT} - UNION ALL - SELECT - '铏氭嫙鍗�' AS cardType, - virtualCard.vc_num AS CardNum, - virtualCard.money AS vcMoney, - (CASE - WHEN virtualCard.in_use = 0 THEN '鏈娇鐢�' - WHEN virtualCard.in_use = 1 THEN '浣跨敤涓�' - END) AS State - FROM se_client client - LEFT JOIN se_virtual_card virtualCard ON client.id = virtualCard.client_id - WHERE client.id = #{clientId,jdbcType=BIGINT} - ) card - ORDER BY card.Money DESC , card.State DESC - </select> - - <!--鏍规嵁姘村崱缂栧彿鑾峰彇鎿嶄綔璁板綍鍒楄〃--> - <select id="getOperateRecordsByCardNum" resultType="java.util.HashMap"> - SELECT * FROM v_operate WHERE cardNum = #{cardNum,jdbcType=BIGINT} - </select> - - <!--鏍规嵁姘村崱缂栧彿鑾峰彇浣欓--> - <select id="getMoneyByCardNum" resultType="java.lang.Float"> - SELECT money FROM se_client_card WHERE cardNum = #{cardNum,jdbcType=BIGINT} - </select> - - <!--鏍规嵁姘村崱缂栧彿鑾峰彇鍏呭�兼�婚--> - <select id="sumRechargeByCardNum" resultType="java.lang.Float"> - SELECT - SUM(his.amount) AS amount - FROM se_recharge_history his - INNER JOIN se_client_card card ON his.cardId = card.id - WHERE card.cardNum = #{cardNum,jdbcType=BIGINT} - </select> - - <!--鏍规嵁姘村崱缂栧彿鑾峰彇鍗$墖鐘舵�侊細1-寮�鍗★紝2-琛ュ崱锛�3-鍏呭�硷紝4-鎸傚け锛�5-娉ㄩ攢锛�6-瑙i攣锛�7-鍐叉锛�8-娑堣垂--> - <select id="getCardStateByCardNum" resultType="java.lang.String"> -<!-- SELECT--> -<!-- (CASE--> -<!-- WHEN lastOper = 1 THEN "寮�鍗�"--> -<!-- WHEN lastOper = 2 THEN "琛ュ崱"--> -<!-- WHEN lastOper = 3 THEN "鍏呭��"--> -<!-- WHEN lastOper = 4 THEN "鎸傚け"--> -<!-- WHEN lastOper = 5 THEN "娉ㄩ攢"--> -<!-- WHEN lastOper = 6 THEN "瑙i攣"--> -<!-- WHEN lastOper = 7 THEN "鍐叉"--> -<!-- WHEN lastOper = 8 THEN "娑堣垂"--> -<!-- END) AS stateName--> -<!-- FROM se_client_card--> -<!-- WHERE cardNum = ${cardNum}--> - SELECT - (CASE - WHEN state = 1 THEN '姝e父' - WHEN state = 2 THEN '宸叉敞閿�' - WHEN state = 3 THEN '宸叉寕澶�' - END) AS stateName - FROM se_client_card - WHERE cardNum = #{cardNum,jdbcType=BIGINT} - </select> - - <!--鏍规嵁鎸囧畾鏉′欢鑾峰彇姘村崱鍒楄〃璁板綍鏁帮紝搴旂敤绋嬪簭浣跨敤--> - <select id="getCardsCount" parameterType="java.util.Map" resultType="java.lang.Long"> - SELECT - COUNT(*) AS recordCount - FROM se_client_card card - INNER JOIN se_client cli ON card.clientId = cli.id - <where> - AND card.state = 1 - <if test = "clientNum != null and clientNum !=''"> - AND cli.clientNum like CONCAT('%',#{clientNum},'%') - </if> - - <if test = "clientName != null and clientName !=''"> - AND cli.name like CONCAT('%',#{clientName},'%') - </if> - - <if test = "cardNum != null and cardNum !=''"> - AND card.cardNum like CONCAT('%',#{cardNum},'%') - </if> - </where> - </select> - - <!--鏍规嵁鎸囧畾鏉′欢鑾峰彇姘村崱鍒楄〃锛屽簲鐢ㄧ▼搴忎娇鐢�--> - <select id="getCards" resultType="com.dy.pipIrrGlobal.voSe.VoCards"> - SELECT - cli.clientNum, - cli.name AS clientName, - cardNum, -<!-- CASE--> -<!-- WHEN card.cardNum LIKE '10%' THEN CONCAT(SUBSTRING(card.cardNum, 7, 6),SUBSTRING(card.cardNum, 14, 4))--> -<!-- ELSE card.cardNum--> -<!-- END AS cardNum,--> - cli.phone, - cli.idCard, - card.state AS cardState, -<!-- (CASE--> -<!-- WHEN card.state = 1 THEN '姝e父'--> -<!-- WHEN card.state = 2 THEN '宸叉敞閿�'--> -<!-- WHEN card.state = 3 THEN '宸叉寕澶�'--> -<!-- End) AS stateName,--> - '姝e父' AS stateName, - '鍐滄埛鍗�' AS cardType, - FORMAT(card.money, 2) AS money - FROM se_client_card card - INNER JOIN se_client cli ON card.clientId = cli.id - <where> - AND card.state = 1 - <if test = "clientNum != null and clientNum !=''"> - AND cli.clientNum like CONCAT('%',#{clientNum},'%') - </if> - - <if test = "clientName != null and clientName !=''"> - AND cli.name like CONCAT('%',#{clientName},'%') - </if> - - <if test = "cardNum != null and cardNum !=''"> - AND card.cardNum like CONCAT('%',#{cardNum},'%') - </if> - </where> - ORDER BY card.id - <trim prefix="limit " > - <if test="start != null and count != null"> - #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} - </if> - </trim> - </select> - - <!--鑾峰彇宸叉寕澶辨湭琛ュ崱鐨勮褰曟暟閲�--> - <select id="getUnreplacedRecordCount" resultType="java.lang.Long"> - SELECT - COUNT(*) AS recordCount - FROM se_client_card card - INNER JOIN se_client cli ON card.clientId = cli.id - WHERE card.state = 3 AND NOT EXISTS (SELECT * FROM se_client_card card2 WHERE card2.original_card_id = card.cardNum) - </select> - - <!--鑾峰彇宸叉寕澶辨湭琛ュ崱鐨勮褰�--> - <select id="getUnreplaced" resultType="com.dy.pipIrrGlobal.voSe.VoCards"> - SELECT - cli.clientNum, - cli.name AS clientName, - cardNum, -<!-- CASE--> -<!-- WHEN card.cardNum LIKE '10%' THEN CONCAT(SUBSTRING(card.cardNum, 7, 6),SUBSTRING(card.cardNum, 14, 4))--> -<!-- ELSE card.cardNum--> -<!-- END AS cardNum,--> - cli.phone, - cli.idCard, - card.state AS cardState, - '宸叉寕澶�' AS stateName, - '鍐滄埛鍗�' AS cardType, - FORMAT(card.money,2) AS money - FROM se_client_card card - INNER JOIN se_client cli ON card.clientId = cli.id - WHERE card.state = 3 AND NOT EXISTS (SELECT * FROM se_client_card card2 WHERE card2.original_card_id = card.id) - ORDER BY card.id - <trim prefix="limit " > - <if test="start != null and count != null"> - #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} - </if> - </trim> - </select> - - <!--鏍规嵁鎸囧畾姘村崱缂栧彿鑾峰彇鎸傚け浜嬭褰曟暟閲忥紙琛ュ崱銆佽В閿佷娇鐢級--> - <select id="getLostCount" resultType="java.lang.Integer"> - SELECT - COUNT(*) AS recordCount - FROM se_client_card card - <where> - AND card.state = 3 - <if test = "cardNum != null and cardNum > 0"> - AND card.cardNum = #{cardNum} - </if> - </where> - </select> - - <!--鏍规嵁鎸囧畾姘村崱缂栧彿鑾峰彇宸茶ˉ鍗℃暟閲忥紙琛ュ崱銆佽В閿佷娇鐢級--> - <select id="getReplacedCount" resultType="java.lang.Integer"> - SELECT - COUNT(*) AS recordCount - FROM se_client_card card - INNER JOIN se_client_card card2 ON card2.original_card_id = card.id - <where> - <if test = "cardNum != null and cardNum > 0"> - AND card.cardNum = #{cardNum} - </if> - </where> - </select> - <!--鏍规嵁鍐滄埛濮撳悕鍜屾墜鏈哄彿鑾峰彇姘村崱鍒楄〃璁板綍鏁帮紝搴旂敤绋嬪簭浣跨敤--> - <select id="getCardsByClientNameAndPhoneCount" resultType="java.lang.Long"> - SELECT - COUNT(*) AS recordCount - FROM se_client_card card - INNER JOIN se_client cli ON card.clientId = cli.id - <where> - card.state = 1 - <if test = "clientName != null and clientName !=''"> - AND cli.name like CONCAT('%',#{clientName},'%') - </if> - - <if test = "phone != null and phone !=''"> - AND cli.phone like CONCAT('%',#{phone},'%') - </if> - </where> + remarks + </sql> + <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> + <!--@mbg.generated--> + select + <include refid="Base_Column_List"/> + from se_client_card + where id = #{id,jdbcType=BIGINT} </select> - <!--鏍规嵁鍐滄埛濮撳悕鍜屾墜鏈哄彿鑾峰彇姘村崱鍒楄〃锛屽簲鐢ㄧ▼搴忎娇鐢�--> - <select id="getCardsByClientNameAndPhone" resultType="com.dy.pipIrrGlobal.voSe.VoCards2"> - SELECT - card.id AS clientCardId, - cli.id AS clientId, - cli.clientNum, - cli.name AS clientName, - card.cardNum, - cli.phone, - cli.idCard, - card.state AS cardState, - (CASE - WHEN card.state = 1 THEN '姝e父' - WHEN card.state = 2 THEN '宸叉敞閿�' - WHEN card.state = 3 THEN '宸叉寕澶�' - End) AS stateName, - '鍐滄埛鍗�' AS cardType, - FORMAT(card.money, 2) AS money - FROM se_client_card card - INNER JOIN se_client cli ON card.clientId = cli.id - <where> - card.state = 1 - <if test = "clientName != null and clientName !=''"> - AND cli.name like CONCAT('%',#{clientName},'%') - </if> + <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> + <!--@mbg.generated--> + delete + from se_client_card + where id = #{id,jdbcType=BIGINT} + </delete> - <if test = "phone != null and phone !=''"> - AND cli.phone like CONCAT('%',#{phone},'%') - </if> - </where> - ORDER BY card.id - <trim prefix="limit " > - <if test="start != null and count != null"> - #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} - </if> - </trim> - </select> - <!--鏍规嵁鍐滄埛ID鏌ヨ姝e父鐘舵�佺殑姘村崱鍒楄〃,灏忕▼搴忎娇鐢�--> - <select id="getCardsByClientID" resultType="com.dy.pipIrrGlobal.voWe.VoCards3"> - SELECT - card.id AS clientCardId, - cli.id AS clientId, - cli.clientNum, - cli.name AS clientName, - card.cardNum, - cli.phone, - cli.idCard, - card.state AS cardState, - (CASE - WHEN card.state = 1 THEN '姝e父' - WHEN card.state = 2 THEN '宸叉敞閿�' - WHEN card.state = 3 THEN '宸叉寕澶�' - End) AS stateName, - '鍐滄埛鍗�' AS cardType, - FORMAT(card.money, 2) AS money - FROM se_client_card card - INNER JOIN se_client cli ON card.clientId = cli.id - where - card.state = 1 - AND cli.id like CONCAT('%',#{clientId},'%') + <!--渚濇嵁姘村崱鍦板潃鑾峰彇姘村崱缂栧彿锛�12鏈�19鏃ュ簾寮冿級--> + <select id="getCardIdByAddr" resultType="java.lang.Long"> + SELECT id AS cardId + FROM se_client_card + WHERE cardAddr = #{cardAddr} + </select> + + <!--鏍规嵁姘村崱缂栧彿鑾峰彇姘村崱琛ㄤ富閿紙12鏈�19鏃ユ坊鍔犲悗搴熷純锛�--> + <select id="getCardIdByNum" resultType="java.lang.Long"> + SELECT id AS cardId + FROM se_client_card + WHERE cardNum = #{cardNum} + </select> + + <!--鏍规嵁姘村崱缂栧彿鑾峰彇姘村崱琛ㄤ富閿強鍐滄埛缂栧彿--> + <select id="getCardIdAndClientNum" resultType="java.util.Map"> + <!-- SELECT id AS cardId, clientNum FROM se_client_card WHERE cardNum = #{cardNum}--> + SELECT card.id AS cardId, + cli.clientNum, + cli.id AS clientId, + protocol + FROM se_client_card card + INNER JOIN se_client cli ON card.clientId = cli.id + WHERE card.cardNum = #{cardNum} + </select> + + <!-- 鏍规嵁姘村崱缂栧彿鑾峰彇姘村崱瀵瑰簲鐨勫啘鎴穒d鍜屽鍚� --> + <select id="getClientIdAndNameByCardAddrAndCardNo" resultType="java.util.Map"> + SELECT cli.id AS clientId, + cli.name AS clientName + FROM se_client_card card + INNER JOIN se_client cli ON card.clientId = cli.id + WHERE card.cardAddr = #{cardAddr} + and card.cardNum = #{cardNum} + </select> - ORDER BY card.id - </select> - <!--褰撳墠浣欓鎬婚噺锛堢墿鐞嗗崱锛�--> - <select id="getTotalMoneyIcCards" resultType="java.lang.Double"> - SELECT - IFNULL(SUM(money),0) AS totalMoney - FROM - `se_client_card` - WHERE state = 1 - </select> + <!-- 鏍规嵁姘村崱缂栧彿鑾峰彇姘村崱 --> + <select id="getCardsByAddrAndNum" resultType="com.dy.pipIrrGlobal.voSe.VoCardInfo1"> + SELECT id, + money + FROM se_client_card + WHERE cardAddr = #{cardAddr} + and cardNum = #{cardNum} + </select> - <!--鏍规嵁姘村崱鍦板潃鑾峰彇姘村崱鏁伴噺--> - <select id="getCountByCardAddr" resultType="java.lang.Long"> - SELECT COUNT(*) AS recordCount FROM se_client_card WHERE cardAddr = #{cardAddr} - </select> + <!--鏍规嵁琛屾斂鍖哄垝涓叉ā绯婃煡璇㈡按鍗$紪鍙�--> + <select id="getCardNumOfMax" resultType="java.lang.String"> + SELECT cardNum + FROM se_client_card + WHERE cardNum LIKE CONCAT(#{areaCode}, '%') + ORDER BY cardNum desc + LIMIT 0,1 + </select> - <!--鏍规嵁姘村崱鍦板潃鑾峰彇鎸囧畾鐘舵�佺殑姘村崱鏁伴噺--> - <select id="getCountByCardAddrAndState" resultType="java.lang.Long"> - SELECT COUNT(*) AS recordCount FROM se_client_card WHERE cardAddr = #{cardAddr} AND state IN(1,3) - </select> + <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.dy.pipIrrGlobal.pojoSe.SeClientCard"> + <!--@mbg.generated--> + insert into se_client_card (id, protocol, cardAddr, cardNum, clientId, + money, `state`, original_card_id, createDt, + replaceDt, rechargeDt, lossDtDt, + cancelDt, unlockDt, reversalDt, refundDt, + consumeDt, lastOper, remarks) + values (#{id,jdbcType=BIGINT}, #{protocol,jdbcType=VARCHAR}, #{cardaddr,jdbcType=VARCHAR}, + #{cardnum,jdbcType=BIGINT}, #{clientid,jdbcType=BIGINT}, + #{money,jdbcType=FLOAT}, #{state,jdbcType=TINYINT}, #{originalCardId,jdbcType=BIGINT}, + #{createdt,jdbcType=TIMESTAMP}, + #{replacedt,jdbcType=TIMESTAMP}, #{rechargedt,jdbcType=TIMESTAMP}, #{lossdtdt,jdbcType=TIMESTAMP}, + #{canceldt,jdbcType=TIMESTAMP}, #{unlockdt,jdbcType=TIMESTAMP}, #{reversaldt,jdbcType=TIMESTAMP}, + #{refunddt,jdbcType=TIMESTAMP}, #{consumedt,jdbcType=TIMESTAMP}, #{lastoper,jdbcType=TINYINT}, + #{remarks,jdbcType=VARCHAR}) + </insert> + <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.dy.pipIrrGlobal.pojoSe.SeClientCard" + useGeneratedKeys="true"> + <!--@mbg.generated--> + insert into se_client_card + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null"> + id, + </if> + <if test="protocol != null"> + protocol, + </if> + <if test="cardaddr != null"> + cardAddr, + </if> + <if test="cardnum != null"> + cardNum, + </if> + <if test="clientid != null"> + clientId, + </if> + <if test="money != null"> + money, + </if> + <if test="state != null"> + `state`, + </if> + <if test="originalCardId != null"> + original_card_id, + </if> + <if test="createdt != null"> + createDt, + </if> + <if test="replacedt != null"> + replaceDt, + </if> + <if test="rechargedt != null"> + rechargeDt, + </if> + <if test="lossdtdt != null"> + lossDtDt, + </if> + <if test="canceldt != null"> + cancelDt, + </if> + <if test="unlockdt != null"> + unlockDt, + </if> + <if test="reversaldt != null"> + reversalDt, + </if> + <if test="refunddt != null"> + refundDt, + </if> + <if test="consumedt != null"> + consumeDt, + </if> + <if test="lastoper != null"> + lastOper, + </if> + <if test="remarks != null"> + remarks, + </if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="id != null"> + #{id,jdbcType=BIGINT}, + </if> + <if test="protocol != null"> + #{protocol,jdbcType=VARCHAR}, + </if> + <if test="cardaddr != null"> + #{cardaddr,jdbcType=VARCHAR}, + </if> + <if test="cardnum != null"> + #{cardnum,jdbcType=BIGINT}, + </if> + <if test="clientid != null"> + #{clientid,jdbcType=BIGINT}, + </if> + <if test="money != null"> + #{money,jdbcType=FLOAT}, + </if> + <if test="state != null"> + #{state,jdbcType=TINYINT}, + </if> + <if test="originalCardId != null"> + #{originalCardId,jdbcType=BIGINT}, + </if> + <if test="createdt != null"> + #{createdt,jdbcType=TIMESTAMP}, + </if> + <if test="replacedt != null"> + #{replacedt,jdbcType=TIMESTAMP}, + </if> + <if test="rechargedt != null"> + #{rechargedt,jdbcType=TIMESTAMP}, + </if> + <if test="lossdtdt != null"> + #{lossdtdt,jdbcType=TIMESTAMP}, + </if> + <if test="canceldt != null"> + #{canceldt,jdbcType=TIMESTAMP}, + </if> + <if test="unlockdt != null"> + #{unlockdt,jdbcType=TIMESTAMP}, + </if> + <if test="reversaldt != null"> + #{reversaldt,jdbcType=TIMESTAMP}, + </if> + <if test="refunddt != null"> + #{refunddt,jdbcType=TIMESTAMP}, + </if> + <if test="consumedt != null"> + #{consumedt,jdbcType=TIMESTAMP}, + </if> + <if test="lastoper != null"> + #{lastoper,jdbcType=TINYINT}, + </if> + <if test="remarks != null"> + #{remarks,jdbcType=VARCHAR}, + </if> + </trim> + </insert> + <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoSe.SeClientCard"> + <!--@mbg.generated--> + update se_client_card + <set> + <if test="protocol != null"> + protocol = #{protocol,jdbcType=VARCHAR}, + </if> + <if test="cardaddr != null"> + cardAddr = #{cardaddr,jdbcType=VARCHAR}, + </if> + <if test="cardnum != null"> + cardNum = #{cardnum,jdbcType=BIGINT}, + </if> + <if test="clientid != null"> + clientId = #{clientid,jdbcType=BIGINT}, + </if> + <if test="money != null"> + money = #{money,jdbcType=FLOAT}, + </if> + <if test="state != null"> + `state` = #{state,jdbcType=TINYINT}, + </if> + <if test="originalCardId != null"> + `original_card_id` = #{originalCardId,jdbcType=BIGINT}, + </if> + <if test="createdt != null"> + createDt = #{createdt,jdbcType=TIMESTAMP}, + </if> + <if test="replacedt != null"> + replaceDt = #{replacedt,jdbcType=TIMESTAMP}, + </if> + <if test="rechargedt != null"> + rechargeDt = #{rechargedt,jdbcType=TIMESTAMP}, + </if> + <if test="lossdtdt != null"> + lossDtDt = #{lossdtdt,jdbcType=TIMESTAMP}, + </if> + <if test="canceldt != null"> + cancelDt = #{canceldt,jdbcType=TIMESTAMP}, + </if> + <if test="unlockdt != null"> + unlockDt = #{unlockdt,jdbcType=TIMESTAMP}, + </if> + <if test="reversaldt != null"> + reversalDt = #{reversaldt,jdbcType=TIMESTAMP}, + </if> + <if test="refunddt != null"> + refundDt = #{refunddt,jdbcType=TIMESTAMP}, + </if> + <if test="consumedt != null"> + consumeDt = #{consumedt,jdbcType=TIMESTAMP}, + </if> + <if test="lastoper != null"> + lastOper = #{lastoper,jdbcType=TINYINT}, + </if> + <if test="remarks != null"> + remarks = #{remarks,jdbcType=VARCHAR}, + </if> + </set> + where id = #{id,jdbcType=BIGINT} + </update> + <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoSe.SeClientCard"> + <!--@mbg.generated--> + update se_client_card + set protocol = #{protocol,jdbcType=VARCHAR}, + cardAddr = #{cardaddr,jdbcType=VARCHAR}, + cardNum = #{cardnum,jdbcType=BIGINT}, + clientId = #{clientid,jdbcType=BIGINT}, + money = #{money,jdbcType=FLOAT}, + `state` = #{state,jdbcType=TINYINT}, + original_card_id = #{originalCardId,jdbcType=BIGINT}, + createDt = #{createdt,jdbcType=TIMESTAMP}, + replaceDt = #{replacedt,jdbcType=TIMESTAMP}, + rechargeDt = #{rechargedt,jdbcType=TIMESTAMP}, + lossDtDt = #{lossdtdt,jdbcType=TIMESTAMP}, + cancelDt = #{canceldt,jdbcType=TIMESTAMP}, + unlockDt = #{unlockdt,jdbcType=TIMESTAMP}, + reversalDt = #{reversaldt,jdbcType=TIMESTAMP}, + refundDt = #{refunddt,jdbcType=TIMESTAMP}, + consumeDt = #{consumedt,jdbcType=TIMESTAMP}, + lastOper = #{lastoper,jdbcType=TINYINT}, + remarks = #{remarks,jdbcType=VARCHAR} + where id = #{id,jdbcType=BIGINT} + </update> + <update id="updateMoney"> + update se_client_card + set money = #{money,jdbcType=FLOAT} + where id = #{id,jdbcType=BIGINT} + </update> + <!--鏍规嵁鍐滄埛涓婚敭鑾峰彇姘村崱鍒楄〃锛堢墿鐞嗗崱+铏氭嫙鍗★級--> + <select id="getCardInfoByClientId" resultType="com.dy.pipIrrGlobal.voSe.VoCardInfo"> + SELECT * + FROM (SELECT '鐗╃悊鍗�' AS cardType, + clientCard.cardNum AS cardNum, + clientCard.money AS money, + (CASE + WHEN clientCard.state = 1 THEN '姝e父' + WHEN clientCard.state = 2 THEN '宸叉敞閿�' + ELSE '宸叉寕澶�' + END) AS state + FROM se_client client + LEFT JOIN se_client_card clientCard ON clientCard.clientId = client.id + WHERE client.id = #{clientId,jdbcType=BIGINT} + UNION ALL + SELECT '铏氭嫙鍗�' AS cardType, + vc.vc_num AS cardNum, + vc.money AS money, + (CASE + WHEN vc.in_use = 0 THEN '鏈娇鐢�' + WHEN vc.in_use = 1 THEN '浣跨敤涓�' + END) AS state + FROM se_virtual_card vc + INNER JOIN se_client cli ON cli.id = vc.client_id + WHERE vc.client_id = #{clientId,jdbcType=BIGINT} + <!-- SELECT '铏氭嫙鍗�' AS cardType,--> + <!-- virtualCard.vc_num AS CardNum,--> + <!-- virtualCard.money AS vcMoney,--> + <!-- (CASE--> + <!-- WHEN virtualCard.in_use = 0 THEN '鏈娇鐢�'--> + <!-- WHEN virtualCard.in_use = 1 THEN '浣跨敤涓�'--> + <!-- END) AS State--> + <!-- FROM se_client client--> + <!-- LEFT JOIN se_virtual_card virtualCard ON client.id = virtualCard.client_id--> + <!-- WHERE client.id = #{clientId,jdbcType=BIGINT}--> + ) card + ORDER BY card.Money DESC, card.State DESC + </select> + + <!--鏍规嵁姘村崱缂栧彿鑾峰彇鎿嶄綔璁板綍鍒楄〃--> + <select id="getOperateRecordsByCardNum" resultType="java.util.HashMap"> + SELECT * + FROM v_operate + WHERE cardNum = #{cardNum,jdbcType=BIGINT} + </select> + + <!--鏍规嵁姘村崱缂栧彿鑾峰彇浣欓--> + <select id="getMoneyByCardNum" resultType="java.lang.Float"> + SELECT money + FROM se_client_card + WHERE cardNum = #{cardNum,jdbcType=BIGINT} + </select> + + <!--鏍规嵁姘村崱缂栧彿鑾峰彇鍏呭�兼�婚--> + <select id="sumRechargeByCardNum" resultType="java.lang.Float"> + SELECT SUM(his.amount) AS amount + FROM se_recharge_history his + INNER JOIN se_client_card card ON his.cardId = card.id + WHERE card.cardNum = #{cardNum,jdbcType=BIGINT} + </select> + + <!--鏍规嵁姘村崱缂栧彿鑾峰彇鍗$墖鐘舵�侊細1-寮�鍗★紝2-琛ュ崱锛�3-鍏呭�硷紝4-鎸傚け锛�5-娉ㄩ攢锛�6-瑙i攣锛�7-鍐叉锛�8-娑堣垂--> + <select id="getCardStateByCardNum" resultType="java.lang.String"> + <!-- SELECT--> + <!-- (CASE--> + <!-- WHEN lastOper = 1 THEN "寮�鍗�"--> + <!-- WHEN lastOper = 2 THEN "琛ュ崱"--> + <!-- WHEN lastOper = 3 THEN "鍏呭��"--> + <!-- WHEN lastOper = 4 THEN "鎸傚け"--> + <!-- WHEN lastOper = 5 THEN "娉ㄩ攢"--> + <!-- WHEN lastOper = 6 THEN "瑙i攣"--> + <!-- WHEN lastOper = 7 THEN "鍐叉"--> + <!-- WHEN lastOper = 8 THEN "娑堣垂"--> + <!-- END) AS stateName--> + <!-- FROM se_client_card--> + <!-- WHERE cardNum = ${cardNum}--> + SELECT (CASE + WHEN state = 1 THEN '姝e父' + WHEN state = 2 THEN '宸叉敞閿�' + WHEN state = 3 THEN '宸叉寕澶�' + END) AS stateName + FROM se_client_card + WHERE cardNum = #{cardNum,jdbcType=BIGINT} + </select> + + <!--鏍规嵁鎸囧畾鏉′欢鑾峰彇姘村崱鍒楄〃璁板綍鏁帮紝搴旂敤绋嬪簭浣跨敤--> + <select id="getCardsCount" parameterType="java.util.Map" resultType="java.lang.Long"> + SELECT COUNT(*) AS recordCount + FROM se_client_card card + INNER JOIN se_client cli ON card.clientId = cli.id + <where> + AND card.state = 1 + <if test="clientNum != null and clientNum != ''"> + AND cli.clientNum like CONCAT('%', #{clientNum}, '%') + </if> + + <if test="clientName != null and clientName != ''"> + AND cli.name like CONCAT('%', #{clientName}, '%') + </if> + + <if test="cardNum != null and cardNum != ''"> + AND card.cardNum like CONCAT('%', #{cardNum}, '%') + </if> + </where> + </select> + + <!--鏍规嵁鎸囧畾鏉′欢鑾峰彇姘村崱鍒楄〃锛屽簲鐢ㄧ▼搴忎娇鐢�--> + <select id="getCards" resultType="com.dy.pipIrrGlobal.voSe.VoCards"> + SELECT cli.clientNum, + cli.name AS clientName, + cardNum, + <!-- CASE--> + <!-- WHEN card.cardNum LIKE '10%' THEN CONCAT(SUBSTRING(card.cardNum, 7, 6),SUBSTRING(card.cardNum, 14, 4))--> + <!-- ELSE card.cardNum--> + <!-- END AS cardNum,--> + cli.phone, + cli.idCard, + card.state AS cardState, + <!-- (CASE--> + <!-- WHEN card.state = 1 THEN '姝e父'--> + <!-- WHEN card.state = 2 THEN '宸叉敞閿�'--> + <!-- WHEN card.state = 3 THEN '宸叉寕澶�'--> + <!-- End) AS stateName,--> + '姝e父' AS stateName, + '鍐滄埛鍗�' AS cardType, + FORMAT(card.money, 2) AS money + FROM se_client_card card + INNER JOIN se_client cli ON card.clientId = cli.id + <where> + AND card.state = 1 + <if test="clientNum != null and clientNum != ''"> + AND cli.clientNum like CONCAT('%', #{clientNum}, '%') + </if> + + <if test="clientName != null and clientName != ''"> + AND cli.name like CONCAT('%', #{clientName}, '%') + </if> + + <if test="cardNum != null and cardNum != ''"> + AND card.cardNum like CONCAT('%', #{cardNum}, '%') + </if> + </where> + ORDER BY card.id + <trim prefix="limit "> + <if test="start != null and count != null"> + #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} + </if> + </trim> + </select> + + <!--鑾峰彇宸叉寕澶辨湭琛ュ崱鐨勮褰曟暟閲�--> + <select id="getUnreplacedRecordCount" resultType="java.lang.Long"> + SELECT COUNT(*) AS recordCount + FROM se_client_card card + INNER JOIN se_client cli ON card.clientId = cli.id + WHERE card.state = 3 + AND NOT EXISTS(SELECT * FROM se_client_card card2 WHERE card2.original_card_id = card.cardNum) + </select> + + <!--鑾峰彇宸叉寕澶辨湭琛ュ崱鐨勮褰�--> + <select id="getUnreplaced" resultType="com.dy.pipIrrGlobal.voSe.VoCards"> + SELECT cli.clientNum, + cli.name AS clientName, + cardNum, + <!-- CASE--> + <!-- WHEN card.cardNum LIKE '10%' THEN CONCAT(SUBSTRING(card.cardNum, 7, 6),SUBSTRING(card.cardNum, 14, 4))--> + <!-- ELSE card.cardNum--> + <!-- END AS cardNum,--> + cli.phone, + cli.idCard, + card.state AS cardState, + '宸叉寕澶�' AS stateName, + '鍐滄埛鍗�' AS cardType, + FORMAT(card.money, 2) AS money + FROM se_client_card card + INNER JOIN se_client cli ON card.clientId = cli.id + WHERE card.state = 3 + AND NOT EXISTS(SELECT * FROM se_client_card card2 WHERE card2.original_card_id = card.id) + ORDER BY card.id + <trim prefix="limit "> + <if test="start != null and count != null"> + #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} + </if> + </trim> + </select> + + <!--鏍规嵁鎸囧畾姘村崱缂栧彿鑾峰彇鎸傚け浜嬭褰曟暟閲忥紙琛ュ崱銆佽В閿佷娇鐢級--> + <select id="getLostCount" resultType="java.lang.Integer"> + SELECT COUNT(*) AS recordCount + FROM se_client_card card + <where> + AND card.state = 3 + <if test="cardNum != null and cardNum > 0"> + AND card.cardNum = #{cardNum} + </if> + </where> + </select> + + <!--鏍规嵁鎸囧畾姘村崱缂栧彿鑾峰彇宸茶ˉ鍗℃暟閲忥紙琛ュ崱銆佽В閿佷娇鐢級--> + <select id="getReplacedCount" resultType="java.lang.Integer"> + SELECT COUNT(*) AS recordCount + FROM se_client_card card + INNER JOIN se_client_card card2 ON card2.original_card_id = card.id + <where> + <if test="cardNum != null and cardNum > 0"> + AND card.cardNum = #{cardNum} + </if> + </where> + </select> + <!--鏍规嵁鍐滄埛濮撳悕鍜屾墜鏈哄彿鑾峰彇姘村崱鍒楄〃璁板綍鏁帮紝搴旂敤绋嬪簭浣跨敤--> + <select id="getCardsByClientNameAndPhoneCount" resultType="java.lang.Long"> + SELECT COUNT(*) AS recordCount + FROM se_client_card card + INNER JOIN se_client cli ON card.clientId = cli.id + <where> + card.state = 1 + <if test="clientName != null and clientName != ''"> + AND cli.name like CONCAT('%', #{clientName}, '%') + </if> + + <if test="phone != null and phone != ''"> + AND cli.phone like CONCAT('%', #{phone}, '%') + </if> + </where> + </select> + <!--鏍规嵁鍐滄埛濮撳悕鍜屾墜鏈哄彿鑾峰彇姘村崱鍒楄〃锛屽簲鐢ㄧ▼搴忎娇鐢�--> + <select id="getCardsByClientNameAndPhone" resultType="com.dy.pipIrrGlobal.voSe.VoCards2"> + SELECT card.id AS clientCardId, + cli.id AS clientId, + cli.clientNum, + cli.name AS clientName, + card.cardNum, + cli.phone, + cli.idCard, + card.state AS cardState, + (CASE + WHEN card.state = 1 THEN '姝e父' + WHEN card.state = 2 THEN '宸叉敞閿�' + WHEN card.state = 3 THEN '宸叉寕澶�' + End) AS stateName, + '鍐滄埛鍗�' AS cardType, + FORMAT(card.money, 2) AS money + FROM se_client_card card + INNER JOIN se_client cli ON card.clientId = cli.id + <where> + card.state = 1 + <if test="clientName != null and clientName != ''"> + AND cli.name like CONCAT('%', #{clientName}, '%') + </if> + + <if test="phone != null and phone != ''"> + AND cli.phone like CONCAT('%', #{phone}, '%') + </if> + </where> + ORDER BY card.id + <trim prefix="limit "> + <if test="start != null and count != null"> + #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} + </if> + </trim> + </select> + <!--鏍规嵁鍐滄埛ID鏌ヨ姝e父鐘舵�佺殑姘村崱鍒楄〃,灏忕▼搴忎娇鐢�--> + <select id="getCardsByClientID" resultType="com.dy.pipIrrGlobal.voWe.VoCards3"> + SELECT card.id AS clientCardId, + cli.id AS clientId, + cli.clientNum, + cli.name AS clientName, + card.cardNum, + cli.phone, + cli.idCard, + card.state AS cardState, + (CASE + WHEN card.state = 1 THEN '姝e父' + WHEN card.state = 2 THEN '宸叉敞閿�' + WHEN card.state = 3 THEN '宸叉寕澶�' + End) AS stateName, + '鍐滄埛鍗�' AS cardType, + FORMAT(card.money, 2) AS money + FROM se_client_card card + INNER JOIN se_client cli ON card.clientId = cli.id + where card.state = 1 + AND cli.id like CONCAT('%', #{clientId}, '%') + + + ORDER BY card.id + </select> + <!--褰撳墠浣欓鎬婚噺锛堢墿鐞嗗崱锛�--> + <select id="getTotalMoneyIcCards" resultType="java.lang.Double"> + SELECT IFNULL(SUM(money), 0) AS totalMoney + FROM `se_client_card` + WHERE state = 1 + </select> + + <!--鏍规嵁姘村崱鍦板潃鑾峰彇姘村崱鏁伴噺--> + <select id="getCountByCardAddr" resultType="java.lang.Long"> + SELECT COUNT(*) AS recordCount + FROM se_client_card + WHERE cardAddr = #{cardAddr} + </select> + + <!--鏍规嵁姘村崱鍦板潃鑾峰彇鎸囧畾鐘舵�佺殑姘村崱鏁伴噺--> + <select id="getCountByCardAddrAndState" resultType="java.lang.Long"> + SELECT COUNT(*) AS recordCount + FROM se_client_card + WHERE cardAddr = #{cardAddr} + AND state IN (1, 3) + </select> </mapper> \ No newline at end of file -- Gitblit v1.8.0