afa před 7 měsíci
rodič
revize
341bc14623

+ 10 - 7
application/common/logic/PledgeLogic.php

@@ -68,7 +68,7 @@ class PledgeLogic
         $list   = $model::alias('a')
             ->join('product_pledge b', 'a.pledge_id = b.id', 'left')
             ->where('a.user_id', $user_id)
-            ->where('a.status', $model::Ongoing)
+            ->where('a.status', '>', $model::Close)
             ->field('a.*,b.title')
             ->select();
         if(empty($list))  throw new Exception('暂无质押订单');
@@ -77,10 +77,14 @@ class PledgeLogic
         $growth= 0; //增长累计收益
         $time  = time();
         foreach ($list as $item) {
-           $reta  = bcdiv($item->day_num, $day, 6); //天
-           $inter = ($item->last_time == 0) ? $time - $item->create_time: $time - $item->last_time; //最后收取时间
-           $total += bcmul($reta, $inter, 6)* $item->num; //累计收益
-           $growth += $reta* $item->num;
+            if($item->status == $model::Remove) {
+                $total += $item->total_self;
+            }else{
+                $reta  = bcdiv($item->day_num, $day, 6); //天
+                $inter = ($item->last_time == 0) ? $time - $item->create_time: $time - $item->last_time; //最后收取时间
+                $total += bcmul($reta, $inter, 6)* $item->num; //累计收益
+                $growth += $reta* $item->num; //增长收益
+            }
         }
         return ['total' => $total, 'growth' => $growth, 'list' => $list];   
     }
@@ -102,7 +106,6 @@ class PledgeLogic
         //修改状态
         $detail =json_decode($rows->details, true);
         Loader::model('ProductOrder')::whereIn('order_no', array_column($detail, 'order_no'))->setField('status', ProductOrder::Paid);
-
         $rows->status    = $model::Remove;
         $rows->last_time = $time;
         return  $rows->save();   
@@ -117,7 +120,7 @@ class PledgeLogic
         $list   = $model::where('user_id', $user_id)->where('status', '>', $model::Close)->select();
         if(empty($list)) throw new Exception('暂无质押订单');
         $day   = 86400;
-        $total = 0; //前累计收益
+        $total = 0; //前累计收益
         $time  = time();
         foreach ($list as $item) 
         {

+ 4 - 3
application/common/model/ProductOrder.php

@@ -42,9 +42,10 @@ class ProductOrder extends Model
     const Super             = 4; //新人福利空投
     const Airdrop           = 5; //空投
     const Synthesi          = 6; //合成
-    /* 
-     *  订单状态 '已下单', 1=>'已付款', 2=>'已转让', 3=>'提货', 4=>'已取消', 5=>'完成'];
-     */
+
+    
+    // 订单状态 '已下单', 1=>'已付款', 2=>'已转让', 3=>'提货', 4=>'已取消', 5=>'完成'];
+    
     public $order_status = [
         '-1'                    => '全部',
         self::Ordered           => '已下单',