浏览代码

解除质押

afa 6 月之前
父节点
当前提交
3098c1362a
共有 1 个文件被更改,包括 9 次插入5 次删除
  1. 9 5
      application/api/logic/PledgeLogic.php

+ 9 - 5
application/api/logic/PledgeLogic.php

@@ -111,7 +111,7 @@ class PledgeLogic
                 ->field('a.*,b.day_num')
                 ->find();
         if(empty($rows))  throw new Exception('暂无质押订单');
-    
+
         $orderId  = explode(',', $order_id);
         $detail   = json_decode($rows->details, true);
         $count    = count($orderId);
@@ -119,9 +119,15 @@ class PledgeLogic
         if(count($orderId) == count($detail)) {
             $rows->status  = $model::Remove;
         }else{
-            $rows->num       = count($detail) - $count;
+           
+            $result = [];
+            foreach ($detail as &$item) 
+                if(!in_array($item['id'], $orderId)) $result[] = $item;
             $num             = $count;
+            $rows->num       = count($result);
+            $rows->details   = json_encode($result, JSON_UNESCAPED_UNICODE);
         }
+
         $day   = 86400;
         $total = 0; //当前累计收益
         $reta  = bcdiv($rows->day_num, $day, 6); //天数
@@ -155,8 +161,7 @@ class PledgeLogic
         if(empty($list)) throw new Exception('暂无质押订单');
         $day   = 86400;
         $total = 0; //当前累计收益
-        foreach ($list as $item) 
-        {
+        foreach ($list as $item) {
             //解冻
             if($item->status == $model::Remove) {
                 $total += $item->total_self;
@@ -185,7 +190,6 @@ class PledgeLogic
   
         $pledge->end_time = $pledge->end_time + config('pledge_end_time');
         return $pledge->save();
-
     }
 
 }