|
|
@@ -48,9 +48,26 @@ class PledgeLogic
|
|
|
|
|
|
//修改状态
|
|
|
return $model->whereIn('order_no', $order_no)->setField('status', $model::Freeze);
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
+ //获取质抵押订单列表
|
|
|
+ //(60*60*24)*(当前时间-最后一次收取时间)
|
|
|
+ public static function getPledgeOrderList(int $user_id)
|
|
|
+ {
|
|
|
+ $model = Loader::model('UserPledge');
|
|
|
+ $list = $model::where('user_id', $user_id)->where('status', $model::Ongoing)->select();
|
|
|
+ if(empty($list)) throw new Exception('暂无质押订单');
|
|
|
+ $day = 86400;
|
|
|
+ $total = 0; //当前累计收益
|
|
|
+ $growth= 0; //增长累计收益
|
|
|
+ $time = time();
|
|
|
+ foreach ($list as $item) {
|
|
|
+ $reta = bcdiv($item->day_num, $day, 2); //天数
|
|
|
+ $inter = ($item->last_time == 0) ? $time - $item->create_time: $time - $item->last_time; //最后收取时间
|
|
|
+ $total += bcmul($reta, $inter, 2) * $item->num; //累计收益
|
|
|
+ $growth += $reta* $item->num;
|
|
|
+ }
|
|
|
+ return ['total' => $total, 'growth' => $growth, 'list' => $list];
|
|
|
+ }
|
|
|
|
|
|
}
|