chore(src): 所有代码上传
This commit is contained in:
@@ -1,51 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\system\Addon as AddonModel;
|
||||
|
||||
/**
|
||||
* 插件管理
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
class Addon extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 列表信息
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$addon = new AddonModel();
|
||||
$list = $addon->getAddonList();
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
public function addonisexit()
|
||||
{
|
||||
$addon_api = new \app\api\controller\Addon();
|
||||
$res = $addon_api->addonIsExit();
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 插件是否存在
|
||||
*/
|
||||
public function isexit()
|
||||
{
|
||||
$name = $this->params[ 'name' ] ?? '';
|
||||
$res = 0;
|
||||
if (!empty($name)) $res = addon_is_exit($name, $this->site_id);
|
||||
return $this->response($this->success($res));
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\system\Addon as AddonModel;
|
||||
|
||||
/**
|
||||
* 插件管理
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
class Addon extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 列表信息
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$addon = new AddonModel();
|
||||
$list = $addon->getAddonList();
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
public function addonisexit()
|
||||
{
|
||||
$addon_api = new \app\api\controller\Addon();
|
||||
$res = $addon_api->addonIsExit();
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 插件是否存在
|
||||
*/
|
||||
public function isexit()
|
||||
{
|
||||
$name = $this->params[ 'name' ] ?? '';
|
||||
$res = 0;
|
||||
if (!empty($name)) $res = addon_is_exit($name, $this->site_id);
|
||||
return $this->response($this->success($res));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,76 +1,68 @@
|
||||
<?php
|
||||
/**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\system\Address as AddressModel;
|
||||
|
||||
/**
|
||||
* 地址管理
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
class Address extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 基础信息
|
||||
*/
|
||||
public function info()
|
||||
{
|
||||
$id = $this->params[ 'id' ];
|
||||
$address = new AddressModel();
|
||||
$info = $address->getAreaInfo($id);
|
||||
return $this->response($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表信息
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$pid = $this->params['pid'] ?? 0;
|
||||
$address = new AddressModel();
|
||||
$list = $address->getAreas($pid);
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 树状结构信息
|
||||
*/
|
||||
public function tree()
|
||||
{
|
||||
$id = $this->params[ 'id' ];
|
||||
$address = new AddressModel();
|
||||
$tree = $address->getAreas($id);
|
||||
return $this->response($tree);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全部城市列表
|
||||
*/
|
||||
public function city()
|
||||
{
|
||||
$address = new AddressModel();
|
||||
$data = $address->getAreaList([ [ 'level', '=', 2 ], [ 'status', '=', 1 ] ], 'id,shortname as title', 'sort asc');
|
||||
return $this->response($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据城市名称获取城市
|
||||
*/
|
||||
public function cityByName()
|
||||
{
|
||||
$name = $this->params[ 'city' ] ?? '';
|
||||
$address = new AddressModel();
|
||||
$data = $address->getAreasInfo([ [ 'name', 'like', "%{$name}%" ], [ 'level', '=', 2 ], [ 'status', '=', 1 ] ], 'id,shortname as title');
|
||||
return $this->response($data);
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\system\Address as AddressModel;
|
||||
|
||||
/**
|
||||
* 地址管理
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
class Address extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 基础信息
|
||||
*/
|
||||
public function info()
|
||||
{
|
||||
$id = $this->params[ 'id' ];
|
||||
$address = new AddressModel();
|
||||
$info = $address->getAreaInfo($id);
|
||||
return $this->response($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表信息
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$pid = $this->params['pid'] ?? 0;
|
||||
$address = new AddressModel();
|
||||
$list = $address->getAreas($pid);
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 树状结构信息
|
||||
*/
|
||||
public function tree()
|
||||
{
|
||||
$id = $this->params[ 'id' ];
|
||||
$address = new AddressModel();
|
||||
$tree = $address->getAreas($id);
|
||||
return $this->response($tree);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全部城市列表
|
||||
*/
|
||||
public function city()
|
||||
{
|
||||
$address = new AddressModel();
|
||||
$data = $address->getAreaList([ [ 'level', '=', 2 ], [ 'status', '=', 1 ] ], 'id,shortname as title', 'sort asc');
|
||||
return $this->response($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据城市名称获取城市
|
||||
*/
|
||||
public function cityByName()
|
||||
{
|
||||
$name = $this->params[ 'city' ] ?? '';
|
||||
$address = new AddressModel();
|
||||
$data = $address->getAreasInfo([ [ 'name', 'like', "%{$name}%" ], [ 'level', '=', 2 ], [ 'status', '=', 1 ] ], 'id,shortname as title');
|
||||
return $this->response($data);
|
||||
}
|
||||
}
|
||||
@@ -1,81 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\upload\Album as AlbumModel;
|
||||
|
||||
/**
|
||||
* 相册
|
||||
* Class Album
|
||||
* @package app\shopapi\controller
|
||||
*/
|
||||
class Album extends BaseApi
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//执行父类构造函数
|
||||
parent::__construct();
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) {
|
||||
echo $this->response($token);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取相册分组
|
||||
* @return false|string
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$album_model = new AlbumModel();
|
||||
$type = $this->params['type'] ?? 'img';
|
||||
$album_list = $album_model->getAlbumListTree([ [ 'site_id', "=", $this->site_id ], ['type', '=', $type] ]);
|
||||
return $this->response($album_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图片列表
|
||||
* @return false|string
|
||||
*/
|
||||
public function picList()
|
||||
{
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$limit = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
$album_id = $this->params['album_id'] ?? 0;
|
||||
|
||||
$album_model = new AlbumModel();
|
||||
$condition = array (
|
||||
[ 'site_id', "=", $this->site_id ],
|
||||
[ 'album_id', "=", $album_id ],
|
||||
);
|
||||
if (!empty($pic_name)) {
|
||||
$condition[] = [ 'pic_name', 'like', '%' . $pic_name . '%' ];
|
||||
}
|
||||
$list = $album_model->getAlbumPicPageList($condition, $page, $limit, 'update_time desc','pic_path');
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成缩略图
|
||||
*/
|
||||
public function createThumb()
|
||||
{
|
||||
ignore_user_abort(true);
|
||||
$upload_model = new AlbumModel();
|
||||
$pic_path = $this->params['pic_path'] ?? '';
|
||||
$pic_ids = $upload_model->getAlbumPicList([ ['pic_path', 'in', $pic_path], ['site_id', '=', $this->site_id] ], 'pic_id')['data'] ?? [];
|
||||
$pic_ids = array_column($pic_ids, 'pic_id');
|
||||
$thumb_batch = $upload_model->createThumbBatch($this->site_id, $pic_ids);
|
||||
return $this->response($thumb_batch);
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\upload\Album as AlbumModel;
|
||||
|
||||
/**
|
||||
* 相册
|
||||
* Class Album
|
||||
* @package app\shopapi\controller
|
||||
*/
|
||||
class Album extends BaseApi
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//执行父类构造函数
|
||||
parent::__construct();
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) {
|
||||
echo $this->response($token);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取相册分组
|
||||
* @return false|string
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$album_model = new AlbumModel();
|
||||
$type = $this->params['type'] ?? 'img';
|
||||
$album_list = $album_model->getAlbumListTree([ [ 'site_id', "=", $this->site_id ], ['type', '=', $type] ]);
|
||||
return $this->response($album_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图片列表
|
||||
* @return false|string
|
||||
*/
|
||||
public function picList()
|
||||
{
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$limit = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
$album_id = $this->params['album_id'] ?? 0;
|
||||
|
||||
$album_model = new AlbumModel();
|
||||
$condition = array (
|
||||
[ 'site_id', "=", $this->site_id ],
|
||||
[ 'album_id', "=", $album_id ],
|
||||
);
|
||||
if (!empty($pic_name)) {
|
||||
$condition[] = [ 'pic_name', 'like', '%' . $pic_name . '%' ];
|
||||
}
|
||||
$list = $album_model->getAlbumPicPageList($condition, $page, $limit, 'update_time desc','pic_path');
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成缩略图
|
||||
*/
|
||||
public function createThumb()
|
||||
{
|
||||
ignore_user_abort(true);
|
||||
$upload_model = new AlbumModel();
|
||||
$pic_path = $this->params['pic_path'] ?? '';
|
||||
$pic_ids = $upload_model->getAlbumPicList([ ['pic_path', 'in', $pic_path], ['site_id', '=', $this->site_id] ], 'pic_id')['data'] ?? [];
|
||||
$pic_ids = array_column($pic_ids, 'pic_id');
|
||||
$thumb_batch = $upload_model->createThumbBatch($this->site_id, $pic_ids);
|
||||
return $this->response($thumb_batch);
|
||||
}
|
||||
}
|
||||
@@ -1,421 +1,413 @@
|
||||
<?php
|
||||
/**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
|
||||
use app\model\shop\ShopApply;
|
||||
use app\model\shop\ShopGroup as ShopGroupModel;
|
||||
use app\model\shop\ShopCategory as ShopCategoryModel;
|
||||
use app\model\shop\ShopApply as ShopApplyModel;
|
||||
use app\model\shop\Config as ConfigModel;
|
||||
use app\model\system\Address as AddressModel;
|
||||
use app\model\web\WebSite as WebsiteModel;
|
||||
use app\model\shop\ShopAccount as ShopaccountModel;
|
||||
use app\model\system\Promotion as PromotionModel;
|
||||
use addon\shopwithdraw\model\Config as ShopWithdrawConfig;
|
||||
use app\model\system\User as userModel;
|
||||
use think\facade\Cache;
|
||||
use think\facade\Session;
|
||||
|
||||
class Apply extends BaseApi
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//执行父类构造函数
|
||||
parent::__construct();
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) {
|
||||
echo $this->response($token);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请入驻首页
|
||||
* @return false|string
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//店铺主营行业
|
||||
$shop_category_model = new ShopCategoryModel();
|
||||
$shop_category = $shop_category_model->getCategoryList('', '*', 'sort asc', '');
|
||||
$data[ 'shop_category' ] = $shop_category[ 'data' ];
|
||||
|
||||
//入驻协议
|
||||
$config_model = new ConfigModel();
|
||||
$shop_apply_agreement = $config_model->getShopApplyAgreement();
|
||||
$data[ 'shop_apply_agreement' ] = $shop_apply_agreement[ 'data' ];
|
||||
|
||||
//查询省级数据列表
|
||||
$address_model = new AddressModel();
|
||||
$list = $address_model->getAreaList([ [ "pid", "=", 0 ], [ "level", "=", 1 ] ]);
|
||||
$data[ 'province_list' ] = $list[ "data" ];
|
||||
|
||||
//获取申请完整信息
|
||||
$shop_apply_model = new ShopApplyModel();
|
||||
|
||||
$condition[] = [ 'uid', '=', $this->uid ];
|
||||
$shop_apply_info = $shop_apply_model->getApplyDetail($condition);
|
||||
if ($shop_apply_info[ 'data' ] == null) {//未填写申请信息
|
||||
//第一步
|
||||
$procedure = 1;
|
||||
} else {//已填写申请信息
|
||||
//判断审核状态
|
||||
if ($shop_apply_info[ 'data' ][ 'apply_state' ] == 1) {
|
||||
$procedure = 2;//审核中
|
||||
} elseif ($shop_apply_info[ 'data' ][ 'apply_state' ] == 2) {
|
||||
if ($shop_apply_info[ 'data' ][ 'paying_money_certificate' ] != '') {
|
||||
$procedure = 3;//财务凭据审核中
|
||||
} else {
|
||||
$procedure = 6;//财务凭据提交中
|
||||
}
|
||||
} elseif ($shop_apply_info[ 'data' ][ 'apply_state' ] == 3) {
|
||||
$procedure = 5;//入驻成功
|
||||
} elseif ($shop_apply_info[ 'data' ][ 'apply_state' ] == -2) {
|
||||
$procedure = 7;//财务审核失败
|
||||
} else {
|
||||
$procedure = 4;//审核失败
|
||||
}
|
||||
}
|
||||
$data[ 'procedure' ] = $procedure;
|
||||
$data[ 'shop_apply_info' ] = $shop_apply_info[ "data" ];
|
||||
|
||||
//收款信息
|
||||
$receivable_config = $config_model->getSystemBankAccount();
|
||||
$data[ 'receivable_config' ] = $receivable_config[ 'data' ];
|
||||
|
||||
//平台配置信息
|
||||
$website_model = new WebsiteModel();
|
||||
$website_info = $website_model->getWebSite([ [ 'site_id', '=', 0 ] ], 'web_phone');
|
||||
$data[ 'website_info' ] = $website_info[ 'data' ];
|
||||
|
||||
//快捷入驻
|
||||
$account_model = new ShopaccountModel();
|
||||
$config_info = $account_model->getShopWithdrawConfig();
|
||||
if (empty($config_info[ 'data' ])) {
|
||||
$id_experience = 0;
|
||||
} else {
|
||||
$id_experience = $config_info[ 'data' ][ 'value' ][ 'id_experience' ];
|
||||
}
|
||||
$data[ 'id_experience' ] = $id_experience;
|
||||
|
||||
$promotion_model = new PromotionModel();
|
||||
//插件
|
||||
$promotions = $promotion_model->getPromotions();
|
||||
$promotions = $promotions[ 'shop' ];
|
||||
|
||||
//店铺等级
|
||||
$shop_group_model = new ShopGroupModel();
|
||||
$shop_group = $shop_group_model->getGroupList([ [ 'is_own', '=', 0 ] ], '*', 'fee asc')[ 'data' ];
|
||||
|
||||
foreach ($shop_group as $k => $v) {
|
||||
$addon_array = !empty($v[ 'addon_array' ]) ? explode(',', $v[ 'addon_array' ]) : [];
|
||||
|
||||
foreach ($promotions as $key => &$promotion) {
|
||||
if (!empty($promotion[ 'is_developing' ])) {
|
||||
unset($promotions[ $key ]);
|
||||
continue;
|
||||
}
|
||||
$promotion[ 'is_checked' ] = 0;
|
||||
if (in_array($promotion[ 'name' ], $addon_array)) {
|
||||
$promotion[ 'is_checked' ] = 1;
|
||||
}
|
||||
$shop_group[ $k ][ 'promotion' ][] = $promotion;
|
||||
}
|
||||
array_multisort(array_column($shop_group[ $k ][ 'promotion' ], 'is_checked'), SORT_DESC, $shop_group[ $k ][ 'promotion' ]);
|
||||
}
|
||||
$data[ 'group_info' ] = $shop_group;
|
||||
|
||||
//城市分站
|
||||
$is_city_addon = addon_is_exit('city');
|
||||
$data[ 'is_city' ] = $is_city_addon;
|
||||
|
||||
if ($is_city_addon == 1) {
|
||||
//获取城市分站信息
|
||||
$city = $website_model->getWebsiteList([ [ 'site_id ', '>=', 0 ], [ 'status', '=', 1 ] ], 'site_id,site_area_id,site_area_name');
|
||||
$data[ 'web_city' ] = $city[ 'data' ];
|
||||
} else {
|
||||
$data[ 'web_city' ] = [];
|
||||
}
|
||||
$data[ 'support_transfer_type' ] = $this->getTransferType();
|
||||
|
||||
return $this->response($this->success($data));
|
||||
|
||||
}
|
||||
|
||||
public function groupInfo()
|
||||
{
|
||||
|
||||
$promotion_model = new PromotionModel();
|
||||
//插件
|
||||
$promotions = $promotion_model->getPromotions();
|
||||
$promotions = $promotions[ 'shop' ];
|
||||
|
||||
//店铺等级
|
||||
$shop_group_model = new ShopGroupModel();
|
||||
$shop_group = $shop_group_model->getGroupList([ [ 'is_own', '=', 0 ] ], '*', 'fee asc')[ 'data' ];
|
||||
|
||||
foreach ($shop_group as $k => $v) {
|
||||
$addon_array = !empty($v[ 'addon_array' ]) ? explode(',', $v[ 'addon_array' ]) : [];
|
||||
|
||||
foreach ($promotions as $key => &$promotion) {
|
||||
if (!empty($promotion[ 'is_developing' ])) {
|
||||
unset($promotions[ $key ]);
|
||||
continue;
|
||||
}
|
||||
$promotion[ 'is_checked' ] = 0;
|
||||
if (in_array($promotion[ 'name' ], $addon_array)) {
|
||||
$promotion[ 'is_checked' ] = 1;
|
||||
}
|
||||
$shop_group[ $k ][ 'promotion' ][] = $promotion;
|
||||
}
|
||||
array_multisort(array_column($shop_group[ $k ][ 'promotion' ], 'is_checked'), SORT_DESC, $shop_group[ $k ][ 'promotion' ]);
|
||||
}
|
||||
return $this->response($this->success($shop_group));
|
||||
}
|
||||
|
||||
/*
|
||||
* 申请入驻
|
||||
* */
|
||||
public function apply()
|
||||
{
|
||||
//申请信息
|
||||
$apply_data = [
|
||||
'site_id' => $this->params['site_id'] ?? 0,
|
||||
'website_id' => $this->params['website_id'] ?? 0,
|
||||
'uid' => $this->uid,//用户ID
|
||||
'username' => $this->user_info[ 'username' ],//账户
|
||||
'shop_name' => $this->params['shop_name'] ?? '',//申请店铺名称
|
||||
'apply_state' => 1,//审核状态(待审核)
|
||||
'apply_year' => $this->params['apply_year'] ?? '',//入驻年长
|
||||
'category_name' => $this->params['category_name'] ?? '',//店铺分类名称
|
||||
'category_id' => $this->params['category_id'] ?? '',//店铺分类id
|
||||
'group_name' => $this->params['group_name'] ?? '',//开店套餐名称
|
||||
'group_id' => $this->params['group_id'] ?? ''// 开店套餐ID
|
||||
];
|
||||
|
||||
//认证信息
|
||||
$cert_type = $this->params['cert_type'] ?? '';//申请类型
|
||||
|
||||
if ($cert_type == 1) {
|
||||
//个人
|
||||
$cert_data = [
|
||||
'cert_type' => $cert_type,
|
||||
'contacts_name' => $this->params['contacts_name'] ?? '',//联系人姓名
|
||||
'contacts_mobile' => $this->params['contacts_mobile'] ?? '',//联系人手机
|
||||
'contacts_card_no' => $this->params['contacts_card_no'] ?? '',//联系人身份证
|
||||
'contacts_card_electronic_2' => $this->params['contacts_card_electronic_2'] ?? '',//申请人手持身份证正面
|
||||
'contacts_card_electronic_3' => $this->params['contacts_card_electronic_3'] ?? '',//申请人手持身份证反面
|
||||
'bank_account_name' => $this->params['bank_account_name'] ?? '',//银行开户名
|
||||
'bank_account_number' => $this->params['bank_account_number'] ?? '',//公司银行账号
|
||||
'bank_name' => $this->params['bank_name'] ?? '',//联系人姓名
|
||||
'bank_address' => $this->params['bank_address'] ?? '',//开户银行所在地
|
||||
'bank_code' => $this->params['bank_code'] ?? '',//支行联行号
|
||||
'bank_type' => $this->params['bank_type'] ?? '',//结算账户类型
|
||||
'settlement_bank_account_name' => $this->params['settlement_bank_account_name'] ?? '',
|
||||
'settlement_bank_account_number' => $this->params['settlement_bank_account_number'] ?? '',
|
||||
'settlement_bank_name' => $this->params['settlement_bank_name'] ?? '',//结算开户银行支行名称
|
||||
'settlement_bank_address' => $this->params['settlement_bank_address'] ?? ''//结算开户银行所在地
|
||||
];
|
||||
} else {
|
||||
//公司
|
||||
$cert_data = [
|
||||
'cert_type' => $cert_type,
|
||||
'company_name' => $this->params['company_name'] ?? '',//公司名称
|
||||
'company_province_id' => $this->params['company_province_id'] ?? '',//公司所在省
|
||||
'company_city_id' => $this->params['company_city_id'] ?? '',//公司所在市
|
||||
'company_district_id' => $this->params['company_district_id'] ?? '',//公司所在区/县
|
||||
'company_address' => $this->params['company_address'] ?? '',//公司地址
|
||||
'company_full_address' => $this->params['company_full_address'] ?? '',//公司完整地址
|
||||
'business_licence_number' => $this->params['business_licence_number'] ?? '',//统一社会信用码
|
||||
'business_licence_number_electronic' => $this->params['business_licence_number_electronic'] ?? '',//营业执照电子版
|
||||
'business_sphere' => $this->params['business_sphere'] ?? '',//法定经营范围
|
||||
'contacts_name' => $this->params['contacts_name'] ?? '',//联系人姓名
|
||||
'contacts_mobile' => $this->params['contacts_mobile'] ?? '',//联系人手机
|
||||
'contacts_card_no' => $this->params['contacts_card_no'] ?? '',//联系人身份证
|
||||
'contacts_card_electronic_2' => $this->params['contacts_card_electronic_2'] ?? '',//申请人手持身份证正面
|
||||
'contacts_card_electronic_3' => $this->params['contacts_card_electronic_3'] ?? '',//申请人手持身份证反面
|
||||
'bank_account_name' => $this->params['bank_account_name'] ?? '',//银行开户名
|
||||
'bank_account_number' => $this->params['bank_account_number'] ?? '',//公司银行账号
|
||||
'bank_name' => $this->params['bank_name'] ?? '',//联系人姓名
|
||||
'bank_address' => $this->params['bank_address'] ?? '',//开户银行所在地
|
||||
'bank_code' => $this->params['bank_code'] ?? '',//支行联行号
|
||||
'bank_type' => $this->params['bank_type'] ?? '',//结算账户类型
|
||||
'settlement_bank_account_name' => $this->params['settlement_bank_account_name'] ?? '',
|
||||
'settlement_bank_account_number' => $this->params['settlement_bank_account_number'] ?? '',
|
||||
'settlement_bank_name' => $this->params['settlement_bank_name'] ?? '',//结算开户银行支行名称
|
||||
'settlement_bank_address' => $this->params['settlement_bank_address'] ?? ''//结算开户银行所在地
|
||||
];
|
||||
}
|
||||
$model = new ShopApplyModel();
|
||||
$result = $model->apply($apply_data, $cert_data);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断店铺名称是否存在
|
||||
*/
|
||||
public function shopNameExist()
|
||||
{
|
||||
$shop_name = $this->params['shop_name'] ?? '';
|
||||
|
||||
$model = new ShopApplyModel();
|
||||
$res = $model->shopNameExist($shop_name);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取申请金额
|
||||
* */
|
||||
public function getApplyMoney()
|
||||
{
|
||||
$apply_year = $this->params['apply_year'] ?? '';//入驻年长
|
||||
$category_id = $this->params['category_id'] ?? '';//店铺分类id
|
||||
$group_id = $this->params['group_id'] ?? '';//店铺等级ID
|
||||
|
||||
$model = new ShopApplyModel();
|
||||
$result = $model->getApplyMoney($apply_year, $group_id, $category_id);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/*
|
||||
* 提交支付凭证
|
||||
**/
|
||||
public function editApply()
|
||||
{
|
||||
//申请信息
|
||||
$apply_data = [
|
||||
'paying_money_certificate' => $this->params['paying_money_certificate'] ?? '',// 付款凭证
|
||||
'paying_money_certificate_explain' => $this->params['paying_money_certificate_explain'] ?? '',// 付款凭证说明
|
||||
'apply_state' => 2
|
||||
];
|
||||
|
||||
$model = new ShopApplyModel();
|
||||
$condition[] = [ 'uid', '=', $this->uid ];
|
||||
$result = $model->editApply($apply_data, $condition);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 体验入驻
|
||||
*/
|
||||
public function experienceApply()
|
||||
{
|
||||
$shop_data = [
|
||||
'site_name' => $this->params['site_name'] ?? '', //店铺名称
|
||||
'category_id' => $this->params['category_id'] ?? '', //主营行业id
|
||||
'category_name' => $this->params['category_name'] ?? '', //主营行业名称
|
||||
'website_id' => $this->params['website_id'] ?? '',
|
||||
];
|
||||
|
||||
$model = new ShopApply();
|
||||
$res = $model->experienceApply($shop_data, $this->user_info);
|
||||
return $this->response($res);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断结算类型
|
||||
*/
|
||||
public function getTransferType()
|
||||
{
|
||||
$support_type = [];
|
||||
if (addon_is_exit("shopwithdraw")) {
|
||||
$config_model = new ShopWithdrawConfig();
|
||||
$config_result = $config_model->getConfig();
|
||||
$config = $config_result[ "data" ];
|
||||
if ($config[ "is_use" ]) {
|
||||
$support_type = explode(",", $config[ 'value' ][ "transfer_type" ]);
|
||||
} else {
|
||||
$support_type = [ "alipay", "bank" ];
|
||||
}
|
||||
} else {
|
||||
$support_type = [ "alipay", "bank" ];
|
||||
}
|
||||
return $this->response($support_type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟登陆
|
||||
*/
|
||||
public function simulatedLogin()
|
||||
{
|
||||
$user_model = new UserModel;
|
||||
$res = $user_model->simulatedLogin($this->user_info[ 'username' ], 'shop', 'shopapi');
|
||||
|
||||
if ($res[ 'code' ] >= 0) {
|
||||
$token = $this->createToken($res[ 'data' ]);
|
||||
return $this->response($this->success([ 'token' => $token, 'site_id' => $res[ 'data' ][ 'site_id' ] ]));
|
||||
}
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 店铺绑定openid 二维码
|
||||
*/
|
||||
public function shopBindQrcode()
|
||||
{
|
||||
$key = 'bing_shop_openid_' . md5(uniqid(null, true));
|
||||
$url = addon_url("wechat://api/auth/shopBindOpenid", [ "key" => $key ]);
|
||||
Session::set("bing_shop_openid", $key);
|
||||
Cache::tag("bing_shop_openid")->set($key, [], 600);
|
||||
|
||||
$file_path = qrcode($url, "upload/qrcode/", date("Ymd") . 'qrcode');
|
||||
|
||||
$file = $file_path;
|
||||
if ($fp = fopen($file, "rb", 0)) {
|
||||
$gambar = fread($fp, filesize($file_path));
|
||||
fclose($fp);
|
||||
$base64 = "data:image/jpg/png/gif;base64," . chunk_split(base64_encode($gambar));
|
||||
@unlink($file_path);
|
||||
|
||||
$data = [
|
||||
'key' => $key,
|
||||
'qrcode' => $base64
|
||||
];
|
||||
return $this->response($this->success($data));
|
||||
} else {
|
||||
return $this->response($this->error());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证店铺绑定情况(成功返回openid)
|
||||
*/
|
||||
public function checkShopBind()
|
||||
{
|
||||
|
||||
$key = $this->params['key'] ?? '';
|
||||
$data = Cache::get($key);
|
||||
$shop_apply_model = new ShopApplyModel();
|
||||
if (!isset($data)) {
|
||||
return $this->response($shop_apply_model->error([ "is_expire" => 1 ], "二维码已过期"));
|
||||
}
|
||||
|
||||
if (empty($data)) {
|
||||
return $this->response($shop_apply_model->error([ "is_expire" => 0 ], "二维码还没有被扫描"));
|
||||
}
|
||||
|
||||
return $this->response($shop_apply_model->success($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取店铺设置
|
||||
* @return false|string
|
||||
*/
|
||||
public function getShopWithdrawConfig()
|
||||
{
|
||||
$account_model = new ShopaccountModel();
|
||||
$config_info = $account_model->getShopWithdrawConfig();
|
||||
return $this->response($this->success($config_info[ 'data' ][ 'value' ]));
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
|
||||
use app\model\shop\ShopApply;
|
||||
use app\model\shop\ShopGroup as ShopGroupModel;
|
||||
use app\model\shop\ShopCategory as ShopCategoryModel;
|
||||
use app\model\shop\ShopApply as ShopApplyModel;
|
||||
use app\model\shop\Config as ConfigModel;
|
||||
use app\model\system\Address as AddressModel;
|
||||
use app\model\web\WebSite as WebsiteModel;
|
||||
use app\model\shop\ShopAccount as ShopaccountModel;
|
||||
use app\model\system\Promotion as PromotionModel;
|
||||
use addon\shopwithdraw\model\Config as ShopWithdrawConfig;
|
||||
use app\model\system\User as userModel;
|
||||
use think\facade\Cache;
|
||||
use think\facade\Session;
|
||||
|
||||
class Apply extends BaseApi
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//执行父类构造函数
|
||||
parent::__construct();
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) {
|
||||
echo $this->response($token);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请入驻首页
|
||||
* @return false|string
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//店铺主营行业
|
||||
$shop_category_model = new ShopCategoryModel();
|
||||
$shop_category = $shop_category_model->getCategoryList('', '*', 'sort asc', '');
|
||||
$data[ 'shop_category' ] = $shop_category[ 'data' ];
|
||||
|
||||
//入驻协议
|
||||
$config_model = new ConfigModel();
|
||||
$shop_apply_agreement = $config_model->getShopApplyAgreement();
|
||||
$data[ 'shop_apply_agreement' ] = $shop_apply_agreement[ 'data' ];
|
||||
|
||||
//查询省级数据列表
|
||||
$address_model = new AddressModel();
|
||||
$list = $address_model->getAreaList([ [ "pid", "=", 0 ], [ "level", "=", 1 ] ]);
|
||||
$data[ 'province_list' ] = $list[ "data" ];
|
||||
|
||||
//获取申请完整信息
|
||||
$shop_apply_model = new ShopApplyModel();
|
||||
|
||||
$condition[] = [ 'uid', '=', $this->uid ];
|
||||
$shop_apply_info = $shop_apply_model->getApplyDetail($condition);
|
||||
if ($shop_apply_info[ 'data' ] == null) {//未填写申请信息
|
||||
//第一步
|
||||
$procedure = 1;
|
||||
} else {//已填写申请信息
|
||||
//判断审核状态
|
||||
if ($shop_apply_info[ 'data' ][ 'apply_state' ] == 1) {
|
||||
$procedure = 2;//审核中
|
||||
} elseif ($shop_apply_info[ 'data' ][ 'apply_state' ] == 2) {
|
||||
if ($shop_apply_info[ 'data' ][ 'paying_money_certificate' ] != '') {
|
||||
$procedure = 3;//财务凭据审核中
|
||||
} else {
|
||||
$procedure = 6;//财务凭据提交中
|
||||
}
|
||||
} elseif ($shop_apply_info[ 'data' ][ 'apply_state' ] == 3) {
|
||||
$procedure = 5;//入驻成功
|
||||
} elseif ($shop_apply_info[ 'data' ][ 'apply_state' ] == -2) {
|
||||
$procedure = 7;//财务审核失败
|
||||
} else {
|
||||
$procedure = 4;//审核失败
|
||||
}
|
||||
}
|
||||
$data[ 'procedure' ] = $procedure;
|
||||
$data[ 'shop_apply_info' ] = $shop_apply_info[ "data" ];
|
||||
|
||||
//收款信息
|
||||
$receivable_config = $config_model->getSystemBankAccount();
|
||||
$data[ 'receivable_config' ] = $receivable_config[ 'data' ];
|
||||
|
||||
//平台配置信息
|
||||
$website_model = new WebsiteModel();
|
||||
$website_info = $website_model->getWebSite([ [ 'site_id', '=', 0 ] ], 'web_phone');
|
||||
$data[ 'website_info' ] = $website_info[ 'data' ];
|
||||
|
||||
//快捷入驻
|
||||
$account_model = new ShopaccountModel();
|
||||
$config_info = $account_model->getShopWithdrawConfig();
|
||||
if (empty($config_info[ 'data' ])) {
|
||||
$id_experience = 0;
|
||||
} else {
|
||||
$id_experience = $config_info[ 'data' ][ 'value' ][ 'id_experience' ];
|
||||
}
|
||||
$data[ 'id_experience' ] = $id_experience;
|
||||
|
||||
$promotion_model = new PromotionModel();
|
||||
//插件
|
||||
$promotions = $promotion_model->getPromotions();
|
||||
$promotions = $promotions[ 'shop' ];
|
||||
|
||||
//店铺等级
|
||||
$shop_group_model = new ShopGroupModel();
|
||||
$shop_group = $shop_group_model->getGroupList([ [ 'is_own', '=', 0 ] ], '*', 'fee asc')[ 'data' ];
|
||||
|
||||
foreach ($shop_group as $k => $v) {
|
||||
$addon_array = !empty($v[ 'addon_array' ]) ? explode(',', $v[ 'addon_array' ]) : [];
|
||||
|
||||
foreach ($promotions as $key => &$promotion) {
|
||||
if (!empty($promotion[ 'is_developing' ])) {
|
||||
unset($promotions[ $key ]);
|
||||
continue;
|
||||
}
|
||||
$promotion[ 'is_checked' ] = 0;
|
||||
if (in_array($promotion[ 'name' ], $addon_array)) {
|
||||
$promotion[ 'is_checked' ] = 1;
|
||||
}
|
||||
$shop_group[ $k ][ 'promotion' ][] = $promotion;
|
||||
}
|
||||
array_multisort(array_column($shop_group[ $k ][ 'promotion' ], 'is_checked'), SORT_DESC, $shop_group[ $k ][ 'promotion' ]);
|
||||
}
|
||||
$data[ 'group_info' ] = $shop_group;
|
||||
|
||||
//城市分站
|
||||
$is_city_addon = addon_is_exit('city');
|
||||
$data[ 'is_city' ] = $is_city_addon;
|
||||
|
||||
if ($is_city_addon == 1) {
|
||||
//获取城市分站信息
|
||||
$city = $website_model->getWebsiteList([ [ 'site_id ', '>=', 0 ], [ 'status', '=', 1 ] ], 'site_id,site_area_id,site_area_name');
|
||||
$data[ 'web_city' ] = $city[ 'data' ];
|
||||
} else {
|
||||
$data[ 'web_city' ] = [];
|
||||
}
|
||||
$data[ 'support_transfer_type' ] = $this->getTransferType();
|
||||
|
||||
return $this->response($this->success($data));
|
||||
|
||||
}
|
||||
|
||||
public function groupInfo()
|
||||
{
|
||||
|
||||
$promotion_model = new PromotionModel();
|
||||
//插件
|
||||
$promotions = $promotion_model->getPromotions();
|
||||
$promotions = $promotions[ 'shop' ];
|
||||
|
||||
//店铺等级
|
||||
$shop_group_model = new ShopGroupModel();
|
||||
$shop_group = $shop_group_model->getGroupList([ [ 'is_own', '=', 0 ] ], '*', 'fee asc')[ 'data' ];
|
||||
|
||||
foreach ($shop_group as $k => $v) {
|
||||
$addon_array = !empty($v[ 'addon_array' ]) ? explode(',', $v[ 'addon_array' ]) : [];
|
||||
|
||||
foreach ($promotions as $key => &$promotion) {
|
||||
if (!empty($promotion[ 'is_developing' ])) {
|
||||
unset($promotions[ $key ]);
|
||||
continue;
|
||||
}
|
||||
$promotion[ 'is_checked' ] = 0;
|
||||
if (in_array($promotion[ 'name' ], $addon_array)) {
|
||||
$promotion[ 'is_checked' ] = 1;
|
||||
}
|
||||
$shop_group[ $k ][ 'promotion' ][] = $promotion;
|
||||
}
|
||||
array_multisort(array_column($shop_group[ $k ][ 'promotion' ], 'is_checked'), SORT_DESC, $shop_group[ $k ][ 'promotion' ]);
|
||||
}
|
||||
return $this->response($this->success($shop_group));
|
||||
}
|
||||
|
||||
/*
|
||||
* 申请入驻
|
||||
* */
|
||||
public function apply()
|
||||
{
|
||||
//申请信息
|
||||
$apply_data = [
|
||||
'site_id' => $this->params['site_id'] ?? 0,
|
||||
'website_id' => $this->params['website_id'] ?? 0,
|
||||
'uid' => $this->uid,//用户ID
|
||||
'username' => $this->user_info[ 'username' ],//账户
|
||||
'shop_name' => $this->params['shop_name'] ?? '',//申请店铺名称
|
||||
'apply_state' => 1,//审核状态(待审核)
|
||||
'apply_year' => $this->params['apply_year'] ?? '',//入驻年长
|
||||
'category_name' => $this->params['category_name'] ?? '',//店铺分类名称
|
||||
'category_id' => $this->params['category_id'] ?? '',//店铺分类id
|
||||
'group_name' => $this->params['group_name'] ?? '',//开店套餐名称
|
||||
'group_id' => $this->params['group_id'] ?? ''// 开店套餐ID
|
||||
];
|
||||
|
||||
//认证信息
|
||||
$cert_type = $this->params['cert_type'] ?? '';//申请类型
|
||||
|
||||
if ($cert_type == 1) {
|
||||
//个人
|
||||
$cert_data = [
|
||||
'cert_type' => $cert_type,
|
||||
'contacts_name' => $this->params['contacts_name'] ?? '',//联系人姓名
|
||||
'contacts_mobile' => $this->params['contacts_mobile'] ?? '',//联系人手机
|
||||
'contacts_card_no' => $this->params['contacts_card_no'] ?? '',//联系人身份证
|
||||
'contacts_card_electronic_2' => $this->params['contacts_card_electronic_2'] ?? '',//申请人手持身份证正面
|
||||
'contacts_card_electronic_3' => $this->params['contacts_card_electronic_3'] ?? '',//申请人手持身份证反面
|
||||
'bank_account_name' => $this->params['bank_account_name'] ?? '',//银行开户名
|
||||
'bank_account_number' => $this->params['bank_account_number'] ?? '',//公司银行账号
|
||||
'bank_name' => $this->params['bank_name'] ?? '',//联系人姓名
|
||||
'bank_address' => $this->params['bank_address'] ?? '',//开户银行所在地
|
||||
'bank_code' => $this->params['bank_code'] ?? '',//支行联行号
|
||||
'bank_type' => $this->params['bank_type'] ?? '',//结算账户类型
|
||||
'settlement_bank_account_name' => $this->params['settlement_bank_account_name'] ?? '',
|
||||
'settlement_bank_account_number' => $this->params['settlement_bank_account_number'] ?? '',
|
||||
'settlement_bank_name' => $this->params['settlement_bank_name'] ?? '',//结算开户银行支行名称
|
||||
'settlement_bank_address' => $this->params['settlement_bank_address'] ?? ''//结算开户银行所在地
|
||||
];
|
||||
} else {
|
||||
//公司
|
||||
$cert_data = [
|
||||
'cert_type' => $cert_type,
|
||||
'company_name' => $this->params['company_name'] ?? '',//公司名称
|
||||
'company_province_id' => $this->params['company_province_id'] ?? '',//公司所在省
|
||||
'company_city_id' => $this->params['company_city_id'] ?? '',//公司所在市
|
||||
'company_district_id' => $this->params['company_district_id'] ?? '',//公司所在区/县
|
||||
'company_address' => $this->params['company_address'] ?? '',//公司地址
|
||||
'company_full_address' => $this->params['company_full_address'] ?? '',//公司完整地址
|
||||
'business_licence_number' => $this->params['business_licence_number'] ?? '',//统一社会信用码
|
||||
'business_licence_number_electronic' => $this->params['business_licence_number_electronic'] ?? '',//营业执照电子版
|
||||
'business_sphere' => $this->params['business_sphere'] ?? '',//法定经营范围
|
||||
'contacts_name' => $this->params['contacts_name'] ?? '',//联系人姓名
|
||||
'contacts_mobile' => $this->params['contacts_mobile'] ?? '',//联系人手机
|
||||
'contacts_card_no' => $this->params['contacts_card_no'] ?? '',//联系人身份证
|
||||
'contacts_card_electronic_2' => $this->params['contacts_card_electronic_2'] ?? '',//申请人手持身份证正面
|
||||
'contacts_card_electronic_3' => $this->params['contacts_card_electronic_3'] ?? '',//申请人手持身份证反面
|
||||
'bank_account_name' => $this->params['bank_account_name'] ?? '',//银行开户名
|
||||
'bank_account_number' => $this->params['bank_account_number'] ?? '',//公司银行账号
|
||||
'bank_name' => $this->params['bank_name'] ?? '',//联系人姓名
|
||||
'bank_address' => $this->params['bank_address'] ?? '',//开户银行所在地
|
||||
'bank_code' => $this->params['bank_code'] ?? '',//支行联行号
|
||||
'bank_type' => $this->params['bank_type'] ?? '',//结算账户类型
|
||||
'settlement_bank_account_name' => $this->params['settlement_bank_account_name'] ?? '',
|
||||
'settlement_bank_account_number' => $this->params['settlement_bank_account_number'] ?? '',
|
||||
'settlement_bank_name' => $this->params['settlement_bank_name'] ?? '',//结算开户银行支行名称
|
||||
'settlement_bank_address' => $this->params['settlement_bank_address'] ?? ''//结算开户银行所在地
|
||||
];
|
||||
}
|
||||
$model = new ShopApplyModel();
|
||||
$result = $model->apply($apply_data, $cert_data);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断店铺名称是否存在
|
||||
*/
|
||||
public function shopNameExist()
|
||||
{
|
||||
$shop_name = $this->params['shop_name'] ?? '';
|
||||
|
||||
$model = new ShopApplyModel();
|
||||
$res = $model->shopNameExist($shop_name);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取申请金额
|
||||
* */
|
||||
public function getApplyMoney()
|
||||
{
|
||||
$apply_year = $this->params['apply_year'] ?? '';//入驻年长
|
||||
$category_id = $this->params['category_id'] ?? '';//店铺分类id
|
||||
$group_id = $this->params['group_id'] ?? '';//店铺等级ID
|
||||
|
||||
$model = new ShopApplyModel();
|
||||
$result = $model->getApplyMoney($apply_year, $group_id, $category_id);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/*
|
||||
* 提交支付凭证
|
||||
**/
|
||||
public function editApply()
|
||||
{
|
||||
//申请信息
|
||||
$apply_data = [
|
||||
'paying_money_certificate' => $this->params['paying_money_certificate'] ?? '',// 付款凭证
|
||||
'paying_money_certificate_explain' => $this->params['paying_money_certificate_explain'] ?? '',// 付款凭证说明
|
||||
'apply_state' => 2
|
||||
];
|
||||
|
||||
$model = new ShopApplyModel();
|
||||
$condition[] = [ 'uid', '=', $this->uid ];
|
||||
$result = $model->editApply($apply_data, $condition);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 体验入驻
|
||||
*/
|
||||
public function experienceApply()
|
||||
{
|
||||
$shop_data = [
|
||||
'site_name' => $this->params['site_name'] ?? '', //店铺名称
|
||||
'category_id' => $this->params['category_id'] ?? '', //主营行业id
|
||||
'category_name' => $this->params['category_name'] ?? '', //主营行业名称
|
||||
'website_id' => $this->params['website_id'] ?? '',
|
||||
];
|
||||
|
||||
$model = new ShopApply();
|
||||
$res = $model->experienceApply($shop_data, $this->user_info);
|
||||
return $this->response($res);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断结算类型
|
||||
*/
|
||||
public function getTransferType()
|
||||
{
|
||||
$support_type = [];
|
||||
if (addon_is_exit("shopwithdraw")) {
|
||||
$config_model = new ShopWithdrawConfig();
|
||||
$config_result = $config_model->getConfig();
|
||||
$config = $config_result[ "data" ];
|
||||
if ($config[ "is_use" ]) {
|
||||
$support_type = explode(",", $config[ 'value' ][ "transfer_type" ]);
|
||||
} else {
|
||||
$support_type = [ "alipay", "bank" ];
|
||||
}
|
||||
} else {
|
||||
$support_type = [ "alipay", "bank" ];
|
||||
}
|
||||
return $this->response($support_type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟登陆
|
||||
*/
|
||||
public function simulatedLogin()
|
||||
{
|
||||
$user_model = new UserModel;
|
||||
$res = $user_model->simulatedLogin($this->user_info[ 'username' ], 'shop', 'shopapi');
|
||||
|
||||
if ($res[ 'code' ] >= 0) {
|
||||
$token = $this->createToken($res[ 'data' ]);
|
||||
return $this->response($this->success([ 'token' => $token, 'site_id' => $res[ 'data' ][ 'site_id' ] ]));
|
||||
}
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 店铺绑定openid 二维码
|
||||
*/
|
||||
public function shopBindQrcode()
|
||||
{
|
||||
$key = 'bing_shop_openid_' . md5(uniqid(null, true));
|
||||
$url = addon_url("wechat://api/auth/shopBindOpenid", [ "key" => $key ]);
|
||||
Session::set("bing_shop_openid", $key);
|
||||
Cache::tag("bing_shop_openid")->set($key, [], 600);
|
||||
|
||||
$file_path = qrcode($url, "upload/qrcode/", date("Ymd") . 'qrcode');
|
||||
|
||||
$file = $file_path;
|
||||
if ($fp = fopen($file, "rb", 0)) {
|
||||
$gambar = fread($fp, filesize($file_path));
|
||||
fclose($fp);
|
||||
$base64 = "data:image/jpg/png/gif;base64," . chunk_split(base64_encode($gambar));
|
||||
@unlink($file_path);
|
||||
|
||||
$data = [
|
||||
'key' => $key,
|
||||
'qrcode' => $base64
|
||||
];
|
||||
return $this->response($this->success($data));
|
||||
} else {
|
||||
return $this->response($this->error());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证店铺绑定情况(成功返回openid)
|
||||
*/
|
||||
public function checkShopBind()
|
||||
{
|
||||
|
||||
$key = $this->params['key'] ?? '';
|
||||
$data = Cache::get($key);
|
||||
$shop_apply_model = new ShopApplyModel();
|
||||
if (!isset($data)) {
|
||||
return $this->response($shop_apply_model->error([ "is_expire" => 1 ], "二维码已过期"));
|
||||
}
|
||||
|
||||
if (empty($data)) {
|
||||
return $this->response($shop_apply_model->error([ "is_expire" => 0 ], "二维码还没有被扫描"));
|
||||
}
|
||||
|
||||
return $this->response($shop_apply_model->success($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取店铺设置
|
||||
* @return false|string
|
||||
*/
|
||||
public function getShopWithdrawConfig()
|
||||
{
|
||||
$account_model = new ShopaccountModel();
|
||||
$config_info = $account_model->getShopWithdrawConfig();
|
||||
return $this->response($this->success($config_info[ 'data' ][ 'value' ]));
|
||||
}
|
||||
}
|
||||
@@ -1,377 +1,369 @@
|
||||
<?php
|
||||
/**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\exception\ApiException;
|
||||
use app\model\shop\Shop;
|
||||
use app\model\system\Api;
|
||||
use app\model\system\Group as GroupModel;
|
||||
use app\model\system\Site;
|
||||
use app\model\system\User as UserModel;
|
||||
use extend\RSA;
|
||||
use think\facade\Cache;
|
||||
use think\Response;
|
||||
|
||||
class BaseApi
|
||||
{
|
||||
public $lang;
|
||||
|
||||
public $params;
|
||||
|
||||
public $token;
|
||||
|
||||
protected $user_info;
|
||||
|
||||
protected $uid;
|
||||
|
||||
protected $url;
|
||||
|
||||
protected $site_id;
|
||||
|
||||
protected $website_id;
|
||||
|
||||
protected $group_info;
|
||||
|
||||
protected $shop_info;
|
||||
|
||||
public $app_type;
|
||||
|
||||
protected $app_module = 'shop';
|
||||
|
||||
protected $api_config;
|
||||
|
||||
protected $addon = '';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
if ($_SERVER[ 'REQUEST_METHOD' ] == 'OPTIONS') {
|
||||
exit;
|
||||
}
|
||||
$this->url = strtolower(request()->parseUrl());
|
||||
$this->addon = request()->addon() ? request()->addon() : '';
|
||||
//获取参数
|
||||
$this->params = input();
|
||||
$this->getApiConfig();
|
||||
$this->decryptParams();
|
||||
$this->site_id = request()->siteid();
|
||||
//todo 基于将这个类所谓api基类的解决方案(主观应该提取公共部分重新封装)
|
||||
if($this->app_module == 'shop'){
|
||||
if (!addon_is_exit('mobileshop', $this->site_id)) {
|
||||
$error = $this->error([], 'ADDON_NOT_EXIST');
|
||||
throw new ApiException($error['code'], $error['message']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* api请求参数解密
|
||||
*/
|
||||
private function decryptParams()
|
||||
{
|
||||
if ($this->api_config[ 'is_use' ] && !empty($this->api_config[ 'value' ]) && isset($this->params[ 'encrypt' ])) {
|
||||
$decrypted = RSA::decrypt(
|
||||
$this->params[ 'encrypt' ],
|
||||
$this->api_config[ 'value' ][ 'private_key' ],
|
||||
$this->api_config[ 'value' ][ 'public_key' ]
|
||||
);
|
||||
if ($decrypted[ 'code' ] >= 0) {
|
||||
$this->params = json_decode($decrypted[ 'data' ], true);
|
||||
} else {
|
||||
$this->params = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取api配置
|
||||
*/
|
||||
private function getApiConfig()
|
||||
{
|
||||
$api_model = new Api();
|
||||
$config_result = $api_model->getApiConfig();
|
||||
$this->api_config = $config_result[ "data" ];
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测token(使用私钥检测)
|
||||
*/
|
||||
protected function checkToken() : array
|
||||
{
|
||||
if (empty($this->params[ 'token' ])) {
|
||||
return $this->error('', 'TOKEN_NOT_EXIST');
|
||||
}
|
||||
|
||||
if ($this->api_config[ 'is_use' ] && isset($this->api_config[ 'value' ][ 'private_key' ])
|
||||
&& !empty($this->api_config[ 'value' ][ 'private_key' ])) {
|
||||
$decrypt = decrypt($this->params[ 'token' ], $this->api_config[ 'value' ][ 'private_key' ]);
|
||||
} else {
|
||||
$decrypt = decrypt($this->params[ 'token' ]);
|
||||
}
|
||||
if (empty($decrypt)) {
|
||||
return $this->error('', 'TOKEN_ERROR');
|
||||
}
|
||||
$data = json_decode($decrypt, true);
|
||||
|
||||
if (!empty($data[ 'expire_time' ]) && $data[ 'expire_time' ] > time()) {
|
||||
return $this->error('', 'TOKEN_EXPIRE');
|
||||
}
|
||||
$this->user_info = $data[ 'user_info' ];
|
||||
$this->app_module = $this->user_info['app_module'];
|
||||
|
||||
$this->uid = $data[ 'user_info' ][ 'uid' ];
|
||||
|
||||
$this->getShopInfo();
|
||||
$this->getGroupInfo();
|
||||
|
||||
//判断权限
|
||||
if (!$this->checkAuth()) {
|
||||
$error = $this->error([], 'NO_PERMISSION');
|
||||
throw new ApiException($error['code'], $error['message']);
|
||||
}
|
||||
|
||||
return success(0, '', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建token
|
||||
* @param $user_info
|
||||
* @param int $expire_time 有效时间 0为永久 单位s
|
||||
* @return string
|
||||
*/
|
||||
protected function createToken($user_info)
|
||||
{
|
||||
$data = [
|
||||
'user_info' => $user_info,
|
||||
'expire_time' => $this->api_config[ 'value' ]['long_time'] * 3600
|
||||
];
|
||||
if ($this->api_config[ 'is_use' ] && isset($this->api_config[ 'value' ][ 'private_key' ])
|
||||
&& !empty($this->api_config[ 'value' ][ 'private_key' ])) {
|
||||
$token = encrypt(json_encode($data), $this->api_config[ 'value' ][ 'private_key' ]);
|
||||
} else {
|
||||
$token = encrypt(json_encode($data));
|
||||
}
|
||||
return $token;
|
||||
}
|
||||
|
||||
public function getShopInfo()
|
||||
{
|
||||
//获取店铺信息
|
||||
$condition = array (
|
||||
[ "site_id", "=", $this->site_id ]
|
||||
);
|
||||
$shop_info_result = (new Shop())->getShopInfo($condition);
|
||||
$site_info = (new Site())->getSiteInfo($condition);
|
||||
|
||||
$this->shop_info = array_merge($shop_info_result['data'], $site_info['data']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户的用户组
|
||||
*/
|
||||
private function getGroupInfo()
|
||||
{
|
||||
$group_model = new GroupModel();
|
||||
|
||||
$group_info_result = $group_model->getGroupInfo([ [ "group_id", "=", $this->user_info[ "group_id" ] ], [ "site_id", "=", $this->site_id ], [ "app_module", "=", $this->app_module ] ]);
|
||||
|
||||
$this->group_info = $group_info_result[ "data" ];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回数据
|
||||
* @param $data
|
||||
* @return false|string
|
||||
*/
|
||||
public function response($data)
|
||||
{
|
||||
$data[ 'timestamp' ] = time();
|
||||
return Response::create($data, 'json', 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* 操作成功返回值函数
|
||||
* @param string $data
|
||||
* @param string $code_var
|
||||
* @return array
|
||||
*/
|
||||
public function success($data = '', $code_var = 'SUCCESS')
|
||||
{
|
||||
$lang_array = $this->getLang();
|
||||
$code_array = $this->getCode();
|
||||
$lang_var = $lang_array[$code_var] ?? $code_var;
|
||||
$code_var = $code_array[$code_var] ?? $code_array['SUCCESS'];
|
||||
return success($code_var, $lang_var, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 操作失败返回值函数
|
||||
* @param string $data
|
||||
* @param string $code_var
|
||||
* @return array
|
||||
*/
|
||||
public function error($data = '', $code_var = 'ERROR')
|
||||
{
|
||||
$lang_array = $this->getLang();
|
||||
$code_array = $this->getCode();
|
||||
$lang_var = $lang_array[$code_var] ?? $code_var;
|
||||
$code_var = $code_array[$code_var] ?? $code_array['ERROR'];
|
||||
return error($code_var, $lang_var, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取语言包数组
|
||||
* @return array|mixed
|
||||
*/
|
||||
private function getLang()
|
||||
{
|
||||
$default_lang = config("lang.default_lang");
|
||||
$addon = request()->addon();
|
||||
$addon = $addon ?? '';
|
||||
$cache_common = Cache::get("lang_app/shopapi/lang/" . $default_lang);
|
||||
|
||||
if (!empty($addon)) {
|
||||
$addon_cache_common = Cache::get("lang_app/shopapi/lang/" . $addon . '_' . $default_lang);
|
||||
if (!empty($addon_cache_common)) {
|
||||
$cache_common = array_merge($cache_common, $addon_cache_common);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($cache_common)) {
|
||||
$cache_common = include 'app/shopapi/lang/' . $default_lang . '.php';
|
||||
Cache::tag("lang")->set("lang_app/shopapi/lang/" . $default_lang, $cache_common);
|
||||
if (!empty($addon)) {
|
||||
try {
|
||||
$addon_cache_common = include 'addon/' . $addon . '/shopapi/lang/' . $default_lang . '.php';
|
||||
if (!empty($addon_cache_common)) {
|
||||
$cache_common = array_merge($cache_common, $addon_cache_common);
|
||||
Cache::tag("lang")->set(
|
||||
"lang_app/shopapi/lang/" . $addon . '_' . $default_lang,
|
||||
$addon_cache_common
|
||||
);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
$lang_path = $this->lang ?? '';
|
||||
if (!empty($lang_path)) {
|
||||
$cache_path = Cache::get("lang_" . $lang_path . "/" . $default_lang);
|
||||
if (empty($cache_path)) {
|
||||
$cache_path = include $lang_path . "/" . $default_lang . '.php';
|
||||
Cache::tag("lang")->set("lang_" . $lang_path . "/" . $default_lang, $cache_path);
|
||||
}
|
||||
$lang = array_merge($cache_common, $cache_path);
|
||||
} else {
|
||||
$lang = $cache_common;
|
||||
}
|
||||
return $lang;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取code编码
|
||||
* @return array|mixed
|
||||
*/
|
||||
private function getCode()
|
||||
{
|
||||
$addon = request()->addon();
|
||||
$addon = $addon ?? '';
|
||||
$cache_common = Cache::get("lang_code_app/shopapi/lang");
|
||||
|
||||
if (!empty($addon)) {
|
||||
$addon_cache_common = Cache::get("lang_code_app/shopapi/lang/" . $addon);
|
||||
if (!empty($addon_cache_common)) {
|
||||
$cache_common = array_merge($cache_common, $addon_cache_common);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($cache_common)) {
|
||||
$cache_common = include 'app/shopapi/lang/code.php';
|
||||
Cache::tag("lang_code")->set("lang_code_app/shopapi/lang", $cache_common);
|
||||
|
||||
if (!empty($addon)) {
|
||||
try {
|
||||
$addon_cache_common = include 'addon/' . $addon . '/shopapi/lang/code.php';
|
||||
if (!empty($addon_cache_common)) {
|
||||
Cache::tag("lang_code")->set("lang_code_app/shopapi/lang/" . $addon, $addon_cache_common);
|
||||
$cache_common = array_merge($cache_common, $addon_cache_common);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
$lang_path = $this->lang ?? '';
|
||||
if (!empty($lang_path)) {
|
||||
$cache_path = Cache::get("lang_code_" . $lang_path);
|
||||
if (empty($cache_path)) {
|
||||
$cache_path = include $lang_path . '/code.php';
|
||||
Cache::tag("lang")->set("lang_code_" . $lang_path, $cache_path);
|
||||
}
|
||||
$lang = array_merge($cache_common, $cache_path);
|
||||
} else {
|
||||
$lang = $cache_common;
|
||||
}
|
||||
return $lang;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检测权限
|
||||
*/
|
||||
protected function checkAuth()
|
||||
{
|
||||
if (empty($addon)) {
|
||||
$auth_name = 'config/auth_shopapi.php';
|
||||
} else {
|
||||
$auth_name = 'addon/' . $addon . '/config/auth_shopapi.php';
|
||||
}
|
||||
|
||||
$auth_array = require $auth_name;
|
||||
$this->url = strtolower($this->url);
|
||||
|
||||
if ($this->group_info[ 'is_system' ] == 1) {
|
||||
return true;
|
||||
}
|
||||
if (!isset($auth_array[ $this->url ])) {
|
||||
return true;
|
||||
}
|
||||
$auth_control = event('AuthControl', [ 'key' => $auth_array[ $this->url ], 'app_module' => $this->app_module, 'ajax' => 1 ], 1);
|
||||
if (!empty($auth_control)) {
|
||||
if ($auth_control[ 'code' ] < 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists($this->url, $auth_array)) {
|
||||
|
||||
if (strpos(',' . $this->group_info[ 'menu_array' ] . ',', ',' . $auth_array[ $this->url ] . ',')) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加日志
|
||||
* @param unknown $action_name
|
||||
* @param unknown $data
|
||||
*/
|
||||
protected function addLog($action_name, $data = [])
|
||||
{
|
||||
$user = new UserModel();
|
||||
$user->addUserLog($this->uid, $this->user_info[ 'username' ], $this->site_id, $action_name, $data);
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\exception\ApiException;
|
||||
use app\model\shop\Shop;
|
||||
use app\model\system\Api;
|
||||
use app\model\system\Group as GroupModel;
|
||||
use app\model\system\Site;
|
||||
use app\model\system\User as UserModel;
|
||||
use extend\RSA;
|
||||
use think\facade\Cache;
|
||||
use think\Response;
|
||||
|
||||
class BaseApi
|
||||
{
|
||||
public $lang;
|
||||
|
||||
public $params;
|
||||
|
||||
public $token;
|
||||
|
||||
protected $user_info;
|
||||
|
||||
protected $uid;
|
||||
|
||||
protected $url;
|
||||
|
||||
protected $site_id;
|
||||
|
||||
protected $website_id;
|
||||
|
||||
protected $group_info;
|
||||
|
||||
protected $shop_info;
|
||||
|
||||
public $app_type;
|
||||
|
||||
protected $app_module = 'shop';
|
||||
|
||||
protected $api_config;
|
||||
|
||||
protected $addon = '';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
if ($_SERVER[ 'REQUEST_METHOD' ] == 'OPTIONS') {
|
||||
exit;
|
||||
}
|
||||
$this->url = strtolower(request()->parseUrl());
|
||||
$this->addon = request()->addon() ? request()->addon() : '';
|
||||
//获取参数
|
||||
$this->params = input();
|
||||
$this->getApiConfig();
|
||||
$this->decryptParams();
|
||||
$this->site_id = request()->siteid();
|
||||
//todo 基于将这个类所谓api基类的解决方案(主观应该提取公共部分重新封装)
|
||||
if($this->app_module == 'shop'){
|
||||
if (!addon_is_exit('mobileshop', $this->site_id)) {
|
||||
$error = $this->error([], 'ADDON_NOT_EXIST');
|
||||
throw new ApiException($error['code'], $error['message']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* api请求参数解密
|
||||
*/
|
||||
private function decryptParams()
|
||||
{
|
||||
if ($this->api_config[ 'is_use' ] && !empty($this->api_config[ 'value' ]) && isset($this->params[ 'encrypt' ])) {
|
||||
$decrypted = RSA::decrypt(
|
||||
$this->params[ 'encrypt' ],
|
||||
$this->api_config[ 'value' ][ 'private_key' ],
|
||||
$this->api_config[ 'value' ][ 'public_key' ]
|
||||
);
|
||||
if ($decrypted[ 'code' ] >= 0) {
|
||||
$this->params = json_decode($decrypted[ 'data' ], true);
|
||||
} else {
|
||||
$this->params = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取api配置
|
||||
*/
|
||||
private function getApiConfig()
|
||||
{
|
||||
$api_model = new Api();
|
||||
$config_result = $api_model->getApiConfig();
|
||||
$this->api_config = $config_result[ "data" ];
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测token(使用私钥检测)
|
||||
*/
|
||||
protected function checkToken() : array
|
||||
{
|
||||
if (empty($this->params[ 'token' ])) {
|
||||
return $this->error('', 'TOKEN_NOT_EXIST');
|
||||
}
|
||||
|
||||
if ($this->api_config[ 'is_use' ] && isset($this->api_config[ 'value' ][ 'private_key' ])
|
||||
&& !empty($this->api_config[ 'value' ][ 'private_key' ])) {
|
||||
$decrypt = decrypt($this->params[ 'token' ], $this->api_config[ 'value' ][ 'private_key' ]);
|
||||
} else {
|
||||
$decrypt = decrypt($this->params[ 'token' ]);
|
||||
}
|
||||
if (empty($decrypt)) {
|
||||
return $this->error('', 'TOKEN_ERROR');
|
||||
}
|
||||
$data = json_decode($decrypt, true);
|
||||
|
||||
if (!empty($data[ 'expire_time' ]) && $data[ 'expire_time' ] > time()) {
|
||||
return $this->error('', 'TOKEN_EXPIRE');
|
||||
}
|
||||
$this->user_info = $data[ 'user_info' ];
|
||||
$this->app_module = $this->user_info['app_module'];
|
||||
|
||||
$this->uid = $data[ 'user_info' ][ 'uid' ];
|
||||
|
||||
$this->getShopInfo();
|
||||
$this->getGroupInfo();
|
||||
|
||||
//判断权限
|
||||
if (!$this->checkAuth()) {
|
||||
$error = $this->error([], 'NO_PERMISSION');
|
||||
throw new ApiException($error['code'], $error['message']);
|
||||
}
|
||||
|
||||
return success(0, '', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建token
|
||||
* @param $user_info
|
||||
* @param int $expire_time 有效时间 0为永久 单位s
|
||||
* @return string
|
||||
*/
|
||||
protected function createToken($user_info)
|
||||
{
|
||||
$data = [
|
||||
'user_info' => $user_info,
|
||||
'expire_time' => $this->api_config[ 'value' ]['long_time'] * 3600
|
||||
];
|
||||
if ($this->api_config[ 'is_use' ] && isset($this->api_config[ 'value' ][ 'private_key' ])
|
||||
&& !empty($this->api_config[ 'value' ][ 'private_key' ])) {
|
||||
$token = encrypt(json_encode($data), $this->api_config[ 'value' ][ 'private_key' ]);
|
||||
} else {
|
||||
$token = encrypt(json_encode($data));
|
||||
}
|
||||
return $token;
|
||||
}
|
||||
|
||||
public function getShopInfo()
|
||||
{
|
||||
//获取店铺信息
|
||||
$condition = array (
|
||||
[ "site_id", "=", $this->site_id ]
|
||||
);
|
||||
$shop_info_result = (new Shop())->getShopInfo($condition);
|
||||
$site_info = (new Site())->getSiteInfo($condition);
|
||||
|
||||
$this->shop_info = array_merge($shop_info_result['data'], $site_info['data']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户的用户组
|
||||
*/
|
||||
private function getGroupInfo()
|
||||
{
|
||||
$group_model = new GroupModel();
|
||||
|
||||
$group_info_result = $group_model->getGroupInfo([ [ "group_id", "=", $this->user_info[ "group_id" ] ], [ "site_id", "=", $this->site_id ], [ "app_module", "=", $this->app_module ] ]);
|
||||
|
||||
$this->group_info = $group_info_result[ "data" ];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回数据
|
||||
* @param $data
|
||||
* @return false|string
|
||||
*/
|
||||
public function response($data)
|
||||
{
|
||||
$data[ 'timestamp' ] = time();
|
||||
return Response::create($data, 'json', 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* 操作成功返回值函数
|
||||
* @param string $data
|
||||
* @param string $code_var
|
||||
* @return array
|
||||
*/
|
||||
public function success($data = '', $code_var = 'SUCCESS')
|
||||
{
|
||||
$lang_array = $this->getLang();
|
||||
$code_array = $this->getCode();
|
||||
$lang_var = $lang_array[$code_var] ?? $code_var;
|
||||
$code_var = $code_array[$code_var] ?? $code_array['SUCCESS'];
|
||||
return success($code_var, $lang_var, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 操作失败返回值函数
|
||||
* @param string $data
|
||||
* @param string $code_var
|
||||
* @return array
|
||||
*/
|
||||
public function error($data = '', $code_var = 'ERROR')
|
||||
{
|
||||
$lang_array = $this->getLang();
|
||||
$code_array = $this->getCode();
|
||||
$lang_var = $lang_array[$code_var] ?? $code_var;
|
||||
$code_var = $code_array[$code_var] ?? $code_array['ERROR'];
|
||||
return error($code_var, $lang_var, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取语言包数组
|
||||
* @return array|mixed
|
||||
*/
|
||||
private function getLang()
|
||||
{
|
||||
$default_lang = config("lang.default_lang");
|
||||
$addon = request()->addon();
|
||||
$addon = $addon ?? '';
|
||||
$cache_common = Cache::get("lang_app/shopapi/lang/" . $default_lang);
|
||||
|
||||
if (!empty($addon)) {
|
||||
$addon_cache_common = Cache::get("lang_app/shopapi/lang/" . $addon . '_' . $default_lang);
|
||||
if (!empty($addon_cache_common)) {
|
||||
$cache_common = array_merge($cache_common, $addon_cache_common);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($cache_common)) {
|
||||
$cache_common = include 'app/shopapi/lang/' . $default_lang . '.php';
|
||||
Cache::tag("lang")->set("lang_app/shopapi/lang/" . $default_lang, $cache_common);
|
||||
if (!empty($addon)) {
|
||||
try {
|
||||
$addon_cache_common = include 'addon/' . $addon . '/shopapi/lang/' . $default_lang . '.php';
|
||||
if (!empty($addon_cache_common)) {
|
||||
$cache_common = array_merge($cache_common, $addon_cache_common);
|
||||
Cache::tag("lang")->set(
|
||||
"lang_app/shopapi/lang/" . $addon . '_' . $default_lang,
|
||||
$addon_cache_common
|
||||
);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
$lang_path = $this->lang ?? '';
|
||||
if (!empty($lang_path)) {
|
||||
$cache_path = Cache::get("lang_" . $lang_path . "/" . $default_lang);
|
||||
if (empty($cache_path)) {
|
||||
$cache_path = include $lang_path . "/" . $default_lang . '.php';
|
||||
Cache::tag("lang")->set("lang_" . $lang_path . "/" . $default_lang, $cache_path);
|
||||
}
|
||||
$lang = array_merge($cache_common, $cache_path);
|
||||
} else {
|
||||
$lang = $cache_common;
|
||||
}
|
||||
return $lang;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取code编码
|
||||
* @return array|mixed
|
||||
*/
|
||||
private function getCode()
|
||||
{
|
||||
$addon = request()->addon();
|
||||
$addon = $addon ?? '';
|
||||
$cache_common = Cache::get("lang_code_app/shopapi/lang");
|
||||
|
||||
if (!empty($addon)) {
|
||||
$addon_cache_common = Cache::get("lang_code_app/shopapi/lang/" . $addon);
|
||||
if (!empty($addon_cache_common)) {
|
||||
$cache_common = array_merge($cache_common, $addon_cache_common);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($cache_common)) {
|
||||
$cache_common = include 'app/shopapi/lang/code.php';
|
||||
Cache::tag("lang_code")->set("lang_code_app/shopapi/lang", $cache_common);
|
||||
|
||||
if (!empty($addon)) {
|
||||
try {
|
||||
$addon_cache_common = include 'addon/' . $addon . '/shopapi/lang/code.php';
|
||||
if (!empty($addon_cache_common)) {
|
||||
Cache::tag("lang_code")->set("lang_code_app/shopapi/lang/" . $addon, $addon_cache_common);
|
||||
$cache_common = array_merge($cache_common, $addon_cache_common);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
$lang_path = $this->lang ?? '';
|
||||
if (!empty($lang_path)) {
|
||||
$cache_path = Cache::get("lang_code_" . $lang_path);
|
||||
if (empty($cache_path)) {
|
||||
$cache_path = include $lang_path . '/code.php';
|
||||
Cache::tag("lang")->set("lang_code_" . $lang_path, $cache_path);
|
||||
}
|
||||
$lang = array_merge($cache_common, $cache_path);
|
||||
} else {
|
||||
$lang = $cache_common;
|
||||
}
|
||||
return $lang;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检测权限
|
||||
*/
|
||||
protected function checkAuth()
|
||||
{
|
||||
if (empty($addon)) {
|
||||
$auth_name = 'config/auth_shopapi.php';
|
||||
} else {
|
||||
$auth_name = 'addon/' . $addon . '/config/auth_shopapi.php';
|
||||
}
|
||||
|
||||
$auth_array = require $auth_name;
|
||||
$this->url = strtolower($this->url);
|
||||
|
||||
if ($this->group_info[ 'is_system' ] == 1) {
|
||||
return true;
|
||||
}
|
||||
if (!isset($auth_array[ $this->url ])) {
|
||||
return true;
|
||||
}
|
||||
$auth_control = event('AuthControl', [ 'key' => $auth_array[ $this->url ], 'app_module' => $this->app_module, 'ajax' => 1 ], 1);
|
||||
if (!empty($auth_control)) {
|
||||
if ($auth_control[ 'code' ] < 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists($this->url, $auth_array)) {
|
||||
|
||||
if (strpos(',' . $this->group_info[ 'menu_array' ] . ',', ',' . $auth_array[ $this->url ] . ',')) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加日志
|
||||
* @param unknown $action_name
|
||||
* @param unknown $data
|
||||
*/
|
||||
protected function addLog($action_name, $data = [])
|
||||
{
|
||||
$user = new UserModel();
|
||||
$user->addUserLog($this->uid, $this->user_info[ 'username' ], $this->site_id, $action_name, $data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,52 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\web\Config as ConfigModel;
|
||||
|
||||
class Config extends BaseApi
|
||||
{
|
||||
/**
|
||||
* 详情信息
|
||||
*/
|
||||
public function defaultimg()
|
||||
{
|
||||
$upload_config_model = new ConfigModel();
|
||||
$res = $upload_config_model->getDefaultImg($this->site_id);
|
||||
if (!empty($res[ 'data' ][ 'value' ])) {
|
||||
return $this->response($this->success($res[ 'data' ][ 'value' ]));
|
||||
} else {
|
||||
return $this->response($this->error());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 版权信息
|
||||
*/
|
||||
public function copyright()
|
||||
{
|
||||
$config_model = new ConfigModel();
|
||||
$res = $config_model->getCopyright();
|
||||
return $this->response($this->success($res[ 'data' ][ 'value' ]));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询验证码设置
|
||||
* @return false|string
|
||||
*/
|
||||
public function captchaConfig()
|
||||
{
|
||||
$config_model = new ConfigModel();
|
||||
$config_info = $config_model->getCaptchaConfig();
|
||||
return $this->response($this->success($config_info[ 'data' ][ 'value' ]));
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\web\Config as ConfigModel;
|
||||
|
||||
class Config extends BaseApi
|
||||
{
|
||||
/**
|
||||
* 详情信息
|
||||
*/
|
||||
public function defaultimg()
|
||||
{
|
||||
$upload_config_model = new ConfigModel();
|
||||
$res = $upload_config_model->getDefaultImg($this->site_id);
|
||||
if (!empty($res[ 'data' ][ 'value' ])) {
|
||||
return $this->response($this->success($res[ 'data' ][ 'value' ]));
|
||||
} else {
|
||||
return $this->response($this->error());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 版权信息
|
||||
*/
|
||||
public function copyright()
|
||||
{
|
||||
$config_model = new ConfigModel();
|
||||
$res = $config_model->getCopyright();
|
||||
return $this->response($this->success($res[ 'data' ][ 'value' ]));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询验证码设置
|
||||
* @return false|string
|
||||
*/
|
||||
public function captchaConfig()
|
||||
{
|
||||
$config_model = new ConfigModel();
|
||||
$config_info = $config_model->getCaptchaConfig();
|
||||
return $this->response($this->success($config_info[ 'data' ][ 'value' ]));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,114 +1,106 @@
|
||||
<?php
|
||||
/**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\order\Order;
|
||||
use app\model\shop\Shop as ShopModel;
|
||||
use app\model\shop\ShopReopen as ShopReopenModel;
|
||||
use app\model\system\Stat;
|
||||
use app\model\web\Notice as NoticeModel;
|
||||
use Carbon\Carbon;
|
||||
use app\model\web\WebSite as WebsiteModel;
|
||||
use app\model\goods\Goods as GoodsModel;
|
||||
use app\model\system\User as ShopUser;
|
||||
use app\model\order\OrderCommon;
|
||||
use app\model\order\OrderRefund as OrderRefundModel;
|
||||
use app\model\member\Member;
|
||||
|
||||
class Index extends BaseApi
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//执行父类构造函数
|
||||
parent::__construct();
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) {
|
||||
echo $this->response($token);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页
|
||||
* @return mixed
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//店铺基础信息
|
||||
$data[ 'shop_info' ] = $this->shop_info;
|
||||
|
||||
//基础统计信息
|
||||
$stat_shop_model = new Stat();
|
||||
$today = Carbon::now();
|
||||
$yesterday = Carbon::yesterday();
|
||||
// $stat_today = $stat_shop_model->getStatShop($this->site_id, $today->year, $today->month, $today->day);
|
||||
// $stat_yesterday = $stat_shop_model->getStatShop($this->site_id, $yesterday->year, $yesterday->month, $yesterday->day);
|
||||
$stat_today = $stat_shop_model->getShopStatSum($this->site_id, $today->startOfDay()->timestamp, $today->endOfDay()->timestamp);
|
||||
$stat_yesterday = $stat_shop_model->getShopStatSum($this->site_id, $yesterday->startOfDay()->timestamp, $yesterday->endOfDay()->timestamp);
|
||||
|
||||
|
||||
$data[ 'stat_day' ] = $stat_today[ 'data' ];
|
||||
$data[ 'stat_yesterday' ] = $stat_yesterday[ 'data' ];
|
||||
// $data[ 'today' ] = $today;
|
||||
|
||||
//日同比
|
||||
$day_rate[ 'order_pay_count' ] = diff_rate($stat_today[ 'data' ][ 'order_pay_count' ], $stat_yesterday[ 'data' ][ 'order_pay_count' ]);
|
||||
$day_rate[ 'order_total' ] = diff_rate($stat_today[ 'data' ][ 'order_total' ], $stat_yesterday[ 'data' ][ 'order_total' ]);
|
||||
$day_rate[ 'collect_goods' ] = diff_rate($stat_today[ 'data' ][ 'collect_goods' ], $stat_yesterday[ 'data' ][ 'collect_goods' ]);
|
||||
$day_rate[ 'visit_count' ] = diff_rate($stat_today[ 'data' ][ 'visit_count' ], $stat_yesterday[ 'data' ][ 'visit_count' ]);
|
||||
$day_rate[ 'member_count' ] = diff_rate($stat_today[ 'data' ][ 'member_count' ], $stat_yesterday[ 'data' ][ 'member_count' ]);
|
||||
$data[ 'day_rate' ] = $day_rate;
|
||||
|
||||
//获取总数
|
||||
$shop_stat_sum = $stat_shop_model->getShopStatSum($this->site_id);
|
||||
$goods_model = new GoodsModel();
|
||||
$shop_stat_sum[ 'data' ][ 'goods_count' ] = $goods_model->getGoodsTotalCount([ [ 'site_id', '=', $this->site_id ], [ 'is_delete', '=', 0 ] ])[ 'data' ];
|
||||
$shop_stat_sum[ 'data' ]['member_count'] = (new Member())->getMemberCount([ [ 'site_id', '=', $this->site_id ], [ 'is_delete', '=', 0 ] ])[ 'data' ];
|
||||
$order = new Order();
|
||||
$shop_stat_sum[ 'data' ][ 'order_pay_count' ] = $order->getOrderCount([ [ 'site_id', '=', $this->site_id ], [ 'is_delete', '=', 0 ], [ 'pay_status', '=', 1 ] ])['data'];
|
||||
$shop_stat_sum[ 'data' ][ 'order_total' ] = $order->getOrderMoneySum([ [ 'site_id', '=', $this->site_id ], [ 'is_delete', '=', 0 ], [ 'pay_status', '=', 1 ] ], 'pay_money')['data'];
|
||||
$data[ 'shop_stat_sum' ] = $shop_stat_sum[ 'data' ];
|
||||
|
||||
//数据信息统计
|
||||
$order = new OrderCommon();
|
||||
$waitpay = $order->getOrderCount([ [ 'order_status', '=', 0 ], [ 'site_id', '=', $this->site_id ], [ 'is_delete', '=', 0 ], ['order_scene', '=', 'online'] ]);
|
||||
$waitsend = $order->getOrderCount([ [ 'order_status', '=', 1 ], [ 'site_id', '=', $this->site_id ], [ 'is_delete', '=', 0 ] ]);
|
||||
$order_refund_model = new OrderRefundModel();
|
||||
$refund_num = $order_refund_model->getRefundOrderGoodsCount([
|
||||
[ "site_id", "=", $this->site_id ],
|
||||
[ "refund_status", "not in", [ 0, 3 ] ]
|
||||
]);
|
||||
|
||||
//商品预警数
|
||||
$goods_stock_alarm = $goods_model->getGoodsStockAlarm($this->site_id);
|
||||
|
||||
//商品总数
|
||||
$goods_total = $goods_model->getGoodsTotalCount([ [ 'goods_state', '=', 1 ], [ 'site_id', '=', $this->site_id ], [ 'is_delete', '=', 0 ] ]);
|
||||
|
||||
$num_data = [
|
||||
'waitpay' => $waitpay[ 'data' ],
|
||||
'waitsend' => $waitsend[ 'data' ],
|
||||
'refund' => $refund_num[ 'data' ],
|
||||
'goods_stock_alarm' => is_array($goods_stock_alarm[ 'data' ]) ? count($goods_stock_alarm[ 'data' ]) : 0,
|
||||
'goods_total' => $goods_total[ 'data' ]
|
||||
];
|
||||
$data[ 'num_data' ] = $num_data;
|
||||
|
||||
$notice = new NoticeModel();
|
||||
$notice_list = $notice->getNoticePageList([ [ 'receiving_type', 'like', '%shop%' ] ], 1, 3, 'is_top desc,create_time desc', 'id, title');
|
||||
$notice_list = $notice_list[ 'data' ][ 'list' ];
|
||||
$data[ 'notice_list' ] = $notice_list;
|
||||
|
||||
return $this->response($this->success($data));
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\order\Order;
|
||||
use app\model\shop\Shop as ShopModel;
|
||||
use app\model\shop\ShopReopen as ShopReopenModel;
|
||||
use app\model\system\Stat;
|
||||
use app\model\web\Notice as NoticeModel;
|
||||
use Carbon\Carbon;
|
||||
use app\model\web\WebSite as WebsiteModel;
|
||||
use app\model\goods\Goods as GoodsModel;
|
||||
use app\model\system\User as ShopUser;
|
||||
use app\model\order\OrderCommon;
|
||||
use app\model\order\OrderRefund as OrderRefundModel;
|
||||
use app\model\member\Member;
|
||||
|
||||
class Index extends BaseApi
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//执行父类构造函数
|
||||
parent::__construct();
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) {
|
||||
echo $this->response($token);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页
|
||||
* @return mixed
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//店铺基础信息
|
||||
$data[ 'shop_info' ] = $this->shop_info;
|
||||
|
||||
//基础统计信息
|
||||
$stat_shop_model = new Stat();
|
||||
$today = Carbon::now();
|
||||
$yesterday = Carbon::yesterday();
|
||||
// $stat_today = $stat_shop_model->getStatShop($this->site_id, $today->year, $today->month, $today->day);
|
||||
// $stat_yesterday = $stat_shop_model->getStatShop($this->site_id, $yesterday->year, $yesterday->month, $yesterday->day);
|
||||
$stat_today = $stat_shop_model->getShopStatSum($this->site_id, $today->startOfDay()->timestamp, $today->endOfDay()->timestamp);
|
||||
$stat_yesterday = $stat_shop_model->getShopStatSum($this->site_id, $yesterday->startOfDay()->timestamp, $yesterday->endOfDay()->timestamp);
|
||||
|
||||
|
||||
$data[ 'stat_day' ] = $stat_today[ 'data' ];
|
||||
$data[ 'stat_yesterday' ] = $stat_yesterday[ 'data' ];
|
||||
// $data[ 'today' ] = $today;
|
||||
|
||||
//日同比
|
||||
$day_rate[ 'order_pay_count' ] = diff_rate($stat_today[ 'data' ][ 'order_pay_count' ], $stat_yesterday[ 'data' ][ 'order_pay_count' ]);
|
||||
$day_rate[ 'order_total' ] = diff_rate($stat_today[ 'data' ][ 'order_total' ], $stat_yesterday[ 'data' ][ 'order_total' ]);
|
||||
$day_rate[ 'collect_goods' ] = diff_rate($stat_today[ 'data' ][ 'collect_goods' ], $stat_yesterday[ 'data' ][ 'collect_goods' ]);
|
||||
$day_rate[ 'visit_count' ] = diff_rate($stat_today[ 'data' ][ 'visit_count' ], $stat_yesterday[ 'data' ][ 'visit_count' ]);
|
||||
$day_rate[ 'member_count' ] = diff_rate($stat_today[ 'data' ][ 'member_count' ], $stat_yesterday[ 'data' ][ 'member_count' ]);
|
||||
$data[ 'day_rate' ] = $day_rate;
|
||||
|
||||
//获取总数
|
||||
$shop_stat_sum = $stat_shop_model->getShopStatSum($this->site_id);
|
||||
$goods_model = new GoodsModel();
|
||||
$shop_stat_sum[ 'data' ][ 'goods_count' ] = $goods_model->getGoodsTotalCount([ [ 'site_id', '=', $this->site_id ], [ 'is_delete', '=', 0 ] ])[ 'data' ];
|
||||
$shop_stat_sum[ 'data' ]['member_count'] = (new Member())->getMemberCount([ [ 'site_id', '=', $this->site_id ], [ 'is_delete', '=', 0 ] ])[ 'data' ];
|
||||
$order = new Order();
|
||||
$shop_stat_sum[ 'data' ][ 'order_pay_count' ] = $order->getOrderCount([ [ 'site_id', '=', $this->site_id ], [ 'is_delete', '=', 0 ], [ 'pay_status', '=', 1 ] ])['data'];
|
||||
$shop_stat_sum[ 'data' ][ 'order_total' ] = $order->getOrderMoneySum([ [ 'site_id', '=', $this->site_id ], [ 'is_delete', '=', 0 ], [ 'pay_status', '=', 1 ] ], 'pay_money')['data'];
|
||||
$data[ 'shop_stat_sum' ] = $shop_stat_sum[ 'data' ];
|
||||
|
||||
//数据信息统计
|
||||
$order = new OrderCommon();
|
||||
$waitpay = $order->getOrderCount([ [ 'order_status', '=', 0 ], [ 'site_id', '=', $this->site_id ], [ 'is_delete', '=', 0 ], ['order_scene', '=', 'online'] ]);
|
||||
$waitsend = $order->getOrderCount([ [ 'order_status', '=', 1 ], [ 'site_id', '=', $this->site_id ], [ 'is_delete', '=', 0 ] ]);
|
||||
$order_refund_model = new OrderRefundModel();
|
||||
$refund_num = $order_refund_model->getRefundOrderGoodsCount([
|
||||
[ "site_id", "=", $this->site_id ],
|
||||
[ "refund_status", "not in", [ 0, 3 ] ]
|
||||
]);
|
||||
|
||||
//商品预警数
|
||||
$goods_stock_alarm = $goods_model->getGoodsStockAlarm($this->site_id);
|
||||
|
||||
//商品总数
|
||||
$goods_total = $goods_model->getGoodsTotalCount([ [ 'goods_state', '=', 1 ], [ 'site_id', '=', $this->site_id ], [ 'is_delete', '=', 0 ] ]);
|
||||
|
||||
$num_data = [
|
||||
'waitpay' => $waitpay[ 'data' ],
|
||||
'waitsend' => $waitsend[ 'data' ],
|
||||
'refund' => $refund_num[ 'data' ],
|
||||
'goods_stock_alarm' => is_array($goods_stock_alarm[ 'data' ]) ? count($goods_stock_alarm[ 'data' ]) : 0,
|
||||
'goods_total' => $goods_total[ 'data' ]
|
||||
];
|
||||
$data[ 'num_data' ] = $num_data;
|
||||
|
||||
$notice = new NoticeModel();
|
||||
$notice_list = $notice->getNoticePageList([ [ 'receiving_type', 'like', '%shop%' ] ], 1, 3, 'is_top desc,create_time desc', 'id, title');
|
||||
$notice_list = $notice_list[ 'data' ][ 'list' ];
|
||||
$data[ 'notice_list' ] = $notice_list;
|
||||
|
||||
return $this->response($this->success($data));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,69 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\system\User as UserModel;
|
||||
use app\model\web\Config as ConfigModel;
|
||||
|
||||
class Login extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 登录方法
|
||||
*/
|
||||
public function login()
|
||||
{
|
||||
if (empty($this->params[ "username" ])) return $this->response($this->error([], "商家账号不能为空!"));
|
||||
if (empty($this->params[ "password" ])) return $this->response($this->error([], "密码不可为空!"));
|
||||
|
||||
$config_model = new ConfigModel();
|
||||
$config_info = $config_model->getCaptchaConfig();
|
||||
$config = $config_info[ 'data' ][ 'value' ];
|
||||
$shop_login = $config[ "shop_login" ] ?? 0;
|
||||
|
||||
if ($shop_login == 1) {
|
||||
// 校验验证码
|
||||
$captcha = new Captcha();
|
||||
$check_res = $captcha->checkCaptcha();
|
||||
if ($check_res[ 'code' ] < 0) return $this->response($check_res);
|
||||
}
|
||||
|
||||
// 登录
|
||||
$login = new UserModel();
|
||||
$res = $login->uniAppLogin($this->params[ 'username' ], $this->params[ "password" ], $this->app_module);
|
||||
|
||||
//生成access_token
|
||||
if ($res[ 'code' ] >= 0) {
|
||||
$token = $this->createToken($res[ 'data' ]);
|
||||
return $this->response($this->success([ 'token' => $token, 'site_id' => $res[ 'data' ][ 'site_id' ] ]));
|
||||
}
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
* */
|
||||
public function modifyPassword()
|
||||
{
|
||||
if (empty($this->params[ "old_pass" ])) return $this->response($this->error([], "旧密码不能为空!"));
|
||||
if (empty($this->params[ "new_pass" ])) return $this->response($this->error([], "新密码不能为空!"));
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
$user_model = new UserModel();
|
||||
$condition = [
|
||||
['uid','=', $this->uid],
|
||||
['password', '=', data_md5($this->params[ 'old_pass' ])]
|
||||
];
|
||||
$res = $user_model->modifyAdminUserPassword($condition, $this->params[ 'new_pass' ]);
|
||||
|
||||
return $this->response($res);
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\system\User as UserModel;
|
||||
use app\model\web\Config as ConfigModel;
|
||||
|
||||
class Login extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 登录方法
|
||||
*/
|
||||
public function login()
|
||||
{
|
||||
if (empty($this->params[ "username" ])) return $this->response($this->error([], "商家账号不能为空!"));
|
||||
if (empty($this->params[ "password" ])) return $this->response($this->error([], "密码不可为空!"));
|
||||
|
||||
$config_model = new ConfigModel();
|
||||
$config_info = $config_model->getCaptchaConfig();
|
||||
$config = $config_info[ 'data' ][ 'value' ];
|
||||
$shop_login = $config[ "shop_login" ] ?? 0;
|
||||
|
||||
if ($shop_login == 1) {
|
||||
// 校验验证码
|
||||
$captcha = new Captcha();
|
||||
$check_res = $captcha->checkCaptcha();
|
||||
if ($check_res[ 'code' ] < 0) return $this->response($check_res);
|
||||
}
|
||||
|
||||
// 登录
|
||||
$login = new UserModel();
|
||||
$res = $login->uniAppLogin($this->params[ 'username' ], $this->params[ "password" ], $this->app_module);
|
||||
|
||||
//生成access_token
|
||||
if ($res[ 'code' ] >= 0) {
|
||||
$token = $this->createToken($res[ 'data' ]);
|
||||
return $this->response($this->success([ 'token' => $token, 'site_id' => $res[ 'data' ][ 'site_id' ] ]));
|
||||
}
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
* */
|
||||
public function modifyPassword()
|
||||
{
|
||||
if (empty($this->params[ "old_pass" ])) return $this->response($this->error([], "旧密码不能为空!"));
|
||||
if (empty($this->params[ "new_pass" ])) return $this->response($this->error([], "新密码不能为空!"));
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
$user_model = new UserModel();
|
||||
$condition = [
|
||||
['uid','=', $this->uid],
|
||||
['password', '=', data_md5($this->params[ 'old_pass' ])]
|
||||
];
|
||||
$res = $user_model->modifyAdminUserPassword($condition, $this->params[ 'new_pass' ]);
|
||||
|
||||
return $this->response($res);
|
||||
}
|
||||
}
|
||||
@@ -1,46 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\web\Notice as NoticeModel;
|
||||
|
||||
/**
|
||||
* 网站公告
|
||||
* Class Notice
|
||||
* @package app\shopapi\controller
|
||||
*/
|
||||
class Notice extends BaseApi
|
||||
{
|
||||
|
||||
public function lists()
|
||||
{
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$limit = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
|
||||
$condition = [];
|
||||
$receiving_type = $this->params['receiving_type'] ?? 'shop';
|
||||
if ($receiving_type) {
|
||||
$condition[] = [ 'receiving_type', 'like', '%' . $receiving_type . '%' ];
|
||||
}
|
||||
$notice = new NoticeModel();
|
||||
$list = $notice->getNoticePageList($condition, $page, $limit);
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
public function detail()
|
||||
{
|
||||
$id = $this->params['id'] ?? 0;
|
||||
|
||||
$notice = new NoticeModel();
|
||||
$info = $notice->getNoticeInfo([ [ 'id', '=', $id ] ]);
|
||||
return $this->response($info);
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\web\Notice as NoticeModel;
|
||||
|
||||
/**
|
||||
* 网站公告
|
||||
* Class Notice
|
||||
* @package app\shopapi\controller
|
||||
*/
|
||||
class Notice extends BaseApi
|
||||
{
|
||||
|
||||
public function lists()
|
||||
{
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$limit = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
|
||||
$condition = [];
|
||||
$receiving_type = $this->params['receiving_type'] ?? 'shop';
|
||||
if ($receiving_type) {
|
||||
$condition[] = [ 'receiving_type', 'like', '%' . $receiving_type . '%' ];
|
||||
}
|
||||
$notice = new NoticeModel();
|
||||
$list = $notice->getNoticePageList($condition, $page, $limit);
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
public function detail()
|
||||
{
|
||||
$id = $this->params['id'] ?? 0;
|
||||
|
||||
$notice = new NoticeModel();
|
||||
$info = $notice->getNoticeInfo([ [ 'id', '=', $id ] ]);
|
||||
return $this->response($info);
|
||||
}
|
||||
}
|
||||
@@ -1,55 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\system\User as UserModel;
|
||||
use app\model\web\Config as ConfigModel;
|
||||
|
||||
class Register extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 用户名密码注册
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$config_model = new ConfigModel();
|
||||
$config_info = $config_model->getCaptchaConfig();
|
||||
$config = $config_info[ 'data' ][ 'value' ];
|
||||
|
||||
$register = new UserModel();
|
||||
|
||||
if (empty($this->params[ "username" ])) return $this->response($this->error([], "用户名不可为空!"));
|
||||
if (empty($this->params[ "password" ])) return $this->response($this->error([], "密码不可为空!"));
|
||||
|
||||
// 校验验证码
|
||||
if ($config[ "shop_login" ] == 1) {
|
||||
$captcha = new Captcha();
|
||||
$check_res = $captcha->checkCaptcha();
|
||||
if ($check_res[ 'code' ] < 0) return $this->response($check_res);
|
||||
}
|
||||
|
||||
$data[ 'username' ] = $this->params[ 'username' ];
|
||||
$data[ 'password' ] = $this->params[ 'password' ];
|
||||
$data[ 'app_module' ] = $this->app_module;
|
||||
$data[ 'site_id' ] = 0;
|
||||
|
||||
$res = $register->addUser($data);
|
||||
|
||||
//生成access_token
|
||||
if ($res[ 'code' ] >= 0) {
|
||||
$token = $this->createToken($res[ 'data' ]);
|
||||
return $this->response($this->success([ 'token' => $token, 'site_id' => $res[ 'data' ][ 'site_id' ] ]));
|
||||
}
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\system\User as UserModel;
|
||||
use app\model\web\Config as ConfigModel;
|
||||
|
||||
class Register extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 用户名密码注册
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$config_model = new ConfigModel();
|
||||
$config_info = $config_model->getCaptchaConfig();
|
||||
$config = $config_info[ 'data' ][ 'value' ];
|
||||
|
||||
$register = new UserModel();
|
||||
|
||||
if (empty($this->params[ "username" ])) return $this->response($this->error([], "用户名不可为空!"));
|
||||
if (empty($this->params[ "password" ])) return $this->response($this->error([], "密码不可为空!"));
|
||||
|
||||
// 校验验证码
|
||||
if ($config[ "shop_login" ] == 1) {
|
||||
$captcha = new Captcha();
|
||||
$check_res = $captcha->checkCaptcha();
|
||||
if ($check_res[ 'code' ] < 0) return $this->response($check_res);
|
||||
}
|
||||
|
||||
$data[ 'username' ] = $this->params[ 'username' ];
|
||||
$data[ 'password' ] = $this->params[ 'password' ];
|
||||
$data[ 'app_module' ] = $this->app_module;
|
||||
$data[ 'site_id' ] = 0;
|
||||
|
||||
$res = $register->addUser($data);
|
||||
|
||||
//生成access_token
|
||||
if ($res[ 'code' ] >= 0) {
|
||||
$token = $this->createToken($res[ 'data' ]);
|
||||
return $this->response($this->success([ 'token' => $token, 'site_id' => $res[ 'data' ][ 'site_id' ] ]));
|
||||
}
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,242 +1,234 @@
|
||||
<?php
|
||||
/**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\store\Store as StoreModel;
|
||||
use app\model\system\Address as AddressModel;
|
||||
use app\model\web\Config as ConfigModel;
|
||||
|
||||
/**
|
||||
* 门店
|
||||
* Class Store
|
||||
* @package app\shop\controller
|
||||
*/
|
||||
class Store extends BaseApi
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//执行父类构造函数
|
||||
parent::__construct();
|
||||
$token = $this->checkToken();
|
||||
if ($token['code'] < 0) {
|
||||
echo $this->response($token);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 门店列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
//判断门店插件是否存在
|
||||
$store_is_exit = addon_is_exit('store', $this->site_id);
|
||||
if ($store_is_exit) {
|
||||
$store_model = new StoreModel();
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
$order = $this->params['order'] ?? "create_time desc";
|
||||
$keyword = $this->params['keyword'] ?? '';
|
||||
$status = $this->params['status'] ?? '';
|
||||
$type = $this->params['type'] ?? '';
|
||||
$condition = [];
|
||||
if ($type == 1) {
|
||||
if ($status != null) {
|
||||
$condition[] = ['status', '=', $status];
|
||||
$condition[] = ['is_frozen', '=', 0];
|
||||
}
|
||||
} else if ($type == 2) {
|
||||
$condition[] = ['is_frozen', '=', $status];
|
||||
}
|
||||
$condition[] = ['site_id', "=", $this->site_id];
|
||||
//关键字查询
|
||||
if (!empty($keyword)) {
|
||||
$condition[] = ["store_name", "like", "%" . $keyword . "%"];
|
||||
}
|
||||
$list = $store_model->getStorePageList($condition, $page, $page_size, $order);
|
||||
return $this->response($list);
|
||||
} else {
|
||||
return $this->response($this->success('', '请联系管理员安装插件!'));
|
||||
}
|
||||
}
|
||||
|
||||
public function detail(){
|
||||
$store_id = $this->params['store_id'] ?? 0;
|
||||
$condition = array(
|
||||
["site_id", "=", $this->site_id],
|
||||
["store_id", "=", $store_id]
|
||||
);
|
||||
$store_model = new StoreModel();
|
||||
$info_result = $store_model->getStoreInfo($condition);//门店信息
|
||||
$info = $info_result["data"];
|
||||
$data["info"] = $info;
|
||||
$is_exit = addon_is_exit("store");
|
||||
$config_model = new ConfigModel();
|
||||
$mp_config = $config_model->getMapConfig($this->site_id);
|
||||
$data["info"] = $info;
|
||||
$data["is_exit"] = $is_exit;
|
||||
$data["http_type"] = get_http_type();
|
||||
$data["tencent_map_key"] = $mp_config['data']['value']['tencent_map_key'];
|
||||
return $this->response($this->success($data));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加门店
|
||||
* @return mixed
|
||||
*/
|
||||
public function addStore()
|
||||
{
|
||||
$is_store = addon_is_exit('store');
|
||||
$store_name = $this->params['store_name'] ?: '';
|
||||
$telphone = $this->params['telphone'] ?: '';
|
||||
$store_image = $this->params['store_image'] ?: '';
|
||||
$status = $this->params['status'] ?: 0;
|
||||
$province_id = $this->params['province_id'] ?: 0;
|
||||
$city_id = $this->params['city_id'] ?: 0;
|
||||
$district_id = $this->params['district_id'] ?: 0;
|
||||
$community_id = $this->params['community_id'] ?: 0;
|
||||
$address = $this->params['address'] ?: '';
|
||||
$full_address = $this->params['full_address'] ?: '';
|
||||
$longitude = $this->params['longitude'] ?: 0;
|
||||
$latitude = $this->params['latitude'] ?: 0;
|
||||
$is_pickup = $this->params['is_pickup'] ?: 0;
|
||||
$is_o2o = $this->params['is_o2o'] ?: 0;
|
||||
$open_date = $this->params['open_date'] ?: '';
|
||||
$data = array(
|
||||
"store_name" => $store_name,
|
||||
"telphone" => $telphone,
|
||||
"store_image" => $store_image,
|
||||
"status" => $status,
|
||||
"province_id" => $province_id,
|
||||
"city_id" => $city_id,
|
||||
"district_id" => $district_id,
|
||||
"community_id" => $community_id,
|
||||
"address" => $address,
|
||||
"full_address" => $full_address,
|
||||
"longitude" => $longitude,
|
||||
"latitude" => $latitude,
|
||||
"is_pickup" => $is_pickup,
|
||||
"is_o2o" => $is_o2o,
|
||||
"open_date" => $open_date,
|
||||
"site_id" => $this->site_id
|
||||
);
|
||||
//判断是否开启多门店
|
||||
if ($is_store == 1) {
|
||||
$user_data = [
|
||||
'username' => $this->params['username'] ?? '',
|
||||
'password' => data_md5($this->params['password'] ?? ''),
|
||||
];
|
||||
} else {
|
||||
$user_data = [];
|
||||
}
|
||||
$store_model = new StoreModel();
|
||||
$result = $store_model->addStore($data, $user_data, $is_store);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑门店
|
||||
* @return mixed
|
||||
*/
|
||||
public function editStore()
|
||||
{
|
||||
|
||||
$store_id = $this->params['store_id'] ?? 0;
|
||||
$condition = array(
|
||||
["site_id", "=", $this->site_id],
|
||||
["store_id", "=", $store_id]
|
||||
);
|
||||
$store_model = new StoreModel();
|
||||
$store_name = $this->params['store_name'] ?? 0;
|
||||
$telphone = $this->params['telphone'] ?? '';
|
||||
$store_image = $this->params['store_image'] ?? '';
|
||||
$status = $this->params['status'] ?? 0;
|
||||
$province_id = $this->params['province_id'] ?? 0;
|
||||
$city_id = $this->params['city_id'] ?? 0;
|
||||
$district_id = $this->params['district_id'] ?? 0;
|
||||
$community_id = $this->params['community_id'] ?? 0;
|
||||
$address = $this->params['address'] ?? '';
|
||||
$full_address = $this->params['full_address'] ?? '';
|
||||
$longitude = $this->params['longitude'] ?? 0;
|
||||
$latitude = $this->params['latitude'] ?? 0;
|
||||
$is_pickup = $this->params['is_pickup'] ?? 0;
|
||||
$is_o2o = $this->params['is_o2o'] ?? 0;
|
||||
$open_date = $this->params['open_date'] ?? '';
|
||||
$data = array(
|
||||
"store_name" => $store_name,
|
||||
"telphone" => $telphone,
|
||||
"store_image" => $store_image,
|
||||
"status" => $status,
|
||||
"province_id" => $province_id,
|
||||
"city_id" => $city_id,
|
||||
"district_id" => $district_id,
|
||||
"community_id" => $community_id,
|
||||
"address" => $address,
|
||||
"full_address" => $full_address,
|
||||
"longitude" => $longitude,
|
||||
"latitude" => $latitude,
|
||||
"is_pickup" => $is_pickup,
|
||||
"is_o2o" => $is_o2o,
|
||||
"open_date" => $open_date,
|
||||
);
|
||||
$result = $store_model->editStore($data, $condition);
|
||||
return $this->response($result);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除门店
|
||||
* @return mixed
|
||||
*/
|
||||
public function deleteStore()
|
||||
{
|
||||
$store_id = $this->params["store_id"] ?? '0';
|
||||
$condition = array(
|
||||
["site_id", "=", $this->site_id],
|
||||
["store_id", "=", $store_id]
|
||||
);
|
||||
$store_model = new StoreModel();
|
||||
$result = $store_model->deleteStore($condition);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 冻结门店
|
||||
* @return array
|
||||
*/
|
||||
public function frozenStore()
|
||||
{
|
||||
$store_id = $this->params['store_id'] ?? '0';
|
||||
$is_frozen = $this->params['is_frozen'] ?? '0';
|
||||
$condition = [
|
||||
["site_id", "=", $this->site_id],
|
||||
["store_id", "=", $store_id]
|
||||
];
|
||||
$store_model = new StoreModel();
|
||||
$res = $store_model->frozenStore($condition, $is_frozen);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
*/
|
||||
public function modifyPassword()
|
||||
{
|
||||
$store_id = $this->params['store_id'] ?? '0';
|
||||
$password = $this->params['password'] ?? '123456';
|
||||
$store_model = new StoreModel();
|
||||
$data = $store_model->resetStorePassword($password, [['store_id', '=', $store_id]]);
|
||||
return $this->response($data);
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\store\Store as StoreModel;
|
||||
use app\model\system\Address as AddressModel;
|
||||
use app\model\web\Config as ConfigModel;
|
||||
|
||||
/**
|
||||
* 门店
|
||||
* Class Store
|
||||
* @package app\shop\controller
|
||||
*/
|
||||
class Store extends BaseApi
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//执行父类构造函数
|
||||
parent::__construct();
|
||||
$token = $this->checkToken();
|
||||
if ($token['code'] < 0) {
|
||||
echo $this->response($token);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 门店列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
//判断门店插件是否存在
|
||||
$store_is_exit = addon_is_exit('store', $this->site_id);
|
||||
if ($store_is_exit) {
|
||||
$store_model = new StoreModel();
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
$order = $this->params['order'] ?? "create_time desc";
|
||||
$keyword = $this->params['keyword'] ?? '';
|
||||
$status = $this->params['status'] ?? '';
|
||||
$type = $this->params['type'] ?? '';
|
||||
$condition = [];
|
||||
if ($type == 1) {
|
||||
if ($status != null) {
|
||||
$condition[] = ['status', '=', $status];
|
||||
$condition[] = ['is_frozen', '=', 0];
|
||||
}
|
||||
} else if ($type == 2) {
|
||||
$condition[] = ['is_frozen', '=', $status];
|
||||
}
|
||||
$condition[] = ['site_id', "=", $this->site_id];
|
||||
//关键字查询
|
||||
if (!empty($keyword)) {
|
||||
$condition[] = ["store_name", "like", "%" . $keyword . "%"];
|
||||
}
|
||||
$list = $store_model->getStorePageList($condition, $page, $page_size, $order);
|
||||
return $this->response($list);
|
||||
} else {
|
||||
return $this->response($this->success('', '请联系管理员安装插件!'));
|
||||
}
|
||||
}
|
||||
|
||||
public function detail(){
|
||||
$store_id = $this->params['store_id'] ?? 0;
|
||||
$condition = array(
|
||||
["site_id", "=", $this->site_id],
|
||||
["store_id", "=", $store_id]
|
||||
);
|
||||
$store_model = new StoreModel();
|
||||
$info_result = $store_model->getStoreInfo($condition);//门店信息
|
||||
$info = $info_result["data"];
|
||||
$data["info"] = $info;
|
||||
$is_exit = addon_is_exit("store");
|
||||
$config_model = new ConfigModel();
|
||||
$mp_config = $config_model->getMapConfig($this->site_id);
|
||||
$data["info"] = $info;
|
||||
$data["is_exit"] = $is_exit;
|
||||
$data["http_type"] = get_http_type();
|
||||
$data["tencent_map_key"] = $mp_config['data']['value']['tencent_map_key'];
|
||||
return $this->response($this->success($data));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加门店
|
||||
* @return mixed
|
||||
*/
|
||||
public function addStore()
|
||||
{
|
||||
$is_store = addon_is_exit('store');
|
||||
$store_name = $this->params['store_name'] ?: '';
|
||||
$telphone = $this->params['telphone'] ?: '';
|
||||
$store_image = $this->params['store_image'] ?: '';
|
||||
$status = $this->params['status'] ?: 0;
|
||||
$province_id = $this->params['province_id'] ?: 0;
|
||||
$city_id = $this->params['city_id'] ?: 0;
|
||||
$district_id = $this->params['district_id'] ?: 0;
|
||||
$community_id = $this->params['community_id'] ?: 0;
|
||||
$address = $this->params['address'] ?: '';
|
||||
$full_address = $this->params['full_address'] ?: '';
|
||||
$longitude = $this->params['longitude'] ?: 0;
|
||||
$latitude = $this->params['latitude'] ?: 0;
|
||||
$is_pickup = $this->params['is_pickup'] ?: 0;
|
||||
$is_o2o = $this->params['is_o2o'] ?: 0;
|
||||
$open_date = $this->params['open_date'] ?: '';
|
||||
$data = array(
|
||||
"store_name" => $store_name,
|
||||
"telphone" => $telphone,
|
||||
"store_image" => $store_image,
|
||||
"status" => $status,
|
||||
"province_id" => $province_id,
|
||||
"city_id" => $city_id,
|
||||
"district_id" => $district_id,
|
||||
"community_id" => $community_id,
|
||||
"address" => $address,
|
||||
"full_address" => $full_address,
|
||||
"longitude" => $longitude,
|
||||
"latitude" => $latitude,
|
||||
"is_pickup" => $is_pickup,
|
||||
"is_o2o" => $is_o2o,
|
||||
"open_date" => $open_date,
|
||||
"site_id" => $this->site_id
|
||||
);
|
||||
//判断是否开启多门店
|
||||
if ($is_store == 1) {
|
||||
$user_data = [
|
||||
'username' => $this->params['username'] ?? '',
|
||||
'password' => data_md5($this->params['password'] ?? ''),
|
||||
];
|
||||
} else {
|
||||
$user_data = [];
|
||||
}
|
||||
$store_model = new StoreModel();
|
||||
$result = $store_model->addStore($data, $user_data, $is_store);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑门店
|
||||
* @return mixed
|
||||
*/
|
||||
public function editStore()
|
||||
{
|
||||
|
||||
$store_id = $this->params['store_id'] ?? 0;
|
||||
$condition = array(
|
||||
["site_id", "=", $this->site_id],
|
||||
["store_id", "=", $store_id]
|
||||
);
|
||||
$store_model = new StoreModel();
|
||||
$store_name = $this->params['store_name'] ?? 0;
|
||||
$telphone = $this->params['telphone'] ?? '';
|
||||
$store_image = $this->params['store_image'] ?? '';
|
||||
$status = $this->params['status'] ?? 0;
|
||||
$province_id = $this->params['province_id'] ?? 0;
|
||||
$city_id = $this->params['city_id'] ?? 0;
|
||||
$district_id = $this->params['district_id'] ?? 0;
|
||||
$community_id = $this->params['community_id'] ?? 0;
|
||||
$address = $this->params['address'] ?? '';
|
||||
$full_address = $this->params['full_address'] ?? '';
|
||||
$longitude = $this->params['longitude'] ?? 0;
|
||||
$latitude = $this->params['latitude'] ?? 0;
|
||||
$is_pickup = $this->params['is_pickup'] ?? 0;
|
||||
$is_o2o = $this->params['is_o2o'] ?? 0;
|
||||
$open_date = $this->params['open_date'] ?? '';
|
||||
$data = array(
|
||||
"store_name" => $store_name,
|
||||
"telphone" => $telphone,
|
||||
"store_image" => $store_image,
|
||||
"status" => $status,
|
||||
"province_id" => $province_id,
|
||||
"city_id" => $city_id,
|
||||
"district_id" => $district_id,
|
||||
"community_id" => $community_id,
|
||||
"address" => $address,
|
||||
"full_address" => $full_address,
|
||||
"longitude" => $longitude,
|
||||
"latitude" => $latitude,
|
||||
"is_pickup" => $is_pickup,
|
||||
"is_o2o" => $is_o2o,
|
||||
"open_date" => $open_date,
|
||||
);
|
||||
$result = $store_model->editStore($data, $condition);
|
||||
return $this->response($result);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除门店
|
||||
* @return mixed
|
||||
*/
|
||||
public function deleteStore()
|
||||
{
|
||||
$store_id = $this->params["store_id"] ?? '0';
|
||||
$condition = array(
|
||||
["site_id", "=", $this->site_id],
|
||||
["store_id", "=", $store_id]
|
||||
);
|
||||
$store_model = new StoreModel();
|
||||
$result = $store_model->deleteStore($condition);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 冻结门店
|
||||
* @return array
|
||||
*/
|
||||
public function frozenStore()
|
||||
{
|
||||
$store_id = $this->params['store_id'] ?? '0';
|
||||
$is_frozen = $this->params['is_frozen'] ?? '0';
|
||||
$condition = [
|
||||
["site_id", "=", $this->site_id],
|
||||
["store_id", "=", $store_id]
|
||||
];
|
||||
$store_model = new StoreModel();
|
||||
$res = $store_model->frozenStore($condition, $is_frozen);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
*/
|
||||
public function modifyPassword()
|
||||
{
|
||||
$store_id = $this->params['store_id'] ?? '0';
|
||||
$password = $this->params['password'] ?? '123456';
|
||||
$store_model = new StoreModel();
|
||||
$data = $store_model->resetStorePassword($password, [['store_id', '=', $store_id]]);
|
||||
return $this->response($data);
|
||||
}
|
||||
}
|
||||
@@ -1,86 +1,78 @@
|
||||
<?php
|
||||
/**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\upload\Album;
|
||||
use app\model\upload\Upload as UploadModel;
|
||||
|
||||
/**
|
||||
* 上传管理
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
class Upload extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 头像上传
|
||||
*/
|
||||
public function image()
|
||||
{
|
||||
$upload_model = new UploadModel($this->site_id);
|
||||
$param = array (
|
||||
"thumb_type" => "",
|
||||
"name" => "file"
|
||||
);
|
||||
$path = $this->site_id > 0 ? "common/images/" . date("Ymd") . '/' : "common/images/" . date("Ymd") . '/';
|
||||
$result = $upload_model->setPath($path)->image($param);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传 存入相册
|
||||
*/
|
||||
public function album()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$album_id = $this->params['album_id'] ?? 0;
|
||||
|
||||
$upload_model = new UploadModel($this->site_id);
|
||||
|
||||
$album_model = new Album();
|
||||
$album_info = $album_model->getAlbumInfo([
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'is_default', '=', 1 ]
|
||||
], 'album_id')[ 'data' ];
|
||||
if (empty($album_id)) {
|
||||
$album_id = $album_info[ 'album_id' ];
|
||||
}
|
||||
|
||||
$param = array (
|
||||
"thumb_type" => [ "BIG", "MID", "SMALL" ],
|
||||
"name" => "file",
|
||||
"album_id" => $album_id,
|
||||
"is_thumb" => 1
|
||||
);
|
||||
$result = $upload_model->setPath("common/images/" . date("Ymd") . '/')->imageToAlbum($param);
|
||||
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 视频上传
|
||||
* @return \multitype
|
||||
*/
|
||||
public function video()
|
||||
{
|
||||
$upload_model = new UploadModel($this->site_id);
|
||||
$name = input("name", "");
|
||||
$param = array (
|
||||
"name" => "file"
|
||||
);
|
||||
$result = $upload_model->setPath("common/video/" . date("Ymd") . '/')->video($param);
|
||||
return $result;
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\upload\Album;
|
||||
use app\model\upload\Upload as UploadModel;
|
||||
|
||||
/**
|
||||
* 上传管理
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
class Upload extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 头像上传
|
||||
*/
|
||||
public function image()
|
||||
{
|
||||
$upload_model = new UploadModel($this->site_id);
|
||||
$param = array (
|
||||
"thumb_type" => "",
|
||||
"name" => "file"
|
||||
);
|
||||
$path = $this->site_id > 0 ? "common/images/" . date("Ymd") . '/' : "common/images/" . date("Ymd") . '/';
|
||||
$result = $upload_model->setPath($path)->image($param);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传 存入相册
|
||||
*/
|
||||
public function album()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$album_id = $this->params['album_id'] ?? 0;
|
||||
|
||||
$upload_model = new UploadModel($this->site_id);
|
||||
|
||||
$album_model = new Album();
|
||||
$album_info = $album_model->getAlbumInfo([
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'is_default', '=', 1 ]
|
||||
], 'album_id')[ 'data' ];
|
||||
if (empty($album_id)) {
|
||||
$album_id = $album_info[ 'album_id' ];
|
||||
}
|
||||
|
||||
$param = array (
|
||||
"thumb_type" => [ "BIG", "MID", "SMALL" ],
|
||||
"name" => "file",
|
||||
"album_id" => $album_id,
|
||||
"is_thumb" => 1
|
||||
);
|
||||
$result = $upload_model->setPath("common/images/" . date("Ymd") . '/')->imageToAlbum($param);
|
||||
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 视频上传
|
||||
* @return \multitype
|
||||
*/
|
||||
public function video()
|
||||
{
|
||||
$upload_model = new UploadModel($this->site_id);
|
||||
$name = input("name", "");
|
||||
$param = array (
|
||||
"name" => "file"
|
||||
);
|
||||
$result = $upload_model->setPath("common/video/" . date("Ymd") . '/')->video($param);
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user