setter
parent
335a675f53
commit
54ed63a287
app
|
@ -427,4 +427,10 @@ class Order extends Base
|
|||
return $this->json(0, 'success', ['group_id' => $groupId]);
|
||||
}
|
||||
|
||||
|
||||
public function shopCartCartOrder()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -27,8 +27,8 @@ class Spu extends Base
|
|||
*/
|
||||
public function category(): Json
|
||||
{
|
||||
$list = SpuRepository::getInstance()->category()->toArray();
|
||||
|
||||
$pid = input("pid/d",0);
|
||||
$list = SpuRepository::getInstance()->category($pid)->toArray();
|
||||
return $this->json(0, 'success', $list);
|
||||
}
|
||||
|
||||
|
@ -66,17 +66,17 @@ class Spu extends Base
|
|||
$repo = SpuRepository::getInstance();
|
||||
|
||||
$fields = [
|
||||
'id', 'name', 'subtitle', 'price', 'original_price', 'cover', 'home_display', 'stock', 'amount','activity_id','activity_type'
|
||||
'id', 'name', 'subtitle', 'original_price', 'cover',
|
||||
];
|
||||
|
||||
$params = input();
|
||||
$params['fields'] = $fields;
|
||||
$params['is_home'] = SpuModel::COMMON_ON;
|
||||
$params['is_score'] = SpuModel::COMMON_OFF;//排除积分商品
|
||||
//$params['is_score'] = SpuModel::COMMON_OFF;//排除积分商品
|
||||
|
||||
if (!isset($params['category_id']) || empty($params['category_id'])) {
|
||||
$params['category_id'] = \app\model\mall\Category::getFirst();
|
||||
}
|
||||
// if (!isset($params['category_id']) || empty($params['category_id'])) {
|
||||
// $params['category_id'] = \app\model\mall\Category::getFirst();
|
||||
// }
|
||||
|
||||
$list = $repo->listForFront($params, function ($q) {
|
||||
return $q->withAttr('cover', function ($value, $data) {
|
||||
|
@ -279,6 +279,10 @@ class Spu extends Base
|
|||
$data['detail']['share_img'] = $data['detail']['share_img'] ?? '';
|
||||
$data['detail']['share_img'] = resourceJoin($data['detail']['share_img'], $domain);
|
||||
|
||||
$pregRule = "/<[img|IMG].*?src=[\'|\"][\/storage]{1}(.*?(?:[\.jpg|\.jpeg|\.png|\.gif|\.bmp]))[\'|\"].*?[\/]?>/";
|
||||
$data['detail']['content'] = preg_replace($pregRule, '<img src="' . $this->request->domain() . '/${1}" style="max-width:100%">', (string)$data['detail']['content'] );
|
||||
|
||||
|
||||
if(isset($data['detail']['images']) && !empty($data['detail']['images'])){
|
||||
$images = explode(',', $data['detail']['images']);
|
||||
$imageArr = [];
|
||||
|
@ -287,7 +291,7 @@ class Spu extends Base
|
|||
$imageArr[] = resourceJoin($image, $domain);
|
||||
}
|
||||
}
|
||||
$data['detail']['images'] = implode(',', $imageArr);
|
||||
$data['detail']['images'] = $imageArr;
|
||||
}
|
||||
return $this->json(0, 'success', $data);
|
||||
} catch (RepositoryException $e) {
|
||||
|
|
|
@ -208,6 +208,7 @@ class SpuRepository extends Repository
|
|||
if (empty($order)) {
|
||||
$order = ['published_at' => 'desc'];
|
||||
}
|
||||
|
||||
$list = Spu::findList($searchMap, $fields, $page, $size, $callback, $order);
|
||||
|
||||
$activityText = Spu::activityTextList();
|
||||
|
@ -234,7 +235,7 @@ class SpuRepository extends Repository
|
|||
public function detail(int $id, int $accountId = 0): array
|
||||
{
|
||||
$field = [
|
||||
'id', 'activity_id', 'activity_type', 'name', 'subtitle', 'price', 'original_price', 'limit_num', 'cover', 'images',
|
||||
'id', 'activity_id', 'activity_type', 'name', 'subtitle', 'price', 'original_price', 'unit','limit_num', 'cover', 'images',
|
||||
'share_img', 'is_activity', 'stock', 'amount', 'multi_spec', 'content'
|
||||
];
|
||||
|
||||
|
@ -291,6 +292,7 @@ class SpuRepository extends Repository
|
|||
$spu['original_price'] = $spu['price'];
|
||||
$spu['price'] = $default['price'];
|
||||
}
|
||||
$spu["skuId"] = $skuList[0]["id"] ?? 0;
|
||||
|
||||
$res['detail'] = $spu;
|
||||
// $res['sku'] = $skuList;
|
||||
|
|
|
@ -51,8 +51,9 @@ trait ShoppingCartTrait
|
|||
->where('is_score', $isScore)
|
||||
->with([
|
||||
'spu' => function ($query) {
|
||||
$query->field('id,name as spu_name,cover as spu_cover');
|
||||
}, 'sku' => function ($query) {
|
||||
$query->field('id,name as spu_name,cover as spu_cover,original_price,unit');
|
||||
},
|
||||
'sku' => function ($query) {
|
||||
$query->field('id,title as sku_name,main_image as sku_cover,price as sku_price,coding,spec_text,type as activity_type');
|
||||
}
|
||||
]);
|
||||
|
|
Loading…
Reference in New Issue