初始上传
This commit is contained in:
131
addon/store/shop/controller/Account.php
Executable file
131
addon/store/shop/controller/Account.php
Executable file
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\store\shop\controller;
|
||||
|
||||
use addon\store\model\StoreAccount;
|
||||
use app\model\system\Export as ExportModel;
|
||||
use app\shop\controller\BaseShop;
|
||||
|
||||
/**
|
||||
* 门店账户
|
||||
*/
|
||||
class Account extends BaseShop
|
||||
{
|
||||
/**
|
||||
* 门店提现列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$account_model = new StoreAccount();
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$remark = input('remark', '');
|
||||
$start_date = input('start_date', '');
|
||||
$end_date = input('end_date', '');
|
||||
$from_type = input('from_type', '');
|
||||
$store_id = input('store_id', 0);//门店
|
||||
|
||||
$alias = 'sa';
|
||||
$join = [
|
||||
['store s', 'sa.store_id = s.store_id', 'inner'],
|
||||
];
|
||||
|
||||
$condition = [ [ 'sa.site_id', '=', $this->site_id ] ];
|
||||
|
||||
if (!empty($remark)) {
|
||||
$condition[] = [ 'sa.remark', 'like', '%' . $remark . '%' ];
|
||||
}
|
||||
if (!empty($from_type)) {
|
||||
$condition[] = [ 'sa.from_type', '=', $from_type ];
|
||||
}
|
||||
if ($store_id > 0) {
|
||||
$condition[] = [ 'sa.store_id', '=', $store_id ];
|
||||
}
|
||||
if ($start_date != '' && $end_date != '') {
|
||||
$condition[] = [ 'sa.create_time', 'between', [ strtotime($start_date), strtotime($end_date) ] ];
|
||||
} else if ($start_date != '' && $end_date == '') {
|
||||
$condition[] = [ 'sa.create_time', '>=', strtotime($start_date) ];
|
||||
} else if ($start_date == '' && $end_date != '') {
|
||||
$condition[] = [ 'sa.create_time', '<=', strtotime($end_date) ];
|
||||
}
|
||||
|
||||
$field = 'sa.*,s.store_name';
|
||||
$order = 'sa.id desc';
|
||||
$res = $account_model->getStoreAccountPageList($condition, $page, $page_size, $order, $field, $alias, $join);
|
||||
|
||||
//账户金额累加
|
||||
$account_info = $account_model->getStoreAccountInfo($condition, 'sum(sa.account_data) as account_data_sum', $alias, $join)['data'];
|
||||
$res['data']['account_data_sum'] = $account_info['account_data_sum'] ?? 0;
|
||||
|
||||
return $res;
|
||||
} else {
|
||||
//门店列表
|
||||
$store_model = new \app\model\store\Store();
|
||||
$store_list = $store_model->getStoreList([ [ 'site_id', '=', $this->site_id ] ], '*', 'is_default desc,store_id desc')[ 'data' ] ?? [];
|
||||
$this->assign('store_list', $store_list);
|
||||
//门店相关统计
|
||||
$stat_model = new \addon\store\model\Stat();
|
||||
$stat_condition = array (
|
||||
[ 'site_id', '=', $this->site_id ]
|
||||
);
|
||||
$total_account = $stat_model->getStoreAccountSum($stat_condition, 'account')[ 'data' ] ?? 0;
|
||||
$total_account_apply = $stat_model->getStoreAccountSum($stat_condition, 'account_apply')[ 'data' ] ?? 0;
|
||||
$total_account_withdraw = $stat_model->getStoreAccountSum($stat_condition, 'account_withdraw')[ 'data' ] ?? 0;
|
||||
$this->assign('stat', [
|
||||
'total_account' => $total_account,
|
||||
'total_account_apply' => $total_account_apply,
|
||||
'total_account_withdraw' => $total_account_withdraw,
|
||||
]);
|
||||
//来源方式
|
||||
$from_type_list = $account_model->from_type;
|
||||
$this->assign('from_type_list', $from_type_list);
|
||||
return $this->fetch('account/lists');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加导出
|
||||
*/
|
||||
public function addExport()
|
||||
{
|
||||
$input = input();
|
||||
$input['site_id'] = $this->site_id;
|
||||
$account_model = new StoreAccount();
|
||||
return $account_model->addStoreAccountExport($input);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出列表
|
||||
*/
|
||||
public function exportList()
|
||||
{
|
||||
$param = [
|
||||
'from_type_list' => [
|
||||
['id' => 'store_account', 'name' => '门店账户'],
|
||||
],
|
||||
'lists_url' => 'store://shop/account/exportList',
|
||||
'delete_url' => 'store://shop/account/deleteExport',
|
||||
];
|
||||
$export_controller = new \app\shop\controller\Export();
|
||||
return $export_controller->lists($param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除导出
|
||||
*/
|
||||
public function deleteExport()
|
||||
{
|
||||
$export_controller = new \app\shop\controller\Export();
|
||||
return $export_controller->delete('store_account');
|
||||
}
|
||||
}
|
||||
85
addon/store/shop/controller/Config.php
Executable file
85
addon/store/shop/controller/Config.php
Executable file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\store\shop\controller;
|
||||
|
||||
use addon\store\model\Config as ConfigModel;
|
||||
use app\model\order\OrderCommon as OrderCommonModel;
|
||||
use app\shop\controller\BaseShop;
|
||||
use think\App;
|
||||
|
||||
/**
|
||||
* 门店设置控制器
|
||||
*/
|
||||
class Config extends BaseShop
|
||||
{
|
||||
|
||||
public function __construct(App $app = null)
|
||||
{
|
||||
$this->replace = [
|
||||
'STORE_IMG' => __ROOT__ . '/addon/store/shop/view/public/img',
|
||||
'STORE_JS' => __ROOT__ . '/addon/store/shop/view/public/js',
|
||||
'STORE_CSS' => __ROOT__ . '/addon/store/shop/view/public/css',
|
||||
];
|
||||
parent::__construct($app);
|
||||
}
|
||||
|
||||
/**
|
||||
* 门店结算周期配置
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$config_model = new ConfigModel();
|
||||
if (request()->isJson()) {
|
||||
if(env('IS_RELEASE_WEAPP')){
|
||||
return error(-1, '发布小程序期间禁止操作');
|
||||
}
|
||||
//门店结算与提现设置
|
||||
$withdraw_config = [
|
||||
'is_settlement' => input('is_settlement', 0), // 是否进行门店结算
|
||||
'period_type' => input('period_type', 4), // 结算方式 1 按天 2. 按周 3. 按月 4. 门店申请结算
|
||||
'settlement_rate' => input('settlement_rate', 0), // 结算比率
|
||||
'settlement_pay_type' => input('settlement_pay_type', ''), // 结算付款控制
|
||||
'settlement_cost' => input('settlement_cost', ''), // 结算成本控制 coupon,point,balance,fenxiao_commission
|
||||
'is_withdraw' => input('is_withdraw', 0), // 是否允许提现
|
||||
'is_audit' => input('is_audit', 0), // 是否需要提现审核
|
||||
'is_auto_transfer' => input('is_auto_transfer', 0), // 是否自动转账
|
||||
'withdraw_type' => input('withdraw_type', ''), // 可提现账户类型 wechat,alipay, bank
|
||||
'withdraw_least' => input('withdraw_least', 0), // 提现最低金额
|
||||
];
|
||||
$config_model->setStoreWithdrawConfig($this->site_id, $withdraw_config);
|
||||
$business_config = [
|
||||
'store_business' => input('store_business', 'shop'), // 门店运营模式 shop:店铺整体运营 store:连锁门店运营模式
|
||||
'is_allow_change' => input('is_allow_change', 1), // 是否允许切换门店
|
||||
'confirm_popup_control' => input('confirm_popup_control', 0), // 门店确认弹窗
|
||||
'store_auth' => input('store_auth', ''), // 门店控制权限
|
||||
];
|
||||
$res = $config_model->setStoreBusinessConfig($this->site_id, $business_config);
|
||||
return $res;
|
||||
} else {
|
||||
|
||||
$business_config = $config_model->getStoreBusinessConfig($this->site_id)[ 'data' ][ 'value' ];
|
||||
$this->assign('business_config', $business_config);
|
||||
|
||||
$withdraw_config = $config_model->getStoreWithdrawConfig($this->site_id)[ 'data' ][ 'value' ];
|
||||
$this->assign('withdraw_config', $withdraw_config);
|
||||
|
||||
if (addon_is_exit('cashier') == 1) {
|
||||
$order_common_model = new OrderCommonModel();
|
||||
$pay_type = $order_common_model->getPayType([ 'order_type' => 5 ]);
|
||||
if (isset($pay_type[ 'BALANCE' ])) unset($pay_type[ 'BALANCE' ]);
|
||||
if (isset($pay_type[ 'ONLINE_PAY' ])) unset($pay_type[ 'ONLINE_PAY' ]);
|
||||
$this->assign('pay_type_list', $pay_type);
|
||||
}
|
||||
|
||||
return $this->fetch('config/index');
|
||||
}
|
||||
}
|
||||
}
|
||||
104
addon/store/shop/controller/Settlement.php
Executable file
104
addon/store/shop/controller/Settlement.php
Executable file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\store\shop\controller;
|
||||
|
||||
use app\model\order\OrderCommon as OrderCommonModel;
|
||||
use app\model\store\Store;
|
||||
use app\shop\controller\BaseShop;
|
||||
use addon\store\model\Settlement as SettlementModel;
|
||||
|
||||
/**
|
||||
* 门店结算控制器
|
||||
*/
|
||||
class Settlement extends BaseShop
|
||||
{
|
||||
|
||||
/**
|
||||
* 门店结算列表
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$model = new SettlementModel();
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$store_id = input('store_id', '');
|
||||
if (!empty($store_id)) {
|
||||
$condition[] = [ 'store_id', '=', $store_id ];
|
||||
}
|
||||
$condition[] = [ 'site_id', '=', $this->site_id ];
|
||||
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
if (!empty($start_time) && empty($end_time)) {
|
||||
$condition[] = [ 'start_time', '>=', $start_time ];
|
||||
} elseif (empty($start_time) && !empty($end_time)) {
|
||||
$condition[] = [ 'end_time', '<=', $end_time ];
|
||||
} elseif (!empty($start_time) && !empty($end_time)) {
|
||||
$condition[] = [ 'start_time', '>=', $start_time ];
|
||||
$condition[] = [ 'end_time', '<=', $end_time ];
|
||||
}
|
||||
$order = 'id desc';
|
||||
$field = 'id,settlement_no,site_id,site_name,store_name,order_money,shop_money,refund_platform_money,platform_money,refund_shop_money,
|
||||
refund_money,create_time,commission,is_settlement,offline_refund_money,offline_order_money,start_time,end_time, store_commission, withdraw_id';
|
||||
$list = $model->getStoreSettlementPageList($condition, $page, $page_size, $order, $field);
|
||||
return $list;
|
||||
}
|
||||
//门店列表
|
||||
$store_model = new Store();
|
||||
$store_list = $store_model->getStoreList([ [ 'site_id', '=', $this->site_id ] ]);
|
||||
$this->assign('store_list', $store_list[ 'data' ]);
|
||||
return $this->fetch('settlement/index');
|
||||
}
|
||||
|
||||
/**
|
||||
* 已结算
|
||||
* @return array
|
||||
*/
|
||||
public function settlement()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$remark = input('remark', '');
|
||||
$settlement_id = input('settlement_id', 0);
|
||||
if (empty($remark)) {
|
||||
return error(-1, '请填写备注!');
|
||||
}
|
||||
$settlement_model = new SettlementModel();
|
||||
$res = $settlement_model->editSettlement([ 'is_settlement' => 1, 'remark' => $remark ], [ [ 'id', '=', $settlement_id ] ]);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* detail 结算详情
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$settlement_id = input('settlement_id', 0);
|
||||
$order_model = new OrderCommonModel();
|
||||
if (request()->isJson()) {
|
||||
$condition[] = [ 'store_settlement_id', '=', $settlement_id ];
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$field = 'order_id,order_no,pay_type,order_money,pay_type_name,order_status,refund_money,commission,finish_time,store_commission';
|
||||
$list = $order_model->getOrderPageList($condition, $page, $page_size, 'finish_time desc', $field);
|
||||
|
||||
return $list;
|
||||
}
|
||||
$settlement_model = new SettlementModel();
|
||||
$settlement_info = $settlement_model->getSettlementInfo([ [ 'id', '=', $settlement_id ] ]);
|
||||
$store_model = new Store();
|
||||
$store_info = $store_model->getStoreInfoByAccount([ [ 'store_id', '=', $settlement_info[ 'data' ][ 'store_id' ] ] ], 'create_time');
|
||||
$this->assign('store_info', $store_info[ 'data' ]);
|
||||
$this->assign('info', $settlement_info[ 'data' ]);
|
||||
return $this->fetch('settlement/detail');
|
||||
}
|
||||
}
|
||||
159
addon/store/shop/controller/Stat.php
Executable file
159
addon/store/shop/controller/Stat.php
Executable file
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 上海牛之云网络科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\store\shop\controller;
|
||||
|
||||
use app\model\store\Stat as StatModel;
|
||||
use app\model\store\Store as StoreModel;
|
||||
use app\shop\controller\BaseShop;
|
||||
use Carbon\Carbon;
|
||||
|
||||
|
||||
class Stat extends BaseShop
|
||||
{
|
||||
/**
|
||||
* 门店统计数据
|
||||
*/
|
||||
public function store()
|
||||
{
|
||||
$store_list = ( new StoreModel() )->getStoreList([ [ 'site_id', '=', $this->site_id ] ], 'store_id,store_name');
|
||||
$this->assign('store_list', $store_list[ 'data' ]);
|
||||
$this->assign('today', Carbon::today()->toDateString());
|
||||
$this->assign('yesterday', Carbon::yesterday()->toDateString());
|
||||
return $this->fetch('stat/store');
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计数据总和
|
||||
*/
|
||||
public function statTotal()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$store_id = input('store_id', 0);
|
||||
$start_time = $end_time = input('start_time', strtotime(date('Y-m-d', time())));
|
||||
$end_time = input('end_time', time());
|
||||
|
||||
if ($start_time > $end_time) {
|
||||
$start_time = input('end_time');
|
||||
$end_time = input('start_time');
|
||||
}
|
||||
|
||||
$stat_model = new StatModel();
|
||||
|
||||
$data = $stat_model->getShopStatSum($this->site_id, $start_time, $end_time, $store_id);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取天统计趋势数据
|
||||
*/
|
||||
public function dayStatData()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$store_id = input('store_id', 0);
|
||||
$start_time = input('start_time', strtotime(date('Y-m-d', strtotime('-6 day'))));
|
||||
$end_time = input('end_time', time());
|
||||
|
||||
if ($start_time > $end_time) {
|
||||
$start_time = input('end_time');
|
||||
$end_time = input('start_time');
|
||||
}
|
||||
|
||||
$stat_model = new StatModel();
|
||||
$fields = $stat_model->getStatField();
|
||||
$fields[] = 'expected_earnings_total_money';
|
||||
|
||||
$stat_list = $stat_model->getShopStatList($this->site_id, $start_time, $end_time, $store_id)[ 'data' ];
|
||||
$temp_stat_list = [];
|
||||
foreach ($stat_list as $v){
|
||||
$temp_day = date('Y-m-d', $v[ 'day_time' ]);
|
||||
$v['day_time'] = $temp_day;
|
||||
$temp_stat_list[$temp_day][] = $v;
|
||||
}
|
||||
// $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;
|
||||
$temp_day_stat_list = $temp_stat_list[$date] ?? [];
|
||||
$field_value = 0;
|
||||
if(!empty($temp_day_stat_list)){
|
||||
foreach($temp_day_stat_list as $temp_v){
|
||||
$field_value += $temp_v ? $temp_v[ $field ] : 0;
|
||||
}
|
||||
}
|
||||
$value[] += $field_value;
|
||||
}
|
||||
$data[ $field ] = $value;
|
||||
$data[ 'time' ] = $time;
|
||||
}
|
||||
return success(0, '', $data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小时统计趋势数据
|
||||
*/
|
||||
public function hourStatData()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$time = input('start_time', time());
|
||||
$store_id = input('store_id', 0);
|
||||
$carbon = Carbon::createFromTimestamp($time);
|
||||
|
||||
$stat_model = new StatModel();
|
||||
$fields = $stat_model->getStatHourField();
|
||||
$fields[] = 'expected_earnings_total_money';
|
||||
|
||||
$stat_list = $stat_model->getShopStatHourList($this->site_id, $carbon->year, $carbon->month, $carbon->day, $store_id)[ 'data' ];
|
||||
|
||||
$data = [];
|
||||
$empty = array_map(function() { return 0; }, range(0, 23, 1));
|
||||
if (!empty($stat_list)) {
|
||||
// $stat_list = array_column($stat_list, null, 'hour');
|
||||
$temp_stat_list = [];
|
||||
foreach($stat_list as $v){
|
||||
$temp_stat_list[$v['hour']][] = $v;
|
||||
}
|
||||
foreach ($fields as $field) {
|
||||
$value = [];
|
||||
for ($i = 0; $i < 24; $i++) {
|
||||
$value[ $i ] = 0;
|
||||
$temp_item_stat_list = $temp_stat_list[ $i ] ?? [];
|
||||
if(!empty($temp_item_stat_list)){
|
||||
foreach($temp_item_stat_list as $temp_v){
|
||||
$value[ $i ] += $temp_v ? $temp_v[ $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 success(0, '', $data);
|
||||
}
|
||||
}
|
||||
}
|
||||
863
addon/store/shop/controller/Store.php
Executable file
863
addon/store/shop/controller/Store.php
Executable file
@@ -0,0 +1,863 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\store\shop\controller;
|
||||
|
||||
use addon\store\model\Category;
|
||||
use addon\store\model\Label;
|
||||
use addon\store\model\StoreWithdraw;
|
||||
use app\model\express\Config as ExpressConfig;
|
||||
use app\model\express\ExpressDeliver;
|
||||
use app\model\express\Local as LocalModel;
|
||||
use app\model\order\Order;
|
||||
use app\model\shop\ShopApply as ShopApplyModel;
|
||||
use app\model\store\Store as StoreModel;
|
||||
use app\model\system\Address as AddressModel;
|
||||
use app\model\system\User;
|
||||
use app\model\web\Config as ConfigModel;
|
||||
use app\model\web\Config as WebConfig;
|
||||
use app\shop\controller\BaseShop;
|
||||
use addon\store\model\Config as StoreConfig;
|
||||
use think\facade\Cache;
|
||||
use think\facade\Session;
|
||||
|
||||
/**
|
||||
* 门店
|
||||
* Class Store
|
||||
* @package app\shop\controller
|
||||
*/
|
||||
class Store extends BaseShop
|
||||
{
|
||||
/**
|
||||
* 门店首页
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$store_model = new StoreModel();
|
||||
$order_model = new Order();
|
||||
$withdrawal_model = new StoreWithdraw();
|
||||
$data = [
|
||||
'store_num' => $store_model->getStoreCount([ [ 'site_id', '=', $this->site_id ] ])[ 'data' ],
|
||||
'in_business_num' => $store_model->getStoreCount([ [ 'site_id', '=', $this->site_id ], [ 'status', '=', 1 ] ])[ 'data' ],
|
||||
'total_order_num' => $order_model->getOrderCount([ [ 'site_id', '=', $this->site_id ], [ 'store_id', '>', 0 ], [ 'is_delete', '=', 0 ], [ 'pay_status', '=', 1 ] ])[ 'data' ],
|
||||
'total_order_money' => $order_model->getOrderMoneySum([ [ 'site_id', '=', $this->site_id ], [ 'store_id', '>', 0 ], [ 'is_delete', '=', 0 ], [ 'pay_status', '=', 1 ] ])[ 'data' ],
|
||||
'account_apply' => $store_model->getStoreSum([ [ 'site_id', '=', $this->site_id ] ], 'account_apply')[ 'data' ],
|
||||
'wait_audit_num' => $withdrawal_model->getStoreWithdrawCount([ [ 'site_id', '=', $this->site_id ], [ 'status', '=', 0 ] ])[ 'data' ],
|
||||
'wait_audit_money' => $withdrawal_model->getStoreWithdrawSum([ [ 'site_id', '=', $this->site_id ], [ 'status', '=', 0 ] ], 'money')[ 'data' ],
|
||||
'wait_transfer_num' => $withdrawal_model->getStoreWithdrawCount([ [ 'site_id', '=', $this->site_id ], [ 'status', '=', 1 ] ])[ 'data' ],
|
||||
'wait_transfer_money' => $withdrawal_model->getStoreWithdrawSum([ [ 'site_id', '=', $this->site_id ], [ 'status', '=', 1 ] ], 'money')[ 'data' ],
|
||||
];
|
||||
return $store_model->success($data);
|
||||
}
|
||||
return $this->fetch('store/index');
|
||||
}
|
||||
|
||||
/**
|
||||
* 门店排行
|
||||
*/
|
||||
public function storeRanking()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$order = input('order', 'num');
|
||||
$stat_model = new \addon\store\model\Stat();
|
||||
$data = $stat_model->getStoreOrderRank([
|
||||
'site_id' => $this->site_id,
|
||||
'order' => $order,
|
||||
]);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品排行
|
||||
*/
|
||||
public function goodsRanking()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$order_model = new Order();
|
||||
$order = input('order', 'num');
|
||||
$condition = [
|
||||
[ 'og.site_id', '=', $this->site_id ],
|
||||
[ 'og.store_id', '>', 0 ],
|
||||
[ 'o.pay_status', '=', 1 ],
|
||||
[ 'o.is_delete', '=', 0 ]
|
||||
];
|
||||
$join = [
|
||||
[ 'order o', 'o.order_id = og.order_id', 'inner' ],
|
||||
[ 'store s', 's.store_id = o.store_id', 'inner' ]
|
||||
];
|
||||
$order = $order == 'num' ? 'goods_num desc' : 'goods_money desc';
|
||||
$res = $order_model->getOrderGoodsList($condition, 'sum(og.num) as goods_num, sum(o.goods_money) as goods_money,og.goods_name', $order, 5, 'og.goods_id', 'og', $join);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 门店列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$store_model = new StoreModel();
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
// $order = input("order", "create_time desc");
|
||||
$keyword = input('search_text', '');
|
||||
$status = input('status', '');
|
||||
$type = input('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 . '%'];
|
||||
}
|
||||
$order = 'is_default desc,store_id desc';
|
||||
$list = $store_model->getStorePageListByAccount($condition, $page, $page_size, $order);
|
||||
return $list;
|
||||
} else {
|
||||
|
||||
//判断门店插件是否存在
|
||||
$store_is_exit = addon_is_exit('store', $this->site_id);
|
||||
$this->assign('store_is_exit', $store_is_exit);
|
||||
$this->assign('title', $store_is_exit ? '门店' : '自提点');
|
||||
$this->assign('store_type', ( new StoreModel() )->getStoreType());
|
||||
|
||||
$config_model = new ConfigModel();
|
||||
$default_img = $config_model->getDefaultImg($this->site_id, $this->app_module)[ 'data' ][ 'value' ];
|
||||
$this->assign('default_img', $default_img);
|
||||
|
||||
return $this->fetch('store/lists');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加门店
|
||||
* @return mixed
|
||||
*/
|
||||
public function addStore()
|
||||
{
|
||||
$is_store = addon_is_exit('store');
|
||||
|
||||
if (request()->isJson()) {
|
||||
$store_name = input('store_name', '');
|
||||
$telphone = input('telphone', '');
|
||||
$store_image = input('store_image', '');
|
||||
$province_id = input('province_id', 0);
|
||||
$city_id = input('city_id', 0);
|
||||
$district_id = input('district_id', 0);
|
||||
$community_id = input('community_id', 0);
|
||||
$address = input('address', '');
|
||||
$full_address = input('full_address', '');
|
||||
$longitude = input('longitude', 0);
|
||||
$latitude = input('latitude', 0);
|
||||
$is_pickup = input('is_pickup', 0);
|
||||
$is_o2o = input('is_o2o', 0);
|
||||
$start_time = input('start_time', 0);
|
||||
$end_time = input('end_time', 0);
|
||||
$time_type = input('time_type', 0);
|
||||
$time_week = input('time_week', '');
|
||||
$stock_type = input('stock_type', '');
|
||||
if (!empty($time_week)) {
|
||||
$time_week = implode(',', $time_week);
|
||||
}
|
||||
$data = [
|
||||
'store_name' => $store_name,
|
||||
'telphone' => $telphone,
|
||||
'store_image' => $store_image,
|
||||
'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,
|
||||
'open_date' => '全天营业',
|
||||
'site_id' => $this->site_id,
|
||||
'start_time' => $start_time,
|
||||
'end_time' => $end_time,
|
||||
'time_type' => $time_type,
|
||||
'time_week' => $time_week,
|
||||
'stock_type' => $stock_type,
|
||||
'is_pickup' => $is_pickup,
|
||||
'is_o2o' => $is_o2o,
|
||||
'store_type' => input('store_type', ''),
|
||||
'category_id' => input('category_id', 0),
|
||||
'category_name' => input('category_name', ''),
|
||||
'label_id' => input('label_id', ''),
|
||||
'label_name' => input('label_name', ''),
|
||||
'store_images' => input('store_images', ''),
|
||||
'store_introduce' => input('store_introduce', '')
|
||||
];
|
||||
|
||||
//判断是否开启多门店
|
||||
if ($is_store == 1) {
|
||||
$user_data = [
|
||||
'uid' => input('uid', ''),
|
||||
];
|
||||
} else {
|
||||
$user_data = [];
|
||||
}
|
||||
$store_model = new StoreModel();
|
||||
$result = $store_model->addStore($data, $user_data, $is_store);
|
||||
return $result;
|
||||
} else {
|
||||
//查询省级数据列表
|
||||
$address_model = new AddressModel();
|
||||
$list = $address_model->getAreaList([ ['pid', '=', 0 ], ['level', '=', 1 ] ]);
|
||||
$this->assign('province_list', $list['data']);
|
||||
|
||||
$this->assign('is_exit', $is_store);
|
||||
|
||||
$this->assign('title', $is_store ? '门店' : '自提点');
|
||||
|
||||
$this->assign('http_type', get_http_type());
|
||||
|
||||
$config_model = new ConfigModel();
|
||||
$mp_config = $config_model->getMapConfig($this->site_id);
|
||||
$this->assign('tencent_map_key', $mp_config[ 'data' ][ 'value' ][ 'tencent_map_key' ]);
|
||||
|
||||
//效验腾讯地图KEY
|
||||
$check_map_key = $config_model->checkQqMapKey($mp_config[ 'data' ][ 'value' ][ 'tencent_map_key' ]);
|
||||
$this->assign('check_map_key', $check_map_key);
|
||||
|
||||
$express_type = ( new ExpressConfig() )->getEnabledExpressType($this->site_id);
|
||||
if (isset($express_type[ 'express' ])) unset($express_type[ 'express' ]);
|
||||
$this->assign('express_type', $express_type);
|
||||
$this->assign('store_type', ( new StoreModel() )->getStoreType());
|
||||
|
||||
$user_list = ( new User() )->getUserList([ [ 'site_id', '=', $this->site_id ],['app_module', '=', 'shop'],['is_admin', '=', 0] ], 'uid,username')[ 'data' ];
|
||||
$this->assign('user_list', $user_list);
|
||||
|
||||
$category = new Category();
|
||||
$category_config = $category->getCategoryConfig($this->site_id)[ 'data' ][ 'value' ];
|
||||
if ($category_config[ 'status' ]) {
|
||||
$category_list = $category->getStoreCategoryList([ [ 'site_id', '=', $this->site_id ] ], 'category_id,category_name')[ 'data' ];
|
||||
$this->assign('category_list', $category_list);
|
||||
}
|
||||
$this->assign('category_status', $category_config[ 'status' ]);
|
||||
|
||||
$label_list = ( new Label() )->getStoreLabelList([ [ 'site_id', '=', $this->site_id ] ], 'label_id,label_name')[ 'data' ];
|
||||
$this->assign('label_list', $label_list);
|
||||
|
||||
return $this->fetch('store/add_store');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑门店
|
||||
* @return mixed
|
||||
*/
|
||||
public function editStore()
|
||||
{
|
||||
$is_exit = addon_is_exit('store');
|
||||
$store_id = input('store_id', 0);
|
||||
$condition = [
|
||||
['site_id', '=', $this->site_id ],
|
||||
['store_id', '=', $store_id ]
|
||||
];
|
||||
$store_model = new StoreModel();
|
||||
if (request()->isJson()) {
|
||||
$store_name = input('store_name', '');
|
||||
$telphone = input('telphone', '');
|
||||
$store_image = input('store_image', '');
|
||||
$province_id = input('province_id', 0);
|
||||
$city_id = input('city_id', 0);
|
||||
$district_id = input('district_id', 0);
|
||||
$community_id = input('community_id', 0);
|
||||
$address = input('address', '');
|
||||
$full_address = input('full_address', '');
|
||||
$longitude = input('longitude', 0);
|
||||
$latitude = input('latitude', 0);
|
||||
$is_pickup = input('is_pickup', 0);
|
||||
$is_o2o = input('is_o2o', 0);
|
||||
$start_time = input('start_time', 0);
|
||||
$end_time = input('end_time', 0);
|
||||
$time_type = input('time_type', 0);
|
||||
$time_week = input('time_week', '');
|
||||
$stock_type = input('stock_type', '');
|
||||
if (!empty($time_week)) {
|
||||
$time_week = implode(',', $time_week);
|
||||
}
|
||||
$data = [
|
||||
'store_name' => $store_name,
|
||||
'telphone' => $telphone,
|
||||
'store_image' => $store_image,
|
||||
'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,
|
||||
'start_time' => $start_time,
|
||||
'end_time' => $end_time,
|
||||
'time_type' => $time_type,
|
||||
'time_week' => $time_week,
|
||||
'stock_type' => $stock_type,
|
||||
'is_pickup' => $is_pickup,
|
||||
'is_o2o' => $is_o2o,
|
||||
'store_type' => input('store_type', ''),
|
||||
'category_id' => input('category_id', 0),
|
||||
'category_name' => input('category_name', ''),
|
||||
'label_id' => input('label_id', ''),
|
||||
'label_name' => input('label_name', ''),
|
||||
'store_images' => input('store_images', ''),
|
||||
'store_introduce' => input('store_introduce', '')
|
||||
];
|
||||
$result = $store_model->editStore($data, $condition, [], $is_exit, 1);
|
||||
return $result;
|
||||
} else {
|
||||
//查询省级数据列表
|
||||
$address_model = new AddressModel();
|
||||
$list = $address_model->getAreaList([ ['pid', '=', 0 ], ['level', '=', 1 ] ]);
|
||||
$this->assign('province_list', $list['data']);
|
||||
$info_result = $store_model->getStoreDetail($condition);//门店信息
|
||||
$info = $info_result['data'];
|
||||
|
||||
if (empty($info)) $this->error('未获取到门店数据', href_url('store://shop/store/lists'));
|
||||
|
||||
$this->assign('info', $info);
|
||||
$this->assign('store_id', $store_id);
|
||||
|
||||
$this->assign('is_exit', $is_exit);
|
||||
$this->assign('title', $is_exit ? '门店' : '自提点');
|
||||
$this->assign('http_type', get_http_type());
|
||||
|
||||
$config_model = new ConfigModel();
|
||||
$mp_config = $config_model->getMapConfig($this->site_id);
|
||||
$this->assign('tencent_map_key', $mp_config[ 'data' ][ 'value' ][ 'tencent_map_key' ]);
|
||||
|
||||
//效验腾讯地图KEY
|
||||
$check_map_key = $config_model->checkQqMapKey($mp_config[ 'data' ][ 'value' ][ 'tencent_map_key' ]);
|
||||
$this->assign('check_map_key', $check_map_key);
|
||||
|
||||
$express_type = ( new ExpressConfig() )->getEnabledExpressType($this->site_id);
|
||||
if (isset($express_type[ 'express' ])) unset($express_type[ 'express' ]);
|
||||
$this->assign('express_type', $express_type);
|
||||
$this->assign('store_type', ( new StoreModel() )->getStoreType());
|
||||
|
||||
$category = new Category();
|
||||
$category_config = $category->getCategoryConfig($this->site_id)[ 'data' ][ 'value' ];
|
||||
if ($category_config[ 'status' ]) {
|
||||
$category_list = $category->getStoreCategoryList([ [ 'site_id', '=', $this->site_id ] ], 'category_id,category_name')[ 'data' ];
|
||||
$this->assign('category_list', $category_list);
|
||||
}
|
||||
$this->assign('category_status', $category_config[ 'status' ]);
|
||||
|
||||
$label_list = ( new Label() )->getStoreLabelList([ [ 'site_id', '=', $this->site_id ] ], 'label_id,label_name')[ 'data' ];
|
||||
$this->assign('label_list', $label_list);
|
||||
|
||||
return $this->fetch('store/edit_store');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function operate()
|
||||
{
|
||||
$store_id = input('store_id', 0);
|
||||
$condition = [
|
||||
['site_id', '=', $this->site_id ],
|
||||
['store_id', '=', $store_id ]
|
||||
];
|
||||
$store_model = new StoreModel();
|
||||
if (request()->isJson()) {
|
||||
$status = input('status', 0);
|
||||
$is_pickup = input('is_pickup', 0);
|
||||
$is_o2o = input('is_o2o', 0);
|
||||
$start_time = input('start_time', 0);
|
||||
$end_time = input('end_time', 0);
|
||||
$time_type = input('time_type', 0);
|
||||
$time_week = input('time_week', '');
|
||||
$stock_type = input('stock_type', '');
|
||||
if (!empty($time_week)) {
|
||||
$time_week = implode(',', $time_week);
|
||||
}
|
||||
$data = [
|
||||
'status' => $status,
|
||||
'start_time' => $start_time,
|
||||
'end_time' => $end_time,
|
||||
'time_type' => $time_type,
|
||||
'time_week' => $time_week,
|
||||
'stock_type' => $stock_type,
|
||||
'is_pickup' => $is_pickup,
|
||||
'is_o2o' => $is_o2o,
|
||||
'time_interval' => input('time_interval', 30),
|
||||
'delivery_time' => input('delivery_time', ''),
|
||||
'advance_day' => input('advance_day', 0),
|
||||
'most_day' => input('most_day', 7),
|
||||
'is_express' => input('is_express', 0),
|
||||
'open_date_config' => input('open_date_config', '[]'),
|
||||
'open_date' => input('open_date', ''),
|
||||
'out_open_date_o2o_pay' => input('out_open_date_o2o_pay', 1),
|
||||
'close_show' => input('close_show', 0),
|
||||
'close_desc' => input('close_desc', ''),
|
||||
];
|
||||
$result = $store_model->editStore($data, $condition, [], 1, 1);
|
||||
return $result;
|
||||
}
|
||||
|
||||
$store_info = $store_model->getStoreDetail($condition)[ 'data' ];//门店信息
|
||||
if (empty($store_info)) $this->error('未获取到门店信息');
|
||||
|
||||
$this->assign('info', $store_info);
|
||||
$this->assign('store_id', $store_id);
|
||||
$business_config = ( new StoreConfig() )->getStoreBusinessConfig($this->site_id);
|
||||
$this->assign('business_config', $business_config[ 'data' ][ 'value' ]);
|
||||
return $this->fetch('store/operate');
|
||||
}
|
||||
|
||||
public function frozenStore()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$store_id = input('store_id', 0);
|
||||
$is_frozen = input('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 $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
*/
|
||||
public function modifyPassword()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$store_id = input('store_id', '');
|
||||
$password = input('password', '123456');
|
||||
$store_model = new StoreModel();
|
||||
return $store_model->resetStorePassword($password, [ [ 'store_id', '=', $store_id ] ]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 同城配送
|
||||
*/
|
||||
public function local()
|
||||
{
|
||||
$store_id = input('store_id', 0);
|
||||
$store_model = new StoreModel();
|
||||
$info_result = $store_model->getStoreInfo([ [ 'site_id', '=', $this->site_id ], [ 'store_id', '=', $store_id ] ]);//门店信息
|
||||
$info = $info_result['data'];
|
||||
if (empty($info)) {
|
||||
$this->error([], '门店未找到');
|
||||
}
|
||||
$local_model = new LocalModel();
|
||||
if (request()->isJson()) {
|
||||
|
||||
$data = [
|
||||
'type' => input('type', 'default'),//配送方式 default 商家自配送 other 第三方配送
|
||||
'area_type' => input('area_type', 1),//配送区域
|
||||
'local_area_json' => input('local_area_json', ''),//区域及业务集合json
|
||||
'time_is_open' => input('time_is_open', 0),
|
||||
'time_type' => input('time_type', 0),//时间选取类型 0 全天 1 自定义
|
||||
'time_week' => input('time_week', ''),
|
||||
'start_time' => input('start_time', 0),
|
||||
'end_time' => input('end_time', 0),
|
||||
'update_time' => time(),
|
||||
'is_open_step' => input('is_open_step', 0),
|
||||
'start_distance' => input('start_distance', 0),
|
||||
'start_delivery_money' => input('start_delivery_money', 0),
|
||||
'continued_distance' => input('continued_distance', 0),
|
||||
'continued_delivery_money' => input('continued_delivery_money', 0),
|
||||
'start_money' => input('start_money', 0),
|
||||
'delivery_money' => input('delivery_money', 0),
|
||||
'area_array' => input('area_array', ''),//地域集合
|
||||
'man_money' => input('man_money', ''),
|
||||
'man_type' => input('man_type', ''),
|
||||
'man_discount' => input('man_discount', ''),
|
||||
'time_interval' => input('time_interval', 30),
|
||||
'delivery_time' => input('delivery_time', ''),
|
||||
'advance_day' => input('advance_day', 0),
|
||||
'most_day' => input('most_day', 7)
|
||||
];
|
||||
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'store_id', '=', $store_id ],
|
||||
];
|
||||
return $local_model->editLocal($data, $condition);
|
||||
} else {
|
||||
|
||||
$this->assign('store_detail', $info);
|
||||
$local_result = $local_model->getLocalInfo([ [ 'site_id', '=', $this->site_id ], [ 'store_id', '=', $store_id ] ]);
|
||||
|
||||
$district_list = [];
|
||||
if ($info[ 'province_id' ] > 0 && $info[ 'city_id' ] > 0) {
|
||||
//查询省级数据列表
|
||||
$address_model = new AddressModel();
|
||||
$list = $address_model->getAreaList([ ['pid', '=', $info[ 'city_id' ] ], ['level', '=', 3 ] ]);
|
||||
$district_list = $list['data'];
|
||||
}
|
||||
$this->assign('district_list', $district_list);
|
||||
$this->assign('local_info', $local_result[ 'data' ]);
|
||||
|
||||
$config_model = new WebConfig();
|
||||
$mp_config = $config_model->getMapConfig($this->site_id);
|
||||
$this->assign('tencent_map_key', $mp_config[ 'data' ][ 'value' ][ 'tencent_map_key' ]);
|
||||
|
||||
//效验腾讯地图KEY
|
||||
$check_map_key = $config_model->checkQqMapKey($mp_config[ 'data' ][ 'value' ][ 'tencent_map_key' ]);
|
||||
$this->assign('check_map_key', $check_map_key);
|
||||
|
||||
$this->assign('store_id', $store_id);
|
||||
return $this->fetch('store/local');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 结算设置
|
||||
*/
|
||||
public function settlement()
|
||||
{
|
||||
$store_id = input('store_id', 0);
|
||||
if (empty($store_id)) {
|
||||
$this->error('未获取到门店信息');
|
||||
}
|
||||
$store_model = new StoreModel();
|
||||
if (request()->isJson()) {
|
||||
$is_settlement = input('is_settlement', 0);
|
||||
if (empty($is_settlement)) {
|
||||
$data = [
|
||||
'is_settlement' => 0,
|
||||
'settlement_rate' => 0
|
||||
];
|
||||
} else {
|
||||
$data = [
|
||||
'is_settlement' => 1,
|
||||
'settlement_rate' => input('settlement_rate', 0),//跟随系统传入0,独立设置大于0
|
||||
'bank_type' => input('bank_type', 0),//1微信 2.支付宝 3,银行卡
|
||||
'bank_type_name' => input('bank_type_name', ''), //账户类型名称 微信默认为微信 支付宝默认是支付宝 银行卡需要传银行名称
|
||||
'bank_user_name' => input('bank_user_name', ''), //账户所属人姓名 针对银行卡需要传入
|
||||
'bank_type_account' => input('bank_type_account', ''), //具体账户信息,微信需要传入微信名称
|
||||
];
|
||||
}
|
||||
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'store_id', '=', $store_id ],
|
||||
];
|
||||
$result = $store_model->editStore($data, $condition, [], 1, 1);
|
||||
return $result;
|
||||
}
|
||||
|
||||
$store_info = $store_model->getStoreInfo([ [ 'site_id', '=', $this->site_id ], [ 'store_id', '=', $store_id ] ]);//门店信息
|
||||
if (empty($store_info)) $this->error('未获取到门店信息');
|
||||
|
||||
$this->assign('info', $store_info[ 'data' ]);
|
||||
$this->assign('store_id', $store_id);
|
||||
$withdraw_config = ( new StoreConfig() )->getStoreWithdrawConfig($this->site_id);
|
||||
$this->assign('withdraw_config', $withdraw_config[ 'data' ][ 'value' ]);
|
||||
return $this->fetch('store/settlement');
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信授权二维码
|
||||
*/
|
||||
public function createWechatAuthQrcode()
|
||||
{
|
||||
$cache_key = 'wechat_auth_' . md5(uniqid(null, true));
|
||||
$model = new \app\model\system\Qrcode();
|
||||
$url = addon_url("wechat://api/auth/getAuthInfo", [ "cache_key" => $cache_key ]);
|
||||
$qrcode = $model->createBase64Qrcode($url)['data'];
|
||||
return $model->success([
|
||||
'cache_key' => $cache_key,
|
||||
'qrcode' => $qrcode,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信授权数据
|
||||
*/
|
||||
public function getWechatAuthData()
|
||||
{
|
||||
$cache_key = input('cache_key', '');
|
||||
$data = Cache::get($cache_key);
|
||||
$model = new StoreModel();
|
||||
return $model->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 配送员列表
|
||||
*/
|
||||
public function deliverLists()
|
||||
{
|
||||
$store_id = input('store_id', 0);
|
||||
|
||||
$deliver_model = new ExpressDeliver();
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', '1');
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$condition = [
|
||||
[
|
||||
'site_id', '=', $this->site_id,
|
||||
],
|
||||
[
|
||||
'store_id', '=', $store_id,
|
||||
]
|
||||
];
|
||||
$search_text = input('search_text', '');
|
||||
if (!empty($search_text)) {
|
||||
$condition[] = [ 'deliver_name', 'like', '%' . $search_text . '%' ];
|
||||
}
|
||||
$deliver_lists = $deliver_model->getDeliverPageLists($condition, '*', 'create_time desc', $page, $page_size);
|
||||
return $deliver_lists;
|
||||
} else {
|
||||
$this->assign('store_id', $store_id);
|
||||
return $this->fetch('store/deliverlists');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加配送员
|
||||
*/
|
||||
public function addDeliver()
|
||||
{
|
||||
$store_id = input('store_id', 0);
|
||||
$this->assign('store_id', $store_id);
|
||||
return $this->fetch('store/adddeliver');
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑配送员
|
||||
*/
|
||||
public function editDeliver()
|
||||
{
|
||||
$store_id = input('store_id', 0);
|
||||
$this->assign('store_id', $store_id);
|
||||
$deliver_model = new ExpressDeliver();
|
||||
$deliver_id = input('deliver_id', 0);
|
||||
$this->assign('deliver_id', $deliver_id);
|
||||
$deliver_info = $deliver_model->getDeliverInfo($deliver_id, $this->site_id);
|
||||
$this->assign('deliver_info', $deliver_info[ 'data' ]);
|
||||
return $this->fetch('store/editdeliver');
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择门店
|
||||
* @return mixed
|
||||
*/
|
||||
public function selectStore()
|
||||
{
|
||||
$store_list = ( new StoreModel() )->getStoreList([ [ 'site_id', '=', $this->site_id ] ], 'store_id,store_name,status,address,full_address,is_frozen');
|
||||
$this->assign('store_list', $store_list[ 'data' ]);
|
||||
$store_id = explode(',', input('store_id', ''));
|
||||
$this->assign('store_id', $store_id);
|
||||
return $this->fetch('store/select');
|
||||
}
|
||||
|
||||
/**
|
||||
* 门店主页装修
|
||||
*/
|
||||
public function diy()
|
||||
{
|
||||
$data = [
|
||||
'site_id' => $this->site_id,
|
||||
'name' => 'DIY_STORE'
|
||||
];
|
||||
$edit_view = event('DiyViewEdit', $data, true);
|
||||
return $edit_view;
|
||||
}
|
||||
|
||||
/**
|
||||
* 门店分类
|
||||
* @return mixed
|
||||
*/
|
||||
public function category()
|
||||
{
|
||||
$category = new Category();
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ]
|
||||
];
|
||||
if (!empty($search_text)) $condition[] = [ 'category_name', 'like', "%{$search_text}%" ];
|
||||
return $category->getStoreCategoryPageList($condition, $page, $page_size);
|
||||
}
|
||||
$config = $category->getCategoryConfig($this->site_id)[ 'data' ][ 'value' ];
|
||||
$this->assign('status', $config[ 'status' ]);
|
||||
return $this->fetch('store/category');
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加分类
|
||||
* @return array
|
||||
*/
|
||||
public function addCategory()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$data = [
|
||||
'category_name' => input('category_name', ''),
|
||||
'site_id' => $this->site_id
|
||||
];
|
||||
return ( new Category() )->addStoreCategory($data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑分类
|
||||
* @return array
|
||||
*/
|
||||
public function editCategory()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$category_id = input('category_id', 0);
|
||||
$data = [
|
||||
'category_name' => input('category_name', ''),
|
||||
'sort' => input('sort', 0)
|
||||
];
|
||||
return ( new Category() )->editStoreCategory($data, [ [ 'category_id', '=', $category_id ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除分类
|
||||
* @return array
|
||||
*/
|
||||
public function deleteCategory()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$category_id = input('category_id', 0);
|
||||
return ( new Category() )->deleteStoreCategory([ [ 'category_id', 'in', $category_id ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 门店分类是否启用
|
||||
*/
|
||||
public function categoryConfig()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$status = input('status', 0);
|
||||
return ( new Category() )->setCategoryConfig([ 'status' => $status ], $this->site_id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 门店标签
|
||||
* @return mixed
|
||||
*/
|
||||
public function tag()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$search_text = input('search_text', '');
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ]
|
||||
];
|
||||
if (!empty($search_text)) $condition[] = [ 'label_name', 'like', "%{$search_text}%" ];
|
||||
return ( new Label() )->getStoreLabelPageList($condition, $page, $page_size);
|
||||
}
|
||||
return $this->fetch('store/tag');
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加标签
|
||||
* @return array
|
||||
*/
|
||||
public function addLabel()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$data = [
|
||||
'label_name' => input('label_name', ''),
|
||||
'site_id' => $this->site_id,
|
||||
'create_time' => time()
|
||||
];
|
||||
return ( new Label() )->addStoreLabel($data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑标签
|
||||
* @return array
|
||||
*/
|
||||
public function editLabel()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$label_id = input('label_id', 0);
|
||||
$data = [
|
||||
'label_name' => input('label_name', ''),
|
||||
'sort' => input('sort', 0)
|
||||
];
|
||||
return ( new Label() )->editStoreLabel($data, [ [ 'label_id', '=', $label_id ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除标签
|
||||
* @return array
|
||||
*/
|
||||
public function deleteLabel()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$label_id = input('label_id', 0);
|
||||
return ( new Label() )->deleteStoreLabel([ [ 'label_id', '=', $label_id ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 门店标签选择框
|
||||
* @return mixed
|
||||
*/
|
||||
public function labelSelect()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$search_text = input('search_text', '');
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ]
|
||||
];
|
||||
if (!empty($search_text)) $condition[] = [ 'label_name', 'like', "%{$search_text}%" ];
|
||||
return ( new Label() )->getStoreLabelPageList($condition, $page, $page_size);
|
||||
} else {
|
||||
$select_id = input('select_id', '');
|
||||
$this->assign('select_id', $select_id);
|
||||
return $this->fetch('store/label_select');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改排序
|
||||
*/
|
||||
public function modifySort()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$sort = input('sort', 0);
|
||||
$label_id = input('label_id', 0);
|
||||
$label_model = new Label();
|
||||
$res = $label_model->modifySort($sort, $label_id, $this->site_id);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
202
addon/store/shop/controller/Withdraw.php
Executable file
202
addon/store/shop/controller/Withdraw.php
Executable file
@@ -0,0 +1,202 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\store\shop\controller;
|
||||
|
||||
use addon\mobileshop\model\Config as ConfigModel;
|
||||
use addon\store\model\StoreWithdraw;
|
||||
use addon\wechatpay\model\Config as WechatPayConfig;
|
||||
use app\shop\controller\BaseShop;
|
||||
|
||||
/**
|
||||
* 门店提现控制器
|
||||
*/
|
||||
class Withdraw extends BaseShop
|
||||
{
|
||||
|
||||
/**
|
||||
* 转账
|
||||
*/
|
||||
public function transferFinish()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$withdraw_id = input('withdraw_id', 0);
|
||||
$voucher_img = input('voucher_img', '');
|
||||
$voucher_desc = input('voucher_desc', '');
|
||||
$withdraw_model = new StoreWithdraw();
|
||||
$data = array (
|
||||
'withdraw_id' => $withdraw_id,
|
||||
'site_id' => $this->site_id,
|
||||
'voucher_desc' => $voucher_desc,
|
||||
'voucher_img' => $voucher_img,
|
||||
);
|
||||
$result = $withdraw_model->transferFinish($data);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 门店提现列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$withdraw_model = new StoreWithdraw();
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$withdraw_no = input('withdraw_no', '');
|
||||
$start_date = input('start_date', '');
|
||||
$end_date = input('end_date', '');
|
||||
$status = input('status', 'all');//提现状态
|
||||
$transfer_type = input('transfer_type', '');//提现转账方式
|
||||
$store_id = input('store_id', 0);//门店
|
||||
|
||||
$transfer_start_date = input('transfer_start_date', '');
|
||||
$transfer_end_date = input('transfer_end_date', '');
|
||||
$settlement_type = input('settlement_type', '');
|
||||
$condition = [ [ 'sw.site_id', '=', $this->site_id ] ];
|
||||
|
||||
if (!empty($withdraw_no)) {
|
||||
$condition[] = [ 'withdraw_no', 'like', '%' . $withdraw_no . '%' ];
|
||||
}
|
||||
if (!empty($transfer_type)) {
|
||||
$condition[] = [ 'transfer_type', '=', $transfer_type ];
|
||||
}
|
||||
if ($store_id > 0) {
|
||||
$condition[] = [ 'sw.store_id', '=', $store_id ];
|
||||
}
|
||||
if (!empty($settlement_type)) {
|
||||
$condition[] = [ 'settlement_type', '=', $settlement_type ];
|
||||
}
|
||||
if ($status != 'all') {
|
||||
$condition[] = [ 'sw.status', '=', $status ];
|
||||
}
|
||||
if ($start_date != '' && $end_date != '') {
|
||||
$condition[] = [ 'apply_time', 'between', [ strtotime($start_date), strtotime($end_date) ] ];
|
||||
} else if ($start_date != '' && $end_date == '') {
|
||||
$condition[] = [ 'apply_time', '>=', strtotime($start_date) ];
|
||||
} else if ($start_date == '' && $end_date != '') {
|
||||
$condition[] = [ 'apply_time', '<=', strtotime($end_date) ];
|
||||
}
|
||||
|
||||
if ($transfer_start_date != '' && $transfer_end_date != '') {
|
||||
$condition[] = [ 'transfer_time', 'between', [ strtotime($transfer_start_date), strtotime($transfer_end_date) ] ];
|
||||
} else if ($transfer_start_date != '' && $transfer_end_date == '') {
|
||||
$condition[] = [ 'transfer_time', '>=', strtotime($transfer_start_date) ];
|
||||
} else if ($transfer_start_date == '' && $transfer_end_date != '') {
|
||||
$condition[] = [ 'transfer_time', '<=', strtotime($transfer_end_date) ];
|
||||
}
|
||||
|
||||
$order = 'apply_time desc';
|
||||
$join = [
|
||||
[ 'store s', 's.store_id = sw.store_id', 'left' ]
|
||||
];
|
||||
return $withdraw_model->getStoreWithdrawPageList($condition, $page, $page_size, $order, 'sw.*,s.telphone', 'sw', $join);
|
||||
} else {
|
||||
$this->assign('settlement_type_list', $withdraw_model->settlement_type);
|
||||
$transfer_type_list = $withdraw_model->getTransferType($this->site_id);
|
||||
$this->assign('transfer_type_list', $transfer_type_list);
|
||||
$store_model = new \app\model\store\Store();
|
||||
$store_list = $store_model->getStoreList([ [ 'site_id', '=', $this->site_id ] ])[ 'data' ] ?? [];
|
||||
$this->assign('store_list', $store_list);
|
||||
$stat_model = new \addon\store\model\Stat();
|
||||
$stat_condition = array (
|
||||
[ 'site_id', '=', $this->site_id ]
|
||||
);
|
||||
$total_account = $stat_model->getStoreAccountSum($stat_condition, 'account')[ 'data' ] ?? 0;
|
||||
$total_account_apply = $stat_model->getStoreAccountSum($stat_condition, 'account_apply')[ 'data' ] ?? 0;
|
||||
$total_account_withdraw = $stat_model->getStoreAccountSum($stat_condition, 'account_withdraw')[ 'data' ] ?? 0;
|
||||
|
||||
$this->assign('stat', [
|
||||
'total_account' => $total_account,
|
||||
'total_account_apply' => $total_account_apply,
|
||||
'total_account_withdraw' => $total_account_withdraw,
|
||||
]);
|
||||
$this->assign('status_list', $withdraw_model->status);
|
||||
|
||||
$config_model = new WechatPayConfig();
|
||||
$config = $config_model->getPayConfig($this->site_id)[ 'data' ][ 'value' ];;
|
||||
$transfer_v3_type = $config['transfer_type'] == 'v3' && $config['transfer_v3_type'] == $config_model::TRANSFER_V3_TYPE_USER ;
|
||||
$this->assign("transfer_v3_type",$transfer_v3_type);
|
||||
|
||||
return $this->fetch('withdraw/lists');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 提现详情
|
||||
* @return mixed
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$withdraw_id = input('withdraw_id', 0);
|
||||
$withdraw_model = new StoreWithdraw();
|
||||
$withdraw_info = $withdraw_model->detail([ 'site_id' => $this->site_id, 'withdraw_id' => $withdraw_id ])[ 'data' ] ?? [];
|
||||
if (empty($withdraw_info))
|
||||
$this->error('找不到此项提现记录!');
|
||||
|
||||
$this->assign('withdraw_info', $withdraw_info);
|
||||
return $this->fetch('withdraw/detail');
|
||||
}
|
||||
|
||||
/**
|
||||
* 同意
|
||||
* @return array
|
||||
*/
|
||||
public function agree()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$withdraw_id = input('withdraw_id', 0);
|
||||
$withdraw_model = new StoreWithdraw();
|
||||
|
||||
$params = array (
|
||||
'site_id' => $this->site_id,
|
||||
'withdraw_id' => $withdraw_id,
|
||||
'status' => 0
|
||||
);
|
||||
$result = $withdraw_model->agree($params);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 拒绝
|
||||
* @return array
|
||||
*/
|
||||
public function refuse()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$withdraw_id = input('withdraw_id', 0);
|
||||
$refuse_reason = input('refuse_reason', '');
|
||||
$withdraw_model = new StoreWithdraw();
|
||||
$params = array (
|
||||
'site_id' => $this->site_id,
|
||||
'withdraw_id' => $withdraw_id,
|
||||
'refuse_reason' => $refuse_reason
|
||||
);
|
||||
$result = $withdraw_model->refuse($params);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转账
|
||||
*/
|
||||
public function transfer()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$withdraw_id = input('withdraw_id', 0);
|
||||
$withdraw_model = new StoreWithdraw();
|
||||
$result = $withdraw_model->transfer($withdraw_id);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user