|
@@ -51,12 +51,14 @@ class UserPledge extends Model
|
|
|
//所有有效质押订单的日产量X数量的和
|
|
//所有有效质押订单的日产量X数量的和
|
|
|
public static function getCountByTimeTeac():int
|
|
public static function getCountByTimeTeac():int
|
|
|
{
|
|
{
|
|
|
- $productPledges = new ProductPledges();
|
|
|
|
|
- $list = self::where('status', self::Ongoing)->column('pledge_id,num');
|
|
|
|
|
|
|
+ $list = self::alias('a')
|
|
|
|
|
+ ->join('product_pledge b','a.pledge_id = b.id','left')
|
|
|
|
|
+ ->where('a.status', self::Ongoing)
|
|
|
|
|
+ ->field('b.day_num,a.num')
|
|
|
|
|
+ ->select();
|
|
|
$count = 0;
|
|
$count = 0;
|
|
|
- foreach ($list as $key=>$item) {
|
|
|
|
|
- $day_num = $productPledges::where('id',$key)->value('day_num');
|
|
|
|
|
- $count += bcmul($item, $day_num, 2);
|
|
|
|
|
|
|
+ foreach ($list as $item) {
|
|
|
|
|
+ $count += bcmul($item['day_num'], $item['num'], 2);
|
|
|
}
|
|
}
|
|
|
return $count;
|
|
return $count;
|
|
|
}
|
|
}
|