From 74ee9c42c1d87f3724a21e92871bc8c95c8364c6 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 03 九月 2019 17:04:03 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/div' into div
---
fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralExchangeServiceImpl.java | 97 ++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 80 insertions(+), 17 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralExchangeServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralExchangeServiceImpl.java
index dd22129..093e088 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralExchangeServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralExchangeServiceImpl.java
@@ -16,13 +16,16 @@
import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
import com.yeshi.fanli.entity.bus.user.UserSystemCoupon;
import com.yeshi.fanli.entity.integral.CodePublishRecord;
+import com.yeshi.fanli.entity.integral.IntegralDetail;
import com.yeshi.fanli.entity.integral.IntegralExchange;
import com.yeshi.fanli.entity.integral.IntegralExchange.ExchangeTypeEnum;
import com.yeshi.fanli.entity.money.UserMoneyDetail;
import com.yeshi.fanli.exception.integral.IntegralExchangeException;
import com.yeshi.fanli.log.LogHelper;
+import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoV2Service;
import com.yeshi.fanli.service.inter.integral.CodePublishRecordService;
+import com.yeshi.fanli.service.inter.integral.IntegralDetailService;
import com.yeshi.fanli.service.inter.integral.IntegralExchangeRecordService;
import com.yeshi.fanli.service.inter.integral.IntegralExchangeService;
import com.yeshi.fanli.service.inter.msg.MsgInviteDetailService;
@@ -45,6 +48,9 @@
@Resource
private IntegralExchangeMapper integralExchangeMapper;
+
+ @Resource
+ private ConfigService configService;
@Resource
private UserInfoExtraService userInfoExtraService;
@@ -76,6 +82,8 @@
@Resource
private MsgInviteDetailService msgInviteDetailService;
+ @Resource
+ private IntegralDetailService integralDetailService;
@Override
@@ -111,15 +119,22 @@
exchangeTip.setId(id);
ExchangeTypeEnum type = exchange.getType();
if (ExchangeTypeEnum.inviteCodeActivate == type) {
- //exchangeTip.setTip("娉細鍏戞崲鎴愬姛鍚庤鍒扳�滄秷鎭�-绯荤粺娑堟伅鈥濇煡鐪�");
- //exchangeTip.setGoldCoin(goldCoin + "閲戝竵");
exchangeTip.setType(type.name());
return exchangeTip;
}
+ long exchangeCount = 0;
+ if (ExchangeTypeEnum.freeCouponBuy == type) {
+ exchangeCount = integralExchangeRecordService.countRecordByUid(id, uid, null);
+ if (exchangeCount >= 1) {
+ throw new IntegralExchangeException(1, "鑷喘鍏嶅崟鍒革紝浠呰兘鍏戞崲涓�娆�");
+ }
+ }
+
Integer upperLimit = exchange.getUpperLimit();
if (upperLimit != null) { // 鏄惁鏈夐檺鍒舵瘡鏃ユ鏁�
- long exchangeCount = integralExchangeRecordService.countRecordByUid(id, uid);
+ Integer today = 1;
+ exchangeCount = integralExchangeRecordService.countRecordByUid(id, uid, today);
if (exchangeCount >= upperLimit) {
throw new IntegralExchangeException(1, "浠婃棩鍏戞崲宸茶揪涓婇檺");
}
@@ -145,10 +160,10 @@
exchangeTip.setInviteCode(extraVO.getInviteCode());
exchangeTip.setTip("鍏戞崲鎴愬姛鍚庯紝灏嗗彂甯冧簬鈥滄縺娲婚個璇风爜鍏戞崲鍔熻兘涓�濓紝闇�婵�娲婚個璇风殑鐢ㄦ埛鍙敤閲戝竵鍏戞崲锛屾湰娆″睍绀烘湁鏁堟湡涓�3澶┿��");
} else if (ExchangeTypeEnum.taoLiJin == type) {
- exchangeTip.setName(exchange.getAmount() + "鍏冩帹骞跨孩鍖�");
+ exchangeTip.setName(exchange.getAmount().setScale(0) + "鍏冩帹骞跨孩鍖�");
exchangeTip.setTip("娉�:鍏戞崲鎴愬姛鍚庤鍒扳�滄垜鐨�-鎺ㄥ箍绾㈠寘鈥濅腑鏌ョ湅");
} else if (ExchangeTypeEnum.cash == type) {
- exchangeTip.setName(exchange.getAmount() + "鍏冪幇閲戠孩鍖�");
+ exchangeTip.setName(exchange.getAmount().setScale(0) + "鍏冪幇閲戠孩鍖�");
exchangeTip.setTip("娉細鍏戞崲鎴愬姛鍚庤鍒扳�滄垜鐨�-璐︽埛浣欓鈥濅腑鏌ョ湅");
} else {
throw new IntegralExchangeException(1, "鍏戞崲鏂瑰紡涓嶅瓨鍦�");
@@ -175,12 +190,22 @@
if (exchange == null)
throw new IntegralExchangeException(1, "鍏戞崲鏂瑰紡涓嶅瓨鍦�");
+ ExchangeTypeEnum type = exchange.getType();
+
long exchangeCount = 0;
+ if (ExchangeTypeEnum.freeCouponBuy == type) {
+ exchangeCount = integralExchangeRecordService.countRecordByUid(id, uid, null);
+ if (exchangeCount >= 1) {
+ throw new IntegralExchangeException(1, "鑷喘鍏嶅崟鍒革紝浠呰兘鍏戞崲涓�娆�");
+ }
+ }
+
Integer upperLimit = exchange.getUpperLimit();
if (upperLimit != null) { // 鏄惁鏈夐檺鍒舵瘡鏃ユ鏁�
- exchangeCount = integralExchangeRecordService.countRecordByUid(id, uid);
+ Integer today = 1;
+ exchangeCount = integralExchangeRecordService.countRecordByUid(id, uid, today);
if (exchangeCount >= upperLimit) {
- throw new IntegralExchangeException(1, "浠婃棩鍏戞崲宸茶揪涓婇檺");
+ throw new IntegralExchangeException(1, "鍏戞崲宸茶揪涓婇檺");
}
}
@@ -191,28 +216,45 @@
}
String thing = "";
+ String thingNum = "";
+ int couponNews = 0;
+ boolean once = false; // 鍏戞崲涓�娆℃槸鍚︽秷澶�
try {
- ExchangeTypeEnum type = exchange.getType();
if (ExchangeTypeEnum.freeCouponBuy == type) {
thing = "鑷喘鍏嶅崟鍒�";
+ thingNum = "1寮�";
userSystemCouponService.exchangeCoupon(uid, type.name(), UserSystemCoupon.SOURCE_EXCHANGE, null);
+ once = true;
+ couponNews = 1;
} else if (ExchangeTypeEnum.freeCouponGive == type) {
thing = "璧犻�佸厤鍗曞埜";
+ thingNum = "1寮�";
userSystemCouponService.exchangeCoupon(uid, type.name(), UserSystemCoupon.SOURCE_EXCHANGE, null);
+ couponNews = 1;
} else if (ExchangeTypeEnum.rebatePercentCoupon == type) {
- thing = "濂栧姳鍏嶅崟鍒�";
- userSystemCouponService.exchangeCoupon(uid, type.name(), UserSystemCoupon.SOURCE_EXCHANGE, new BigDecimal(10));
+ thing = "杩斿埄濂栧姳鍒�";
+ thingNum = "1寮�";
+ String percent = configService.get("exchange_rebate_percent");
+ userSystemCouponService.exchangeCoupon(uid, type.name(), UserSystemCoupon.SOURCE_EXCHANGE, new BigDecimal(percent));
+ couponNews = 1;
} else if (ExchangeTypeEnum.inviteCodePublish == type) {
- thing = "閭�璇风爜婵�娲诲崱";
+ thing = "閭�璇风爜鍙戝竷鍗�";
+ thingNum = "3澶�";
if(codePublishRecordService.countValidRecord(uid) > 0)
throw new IntegralExchangeException(1, "涓夊ぉ涔嬪唴涓嶅彲閲嶅鍏戞崲");
codePublishRecordService.publishInviteCode(uid);
+
+ exchange.setNeedJump(true);
+ exchange.setBtnName("鍘绘煡鐪�");
} else if (ExchangeTypeEnum.taoLiJin == type) {
thing = "鎺ㄥ箍绾㈠寘";
+ thingNum = exchange.getAmount() + "鍏�";
userTaoLiJinOriginService.exchangeMoney(uid, exchange.getAmount());
} else if (ExchangeTypeEnum.cash == type) {
thing = "鐜伴噾绾㈠寘";
BigDecimal money = exchange.getAmount();
+ thingNum = money + "鍏�";
+
// 1銆佹彃鍏ョ孩鍖呮暟鎹�
HongBaoV2 hongBaoV2 = new HongBaoV2();
hongBaoV2.setMoney(money);
@@ -244,14 +286,26 @@
int surplus = goldCoinHas.intValue() - goldCoin.intValue();
exchange.setUserGoldCoin(surplus + "鏋�");
- // 鏇存柊閲戝竵
+ // 鏇存柊閲戝竵 + 绂忓埄涓績娑堟伅鏁�
+ if (extraVO.getCouponNews() != null && extraVO.getCouponNews() > 0)
+ couponNews = couponNews + extraVO.getCouponNews();
+
UserInfoExtraVO extraUpdate = new UserInfoExtraVO();
extraUpdate.setId(extraVO.getId());
extraUpdate.setGoldCoin(surplus);
+ extraUpdate.setCouponNews(couponNews);
userInfoExtraService.saveUserInfoExtra(extraUpdate);
// 娣诲姞鍏戞崲璁板綍
integralExchangeRecordService.addExchangeRecord(id, uid);
+
+ // 鍔犲叆鏄庣粏
+ IntegralDetail detail = new IntegralDetail();
+ detail.setUid(uid);
+ detail.setTitle("閲戝竵鍏戞崲-" + thing + "-" + thingNum);
+ detail.setMoney(-goldCoin);
+ detail.setCreateTime(new Date());
+ integralDetailService.insertSelective(detail);
// 娑堟伅
final String things = thing;
@@ -266,6 +320,9 @@
userOtherMsgNotificationService.exchangeMsg(uid, "", msgOther);
}
});
+
+ if (once) // 鍏戞崲涔嬪悗娑堝け
+ exchange = null;
return exchange;
} catch (Exception e) {
@@ -317,7 +374,7 @@
@Override
- public void exchangeInviteCode(Long uid, Long id) throws IntegralExchangeException {
+ public String exchangeInviteCode(Long uid, Long id) throws IntegralExchangeException {
if (uid == null || uid <= 0)
throw new IntegralExchangeException(1, "鐢ㄦ埛鏈櫥褰�");
@@ -351,7 +408,6 @@
throw new IntegralExchangeException(1, "鍏戞崲澶辫触锛岃鐢ㄦ埛閭�璇风爜涓嶅瓨鍦�");
String inviteCode = inviteExtra.getInviteCode();
- userInfoExtraService.activateInviteCode(uid, inviteExtra.getInviteCode());
// 鍓╀綑閲戝竵
int surplus = goldCoinHas.intValue() - goldCoin.intValue();
@@ -362,7 +418,14 @@
extraUpdate.setGoldCoin(surplus);
userInfoExtraService.saveUserInfoExtra(extraUpdate);
-
+ // 鍔犲叆鏄庣粏
+ IntegralDetail detail = new IntegralDetail();
+ detail.setUid(uid);
+ detail.setTitle("閲戝竵鍏戞崲-閭�璇风爜婵�娲诲崱-1缁�");
+ detail.setMoney(-goldCoin);
+ detail.setCreateTime(new Date());
+ integralDetailService.insertSelective(detail);
+
// 娣诲姞鍏戞崲璁板綍
integralExchangeRecordService.addExchangeRecord(id, uid);
@@ -385,11 +448,11 @@
userOtherMsgNotificationService.exchangeMsg(uid, beizu, msgOther);
}
});
+
+ return inviteCode;
} catch (Exception e) {
LogHelper.errorDetailInfo(e);
throw new IntegralExchangeException(1, "鍏戞崲澶辫触");
}
-
-
}
}
--
Gitblit v1.8.0