From ab9e60fa9a8e43d797446730a5dc9ebfb6b3f4e6 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期四, 27 六月 2019 09:48:17 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinRecordServiceImpl.java | 38 +++++++++++++++++++++++++++++++++----- 1 files changed, 33 insertions(+), 5 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 e1c1ed7..080f0d3 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 @@ -98,6 +98,8 @@ return userTaoLiJinRecordMapper.selectByPrimaryKey(id); } + + @Transactional @Override public UserTaoLiJinRecord createSelfBuyTaoLiJin(Long uid, int totalNum, TaoBaoGoodsBrief goods) throws UserTaoLiJinRecordException { @@ -138,6 +140,10 @@ 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(); + updateRecoed.setId(record.getId()); + updateRecoed.setSendUrl(record.getSendUrl()); + userTaoLiJinRecordMapper.updateByPrimaryKeySelective(record); return record; } else {// 杩斿埄搴撳晢鍝� return createUserTaoLiJin(1, uid, goods.getAuctionId(), perface, 1, name, sendStartTime, sendEndTime, null, @@ -146,6 +152,7 @@ } + @Transactional @Override public UserTaoLiJinRecord createShareTaoLiJin(Long uid, int totalNum, TaoBaoGoodsBrief goods) throws UserTaoLiJinRecordException { @@ -196,6 +203,10 @@ sendStartTime, sendEndTime, null, useEndTime, TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT); String sendUrl = record.getSendUrl() + "&relationId=" + relationId; record.setSendUrl(sendUrl); + UserTaoLiJinRecord updateRecoed=new UserTaoLiJinRecord(); + updateRecoed.setId(record.getId()); + updateRecoed.setSendUrl(sendUrl); + userTaoLiJinRecordMapper.updateByPrimaryKeySelective(record); return record; } @@ -213,12 +224,24 @@ // 杩囨湡 userTaoLiJinOriginService.overdueHongBao(uid); - - BigDecimal tlj = userMoneyExtra.getTlj(); + + // 鎬绘帹骞跨孩鍖� BigDecimal totalMoney = MoneyBigDecimalUtil.mul(perface, new BigDecimal(totalNum)); - if (totalMoney.compareTo(tlj) > 0) { + + // 鑷喘鏃剁殑绾㈠寘浣欓 + 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 = TaoKeApiUtil.createTaoLiJin(auctionId, name, perface, totalNum, sendStartTime, @@ -243,10 +266,15 @@ record.setCreateTime(new Date()); userTaoLiJinRecordMapper.insertSelective(record); - // 鍓╀綑娣樼ぜ閲� - BigDecimal surplusTlj = MoneyBigDecimalUtil.sub(tlj, totalMoney); + UserMoneyExtra updateExtra = new UserMoneyExtra(); updateExtra.setUid(uid); + if (origin == 1) { // 鍓╀綑娣樼ぜ閲�-- 鑷喘 + updateExtra.setTljSelf(MoneyBigDecimalUtil.sub(userMoneyExtra.getTljSelf(), totalMoney)); + } + + // 鍓╀綑娣樼ぜ閲� + BigDecimal surplusTlj = MoneyBigDecimalUtil.sub(tlj, totalMoney); updateExtra.setTlj(surplusTlj); updateExtra.setUpdateTime(new Date()); userMoneyExtraService.updateByPrimaryKeySelective(updateExtra); -- Gitblit v1.8.0