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 | 63 ++++++++++++------------------- 1 files changed, 25 insertions(+), 38 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 71d1031..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; @@ -220,12 +220,12 @@ perface = new BigDecimal(1); } else { // 璁$畻鎺ㄥ箍绾㈠寘 - String warningRate = configTaoLiJinService.getValueByKey("warning_value"); + String warningRate = configTaoLiJinService.getValueByKey("warning_value",new Date()); perface = TaoLiJinUtil.getSpreadMoney(warningRate, goods); } UserTaoLiJinRecord record = createUserTaoLiJin(2, uid, goods.getAuctionId(), perface, totalNum, name, - sendStartTime, sendEndTime, null, useEndTime, TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT); + sendStartTime, sendEndTime, null, useEndTime, TaoBaoConstant.TAOBAO_TLJ_RELATION_PID_DEFAULT); String sendUrl = record.getSendUrl() + "&relationId=" + relationId; record.setSendUrl(sendUrl); UserTaoLiJinRecord updateRecoed=new UserTaoLiJinRecord(); @@ -533,58 +533,45 @@ if (amount.compareTo(tlj) > 0) throw new UserTaoLiJinRecordException(1, "绾㈠寘浣欓涓嶈冻"); - Date nowDate = new Date(); - // 璧犻�佽褰� 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(giveRecord.getId()+""); // 璁板綍id - tokenRecord.setType(TokenTypeEnum.taoLiJin); - tokenRecord.setStartTime(nowDate); - tokenRecord.setEndTime(DateUtil.plusDayDate(3, nowDate)); - 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