admin
2025-04-19 0a282218b2ddf541fd3b89ed2605c2a4bc720691
积分相关实体类创建
1个文件已修改
13个文件已添加
790 ■■■■■ 已修改文件
src/main/java/com/taoke/autopay/dao/credit/CreditExchangeRecordMapper.java 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/taoke/autopay/dao/credit/ExchangeRateMapper.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/taoke/autopay/dao/credit/UserAlipayBindingMapper.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/taoke/autopay/dao/credit/UserCreditBalanceMapper.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/taoke/autopay/dao/credit/UserCreditRecordMapper.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/taoke/autopay/entity/credit/CreditSetting.java 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/taoke/autopay/entity/credit/UserAlipayBinding.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/taoke/autopay/entity/credit/UserCreditRecord.java 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/CreditExchangeRecordMapper.xml 100 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/UserCreditRecordMapper.xml 90 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/credit/ExchangeRateMapper.xml 77 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/credit/UserAlipayBindingMapper.xml 70 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/credit/UserCreditBalanceMapper.xml 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/java/com/taoke/autopay/PictureTest.java 83 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/taoke/autopay/dao/credit/CreditExchangeRecordMapper.java
New file
@@ -0,0 +1,41 @@
package com.taoke.autopay.dao.credit;
import java.lang.Long;
import java.lang.String;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.taoke.autopay.entity.credit.CreditExchangeRecord;
import org.yeshi.utils.mybatis.BaseMapper;
public interface CreditExchangeRecordMapper extends BaseMapper<CreditExchangeRecord> {
    CreditExchangeRecord selectByPrimaryKeyForUpdate(@Param("id") Long id);
    List<CreditExchangeRecord> list(@Param("query") DaoQuery query);
    long count(@Param("query") DaoQuery query);
    public static class DaoQuery {
        public Long id;
        public Long uid;
        public CreditExchangeRecord.ExchangeType exchangeType;
        public BigDecimal exchangeValue;
        public Integer consumedCredits;
        public Integer creditBalance;
        public String exchangeInfo1;
        public String exchangeInfo2;
        public Integer exchangeStatus;
        public String exchangeStatusDescription;
        public Date minCreateTime;
        public Date maxCreateTime;
        public Date minUpdateTime;
        public Date maxUpdateTime;
        public long start;
        public int count;
        public List<String> sortList;
    }
}
src/main/java/com/taoke/autopay/dao/credit/ExchangeRateMapper.java
New file
@@ -0,0 +1,36 @@
package com.taoke.autopay.dao.credit;
import java.lang.Long;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.taoke.autopay.entity.credit.ExchangeRate;
import org.yeshi.utils.mybatis.BaseMapper;
public interface ExchangeRateMapper extends BaseMapper<ExchangeRate> {
    ExchangeRate selectByPrimaryKeyForUpdate(@Param("id") Long id);
    List<ExchangeRate> list(@Param("query") DaoQuery query);
    long count(@Param("query") DaoQuery query);
    public static class DaoQuery {
        public Long id;
        public ExchangeRate.ExchangeType exchangeType;
        public Double rate;
        public Date minStartTime;
        public Date maxStartTime;
        public Date minEndTime;
        public Date maxEndTime;
        public Date minCreateTime;
        public Date maxCreateTime;
        public Date minUpdateTime;
        public Date maxUpdateTime;
        public long start;
        public int count;
        public List<String> sortList;
    }
}
src/main/java/com/taoke/autopay/dao/credit/UserAlipayBindingMapper.java
New file
@@ -0,0 +1,33 @@
package com.taoke.autopay.dao.credit;
import java.lang.Long;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.taoke.autopay.entity.credit.UserAlipayBinding;
import org.yeshi.utils.mybatis.BaseMapper;
public interface UserAlipayBindingMapper extends BaseMapper<UserAlipayBinding> {
    UserAlipayBinding selectByPrimaryKeyForUpdate(@Param("id") Long id);
    List<UserAlipayBinding> list(@Param("query") DaoQuery query);
    long count(@Param("query") DaoQuery query);
    public static class DaoQuery {
        public Long id;
        public Long uid;
        public String alipayName;
        public String alipayAccount;
        public Date minCreateTime;
        public Date maxCreateTime;
        public Date minUpdateTime;
        public Date maxUpdateTime;
        public long start;
        public int count;
        public List<String> sortList;
    }
}
src/main/java/com/taoke/autopay/dao/credit/UserCreditBalanceMapper.java
New file
@@ -0,0 +1,32 @@
package com.taoke.autopay.dao.credit;
import java.lang.Long;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.taoke.autopay.entity.credit.UserCreditBalance;
import org.yeshi.utils.mybatis.BaseMapper;
public interface UserCreditBalanceMapper extends BaseMapper<UserCreditBalance> {
    UserCreditBalance selectByPrimaryKeyForUpdate(@Param("id") Long id);
    List<UserCreditBalance> list(@Param("query") DaoQuery query);
    long count(@Param("query") DaoQuery query);
    public static class DaoQuery {
        public Long id;
        public Long uid;
        public Integer creditBalance;
        public Date minCreateTime;
        public Date maxCreateTime;
        public Date minUpdateTime;
        public Date maxUpdateTime;
        public long start;
        public int count;
        public List<String> sortList;
    }
}
src/main/java/com/taoke/autopay/dao/credit/UserCreditRecordMapper.java
New file
@@ -0,0 +1,36 @@
package com.taoke.autopay.dao.credit;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.taoke.autopay.entity.credit.UserCreditRecord;
import org.yeshi.utils.mybatis.BaseMapper;
public interface UserCreditRecordMapper extends BaseMapper<UserCreditRecord> {
    UserCreditRecord selectByPrimaryKeyForUpdate(@Param("id") Long id);
    List<UserCreditRecord> list(@Param("query") DaoQuery query);
    long count(@Param("query") DaoQuery query);
    public static class DaoQuery {
        public Long id;
        public Long uid;
        public Integer direction;
        public String identifierId;
        public Integer creditAmount;
        public UserCreditRecord.AcquisitionMethod acquisitionMethod;
        public UserCreditRecord.ConsumptionMethod consumptionMethod;
        public String description;
        public Date minCreateTime;
        public Date maxCreateTime;
        public Date minUpdateTime;
        public Date maxUpdateTime;
        public long start;
        public int count;
        public List<String> sortList;
    }
}
src/main/java/com/taoke/autopay/entity/credit/CreditSetting.java
New file
@@ -0,0 +1,51 @@
package com.taoke.autopay.entity.credit;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.yeshi.utils.generater.mybatis.Column;
import org.yeshi.utils.generater.mybatis.Table;
import java.util.Date;
@Data
@Table(value = "table_credit_setting")
public class CreditSetting {
    // 枚举类型:积分设置类型
    public enum CreditSettingType {
        MINIMUM_EXCHANGE_AMOUNT, // 最低兑换金额
        DOUYIN_PAYMENT_SUCCESS_CREDITS, // 抖音支付成功积分
        KUAISHOU_PAYMENT_SUCCESS_CREDITS, // 快手支付成功积分
        DAILY_EXCHANGE_LIMIT // 每日兑换次数
    }
    @Id
    @Column(name = "id")
    private Long id; // 主键ID
    @Column(name = "type")
    private CreditSettingType type; // 类型
    @Column(name = "name")
    private String name; // 名称
    @Column(name = "value")
    private String value; // 数值
    // 新增开始时间字段
    @Column(name = "start_time")
    private Date startTime; // 开始时间
    // 新增结束时间字段
    @Column(name = "end_time")
    private Date endTime; // 结束时间
    @Column(name = "create_time")
    private Date createTime; // 创建时间
    @Column(name = "update_time")
    private Date updateTime; // 更新时间
}
src/main/java/com/taoke/autopay/entity/credit/UserAlipayBinding.java
New file
@@ -0,0 +1,33 @@
package com.taoke.autopay.entity.credit;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.yeshi.utils.generater.mybatis.Column;
import org.yeshi.utils.generater.mybatis.Table;
import java.util.Date;
@Data
@Table(value = "table_user_alipay_binding")
public class UserAlipayBinding {
    @Id
    @Column(name = "id")
    private Long id; // 主键ID
    @Column(name = "uid")
    private Long uid; // 用户ID
    @Column(name = "alipay_name")
    private String alipayName; // 支付宝名称
    @Column(name = "alipay_account")
    private String alipayAccount; // 支付宝账号
    @Column(name = "create_time")
    private Date createTime; // 创建时间
    @Column(name = "update_time")
    private Date updateTime; // 更新时间
}
src/main/java/com/taoke/autopay/entity/credit/UserCreditRecord.java
@@ -16,7 +16,7 @@
    public static final int DIRECTION_GAIN = 1; // 方向获得
    // 添加常量:方向消耗
    public static final int  DIRECTION_CONSUME = 0; // 方向消耗
    public static final int DIRECTION_CONSUME = 0; // 方向消耗
    @Id
    @Column(name = "id")
