71 lines
2.7 KiB
PHP
71 lines
2.7 KiB
PHP
<?php
|
|
/**
|
|
* SaaSMall商城系统 - 团队十年电商经验汇集巨献!
|
|
* =========================================================
|
|
* Copy right 2019-2029 上海牛之云网络科技有限公司, 保留所有权利。
|
|
* ----------------------------------------------
|
|
* 官方网址: https://www.gobuysaas.com
|
|
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
|
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
|
* =========================================================
|
|
*/
|
|
|
|
namespace addon\store\shopapi\controller;
|
|
|
|
use addon\store\model\service\OnceCard as OnceCardModel;
|
|
|
|
|
|
class Oncecard extends BaseStoreApi
|
|
{
|
|
public function page()
|
|
{
|
|
$page_index = $this->params[ 'page' ] ?? 1;
|
|
$page_size = $this->params[ 'page_size' ] ?? PAGE_LIST_ROWS;
|
|
$search_text = $this->params[ 'search_text' ] ?? '';
|
|
$goods_state = $this->params[ 'goods_state' ] ?? 'all';
|
|
$card_type = $this->params[ 'card_type' ] ?? 'all';
|
|
|
|
$model = new OnceCardModel();
|
|
$condition = [
|
|
[ 'g.site_id', '=', $this->site_id ],
|
|
[ 'g.goods_type', '=', $model->goods_type ],
|
|
[ 'g.is_delete', '=', 0 ],
|
|
];
|
|
|
|
if ($goods_state !== 'all') $condition[] = [ 'g.goods_state', '=', $goods_state ];
|
|
if ($card_type !== 'all') $condition[] = [ 'gc.card_type', '=', $card_type ];
|
|
if ($search_text != '') $condition[] = [ 'g.goods_name', 'like', "%{$search_text}%" ];
|
|
$join = [
|
|
[ 'goods_card gc', 'gc.goods_id = g.goods_id', 'left' ]
|
|
];
|
|
|
|
$field = 'g.goods_id,g.goods_name,g.goods_image,g.goods_state,g.sku_id,g.discount_price,g.goods_type,gc.group_goods_ids,gc.limittime_type,gc.limittime_day,gc.limittime_day,gc.card_type';
|
|
$res = $model->getPageList($condition, $page_index, $page_size, 'g.create_time desc', $field, 'g', $join);
|
|
|
|
foreach ($res[ 'data' ][ 'list' ] as $k => $v) {
|
|
$res[ 'data' ][ 'list' ][ $k ][ 'card_type_name' ] = $model->getCardType($v[ 'card_type' ])[ 'title' ];
|
|
}
|
|
|
|
return $this->response($res);
|
|
}
|
|
|
|
/**
|
|
* 获取套餐详情
|
|
*/
|
|
public function detail()
|
|
{
|
|
$sku_id = isset($this->params[ 'sku_id' ]) ? $this->params[ 'sku_id' ] : 0;
|
|
if (empty($sku_id)) {
|
|
return $this->response($this->error('', 'REQUEST_SKU_ID'));
|
|
}
|
|
|
|
$model = new OnceCardModel();
|
|
$goods_info = $model->getGoodsSkuDetail($sku_id, $this->site_id)[ 'data' ];
|
|
|
|
if (empty($goods_info)) return $this->response($this->error(null, '未获取到卡项数据'));
|
|
|
|
return $this->response($this->success($goods_info));
|
|
}
|
|
|
|
}
|