From c044b6dd024b6884a4f39bc56e4873c95b13fe02 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期四, 22 八月 2019 11:59:00 +0800 Subject: [PATCH] 免单更改 --- fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinRecordServiceImpl.java | 88 +++++++++++++++----------------------------- 1 files changed, 30 insertions(+), 58 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 ce6ae73..673415e 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; @@ -533,73 +533,45 @@ if (amount.compareTo(tlj) > 0) throw new UserTaoLiJinRecordException(1, "绾㈠寘浣欓涓嶈冻"); - 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); - 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); - - 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.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)); 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("{鍙d护}", token).replace("{涓嬭浇閾炬帴}", configService.get("app_down_link")) + .replace("{闈㈤}", amount.setScale(0).toString()); executor.execute(new Runnable() { @Override -- Gitblit v1.8.0