|
@@ -18,6 +18,7 @@ use app\models\store\{
|
|
|
StoreBargain, StoreCombination, StoreSeckill
|
|
StoreBargain, StoreCombination, StoreSeckill
|
|
|
};
|
|
};
|
|
|
use app\models\user\UserSearch;
|
|
use app\models\user\UserSearch;
|
|
|
|
|
+use think\facade\Config;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* TODO 产品Model
|
|
* TODO 产品Model
|
|
@@ -59,10 +60,19 @@ class StoreProduct extends BaseModel
|
|
|
return htmlspecialchars_decode($value);
|
|
return htmlspecialchars_decode($value);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public static function getValidProduct($productId, $field = 'add_time,browse,cate_id,code_path,ficti,give_integral,id,image,is_sub,is_bargain,is_benefit,is_best,is_del,is_hot,is_new,is_postage,is_seckill,is_show,keyword,mer_id,mer_use,ot_price,postage,price,sales,slider_image,sort,stock,store_info,store_name,unit_name,vip_price,spec_type,IFNULL(sales,0) + IFNULL(ficti,0) as fsales,video_link')
|
|
|
|
|
|
|
+ public static function getValidProduct($productId, $field = 'add_time,browse,cate_id,code_path,ficti,give_integral,id,image,is_sub,is_bargain,is_benefit,is_best,is_del,is_hot,is_new,is_postage,is_seckill,is_show,keyword,mer_id,mer_use,ot_price,postage,price,sales,slider_image,sort,stock,store_info,store_name,unit_name,vip_price,spec_type,IFNULL(sales,0) + IFNULL(ficti,0) as fsales,video_link,cost')
|
|
|
{
|
|
{
|
|
|
- $Product = self::where('is_del', 0)->where('is_show', 1)->where('id', $productId)->field($field)->find();
|
|
|
|
|
- if ($Product) return $Product->toArray();
|
|
|
|
|
|
|
+ $product = self::where('is_del', 0)->where('is_show', 1)->where('id', $productId)->field($field)->find();
|
|
|
|
|
+ if ($product) {
|
|
|
|
|
+ $product = $product->toArray();
|
|
|
|
|
+
|
|
|
|
|
+ if (Config::get('app.show_benefit')) {
|
|
|
|
|
+ $rate = getRate($product['cate_id']);
|
|
|
|
|
+ $product['reputation'] = '赔付' . getReputation($product, $rate);
|
|
|
|
|
+ }
|
|
|
|
|
+ unset($product['cost']);
|
|
|
|
|
+ return $product;
|
|
|
|
|
+ }
|
|
|
else return false;
|
|
else return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -117,7 +127,13 @@ class StoreProduct extends BaseModel
|
|
|
if ($salesOrder) $baseOrder = $salesOrder == 'desc' ? 'sales DESC' : 'sales ASC';//虚拟销量
|
|
if ($salesOrder) $baseOrder = $salesOrder == 'desc' ? 'sales DESC' : 'sales ASC';//虚拟销量
|
|
|
if ($baseOrder) $baseOrder .= ', ';
|
|
if ($baseOrder) $baseOrder .= ', ';
|
|
|
$model->order($baseOrder . 'sort DESC, add_time DESC');
|
|
$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,spec_type')->select()->each(function ($item) use ($uid, $type) {
|
|
|
|
|
|
|
+ $show_benefit = Config::get('app.show_benefit', false);
|
|
|
|
|
+ $fields = 'id,store_name,cate_id,image,IFNULL(sales,0) + IFNULL(ficti,0) as sales,price,stock,spec_type';
|
|
|
|
|
+ if ($show_benefit) {
|
|
|
|
|
+ $fields .= ',cost';
|
|
|
|
|
+ }
|
|
|
|
|
+ $list = $model->page((int)$page, (int)$limit)->field($fields)->select()->each(function ($item)
|
|
|
|
|
+ use ($uid, $type, $show_benefit, $sId) {
|
|
|
if ($type) {
|
|
if ($type) {
|
|
|
if ($item['spec_type']) {
|
|
if ($item['spec_type']) {
|
|
|
$item['is_att'] = StoreProductAttrValueModel::where(['product_id' => $item['id'], 'type' => 0])->count() ? true : false;
|
|
$item['is_att'] = StoreProductAttrValueModel::where(['product_id' => $item['id'], 'type' => 0])->count() ? true : false;
|
|
@@ -128,6 +144,12 @@ class StoreProduct extends BaseModel
|
|
|
else $item['cart_num'] = 0;
|
|
else $item['cart_num'] = 0;
|
|
|
if (is_null($item['cart_num'])) $item['cart_num'] = 0;
|
|
if (is_null($item['cart_num'])) $item['cart_num'] = 0;
|
|
|
}
|
|
}
|
|
|
|
|
+ // show benefit
|
|
|
|
|
+ if ($show_benefit) {
|
|
|
|
|
+ $rate = getRate($sId);
|
|
|
|
|
+ $item['reputation'] = '赔付' . getReputation($item, $rate);
|
|
|
|
|
+ unset($item['cost']);
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
$list = count($list) ? $list->toArray() : [];
|
|
$list = count($list) ? $list->toArray() : [];
|
|
|
if (!empty($list)) {
|
|
if (!empty($list)) {
|