fanli/src/main/java/com/yeshi/fanli/controller/client/v2/IntegralControllerV2.java
@@ -1,5 +1,6 @@ package com.yeshi.fanli.controller.client.v2; import java.io.IOException; import java.io.PrintWriter; import java.lang.reflect.Type; import java.util.ArrayList; @@ -22,8 +23,12 @@ import com.google.gson.JsonPrimitive; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; import com.google.gson.TypeAdapter; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.yeshi.fanli.entity.accept.AcceptData; import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinDetail.TaoLiJinDetailTypeEnum; import com.yeshi.fanli.entity.bus.user.UserInfo; import com.yeshi.fanli.entity.bus.user.UserRank; import com.yeshi.fanli.entity.integral.CodePublishRecord; @@ -36,6 +41,7 @@ import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.config.ConfigService; import com.yeshi.fanli.service.inter.integral.CodePublishRecordService; import com.yeshi.fanli.service.inter.integral.IntegralDetailService; import com.yeshi.fanli.service.inter.integral.IntegralExchangeRecordService; import com.yeshi.fanli.service.inter.integral.IntegralExchangeService; import com.yeshi.fanli.service.inter.integral.IntegralTaskClassService; @@ -44,8 +50,10 @@ import com.yeshi.fanli.service.inter.user.UserInfoService; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.TimeUtil; import com.yeshi.fanli.vo.integral.DailySignVO; import com.yeshi.fanli.vo.integral.ExchangeTipVO; import com.yeshi.fanli.vo.integral.IntegralDetailVO; import com.yeshi.fanli.vo.integral.IntegralTaskClassVO; import com.yeshi.fanli.vo.user.UserInfoExtraVO; @@ -75,6 +83,9 @@ @Resource private IntegralExchangeRecordService integralExchangeRecordService; @Resource private IntegralDetailService integralDetailService; @Resource private CodePublishRecordService codePublishRecordService; @@ -165,7 +176,12 @@ return; } List<IntegralTaskRecord> list = integralTaskRecordService.listNotReceived(5, uid); int count = 5; if ("android".equalsIgnoreCase(acceptData.getPlatform())) { count = Integer.MAX_VALUE; } List<IntegralTaskRecord> list = integralTaskRecordService.listNotReceived(count, uid); if (list == null) { list = new ArrayList<IntegralTaskRecord>(); } @@ -188,30 +204,37 @@ * @param out */ @RequestMapping(value = "receiveGoldCoin", method = RequestMethod.POST) public void receiveGoldCoin(AcceptData acceptData, Long uid, String ids, String gids, PrintWriter out) { public void receiveGoldCoin(AcceptData acceptData, Long uid, Integer type, String ids, String gids, PrintWriter out) { if (uid == null || uid <= 0) { out.print(JsonUtil.loadFalseResult(1, "用户未登录")); return; } Gson gson = new Gson(); Set<Long> idList = gson.fromJson(ids, new TypeToken<HashSet<Long>>() { }.getType()); if (idList == null || idList.size() == 0) { out.print(JsonUtil.loadFalseResult("领取id不能为空")); return; } Set<Long> gidList = gson.fromJson(gids, new TypeToken<HashSet<Long>>() {}.getType()); try { Integer goldCoin = integralTaskRecordService.receiveGoldCoin(uid, idList); // 全部领取 if (type != null && type == 1) { Integer goldCoin = integralTaskRecordService.receiveGoldCoinALL(uid); JSONObject data = new JSONObject(); data.put("goldCoin", goldCoin); out.print(JsonUtil.loadTrueResult(data)); return; } // 部分领取 Gson gson = new Gson(); Set<Long> idList = gson.fromJson(ids, new TypeToken<HashSet<Long>>() { }.getType()); if (idList == null || idList.size() == 0) { out.print(JsonUtil.loadFalseResult("领取id不能为空")); return; } Integer goldCoin = integralTaskRecordService.receiveGoldCoin(uid, idList); Set<Long> gidList = gson.fromJson(gids, new TypeToken<HashSet<Long>>() {}.getType()); List<IntegralTaskRecord> list = null; if (gidList != null && gidList.size() > 0) { list = integralTaskRecordService.listNotReceived(5 - gidList.size(), uid); list = integralTaskRecordService.listNotReceivedExcludeId(5 - gidList.size(), uid, gidList); } else { list = integralTaskRecordService.listNotReceived(5, uid); list = integralTaskRecordService.listNotReceivedExcludeId(5, uid, null); } if (list == null) { @@ -219,7 +242,7 @@ } GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation(); Gson gson2 = gsonBuilder.create(); JSONObject data = new JSONObject(); data.put("goldCoin", goldCoin); data.put("list", gson2.toJson(list)); @@ -260,14 +283,14 @@ if (list == null) list = new ArrayList<IntegralExchange>(); Long count = integralExchangeService.countValid(); //Long count = integralExchangeService.countValid(); GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation(); Gson gson = gsonBuilder.create(); JSONObject data = new JSONObject(); data.put("goldCoin", extraVO.getGoldCoin() + "枚"); data.put("count", count); data.put("count", list.size()); data.put("list", gson.toJson(list)); out.print(JsonUtil.loadTrueResult(data)); } @@ -502,4 +525,78 @@ return gson; } /** * 明细详情 * * @param acceptData * @param uid * @param index * List最末的主键ID * @param year * 年份 * @param month * 月份 * @param type 统计类型 0全部 1 * @param out */ @RequestMapping(value = "getDetails") public void getDetails(AcceptData acceptData, Long uid, Long index, Integer year, Integer month, Integer type, PrintWriter out) { if (uid == null || uid == 0) { out.print(JsonUtil.loadFalseResult(1, "用户未登录")); return; } if ((year == null && month != null) || (year != null && month == null)) { out.print(JsonUtil.loadFalseResult(1, "日期不完整")); return; } Date date = null; if (year != null && month != null) { date = new Date(TimeUtil.convertToTimeTemp(year + "-" + month, "yyyy-M")); Calendar ca = Calendar.getInstance(); ca.setTime(date); ca.add(Calendar.MONTH, 1); date = new Date(ca.getTimeInMillis() - 1); } // 查询列表 List<IntegralDetailVO> list = integralDetailService.listDetailForClient(uid, index, date); // 统计总条数 long count = integralDetailService.countDetailForClient(uid, index, date); GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation(); gsonBuilder.registerTypeAdapter(TaoLiJinDetailTypeEnum.class, new TypeAdapter<TaoLiJinDetailTypeEnum>() { @Override public TaoLiJinDetailTypeEnum read(JsonReader arg0) throws IOException { return null; } @Override public void write(JsonWriter out, TaoLiJinDetailTypeEnum arg1) throws IOException { out.beginObject(); out.name("portrait").value(arg1.getPicture()); out.endObject(); } }).registerTypeAdapter(Date.class, new JsonSerializer<Date>() { @Override public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) { if (value == null) { return new JsonPrimitive(""); } else { return new JsonPrimitive(TimeUtil.getGernalTime(value.getTime(), "yyyy.MM.dd HH:mm")); } } }); Gson gson = gsonBuilder.create(); JSONObject data = new JSONObject(); data.put("count", count); data.put("data", gson.toJson(list)); out.print(JsonUtil.loadTrueResult(data)); } } fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RecommendControllerV2.java
@@ -332,7 +332,7 @@ params.put("url", configService.get("spike_goods_link")); root.put("params", params); root.put("jumpDetail", jumpDetailV2Service.getByTypeCache("web", root.put("jumpDetail", jumpDetailV2Service.getByTypeCache("integralExchange", Constant.getPlatformCode(acceptData.getPlatform()), Integer.parseInt(acceptData.getVersion()))); root.put("name", "金币兑换"); fanli/src/main/java/com/yeshi/fanli/dao/mybatis/integral/IntegralDetailMapper.java
New file @@ -0,0 +1,72 @@ package com.yeshi.fanli.dao.mybatis.integral; import java.util.Date; import java.util.List; import org.apache.ibatis.annotations.Param; import com.yeshi.fanli.dao.BaseMapper; import com.yeshi.fanli.entity.integral.IntegralDetail; import com.yeshi.fanli.vo.integral.IntegralMonthVO; public interface IntegralDetailMapper extends BaseMapper<IntegralDetail> { /** * 获取用户总共有多少记录数据 * * @param uid * @return */ Long selectCountByUid(@Param("uid") Long uid); /** * 按用户ID和最大时间检索月份的数量 * * @param uid * @param maxDate * @return */ int selectMonthCountByUid(@Param("uid") Long uid, @Param("date") Date maxDate); /** * 按最大的创建时间和用户ID检索数量 * * @param uid * @param date * @return */ Long selectCountByUidAndMaxCreateTime(@Param("uid") Long uid, @Param("date") Date date); /** * 按最大的创建时间和用户ID检索列表 * * @param uid * @param date * @return */ List<IntegralDetail> selectByMaxCreateTime(@Param("uid") Long uid, @Param("date") Date date, @Param("count") int count); /** * 通过用户ID和返回的最大时间的详情ID来获取下一页的数据 * * @param uid * @param id * @param count * @return */ List<IntegralDetail> selectByUidWithIndexId(@Param("uid") Long uid, @Param("id") Long id, @Param("count") int count); /** * 统计某个月份的收入与支出 * * @param uid * @param dateFormat * @return */ List<IntegralMonthVO> selectMonthMoneyByUid(@Param("uid") Long uid, @Param("dateFormat") List<String> dateFormat); } fanli/src/main/java/com/yeshi/fanli/dao/mybatis/integral/IntegralTaskRecordMapper.java
@@ -1,6 +1,7 @@ package com.yeshi.fanli.dao.mybatis.integral; import java.util.List; import java.util.Set; import org.apache.ibatis.annotations.Param; @@ -16,6 +17,16 @@ * @return */ List<IntegralTaskRecord> listNotReceived(@Param("count") int count, @Param("uid") Long uid); /** * 未领取金币- 排除id * @param count * @param uid * @return */ List<IntegralTaskRecord> listNotReceivedExcludeId(@Param("count") int count, @Param("uid") Long uid, @Param("list")Set<Long> idList); /** @@ -44,5 +55,20 @@ */ List<IntegralTaskRecord> listDaySignRecord(@Param("uid") Long uid, @Param("cid") Long cid); /** * 未领取金币 * @param count * @param uid * @return */ int countTotalGoldCoin(@Param("uid") Long uid); /** * 更新领取状态 * @param uid */ void updateReceived(@Param("uid") Long uid); } fanli/src/main/java/com/yeshi/fanli/dao/mybatis/user/UserSystemCouponRecordMapper.java
@@ -46,4 +46,11 @@ */ List<UserSystemCouponRecord> getCouponByUsingTimeOut(@Param("uid") Long uid, @Param("number") Long number); /** * 查询最近使用记录 * @param userCouponId * @return */ UserSystemCouponRecord getNearByUserCouponId(@Param("userCouponId") Long userCouponId); } fanli/src/main/java/com/yeshi/fanli/entity/bus/user/UserSystemCouponRecord.java
@@ -22,6 +22,9 @@ public final static int STATE_FREE_ON = 2; public final static int STATE_SUCCESS = 3; public final static int STATE_GIVE_ON = 11; // 增送中 @Column(name = "ucr_id") private Long id; fanli/src/main/java/com/yeshi/fanli/entity/integral/IntegralDetail.java
New file @@ -0,0 +1,102 @@ package com.yeshi.fanli.entity.integral; import java.util.Date; import org.yeshi.utils.mybatis.Column; import org.yeshi.utils.mybatis.Table; import com.google.gson.annotations.Expose; /** * 积分明细 * * @author Administrator * */ @Table("yeshi_ec_integral_detail") public class IntegralDetail { @Expose @Column(name = "td_id") private Long id; @Column(name = "td_uid") private Long uid; // 用户id @Expose @Column(name = "td_money") private Integer money; // 积分 @Expose @Column(name = "td_title") private String title; // 标题 @Expose @Column(name = "td_desc_info") private String descInfo; // 详细信息 @Expose @Column(name = "td_remark") private String remark; // 备注 @Expose @Column(name = "td_create_time") private Date createTime; 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 Integer getMoney() { return money; } public void setMoney(Integer money) { this.money = money; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getDescInfo() { return descInfo; } public void setDescInfo(String descInfo) { this.descInfo = descInfo; } public String getRemark() { return remark; } public void setRemark(String remark) { this.remark = remark; } public Date getCreateTime() { return createTime; } public void setCreateTime(Date createTime) { this.createTime = createTime; } } fanli/src/main/java/com/yeshi/fanli/entity/integral/IntegralExchange.java
@@ -92,6 +92,10 @@ // 用户金币 @Expose private String userGoldCoin; // 发布列表-需要跳转 @Expose private boolean needJump; public Long getId() { return id; @@ -220,4 +224,12 @@ public void setUserGoldCoin(String userGoldCoin) { this.userGoldCoin = userGoldCoin; } public boolean isNeedJump() { return needJump; } public void setNeedJump(boolean needJump) { this.needJump = needJump; } } fanli/src/main/java/com/yeshi/fanli/job/UserSystemCouponJob.java
@@ -1,8 +1,5 @@ package com.yeshi.fanli.job; import java.math.BigDecimal; import java.util.Collections; import java.util.Date; import java.util.List; import javax.annotation.Resource; @@ -10,27 +7,9 @@ import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinGiveRecord; import com.yeshi.fanli.entity.bus.user.UserSystemCouponGiveRecord; import com.yeshi.fanli.entity.taobao.ShareHotGoods; import com.yeshi.fanli.entity.taobao.TLJBuyGoods; import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig; import com.yeshi.fanli.entity.taobao.TaoKeAppInfo; import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException; import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.taobao.ShareHotGoodsService; import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService; import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService; import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailService; import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinGiveRecordService; import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinOriginService; import com.yeshi.fanli.service.inter.user.UserSystemCouponGiveRecordService; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.TaoBaoConstant; import com.yeshi.fanli.util.TimeUtil; import com.yeshi.fanli.util.taobao.TaoBaoUtil; import com.yeshi.fanli.util.taobao.TaoKeApiUtil; @Component public class UserSystemCouponJob { @@ -54,16 +33,11 @@ } for (UserSystemCouponGiveRecord record: overdueList) { // try { // userTaoLiJinOriginService.giveSendBack(record.getGiveUid(), record.getAmount()); // // 更新记录 // UserTaoLiJinGiveRecord updateRecord = new UserTaoLiJinGiveRecord(); // updateRecord.setId(record.getId()); // updateRecord.setState(UserTaoLiJinGiveRecord.STATE_OVERDUE); // userTaoLiJinGiveRecordService.updateByPrimaryKeySelective(updateRecord); // } catch (Exception e) { // e.printStackTrace(); // } UserSystemCouponGiveRecord updateRecord = new UserSystemCouponGiveRecord(); updateRecord.setId(record.getId()); updateRecord.setState(UserSystemCouponGiveRecord.STATE_OVERDUE); userSystemCouponGiveRecordService.updateByPrimaryKeySelective(updateRecord); } } } fanli/src/main/java/com/yeshi/fanli/mapping/integral/IntegralDetailMapper.xml
New file @@ -0,0 +1,115 @@ <?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.integral.IntegralDetailMapper"> <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.integral.IntegralDetail"> <id column="td_id" property="id" jdbcType="BIGINT"/> <result column="td_uid" property="uid" jdbcType="BIGINT"/> <result column="td_money" property="money" jdbcType="INTEGER"/> <result column="td_title" property="title" jdbcType="VARCHAR"/> <result column="td_desc_info" property="descInfo" jdbcType="VARCHAR"/> <result column="td_remark" property="remark" jdbcType="VARCHAR"/> <result column="td_create_time" property="createTime" jdbcType="TIMESTAMP"/> </resultMap> <resultMap id="UserMonthMoneyMap" type="com.yeshi.fanli.vo.integral.IntegralMonthVO"> <result column="expend" property="expend" jdbcType="DECIMAL" /> <result column="income" property="income" jdbcType="DECIMAL" /> <result column="dateFormate" property="dateFormate" jdbcType="VARCHAR" /> </resultMap> <sql id="Base_Column_List">td_id,td_uid,td_money,td_title,td_desc_info,td_remark,td_create_time</sql> <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select <include refid="Base_Column_List"/>from yeshi_ec_integral_detail where td_id = #{id,jdbcType=BIGINT} </select> <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_integral_detail where td_id = #{id,jdbcType=BIGINT}</delete> <insert id="insert" parameterType="com.yeshi.fanli.entity.integral.IntegralDetail" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_integral_detail (td_id,td_uid,td_money,td_title,td_desc_info,td_remark,td_create_time) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{money,jdbcType=INTEGER},#{title,jdbcType=VARCHAR},#{descInfo,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP})</insert> <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.integral.IntegralDetail" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_integral_detail <trim prefix="(" suffix=")" suffixOverrides=","> <if test="id != null">td_id,</if> <if test="uid != null">td_uid,</if> <if test="money != null">td_money,</if> <if test="title != null">td_title,</if> <if test="descInfo != null">td_desc_info,</if> <if test="remark != null">td_remark,</if> <if test="createTime != null">td_create_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="money != null">#{money,jdbcType=INTEGER},</if> <if test="title != null">#{title,jdbcType=VARCHAR},</if> <if test="descInfo != null">#{descInfo,jdbcType=VARCHAR},</if> <if test="remark != null">#{remark,jdbcType=VARCHAR},</if> <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> </trim> </insert> <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.integral.IntegralDetail">update yeshi_ec_integral_detail set td_uid = #{uid,jdbcType=BIGINT},td_money = #{money,jdbcType=INTEGER},td_title = #{title,jdbcType=VARCHAR},td_desc_info = #{descInfo,jdbcType=VARCHAR},td_remark = #{remark,jdbcType=VARCHAR},td_create_time = #{createTime,jdbcType=TIMESTAMP} where td_id = #{id,jdbcType=BIGINT}</update> <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.integral.IntegralDetail">update yeshi_ec_integral_detail <set> <if test="uid != null">td_uid=#{uid,jdbcType=BIGINT},</if> <if test="money != null">td_money=#{money,jdbcType=INTEGER},</if> <if test="title != null">td_title=#{title,jdbcType=VARCHAR},</if> <if test="descInfo != null">td_desc_info=#{descInfo,jdbcType=VARCHAR},</if> <if test="remark != null">td_remark=#{remark,jdbcType=VARCHAR},</if> <if test="createTime != null">td_create_time=#{createTime,jdbcType=TIMESTAMP},</if> </set> where td_id = #{id,jdbcType=BIGINT} </update> <select id="selectCountByUid" resultType="java.lang.Long" parameterType="java.lang.Long"> SELECT count(td_id) FROM yeshi_ec_integral_detail WHERE td_uid = #{uid} </select> <select id="selectMonthCountByUid" resultType="java.lang.Integer"> SELECT COUNT(*) FROM (SELECT * FROM yeshi_ec_integral_detail d WHERE d.`td_uid`=#{uid} AND d.`td_create_time` <![CDATA[<=]]> #{date} GROUP BY DATE_FORMAT(d.`td_create_time`,'%y-%m') ) a </select> <select id="selectCountByUidAndMaxCreateTime" resultType="java.lang.Long"> SELECT count(utd_id) FROM yeshi_ec_integral_detail WHERE td_uid=#{uid} and `td_create_time`<![CDATA[<=]]>#{date} </select> <select id="selectByMaxCreateTime" resultMap="BaseResultMap"> SELECT <include refid="Base_Column_List" /> FROM yeshi_ec_integral_detail t WHERE t.`td_uid`=#{uid} AND t.`td_create_time`<![CDATA[<=]]> #{date} ORDER BY t.`td_create_time` DESC,t.td_id DESC LIMIT #{count} </select> <select id="selectByUidWithIndexId" resultMap="BaseResultMap"> SELECT <include refid="Base_Column_List" /> FROM yeshi_ec_integral_detail t WHERE t.`td_uid`=#{uid} AND t.`td_create_time`<![CDATA[<=]]>(SELECT td_create_time FROM yeshi_ec_integral_detail WHERE td_id =#{id}) ORDER BY t.`td_create_time` DESC,t.td_id DESC LIMIT #{count} </select> <select id="selectMonthMoneyByUid" resultMap="UserMonthMoneyMap"> <foreach collection="dateFormat" index="index" item="item" separator="UNION ALL"> <trim prefix="(" suffix=")"> SELECT c.time AS dateFormate , IF(a.money IS NULL,0,a.money) AS income ,IF(b.money IS NULL,0,b.money) AS expend FROM (SELECT #{item} AS `time`) c LEFT JOIN (SELECT DATE_FORMAT(d.`td_create_time`,'%Y-%m') AS `time`,SUM(d.`td_money`)AS money FROM `yeshi_ec_integral_detail` d WHERE d.`td_uid`=#{uid} AND d.`td_money`<![CDATA[>=]]>0 AND DATE_FORMAT(d.`td_create_time`,'%Y-%m')=#{item} GROUP BY DATE_FORMAT(d.`td_create_time`,'%Y-%m') ) a ON a.time=c.time LEFT JOIN(SELECT DATE_FORMAT(d.`td_create_time`,'%Y-%m') AS `time`,SUM(d.`td_money`) AS money FROM `yeshi_ec_integral_detail` d WHERE d.`td_uid`=#{uid} AND d.`td_money` <![CDATA[<]]>0 AND DATE_FORMAT(d.`td_create_time`,'%Y-%m')=#{item} GROUP BY DATE_FORMAT(d.`td_create_time`,'%Y-%m') ) b ON c.time=b.time </trim> </foreach> </select> </mapper> fanli/src/main/java/com/yeshi/fanli/mapping/integral/IntegralTaskRecordMapper.xml
@@ -55,10 +55,31 @@ </set> where ir_id = #{id,jdbcType=BIGINT} </update> <update id="updateReceived" parameterType="Long"> UPDATE yeshi_ec_integral_task_record SET ir_state = 1,ir_update_time = NOW() WHERE ir_state = 0 AND ir_uid = #{uid} </update> <select id="listNotReceived" resultMap="BaseResultMap"> SELECT tc.`tc_name` AS taskName,d.* FROM yeshi_ec_integral_task_record d LEFT JOIN `yeshi_ec_integral_task_class` tc ON tc.`tc_id` = d.`ir_cid` WHERE d.`ir_uid` = #{uid} AND d.ir_state = 0 ORDER BY d.ir_create_time LIMIT #{count} </select> <select id="listNotReceivedExcludeId" resultMap="BaseResultMap"> SELECT tc.`tc_name` AS taskName,d.* FROM yeshi_ec_integral_task_record d LEFT JOIN `yeshi_ec_integral_task_class` tc ON tc.`tc_id` = d.`ir_cid` WHERE d.`ir_uid` = #{uid} AND d.ir_state = 0 <if test="list != null"> AND d.ir_id not in <foreach collection="list" item="item" open="(" separator="," close=")"> ${item} </foreach> </if> ORDER BY d.ir_create_time LIMIT #{count} </select> @@ -85,4 +106,9 @@ ORDER BY d.ir_create_time </select> <select id="countTotalGoldCoin" resultType="Integer"> SELECT IFNULL(SUM(d.`ir_gold_coin`),0) FROM `yeshi_ec_integral_task_record` d WHERE d.`ir_uid` = #{uid} AND d.`ir_state` = 0 </select> </mapper> fanli/src/main/java/com/yeshi/fanli/mapping/user/TokenRecordMapper.xml
@@ -69,7 +69,7 @@ <select id="getNearByTypeAndIdentify" resultMap="BaseResultMap"> SELECT * FROM yeshi_ec_token_record WHERE tr_identify = #{identify} AND tr_type = #{type} WHERE tr_state = 0 AND tr_identify = #{identify} AND tr_type = #{type} ORDER BY tr_create_time DESC LIMIT 1 </select> fanli/src/main/java/com/yeshi/fanli/mapping/user/UserSystemCouponGiveRecordMapper.xml
@@ -55,7 +55,7 @@ <select id="getRecordByUidAndCouponId" resultMap="BaseResultMap"> SELECT * FROM yeshi_ec_user_system_coupon_give_record WHERE cgr_give_uid = #{uid} AND cgr_coupon_id = #{couponId} WHERE cgr_state = 0 AND cgr_give_uid = #{uid} AND cgr_coupon_id = #{couponId} ORDER BY cgr_end_time desc LIMIT 1 </select> fanli/src/main/java/com/yeshi/fanli/mapping/user/UserSystemCouponRecordMapper.xml
@@ -94,4 +94,12 @@ AND (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(cp.`usc_use_time`)) <![CDATA[>]]> #{number}; </select> <select id="getNearByUserCouponId" resultMap="BaseResultMap"> SELECT * FROM `yeshi_ec_user_system_coupon_record` WHERE ucr_user_coupon_id = #{userCouponId} ORDER BY ucr_create_time DESC LIMIT 1 </select> </mapper> fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralDetailServiceImpl.java
New file @@ -0,0 +1,184 @@ package com.yeshi.fanli.service.impl.integral; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeMap; import javax.annotation.Resource; import org.springframework.stereotype.Service; import com.yeshi.fanli.dao.mybatis.integral.IntegralDetailMapper; import com.yeshi.fanli.entity.integral.IntegralDetail; import com.yeshi.fanli.service.inter.integral.IntegralDetailService; import com.yeshi.fanli.util.TimeUtil; import com.yeshi.fanli.vo.integral.IntegralDetailVO; import com.yeshi.fanli.vo.integral.IntegralMonthVO; @Service public class IntegralDetailServiceImpl implements IntegralDetailService { @Resource private IntegralDetailMapper integralDetailMapper; @Override public List<IntegralDetailVO> listDetailForClient(Long uid, Long detailId, Date maxTime) { List<IntegralDetailVO> finalList = new ArrayList<>(); List<IntegralDetail> list = null; if (detailId == null) {// 首次请求 if (maxTime == null)// 没有筛选时间 { list = integralDetailMapper.selectByMaxCreateTime(uid, new Date(System.currentTimeMillis() + 1000 * 60 * 60L), 20); } else {// 筛选了时间 list = integralDetailMapper.selectByMaxCreateTime(uid, maxTime, 20); } if (list != null && list.size() > 0) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(list.get(0).getCreateTime().getTime()); IntegralDetailVO vo = new IntegralDetailVO(); vo.setMonth(new IntegralMonthVO(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1)); finalList.add(vo); } else { if (maxTime != null) {// Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(maxTime.getTime()); IntegralDetailVO vo = new IntegralDetailVO(); vo.setMonth(new IntegralMonthVO(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1)); vo.getMonth().setExpend("0"); vo.getMonth().setIncome("0"); finalList.add(vo); } } } else {// 二次请求 int size = 21; List<IntegralDetail> tempList = integralDetailMapper.selectByUidWithIndexId(uid, detailId, size); Set<Date> dateSet = new HashSet<>();// 用于储存是否在同一时间上面(精确到秒) if (tempList.size() > 0) { for (IntegralDetail umd : tempList) { dateSet.add(umd.getCreateTime()); } List<IntegralDetail> tempList2 = new ArrayList<>(); while (dateSet.size() == 1 && tempList2.size() != tempList.size() && size < 40) {// 只有一个时间点的数据 tempList = tempList2; size += 10; tempList2 = integralDetailMapper.selectByUidWithIndexId(uid, detailId, size); dateSet.clear(); for (IntegralDetail umd : tempList2) { dateSet.add(umd.getCreateTime()); } } if (tempList2.size() > 0) tempList = tempList2; } for (int i = 0; i < tempList.size(); i++) { if (tempList.get(i).getId().longValue() == detailId) { tempList.remove(i); break; } else { tempList.remove(i); i--; } } list = tempList; } if (list != null) { if (detailId != null && list.size() > 0) { IntegralDetail umd = integralDetailMapper.selectByPrimaryKey(detailId); if (!TimeUtil.getGernalTime(umd.getCreateTime().getTime(), "yyyy-MM") .equalsIgnoreCase(TimeUtil.getGernalTime(list.get(0).getCreateTime().getTime(), "yyyy-MM"))) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(list.get(0).getCreateTime().getTime()); IntegralDetailVO vo = new IntegralDetailVO(); vo.setMonth(new IntegralMonthVO(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1)); finalList.add(vo); } } for (int i = 0; i < list.size(); i++) { if (i > 0 && !TimeUtil.getGernalTime(list.get(i - 1).getCreateTime().getTime(), "yyyy-MM") .equalsIgnoreCase(TimeUtil.getGernalTime(list.get(i).getCreateTime().getTime(), "yyyy-MM"))) {// 本条数据与上条数据不是同一月则插入月份 Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(list.get(i).getCreateTime().getTime()); IntegralDetailVO vo = new IntegralDetailVO(); vo.setMonth(new IntegralMonthVO(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1)); finalList.add(vo); } IntegralDetailVO vo = new IntegralDetailVO(); vo.setDetail(list.get(i)); finalList.add(vo); } } // 统计月资金 Map<Integer, IntegralDetailVO> monthMap = new TreeMap<>(); if (finalList.size() > 1) for (int i = 0; i < finalList.size(); i++) { if (finalList.get(i).getMonth() != null) monthMap.put(i, finalList.get(i)); } if (!monthMap.isEmpty()) { List<String> dateFormat = new ArrayList<>(); Iterator<Integer> keys = monthMap.keySet().iterator(); while (keys.hasNext()) { Integer key = keys.next(); String date = ""; date += monthMap.get(key).getMonth().getYear(); date += "-"; date += (monthMap.get(key).getMonth().getMonth() + "").length() < 2 ? "0" + monthMap.get(key).getMonth().getMonth() : monthMap.get(key).getMonth().getMonth(); dateFormat.add(date); } List<IntegralMonthVO> voList = integralDetailMapper.selectMonthMoneyByUid(uid, dateFormat); int p = 0; keys = monthMap.keySet().iterator(); while (keys.hasNext()) { Integer key = keys.next(); BigDecimal expend = new BigDecimal(voList.get(p).getExpend()); BigDecimal income = new BigDecimal(voList.get(p).getIncome()); // 去除支出负号 finalList.get(key).getMonth().setExpend(expend.setScale(2).toString().replace("-", "")); finalList.get(key).getMonth().setIncome(income.setScale(2).toString()); p++; } } return finalList; } @Override public long countDetailForClient(Long uid, Long detailId, Date maxTime) { long monthCount = 0L; long detailCount = 0L; // 未通过时间筛选,查询所有 if (maxTime == null) { detailCount = integralDetailMapper.selectCountByUid(uid); // 用于表示当前所有 monthCount = integralDetailMapper.selectMonthCountByUid(uid, new Date(System.currentTimeMillis() + 1000 * 60 * 60L)); } else {// 通过时间筛选了的,需要查询所有 detailCount = integralDetailMapper.selectCountByUidAndMaxCreateTime(uid, maxTime); monthCount = integralDetailMapper.selectMonthCountByUid(uid, maxTime); } return monthCount + detailCount; } } fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralExchangeRecordServiceImpl.java
@@ -13,6 +13,7 @@ import com.yeshi.fanli.entity.integral.IntegralExchange.ExchangeTypeEnum; import com.yeshi.fanli.entity.integral.IntegralExchangeRecord; import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.integral.CodePublishRecordService; import com.yeshi.fanli.service.inter.integral.IntegralExchangeRecordService; import com.yeshi.fanli.service.inter.integral.IntegralExchangeService; import com.yeshi.fanli.service.inter.user.UserInfoExtraService; @@ -29,6 +30,11 @@ @Resource private UserInfoExtraService userInfoExtraService; @Resource private CodePublishRecordService codePublishRecordService; @Override public List<IntegralExchange> listExchange(long start, int count, Long uid){ @@ -76,10 +82,17 @@ } // 邀请码发布卡,兑换项,如果当前用户未激活邀请功能,则不需要显示该兑换项。 if (type == ExchangeTypeEnum.inviteCodePublish && !hasCode) { listValid.remove(i); i --; continue; if (type == ExchangeTypeEnum.inviteCodePublish) { if (!hasCode) { listValid.remove(i); i --; continue; } if(codePublishRecordService.countValidRecord(uid) > 0) { exchange.setBtnName("去查看"); exchange.setNeedJump(true); } } String progress = exchange.getProgress(); fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralExchangeServiceImpl.java
@@ -145,10 +145,10 @@ exchangeTip.setInviteCode(extraVO.getInviteCode()); exchangeTip.setTip("兑换成功后,将发布于“激活邀请码兑换功能中”,需激活邀请的用户可用金币兑换,本次展示有效期为3天。"); } else if (ExchangeTypeEnum.taoLiJin == type) { exchangeTip.setName(exchange.getAmount() + "元推广红包"); exchangeTip.setName(exchange.getAmount().setScale(0) + "元推广红包"); exchangeTip.setTip("注:兑换成功后请到“我的-推广红包”中查看"); } else if (ExchangeTypeEnum.cash == type) { exchangeTip.setName(exchange.getAmount() + "元现金红包"); exchangeTip.setName(exchange.getAmount().setScale(0) + "元现金红包"); exchangeTip.setTip("注:兑换成功后请到“我的-账户余额”中查看"); } else { throw new IntegralExchangeException(1, "兑换方式不存在"); @@ -203,7 +203,7 @@ thing = "奖励免单券"; userSystemCouponService.exchangeCoupon(uid, type.name(), UserSystemCoupon.SOURCE_EXCHANGE, new BigDecimal(10)); } else if (ExchangeTypeEnum.inviteCodePublish == type) { thing = "邀请码激活卡"; thing = "邀请码发布卡"; if(codePublishRecordService.countValidRecord(uid) > 0) throw new IntegralExchangeException(1, "三天之内不可重复兑换"); codePublishRecordService.publishInviteCode(uid); @@ -273,7 +273,6 @@ throw new IntegralExchangeException(1, "兑换异常"); } } @Override fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralTaskRecordServiceImpl.java
@@ -121,6 +121,45 @@ @Override public List<IntegralTaskRecord> listNotReceivedExcludeId(int count, long uid, Set<Long> idList) { if (idList != null && idList.size() == 0) { idList = null; } return integralTaskRecordMapper.listNotReceivedExcludeId(count, uid, idList); } @Override @Transactional public Integer receiveGoldCoinALL(Long uid) throws IntegralTaskRecordException { UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid); if (userInfoExtra == null) throw new IntegralTaskRecordException(1, "用户信息不全"); int totalGoldCoin = integralTaskRecordMapper.countTotalGoldCoin(uid); if (totalGoldCoin > 0) { integralTaskRecordMapper.updateReceived(uid); } Integer goldCoin = userInfoExtra.getGoldCoin(); if (goldCoin == null) goldCoin = 0; UserInfoExtra extra = new UserInfoExtra(); extra.setId(userInfoExtra.getId()); extra.setGoldCoin(goldCoin + totalGoldCoin); try { userInfoExtraService.saveUserInfoExtra(extra); } catch (UserInfoExtraException e) { throw new IntegralTaskRecordException(1, "用户信息不全"); } return extra.getGoldCoin(); } @Override @Transactional public Integer receiveGoldCoin(Long uid, Set<Long> idList) throws IntegralTaskRecordException { if(idList == null || idList.size() == 0) { fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinRecordServiceImpl.java
@@ -536,17 +536,13 @@ Long giveId = null; Date nowDate = new Date(); try { String endDay = DateUtil.plusDay(Constant.GIVE_DAYS - 1, nowDate); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); Date endTime = format.parse(endDay); // 赠送记录 UserTaoLiJinGiveRecord giveRecord = new UserTaoLiJinGiveRecord(); giveRecord.setAmount(amount); giveRecord.setGiveUid(uid); giveRecord.setState(UserTaoLiJinGiveRecord.STATE_INIT); giveRecord.setGiveTime(nowDate); giveRecord.setEndTime(endTime); giveRecord.setEndTime(DateUtil.plusDayDate(Constant.GIVE_DAYS, new Date())); userTaoLiJinGiveRecordService.insertSelective(giveRecord); giveId = giveRecord.getId(); @@ -562,16 +558,12 @@ long num = 10000 + (long) (Math.random() * 10000); token = UserUtil.getInviteCode(num); String endDay = DateUtil.plusDay(Constant.TOKEN_DAYS - 1,nowDate); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); Date endTime = format.parse(endDay); TokenRecord tokenRecord = new TokenRecord(); tokenRecord.setUid(uid); tokenRecord.setIdentify(giveId + ""); // 记录id tokenRecord.setType(TokenTypeEnum.taoLiJin); tokenRecord.setStartTime(nowDate); tokenRecord.setEndTime(endTime); tokenRecord.setEndTime(DateUtil.plusDayDate(Constant.TOKEN_DAYS, new Date())); tokenRecord.setToken(token); tokenRecord.setState(0); tokenRecordService.insertSelective(tokenRecord); @@ -594,12 +586,13 @@ updateExtra.setUpdateTime(new Date()); userMoneyExtraService.updateByPrimaryKeySelective(updateExtra); String tips = "送给你[%s]元推广红包快去领取吧,复制本条消息[&%s&],打开[返利券]App领取,用推广分享爆款商品,成单率更高哦。\r\n" + "----------------------------\r\n" + "下载[返利券]App链接:%s\r\n" + "PS:口令将会24小时内失效,请及时领取。"; tips = String.format(tips, amount, token, configService.get("app_down_link")); String tips = configTaoLiJinService.getValueByKey("give_taolijin_tips"); String projectChineseName = Constant.systemCommonConfig.getProjectChineseName(); while(tips.contains("{APP名称}")) { tips = tips.replace("{APP名称}", projectChineseName); } tips = tips.replace("{口令}", token).replace("{下载链接}", configService.get("app_down_link")) .replace("{面额}", amount.setScale(0).toString()); executor.execute(new Runnable() { @Override fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java
@@ -20,6 +20,7 @@ import com.yeshi.fanli.entity.bus.user.UserInfoExtra; import com.yeshi.fanli.entity.bus.user.UserSystemCoupon; import com.yeshi.fanli.entity.bus.user.UserSystemCouponGiveRecord; import com.yeshi.fanli.entity.bus.user.UserSystemCouponRecord; import com.yeshi.fanli.entity.system.SystemCoupon.CouponTypeEnum; import com.yeshi.fanli.exception.tlj.UserTaoLiJinOriginException; import com.yeshi.fanli.exception.user.TokenRecordException; @@ -33,6 +34,7 @@ import com.yeshi.fanli.service.inter.user.UserInfoExtraService; import com.yeshi.fanli.service.inter.user.UserInfoService; import com.yeshi.fanli.service.inter.user.UserSystemCouponGiveRecordService; import com.yeshi.fanli.service.inter.user.UserSystemCouponRecordService; import com.yeshi.fanli.service.inter.user.UserSystemCouponService; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.StringUtil; @@ -43,7 +45,7 @@ @Resource(name = "taskExecutor") private TaskExecutor executor; @Resource private TokenRecordMapper tokenRecordMapper; @@ -63,16 +65,17 @@ private UserInfoExtraService userInfoExtraService; @Resource private UserSystemCouponRecordService userSystemCouponRecordService; @Resource private UserSystemCouponGiveRecordService userSystemCouponGiveRecordService; @Resource private UserTaoLiJinOriginService userTaoLiJinOriginService; @Resource private UserOtherMsgNotificationService userOtherMsgNotificationService; @Override public void insertSelective(TokenRecord record) { record.setCreateTime(new Date()); @@ -89,19 +92,132 @@ public TokenVO discernToken(String token, Long uid) throws TokenRecordException { // TODO token 验证 TokenRecord rokenRecord = tokenRecordMapper.getByToken(token); if (rokenRecord == null) throw new TokenRecordException(1, "口令不存在"); Date now = new Date(); Date endTimeToken = rokenRecord.getEndTime(); if (endTimeToken != null && endTimeToken.getTime() < now.getTime()) throw new TokenRecordException(1, "口令已失效"); Integer stateTtoken = rokenRecord.getState(); if (stateTtoken != null && stateTtoken == 1) if (endTimeToken != null && endTimeToken.getTime() < now.getTime() || (stateTtoken != null && stateTtoken == 1) || StringUtil.isNullOrEmpty(rokenRecord.getIdentify())) throw new TokenRecordException(1, "口令已失效"); Integer num = 1; Integer type = 0; boolean state = false; List<String> tips = new ArrayList<String>(); String identify = rokenRecord.getIdentify(); TokenTypeEnum tokenType = rokenRecord.getType(); if (tokenType == TokenTypeEnum.freeCoupon) { type = 10; UserSystemCouponGiveRecord giveRecord = userSystemCouponGiveRecordService .selectByPrimaryKey(Long.parseLong(identify)); if (giveRecord == null) throw new TokenRecordException(1, "赠送记录不存在"); Date endTime = giveRecord.getEndTime(); if (endTime != null && endTime.getTime() < now.getTime()) throw new TokenRecordException(1, "赠送记录已过期"); // 用户券信息 UserSystemCoupon userCoupon = userSystemCouponService.selectByPrimaryKey(giveRecord.getCouponId()); if (userCoupon == null || userCoupon.getGive() == null || !userCoupon.getGive()) throw new TokenRecordException(1, "券不存在或非赠送状态"); if (userCoupon.getState() == UserSystemCoupon.STATE_OVERDUE) { tips.add("哎呀,这张免单券已失效了!"); } else if (userCoupon.getState() == UserSystemCoupon.STATE_END_USE) { tips.add("哎呀,这张免单券已被领取了!"); } else if (userCoupon.getState() == UserSystemCoupon.STATE_IN_USE) { if (uid == null || uid <= 0) throw new TokenRecordException(1001, "温馨提示,[免单券]需要登录后领取"); state = true; UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid); if (userInfoExtra == null || StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) { tips.add("确认领取后,你将成为赠送者的一级队员;"); tips.add("获赠的免单券,需要激活后才能使用,详情参见免单券激活规则;"); tips.add("成功领取后,请到“我的-福利中心”查看。"); } else { tips.add("获赠的免单券,需要激活后才能使用,详情参见免单券激活规则;"); tips.add("成功领取后,请到“我的-福利中心”查看。"); } } else { throw new TokenRecordException(1, "口令已失效"); } } else if (tokenType == TokenTypeEnum.rebatePercentCoupon) { type = 11; // 赠送记录 UserSystemCouponGiveRecord giveRecord = userSystemCouponGiveRecordService .selectByPrimaryKey(Long.parseLong(identify)); if (giveRecord == null) throw new TokenRecordException(1, "赠送记录不存在"); Date endTime = giveRecord.getEndTime(); if (endTime != null && endTime.getTime() < now.getTime()) throw new TokenRecordException(1, "赠送记录已过期"); UserSystemCoupon userCoupon = userSystemCouponService.selectByPrimaryKey(giveRecord.getCouponId()); if (userCoupon == null || userCoupon.getGive() == null || !userCoupon.getGive()) throw new TokenRecordException(1, "券不存在或非赠送状态"); if (userCoupon.getState() == UserSystemCoupon.STATE_OVERDUE) { tips.add("哎呀,这张返利奖励券已失效了!"); } else if (userCoupon.getState() == UserSystemCoupon.STATE_END_USE) { tips.add("哎呀,这张返利奖励券已被领取了!"); } else if (userCoupon.getState() == UserSystemCoupon.STATE_IN_USE) { if (uid == null || uid <= 0) throw new TokenRecordException(1001, "温馨提示,[返利奖励券]需要登录后领取"); state = true; UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid); if (userInfoExtra == null || StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) { tips.add("确认领取后,你将成为赠送者的一级队员;"); tips.add("返利券奖励券,可用于“已到账”的返利订单,在返利的基础上再获得一定比例的返利;"); tips.add("成功领取后,请到“我的-福利中心”中查看。"); } else { tips.add("返利券奖励券,可用于“已到账”的返利订单,在返利的基础上再获得一定比例的返利;"); tips.add("成功领取后,请到“我的-福利中心”中查看。"); } } else { throw new TokenRecordException(1, "口令已失效"); } } else if (tokenType == TokenTypeEnum.taoLiJin) { type = 12; UserTaoLiJinGiveRecord giveRecord = userTaoLiJinGiveRecordService .selectByPrimaryKey(Long.parseLong(identify)); if (giveRecord == null || giveRecord.getState() == UserTaoLiJinGiveRecord.STATE_OVERDUE) { tips.add("哎呀,推广红包已失效了!"); } else if (giveRecord.getState() == UserTaoLiJinGiveRecord.STATE_RECEIVE) { tips.add("哎呀,推广红包已被领取了!"); } else if (giveRecord.getState() == UserTaoLiJinGiveRecord.STATE_INIT) { if (uid == null || uid <= 0) throw new TokenRecordException(1001, "温馨提示,[推广红包]需要登录后领取"); state = true; BigDecimal amount = giveRecord.getAmount(); num = Integer.parseInt(amount.setScale(0).toString()); UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid); if (userInfoExtra == null || StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) { tips.add("确认领取后,你将成为赠送者的一级队员;"); tips.add("推广红包,可分享爆款商品,让分享订单成单率更高;"); tips.add("成功领取后,请到“我的-推广红包”中查看。"); } else { tips.add("推广红包,可分享爆款商品,让分享订单成单率更高;"); tips.add("成功领取后,请到“我的-推广红包”中查看。"); } } else { throw new TokenRecordException(1, "口令失效"); } } else { throw new TokenRecordException(1, "无对应类型"); } String nickName = null; String portrait = null; @@ -123,125 +239,19 @@ if (nickName.length() > 6) { nickName = nickName.substring(0, 6) + "..."; } TokenVO tokenVO = new TokenVO(); tokenVO.setAmount(num); tokenVO.setToken(token); tokenVO.setNickName(nickName + "赠送"); tokenVO.setPortrait(portrait); String identify = rokenRecord.getIdentify(); if (StringUtil.isNullOrEmpty(identify)) throw new TokenRecordException(1, "口令标识不存在"); Integer type = 0; boolean state = false; List<String> tips = new ArrayList<String>(); TokenTypeEnum tokenType = rokenRecord.getType(); if (tokenType == TokenTypeEnum.freeCoupon) { type = 10; UserSystemCoupon userCoupon = userSystemCouponService.selectByPrimaryKey(Long.parseLong(identify)); if (userCoupon == null) { tips.add("哎呀,这张免单券已失效了!"); } else { Boolean give = userCoupon.getGive(); if (give == null) give = false; if (userCoupon.getState() == UserSystemCoupon.STATE_OVERDUE) { tips.add("哎呀,这张免单券已失效了!"); } else if (userCoupon.getState() == UserSystemCoupon.STATE_END_USE) { tips.add("哎呀,这张免单券已被领取了!"); } else if (userCoupon.getState() == UserSystemCoupon.STATE_CAN_USE) { throw new TokenRecordException(1, "口令已失效"); } else if (give && userCoupon.getState() == UserSystemCoupon.STATE_IN_USE) { if (uid == null || uid <= 0) throw new TokenRecordException(1001, "温馨提示,[免单券]需要登录后领取"); state = true; tokenVO.setAmount(1); UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid); if (userInfoExtra == null || StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) { tips.add("确认领取后,你将成为赠送者的一级队员;"); tips.add("获赠的免单券,需要激活后才能使用,详情参见免单券激活规则;"); tips.add("成功领取后,请到“我的-福利中心”查看。"); } else { tips.add("获赠的免单券,需要激活后才能使用,详情参见免单券激活规则;"); tips.add("成功领取后,请到“我的-福利中心”查看。"); } } else { throw new TokenRecordException(1, "口令已失效"); } } } else if (tokenType == TokenTypeEnum.rebatePercentCoupon) { type = 11; UserSystemCoupon userCoupon = userSystemCouponService.selectByPrimaryKey(Long.parseLong(identify)); if (userCoupon == null) { } else { Boolean give = userCoupon.getGive(); if (give == null) give = false; if (userCoupon.getState() == UserSystemCoupon.STATE_OVERDUE) { tips.add("哎呀,这张返利奖励券已失效了!"); } else if (userCoupon.getState() == UserSystemCoupon.STATE_END_USE) { tips.add("哎呀,这张返利奖励券已被领取了!"); } else if (userCoupon.getState() == UserSystemCoupon.STATE_CAN_USE) { throw new TokenRecordException(1, "口令已失效"); } else if (give && userCoupon.getState() == UserSystemCoupon.STATE_IN_USE) { if (uid == null || uid <= 0) throw new TokenRecordException(1001, "温馨提示,[返利奖励券]需要登录后领取"); state = true; tokenVO.setAmount(1); UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid); if (userInfoExtra == null || StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) { tips.add("确认领取后,你将成为赠送者的一级队员;"); tips.add("返利券奖励券,可用于“已到账”的返利订单,在返利的基础上再获得一定比例的返利;"); tips.add("成功领取后,请到“我的-福利中心”中查看。"); } else { tips.add("返利券奖励券,可用于“已到账”的返利订单,在返利的基础上再获得一定比例的返利;"); tips.add("成功领取后,请到“我的-福利中心”中查看。"); } } else { throw new TokenRecordException(1, "口令已失效"); } } } else if (tokenType == TokenTypeEnum.taoLiJin) { type = 12; UserTaoLiJinGiveRecord giveRecord = userTaoLiJinGiveRecordService .selectByPrimaryKey(Long.parseLong(identify)); if (giveRecord == null || giveRecord.getState() == UserTaoLiJinGiveRecord.STATE_OVERDUE) { tips.add("哎呀,推广红包已失效了!"); } else if (giveRecord.getState() == UserTaoLiJinGiveRecord.STATE_RECEIVE) { tips.add("哎呀,推广红包已被领取了!"); } else { if (uid == null || uid <= 0) throw new TokenRecordException(1001, "温馨提示,[推广红包]需要登录后领取"); BigDecimal amount = giveRecord.getAmount(); state = true; tokenVO.setAmount(Integer.parseInt(amount.setScale(0).toString())); UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid); if (userInfoExtra == null || StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) { tips.add("确认领取后,你将成为赠送者的一级队员;"); tips.add("推广红包,可分享爆款商品,让分享订单成单率更高;"); tips.add("成功领取后,请到“我的-推广红包”中查看。"); } else { tips.add("推广红包,可分享爆款商品,让分享订单成单率更高;"); tips.add("成功领取后,请到“我的-推广红包”中查看。"); } } } else { throw new TokenRecordException(1, "无对应类型"); } tokenVO.setTips(tips); tokenVO.setState(state); tokenVO.setType(type); return tokenVO; } @Override public String receiveToken(String token, Long uid) throws TokenRecordException { @@ -254,241 +264,241 @@ TokenRecord rokenRecord = tokenRecordMapper.getByToken(token); if (rokenRecord == null) throw new TokenRecordException(1, "口令已失效"); Date now = new Date(); Date endTimeToken = rokenRecord.getEndTime(); if (endTimeToken != null && endTimeToken.getTime() < now.getTime()) throw new TokenRecordException(1, "口令已失效"); Integer stateTtoken = rokenRecord.getState(); if (stateTtoken != null && stateTtoken == 1) throw new TokenRecordException(1, "口令已失效"); String identify = rokenRecord.getIdentify(); if (StringUtil.isNullOrEmpty(identify)) throw new TokenRecordException(1, "口令标识不存在"); Long giveUid = rokenRecord.getUid(); UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid); if (userInfoExtra == null) if (userInfoExtra == null) throw new TokenRecordException(1, "用户信息缺失"); String msg = "领取成功"; TokenTypeEnum tokenType = rokenRecord.getType(); if (tokenType == TokenTypeEnum.freeCoupon) { long couponId = Long.parseLong(identify); UserSystemCoupon userCoupon = userSystemCouponService.selectByPrimaryKey(couponId); if (userCoupon == null) throw new TokenRecordException(1, "该券不存在"); Boolean give = userCoupon.getGive(); if (give == null) give = false; if (userCoupon.getState() == UserSystemCoupon.STATE_OVERDUE) throw new TokenRecordException(1, "哎呀,这张免单券已失效了!"); if (userCoupon.getState() == UserSystemCoupon.STATE_END_USE) throw new TokenRecordException(1, "哎呀,这张免单券已被领取了!"); if (userCoupon.getState() == UserSystemCoupon.STATE_CAN_USE) throw new TokenRecordException(1, "口令已失效"); if (give && userCoupon.getState() == UserSystemCoupon.STATE_IN_USE) { UserSystemCouponGiveRecord giveRecord = userSystemCouponGiveRecordService.getRecordByUidAndCouponId(giveUid, couponId); if (giveRecord == null ) throw new TokenRecordException(1, "口令已失效"); Date endTime = giveRecord.getEndTime(); if (endTime != null && endTime.getTime() < now.getTime()) throw new TokenRecordException(1, "哎呀,这张免单券已失效了!"); try { userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.freeCoupon.name(), UserSystemCoupon.SOURCE_GIVE); } catch (Exception e) { LogHelper.errorDetailInfo(e); throw new TokenRecordException(1, "领取失败"); } // 更新赠送券信息 userSystemCouponService.updateGiveRecord(uid, couponId, CouponTypeEnum.freeCoupon.name()); // 更新赠送记录 giveRecord.setReceiveUid(uid); giveRecord.setReceiveTime(new Date()); userSystemCouponGiveRecordService.updateByPrimaryKeySelective(giveRecord); msg = "领取成功[免单券]成功,请到[我的-福利中心]中查看"; // 消息 + 队员 executor.execute(new Runnable() { @Override public void run() { SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH.mm"); boolean addTeam = addInviteTeam(uid, giveUid, userInfoExtra); String beiZhu = "无"; if (addTeam) beiZhu = "领取人已经成为你的一级队员"; String userName = "无"; UserInfo user = userInfoService.selectByPKey(uid); if (user != null && !StringUtil.isNullOrEmpty(user.getNickName())) userName = user.getNickName(); MsgOtherGiveContentDTO msgOther = new MsgOtherGiveContentDTO(); msgOther.setType(MsgOtherGiveContentDTO.TYEP_COUPON); msgOther.setTitle("赠送免单券"); msgOther.setGiveType("你赠送的免单券被成功领取"); msgOther.setReceiveInfo("昵称: " + userName +" ID:" + uid); msgOther.setGiveTime(sd.format(giveRecord.getGiveTime())); msgOther.setReceiveTime(sd.format(new Date())); userOtherMsgNotificationService.tokenGiveMsg(giveUid, beiZhu, msgOther); } }); } else { throw new TokenRecordException(1, "口令已失效"); // 赠送记录 UserSystemCouponGiveRecord giveRecord = userSystemCouponGiveRecordService .selectByPrimaryKey(Long.parseLong(identify)); if (giveRecord == null) throw new TokenRecordException(1, "赠送记录不存在"); Date endTime = giveRecord.getEndTime(); if (endTime != null && endTime.getTime() < now.getTime()) throw new TokenRecordException(1, "赠送记录已过期"); UserSystemCoupon userCoupon = userSystemCouponService.selectByPrimaryKey(giveRecord.getCouponId()); if (userCoupon == null || userCoupon.getGive() == null || !userCoupon.getGive() || userCoupon.getState() != UserSystemCoupon.STATE_IN_USE) throw new TokenRecordException(1, "该券不存在或非赠送"); try { userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.freeCoupon.name(), UserSystemCoupon.SOURCE_GIVE); } catch (Exception e) { LogHelper.errorDetailInfo(e); throw new TokenRecordException(1, "领取失败"); } // 更新状态 Date date = new Date(); userCoupon.setId(userCoupon.getId()); userCoupon.setState(UserSystemCoupon.STATE_END_USE); userCoupon.setUseTime(date); userCoupon.setUpdateTime(date); userSystemCouponService.updateByPrimaryKeySelective(userCoupon); // 更新使用记录 UserSystemCouponRecord useRecord = userSystemCouponRecordService.getNearByUserCouponId(userCoupon.getId()); if (useRecord != null) { UserSystemCouponRecord updateuseRecord = new UserSystemCouponRecord(); updateuseRecord.setId(useRecord.getId()); updateuseRecord.setState(UserSystemCouponRecord.STATE_SUCCESS); updateuseRecord.setUpdateTime(new Date()); userSystemCouponRecordService.updateByPrimaryKeySelective(updateuseRecord); } // 更新赠送记录 UserSystemCouponGiveRecord updateGiveRecord = new UserSystemCouponGiveRecord(); updateGiveRecord.setReceiveUid(uid); updateGiveRecord.setReceiveTime(new Date()); updateGiveRecord.setState(UserSystemCouponGiveRecord.STATE_RECEIVE); userSystemCouponGiveRecordService.updateByPrimaryKeySelective(updateGiveRecord); msg = "领取成功[免单券]成功,请到[我的-福利中心]中查看"; // 消息 + 队员 executor.execute(new Runnable() { @Override public void run() { SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH.mm"); boolean addTeam = addInviteTeam(uid, giveUid, userInfoExtra); String beiZhu = "无"; if (addTeam) beiZhu = "领取人已经成为你的一级队员"; String userName = "无"; UserInfo user = userInfoService.selectByPKey(uid); if (user != null && !StringUtil.isNullOrEmpty(user.getNickName())) userName = user.getNickName(); MsgOtherGiveContentDTO msgOther = new MsgOtherGiveContentDTO(); msgOther.setType(MsgOtherGiveContentDTO.TYEP_COUPON); msgOther.setTitle("赠送免单券"); msgOther.setGiveType("你赠送的免单券被成功领取"); msgOther.setReceiveInfo("昵称: " + userName + " ID:" + uid); msgOther.setGiveTime(sd.format(giveRecord.getGiveTime())); msgOther.setReceiveTime(sd.format(new Date())); userOtherMsgNotificationService.tokenGiveMsg(giveUid, beiZhu, msgOther); } }); } else if (tokenType == TokenTypeEnum.rebatePercentCoupon) { long couponId = Long.parseLong(identify); UserSystemCoupon userCoupon = userSystemCouponService.selectByPrimaryKey(couponId); if (userCoupon == null) throw new TokenRecordException(1, "该券不存在"); // 赠送记录 UserSystemCouponGiveRecord giveRecord = userSystemCouponGiveRecordService .selectByPrimaryKey(Long.parseLong(identify)); if (giveRecord == null) throw new TokenRecordException(1, "赠送记录不存在"); Boolean give = userCoupon.getGive(); if (give == null) give = false; Date endTime = giveRecord.getEndTime(); if (endTime != null && endTime.getTime() < now.getTime()) throw new TokenRecordException(1, "赠送记录已过期"); if (userCoupon.getState() == UserSystemCoupon.STATE_OVERDUE) throw new TokenRecordException(1, "哎呀,这张返利奖励券已失效了!"); if (userCoupon.getState() == UserSystemCoupon.STATE_END_USE) throw new TokenRecordException(1, "哎呀,这张返利奖励券已被领取了!"); if (userCoupon.getState() == UserSystemCoupon.STATE_CAN_USE) throw new TokenRecordException(1, "口令已失效"); if (give && userCoupon.getState() == UserSystemCoupon.STATE_IN_USE) { UserSystemCouponGiveRecord giveRecord = userSystemCouponGiveRecordService.getRecordByUidAndCouponId(giveUid, couponId); if (giveRecord == null ) throw new TokenRecordException(1, "口令已失效"); Date endTime = giveRecord.getEndTime(); if (endTime != null && endTime.getTime() < now.getTime()) throw new TokenRecordException(1, "哎呀,这张返利奖励券已失效了!"); try { userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.rebatePercentCoupon.name(), UserSystemCoupon.SOURCE_GIVE); } catch (Exception e) { LogHelper.errorDetailInfo(e); throw new TokenRecordException(1, "领取失败"); } // 更新赠送券信息 userSystemCouponService.updateGiveRecord(uid, couponId, CouponTypeEnum.rebatePercentCoupon.name()); // 更新赠送记录 giveRecord.setReceiveUid(uid); giveRecord.setReceiveTime(new Date()); userSystemCouponGiveRecordService.updateByPrimaryKeySelective(giveRecord); msg = "领取成功[返利奖励券]成功,请到[我的-福利中心]中查看"; // 消息 + 队员 executor.execute(new Runnable() { @Override public void run() { SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH.mm"); boolean addTeam = addInviteTeam(uid, giveUid, userInfoExtra); String beiZhu = "无"; if (addTeam) beiZhu = "领取人已经成为你的一级队员"; String userName = "无"; UserInfo user = userInfoService.selectByPKey(uid); if (user != null && !StringUtil.isNullOrEmpty(user.getNickName())) userName = user.getNickName(); MsgOtherGiveContentDTO msgOther = new MsgOtherGiveContentDTO(); msgOther.setType(MsgOtherGiveContentDTO.TYEP_COUPON); msgOther.setTitle("赠送奖励券"); msgOther.setGiveType("你赠送的奖励券被成功领取"); msgOther.setReceiveInfo("昵称: " + userName +" ID:" + uid); msgOther.setGiveTime(sd.format(giveRecord.getGiveTime())); msgOther.setReceiveTime(sd.format(new Date())); userOtherMsgNotificationService.tokenGiveMsg(giveUid, beiZhu, msgOther); } }); } else { throw new TokenRecordException(1, "口令已失效"); UserSystemCoupon userCoupon = userSystemCouponService.selectByPrimaryKey(giveRecord.getCouponId()); if (userCoupon == null || userCoupon.getGive() == null || !userCoupon.getGive() || userCoupon.getState() != UserSystemCoupon.STATE_IN_USE) throw new TokenRecordException(1, "该券不存在或非赠送"); try { userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.freeCoupon.name(), UserSystemCoupon.SOURCE_GIVE); } catch (Exception e) { LogHelper.errorDetailInfo(e); throw new TokenRecordException(1, "领取失败"); } // 更新状态 Date date = new Date(); userCoupon.setId(userCoupon.getId()); userCoupon.setState(UserSystemCoupon.STATE_END_USE); userCoupon.setUseTime(date); userCoupon.setUpdateTime(date); userSystemCouponService.updateByPrimaryKeySelective(userCoupon); // 更新使用记录 UserSystemCouponRecord useRecord = userSystemCouponRecordService.getNearByUserCouponId(userCoupon.getId()); if (useRecord != null) { UserSystemCouponRecord updateuseRecord = new UserSystemCouponRecord(); updateuseRecord.setId(useRecord.getId()); updateuseRecord.setState(UserSystemCouponRecord.STATE_SUCCESS); updateuseRecord.setUpdateTime(new Date()); userSystemCouponRecordService.updateByPrimaryKeySelective(updateuseRecord); } // 更新赠送记录 UserSystemCouponGiveRecord updateGiveRecord = new UserSystemCouponGiveRecord(); updateGiveRecord.setReceiveUid(uid); updateGiveRecord.setReceiveTime(new Date()); updateGiveRecord.setState(UserSystemCouponGiveRecord.STATE_RECEIVE); userSystemCouponGiveRecordService.updateByPrimaryKeySelective(updateGiveRecord); msg = "领取成功[返利奖励券]成功,请到[我的-福利中心]中查看"; // 消息 + 队员 executor.execute(new Runnable() { @Override public void run() { SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH.mm"); boolean addTeam = addInviteTeam(uid, giveUid, userInfoExtra); String beiZhu = "无"; if (addTeam) beiZhu = "领取人已经成为你的一级队员"; String userName = "无"; UserInfo user = userInfoService.selectByPKey(uid); if (user != null && !StringUtil.isNullOrEmpty(user.getNickName())) userName = user.getNickName(); MsgOtherGiveContentDTO msgOther = new MsgOtherGiveContentDTO(); msgOther.setType(MsgOtherGiveContentDTO.TYEP_COUPON); msgOther.setTitle("赠送奖励券"); msgOther.setGiveType("你赠送的奖励券被成功领取"); msgOther.setReceiveInfo("昵称: " + userName + " ID:" + uid); msgOther.setGiveTime(sd.format(giveRecord.getGiveTime())); msgOther.setReceiveTime(sd.format(new Date())); userOtherMsgNotificationService.tokenGiveMsg(giveUid, beiZhu, msgOther); } }); } else if (tokenType == TokenTypeEnum.taoLiJin) { UserTaoLiJinGiveRecord giveRecord = userTaoLiJinGiveRecordService .selectByPrimaryKey(Long.parseLong(identify)); if (giveRecord == null || giveRecord.getState() == UserTaoLiJinGiveRecord.STATE_OVERDUE) { throw new TokenRecordException(1, "哎呀,推广红包已失效了!"); } else if (giveRecord.getState() == UserTaoLiJinGiveRecord.STATE_RECEIVE) { throw new TokenRecordException(1, "哎呀,推广红包已被领取了!"); } else { Date endTime = giveRecord.getEndTime(); if (endTime != null && endTime.getTime() < now.getTime()) throw new TokenRecordException(1, "哎呀,推广红包已失效了!"); BigDecimal amount = giveRecord.getAmount(); try { // 领取 userTaoLiJinOriginService.receiveFriendsGive(uid, amount); // 更新记录 UserTaoLiJinGiveRecord updateRecord = new UserTaoLiJinGiveRecord(); updateRecord.setId(Long.parseLong(identify)); updateRecord.setReceiveTime(new Date()); updateRecord.setReceiveUid(uid); updateRecord.setState(UserTaoLiJinGiveRecord.STATE_RECEIVE); userTaoLiJinGiveRecordService.updateByPrimaryKeySelective(updateRecord); msg = "领取成功[推广红包]成功,请到[我的-推广红包]中查看"; // 消息 + 队员 executor.execute(new Runnable() { @Override public void run() { SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH.mm"); boolean addTeam = addInviteTeam(uid, giveUid, userInfoExtra); String beiZhu = "无"; if (addTeam) beiZhu = "领取人已经成为你的一级队员"; String userName = "无"; UserInfo user = userInfoService.selectByPKey(uid); if (user != null && !StringUtil.isNullOrEmpty(user.getNickName())) userName = user.getNickName(); MsgOtherGiveContentDTO msgOther = new MsgOtherGiveContentDTO(); msgOther.setType(MsgOtherGiveContentDTO.TYEP_COUPON); msgOther.setTitle("赠送推广红包"); msgOther.setGiveType("你赠送的推广红包被成功领取"); msgOther.setReceiveInfo("昵称: " + userName +" ID:" + uid); msgOther.setGiveTime(sd.format(giveRecord.getGiveTime())); msgOther.setReceiveTime(sd.format(new Date())); userOtherMsgNotificationService.tokenGiveMsg(giveUid, beiZhu, msgOther); } }); } catch (UserTaoLiJinOriginException e) { e.printStackTrace(); } if (giveRecord == null || giveRecord.getState() != UserTaoLiJinGiveRecord.STATE_INIT) throw new TokenRecordException(1, "赠送记录失效或已被领取"); Date endTime = giveRecord.getEndTime(); if (endTime != null && endTime.getTime() < now.getTime()) throw new TokenRecordException(1, "推广红包已失效了"); BigDecimal amount = giveRecord.getAmount(); try { // 领取 userTaoLiJinOriginService.receiveFriendsGive(uid, amount); // 更新记录 UserTaoLiJinGiveRecord updateRecord = new UserTaoLiJinGiveRecord(); updateRecord.setId(Long.parseLong(identify)); updateRecord.setReceiveTime(new Date()); updateRecord.setReceiveUid(uid); updateRecord.setState(UserTaoLiJinGiveRecord.STATE_RECEIVE); userTaoLiJinGiveRecordService.updateByPrimaryKeySelective(updateRecord); msg = "领取成功[推广红包]成功,请到[我的-推广红包]中查看"; // 消息 + 队员 executor.execute(new Runnable() { @Override public void run() { SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH.mm"); boolean addTeam = addInviteTeam(uid, giveUid, userInfoExtra); String beiZhu = "无"; if (addTeam) beiZhu = "领取人已经成为你的一级队员"; String userName = "无"; UserInfo user = userInfoService.selectByPKey(uid); if (user != null && !StringUtil.isNullOrEmpty(user.getNickName())) userName = user.getNickName(); MsgOtherGiveContentDTO msgOther = new MsgOtherGiveContentDTO(); msgOther.setType(MsgOtherGiveContentDTO.TYEP_COUPON); msgOther.setTitle("赠送推广红包"); msgOther.setGiveType("你赠送的推广红包被成功领取"); msgOther.setReceiveInfo("昵称: " + userName + " ID:" + uid); msgOther.setGiveTime(sd.format(giveRecord.getGiveTime())); msgOther.setReceiveTime(sd.format(new Date())); userOtherMsgNotificationService.tokenGiveMsg(giveUid, beiZhu, msgOther); } }); } catch (UserTaoLiJinOriginException e) { e.printStackTrace(); } } else { throw new TokenRecordException(1, "无对应类型"); } return msg; } /** * 未激活邀请码: 上下级关系确立 * 未激活邀请码: 上下级关系确立 * * @param uid * @param giveUid * @param userInfoExtra @@ -498,9 +508,9 @@ boolean invite = false; if (StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) { UserInfoExtra userInfoExtraGive = userInfoExtraService.getUserInfoExtra(giveUid); if (userInfoExtraGive != null ) { if (userInfoExtraGive != null) { String inviteCode = userInfoExtraGive.getInviteCode(); if(!StringUtil.isNullOrEmpty(inviteCode)) { if (!StringUtil.isNullOrEmpty(inviteCode)) { try { userInfoExtraService.activateInviteCode(uid, inviteCode); invite = true; @@ -512,5 +522,5 @@ } return invite; } } fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponGiveRecordServiceImpl.java
@@ -23,6 +23,11 @@ } @Override public UserSystemCouponGiveRecord selectByPrimaryKey(Long id) { return userSystemCouponGiveRecordMapper.selectByPrimaryKey(id); } @Override public UserSystemCouponGiveRecord getRecordByUidAndCouponId(Long giveUid, Long couponId) { return userSystemCouponGiveRecordMapper.getRecordByUidAndCouponId(giveUid, couponId); } fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponRecordServiceImpl.java
@@ -74,4 +74,8 @@ return false; } @Override public UserSystemCouponRecord getNearByUserCouponId(Long userCouponId) { return userSystemCouponRecordMapper.getNearByUserCouponId(userCouponId); } } fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java
@@ -1824,16 +1824,38 @@ jumpBtn.put("params", jumpLink); jumpBtn.put("jumpDetail", jumpDetailV2Service.getByTypeCache("orderList")); } } else if (UserSystemCoupon.STATE_IN_USE == state) { } else if (UserSystemCoupon.STATE_IN_USE == state && give) { userCouponVO.setCouponEffect("赠送中"); String tips = null; if (CouponTypeEnum.freeCouponGive == type) { userCouponVO.setState(UserSystemCoupon.STATE_GIVE_IN); tips = configService.get("give_free_coupon_tips"); } if (give && CouponTypeEnum.rebatePercentCoupon == type) { if (CouponTypeEnum.rebatePercentCoupon == type) { userCouponVO.setState(UserSystemCoupon.STATE_GIVE_IN); tips = configService.get("give_free_coupon_tips"); } if (!StringUtil.isNullOrEmpty(tips)) { UserSystemCouponGiveRecord record = userSystemCouponGiveRecordService.getRecordByUidAndCouponId(uid, userCouponVO.getId()); if (record != null) { TokenRecord tokenRecord = tokenRecordService.getNearByTypeAndIdentify(CouponTypeEnum.freeCoupon.name(), record.getId().toString()); if (tokenRecord != null && !StringUtil.isNullOrEmpty(tokenRecord.getToken())) { String projectChineseName = Constant.systemCommonConfig.getProjectChineseName(); while(tips.contains("{APP名称}")) { tips = tips.replace("{APP名称}", projectChineseName); } tips = tips.replace("{口令}", tokenRecord.getToken()).replace("{下载链接}", configService.get("app_down_link")); } } } else { tips = ""; } userCouponVO.setGiveTips(tips); } else if (UserSystemCoupon.STATE_END_USE == state) { if (CouponTypeEnum.freeCouponGive == type) { if (give && CouponTypeEnum.freeCouponGive == type) { userCouponVO.setState(UserSystemCoupon.STATE_GIVE_END); } @@ -1873,109 +1895,130 @@ if (type != CouponTypeEnum.freeCouponGive && type != CouponTypeEnum.rebatePercentCoupon ) throw new UserSystemCouponException(1, "该券不支持赠送"); String tips = null; TokenTypeEnum tokenTypeEnum = null; if (type == CouponTypeEnum.freeCouponGive) { tokenTypeEnum = TokenTypeEnum.freeCoupon; tips = configService.get("give_free_coupon_tips"); } else if (type == CouponTypeEnum.rebatePercentCoupon){ tokenTypeEnum = TokenTypeEnum.rebatePercentCoupon; tips = configService.get("give_rebate_percent_coupon_tips"); } else { throw new UserSystemCouponException(1, "该券不支持赠送"); } String token = null; Date nowDate = new Date(); TokenRecord record = tokenRecordService.getNearByTypeAndIdentify(tokenTypeEnum.name(), id+""); if (record != null && record.getEndTime().getTime() > nowDate.getTime()) { token = record.getToken(); } else { for (int i = 0; i < 5; i++) { try { // TODO 口令生成规则待定 long num = 10000 + (long) (Math.random() * 10000); token = UserUtil.getInviteCode(num); String endDay = DateUtil.plusDay(Constant.TOKEN_DAYS - 1,nowDate); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); Date endTime = format.parse(endDay); TokenRecord tokenRecord = new TokenRecord(); tokenRecord.setUid(uid); tokenRecord.setIdentify(id+""); tokenRecord.setType(tokenTypeEnum); tokenRecord.setStartTime(nowDate); tokenRecord.setEndTime(endTime); tokenRecord.setToken(token); tokenRecord.setState(0); tokenRecordService.insertSelective(tokenRecord); } catch (Exception e) { LogHelper.errorDetailInfo(e); token = null; if (StringUtil.isNullOrEmpty(tips)) throw new UserSystemCouponException(1, "tips数据缺失"); // 是否最近生成口令有效 UserSystemCouponGiveRecord record = userSystemCouponGiveRecordService.getRecordByUidAndCouponId(uid, id); if (record != null) { TokenRecord tokenRecord = tokenRecordService.getNearByTypeAndIdentify(tokenTypeEnum.name(), id+""); if (tokenRecord != null && !StringUtil.isNullOrEmpty(tokenRecord.getToken())) { String projectChineseName = Constant.systemCommonConfig.getProjectChineseName(); while(tips.contains("{APP名称}")) { tips = tips.replace("{APP名称}", projectChineseName); } if(!StringUtil.isNullOrEmpty(token)) { break; } } if(StringUtil.isNullOrEmpty(token)) throw new UserSystemCouponException(1, "口令生成失败"); // 插入赠送记录 try { String endDay = DateUtil.plusDay(Constant.GIVE_DAYS - 1, new Date()); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); Date endTime = format.parse(endDay); UserSystemCouponGiveRecord giveRecord = new UserSystemCouponGiveRecord(); giveRecord.setCouponId(id); giveRecord.setGiveUid(uid); giveRecord.setGiveTime(nowDate); giveRecord.setEndTime(endTime); userSystemCouponGiveRecordService.insertSelective(giveRecord); } catch (Exception e) { LogHelper.errorDetailInfo(e); throw new UserSystemCouponException(1, "赠送记录创建失败"); tips = tips.replace("{口令}", tokenRecord.getToken()).replace("{下载链接}", configService.get("app_down_link")); return tips; } } Long giveRecordId = null; Date nowDate = new Date(); // 插入赠送记录 try { UserSystemCouponGiveRecord giveRecord = new UserSystemCouponGiveRecord(); giveRecord.setCouponId(id); giveRecord.setGiveUid(uid); giveRecord.setGiveTime(nowDate); giveRecord.setEndTime(DateUtil.plusDayDate(Constant.GIVE_DAYS, nowDate)); userSystemCouponGiveRecordService.insertSelective(giveRecord); giveRecordId = giveRecord.getId(); } catch (Exception e) { LogHelper.errorDetailInfo(e); throw new UserSystemCouponException(1, "赠送记录创建失败"); } String token = null; for (int i = 0; i < 5; i++) { try { // TODO 口令生成规则待定 long num = 10000 + (long) (Math.random() * 10000); token = UserUtil.getInviteCode(num); TokenRecord tokenRecord = new TokenRecord(); tokenRecord.setUid(uid); tokenRecord.setIdentify(giveRecordId+""); tokenRecord.setType(tokenTypeEnum); tokenRecord.setStartTime(nowDate); tokenRecord.setEndTime(DateUtil.plusDayDate(Constant.TOKEN_DAYS, nowDate)); tokenRecord.setToken(token); tokenRecord.setState(0); tokenRecordService.insertSelective(tokenRecord); } catch (Exception e) { LogHelper.errorDetailInfo(e); token = null; } if(!StringUtil.isNullOrEmpty(token)) { break; } } if(StringUtil.isNullOrEmpty(token)) throw new UserSystemCouponException(1, "口令生成失败"); userSystemCoupon.setState(UserSystemCoupon.STATE_IN_USE); userSystemCoupon.setGive(true); userSystemCoupon.setUpdateTime(nowDate); userSystemCouponMapper.updateByPrimaryKeySelective(userSystemCoupon); String tips = "送给你一张返利奖励券快去领取吧,复制本条消息[&%s&],打开[返利券]App领取,使用后可让返利加倍。\r\n" +"----------------------------\r\n" + "下载[返利券]App链接:%s\r\n" + "PS:口令将会24小时内失效,请及时领取。"; tips = String.format(tips, token, configService.get("app_down_link")); // 插入使用券记录 UserSystemCouponRecord couponRecord = new UserSystemCouponRecord(); couponRecord.setState(UserSystemCouponRecord.STATE_GIVE_ON); couponRecord.setUserSystemCoupon(userSystemCoupon); couponRecord.setCouponType(type.name()); couponRecord.setCreateTime(nowDate); couponRecord.setUpdateTime(nowDate); userSystemCouponRecordService.insertSelective(couponRecord); String projectChineseName = Constant.systemCommonConfig.getProjectChineseName(); while(tips.contains("{APP名称}")) { tips = tips.replace("{APP名称}", projectChineseName); } tips = tips.replace("{口令}", token).replace("{下载链接}", configService.get("app_down_link")); return tips; } @Override public void updateGiveRecord(Long uid, Long id, String couponType) { Date date = new Date(); // 更新券状态:已使用 UserSystemCoupon userCoupon = new UserSystemCoupon(); userCoupon.setId(id); userCoupon.setState(UserSystemCoupon.STATE_END_USE); userCoupon.setUseTime(date); userCoupon.setUpdateTime(date); userSystemCouponMapper.updateByPrimaryKeySelective(userCoupon); public void sendBackGive(Long id) { UserSystemCoupon userSystemCoupon = userSystemCouponMapper.selectByPrimaryKey(id); if (userSystemCoupon == null) return; Integer state = userSystemCoupon.getState(); if (state != UserSystemCoupon.STATE_IN_USE) return; Date now = new Date(); Date endTime = userSystemCoupon.getEndTime(); if (endTime != null && endTime.getTime() < now.getTime()) { // TODO 过期 return; } userSystemCoupon.setGive(false); userSystemCoupon.setUseTime(null); userSystemCoupon.setState(UserSystemCoupon.STATE_CAN_USE); userSystemCoupon.setUpdateTime(new Date()); userSystemCouponMapper.updateByPrimaryKey(userSystemCoupon); // 插入使用券记录 UserSystemCouponRecord couponRecord = new UserSystemCouponRecord(); couponRecord.setState(UserSystemCouponRecord.STATE_SUCCESS); couponRecord.setUserSystemCoupon(userCoupon); couponRecord.setCouponType(couponType); couponRecord.setCreateTime(date); couponRecord.setUpdateTime(date); userSystemCouponRecordService.insertSelective(couponRecord); // TODO 消息 } } fanli/src/main/java/com/yeshi/fanli/service/inter/integral/IntegralDetailService.java
New file @@ -0,0 +1,30 @@ package com.yeshi.fanli.service.inter.integral; import java.util.Date; import java.util.List; import com.yeshi.fanli.vo.integral.IntegralDetailVO; public interface IntegralDetailService { /** * 积分明细 * @param uid * @param detailId * @param maxTime * @return */ public List<IntegralDetailVO> listDetailForClient(Long uid, Long detailId, Date maxTime); /** * 明细统计 * @param uid * @param detailId * @param maxTime * @return */ public long countDetailForClient(Long uid, Long detailId, Date maxTime); } fanli/src/main/java/com/yeshi/fanli/service/inter/integral/IntegralTaskRecordService.java
@@ -78,4 +78,21 @@ */ public Integer receiveGoldCoin(Long uid, Set<Long> idList) throws IntegralTaskRecordException; /** * 返回领取列表 * @param count * @param uid * @param idList * @return */ public List<IntegralTaskRecord> listNotReceivedExcludeId(int count, long uid, Set<Long> idList); /** * 领取所有 * @param uid * @return * @throws IntegralTaskRecordException */ public Integer receiveGoldCoinALL(Long uid) throws IntegralTaskRecordException; } fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserSystemCouponGiveRecordService.java
@@ -33,4 +33,12 @@ */ public List<UserSystemCouponGiveRecord> overdueList(int count); /** * id查询 * @param id * @return */ public UserSystemCouponGiveRecord selectByPrimaryKey(Long id); } fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserSystemCouponRecordService.java
@@ -44,4 +44,12 @@ */ public boolean isSuccessMianDan(Integer source, String orderId); /** * 查询最近记录 * @param userCouponId * @return */ public UserSystemCouponRecord getNearByUserCouponId(Long userCouponId); } fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserSystemCouponService.java
@@ -237,12 +237,11 @@ */ public String giveCoupon(Long uid, Long id) throws UserSystemCouponException; /** * 更新赠送记录 * @param uid * 赠送退回 * @param id * @param couponType */ public void updateGiveRecord(Long uid, Long id, String couponType); public void sendBackGive(Long id); } fanli/src/main/java/com/yeshi/fanli/vo/integral/IntegralDetailVO.java
New file @@ -0,0 +1,33 @@ package com.yeshi.fanli.vo.integral; import java.io.Serializable; import com.google.gson.annotations.Expose; import com.yeshi.fanli.entity.integral.IntegralDetail; public class IntegralDetailVO implements Serializable{ /** * */ private static final long serialVersionUID = 1L; @Expose private IntegralMonthVO month; @Expose private IntegralDetail detail; public IntegralMonthVO getMonth() { return month; } public void setMonth(IntegralMonthVO month) { this.month = month; } public IntegralDetail getDetail() { return detail; } public void setDetail(IntegralDetail detail) { this.detail = detail; } } fanli/src/main/java/com/yeshi/fanli/vo/integral/IntegralMonthVO.java
New file @@ -0,0 +1,72 @@ package com.yeshi.fanli.vo.integral; import java.io.Serializable; import com.google.gson.annotations.Expose; public class IntegralMonthVO implements Serializable{ /** * */ private static final long serialVersionUID = 1L; @Expose private int year;// 年份 @Expose private int month;// 月 @Expose private String expend;// 支出 @Expose private String income;// 收入 private String dateFormate; public String getDateFormate() { return dateFormate; } public void setDateFormate(String dateFormate) { this.dateFormate = dateFormate; } public IntegralMonthVO(int year, int month) { this.year = year; this.month = month; } public IntegralMonthVO() { } public int getYear() { return year; } public void setYear(int year) { this.year = year; } public int getMonth() { return month; } public void setMonth(int month) { this.month = month; } public String getExpend() { return expend; } public void setExpend(String expend) { this.expend = expend; } public String getIncome() { return income; } public void setIncome(String income) { this.income = income; } } fanli/src/main/java/com/yeshi/fanli/vo/user/UserSystemCouponVO.java
@@ -58,6 +58,10 @@ @Expose private List<String> tips; // 赠送中-分享口令 @Expose private String giveTips; public String getTopPicture() { @@ -164,4 +168,11 @@ this.popup = popup; } public String getGiveTips() { return giveTips; } public void setGiveTips(String giveTips) { this.giveTips = giveTips; } }