Browse Source

日收益

afa 7 months ago
parent
commit
89d20350b6

+ 1 - 1
application/api/controller/Pledge.php

@@ -121,7 +121,7 @@ class Pledge extends Api
       */
       public function collect(PledgeLogic $pledgeLogic)
       {     
-            if(cache('collect_'.$this->auth->id)) $this->error(__("正在挖矿中,请稍后再试"));
+           if(cache('collect_'.$this->auth->id)) $this->error(__("正在挖矿中,请稍后再试"));
             Db::startTrans();
             try {
                   // 质抵押订单

+ 16 - 9
application/common/logic/PledgeLogic.php

@@ -42,11 +42,9 @@ class PledgeLogic
     {
         $model  = Loader::model('ProductOrder');
         $count = count($order_no);
-
-       
         $product= $model::alias('a')
             ->join('product_list b', 'a.product_id = b.id', 'left')
-            ->where('a.user_id', 1275)
+            ->where('a.user_id', $user_id)
             ->where('a.status', $model::Paid)
             ->whereIn('a.order_no', $order_no)->field('a.id,b.zh_name,b.thum,a.order_no')->limit($count)->select();
         
@@ -61,8 +59,6 @@ class PledgeLogic
         $product, //订单信息
         $pledge->day_num, $pledge_num);
 
-        \think\Log::info('添加质抵押订单'.  json_encode(['pledge_id' => $pledge->id, 'order_no' => $order_no, 'user_id' => $user_id]));
-       
         //修改状态
         return $model->whereIn('id', array_column($product, 'id'))->setField('status', $model::Freeze);
     }
@@ -76,7 +72,7 @@ class PledgeLogic
             ->join('product_pledge b', 'a.pledge_id = b.id', 'left')
             ->where('a.user_id', $user_id)
             ->where('a.status', '>', $model::Close)
-            ->field('a.*,b.title')
+            ->field('a.*,b.title,b.day_num')
             ->select();
         if(empty($list)) throw new Exception('暂无质押订单');
         $day   = 86400;
@@ -102,7 +98,12 @@ class PledgeLogic
     public static function setPledgeRemove(int $pledge_id, int $user_id)
     {
         $model  = Loader::model('UserPledge');
-        $rows   = $model::where('user_id', $user_id)->where('id', $pledge_id)->where('status', $model::Ongoing)->find();
+        $rows   = $model::alias('a')
+                ->join('product_pledge b', 'a.pledge_id = b.id', 'left')
+                ->where('a.user_id', $user_id)
+                ->where('a.id', $pledge_id)->where('a.status', $model::Ongoing)
+                ->field('a.*,b.day_num')
+                ->find();
         if(empty($rows))  throw new Exception('暂无质押订单');
         $day   = 86400;
         $total = 0; //当前累计收益
@@ -112,7 +113,6 @@ class PledgeLogic
         $total = bcmul($reta, $inter, 6) * $rows->num; //累计收益
         $rows->total_self= bcadd($total, $rows->total_self, 6);
 
-        \think\Log::info('解除质抵押订单'. json_encode(['pledge_id' => $pledge_id, 'detail' => $rows->details, 'user_id' => $user_id]));
         //修改状态
         $detail =json_decode($rows->details, true);
         Loader::model('ProductOrder')::whereIn('id', array_column($detail, 'id'))->setField('status', ProductOrder::Paid);
@@ -128,7 +128,13 @@ class PledgeLogic
     public static function getPledgeCollect(int $user_id)
     {   
         $model  = Loader::model('UserPledge');
-        $list   = $model::where('user_id', $user_id)->where('status', '>', $model::Close)->select();
+        $list   = $model::alias('a')
+                ->join('product_pledge b', 'a.pledge_id = b.id', 'left')
+                ->where('a.user_id', $user_id)
+                ->where('a.status', '>', $model::Close)
+                ->field('a.*,b.day_num')
+                ->select();
+
         if(empty($list)) throw new Exception('暂无质押订单');
         $day   = 86400;
         $total = 0; //当前累计收益
@@ -156,6 +162,7 @@ class PledgeLogic
 
 
 
+
     //判断请求限制
     public static function getCheckRequestApi(string $key, int $user_id, int $time = 300)
     {

+ 5 - 0
application/common/model/ProductPledges.php

@@ -48,6 +48,11 @@ class ProductPledges extends Model
         return ['en' => __('En'), 'zh' => __('Zh')];
     }
 
+    //获取日产量
+    public static function getByDayNum(int $ids)
+    {
+        return self::where('id', $ids)->value('day_num');
+    }
 
     public function getToLangTextAttr($value, $data)
     {