84 lines
2.9 KiB
PHP
84 lines
2.9 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @author Any
|
|
* @description KISS
|
|
* @date 2021年10月12日
|
|
* @version 1.0.0
|
|
*
|
|
* _____LOG_____
|
|
*
|
|
*/
|
|
namespace app\models\common\integral\mall;
|
|
|
|
use app\models\common\CommonGoodsListForm;
|
|
use app\models\integral\mall\IntegralMallGoods;
|
|
use app\models\integral\mall\IntegralMallGoodsAttr;
|
|
use app\models\Goods;
|
|
use app\models\GoodsHub;
|
|
use app\models\GoodsAttr;
|
|
use app\models\Model;
|
|
use app\components\SiteHelper;
|
|
use app\components\SysConst;
|
|
use app\components\Serializer;
|
|
|
|
|
|
class CommonIntegralMallGoodsListForm extends CommonGoodsListForm
|
|
{
|
|
|
|
protected function getQuery($cat_query)
|
|
{
|
|
$query = Goods::find()->alias('g')
|
|
->leftJoin(['gh' => GoodsHub::tableName()],'gh.id=g.goods_hub_id')
|
|
->leftJoin(['img' => IntegralMallGoods::tableName()],'img.goods_id=g.id')
|
|
->leftJoin(['gc' => $cat_query], 'gc.goods_hub_id=gh.id');
|
|
return $query;
|
|
}
|
|
|
|
|
|
protected function handleList($list)
|
|
{
|
|
foreach ($list as $index => $item){
|
|
if(isset($item['status'])){
|
|
$item['status_cn'] = $item['status'] == Goods::STATUS_ONLINE ? '已上架' : '已下架';
|
|
}
|
|
$item['created_at_cn'] = date('Y-m-d H:i:s',$item['created_at']);
|
|
if(isset($item['goods_hub_id'])){
|
|
$item['cat_list'] = $this->getCatList($item['goods_hub_id']);
|
|
}
|
|
$item['cover_pic'] = SiteHelper::getFullUrl($item['cover_pic']);
|
|
if($this->scenario == 'detail'){
|
|
$item['detail'] = SiteHelper::repairContent($item['detail']);
|
|
$item['pic_urls'] = $this->fixPicUrls($item['pic_urls']);
|
|
$item['video_url'] = SiteHelper::getFullUrl($item['video_url']);
|
|
$item['goods_sales'] = $item['virtaul_sales'] + $item['sales'];
|
|
$item['attr_groups'] = empty($item['attr_groups']) ? [] : json_decode($item['attr_groups'],true);
|
|
$item['attr'] = $this->getAttr($item['id']);
|
|
}
|
|
$list[$index] = $item;
|
|
}
|
|
return $list;
|
|
}
|
|
|
|
//获取商品规格
|
|
private function getAttr($goods_id)
|
|
{
|
|
$attr = GoodsAttr::find()->alias('gr')
|
|
->leftJoin(['imgr' => IntegralMallGoodsAttr::tableName()],'imgr.goods_attr_id=gr.id')
|
|
->where([
|
|
'gr.goods_id' => $goods_id,
|
|
'gr.is_delete' => 0,
|
|
'imgr.is_delete' => 0
|
|
])
|
|
->select('gr.id,gr.goods_id,gr.price,gr.sign_id,gr.stock,gr.serial_no,gr.weight,gr.cover_pic,imgr.integral_num')
|
|
->asArray()->all();
|
|
foreach($attr as $index => $item){
|
|
$item['cover_pic'] = SiteHelper::getFullUrl($item['cover_pic']);
|
|
$attr[$index] = $item;
|
|
}
|
|
return $attr;
|
|
|
|
}
|
|
}
|
|
|