@@ -29,10 +29,20 @@
    private Integer direction; // 方向(获得/消耗)
    @Column(name = "identifier_id")
    private Long identifierId; // 标识ID
    private String identifierId; // 标识ID
    @Column(name = "credit_amount")
    private Integer creditAmount; // 积分数量
    @Column(name = "acquisition_method")
    private AcquisitionMethod acquisitionMethod; // 获取方式
    @Column(name = "consumption_method")
    private ConsumptionMethod consumptionMethod; // 消耗方式
    // 新增:说明字段
    @Column(name = "description")
    private String description; // 说明
    @Column(name = "create_time")
    private Date createTime; // 创建时间
@@ -40,4 +50,33 @@
    @Column(name = "update_time")
    private Date updateTime; // 更新时间
    // 新增:获取方式枚举
    public enum AcquisitionMethod {
        COMMAND_PAYMENT("口令代付");
        private final String description;
        AcquisitionMethod(String description) {
            this.description = description;
        }
        public String getDescription() {
            return description;
        }
    }
    // 消耗方式枚举
    public enum ConsumptionMethod {
        EXCHANGE_RED_PACKET("兑换红包");
        private final String description;
        ConsumptionMethod(String description) {
            this.description = description;
        }
        public String getDescription() {
            return description;
        }
    }
}
src/main/resources/mapper/CreditExchangeRecordMapper.xml
New file
@@ -0,0 +1,100 @@
<?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.taoke.autopay.dao.credit.CreditExchangeRecordMapper">
    <resultMap id="BaseResultMap" type="com.taoke.autopay.entity.credit.CreditExchangeRecord">
        <id column="id" property="id" jdbcType="BIGINT"/>
        <result column="uid" property="uid" jdbcType="BIGINT"/>
        <result column="exchange_type" property="exchangeType" jdbcType="VARCHAR"/>
        <result column="exchange_value" property="exchangeValue" jdbcType="DECIMAL"/>
        <result column="consumed_credits" property="consumedCredits" jdbcType="INTEGER"/>
        <result column="credit_balance" property="creditBalance" jdbcType="INTEGER"/>
        <result column="exchange_info_1" property="exchangeInfo1" jdbcType="VARCHAR"/>
        <result column="exchange_info_2" property="exchangeInfo2" jdbcType="VARCHAR"/>
        <result column="exchange_status" property="exchangeStatus" jdbcType="INTEGER"/>
        <result column="exchange_status_description" property="exchangeStatusDescription" jdbcType="VARCHAR"/>
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    </resultMap>
    <sql id="Base_Column_List">id,uid,exchange_type,exchange_value,consumed_credits,credit_balance,exchange_info_1,exchange_info_2,exchange_status,exchange_status_description,create_time,update_time</sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
        <include refid="Base_Column_List"/> from table_credit_exchange_record where id = #{id,jdbcType=BIGINT}
    </select>
    <select id="selectByPrimaryKeyForUpdate" resultMap="BaseResultMap" parameterType="java.lang.Long">select
        <include refid="Base_Column_List"/> from table_credit_exchange_record where id = #{id,jdbcType=BIGINT} for update
    </select>
    <sql id="listWhereSQL">
        <if test="query.id!=null">AND id = #{query.id}</if>
        <if test="query.uid!=null">AND uid = #{query.uid}</if>
        <if test="query.exchangeType!=null">AND exchange_type = #{query.exchangeType}</if>
        <if test="query.exchangeValue!=null">AND exchange_value = #{query.exchangeValue}</if>
        <if test="query.consumedCredits!=null">AND consumed_credits = #{query.consumedCredits}</if>
        <if test="query.creditBalance!=null">AND credit_balance = #{query.creditBalance}</if>
        <if test="query.exchangeInfo1!=null">AND exchange_info_1 = #{query.exchangeInfo1}</if>
        <if test="query.exchangeInfo2!=null">AND exchange_info_2 = #{query.exchangeInfo2}</if>
        <if test="query.exchangeStatus!=null">AND exchange_status = #{query.exchangeStatus}</if>
        <if test="query.exchangeStatusDescription!=null">AND exchange_status_description = #{query.exchangeStatusDescription}</if>
        <if test="query.minCreateTime!=null">AND create_time >= #{query.minCreateTime}</if>
        <if test="query.maxCreateTime!=null">AND #{query.maxCreateTime} > create_time</if>
        <if test="query.minUpdateTime!=null">AND update_time >= #{query.minUpdateTime}</if>
        <if test="query.maxUpdateTime!=null">AND #{query.maxUpdateTime} > update_time</if>
    </sql>
    <select id="list" resultMap="BaseResultMap">select
        <include refid="Base_Column_List"/> from table_credit_exchange_record where 1=1
        <include refid="listWhereSQL"/>
        <if test="query.sortList!=null">
            <foreach collection="query.sortList" item="item" open=" order by " separator=",">#{item}</foreach>
        </if>limit #{query.start},#{query.count}
    </select>
    <select id="count" resultType="java.lang.Long">select count(*) from table_credit_exchange_record where 1=1
        <include refid="listWhereSQL"/>
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from table_credit_exchange_record where id = #{id,jdbcType=BIGINT}</delete>
    <insert id="insert" parameterType="com.taoke.autopay.entity.credit.CreditExchangeRecord" useGeneratedKeys="true" keyProperty="id">insert into table_credit_exchange_record (id,uid,exchange_type,exchange_value,consumed_credits,credit_balance,exchange_info_1,exchange_info_2,exchange_status,exchange_status_description,create_time,update_time) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{exchangeType,jdbcType=VARCHAR},#{exchangeValue,jdbcType=DECIMAL},#{consumedCredits,jdbcType=INTEGER},#{creditBalance,jdbcType=INTEGER},#{exchangeInfo1,jdbcType=VARCHAR},#{exchangeInfo2,jdbcType=VARCHAR},#{exchangeStatus,jdbcType=INTEGER},#{exchangeStatusDescription,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
    <insert id="insertSelective" parameterType="com.taoke.autopay.entity.credit.CreditExchangeRecord" useGeneratedKeys="true" keyProperty="id">insert into table_credit_exchange_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="uid != null">uid,</if>
            <if test="exchangeType != null">exchange_type,</if>
            <if test="exchangeValue != null">exchange_value,</if>
            <if test="consumedCredits != null">consumed_credits,</if>
            <if test="creditBalance != null">credit_balance,</if>
            <if test="exchangeInfo1 != null">exchange_info_1,</if>
            <if test="exchangeInfo2 != null">exchange_info_2,</if>
            <if test="exchangeStatus != null">exchange_status,</if>
            <if test="exchangeStatusDescription != null">exchange_status_description,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
        </trim>values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="uid != null">#{uid,jdbcType=BIGINT},</if>
            <if test="exchangeType != null">#{exchangeType,jdbcType=VARCHAR},</if>
            <if test="exchangeValue != null">#{exchangeValue,jdbcType=DECIMAL},</if>
            <if test="consumedCredits != null">#{consumedCredits,jdbcType=INTEGER},</if>
            <if test="creditBalance != null">#{creditBalance,jdbcType=INTEGER},</if>
            <if test="exchangeInfo1 != null">#{exchangeInfo1,jdbcType=VARCHAR},</if>
            <if test="exchangeInfo2 != null">#{exchangeInfo2,jdbcType=VARCHAR},</if>
            <if test="exchangeStatus != null">#{exchangeStatus,jdbcType=INTEGER},</if>
            <if test="exchangeStatusDescription != null">#{exchangeStatusDescription,jdbcType=VARCHAR},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey" parameterType="com.taoke.autopay.entity.credit.CreditExchangeRecord">update table_credit_exchange_record set uid = #{uid,jdbcType=BIGINT},exchange_type = #{exchangeType,jdbcType=VARCHAR},exchange_value = #{exchangeValue,jdbcType=DECIMAL},consumed_credits = #{consumedCredits,jdbcType=INTEGER},credit_balance = #{creditBalance,jdbcType=INTEGER},exchange_info_1 = #{exchangeInfo1,jdbcType=VARCHAR},exchange_info_2 = #{exchangeInfo2,jdbcType=VARCHAR},exchange_status = #{exchangeStatus,jdbcType=INTEGER},exchange_status_description = #{exchangeStatusDescription,jdbcType=VARCHAR},create_time = #{createTime,jdbcType=TIMESTAMP},update_time = #{updateTime,jdbcType=TIMESTAMP} where id = #{id,jdbcType=BIGINT}</update>
    <update id="updateByPrimaryKeySelective" parameterType="com.taoke.autopay.entity.credit.CreditExchangeRecord">update table_credit_exchange_record
        <set>
            <if test="uid != null">uid=#{uid,jdbcType=BIGINT},</if>
            <if test="exchangeType != null">exchange_type=#{exchangeType,jdbcType=VARCHAR},</if>
            <if test="exchangeValue != null">exchange_value=#{exchangeValue,jdbcType=DECIMAL},</if>
            <if test="consumedCredits != null">consumed_credits=#{consumedCredits,jdbcType=INTEGER},</if>
            <if test="creditBalance != null">credit_balance=#{creditBalance,jdbcType=INTEGER},</if>
            <if test="exchangeInfo1 != null">exchange_info_1=#{exchangeInfo1,jdbcType=VARCHAR},</if>
            <if test="exchangeInfo2 != null">exchange_info_2=#{exchangeInfo2,jdbcType=VARCHAR},</if>
            <if test="exchangeStatus != null">exchange_status=#{exchangeStatus,jdbcType=INTEGER},</if>
            <if test="exchangeStatusDescription != null">exchange_status_description=#{exchangeStatusDescription,jdbcType=VARCHAR},</if>
            <if test="createTime != null">create_time=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
        </set> where id = #{id,jdbcType=BIGINT}
    </update>
