From 39c683421f75449c7a85280fa499bae3a2f5241b Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期一, 26 八月 2019 09:27:49 +0800 Subject: [PATCH] 金币领取 --- fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinRecordServiceImpl.java | 69 ++++++++++++---------------------- 1 files changed, 24 insertions(+), 45 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinRecordServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinRecordServiceImpl.java index 15abadd..724a745 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinRecordServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinRecordServiceImpl.java @@ -53,7 +53,7 @@ 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; @@ -394,7 +394,7 @@ // 浣跨敤鎴愬姛娑堟伅 try { String beizhu = "鏈棰嗗彇鎴栭鍙栧悗鏈娇鐢ㄩ儴鍒嗛��鍥�"; - SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH.mm"); + SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH:mm"); String time = sd.format(new Date()); MsgOtherTaoLiJinContentDTO content = new MsgOtherTaoLiJinContentDTO(); content.setState("绾㈠寘鎵i櫎"); @@ -533,53 +533,32 @@ 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.setGiveUid(uid); - giveRecord.setState(UserTaoLiJinGiveRecord.STATE_INIT); - giveRecord.setGiveTime(nowDate); - 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, "璧犻�佽褰曞垱寤哄け璐�"); - } + // 璧犻�佽褰� + UserTaoLiJinGiveRecord giveRecord = new UserTaoLiJinGiveRecord(); + giveRecord.setAmount(amount); + giveRecord.setGiveUid(uid); + giveRecord.setState(UserTaoLiJinGiveRecord.STATE_INIT); + giveRecord.setGiveTime(nowDate); + giveRecord.setEndTime(DateUtil.plusDayDate(Constant.GIVE_DAYS, new Date())); + userTaoLiJinGiveRecordService.insertSelective(giveRecord); - String token = null; - for (int i = 0; i < 5; i++) { - try { - // TODO 鍙d护鐢熸垚瑙勫垯寰呭畾 - long num = 10000 + (long) (Math.random() * 10000); - token = UserUtil.getInviteCode(num); - - TokenRecord tokenRecord = new TokenRecord(); - tokenRecord.setUid(uid); - tokenRecord.setIdentify(giveId + ""); // 璁板綍id - 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; - } - } + // 鍙d护璁板綍 + TokenRecord tokenRecord = new TokenRecord(); + tokenRecord.setUid(uid); + tokenRecord.setIdentify(giveRecord.getId() + ""); + tokenRecord.setType(TokenTypeEnum.taoLiJin); + tokenRecord.setStartTime(nowDate); + tokenRecord.setEndTime(DateUtil.plusDayDate(Constant.TOKEN_DAYS, new Date())); + tokenRecord.setState(0); + tokenRecordService.insertSelective(tokenRecord); - if(StringUtil.isNullOrEmpty(token)) - throw new UserTaoLiJinRecordException(1, "鍙d护鐢熸垚澶辫触"); + // 鍒涘缓鍙d护 + String token = TokenUtil.createToken(tokenRecord.getId()); + tokenRecord.setToken(token); + tokenRecordService.updateByPrimaryKeySelective(tokenRecord); + // 鏇存柊浣欓 UserMoneyExtra updateExtra = new UserMoneyExtra(); updateExtra.setUid(uid); updateExtra.setTlj(MoneyBigDecimalUtil.sub(tlj, amount)); -- Gitblit v1.8.0