zhubaomin
1 天以前 ee1800e3988e4913f5328c2cba07735fb4d06eff
操作回调开卡附加充值部分
23个文件已修改
1个文件已添加
1813 ■■■■ 已修改文件
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSe/SeCardOperateMapper.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSe/SeClientCardMapper.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSe/SeRechargeHistoryMapper.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoSe/SeClientCard.java 28 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoSe/SeRechargeHistory.java 26 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voSe/VoAfterRecharge.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeCardOperateMapper.xml 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeClientCardMapper.xml 1447 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeRechargeHistoryMapper.xml 93 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/CommandSv.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/p202404V201/cd15/CdCtrl.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/p202404V201/cd15/CdSv.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/p202404V201/cd92/CdSv.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/valve/ValveCtrl.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/activeCard/ActiveCardCtrl.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/recharge/RechargeSv.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/card/IcCardSv.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StChargeByClientSv.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StChargeByIcSv.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-terminal/src/main/java/com/dy/pipIrrTerminal/card/CardCtrl.java 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-terminal/src/main/java/com/dy/pipIrrTerminal/card/CardSv.java 78 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/client/ClientCardSv.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/CommandSv.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/ValveCtrl.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSe/SeCardOperateMapper.java
@@ -4,6 +4,7 @@
import com.dy.pipIrrGlobal.voSe.*;
import com.dy.pipIrrGlobal.voSt.VoClientOpenCardCount;
import com.dy.pipIrrGlobal.voSt.VoClientRechargeTotal;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -15,6 +16,7 @@
 * @LastEditTime 2025-05-08 17:15
 * @Description
 */
