From f788607ff771a47bc60d6a86e00b3433c40f3d2c Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 24 九月 2021 15:22:03 +0800
Subject: [PATCH] 接入视频直播

---
 src/main/java/com/yeshi/buwan/service/manager/GoldCornManager.java |  101 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 100 insertions(+), 1 deletions(-)

diff --git a/src/main/java/com/yeshi/buwan/service/manager/GoldCornManager.java b/src/main/java/com/yeshi/buwan/service/manager/GoldCornManager.java
index 7046d67..c593b88 100644
--- a/src/main/java/com/yeshi/buwan/service/manager/GoldCornManager.java
+++ b/src/main/java/com/yeshi/buwan/service/manager/GoldCornManager.java
@@ -3,8 +3,15 @@
 import com.ks.goldcorn.exception.GoldAppException;
 import com.ks.goldcorn.exception.GoldTradeException;
 import com.ks.goldcorn.exception.GoldUserException;
+import com.ks.goldcorn.pojo.DO.GoldCornGetSource;
+import com.ks.goldcorn.pojo.DO.GoldCornRecord;
+import com.ks.goldcorn.pojo.DO.GoldCornRecordCountMap;
+import com.ks.goldcorn.pojo.Query.GoldCornRecordQuery;
 import com.ks.goldcorn.service.remote.GoldCornBalanceService;
+import com.ks.goldcorn.service.remote.GoldCornGetSourceService;
+import com.ks.goldcorn.service.remote.GoldCornRecordService;
 import com.ks.goldcorn.service.remote.GoldCornTradeService;
+import com.yeshi.buwan.domain.goldcorn.CodeCornGetSourceType;
 import com.yeshi.buwan.domain.vip.OrderType;
 import com.yeshi.buwan.domain.vip.OrderRecord;
 import com.yeshi.buwan.exception.goldcorn.GoldCornException;
@@ -14,6 +21,9 @@
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
 
 @Component
 public class GoldCornManager {
@@ -26,7 +36,17 @@
     private GoldCornTradeService goldCornTradeService;
 
     @Reference(version = "1.0", check = false)
+    private GoldCornRecordService goldCornRecordService;
+
+    @Reference(version = "1.0", check = false)
     private GoldCornBalanceService goldCornBalanceService;
+
+    @Reference(version = "1.0", check = false)
+    private GoldCornGetSourceService goldCornGetSourceService;
+
+    public void init(String uid) throws Exception {
+        goldCornBalanceService.init(getAppCode(), getUid(uid));
+    }
 
 
     /**
@@ -53,9 +73,14 @@
     }
 
     public long getBalance(String uid) {
+        if (StringUtil.isNullOrEmpty(uid))
+            return 0;
         try {
             Long count = goldCornBalanceService.getBalance(getAppCode(), getUid(uid));
-            return count==null?0:count;
+            if (count == null) {
+                init(uid);
+            }
+            return count == null ? 0 : count;
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -87,6 +112,28 @@
         consumeGoldCorn(appCode, tuid, sourceCode, goldCornCount, title, desc);
     }
 
+
+    /**
+     * 娣诲姞閲戝竵
+     *
+     * @param uid
+     * @param source
+     * @param goldCorn
+     * @param title
+     * @param desc
+     * @throws GoldUserException
+     * @throws GoldAppException
+     * @throws GoldTradeException
+     * @throws Exception
+     */
+    public void addGoldCorn(String uid, CodeCornGetSourceType source, Integer goldCorn, String title, String desc) throws GoldUserException, GoldAppException, GoldTradeException, Exception {
+        addGoldCorn(getAppCode(), getUid(uid), source.name(), goldCorn, title, desc);
+    }
+
+    public GoldCornGetSource getGoldCornGetSource(CodeCornGetSourceType source) throws GoldAppException {
+        return goldCornGetSourceService.selectByAppAndCode(getAppCode(), source.name());
+    }
+
     /**
      * 杩斿洖褰辫璞�
      *
@@ -110,6 +157,19 @@
         addGoldCorn(appCode, tuid, sourceCode, record.getGoldCorn(), title, desc);
     }
 
+    public List<GoldCornRecord> getRecordList(GoldCornRecordQuery query, String uid) throws Exception {
+        query.setAppCode(getAppCode());
+        query.setUid(getUid(uid));
+        return goldCornRecordService.listUserRecord(query);
+    }
+
+
+    public long getRecordCount(GoldCornRecordQuery query, String uid) throws Exception {
+        query.setAppCode(getAppCode());
+        query.setUid(getUid(uid));
+        return goldCornRecordService.countUserRecord(query);
+    }
+
     private void addGoldCorn(String appCode, String uid, String sourceCode, Integer goldCornCount, String title, String desc) throws GoldUserException, GoldAppException, GoldTradeException {
         goldCornTradeService.addGoldCorn(appCode, uid, sourceCode, goldCornCount, title, desc);
     }
@@ -120,4 +180,43 @@
     }
 
 
+    public List<GoldCornGetSource> listGetCornSource(int page, int pageSize) throws GoldAppException {
+        return goldCornGetSourceService.listShow(getAppCode(), page, pageSize);
+    }
+
+    public List<GoldCornRecordCountMap> countRecordByGetSource(String uid, List<String> sourceCodes, Date minCreateTime, Date maxCreateTime) throws Exception {
+        if (StringUtil.isNullOrEmpty(uid)) {
+            return new ArrayList<>();
+        }
+        GoldCornRecordQuery query = new GoldCornRecordQuery();
+        query.setUid(getUid(uid));
+        query.setAppCode(getAppCode());
+        query.setSourceCodes(sourceCodes);
+        query.setMinCreateTime(minCreateTime);
+        query.setMaxCreateTime(maxCreateTime);
+        query.setType(GoldCornRecord.TYPE_GET);
+        return goldCornRecordService.countUserRecordBySource(query);
+    }
+
+    /**
+     * 鑾峰彇涓嬩竴娆″彲浠ュ仛浠诲姟鐨勬椂闂�
+     *
+     * @param source
+     * @param uid
+     * @return
+     */
+    public long getNextDoTaskTime(CodeCornGetSourceType source, String uid) {
+        if (StringUtil.isNullOrEmpty(uid)) {
+            return -1;
+        }
+        try {
+            return goldCornTradeService.getNextDoTaskTime(getAppCode(), getUid(uid), source.name());
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return -1;
+    }
+
+
 }

--
Gitblit v1.8.0