New file |
| | |
| | | package com.yeshi.fanli.controller.client.v2;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.core.task.TaskExecutor;
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
|
| | | import com.yeshi.fanli.exception.user.UserSystemCouponException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.config.SystemCouponService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.user.DeviceLotteryRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.UserLotteryRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.vo.user.UserSystemCouponVO;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | /**
|
| | | * 福利中心
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Controller
|
| | | @RequestMapping("api/v2/user/coupon")
|
| | | public class UserCouponControllerV2 {
|
| | |
|
| | | @Resource(name = "taskExecutor")
|
| | | private TaskExecutor executor;
|
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
|
| | | @Resource
|
| | | private SystemCouponService systemCouponService;
|
| | | |
| | | @Resource
|
| | | private UserSystemCouponService UserSystemCouponService;
|
| | |
|
| | | @Resource
|
| | | private SwiperPictureService swiperPictureService;
|
| | |
|
| | | @Resource
|
| | | private CommonOrderService commonOrderService;
|
| | |
|
| | | @Resource
|
| | | private DeviceLotteryRecordService deviceLotteryRecordService;
|
| | |
|
| | | @Resource
|
| | | private UserSystemCouponService userSystemCouponService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | |
|
| | | |
| | | @Resource
|
| | | private UserLotteryRecordService userLotteryRecordService;
|
| | | |
| | |
|
| | | /**
|
| | | * 用户券列表查询
|
| | | * |
| | | * @param acceptData
|
| | | * @param page
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getCouponList", method = RequestMethod.POST)
|
| | | public void getCouponList(AcceptData acceptData, Integer page, Long uid, PrintWriter out) {
|
| | | if (uid == null || uid <= 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (page == null || page < 1) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "页码不正确"));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | | JSONObject data = new JSONObject();
|
| | | if (page == 1) {
|
| | | // 福利中心图片
|
| | | List<SwiperPicture> listswiper = swiperPictureService.getByBannerCard("welfare_top_1.6.5");
|
| | | if (listswiper != null && listswiper.size() > 0) {
|
| | | String topPicture = listswiper.get(0).getSrc();
|
| | | data.put("topPicture", topPicture);
|
| | | }
|
| | | }
|
| | | |
| | | long count = UserSystemCouponService.countUserCouponList(uid);
|
| | | |
| | | List<UserSystemCouponVO> resultList = UserSystemCouponService.getCouponList((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, uid);
|
| | | if (resultList == null) {
|
| | | resultList = new ArrayList<UserSystemCouponVO>();
|
| | | }
|
| | | |
| | | data.put("count", count);
|
| | | data.put("list", JsonUtil.getApiCommonGson().toJson(resultList));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } catch (UserSystemCouponException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "查询失败"));
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | @RequestMapping(value = "giveCoupon", method = RequestMethod.POST)
|
| | | public void giveCoupon(AcceptData acceptData, Long uid, Long id, PrintWriter out) {
|
| | | if (uid == null || uid <= 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | | |
| | | if (id == null || id <= 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "传递参数不正确"));
|
| | | return;
|
| | | }
|
| | | |
| | | |
| | | try {
|
| | | String tips = UserSystemCouponService.giveCoupon(uid, id);
|
| | | out.print(JsonUtil.loadTrueResult(tips));
|
| | | } catch (UserSystemCouponException e) {
|
| | | out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
|
| | | }
|
| | | |
| | | |
| | | |
| | | |
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.dao.mybatis.user; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | | import com.yeshi.fanli.entity.bus.user.TokenRecord; |
| | | |
| | | public interface TokenRecordMapper extends BaseMapper<TokenRecord> { |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.entity.bus.user;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import org.yeshi.utils.mybatis.Column;
|
| | | import org.yeshi.utils.mybatis.Table;
|
| | |
|
| | | import com.google.gson.annotations.Expose;
|
| | |
|
| | | /**
|
| | | * 系统内部口令记录
|
| | | *
|
| | | */
|
| | | @Table("yeshi_ec_token_record")
|
| | | public class TokenRecord {
|
| | | |
| | | // 口令类型
|
| | | public enum TokenTypeEnum {
|
| | | coupon("福利中心券");
|
| | | private final String desc;
|
| | |
|
| | | private TokenTypeEnum(String desc) {
|
| | | this.desc = desc;
|
| | | }
|
| | |
|
| | | public String getDesc() {
|
| | | return desc;
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | @Column(name = "tr_id")
|
| | | private Long id;
|
| | |
|
| | | // 用户id
|
| | | @Column(name = "tr_uid")
|
| | | private Long uid;
|
| | | |
| | | // 口令类型
|
| | | @Column(name = "tr_type")
|
| | | private TokenTypeEnum type;
|
| | |
|
| | | // 类型标识
|
| | | @Column(name = "tr_identify")
|
| | | private String identify;
|
| | | |
| | | // 开始时间
|
| | | @Column(name = "tr_start_time")
|
| | | private Date startTime;
|
| | | |
| | | // 结束时间
|
| | | @Expose
|
| | | @Column(name = "tr_end_time")
|
| | | private Date endTime;
|
| | | |
| | | // 状态:0失效 1有效
|
| | | @Column(name = "tr_state")
|
| | | private Integer state;
|
| | |
|
| | | // 口令
|
| | | @Column(name = "tr_token")
|
| | | private String token;
|
| | |
|
| | | // 创建时间
|
| | | @Column(name = "tr_create_time")
|
| | | private Date createTime;
|
| | |
|
| | | // 更新时间
|
| | | @Column(name = "tr_update_time")
|
| | | private Date updateTime;
|
| | | |
| | | |
| | |
|
| | | public Long getId() {
|
| | | return id;
|
| | | }
|
| | |
|
| | | public void setId(Long id) {
|
| | | this.id = id;
|
| | | }
|
| | |
|
| | | public Long getUid() {
|
| | | return uid;
|
| | | }
|
| | |
|
| | | public void setUid(Long uid) {
|
| | | this.uid = uid;
|
| | | }
|
| | |
|
| | | public TokenTypeEnum getType() {
|
| | | return type;
|
| | | }
|
| | |
|
| | | public void setType(TokenTypeEnum type) {
|
| | | this.type = type;
|
| | | }
|
| | |
|
| | | public String getIdentify() {
|
| | | return identify;
|
| | | }
|
| | |
|
| | | public void setIdentify(String identify) {
|
| | | this.identify = identify;
|
| | | }
|
| | |
|
| | | public Date getStartTime() {
|
| | | return startTime;
|
| | | }
|
| | |
|
| | | public void setStartTime(Date startTime) {
|
| | | this.startTime = startTime;
|
| | | }
|
| | |
|
| | | public Date getEndTime() {
|
| | | return endTime;
|
| | | }
|
| | |
|
| | | public void setEndTime(Date endTime) {
|
| | | this.endTime = endTime;
|
| | | }
|
| | |
|
| | | public Integer getState() {
|
| | | return state;
|
| | | }
|
| | |
|
| | | public void setState(Integer state) {
|
| | | this.state = state;
|
| | | }
|
| | |
|
| | | public String getToken() {
|
| | | return token;
|
| | | }
|
| | |
|
| | | public void setToken(String token) {
|
| | | this.token = token;
|
| | | }
|
| | |
|
| | | public Date getCreateTime() {
|
| | | return createTime;
|
| | | }
|
| | |
|
| | | public void setCreateTime(Date createTime) {
|
| | | this.createTime = createTime;
|
| | | }
|
| | |
|
| | | public Date getUpdateTime() {
|
| | | return updateTime;
|
| | | }
|
| | |
|
| | | public void setUpdateTime(Date updateTime) {
|
| | | this.updateTime = updateTime;
|
| | | }
|
| | | |
| | | }
|
New file |
| | |
| | | <?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.yeshi.fanli.dao.mybatis.user.TokenRecordMapper"> |
| | | <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.user.TokenRecord"> |
| | | <id column="tr_id" property="id" jdbcType="BIGINT"/> |
| | | <result column="tr_uid" property="uid" jdbcType="BIGINT"/> |
| | | <result column="tr_identify" property="identify" jdbcType="VARCHAR"/> |
| | | <result column="tr_start_time" property="startTime" jdbcType="TIMESTAMP"/> |
| | | <result column="tr_end_time" property="endTime" jdbcType="TIMESTAMP"/> |
| | | <result column="tr_state" property="state" jdbcType="INTEGER"/> |
| | | <result column="tr_token" property="token" jdbcType="VARCHAR"/> |
| | | <result column="tr_create_time" property="createTime" jdbcType="TIMESTAMP"/> |
| | | <result column="tr_update_time" property="updateTime" jdbcType="TIMESTAMP"/> |
| | | <result column="tr_type" property="type" typeHandler="com.yeshi.fanli.util.mybatishandler.TokenTypeEnumHandler"/> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">tr_id,tr_uid,tr_type,tr_identify,tr_start_time,tr_end_time,tr_state,tr_token,tr_create_time,tr_update_time</sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select |
| | | <include refid="Base_Column_List"/>from yeshi_ec_token_record where tr_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_token_record where tr_id = #{id,jdbcType=BIGINT}</delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.TokenRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_token_record (tr_id,tr_uid,tr_type,tr_identify,tr_start_time,tr_end_time,tr_state,tr_token,tr_create_time,tr_update_time) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{type,jdbcType=VARCHAR},#{identify,jdbcType=VARCHAR},#{startTime,jdbcType=TIMESTAMP},#{endTime,jdbcType=TIMESTAMP},#{state,jdbcType=INTEGER},#{token,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.user.TokenRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_token_record |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">tr_id,</if> |
| | | <if test="uid != null">tr_uid,</if> |
| | | <if test="type != null">tr_type,</if> |
| | | <if test="identify != null">tr_identify,</if> |
| | | <if test="startTime != null">tr_start_time,</if> |
| | | <if test="endTime != null">tr_end_time,</if> |
| | | <if test="state != null">tr_state,</if> |
| | | <if test="token != null">tr_token,</if> |
| | | <if test="createTime != null">tr_create_time,</if> |
| | | <if test="updateTime != null">tr_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="type != null">#{type,jdbcType=VARCHAR},</if> |
| | | <if test="identify != null">#{identify,jdbcType=VARCHAR},</if> |
| | | <if test="startTime != null">#{startTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="endTime != null">#{endTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="state != null">#{state,jdbcType=INTEGER},</if> |
| | | <if test="token != null">#{token,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.yeshi.fanli.entity.bus.user.TokenRecord">update yeshi_ec_token_record set tr_uid = #{uid,jdbcType=BIGINT},tr_type = #{type,jdbcType=VARCHAR},tr_identify = #{identify,jdbcType=VARCHAR},tr_start_time = #{startTime,jdbcType=TIMESTAMP},tr_end_time = #{endTime,jdbcType=TIMESTAMP},tr_state = #{state,jdbcType=INTEGER},tr_token = #{token,jdbcType=VARCHAR},tr_create_time = #{createTime,jdbcType=TIMESTAMP},tr_update_time = #{updateTime,jdbcType=TIMESTAMP} where tr_id = #{id,jdbcType=BIGINT}</update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.user.TokenRecord">update yeshi_ec_token_record |
| | | <set> |
| | | <if test="uid != null">tr_uid=#{uid,jdbcType=BIGINT},</if> |
| | | <if test="type != null">tr_type=#{type,jdbcType=VARCHAR},</if> |
| | | <if test="identify != null">tr_identify=#{identify,jdbcType=VARCHAR},</if> |
| | | <if test="startTime != null">tr_start_time=#{startTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="endTime != null">tr_end_time=#{endTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="state != null">tr_state=#{state,jdbcType=INTEGER},</if> |
| | | <if test="token != null">tr_token=#{token,jdbcType=VARCHAR},</if> |
| | | <if test="createTime != null">tr_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">tr_update_time=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </set> where tr_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | </mapper> |
New file |
| | |
| | | package com.yeshi.fanli.service.impl.user;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.user.TokenRecordMapper;
|
| | | import com.yeshi.fanli.entity.bus.user.TokenRecord;
|
| | | import com.yeshi.fanli.service.inter.user.TokenRecordService;
|
| | |
|
| | | @Service
|
| | | public class TokenRecordServiceImpl implements TokenRecordService{
|
| | |
|
| | | @Resource
|
| | | private TokenRecordMapper tokenRecordMapper;
|
| | | |
| | | @Override
|
| | | public void insertSelective(TokenRecord record) {
|
| | | record.setCreateTime(new Date());
|
| | | record.setUpdateTime(new Date());
|
| | | tokenRecordMapper.insertSelective(record);
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.user;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.TokenRecord;
|
| | |
|
| | | public interface TokenRecordService {
|
| | |
|
| | | public void insertSelective(TokenRecord record);
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.util.mybatishandler;
|
| | |
|
| | | import java.sql.CallableStatement;
|
| | | import java.sql.PreparedStatement;
|
| | | import java.sql.ResultSet;
|
| | | import java.sql.SQLException;
|
| | |
|
| | | import org.apache.ibatis.type.BaseTypeHandler;
|
| | | import org.apache.ibatis.type.JdbcType;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.TokenRecord.TokenTypeEnum;
|
| | |
|
| | | public class TokenTypeEnumHandler extends BaseTypeHandler<TokenTypeEnum> {
|
| | |
|
| | | @Override
|
| | | public TokenTypeEnum getNullableResult(ResultSet arg0, String arg1) throws SQLException {
|
| | | String key = arg0.getString(arg1);
|
| | | if (arg0.wasNull()) {
|
| | | return null;
|
| | | } else {
|
| | | return TokenTypeEnum.valueOf(key);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public TokenTypeEnum getNullableResult(ResultSet arg0, int arg1) throws SQLException {
|
| | | String key = arg0.getString(arg1);
|
| | | if (arg0.wasNull()) {
|
| | | return null;
|
| | | } else {
|
| | | // 根据数据库中的key值,定位SexEnum子类
|
| | | return TokenTypeEnum.valueOf(key);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public TokenTypeEnum getNullableResult(CallableStatement arg0, int arg1) throws SQLException {
|
| | | String key = arg0.getString(arg1);
|
| | | if (arg0.wasNull()) {
|
| | | return null;
|
| | | } else {
|
| | | // 根据数据库中的key值,定位SexEnum子类
|
| | | return TokenTypeEnum.valueOf(key);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void setNonNullParameter(PreparedStatement arg0, int arg1, TokenTypeEnum arg2, JdbcType arg3)
|
| | | throws SQLException {
|
| | | arg0.setString(arg1, arg2.name());
|
| | | }
|
| | |
|
| | | }
|