95 lines
3.4 KiB
PHP
95 lines
3.4 KiB
PHP
<?php
|
|
namespace addon\saas\api\controller;
|
|
use addon\saas\model\Config as ConfigModel;
|
|
use app\api\controller\BaseApi;
|
|
use app\model\goods\Goods;
|
|
use app\model\system\Document;
|
|
class Config extends BaseApi
|
|
{
|
|
/***
|
|
* 基本信息
|
|
* @return false|string
|
|
*/
|
|
public function basics()
|
|
{
|
|
$model = new ConfigModel();
|
|
$basics = $model->getBasicsConfig($this->site_id);
|
|
$token = $this->checkToken();
|
|
$basics['data']['value']['rcode'] = '';
|
|
if ($token['code'] == 0) {
|
|
$join=[
|
|
['manage_user mu','m.source_member=mu.member_id','left']
|
|
];
|
|
$where=[
|
|
['m.site_id', '=', $this->site_id],
|
|
['m.member_id', '=', $token['data']['member_id']]
|
|
];
|
|
$manage_user = model('member')->getInfo($where, 'mu.rcode','m',$join);
|
|
$basics['data']['value']['rcode'] = $manage_user['rcode'] ?? '';
|
|
}
|
|
return $this->response($this->success($basics['data']['value']));
|
|
}
|
|
|
|
/***
|
|
* 申请服务协议
|
|
* @return false|string
|
|
*/
|
|
public function agreement()
|
|
{
|
|
$document_model = new Document();
|
|
$document = $document_model->getDocument([['site_id', '=', $this->site_id], ['app_module', '=', 'shop'], ['document_key', '=', "SAAS_PROMOTE_RULE"]]);
|
|
$res['is_agreement'] = 1;
|
|
$document['data']['img'] = '';
|
|
$res['document'] = $document['data'];
|
|
return $this->response($this->success($res));
|
|
}
|
|
|
|
/****
|
|
* 获取服务协议及使用规则
|
|
* @return false|string
|
|
*/
|
|
public function rule()
|
|
{
|
|
$model = new ConfigModel();
|
|
$basics = $model->getBasicsConfig($this->site_id);
|
|
$basics['data']['value']['goods_list'] = [];
|
|
if ($basics['data']['value']['settled_condition'] == 4) { // 购买指定商品
|
|
$page = $this->params['page'] ?? 1;
|
|
$page_size = $this->params['page_size'] ?? 10;
|
|
$condition[] = ['gs.goods_state', '=', 1];
|
|
$condition[] = ['gs.is_delete', '=', 0];
|
|
$condition[] = ['gs.site_id', '=', $this->site_id];
|
|
$condition[] = ['gs.goods_id', 'in', $basics['data']['value']['goods_ids']];
|
|
$goods = new Goods();
|
|
$field = 'gs.goods_id,gs.sku_id,gs.sku_name,gs.price,gs.market_price,gs.discount_price,gs.stock,(g.sale_num + g.virtual_sale) as sale_num,gs.sku_image,gs.goods_name,gs.site_id,gs.is_free_shipping,gs.introduction,gs.promotion_type,g.goods_image,gs.unit';
|
|
$alias = 'gs';
|
|
$join = [
|
|
['goods g', 'gs.sku_id = g.sku_id', 'inner']
|
|
];
|
|
$list = $goods->getGoodsSkuPageList($condition, $page, $page_size, '', $field, $alias, $join);
|
|
$basics['data']['value']['goods_list'] = $list['data']['list'];
|
|
}
|
|
return $this->response($this->success($basics['data']['value']));
|
|
}
|
|
|
|
/**
|
|
* 提现配置
|
|
*/
|
|
public function withdraw()
|
|
{
|
|
$config = new ConfigModel();
|
|
$res = $config->getWithdrawConfig($this->site_id);
|
|
return $this->response($this->success($res['data']['value']));
|
|
}
|
|
|
|
/**
|
|
* 提现配置
|
|
*/
|
|
public function region()
|
|
{
|
|
$config = new ConfigModel();
|
|
$res = $config->getRegionSettlementConfig($this->site_id);
|
|
return $this->response($this->success($res['data']['value']));
|
|
}
|
|
}
|