From 2442c923fd35ef864be1cfe07e039eebfaf24ffc Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期二, 03 十二月 2019 11:48:21 +0800
Subject: [PATCH] 新人红包功能

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsServiceImpl.java |   45 +++++++++++++++++++--------------------------
 1 files changed, 19 insertions(+), 26 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsServiceImpl.java
index 06ef3ea..6f55cf9 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsServiceImpl.java
@@ -25,9 +25,7 @@
 import com.yeshi.fanli.dao.mybatis.share.PidUserMapper;
 import com.yeshi.fanli.dto.taobao.TaoLiJinDTO;
 import com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory;
-import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinRecord;
 import com.yeshi.fanli.entity.bus.user.UserInfo;
-import com.yeshi.fanli.entity.bus.user.UserMoneyExtra;
 import com.yeshi.fanli.entity.taobao.PidUser;
 import com.yeshi.fanli.entity.taobao.TBPid;
 import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
@@ -39,7 +37,7 @@
 import com.yeshi.fanli.exception.taobao.TaoKeApiException;
 import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
 import com.yeshi.fanli.exception.tlj.TaoLiJinCreateException;
-import com.yeshi.fanli.exception.tlj.UserTaoLiJinRecordException;
+import com.yeshi.fanli.exception.tlj.UserTaoLiJinNewbiesException;
 import com.yeshi.fanli.log.LogHelper;
 import com.yeshi.fanli.service.inter.config.ConfigService;
 import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
@@ -47,6 +45,7 @@
 import com.yeshi.fanli.service.inter.money.UserMoneyExtraService;
 import com.yeshi.fanli.service.inter.monitor.BusinessEmergent110Service;
 import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
+import com.yeshi.fanli.service.inter.redpack.UserTaoLiJinNewbiesService;
 import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService;
 import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
 import com.yeshi.fanli.service.inter.taobao.UserTLJBuyHistoryService;
@@ -119,6 +118,9 @@
 	@Resource
 	private BusinessEmergent110Service businessEmergent110Service;
 
+	@Resource
+	private UserTaoLiJinNewbiesService userTaoLiJinNewbiesService;
+	
 	@Override
 	public void addShareGoodsHistory(UserShareGoodsHistory history) {
 		UserShareGoodsHistory userShareGoodsHistory = userShareGoodsHistoryMapper
@@ -677,39 +679,31 @@
 	@Override
 	public TaoBaoLink getTaoLiJinLinkForBuy(Long uid, String specialId, Long auctionId, String pid)
 			throws ShareGoodsException {
-		if (uid == null || uid <= 0) {
+		if (uid == null || uid <= 0) 
 			throw new ShareGoodsException(1, "鐢ㄦ埛ID涓嶈兘涓虹┖");
-		}
 
-		if (auctionId == null || auctionId <= 0) {
-			throw new ShareGoodsException(2, "鍟嗗搧ID涓嶈兘涓虹┖");
-		}
-
-		// 鐢ㄦ埛鍓╀綑鍙互娣樼ぜ閲戦獙璇�
-		UserMoneyExtra userMoneyExtra = userMoneyExtraService.selectByPrimaryKey(uid);
-		if (userMoneyExtra == null || userMoneyExtra.getTlj() == null) {
-			throw new ShareGoodsException(101, "绾㈠寘浣欓涓嶈冻");
-		}
-
+		if (auctionId == null || auctionId <= 0) 
+			throw new ShareGoodsException(1, "鍟嗗搧ID涓嶈兘涓虹┖");
+		
 		TaoKeAppInfo app = new TaoKeAppInfo();
 		app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
 		app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
-		if (pid == null)
+		if (pid == null) {
 			app.setPid(TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT);
-		else
+		} else {
 			app.setPid(pid);
-		TaoBaoGoodsBrief goods = TaoKeApiUtil.specialConvertCoupon(auctionId, app);
-		if (goods == null) {
-			throw new ShareGoodsException(1, "");
 		}
-
+		
+		TaoBaoGoodsBrief goods = TaoKeApiUtil.specialConvertCoupon(auctionId, app);
+		if (goods == null) 
+			throw new ShareGoodsException(1, "杞摼鎺ュけ璐�");
+		
 		String taoLiJinLink = null;
 		try {
 			goods.setAuctionId(auctionId);
-			UserTaoLiJinRecord createUserTaoLiJin = userTaoLiJinRecordService.createSelfBuyTaoLiJin(uid, 1, goods);
-			taoLiJinLink = createUserTaoLiJin.getSendUrl();
-		} catch (UserTaoLiJinRecordException e) {
-			throw new ShareGoodsException(e.getCode(), e.getMsg());
+			taoLiJinLink = userTaoLiJinNewbiesService.createTaoLiJinForBuy(goods, uid);
+		} catch (UserTaoLiJinNewbiesException e1) {
+			throw new ShareGoodsException(e1.getCode(), e1.getMsg());
 		}
 
 		TaoBaoLink taoBaoLink = new TaoBaoLink();
@@ -717,7 +711,6 @@
 		taoBaoLink.setClickUrl(goods.getAuctionUrl());
 		taoBaoLink.setCouponLink(taoLiJinLink);
 		taoBaoLink.setGoods(goods);
-
 		return taoBaoLink;
 	}
 

--
Gitblit v1.8.0