Browse Source

收取茶矿

afa 7 months ago
parent
commit
1d333b5e7c

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

@@ -120,14 +120,14 @@ class Pledge extends Api
       */
       */
       public function collect(PledgeLogic $pledgeLogic)
       public function collect(PledgeLogic $pledgeLogic)
       {     
       {     
-            if(cache('collect_'.$this->auth->id)) $this->error(__("正在挖矿中,请稍后再试"));
+            //if(cache('collect_'.$this->auth->id)) $this->error(__("正在挖矿中,请稍后再试"));
 
 
             Db::startTrans();
             Db::startTrans();
             try {
             try {
                   // 质抵押订单
                   // 质抵押订单
                   $res = $pledgeLogic::getPledgeCollect($this->auth->id);
                   $res = $pledgeLogic::getPledgeCollect($this->auth->id);
                   //请求限制      
                   //请求限制      
-                  cache('collect_'.$this->auth->id, time(), 300);
+                 // cache('collect_'.$this->auth->id, time(), 300);
                  // 提交事务
                  // 提交事务
                   Db::commit();
                   Db::commit();
             } catch (Exception $e) {
             } catch (Exception $e) {

+ 5 - 4
application/common/logic/PledgeLogic.php

@@ -115,9 +115,9 @@ class PledgeLogic
     {   
     {   
         $model  = Loader::model('UserPledge');
         $model  = Loader::model('UserPledge');
         $list   = $model::where('user_id', $user_id)->where('status', '>', $model::Close)->select();
         $list   = $model::where('user_id', $user_id)->where('status', '>', $model::Close)->select();
-        if(empty($list))  throw new Exception('暂无质押订单');
+        if(empty($list)) throw new Exception('暂无质押订单');
         $day   = 86400;
         $day   = 86400;
-        $total = 0; //前累计收益
+        $total = 0; //前累计收益
         $time  = time();
         $time  = time();
         foreach ($list as $item) 
         foreach ($list as $item) 
         {
         {
@@ -128,9 +128,10 @@ class PledgeLogic
             }else{
             }else{
                 $reta  = bcdiv($item->day_num, $day, 6); //天数
                 $reta  = bcdiv($item->day_num, $day, 6); //天数
                 $inter = ($item->last_time == 0) ? $time - $item->create_time: $time - $item->last_time; //最后收取时间
                 $inter = ($item->last_time == 0) ? $time - $item->create_time: $time - $item->last_time; //最后收取时间
-                $total += bcmul($reta, $inter, 6) * $item->num; //累计收益
+                $total_inco = bcmul($reta, $inter, 6) * $item->num; //累计收益
                 $item->last_time = $time; //收取时间
                 $item->last_time = $time; //收取时间
-                $item->total_self= bcadd($total, $item->total_self, 2); //累计收益
+                $item->total_self= bcadd($total_inco, $item->total_self, 2); //累计收益
+                $total += $total_inco; //累计收益
             }
             }
             //更新领取状态
             //更新领取状态
             $item->save();
             $item->save();