初始上传
This commit is contained in:
230
app/shopapi/controller/Account.php
Executable file
230
app/shopapi/controller/Account.php
Executable file
@@ -0,0 +1,230 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use addon\fenxiao\model\FenxiaoData;
|
||||
use app\model\member\Withdraw;
|
||||
use app\model\order\Order as OrderModel;
|
||||
use app\model\order\OrderCommon as OrderCommonModel;
|
||||
use app\model\order\OrderRefund;
|
||||
use app\model\shop\Shop as ShopModel;
|
||||
use app\model\shop\ShopAccount;
|
||||
use app\model\shop\ShopOpenAccount;
|
||||
use app\model\shop\ShopReopen as ShopReopenModel;
|
||||
use app\model\shop\ShopSettlement;
|
||||
use app\model\web\Account as AccountModel;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class Account extends BaseApi
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//执行父类构造函数
|
||||
parent::__construct();
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) {
|
||||
echo json_encode($token);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 资产概况
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$shop_model = new ShopModel();
|
||||
$shop_account_model = new ShopAccount();
|
||||
|
||||
$data = [];
|
||||
//获取商家转账设置
|
||||
$shop_withdraw_config = $shop_account_model->getShopWithdrawConfig();
|
||||
$data[ 'shop_withdraw_config' ] = $shop_withdraw_config[ 'data' ][ 'value' ];//商家转账设置
|
||||
|
||||
//获取店铺的账户信息
|
||||
$condition = array (
|
||||
['site_id', '=', $this->site_id ]
|
||||
);
|
||||
$shop_info = $shop_model->getShopInfo($condition, 'site_name,logo,account, account_withdraw,account_withdraw_apply,shop_open_fee,shop_baozhrmb')[ 'data' ];
|
||||
$data[ 'shop_info' ] = $shop_info;
|
||||
|
||||
//余额
|
||||
$account = $shop_info[ 'account' ] - $shop_info[ 'account_withdraw_apply' ];
|
||||
$data[ 'account' ] = number_format($account, 2, '.', '');
|
||||
|
||||
//累计收入
|
||||
$total = $shop_info[ 'account' ] + $shop_info[ 'account_withdraw' ];
|
||||
$data[ 'total' ] = number_format($total, 2, '.', '');
|
||||
|
||||
//已提现
|
||||
$data[ 'account_withdraw' ] = number_format($shop_info[ 'account_withdraw' ], 2, '.', '');
|
||||
|
||||
//提现中
|
||||
$data[ 'account_withdraw_apply' ] = number_format($shop_info[ 'account_withdraw_apply' ], 2, '.', '');
|
||||
|
||||
//获取店家结算账户信息
|
||||
$shop_cert_result = $shop_model->getShopCert($condition, 'bank_type, settlement_bank_account_name, settlement_bank_account_number, settlement_bank_name, settlement_bank_address');
|
||||
$data[ 'shop_cert_info' ] = $shop_cert_result[ 'data' ];//店家结算账户信息
|
||||
|
||||
//店铺的待结算金额
|
||||
$settlement_model = new ShopSettlement();
|
||||
$settlement_info = $settlement_model->getWaitSettlementInfo($this->site_id);
|
||||
$order_apply = $settlement_info[ 'shop_money' ] - $settlement_info[ 'refund_shop_money' ] - $settlement_info[ 'commission' ] + $settlement_info[ 'platform_coupon_money' ] - $settlement_info[ 'refund_platform_coupon_money' ];
|
||||
$data[ 'order_apply' ] = number_format($order_apply, 2, '.', '');
|
||||
|
||||
return $this->response($this->success($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 店铺账户面板
|
||||
*/
|
||||
public function dashboard()
|
||||
{
|
||||
$start_time = $this->params['start_time'] ?? Carbon::today()->timestamp;
|
||||
$end_time = $this->params['end_time'] ?? Carbon::tomorrow()->timestamp;
|
||||
|
||||
$data = [];
|
||||
// 收入
|
||||
$order_money = (new OrderModel())->getOrderMoneySum([ ['site_id', '=', $this->site_id], ['pay_time', 'between', [$start_time, $end_time] ], ['order_scene', '=', 'online'] ], 'pay_money')['data'];
|
||||
$income_data = [
|
||||
[
|
||||
'title' => '商城订单',
|
||||
'value' => $order_money,
|
||||
'desc' => '统计时间内,所有付款订单实付金额之和',
|
||||
'url' => 'shop/order/lists'
|
||||
]
|
||||
];
|
||||
$event = event('IncomeStatistics', ['site_id' => $this->site_id, 'start_time' => $start_time, 'end_time' => $end_time]);
|
||||
if (!empty($event)) $income_data = array_merge($income_data, ...$event);
|
||||
$data['total_income'] = array_sum(array_column($income_data, 'value'));
|
||||
$data['income_data'] = $income_data;
|
||||
// 支出
|
||||
$disburse_data = [
|
||||
[
|
||||
'title' => '订单退款',
|
||||
'value' => (new OrderRefund())->getRefundSum([ ['site_id', '=', $this->site_id], ['refund_money_type', '=', '1,2'], ['refund_time', 'between', [$start_time, $end_time] ] ], 'refund_pay_money')['data'],
|
||||
'desc' => '统计时间内,所有订单退款转账金额之和',
|
||||
'url' => 'shop/orderrefund/lists'
|
||||
],
|
||||
[
|
||||
'title' => '会员提现',
|
||||
'value' => (new Withdraw())->getMemberWithdrawSum([ ['site_id', '=', $this->site_id], ['payment_time', 'between', [$start_time, $end_time] ] ], 'apply_money')['data'],
|
||||
'desc' => '统计时间内,所有会员提现转账金额之和',
|
||||
'url' => 'shop/memberwithdraw/lists'
|
||||
]
|
||||
];
|
||||
$event = event('DisburseStatistics', ['site_id' => $this->site_id, 'start_time' => $start_time, 'end_time' => $end_time]);
|
||||
if (!empty($event)) $disburse_data = array_merge($disburse_data, ...$event);
|
||||
$data['total_disburse'] = array_sum(array_column($disburse_data, 'value'));
|
||||
$data['disburse_data'] = $disburse_data;
|
||||
|
||||
return $this->response($this->success($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 账户交易记录
|
||||
*/
|
||||
public function orderList()
|
||||
{
|
||||
$order_model = new OrderCommonModel();
|
||||
$condition[] = [ 'site_id', '=', $this->site_id ];
|
||||
|
||||
//下单时间
|
||||
$start_time = $this->params['start_time'] ?? '';
|
||||
$end_time = $this->params['end_time'] ?? '';
|
||||
|
||||
if (!empty($start_time) && empty($end_time)) {
|
||||
$condition[] = ['finish_time', '>=', $start_time ];
|
||||
} elseif (empty($start_time) && !empty($end_time)) {
|
||||
$condition[] = ['finish_time', '<=', $end_time ];
|
||||
} elseif (!empty($start_time) && !empty($end_time)) {
|
||||
$condition[] = [ 'finish_time', 'between', [ $start_time, $end_time ] ];
|
||||
}
|
||||
|
||||
//订单状态
|
||||
$order_status = $this->params['order_status'] ?? '';
|
||||
if ($order_status != '') {
|
||||
switch ( $order_status ) {
|
||||
case 1://进行中
|
||||
|
||||
$condition[] = ['order_status', 'not in', [ 0, -1, 10 ] ];
|
||||
$order = 'pay_time desc';
|
||||
break;
|
||||
case 2://待结算
|
||||
|
||||
$condition[] = ['order_status', '=', 10 ];
|
||||
$condition[] = ['is_settlement', '=', 0 ];
|
||||
$order = 'finish_time desc';
|
||||
break;
|
||||
case 3://已结算
|
||||
|
||||
$condition[] = ['order_status', '=', 10 ];
|
||||
$condition[] = ['settlement_id', '>', 0 ];
|
||||
$order = 'finish_time desc';
|
||||
break;
|
||||
case 4://全部
|
||||
$condition[] = ['order_status', 'not in', [ 0, -1 ] ];
|
||||
$order = 'pay_time desc';
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$condition[] = ['order_status', '=', 10 ];
|
||||
$condition[] = ['settlement_id', '=', 0 ];
|
||||
$order = 'finish_time desc';
|
||||
}
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
|
||||
$field = 'order_id,order_no,order_money,order_status_name,shop_money,platform_money,refund_money,refund_shop_money,refund_platform_money,commission,finish_time,settlement_id';
|
||||
$list = $order_model->getOrderPageList($condition, $page, $page_size, $order, $field);
|
||||
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单统计
|
||||
* @return false|string
|
||||
*/
|
||||
public function orderStat()
|
||||
{
|
||||
$data = [];
|
||||
//店铺的待结算金额
|
||||
$settlement_model = new ShopSettlement();
|
||||
$settlement_info = $settlement_model->getWaitSettlementInfo($this->site_id);
|
||||
$wait_settlement = $settlement_info[ 'shop_money' ] - $settlement_info[ 'refund_shop_money' ] - $settlement_info[ 'commission' ];
|
||||
$data[ 'wait_settlement' ] = number_format($wait_settlement, 2, '.', '');
|
||||
|
||||
//店铺的已结算金额
|
||||
$finish_condition = [
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'order_status', '=', 10 ],
|
||||
[ 'settlement_id', '>', 0 ]
|
||||
];
|
||||
$settlement_info = $settlement_model->getShopSettlementData($finish_condition);
|
||||
$finish_settlement = $settlement_info[ 'shop_money' ] - $settlement_info[ 'refund_shop_money' ] - $settlement_info[ 'commission' ];
|
||||
$data[ 'finish_settlement' ] = number_format($finish_settlement, 2, '.', '');
|
||||
|
||||
//店铺的进行中金额
|
||||
$settlement_condition = [
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'order_status', 'not in', [ 0, -1, 10 ] ]
|
||||
];
|
||||
$settlement_info = $settlement_model->getShopSettlementData($settlement_condition);
|
||||
$settlement = $settlement_info[ 'shop_money' ] - $settlement_info[ 'refund_shop_money' ] - $settlement_info[ 'commission' ];
|
||||
$data[ 'settlement' ] = number_format($settlement, 2, '.', '');
|
||||
|
||||
return $this->response($this->success($data));
|
||||
}
|
||||
|
||||
}
|
||||
51
app/shopapi/controller/Addon.php
Executable file
51
app/shopapi/controller/Addon.php
Executable file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
||||
76
app/shopapi/controller/Address.php
Executable file
76
app/shopapi/controller/Address.php
Executable file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
81
app/shopapi/controller/Album.php
Executable file
81
app/shopapi/controller/Album.php
Executable file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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 json_encode($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);
|
||||
}
|
||||
}
|
||||
377
app/shopapi/controller/BaseApi.php
Executable file
377
app/shopapi/controller/BaseApi.php
Executable file
@@ -0,0 +1,377 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
48
app/shopapi/controller/Captcha.php
Executable file
48
app/shopapi/controller/Captcha.php
Executable file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use think\captcha\facade\Captcha as ThinkCaptcha;
|
||||
use think\facade\Cache;
|
||||
|
||||
class Captcha extends BaseApi
|
||||
{
|
||||
/**
|
||||
* 验证码
|
||||
*/
|
||||
public function captcha()
|
||||
{
|
||||
if (isset($this->params['captcha_id']) && !empty($this->params['captcha_id'])) {
|
||||
Cache::delete($this->params['captcha_id']);
|
||||
}
|
||||
|
||||
$captcha_data = ThinkCaptcha::create(null, true);
|
||||
$captcha_id = md5(uniqid(null, true));
|
||||
// 验证码10分钟有效
|
||||
Cache::set($captcha_id, $captcha_data['code'], 600);
|
||||
return $this->response($this->success([ 'id' => $captcha_id, 'img' => $captcha_data['img'] ]));
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测验证码
|
||||
* @param boolean $snapchat 阅后即焚
|
||||
*/
|
||||
public function checkCaptcha($snapchat = true) : array
|
||||
{
|
||||
if (!isset($this->params['captcha_id']) || empty($this->params['captcha_id'])) {
|
||||
return $this->error('', 'REQUEST_CAPTCHA_ID');
|
||||
}
|
||||
|
||||
if (!isset($this->params['captcha_code']) || empty($this->params['captcha_code'])) {
|
||||
return $this->error('', 'REQUEST_CAPTCHA_CODE');
|
||||
}
|
||||
|
||||
if ($snapchat) $captcha_data = Cache::pull($this->params['captcha_id']);
|
||||
else $captcha_data = Cache::get($this->params['captcha_id']);
|
||||
if (empty($captcha_data)) return $this->error('', 'CAPTCHA_FAILURE');
|
||||
|
||||
if ($this->params['captcha_code'] != $captcha_data) return $this->error('', 'CAPTCHA_ERROR');
|
||||
|
||||
return $this->success();
|
||||
}
|
||||
}
|
||||
270
app/shopapi/controller/Cert.php
Executable file
270
app/shopapi/controller/Cert.php
Executable file
@@ -0,0 +1,270 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use addon\shopwithdraw\model\Config as ShopWithdrawConfig;
|
||||
use app\model\shop\ShopApply;
|
||||
use app\model\shop\ShopGroup as ShopGroupModel;
|
||||
use app\model\system\Promotion as PromotionModel;
|
||||
use app\model\web\WebSite as WebsiteModel;
|
||||
use app\model\shop\Config as ShopConfigModel;
|
||||
use app\model\shop\Shop as ShopModel;
|
||||
use app\model\shop\ShopReopen as ShopReopenModel;
|
||||
use app\model\system\Address as AddressModel;
|
||||
|
||||
|
||||
/**
|
||||
* 快捷开店认证
|
||||
* Class Cert
|
||||
* @package app\shop\controller
|
||||
*/
|
||||
class Cert extends BaseApi
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//执行父类构造函数
|
||||
parent::__construct();
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) {
|
||||
echo json_encode($token);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 认证首页
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$shop_group_model = new ShopGroupModel();
|
||||
$promotion_model = new PromotionModel();
|
||||
//插件
|
||||
$promotions = $promotion_model->getPromotions();
|
||||
$promotions = $promotions[ 'shop' ];
|
||||
//店铺等级
|
||||
$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;
|
||||
|
||||
//查询省级数据列表
|
||||
$address_model = new AddressModel();
|
||||
$list = $address_model->getAreaList([ ['pid', '=', 0 ], ['level', '=', 1 ] ]);
|
||||
$data[ 'province_list' ] = $list['data'];
|
||||
|
||||
$shop_apply_model = new ShopApply();
|
||||
$shop_apply_info = $shop_apply_model->getApplyDetail([ [ 'uid', '=', $this->uid ] ]);
|
||||
$data[ 'shop_apply_info' ] = $shop_apply_info[ 'data' ];
|
||||
|
||||
//商家信息
|
||||
$shop_apply_model = new ShopModel();
|
||||
$shop = $shop_apply_model->getShopInfo([ [ 'site_id', '=', $this->site_id ] ], 'site_id,site_name,category_id,category_name');
|
||||
$data[ 'shop_info' ] = $shop[ 'data' ];
|
||||
|
||||
//平台配置信息
|
||||
$website_model = new WebsiteModel();
|
||||
$website_info = $website_model->getWebSite([ [ 'site_id', '=', 0 ] ], 'web_qrcode,web_phone');
|
||||
$data[ 'website_info' ] = $website_info[ 'data' ];
|
||||
|
||||
//收款信息
|
||||
$shop_config_model = new ShopConfigModel();
|
||||
$receivable_config = $shop_config_model->getSystemBankAccount();
|
||||
$data[ 'receivable_config' ] = $receivable_config[ 'data' ];
|
||||
$data[ 'support_transfer_type' ] = $this->getTransferType();
|
||||
|
||||
return $this->response($this->success($data));
|
||||
}
|
||||
|
||||
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 $support_type;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 申请续签
|
||||
*/
|
||||
public function reopen()
|
||||
{
|
||||
if (request()->isPost()) {
|
||||
|
||||
$site_id = $this->site_id;
|
||||
$reopen_data = [
|
||||
'site_id' => $site_id,//店铺ID
|
||||
'apply_year' => $this->params['apply_year'] ?? '',//入驻年长
|
||||
'shop_group_name' => $this->params['shop_group_name'] ?? '',//开店套餐名称
|
||||
'shop_group_id' => $this->params['shop_group_id'] ?? 0,//开店套餐id
|
||||
'paying_money_certificate' => $this->params['paying_money_certificate'] ?? '',//支付凭证
|
||||
'paying_money_certificate_explain' => $this->params['paying_money_certificate_explain'] ?? '' //付款凭证说明
|
||||
];
|
||||
|
||||
$model = new ShopReopenModel();
|
||||
//计算入驻金额
|
||||
$apply_money = $model->getReopenMoney($reopen_data[ 'apply_year' ], $reopen_data[ 'shop_group_id' ]);
|
||||
$reopen_data[ 'paying_amount' ] = $apply_money[ 'data' ][ 'money' ];
|
||||
|
||||
$result = $model->addReopen($reopen_data);
|
||||
|
||||
return $this->response($result);
|
||||
} else {
|
||||
//获取店铺信息
|
||||
$condition[] = [ 'site_id', '=', $this->site_id ];
|
||||
$field = 'site_id,site_name,category_id,category_name,group_id,group_name';
|
||||
$shop_model = new ShopModel();
|
||||
$shop_info = $shop_model->getShopInfo($condition, $field);
|
||||
$data[ 'shop_info' ] = $shop_info[ 'data' ];
|
||||
|
||||
$shop_group_model = new ShopGroupModel();
|
||||
$promotion_model = new PromotionModel();
|
||||
//插件
|
||||
$promotions = $promotion_model->getPromotions();
|
||||
$promotions = $promotions[ 'shop' ];
|
||||
//店铺等级
|
||||
$shop_group = $shop_group_model->getGroupList([ [ 'is_own', '=', 0 ] ], '*', 'fee asc');
|
||||
$shop_group = $shop_group[ '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;
|
||||
|
||||
//平台配置信息
|
||||
$website_model = new WebsiteModel();
|
||||
$website_info = $website_model->getWebSite([ [ 'site_id', '=', 0 ] ], 'web_qrcode,web_phone');
|
||||
$data[ 'website_info' ] = $website_info[ 'data' ];
|
||||
|
||||
//收款信息
|
||||
$shop_config_model = new ShopConfigModel();
|
||||
$receivable_config = $shop_config_model->getSystemBankAccount();
|
||||
$data[ 'receivable_config' ] = $receivable_config[ 'data' ];
|
||||
|
||||
return $this->response($this->success($data));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑续签首页
|
||||
*/
|
||||
public function editReopenInfo()
|
||||
{
|
||||
$reopen_model = new ShopReopenModel();
|
||||
if (request()->isPost()) {
|
||||
$site_id = $this->site_id;
|
||||
$reopen_data = [
|
||||
'id' => $this->params['id'] ?? '',
|
||||
'site_id' => $site_id,//店铺ID
|
||||
'paying_money_certificate' => $this->params['paying_money_certificate'] ?? '',//支付凭证
|
||||
'paying_money_certificate_explain' => $this->params['paying_money_certificate_explain'] ?? '' //付款凭证说明
|
||||
];
|
||||
|
||||
$result = $reopen_model->editReopen($reopen_data);
|
||||
|
||||
return $this->response($result);
|
||||
} else {
|
||||
//获取店铺信息
|
||||
$condition[] = [ 'site_id', '=', $this->site_id ];
|
||||
$apply_model = new ShopModel();
|
||||
$field = 'site_id,site_name,category_id,category_name,group_id,group_name';
|
||||
$shop_info = $apply_model->getShopInfo($condition, $field);
|
||||
$data[ 'shop_info' ] = $shop_info[ 'data' ];
|
||||
|
||||
$shop_group_model = new ShopGroupModel();
|
||||
$promotion_model = new PromotionModel();
|
||||
//插件
|
||||
$promotions = $promotion_model->getPromotions();
|
||||
$promotions = $promotions[ 'shop' ];
|
||||
//店铺等级
|
||||
$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;
|
||||
|
||||
//平台配置信息
|
||||
$website_model = new WebsiteModel();
|
||||
$website_info = $website_model->getWebSite([ [ 'site_id', '=', 0 ] ], 'web_qrcode,web_phone');
|
||||
$data[ 'website_info' ] = $website_info[ 'data' ];
|
||||
|
||||
//收款信息
|
||||
$shop_config_model = new ShopConfigModel();
|
||||
$receivable_config = $shop_config_model->getSystemBankAccount();
|
||||
$data[ 'receivable_config' ] = $receivable_config[ 'data' ];
|
||||
|
||||
//获取续签信息
|
||||
$reopen_info = $reopen_model->getReopenInfo([ [ 'sr.apply_state', 'in', '-1,1' ], [ 'sr.site_id', '=', $this->site_id ] ], '*');
|
||||
$data[ 'reopen_info' ] = $reopen_info[ 'data' ];
|
||||
|
||||
return $this->response($this->success($data));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
52
app/shopapi/controller/Config.php
Executable file
52
app/shopapi/controller/Config.php
Executable file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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' ]));
|
||||
}
|
||||
|
||||
}
|
||||
60
app/shopapi/controller/Express.php
Executable file
60
app/shopapi/controller/Express.php
Executable file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\express\ExpressCompany;
|
||||
use app\model\express\ExpressTemplate as ExpressTemplateModel;
|
||||
|
||||
/**
|
||||
* 配送
|
||||
* Class Express
|
||||
* @package app\shop\controller
|
||||
*/
|
||||
class Express extends BaseApi
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//执行父类构造函数
|
||||
parent::__construct();
|
||||
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) {
|
||||
echo json_encode($token);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取运费模板
|
||||
* @return false|string
|
||||
*/
|
||||
public function getExpressTemplateList()
|
||||
{
|
||||
$express_template_model = new ExpressTemplateModel();
|
||||
$express_template_list = $express_template_model->getExpressTemplateList([ [ 'site_id', "=", $this->site_id ] ], 'template_id,template_name', 'is_default desc');
|
||||
return $this->response($express_template_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 物流公司
|
||||
* @return mixed
|
||||
*/
|
||||
public function expressCompany()
|
||||
{
|
||||
$express_company_model = new ExpressCompany();
|
||||
$company_list_result = $express_company_model->getExpressCompanyList([ [ "site_id", "=", $this->site_id ] ]);
|
||||
return $this->response($company_list_result);
|
||||
}
|
||||
|
||||
}
|
||||
831
app/shopapi/controller/Goods.php
Executable file
831
app/shopapi/controller/Goods.php
Executable file
@@ -0,0 +1,831 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\express\ExpressTemplate as ExpressTemplateModel;
|
||||
use app\model\goods\Goods as GoodsModel;
|
||||
use app\model\goods\GoodsAttribute as GoodsAttributeModel;
|
||||
use app\model\goods\GoodsBrowse;
|
||||
use app\model\goods\GoodsCategory as GoodsCategoryModel;
|
||||
use app\model\goods\GoodsCollect;
|
||||
use app\model\goods\GoodsEvaluate as GoodsEvaluateModel;
|
||||
use app\model\web\Config as ConfigModel;
|
||||
|
||||
/**
|
||||
* 实物商品
|
||||
* Class Goods
|
||||
* @package app\shop\controller
|
||||
*/
|
||||
class Goods extends BaseApi
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//执行父类构造函数
|
||||
parent::__construct();
|
||||
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) {
|
||||
echo json_encode($token);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品条件
|
||||
* @return false|string
|
||||
*/
|
||||
public function condition()
|
||||
{
|
||||
$data = [];
|
||||
// 营销活动
|
||||
$goods_promotion_type = event('GoodsPromotionType');
|
||||
$data[ 'goods_promotion_type' ] = $goods_promotion_type;
|
||||
|
||||
return $this->response($this->success($data));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 商品列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$goods_model = new GoodsModel();
|
||||
|
||||
$page_index = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
|
||||
$search_text = $this->params['search_text'] ?? '';
|
||||
$goods_state = $this->params['goods_state'] ?? '';
|
||||
$start_sale = $this->params['start_sale'] ?? 0;
|
||||
$end_sale = $this->params['end_sale'] ?? 0;
|
||||
$start_price = $this->params['start_price'] ?? 0;
|
||||
$end_price = $this->params['end_price'] ?? 0;
|
||||
$goods_shop_category_ids = $this->params['goods_shop_category_ids'] ?? '';
|
||||
$goods_class = $this->params['goods_class'] ?? '';
|
||||
$order = $this->params['order'] ?? 'create_time';
|
||||
$sort = $this->params['sort'] ?? 'desc';
|
||||
$promotion_type = $this->params['promotion_type'] ?? '';
|
||||
$stockalarm = $this->params[ 'stockalarm' ] ?? 0;
|
||||
$order_by = $order . ' ' . $sort;
|
||||
|
||||
$condition = [ [ 'is_delete', '=', 0 ], [ 'site_id', '=', $this->site_id ] ];
|
||||
|
||||
//名称和条码都可以搜索
|
||||
if (!empty($search_text)) {
|
||||
//$condition[] = [ 'goods_name', 'like', '%' . $search_text . '%' ];
|
||||
$sql = "goods_name like '%{$search_text}%'";
|
||||
$goods_sku_list = $goods_model->getGoodsSkuList([['sku_no', 'like', '%' . $search_text . '%']], 'goods_id')[ 'data' ];
|
||||
if(!empty($goods_sku_list)){
|
||||
$goods_id_arr = array_unique(array_column($goods_sku_list, 'goods_id'));
|
||||
$sql .= " or goods_id in (".join(',', $goods_id_arr).")";
|
||||
}
|
||||
$condition[] = ['', 'exp', \think\facade\Db::raw($sql)];
|
||||
}
|
||||
|
||||
if ($goods_class !== "") {
|
||||
$condition[] = [ 'goods_class', '=', $goods_class ];
|
||||
}
|
||||
|
||||
// 上架状态
|
||||
if ($goods_state !== '') {
|
||||
$condition[] = [ 'goods_state', '=', $goods_state ];
|
||||
}
|
||||
//参与活动
|
||||
if (!empty($promotion_type)) {
|
||||
$condition[] = [ 'promotion_addon', 'like', "%{$promotion_type}%" ];
|
||||
}
|
||||
|
||||
// 查询库存预警的商品
|
||||
if ($stockalarm) {
|
||||
$stock_alarm = $goods_model->getGoodsStockAlarm($this->site_id);
|
||||
if (!empty($stock_alarm[ 'data' ])) $condition[] = [ 'goods_id', 'in', $stock_alarm[ 'data' ] ];
|
||||
else return $this->response($this->success([ 'page_count' => 1, 'count' => 0, 'list' => [] ]));
|
||||
}
|
||||
|
||||
if (!empty($start_sale)) $condition[] = [ 'sale_num', '>=', $start_sale ];
|
||||
if (!empty($end_sale)) $condition[] = [ 'sale_num', '<=', $end_sale ];
|
||||
if (!empty($start_price)) $condition[] = [ 'price', '>=', $start_price ];
|
||||
if (!empty($end_price)) $condition[] = [ 'price', '<=', $end_price ];
|
||||
if (!empty($goods_shop_category_ids)) $condition[] = [ 'goods_shop_category_ids', 'like', [ $goods_shop_category_ids, '%' . $goods_shop_category_ids . ',%', '%' . $goods_shop_category_ids, '%,' . $goods_shop_category_ids . ',%' ], 'or' ];
|
||||
|
||||
$res = $goods_model->getGoodsPageList($condition, $page_index, $page_size, $order_by);
|
||||
|
||||
if (!empty($res[ 'data' ][ 'list' ])) {
|
||||
$goods_promotion_type = event('GoodsPromotionType');
|
||||
foreach ($res[ 'data' ][ 'list' ] as $k => $v) {
|
||||
if (!empty($v[ 'promotion_addon' ])) {
|
||||
$v[ 'promotion_addon' ] = json_decode($v[ 'promotion_addon' ], true);
|
||||
foreach ($v[ 'promotion_addon' ] as $ck => $cv) {
|
||||
foreach ($goods_promotion_type as $gk => $gv) {
|
||||
if ($gv[ 'type' ] == $ck) {
|
||||
$res[ 'data' ][ 'list' ][ $k ][ 'promotion_addon_list' ][] = $gv;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->response($res);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加商品
|
||||
* @return mixed
|
||||
*/
|
||||
public function addGoods()
|
||||
{
|
||||
$data = [
|
||||
'goods_name' => $this->params['goods_name'] ?? '',// 商品名称,
|
||||
'goods_attr_class' => $this->params['goods_attr_class'] ?? '',// 商品类型id,
|
||||
'goods_attr_name' => $this->params['goods_attr_name'] ?? '',// 商品类型名称,
|
||||
'site_id' => $this->site_id,
|
||||
'category_id' => $this->params[ 'category_id' ] ?? '',
|
||||
'category_json' => $this->params[ 'category_json' ] ?? '',
|
||||
'goods_image' => $this->params['goods_image'] ?? '',// 商品主图路径
|
||||
'goods_content' => $this->params['goods_content'] ?? '',// 商品详情
|
||||
'goods_state' => $this->params['goods_state'] ?? '',// 商品状态(1.正常0下架)
|
||||
'price' => $this->params['price'] ?? 0,// 商品价格(取第一个sku)
|
||||
'market_price' => $this->params['market_price'] ?? '',// 市场价格(取第一个sku)
|
||||
'cost_price' => $this->params['cost_price'] ?? 0,// 成本价(取第一个sku)
|
||||
'sku_no' => $this->params['sku_no'] ?? '',// 商品sku编码
|
||||
'weight' => $this->params['weight'] ?? '',// 重量
|
||||
'volume' => $this->params['volume'] ?? '',// 体积
|
||||
'goods_stock' => $this->params['goods_stock'] ?? 0,// 商品库存(总和)
|
||||
|
||||
'goods_stock_alarm' => $this->params['goods_stock_alarm'] ?? 0,// 库存预警
|
||||
'is_free_shipping' => $this->params['is_free_shipping'] ?? 1,// 是否免邮
|
||||
'shipping_template' => $this->params['shipping_template'] ?? 0,// 指定运费模板
|
||||
'goods_spec_format' => $this->params['goods_spec_format'] ?? '',// 商品规格格式
|
||||
'goods_attr_format' => $this->params['goods_attr_format'] ?? '',// 商品参数格式
|
||||
'introduction' => $this->params['introduction'] ?? '',// 促销语
|
||||
'keywords' => $this->params['keywords'] ?? '',// 关键词
|
||||
'unit' => $this->params['unit'] ?? '',// 单位
|
||||
'sort' => $this->params['sort'] ?? 0,// 排序,
|
||||
'video_url' => $this->params['video_url'] ?? '',// 视频
|
||||
'goods_sku_data' => $this->params['goods_sku_data'] ?? '',// SKU商品数据
|
||||
'label_id' => $this->params['label_id'] ?? '',// 商品分组id
|
||||
'max_buy' => $this->params['max_buy'] ?? '',// 限购
|
||||
'min_buy' => $this->params['min_buy'] ?? '',// 起售
|
||||
|
||||
'timer_on' => isset($this->params[ 'timer_on' ]) ? strtotime($this->params[ 'timer_on' ]) : 0,//定时上架
|
||||
'timer_off' => isset($this->params[ 'timer_off' ]) ? strtotime($this->params[ 'timer_off' ]) : 0,//定时下架
|
||||
|
||||
'site_name' => $this->shop_info[ 'site_name' ],//店铺名
|
||||
'virtual_sale' => $this->params[ 'virtual_sale' ] ?? 0,// 虚拟销量
|
||||
'is_consume_discount' => $this->params[ 'is_consume_discount' ] ?? 0, //是否参与会员折扣
|
||||
'goods_service_ids' => $this->params[ 'goods_service_ids' ] ?? '',// 商品服务id集合
|
||||
'recommend_way' => $this->params[ 'recommend_way' ] ?? 0, // 推荐方式,1:新品,2:精品,3;推荐
|
||||
|
||||
'is_limit' => $this->params[ 'is_limit' ] ?? 0,// 商品是否限购,
|
||||
'limit_type' => $this->params[ 'limit_type' ] ?? 1, // 商品限购类型,
|
||||
|
||||
'sale_show' => $this->params[ 'sale_show' ] ?? 0,
|
||||
'stock_show' => $this->params[ 'stock_show' ] ?? 0,
|
||||
'market_price_show' => $this->params[ 'market_price_show' ] ?? 0,
|
||||
'barrage_show' => $this->params[ 'barrage_show' ] ?? 0,
|
||||
'brand_id' => $this->params[ 'brand_id' ] ?? 0,
|
||||
'support_trade_type' => $this->params[ 'support_trade_type' ] ?? '',
|
||||
'form_id' => $this->params[ 'goods_form' ] ?? 0,
|
||||
'supplier_id' => $this->params[ 'supplier_id' ] ?? 0,
|
||||
];
|
||||
|
||||
$goods_model = new GoodsModel();
|
||||
$res = $goods_model->addGoods($data);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑商品
|
||||
* @return mixed
|
||||
*/
|
||||
public function editGoods()
|
||||
{
|
||||
$goods_model = new GoodsModel();
|
||||
$data = [
|
||||
'goods_id' => $this->params['goods_id'] ?? 0,// 商品id
|
||||
'goods_name' => $this->params['goods_name'] ?? '',// 商品名称,
|
||||
'goods_attr_class' => $this->params['goods_attr_class'] ?? '',// 商品类型id,
|
||||
'goods_attr_name' => $this->params['goods_attr_name'] ?? '',// 商品类型名称,
|
||||
'site_id' => $this->site_id,
|
||||
'category_id' => $this->params[ 'category_id' ] ?? '',
|
||||
'category_json' => $this->params[ 'category_json' ] ?? '',
|
||||
'goods_image' => $this->params['goods_image'] ?? '',// 商品主图路径
|
||||
'goods_content' => $this->params['goods_content'] ?? '',// 商品详情
|
||||
'goods_state' => $this->params['goods_state'] ?? '',// 商品状态(1.正常0下架)
|
||||
'price' => $this->params['price'] ?? 0,// 商品价格(取第一个sku)
|
||||
'market_price' => $this->params['market_price'] ?? 0,// 市场价格(取第一个sku)
|
||||
'cost_price' => $this->params['cost_price'] ?? 0,// 成本价(取第一个sku)
|
||||
'sku_no' => $this->params['sku_no'] ?? '',// 商品sku编码
|
||||
'weight' => $this->params['weight'] ?? '',// 重量
|
||||
'volume' => $this->params['volume'] ?? '',// 体积
|
||||
'goods_stock' => $this->params['goods_stock'] ?? 0,// 商品库存(总和)
|
||||
'goods_stock_alarm' => $this->params['goods_stock_alarm'] ?? 0,// 库存预警
|
||||
'is_free_shipping' => $this->params['is_free_shipping'] ?? 1,// 是否免邮
|
||||
'shipping_template' => $this->params['shipping_template'] ?? 0,// 指定运费模板
|
||||
'goods_spec_format' => $this->params['goods_spec_format'] ?? '',// 商品规格格式
|
||||
'goods_attr_format' => $this->params['goods_attr_format'] ?? '',// 商品参数格式
|
||||
'introduction' => $this->params['introduction'] ?? '',// 促销语
|
||||
'keywords' => $this->params['keywords'] ?? '',// 关键词
|
||||
'unit' => $this->params['unit'] ?? '',// 单位
|
||||
'sort' => $this->params['sort'] ?? 0,// 排序,
|
||||
'video_url' => $this->params['video_url'] ?? '',// 视频
|
||||
'goods_sku_data' => $this->params['goods_sku_data'] ?? '',// SKU商品数据
|
||||
'label_id' => $this->params['label_id'] ?? '',// 商品分组id
|
||||
'max_buy' => $this->params['max_buy'] ?? 0,// 限购
|
||||
'min_buy' => $this->params['min_buy'] ?? 0,// 起售
|
||||
'timer_on' => isset($this->params[ 'timer_on' ]) ? strtotime($this->params[ 'timer_on' ]) : 0,//定时上架
|
||||
'timer_off' => isset($this->params[ 'timer_off' ]) ? strtotime($this->params[ 'timer_off' ]) : 0,//定时下架
|
||||
'spec_type_status' => $this->params['spec_type_status'] ?? 0,
|
||||
|
||||
'site_name' => $this->shop_info[ 'site_name' ],
|
||||
'virtual_sale' => $this->params[ 'virtual_sale' ] ?? 0,// 虚拟销量
|
||||
'is_consume_discount' => $this->params[ 'is_consume_discount' ] ?? 0, //是否参与会员折扣
|
||||
'goods_service_ids' => $this->params[ 'goods_service_ids' ] ?? '',// 商品服务id集合
|
||||
'recommend_way' => $this->params[ 'recommend_way' ] ?? 0, // 推荐方式,1:新品,2:精品,3;推荐
|
||||
|
||||
'is_limit' => $this->params[ 'is_limit' ] ?? 0,// 商品是否限购,
|
||||
'limit_type' => $this->params[ 'limit_type' ] ?? 1, // 商品限购类型,
|
||||
'sale_show' => $this->params[ 'sale_show' ] ?? 0,
|
||||
'stock_show' => $this->params[ 'stock_show' ] ?? 0,
|
||||
'market_price_show' => $this->params[ 'market_price_show' ] ?? 0,
|
||||
'barrage_show' => $this->params[ 'barrage_show' ] ?? 0,
|
||||
'brand_id' => $this->params[ 'brand_id' ] ?? 0,
|
||||
'support_trade_type' => $this->params[ 'support_trade_type' ] ?? '',
|
||||
'form_id' => $this->params[ 'goods_form' ] ?? 0,
|
||||
'supplier_id' => $this->params[ 'supplier_id' ] ?? 0,
|
||||
];
|
||||
|
||||
$res = $goods_model->editGoods($data);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取编辑商品所需数据
|
||||
* @return false|string
|
||||
*/
|
||||
public function editGetGoodsInfo()
|
||||
{
|
||||
$goods_id = $this->params['goods_id'] ?? 0;
|
||||
|
||||
$goods_model = new GoodsModel();
|
||||
$goods_info = $goods_model->editGetGoodsInfo([ [ 'goods_id', '=', $goods_id ], [ 'site_id', '=', $this->site_id ] ])[ 'data' ];
|
||||
$goods_sku_list = $goods_model->getGoodsSkuList([ [ 'goods_id', '=', $goods_id ], [ 'site_id', '=', $this->site_id ] ], "sku_id,sku_name,sku_no,sku_spec_format,price,market_price,cost_price,stock,weight,volume,sku_image,sku_images,goods_spec_format,spec_name,stock_alarm,is_default,verify_num,supplier_id", '')[ 'data' ];
|
||||
$goods_info[ 'goods_sku_data' ] = $goods_sku_list;
|
||||
|
||||
if (!empty($goods_info[ 'shipping_template' ])) {
|
||||
//获取运费模板
|
||||
$express_template_model = new ExpressTemplateModel();
|
||||
$express_template_list = $express_template_model->getExpressTemplateList([ [ 'site_id', "=", $this->site_id ], [ 'template_id', '=', $goods_info[ 'shipping_template' ] ] ], 'template_name')[ 'data' ];
|
||||
if (!empty($express_template_list)) {
|
||||
$goods_info[ 'template_name' ] = $express_template_list[ 0 ][ 'template_name' ];
|
||||
}
|
||||
}
|
||||
return $this->response($this->success($goods_info));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品
|
||||
*/
|
||||
public function deleteGoods()
|
||||
{
|
||||
$goods_ids = $this->params['goods_ids'] ?? 0;
|
||||
$goods_model = new GoodsModel();
|
||||
$res = $goods_model->modifyIsDelete($goods_ids, 1, $this->site_id);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品回收站
|
||||
*/
|
||||
public function recycle()
|
||||
{
|
||||
$page_index = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
$search_keys = $this->params['search_keys'] ?? '';
|
||||
|
||||
$condition = [ [ 'is_delete', '=', 1 ], [ 'site_id', "=", $this->site_id ] ];
|
||||
if (!empty($search_keys)) {
|
||||
$condition[] = [ 'goods_name', 'like', '%' . $search_keys . '%' ];
|
||||
}
|
||||
$goods_model = new GoodsModel();
|
||||
$res = $goods_model->getGoodsPageList($condition, $page_index, $page_size);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品回收站商品删除
|
||||
*/
|
||||
public function deleteRecycleGoods()
|
||||
{
|
||||
$goods_ids = $this->params['goods_ids'] ?? 0;
|
||||
$goods_model = new GoodsModel();
|
||||
$res = $goods_model->deleteRecycleGoods($goods_ids, $this->site_id);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品回收站商品恢复
|
||||
*/
|
||||
public function recoveryRecycle()
|
||||
{
|
||||
$goods_ids = $this->params['goods_ids'] ?? 0;
|
||||
$goods_model = new GoodsModel();
|
||||
$res = $goods_model->modifyIsDelete($goods_ids, 0, $this->site_id);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品下架
|
||||
*/
|
||||
public function offGoods()
|
||||
{
|
||||
$goods_ids = $this->params['goods_ids'] ?? 0;
|
||||
$goods_state = $this->params['goods_state'] ?? 0;
|
||||
$goods_model = new GoodsModel();
|
||||
$res = $goods_model->modifyGoodsState($goods_ids, $goods_state, $this->site_id);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品上架
|
||||
*/
|
||||
public function onGoods()
|
||||
{
|
||||
$goods_ids = $this->params['goods_ids'] ?? 0;
|
||||
$goods_state = $this->params['goods_state'] ?? 0;
|
||||
$goods_model = new GoodsModel();
|
||||
$res = $goods_model->modifyGoodsState($goods_ids, $goods_state, $this->site_id);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑商品库存
|
||||
* @return false|string
|
||||
*/
|
||||
public function editGoodsStock()
|
||||
{
|
||||
$sku_list = $this->params['sku_list'] ?? '';
|
||||
$res = $this->error();
|
||||
if (!empty($sku_list)) {
|
||||
$sku_list = json_decode($sku_list, true);
|
||||
$model = new GoodsModel();
|
||||
$res = $model->editGoodsStock($sku_list, $this->site_id);
|
||||
}
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品分类列表
|
||||
* @return false|string
|
||||
*/
|
||||
public function getCategoryList()
|
||||
{
|
||||
$category_id = $this->params['category_id'] ?? 0;
|
||||
$goods_category_model = new GoodsCategoryModel();
|
||||
$condition = [
|
||||
[ 'pid', '=', $category_id ]
|
||||
];
|
||||
$goods_category_list = $goods_category_model->getCategoryList($condition, 'category_id,category_name,level,commission_rate');
|
||||
return $this->response($goods_category_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品分类列表
|
||||
* @return false|string
|
||||
*/
|
||||
public function getCategoryTree()
|
||||
{
|
||||
$goods_category_model = new GoodsCategoryModel();
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ]
|
||||
];
|
||||
$goods_category_list = $goods_category_model->getCategoryTree($condition, 'category_id,category_name,level,commission_rate,sort,pid');
|
||||
return $this->response($goods_category_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品规格列表
|
||||
*/
|
||||
public function getSpecList()
|
||||
{
|
||||
$attr_id = $this->params['attr_id'] ?? '';//排除已存在的规格项
|
||||
$search_text = $this->params['search_text'] ?? '';
|
||||
|
||||
$condition = [ [ 'is_spec', '=', 1 ], [ 'site_id', 'in', ( "0,$this->site_id" ) ] ];
|
||||
if (!empty($attr_id)) {
|
||||
$condition[] = [ 'attr_id', 'not in', $attr_id ];
|
||||
}
|
||||
if (!empty($search_text)) {
|
||||
$condition[] = [ 'attr_name', 'like', '%' . $search_text . '%' ];
|
||||
}
|
||||
$goods_attr_model = new GoodsAttributeModel();
|
||||
$spec_list = $goods_attr_model->getSpecList($condition, 'attr_id,attr_name,attr_class_name', 'attr_id desc', 50);
|
||||
return $this->response($spec_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品规格值列表
|
||||
*/
|
||||
public function getSpecValueList()
|
||||
{
|
||||
$attr_id = $this->params['attr_id'] ?? 0;
|
||||
$search_text = $this->params['search_text'] ?? '';
|
||||
$condition = [];
|
||||
if (!empty($attr_id)) {
|
||||
$condition[] = [ 'attr_id', '=', $attr_id ];
|
||||
}
|
||||
if (!empty($search_text)) {
|
||||
$condition[] = [ 'attr_value_name', 'like', '%' . $search_text . '%' ];
|
||||
}
|
||||
|
||||
$goods_attr_model = new GoodsAttributeModel();
|
||||
$spec_list = $goods_attr_model->getSpecValueList($condition, 'attr_value_id,attr_value_name');
|
||||
return $this->response($spec_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品参数列表
|
||||
*/
|
||||
public function getAttributeList()
|
||||
{
|
||||
$goods_attr_model = new GoodsAttributeModel();
|
||||
$attr_class_id = $this->params['attr_class_id'] ?? 0;// 商品类型id
|
||||
$attribute_list = $goods_attr_model->getAttributeList([ [ 'attr_class_id', '=', $attr_class_id ], [ 'is_spec', '=', 0 ], [ 'site_id', 'in', ( "0,$this->site_id" ) ] ], 'attr_id,attr_name,attr_class_id,attr_class_name,attr_type,attr_value_format');
|
||||
if (!empty($attribute_list[ 'data' ])) {
|
||||
foreach ($attribute_list[ 'data' ] as $k => $v) {
|
||||
if (!empty($v[ 'attr_value_format' ])) {
|
||||
$attribute_list[ 'data' ][ $k ][ 'attr_value_format' ] = json_decode($v[ 'attr_value_format' ], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->response($attribute_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取SKU商品列表
|
||||
*/
|
||||
public function getGoodsSkuList()
|
||||
{
|
||||
$goods_id = $this->params['goods_id'] ?? 0;
|
||||
$goods_model = new GoodsModel();
|
||||
$res = $goods_model->getGoodsSkuList([ [ 'goods_id', '=', $goods_id ], [ 'site_id', '=', $this->site_id ] ], 'sku_id,sku_name,price,market_price,cost_price,stock,weight,volume,sku_no,sale_num,sku_image,spec_name,goods_id');
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取SKU商品出入库列表
|
||||
*/
|
||||
public function getOutputList()
|
||||
{
|
||||
$goods_id = $this->params['goods_id'] ?? 0;
|
||||
$goods_model = new GoodsModel();
|
||||
$res = $goods_model->getGoodsSkuList([ [ 'goods_id', '=', $goods_id ], [ 'site_id', '=', $this->site_id ] ], 'sku_id,sku_name,spec_name,price,market_price,cost_price,stock', 'is_default desc,price asc');
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/***********************************************************商品评价**************************************************/
|
||||
|
||||
/**
|
||||
* 商品评价
|
||||
*/
|
||||
public function evaluate()
|
||||
{
|
||||
$goods_evaluate = new GoodsEvaluateModel();
|
||||
|
||||
$page_index = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
|
||||
$explain_type = $this->params['explain_type'] ?? ''; //1好评2中评3差评
|
||||
$is_show = $this->params['is_show'] ?? ''; //1显示 0隐藏
|
||||
$search_text = $this->params['search_text'] ?? ''; //搜索值
|
||||
$search_type = $this->params['search_type'] ?? ''; //搜索类型
|
||||
$start_time = $this->params['start_time'] ?? '';
|
||||
$end_time = $this->params['end_time'] ?? '';
|
||||
|
||||
$is_image = $this->params['is_image'] ?? 0;//是否有图 1 有图 2 仅文字
|
||||
$is_reply = $this->params['is_reply'] ?? 0;//是否回复 1 已回复 2 未回复
|
||||
$condition = [
|
||||
[ "site_id", "=", $this->site_id ]
|
||||
];
|
||||
$condition[] = [ 'is_audit', '=', 1 ];
|
||||
//评分类型
|
||||
if ($explain_type != "") {
|
||||
$condition[] = [ "explain_type", "=", $explain_type ];
|
||||
}
|
||||
if ($is_show != "") {
|
||||
$condition[] = [ "is_show", "=", $is_show ];
|
||||
}
|
||||
//评论内容
|
||||
if ($is_image > 0) {
|
||||
if ($is_image == 1) {
|
||||
$condition[] = [ "images", "<>", '' ];
|
||||
} else if ($is_image == 2) {
|
||||
$condition[] = [ "images", "=", '' ];
|
||||
}
|
||||
|
||||
}
|
||||
//全部回复
|
||||
if ($is_reply > 0) {
|
||||
if ($is_reply == 1) {
|
||||
$condition[] = [ "explain_first", "<>", '' ];
|
||||
} else if ($is_reply == 2) {
|
||||
$condition[] = [ "explain_first", "=", '' ];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($search_text)) {
|
||||
if (!empty($search_type)) {
|
||||
$condition[] = [ $search_type, 'like', '%' . $search_text . '%' ];
|
||||
} else {
|
||||
$condition[] = [ 'sku_name', 'like', '%' . $search_text . '%' ];
|
||||
}
|
||||
}
|
||||
if (!empty($start_time) && empty($end_time)) {
|
||||
$condition[] = [ "create_time", ">=", date_to_time($start_time) ];
|
||||
} elseif (empty($start_time) && !empty($end_time)) {
|
||||
$condition[] = [ "create_time", "<=", date_to_time($end_time) ];
|
||||
} elseif (!empty($start_time) && !empty($end_time)) {
|
||||
$condition[] = [ 'create_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
|
||||
}
|
||||
$list = $goods_evaluate->getEvaluatePageList($condition, $page_index, $page_size, "create_time desc");
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品评价删除
|
||||
*/
|
||||
public function deleteEvaluate()
|
||||
{
|
||||
$goods_evaluate = new GoodsEvaluateModel();
|
||||
$evaluate_id = $this->params['evaluate_id'] ?? 0;
|
||||
$res = $goods_evaluate->deleteEvaluate($evaluate_id);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品推广
|
||||
* return
|
||||
*/
|
||||
public function goodsUrl()
|
||||
{
|
||||
$goods_id = $this->params['goods_id'] ?? '';
|
||||
|
||||
$goods_model = new GoodsModel();
|
||||
$goods_sku_info = $goods_model->getGoodsSkuInfo([ [ 'goods_id', '=', $goods_id ] ], 'sku_id,goods_name')[ 'data' ];
|
||||
$res = $goods_model->qrcode($goods_id, $goods_sku_info[ 'goods_name' ], $this->site_id);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品预览
|
||||
* return
|
||||
*/
|
||||
public function goodsPreview()
|
||||
{
|
||||
$goods_id = $this->params['goods_id'] ?? '';
|
||||
$goods_model = new GoodsModel();
|
||||
$goods_sku_info = $goods_model->getGoodsSkuInfo([ [ 'goods_id', '=', $goods_id ] ], 'sku_id,goods_name')[ 'data' ];
|
||||
$res = $goods_model->qrcode($goods_sku_info[ 'sku_id' ], $goods_sku_info[ 'goods_name' ], $this->site_id);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品评价回复
|
||||
*/
|
||||
public function evaluateApply()
|
||||
{
|
||||
$goods_evaluate = new GoodsEvaluateModel();
|
||||
$evaluate_id = $this->params['evaluate_id'] ?? 0;
|
||||
$explain = $this->params['explain'] ?? 0;
|
||||
$is_first_explain = $this->params['is_first_explain'] ?? 0;// 是否第一次回复
|
||||
$data = [
|
||||
'evaluate_id' => $evaluate_id
|
||||
];
|
||||
if ($is_first_explain == 0) {
|
||||
$data[ 'explain_first' ] = $explain;
|
||||
} elseif ($is_first_explain == 1) {
|
||||
$data[ 'again_explain' ] = $explain;
|
||||
}
|
||||
|
||||
$res = $goods_evaluate->evaluateApply($data);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品评价回复
|
||||
*/
|
||||
public function deleteContent()
|
||||
{
|
||||
$goods_evaluate = new GoodsEvaluateModel();
|
||||
$evaluate_id = $this->params['evaluate_id'] ?? 0;
|
||||
$is_first_explain = $this->params['is_first'] ?? 0;// 0 第一次回复,1 追评回复
|
||||
$data = [];
|
||||
if ($is_first_explain == 0) {
|
||||
$data[ 'explain_first' ] = '';
|
||||
} elseif ($is_first_explain == 1) {
|
||||
$data[ 'again_explain' ] = '';
|
||||
}
|
||||
$condition = [
|
||||
[ 'evaluate_id', '=', $evaluate_id ],
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
];
|
||||
|
||||
$res = $goods_evaluate->editEvaluate($data, $condition);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品复制
|
||||
*/
|
||||
public function copyGoods()
|
||||
{
|
||||
$goods_id = $this->params['goods_id'] ?? 0;
|
||||
$goods_model = new GoodsModel();
|
||||
$result = $goods_model->copyGoods($goods_id, $this->site_id);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员商品收藏
|
||||
*/
|
||||
public function memberGoodsCollect()
|
||||
{
|
||||
$goods_collect_model = new GoodsCollect();
|
||||
$member_id = $this->params['member_id'] ?? 0;
|
||||
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
|
||||
$condition = [];
|
||||
$condition[] = [ 'gc.site_id', '=', $this->site_id ];
|
||||
$condition[] = [ 'gc.member_id', '=', $member_id ];
|
||||
$order = 'gc.create_time desc';
|
||||
$field = 'gc.collect_id, gc.member_id, gc.goods_id, gc.sku_id,gc.sku_name, gc.sku_price, gc.sku_image,g.goods_name,g.is_free_shipping,sku.promotion_type,sku.discount_price,g.sale_num,g.price,g.market_price,g.is_virtual,sku.*';
|
||||
$res = $goods_collect_model->getCollectPageList($condition, $page, $page_size, $order, $field);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员浏览记录
|
||||
*/
|
||||
public function memberGoodsBrowse()
|
||||
{
|
||||
$member_id = $this->params['member_id'] ?? 0;
|
||||
$goods_browse_model = new GoodsBrowse();
|
||||
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
$search = $this->params['search'] ?? '';
|
||||
$condition = [];
|
||||
$condition[] = [ 'gb.site_id', '=', $this->site_id ];
|
||||
$condition[] = [ 'gb.member_id', '=', $member_id ];
|
||||
if (!empty($search))
|
||||
$condition[] = [ 'gs.sku_name', 'like', '%' . $search . '%' ];
|
||||
|
||||
$order = 'browse_time desc';
|
||||
$field = 'gb.*,gs.sku_name,gs.sku_image,gs.price,gs.goods_state,gs.stock,gs.click_num';
|
||||
$alias = 'gb';
|
||||
$join = [
|
||||
[ 'goods_sku gs', 'gs.sku_id = gb.sku_id', 'left' ]
|
||||
];
|
||||
$res = $goods_browse_model->getBrowsePageList($condition, $page, $page_size, $order, $field, $alias, $join);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品浏览记录
|
||||
*/
|
||||
public function goodsBrowse()
|
||||
{
|
||||
$goods_id = $this->params['goods_id'] ?? '';
|
||||
$goods_browse_model = new GoodsBrowse();
|
||||
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
|
||||
$search = $this->params['search'] ?? '';
|
||||
$condition = [];
|
||||
$condition[] = [ 'gb.site_id', '=', $this->site_id ];
|
||||
if ($goods_id > 0) {
|
||||
$condition[] = [ 'gb.goods_id', '=', $goods_id ];
|
||||
}
|
||||
if (!empty($search))
|
||||
$condition[] = [ 'gs.sku_name', 'like', '%' . $search . '%' ];
|
||||
|
||||
$order = 'browse_time desc';
|
||||
$field = 'gb.*,gs.sku_name,gs.sku_image,gs.price,gs.goods_state,gs.stock,gs.click_num,m.nickname,m.headimg';
|
||||
$alias = 'gb';
|
||||
$join = [
|
||||
[ 'goods_sku gs', 'gs.sku_id = gb.sku_id', 'left' ],
|
||||
[ 'member m', 'm.member_id = gb.member_id', 'left' ]
|
||||
];
|
||||
$res = $goods_browse_model->getBrowsePageList($condition, $page, $page_size, $order, $field, $alias, $join);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品参数
|
||||
* @return false|string
|
||||
*/
|
||||
public function getAttrClassList()
|
||||
{
|
||||
$goods_attr_model = new GoodsAttributeModel();
|
||||
$attr_class_list = $goods_attr_model->getAttrClassList([ [ 'site_id', 'in', ( "0,$this->site_id" ) ] ], 'class_id,class_name');
|
||||
return $this->response($attr_class_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品设置参数
|
||||
* @return false|string
|
||||
*/
|
||||
public function config()
|
||||
{
|
||||
$data = [];
|
||||
$config_model = new ConfigModel();
|
||||
$goods_sort_config = $config_model->getGoodsSort($this->site_id, $this->app_module)[ 'data' ][ 'value' ];
|
||||
$default_search_words = $config_model->getDefaultSearchWords($this->site_id, $this->app_module)[ 'data' ][ 'value' ];
|
||||
$hot_search_words = $config_model->getHotSearchWords($this->site_id, $this->app_module)[ 'data' ][ 'value' ];
|
||||
$words_array = [];
|
||||
if (!empty($hot_search_words[ 'words' ])) {
|
||||
$words_array = explode(',', $hot_search_words[ 'words' ]);
|
||||
}
|
||||
$hot_search_words[ 'words_array' ] = $words_array;
|
||||
$data[ "hot_words" ] = $hot_search_words;
|
||||
$data[ "default_words" ] = $default_search_words;
|
||||
$data[ "goods_sort_config" ] = $goods_sort_config;
|
||||
return $this->response($this->success($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑商品设置
|
||||
* @return false|string
|
||||
*/
|
||||
public function setConfig()
|
||||
{
|
||||
$config_model = new ConfigModel();
|
||||
$hot_search_words = $this->params['hot_words'] ?? [];
|
||||
$default_search_words = $this->params['default_words'] ?? '';
|
||||
$type = $this->params['sort_type'] ?? 'asc';
|
||||
$default_value = $this->params['sort_value'] ?? '0';
|
||||
$config_model->setHotSearchWords([ 'words' => implode(',', explode(',', $hot_search_words)) ], $this->site_id, $this->app_module);
|
||||
$config_model->setDefaultSearchWords([ 'words' => $default_search_words ], $this->site_id, $this->app_module);
|
||||
$config_model->setGoodsSort([ 'type' => trim($type), 'default_value' => trim($default_value) ], $this->site_id, $this->app_module);
|
||||
return $this->response($this->success());
|
||||
}
|
||||
|
||||
/**
|
||||
* 核销码
|
||||
*/
|
||||
public function verify()
|
||||
{
|
||||
$goods_id = $this->params[ 'goods_id' ] ?? 0;
|
||||
$virtual_goods_model = new \app\model\goods\VirtualGoods();
|
||||
|
||||
$verify_count = $virtual_goods_model->getVirtualGoodsInfo([ [ 'goods_id', '=', $goods_id ], [ 'site_id', '=', $this->site_id ] ], 'count(id) as total_count, sum(verify_use_num) as verify_use_num')[ 'data' ] ?? [];
|
||||
return $this->response($this->success($verify_count));
|
||||
}
|
||||
|
||||
public function virtualGoodsList()
|
||||
{
|
||||
$virtual_goods_model = new \app\model\goods\VirtualGoods();
|
||||
|
||||
$goods_id = $this->params[ 'goods_id' ] ?? 0;
|
||||
$search_text = input("search_text", '');
|
||||
|
||||
$field = 'gv.*, m.nickname,m.headimg';
|
||||
|
||||
$page_index = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$alias = 'gv';
|
||||
$condition = [
|
||||
[ "gv.site_id", "=", $this->site_id ],
|
||||
[ "gv.goods_id", "=", $goods_id ],
|
||||
];
|
||||
if ($search_text) $condition[] = [ 'm.nickname|gv.code', 'like', '%' . $search_text . '%' ];
|
||||
$order = "gv.id desc";
|
||||
$join = [
|
||||
[
|
||||
'member m',
|
||||
'm.member_id = gv.member_id',
|
||||
'left'
|
||||
]
|
||||
];
|
||||
$list = $virtual_goods_model->getVirtualGoodsPageList($condition, $page_index, $page_size, $order, $field, $alias, $join);
|
||||
return $this->response($list);
|
||||
}
|
||||
}
|
||||
47
app/shopapi/controller/Goodscategory.php
Executable file
47
app/shopapi/controller/Goodscategory.php
Executable file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\goods\GoodsCategory as GoodscategoryModel;
|
||||
|
||||
/**
|
||||
* 商品分类管理 控制器
|
||||
*/
|
||||
class Goodscategory extends BaseApi
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//执行父类构造函数
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品分类
|
||||
*/
|
||||
public function getCategoryByParent()
|
||||
{
|
||||
$pid = $this->params['pid'] ?? 0;// 上级id
|
||||
$level = $this->params['level'] ?? 0;// 层级
|
||||
$goods_category_model = new GoodscategoryModel();
|
||||
if (!empty($level)) {
|
||||
$condition[] = [ 'level', '=', $level ];
|
||||
}
|
||||
if (!empty($pid)) {
|
||||
$condition[] = [ 'pid', '=', $pid ];
|
||||
}
|
||||
$list = $goods_category_list = $goods_category_model->getCategoryByParent($condition, 'category_id,category_name,pid,level,category_id_1,category_id_2,category_id_3');
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
}
|
||||
115
app/shopapi/controller/Index.php
Executable file
115
app/shopapi/controller/Index.php
Executable file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\dict\order_refund\OrderRefundDict;
|
||||
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 json_encode($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", [ OrderRefundDict::REFUND_NOT_APPLY, OrderRefundDict::REFUND_COMPLETE,OrderRefundDict::PARTIAL_REFUND ] ]
|
||||
]);
|
||||
|
||||
//商品预警数
|
||||
$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));
|
||||
}
|
||||
|
||||
}
|
||||
56
app/shopapi/controller/Localorder.php
Executable file
56
app/shopapi/controller/Localorder.php
Executable file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\order\LocalOrder as LocalOrderModel;
|
||||
|
||||
/**
|
||||
* 外卖订单
|
||||
* Class Order
|
||||
* @package app\shop\controller
|
||||
*/
|
||||
class Localorder extends BaseApi
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//执行父类构造函数
|
||||
parent::__construct();
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) {
|
||||
echo json_encode($token);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发货
|
||||
* @return false|string
|
||||
*/
|
||||
public function delivery()
|
||||
{
|
||||
$order_id = $this->params['order_id'] ?? 0;
|
||||
$deliverer = $this->params['deliverer'] ?? '';
|
||||
$deliverer_mobile = $this->params['deliverer_mobile'] ?? '';
|
||||
$local_order_model = new LocalOrderModel();
|
||||
$data = [
|
||||
'order_id' => $order_id,
|
||||
'deliverer' => $deliverer,
|
||||
'deliverer_mobile' => $deliverer_mobile,
|
||||
'site_id' => $this->site_id
|
||||
];
|
||||
$result = $local_order_model->orderGoodsDelivery($data);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
}
|
||||
69
app/shopapi/controller/Login.php
Executable file
69
app/shopapi/controller/Login.php
Executable file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
320
app/shopapi/controller/Member.php
Executable file
320
app/shopapi/controller/Member.php
Executable file
@@ -0,0 +1,320 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
|
||||
use app\model\member\Member as MemberModel;
|
||||
use app\model\member\MemberAccount as MemberAccountModel;
|
||||
use app\model\member\MemberLabel as MemberLabelModel;
|
||||
use app\model\member\MemberLevel as MemberLevelModel;
|
||||
use app\model\order\OrderCommon;
|
||||
use app\model\order\OrderCommon as OrderCommonModel;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 店铺会员
|
||||
* @package app\shop\controller
|
||||
*/
|
||||
class Member extends BaseApi
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
//执行父类构造函数
|
||||
parent::__construct();
|
||||
$token = $this->checkToken();
|
||||
if ($token['code'] < 0) {
|
||||
echo json_encode($token);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 店铺会员列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$member = new MemberModel();
|
||||
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
$start_date = $this->params['start_date'] ?? '';
|
||||
$end_date = $this->params['end_date'] ?? '';
|
||||
$start_order_complete_money = $this->params['start_order_complete_money'] ?? '';
|
||||
$end_order_complete_money = $this->params['end_order_complete_money'] ?? '';
|
||||
$start_point = $this->params['start_point'] ?? '';
|
||||
$end_point = $this->params['end_point'] ?? '';
|
||||
$start_balance = $this->params['start_balance'] ?? '';
|
||||
$end_balance = $this->params['end_balance'] ?? '';
|
||||
$start_growth = $this->params['start_growth'] ?? '';
|
||||
$end_growth = $this->params['end_growth'] ?? '';
|
||||
$is_member = $this->params['is_member'] ?? '';
|
||||
$status = $this->params['status'] ?? '';
|
||||
$search_text = $this->params['search_text'] ?? '';
|
||||
|
||||
$condition = [
|
||||
['site_id', '=', $this->site_id]
|
||||
];
|
||||
if (!empty($search_text)) {
|
||||
$condition[] = ['nickname|mobile', 'like', "%" . $search_text . "%"];
|
||||
}
|
||||
// 关注时间
|
||||
if ($start_date != '' && $end_date != '') {
|
||||
$condition[] = ['reg_time', 'between', [strtotime($start_date), strtotime($end_date)]];
|
||||
} else if ($start_date != '' && $end_date == '') {
|
||||
$condition[] = ['reg_time', '>=', strtotime($start_date)];
|
||||
} else if ($start_date == '' && $end_date != '') {
|
||||
$condition[] = ['reg_time', '<=', strtotime($end_date)];
|
||||
}
|
||||
//会员状态
|
||||
if ($status != '') {
|
||||
$condition[] = [ 'status', '=', $status ];
|
||||
}
|
||||
//消费金额
|
||||
if ($start_order_complete_money != '' && $end_order_complete_money != '') {
|
||||
$condition[] = [ 'order_complete_money', 'between', [ $start_order_complete_money, $end_order_complete_money ] ];
|
||||
} else if ($start_order_complete_money != '' && $end_order_complete_money == '') {
|
||||
$condition[] = [ 'order_complete_money', '>=', $start_order_complete_money ];
|
||||
} else if ($start_order_complete_money == '' && $end_order_complete_money != '') {
|
||||
$condition[] = [ 'order_complete_money', '<=', $end_order_complete_money ];
|
||||
}
|
||||
//积分
|
||||
if ($start_point != '' && $end_point != '') {
|
||||
$condition[] = [ 'point', 'between', [ $start_point, $end_point ] ];
|
||||
} else if ($start_point != '' && $end_point == '') {
|
||||
$condition[] = [ 'point', '>=', $start_point ];
|
||||
} else if ($start_point == '' && $end_point != '') {
|
||||
$condition[] = [ 'point', '<=', $end_point ];
|
||||
}
|
||||
//余额
|
||||
if ($start_balance != '' && $end_balance != '') {
|
||||
$condition[] = [ '', 'exp', Db::raw("(balance + balance_money) between {$start_balance} and {$end_balance}") ];
|
||||
} else if ($start_balance != '' && $end_balance == '') {
|
||||
$condition[] = [ '', 'exp', Db::raw("(balance + balance_money) >= {$start_balance}") ];
|
||||
} else if ($start_balance == '' && $end_balance != '') {
|
||||
$condition[] = [ '', 'exp', Db::raw("(balance + balance_money) <= {$end_balance}") ];
|
||||
}
|
||||
//成长值
|
||||
if ($start_growth != '' && $end_growth != '') {
|
||||
$condition[] = [ 'growth', 'between', [ $start_growth, $end_growth ] ];
|
||||
} else if ($start_growth != '' && $end_growth == '') {
|
||||
$condition[] = [ 'growth', '>=', $start_growth ];
|
||||
} else if ($start_growth == '' && $end_growth != '') {
|
||||
$condition[] = [ 'growth', '<=', $end_growth ];
|
||||
}
|
||||
if ($is_member != '') $condition[] = [ 'is_member', '=', $is_member ];
|
||||
$list = $member->getMemberPageList($condition, $page, $page_size, 'last_visit_time desc', 'nickname,mobile,member_level_name,member_level,headimg,member_id,last_login_time,point,balance,balance_money,growth,status,is_member,order_money,order_complete_money');
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员详情
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$member_id = $this->params['member_id'] ?? 0;
|
||||
$member = new MemberModel();
|
||||
$condition = [
|
||||
['member_id', '=', $member_id],
|
||||
['site_id', '=', $this->site_id]
|
||||
];
|
||||
$field = 'member_id,username,headimg,nickname,mobile,member_level_name,member_label_name,birthday,sex,point,balance,growth,balance_money,is_member';
|
||||
$info = $member->getMemberInfo($condition, $field);
|
||||
$data['member_info'] = $info[ 'data' ];
|
||||
//会员等级
|
||||
$member_level_model = new MemberLevelModel();
|
||||
$member_level_list = $member_level_model->getMemberLevelList([ [ 'site_id', '=', $this->site_id ] ], 'level_id, level_name', 'growth asc');
|
||||
$data['member_level_list'] = $member_level_list[ 'data' ];
|
||||
|
||||
//会员标签
|
||||
$member_label_model = new MemberLabelModel();
|
||||
$member_label_list = $member_label_model->getMemberLabelList([ [ 'site_id', '=', $this->site_id ] ], 'label_id, label_name', 'sort asc');
|
||||
$data['member_label_list'] = $member_label_list[ 'data' ];
|
||||
return $this->response($this->success($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员编辑
|
||||
*/
|
||||
public function editMember(){
|
||||
$data = [];
|
||||
if (isset($this->params['headimg'])) $data['headimg'] = $this->params['headimg'];
|
||||
if (isset($this->params['nickname'])) $data['nickname'] = $this->params['nickname'];
|
||||
if (isset($this->params['mobile'])) $data['mobile'] = $this->params['mobile'];
|
||||
if (isset($this->params['level_id']) && !empty($this->params['level_id'])) $data['member_level'] = $this->params['level_id'];
|
||||
if (isset($this->params['level_id']) && !empty($this->params['level_id'])){
|
||||
$member_level_model = new MemberLevelModel();
|
||||
$condition = [
|
||||
['site_id', '=', $this->site_id],
|
||||
['level_id', '=', $this->params['level_id']],
|
||||
['status', '=', 1]
|
||||
];
|
||||
$member_level = $member_level_model->getFirstMemberLevel($condition);
|
||||
$data['member_level_name'] = $member_level['data']['level_name'];
|
||||
}
|
||||
if (isset($this->params['label_id']) && !empty($this->params['label_id'])) $data['member_label'] = $this->params['label_id'];
|
||||
if (isset($this->params['label_id']) && !empty($this->params['label_id'])){
|
||||
$member_label_model = new MemberLabelModel();
|
||||
$member_label = $member_label_model->getMemberLabelInfo([['label_id', '=', $this->params['label_id']]]);
|
||||
$data['member_label_name'] = $member_label['data']['label_name'];
|
||||
}
|
||||
if (isset($this->params['sex'])) $data['sex'] = $this->params['sex'];
|
||||
if (isset($this->params['birthday'])) $data['birthday'] = $this->params['birthday'] ? strtotime($this->params['birthday']) : 0;
|
||||
$member_id = $this->params['member_id'];
|
||||
$member_model = new MemberModel();
|
||||
$this->addLog("编辑会员:id" . $member_id, $data);
|
||||
$info = $member_model->editMember($data, [ [ 'member_id', '=', $member_id ], ['site_id', '=', $this->site_id] ]);
|
||||
return $this->response($info);
|
||||
}
|
||||
/**
|
||||
* 账户流水
|
||||
* @return false|string
|
||||
*/
|
||||
public function memberAccountList()
|
||||
{
|
||||
$member_id = $this->params['member_id'] ?? 0;
|
||||
$page_index = isset($this->params['page']) && !empty($this->params['page_size']) ? $this->params['page'] : 1;
|
||||
$page_size = isset($this->params['page_size']) && !empty($this->params['page_size']) ? $this->params['page_size'] : PAGE_LIST_ROWS;
|
||||
$account_type = $this->params['account_type'] ?? '';
|
||||
if(!empty($account_type)){
|
||||
if (!in_array($account_type, ['point', 'growth', 'balance','balance_money' ])){
|
||||
return $this->response($this->error('', 'INVALID_PARAMETER'));
|
||||
}
|
||||
}
|
||||
$memberAcc = new MemberAccountModel();
|
||||
$condition = [
|
||||
['member_id', '=', $member_id],
|
||||
['site_id', '=', $this->site_id]
|
||||
];
|
||||
if (!empty($account_type)) {
|
||||
$condition[] = [ 'account_type', '=', $account_type ];
|
||||
}
|
||||
$field = 'id,member_id,account_type,account_data,from_type,type_name,type_tag,remark,create_time,username,mobile,email';
|
||||
$data = $memberAcc->getMemberAccountPageList($condition, $page_index, $page_size, 'create_time desc', $field);
|
||||
|
||||
if (!empty($data['data']['list'])) {
|
||||
$account_type = $memberAcc->getAccountType();
|
||||
$data['data']['list'] = array_map(function ($item) use ($account_type) {
|
||||
$item['account_type_name'] = $account_type[ $item['account_type'] ];
|
||||
return $item;
|
||||
}, $data['data']['list']);
|
||||
}
|
||||
return $this->response($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 加入移除黑名单
|
||||
* @return false|string
|
||||
*/
|
||||
public function joinBlacklist()
|
||||
{
|
||||
$member_id = input('member_id', 0);
|
||||
$status = input('status', 0);
|
||||
$condition = [
|
||||
['member_id', '=', $member_id],
|
||||
['site_id', '=', $this->site_id]
|
||||
];
|
||||
$member_model = new MemberModel();
|
||||
$info = $member_model->modifyMemberStatus($status, $condition);
|
||||
return $this->response($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员订单列表
|
||||
*/
|
||||
public function orderList()
|
||||
{
|
||||
$search_text = $this->params['search_text'] ?? '';
|
||||
$member_id = $this->params['member_id'] ?? 0;
|
||||
$page_index = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
if (!empty($search_text)) {
|
||||
$condition[] = ['order_no', 'like', '%' . $search_text . '%'];
|
||||
}
|
||||
$condition[] = ['member_id', '=', $member_id];
|
||||
$condition[] = ['site_id', '=', $this->site_id];
|
||||
$field = 'order_id,order_no,order_name,order_type,order_money,pay_money,balance_money,order_type_name,order_status_name,delivery_status_name,create_time';
|
||||
$order = new OrderCommon();
|
||||
$list = $order->getMemberOrderPageList($condition, $page_index, $page_size, 'order_id desc', $field);
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
*/
|
||||
public function modifyMemberPassword()
|
||||
{
|
||||
$password = $this->params['password'] ?? '123456';
|
||||
$member_id = $this->params['member_id'] ?? 0;
|
||||
$member_model = new MemberModel();
|
||||
$info = $member_model->resetMemberPassword($password, [['member_id', '=', $member_id], ['site_id', '=', $this->site_id]]);
|
||||
return $this->response($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 调整余额
|
||||
*/
|
||||
public function modifyBalance()
|
||||
{
|
||||
$member_id = $this->params['member_id'] ?? 0;
|
||||
$adjust_num = $this->params['adjust_num'] ?? 0;
|
||||
$remark = $this->params['remark'] ?? '商家调整';
|
||||
$this->addLog("会员余额调整id:" . $member_id . "金额" . $adjust_num);
|
||||
$member_account_model = new MemberAccountModel();
|
||||
$info = $member_account_model->addMemberAccount($this->site_id, $member_id, 'balance', $adjust_num, 'adjust', 0, $remark);
|
||||
return $this->response($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 余额调整(可提现)
|
||||
*/
|
||||
public function modifyBalanceMoney()
|
||||
{
|
||||
return $this->response($this->error());
|
||||
|
||||
$member_id = $this->params['member_id'] ?? 0;
|
||||
$adjust_num = $this->params['adjust_num'] ?? 0;
|
||||
$remark = $this->params['remark'] ?? '商家调整';
|
||||
$this->addLog("会员余额调整id:" . $member_id . "金额" . $adjust_num);
|
||||
$member_account_model = new MemberAccountModel();
|
||||
$info = $member_account_model->addMemberAccount($this->site_id, $member_id, 'balance_money', $adjust_num, 'adjust', 0, $remark);
|
||||
return $this->response($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 积分调整
|
||||
*/
|
||||
public function modifyPoint()
|
||||
{
|
||||
$member_id = $this->params['member_id'] ?? 0;
|
||||
$adjust_num = $this->params['adjust_num'] ?? 0;
|
||||
$remark = $this->params['remark'] ?? '商家调整';
|
||||
$this->addLog("会员积分调整id:" . $member_id . "数量" . $adjust_num);
|
||||
$member_account_model = new MemberAccountModel();
|
||||
$info = $member_account_model->addMemberAccount($this->site_id, $member_id, 'point', $adjust_num, 'adjust', 0, $remark);
|
||||
return $this->response($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 成长值调整
|
||||
*/
|
||||
public function modifyGrowth()
|
||||
{
|
||||
$member_id = $this->params['member_id'] ?? 0;
|
||||
$adjust_num = $this->params['adjust_num'] ?? 0;
|
||||
$remark = $this->params['remark'] ?? '商家调整';
|
||||
$this->addLog("会员成长值调整id:" . $member_id . "数量" . $adjust_num);
|
||||
$member_account_model = new MemberAccountModel();
|
||||
$info = $member_account_model->addMemberAccount($this->site_id, $member_id, 'growth', $adjust_num, 'adjust', 0, $remark);
|
||||
return $this->response($info);
|
||||
}
|
||||
}
|
||||
46
app/shopapi/controller/Memberlevel.php
Executable file
46
app/shopapi/controller/Memberlevel.php
Executable file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 上海牛之云网络科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\member\MemberLevel as MemberLevelModel;
|
||||
|
||||
/**
|
||||
* 会员等级
|
||||
* @package app\shop\controller
|
||||
*/
|
||||
class Memberlevel extends BaseApi
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
//执行父类构造函数
|
||||
parent::__construct();
|
||||
$token = $this->checkToken();
|
||||
if ($token['code'] < 0) {
|
||||
echo json_encode($token);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员等级列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$condition = [
|
||||
['site_id', '=', $this->site_id],
|
||||
['level_type', '=', 0]
|
||||
];
|
||||
$list = (new MemberLevelModel())->getMemberLevelList($condition, 'level_id, level_name', 'growth asc');
|
||||
return $this->response($list);
|
||||
}
|
||||
}
|
||||
46
app/shopapi/controller/Notice.php
Executable file
46
app/shopapi/controller/Notice.php
Executable file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
666
app/shopapi/controller/Order.php
Executable file
666
app/shopapi/controller/Order.php
Executable file
@@ -0,0 +1,666 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\express\ExpressDeliver;
|
||||
use app\model\express\ExpressPackage;
|
||||
use app\model\order\Config as ConfigModel;
|
||||
use app\model\order\Order as OrderModel;
|
||||
use app\model\order\OrderCommon as OrderCommonModel;
|
||||
use app\model\order\OrderLog;
|
||||
use think\facade\Config;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 订单
|
||||
* Class Order
|
||||
* @package app\shop\controller
|
||||
*/
|
||||
class Order extends BaseApi
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//执行父类构造函数
|
||||
parent::__construct();
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) {
|
||||
echo json_encode($token);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单查询条件
|
||||
*/
|
||||
public function condition()
|
||||
{
|
||||
$data = [];
|
||||
|
||||
$order_common_model = new OrderCommonModel();
|
||||
|
||||
$order_type_list = $order_common_model->getOrderTypeStatusList();
|
||||
if (array_key_exists('all', $order_type_list)) {
|
||||
array_unshift($order_type_list, $order_type_list[ 'all' ]);
|
||||
unset($order_type_list[ 'all' ]);
|
||||
}
|
||||
$data[ 'order_type_list' ] = $order_type_list;
|
||||
$data[ 'order_status_list' ] = $order_type_list[ 1 ][ 'status' ];//订单状态
|
||||
|
||||
//订单来源 (支持端口)
|
||||
$order_from = Config::get("app_type");
|
||||
$data[ 'order_from_list' ] = $order_from;
|
||||
|
||||
$pay_type = $order_common_model->getPayType();
|
||||
$data[ 'pay_type_list' ] = $pay_type;
|
||||
|
||||
//营销活动类型
|
||||
$order_promotion_type = event('OrderPromotionType');
|
||||
$data[ 'promotion_type' ] = $order_promotion_type;
|
||||
$data[ 'http_type' ] = get_http_type();
|
||||
|
||||
return $this->response($this->success($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$order_status = $this->params['order_status'] ?? '';//订单状态
|
||||
$order_name = $this->params['order_name'] ?? '';
|
||||
$pay_type = $this->params['pay_type'] ?? '';
|
||||
$order_from = $this->params['order_from'] ?? '';
|
||||
$start_time = $this->params['start_time'] ?? '';
|
||||
$end_time = $this->params['end_time'] ?? '';
|
||||
|
||||
$search_text = $this->params['search'] ?? '';
|
||||
$promotion_type = $this->params['promotion_type'] ?? '';//订单类型
|
||||
$order_type = $this->params['order_type'] ?? 'all';//营销类型
|
||||
$settlement_state = $this->params['settlement_state'] ?? '';//结算状态
|
||||
$page_index = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
|
||||
$alias = 'o';
|
||||
$join = null;
|
||||
$condition = [
|
||||
[ "o.site_id", "=", $this->site_id ],
|
||||
[ 'o.is_delete', '=', 0 ]
|
||||
];
|
||||
//订单状态
|
||||
if ($order_status != "") {
|
||||
if ($order_status != 'refunding') {
|
||||
if ($order_status == 0) {
|
||||
$condition[] = [ "o.order_status", "=", $order_status ];
|
||||
$condition[] = [ 'o.order_scene', '=', 'online' ];
|
||||
} else {
|
||||
$condition[] = [ "o.order_status", "=", $order_status ];
|
||||
}
|
||||
} else {
|
||||
$join = [
|
||||
[
|
||||
'order_goods og',
|
||||
'og.order_id = o.order_id',
|
||||
'left'
|
||||
]
|
||||
];
|
||||
$condition[] = [ "og.refund_status", "not in", [ 0, 3 ] ];
|
||||
}
|
||||
} else {
|
||||
$condition[] = [ '', 'exp', Db::raw("o.order_scene = 'online' OR (o.order_scene = 'cashier' AND o.pay_status = 1)") ];
|
||||
}
|
||||
//订单内容 模糊查询
|
||||
if ($order_name != "") {
|
||||
$condition[] = [ "o.order_name", 'like', "%$order_name%" ];
|
||||
}
|
||||
//订单来源
|
||||
if ($order_from != "") {
|
||||
$condition[] = [ "o.order_from", "=", $order_from ];
|
||||
}
|
||||
//订单支付
|
||||
if ($pay_type != "") {
|
||||
$condition[] = [ "o.pay_type", "=", $pay_type ];
|
||||
}
|
||||
//订单类型
|
||||
if ($order_type != 'all') {
|
||||
$condition[] = [ "o.order_type", "=", $order_type ];
|
||||
}
|
||||
//结算状态
|
||||
if ($settlement_state == 1) {
|
||||
$condition[] = [ "o.is_settlement", "=", '1' ];
|
||||
} elseif ($settlement_state == 2) {
|
||||
$condition[] = [ "o.is_settlement", "=", '0' ];
|
||||
}
|
||||
//营销类型
|
||||
if ($promotion_type != "") {
|
||||
if ($promotion_type == 'empty') {
|
||||
$condition[] = [ "o.promotion_type", "=", '' ];
|
||||
} else {
|
||||
$condition[] = [ "o.promotion_type", "=", $promotion_type ];
|
||||
}
|
||||
}
|
||||
if (!empty($start_time) && empty($end_time)) {
|
||||
$condition[] = [ "o.create_time", ">=", date_to_time($start_time . ' 00:00:00') ];
|
||||
} elseif (empty($start_time) && !empty($end_time)) {
|
||||
$condition[] = [ "o.create_time", "<=", date_to_time($end_time . ' 23:59:59') ];
|
||||
} elseif (!empty($start_time) && !empty($end_time)) {
|
||||
$condition[] = [ 'o.create_time', 'between', [ date_to_time($start_time . ' 00:00:00'), date_to_time($end_time . ' 23:59:59') ] ];
|
||||
}
|
||||
|
||||
//订单内容
|
||||
if ($search_text != '') {
|
||||
$condition[] = [ 'o.order_no|o.out_trade_no|o.order_name|o.name|o.mobile', 'like', '%' . $search_text . '%' ];
|
||||
}
|
||||
|
||||
$order_common_model = new OrderCommonModel();
|
||||
$field = 'o.order_id, o.order_no, o.order_type, o.order_type_name, o.order_status, o.order_status_name, o.order_status_action, o.pay_type_name, o.name, o.mobile, o.address, o.full_address, o.order_money, o.create_time, o.remark, o.promotion_type_name, o.promotion_status_name, o.buyer_message, o.is_enable_refund, o.promotion_type, o.order_scene,o.buyer_ask_delivery_time';
|
||||
$list = $order_common_model->getOrderPageList($condition, $page_index, $page_size, "o.create_time desc", $field, $alias, $join);
|
||||
foreach ($list[ 'data' ][ 'list' ] as $k => $v) {
|
||||
// 2:自提提货,3:本地配送外卖
|
||||
if ($v[ 'order_type' ] == 2 || $v[ 'order_type' ] == 3) {
|
||||
$list[ 'data' ][ 'list' ][ $k ][ 'buyer_ask_delivery_time_str' ] = $v['buyer_ask_delivery_time'];
|
||||
// if ($list[ 'data' ][ 'list' ][ $k ][ 'buyer_ask_delivery_time' ] == 0) {
|
||||
// $list[ 'data' ][ 'list' ][ $k ][ 'buyer_ask_delivery_time_str' ] = '立即送达';
|
||||
// } elseif (strpos($list[ 'data' ][ 'list' ][ $k ][ 'buyer_ask_delivery_time' ], '-') !== false) {
|
||||
// $list[ 'data' ][ 'list' ][ $k ][ 'buyer_ask_delivery_time_str' ] = $list[ 'data' ][ 'list' ][ $k ][ 'buyer_ask_delivery_time' ];
|
||||
// } else {
|
||||
// $list[ 'data' ][ 'list' ][ $k ][ 'buyer_ask_delivery_time_str' ] = date("H:i:s", $list[ 'data' ][ 'list' ][ $k ][ 'buyer_ask_delivery_time' ]);
|
||||
// }
|
||||
}
|
||||
}
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 快递订单详情
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$order_id = $this->params['order_id'] ?? 0;
|
||||
|
||||
$order_common_model = new OrderCommonModel();
|
||||
$order_detail = $order_common_model->getOrderDetail($order_id)['data'] ?? [];
|
||||
if (empty($order_detail)) {
|
||||
return $this->response($this->error('查询不到此订单信息!'));
|
||||
}
|
||||
if ($order_detail[ 'site_id' ] != $this->site_id) {
|
||||
return $this->response($this->error('查询不到此订单信息!'));
|
||||
}
|
||||
|
||||
$order_log_condition = array (
|
||||
[ 'order_id', '=', $order_id ]
|
||||
);
|
||||
$order_log_count = OrderLog::getOrderLogCount($order_log_condition, $order_common_model);
|
||||
|
||||
// if ($order_detail_result[ 'data' ][ 'buyer_ask_delivery_time' ] == 0) {
|
||||
// $order_detail_result[ 'data' ][ 'buyer_ask_delivery_time_str' ] = '立即送达';
|
||||
// } elseif (strpos($order_detail_result[ 'data' ][ 'buyer_ask_delivery_time' ], '-') !== false) {
|
||||
// $order_detail_result[ 'data' ][ 'buyer_ask_delivery_time_str' ] = $order_detail_result[ 'data' ][ 'buyer_ask_delivery_time' ];
|
||||
// } else {
|
||||
// $order_detail_result[ 'data' ][ 'buyer_ask_delivery_time_str' ] = date("H:i:s", $order_detail_result[ 'data' ][ 'buyer_ask_delivery_time' ]);
|
||||
// }
|
||||
$order_detail[ 'buyer_ask_delivery_time_str' ] = $order_detail[ 'buyer_ask_delivery_time' ];
|
||||
$order_detail[ 'log_count' ] = $order_log_count[ 'data' ];
|
||||
|
||||
return $this->response($this->success($order_detail));
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单日志列表
|
||||
* @return false|string
|
||||
*/
|
||||
public function log()
|
||||
{
|
||||
$order_id = $this->params['order_id'] ?? 0;
|
||||
$order_common_model = new OrderCommonModel();
|
||||
|
||||
$order_log_condition = array (
|
||||
[ 'order_id', '=', $order_id ]
|
||||
);
|
||||
$order_log_list = OrderLog::getOrderLogList($order_log_condition, '*', 'action_time desc', $order_common_model);
|
||||
return $this->response($order_log_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单关闭
|
||||
* @return mixed
|
||||
*/
|
||||
public function close()
|
||||
{
|
||||
$order_id = $this->params['order_id'] ?? 0;
|
||||
$order_common_model = new OrderCommonModel();
|
||||
|
||||
//关闭检测
|
||||
$check_res = $order_common_model->activeOrderCloseCheck($order_id);
|
||||
if($check_res['code'] < 0) $this->response($check_res);
|
||||
|
||||
$log_data = [
|
||||
'uid' => $this->user_info[ 'uid' ],
|
||||
'nick_name' => $this->user_info[ 'username' ],
|
||||
'action_way' => 2
|
||||
];
|
||||
$result = $order_common_model->orderClose($order_id, $log_data);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单调价
|
||||
* @return mixed
|
||||
*/
|
||||
public function adjustPrice()
|
||||
{
|
||||
$order_id = $this->params[ 'order_id' ] ?? 0;
|
||||
$adjust_money = $this->params['adjust_money'] ?? 0;
|
||||
$delivery_money = $this->params['delivery_money'] ?? 0;
|
||||
$order_common_model = new OrderCommonModel();
|
||||
$result = $order_common_model->orderAdjustMoney($order_id, $adjust_money, $delivery_money);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单发货
|
||||
* @return mixed
|
||||
*/
|
||||
public function delivery()
|
||||
{
|
||||
$order_id = $this->params[ 'order_id' ] ?? 0;
|
||||
$order_goods_ids = $this->params['order_goods_ids'] ?? '';
|
||||
$express_company_id = $this->params['express_company_id'] ?? 0;
|
||||
$delivery_no = $this->params['delivery_no'] ?? '';
|
||||
$delivery_type = $this->params['delivery_type'] ?? 0;
|
||||
$order_model = new OrderModel();
|
||||
$data = array (
|
||||
"type" => $this->params['type'] ?? 'manual',//发货方式(手动发货、电子面单)
|
||||
"order_goods_ids" => $order_goods_ids,
|
||||
"express_company_id" => $express_company_id,
|
||||
"delivery_no" => $delivery_no,
|
||||
"order_id" => $order_id,
|
||||
"delivery_type" => $delivery_type,
|
||||
"site_id" => $this->site_id,
|
||||
"template_id" => $this->params['template_id'] ?? '0'//电子面单模板id
|
||||
);
|
||||
$log_data = [
|
||||
'uid' => $this->user_info[ 'uid' ],
|
||||
'nick_name' => $this->user_info[ 'username' ],
|
||||
'action' => '商家对订单进行了发货',
|
||||
'action_way' => 2
|
||||
];
|
||||
$result = $order_model->orderGoodsDelivery($data, 1, $log_data);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单项列表
|
||||
*/
|
||||
public function getOrderGoodsList()
|
||||
{
|
||||
$order_id = $this->params[ 'order_id' ] ?? 0;
|
||||
$delivery_status = $this->params[ 'delivery_status' ] ?? '';
|
||||
|
||||
$order_common_model = new OrderCommonModel();
|
||||
$condition = array (
|
||||
[ "order_id", "=", $order_id ],
|
||||
[ "site_id", "=", $this->site_id ],
|
||||
[ "refund_status", "<>", 3 ],
|
||||
);
|
||||
if ($delivery_status != '') {
|
||||
$condition[] = [ "delivery_status", "=", $delivery_status ];
|
||||
}
|
||||
$field = "order_goods_id, order_id, site_id, sku_name, sku_image, sku_no, is_virtual, price, cost_price, num, goods_money, cost_money, delivery_status, delivery_no, goods_id, delivery_status_name,refund_status,refund_status_name";
|
||||
$result = $order_common_model->getOrderGoodsList($condition, $field, '', null, "");
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单修改收货地址
|
||||
* @return mixed
|
||||
*/
|
||||
public function editAddress()
|
||||
{
|
||||
$order_id = $this->params[ 'order_id' ] ?? 0;
|
||||
|
||||
$order_model = new OrderModel();
|
||||
$province_id = $this->params['province_id'] ?? '';
|
||||
$city_id = $this->params['city_id'] ?? '';
|
||||
$district_id = $this->params['district_id'] ?? '';
|
||||
$community_id = $this->params['community_id'] ?? '';
|
||||
$address = $this->params['address'] ?? '';
|
||||
$full_address = $this->params['full_address'] ?? '';
|
||||
$longitude = $this->params['longitude'] ?? '';
|
||||
$latitude = $this->params['latitude'] ?? '';
|
||||
$mobile = $this->params['mobile'] ?? '';
|
||||
$telephone = $this->params['telephone'] ?? '';
|
||||
$name = $this->params['name'] ?? '';
|
||||
$data = array (
|
||||
"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,
|
||||
"mobile" => $mobile,
|
||||
"telephone" => $telephone,
|
||||
"name" => $name,
|
||||
);
|
||||
$condition = array (
|
||||
[ "order_id", "=", $order_id ],
|
||||
[ "site_id", "=", $this->site_id ]
|
||||
);
|
||||
$log_data = [
|
||||
'uid' => $this->user_info[ 'uid' ],
|
||||
'nick_name' => $this->user_info[ 'username' ],
|
||||
'action' => '商家修改了收货地址',
|
||||
'action_way' => '2',
|
||||
'order_id' => $order_id
|
||||
];
|
||||
$result = $order_model->orderAddressUpdate($data, $condition, $log_data);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单信息
|
||||
*/
|
||||
public function getOrderInfo()
|
||||
{
|
||||
$order_id = $this->params[ 'order_id' ] ?? 0;
|
||||
|
||||
$order_common_model = new OrderCommonModel();
|
||||
$condition = array (
|
||||
[ "order_id", "=", $order_id ],
|
||||
[ "site_id", "=", $this->site_id ],
|
||||
);
|
||||
$result = $order_common_model->getOrderInfo($condition);
|
||||
// 获取配送员信息
|
||||
if(!empty($result['data'])){
|
||||
$deliver_model = new ExpressDeliver();
|
||||
$deliver_condition = [ [ 'site_id', '=', $this->site_id ] ];
|
||||
if(addon_is_exit('store')){
|
||||
$deliver_condition[] = ['store_id', '=', $result['data']['store_id']];
|
||||
}
|
||||
$result[ 'data' ][ 'deliver_list' ] = $deliver_model->getDeliverLists($deliver_condition, 'deliver_id,deliver_name,deliver_mobile')[ 'data' ];
|
||||
}
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单 订单项内容
|
||||
*/
|
||||
public function getOrderDetail()
|
||||
{
|
||||
$order_id = $this->params[ 'order_id' ] ?? 0;
|
||||
$order_common_model = new OrderCommonModel();
|
||||
$result = $order_common_model->getOrderDetail($order_id);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 卖家备注
|
||||
*/
|
||||
public function orderRemark()
|
||||
{
|
||||
$order_id = $this->params[ 'order_id' ] ?? 0;
|
||||
$remark = $this->params[ 'remark' ] ?? '';
|
||||
|
||||
$order_common_model = new OrderCommonModel();
|
||||
$condition = array (
|
||||
[ "order_id", "=", $order_id ],
|
||||
[ "site_id", "=", $this->site_id ],
|
||||
);
|
||||
$data = array (
|
||||
"remark" => $remark
|
||||
);
|
||||
$log_data = [
|
||||
'action' => '商家备注了订单,备注内容:' . $remark,
|
||||
'action_way' => 2,
|
||||
'uid' => $this->user_info[ 'uid' ],
|
||||
'nick_name' => $this->user_info[ 'username' ],
|
||||
'order_id' => $order_id
|
||||
];
|
||||
$result = $order_common_model->orderUpdate($data, $condition, $log_data);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 延长收货时间
|
||||
*/
|
||||
public function extendTakeDelivery()
|
||||
{
|
||||
$order_id = $this->params[ 'order_id' ] ?? 0;
|
||||
$condition = array (
|
||||
[ 'order_id', '=', $order_id ],
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
);
|
||||
$order_common_model = new OrderCommonModel();
|
||||
$log_data = [
|
||||
'uid' => $this->uid,
|
||||
'username' => $this->user_info[ 'username' ],
|
||||
'module' => 'shop'
|
||||
];
|
||||
$result = $order_common_model->extendTakeDelivery($condition, $log_data);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 线下支付
|
||||
*/
|
||||
public function offlinePay()
|
||||
{
|
||||
$order_id = $this->params[ 'order_id' ] ?? 0;
|
||||
$order_common_model = new OrderCommonModel();
|
||||
$log_data = [
|
||||
'uid' => $this->user_info[ 'uid' ],
|
||||
'nick_name' => $this->user_info[ 'username' ],
|
||||
'action_way' => 2
|
||||
];
|
||||
$order_detail_result = $order_common_model->orderOfflinePay($order_id, $log_data);
|
||||
return $this->response($order_detail_result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 订单列表(发票)
|
||||
*/
|
||||
public function invoicelist()
|
||||
{
|
||||
$order_common_model = new OrderCommonModel();
|
||||
$page_index = $this->params[ 'page' ] ?? 1;
|
||||
$page_size = $this->params[ 'page_size' ] ?? PAGE_LIST_ROWS;
|
||||
$invoice_status = input("invoice_status", '');
|
||||
$order_type = $this->params[ 'order_type' ] ?? '';//营销类型
|
||||
$order_status = $this->params[ 'order_status' ] ?? '';
|
||||
$start_time = $this->params[ 'start_time' ] ?? '';
|
||||
$end_time = $this->params[ 'end_time' ] ?? '';
|
||||
//订单编号
|
||||
$order_no = $this->params[ 'search_text' ] ?? '';
|
||||
$alias = 'o';
|
||||
$join = null;
|
||||
$condition = [
|
||||
[ "o.site_id", "=", $this->site_id ],
|
||||
[ 'o.is_invoice', '=', 1 ]
|
||||
];
|
||||
//发票状态
|
||||
if ($invoice_status != '') {
|
||||
$condition[] = [ 'o.invoice_status', '=', $invoice_status ];
|
||||
}
|
||||
if ($order_no) {
|
||||
$condition[] = [ "o.order_no", "like", "%" . $order_no . "%" ];
|
||||
}
|
||||
//订单状态
|
||||
if ($order_status != "") {
|
||||
if ($order_status != 'refunding') {
|
||||
$condition[] = [ "o.order_status", "=", $order_status ];
|
||||
} else {
|
||||
$join = [
|
||||
[
|
||||
'order_goods og',
|
||||
'og.order_id = o.order_id',
|
||||
'left'
|
||||
]
|
||||
];
|
||||
$condition[] = [ "og.refund_status", "not in", [ 0, 3 ] ];
|
||||
}
|
||||
}
|
||||
|
||||
//订单类型
|
||||
if (!empty($order_type)) {
|
||||
$condition[] = [ "o.order_type", "=", $order_type ];
|
||||
}
|
||||
|
||||
if (!empty($start_time) && empty($end_time)) {
|
||||
$condition[] = [ "o.create_time", ">=", date_to_time($start_time . ' 00:00:00') ];
|
||||
} elseif (empty($start_time) && !empty($end_time)) {
|
||||
$condition[] = [ "o.create_time", "<=", date_to_time($end_time . ' 23:59:59') ];
|
||||
} elseif (!empty($start_time) && !empty($end_time)) {
|
||||
$condition[] = [ 'o.create_time', 'between', [ date_to_time($start_time . ' 00:00:00'), date_to_time($end_time . ' 23:59:59') ] ];
|
||||
}
|
||||
$list = $order_common_model->getOrderPageList($condition, $page_index, $page_size, "o.create_time desc", 'o.*', $alias, $join);
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单列表(发票编辑)
|
||||
*/
|
||||
public function invoiceEdit()
|
||||
{
|
||||
//接收数据
|
||||
$order_id = $this->params[ 'order_id' ] ?? '';
|
||||
$invoice_status = $this->params[ 'invoice_status' ] ?? '';
|
||||
$invoice_code = $this->params[ 'invoice_code' ] ?? '';
|
||||
$invoice_remark = $this->params[ 'invoice_remark' ] ?? '';
|
||||
$condition = [
|
||||
[ "order_id", "=", $order_id ]
|
||||
];
|
||||
$data[ 'invoice_status' ] = $invoice_status;
|
||||
$data[ 'invoice_code' ] = $invoice_code;
|
||||
$data[ 'invoice_remark' ] = $invoice_remark;
|
||||
$data[ 'invoice_time' ] = time();
|
||||
$order_common_model = new OrderCommonModel();
|
||||
$res = $order_common_model->orderUpdate($data, $condition);
|
||||
return $this->response($res);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单包裹信息
|
||||
*/
|
||||
public function package()
|
||||
{
|
||||
$order_id = $this->params[ 'order_id' ] ?? '';//订单id
|
||||
$express_package_model = new ExpressPackage();
|
||||
$condition = array (
|
||||
[ "order_id", "=", $order_id ],
|
||||
);
|
||||
$order_model = new OrderCommonModel();
|
||||
$order_info = $order_model->getOrderInfo($condition)[ 'data' ] ?? [];
|
||||
$save_trace = $order_info['order_status'] == OrderCommonModel::ORDER_TAKE_DELIVERY;
|
||||
$condition[] = [ 'site_id', '=', $order_info[ 'site_id' ] ];
|
||||
$package = $express_package_model->package($condition, $order_info[ 'mobile' ], $save_trace);
|
||||
if ($package) {
|
||||
$result = [
|
||||
'package' => $package,
|
||||
'order_status' => $order_info[ 'order_status' ]
|
||||
];
|
||||
return $this->response($this->success($result));
|
||||
} else {
|
||||
return $this->response($this->error());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改单个订单的物流信息(电子面单的除外)
|
||||
*/
|
||||
public function editOrderDelivery()
|
||||
{
|
||||
$order_id = $this->params[ 'order_id' ] ?? 0;// 订单id
|
||||
$package_id = $this->params[ 'package_id' ] ?? 0;// 包裹id
|
||||
$delivery_type = $this->params[ 'delivery_type' ] ?? 0;// 是否需要物流
|
||||
$express_company_id = $this->params[ 'express_company_id' ] ?? '';// 物流公司
|
||||
$delivery_no = $this->params[ 'delivery_no' ] ?? '';// 物流单号
|
||||
|
||||
$delivery_json = array (
|
||||
'site_id' => $this->site_id,
|
||||
'order_id' => $order_id,
|
||||
'package_id' => $package_id,
|
||||
'delivery_type' => $delivery_type,
|
||||
'express_company_id' => $express_company_id,
|
||||
'delivery_no' => $delivery_no
|
||||
);
|
||||
$express_package_model = new ExpressPackage();
|
||||
$res = $express_package_model->editOrderExpressDeliveryPackage($delivery_json);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认收货
|
||||
*/
|
||||
public function takeDelivery()
|
||||
{
|
||||
$order_id = $this->params[ 'order_id' ] ?? 0;// 订单id
|
||||
$order_model = new OrderCommonModel();
|
||||
$log_data = [
|
||||
'uid' => $this->user_info[ 'uid' ],
|
||||
'nick_name' => $this->user_info[ 'username' ],
|
||||
'action_way' => 2
|
||||
];
|
||||
$result = $order_model->orderCommonTakeDelivery($order_id, $log_data);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 交易配置
|
||||
*/
|
||||
public function config()
|
||||
{
|
||||
$config_model = new ConfigModel();
|
||||
//订单事件时间设置
|
||||
$order_event_time_config = $config_model->getOrderEventTimeConfig($this->site_id, $this->app_module);
|
||||
$order_event_time_config[ 'data' ][ 'value' ][ 'invoice_content' ] = explode(',', $order_event_time_config[ 'data' ][ 'value' ][ 'invoice_content' ]);
|
||||
$order_event_time_config[ 'data' ][ 'value' ][ 'invoice_type' ] = explode(',', $order_event_time_config[ 'data' ][ 'value' ][ 'invoice_type' ]);
|
||||
//订单评价设置
|
||||
$order_evaluate_config = $config_model->getOrderEvaluateConfig($this->site_id, $this->app_module)[ 'data' ][ 'value' ];
|
||||
//余额支付配置
|
||||
$balance_config = $config_model->getBalanceConfig($this->site_id, $this->app_module)[ 'data' ][ 'value' ];
|
||||
$data[ 'balance_config' ] = $balance_config;
|
||||
$data[ 'order_event_time_config' ] = $order_event_time_config[ 'data' ][ 'value' ];
|
||||
$data[ 'order_evaluate_config' ] = $order_evaluate_config;
|
||||
return $this->response($this->success($data));
|
||||
}
|
||||
|
||||
public function setConfig()
|
||||
{
|
||||
$config_model = new ConfigModel();
|
||||
//订单事件时间设置数据
|
||||
$order_event_time_config_data = [
|
||||
'auto_close' => $this->params[ 'order_auto_close_time' ] ?? 0,//订单未付款自动关闭时间 数字 单位(分钟)
|
||||
'auto_take_delivery' => $this->params[ 'order_auto_take_delivery_time' ] ?? 0,//订单发货后自动收货时间 数字 单位(天)
|
||||
'auto_complete' => $this->params[ 'order_auto_complete_time' ] ?? 0,//订单收货后自动完成时间 数字 单位(天)
|
||||
'after_sales_time' => $this->params[ 'after_sales_time' ] ?? 0,//订单完成后可维权时间 数字 单位(天)
|
||||
'invoice_status' => $this->params[ 'invoice_status' ] ?? 0,
|
||||
'invoice_rate' => $this->params[ 'invoice_rate' ] ?? 0,
|
||||
'invoice_content' => implode(',', explode(',', isset($this->params[ 'invoice_content' ]) && !empty($this->params[ 'invoice_content' ]) ? $this->params[ 'invoice_content' ] : '')),
|
||||
'invoice_money' => $this->params[ 'invoice_money' ] ?? 0,
|
||||
'invoice_type' => implode(',', explode(',', isset($this->params[ 'invoice_type' ]) && !empty($this->params[ 'invoice_type' ]) ? $this->params[ 'invoice_type' ] : ''))
|
||||
];
|
||||
//订单评价设置数据
|
||||
$order_evaluate_config_data = [
|
||||
'evaluate_status' => $this->params[ 'evaluate_status' ] ?? 0,//订单评价状态(0关闭 1开启)
|
||||
'evaluate_show' => $this->params[ 'evaluate_show' ] ?? 0,//显示评价(0关闭 1开启)
|
||||
'evaluate_audit' => $this->params[ 'evaluate_audit' ] ?? 0,//评价审核状态(0关闭 1开启)
|
||||
];
|
||||
$res = $config_model->setOrderEventTimeConfig($order_event_time_config_data, $this->site_id, $this->app_module);
|
||||
$config_model->setOrderEvaluateConfig($order_evaluate_config_data, $this->site_id, $this->app_module);
|
||||
return $this->response($res);
|
||||
}
|
||||
}
|
||||
281
app/shopapi/controller/Orderrefund.php
Executable file
281
app/shopapi/controller/Orderrefund.php
Executable file
@@ -0,0 +1,281 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\dict\order_refund\OrderRefundDict;
|
||||
use app\model\order\OrderCommon;
|
||||
use app\model\order\OrderRefund as OrderRefundModel;
|
||||
use app\model\member\Member;
|
||||
|
||||
/**
|
||||
* 订单维权
|
||||
* Class Orderrefund
|
||||
* @package app\shop\controller
|
||||
*/
|
||||
class Orderrefund extends BaseApi
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//执行父类构造函数
|
||||
parent::__construct();
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) {
|
||||
echo json_encode($token);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单条件
|
||||
* @return false|string
|
||||
*/
|
||||
public function condition()
|
||||
{
|
||||
$data = [
|
||||
'refund_status_list' => OrderRefundDict::getStatus(),//退款状态
|
||||
'refund_type_list' => OrderRefundDict::getRefundType()//退款方式
|
||||
];
|
||||
|
||||
return $this->response($this->success($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 维权订单列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$refund_status = $this->params['refund_status'] ?? '';//退款状态
|
||||
$sku_name = $this->params['sku_name'] ?? '';//商品名称
|
||||
$refund_type = $this->params['refund_type'] ?? '';//退款方式
|
||||
$start_time = $this->params['start_time'] ?? '';//开始时间
|
||||
$end_time = $this->params['end_time'] ?? '';//结束时间
|
||||
$order_no = $this->params['order_no'] ?? '';//订单编号
|
||||
$delivery_status = $this->params['delivery_status'] ?? '';//物流状态
|
||||
$refund_no = $this->params['refund_no'] ?? '';//退款编号
|
||||
$delivery_no = $this->params['delivery_no'] ?? '';//物流编号
|
||||
$refund_delivery_no = $this->params['refund_delivery_no'] ?? '';//退款物流编号
|
||||
$order_refund_model = new OrderRefundModel();
|
||||
|
||||
$page_index = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
$condition = [
|
||||
[ "nop.site_id", "=", $this->site_id ]
|
||||
];
|
||||
//退款状态
|
||||
if ($refund_status != "") {
|
||||
$condition[] = [ "nop.refund_status", "=", $refund_status ];
|
||||
} else {
|
||||
$condition[] = [ "nop.refund_status", "<>", 0 ];
|
||||
}
|
||||
//物流状态
|
||||
if ($delivery_status != "") {
|
||||
$condition[] = [ "nop.delivery_status", "=", $delivery_status ];
|
||||
}
|
||||
//商品名称
|
||||
if ($sku_name != "") {
|
||||
$condition[] = [ "nop.sku_name", "like", "%$sku_name%" ];
|
||||
}
|
||||
//退款方式
|
||||
if ($refund_type != "") {
|
||||
$condition[] = [ "nop.refund_type", "=", $refund_type ];
|
||||
}
|
||||
//退款编号
|
||||
if ($refund_no != "") {
|
||||
$condition[] = [ "nop.refund_no", "like", "%$refund_no%" ];
|
||||
}
|
||||
//订单编号
|
||||
if ($order_no != "") {
|
||||
$condition[] = [ "nop.order_no", "like", "%$order_no%" ];
|
||||
}
|
||||
//物流编号
|
||||
if ($delivery_no != "") {
|
||||
$condition[] = [ "nop.delivery_no", "like", "%$delivery_no%" ];
|
||||
}
|
||||
//退款物流编号
|
||||
if ($refund_delivery_no != "") {
|
||||
$condition[] = [ "nop.refund_delivery_no", "like", "%$refund_delivery_no%" ];
|
||||
}
|
||||
|
||||
if (!empty($start_time) && empty($end_time)) {
|
||||
$condition[] = [ "nop.refund_action_time", ">=", date_to_time($start_time) ];
|
||||
} elseif (empty($start_time) && !empty($end_time)) {
|
||||
$condition[] = [ "nop.refund_action_time", "<=", date_to_time($end_time) ];
|
||||
} elseif (!empty($start_time) && !empty($end_time)) {
|
||||
$condition[] = [ 'nop.refund_action_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
|
||||
}
|
||||
$list = $order_refund_model->getRefundOrderGoodsPageList($condition, $page_index, $page_size, "nop.refund_action_time desc");
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 维权订单详情
|
||||
* @return mixed
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$order_goods_id = $this->params['order_goods_id'] ?? 0;
|
||||
//维权订单项信息
|
||||
$order_refund_model = new OrderRefundModel();
|
||||
|
||||
$detail = $order_refund_model->getRefundDetail($order_goods_id)[ 'data' ];
|
||||
|
||||
if (empty($detail)) {
|
||||
return $this->response($this->error('查询不到此退款信息!'));
|
||||
}
|
||||
if ($detail[ 'site_id' ] != $this->site_id) {
|
||||
return $this->response($this->error('查询不到此退款信息!'));
|
||||
}
|
||||
|
||||
$order_common_model = new OrderCommon();
|
||||
$order_info_result = $order_common_model->getOrderInfo([ [ "order_id", "=", $detail[ "order_id" ] ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
$order_info = $order_info_result[ "data" ];
|
||||
|
||||
//添加会员昵称
|
||||
$member = new Member();
|
||||
$member_info = $member->getMemberInfo([ [ "member_id", '=', $order_info[ 'member_id' ] ] ], 'nickname');
|
||||
$order_info[ 'nickname' ] = $member_info[ 'data' ][ 'nickname' ];
|
||||
|
||||
$data = [
|
||||
'detail' => $detail,
|
||||
'order_info' => $order_info
|
||||
];
|
||||
return $this->response($this->success($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 维权拒绝
|
||||
* @return mixed
|
||||
*/
|
||||
public function refuse()
|
||||
{
|
||||
$order_goods_id = $this->params['order_goods_id'] ?? 0;
|
||||
$refund_refuse_reason = $this->params['refund_refuse_reason'] ?? '';
|
||||
$order_refund_model = new OrderRefundModel();
|
||||
$data = array (
|
||||
"order_goods_id" => $order_goods_id,
|
||||
"refund_refuse_reason" => $refund_refuse_reason,
|
||||
'site_id' => $this->site_id
|
||||
);
|
||||
$log_data = [
|
||||
'uid' => $this->user_info[ 'uid' ],
|
||||
'nick_name' => $this->user_info[ 'username' ],
|
||||
'action' => '商家拒绝了维权',
|
||||
'action_way' => 2
|
||||
];
|
||||
$res = $order_refund_model->orderRefundRefuse($data, $this->user_info, $refund_refuse_reason, $log_data);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 维权同意
|
||||
* @return mixed
|
||||
*/
|
||||
public function agree()
|
||||
{
|
||||
$order_goods_id = $this->params['order_goods_id'] ?? 0;
|
||||
$order_refund_model = new OrderRefundModel();
|
||||
$data = array (
|
||||
"order_goods_id" => $order_goods_id,
|
||||
'site_id' => $this->site_id
|
||||
);
|
||||
$res = $order_refund_model->orderRefundConfirm($data, $this->user_info);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 维权收货
|
||||
* @return mixed
|
||||
*/
|
||||
public function receive()
|
||||
{
|
||||
$order_goods_id = $this->params['order_goods_id'] ?? 0;
|
||||
$is_refund_stock = $this->params['is_refund_stock'] ?? 0;
|
||||
$order_refund_model = new OrderRefundModel();
|
||||
$data = array (
|
||||
"order_goods_id" => $order_goods_id,
|
||||
"is_refund_stock" => $is_refund_stock,
|
||||
'site_id' => $this->site_id
|
||||
);
|
||||
$res = $order_refund_model->orderRefundTakeDelivery($data, $this->user_info);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 维权通过
|
||||
* @return mixed
|
||||
*/
|
||||
public function complete()
|
||||
{
|
||||
$order_goods_id = $this->params['order_goods_id'] ?? 0;
|
||||
$refund_money_type = $this->params[ 'refund_money_type' ] ?? 2;
|
||||
$shop_refund_remark = $this->params[ 'shop_refund_remark' ] ?? '';
|
||||
$refund_real_money = $this->params[ 'refund_real_money' ] ?? 0;
|
||||
$order_refund_model = new OrderRefundModel();
|
||||
$data = array (
|
||||
'order_goods_id' => $order_goods_id,
|
||||
'site_id' => $this->site_id,
|
||||
'refund_money_type' => $refund_money_type,
|
||||
'shop_refund_remark' => $shop_refund_remark,
|
||||
'refund_real_money' => $refund_real_money
|
||||
);
|
||||
$log_data = [
|
||||
'uid' => $this->user_info[ 'uid' ],
|
||||
'nick_name' => $this->user_info[ 'username' ],
|
||||
'action' => '商家对维权进行了转账,维权结束',
|
||||
'action_way' => 2
|
||||
];
|
||||
$res = $order_refund_model->orderRefundFinish($data, $this->user_info, $log_data);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 维权关闭
|
||||
* @return false|string
|
||||
*/
|
||||
public function close()
|
||||
{
|
||||
$order_goods_id = $this->params['order_goods_id'] ?? 0;
|
||||
$order_refund_model = new OrderRefundModel();
|
||||
$res = $order_refund_model->orderRefundClose($order_goods_id, $this->site_id, $this->user_info);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 主动退款
|
||||
* @return false|string
|
||||
*/
|
||||
public function activeRefund()
|
||||
{
|
||||
$order_goods_id = $this->params[ 'order_goods_id' ] ?? 0;
|
||||
$shop_active_refund_money_type = $this->params[ 'shop_active_refund_money_type' ] ?? '';
|
||||
$shop_active_refund_remark = $this->params[ 'shop_active_refund_remark' ] ?? '';
|
||||
$shop_active_refund_money = $this->params[ 'shop_active_refund_money' ] ?? '';
|
||||
$refund_status = $this->params['refund_status'] ?? 'PARTIAL_REFUND';
|
||||
|
||||
$order_refund_model = new OrderRefundModel();
|
||||
$params = array (
|
||||
'site_id' => $this->site_id,
|
||||
'app_module' => $this->app_module,
|
||||
'shop_active_refund_money_type' => $shop_active_refund_money_type,
|
||||
'shop_active_refund_remark' => $shop_active_refund_remark,
|
||||
'user_info' => $this->user_info,
|
||||
'order_goods_id' => $order_goods_id,
|
||||
'shop_active_refund_money' => $shop_active_refund_money,
|
||||
'refund_status' => $refund_status,
|
||||
);
|
||||
$res = $order_refund_model->shopActiveRefund($params);
|
||||
return $this->response($res);
|
||||
}
|
||||
}
|
||||
55
app/shopapi/controller/Register.php
Executable file
55
app/shopapi/controller/Register.php
Executable file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
113
app/shopapi/controller/Settlement.php
Executable file
113
app/shopapi/controller/Settlement.php
Executable file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\shop\ShopSettlement;
|
||||
use app\model\order\OrderCommon as OrderCommonModel;
|
||||
|
||||
/**
|
||||
* 店铺结算
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
class Settlement extends BaseApi
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
//执行父类构造函数
|
||||
parent::__construct();
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) {
|
||||
echo json_encode($token);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 结算列表
|
||||
* @return false|string
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$model = new ShopSettlement();
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
|
||||
$condition[] = [ 'site_id', '=', $this->site_id ];
|
||||
|
||||
$start_time = $this->params['start_time'] ?? '';
|
||||
$end_time = $this->params['end_time'] ?? '';
|
||||
if (!empty($start_time) && empty($end_time)) {
|
||||
$condition[] = [ 'period_start_time', '>=', $start_time ];
|
||||
} elseif (empty($start_time) && !empty($end_time)) {
|
||||
$condition[] = [ 'period_end_time', '<=', $end_time ];
|
||||
} elseif (!empty($start_time) && !empty($end_time)) {
|
||||
$condition[] = [ 'period_start_time', '>=', $start_time ];
|
||||
$condition[] = [ 'period_end_time', '<=', $end_time ];
|
||||
}
|
||||
|
||||
$order = 'id desc';
|
||||
$field = 'id,settlement_no,site_id,period_id,site_name,order_money,shop_money,refund_platform_money,platform_money,refund_shop_money,
|
||||
refund_money,create_time,period_start_time,period_end_time,commission,platform_coupon_money,refund_platform_coupon_money';
|
||||
$list = $model->getShopSettlementPageList($condition, $page, $page_size, $order, $field);
|
||||
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 结算信息
|
||||
* @return false|string
|
||||
*/
|
||||
public function info()
|
||||
{
|
||||
$model = new ShopSettlement();
|
||||
|
||||
$id = $this->params['id'] ?? '';
|
||||
$field = 'id,settlement_no,site_id,period_id,site_name,order_money,shop_money,refund_platform_money,platform_money,refund_shop_money,
|
||||
refund_money,create_time,period_start_time,period_end_time,commission,platform_coupon_money,refund_platform_coupon_money';
|
||||
$info = $model->getShopSettlementInfo([ [ 'id', '=', $id ] ], $field);
|
||||
$info = $info[ 'data' ];
|
||||
//店铺收入
|
||||
$shop_money = $info[ 'shop_money' ] - $info[ 'refund_shop_money' ] - $info[ 'commission' ] + $info[ 'platform_coupon_money' ] - $info[ 'refund_platform_coupon_money' ];
|
||||
//平台收入
|
||||
$money = $info[ 'platform_money' ] - $info[ 'refund_platform_money' ];
|
||||
|
||||
$data = [
|
||||
'info' => $info,
|
||||
'shop_money' => number_format($shop_money, 2, '.', ''),
|
||||
'money' => number_format($money, 2, '.', '')
|
||||
];
|
||||
return $this->response($this->success($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 结算明细
|
||||
* @return false|string
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$id = $this->params['id'] ?? '';
|
||||
|
||||
$order_model = new OrderCommonModel();
|
||||
$condition[] = [ 'settlement_id', '=', $id ];
|
||||
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
|
||||
$field = 'order_id,order_no,order_money,order_status,shop_money,platform_money,refund_money,refund_shop_money,refund_platform_money,commission,finish_time,platform_coupon_money,refund_platform_coupon_money';
|
||||
$list = $order_model->getOrderPageList($condition, $page, $page_size, 'finish_time desc', $field);
|
||||
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
}
|
||||
149
app/shopapi/controller/Shop.php
Executable file
149
app/shopapi/controller/Shop.php
Executable file
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\exception\ApiException;
|
||||
use app\model\shop\Shop as ShopModel;
|
||||
use app\model\system\Site;
|
||||
|
||||
/**
|
||||
* 店铺
|
||||
* Class Shop
|
||||
* @package app\shop\controller
|
||||
*/
|
||||
class Shop extends BaseApi
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//执行父类构造函数
|
||||
parent::__construct();
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) {
|
||||
throw new ApiException($token['code'], $token['message']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取店铺信息
|
||||
* @return false|string
|
||||
*/
|
||||
public function shopInfo()
|
||||
{
|
||||
$condition = array (
|
||||
[ "site_id", "=", $this->site_id ]
|
||||
);
|
||||
$shop_info_result = (new ShopModel())->getShopInfo($condition);
|
||||
$site_info = (new Site())->getSiteInfo($condition);
|
||||
|
||||
$shop_info = array_merge($shop_info_result['data'], $site_info['data']);
|
||||
|
||||
$user_info = [
|
||||
'group_id' => $this->user_info[ 'group_id' ],
|
||||
'group_name' => $this->user_info[ 'group_name' ],
|
||||
'is_admin' => $this->user_info[ 'is_admin' ],
|
||||
'status' => $this->user_info[ 'status' ],
|
||||
'uid' => $this->user_info[ 'uid' ],
|
||||
'username' => $this->user_info[ 'username' ],
|
||||
];
|
||||
$res = [
|
||||
'shop_info' => $shop_info,
|
||||
'user_info' => $user_info
|
||||
];
|
||||
return $this->response($this->success($res));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 店铺设置
|
||||
* @return mixed
|
||||
*/
|
||||
public function config()
|
||||
{
|
||||
$shop_model = new Site();
|
||||
$logo = $this->params['logo'] ?? '';//店铺logo
|
||||
$avatar = $this->params['avatar'] ?? '';//店铺头像(大图)
|
||||
$banner = $this->params['banner'] ?? '';//店铺条幅
|
||||
$sit_name = $this->params['site_name'] ?? '';
|
||||
$seo_keywords = $this->params['seo_keywords'] ?? '';
|
||||
$seo_description = $this->params['seo_description'] ?? '';//店铺简介
|
||||
$data = array (
|
||||
"logo" => $logo,
|
||||
"avatar" => $avatar,
|
||||
"site_name"=> $sit_name,
|
||||
"banner" => $banner,
|
||||
"seo_keywords" => $seo_keywords,
|
||||
"seo_description" => $seo_description,
|
||||
);
|
||||
$res = $shop_model->editSite($data, [ [ 'site_id', '=', $this->site_id ] ]);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 联系方式
|
||||
* @return mixed
|
||||
*/
|
||||
public function contact()
|
||||
{
|
||||
$shop_model = new ShopModel();
|
||||
|
||||
$province = $this->params['province'] ?? '';//省级地址
|
||||
$province_name = $this->params['province_name'] ?? '';//省级地址
|
||||
$city = $this->params['city'] ?? '';//市级地址
|
||||
$city_name = $this->params['city_name'] ?? '';//市级地址
|
||||
$district = $this->params['district'] ?? '';//县级地址
|
||||
$district_name = $this->params['district_name'] ?? '';//县级地址
|
||||
$community = $this->params['community'] ?? '';//乡镇地址
|
||||
$community_name = $this->params['community_name'] ?? '';//乡镇地址
|
||||
$address = $this->params['address'] ?? '';//详细地址
|
||||
$full_address = $this->params['full_address'] ?? '';//完整地址
|
||||
$longitude = $this->params['longitude'] ?? '';//经度
|
||||
$latitude = $this->params['latitude'] ?? '';//纬度
|
||||
|
||||
$qq = $this->params['qq'] ?? '';//qq
|
||||
$ww = $this->params['ww'] ?? '';//ww
|
||||
$email = $this->params['email'] ?? '';//邮箱
|
||||
$telephone = $this->params['telephone'] ?? '';//联系电话
|
||||
$name = $this->params['name'] ?? '';//联系人姓名
|
||||
$mobile = $this->params['mobile'] ?? '';//联系人手机号
|
||||
$work_week = $this->params['work_week'] ?? '';//工作日 例如 : 1,2,3,4,5,6,7
|
||||
$start_time = $this->params['start_time'] ?? '';//开始时间
|
||||
$end_time = $this->params['end_time'] ?? '';//结束时间
|
||||
$data = array (
|
||||
"province" => $province,
|
||||
"province_name" => $province_name,
|
||||
"city" => $city,
|
||||
"city_name" => $city_name,
|
||||
"district" => $district,
|
||||
"district_name" => $district_name,
|
||||
"community" => $community,
|
||||
"community_name" => $community_name,
|
||||
"address" => $address,
|
||||
"full_address" => $full_address,
|
||||
"longitude" => $longitude,
|
||||
"latitude" => $latitude,
|
||||
"qq" => $qq,
|
||||
"ww" => $ww,
|
||||
"email" => $email,
|
||||
"telephone" => $telephone,
|
||||
"work_week" => $work_week,
|
||||
"start_time" => $start_time,
|
||||
"end_time" => $end_time,
|
||||
"name" => $name,
|
||||
"mobile" => $mobile
|
||||
);
|
||||
$res = $shop_model->editShop($data, [ [ 'site_id', '=', $this->site_id ] ]);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
}
|
||||
125
app/shopapi/controller/Shopreopen.php
Executable file
125
app/shopapi/controller/Shopreopen.php
Executable file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\shop\ShopReopen as ShopReopenModel;
|
||||
|
||||
/**
|
||||
* 店铺
|
||||
* Class Shop
|
||||
* @package app\shop\controller
|
||||
*/
|
||||
class Shopreopen extends BaseApi
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//执行父类构造函数
|
||||
parent::__construct();
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) {
|
||||
echo json_encode($token);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getReopenDetail()
|
||||
{
|
||||
$reopen_model = new ShopReopenModel();
|
||||
$reopen_info = $reopen_model->getReopenInfo([ [ 'sr.apply_state', 'in', '-1,1' ], [ 'sr.site_id', '=', $this->site_id ] ], '*');
|
||||
return $this->response($reopen_info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取续费信息
|
||||
*/
|
||||
public function getReopenInfo()
|
||||
{
|
||||
$reopen_model = new ShopReopenModel();
|
||||
|
||||
$id = $this->params['id'] ?? '';
|
||||
//获取续签信息
|
||||
$result = $reopen_model->getReopenInfo([ [ 'sr.id', '=', $id ], [ 'sr.site_id', '=', $this->site_id ] ], '*');
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加续签
|
||||
* @return false|string
|
||||
*/
|
||||
public function addReopen()
|
||||
{
|
||||
$reopen_data = [
|
||||
'site_id' => $this->site_id,//店铺ID
|
||||
'apply_year' => $this->params['apply_year'] ?? '',//入驻年长
|
||||
'shop_group_name' => $this->params['shop_group_name'] ?? '',//开店套餐名称
|
||||
'shop_group_id' => $this->params['shop_group_id'] ?? '',//开店套餐id
|
||||
'paying_money_certificate' => $this->params['paying_money_certificate'] ?? '',//支付凭证
|
||||
'paying_money_certificate_explain' => $this->params['paying_money_certificate_explain'] ?? ''//付款凭证说明
|
||||
];
|
||||
|
||||
$reopen_model = new ShopReopenModel();
|
||||
//计算入驻金额
|
||||
$apply_money = $reopen_model->getReopenMoney($reopen_data[ 'apply_year' ], $reopen_data[ 'shop_group_id' ]);
|
||||
$reopen_data[ 'paying_amount' ] = $apply_money[ 'data' ][ 'money' ];
|
||||
|
||||
$result = $reopen_model->addReopen($reopen_data);
|
||||
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑续签
|
||||
* @return false|string
|
||||
*/
|
||||
public function editReopen()
|
||||
{
|
||||
$reopen_data = [
|
||||
'site_id' => $this->site_id,
|
||||
'id' => $this->params['id'] ?? '',
|
||||
'paying_money_certificate' => $this->params['paying_money_certificate'] ?? '',//支付凭证
|
||||
'paying_money_certificate_explain' => $this->params['paying_money_certificate_explain'] ?? ''//付款凭证说明
|
||||
];
|
||||
|
||||
$model = new ShopReopenModel();
|
||||
$result = $model->editReopen($reopen_data);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除续签
|
||||
*/
|
||||
public function deleteReopen()
|
||||
{
|
||||
$id = $this->params['id'] ?? '';
|
||||
$model = new ShopReopenModel();
|
||||
|
||||
$res = $model->deleteReopen($id);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取续签金额
|
||||
*/
|
||||
public function getReopenMoney()
|
||||
{
|
||||
$apply_year = $this->params['apply_year'] ?? '';//入驻年长
|
||||
$group_id = $this->params['group_id'] ?? '';//店铺等级ID
|
||||
|
||||
$model = new ShopReopenModel();
|
||||
$result = $model->getReopenMoney($apply_year, $group_id);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
}
|
||||
152
app/shopapi/controller/Shopwithdraw.php
Executable file
152
app/shopapi/controller/Shopwithdraw.php
Executable file
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\member\Withdraw as MemberWithdrawModel;
|
||||
use app\model\shop\ShopAccount;
|
||||
use app\model\shop\Shop as ShopModel;
|
||||
use app\model\web\Account as AccountModel;
|
||||
|
||||
class Shopwithdraw extends BaseApi
|
||||
{
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//执行父类构造函数
|
||||
parent::__construct();
|
||||
$token = $this->checkToken();
|
||||
if ($token['code'] < 0) {
|
||||
echo json_encode($token);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 账户信息
|
||||
* @return false|string
|
||||
*/
|
||||
public function info()
|
||||
{
|
||||
$account_model = new AccountModel();
|
||||
//会员余额
|
||||
$member_balance_sum = $account_model->getMemberBalanceSum($this->site_id);
|
||||
$is_memberwithdraw = addon_is_exit('memberwithdraw', $this->site_id);
|
||||
if ($is_memberwithdraw == 1) {
|
||||
$data = $member_balance_sum['data'];
|
||||
} else {
|
||||
$data = number_format($member_balance_sum['data']['balance'] + $member_balance_sum['data']['balance_money'], 2, '.', '');
|
||||
}
|
||||
return $this->response($this->success($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请提现
|
||||
* */
|
||||
public function apply()
|
||||
{
|
||||
$money = $this->params['apply_money'] ?? '';
|
||||
$shop_account_model = new ShopAccount();
|
||||
$result = $shop_account_model->applyWithdraw($this->site_id, $money);
|
||||
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取提现记录
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$withdraw_model = new MemberWithdrawModel();
|
||||
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
$status = $this->params['status'] ?? '';
|
||||
$start_time = $this->params['start_time'] ?? '';
|
||||
$end_time = $this->params['end_time'] ?? '';
|
||||
$search_text = $this->params['search_text'] ?? '';
|
||||
$condition[] = ['site_id', '=', $this->site_id];
|
||||
if (!empty($status)) {
|
||||
if ($status == 3) {//待审核
|
||||
$condition[] = ['status', '=', 0];
|
||||
} else {
|
||||
$condition[] = ['status', '=', $status];
|
||||
}
|
||||
}
|
||||
if(!empty($search_text)){
|
||||
$condition[] =['withdraw_no|member_name|realname|mobile|account_number' , "like", "%" . $search_text . "%"];
|
||||
}
|
||||
|
||||
if (!empty($start_time) && empty($end_time)) {
|
||||
$condition[] = ['apply_time', '>=', $start_time];
|
||||
} elseif (empty($start_time) && !empty($end_time)) {
|
||||
$condition[] = ['apply_time', '<=', $end_time];
|
||||
} elseif (!empty($start_time) && !empty($end_time)) {
|
||||
$condition[] = ['apply_time', 'between', [$start_time, $end_time]];
|
||||
}
|
||||
|
||||
$order = "id desc";
|
||||
|
||||
$list = $withdraw_model->getMemberWithdrawPageList($condition, $page, $page_size, $order);
|
||||
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提现信息
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$id = $this->params['id'] ?? 0;
|
||||
$withdraw_model = new MemberWithdrawModel();
|
||||
$info = $withdraw_model->getMemberWithdrawInfo([["id", "=", $id], ['site_id', '=', $this->site_id]]);
|
||||
return $this->response($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同意
|
||||
* @return array
|
||||
*/
|
||||
public function agree()
|
||||
{
|
||||
$id = $this->params['id'] ?? 0;
|
||||
$withdraw_model = new MemberWithdrawModel();
|
||||
$condition = array(
|
||||
['site_id', '=', $this->site_id],
|
||||
["id", "=", $id]
|
||||
);
|
||||
$result = $withdraw_model->agree($condition);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拒绝
|
||||
* @return array
|
||||
*/
|
||||
public function refuse()
|
||||
{
|
||||
$id = $this->params['id'] ?? 0;
|
||||
$refuse_reason = $this->params['refuse_reason'] ?? 0;
|
||||
$withdraw_model = new MemberWithdrawModel();
|
||||
$condition = array(
|
||||
['site_id', '=', $this->site_id],
|
||||
["id", "=", $id]
|
||||
);
|
||||
$data = array(
|
||||
"refuse_reason" => $refuse_reason
|
||||
);
|
||||
$result = $withdraw_model->refuse($condition, $data);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
}
|
||||
554
app/shopapi/controller/Statistics.php
Executable file
554
app/shopapi/controller/Statistics.php
Executable file
@@ -0,0 +1,554 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\exception\ApiException;
|
||||
use app\model\system\Stat as StatModel;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class Statistics extends BaseApi
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
//执行父类构造函数
|
||||
parent::__construct();
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) {
|
||||
throw new ApiException($token['code'], $token['message']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 店铺统计
|
||||
* @return mixed
|
||||
*/
|
||||
public function shop()
|
||||
{
|
||||
$date_type = $this->params['date_type'] ?? 0;
|
||||
if ($date_type == 0) {
|
||||
$start_time = strtotime("today");
|
||||
$time_range = date('Y-m-d', $start_time);
|
||||
} else if ($date_type == 1) {
|
||||
$start_time = strtotime(date('Y-m-d', strtotime("-6 day")));
|
||||
$time_range = date('Y-m-d', $start_time) . ' 至 ' . date('Y-m-d', strtotime("today"));
|
||||
} else if ($date_type == 2) {
|
||||
$start_time = strtotime(date('Y-m-d', strtotime("-29 day")));
|
||||
$time_range = date('Y-m-d', $start_time) . ' 至 ' . date('Y-m-d', strtotime("today"));
|
||||
}
|
||||
|
||||
$stat_model = new StatModel();
|
||||
|
||||
$shop_stat_sum = $stat_model->getShopStatSum($this->site_id, $start_time);
|
||||
|
||||
$shop_stat_sum[ 'data' ][ 'time_range' ] = $time_range;
|
||||
|
||||
return $this->response($shop_stat_sum);
|
||||
}
|
||||
|
||||
/**
|
||||
* 店铺统计报表
|
||||
* */
|
||||
public function getShopStatList()
|
||||
{
|
||||
$date_type = $this->params['date_type'] ?? 1;
|
||||
if ($date_type == 1) {
|
||||
$start_time = strtotime(date('Y-m-d', strtotime("-6 day")));
|
||||
$time_range = date('Y-m-d', $start_time) . ' 至 ' . date('Y-m-d', strtotime("today"));
|
||||
$day = 6;
|
||||
} else if ($date_type == 2) {
|
||||
$start_time = strtotime(date('Y-m-d', strtotime("-29 day")));
|
||||
$time_range = date('Y-m-d', $start_time) . ' 至 ' . date('Y-m-d', strtotime("today"));
|
||||
$day = 29;
|
||||
}
|
||||
|
||||
$stat_model = new StatModel();
|
||||
|
||||
$stat_list = $stat_model->getShopStatList($this->site_id, $start_time, time());
|
||||
|
||||
//将时间戳作为列表的主键
|
||||
$shop_stat_list = array_column($stat_list[ 'data' ], null, 'day_time');
|
||||
|
||||
$data = array ();
|
||||
|
||||
for ($i = 0; $i <= $day; $i++) {
|
||||
$time = strtotime(date('Y-m-d', strtotime("-" . ( $day - $i ) . " day")));
|
||||
$data[ 'time' ][ $i ] = date('Y-m-d', $time);
|
||||
if (array_key_exists($time, $shop_stat_list)) {
|
||||
$data[ 'order_total' ][ $i ] = $shop_stat_list[ $time ][ 'order_total' ];
|
||||
$data[ 'shipping_total' ][ $i ] = $shop_stat_list[ $time ][ 'shipping_total' ];
|
||||
$data[ 'refund_total' ][ $i ] = $shop_stat_list[ $time ][ 'refund_total' ];
|
||||
$data[ 'order_pay_count' ][ $i ] = $shop_stat_list[ $time ][ 'order_pay_count' ];
|
||||
$data[ 'goods_pay_count' ][ $i ] = $shop_stat_list[ $time ][ 'goods_pay_count' ];
|
||||
$data[ 'shop_money' ][ $i ] = $shop_stat_list[ $time ][ 'shop_money' ];
|
||||
$data[ 'platform_money' ][ $i ] = $shop_stat_list[ $time ][ 'platform_money' ];
|
||||
$data[ 'collect_shop' ][ $i ] = $shop_stat_list[ $time ][ 'collect_shop' ];
|
||||
$data[ 'collect_goods' ][ $i ] = $shop_stat_list[ $time ][ 'collect_goods' ];
|
||||
$data[ 'visit_count' ][ $i ] = $shop_stat_list[ $time ][ 'visit_count' ];
|
||||
$data[ 'order_count' ][ $i ] = $shop_stat_list[ $time ][ 'order_count' ];
|
||||
$data[ 'goods_count' ][ $i ] = $shop_stat_list[ $time ][ 'goods_count' ];
|
||||
$data[ 'add_goods_count' ][ $i ] = $shop_stat_list[ $time ][ 'add_goods_count' ];
|
||||
$data[ 'member_count' ][ $i ] = $shop_stat_list[ $time ][ 'member_count' ];
|
||||
} else {
|
||||
$data[ 'order_total' ][ $i ] = 0.00;
|
||||
$data[ 'shipping_total' ][ $i ] = 0.00;
|
||||
$data[ 'refund_total' ][ $i ] = 0.00;
|
||||
$data[ 'order_pay_count' ][ $i ] = 0;
|
||||
$data[ 'goods_pay_count' ][ $i ] = 0;
|
||||
$data[ 'shop_money' ][ $i ] = 0.00;
|
||||
$data[ 'platform_money' ][ $i ] = 0.00;
|
||||
$data[ 'collect_shop' ][ $i ] = 0;
|
||||
$data[ 'collect_goods' ][ $i ] = 0;
|
||||
$data[ 'visit_count' ][ $i ] = 0;
|
||||
$data[ 'order_count' ][ $i ] = 0;
|
||||
$data[ 'goods_count' ][ $i ] = 0;
|
||||
$data[ 'add_goods_count' ][ $i ] = 0;
|
||||
$data[ 'member_count' ][ $i ] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$data[ 'time_range' ] = $time_range;
|
||||
|
||||
return $this->response($this->success($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品统计
|
||||
* @return mixed
|
||||
*/
|
||||
public function goods()
|
||||
{
|
||||
$date_type = $this->params['date_type'] ?? 0;
|
||||
if ($date_type == 0) {
|
||||
$start_time = strtotime("today");
|
||||
$time_range = date('Y-m-d', $start_time);
|
||||
} else if ($date_type == 1) {
|
||||
$start_time = strtotime("-6 day");
|
||||
$time_range = date('Y-m-d', $start_time) . ' 至 ' . date('Y-m-d', strtotime("today"));
|
||||
} else if ($date_type == 2) {
|
||||
$start_time = strtotime("-29 day");
|
||||
$time_range = date('Y-m-d', $start_time) . ' 至 ' . date('Y-m-d', strtotime("today"));
|
||||
}
|
||||
|
||||
$stat_model = new StatModel();
|
||||
|
||||
$shop_stat_sum = $stat_model->getShopStatSum($this->site_id, $start_time);
|
||||
|
||||
$shop_stat_sum[ 'data' ][ 'time_range' ] = $time_range;
|
||||
|
||||
return $this->response($shop_stat_sum);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品统计报表
|
||||
* */
|
||||
public function getGoodsStatList()
|
||||
{
|
||||
$date_type = $this->params['date_type'] ?? 1;
|
||||
if ($date_type == 1) {
|
||||
$start_time = strtotime("-6 day");
|
||||
$time_range = date('Y-m-d', $start_time) . ' 至 ' . date('Y-m-d', strtotime("today"));
|
||||
$day = 6;
|
||||
} else if ($date_type == 2) {
|
||||
$start_time = strtotime("-29 day");
|
||||
$time_range = date('Y-m-d', $start_time) . ' 至 ' . date('Y-m-d', strtotime("today"));
|
||||
$day = 29;
|
||||
}
|
||||
|
||||
$stat_model = new StatModel();
|
||||
$stat_list = $stat_model->getShopStatList($this->site_id, $start_time, time());
|
||||
//将时间戳作为列表的主键
|
||||
$shop_stat_list = array_column($stat_list[ 'data' ], null, 'day_time');
|
||||
|
||||
$data = array ();
|
||||
for ($i = 0; $i <= $day; $i++) {
|
||||
$time = strtotime(date('Y-m-d', strtotime("-" . ( $day - $i ) . " day")));
|
||||
$data[ 'time' ][ $i ] = date('Y-m-d', $time);
|
||||
if (array_key_exists($time, $shop_stat_list)) {
|
||||
$data[ 'order_total' ][ $i ] = $shop_stat_list[ $time ][ 'order_total' ];
|
||||
$data[ 'shipping_total' ][ $i ] = $shop_stat_list[ $time ][ 'shipping_total' ];
|
||||
$data[ 'refund_total' ][ $i ] = $shop_stat_list[ $time ][ 'refund_total' ];
|
||||
$data[ 'order_pay_count' ][ $i ] = $shop_stat_list[ $time ][ 'order_pay_count' ];
|
||||
$data[ 'goods_pay_count' ][ $i ] = $shop_stat_list[ $time ][ 'goods_pay_count' ];
|
||||
$data[ 'shop_money' ][ $i ] = $shop_stat_list[ $time ][ 'shop_money' ];
|
||||
$data[ 'platform_money' ][ $i ] = $shop_stat_list[ $time ][ 'platform_money' ];
|
||||
$data[ 'collect_shop' ][ $i ] = $shop_stat_list[ $time ][ 'collect_shop' ];
|
||||
$data[ 'collect_goods' ][ $i ] = $shop_stat_list[ $time ][ 'collect_goods' ];
|
||||
$data[ 'visit_count' ][ $i ] = $shop_stat_list[ $time ][ 'visit_count' ];
|
||||
$data[ 'order_count' ][ $i ] = $shop_stat_list[ $time ][ 'order_count' ];
|
||||
$data[ 'goods_count' ][ $i ] = $shop_stat_list[ $time ][ 'goods_count' ];
|
||||
$data[ 'add_goods_count' ][ $i ] = $shop_stat_list[ $time ][ 'add_goods_count' ];
|
||||
$data[ 'member_count' ][ $i ] = $shop_stat_list[ $time ][ 'member_count' ];
|
||||
} else {
|
||||
$data[ 'order_total' ][ $i ] = 0.00;
|
||||
$data[ 'shipping_total' ][ $i ] = 0.00;
|
||||
$data[ 'refund_total' ][ $i ] = 0.00;
|
||||
$data[ 'order_pay_count' ][ $i ] = 0;
|
||||
$data[ 'goods_pay_count' ][ $i ] = 0;
|
||||
$data[ 'shop_money' ][ $i ] = 0.00;
|
||||
$data[ 'platform_money' ][ $i ] = 0.00;
|
||||
$data[ 'collect_shop' ][ $i ] = 0;
|
||||
$data[ 'collect_goods' ][ $i ] = 0;
|
||||
$data[ 'visit_count' ][ $i ] = 0;
|
||||
$data[ 'order_count' ][ $i ] = 0;
|
||||
$data[ 'goods_count' ][ $i ] = 0;
|
||||
$data[ 'add_goods_count' ][ $i ] = 0;
|
||||
$data[ 'member_count' ][ $i ] = 0;
|
||||
}
|
||||
}
|
||||
$data[ 'time_range' ] = $time_range;
|
||||
return $this->response($this->success($data));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 订单金额及订单数量统计(7、15、30天)
|
||||
* @return mixed
|
||||
*/
|
||||
public function orderStatistics()
|
||||
{
|
||||
$day = $this->params['day'] ?? 7;
|
||||
|
||||
$stat_shop_model = new StatModel();
|
||||
//近十天的订单数以及销售金额
|
||||
$date_day = getweeks($day);
|
||||
|
||||
$data = [
|
||||
'order_total' => [],
|
||||
'order_pay_count' => []
|
||||
];
|
||||
|
||||
for ($i = 1; $i <= $day; $i++) {
|
||||
$time = strtotime(date('Y-m-d', strtotime("-" . ($day - $i) . " day")));
|
||||
$date = date('Y-m-d', $time);
|
||||
$dayarr = explode('-', $date);
|
||||
|
||||
$stat_data = $stat_shop_model->getStatShop($this->site_id, $dayarr[ 0 ], $dayarr[ 1 ], $dayarr[ 2 ]);
|
||||
$stat_data = $stat_data[ 'data' ];
|
||||
|
||||
array_push($data['order_total'], $stat_data[ 'order_total' ]);
|
||||
array_push($data['order_pay_count'], $stat_data[ 'order_pay_count' ]);
|
||||
}
|
||||
|
||||
return $this->response($this->success($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 交易统计
|
||||
* @return mixed
|
||||
*/
|
||||
public function order()
|
||||
{
|
||||
$date_type = $this->params['date_type'] ?? 0;
|
||||
if ($date_type == 0) {
|
||||
$start_time = strtotime("today");
|
||||
$time_range = date('Y-m-d', $start_time);
|
||||
} else if ($date_type == 1) {
|
||||
$start_time = strtotime(date('Y-m-d', strtotime("-6 day")));
|
||||
$time_range = date('Y-m-d', $start_time) . ' 至 ' . date('Y-m-d', strtotime("today"));
|
||||
} else if ($date_type == 2) {
|
||||
$start_time = strtotime(date('Y-m-d', strtotime("-29 day")));
|
||||
$time_range = date('Y-m-d', $start_time) . ' 至 ' . date('Y-m-d', strtotime("today"));
|
||||
}
|
||||
|
||||
$stat_model = new StatModel();
|
||||
|
||||
$shop_stat_sum = $stat_model->getShopStatSum($this->site_id, $start_time);
|
||||
|
||||
$shop_stat_sum[ 'data' ][ 'time_range' ] = $time_range;
|
||||
|
||||
return $this->response($shop_stat_sum);
|
||||
}
|
||||
|
||||
/**
|
||||
* 交易统计报表
|
||||
* */
|
||||
public function getOrderStatList()
|
||||
{
|
||||
$date_type = $this->params['date_type'] ?? 1;
|
||||
if ($date_type == 1) {
|
||||
$start_time = strtotime(date('Y-m-d', strtotime("-6 day")));
|
||||
$time_range = date('Y-m-d', $start_time) . ' 至 ' . date('Y-m-d', strtotime("today"));
|
||||
$day = 6;
|
||||
} else if ($date_type == 2) {
|
||||
$start_time = strtotime(date('Y-m-d', strtotime("-29 day")));
|
||||
$time_range = date('Y-m-d', $start_time) . ' 至 ' . date('Y-m-d', strtotime("today"));
|
||||
$day = 29;
|
||||
}
|
||||
|
||||
$stat_model = new StatModel();
|
||||
|
||||
$stat_list = $stat_model->getShopStatList($this->site_id, $start_time, time());
|
||||
|
||||
//将时间戳作为列表的主键
|
||||
$shop_stat_list = array_column($stat_list[ 'data' ], null, 'day_time');
|
||||
|
||||
$data = array ();
|
||||
|
||||
for ($i = 0; $i <= $day; $i++) {
|
||||
$time = strtotime(date('Y-m-d', strtotime("-" . ( $day - $i ) . " day")));
|
||||
$data[ 'time' ][ $i ] = date('Y-m-d', $time);
|
||||
if (array_key_exists($time, $shop_stat_list)) {
|
||||
$data[ 'order_total' ][ $i ] = $shop_stat_list[ $time ][ 'order_total' ];
|
||||
$data[ 'shipping_total' ][ $i ] = $shop_stat_list[ $time ][ 'shipping_total' ];
|
||||
$data[ 'refund_total' ][ $i ] = $shop_stat_list[ $time ][ 'refund_total' ];
|
||||
$data[ 'order_pay_count' ][ $i ] = $shop_stat_list[ $time ][ 'order_pay_count' ];
|
||||
$data[ 'goods_pay_count' ][ $i ] = $shop_stat_list[ $time ][ 'goods_pay_count' ];
|
||||
$data[ 'shop_money' ][ $i ] = $shop_stat_list[ $time ][ 'shop_money' ];
|
||||
$data[ 'platform_money' ][ $i ] = $shop_stat_list[ $time ][ 'platform_money' ];
|
||||
$data[ 'collect_shop' ][ $i ] = $shop_stat_list[ $time ][ 'collect_shop' ];
|
||||
$data[ 'collect_goods' ][ $i ] = $shop_stat_list[ $time ][ 'collect_goods' ];
|
||||
$data[ 'visit_count' ][ $i ] = $shop_stat_list[ $time ][ 'visit_count' ];
|
||||
$data[ 'order_count' ][ $i ] = $shop_stat_list[ $time ][ 'order_count' ];
|
||||
$data[ 'goods_count' ][ $i ] = $shop_stat_list[ $time ][ 'goods_count' ];
|
||||
$data[ 'add_goods_count' ][ $i ] = $shop_stat_list[ $time ][ 'add_goods_count' ];
|
||||
} else {
|
||||
$data[ 'order_total' ][ $i ] = 0.00;
|
||||
$data[ 'shipping_total' ][ $i ] = 0.00;
|
||||
$data[ 'refund_total' ][ $i ] = 0.00;
|
||||
$data[ 'order_pay_count' ][ $i ] = 0;
|
||||
$data[ 'goods_pay_count' ][ $i ] = 0;
|
||||
$data[ 'shop_money' ][ $i ] = 0.00;
|
||||
$data[ 'platform_money' ][ $i ] = 0.00;
|
||||
$data[ 'collect_shop' ][ $i ] = 0;
|
||||
$data[ 'collect_goods' ][ $i ] = 0;
|
||||
$data[ 'visit_count' ][ $i ] = 0;
|
||||
$data[ 'order_count' ][ $i ] = 0;
|
||||
$data[ 'goods_count' ][ $i ] = 0;
|
||||
$data[ 'add_goods_count' ][ $i ] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$data[ 'time_range' ] = $time_range;
|
||||
return $this->response($this->success($data));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 访问统计
|
||||
* @return mixed
|
||||
*/
|
||||
public function visit()
|
||||
{
|
||||
$date_type = $this->params['date_type'] ?? 0;
|
||||
|
||||
if ($date_type == 0) {
|
||||
$start_time = strtotime("today");
|
||||
$time_range = date('Y-m-d', $start_time);
|
||||
} else if ($date_type == 1) {
|
||||
$start_time = strtotime(date('Y-m-d', strtotime("-6 day")));
|
||||
$time_range = date('Y-m-d', $start_time) . ' 至 ' . date('Y-m-d', strtotime("today"));
|
||||
} else if ($date_type == 2) {
|
||||
$start_time = strtotime(date('Y-m-d', strtotime("-29 day")));
|
||||
$time_range = date('Y-m-d', $start_time) . ' 至 ' . date('Y-m-d', strtotime("today"));
|
||||
}
|
||||
|
||||
$stat_model = new StatModel();
|
||||
|
||||
$shop_stat_sum = $stat_model->getShopStatSum($this->site_id, $start_time);
|
||||
|
||||
$shop_stat_sum[ 'data' ][ 'time_range' ] = $time_range;
|
||||
|
||||
return $this->response($shop_stat_sum);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 访问统计报表
|
||||
* */
|
||||
public function getVisitStatList()
|
||||
{
|
||||
$date_type = $this->params['date_type'] ?? 1;
|
||||
|
||||
if ($date_type == 1) {
|
||||
$start_time = strtotime(date('Y-m-d', strtotime("-6 day")));
|
||||
$time_range = date('Y-m-d', $start_time) . ' 至 ' . date('Y-m-d', strtotime("today"));
|
||||
$day = 6;
|
||||
} else if ($date_type == 2) {
|
||||
$start_time = strtotime(date('Y-m-d', strtotime("-29 day")));
|
||||
$time_range = date('Y-m-d', $start_time) . ' 至 ' . date('Y-m-d', strtotime("today"));
|
||||
$day = 29;
|
||||
}
|
||||
|
||||
$stat_model = new StatModel();
|
||||
|
||||
$stat_list = $stat_model->getShopStatList($this->site_id, $start_time, time());
|
||||
|
||||
//将时间戳作为列表的主键
|
||||
$shop_stat_list = array_column($stat_list[ 'data' ], null, 'day_time');
|
||||
|
||||
$data = array ();
|
||||
|
||||
for ($i = 0; $i <= $day; $i++) {
|
||||
$time = strtotime(date('Y-m-d', strtotime("-" . ( $day - $i ) . " day")));
|
||||
$data[ 'time' ][ $i ] = date('Y-m-d', $time);
|
||||
if (array_key_exists($time, $shop_stat_list)) {
|
||||
$data[ 'order_total' ][ $i ] = $shop_stat_list[ $time ][ 'order_total' ];
|
||||
$data[ 'shipping_total' ][ $i ] = $shop_stat_list[ $time ][ 'shipping_total' ];
|
||||
$data[ 'refund_total' ][ $i ] = $shop_stat_list[ $time ][ 'refund_total' ];
|
||||
$data[ 'order_pay_count' ][ $i ] = $shop_stat_list[ $time ][ 'order_pay_count' ];
|
||||
$data[ 'goods_pay_count' ][ $i ] = $shop_stat_list[ $time ][ 'goods_pay_count' ];
|
||||
$data[ 'shop_money' ][ $i ] = $shop_stat_list[ $time ][ 'shop_money' ];
|
||||
$data[ 'platform_money' ][ $i ] = $shop_stat_list[ $time ][ 'platform_money' ];
|
||||
$data[ 'collect_shop' ][ $i ] = $shop_stat_list[ $time ][ 'collect_shop' ];
|
||||
$data[ 'collect_goods' ][ $i ] = $shop_stat_list[ $time ][ 'collect_goods' ];
|
||||
$data[ 'visit_count' ][ $i ] = $shop_stat_list[ $time ][ 'visit_count' ];
|
||||
$data[ 'order_count' ][ $i ] = $shop_stat_list[ $time ][ 'order_count' ];
|
||||
$data[ 'goods_count' ][ $i ] = $shop_stat_list[ $time ][ 'goods_count' ];
|
||||
$data[ 'add_goods_count' ][ $i ] = $shop_stat_list[ $time ][ 'add_goods_count' ];
|
||||
} else {
|
||||
$data[ 'order_total' ][ $i ] = 0.00;
|
||||
$data[ 'shipping_total' ][ $i ] = 0.00;
|
||||
$data[ 'refund_total' ][ $i ] = 0.00;
|
||||
$data[ 'order_pay_count' ][ $i ] = 0;
|
||||
$data[ 'goods_pay_count' ][ $i ] = 0;
|
||||
$data[ 'shop_money' ][ $i ] = 0.00;
|
||||
$data[ 'platform_money' ][ $i ] = 0.00;
|
||||
$data[ 'collect_shop' ][ $i ] = 0;
|
||||
$data[ 'collect_goods' ][ $i ] = 0;
|
||||
$data[ 'visit_count' ][ $i ] = 0;
|
||||
$data[ 'order_count' ][ $i ] = 0;
|
||||
$data[ 'goods_count' ][ $i ] = 0;
|
||||
$data[ 'add_goods_count' ][ $i ] = 0;
|
||||
}
|
||||
}
|
||||
$data[ 'time_range' ] = $time_range;
|
||||
return $this->response($this->success($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取时间段内统计数据总和
|
||||
*/
|
||||
public function getStatTotal()
|
||||
{
|
||||
$start_time = $this->params['start_time'] ?? strtotime(date('Y-m-d', time()));
|
||||
$end_time = $this->params['end_time'] ?? time();
|
||||
|
||||
if ($start_time > $end_time) {
|
||||
$start_time = $this->params['end_time'];
|
||||
$end_time = $this->params['start_time'];
|
||||
}
|
||||
|
||||
$stat_model = new StatModel();
|
||||
$data = $stat_model->getShopStatSum($this->site_id, $start_time, $end_time);
|
||||
return $this->response($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取天统计趋势数据
|
||||
*/
|
||||
public function getStatData()
|
||||
{
|
||||
$start_time = $this->params['start_time'] ?? strtotime(date('Y-m-d', strtotime('-6 day')));
|
||||
$end_time = $this->params['end_time'] ?? time();
|
||||
|
||||
if ($start_time > $end_time) {
|
||||
$start_time = $this->params['end_time'];
|
||||
$end_time = $this->params['start_time'];
|
||||
}
|
||||
|
||||
$stat_model = new StatModel();
|
||||
$fields = $stat_model->getStatField();
|
||||
$fields[] = 'cashier_order_pay_money';
|
||||
|
||||
$stat_list = $stat_model->getShopStatList($this->site_id, $start_time, $end_time)[ 'data' ];
|
||||
$stat_list = array_map(function($item) {
|
||||
$item[ 'day_time' ] = date('Y-m-d', $item[ 'day_time' ]);
|
||||
return $item;
|
||||
}, $stat_list);
|
||||
$stat_list = array_column($stat_list, null, 'day_time');
|
||||
|
||||
$day = ceil(( $end_time - $start_time ) / 86400);
|
||||
|
||||
foreach ($fields as $field) {
|
||||
$value = [];
|
||||
$time = [];
|
||||
for ($i = 0; $i < $day; $i++) {
|
||||
$date = date('Y-m-d', $start_time + $i * 86400);
|
||||
$time[] = $date;
|
||||
$value[] = isset($stat_list[ $date ]) && isset($stat_list[ $date ][ $field ]) ? $stat_list[ $date ][ $field ] : 0;
|
||||
}
|
||||
$data[ $field ] = $value;
|
||||
$data[ 'time' ] = $time;
|
||||
}
|
||||
return $this->response($this->success($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小时统计趋势数据
|
||||
*/
|
||||
public function getStatHourData()
|
||||
{
|
||||
$time = $this->params['start_time'] ?? time();
|
||||
$carbon = Carbon::createFromTimestamp($time);
|
||||
|
||||
$stat_model = new StatModel();
|
||||
$fields = $stat_model->getStatHourField();
|
||||
$fields[] = 'cashier_order_pay_money';
|
||||
|
||||
$stat_list = $stat_model->getShopStatHourList($this->site_id, $carbon->year, $carbon->month, $carbon->day)[ 'data' ];
|
||||
|
||||
$data = [];
|
||||
$empty = array_map(function() { return 0; }, range(0, 23, 1));
|
||||
if (!empty($stat_list)) {
|
||||
$stat_list = array_column($stat_list, null, 'hour');
|
||||
foreach ($fields as $field) {
|
||||
$value = [];
|
||||
for ($i = 0; $i < 24; $i++) {
|
||||
$value[ $i ] = isset($stat_list[ $i ][ $field ]) && isset($stat_list[ $i ][ $field ]) ? $stat_list[ $i ][ $field ] : 0;
|
||||
}
|
||||
$data[ $field ] = $value;
|
||||
}
|
||||
} else {
|
||||
foreach ($fields as $field) {
|
||||
$data[ $field ] = $empty;
|
||||
}
|
||||
}
|
||||
$data[ 'time' ] = array_map(function($value) { return $value . '时'; }, range(0, 23, 1));
|
||||
return $this->response($this->success($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品排行榜 销量
|
||||
* */
|
||||
public function countGoodsSale()
|
||||
{
|
||||
$start_time = $this->params['start_time'] ?? '';
|
||||
$end_time = $this->params['end_time'] ?? '';
|
||||
|
||||
if ($start_time > $end_time) {
|
||||
$start_time = $this->params['end_time'];
|
||||
$end_time = $this->params['start_time'];
|
||||
}
|
||||
|
||||
$stat_model = new StatModel();
|
||||
$res = $stat_model->getGoodsSaleNumRankingList($this->site_id, $start_time, $end_time, 1, 5);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品排行榜 销售额
|
||||
* */
|
||||
public function countGoodsSaleMoney()
|
||||
{
|
||||
$start_time = $this->params['start_time'] ?? '';
|
||||
$end_time = $this->params['end_time'] ?? '';
|
||||
|
||||
if ($start_time > $end_time) {
|
||||
$start_time = $this->params['end_time'];
|
||||
$end_time = $this->params['start_time'];
|
||||
}
|
||||
|
||||
$stat_model = new StatModel();
|
||||
$res = $stat_model->getGoodsSaleMoneyRankingList($this->site_id, $start_time, $end_time, 1, 5);
|
||||
return $this->response($res);
|
||||
}
|
||||
}
|
||||
242
app/shopapi/controller/Store.php
Executable file
242
app/shopapi/controller/Store.php
Executable file
@@ -0,0 +1,242 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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 json_encode($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);
|
||||
}
|
||||
}
|
||||
66
app/shopapi/controller/Storeorder.php
Executable file
66
app/shopapi/controller/Storeorder.php
Executable file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\order\OrderCommon as OrderCommonModel;
|
||||
use app\model\order\StoreOrder as StoreOrderModel;
|
||||
|
||||
/**
|
||||
* 订单
|
||||
* Class Order
|
||||
* @package app\shop\controller
|
||||
*/
|
||||
class Storeorder extends BaseApi
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//执行父类构造函数
|
||||
parent::__construct();
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) {
|
||||
echo json_encode($token);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 门店提货
|
||||
* @return false|string
|
||||
*/
|
||||
public function storeOrderTakeDelivery()
|
||||
{
|
||||
$order_id = $this->params['order_id'] ?? 0;
|
||||
|
||||
$order_common_model = new OrderCommonModel();
|
||||
$condition = array (
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'order_id', '=', $order_id ]
|
||||
);
|
||||
$order_info = $order_common_model->getOrderInfo($condition, 'delivery_code')[ 'data' ] ?? [];
|
||||
if (empty($order_info))
|
||||
return $order_common_model->error('', '订单不存在');
|
||||
|
||||
$verify_code = $order_info[ 'delivery_code' ];
|
||||
$info = array (
|
||||
"verifier_id" => $this->uid,
|
||||
"verifier_name" => $this->user_info[ 'username' ],
|
||||
"verify_from" => 'shop',
|
||||
);
|
||||
$verify_model = new \app\model\verify\Verify();
|
||||
$result = $verify_model->verify($info, $verify_code);
|
||||
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
}
|
||||
86
app/shopapi/controller/Upload.php
Executable file
86
app/shopapi/controller/Upload.php
Executable file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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);
|
||||
|
||||
if (empty($album_id)) {
|
||||
$album_model = new Album();
|
||||
$album_info = $album_model->getAlbumInfo([
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'is_default', '=', 1 ]
|
||||
])[ 'data' ];
|
||||
$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;
|
||||
}
|
||||
|
||||
}
|
||||
199
app/shopapi/controller/User.php
Executable file
199
app/shopapi/controller/User.php
Executable file
@@ -0,0 +1,199 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\system\User as UserModel;
|
||||
use app\model\system\Group;
|
||||
use app\model\system\UserGroup;
|
||||
|
||||
/**
|
||||
* 用户
|
||||
* Class User
|
||||
* @package app\shop\controller
|
||||
*/
|
||||
class User extends BaseApi
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
//执行父类构造函数
|
||||
parent::__construct();
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) {
|
||||
echo json_encode($token);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
|
||||
$status = $this->params['status'] ?? '';
|
||||
$search_keys = $this->params['search_keys'] ?? '';
|
||||
|
||||
$condition = [];
|
||||
$condition[] = [ "site_id", "=", $this->site_id ];
|
||||
$condition[] = [ "app_module", "=", $this->app_module ];
|
||||
if (!empty($search_keys)) {
|
||||
$condition[] = [ 'username', 'like', '%' . $search_keys . '%' ];
|
||||
}
|
||||
if ($status != "") {
|
||||
$condition[] = [ "status", "=", $status ];
|
||||
}
|
||||
|
||||
$user_model = new UserModel();
|
||||
$list = $user_model->getUserPageList($condition, $page, $page_size);
|
||||
if (!empty($list['data']['list']) && addon_is_exit('cashier', $this->site_id)) {
|
||||
$join = [
|
||||
['store s', 's.store_id = ug.store_id', 'left'],
|
||||
['cashier_auth_group cag', 'cag.group_id = ug.group_id', 'left']
|
||||
];
|
||||
foreach ($list['data']['list'] as $k => $item) {
|
||||
$list['data']['list'][$k]['user_group_list'] = (new UserGroup())->getUserList([ ['ug.uid', '=', $item['uid'] ] ], 's.store_name,cag.group_name', '', 'ug', $join)['data'];
|
||||
}
|
||||
}
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*/
|
||||
public function info()
|
||||
{
|
||||
$uid = $this->params['uid'] ?? '';
|
||||
|
||||
$user_model = new UserModel();
|
||||
$info = $user_model->getUserInfo([ [ 'uid', '=', $uid ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
return $this->response($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加用户
|
||||
* @return mixed
|
||||
*/
|
||||
public function addUser()
|
||||
{
|
||||
$username = $this->params['username'] ?? '';
|
||||
$password = $this->params['password'] ?? '';
|
||||
$group_id = $this->params['group_id'] ?? '';
|
||||
|
||||
$user_model = new UserModel();
|
||||
$data = array (
|
||||
"username" => $username,
|
||||
"password" => $password,
|
||||
"group_id" => $group_id,
|
||||
"app_module" => $this->app_module,
|
||||
"site_id" => $this->site_id
|
||||
);
|
||||
$result = $user_model->addUser($data, 'add');
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑用户
|
||||
* @return mixed
|
||||
*/
|
||||
public function editUser()
|
||||
{
|
||||
$user_model = new UserModel();
|
||||
|
||||
$group_id = $this->params['group_id'] ?? '';
|
||||
$status = $this->params['status'] ?? '';
|
||||
$uid = $this->params['uid'] ?? '';
|
||||
|
||||
$condition = array (
|
||||
[ "uid", "=", $uid ],
|
||||
[ "site_id", "=", $this->site_id ],
|
||||
[ "app_module", "=", $this->app_module ],
|
||||
);
|
||||
$data = array (
|
||||
"group_id" => $group_id,
|
||||
"status" => $status
|
||||
);
|
||||
|
||||
$result = $user_model->editUser($data, $condition);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
*/
|
||||
public function deleteUser()
|
||||
{
|
||||
$uid = $this->params['uid'] ?? '';
|
||||
$user_model = new UserModel();
|
||||
$condition = array (
|
||||
[ "uid", "=", $uid ],
|
||||
[ "app_module", "=", $this->app_module ],
|
||||
[ "site_id", "=", $this->site_id ],
|
||||
);
|
||||
$result = $user_model->deleteUser($condition);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑管理员状态
|
||||
*/
|
||||
public function modifyUserStatus()
|
||||
{
|
||||
$uid = $this->params['uid'] ?? '';
|
||||
$status = $this->params['status'] ?? 0;
|
||||
|
||||
$user_model = new UserModel();
|
||||
$condition = array (
|
||||
[ "uid", "=", $uid ],
|
||||
[ "site_id", "=", $this->site_id ],
|
||||
[ "app_module", "=", $this->app_module ],
|
||||
);
|
||||
$result = $user_model->modifyUserStatus($status, $condition);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
*/
|
||||
public function modifyPassword()
|
||||
{
|
||||
$password = $this->params['password'] ?? '123456';
|
||||
$uid = $this->params['uid'] ?? $this->uid;
|
||||
|
||||
$site_id = $this->site_id;
|
||||
$user_model = new UserModel();
|
||||
$res = $user_model->modifyUserPassword($password, [ [ 'uid', '=', $uid ], [ 'site_id', '=', $site_id ] ]);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户组列表
|
||||
*/
|
||||
public function groupList()
|
||||
{
|
||||
$group_model = new Group();
|
||||
$group_list = $group_model->getGroupList([ [ "site_id", "=", $this->site_id ], [ "app_module", "=", $this->app_module ] ]);
|
||||
return $this->response($group_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户组权限
|
||||
* @return false|string
|
||||
*/
|
||||
public function permission(){
|
||||
$permission = empty($this->group_info['menu_array']) ? [] : explode(',', $this->group_info['menu_array']);
|
||||
return $this->response($this->success($permission));
|
||||
}
|
||||
}
|
||||
268
app/shopapi/controller/Verify.php
Executable file
268
app/shopapi/controller/Verify.php
Executable file
@@ -0,0 +1,268 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\member\Member;
|
||||
use app\model\verify\Verifier;
|
||||
use app\model\verify\Verify as VerifyModel;
|
||||
|
||||
/**
|
||||
* 核销
|
||||
* Class Verify
|
||||
* @package app\shop\controller
|
||||
*/
|
||||
class Verify extends BaseApi
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//执行父类构造函数
|
||||
parent::__construct();
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) {
|
||||
echo json_encode($token);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 核销记录
|
||||
* @return mixed
|
||||
*/
|
||||
public function records()
|
||||
{
|
||||
$verify_model = new VerifyModel();
|
||||
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
|
||||
$order = $this->params['order'] ?? 'create_time desc';
|
||||
$verify_type = $this->params['verify_type'] ?? '';//验证类型
|
||||
$verify_code = $this->params['verify_code'] ?? '';//验证码
|
||||
$verifier_name = $this->params['verifier_name'] ?? '';
|
||||
$start_time = $this->params['start_time'] ?? '';
|
||||
$end_time = $this->params['end_time'] ?? '';
|
||||
|
||||
$condition = [
|
||||
[ 'site_id', "=", $this->site_id ],
|
||||
[ 'is_verify', '=', 1 ]
|
||||
];
|
||||
if (!empty($verify_type)) {
|
||||
$condition[] = [ "verify_type", "=", $verify_type ];
|
||||
}
|
||||
if (!empty($verify_code)) {
|
||||
$condition[] = [ "verify_code", 'like', '%' . $verify_code . '%' ];
|
||||
}
|
||||
if (!empty($verifier_name)) {
|
||||
$condition[] = [ 'verifier_name', 'like', '%' . $verifier_name . '%' ];
|
||||
}
|
||||
if (!empty($start_time) && empty($end_time)) {
|
||||
$condition[] = [ 'create_time', '>=', date_to_time($start_time) ];
|
||||
} elseif (empty($start_time) && !empty($end_time)) {
|
||||
$condition[] = [ "create_time", "<=", date_to_time($end_time) ];
|
||||
} elseif (!empty($start_time) && !empty($end_time)) {
|
||||
$condition[] = [ 'create_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
|
||||
}
|
||||
$list = $verify_model->getVerifyPageList($condition, $page, $page_size, $order, $field = 'id, verify_code, verify_type, verify_type_name, verify_content_json, verifier_id, verifier_name, is_verify, create_time, verify_time,member_id');
|
||||
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 核销类型
|
||||
* @return false|string
|
||||
*/
|
||||
public function verifyType()
|
||||
{
|
||||
$verify_model = new VerifyModel();
|
||||
$verify_type = $verify_model->getVerifyType();
|
||||
return $this->response($this->success($verify_type));
|
||||
}
|
||||
|
||||
/**
|
||||
* 核销信息
|
||||
*/
|
||||
public function verifyInfo()
|
||||
{
|
||||
$id = $this->params['id'] ?? '';
|
||||
|
||||
$verify_model = new VerifyModel();
|
||||
$info = $verify_model->getVerifyInfo([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
|
||||
return $this->response($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 核销台
|
||||
* @return mixed
|
||||
*/
|
||||
public function verifyCard()
|
||||
{
|
||||
$verify_code = $this->params['verify_code'] ?? '';
|
||||
$verify_model = new VerifyModel();
|
||||
$res = $verify_model->getVerifyInfo([ [ "verify_code", "=", $verify_code ], [ "site_id", "=", $this->site_id ] ]);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 核销人员
|
||||
* @return mixed
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
$verifier = new Verifier();
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
|
||||
$order = $this->params['order'] ?? 'v.create_time desc';
|
||||
$verifier_name = $this->params['verifier_name'] ?? '';
|
||||
$condition = [];
|
||||
$condition[] = [ 'v.site_id', "=", $this->site_id ];
|
||||
if ($verifier_name) {
|
||||
$condition[] = [ 'v.verifier_name', '=', $verifier_name ];
|
||||
}
|
||||
$list = $verifier->getVerifierPageList($condition, $page, $page_size, $order);
|
||||
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加核销人员
|
||||
* @return mixed
|
||||
*/
|
||||
public function addUser()
|
||||
{
|
||||
$verifier_name = $this->params['verifier_name'] ?? '';
|
||||
$member_id = $this->params['member_id'] ?? 0;//会员账号
|
||||
$model = new Verifier();
|
||||
if ($member_id <= 0) {
|
||||
$model->error([], "EMPTY_BIND_MEMBER");
|
||||
}
|
||||
|
||||
$uid = $this->params['uid'] ?? 0;//管理员账号
|
||||
$data = array ();
|
||||
$data[ 'site_id' ] = $this->site_id;
|
||||
$data[ 'create_time' ] = time();
|
||||
$data[ "verifier_name" ] = $verifier_name;
|
||||
$data[ "member_id" ] = $member_id;
|
||||
$data[ "uid" ] = $uid;
|
||||
$result = $model->addVerifier($data);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取核销人员详情
|
||||
*/
|
||||
public function verifyUSerInfo()
|
||||
{
|
||||
$model = new Verifier();
|
||||
$verifier_id = $this->params['verifier_id'] ?? 0;
|
||||
//用户信息
|
||||
$condition = [
|
||||
[ "verifier_id", "=", $verifier_id ],
|
||||
[ "site_id", "=", $this->site_id ],
|
||||
];
|
||||
$info_result = $model->getVerifierInfo($condition);
|
||||
$info = $info_result[ "data" ];
|
||||
$member_account = "";
|
||||
if (!empty($info[ "member_id" ])) {
|
||||
$member_model = new Member();
|
||||
$member_info_result = $member_model->getMemberInfo([ [ "member_id", "=", $info[ "member_id" ] ] ], "username");
|
||||
$member_info = $member_info_result[ "data" ];
|
||||
if (!empty($member_info)) {
|
||||
$member_account = $member_info[ "username" ];
|
||||
}
|
||||
|
||||
}
|
||||
$info[ "member_account" ] = $member_account;
|
||||
|
||||
return $this->response($this->success($info));
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑核销人员
|
||||
* @return mixed
|
||||
*/
|
||||
public function editUser()
|
||||
{
|
||||
$model = new Verifier();
|
||||
$verifier_id = $this->params['verifier_id'] ?? 0;//核销员id
|
||||
|
||||
$verifier_name = $this->params['verifier_name'] ?? '';
|
||||
$member_id = $this->params['member_id'] ?? '';//会员账号
|
||||
if ($member_id <= 0) {
|
||||
$model->error([], "EMPTY_BIND_MEMBER");
|
||||
}
|
||||
|
||||
$data = [
|
||||
'verifier_name' => $verifier_name,
|
||||
'modify_time' => time(),
|
||||
];
|
||||
$data[ "member_id" ] = $member_id;
|
||||
$data[ "uid" ] = 0;
|
||||
$condition = array (
|
||||
[ 'verifier_id', '=', $verifier_id ],
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
);
|
||||
|
||||
$result = $model->editVerifier($data, $condition);
|
||||
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除核销人员
|
||||
* @return mixed
|
||||
*/
|
||||
public function deleteUser()
|
||||
{
|
||||
$verifier = new Verifier();
|
||||
|
||||
$verifier_id = $this->params['ids'] ?? '';
|
||||
$res = $verifier->deleteVerifier($verifier_id, $this->site_id);
|
||||
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 核销
|
||||
*/
|
||||
public function verify()
|
||||
{
|
||||
//先验证登录用户是否具备核销权限
|
||||
$info = array (
|
||||
"verifier_id" => $this->uid,
|
||||
"verifier_name" => $this->user_info[ 'username' ],
|
||||
"verify_from" => 'mobile',
|
||||
);
|
||||
$verify_code = $this->params['verify_code'] ?? '';
|
||||
$verify_model = new VerifyModel();
|
||||
$res = $verify_model->verify($info, $verify_code);
|
||||
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索会员
|
||||
* 不是菜单 不入权限
|
||||
*/
|
||||
public function searchMember()
|
||||
{
|
||||
$search_text = $this->params['search_text'] ?? '';
|
||||
$member_model = new Member();
|
||||
$member_info = $member_model->getMemberInfo([ [ 'username|mobile', '=', $search_text ] ]);
|
||||
|
||||
return $this->response($member_info);
|
||||
}
|
||||
|
||||
}
|
||||
185
app/shopapi/controller/Virtualgoods.php
Executable file
185
app/shopapi/controller/Virtualgoods.php
Executable file
@@ -0,0 +1,185 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\goods\VirtualGoods as VirtualGoodsModel;
|
||||
|
||||
/**
|
||||
* 虚拟商品
|
||||
* Class Virtualgoods
|
||||
* @package app\shop\controller
|
||||
*/
|
||||
class Virtualgoods extends BaseApi
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//执行父类构造函数
|
||||
parent::__construct();
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) {
|
||||
echo json_encode($token);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加商品
|
||||
* @return mixed
|
||||
*/
|
||||
public function addGoods()
|
||||
{
|
||||
$data = [
|
||||
'goods_name' => $this->params['goods_name'] ?? '',// 商品名称,
|
||||
'goods_attr_class' => $this->params['goods_attr_class'] ?? '',// 商品类型id,
|
||||
'goods_attr_name' => $this->params['goods_attr_name'] ?? '',// 商品类型名称,
|
||||
'site_id' => $this->site_id,
|
||||
'category_id' => $this->params[ 'category_id' ] ?? '',
|
||||
'category_json' => $this->params[ 'category_json' ] ?? '',
|
||||
'goods_image' => $this->params['goods_image'] ?? '',// 商品主图路径
|
||||
'goods_content' => $this->params['goods_content'] ?? '',// 商品详情
|
||||
'goods_state' => $this->params['goods_state'] ?? '',// 商品状态(1.正常0下架)
|
||||
'price' => $this->params['price'] ?? 0,// 商品价格(取第一个sku)
|
||||
'market_price' => $this->params['market_price'] ?? '',// 市场价格(取第一个sku)
|
||||
'cost_price' => $this->params['cost_price'] ?? 0,// 成本价(取第一个sku)
|
||||
'sku_no' => $this->params['sku_no'] ?? '',// 商品sku编码
|
||||
'weight' => $this->params['weight'] ?? '',// 重量
|
||||
'volume' => $this->params['volume'] ?? '',// 体积
|
||||
'goods_stock' => $this->params['goods_stock'] ?? 0,// 商品库存(总和)
|
||||
|
||||
'goods_stock_alarm' => $this->params['goods_stock_alarm'] ?? 0,// 库存预警
|
||||
'is_free_shipping' => $this->params['is_free_shipping'] ?? 1,// 是否免邮
|
||||
'shipping_template' => $this->params['shipping_template'] ?? 0,// 指定运费模板
|
||||
'goods_spec_format' => $this->params['goods_spec_format'] ?? '',// 商品规格格式
|
||||
'goods_attr_format' => $this->params['goods_attr_format'] ?? '',// 商品参数格式
|
||||
'introduction' => $this->params['introduction'] ?? '',// 促销语
|
||||
'keywords' => $this->params['keywords'] ?? '',// 关键词
|
||||
'unit' => $this->params['unit'] ?? '',// 单位
|
||||
'sort' => $this->params['sort'] ?? 0,// 排序,
|
||||
'video_url' => $this->params['video_url'] ?? '',// 视频
|
||||
'goods_sku_data' => $this->params['goods_sku_data'] ?? '',// SKU商品数据
|
||||
'label_id' => $this->params['label_id'] ?? '',// 商品分组id
|
||||
'max_buy' => $this->params['max_buy'] ?? '',// 限购
|
||||
'min_buy' => $this->params['min_buy'] ?? '',// 起售
|
||||
'timer_on' => isset($this->params[ 'timer_on' ]) ? strtotime($this->params[ 'timer_on' ]) : 0,//定时上架
|
||||
'timer_off' => isset($this->params[ 'timer_off' ]) ? strtotime($this->params[ 'timer_off' ]) : 0,//定时下架
|
||||
|
||||
'site_name' => $this->shop_info[ 'site_name' ],//店铺名
|
||||
'virtual_sale' => $this->params[ 'virtual_sale' ] ?? 0,// 虚拟销量
|
||||
'is_consume_discount' => $this->params[ 'is_consume_discount' ] ?? 0, //是否参与会员折扣
|
||||
'goods_service_ids' => $this->params[ 'goods_service_ids' ] ?? '',// 商品服务id集合
|
||||
'recommend_way' => $this->params[ 'recommend_way' ] ?? 0, // 推荐方式,1:新品,2:精品,3;推荐
|
||||
'is_need_verify' => $this->params[ 'is_need_verify' ] ?? 0, // 是否需要核销
|
||||
'verify_validity_type' => $this->params[ 'verify_validity_type' ] ?? 0,// 核销有效期类型
|
||||
'virtual_indate' => $this->params[ 'virtual_indate' ] ?? 1,// 虚拟商品有效期
|
||||
'verify_num' => $this->params[ 'verify_num' ] ?? 1, // 核销次数
|
||||
'is_limit' => $this->params[ 'is_limit' ] ?? 0,// 商品是否限购,
|
||||
'limit_type' => $this->params[ 'limit_type' ] ?? 1, // 商品限购类型,
|
||||
'sale_show' => $this->params[ 'sale_show' ] ?? 0,
|
||||
'stock_show' => $this->params[ 'stock_show' ] ?? 0,
|
||||
'market_price_show' => $this->params[ 'market_price_show' ] ?? 0,
|
||||
'barrage_show' => $this->params[ 'barrage_show' ] ?? 0,
|
||||
'brand_id' => $this->params[ 'brand_id' ] ?? 0,
|
||||
'virtual_deliver_type' => $this->params[ 'virtual_deliver_type' ] ?? '',
|
||||
'virtual_receive_type' => $this->params[ 'virtual_receive_type' ] ?? '',
|
||||
'form_id' => $this->params[ 'goods_form' ] ?? 0,
|
||||
'supplier_id' => $this->params[ 'supplier_id' ] ?? 0,
|
||||
];
|
||||
|
||||
if ($data[ 'verify_validity_type' ] == 2) {
|
||||
$data[ 'virtual_indate' ] = strtotime($data[ 'virtual_indate' ]);
|
||||
}
|
||||
|
||||
$virtual_goods_model = new VirtualGoodsModel();
|
||||
$res = $virtual_goods_model->addGoods($data);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑商品
|
||||
* @return mixed
|
||||
*/
|
||||
public function editGoods()
|
||||
{
|
||||
$virtual_goods_model = new VirtualGoodsModel();
|
||||
|
||||
$data = [
|
||||
'goods_id' => $this->params['goods_id'] ?? 0,// 商品id
|
||||
'goods_name' => $this->params['goods_name'] ?? '',// 商品名称,
|
||||
'goods_attr_class' => $this->params['goods_attr_class'] ?? '',// 商品类型id,
|
||||
'goods_attr_name' => $this->params['goods_attr_name'] ?? '',// 商品类型名称,
|
||||
'site_id' => $this->site_id,
|
||||
'category_id' => $this->params[ 'category_id' ] ?? '',
|
||||
'category_json' => $this->params[ 'category_json' ] ?? '',
|
||||
|
||||
'goods_image' => $this->params['goods_image'] ?? '',// 商品主图路径
|
||||
'goods_content' => $this->params['goods_content'] ?? '',// 商品详情
|
||||
'goods_state' => $this->params['goods_state'] ?? '',// 商品状态(1.正常0下架)
|
||||
'price' => $this->params['price'] ?? 0,// 商品价格(取第一个sku)
|
||||
'market_price' => $this->params['market_price'] ?? '',// 市场价格(取第一个sku)
|
||||
'cost_price' => $this->params['cost_price'] ?? 0,// 成本价(取第一个sku)
|
||||
'sku_no' => $this->params['sku_no'] ?? '',// 商品sku编码
|
||||
'weight' => $this->params['weight'] ?? '',// 重量
|
||||
'volume' => $this->params['volume'] ?? '',// 体积
|
||||
'goods_stock' => $this->params['goods_stock'] ?? 0,// 商品库存(总和)
|
||||
|
||||
'goods_stock_alarm' => $this->params['goods_stock_alarm'] ?? 0,// 库存预警
|
||||
'is_free_shipping' => $this->params['is_free_shipping'] ?? 1,// 是否免邮
|
||||
'shipping_template' => $this->params['shipping_template'] ?? 0,// 指定运费模板
|
||||
'goods_spec_format' => $this->params['goods_spec_format'] ?? '',// 商品规格格式
|
||||
'goods_attr_format' => $this->params['goods_attr_format'] ?? '',// 商品参数格式
|
||||
'introduction' => $this->params['introduction'] ?? '',// 促销语
|
||||
'keywords' => $this->params['keywords'] ?? '',// 关键词
|
||||
'unit' => $this->params['unit'] ?? '',// 单位
|
||||
'sort' => $this->params['sort'] ?? 0,// 排序,
|
||||
'video_url' => $this->params['video_url'] ?? '',// 视频
|
||||
'goods_sku_data' => $this->params['goods_sku_data'] ?? '',// SKU商品数据
|
||||
'label_id' => $this->params['label_id'] ?? '',// 商品分组id
|
||||
'max_buy' => $this->params['max_buy'] ?? '',// 限购
|
||||
'min_buy' => $this->params['min_buy'] ?? '',// 起售
|
||||
'timer_on' => isset($this->params[ 'timer_on' ]) ? strtotime($this->params[ 'timer_on' ]) : 0,//定时上架
|
||||
'timer_off' => isset($this->params[ 'timer_off' ]) ? strtotime($this->params[ 'timer_off' ]) : 0,//定时下架
|
||||
'spec_type_status' => isset($this->params[ 'spec_type_status' ]) ? strtotime($this->params[ 'spec_type_status' ]) : 0,
|
||||
|
||||
'site_name' => $this->shop_info[ 'site_name' ],//店铺名
|
||||
'virtual_sale' => $this->params[ 'virtual_sale' ] ?? 0,// 虚拟销量
|
||||
'is_consume_discount' => $this->params[ 'is_consume_discount' ] ?? 0, //是否参与会员折扣
|
||||
'goods_service_ids' => $this->params[ 'goods_service_ids' ] ?? '',// 商品服务id集合
|
||||
'recommend_way' => $this->params[ 'recommend_way' ] ?? 0, // 推荐方式,1:新品,2:精品,3;推荐
|
||||
'is_need_verify' => $this->params[ 'is_need_verify' ] ?? 0, // 是否需核销
|
||||
'verify_validity_type' => $this->params[ 'verify_validity_type' ] ?? 0,// 核销有效期类型
|
||||
'virtual_indate' => $this->params[ 'virtual_indate' ] ?? 1,// 虚拟商品有效期
|
||||
'verify_num' => $this->params[ 'verify_num' ] ?? 1, // 核销次数
|
||||
'is_limit' => $this->params[ 'is_limit' ] ?? 0,// 商品是否限购,
|
||||
'limit_type' => $this->params[ 'limit_type' ] ?? 1, // 商品限购类型,
|
||||
'sale_show' => $this->params[ 'sale_show' ] ?? 0,
|
||||
'stock_show' => $this->params[ 'stock_show' ] ?? 0,
|
||||
'market_price_show' => $this->params[ 'market_price_show' ] ?? 0,
|
||||
'barrage_show' => $this->params[ 'barrage_show' ] ?? 0,
|
||||
'brand_id' => $this->params[ 'brand_id' ] ?? 0,
|
||||
'virtual_deliver_type' => $this->params[ 'virtual_deliver_type' ] ?? '',
|
||||
'virtual_receive_type' => $this->params[ 'virtual_receive_type' ] ?? '',
|
||||
'form_id' => $this->params[ 'goods_form' ] ?? 0,
|
||||
'supplier_id' => $this->params[ 'supplier_id' ] ?? 0,
|
||||
];
|
||||
|
||||
if ($data[ 'verify_validity_type' ] == 2) {
|
||||
$data[ 'virtual_indate' ] = strtotime($data[ 'virtual_indate' ]);
|
||||
}
|
||||
|
||||
$res = $virtual_goods_model->editGoods($data);
|
||||
return $this->response($res);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
58
app/shopapi/controller/Virtualorder.php
Executable file
58
app/shopapi/controller/Virtualorder.php
Executable file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\model\order\VirtualOrder as VirtualOrderModel;
|
||||
|
||||
/**
|
||||
* 虚拟订单
|
||||
* Class Order
|
||||
* @package app\shop\controller
|
||||
*/
|
||||
class Virtualorder extends BaseApi
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//执行父类构造函数
|
||||
parent::__construct();
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) {
|
||||
echo json_encode($token);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发货
|
||||
* @return false|string
|
||||
*/
|
||||
public function delivery()
|
||||
{
|
||||
$order_id = $this->params[ 'order_id' ] ?? 0;
|
||||
$virtual_order_model = new VirtualOrderModel();
|
||||
$params = array (
|
||||
'order_id' => $order_id,
|
||||
'site_id' => $this->site_id
|
||||
);
|
||||
$log_data = [
|
||||
'uid' => $this->user_info[ 'uid' ],
|
||||
'nick_name' => $this->user_info[ 'username' ],
|
||||
'action' => '商家对订单进行了发货',
|
||||
'action_way' => 2,
|
||||
];
|
||||
$result = $virtual_order_model->virtualDelivery($params, $log_data);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
}
|
||||
53
app/shopapi/lang/code.php
Executable file
53
app/shopapi/lang/code.php
Executable file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'SUCCESS' => 0,
|
||||
'ERROR' => -1,
|
||||
'FAIL' => -10001,
|
||||
'SAVE_SUCCESS' => 10002,
|
||||
'SAVE_FAIL' => -10002,
|
||||
'REQUEST_SUCCESS' => 10003,
|
||||
'REQUEST_FAIL' => -10003,
|
||||
'DELETE_SUCCESS' => 10004,
|
||||
'DELETE_FAIL' => -10004,
|
||||
'UNKNOW_ERROR' => -10005,
|
||||
'PARAMETER_ERROR' => -10006,
|
||||
'REQUEST_SITE_ID' => -10007,
|
||||
'REQUEST_APP_MODULE' => -10008,
|
||||
'TOKEN_NOT_EXIST' => -1,
|
||||
'TOKEN_ERROR' => -10009,
|
||||
'TOKEN_EXPIRE' => -10010,
|
||||
'ADDON_NOT_EXIST' => -10011,
|
||||
'NO_PERMISSION' => -10012,
|
||||
'CAPTCHA_FAILURE' => -1,
|
||||
'CAPTCHA_ERROR' => -1,
|
||||
'REQUEST_COUPON_TYPE_ID' => -1,
|
||||
'REQUEST_CAPTCHA_ID' => -1,
|
||||
'REQUEST_CAPTCHA_CODE' => -1,
|
||||
'REQUEST_SKU_ID' => -1,
|
||||
'REQUEST_NUM' => -1,
|
||||
'REQUEST_CART_ID' => -1,
|
||||
'REQUEST_CATEGORY_ID' => -1,
|
||||
'REQUEST_ID' => -1,
|
||||
'REQUEST_ORDER_ID' => -1,
|
||||
'REQUEST_GOODS_EVALUATE' => -1,
|
||||
'REQUEST_ORDER_STATUS' => -1,
|
||||
'REQUEST_DIY_ID_NAME' => -1,
|
||||
'REQUEST_TOPIC_ID' => -1,
|
||||
'REQUEST_SECKILL_ID' => -1,
|
||||
'REQUEST_KEYWORD' => -1,
|
||||
'REQUEST_GOODS_ID' => -1,
|
||||
'REQUEST_PINTUAN_ID' => -1,
|
||||
'REQUEST_EMAIL' => -1,
|
||||
'REQUEST_MOBILE' => -1,
|
||||
'REQUEST_GROUPBUY_ID' => -1,
|
||||
'REQUEST_RECHARGE_ID' => -1,
|
||||
'REQUEST_BL_ID' => -1,
|
||||
'REQUEST_NAME' => -1,
|
||||
'REQUEST_STORE_ID' => -1,
|
||||
'REQUEST_REAL_NAME' => -1,
|
||||
'REQUEST_WITHDRAW_TYPE' => -1,
|
||||
'REQUEST_BRANCH_BANK_NAME' => -1,
|
||||
'REQUEST_BRANCH_BANK_ACCOUNT' => -1,
|
||||
|
||||
];
|
||||
17
app/shopapi/lang/en-us.php
Executable file
17
app/shopapi/lang/en-us.php
Executable file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'SUCCESS' => 'success',
|
||||
'ERROR' => 'error',
|
||||
'FAIL' => 'fail',
|
||||
'SAVE_SUCCESS' => 'save success',
|
||||
'SAVE_FAIL' => 'save fail',
|
||||
'REQUEST_SUCCESS' => 'request success',
|
||||
'REQUEST_FAIL' => 'request error',
|
||||
'DELETE_SUCCESS' => 'delete success',
|
||||
'DELETE_FAIL' => 'delete fail',
|
||||
'UNKNOW_ERROR' => 'unknow error',
|
||||
'PARAMETER_ERROR' => 'parameter error',
|
||||
'REQUEST_SITE_ID' => 'request site id',
|
||||
'REQUEST_APP_MODULE' => 'request app module'
|
||||
];
|
||||
52
app/shopapi/lang/zh-cn.php
Executable file
52
app/shopapi/lang/zh-cn.php
Executable file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
'SUCCESS' => '操作成功',
|
||||
'ERROR' => '操作失败',
|
||||
'SAVE_SUCCESS' => '保存成功',
|
||||
'SAVE_FAIL' => '保存失败',
|
||||
'REQUEST_SUCCESS' => '请求成功',
|
||||
'REQUEST_FAIL' => '请求失败',
|
||||
'DELETE_SUCCESS' => '删除成功',
|
||||
'DELETE_FAIL' => '删除失败',
|
||||
'UNKNOW_ERROR' => '未知错误',
|
||||
'PARAMETER_ERROR' => '参数错误',
|
||||
'REQUEST_SITE_ID' => '缺少必须参数站点id',
|
||||
'REQUEST_APP_MODULE' => '缺少必须参数应用模块',
|
||||
'TOKEN_NOT_EXIST' => 'token不存在',
|
||||
'TOKEN_ERROR' => 'token错误',
|
||||
'TOKEN_EXPIRE' => 'token已过期',
|
||||
'CAPTCHA_FAILURE' => '验证码已失效',
|
||||
'CAPTCHA_ERROR' => '验证码不正确',
|
||||
'REQUEST_COUPON_TYPE_ID' => '缺少参数coupon_type_id',
|
||||
'REQUEST_CAPTCHA_ID' => '缺少参数captcha_id',
|
||||
'REQUEST_CAPTCHA_CODE' => '缺少参数captcha_code',
|
||||
'REQUEST_SKU_ID' => '缺少参数sku_id',
|
||||
'REQUEST_NUM' => '缺少参数num',
|
||||
'REQUEST_CART_ID' => '缺少参数cart_id',
|
||||
'REQUEST_CATEGORY_ID' => '缺少参数category_id',
|
||||
'REQUEST_ID' => '缺少参数id',
|
||||
'REQUEST_ORDER_ID' => '缺少参数order_id',
|
||||
'REQUEST_GOODS_EVALUATE' => '缺少参数goods_evaluate',
|
||||
'REQUEST_ORDER_STATUS' => '缺少参数order_status',
|
||||
'REQUEST_DIY_ID_NAME' => '缺少参数id/name',
|
||||
'REQUEST_TOPIC_ID' => '缺少参数topic_id',
|
||||
'REQUEST_SECKILL_ID' => '缺少参数seckill_id',
|
||||
'REQUEST_KEYWORD' => '缺少参数keyword',
|
||||
'REQUEST_GOODS_ID' => '缺少参数goods_id',
|
||||
'REQUEST_PINTUAN_ID' => '缺少参数pintuan_id',
|
||||
'REQUEST_EMAIL' => '缺少参数email',
|
||||
'REQUEST_MOBILE' => '缺少参数mobile',
|
||||
'REQUEST_GROUPBUY_ID' => '缺少参数groupbuy_id',
|
||||
'REQUEST_RECHARGE_ID' => '缺少参数recharge_id',
|
||||
'REQUEST_BL_ID' => '缺少参数bl_id',
|
||||
'REQUEST_NAME' => '缺少参数name',
|
||||
'REQUEST_STORE_ID' => '缺少参数store_id',
|
||||
'REQUEST_REAL_NAME' => '缺少参数real_name',
|
||||
'REQUEST_WITHDRAW_TYPE' => '缺少参数withdraw_type',
|
||||
'REQUEST_BRANCH_BANK_NAME' => '缺少参数branch_bank_name',
|
||||
'REQUEST_BRANCH_BANK_ACCOUNT' => '缺少参数bank_account',
|
||||
'ADDON_NOT_EXIST' => '商家手机管理端插件不存在',
|
||||
'NO_PERMISSION' => '权限不足'
|
||||
];
|
||||
Reference in New Issue
Block a user