</mapper>
src/main/resources/mapper/UserCreditRecordMapper.xml
New file
@@ -0,0 +1,90 @@
<?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.taoke.autopay.dao.credit.UserCreditRecordMapper">
    <resultMap id="BaseResultMap" type="com.taoke.autopay.entity.credit.UserCreditRecord">
        <id column="id" property="id" jdbcType="BIGINT"/>
        <result column="uid" property="uid" jdbcType="BIGINT"/>
        <result column="direction" property="direction" jdbcType="INTEGER"/>
        <result column="identifier_id" property="identifierId" jdbcType="VARCHAR"/>
        <result column="credit_amount" property="creditAmount" jdbcType="INTEGER"/>
        <result column="acquisition_method" property="acquisitionMethod" jdbcType="VARCHAR"/>
        <result column="consumption_method" property="consumptionMethod" jdbcType="VARCHAR"/>
        <result column="description" property="description" jdbcType="VARCHAR"/>
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    </resultMap>
    <sql id="Base_Column_List">id,uid,direction,identifier_id,credit_amount,acquisition_method,consumption_method,description,create_time,update_time</sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
        <include refid="Base_Column_List"/> from table_user_credit_record where id = #{id,jdbcType=BIGINT}
    </select>
    <select id="selectByPrimaryKeyForUpdate" resultMap="BaseResultMap" parameterType="java.lang.Long">select
        <include refid="Base_Column_List"/> from table_user_credit_record where id = #{id,jdbcType=BIGINT} for update
    </select>
    <sql id="listWhereSQL">
        <if test="query.id!=null">AND id = #{query.id}</if>
        <if test="query.uid!=null">AND uid = #{query.uid}</if>
        <if test="query.direction!=null">AND direction = #{query.direction}</if>
        <if test="query.identifierId!=null">AND identifier_id = #{query.identifierId}</if>
        <if test="query.creditAmount!=null">AND credit_amount = #{query.creditAmount}</if>
        <if test="query.acquisitionMethod!=null">AND acquisition_method = #{query.acquisitionMethod}</if>
        <if test="query.consumptionMethod!=null">AND consumption_method = #{query.consumptionMethod}</if>
        <if test="query.description!=null">AND description = #{query.description}</if>
        <if test="query.minCreateTime!=null">AND create_time >= #{query.minCreateTime}</if>
        <if test="query.maxCreateTime!=null">AND #{query.maxCreateTime} > create_time</if>
        <if test="query.minUpdateTime!=null">AND update_time >= #{query.minUpdateTime}</if>
        <if test="query.maxUpdateTime!=null">AND #{query.maxUpdateTime} > update_time</if>
    </sql>
    <select id="list" resultMap="BaseResultMap">select
        <include refid="Base_Column_List"/> from table_user_credit_record where 1=1
        <include refid="listWhereSQL"/>
        <if test="query.sortList!=null">
            <foreach collection="query.sortList" item="item" open=" order by " separator=",">#{item}</foreach>
        </if>limit #{query.start},#{query.count}
    </select>
    <select id="count" resultType="java.lang.Long">select count(*) from table_user_credit_record where 1=1
        <include refid="listWhereSQL"/>
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from table_user_credit_record where id = #{id,jdbcType=BIGINT}</delete>
    <insert id="insert" parameterType="com.taoke.autopay.entity.credit.UserCreditRecord" useGeneratedKeys="true" keyProperty="id">insert into table_user_credit_record (id,uid,direction,identifier_id,credit_amount,acquisition_method,consumption_method,description,create_time,update_time) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{direction,jdbcType=INTEGER},#{identifierId,jdbcType=VARCHAR},#{creditAmount,jdbcType=INTEGER},#{acquisitionMethod,jdbcType=VARCHAR},#{consumptionMethod,jdbcType=VARCHAR},#{description,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
    <insert id="insertSelective" parameterType="com.taoke.autopay.entity.credit.UserCreditRecord" useGeneratedKeys="true" keyProperty="id">insert into table_user_credit_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="uid != null">uid,</if>
            <if test="direction != null">direction,</if>
            <if test="identifierId != null">identifier_id,</if>
            <if test="creditAmount != null">credit_amount,</if>
            <if test="acquisitionMethod != null">acquisition_method,</if>
            <if test="consumptionMethod != null">consumption_method,</if>
            <if test="description != null">description,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
        </trim>values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="uid != null">#{uid,jdbcType=BIGINT},</if>
            <if test="direction != null">#{direction,jdbcType=INTEGER},</if>
            <if test="identifierId != null">#{identifierId,jdbcType=VARCHAR},</if>
            <if test="creditAmount != null">#{creditAmount,jdbcType=INTEGER},</if>
            <if test="acquisitionMethod != null">#{acquisitionMethod,jdbcType=VARCHAR},</if>
            <if test="consumptionMethod != null">#{consumptionMethod,jdbcType=VARCHAR},</if>
            <if test="description != null">#{description,jdbcType=VARCHAR},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey" parameterType="com.taoke.autopay.entity.credit.UserCreditRecord">update table_user_credit_record set uid = #{uid,jdbcType=BIGINT},direction = #{direction,jdbcType=INTEGER},identifier_id = #{identifierId,jdbcType=VARCHAR},credit_amount = #{creditAmount,jdbcType=INTEGER},acquisition_method = #{acquisitionMethod,jdbcType=VARCHAR},consumption_method = #{consumptionMethod,jdbcType=VARCHAR},description = #{description,jdbcType=VARCHAR},create_time = #{createTime,jdbcType=TIMESTAMP},update_time = #{updateTime,jdbcType=TIMESTAMP} where id = #{id,jdbcType=BIGINT}</update>
    <update id="updateByPrimaryKeySelective" parameterType="com.taoke.autopay.entity.credit.UserCreditRecord">update table_user_credit_record
        <set>
            <if test="uid != null">uid=#{uid,jdbcType=BIGINT},</if>
            <if test="direction != null">direction=#{direction,jdbcType=INTEGER},</if>
            <if test="identifierId != null">identifier_id=#{identifierId,jdbcType=VARCHAR},</if>
            <if test="creditAmount != null">credit_amount=#{creditAmount,jdbcType=INTEGER},</if>
            <if test="acquisitionMethod != null">acquisition_method=#{acquisitionMethod,jdbcType=VARCHAR},</if>
            <if test="consumptionMethod != null">consumption_method=#{consumptionMethod,jdbcType=VARCHAR},</if>
            <if test="description != null">description=#{description,jdbcType=VARCHAR},</if>
            <if test="createTime != null">create_time=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
        </set> where id = #{id,jdbcType=BIGINT}
    </update>
