| | |
| | | }
|
| | |
|
| | | // 查询列表
|
| | | List<IntegralDetailVO> list = integralDetailService.listDetailForClient(uid, index, date);
|
| | | List<IntegralDetailVO> list = integralDetailService.listDetailForClient(uid, index, date, type);
|
| | | // 统计总条数
|
| | | long count = integralDetailService.countDetailForClient(uid, index, date);
|
| | | long count = integralDetailService.countDetailForClient(uid, index, date, type);
|
| | |
|
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
|
| | | gsonBuilder.registerTypeAdapter(TaoLiJinDetailTypeEnum.class, new TypeAdapter<TaoLiJinDetailTypeEnum>() {
|
| | |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | Long selectCountByUid(@Param("uid") Long uid); |
| | | Long selectCountByUid(@Param("uid") Long uid, @Param("type")Integer type); |
| | | |
| | | /** |
| | | * 按用户ID和最大时间检索月份的数量 |
| | |
| | | * @param maxDate |
| | | * @return |
| | | */ |
| | | int selectMonthCountByUid(@Param("uid") Long uid, @Param("date") Date maxDate); |
| | | int selectMonthCountByUid(@Param("uid") Long uid, @Param("date") Date maxDate, @Param("type")Integer type); |
| | | |
| | | |
| | | /** |
| | |
| | | * @param date |
| | | * @return |
| | | */ |
| | | Long selectCountByUidAndMaxCreateTime(@Param("uid") Long uid, @Param("date") Date date); |
| | | Long selectCountByUidAndMaxCreateTime(@Param("uid") Long uid, @Param("date") Date date, @Param("type")Integer type); |
| | | |
| | | |
| | | /** |
| | |
| | | * @param date |
| | | * @return |
| | | */ |
| | | List<IntegralDetail> selectByMaxCreateTime(@Param("uid") Long uid, @Param("date") Date date, @Param("count") int count); |
| | | List<IntegralDetail> selectByMaxCreateTime(@Param("uid") Long uid, @Param("date") Date date, @Param("count") int count, @Param("type")Integer type); |
| | | |
| | | |
| | | /** |
| | |
| | | * @param count |
| | | * @return |
| | | */ |
| | | List<IntegralDetail> selectByUidWithIndexId(@Param("uid") Long uid, @Param("id") Long id, @Param("count") int count); |
| | | List<IntegralDetail> selectByUidWithIndexId(@Param("uid") Long uid, @Param("id") Long id, @Param("count") int count, @Param("type")Integer type); |
| | | |
| | | |
| | | /** |
| | |
| | | * @param dateFormat |
| | | * @return |
| | | */ |
| | | List<IntegralMonthVO> selectMonthMoneyByUid(@Param("uid") Long uid, @Param("dateFormat") List<String> dateFormat); |
| | | List<IntegralMonthVO> selectMonthMoneyByUid(@Param("uid") Long uid, @Param("dateFormat") List<String> dateFormat, @Param("type")Integer type); |
| | | |
| | | } |
| | |
| | | <select id="selectCountByUid" resultType="java.lang.Long" parameterType="java.lang.Long"> |
| | | SELECT count(td_id) FROM yeshi_ec_integral_detail |
| | | WHERE td_uid = #{uid} |
| | | <if test="type == 1">AND td_money <![CDATA[>]]> 0</if> |
| | | <if test="type == 2">AND td_money <![CDATA[<]]> 0</if> |
| | | </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} |
| | | <if test="type == 1">AND d.td_money <![CDATA[>]]> 0</if> |
| | | <if test="type == 2">AND d.td_money <![CDATA[<]]> 0</if> |
| | | 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} |
| | | <if test="type == 1">AND td_money <![CDATA[>]]> 0</if> |
| | | <if test="type == 2">AND td_money <![CDATA[<]]> 0</if> |
| | | </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} |
| | | <if test="type == 1">AND t.td_money <![CDATA[>]]> 0</if> |
| | | <if test="type == 2">AND t.td_money <![CDATA[<]]> 0</if> |
| | | ORDER BY t.`td_create_time` DESC,t.td_id DESC |
| | | LIMIT #{count} |
| | | </select> |
| | |
| | | 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}) |
| | | <if test="type == 1">AND t.td_money <![CDATA[>]]> 0</if> |
| | | <if test="type == 2">AND t.td_money <![CDATA[<]]> 0</if> |
| | | ORDER BY t.`td_create_time` DESC,t.td_id DESC |
| | | LIMIT #{count} |
| | | </select> |
| | |
| | | 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} |
| | | <if test="type == 1">AND d.td_money <![CDATA[>]]> 0</if> |
| | | <if test="type == 2">AND d.td_money <![CDATA[<]]> 0</if> |
| | | 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} |
| | | <if test="type == 1">AND d.td_money <![CDATA[>]]> 0</if> |
| | | <if test="type == 2">AND d.td_money <![CDATA[<]]> 0</if> |
| | | GROUP BY DATE_FORMAT(d.`td_create_time`,'%Y-%m') |
| | | ) b ON c.time=b.time |
| | | </trim> |
| | |
| | |
|
| | |
|
| | | @Override
|
| | | public List<IntegralDetailVO> listDetailForClient(Long uid, Long detailId, Date maxTime) {
|
| | | public List<IntegralDetailVO> listDetailForClient(Long uid, Long detailId, Date maxTime, Integer type) {
|
| | | 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);
|
| | | new Date(System.currentTimeMillis() + 1000 * 60 * 60L), 20, type);
|
| | | } else {// 筛选了时间
|
| | | list = integralDetailMapper.selectByMaxCreateTime(uid, maxTime, 20);
|
| | | list = integralDetailMapper.selectByMaxCreateTime(uid, maxTime, 20, type);
|
| | | }
|
| | | if (list != null && list.size() > 0) {
|
| | | Calendar calendar = Calendar.getInstance();
|
| | |
| | | } else {// 二次请求
|
| | |
|
| | | int size = 21;
|
| | | List<IntegralDetail> tempList = integralDetailMapper.selectByUidWithIndexId(uid, detailId, size);
|
| | | List<IntegralDetail> tempList = integralDetailMapper.selectByUidWithIndexId(uid, detailId, size, type);
|
| | | Set<Date> dateSet = new HashSet<>();// 用于储存是否在同一时间上面(精确到秒)
|
| | | if (tempList.size() > 0) {
|
| | | for (IntegralDetail umd : tempList) {
|
| | |
| | | while (dateSet.size() == 1 && tempList2.size() != tempList.size() && size < 40) {// 只有一个时间点的数据
|
| | | tempList = tempList2;
|
| | | size += 10;
|
| | | tempList2 = integralDetailMapper.selectByUidWithIndexId(uid, detailId, size);
|
| | | tempList2 = integralDetailMapper.selectByUidWithIndexId(uid, detailId, size, type);
|
| | | dateSet.clear();
|
| | | for (IntegralDetail umd : tempList2) {
|
| | | dateSet.add(umd.getCreateTime());
|
| | |
| | | ? "0" + monthMap.get(key).getMonth().getMonth() : monthMap.get(key).getMonth().getMonth();
|
| | | dateFormat.add(date);
|
| | | }
|
| | | List<IntegralMonthVO> voList = integralDetailMapper.selectMonthMoneyByUid(uid, dateFormat);
|
| | | List<IntegralMonthVO> voList = integralDetailMapper.selectMonthMoneyByUid(uid, dateFormat, type);
|
| | |
|
| | | int p = 0;
|
| | | keys = monthMap.keySet().iterator();
|
| | |
| | |
|
| | |
|
| | | @Override
|
| | | public long countDetailForClient(Long uid, Long detailId, Date maxTime) {
|
| | | public long countDetailForClient(Long uid, Long detailId, Date maxTime, Integer type) {
|
| | | long monthCount = 0L;
|
| | | long detailCount = 0L;
|
| | | // 未通过时间筛选,查询所有
|
| | | if (maxTime == null) {
|
| | | detailCount = integralDetailMapper.selectCountByUid(uid);
|
| | | detailCount = integralDetailMapper.selectCountByUid(uid, type);
|
| | | // 用于表示当前所有
|
| | | monthCount = integralDetailMapper.selectMonthCountByUid(uid, new Date(System.currentTimeMillis() + 1000 * 60 * 60L));
|
| | | monthCount = integralDetailMapper.selectMonthCountByUid(uid, new Date(System.currentTimeMillis() + 1000 * 60 * 60L), type);
|
| | | } else {// 通过时间筛选了的,需要查询所有
|
| | | detailCount = integralDetailMapper.selectCountByUidAndMaxCreateTime(uid, maxTime);
|
| | | monthCount = integralDetailMapper.selectMonthCountByUid(uid, maxTime);
|
| | | detailCount = integralDetailMapper.selectCountByUidAndMaxCreateTime(uid, maxTime, type);
|
| | | monthCount = integralDetailMapper.selectMonthCountByUid(uid, maxTime, type);
|
| | | }
|
| | |
|
| | | return monthCount + detailCount;
|
| | |
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | | import com.yeshi.fanli.util.account.UserUtil;
|
| | | import com.yeshi.fanli.util.TokenUtil;
|
| | | import com.yeshi.fanli.util.factory.CommonGoodsFactory;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoLiJinUtil;
|
| | |
| | | if (amount.compareTo(tlj) > 0)
|
| | | throw new UserTaoLiJinRecordException(1, "红包余额不足");
|
| | |
|
| | | Long giveId = null;
|
| | | Date nowDate = new Date();
|
| | | try {
|
| | | // 赠送记录
|
| | | UserTaoLiJinGiveRecord giveRecord = new UserTaoLiJinGiveRecord();
|
| | | giveRecord.setAmount(amount);
|
| | |
| | | giveRecord.setEndTime(DateUtil.plusDayDate(Constant.GIVE_DAYS, new Date()));
|
| | | userTaoLiJinGiveRecordService.insertSelective(giveRecord);
|
| | |
|
| | | giveId = giveRecord.getId();
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | throw new UserTaoLiJinRecordException(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(giveId + ""); // 记录id
|
| | | tokenRecord.setIdentify(giveRecord.getId() + "");
|
| | | tokenRecord.setType(TokenTypeEnum.taoLiJin);
|
| | | tokenRecord.setStartTime(nowDate);
|
| | | tokenRecord.setEndTime(DateUtil.plusDayDate(Constant.TOKEN_DAYS, new Date()));
|
| | | tokenRecord.setToken(token);
|
| | | tokenRecord.setState(0);
|
| | | tokenRecordService.insertSelective(tokenRecord);
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | token = null;
|
| | | }
|
| | |
|
| | | if(!StringUtil.isNullOrEmpty(token)) {
|
| | | break;
|
| | | }
|
| | | }
|
| | | // 创建口令
|
| | | String token = TokenUtil.createToken(tokenRecord.getId());
|
| | | tokenRecord.setToken(token);
|
| | | tokenRecordService.updateByPrimaryKeySelective(tokenRecord);
|
| | |
|
| | | if(StringUtil.isNullOrEmpty(token))
|
| | | throw new UserTaoLiJinRecordException(1, "口令生成失败");
|
| | | |
| | | // 更新余额
|
| | | UserMoneyExtra updateExtra = new UserMoneyExtra();
|
| | | updateExtra.setUid(uid);
|
| | | updateExtra.setTlj(MoneyBigDecimalUtil.sub(tlj, amount));
|
| | |
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TokenUtil;
|
| | | import com.yeshi.fanli.vo.msg.TokenVO;
|
| | |
|
| | | @Service
|
| | |
| | | tokenRecordMapper.insertSelective(record);
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public void updateByPrimaryKeySelective(TokenRecord record) {
|
| | | tokenRecordMapper.updateByPrimaryKeySelective(record);
|
| | | }
|
| | | |
| | | @Override
|
| | | public TokenRecord getNearByTypeAndIdentify(String type, String identify) {
|
| | | return tokenRecordMapper.getNearByTypeAndIdentify(type, identify);
|
| | |
| | |
|
| | | @Override
|
| | | public TokenVO discernToken(String token, Long uid) throws TokenRecordException {
|
| | | // 解析口令
|
| | | String parseToken = TokenUtil.parseToken(token);
|
| | | if (StringUtil.isNullOrEmpty(parseToken)) |
| | | throw new TokenRecordException(1, "未发现口令");
|
| | |
|
| | | // TODO token 验证
|
| | | TokenRecord rokenRecord = tokenRecordMapper.getByToken(token);
|
| | | if (rokenRecord == null)
|
| | | throw new TokenRecordException(1, "口令不存在");
|
| | |
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.account.UserUtil;
|
| | | import com.yeshi.fanli.util.TokenUtil;
|
| | | import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
|
| | |
| | | }
|
| | |
|
| | |
|
| | | 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.setIdentify(giveRecord.getId()+"");
|
| | | 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;
|
| | | }
|
| | | }
|
| | | // 创建口令
|
| | | String token = TokenUtil.createToken(tokenRecord.getId());
|
| | | tokenRecord.setToken(token);
|
| | | tokenRecordService.updateByPrimaryKeySelective(tokenRecord);
|
| | |
|
| | | if(StringUtil.isNullOrEmpty(token))
|
| | | throw new UserSystemCouponException(1, "口令生成失败");
|
| | | |
| | | // 券状态
|
| | | userSystemCoupon.setState(UserSystemCoupon.STATE_IN_USE);
|
| | | userSystemCoupon.setGive(true);
|
| | | userSystemCoupon.setUpdateTime(nowDate);
|
| | |
| | | * @param maxTime
|
| | | * @return
|
| | | */
|
| | | public List<IntegralDetailVO> listDetailForClient(Long uid, Long detailId, Date maxTime);
|
| | | public List<IntegralDetailVO> listDetailForClient(Long uid, Long detailId, Date maxTime, Integer type);
|
| | |
|
| | | /**
|
| | | * 明细统计
|
| | |
| | | * @param maxTime
|
| | | * @return
|
| | | */
|
| | | public long countDetailForClient(Long uid, Long detailId, Date maxTime);
|
| | | public long countDetailForClient(Long uid, Long detailId, Date maxTime, Integer type);
|
| | |
|
| | |
|
| | |
|
| | |
| | | */
|
| | | public String receiveToken(String token, Long uid) throws TokenRecordException;
|
| | |
|
| | | |
| | | public void updateByPrimaryKeySelective(TokenRecord record);
|
| | |
|
| | | }
|