@Mapper
public interface SeCardOperateMapper {
    int deleteByPrimaryKey(Long id);
@@ -229,6 +231,28 @@
     */
    Integer turnOperateValidByCardId(@Param("cardId") Long cardId, @Param("operateType") Integer operateType);
    /**
     * 充值机用根据订单号将操作记录改为有效
     * @param orderNumber
     * @return
     */
    Integer turnOperateValidByOrderNumber(String orderNumber);
    /**
     * 充值机用获取充值操作后新的余额及充值时间
     * @param orderNumber
     * @return
     */
    //Float getBalanceAfterRecharge(String orderNumber);
    VoAfterRecharge getBalanceAfterRecharge(String orderNumber);
    /**
     * 充值机用根据水卡ID获取同步充值记录数量
     * @param cardId
     * @return
     */
    Integer getPlusRechargeCount(Long cardId);
    /**
     * 根据水卡ID、操作类型获取获取最后一条记录,判断开卡是否同步充值使用
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSe/SeClientCardMapper.java
@@ -16,8 +16,8 @@
/**
 * @author ZhuBaoMin
 * @date 2023/12/22 16:04
 * @LastEditTime 2023/12/22 16:04
 * @date 2025-06-06 10:21
 * @LastEditTime 2025-06-06 10:21
 * @Description
 */
@@ -245,6 +245,13 @@
    Integer turnCardValidByAddr(@Param("cardAddr")String cardAddr, @Param("operateType")Integer operateType);
    /**
     * 充值机用根据订单号将水卡改为有效
     * @param orderNumber
     * @return
     */
    Integer turnCardValidByOrderNumber(@Param("orderNumber")String orderNumber);
    /**
     * 根据水卡ID获取原水卡ID,补卡通知中使用
     * @param cardId
     * @return
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSe/SeRechargeHistoryMapper.java
@@ -11,8 +11,8 @@
/**
 * @author ZhuBaoMin
 * @date 2023/12/23 8:47
 * @LastEditTime 2023/12/23 8:47
 * @date 2025-06-06 10:34
 * @LastEditTime 2025-06-06 10:34
 * @Description
 */
@@ -37,9 +37,12 @@
     */
    Integer turnRechargeHistoryValidByCardId(@Param("cardId") Long cardId);
    ///////////////////////////////
    //统计相关
    /**
     * 充值机用根据订单号将充值历史记录改为有效
     * @param orderNumber
     * @return
     */
    Integer turnRechargeHistoryValidByOrderNumber(@Param("orderNumber") String orderNumber);
    /**
     * 以农户和IC卡为单位统计一日的充值
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoSe/SeClientCard.java
@@ -18,9 +18,9 @@
/**
 * @author ZhuBaoMin
 * @date 2023/12/7 9:06
 * @LastEditTime 2023/12/18 10:14
 * @Description 添加水卡编号(cardnum)字段
 * @date 2025-06-06 10:21
 * @LastEditTime 2025-06-06 10:21
 * @Description
 */
/**
@@ -33,7 +33,6 @@
@ToString
@NoArgsConstructor
@AllArgsConstructor
@Schema(name = "农户水卡实体")
public class SeClientCard implements BaseEntity {
    public static final long serialVersionUID = 202401151518004L;
@@ -42,7 +41,6 @@
     */
    @JSONField(serializeUsing= ObjectWriterImplToString.class)
    @TableId(type = IdType.INPUT)
    @Schema(description = "实体id", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    private Long id;
    @NotBlank(message = "通讯协议不能为空")
@@ -51,35 +49,30 @@
    /**
     * 水卡地址
     */
    @Schema(description = "水卡地址", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotBlank(message = "水卡地址不能为空")
    private String cardaddr;
    /**
     * 水卡编号
     */
    @Schema(description = "水卡编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotBlank(message = "水卡编号不能为空")
    private String cardnum;
    /**
     * 农户ID
     */
    @Schema(description = "农户ID", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotBlank(message = "农户ID不能为空")
    private Long clientid;
    /**
     * 余额
     */
    @Schema(description = "余额", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @JsonFormat(shape = JsonFormat.Shape.NUMBER_FLOAT, pattern="0.00" )
    private Float money;
    /**
     * 卡片状态;1-正常,2-已注销,3-已挂失
     */
    @Schema(description = "卡片状态", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @Positive(message = "卡片状态必须为1或2或3")
    @Size(min = 1, max = 3)
    private Byte state;
@@ -87,32 +80,27 @@
    /**
     * 原挂失卡ID
     */
    @Schema(description = "卡片状态", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @Positive(message = "原挂失卡ID必须为正数")
    private Long originalCardId;
    /**
     * 开卡时间
     */
    @Schema(description = "开卡时间", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    private Date createdt;
    /**
     * 补卡时间
     */
    @Schema(description = "补卡时间", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    private Date replacedt;
    /**
     * 充值时间
     */
    @Schema(description = "充值时间", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    private Date rechargedt;
    /**
     * 挂失时间
     */
    @Schema(description = "挂失时间", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    private Date lossdtdt;
    /**
@@ -124,31 +112,26 @@
    /**
     * 解锁时间
     */
    @Schema(description = "解锁时间", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    private Date unlockdt;
    /**
     * 冲正时间
     */
    @Schema(description = "冲正时间", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    private Date reversaldt;
    /**
     * 补扣时间
     */
    @Schema(description = "补扣时间", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    private Date refunddt;
    /**
     * 消费时间
     */
    @Schema(description = "消费时间", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    private Date consumedt;
    /**
     * 最后操作类型;1-开卡,2-补卡,3-充值,4-挂失,5-注销,6-解锁,7-冲正,8-消费
     */
    @Schema(description = "最后操作类型", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @Positive(message = "卡片状态必须为1到8的正整数")
    @Size(min = 1, max = 8)
    private Byte lastoper;
@@ -156,8 +139,11 @@
    /**
     * 备注信息
     */
    @Schema(description = "备注", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @Length(message = "备注长度小于{max}字", min = 1, max = 200)
    private String remarks;
    /**
     * 订单号
     */
    private String orderNo;
}
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoSe/SeRechargeHistory.java
@@ -17,8 +17,8 @@
/**
 * @author ZhuBaoMin
 * @date 2023/12/7 20:33
 * @LastEditTime 2023/12/7 20:33
 * @date 2025-06-06 10:34
 * @LastEditTime 2025-06-06 10:34
 * @Description
 */
@@ -32,7 +32,6 @@
@ToString
@NoArgsConstructor
@AllArgsConstructor
@Schema(name = "水卡充值历史实体")
public class SeRechargeHistory implements BaseEntity {
    public static final long serialVersionUID = 202401151519002L;
@@ -41,31 +40,23 @@
     */
    @JSONField(serializeUsing= ObjectWriterImplToString.class)
    @TableId(type = IdType.INPUT)
    @Schema(description = "实体id", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    private Long id;
    /**
     * 水卡ID
     */
    @Schema(description = "水卡ID", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    //@NotBlank(message = "水卡ID不能为空")
    //private String cardnum;
    @NotNull(message = "水卡ID不能为空")
    private Long cardid;
    /**
     * 农户ID
     */
    @Schema(description = "农户ID", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    //@NotBlank(message = "农户ID不能为空")
    //private String clientnum;
    @NotNull(message = "农户ID不能为空")
    private Long clientid;
    /**
     * 卡片余额
     */
    @Schema(description = "卡片余额", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotNull(message = "卡片余额不能为空")
    @Length(message = "卡片余额不小于{min}", min = 0)
    @JsonFormat(shape = JsonFormat.Shape.NUMBER_FLOAT, pattern="0.00" )
@@ -74,7 +65,6 @@
    /**
     * 充值金额
     */
    @Schema(description = "充值金额", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotNull(message = "充值金额不能为空")
    @Length(message = "充值金额不小于{min}", min = 0)
    @JsonFormat(shape = JsonFormat.Shape.NUMBER_FLOAT, pattern="0.00" )
@@ -83,7 +73,6 @@
    /**
     * 赠送金额
     */
    @Schema(description = "赠送金额", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @Length(message = "赠送金额不小于{min}", min = 0)
    @JsonFormat(shape = JsonFormat.Shape.NUMBER_FLOAT, pattern="0.00" )
    private Float gift;
@@ -91,7 +80,6 @@
    /**
     * 充值后余额
     */
    @Schema(description = "充值后余额", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @Length(message = "充值后余额不小于{min}", min = 0)
    @JsonFormat(shape = JsonFormat.Shape.NUMBER_FLOAT, pattern="0.00" )
    private Float afterrecharge;
@@ -99,14 +87,12 @@
    /**
     * 付款方式编号
     */
    @Schema(description = "付款方式编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @Length(message = "付款方式编号不大于{max},不小于{min}", min = 1, max = 4)
    private Long paymentid;
    /**
     * 水价
     */
    @Schema(description = "水价", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @Length(message = "水价不小于{min}", min = 0)
    @JsonFormat(shape = JsonFormat.Shape.NUMBER_FLOAT, pattern="0.00" )
    private Float price;
@@ -114,21 +100,18 @@
    /**
     * 备注信息
     */
    @Schema(description = "备注", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @Length(message = "备注长度小于{max}字", min = 1, max = 200)
    private String remarks;
    /**
     * 操作人ID
     */
    @Schema(description = "操作人ID", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @Positive(message = "操作人ID必须为大于0的整数")
    private Long operator;
    /**
     * 操作时间
     */
    @Schema(description = "操作时间", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    private Date operatedt;
    /**
@@ -137,4 +120,9 @@
    @Length(message = "操作有效性不大于{max},不小于{min}", min = 1, max = 2)
    private Byte operateValid;
    /**
     * 订单号
     */
    private String orderNo;
}
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voSe/VoAfterRecharge.java
New file
@@ -0,0 +1,23 @@
package com.dy.pipIrrGlobal.voSe;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import lombok.Data;
import java.util.Date;
/**
 * @author ZhuBaoMin
 * @date 2025-06-06 16:02
 * @LastEditTime 2025-06-06 16:02
 * @Description 充值机用充值后信息
 */
@Data
@JsonPropertyOrder({"balanceAfterRecharge", "operateTime"})
public class VoAfterRecharge {
    private static final long serialVersionUID = 202506061605001L;
    private float balanceAfterRecharge;
    private Date operateTime;
}
pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeCardOperateMapper.xml
@@ -1083,6 +1083,29 @@
    );
  </update>
  <!--充值机用根据订单号将操作记录改为有效-->
  <update id="turnOperateValidByOrderNumber">
    UPDATE se_card_operate
    SET operate_valid = 2
    WHERE operate_valid = 1 AND order_no = #{orderNumber}
  </update>
  <!--充值机用获取充值操作后新的余额及充值时间-->
  <select id="getBalanceAfterRecharge" resultType="com.dy.pipIrrGlobal.voSe.VoAfterRecharge">
    SELECT
        (money + trade_amount + gift) AS balanceAfterRecharge,
        operate_dt AS operateTime
    FROM se_card_operate
    WHERE order_no = #{orderNumber}
  </select>
  <!--充值机用根据水卡ID获取同步充值记录数量-->
  <select id="getPlusRechargeCount" resultType="java.lang.Integer">
    SELECT COUNT(*)
    FROM se_card_operate
    WHERE operate_type = 2 AND order_no = CONCAT((SELECT order_no FROM se_card_operate WHERE operate_type = 1 AND card_id = #{cardId}),'p')
  </select>
  <!--根据操作类型、水卡ID获取获取最后一条记录-->
  <select id="getCardOperate" resultType="com.dy.pipIrrGlobal.pojoSe.SeCardOperate">
    SELECT * FROM se_card_operate
pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeClientCardMapper.xml
@@ -1,783 +1,784 @@
<?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-->
  <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" />
    <result column="order_no" jdbcType="VARCHAR" property="orderNo" />
  </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, order_no
  </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>
  <insert id="insert" 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, order_no)
    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}, #{orderNo,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoSe.SeClientCard">
    <!--@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,
        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>
      </if>
      <if test="remarks != null">
        remarks,
      </if>
      <if test="orderNo != null">
        order_no,
      </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>
      <if test="orderNo != null">
        #{orderNo,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>
      <if test="orderNo != null">
        order_no = #{orderNo,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},
      order_no = #{orderNo,jdbcType=VARCHAR}
    where id = #{id,jdbcType=BIGINT}
  </update>
    <!--依据水卡地址获取水卡编号(12月19日废弃)-->
    <!--2024-06-30取消废弃,恢复使用-->
    <select id="getCardIdByAddr" resultType="java.lang.Long">
        SELECT id AS cardId
        FROM se_client_card
        WHERE cardAddr = #{cardAddr}
        ORDER BY id DESC
        LIMIT 1
    </select>
  <!--依据水卡地址获取水卡编号(12月19日废弃)-->
  <!--2024-06-30取消废弃,恢复使用-->
  <select id="getCardIdByAddr" resultType="java.lang.Long">
    SELECT id AS cardId
    FROM se_client_card
    WHERE cardAddr = #{cardAddr}
    ORDER BY id DESC
    LIMIT 1
  </select>
    <!--根据水卡编号获取水卡表主键(12月19日添加后废弃)-->
    <select id="getCardIdByNum" resultType="java.lang.Long">
        SELECT id AS cardId
        FROM se_client_card
        WHERE cardNum = #{cardNum}
    </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>
  <!--根据水卡编号获取水卡表主键及农户编号-->
  <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>
    <!-- 根据水卡编号获取水卡对应的农户id和姓名 -->
    <select id="getClientIdAndNameByCardAddrAndCardNo" resultType="java.util.Map">
        SELECT cli.id   AS clientId,
               cli.name AS clientName,
               cli.address AS clientAddress
        FROM se_client_card card
                 INNER JOIN se_client cli ON card.clientId = cli.id
        WHERE card.cardAddr = #{cardAddr}
          and card.cardNum = #{cardNum}
    </select>
  <!-- 根据水卡编号获取水卡对应的农户id和姓名 -->
  <select id="getClientIdAndNameByCardAddrAndCardNo" resultType="java.util.Map">
    SELECT cli.id   AS clientId,
    cli.name AS clientName,
    cli.address AS clientAddress
    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="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>
  <!--根据行政区划串模糊查询水卡编号-->
  <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">
                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,
                card.cardNum AS cardNum,
                card.money   AS money,
                (CASE
                    WHEN card.state = 1 THEN '正常'
                    WHEN card.state = 2 THEN '已注销'
                    ELSE '已挂失'
                END) AS state
              FROM se_client_card card
                INNER JOIN se_client cli ON cli.id = card.clientId
              WHERE state != 4 AND card.clientId = #{clientId,jdbcType=BIGINT}
              UNION ALL
              SELECT
                '虚拟卡' AS cardType,
                vc.vc_num AS cardNum,
                ROUND(vc.money /100, 2)  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.state = 1 AND vc.client_id = #{clientId,jdbcType=BIGINT}
        ) card
        ORDER BY card.Money DESC, card.State DESC
    </select>
  <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,
    card.cardNum AS cardNum,
    card.money   AS money,
    (CASE
    WHEN card.state = 1 THEN '正常'
    WHEN card.state = 2 THEN '已注销'
    ELSE '已挂失'
    END) AS state
    FROM se_client_card card
    INNER JOIN se_client cli ON cli.id = card.clientId
    WHERE state != 4 AND card.clientId = #{clientId,jdbcType=BIGINT}
    UNION ALL
    SELECT
    '虚拟卡' AS cardType,
    vc.vc_num AS cardNum,
    ROUND(vc.money /100, 2)  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.state = 1 AND vc.client_id = #{clientId,jdbcType=BIGINT}
    ) card
    ORDER BY card.Money DESC, card.State DESC
  </select>
    <!--根据水卡编号获取操作记录列表-->
    <select id="getOperateRecordsByCardNum" resultType="java.util.HashMap">
        SELECT
            ope.id AS orderNumber,
            cli.villageId,
            cli.districtTitle,
            cli.clientNum,
            cli.`name`,
            card.cardNum,
            cli.idCard,
            cli.phone,
            IFNULL(ope.money,0) AS money,
            IFNULL(ope.gift,0) AS gift,
            IFNULL(ope.card_cost,0) AS cardCost,
            IFNULL((ope.money + ope.trade_amount + ope.gift),0) AS afterRecharge,
            ope.payment_id AS paymentId,
            pay.name AS paymentMethod,
            CASE
            WHEN ope.operate_type = 1 THEN '开卡'
            WHEN ope.operate_type = 2 THEN '充值'
            WHEN ope.operate_type = 3 THEN '销卡'
            END AS operateType,
            ope.operate_dt AS operateDt,
            user.name AS operatorName
        FROM se_card_operate ope
            LEFT JOIN se_client cli ON cli.id = ope.client_id
            LEFT JOIN se_client_card card ON card.id = ope.card_id
            LEFT JOIN se_payment_method pay ON pay.id = ope.payment_id
            LEFT JOIN ba_user user ON user.id = ope.operator
        WHERE ope.operate_valid = 2 AND ope.operate_type in (1,2,3) AND cardNum = #{cardNum,jdbcType=BIGINT}
<!--        SELECT *-->
<!--        FROM v_operate-->
<!--        WHERE cardNum = #{cardNum,jdbcType=BIGINT}-->
    </select>
  <!--根据水卡编号获取操作记录列表-->
  <select id="getOperateRecordsByCardNum" resultType="java.util.HashMap">
    SELECT
    ope.id AS orderNumber,
    cli.villageId,
    cli.districtTitle,
    cli.clientNum,
    cli.`name`,
    card.cardNum,
    cli.idCard,
    cli.phone,
    IFNULL(ope.money,0) AS money,
    IFNULL(ope.gift,0) AS gift,
    IFNULL(ope.card_cost,0) AS cardCost,
    IFNULL((ope.money + ope.trade_amount + ope.gift),0) AS afterRecharge,
    ope.payment_id AS paymentId,
    pay.name AS paymentMethod,
    CASE
    WHEN ope.operate_type = 1 THEN '开卡'
    WHEN ope.operate_type = 2 THEN '充值'
    WHEN ope.operate_type = 3 THEN '销卡'
    END AS operateType,
    ope.operate_dt AS operateDt,
    user.name AS operatorName
    FROM se_card_operate ope
    LEFT JOIN se_client cli ON cli.id = ope.client_id
    LEFT JOIN se_client_card card ON card.id = ope.card_id
    LEFT JOIN se_payment_method pay ON pay.id = ope.payment_id
    LEFT JOIN ba_user user ON user.id = ope.operator
    WHERE ope.operate_valid = 2 AND ope.operate_type in (1,2,3) AND cardNum = #{cardNum,jdbcType=BIGINT}
    <!--        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="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>
  <!--根据水卡编号获取充值总额-->
  <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-解锁,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 "解锁"-->
        <!--         WHEN lastOper = 7 THEN "冲正"-->
        <!--         WHEN lastOper = 8 THEN "消费"-->
        <!--        END) AS stateName-->
        <!--    FROM se_client_card-->
        <!--    WHERE cardNum = ${cardNum}-->
        SELECT (CASE
                    WHEN state = 1 THEN '正常'
                    WHEN state = 2 THEN '已注销'
                    WHEN state = 3 THEN '已挂失'
                    WHEN state = 4 THEN '无效卡片'
            END) AS stateName
        FROM se_client_card
        WHERE cardNum = #{cardNum,jdbcType=BIGINT}
    </select>
  <!--根据水卡编号获取卡片状态:1-开卡,2-补卡,3-充值,4-挂失,5-注销,6-解锁,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 "解锁"-->
    <!--         WHEN lastOper = 7 THEN "冲正"-->
    <!--         WHEN lastOper = 8 THEN "消费"-->
    <!--        END) AS stateName-->
    <!--    FROM se_client_card-->
    <!--    WHERE cardNum = ${cardNum}-->
    SELECT (CASE
    WHEN state = 1 THEN '正常'
    WHEN state = 2 THEN '已注销'
    WHEN state = 3 THEN '已挂失'
    WHEN state = 4 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
            LEFT 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>
  <!--根据指定条件获取水卡列表记录数,应用程序使用-->
  <select id="getCardsCount" parameterType="java.util.Map" resultType="java.lang.Long">
    SELECT COUNT(*) AS recordCount
    FROM se_client_card card
    LEFT 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="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>
      <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,
            cli.phone,
            cli.idCard,
            card.state AS cardState,
            '正常' AS stateName,
            '农户卡' AS cardType,
            FORMAT(card.money, 2) AS money
        FROM se_client_card card
            LEFT 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>
  <!--根据指定条件获取水卡列表,应用程序使用-->
  <select id="getCards" resultType="com.dy.pipIrrGlobal.voSe.VoCards">
    SELECT cli.clientNum,
    cli.name AS clientName,
    cardNum,
    cli.phone,
    cli.idCard,
    card.state AS cardState,
    '正常' AS stateName,
    '农户卡' AS cardType,
    FORMAT(card.money, 2) AS money
    FROM se_client_card card
    LEFT 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="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>
      <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="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,
            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="getUnreplaced" resultType="com.dy.pipIrrGlobal.voSe.VoCards">
    SELECT
    cli.clientNum,
    cli.name AS clientName,
    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="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>
  <!--根据指定水卡编号获取已补卡数量(补卡、解锁使用)-->
  <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 '正常'
                    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
            LEFT 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 '正常'
    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
    LEFT 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查询正常状态的水卡列表,小程序使用-->
    <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 '正常'
                    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}, '%')
      <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查询正常状态的水卡列表,小程序使用-->
  <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 '正常'
    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>
    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} AND se_client_card.state != 4
    </select>
  <!--根据水卡地址获取水卡数量,无效卡片排除在外-->
  <select id="getCountByCardAddr" resultType="java.lang.Long">
    SELECT COUNT(*) AS recordCount
    FROM se_client_card
    WHERE cardAddr = #{cardAddr} AND se_client_card.state != 4
  </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>
  <!--根据水卡地址获取指定状态的水卡数量-->
  <select id="getCountByCardAddrAndState" resultType="java.lang.Long">
    SELECT COUNT(*) AS recordCount
    FROM se_client_card
    WHERE cardAddr = #{cardAddr}
    AND state IN (1, 3)
  </select>
    <!--获取指定时间段水卡使用情况记录数量-->
    <select id="getCardUsagesCount" resultType="com.dy.pipIrrGlobal.voSt.VoCardUsage">
        SELECT
        card.id as cardId,
        cli.name AS clientName,
        card.cardNum,
        a.cl_ic_card_no,
        card.money AS balance,
        a.totalConsumption,
        b.totalRecharge
        FROM  se_client_card card
        INNER JOIN se_client cli ON cli.id = card.clientId
        LEFT JOIN  (
        SELECT his.cl_ic_card_no, SUM(his.cl_this_money) AS totalConsumption
        FROM rm_open_close_valve_history his
        WHERE his.cl_dt BETWEEN #{timeStart} AND #{timeStop}
        GROUP BY his.cl_ic_card_no
        ) a ON  a.cl_ic_card_no = CAST(card.cardNum AS CHAR)
        LEFT JOIN  (
        SELECT rch.cardId,ROUND(SUM(rch.amount),2) as totalRecharge
        FROM se_recharge_history rch
        WHERE rch.operate_valid = 2  AND rch.operateDt BETWEEN #{timeStart} AND #{timeStop}
        GROUP BY rch.cardId
        ) b ON b.cardId = card.id
        <where>
            <if test="clientName != null and clientName != ''">
                AND cli.name like CONCAT('%', #{clientName}, '%')
            </if>
  <!--获取指定时间段水卡使用情况记录数量-->
  <select id="getCardUsagesCount" resultType="com.dy.pipIrrGlobal.voSt.VoCardUsage">
    SELECT
    card.id as cardId,
    cli.name AS clientName,
    card.cardNum,
    a.cl_ic_card_no,
    card.money AS balance,
    a.totalConsumption,
    b.totalRecharge
    FROM  se_client_card card
    INNER JOIN se_client cli ON cli.id = card.clientId
    LEFT JOIN  (
    SELECT his.cl_ic_card_no, SUM(his.cl_this_money) AS totalConsumption
    FROM rm_open_close_valve_history his
    WHERE his.cl_dt BETWEEN #{timeStart} AND #{timeStop}
    GROUP BY his.cl_ic_card_no
    ) a ON  a.cl_ic_card_no = CAST(card.cardNum AS CHAR)
    LEFT JOIN  (
    SELECT rch.cardId,ROUND(SUM(rch.amount),2) as totalRecharge
    FROM se_recharge_history rch
    WHERE rch.operate_valid = 2  AND rch.operateDt BETWEEN #{timeStart} AND #{timeStop}
    GROUP BY rch.cardId
    ) b ON b.cardId = card.id
    <where>
      <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>
      <if test="cardNum != null and cardNum != ''">
        AND card.cardNum like CONCAT('%', #{cardNum}, '%')
      </if>
            <if test="clientNum != null and clientNum != ''">
                AND cli.clientNum like CONCAT('%', #{clientNum}, '%')
            </if>
        </where>
    </select>
      <if test="clientNum != null and clientNum != ''">
        AND cli.clientNum like CONCAT('%', #{clientNum}, '%')
      </if>
    </where>
  </select>
    <!--获取指定时间段水卡使用情况:充值合计、消费合计、余额-->
    <select id="getCardUsages" resultType="com.dy.pipIrrGlobal.voSt.VoCardUsage">
        SELECT
        card.id as cardId,
        cli.name AS clientName,
        card.cardNum,
        a.cl_ic_card_no,
        card.money AS balance,
        a.totalConsumption,
        b.totalRecharge
        FROM  se_client_card card
        INNER JOIN se_client cli ON cli.id = card.clientId
        LEFT JOIN  (
        SELECT his.cl_ic_card_no, SUM(his.cl_this_money) AS totalConsumption
        FROM rm_open_close_valve_history his
        WHERE his.cl_dt BETWEEN #{timeStart} AND #{timeStop}
        GROUP BY his.cl_ic_card_no
        ) a ON  a.cl_ic_card_no = CAST(card.cardNum AS CHAR)
        LEFT JOIN  (
        SELECT rch.cardId,ROUND(SUM(rch.amount),2) as totalRecharge
        FROM se_recharge_history rch
        WHERE rch.operate_valid = 2  AND rch.operateDt BETWEEN #{timeStart} AND #{timeStop}
        GROUP BY rch.cardId
        ) b ON b.cardId = card.id
        <where>
            <if test="clientName != null and clientName != ''">
                AND cli.name like CONCAT('%', #{clientName}, '%')
            </if>
  <!--获取指定时间段水卡使用情况:充值合计、消费合计、余额-->
  <select id="getCardUsages" resultType="com.dy.pipIrrGlobal.voSt.VoCardUsage">
    SELECT
    card.id as cardId,
    cli.name AS clientName,
    card.cardNum,
    a.cl_ic_card_no,
    card.money AS balance,
    a.totalConsumption,
    b.totalRecharge
    FROM  se_client_card card
    INNER JOIN se_client cli ON cli.id = card.clientId
    LEFT JOIN  (
    SELECT his.cl_ic_card_no, SUM(his.cl_this_money) AS totalConsumption
    FROM rm_open_close_valve_history his
    WHERE his.cl_dt BETWEEN #{timeStart} AND #{timeStop}
    GROUP BY his.cl_ic_card_no
    ) a ON  a.cl_ic_card_no = CAST(card.cardNum AS CHAR)
    LEFT JOIN  (
    SELECT rch.cardId,ROUND(SUM(rch.amount),2) as totalRecharge
    FROM se_recharge_history rch
    WHERE rch.operate_valid = 2  AND rch.operateDt BETWEEN #{timeStart} AND #{timeStop}
    GROUP BY rch.cardId
    ) b ON b.cardId = card.id
    <where>
      <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>
      <if test="cardNum != null and cardNum != ''">
        AND card.cardNum like CONCAT('%', #{cardNum}, '%')
      </if>
            <if test="clientNum != null and clientNum != ''">
                AND cli.clientNum like CONCAT('%', #{clientNum}, '%')
            </if>
        </where>
        ORDER BY cli.name, card.cardNum
        <trim prefix="limit ">
            <if test="start != null and count != null">
                #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER}
            </if>
        </trim>
    </select>
      <if test="clientNum != null and clientNum != ''">
        AND cli.clientNum like CONCAT('%', #{clientNum}, '%')
      </if>
    </where>
    ORDER BY cli.name, card.cardNum
    <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="getTotalRecharge" resultType="java.lang.Float">
        SELECT ROUND(SUM(amount),2) AS totalRecharge
        FROM se_recharge_history
        WHERE operateDt BETWEEN #{timeStart} AND #{timeStop}
    </select>
  <!--获取指定时间段内水卡充值总计-->
  <select id="getTotalRecharge" resultType="java.lang.Float">
    SELECT ROUND(SUM(amount),2) AS totalRecharge
    FROM se_recharge_history
    WHERE operateDt BETWEEN #{timeStart} AND #{timeStop}
  </select>
    <!--获取指定时间段内水卡消费总计-->
    <select id="getTotalConsumption" resultType="java.lang.Float">
        SELECT ROUND(SUM(cl_this_money),2) AS totalConsumption
        FROM rm_open_close_valve_history
        WHERE cl_dt BETWEEN #{timeStart} AND #{timeStop}
    </select>
  <!--获取指定时间段内水卡消费总计-->
  <select id="getTotalConsumption" resultType="java.lang.Float">
    SELECT ROUND(SUM(cl_this_money),2) AS totalConsumption
    FROM rm_open_close_valve_history
    WHERE cl_dt BETWEEN #{timeStart} AND #{timeStop}
  </select>
    <!--依据水卡地址将最后一条无效状态的指定操作记录改为有效-->
    <update id="turnCardValidByAddr">
        UPDATE se_client_card
        SET state = 1
        WHERE id = (
            SELECT id FROM (
                SELECT id
                FROM se_client_card
                WHERE state = 4 AND cardAddr = #{cardAddr} AND lastOper  = #{operateType}
                ORDER BY id DESC
                LIMIT 1) AS subquery
        );
    </update>
  <!--依据水卡地址将最后一条无效状态的指定操作记录改为有效-->
  <update id="turnCardValidByAddr">
    UPDATE se_client_card
    SET state = 1
    WHERE id = (
    SELECT id FROM (
    SELECT id
    FROM se_client_card
    WHERE state = 4 AND cardAddr = #{cardAddr} AND lastOper  = #{operateType}
    ORDER BY id DESC
    LIMIT 1) AS subquery
    );
  </update>
    <!--根据水卡ID获取原水卡ID,补卡通知中使用-->
    <select id="getOriginalCardIdByCardId" resultType="java.lang.Long">
        SELECT original_card_id AS originalCardId FROM se_client_card WHERE id = #{cardId};
    </select>
  <!--充值机用根据订单号将水卡改为有效-->
  <update id="turnCardValidByOrderNumber">
    UPDATE se_client_card
    SET state = 1
    WHERE state = 4 AND order_no = #{orderNumber}
  </update>
  <!--根据水卡ID获取原水卡ID,补卡通知中使用-->
  <select id="getOriginalCardIdByCardId" resultType="java.lang.Long">
    SELECT original_card_id AS originalCardId FROM se_client_card WHERE id = #{cardId};
  </select>
</mapper>
pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeRechargeHistoryMapper.xml
@@ -16,11 +16,13 @@
    <result column="remarks" jdbcType="VARCHAR" property="remarks" />
    <result column="operator" jdbcType="BIGINT" property="operator" />
    <result column="operateDt" jdbcType="TIMESTAMP" property="operatedt" />
    <result column="operate_valid" jdbcType="TINYINT" property="operateValid" />
    <result column="order_no" jdbcType="VARCHAR" property="orderNo" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, cardId, clientId, money, amount, gift, afterRecharge, paymentId, price, remarks, 
    `operator`, operateDt
    `operator`, operateDt, operate_valid, order_no
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    <!--@mbg.generated-->
@@ -34,23 +36,26 @@
    delete from se_recharge_history
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.dy.pipIrrGlobal.pojoSe.SeRechargeHistory">
  <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoSe.SeRechargeHistory">
    <!--@mbg.generated-->
    insert into se_recharge_history (id, cardId, clientId, money,
      amount, gift, afterRecharge,
    insert into se_recharge_history (id, cardId, clientId,
      money, amount, gift, afterRecharge,
      paymentId, price, remarks, 
      `operator`, operateDt)
    values (#{id,jdbcType=BIGINT}, #{cardid,jdbcType=BIGINT}, #{clientid,jdbcType=BIGINT}, #{money,jdbcType=FLOAT},
      #{amount,jdbcType=FLOAT}, #{gift,jdbcType=FLOAT}, #{afterrecharge,jdbcType=FLOAT},
      `operator`, operateDt, operate_valid,
      order_no)
    values (#{id,jdbcType=BIGINT}, #{cardid,jdbcType=BIGINT}, #{clientid,jdbcType=BIGINT},
      #{money,jdbcType=FLOAT}, #{amount,jdbcType=FLOAT}, #{gift,jdbcType=FLOAT}, #{afterrecharge,jdbcType=FLOAT},
      #{paymentid,jdbcType=BIGINT}, #{price,jdbcType=FLOAT}, #{remarks,jdbcType=VARCHAR}, 
      #{operator,jdbcType=BIGINT}, #{operatedt,jdbcType=TIMESTAMP})
      #{operator,jdbcType=BIGINT}, #{operatedt,jdbcType=TIMESTAMP}, #{operateValid,jdbcType=TINYINT},
      #{orderNo,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.dy.pipIrrGlobal.pojoSe.SeRechargeHistory" useGeneratedKeys="true">
  <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoSe.SeRechargeHistory">
    <!--@mbg.generated-->
    insert into se_recharge_history
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="cardid != null">
        cardId,
      </if>
@@ -84,8 +89,17 @@
      <if test="operatedt != null">
        operateDt,
      </if>
      <if test="operateValid != null">
        operate_valid,
      </if>
      <if test="orderNo != null">
        order_no,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=BIGINT},
      </if>
      <if test="cardid != null">
        #{cardid,jdbcType=BIGINT},
      </if>
@@ -118,6 +132,12 @@
      </if>
      <if test="operatedt != null">
        #{operatedt,jdbcType=TIMESTAMP},
      </if>
      <if test="operateValid != null">
        #{operateValid,jdbcType=TINYINT},
      </if>
      <if test="orderNo != null">
        #{orderNo,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
@@ -158,6 +178,12 @@
      <if test="operatedt != null">
        operateDt = #{operatedt,jdbcType=TIMESTAMP},
      </if>
      <if test="operateValid != null">
        operate_valid = #{operateValid,jdbcType=TINYINT},
      </if>
      <if test="orderNo != null">
        order_no = #{orderNo,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
@@ -174,34 +200,43 @@
      price = #{price,jdbcType=FLOAT},
      remarks = #{remarks,jdbcType=VARCHAR},
      `operator` = #{operator,jdbcType=BIGINT},
      operateDt = #{operatedt,jdbcType=TIMESTAMP}
      operateDt = #{operatedt,jdbcType=TIMESTAMP},
      operate_valid = #{operateValid,jdbcType=TINYINT},
      order_no = #{orderNo,jdbcType=VARCHAR}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <!--依据水卡ID将最后一条无效状态的充值历史记录改为有效-->
  <update id="turnRechargeHistoryValidByCardId">
    UPDATE se_recharge_history
        SET operate_valid = 2
    SET operate_valid = 2
    WHERE id = (
        SELECT id FROM (
            SELECT id
            FROM se_recharge_history
            WHERE operate_valid = 1 AND cardId = #{cardId}
            ORDER BY id DESC
        LIMIT 1) AS subquery
    SELECT id FROM (
    SELECT id
    FROM se_recharge_history
    WHERE operate_valid = 1 AND cardId = #{cardId}
    ORDER BY id DESC
    LIMIT 1) AS subquery
    );
  </update>
  <!--充值机用根据订单号将充值历史记录改为有效-->
  <update id="turnRechargeHistoryValidByOrderNumber">
    UPDATE se_recharge_history
    SET operate_valid = 2
    WHERE operate_valid = 1 AND order_no = #{orderNumber}
  </update>
<!-- /////////////////////////////////// -->
<!-- 统计相关                              -->
<!-- /////////////////////////////////// -->
  <!-- /////////////////////////////////// -->
  <!-- 统计相关                              -->
  <!-- /////////////////////////////////// -->
  <select id="statisticsByIc" resultType="com.dy.pipIrrGlobal.voSt.VoIcRechargeStatistics">
    select clientId as clientId,
           cardId as cardId,
           sum(amount) as amount,
           sum(gift) as gift,
           count(*) as times
    cardId as cardId,
    sum(amount) as amount,
    sum(gift) as gift,
    count(*) as times
    from se_recharge_history
    where operate_valid = 2
    and id <![CDATA[>=]]> #{startId, jdbcType=BIGINT}
@@ -210,9 +245,9 @@
  </select>
  <select id="statisticsByClient" resultType="com.dy.pipIrrGlobal.voSt.VoClientRechargeStatistics">
    select clientId as clientId,
           sum(amount) as amount,
           sum(gift) as gift,
           count(*) as times
    sum(amount) as amount,
    sum(gift) as gift,
    count(*) as times
    from se_recharge_history
    where operate_valid = 2
    and id <![CDATA[>=]]> #{startId, jdbcType=BIGINT}
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/CommandSv.java
@@ -61,7 +61,7 @@
    private String pro_mw = "mw";
    private String key_mw = "comSendUrl";
    @Autowired
    public CommandSv(RmCommandHistoryMapper rmCommandHistoryMapper,RmOpenCloseValveLastMapper rmOpenCloseValveLastMapper, SeVirtualCardMapper seVirtualCardMapper, PrIntakeMapper prIntakeMapper, PrWaterPriceMapper prWaterPriceMapper, PrIntakeVcMapper prIntakeVcMapper, SeClientCardMapper seClientCardMapper, Environment env) {
    public CommandSv(RmCommandHistoryMapper rmCommandHistoryMapper, RmOpenCloseValveLastMapper rmOpenCloseValveLastMapper, SeVirtualCardMapper seVirtualCardMapper, PrIntakeMapper prIntakeMapper, PrWaterPriceMapper prWaterPriceMapper, PrIntakeVcMapper prIntakeVcMapper, SeClientCardMapper seClientCardMapper, Environment env) {
        this.rmCommandHistoryMapper = rmCommandHistoryMapper;
        this.rmOpenCloseValveLastMapper = rmOpenCloseValveLastMapper;
        this.seVirtualCardMapper = seVirtualCardMapper;
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/p202404V201/cd15/CdCtrl.java
@@ -9,7 +9,6 @@
import com.dy.common.util.NumUtil;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.pipIrrGlobal.pojoSe.SeClientCard;
import com.dy.pipIrrRemote.common.dto.DtoBase;
import com.dy.pipIrrRemote.monitor.common.ComCtrl;
import io.swagger.v3.oas.annotations.tags.Tag;
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/p202404V201/cd15/CdSv.java
@@ -1,6 +1,5 @@
package com.dy.pipIrrRemote.monitor.p202404V201.cd15;
import com.dy.pipIrrGlobal.daoPr.PrControllerMapper;
import com.dy.pipIrrGlobal.daoSe.SeClientCardMapper;
import com.dy.pipIrrGlobal.pojoSe.SeClientCard;
import com.dy.pipIrrRemote.monitor.common.ComSv;
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/p202404V201/cd92/CdSv.java
@@ -2,9 +2,7 @@
import com.dy.pipIrrGlobal.daoPr.PrIntakeVcMapper;
import com.dy.pipIrrGlobal.daoPr.PrWaterPriceMapper;
import com.dy.pipIrrGlobal.daoSe.SeClientCardMapper;
import com.dy.pipIrrGlobal.daoSe.SeVirtualCardMapper;
import com.dy.pipIrrGlobal.pojoSe.SeClientCard;
import com.dy.pipIrrGlobal.pojoSe.SeVirtualCard;
import com.dy.pipIrrGlobal.voSe.VoVirtualCard;
import com.dy.pipIrrRemote.monitor.common.ComSv;
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/valve/ValveCtrl.java
@@ -19,7 +19,6 @@
import com.dy.pipIrrGlobal.command.ComSupport;
import com.dy.pipIrrGlobal.command.dto.Param;
import com.dy.pipIrrGlobal.daoSe.SeVirtualCardMapper;
import com.dy.pipIrrGlobal.pojoSe.SeClientCard;
import com.dy.pipIrrGlobal.voRm.VoUnclosedParam;
import com.dy.pipIrrGlobal.voRm.VoUnclosedValve;
import com.dy.pipIrrGlobal.voSe.VoVirtualCard;
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/activeCard/ActiveCardCtrl.java
@@ -8,7 +8,6 @@
import com.dy.pipIrrGlobal.daoBa.BaSettingsMapper;
import com.dy.pipIrrGlobal.pojoSe.SeActiveCard;
import com.dy.pipIrrGlobal.pojoSe.SeClientCard;
import com.dy.pipIrrGlobal.util.Constant;
import com.dy.pipIrrGlobal.voSe.VoActiveCard;
import com.dy.pipIrrSell.cardOperate.enums.OperateTypeENUM;
import com.dy.pipIrrSell.clientCard.CardStateENUM;
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/recharge/RechargeSv.java
@@ -8,7 +8,6 @@
import com.dy.pipIrrGlobal.voSe.VoRecharge;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.common.utils.PojoUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/card/IcCardSv.java
@@ -2,7 +2,6 @@
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pipIrrGlobal.daoSe.SeCardOperateMapper;
import com.dy.pipIrrGlobal.daoSe.SeClientCardMapper;
import com.dy.pipIrrGlobal.voSt.VoCardUsage;
import com.dy.pipIrrGlobal.voSt.VoICCard;
import com.dy.pipIrrStatistics.card.IcCardqo.CommonQO;
pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StChargeByClientSv.java
@@ -1,6 +1,5 @@
package com.dy.pipIrrStatistics.statistics;
import com.dy.pipIrrGlobal.daoSe.SeRechargeHistoryMapper;
import com.dy.pipIrrGlobal.daoSt.StRechargeClientDayMapper;
import com.dy.pipIrrGlobal.daoSt.StRechargeClientMonthMapper;
import com.dy.pipIrrGlobal.daoSt.StRechargeClientYearMapper;
pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StChargeByIcSv.java
@@ -1,6 +1,5 @@
package com.dy.pipIrrStatistics.statistics;
import com.dy.pipIrrGlobal.daoSe.SeRechargeHistoryMapper;
import com.dy.pipIrrGlobal.daoSt.StRechargeIcDayMapper;
import com.dy.pipIrrGlobal.daoSt.StRechargeIcMonthMapper;
import com.dy.pipIrrGlobal.daoSt.StRechargeIcYearMapper;
pipIrr-platform/pipIrr-web/pipIrr-web-terminal/src/main/java/com/dy/pipIrrTerminal/card/CardCtrl.java
@@ -5,10 +5,7 @@
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.pipIrrGlobal.voSe.VoTermActiveCard;
import com.dy.pipIrrGlobal.voSe.VoTermRecharge;
import com.dy.pipIrrTerminal.card.dto.ActiveCard;
import com.dy.pipIrrTerminal.card.dto.DtoLoss;
import com.dy.pipIrrTerminal.card.dto.DtoRecharge;
import com.dy.pipIrrTerminal.card.dto.DtoReissue;
import com.dy.pipIrrTerminal.card.dto.*;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -70,7 +67,7 @@
            return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
        }
        Map map_result = cardSv.addRecharge(po);
        Map map_result = cardSv.addRecharge(po, null);
        if(map_result.get("success").equals(false)) {
            return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString());
        }
@@ -119,4 +116,24 @@
        return BaseResponseUtils.buildSuccess(map_result.get("content")) ;
    }
    /**
     * 操作执行回调
     * @param po
     * @param bindingResult
     * @return
     */
    @PostMapping(path = "termCallBack", consumes = MediaType.APPLICATION_JSON_VALUE)
    @SsoAop()
    public BaseResponse<Boolean> termCallBack(@RequestBody @Valid DtoCallBack po, BindingResult bindingResult) {
        if (bindingResult != null && bindingResult.hasErrors()) {
            return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
        }
        Map map_result = cardSv.callBack(po);
        if(map_result.get("success").equals(false)) {
            return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString());
        }
        return BaseResponseUtils.buildSuccess(map_result.get("content")) ;
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-terminal/src/main/java/com/dy/pipIrrTerminal/card/CardSv.java
@@ -9,6 +9,7 @@
import com.dy.pipIrrGlobal.pojoSe.SeCardOperate;
import com.dy.pipIrrGlobal.pojoSe.SeClientCard;
import com.dy.pipIrrGlobal.pojoSe.SeRechargeHistory;
import com.dy.pipIrrGlobal.voSe.VoAfterRecharge;
import com.dy.pipIrrGlobal.voSe.VoTermActiveCard;
import com.dy.pipIrrGlobal.voSe.VoTermRecharge;
import com.dy.pipIrrTerminal.card.dto.*;
@@ -22,6 +23,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
@@ -245,6 +247,7 @@
        seClientCard.setClientid(po.getClientId());
        seClientCard.setMoney(po.getAmount());
        seClientCard.setState(CardStateENUM.INVALID.getCode());
        seClientCard.setOrderNo(orderNo);
        if (po.getOriginalCardId() != null) {
            // 补卡
            seClientCard.setOriginalCardId(po.getOriginalCardId());
@@ -301,7 +304,7 @@
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public Map plusRecharge(ActiveCard po, Long cardNum) {
    public Map plusRecharge(ActiveCard po, Long cardNum, String orderNo) {
        Map map = new HashMap<>();
        map.put("success", false);
        map.put("content", null);
@@ -318,7 +321,7 @@
        dtoRecharge.setMoney(0f);
        dtoRecharge.setGift(0f);
        dtoRecharge.setPrice(0f);
        Map map_plusRecharge = addRecharge(dtoRecharge);
        Map map_plusRecharge = addRecharge(dtoRecharge, orderNo);
        if (!map_plusRecharge.get("success").equals(true)) {
            map.put("msg", "开卡失败-充值异常");
            return map;
@@ -360,7 +363,7 @@
        }
        if (amount != null && amount > 0 && originalCardId == null) {
            Map map_plusRecharge = plusRecharge(po, cardNum);
            Map map_plusRecharge = plusRecharge(po, cardNum, orderNo);
            if(map_plusRecharge.get("success").equals(false)) {
                map.put("msg", map_plusRecharge.get("msg").toString());
                return map;
@@ -390,7 +393,7 @@
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public Map addRecharge(DtoRecharge po) {
    public Map addRecharge(DtoRecharge po, String orderNo) {
        Map map = new HashMap<>();
        map.put("success", false);
        map.put("content", null);
@@ -411,7 +414,9 @@
        }
        Long cardId = Long.parseLong(map_cardAndClient.get("cardId").toString());
        Long clientId = Long.parseLong(map_cardAndClient.get("clientId").toString());
        String orderNo = generateOrderNo();
        if(orderNo == null || orderNo.length() <= 0) {
            orderNo = generateOrderNo();
        }
        /**
         * 添加水卡充值操作记录
@@ -428,7 +433,7 @@
        seCardOperate.setRemarks(po.getRemarks());
        seCardOperate.setOperator(po.getOperator());
        seCardOperate.setOperateDt(new Date());
        seCardOperate.setOrderNo(orderNo);
        seCardOperate.setOrderNo(orderNo + "p");
        seCardOperate.setOperateValid((byte) 1);
        seCardOperateMapper.insert(seCardOperate);
        Long rec = Optional.ofNullable(seCardOperate.getId()).orElse(0L);
@@ -454,6 +459,7 @@
        seRechargeHistory.setOperator(po.getOperator());
        seRechargeHistory.setOperatedt(new Date());
        seRechargeHistory.setOperateValid((byte) 1);
        seRechargeHistory.setOrderNo(orderNo);
        seRechargeHistoryMapper.insert(seRechargeHistory);
        Long rec_seRechargeHistory = Optional.ofNullable(seRechargeHistory.getId()).orElse(0L);
        if (rec_seRechargeHistory == 0) {
@@ -568,6 +574,11 @@
        return map;
    }
    /**
     * 操作回调
     * @param po
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public Map callBack(DtoCallBack po) {
        Map map = new HashMap<>();
@@ -587,20 +598,69 @@
        if(operateType == 1) {
            /**
             * 开卡操作执行通知
             *  1.依据水卡地址、订单号将无效状态的操作记录改为有效
             *  1.依据订单号将无效状态的操作记录改为有效
             *  2.依据水卡ID将无效状态的水卡记录改为有效
             *  3.如果开卡同步充值
             *      修改充值操作记录为有效
             *      修改充值历史记录为有效
             *      修改水卡表的操作信息
             */
            Integer rec_ope = turnOperateValidByOrderNumber(orderNumber);
            Integer rec_card = turnCardValidByOrderNumber(orderNumber);
            if (rec_ope == 0 || rec_card == 0) {
                map.put("msg", "不存在未生效的水卡");
                return map;
            }
            if(isMergeRecharge(cardId)) {
                turnOperateValidByOrderNumber(orderNumber + "p");
                turnRechargeHistoryValidByOrderNumber(orderNumber);
                updateCard(cardId, orderNumber+"p");
            }
        }
        map.put("success", true);
        map.put("msg", "操作成功");
        return map;
    }
    // 根据订单号将操作记录改为有效
    public Integer turnOperateValidByOrderNumber(String orderNumber) {
        return seCardOperateMapper.turnOperateValidByOrderNumber(orderNumber);
    }
    // 根据订单号将水卡改为有效
    public Integer turnCardValidByOrderNumber(String orderNumber) {
        return seClientCardMapper.turnCardValidByOrderNumber(orderNumber);
    }
    // 根据订单号将充值历史改为有效
    public Integer turnRechargeHistoryValidByOrderNumber(String orderNumber) {
        return seRechargeHistoryMapper.turnRechargeHistoryValidByOrderNumber(orderNumber);
    }
    // 根据cardId判断是否是合并充值
    public Boolean isMergeRecharge(Long cardId) {
        Integer plusRechargeCount = seCardOperateMapper.getPlusRechargeCount(cardId);
        if (plusRechargeCount == 0) {
            return false;
        }
        return true;
    }
    // 修改水卡信息
    public Boolean updateCard(Long cardId, String orderNumber) {
        VoAfterRecharge voAfterRecharge = seCardOperateMapper.getBalanceAfterRecharge(orderNumber);
        SeClientCard clientCard = new SeClientCard();
        clientCard.setId(cardId);
        clientCard.setMoney(voAfterRecharge.getBalanceAfterRecharge());
        clientCard.setRechargedt(voAfterRecharge.getOperateTime());
        clientCard.setLastoper(LastOperateENUM.RECHARGE.getCode());
        Integer rec_updateClientCard = seClientCardMapper.updateByPrimaryKeySelective(clientCard);
        if (rec_updateClientCard == null || rec_updateClientCard == 0) {
            return false;
        }
        return true;
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/client/ClientCardSv.java
@@ -1,6 +1,5 @@
package com.dy.pipIrrWechat.client;
import com.dy.pipIrrGlobal.daoSe.SeClientCardMapper;
import com.dy.pipIrrGlobal.voWe.VoCards3;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/CommandSv.java
@@ -17,7 +17,6 @@
import com.dy.common.mw.protocol.p206V202404.downVos.ComCd93_A3Vo;
import com.dy.common.util.IDLongGenerator;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pipIrrGlobal.command.ComSupport;
import com.dy.pipIrrGlobal.command.dto.Param;
@@ -29,11 +28,9 @@
import com.dy.pipIrrGlobal.daoRm.RmCommandHistoryMapper;
import com.dy.pipIrrGlobal.daoRm.RmIrrigateProfileMapper;
import com.dy.pipIrrGlobal.daoRm.RmOpenCloseValveLastMapper;
import com.dy.pipIrrGlobal.daoSe.SeClientCardMapper;
import com.dy.pipIrrGlobal.daoSe.SeVirtualCardMapper;
import com.dy.pipIrrGlobal.pojoIr.IrIntakeOperate;
import com.dy.pipIrrGlobal.pojoRm.RmCommandHistory;
import com.dy.pipIrrGlobal.pojoSe.SeClientCard;
import com.dy.pipIrrGlobal.voRm.VoIrrigaterProfile;
import com.dy.pipIrrGlobal.voRm.VoRtuAndVc;
import com.dy.pipIrrGlobal.voRm.VoUnclosedValve;
@@ -41,7 +38,6 @@
import com.dy.pipIrrWechat.command.dto.AutomaticClose;
import com.dy.pipIrrWechat.command.dto.ValveClose;
import com.dy.pipIrrWechat.command.dto.ValveOpen;
import com.dy.pipIrrWechat.irrigatePlan.IrrigatePlanSv;
import com.dy.pipIrrWechat.irrigation.IrrigationSv;
import com.dy.pipIrrWechat.result.WechatResultCode;
import lombok.RequiredArgsConstructor;
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/ValveCtrl.java
@@ -9,8 +9,6 @@
import com.dy.common.mw.protocol.p206V202404.CodeV202404;
import com.dy.common.mw.protocol.p206V202404.ProtocolConstantV206V202404;
import com.dy.common.mw.protocol.p206V202404.downVos.ComCd15Vo;
import com.dy.common.mw.protocol.p206V202404.downVos.ComCd92_A2Vo;
import com.dy.common.mw.protocol.p206V202404.downVos.ComCd93_A3Vo;
import com.dy.common.util.IDLongGenerator;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
@@ -18,7 +16,6 @@
import com.dy.pipIrrGlobal.command.ComSupport;
import com.dy.pipIrrGlobal.command.dto.Param;
import com.dy.pipIrrGlobal.daoSe.SeVirtualCardMapper;
import com.dy.pipIrrGlobal.pojoSe.SeClientCard;
import com.dy.pipIrrGlobal.voRm.VoIrrigaterProfile;
import com.dy.pipIrrGlobal.voRm.VoUnclosedValve;
import com.dy.pipIrrGlobal.voSe.VoVirtualCard;