From d28bed1a1275131a5ca37f7da37961e2b518ac07 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期一, 26 八月 2019 13:44:00 +0800 Subject: [PATCH] 淘礼金创建异常处理 --- fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinRecordServiceImpl.java | 63 +++++++++++++++---------------- 1 files changed, 31 insertions(+), 32 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 2a24a5f..7bc334f 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 @@ -26,6 +26,7 @@ import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; import com.yeshi.fanli.entity.taobao.TaoKeAppInfo; import com.yeshi.fanli.exception.taobao.TaoKeApiException; +import com.yeshi.fanli.exception.tlj.TaoLiJinCreateException; import com.yeshi.fanli.exception.tlj.UserTaoLiJinRecordException; import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.goods.CommonGoodsService; @@ -99,13 +100,12 @@ @Resource private ShareHotGoodsService shareHotGoodsService; - + @Override public UserTaoLiJinRecord selectByPrimaryKey(Long id) { return userTaoLiJinRecordMapper.selectByPrimaryKey(id); } - @Transactional @Override public UserTaoLiJinRecord createSelfBuyTaoLiJin(Long uid, int totalNum, TaoBaoGoodsBrief goods) @@ -147,7 +147,7 @@ UserTaoLiJinRecord record = createUserTaoLiJin(1, uid, goods.getAuctionId(), perface, 1, name, sendStartTime, sendEndTime, null, useEndTime, TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID); record.setSendUrl(record.getSendUrl() + "&relationId=" + relationId); - UserTaoLiJinRecord updateRecoed=new UserTaoLiJinRecord(); + UserTaoLiJinRecord updateRecoed = new UserTaoLiJinRecord(); updateRecoed.setId(record.getId()); updateRecoed.setSendUrl(record.getSendUrl()); userTaoLiJinRecordMapper.updateByPrimaryKeySelective(record); @@ -202,7 +202,7 @@ perface = new BigDecimal(1); } else { // 璁$畻鎺ㄥ箍绾㈠寘 - String warningRate = configTaoLiJinService.getValueByKey("warning_value",new Date()); + String warningRate = configTaoLiJinService.getValueByKey("warning_value", new Date()); perface = TaoLiJinUtil.getSpreadMoney(warningRate, goods); } @@ -210,7 +210,7 @@ sendStartTime, sendEndTime, null, useEndTime, TaoBaoConstant.TAOBAO_TLJ_RELATION_PID_DEFAULT); String sendUrl = record.getSendUrl() + "&relationId=" + relationId; record.setSendUrl(sendUrl); - UserTaoLiJinRecord updateRecoed=new UserTaoLiJinRecord(); + UserTaoLiJinRecord updateRecoed = new UserTaoLiJinRecord(); updateRecoed.setId(record.getId()); updateRecoed.setSendUrl(sendUrl); userTaoLiJinRecordMapper.updateByPrimaryKeySelective(record); @@ -231,45 +231,46 @@ // 杩囨湡 -鍙栨秷鏀跺洖 // userTaoLiJinOriginService.overdueHongBao(uid); - + // 鎬绘帹骞跨孩鍖� BigDecimal totalMoney = MoneyBigDecimalUtil.mul(perface, new BigDecimal(totalNum)); - + // 鑷喘鏃剁殑绾㈠寘浣欓 if (origin == 1) { BigDecimal tljSelf = userMoneyExtra.getTljSelf(); if (tljSelf == null || tljSelf.compareTo(totalMoney) < 0) { throw new UserTaoLiJinRecordException(101, "鑷喘绾㈠寘浣欓涓嶈冻"); } - } - + } + // 鍒嗕韩鏃剁殑绾㈠寘浣欓 BigDecimal tlj = userMoneyExtra.getTlj(); if (tlj == null || tlj.compareTo(totalMoney) < 0) { throw new UserTaoLiJinRecordException(101, "鍒嗕韩绾㈠寘浣欓涓嶈冻"); } - // 鍒涘缓娣樼ぜ閲戠孩鍖� TaoLiJinDTO taoLiJinDTO = null; try { - taoLiJinDTO = TaoKeApiUtil.createTaoLiJin(auctionId, name, perface, totalNum, sendStartTime, - sendEndTime, useStartTime, useEndTime, new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET, pid)); - } catch (TaoKeApiException e) { + taoLiJinDTO = TaoKeApiUtil.createTaoLiJin(auctionId, name, perface, totalNum, sendStartTime, sendEndTime, + useStartTime, useEndTime, + new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET, pid)); + } catch (TaoLiJinCreateException e) { LogHelper.errorDetailInfo(e); executor.execute(new Runnable() { @Override public void run() { - if (e.getCode() == TaoKeApiException.CODE_TLJ_FORBIDDEN) { + if (e.getCode() == TaoLiJinCreateException.CODE_TLJ_FORBIDDEN) { // 璇ュ晢鍝佷笉鏀寔鍒涘缓娣樼ぜ閲戠孩鍖� shareHotGoodsService.deleteByGoodsId(auctionId); - } else if (e.getCode() == TaoKeApiException.CODE_TLJ_NO_MONEY) { - // 瀹樻柟鐜╂硶閽卞寘浣欓涓嶈冻 TODO + } else if (e.getCode() == TaoLiJinCreateException.CODE_TLJ_NO_MONEY) { + // 瀹樻柟鐜╂硶閽卞寘浣欓涓嶈冻 TODO } } }); + } catch (TaoKeApiException e1) { } - + if (taoLiJinDTO == null) { throw new UserTaoLiJinRecordException(101, "娣樺疂API鎺ㄥ箍绾㈠寘鍒涘缓澶辫触"); } @@ -288,21 +289,21 @@ record.setRightsId(taoLiJinDTO.getRightsId()); record.setSendUrl(taoLiJinDTO.getSendUrl()); record.setCreateTime(new Date()); - if (origin == 1) { // 鑷喘 + if (origin == 1) { // 鑷喘 record.setUseType(1); - } else { // 鍒嗕韩 + } else { // 鍒嗕韩 record.setUseType(2); } - + userTaoLiJinRecordMapper.insertSelective(record); - BigDecimal surplusTlj = MoneyBigDecimalUtil.sub(tlj, totalMoney); - + BigDecimal surplusTlj = MoneyBigDecimalUtil.sub(tlj, totalMoney); + UserMoneyExtra updateExtra = new UserMoneyExtra(); updateExtra.setUid(uid); if (origin == 1) { // 鍓╀綑娣樼ぜ閲�-- 鑷喘 updateExtra.setTljSelf(MoneyBigDecimalUtil.sub(userMoneyExtra.getTljSelf(), totalMoney)); - } + } updateExtra.setTlj(surplusTlj); updateExtra.setUpdateTime(new Date()); userMoneyExtraService.updateByPrimaryKeySelective(updateExtra); @@ -366,13 +367,11 @@ } catch (Exception e) { LogHelper.errorDetailInfo(e); } - - - if (origin == 1) { - return; // 鑷喘涓嶆帹閫佹秷鎭� + + if (origin == 1) { + return; // 鑷喘涓嶆帹閫佹秷鎭� } - - + // 浣跨敤鎴愬姛娑堟伅 try { String beizhu = "鏈棰嗗彇鎴栭鍙栧悗鏈娇鐢ㄩ儴鍒嗛��鍥�"; @@ -458,7 +457,8 @@ BigDecimal commission = userTaoLiJinRecordVO.getCommission(); if (commission != null && commission.compareTo(shareMoney) > 0) { BigDecimal shareRate = hongBaoManageService.getShareRate(); - shareMoney = MoneyBigDecimalUtil.mul(commission, MoneyBigDecimalUtil.div(shareRate, new BigDecimal(100))); + shareMoney = MoneyBigDecimalUtil.mul(commission, + MoneyBigDecimalUtil.div(shareRate, new BigDecimal(100))); shareMoney = BigDecimalUtil.getWithNoZera(shareMoney); } @@ -480,8 +480,7 @@ public long countShareRecordByUid(Long uid) { return userTaoLiJinRecordMapper.countShareRecordByUid(uid); } - - + @Override public long countTodayNum(Long uid) { return userTaoLiJinRecordMapper.countTodayNum(uid); -- Gitblit v1.8.0