Kirin 4 лет назад
Родитель
Сommit
8a5480f7a8
1 измененных файлов с 1 добавлено и 0 удалено
  1. 1 0
      app/models/store/StoreProduct.php

+ 1 - 0
app/models/store/StoreProduct.php

@@ -115,6 +115,7 @@ class StoreProduct extends BaseModel
         if ($baseOrder) $baseOrder .= ', ';
         $model->order($baseOrder . 'sort DESC, add_time DESC');
         $list = $model->page((int)$page, (int)$limit)->field('id,store_name,cate_id,image,IFNULL(sales,0) + IFNULL(ficti,0) as sales,price,stock,ot_price')->select()->each(function ($item) use ($uid, $type, $store_id) {
+            $item['percent'] = bcdiv($item['stock'], bcadd($item['stock'], $item['sales']), 4) * 100;
             if ($type) {
                 $item['is_att'] = StoreProductAttrValueModel::where('product_id', $item['id'])->count() ? true : false;
                 if ($uid) $item['cart_num'] = StoreCart::where('is_pay', 0)->where('is_del', 0)->where('is_new', 0)->where('type', 'product')->where('product_id', $item['id'])->where('uid', $uid)->value('cart_num');