| | |
| | | package com.ks.vip.pojo.DO; |
| | | |
| | | import com.ks.vip.pojo.Enums.VIPEnum; |
| | | import org.yeshi.utils.generater.mybatis.Column; |
| | | import org.yeshi.utils.generater.mybatis.Table; |
| | | |
| | |
| | | |
| | | @Column(name = "g_icon") |
| | | private String icon; |
| | | |
| | | @Column(name = "g_identity") |
| | | private VIPEnum identity; |
| | | |
| | | @Column(name = "g_sort") |
| | | private Integer sort; |
| | |
| | | public void setUpdateTime(Date updateTime) { |
| | | this.updateTime = updateTime; |
| | | } |
| | | |
| | | public VIPEnum getIdentity() { |
| | | return identity; |
| | | } |
| | | |
| | | public void setIdentity(VIPEnum identity) { |
| | | this.identity = identity; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.vip.pojo.Enums; |
| | | |
| | | |
| | | /** |
| | | * 会员等级 |
| | | */ |
| | | public enum VIPEnum { |
| | | |
| | | bronze("青铜"), |
| | | silver("白银"), |
| | | platinum("铂金"); |
| | | |
| | | private final String desc; |
| | | |
| | | private VIPEnum(String desc) { |
| | | this.desc = desc; |
| | | } |
| | | |
| | | public String getDesc() { |
| | | return desc; |
| | | } |
| | | } |
| | |
| | | |
| | | import com.ks.vip.pojo.DO.VipCenter; |
| | | import com.ks.vip.pojo.DO.VipCombo; |
| | | import com.ks.vip.pojo.DO.VipGrade; |
| | | import com.ks.vip.pojo.DO.VipGradePotence; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | |
| | | public void deteleByUid(String id); |
| | | |
| | | |
| | | /** |
| | | * 获取会员等级 |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | public VipGrade getVipGrade(String uid); |
| | | |
| | | |
| | | |
| | | /** |
| | | * 验证会员状态 |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | public boolean verifyVIP(String uid); |
| | | |
| | | /** |
| | | * 添加会员权益 |
| | | * @param uid |
| | | * @param gradeId |
| | | * @param validDays |
| | | * @param orderId |
| | | */ |
| | | public void saveVipCenter(String uid, Long gradeId, Integer validDays, Long orderId); |
| | | |
| | | |
| | | /** |
| | | * 获取会员权益 |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | public VipGradePotence getVipPotence(String uid); |
| | | |
| | | } |
| | |
| | | public void delete(Long id); |
| | | |
| | | public List<VipGrade> getValidList(); |
| | | |
| | | public VipGrade getByIdentity(String identity); |
| | | |
| | | public VipGrade selectByPrimaryKey(Long id); |
| | | } |
| | |
| | | List<VipGrade> listByPage(@Param("query") VipGradeQuery query); |
| | | |
| | | long count(@Param("query")VipGradeQuery query); |
| | | |
| | | |
| | | /** |
| | | * 根据唯一标识查询 |
| | | * @param identity |
| | | * @return |
| | | */ |
| | | VipGrade getByIdentity(@Param("identity") String identity); |
| | | } |
New file |
| | |
| | | package com.ks.vip.pojo.mybatishandler; |
| | | |
| | | import java.sql.CallableStatement; |
| | | import java.sql.PreparedStatement; |
| | | import java.sql.ResultSet; |
| | | import java.sql.SQLException; |
| | | |
| | | import com.ks.vip.pojo.Enums.VIPEnum; |
| | | import org.apache.ibatis.type.BaseTypeHandler; |
| | | import org.apache.ibatis.type.JdbcType; |
| | | |
| | | |
| | | public class VIPEnumHandler extends BaseTypeHandler<VIPEnum> { |
| | | |
| | | @Override |
| | | public VIPEnum getNullableResult(ResultSet arg0, String arg1) throws SQLException { |
| | | String key = arg0.getString(arg1); |
| | | if (arg0.wasNull()) { |
| | | return null; |
| | | } else { |
| | | return VIPEnum.valueOf(key); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public VIPEnum getNullableResult(ResultSet arg0, int arg1) throws SQLException { |
| | | String key = arg0.getString(arg1); |
| | | if (arg0.wasNull()) { |
| | | return null; |
| | | } else { |
| | | // 根据数据库中的key值,定位SexEnum子类 |
| | | return VIPEnum.valueOf(key); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public VIPEnum getNullableResult(CallableStatement arg0, int arg1) throws SQLException { |
| | | String key = arg0.getString(arg1); |
| | | if (arg0.wasNull()) { |
| | | return null; |
| | | } else { |
| | | // 根据数据库中的key值,定位SexEnum子类 |
| | | return VIPEnum.valueOf(key); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void setNonNullParameter(PreparedStatement arg0, int arg1, VIPEnum arg2, JdbcType arg3) |
| | | throws SQLException { |
| | | arg0.setString(arg1, arg2.name()); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | //id |
| | | public Long id; |
| | | //状态 |
| | | public Integer state; |
| | | |
| | | // 名称 |
| | | public String name; |
| | | |
| | | //状态 |
| | | public String identity; |
| | | |
| | | //状态 |
| | | public Integer state; |
| | | |
| | | } |
| | |
| | | |
| | | import com.ks.vip.mapper.VipCenterMapper; |
| | | import com.ks.vip.mapper.VipComboMapper; |
| | | import com.ks.vip.pojo.DO.VipCenter; |
| | | import com.ks.vip.pojo.DO.VipCenterRecord; |
| | | import com.ks.vip.pojo.DO.VipCombo; |
| | | import com.ks.vip.pojo.DO.*; |
| | | import com.ks.vip.query.VipCenterQuery; |
| | | import com.ks.vip.query.VipComboQuery; |
| | | import com.ks.vip.service.VipCenterRecordService; |
| | | import com.ks.vip.service.VipCenterService; |
| | | import com.ks.vip.service.VipComboService; |
| | | import com.ks.vip.service.*; |
| | | import org.apache.dubbo.config.annotation.Service; |
| | | import org.yeshi.utils.DateUtil; |
| | | |
| | |
| | | |
| | | @Resource |
| | | private VipCenterRecordService vipCenterRecordService; |
| | | |
| | | @Resource |
| | | private VipGradeService vipGradeService; |
| | | |
| | | @Resource |
| | | private VipGradePotenceService vipGradePotenceService; |
| | | |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | public void getVipPotence(String uid) { |
| | | @Override |
| | | public boolean verifyVIP(String uid) { |
| | | VipCenter vipCenter = vipCenterMapper.getByUid(uid); |
| | | if (vipCenter.getGradeId() != null) { |
| | | if (vipCenter == null) { |
| | | return false; |
| | | } |
| | | // 验证会员是否有效 |
| | | long nowTime = java.lang.System.currentTimeMillis(); |
| | | if (vipCenter.getStartTime().getTime() <= nowTime && vipCenter.getEndTime().getTime() >= nowTime) { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public VipGradePotence getVipPotence(String uid) { |
| | | VipCenter vipCenter = vipCenterMapper.getByUid(uid); |
| | | if (vipCenter == null || vipCenter.getGradeId() == null) { |
| | | return null; |
| | | } |
| | | |
| | | |
| | | long nowTime = java.lang.System.currentTimeMillis(); |
| | | if (vipCenter.getStartTime().getTime() <= nowTime && vipCenter.getEndTime().getTime() >= nowTime) { |
| | | return vipGradePotenceService.selectByPrimaryKey(vipCenter.getGradeId()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public VipGrade getVipGrade(String uid) { |
| | | VipCenter vipCenter = vipCenterMapper.getByUid(uid); |
| | | if (vipCenter == null || vipCenter.getGradeId() == null) { |
| | | return null; |
| | | } |
| | | return vipGradeService.selectByPrimaryKey(vipCenter.getGradeId()); |
| | | } |
| | | |
| | | } |
| | |
| | | @Override |
| | | public long count(VipGrade t) { |
| | | VipGradeQuery query = new VipGradeQuery(); |
| | | query.id = t.getId(); |
| | | query.name = t.getName(); |
| | | if (t.getIdentity() != null) { |
| | | query.identity = t.getIdentity().name(); |
| | | } |
| | | query.state = t.getState(); |
| | | return vipGradeMapper.count(query); |
| | | } |
| | |
| | | @Override |
| | | public List<VipGrade> listByPage(int page, int pageSize, VipGrade t) { |
| | | VipGradeQuery query = new VipGradeQuery(); |
| | | query.id = t.getId(); |
| | | query.name = t.getName(); |
| | | if (t.getIdentity() != null) { |
| | | query.identity = t.getIdentity().name(); |
| | | } |
| | | query.state = t.getState(); |
| | | query.start = (page - 1) * pageSize; |
| | | query.count = pageSize; |
| | |
| | | return listByPage(0, Integer.MAX_VALUE, t); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public VipGrade getByIdentity(String identity){ |
| | | return vipGradeMapper.getByIdentity(identity); |
| | | } |
| | | |
| | | @Override |
| | | public VipGrade selectByPrimaryKey(Long id){ |
| | | return vipGradeMapper.selectByPrimaryKey(id); |
| | | } |
| | | } |
| | |
| | | <id column="g_id" property="id" jdbcType="BIGINT"/> |
| | | <result column="g_name" property="name" jdbcType="VARCHAR"/> |
| | | <result column="g_icon" property="icon" jdbcType="VARCHAR"/> |
| | | <result column="g_identity" property="identity" |
| | | typeHandler="com.ks.vip.pojo.mybatishandler.VIPEnumHandler" /> |
| | | <result column="g_sort" property="sort" jdbcType="INTEGER"/> |
| | | <result column="g_state" property="state" jdbcType="INTEGER"/> |
| | | <result column="g_creator_id" property="creatorId" jdbcType="BIGINT"/> |
| | |
| | | <result column="g_updator_id" property="updatorId" jdbcType="BIGINT"/> |
| | | <result column="g_update_time" property="updateTime" jdbcType="TIMESTAMP"/> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">g_id,g_name,g_icon,g_sort,g_state,g_creator_id,g_create_time,g_updator_id,g_update_time</sql> |
| | | <sql id="Base_Column_List">g_id,g_name,g_icon,g_identity,g_sort,g_state,g_creator_id,g_create_time,g_updator_id,g_update_time</sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select |
| | | <include refid="Base_Column_List"/>from vip_grade where g_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from vip_grade where g_id = #{id,jdbcType=BIGINT}</delete> |
| | | <insert id="insert" parameterType="com.ks.vip.pojo.DO.VipGrade" useGeneratedKeys="true" keyProperty="id">insert into vip_grade (g_id,g_name,g_icon,g_sort,g_state,g_creator_id,g_create_time,g_updator_id,g_update_time) values (#{id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{icon,jdbcType=VARCHAR},#{sort,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{creatorId,jdbcType=BIGINT},#{createTime,jdbcType=TIMESTAMP},#{updatorId,jdbcType=BIGINT},#{updateTime,jdbcType=TIMESTAMP})</insert> |
| | | <insert id="insert" parameterType="com.ks.vip.pojo.DO.VipGrade" useGeneratedKeys="true" keyProperty="id">insert into vip_grade (g_id,g_name,g_icon,g_identity,g_sort,g_state,g_creator_id,g_create_time,g_updator_id,g_update_time) values (#{id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{icon,jdbcType=VARCHAR},#{identity,jdbcType=VARCHAR},#{sort,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{creatorId,jdbcType=BIGINT},#{createTime,jdbcType=TIMESTAMP},#{updatorId,jdbcType=BIGINT},#{updateTime,jdbcType=TIMESTAMP})</insert> |
| | | <insert id="insertSelective" parameterType="com.ks.vip.pojo.DO.VipGrade" useGeneratedKeys="true" keyProperty="id">insert into vip_grade |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">g_id,</if> |
| | | <if test="name != null">g_name,</if> |
| | | <if test="icon != null">g_icon,</if> |
| | | <if test="identity != null">g_identity,</if> |
| | | <if test="sort != null">g_sort,</if> |
| | | <if test="state != null">g_state,</if> |
| | | <if test="creatorId != null">g_creator_id,</if> |
| | |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="name != null">#{name,jdbcType=VARCHAR},</if> |
| | | <if test="icon != null">#{icon,jdbcType=VARCHAR},</if> |
| | | <if test="identity != null">#{identity,jdbcType=VARCHAR},</if> |
| | | <if test="sort != null">#{sort,jdbcType=INTEGER},</if> |
| | | <if test="state != null">#{state,jdbcType=INTEGER},</if> |
| | | <if test="creatorId != null">#{creatorId,jdbcType=BIGINT},</if> |
| | |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.ks.vip.pojo.DO.VipGrade">update vip_grade set g_name = #{name,jdbcType=VARCHAR},g_icon = #{icon,jdbcType=VARCHAR},g_sort = #{sort,jdbcType=INTEGER},g_state = #{state,jdbcType=INTEGER},g_creator_id = #{creatorId,jdbcType=BIGINT},g_create_time = #{createTime,jdbcType=TIMESTAMP},g_updator_id = #{updatorId,jdbcType=BIGINT},g_update_time = #{updateTime,jdbcType=TIMESTAMP} where g_id = #{id,jdbcType=BIGINT}</update> |
| | | <update id="updateByPrimaryKey" parameterType="com.ks.vip.pojo.DO.VipGrade">update vip_grade set g_name = #{name,jdbcType=VARCHAR},g_icon = #{icon,jdbcType=VARCHAR},g_identity = #{identity,jdbcType=VARCHAR},g_sort = #{sort,jdbcType=INTEGER},g_state = #{state,jdbcType=INTEGER},g_creator_id = #{creatorId,jdbcType=BIGINT},g_create_time = #{createTime,jdbcType=TIMESTAMP},g_updator_id = #{updatorId,jdbcType=BIGINT},g_update_time = #{updateTime,jdbcType=TIMESTAMP} where g_id = #{id,jdbcType=BIGINT}</update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.ks.vip.pojo.DO.VipGrade">update vip_grade |
| | | <set> |
| | | <if test="name != null">g_name=#{name,jdbcType=VARCHAR},</if> |
| | | <if test="icon != null">g_icon=#{icon,jdbcType=VARCHAR},</if> |
| | | <if test="identity != null">g_identity=#{identity,jdbcType=VARCHAR},</if> |
| | | <if test="sort != null">g_sort=#{sort,jdbcType=INTEGER},</if> |
| | | <if test="state != null">g_state=#{state,jdbcType=INTEGER},</if> |
| | | <if test="creatorId != null">g_creator_id=#{creatorId,jdbcType=BIGINT},</if> |
| | |
| | | <sql id="listWhere"> |
| | | <if test="query.id!=null">and g_id=#{query.id}</if> |
| | | <if test="query.name!=null">and g_name=#{query.name}</if> |
| | | <if test="query.identity!=null">and g_identity=#{query.identity}</if> |
| | | <if test="query.state!=null">and g_state=#{query.state}</if> |
| | | </sql> |
| | | |
| | |
| | | <include refid="listWhere"/> |
| | | </select> |
| | | |
| | | |
| | | <select id="getByIdentity" resultMap="BaseResultMap"> |
| | | select <include refid="Base_Column_List"/> from vip_grade |
| | | where g_identity=#{identity} |
| | | </select> |
| | | |
| | | </mapper> |