afa 4 місяців тому
батько
коміт
a0e98a9c36
1 змінених файлів з 8 додано та 8 видалено
  1. 8 8
      application/api/logic/PledgeLogic.php

+ 8 - 8
application/api/logic/PledgeLogic.php

@@ -84,7 +84,7 @@ class PledgeLogic
         $growth= 0; //增长累计收益
         $result = [];
         foreach ($list as $item) {
-            if($item->end_time >  $time){
+            if($item->end_time <  $time){
                 if($item->status == $model::Remove) {
                     $total += $item->total_self;
                 }else{
@@ -112,7 +112,6 @@ class PledgeLogic
                 ->field('a.*,b.day_num,b.type_id')
                 ->find();
         if(empty($rows))  throw new Exception('暂无质押订单');
-
         $orderId  = explode(',', $order_id);
         $detail   = json_decode($rows->details, true);
         $count    = count($orderId);
@@ -129,19 +128,20 @@ class PledgeLogic
         }
         $day   = 86400;
         $reta  = bcdiv($rows->day_num, $day, 6); //天数
-
+        $total = 0; 
         //到期解除收取
-        if($rows->end_time > $time){
+        if($time > $rows->end_time){
             $inter = ($rows->last_time == 0) ? $rows->end_time - $rows->create_time: $rows->end_time - $rows->last_time; //最后收取时间
             $rows->total_self= bcmul($reta, $inter, 6) * $num; //累计收益
+            $rows->status = $model::Close;   //更新领取状态
             Loader::model('LedgerWalletModel')->changeWalletAccount($user_id, Asset::TEAC, $rows->total_self, LedgerTeacChangeModel::Pledge, 0);  
-            //更新领取状态
-            $rows->status = $model::Close;
         }else{
+
             $inter = ($rows->last_time == 0) ? $time - $rows->create_time: $time - $rows->last_time; //最后收取时间
-            $rows->total_self= bcmul($reta, $inter, 6) * $num; //累计收益
+            $total = bcmul($reta, $inter, 6) * $num; //累计收益
+            $rows->total_self= ($rows->status  == $model::Remove)? $total: bcadd($total, $rows->total_self, 6);
         }
-      
+  
         //修改状态
         Loader::model('ProductOrder')::where('user_id', $user_id)->whereIn('id', $orderId)->setField('status', ProductOrder::Paid);