</mapper>
src/main/resources/mapper/credit/ExchangeRateMapper.xml
New file
@@ -0,0 +1,77 @@
<?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.taoke.autopay.dao.credit.ExchangeRateMapper">
    <resultMap id="BaseResultMap" type="com.taoke.autopay.entity.credit.ExchangeRate">
        <id column="id" property="id" jdbcType="BIGINT"/>
        <result column="exchange_type" property="exchangeType" jdbcType="VARCHAR"/>
        <result column="rate" property="rate" jdbcType="DECIMAL"/>
        <result column="start_time" property="startTime" jdbcType="TIMESTAMP"/>
        <result column="end_time" property="endTime" jdbcType="TIMESTAMP"/>
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    </resultMap>
    <sql id="Base_Column_List">id,exchange_type,rate,start_time,end_time,create_time,update_time</sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
        <include refid="Base_Column_List"/> from table_exchange_rate where id = #{id,jdbcType=BIGINT}
    </select>
    <select id="selectByPrimaryKeyForUpdate" resultMap="BaseResultMap" parameterType="java.lang.Long">select
        <include refid="Base_Column_List"/> from table_exchange_rate where id = #{id,jdbcType=BIGINT} for update
    </select>
    <sql id="listWhereSQL">
        <if test="query.id!=null">AND id = #{query.id}</if>
        <if test="query.exchangeType!=null">AND exchange_type = #{query.exchangeType}</if>
        <if test="query.rate!=null">AND rate = #{query.rate}</if>
        <if test="query.minStartTime!=null">AND start_time >= #{query.minStartTime}</if>
        <if test="query.maxStartTime!=null">AND #{query.maxStartTime} > start_time</if>
        <if test="query.minEndTime!=null">AND end_time >= #{query.minEndTime}</if>
        <if test="query.maxEndTime!=null">AND #{query.maxEndTime} > end_time</if>
        <if test="query.minCreateTime!=null">AND create_time >= #{query.minCreateTime}</if>
        <if test="query.maxCreateTime!=null">AND #{query.maxCreateTime} > create_time</if>
        <if test="query.minUpdateTime!=null">AND update_time >= #{query.minUpdateTime}</if>
        <if test="query.maxUpdateTime!=null">AND #{query.maxUpdateTime} > update_time</if>
    </sql>
    <select id="list" resultMap="BaseResultMap">select
        <include refid="Base_Column_List"/> from table_exchange_rate where 1=1
        <include refid="listWhereSQL"/>
        <if test="query.sortList!=null">
            <foreach collection="query.sortList" item="item" open=" order by " separator=",">#{item}</foreach>
        </if>limit #{query.start},#{query.count}
    </select>
    <select id="count" resultType="java.lang.Long">select count(*) from table_exchange_rate where 1=1
        <include refid="listWhereSQL"/>
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from table_exchange_rate where id = #{id,jdbcType=BIGINT}</delete>
    <insert id="insert" parameterType="com.taoke.autopay.entity.credit.ExchangeRate" useGeneratedKeys="true" keyProperty="id">insert into table_exchange_rate (id,exchange_type,rate,start_time,end_time,create_time,update_time) values (#{id,jdbcType=BIGINT},#{exchangeType,jdbcType=VARCHAR},#{rate,jdbcType=DECIMAL},#{startTime,jdbcType=TIMESTAMP},#{endTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
    <insert id="insertSelective" parameterType="com.taoke.autopay.entity.credit.ExchangeRate" useGeneratedKeys="true" keyProperty="id">insert into table_exchange_rate
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="exchangeType != null">exchange_type,</if>
            <if test="rate != null">rate,</if>
            <if test="startTime != null">start_time,</if>
            <if test="endTime != null">end_time,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
        </trim>values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="exchangeType != null">#{exchangeType,jdbcType=VARCHAR},</if>
            <if test="rate != null">#{rate,jdbcType=DECIMAL},</if>
            <if test="startTime != null">#{startTime,jdbcType=TIMESTAMP},</if>
            <if test="endTime != null">#{endTime,jdbcType=TIMESTAMP},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey" parameterType="com.taoke.autopay.entity.credit.ExchangeRate">update table_exchange_rate set exchange_type = #{exchangeType,jdbcType=VARCHAR},rate = #{rate,jdbcType=DECIMAL},start_time = #{startTime,jdbcType=TIMESTAMP},end_time = #{endTime,jdbcType=TIMESTAMP},create_time = #{createTime,jdbcType=TIMESTAMP},update_time = #{updateTime,jdbcType=TIMESTAMP} where id = #{id,jdbcType=BIGINT}</update>
    <update id="updateByPrimaryKeySelective" parameterType="com.taoke.autopay.entity.credit.ExchangeRate">update table_exchange_rate
        <set>
            <if test="exchangeType != null">exchange_type=#{exchangeType,jdbcType=VARCHAR},</if>
            <if test="rate != null">rate=#{rate,jdbcType=DECIMAL},</if>
            <if test="startTime != null">start_time=#{startTime,jdbcType=TIMESTAMP},</if>
            <if test="endTime != null">end_time=#{endTime,jdbcType=TIMESTAMP},</if>
            <if test="createTime != null">create_time=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
        </set> where id = #{id,jdbcType=BIGINT}
    </update>
</mapper>
src/main/resources/mapper/credit/UserAlipayBindingMapper.xml
New file
@@ -0,0 +1,70 @@
<?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.taoke.autopay.dao.credit.UserAlipayBindingMapper">
    <resultMap id="BaseResultMap" type="com.taoke.autopay.entity.credit.UserAlipayBinding">
        <id column="id" property="id" jdbcType="BIGINT"/>
        <result column="uid" property="uid" jdbcType="BIGINT"/>
        <result column="alipay_name" property="alipayName" jdbcType="VARCHAR"/>
        <result column="alipay_account" property="alipayAccount" jdbcType="VARCHAR"/>
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    </resultMap>
    <sql id="Base_Column_List">id,uid,alipay_name,alipay_account,create_time,update_time</sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
        <include refid="Base_Column_List"/> from table_user_alipay_binding where id = #{id,jdbcType=BIGINT}
    </select>
    <select id="selectByPrimaryKeyForUpdate" resultMap="BaseResultMap" parameterType="java.lang.Long">select
        <include refid="Base_Column_List"/> from table_user_alipay_binding where id = #{id,jdbcType=BIGINT} for update
    </select>
    <sql id="listWhereSQL">
        <if test="query.id!=null">AND id = #{query.id}</if>
        <if test="query.uid!=null">AND uid = #{query.uid}</if>
        <if test="query.alipayName!=null">AND alipay_name = #{query.alipayName}</if>
        <if test="query.alipayAccount!=null">AND alipay_account = #{query.alipayAccount}</if>
        <if test="query.minCreateTime!=null">AND create_time >= #{query.minCreateTime}</if>
        <if test="query.maxCreateTime!=null">AND #{query.maxCreateTime} > create_time</if>
        <if test="query.minUpdateTime!=null">AND update_time >= #{query.minUpdateTime}</if>
        <if test="query.maxUpdateTime!=null">AND #{query.maxUpdateTime} > update_time</if>
    </sql>
    <select id="list" resultMap="BaseResultMap">select
        <include refid="Base_Column_List"/> from table_user_alipay_binding where 1=1
        <include refid="listWhereSQL"/>
        <if test="query.sortList!=null">
            <foreach collection="query.sortList" item="item" open=" order by " separator=",">#{item}</foreach>
        </if>limit #{query.start},#{query.count}
    </select>
    <select id="count" resultType="java.lang.Long">select count(*) from table_user_alipay_binding where 1=1
        <include refid="listWhereSQL"/>
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from table_user_alipay_binding where id = #{id,jdbcType=BIGINT}</delete>
    <insert id="insert" parameterType="com.taoke.autopay.entity.credit.UserAlipayBinding" useGeneratedKeys="true" keyProperty="id">insert into table_user_alipay_binding (id,uid,alipay_name,alipay_account,create_time,update_time) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{alipayName,jdbcType=VARCHAR},#{alipayAccount,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
    <insert id="insertSelective" parameterType="com.taoke.autopay.entity.credit.UserAlipayBinding" useGeneratedKeys="true" keyProperty="id">insert into table_user_alipay_binding
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="uid != null">uid,</if>
            <if test="alipayName != null">alipay_name,</if>
            <if test="alipayAccount != null">alipay_account,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
        </trim>values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="uid != null">#{uid,jdbcType=BIGINT},</if>
            <if test="alipayName != null">#{alipayName,jdbcType=VARCHAR},</if>
            <if test="alipayAccount != null">#{alipayAccount,jdbcType=VARCHAR},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey" parameterType="com.taoke.autopay.entity.credit.UserAlipayBinding">update table_user_alipay_binding set uid = #{uid,jdbcType=BIGINT},alipay_name = #{alipayName,jdbcType=VARCHAR},alipay_account = #{alipayAccount,jdbcType=VARCHAR},create_time = #{createTime,jdbcType=TIMESTAMP},update_time = #{updateTime,jdbcType=TIMESTAMP} where id = #{id,jdbcType=BIGINT}</update>
    <update id="updateByPrimaryKeySelective" parameterType="com.taoke.autopay.entity.credit.UserAlipayBinding">update table_user_alipay_binding
        <set>
            <if test="uid != null">uid=#{uid,jdbcType=BIGINT},</if>
            <if test="alipayName != null">alipay_name=#{alipayName,jdbcType=VARCHAR},</if>
            <if test="alipayAccount != null">alipay_account=#{alipayAccount,jdbcType=VARCHAR},</if>
            <if test="createTime != null">create_time=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
        </set> where id = #{id,jdbcType=BIGINT}
    </update>
</mapper>
src/main/resources/mapper/credit/UserCreditBalanceMapper.xml
New file
@@ -0,0 +1,65 @@
<?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.taoke.autopay.dao.credit.UserCreditBalanceMapper">
    <resultMap id="BaseResultMap" type="com.taoke.autopay.entity.credit.UserCreditBalance">
        <id column="id" property="id" jdbcType="BIGINT"/>
        <result column="uid" property="uid" jdbcType="BIGINT"/>
        <result column="credit_balance" property="creditBalance" jdbcType="DECIMAL"/>
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    </resultMap>
    <sql id="Base_Column_List">id,uid,credit_balance,create_time,update_time</sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
        <include refid="Base_Column_List"/> from table_user_credit_balance where id = #{id,jdbcType=BIGINT}
    </select>
    <select id="selectByPrimaryKeyForUpdate" resultMap="BaseResultMap" parameterType="java.lang.Long">select
        <include refid="Base_Column_List"/> from table_user_credit_balance where id = #{id,jdbcType=BIGINT} for update
    </select>
    <sql id="listWhereSQL">
        <if test="query.id!=null">AND id = #{query.id}</if>
        <if test="query.uid!=null">AND uid = #{query.uid}</if>
        <if test="query.creditBalance!=null">AND credit_balance = #{query.creditBalance}</if>
        <if test="query.minCreateTime!=null">AND create_time >= #{query.minCreateTime}</if>
        <if test="query.maxCreateTime!=null">AND #{query.maxCreateTime} > create_time</if>
        <if test="query.minUpdateTime!=null">AND update_time >= #{query.minUpdateTime}</if>
        <if test="query.maxUpdateTime!=null">AND #{query.maxUpdateTime} > update_time</if>
    </sql>
    <select id="list" resultMap="BaseResultMap">select
        <include refid="Base_Column_List"/> from table_user_credit_balance where 1=1
        <include refid="listWhereSQL"/>
        <if test="query.sortList!=null">
            <foreach collection="query.sortList" item="item" open=" order by " separator=",">#{item}</foreach>
        </if>limit #{query.start},#{query.count}
    </select>
    <select id="count" resultType="java.lang.Long">select count(*) from table_user_credit_balance where 1=1
        <include refid="listWhereSQL"/>
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from table_user_credit_balance where id = #{id,jdbcType=BIGINT}</delete>
    <insert id="insert" parameterType="com.taoke.autopay.entity.credit.UserCreditBalance" useGeneratedKeys="true" keyProperty="id">insert into table_user_credit_balance (id,uid,credit_balance,create_time,update_time) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{creditBalance,jdbcType=DECIMAL},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
    <insert id="insertSelective" parameterType="com.taoke.autopay.entity.credit.UserCreditBalance" useGeneratedKeys="true" keyProperty="id">insert into table_user_credit_balance
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="uid != null">uid,</if>
            <if test="creditBalance != null">credit_balance,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
        </trim>values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="uid != null">#{uid,jdbcType=BIGINT},</if>
            <if test="creditBalance != null">#{creditBalance,jdbcType=DECIMAL},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey" parameterType="com.taoke.autopay.entity.credit.UserCreditBalance">update table_user_credit_balance set uid = #{uid,jdbcType=BIGINT},credit_balance = #{creditBalance,jdbcType=DECIMAL},create_time = #{createTime,jdbcType=TIMESTAMP},update_time = #{updateTime,jdbcType=TIMESTAMP} where id = #{id,jdbcType=BIGINT}</update>
    <update id="updateByPrimaryKeySelective" parameterType="com.taoke.autopay.entity.credit.UserCreditBalance">update table_user_credit_balance
        <set>
            <if test="uid != null">uid=#{uid,jdbcType=BIGINT},</if>
            <if test="creditBalance != null">credit_balance=#{creditBalance,jdbcType=DECIMAL},</if>
            <if test="createTime != null">create_time=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
        </set> where id = #{id,jdbcType=BIGINT}
    </update>
</mapper>
src/test/java/com/taoke/autopay/PictureTest.java
New file
@@ -0,0 +1,83 @@
package com.taoke.autopay;
import org.apache.commons.io.FileUtils;
import org.yeshi.utils.FileUtil;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.color.ColorSpace;
import java.awt.image.BufferedImage;
import java.awt.image.ColorConvertOp;
import java.io.File;
import java.io.IOException;
public class PictureTest {
    public static void resizeImage(File inputFile, File outputFile, int targetWidth, int targetHeight) throws IOException {
        // 步骤 1: 读取原始图片
        BufferedImage originalImage = ImageIO.read(inputFile);
        // 步骤 2: 创建缩放后的图片
        BufferedImage resizedImage = new BufferedImage(targetWidth, targetHeight, originalImage.getType());
        resizedImage.getGraphics().drawImage(originalImage.getScaledInstance(targetWidth, targetHeight, java.awt.Image.SCALE_SMOOTH), 0, 0, null);
        // 或者使用Graphics2D进行更复杂的图像操作(例如保持纵横比)
        // Graphics2D g2d = resizedImage.createGraphics();
        // g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
        // g2d.drawImage(originalImage, 0, 0, targetWidth, targetHeight, null);
        // g2d.dispose();
        // 步骤 3: 保存压缩后的图片
        ImageIO.write(resizedImage, "jpg", outputFile); // 可以根据需要改为png等格式
    }
    public static BufferedImage convertToGrayscale(BufferedImage img) {
        ColorSpace graySpace = ColorSpace.getInstance(ColorSpace.CS_GRAY);
        ColorConvertOp op = new ColorConvertOp(graySpace, null);
        return op.filter(img, null);
    }
    public static double compareImages(File file1, File file2) throws IOException {
        BufferedImage img1 = ImageIO.read(file1);
        BufferedImage img2 = ImageIO.read(file2);
        // 将图片转换为灰度图像
        img1 = convertToGrayscale(img1);
        img2 = convertToGrayscale(img2);
        if (img1.getWidth() != img2.getWidth() || img1.getHeight() != img2.getHeight()) {
            return 0; // 如果尺寸不同,直接返回0
        }
        int width = img1.getWidth();
        int height = img1.getHeight();
        int totalDiff = 0;
        for (int y = 0; y < height; y++) {
            for (int x = 0; x < width; x++) {
                int rgb1 = img1.getRGB(x, y);
                int rgb2 = img2.getRGB(x, y);
                int r1 = (rgb1 >> 16) & 0xff;
                int r2 = (rgb2 >> 16) & 0xff;
                totalDiff += Math.abs(r1 - r2);
            }
        }
        double maxDiff =  255 * width * height;
        return (maxDiff - totalDiff) / maxDiff;
    }
    public static void main(String[] args) throws IOException {
        try {
            File file1 = new File("C:\\Users\\Administrator\\Desktop\\132.jfif");
            File file2 = new File("C:\\Users\\Administrator\\Desktop\\132_c.jfif");
            double similarity = compareImages(file1, file2);
            System.out.println("图片相似度: " + similarity);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}