chore(src): 所有代码上传

This commit is contained in:
2025-12-02 15:36:42 +08:00
parent ce8e59902c
commit eb79ad260c
669 changed files with 86838 additions and 87639 deletions

View File

@@ -1,91 +1,82 @@
<?php
/**
*/
namespace app\shop\controller;
use app\model\member\Withdraw;
use app\model\order\Order as OrderModel;
use app\model\order\OrderRefund;
use Carbon\Carbon;
class Account extends BaseShop
{
public function dashboard()
{
$is_memberwithdraw = addon_is_exit('memberwithdraw', $this->site_id);
$this->assign('is_memberwithdraw', $is_memberwithdraw);
//获取分销商账户统计
$is_addon_fenxiao = addon_is_exit('fenxiao', $this->site_id);
$this->assign('is_addon_fenxiao', $is_addon_fenxiao);
$this->income();
$this->disburse();
return $this->fetch('account/dashboard');
}
/**
* 收入
*/
public function income()
{
$start_time = input('start_time', Carbon::today()->timestamp);
$end_time = input('end_time', Carbon::tomorrow()->timestamp);
$order_money = ( new OrderModel() )->getOrderMoneySum([ [ 'site_id', '=', $this->site_id ], [ 'pay_time', 'between', [ $start_time, $end_time ] ], [ 'order_scene', '=', 'online' ] ], 'pay_money')[ 'data' ];
$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)) $data = array_merge($data, ...$event);
if (request()->isJson()) return success(0, '', $data);
$this->assign('total_income', array_sum(array_column($data, 'value')));
$this->assign('income_data', $data);
}
/**
* 支出
*/
public function disburse()
{
$start_time = input('start_time', Carbon::today()->timestamp);
$end_time = input('end_time', Carbon::tomorrow()->timestamp);
$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)) $data = array_merge($data, ...$event);
if (request()->isJson()) return success(0, '', $data);
$this->assign('total_disburse', array_sum(array_column($data, 'value')));
$this->assign('disburse_data', $data);
}
}
<?php
namespace app\shop\controller;
use app\model\member\Withdraw;
use app\model\order\Order as OrderModel;
use app\model\order\OrderRefund;
use Carbon\Carbon;
class Account extends BaseShop
{
public function dashboard()
{
$is_memberwithdraw = addon_is_exit('memberwithdraw', $this->site_id);
$this->assign('is_memberwithdraw', $is_memberwithdraw);
//获取分销商账户统计
$is_addon_fenxiao = addon_is_exit('fenxiao', $this->site_id);
$this->assign('is_addon_fenxiao', $is_addon_fenxiao);
$this->income();
$this->disburse();
return $this->fetch('account/dashboard');
}
/**
* 收入
*/
public function income()
{
$start_time = input('start_time', Carbon::today()->timestamp);
$end_time = input('end_time', Carbon::tomorrow()->timestamp);
$order_money = ( new OrderModel() )->getOrderMoneySum([ [ 'site_id', '=', $this->site_id ], [ 'pay_time', 'between', [ $start_time, $end_time ] ], [ 'order_scene', '=', 'online' ] ], 'pay_money')[ 'data' ];
$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)) $data = array_merge($data, ...$event);
if (request()->isJson()) return success(0, '', $data);
$this->assign('total_income', array_sum(array_column($data, 'value')));
$this->assign('income_data', $data);
}
/**
* 支出
*/
public function disburse()
{
$start_time = input('start_time', Carbon::today()->timestamp);
$end_time = input('end_time', Carbon::tomorrow()->timestamp);
$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)) $data = array_merge($data, ...$event);
if (request()->isJson()) return success(0, '', $data);
$this->assign('total_disburse', array_sum(array_column($data, 'value')));
$this->assign('disburse_data', $data);
}
}

View File

@@ -1,116 +1,107 @@
<?php
/**
*/
namespace app\shop\controller;
use app\model\article\ArticleCategory as CategoryModel;
/**
* 文章分类
*/
class Articlecategory extends BaseShop
{
/*
* 文章分类列表
*/
public function lists()
{
$model = new CategoryModel();
$condition[] = ['site_id', '=', $this->site_id];
if (request()->isJson()) {
$page = (int)input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
//排序
$order = input('order', 'sort');
$sort = input('sort', 'desc');
if($order == 'sort'){
$order_by = $order . ' ' . $sort;
}else{
$order_by = $order . ' ' . $sort.',sort desc';
}
return $model->getArticleCategoryPageList($condition, $page, $page_size, $order_by);
} else {
return $this->fetch('articlecategory/lists');
}
}
/**
* 添加分组
*/
public function add()
{
if (request()->isJson()) {
$data = [
'site_id' => $this->site_id,
'category_name' => input('category_name', ''),
'sort' => input('sort'),
];
$category_model = new CategoryModel();
return $category_model->addArticleCategory($data);
}
}
/**
* 编辑分组
*/
public function edit()
{
if (request()->isJson()) {
$data = [
'category_id' => input('category_id'),
'site_id' => $this->site_id,
'category_name' => input('category_name', ''),
'sort' => input('sort'),
];
$category_model = new CategoryModel();
return $category_model->editArticleCategory([['site_id', '=', $this->site_id], ['category_id', '=', $data['category_id']]], $data);
}
}
/**
* 编辑分组排序
* @return array
*/
public function modifySort()
{
if (request()->isJson()) {
$data = [
'category_id' => input('category_id'),
'site_id' => $this->site_id,
'sort' => input('sort'),
];
$category_model = new CategoryModel();
return $category_model->editArticleCategory([['site_id', '=', $this->site_id], ['category_id', '=', $data['category_id']]], $data);
}
}
/*
* 删除分组
*/
public function delete()
{
$category_id = input('category_id', '');
$site_id = $this->site_id;
$category_model = new CategoryModel();
return $category_model->deleteArticleCategory($category_id, $site_id);
}
<?php
namespace app\shop\controller;
use app\model\article\ArticleCategory as CategoryModel;
/**
* 文章分类
*/
class Articlecategory extends BaseShop
{
/*
* 文章分类列表
*/
public function lists()
{
$model = new CategoryModel();
$condition[] = ['site_id', '=', $this->site_id];
if (request()->isJson()) {
$page = (int)input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
//排序
$order = input('order', 'sort');
$sort = input('sort', 'desc');
if($order == 'sort'){
$order_by = $order . ' ' . $sort;
}else{
$order_by = $order . ' ' . $sort.',sort desc';
}
return $model->getArticleCategoryPageList($condition, $page, $page_size, $order_by);
} else {
return $this->fetch('articlecategory/lists');
}
}
/**
* 添加分组
*/
public function add()
{
if (request()->isJson()) {
$data = [
'site_id' => $this->site_id,
'category_name' => input('category_name', ''),
'sort' => input('sort'),
];
$category_model = new CategoryModel();
return $category_model->addArticleCategory($data);
}
}
/**
* 编辑分组
*/
public function edit()
{
if (request()->isJson()) {
$data = [
'category_id' => input('category_id'),
'site_id' => $this->site_id,
'category_name' => input('category_name', ''),
'sort' => input('sort'),
];
$category_model = new CategoryModel();
return $category_model->editArticleCategory([['site_id', '=', $this->site_id], ['category_id', '=', $data['category_id']]], $data);
}
}
/**
* 编辑分组排序
* @return array
*/
public function modifySort()
{
if (request()->isJson()) {
$data = [
'category_id' => input('category_id'),
'site_id' => $this->site_id,
'sort' => input('sort'),
];
$category_model = new CategoryModel();
return $category_model->editArticleCategory([['site_id', '=', $this->site_id], ['category_id', '=', $data['category_id']]], $data);
}
}
/*
* 删除分组
*/
public function delete()
{
$category_id = input('category_id', '');
$site_id = $this->site_id;
$category_model = new CategoryModel();
return $category_model->deleteArticleCategory($category_id, $site_id);
}
}

View File

@@ -1,320 +1,312 @@
<?php
/**
*/
namespace app\shop\controller;
use addon\weapp\model\Config as WeappConfigModel;
use app\Controller;
use app\model\store\Store as StoreModel;
use app\model\system\Addon;
use app\model\system\Group as GroupModel;
use app\model\system\Menu;
use app\model\system\Site;
use app\model\system\User as UserModel;
use app\model\upload\Config as UploadConfigModel;
use app\model\web\Config as ConfigModel;
use app\model\web\DiyView as DiyViewModel;
use think\App;
use think\facade\Config;
class BaseShop extends Controller
{
protected $uid;
protected $user_info;
protected $url;
protected $group_info;
protected $site_id;
protected $store_id;
protected $shop_info;
protected $store_info;
protected $app_module = SHOP_MODULE;
protected $replace = [];
protected $addon = '';
/**
* 模板空布局文件,初始化数据
* @var string|bool
*/
protected $layout = 'app/shop/view/layout/base.html';
// 模版布局文件,加载菜单+内容default默认模板后续支持扩展
protected $template = 'app/shop/view/layout/default.html';
public function __construct(App $app = null)
{
//执行父类构造函数
parent::__construct();
$this->app = $app;
//检测基础登录
$this->site_id = request()->siteid();
$user_model = new UserModel();
$this->app_module = $user_model->loginModule($this->site_id);
$this->uid = $user_model->uid($this->app_module, $this->site_id);
// 验证登录
if (empty($this->uid)) {
$this->redirect(url('shop/login/login'));
}
$this->url = request()->parseUrl();
$this->addon = request()->addon() ? request()->addon() : '';
$this->user_info = $user_model->userInfo($this->app_module, $this->site_id);
$this->assign('user_info', $this->user_info);
$this->assign('app_module', $this->app_module);
// 检测用户组
$this->getGroupInfo();
if ($this->app_module == 'store') {
//检测用户组,通过用户组查询对应门店id
$store_model = new StoreModel();
$this->store_info = $store_model->getStoreInfo([ [ 'store_id', '=', $this->store_id ] ])[ 'data' ];
if ($this->store_info[ 'is_frozen' ]) {
$this->error('该门店已关闭,请联系店铺管理员开启');
}
}
if (!$this->checkAuth()) {
$menu_info = $user_model->getRedirectUrl($this->url, $this->app_module, $this->group_info, $this->addon);
if (request()->isJson()) {
if (empty($menu_info)) {
echo json_encode(error(-1, '权限不足,请联系客服', $menu_info));
exit;
}
} elseif (request()->isAjax() && request()->type() == 'html') {
if (empty($menu_info)) {
$this->error('权限不足,请联系客服');
} else {
// 当前页面没有权限,跳转同级别功能页面
$this->redirect(addon_url($menu_info[ 'url' ]));
}
}
}
//获取店铺信息
$site_model = new Site();
$this->shop_info = $site_model->getSiteInfo([ [ 'site_id', '=', $this->site_id ] ], 'site_id,site_name,logo,seo_keywords,seo_description, create_time')[ 'data' ];
$this->assign('shop_info', $this->shop_info);
// 加载自定义图标库
$diy_view = new DiyViewModel();
$diy_icon_url = $diy_view->getIconUrl()[ 'data' ];
$this->assign('load_diy_icon_url', $diy_icon_url);
// 上传图片配置
$uplode_config_model = new UploadConfigModel();
$upload_config = $uplode_config_model->getUploadConfig($this->site_id);
$this->assign('upload_max_filesize', $upload_config[ 'data' ][ 'value' ][ 'upload' ][ 'max_filesize' ] / 1024);
// 在设置模板布局之前,设置变量输出
$config_view = Config::get('view');
$config_view[ 'tpl_replace_string' ] = array_merge($config_view[ 'tpl_replace_string' ], $this->replace);
Config::set($config_view, 'view');
if (!request()->isAjax()) {
$this->initBaseInfo();
$this->loadTemplate();
}
}
/**
* 加载基础信息
*/
private function initBaseInfo()
{
$this->assign('url', $this->url);
//加载版权信息
$config_model = new ConfigModel();
$copyright = $config_model->getCopyright();
$this->assign('copyright', $copyright[ 'data' ][ 'value' ]);
// 查询小程序配置信息
if (addon_is_exit('weapp', $this->site_id)) {
$weapp_config_model = new WeappConfigModel();
$weapp_config = $weapp_config_model->getWeappConfig($this->site_id)[ 'data' ][ 'value' ];
$this->assign('base_weapp_config', $weapp_config);
}
}
/**
* 获取当前用户的用户组
*/
private function getGroupInfo()
{
$group_model = new GroupModel();
$group_info_result = $group_model->getGroupInfo([ [ 'group_id', '=', $this->user_info[ 'group_id' ] ], [ 'app_module', '=', $this->app_module ] ]);
$this->group_info = $group_info_result[ 'data' ];
if ($this->app_module == 'store') {
//门店登录,用户权限对应站点id是门店id
$this->store_id = $this->group_info[ 'site_id' ];
}
}
/**
* 检测权限
*/
private function checkAuth()
{
if ($this->user_info[ 'is_admin' ] == 1) {
return true;
}
$user_model = new UserModel();
$auth = $user_model->checkAuth($this->url, $this->app_module, $this->group_info, $this->addon);
return $auth[ 'code' ] == 0;
}
/**
* 获取菜单
*/
private function getMenuList()
{
$field = 'id, app_module, addon, title, name, parent, level, url, is_show, sort, picture, picture_select';
$menu_model = new Menu();
//暂定全部权限,系统用户做完后放开
//,['id','<>',2498]
$where = [ [ 'app_module', '=', $this->app_module ] ];
$where1 = [ [ 'name', 'in', $this->group_info[ 'menu_array' ] ], [ 'app_module', '=', $this->app_module ] ];
//只有顶藏家有这个功能 || $this->site_id != 821
if($this->site_id != 1710){
$where[] = ['id','<>',2498];
$where1[] = ['id','<>',2498];
}
if($this->site_id != 2230){
$where[] = ['id','<>',2651];
$where1[] = ['id','<>',2651];
}
if($this->site_id != 2558){
$where[] = ['id','<>',2657];
$where1[] = ['id','<>',2657];
}
if ($this->user_info[ 'is_admin' ] || $this->group_info[ 'is_system' ] == 1) {
$menus = $menu_model->getMenuList($where, $field, 'level asc,sort asc');
} else {
$menus = $menu_model->getMenuList($where1, $field, 'level asc,sort asc');
$control_menu = $menu_model->getMenuList([ [ 'is_control', '=', 0 ], [ 'app_module', '=', $this->app_module ] ], $field, 'sort asc');
$menus[ 'data' ] = array_merge($control_menu[ 'data' ], $menus[ 'data' ]);
$keys = array_column($menus[ 'data' ], 'sort');
if (!empty($keys)) {
array_multisort($keys, SORT_ASC, SORT_NUMERIC, $menus[ 'data' ]);
}
}
return $menus[ 'data' ];
}
/**
* 添加日志
* @param $action_name
* @param array $data
*/
protected function addLog($action_name, $data = [])
{
$user = new UserModel();
$user->addUserLog($this->uid, $this->user_info[ 'username' ], $this->site_id, $action_name, $data);
}
public function __call($method, $args)
{
return $this->fetch(app()->getRootPath() . 'public/error/error.html');
}
/**
* 加载模板页面
*/
public function loadTemplate()
{
if (!request()->isAjax()) {
// 设置模版布局
$this->app->view->engine()->layout($this->layout);
// 请求方式,空:返回菜单+内容iframeiframe标签模式返回内容download返回下载资源
$request_mode = input('request_mode', '');
if (empty($request_mode)) {
echo $this->fetch($this->template);
exit;
}
}
}
/**
* 查询菜单列表
* @return array
*/
public function menu()
{
if (request()->isJson()) {
$url = input('url', $this->url);
$res = [
'url' => $url
];
$menus = $this->getMenuList();
$addon_model = new Addon();
$res[ 'quick_addon_menu' ] = $addon_model->getAddonQuickMenuConfig($this->site_id, $this->app_module)[ 'data' ][ 'value' ];
$user_model = new UserModel();
if ($this->user_info[ 'is_admin' ] == 0 && $this->group_info[ 'is_system' ] == 0) {
$menu_model = new Menu();
// 查询有权限的菜单列表
$menu_list = $menu_model->getMenuList([
[ 'is_show', '=', 1 ],
[ 'name', 'in', $this->group_info[ 'menu_array' ] ],
[ 'app_module', '=', $this->app_module ]
],
'id, app_module, name, title, parent, level, url, is_show, sort, `desc`, picture, is_icon, picture_select, is_control, addon',
'level desc,sort asc')[ 'data' ];
$menu_list = array_column($menu_list, null, 'name');
foreach ($menus as $k => $v) {
// if($v['id'] == 2498){
// unset($menus[$k]);
// }
// 将123级菜单和营销活动菜单的链接改成有权限的路径
if (in_array($v[ 'level' ], [ 1, 2, 3 ]) || in_array($v[ 'parent' ], [ 'PROMOTION_CENTER', 'PROMOTION_TOOL' ])) {
$auth = $user_model->checkAuth($v[ 'url' ], $this->app_module, $this->group_info, $this->addon);
if (( $auth[ 'code' ] ) < 0 && !empty($auth[ 'data' ])) {
$redirect_url = $user_model->getAuthUrl($auth[ 'data' ], $this->app_module, $this->group_info, $menu_list);
if (!empty($redirect_url)) {
$menus[ $k ][ 'url' ] = $redirect_url[ 'url' ];
}
}
}
}
}
$menu_info = $user_model->getRedirectUrl($url, $this->app_module, $this->group_info, $this->addon);
if (!empty($menu_info)) {
$res[ 'url' ] = $menu_info[ 'url' ];
}
$res[ 'yuan_menu' ] = $menus;
return $res;
}
}
<?php
namespace app\shop\controller;
use addon\weapp\model\Config as WeappConfigModel;
use app\Controller;
use app\model\store\Store as StoreModel;
use app\model\system\Addon;
use app\model\system\Group as GroupModel;
use app\model\system\Menu;
use app\model\system\Site;
use app\model\system\User as UserModel;
use app\model\upload\Config as UploadConfigModel;
use app\model\web\Config as ConfigModel;
use app\model\web\DiyView as DiyViewModel;
use think\App;
use think\facade\Config;
class BaseShop extends Controller
{
protected $uid;
protected $user_info;
protected $url;
protected $group_info;
protected $site_id;
protected $store_id;
protected $shop_info;
protected $store_info;
protected $app_module = SHOP_MODULE;
protected $replace = [];
protected $addon = '';
/**
* 模板空布局文件,初始化数据
* @var string|bool
*/
protected $layout = 'app/shop/view/layout/base.html';
// 模版布局文件,加载菜单+内容default默认模板后续支持扩展
protected $template = 'app/shop/view/layout/default.html';
public function __construct(App $app = null)
{
//执行父类构造函数
parent::__construct();
$this->app = $app;
//检测基础登录
$this->site_id = request()->siteid();
$user_model = new UserModel();
$this->app_module = $user_model->loginModule($this->site_id);
$this->uid = $user_model->uid($this->app_module, $this->site_id);
// 验证登录
if (empty($this->uid)) {
$this->redirect(url('shop/login/login'));
}
$this->url = request()->parseUrl();
$this->addon = request()->addon() ? request()->addon() : '';
$this->user_info = $user_model->userInfo($this->app_module, $this->site_id);
$this->assign('user_info', $this->user_info);
$this->assign('app_module', $this->app_module);
// 检测用户组
$this->getGroupInfo();
if ($this->app_module == 'store') {
//检测用户组,通过用户组查询对应门店id
$store_model = new StoreModel();
$this->store_info = $store_model->getStoreInfo([ [ 'store_id', '=', $this->store_id ] ])[ 'data' ];
if ($this->store_info[ 'is_frozen' ]) {
$this->error('该门店已关闭,请联系店铺管理员开启');
}
}
if (!$this->checkAuth()) {
$menu_info = $user_model->getRedirectUrl($this->url, $this->app_module, $this->group_info, $this->addon);
if (request()->isJson()) {
if (empty($menu_info)) {
echo json_encode(error(-1, '权限不足,请联系客服', $menu_info));
exit;
}
} elseif (request()->isAjax() && request()->type() == 'html') {
if (empty($menu_info)) {
$this->error('权限不足,请联系客服');
} else {
// 当前页面没有权限,跳转同级别功能页面
$this->redirect(addon_url($menu_info[ 'url' ]));
}
}
}
//获取店铺信息
$site_model = new Site();
$this->shop_info = $site_model->getSiteInfo([ [ 'site_id', '=', $this->site_id ] ], 'site_id,site_name,logo,seo_keywords,seo_description, create_time')[ 'data' ];
$this->assign('shop_info', $this->shop_info);
// 加载自定义图标库
$diy_view = new DiyViewModel();
$diy_icon_url = $diy_view->getIconUrl()[ 'data' ];
$this->assign('load_diy_icon_url', $diy_icon_url);
// 上传图片配置
$uplode_config_model = new UploadConfigModel();
$upload_config = $uplode_config_model->getUploadConfig($this->site_id);
$this->assign('upload_max_filesize', $upload_config[ 'data' ][ 'value' ][ 'upload' ][ 'max_filesize' ] / 1024);
// 在设置模板布局之前,设置变量输出
$config_view = Config::get('view');
$config_view[ 'tpl_replace_string' ] = array_merge($config_view[ 'tpl_replace_string' ], $this->replace);
Config::set($config_view, 'view');
if (!request()->isAjax()) {
$this->initBaseInfo();
$this->loadTemplate();
}
}
/**
* 加载基础信息
*/
private function initBaseInfo()
{
$this->assign('url', $this->url);
//加载版权信息
$config_model = new ConfigModel();
$copyright = $config_model->getCopyright();
$this->assign('copyright', $copyright[ 'data' ][ 'value' ]);
// 查询小程序配置信息
if (addon_is_exit('weapp', $this->site_id)) {
$weapp_config_model = new WeappConfigModel();
$weapp_config = $weapp_config_model->getWeappConfig($this->site_id)[ 'data' ][ 'value' ];
$this->assign('base_weapp_config', $weapp_config);
}
}
/**
* 获取当前用户的用户组
*/
private function getGroupInfo()
{
$group_model = new GroupModel();
$group_info_result = $group_model->getGroupInfo([ [ 'group_id', '=', $this->user_info[ 'group_id' ] ], [ 'app_module', '=', $this->app_module ] ]);
$this->group_info = $group_info_result[ 'data' ];
if ($this->app_module == 'store') {
//门店登录,用户权限对应站点id是门店id
$this->store_id = $this->group_info[ 'site_id' ];
}
}
/**
* 检测权限
*/
private function checkAuth()
{
if ($this->user_info[ 'is_admin' ] == 1) {
return true;
}
$user_model = new UserModel();
$auth = $user_model->checkAuth($this->url, $this->app_module, $this->group_info, $this->addon);
return $auth[ 'code' ] == 0;
}
/**
* 获取菜单
*/
private function getMenuList()
{
$field = 'id, app_module, addon, title, name, parent, level, url, is_show, sort, picture, picture_select';
$menu_model = new Menu();
//暂定全部权限,系统用户做完后放开
//,['id','<>',2498]
$where = [ [ 'app_module', '=', $this->app_module ] ];
$where1 = [ [ 'name', 'in', $this->group_info[ 'menu_array' ] ], [ 'app_module', '=', $this->app_module ] ];
//只有顶藏家有这个功能 || $this->site_id != 821
if($this->site_id != 1710){
$where[] = ['id','<>',2498];
$where1[] = ['id','<>',2498];
}
if($this->site_id != 2230){
$where[] = ['id','<>',2651];
$where1[] = ['id','<>',2651];
}
if($this->site_id != 2558){
$where[] = ['id','<>',2657];
$where1[] = ['id','<>',2657];
}
if ($this->user_info[ 'is_admin' ] || $this->group_info[ 'is_system' ] == 1) {
$menus = $menu_model->getMenuList($where, $field, 'level asc,sort asc');
} else {
$menus = $menu_model->getMenuList($where1, $field, 'level asc,sort asc');
$control_menu = $menu_model->getMenuList([ [ 'is_control', '=', 0 ], [ 'app_module', '=', $this->app_module ] ], $field, 'sort asc');
$menus[ 'data' ] = array_merge($control_menu[ 'data' ], $menus[ 'data' ]);
$keys = array_column($menus[ 'data' ], 'sort');
if (!empty($keys)) {
array_multisort($keys, SORT_ASC, SORT_NUMERIC, $menus[ 'data' ]);
}
}
return $menus[ 'data' ];
}
/**
* 添加日志
* @param $action_name
* @param array $data
*/
protected function addLog($action_name, $data = [])
{
$user = new UserModel();
$user->addUserLog($this->uid, $this->user_info[ 'username' ], $this->site_id, $action_name, $data);
}
public function __call($method, $args)
{
return $this->fetch(app()->getRootPath() . 'public/error/error.html');
}
/**
* 加载模板页面
*/
public function loadTemplate()
{
if (!request()->isAjax()) {
// 设置模版布局
$this->app->view->engine()->layout($this->layout);
// 请求方式,空:返回菜单+内容iframeiframe标签模式返回内容download返回下载资源
$request_mode = input('request_mode', '');
if (empty($request_mode)) {
echo $this->fetch($this->template);
exit;
}
}
}
/**
* 查询菜单列表
* @return array
*/
public function menu()
{
if (request()->isJson()) {
$url = input('url', $this->url);
$res = [
'url' => $url
];
$menus = $this->getMenuList();
$addon_model = new Addon();
$res[ 'quick_addon_menu' ] = $addon_model->getAddonQuickMenuConfig($this->site_id, $this->app_module)[ 'data' ][ 'value' ];
$user_model = new UserModel();
if ($this->user_info[ 'is_admin' ] == 0 && $this->group_info[ 'is_system' ] == 0) {
$menu_model = new Menu();
// 查询有权限的菜单列表
$menu_list = $menu_model->getMenuList([
[ 'is_show', '=', 1 ],
[ 'name', 'in', $this->group_info[ 'menu_array' ] ],
[ 'app_module', '=', $this->app_module ]
],
'id, app_module, name, title, parent, level, url, is_show, sort, `desc`, picture, is_icon, picture_select, is_control, addon',
'level desc,sort asc')[ 'data' ];
$menu_list = array_column($menu_list, null, 'name');
foreach ($menus as $k => $v) {
// if($v['id'] == 2498){
// unset($menus[$k]);
// }
// 将123级菜单和营销活动菜单的链接改成有权限的路径
if (in_array($v[ 'level' ], [ 1, 2, 3 ]) || in_array($v[ 'parent' ], [ 'PROMOTION_CENTER', 'PROMOTION_TOOL' ])) {
$auth = $user_model->checkAuth($v[ 'url' ], $this->app_module, $this->group_info, $this->addon);
if (( $auth[ 'code' ] ) < 0 && !empty($auth[ 'data' ])) {
$redirect_url = $user_model->getAuthUrl($auth[ 'data' ], $this->app_module, $this->group_info, $menu_list);
if (!empty($redirect_url)) {
$menus[ $k ][ 'url' ] = $redirect_url[ 'url' ];
}
}
}
}
}
$menu_info = $user_model->getRedirectUrl($url, $this->app_module, $this->group_info, $this->addon);
if (!empty($menu_info)) {
$res[ 'url' ] = $menu_info[ 'url' ];
}
$res[ 'yuan_menu' ] = $menus;
return $res;
}
}
}

View File

@@ -1,38 +1,30 @@
<?php
/**
*/
namespace app\shop\controller;
use app\model\order\OrderCommon as OrderCommonModel;
/**
* 自提订单
* Class storeorder
* @package app\shop\controller
*/
class Cashorder extends BaseShop
{
/**
* 订单详情
* @return mixed
*/
public function detail()
{
$order_id = input('order_id', 0);
$order_common_model = new OrderCommonModel();
$order_detail_result = $order_common_model->getOrderDetail($order_id);
$order_detail = $order_detail_result['data'];
$this->assign('order_detail', $order_detail);
$this->assign('http_type', get_http_type());
return $this->fetch('cashorder/detail');
}
<?php
namespace app\shop\controller;
use app\model\order\OrderCommon as OrderCommonModel;
/**
* 自提订单
* Class storeorder
* @package app\shop\controller
*/
class Cashorder extends BaseShop
{
/**
* 订单详情
* @return mixed
*/
public function detail()
{
$order_id = input('order_id', 0);
$order_common_model = new OrderCommonModel();
$order_detail_result = $order_common_model->getOrderDetail($order_id);
$order_detail = $order_detail_result['data'];
$this->assign('order_detail', $order_detail);
$this->assign('http_type', get_http_type());
return $this->fetch('cashorder/detail');
}
}

View File

@@ -26,6 +26,7 @@ class Config extends BaseShop
$logo = input('logo', '');
$data = [
'icp' => input('icp', ''),
'business_show_link' => input('business_show_link', ''),
'gov_record' => input('gov_record', ''),
'gov_url' => input('gov_url', ''),
'market_supervision_url' => input('market_supervision_url', ''),
@@ -44,7 +45,7 @@ class Config extends BaseShop
$res = $config_model->setCopyright($data, $this->site_id, $this->app_module);
return $res;
}
$this->assign('is_auth', ( $auth_info[ 'code' ] >= 0 ? 1 : 0 ));
$this->assign('is_auth', ($auth_info[ 'code' ] >= 0 ? 1 : 0));
$this->assign('copyright_config', $copyright[ 'data' ][ 'value' ]);
return $this->fetch('config/copyright');
}
@@ -171,13 +172,16 @@ class Config extends BaseShop
if (request()->isJson()) {
$tencent_map_key = input('tencent_map_key', '');
$wap_is_open = input('wap_is_open', 0);
$wap_valid_time = input('wap_valid_time', 0);
$info = $config_model->checkQqMapKey($tencent_map_key, 1);
if ($info[ 'status' ] != 0) {
return $info;
}
$result = $config_model->setMapConfig([
'tencent_map_key' => $tencent_map_key,
'wap_is_open' => $wap_is_open
'wap_is_open' => $wap_is_open,
'wap_valid_time' => $wap_valid_time
]);
return $result;
} else {

View File

@@ -1,364 +1,356 @@
<?php
/**
*/
namespace app\shop\controller;
use app\model\express\Config as ConfigModel;
use app\model\express\ExpressPackage;
use app\model\order\OrderCommon as OrderCommonModel;
use app\model\order\Order as OrderModel;
use addon\electronicsheet\model\ExpressElectronicsheet as ExpressElectronicsheetModel;
use app\model\web\Config as WebConfig;
use addon\electronicsheet\model\ElectronicsheetDelivery;
/**
* 配送
* Class Express
* @package app\shop\controller
*/
class Delivery extends BaseShop
{
/**
* 发货列表
*/
public function lists()
{
$order_label_list = array (
'order_no' => '订单号',
'out_trade_no' => '外部单号',
'name' => '收货人姓名',
'order_name' => '商品名称',
'mobile' => '收货人电话',
);
$order_model = new OrderModel();
$order_status_list = $order_model->delivery_order_status;
$order_status = input('order_status', '');//订单状态
$order_name = input('order_name', '');
$pay_type = input('pay_type', '');
$order_from = input('order_from', '');
$start_time = input('start_time', '');
$end_time = input('end_time', '');
$order_label = !empty($order_label_list[ input('order_label') ]) ? input('order_label') : '';
$search_text = input('search', '');
$promotion_type = input('promotion_type', '');//订单类型
$order_type = input('order_type', 'all');//营销类型
$order_common_model = new OrderCommonModel();
if (request()->isJson()) {
$page_index = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$condition = [
[ 'order_type', '=', 1 ],
[ 'site_id', '=', $this->site_id ],
[ 'is_delete', '=', 0 ]
];
//订单状态
if ($order_status != '') {
$condition[] = ['order_status', '=', $order_status ];
} else {
$condition[] = [ 'order_status', 'in', array_keys($order_status_list) ];
}
//订单内容 模糊查询
if ($order_name != '') {
$condition[] = ['order_name', 'like', "%$order_name%" ];
}
//订单来源
if ($order_from != '') {
$condition[] = ['order_from', '=', $order_from ];
}
//订单支付
if ($pay_type != '') {
$condition[] = ['pay_type', '=', $pay_type ];
}
//订单类型
if ($order_type != 'all') {
$condition[] = ['order_type', '=', $order_type ];
}
//营销类型
if ($promotion_type != '') {
if ($promotion_type == 'empty') {
$condition[] = ['promotion_type', '=', '' ];
} else {
$condition[] = ['promotion_type', '=', $promotion_type ];
}
}
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) ] ];
}
if ($search_text != '') {
$condition[] = [ $order_label, 'like', "%$search_text%" ];
}
$list = $order_common_model->getOrderPageList($condition, $page_index, $page_size, 'create_time desc');
return $list;
} else {
$this->assign('order_label_list', $order_label_list);
//订单来源 (支持端口)
$order_from = $order_common_model->getOrderFromList();
$this->assign('order_from_list', $order_from);
$pay_type = $order_common_model->getPayType();
$this->assign('pay_type_list', $pay_type);
$this->assign('http_type', get_http_type());
$config_model = new WebConfig();
$mp_config = $config_model->getMapConfig($this->site_id);
$this->assign('tencent_map_key', $mp_config[ 'data' ][ 'value' ][ 'tencent_map_key' ] ?? '');
$this->assign('delivery_order_status', $order_status_list);//订单状态
return $this->fetch('delivery/lists');
}
}
/**
* 配送方式
*/
public function express()
{
$config_model = new ConfigModel();
$config_result = $config_model->getExpressConfig($this->site_id);
$express_config = $config_result[ 'data' ];
$this->assign('express_config', $express_config);
$config_result = $config_model->getStoreConfig($this->site_id);
$store_config = $config_result[ 'data' ];
$this->assign('store_config', $store_config);
$config_result = $config_model->getLocalDeliveryConfig($this->site_id);
$local_delivery_config = $config_result[ 'data' ];
$this->assign('local_delivery_config', $local_delivery_config);
$deliver_type = $config_model->getDeliverTypeSort($this->site_id);
$this->assign('deliver_type', explode(',', $deliver_type[ 'data' ][ 'value' ][ 'deliver_type' ]));
return $this->fetch('delivery/delivery');
}
/**
* 物流开关配置
* @return \multitype
*/
public function modifyExpressStatus()
{
$config_model = new ConfigModel();
if (request()->isJson()) {
$is_use = input('is_use', 0);
$data = array (
'express_name' => input('express_name')
);
$result = $config_model->setExpressConfig($data, $is_use, $this->site_id);
return $result;
}
}
/**
* 自提配置开关
* @return \multitype
*/
public function modifyStoreStatus()
{
$config_model = new ConfigModel();
if (request()->isJson()) {
$is_use = input('is_use', 0);
$data = array (
'store_name' => input('store_name')
);
$result = $config_model->setStoreConfig($data, $is_use, $this->site_id);
return $result;
}
}
/**
* 外卖配送配置开关
* @return \multitype
*/
public function modifyLocalStatus()
{
$config_model = new ConfigModel();
if (request()->isJson()) {
$is_use = input('is_use', 0);
$data = array (
'local_name' => input('local_name')
);
$result = $config_model->setLocalDeliveryConfig($data, $is_use, $this->site_id);
return $result;
}
}
/**
* 外卖配送
*/
public function localConfig()
{
$config_model = new ConfigModel();
if (request()->isJson()) {
$is_use = input('is_use', 0);
$data = array ();
$result = $config_model->setLocalDeliveryConfig($data, $is_use, $this->site_id);
return $result;
} else {
$config_result = $config_model->getLocalDeliveryConfig($this->site_id);
$config = $config_result[ 'data' ];
$this->assign('config', $config);
return $this->fetch('delivery/local_config');
}
}
/**
* 获取电子面单模板列表
*/
public function getExpressElectronicsheetList()
{
//电子面单插件
$addon_is_exit = addon_is_exit('electronicsheet', $this->site_id);
if ($addon_is_exit == 1) {
//获取电子面单模板
$electronicsheet_model = new ExpressElectronicsheetModel();
$condition[] = [ 'site_id', '=', $this->site_id ];
$electronicsheet_list = $electronicsheet_model->getExpressElectronicsheetList($condition, '', 'is_default desc');
return $electronicsheet_list;
} else {
return success(0, 'success', []);
}
}
/**
* 批量发货
*/
public function batchDelivery()
{
if (request()->isJson()) {
$order_model = new OrderModel();
$data = array (
'type' => input('type', 'manual'),//发货方式(手动发货、电子面单)
'express_company_id' => input('express_company_id', 0),//物流公司
'delivery_type' => input('delivery_type', 0),//是否需要物流
'site_id' => $this->site_id,
'template_id' => input('template_id', 0),//电子面单模板id
);
$order_list = input('order_list', '');
$result = $order_model->orderBatchDelivery($data, $order_list);
return $result;
}
}
/**
* 打印电子面单
*/
public function printElectronicsheet()
{
if (request()->isJson()) {
$addon_is_exit = addon_is_exit('electronicsheet', $this->site_id);
if ($addon_is_exit != 1) {
return [
'code' => -1001,
'message' => '电子面单插件不存在',
'data' => ''
];
}
$order_model = new OrderModel();
$data = array (
'type' => 'electronicsheet',//电子面单
'express_company_id' => 0,//物流公司
'delivery_type' => 1,
'site_id' => $this->site_id,
'template_id' => input('template_id', 0),//电子面单模板id
'is_delivery' => input('is_delivery', 0),//是否发货
'order_id' => input('order_id', 0),//订单id
'order_goods_ids' => '',
'delivery_no' => ''
);
$electronicsheet_model = new ElectronicsheetDelivery();
$result = $electronicsheet_model->delivery($data);
if ($result[ 'code' ] >= 0) {
// 发货
if ($data[ 'is_delivery' ] == 1) {
$data[ 'delivery_no' ] = $result[ 'data' ][ 'Order' ][ 'LogisticCode' ];
$res = $order_model->orderGoodsDelivery($data, 2);
if ($res[ 'code' ] < 0) {
return $res;
}
}
}
return $result;
}
}
/**
* 获取单个订单的物流信息(电子面单的除外)
*/
public function getOrderDelivery()
{
if (request()->isJson()) {
$order_id = input('order_id', '');
$condition = [
[ 'order_id', '=', $order_id ],
[ 'site_id', '=', $this->site_id ],
[ 'type', '=', 'manual' ]
];
$express_package_model = new ExpressPackage();
$list = $express_package_model->getExpressDeliveryPackageList($condition);
return $list;
}
}
/**
* 修改单个订单的物流信息(电子面单的除外)
*/
public function editOrderDelivery()
{
if (request()->isJson()) {
$delivery_json = array (
'site_id' => $this->site_id,
'order_id' => input('order_id', ''),//订单id
'package_id' => input('package_id', 0),//包裹id
'delivery_type' => input('delivery_type', 0),//是否需要物流
'express_company_id' => input('express_company_id', 0),//物流公司
'delivery_no' => input('delivery_no', ''),//物流单号
);
$express_package_model = new ExpressPackage();
$res = $express_package_model->editOrderExpressDeliveryPackage($delivery_json);
return $res;
}
}
/**
* 配送方式排序
*/
public function deliverTypeSort()
{
if (request()->isJson()) {
$config_model = new ConfigModel();
$deliver_type = input('deliver_type', '');
$result = $config_model->setDeliverTypeSort([ 'deliver_type' => $deliver_type ], $this->site_id);
return $result;
}
}
<?php
namespace app\shop\controller;
use app\model\express\Config as ConfigModel;
use app\model\express\ExpressPackage;
use app\model\order\OrderCommon as OrderCommonModel;
use app\model\order\Order as OrderModel;
use addon\electronicsheet\model\ExpressElectronicsheet as ExpressElectronicsheetModel;
use app\model\web\Config as WebConfig;
use addon\electronicsheet\model\ElectronicsheetDelivery;
/**
* 配送
* Class Express
* @package app\shop\controller
*/
class Delivery extends BaseShop
{
/**
* 发货列表
*/
public function lists()
{
$order_label_list = array (
'order_no' => '订单号',
'out_trade_no' => '外部单号',
'name' => '收货人姓名',
'order_name' => '商品名称',
'mobile' => '收货人电话',
);
$order_model = new OrderModel();
$order_status_list = $order_model->delivery_order_status;
$order_status = input('order_status', '');//订单状态
$order_name = input('order_name', '');
$pay_type = input('pay_type', '');
$order_from = input('order_from', '');
$start_time = input('start_time', '');
$end_time = input('end_time', '');
$order_label = !empty($order_label_list[ input('order_label') ]) ? input('order_label') : '';
$search_text = input('search', '');
$promotion_type = input('promotion_type', '');//订单类型
$order_type = input('order_type', 'all');//营销类型
$order_common_model = new OrderCommonModel();
if (request()->isJson()) {
$page_index = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$condition = [
[ 'order_type', '=', 1 ],
[ 'site_id', '=', $this->site_id ],
[ 'is_delete', '=', 0 ]
];
//订单状态
if ($order_status != '') {
$condition[] = ['order_status', '=', $order_status ];
} else {
$condition[] = [ 'order_status', 'in', array_keys($order_status_list) ];
}
//订单内容 模糊查询
if ($order_name != '') {
$condition[] = ['order_name', 'like', "%$order_name%" ];
}
//订单来源
if ($order_from != '') {
$condition[] = ['order_from', '=', $order_from ];
}
//订单支付
if ($pay_type != '') {
$condition[] = ['pay_type', '=', $pay_type ];
}
//订单类型
if ($order_type != 'all') {
$condition[] = ['order_type', '=', $order_type ];
}
//营销类型
if ($promotion_type != '') {
if ($promotion_type == 'empty') {
$condition[] = ['promotion_type', '=', '' ];
} else {
$condition[] = ['promotion_type', '=', $promotion_type ];
}
}
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) ] ];
}
if ($search_text != '') {
$condition[] = [ $order_label, 'like', "%$search_text%" ];
}
$list = $order_common_model->getOrderPageList($condition, $page_index, $page_size, 'create_time desc');
return $list;
} else {
$this->assign('order_label_list', $order_label_list);
//订单来源 (支持端口)
$order_from = $order_common_model->getOrderFromList();
$this->assign('order_from_list', $order_from);
$pay_type = $order_common_model->getPayType();
$this->assign('pay_type_list', $pay_type);
$this->assign('http_type', get_http_type());
$config_model = new WebConfig();
$mp_config = $config_model->getMapConfig($this->site_id);
$this->assign('tencent_map_key', $mp_config[ 'data' ][ 'value' ][ 'tencent_map_key' ] ?? '');
$this->assign('delivery_order_status', $order_status_list);//订单状态
return $this->fetch('delivery/lists');
}
}
/**
* 配送方式
*/
public function express()
{
$config_model = new ConfigModel();
$config_result = $config_model->getExpressConfig($this->site_id);
$express_config = $config_result[ 'data' ];
$this->assign('express_config', $express_config);
$config_result = $config_model->getStoreConfig($this->site_id);
$store_config = $config_result[ 'data' ];
$this->assign('store_config', $store_config);
$config_result = $config_model->getLocalDeliveryConfig($this->site_id);
$local_delivery_config = $config_result[ 'data' ];
$this->assign('local_delivery_config', $local_delivery_config);
$deliver_type = $config_model->getDeliverTypeSort($this->site_id);
$this->assign('deliver_type', explode(',', $deliver_type[ 'data' ][ 'value' ][ 'deliver_type' ]));
return $this->fetch('delivery/delivery');
}
/**
* 物流开关配置
* @return \multitype
*/
public function modifyExpressStatus()
{
$config_model = new ConfigModel();
if (request()->isJson()) {
$is_use = input('is_use', 0);
$data = array (
'express_name' => input('express_name')
);
$result = $config_model->setExpressConfig($data, $is_use, $this->site_id);
return $result;
}
}
/**
* 自提配置开关
* @return \multitype
*/
public function modifyStoreStatus()
{
$config_model = new ConfigModel();
if (request()->isJson()) {
$is_use = input('is_use', 0);
$data = array (
'store_name' => input('store_name')
);
$result = $config_model->setStoreConfig($data, $is_use, $this->site_id);
return $result;
}
}
/**
* 外卖配送配置开关
* @return \multitype
*/
public function modifyLocalStatus()
{
$config_model = new ConfigModel();
if (request()->isJson()) {
$is_use = input('is_use', 0);
$data = array (
'local_name' => input('local_name')
);
$result = $config_model->setLocalDeliveryConfig($data, $is_use, $this->site_id);
return $result;
}
}
/**
* 外卖配送
*/
public function localConfig()
{
$config_model = new ConfigModel();
if (request()->isJson()) {
$is_use = input('is_use', 0);
$data = array ();
$result = $config_model->setLocalDeliveryConfig($data, $is_use, $this->site_id);
return $result;
} else {
$config_result = $config_model->getLocalDeliveryConfig($this->site_id);
$config = $config_result[ 'data' ];
$this->assign('config', $config);
return $this->fetch('delivery/local_config');
}
}
/**
* 获取电子面单模板列表
*/
public function getExpressElectronicsheetList()
{
//电子面单插件
$addon_is_exit = addon_is_exit('electronicsheet', $this->site_id);
if ($addon_is_exit == 1) {
//获取电子面单模板
$electronicsheet_model = new ExpressElectronicsheetModel();
$condition[] = [ 'site_id', '=', $this->site_id ];
$electronicsheet_list = $electronicsheet_model->getExpressElectronicsheetList($condition, '', 'is_default desc');
return $electronicsheet_list;
} else {
return success(0, 'success', []);
}
}
/**
* 批量发货
*/
public function batchDelivery()
{
if (request()->isJson()) {
$order_model = new OrderModel();
$data = array (
'type' => input('type', 'manual'),//发货方式(手动发货、电子面单)
'express_company_id' => input('express_company_id', 0),//物流公司
'delivery_type' => input('delivery_type', 0),//是否需要物流
'site_id' => $this->site_id,
'template_id' => input('template_id', 0),//电子面单模板id
);
$order_list = input('order_list', '');
$result = $order_model->orderBatchDelivery($data, $order_list);
return $result;
}
}
/**
* 打印电子面单
*/
public function printElectronicsheet()
{
if (request()->isJson()) {
$addon_is_exit = addon_is_exit('electronicsheet', $this->site_id);
if ($addon_is_exit != 1) {
return [
'code' => -1001,
'message' => '电子面单插件不存在',
'data' => ''
];
}
$order_model = new OrderModel();
$data = array (
'type' => 'electronicsheet',//电子面单
'express_company_id' => 0,//物流公司
'delivery_type' => 1,
'site_id' => $this->site_id,
'template_id' => input('template_id', 0),//电子面单模板id
'is_delivery' => input('is_delivery', 0),//是否发货
'order_id' => input('order_id', 0),//订单id
'order_goods_ids' => '',
'delivery_no' => ''
);
$electronicsheet_model = new ElectronicsheetDelivery();
$result = $electronicsheet_model->delivery($data);
if ($result[ 'code' ] >= 0) {
// 发货
if ($data[ 'is_delivery' ] == 1) {
$data[ 'delivery_no' ] = $result[ 'data' ][ 'Order' ][ 'LogisticCode' ];
$res = $order_model->orderGoodsDelivery($data, 2);
if ($res[ 'code' ] < 0) {
return $res;
}
}
}
return $result;
}
}
/**
* 获取单个订单的物流信息(电子面单的除外)
*/
public function getOrderDelivery()
{
if (request()->isJson()) {
$order_id = input('order_id', '');
$condition = [
[ 'order_id', '=', $order_id ],
[ 'site_id', '=', $this->site_id ],
[ 'type', '=', 'manual' ]
];
$express_package_model = new ExpressPackage();
$list = $express_package_model->getExpressDeliveryPackageList($condition);
return $list;
}
}
/**
* 修改单个订单的物流信息(电子面单的除外)
*/
public function editOrderDelivery()
{
if (request()->isJson()) {
$delivery_json = array (
'site_id' => $this->site_id,
'order_id' => input('order_id', ''),//订单id
'package_id' => input('package_id', 0),//包裹id
'delivery_type' => input('delivery_type', 0),//是否需要物流
'express_company_id' => input('express_company_id', 0),//物流公司
'delivery_no' => input('delivery_no', ''),//物流单号
);
$express_package_model = new ExpressPackage();
$res = $express_package_model->editOrderExpressDeliveryPackage($delivery_json);
return $res;
}
}
/**
* 配送方式排序
*/
public function deliverTypeSort()
{
if (request()->isJson()) {
$config_model = new ConfigModel();
$deliver_type = input('deliver_type', '');
$result = $config_model->setDeliverTypeSort([ 'deliver_type' => $deliver_type ], $this->site_id);
return $result;
}
}
}

View File

@@ -1,26 +1,18 @@
<?php
/**
*/
namespace app\shop\controller;
use app\Controller;
/**
* 空控制器
* Class Error
* @package app\shop\controller
*/
class Error extends Controller
{
public function __call($method, $args)
{
return $this->fetch('error/error');
}
}
<?php
namespace app\shop\controller;
use app\Controller;
/**
* 空控制器
* Class Error
* @package app\shop\controller
*/
class Error extends Controller
{
public function __call($method, $args)
{
return $this->fetch('error/error');
}
}

View File

@@ -1,430 +1,422 @@
<?php
/**
*/
namespace app\shop\controller;
use app\model\express\ExpressCompany;
use app\model\express\ExpressCompanyTemplate;
use app\model\express\ExpressTemplate;
use app\model\system\Address as AddressModel;
use app\model\express\Kd100;
use app\model\express\Kdbird;
/**
* 配送
* Class Express
* @package app\shop\controller
*/
class Express extends BaseShop
{
/**
* 物流公司
* @return mixed
*/
public function expressCompany()
{
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 ];
$condition[] = [ 'company_name', 'like', '%' . $search_text . '%' ];
$order = 'is_electronicsheet desc,sort asc';
$field = 'company_id,company_name,logo,sort,url,is_electronicsheet';
$express_company_model = new ExpressCompanyTemplate();
return $express_company_model->getExpressCompanyTemplatePageList($condition, $page, $page_size, $order, $field);
} else {
return $this->fetch('express/express_company');
}
}
/**
* 添加物流公司
*/
public function addCompany()
{
$template_model = new ExpressCompanyTemplate();
if (request()->isJson()) {
$data = [
'site_id' => $this->site_id,
'company_name' => input('company_name', ''),//物流公司名称
'sort' => input('sort', 0),//排序
'logo' => input('logo', ''),//logo
'url' => input('url', ''),//网址
'express_no' => input('express_no', ''),//编码
'express_no_kd100' => input('express_no_kd100', ''),//编码快递100
'express_no_cainiao' => input('express_no_cainiao', ''),//编码(菜鸟)
'content_json' => input('content_json', '[]'),//打印内容
'background_image' => input('background_image', ''),//打印背景图
'font_size' => input('font_size', 14),//打印字体大小 单位px
'width' => input('width', 0),//显示尺寸宽度 px
'height' => input('height', 0),//显示尺寸高度 px
'scale' => input('scale', 1),//真实尺寸mm与显示尺寸px的比例
'create_time' => time(),
'is_electronicsheet' => input('is_electronicsheet', 0),//是否支持电子面单
'print_style' => input('print_style', 0),//电子面单打印风格
];
$res = $template_model->addExpressCompanyTemplate($data);
if ($res[ 'code' ] >= 0) {
$express_company_model = new ExpressCompany();
$express_company_model->addExpressCompany([ 'site_id' => $this->site_id, 'company_id' => $res[ 'data' ] ]);
$this->addLog('添加物流公司:' . $data[ 'company_name' ], $data);
}
return $res;
} else {
//打印项
$print_item_list = $template_model->getPrintItemList();
$this->assign('print_item_list', $print_item_list);
return $this->fetch('express/add_company');
}
}
/**
* 物流公司编辑
*/
public function editCompany()
{
$template_model = new ExpressCompanyTemplate();
if (request()->isJson()) {
$data = [
'site_id' => $this->site_id,
'company_name' => input('company_name', ''),//物流公司名称
'sort' => input('sort', 0),//排序
'logo' => input('logo', ''),//logo
'url' => input('url', ''),//网址
'express_no' => input('express_no', ''),//编码
'express_no_kd100' => input('express_no_kd100', ''),//编码快递100
'express_no_cainiao' => input('express_no_cainiao', ''),//编码(菜鸟)
'content_json' => input('content_json', '[]'),//打印内容
'background_image' => input('background_image', ''),//打印背景图
'font_size' => input('font_size', 14),//打印字体大小 单位mm
'width' => input('width', 0),//显示尺寸宽度 px
'height' => input('height', 0),//显示尺寸高度 px
'scale' => input('scale', 1),//真实尺寸mm与显示尺寸px的比例
'modify_time' => time(),
'company_id' => input('company_id', 0),
'is_electronicsheet' => input('is_electronicsheet', 0),//是否支持电子面单
'print_style' => input('print_style', 0),//电子面单打印风格
];
$res = $template_model->editExpressCompanyTemplate($data);
if ($res[ 'code' ] == 0) {
$express_company_model = new ExpressCompany();
$express_company_model->editExpressCompany([
'content_json' => $data[ 'content_json' ],
'background_image' => $data[ 'background_image' ],
'font_size' => $data[ 'font_size' ],
'width' => $data[ 'width' ],
'height' => $data[ 'height' ]
], [ ['site_id', '=', $this->site_id ], ['company_id', '=', $data[ 'company_id' ] ] ]);
}
$this->addLog('编辑物流公司:' . $data[ 'company_name' ], $data);
return $res;
} else {
//物流公司信息
$company_id = input('company_id', 0);
$company_info = $template_model->getExpressCompanyTemplateInfo([ [ 'company_id', '=', $company_id ] ]);
$this->assign('company_info', $company_info);
//打印项
$print_item_list = $template_model->getPrintItemList();
$this->assign('print_item_list', $print_item_list);
return $this->fetch('express/edit_company');
}
}
public function deleteCompany()
{
if (request()->isJson()) {
$company_ids = input('company_ids', '');
$template_model = new ExpressCompanyTemplate();
$this->addLog('删除物流公司:' . $company_ids);
$res = $template_model->deleteExpressCompanyTemplate([ [ 'company_id', 'in', $company_ids ] ]);
if ($res[ 'code' ] == 0) {
$express_company_model = new ExpressCompany();
$express_company_model->deleteExpressCompany([ ['site_id', '=', $this->site_id ], ['company_id', 'in', $company_ids ] ]);
}
return $res;
}
}
/**
* 修改物流公司排序
*/
public function modifySort()
{
if (request()->isJson()) {
$sort = input('sort', 0);
$company_id = input('company_id', 0);
$express_company_model = new ExpressCompanyTemplate();
return $express_company_model->modifyExpressCompanyTemplateSort($sort, $company_id);
}
}
/**
* 运费模板
* @return mixed
*/
public function template()
{
if (request()->isJson()) {
$express_template_model = new ExpressTemplate();
$page = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$order = input('order', 'create_time desc');
$keyword = input('keyword', '');
$condition = array (
[ 'site_id', '=', $this->site_id ],
);
//关键字查询
if (!empty($keyword)) {
$condition[] = ['template_name', 'like', '%' . $keyword . '%'];
}
$result = $express_template_model->getExpressTemplatePageList($condition, $page, $page_size, $order);
return $result;
} else {
return $this->fetch('express/template');
}
}
/**
* 添加运费模板
* @return mixed
*/
public function addTemplate()
{
if (request()->isJson()) {
$express_template_model = new ExpressTemplate();
$fee_type = input('fee_type', '');//运费计算方式1.重量2体积3按件
$template_name = input('template_name', '');
$json = input('json', '');
$is_default = input('is_default', 0);
$surplus_area_ids = input('surplus_area_ids', '');
$shipping_json = input('shipping_json', '');
$shipping_surplus_area_ids = input('shipping_surplus_area_ids', '');
$appoint_free_shipping = input('appoint_free_shipping', '0');
if (empty($json))
return error(-1, '模板配置不能为空!');
$data = array (
'fee_type' => $fee_type,
'template_name' => $template_name,
'site_id' => $this->site_id,
'is_default' => $is_default,
'surplus_area_ids' => $surplus_area_ids,
'shipping_surplus_area_ids' => $shipping_surplus_area_ids,
'appoint_free_shipping' => $appoint_free_shipping,
);
$json_data = json_decode($json, true);
$shipping_json_data = json_decode($shipping_json, true);
$result = $express_template_model->addExpressTemplate($data, $json_data, $shipping_json_data);
return $result;
} else {
// 地区等级设置 将来从配置中查询数据
$area_level = 4;
// 计费方式
$fee_type_obj = [
'1' => [ 'name' => '按重量计费', 'snum' => '首重Kg', 'xnum' => '续重Kg' ],
'2' => [ 'name' => '按体积计费', 'snum' => '首体积(m³)', 'xnum' => '续体积(m³)' ],
'3' => [ 'name' => '按件计费', 'snum' => '首件(个)', 'xnum' => '续件(个)' ],
];
$this->assign('fee_type_obj', $fee_type_obj);
$this->assign('fee_type_json', json_encode($fee_type_obj));
$this->assign('area_level', $area_level);//地址级别
return $this->fetch('express/add_template');
}
}
/**
* 编辑运费模板
* @return mixed
*/
public function editTemplate()
{
$template_id = input('template_id', 0);
$express_template_model = new ExpressTemplate();
if (request()->isJson()) {
$fee_type = input('fee_type', '');//运费计算方式1.重量2体积3按件
$template_name = input('template_name', '');
$json = input('json', '');
$is_default = input('is_default', 0);
$surplus_area_ids = input('surplus_area_ids', '');
$shipping_json = input('shipping_json', '');
$shipping_surplus_area_ids = input('shipping_surplus_area_ids', '');
$appoint_free_shipping = input('appoint_free_shipping', '0');
if (empty($json))
return error(-1, '模板配置不能为空!');
$data = array (
'fee_type' => $fee_type,
'template_name' => $template_name,
'site_id' => $this->site_id,
'template_id' => $template_id,
'is_default' => $is_default,
'surplus_area_ids' => $surplus_area_ids,
'shipping_surplus_area_ids' => $shipping_surplus_area_ids,
'appoint_free_shipping' => $appoint_free_shipping,
);
$json_data = json_decode($json, true);
$shipping_json_data = json_decode($shipping_json, true);
$result = $express_template_model->editExpressTemplate($data, $json_data, $shipping_json_data);
return $result;
} else {
// 地区等级设置 将来从配置中查询数据
$area_level = 4;
// 计费方式
$fee_type_obj = [
'1' => [ 'name' => '按重量计费', 'snum' => '首重Kg', 'xnum' => '续重Kg' ],
'2' => [ 'name' => '按体积计费', 'snum' => '首体积(m³)', 'xnum' => '续体积(m³)' ],
'3' => [ 'name' => '按件计费', 'snum' => '首件(个)', 'xnum' => '续件(个)' ],
];
$this->assign('fee_type_obj', $fee_type_obj);
$this->assign('fee_type_json', json_encode($fee_type_obj));
$this->assign('area_level', $area_level);//地址级别
$info_result = $express_template_model->getExpressTemplateInfo($template_id, $this->site_id);
$info = $info_result['data'];
$this->assign('info', $info);
return $this->fetch('express/edit_template');
}
}
/**
* 删除运费模板
* @return mixed
*/
public function deleteTemplate()
{
if (request()->isJson()) {
$template_id = input('template_id', 0);
$express_template_model = new ExpressTemplate();
$result = $express_template_model->deleteExpressTemplate($template_id, $this->site_id);
return $result;
}
}
/**
* 设置默认运费模板
* @return mixed
*/
public function defaultTemplate()
{
if (request()->isJson()) {
$template_id = input('template_id', 0);
$express_template_model = new ExpressTemplate();
$result = $express_template_model->updateDefaultExpressTemplate($template_id, 1, $this->site_id);
return $result;
}
}
/**
* 通过ajax得到运费模板的地区数据
*/
public function getAreaList()
{
if (request()->isJson()) {
$address_model = new AddressModel();
$area_level = input('level', 4);
$area_list = $address_model->getAddressTree($area_level)[ 'data' ];
return $area_list;
}
}
/**
* 获取地区树结构
*/
public function getAreaTree()
{
if (request()->isJson()) {
$address_model = new AddressModel();
$area_level = input('level', 4);
$area_list = $address_model->getAddressTreeList($area_level);
return $area_list;
}
}
/**
* 查询可用物流公司
*/
public function getShopExpressCompanyList()
{
if (request()->isJson()) {
$express_company_model = new ExpressCompany();
// 店铺物流公司
$condition = [
['ec.site_id', '=', $this->site_id ]
];
$field = 'ec.id, ec.company_id, ec.express_no, ec.content_json, ec.background_image, ec.font_size, ec.width, ec.height, ec.scale, ec.company_name';
$order = 'ect.sort desc';
$alias = 'ec';
$join = [
[ 'express_company_template ect', 'ec.company_id = ect.company_id', 'left' ]
];
$result = $express_company_model->getExpressCompanyList($condition, $field, $order, $alias, $join);
return $result;
}
}
/**
* 物流跟踪
*/
public function trace()
{
$kd100_model = new Kd100();
$kdbird_model = new Kdbird();
if (request()->isJson()) {
$trace = input('traces_type', 'kd100');
if ($trace == 'kd100') {
$data = array (
'appkey' => input('appkey', ''),
'customer' => input('customer', ''),
);
$result = $kd100_model->setKd100Config($data, 1, $this->site_id);
}
if ($trace == 'kdbird') {
$data = array (
'EBusinessID' => input('EBusinessID', ''),
'AppKey' => input('AppKey', ''),
'status' => input('kdniao_status', 0),
);
$result = $kdbird_model->setKdbirdConfig($data, 1, $this->site_id);
}
return $result;
} else {
$kd100_config = $kd100_model->getKd100Config($this->site_id);
$kdbird_config = $kdbird_model->getKdbirdConfig($this->site_id);
$traces = [
[
'name' => 'kd100',
'title' => '快递100',
'is_use' => $kd100_config[ 'data' ][ 'is_use' ]
],
[
'name' => 'kdbird',
'title' => '快递鸟',
'is_use' => $kdbird_config[ 'data' ][ 'is_use' ]
]
];
$this->assign('traces_type', $traces);
$this->assign('kd100_config', $kd100_config['data']);
$this->assign('kdbird_config', $kdbird_config['data']);
return $this->fetch('express/trace');
}
}
<?php
namespace app\shop\controller;
use app\model\express\ExpressCompany;
use app\model\express\ExpressCompanyTemplate;
use app\model\express\ExpressTemplate;
use app\model\system\Address as AddressModel;
use app\model\express\Kd100;
use app\model\express\Kdbird;
/**
* 配送
* Class Express
* @package app\shop\controller
*/
class Express extends BaseShop
{
/**
* 物流公司
* @return mixed
*/
public function expressCompany()
{
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 ];
$condition[] = [ 'company_name', 'like', '%' . $search_text . '%' ];
$order = 'is_electronicsheet desc,sort asc';
$field = 'company_id,company_name,logo,sort,url,is_electronicsheet';
$express_company_model = new ExpressCompanyTemplate();
return $express_company_model->getExpressCompanyTemplatePageList($condition, $page, $page_size, $order, $field);
} else {
return $this->fetch('express/express_company');
}
}
/**
* 添加物流公司
*/
public function addCompany()
{
$template_model = new ExpressCompanyTemplate();
if (request()->isJson()) {
$data = [
'site_id' => $this->site_id,
'company_name' => input('company_name', ''),//物流公司名称
'sort' => input('sort', 0),//排序
'logo' => input('logo', ''),//logo
'url' => input('url', ''),//网址
'express_no' => input('express_no', ''),//编码
'express_no_kd100' => input('express_no_kd100', ''),//编码快递100
'express_no_cainiao' => input('express_no_cainiao', ''),//编码(菜鸟)
'content_json' => input('content_json', '[]'),//打印内容
'background_image' => input('background_image', ''),//打印背景图
'font_size' => input('font_size', 14),//打印字体大小 单位px
'width' => input('width', 0),//显示尺寸宽度 px
'height' => input('height', 0),//显示尺寸高度 px
'scale' => input('scale', 1),//真实尺寸mm与显示尺寸px的比例
'create_time' => time(),
'is_electronicsheet' => input('is_electronicsheet', 0),//是否支持电子面单
'print_style' => input('print_style', 0),//电子面单打印风格
];
$res = $template_model->addExpressCompanyTemplate($data);
if ($res[ 'code' ] >= 0) {
$express_company_model = new ExpressCompany();
$express_company_model->addExpressCompany([ 'site_id' => $this->site_id, 'company_id' => $res[ 'data' ] ]);
$this->addLog('添加物流公司:' . $data[ 'company_name' ], $data);
}
return $res;
} else {
//打印项
$print_item_list = $template_model->getPrintItemList();
$this->assign('print_item_list', $print_item_list);
return $this->fetch('express/add_company');
}
}
/**
* 物流公司编辑
*/
public function editCompany()
{
$template_model = new ExpressCompanyTemplate();
if (request()->isJson()) {
$data = [
'site_id' => $this->site_id,
'company_name' => input('company_name', ''),//物流公司名称
'sort' => input('sort', 0),//排序
'logo' => input('logo', ''),//logo
'url' => input('url', ''),//网址
'express_no' => input('express_no', ''),//编码
'express_no_kd100' => input('express_no_kd100', ''),//编码快递100
'express_no_cainiao' => input('express_no_cainiao', ''),//编码(菜鸟)
'content_json' => input('content_json', '[]'),//打印内容
'background_image' => input('background_image', ''),//打印背景图
'font_size' => input('font_size', 14),//打印字体大小 单位mm
'width' => input('width', 0),//显示尺寸宽度 px
'height' => input('height', 0),//显示尺寸高度 px
'scale' => input('scale', 1),//真实尺寸mm与显示尺寸px的比例
'modify_time' => time(),
'company_id' => input('company_id', 0),
'is_electronicsheet' => input('is_electronicsheet', 0),//是否支持电子面单
'print_style' => input('print_style', 0),//电子面单打印风格
];
$res = $template_model->editExpressCompanyTemplate($data);
if ($res[ 'code' ] == 0) {
$express_company_model = new ExpressCompany();
$express_company_model->editExpressCompany([
'content_json' => $data[ 'content_json' ],
'background_image' => $data[ 'background_image' ],
'font_size' => $data[ 'font_size' ],
'width' => $data[ 'width' ],
'height' => $data[ 'height' ]
], [ ['site_id', '=', $this->site_id ], ['company_id', '=', $data[ 'company_id' ] ] ]);
}
$this->addLog('编辑物流公司:' . $data[ 'company_name' ], $data);
return $res;
} else {
//物流公司信息
$company_id = input('company_id', 0);
$company_info = $template_model->getExpressCompanyTemplateInfo([ [ 'company_id', '=', $company_id ] ]);
$this->assign('company_info', $company_info);
//打印项
$print_item_list = $template_model->getPrintItemList();
$this->assign('print_item_list', $print_item_list);
return $this->fetch('express/edit_company');
}
}
public function deleteCompany()
{
if (request()->isJson()) {
$company_ids = input('company_ids', '');
$template_model = new ExpressCompanyTemplate();
$this->addLog('删除物流公司:' . $company_ids);
$res = $template_model->deleteExpressCompanyTemplate([ [ 'company_id', 'in', $company_ids ] ]);
if ($res[ 'code' ] == 0) {
$express_company_model = new ExpressCompany();
$express_company_model->deleteExpressCompany([ ['site_id', '=', $this->site_id ], ['company_id', 'in', $company_ids ] ]);
}
return $res;
}
}
/**
* 修改物流公司排序
*/
public function modifySort()
{
if (request()->isJson()) {
$sort = input('sort', 0);
$company_id = input('company_id', 0);
$express_company_model = new ExpressCompanyTemplate();
return $express_company_model->modifyExpressCompanyTemplateSort($sort, $company_id);
}
}
/**
* 运费模板
* @return mixed
*/
public function template()
{
if (request()->isJson()) {
$express_template_model = new ExpressTemplate();
$page = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$order = input('order', 'create_time desc');
$keyword = input('keyword', '');
$condition = array (
[ 'site_id', '=', $this->site_id ],
);
//关键字查询
if (!empty($keyword)) {
$condition[] = ['template_name', 'like', '%' . $keyword . '%'];
}
$result = $express_template_model->getExpressTemplatePageList($condition, $page, $page_size, $order);
return $result;
} else {
return $this->fetch('express/template');
}
}
/**
* 添加运费模板
* @return mixed
*/
public function addTemplate()
{
if (request()->isJson()) {
$express_template_model = new ExpressTemplate();
$fee_type = input('fee_type', '');//运费计算方式1.重量2体积3按件
$template_name = input('template_name', '');
$json = input('json', '');
$is_default = input('is_default', 0);
$surplus_area_ids = input('surplus_area_ids', '');
$shipping_json = input('shipping_json', '');
$shipping_surplus_area_ids = input('shipping_surplus_area_ids', '');
$appoint_free_shipping = input('appoint_free_shipping', '0');
if (empty($json))
return error(-1, '模板配置不能为空!');
$data = array (
'fee_type' => $fee_type,
'template_name' => $template_name,
'site_id' => $this->site_id,
'is_default' => $is_default,
'surplus_area_ids' => $surplus_area_ids,
'shipping_surplus_area_ids' => $shipping_surplus_area_ids,
'appoint_free_shipping' => $appoint_free_shipping,
);
$json_data = json_decode($json, true);
$shipping_json_data = json_decode($shipping_json, true);
$result = $express_template_model->addExpressTemplate($data, $json_data, $shipping_json_data);
return $result;
} else {
// 地区等级设置 将来从配置中查询数据
$area_level = 4;
// 计费方式
$fee_type_obj = [
'1' => [ 'name' => '按重量计费', 'snum' => '首重Kg', 'xnum' => '续重Kg' ],
'2' => [ 'name' => '按体积计费', 'snum' => '首体积(m³)', 'xnum' => '续体积(m³)' ],
'3' => [ 'name' => '按件计费', 'snum' => '首件(个)', 'xnum' => '续件(个)' ],
];
$this->assign('fee_type_obj', $fee_type_obj);
$this->assign('fee_type_json', json_encode($fee_type_obj));
$this->assign('area_level', $area_level);//地址级别
return $this->fetch('express/add_template');
}
}
/**
* 编辑运费模板
* @return mixed
*/
public function editTemplate()
{
$template_id = input('template_id', 0);
$express_template_model = new ExpressTemplate();
if (request()->isJson()) {
$fee_type = input('fee_type', '');//运费计算方式1.重量2体积3按件
$template_name = input('template_name', '');
$json = input('json', '');
$is_default = input('is_default', 0);
$surplus_area_ids = input('surplus_area_ids', '');
$shipping_json = input('shipping_json', '');
$shipping_surplus_area_ids = input('shipping_surplus_area_ids', '');
$appoint_free_shipping = input('appoint_free_shipping', '0');
if (empty($json))
return error(-1, '模板配置不能为空!');
$data = array (
'fee_type' => $fee_type,
'template_name' => $template_name,
'site_id' => $this->site_id,
'template_id' => $template_id,
'is_default' => $is_default,
'surplus_area_ids' => $surplus_area_ids,
'shipping_surplus_area_ids' => $shipping_surplus_area_ids,
'appoint_free_shipping' => $appoint_free_shipping,
);
$json_data = json_decode($json, true);
$shipping_json_data = json_decode($shipping_json, true);
$result = $express_template_model->editExpressTemplate($data, $json_data, $shipping_json_data);
return $result;
} else {
// 地区等级设置 将来从配置中查询数据
$area_level = 4;
// 计费方式
$fee_type_obj = [
'1' => [ 'name' => '按重量计费', 'snum' => '首重Kg', 'xnum' => '续重Kg' ],
'2' => [ 'name' => '按体积计费', 'snum' => '首体积(m³)', 'xnum' => '续体积(m³)' ],
'3' => [ 'name' => '按件计费', 'snum' => '首件(个)', 'xnum' => '续件(个)' ],
];
$this->assign('fee_type_obj', $fee_type_obj);
$this->assign('fee_type_json', json_encode($fee_type_obj));
$this->assign('area_level', $area_level);//地址级别
$info_result = $express_template_model->getExpressTemplateInfo($template_id, $this->site_id);
$info = $info_result['data'];
$this->assign('info', $info);
return $this->fetch('express/edit_template');
}
}
/**
* 删除运费模板
* @return mixed
*/
public function deleteTemplate()
{
if (request()->isJson()) {
$template_id = input('template_id', 0);
$express_template_model = new ExpressTemplate();
$result = $express_template_model->deleteExpressTemplate($template_id, $this->site_id);
return $result;
}
}
/**
* 设置默认运费模板
* @return mixed
*/
public function defaultTemplate()
{
if (request()->isJson()) {
$template_id = input('template_id', 0);
$express_template_model = new ExpressTemplate();
$result = $express_template_model->updateDefaultExpressTemplate($template_id, 1, $this->site_id);
return $result;
}
}
/**
* 通过ajax得到运费模板的地区数据
*/
public function getAreaList()
{
if (request()->isJson()) {
$address_model = new AddressModel();
$area_level = input('level', 4);
$area_list = $address_model->getAddressTree($area_level)[ 'data' ];
return $area_list;
}
}
/**
* 获取地区树结构
*/
public function getAreaTree()
{
if (request()->isJson()) {
$address_model = new AddressModel();
$area_level = input('level', 4);
$area_list = $address_model->getAddressTreeList($area_level);
return $area_list;
}
}
/**
* 查询可用物流公司
*/
public function getShopExpressCompanyList()
{
if (request()->isJson()) {
$express_company_model = new ExpressCompany();
// 店铺物流公司
$condition = [
['ec.site_id', '=', $this->site_id ]
];
$field = 'ec.id, ec.company_id, ec.express_no, ec.content_json, ec.background_image, ec.font_size, ec.width, ec.height, ec.scale, ec.company_name';
$order = 'ect.sort desc';
$alias = 'ec';
$join = [
[ 'express_company_template ect', 'ec.company_id = ect.company_id', 'left' ]
];
$result = $express_company_model->getExpressCompanyList($condition, $field, $order, $alias, $join);
return $result;
}
}
/**
* 物流跟踪
*/
public function trace()
{
$kd100_model = new Kd100();
$kdbird_model = new Kdbird();
if (request()->isJson()) {
$trace = input('traces_type', 'kd100');
if ($trace == 'kd100') {
$data = array (
'appkey' => input('appkey', ''),
'customer' => input('customer', ''),
);
$result = $kd100_model->setKd100Config($data, 1, $this->site_id);
}
if ($trace == 'kdbird') {
$data = array (
'EBusinessID' => input('EBusinessID', ''),
'AppKey' => input('AppKey', ''),
'status' => input('kdniao_status', 0),
);
$result = $kdbird_model->setKdbirdConfig($data, 1, $this->site_id);
}
return $result;
} else {
$kd100_config = $kd100_model->getKd100Config($this->site_id);
$kdbird_config = $kdbird_model->getKdbirdConfig($this->site_id);
$traces = [
[
'name' => 'kd100',
'title' => '快递100',
'is_use' => $kd100_config[ 'data' ][ 'is_use' ]
],
[
'name' => 'kdbird',
'title' => '快递鸟',
'is_use' => $kdbird_config[ 'data' ][ 'is_use' ]
]
];
$this->assign('traces_type', $traces);
$this->assign('kd100_config', $kd100_config['data']);
$this->assign('kdbird_config', $kdbird_config['data']);
return $this->fetch('express/trace');
}
}
}

View File

@@ -1,334 +1,326 @@
<?php
/**
*/
namespace app\shop\controller;
use app\model\goods\GoodsAttribute as GoodsAttributeModel;
/**
* 商品类型/属性管理 控制器
*/
class Goodsattr extends BaseShop
{
/**
* 商品类型列表
*/
public function lists()
{
if (request()->isJson()) {
$page_index = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$search_keys = input('search_keys', '');
$condition = [];
$condition[] = [ 'site_id', '=', $this->site_id ];
if (!empty($search_keys)) {
$condition[] = [ 'class_name', 'like', '%' . $search_keys . '%' ];
}
//排序
$link_sort = input('order', 'sort');
$sort = input('sort', 'desc');
if ($link_sort == 'sort') {
$order_by = $link_sort . ' ' . $sort;
} else {
$order_by = $link_sort . ' ' . $sort . ',sort desc';
}
$goods_attr_model = new GoodsAttributeModel();
$list = $goods_attr_model->getAttrClassPageList($condition, $page_index, $page_size, $order_by);
return $list;
} else {
return $this->fetch('goodsattr/lists');
}
}
/**
* 商品类型添加
*/
public function addAttr()
{
if (request()->isJson()) {
$class_name = input('class_name', '');
$sort = input('sort', 0);
$data = [
'site_id' => $this->site_id,
'class_name' => $class_name,
'sort' => $sort
];
$goods_attr_model = new GoodsAttributeModel();
$res = $goods_attr_model->addAttrClass($data);
return $res;
}
}
/**
* 商品类型编辑
*/
public function editAttr()
{
$goods_attr_model = new GoodsAttributeModel();
if (request()->isJson()) {
$class_id = input('class_id', 0);
$class_name = input('class_name', '');
$sort = input('sort', 0);
$data = [
'class_id' => $class_id,
'site_id' => $this->site_id,
'class_name' => $class_name,
'sort' => $sort
];
$res = $goods_attr_model->editAttrClass($data);
return $res;
} else {
$class_id = input('class_id', 0);
$this->assign('class_id', $class_id);
//商品类型信息
$attr_class_info = $goods_attr_model->getAttrClassInfo([ [ 'class_id', '=', $class_id ], [ 'site_id', '=', $this->site_id ] ])[ 'data' ];
if (empty($attr_class_info)) $this->error('未获取到属性数据', href_url('shop/goodsattr/lists'));
$this->assign('attr_class_info', $attr_class_info);
return $this->fetch('goodsattr/edit_attr');
}
}
/**
* 修改商品类型排序
*/
public function modifySort()
{
if (request()->isJson()) {
$sort = input('sort', 0);
$class_id = input('class_id', 0);
$goods_attr_model = new GoodsAttributeModel();
return $goods_attr_model->modifyAttrClassSort($sort, $class_id, $this->site_id);
}
}
/**
* 商品类型删除
*/
public function deleteAttr()
{
if (request()->isJson()) {
$class_id = input('class_id', 0);
$goods_attr_model = new GoodsAttributeModel();
$result = $goods_attr_model->deleteAttrClass($class_id, $this->site_id);
return $result;
}
}
/**
* 添加商品参数
*/
public function addAttribute()
{
if (request()->isJson()) {
$attr_name = input('attr_name', '');// 属性名称
$attr_class_id = input('attr_class_id', 0);// 商品类型id
$attr_class_name = input('attr_class_name', '');// 商品类型名称
$attr_value_list = input('attr_value_list', '');// 属性值列表('',''隔开注意键值对)
$attr_type = input('attr_type', 0);// 属性类型 1.单选 2.多选3. 输入 注意输入不参与筛选)
$site_id = $this->site_id;// 站点id
$data = [
'attr_name' => $attr_name,
'attr_class_id' => $attr_class_id,
'attr_class_name' => $attr_class_name,
'attr_value_list' => $attr_value_list,
'attr_type' => $attr_type,
'site_id' => $site_id,
];
$goods_attr_model = new GoodsAttributeModel();
return $goods_attr_model->addAttribute($attr_class_id, $data);
}
}
/**
* 修改商品参数
*/
public function editAttribute()
{
if (request()->isJson()) {
$attr_id = input('attr_id', '');// 属性id
$attr_name = input('attr_name', '');// 属性名称
$attr_class_id = input('attr_class_id', 0);// 商品类型id
$attr_class_name = input('attr_class_name', '');// 商品类型名称
$attr_value_list = input('attr_value_list', '');// 属性值列表('',''隔开注意键值对)
$attr_type = input('attr_type', 0);// 属性类型 1.单选 2.多选3. 输入 注意输入不参与筛选)
$data = [
'attr_id' => $attr_id,
'attr_name' => $attr_name,
'attr_class_id' => $attr_class_id,
'attr_class_name' => $attr_class_name,
'attr_value_list' => $attr_value_list,
'attr_type' => $attr_type,
'site_id' => $this->site_id
];
$goods_attr_model = new GoodsAttributeModel();
return $goods_attr_model->editAttribute($attr_class_id, $data);
}
}
/**
* 删除属性、属性值
* @return \multitype
*/
public function deleteAttribute()
{
if (request()->isJson()) {
$attr_class_id = input('attr_class_id', 0);// 商品类型id
$attr_id = input('attr_id', 0);// 属性id
$goods_attr_model = new GoodsAttributeModel();
$res = $goods_attr_model->deleteAttribute($attr_class_id, $attr_id, $this->site_id);
return $res;
}
}
/**
* 获取属性、属性值详情
* @return \multitype
*/
public function getAttributeDetail()
{
if (request()->isJson()) {
$attr_class_id = input('attr_class_id', 0);// 商品类型id
$attr_id = input('attr_id', 0);// 属性id
$goods_attr_model = new GoodsAttributeModel();
$attr_info = $goods_attr_model->getAttributeInfo([ [ 'attr_class_id', '=', $attr_class_id ], [ 'attr_id', '=', $attr_id ], [ 'site_id', '=', $this->site_id ] ])[ 'data' ];
if (!empty($attr_info)) {
$attr_value_list = $goods_attr_model->getAttributeValueList([ [ 'attr_class_id', '=', $attr_class_id ], [ 'attr_id', '=', $attr_id ] ])[ 'data' ];
$attr_info[ 'value' ] = $attr_value_list;
return success(0, '', $attr_info);
} else {
return error(-1, '未查询到属性信息');
}
}
}
/**
* 获取商品参数列表
* @return \multitype
*/
public function getAttributeList()
{
if (request()->isJson()) {
$attr_class_id = input('attr_class_id', 0);// 商品类型id
$goods_attr_model = new GoodsAttributeModel();
return $goods_attr_model->getAttributeList([ [ 'attr_class_id', '=', $attr_class_id ], [ 'site_id', '=', $this->site_id ] ]);
}
}
/**
* 添加属性值
* @return \multitype
*/
public function addAttributeValue()
{
if (request()->isJson()) {
$attr_class_id = input('attr_class_id', 0);// 商品类型id
$value = input('value', '');
if (!empty($value)) {
$value = json_decode($value, true);
$data = [];
foreach ($value as $k => $v) {
$item = [
'attr_value_name' => $v[ 'attr_value_name' ],
'attr_id' => $v[ 'attr_id' ],
'attr_class_id' => $v[ 'attr_class_id' ],
'sort' => $v[ 'sort' ]
];
$data[] = $item;
}
$goods_attr_model = new GoodsAttributeModel();
$res = $goods_attr_model->addAttributeValue($attr_class_id, $data);
return $res;
}
} else {
return error(-1, '缺少value');
}
}
/**
* 修改商品参数值
*/
public function editAttributeValue()
{
if (request()->isJson()) {
$attr_class_id = input('attr_class_id', 0);// 商品类型id
$data = input('data', '');// 属性值数组对象
if (!empty($data)) {
$data = json_decode($data, true);
$goods_attr_model = new GoodsAttributeModel();
foreach ($data as $k => $v) {
$item = [
'attr_value_id' => $v[ 'attr_value_id' ],
'attr_value_name' => $v[ 'attr_value_name' ],
'attr_id' => $v[ 'attr_id' ],
'attr_class_id' => $v[ 'attr_class_id' ],
'sort' => $v[ 'sort' ],
];
$res = $goods_attr_model->editAttributeValue($attr_class_id, $item);
}
return $res;
} else {
return error(-1, '缺少data');
}
}
}
/**
* 删除属性值
* @return \multitype
*/
public function deleteAttributeValue()
{
if (request()->isJson()) {
$attr_class_id = input('attr_class_id', 0);// 商品类型id
$attr_id = input('attr_id', 0);// 商品类型id
$attr_value_id_arr = input('attr_value_id_arr', 0);
$goods_attr_model = new GoodsAttributeModel();
$res = $goods_attr_model->deleteAttributeValue($attr_class_id, $attr_id, [ [ 'attr_value_id', 'in', $attr_value_id_arr ] ]);
return $res;
}
}
/**
* 修改商品参数值排序
*/
public function modifyAttributeSort()
{
if (request()->isJson()) {
$sort = input('sort', 0);
$attr_class_id = input('attr_class_id', 0);// 商品类型id
$attr_id = input('attr_id', 0);
$goods_attr_model = new GoodsAttributeModel();
return $goods_attr_model->modifyAttributeSort($sort, $attr_class_id, $attr_id, $this->site_id);
}
}
<?php
namespace app\shop\controller;
use app\model\goods\GoodsAttribute as GoodsAttributeModel;
/**
* 商品类型/属性管理 控制器
*/
class Goodsattr extends BaseShop
{
/**
* 商品类型列表
*/
public function lists()
{
if (request()->isJson()) {
$page_index = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$search_keys = input('search_keys', '');
$condition = [];
$condition[] = [ 'site_id', '=', $this->site_id ];
if (!empty($search_keys)) {
$condition[] = [ 'class_name', 'like', '%' . $search_keys . '%' ];
}
//排序
$link_sort = input('order', 'sort');
$sort = input('sort', 'desc');
if ($link_sort == 'sort') {
$order_by = $link_sort . ' ' . $sort;
} else {
$order_by = $link_sort . ' ' . $sort . ',sort desc';
}
$goods_attr_model = new GoodsAttributeModel();
$list = $goods_attr_model->getAttrClassPageList($condition, $page_index, $page_size, $order_by);
return $list;
} else {
return $this->fetch('goodsattr/lists');
}
}
/**
* 商品类型添加
*/
public function addAttr()
{
if (request()->isJson()) {
$class_name = input('class_name', '');
$sort = input('sort', 0);
$data = [
'site_id' => $this->site_id,
'class_name' => $class_name,
'sort' => $sort
];
$goods_attr_model = new GoodsAttributeModel();
$res = $goods_attr_model->addAttrClass($data);
return $res;
}
}
/**
* 商品类型编辑
*/
public function editAttr()
{
$goods_attr_model = new GoodsAttributeModel();
if (request()->isJson()) {
$class_id = input('class_id', 0);
$class_name = input('class_name', '');
$sort = input('sort', 0);
$data = [
'class_id' => $class_id,
'site_id' => $this->site_id,
'class_name' => $class_name,
'sort' => $sort
];
$res = $goods_attr_model->editAttrClass($data);
return $res;
} else {
$class_id = input('class_id', 0);
$this->assign('class_id', $class_id);
//商品类型信息
$attr_class_info = $goods_attr_model->getAttrClassInfo([ [ 'class_id', '=', $class_id ], [ 'site_id', '=', $this->site_id ] ])[ 'data' ];
if (empty($attr_class_info)) $this->error('未获取到属性数据', href_url('shop/goodsattr/lists'));
$this->assign('attr_class_info', $attr_class_info);
return $this->fetch('goodsattr/edit_attr');
}
}
/**
* 修改商品类型排序
*/
public function modifySort()
{
if (request()->isJson()) {
$sort = input('sort', 0);
$class_id = input('class_id', 0);
$goods_attr_model = new GoodsAttributeModel();
return $goods_attr_model->modifyAttrClassSort($sort, $class_id, $this->site_id);
}
}
/**
* 商品类型删除
*/
public function deleteAttr()
{
if (request()->isJson()) {
$class_id = input('class_id', 0);
$goods_attr_model = new GoodsAttributeModel();
$result = $goods_attr_model->deleteAttrClass($class_id, $this->site_id);
return $result;
}
}
/**
* 添加商品参数
*/
public function addAttribute()
{
if (request()->isJson()) {
$attr_name = input('attr_name', '');// 属性名称
$attr_class_id = input('attr_class_id', 0);// 商品类型id
$attr_class_name = input('attr_class_name', '');// 商品类型名称
$attr_value_list = input('attr_value_list', '');// 属性值列表('',''隔开注意键值对)
$attr_type = input('attr_type', 0);// 属性类型 1.单选 2.多选3. 输入 注意输入不参与筛选)
$site_id = $this->site_id;// 站点id
$data = [
'attr_name' => $attr_name,
'attr_class_id' => $attr_class_id,
'attr_class_name' => $attr_class_name,
'attr_value_list' => $attr_value_list,
'attr_type' => $attr_type,
'site_id' => $site_id,
];
$goods_attr_model = new GoodsAttributeModel();
return $goods_attr_model->addAttribute($attr_class_id, $data);
}
}
/**
* 修改商品参数
*/
public function editAttribute()
{
if (request()->isJson()) {
$attr_id = input('attr_id', '');// 属性id
$attr_name = input('attr_name', '');// 属性名称
$attr_class_id = input('attr_class_id', 0);// 商品类型id
$attr_class_name = input('attr_class_name', '');// 商品类型名称
$attr_value_list = input('attr_value_list', '');// 属性值列表('',''隔开注意键值对)
$attr_type = input('attr_type', 0);// 属性类型 1.单选 2.多选3. 输入 注意输入不参与筛选)
$data = [
'attr_id' => $attr_id,
'attr_name' => $attr_name,
'attr_class_id' => $attr_class_id,
'attr_class_name' => $attr_class_name,
'attr_value_list' => $attr_value_list,
'attr_type' => $attr_type,
'site_id' => $this->site_id
];
$goods_attr_model = new GoodsAttributeModel();
return $goods_attr_model->editAttribute($attr_class_id, $data);
}
}
/**
* 删除属性、属性值
* @return \multitype
*/
public function deleteAttribute()
{
if (request()->isJson()) {
$attr_class_id = input('attr_class_id', 0);// 商品类型id
$attr_id = input('attr_id', 0);// 属性id
$goods_attr_model = new GoodsAttributeModel();
$res = $goods_attr_model->deleteAttribute($attr_class_id, $attr_id, $this->site_id);
return $res;
}
}
/**
* 获取属性、属性值详情
* @return \multitype
*/
public function getAttributeDetail()
{
if (request()->isJson()) {
$attr_class_id = input('attr_class_id', 0);// 商品类型id
$attr_id = input('attr_id', 0);// 属性id
$goods_attr_model = new GoodsAttributeModel();
$attr_info = $goods_attr_model->getAttributeInfo([ [ 'attr_class_id', '=', $attr_class_id ], [ 'attr_id', '=', $attr_id ], [ 'site_id', '=', $this->site_id ] ])[ 'data' ];
if (!empty($attr_info)) {
$attr_value_list = $goods_attr_model->getAttributeValueList([ [ 'attr_class_id', '=', $attr_class_id ], [ 'attr_id', '=', $attr_id ] ])[ 'data' ];
$attr_info[ 'value' ] = $attr_value_list;
return success(0, '', $attr_info);
} else {
return error(-1, '未查询到属性信息');
}
}
}
/**
* 获取商品参数列表
* @return \multitype
*/
public function getAttributeList()
{
if (request()->isJson()) {
$attr_class_id = input('attr_class_id', 0);// 商品类型id
$goods_attr_model = new GoodsAttributeModel();
return $goods_attr_model->getAttributeList([ [ 'attr_class_id', '=', $attr_class_id ], [ 'site_id', '=', $this->site_id ] ]);
}
}
/**
* 添加属性值
* @return \multitype
*/
public function addAttributeValue()
{
if (request()->isJson()) {
$attr_class_id = input('attr_class_id', 0);// 商品类型id
$value = input('value', '');
if (!empty($value)) {
$value = json_decode($value, true);
$data = [];
foreach ($value as $k => $v) {
$item = [
'attr_value_name' => $v[ 'attr_value_name' ],
'attr_id' => $v[ 'attr_id' ],
'attr_class_id' => $v[ 'attr_class_id' ],
'sort' => $v[ 'sort' ]
];
$data[] = $item;
}
$goods_attr_model = new GoodsAttributeModel();
$res = $goods_attr_model->addAttributeValue($attr_class_id, $data);
return $res;
}
} else {
return error(-1, '缺少value');
}
}
/**
* 修改商品参数值
*/
public function editAttributeValue()
{
if (request()->isJson()) {
$attr_class_id = input('attr_class_id', 0);// 商品类型id
$data = input('data', '');// 属性值数组对象
if (!empty($data)) {
$data = json_decode($data, true);
$goods_attr_model = new GoodsAttributeModel();
foreach ($data as $k => $v) {
$item = [
'attr_value_id' => $v[ 'attr_value_id' ],
'attr_value_name' => $v[ 'attr_value_name' ],
'attr_id' => $v[ 'attr_id' ],
'attr_class_id' => $v[ 'attr_class_id' ],
'sort' => $v[ 'sort' ],
];
$res = $goods_attr_model->editAttributeValue($attr_class_id, $item);
}
return $res;
} else {
return error(-1, '缺少data');
}
}
}
/**
* 删除属性值
* @return \multitype
*/
public function deleteAttributeValue()
{
if (request()->isJson()) {
$attr_class_id = input('attr_class_id', 0);// 商品类型id
$attr_id = input('attr_id', 0);// 商品类型id
$attr_value_id_arr = input('attr_value_id_arr', 0);
$goods_attr_model = new GoodsAttributeModel();
$res = $goods_attr_model->deleteAttributeValue($attr_class_id, $attr_id, [ [ 'attr_value_id', 'in', $attr_value_id_arr ] ]);
return $res;
}
}
/**
* 修改商品参数值排序
*/
public function modifyAttributeSort()
{
if (request()->isJson()) {
$sort = input('sort', 0);
$attr_class_id = input('attr_class_id', 0);// 商品类型id
$attr_id = input('attr_id', 0);
$goods_attr_model = new GoodsAttributeModel();
return $goods_attr_model->modifyAttributeSort($sort, $attr_class_id, $attr_id, $this->site_id);
}
}
}

View File

@@ -1,115 +1,106 @@
<?php
/**
*/
namespace app\shop\controller;
use app\model\goods\GoodsLabel as GoodsLabelModel;
class GoodsLabel extends BaseShop
{
/**
* 商品分组列表
*/
public function lists()
{
if (request()->isJson()) {
$page_index = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$search_keys = input('search_keys', '');
$condition = [];
$condition[] = ['site_id', '=', $this->site_id];
if (!empty($search_keys)) {
$condition[] = ['label_name', 'like', '%' . $search_keys . '%'];
}
//排序
$link_sort = input('order', 'sort');
$sort = input('sort', 'desc');
if($link_sort == 'sort'){
$order_by = $link_sort . ' ' . $sort;
}else{
$order_by = $link_sort . ' ' . $sort.',sort desc';
}
$goods_attr_model = new GoodsLabelModel();
$list = $goods_attr_model->getLabelPageList($condition, $page_index, $page_size, $order_by);
return $list;
} else {
return $this->fetch('goodslabel/lists');
}
}
/**
* 商品分组添加
*/
public function add()
{
if (request()->isJson()) {
$label_name = input('label_name', '');
$data = [
'site_id' => $this->site_id,
'label_name' => $label_name,
'desc' => input('desc', 0)
];
$model = new GoodsLabelModel();
$res = $model->addLabel($data);
return $res;
}
}
/**
* 商品分组编辑
*/
public function edit()
{
if (request()->isJson()) {
$data = [
'id' => input('id', ''),
'site_id' => $this->site_id,
'label_name' => input('label_name', ''),
'desc' => input('desc', 0)
];
$model = new GoodsLabelModel();
$res = $model->editLabel($data);
return $res;
}
}
/**
* 商品分组删除
*/
public function delete()
{
if (request()->isJson()) {
$id = input('id', 0);
$model = new GoodsLabelModel();
$result = $model->deleteLabel([['id', '=', $id], ['site_id', '=', $this->site_id]]);
return $result;
}
}
/**
* 修改排序
*/
public function modifySort()
{
if (request()->isJson()) {
$sort = input('sort', 0);
$id = input('id', 0);
$model = new GoodsLabelModel();
$result = $model->modifySort($sort, $id, $this->site_id);
return $result;
}
}
<?php
namespace app\shop\controller;
use app\model\goods\GoodsLabel as GoodsLabelModel;
class GoodsLabel extends BaseShop
{
/**
* 商品分组列表
*/
public function lists()
{
if (request()->isJson()) {
$page_index = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$search_keys = input('search_keys', '');
$condition = [];
$condition[] = ['site_id', '=', $this->site_id];
if (!empty($search_keys)) {
$condition[] = ['label_name', 'like', '%' . $search_keys . '%'];
}
//排序
$link_sort = input('order', 'sort');
$sort = input('sort', 'desc');
if($link_sort == 'sort'){
$order_by = $link_sort . ' ' . $sort;
}else{
$order_by = $link_sort . ' ' . $sort.',sort desc';
}
$goods_attr_model = new GoodsLabelModel();
$list = $goods_attr_model->getLabelPageList($condition, $page_index, $page_size, $order_by);
return $list;
} else {
return $this->fetch('goodslabel/lists');
}
}
/**
* 商品分组添加
*/
public function add()
{
if (request()->isJson()) {
$label_name = input('label_name', '');
$data = [
'site_id' => $this->site_id,
'label_name' => $label_name,
'desc' => input('desc', 0)
];
$model = new GoodsLabelModel();
$res = $model->addLabel($data);
return $res;
}
}
/**
* 商品分组编辑
*/
public function edit()
{
if (request()->isJson()) {
$data = [
'id' => input('id', ''),
'site_id' => $this->site_id,
'label_name' => input('label_name', ''),
'desc' => input('desc', 0)
];
$model = new GoodsLabelModel();
$res = $model->editLabel($data);
return $res;
}
}
/**
* 商品分组删除
*/
public function delete()
{
if (request()->isJson()) {
$id = input('id', 0);
$model = new GoodsLabelModel();
$result = $model->deleteLabel([['id', '=', $id], ['site_id', '=', $this->site_id]]);
return $result;
}
}
/**
* 修改排序
*/
public function modifySort()
{
if (request()->isJson()) {
$sort = input('sort', 0);
$id = input('id', 0);
$model = new GoodsLabelModel();
$result = $model->modifySort($sort, $id, $this->site_id);
return $result;
}
}
}

View File

@@ -1,89 +1,81 @@
<?php
/**
*/
namespace app\shop\controller;
use app\model\goods\GoodsService as GoodsServiceModel;
class Goodsservice extends BaseShop
{
/**
* 商品服务列表
*/
public function lists()
{
if (request()->isJson()) {
$page_index = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$search_keys = input('search_keys', '');
$condition = [];
$condition[] = [ 'site_id', '=', $this->site_id ];
if (!empty($search_keys)) {
$condition[] = [ 'service_name', 'like', '%' . $search_keys . '%' ];
}
$goods_attr_model = new GoodsServiceModel();
$list = $goods_attr_model->getServicePageList($condition, $page_index, $page_size);
return $list;
} else {
return $this->fetch('goodsservice/lists');
}
}
/**
* 商品服务添加
*/
public function add()
{
if (request()->isJson()) {
$data = [
'site_id' => $this->site_id,
'service_name' => input('service_name', ''),
'desc' => input('desc', 0),
'icon' => input('icon', '')
];
$model = new GoodsServiceModel();
$res = $model->addService($data);
return $res;
}
}
/**
* 商品服务编辑
*/
public function edit()
{
if (request()->isJson()) {
$id = input('id', '');
$data = [
'service_name' => input('service_name', ''),
'desc' => input('desc', 0),
'icon' => input('icon', '')
];
$model = new GoodsServiceModel();
$res = $model->editService($data, [ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ]);
return $res;
}
}
/**
* 商品服务删除
*/
public function delete()
{
if (request()->isJson()) {
$id = input('id', 0);
$model = new GoodsServiceModel();
$result = $model->deleteService([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ]);
return $result;
}
}
<?php
namespace app\shop\controller;
use app\model\goods\GoodsService as GoodsServiceModel;
class Goodsservice extends BaseShop
{
/**
* 商品服务列表
*/
public function lists()
{
if (request()->isJson()) {
$page_index = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$search_keys = input('search_keys', '');
$condition = [];
$condition[] = [ 'site_id', '=', $this->site_id ];
if (!empty($search_keys)) {
$condition[] = [ 'service_name', 'like', '%' . $search_keys . '%' ];
}
$goods_attr_model = new GoodsServiceModel();
$list = $goods_attr_model->getServicePageList($condition, $page_index, $page_size);
return $list;
} else {
return $this->fetch('goodsservice/lists');
}
}
/**
* 商品服务添加
*/
public function add()
{
if (request()->isJson()) {
$data = [
'site_id' => $this->site_id,
'service_name' => input('service_name', ''),
'desc' => input('desc', 0),
'icon' => input('icon', '')
];
$model = new GoodsServiceModel();
$res = $model->addService($data);
return $res;
}
}
/**
* 商品服务编辑
*/
public function edit()
{
if (request()->isJson()) {
$id = input('id', '');
$data = [
'service_name' => input('service_name', ''),
'desc' => input('desc', 0),
'icon' => input('icon', '')
];
$model = new GoodsServiceModel();
$res = $model->editService($data, [ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ]);
return $res;
}
}
/**
* 商品服务删除
*/
public function delete()
{
if (request()->isJson()) {
$id = input('id', 0);
$model = new GoodsServiceModel();
$result = $model->deleteService([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ]);
return $result;
}
}
}

View File

@@ -1,130 +1,122 @@
<?php
/**
*/
namespace app\shop\controller;
use app\model\system\H5 as H5Model;
use app\model\web\Config;
use app\model\system\Upgrade;
use app\model\web\DiyView as DiyViewModel;
class H5 extends BaseShop
{
/**
* 刷新前端代码
*/
public function refreshH5()
{
if (request()->isJson()) {
$h5 = new H5Model();
$res = $h5->refresh();
$this->h5DomainName(); // 修改H5域名
return $res;
}
}
/**
* 获取H5部署信息
* @return array
*/
public function getDeploy()
{
if (request()->isJson()) {
$config_model = new Config();
$config = $config_model->getH5DomainName($this->site_id)[ 'data' ][ 'value' ];
$res = [
'root_url' => __ROOT__,
'config' => $config
];
return success('', '', $res);
}
}
/**
* h5域名配置
*/
public function h5DomainName()
{
$config_model = new Config();
$domain_name = input('domain', '');
$deploy_way = input('deploy_way', 'default');
if ($deploy_way == 'default') {
$domain_name = __ROOT__ . '/h5';
}
$result = $config_model->seth5DomainName([
'domain_name_h5' => $domain_name,
'deploy_way' => $deploy_way
]);
return $result;
}
/**
* 独立部署版下载
*/
public function downloadSeparate()
{
if (strstr(ROOT_URL, 'liveplatform.cn') === false) {
$domain_name = input('domain', '');
$h5 = new H5Model();
$res = $h5->downloadH5Separate($domain_name);
if (isset($res[ 'code' ]) && $res[ 'code' ] != 0) {
$this->error($res[ 'message' ]);
} else {
$config_model = new Config();
$config_model->seth5DomainName([
'domain_name_h5' => $domain_name,
'deploy_way' => 'separate'
]);
}
}
}
/**
* 下载uniapp源码混入所选模板代码
* @return array|bool|int|mixed|void
*/
public function downloadUniapp()
{
if (strstr(ROOT_URL, 'liveplatform.cn') === false) {
$app_info = config('info');
$upgrade_model = new Upgrade();
$res = $upgrade_model->downloadUniapp($app_info[ 'version_no' ]);
if ($res[ 'code' ] == 0) {
$filename = "upload/{$app_info['version_no']}_uniapp.zip";
$res = file_put_contents($filename, base64_decode($res[ 'data' ]));
$zip = new \ZipArchive();
$zip->open($filename, \ZipArchive::CREATE);
$zip->extractTo('upload/temp/standard_uniapp'); // 将压缩包解压到指定目录
$zip->close();
$diy_view = new DiyViewModel();
// 混入当前所选模板的代码,进行编译
$diy_view->compileUniApp([
'site_id' => $this->site_id
]);
header('Content-Type: application/zip');
header('Content-Transfer-Encoding: Binary');
header('Content-Length: ' . filesize($filename));
header("Content-Disposition: attachment; filename=\"" . basename($filename) . "\"");
readfile($filename);
@unlink($filename);
} else {
$this->error($res[ 'message' ]);
}
}
}
}
<?php
namespace app\shop\controller;
use app\model\system\H5 as H5Model;
use app\model\web\Config;
use app\model\system\Upgrade;
use app\model\web\DiyView as DiyViewModel;
class H5 extends BaseShop
{
/**
* 刷新前端代码
*/
public function refreshH5()
{
if (request()->isJson()) {
$h5 = new H5Model();
$res = $h5->refresh();
$this->h5DomainName(); // 修改H5域名
return $res;
}
}
/**
* 获取H5部署信息
* @return array
*/
public function getDeploy()
{
if (request()->isJson()) {
$config_model = new Config();
$config = $config_model->getH5DomainName($this->site_id)[ 'data' ][ 'value' ];
$res = [
'root_url' => __ROOT__,
'config' => $config
];
return success('', '', $res);
}
}
/**
* h5域名配置
*/
public function h5DomainName()
{
$config_model = new Config();
$domain_name = input('domain', '');
$deploy_way = input('deploy_way', 'default');
if ($deploy_way == 'default') {
$domain_name = __ROOT__ . '/h5';
}
$result = $config_model->seth5DomainName([
'domain_name_h5' => $domain_name,
'deploy_way' => $deploy_way
]);
return $result;
}
/**
* 独立部署版下载
*/
public function downloadSeparate()
{
if (strstr(ROOT_URL, 'liveplatform.cn') === false) {
$domain_name = input('domain', '');
$h5 = new H5Model();
$res = $h5->downloadH5Separate($domain_name);
if (isset($res[ 'code' ]) && $res[ 'code' ] != 0) {
$this->error($res[ 'message' ]);
} else {
$config_model = new Config();
$config_model->seth5DomainName([
'domain_name_h5' => $domain_name,
'deploy_way' => 'separate'
]);
}
}
}
/**
* 下载uniapp源码混入所选模板代码
* @return array|bool|int|mixed|void
*/
public function downloadUniapp()
{
if (strstr(ROOT_URL, 'liveplatform.cn') === false) {
$app_info = config('info');
$upgrade_model = new Upgrade();
$res = $upgrade_model->downloadUniapp($app_info[ 'version_no' ]);
if ($res[ 'code' ] == 0) {
$filename = "upload/{$app_info['version_no']}_uniapp.zip";
$res = file_put_contents($filename, base64_decode($res[ 'data' ]));
$zip = new \ZipArchive();
$zip->open($filename, \ZipArchive::CREATE);
$zip->extractTo('upload/temp/standard_uniapp'); // 将压缩包解压到指定目录
$zip->close();
$diy_view = new DiyViewModel();
// 混入当前所选模板的代码,进行编译
$diy_view->compileUniApp([
'site_id' => $this->site_id
]);
header('Content-Type: application/zip');
header('Content-Transfer-Encoding: Binary');
header('Content-Length: ' . filesize($filename));
header("Content-Disposition: attachment; filename=\"" . basename($filename) . "\"");
readfile($filename);
@unlink($filename);
} else {
$this->error($res[ 'message' ]);
}
}
}
}

View File

@@ -1,262 +1,254 @@
<?php
/**
*/
namespace app\shop\controller;
use app\model\web\Help as HelpModel;
/**
* 网站帮助
*/
class Help extends BaseShop
{
/**
* 分类列表
*/
public function classList()
{
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 ] ];
$condition[] = [ 'class_name', 'like', '%' . $search_text . '%' ];
$condition[] = [ 'app_module', '=', $this->app_module ];
$field = '*';
//排序
$link_sort = input('order', 'sort');
$sort = input('sort', 'desc');
if ($link_sort == 'sort') {
$order_by = $link_sort . ' ' . $sort;
} else {
$order_by = $link_sort . ' ' . $sort . ',sort desc';
}
$help_model = new HelpModel();
return $help_model->getHelpClassPageList($condition, $page, $page_size, $order_by, $field);
} else {
return $this->fetch('help/class_list');
}
}
/**
* 分类添加
*/
public function addClass()
{
if (request()->isJson()) {
$data = [
'site_id' => $this->site_id,
'app_module' => $this->app_module,
'class_name' => input('class_name', ''),
'sort' => input('sort', 0),
];
$help_model = new HelpModel();
return $help_model->addHelpClass($data);
} else {
return $this->fetch('help/add_class');
}
}
/**
* 分类编辑
*/
public function editClass()
{
$help_model = new HelpModel();
if (request()->isJson()) {
$data = [
'site_id' => $this->site_id,
'app_module' => $this->app_module,
'class_name' => input('class_name', ''),
'sort' => input('sort', 0),
];
$class_id = input('class_id', 0);
return $help_model->editHelpClass($data, $class_id);
} else {
$class_id = input('class_id', 0);
$this->assign('class_id', $class_id);
//帮助详情
$class_info = $help_model->getHelpClassInfo([ [ 'class_id', '=', $class_id ], [ 'site_id', '=', $this->site_id ], [ 'app_module', '=', $this->app_module ] ]);
$this->assign('class_info', $class_info);
return $this->fetch('help/edit_class');
}
}
/**
* 分类删除
*/
public function deleteClass()
{
if (request()->isJson()) {
$class_id = input('class_id', 0);
$help_model = new HelpModel();
return $help_model->deleteHelpClass([ [ 'class_id', '=', $class_id ] ]);
}
}
/**
* 修改分类排序
*/
public function modifyClassSort()
{
if (request()->isJson()) {
$sort = input('sort', 0);
$class_id = input('class_id', 0);
$help_model = new HelpModel();
return $help_model->modifyHelpClassSort($sort, $class_id);
}
}
/**
* 帮助列表
*/
public function helpList()
{
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 ] ];
$condition[] = [ 'title', 'like', '%' . $search_text . '%' ];
$condition[] = [ 'app_module', '=', $this->app_module ];
$field = 'id,title,class_id,class_name,sort,create_time';
//排序
$link_sort = input('order', 'sort');
$sort = input('sort', 'desc');
if ($link_sort == 'sort') {
$order_by = $link_sort . ' ' . $sort;
} else {
$order_by = $link_sort . ' ' . $sort . ',sort desc';
}
$help_model = new HelpModel();
return $help_model->getHelpPageList($condition, $page, $page_size, $order_by, $field);
} else {
return $this->fetch('help/help_list');
}
}
/**
* 帮助添加
*/
public function addHelp()
{
$help_model = new HelpModel();
if (request()->isJson()) {
$data = [
'site_id' => $this->site_id,
'app_module' => $this->app_module,
'title' => input('title', ''),
'link_address' => input('link_address', ''),
'content' => input('content', ''),
'class_id' => input('class_id', ''),
'class_name' => input('class_name', ''),
'sort' => input('sort', ''),
'create_time' => time(),
];
return $help_model->addHelp($data);
} else {
//帮助分类
$help_class_list = $help_model->getHelpClassList([ [ 'app_module', '=', $this->app_module ], [ 'site_id', '=', $this->site_id ] ], 'class_id, class_name');
$this->assign('help_class_list', $help_class_list[ 'data' ]);
return $this->fetch('help/add_help');
}
}
/**
* 帮助编辑
*/
public function editHelp()
{
$id = input('id', 0);
$help_model = new HelpModel();
if (request()->isJson()) {
$data = [
'site_id' => $this->site_id,
'app_module' => $this->app_module,
'title' => input('title', ''),
'link_address' => input('link_address', ''),
'content' => input('content', ''),
'class_id' => input('class_id', ''),
'class_name' => input('class_name', ''),
'sort' => input('sort', ''),
'modify_time' => time(),
];
return $help_model->editHelp($data, [ [ 'id', '=', $id ] ]);
} else {
$this->assign('id', $id);
$help_info = $help_model->getHelpInfo($id);
$this->assign('help_info', $help_info[ 'data' ]);
//帮助分类
$help_class_list = $help_model->getHelpClassList([ [ 'app_module', '=', $this->app_module ], [ 'site_id', '=', $this->site_id ] ], 'class_id, class_name');
$this->assign('help_class_list', $help_class_list[ 'data' ]);
return $this->fetch('help/edit_help');
}
}
/**
* 帮助删除
*/
public function deleteHelp()
{
if (request()->isJson()) {
$id = input('id', 0);
$help_model = new HelpModel();
return $help_model->deleteHelp([ [ 'id', '=', $id ] ]);
}
}
/**
* 修改排序
*/
public function modifySort()
{
if (request()->isJson()) {
$sort = input('sort', 0);
$help_id = input('help_id', 0);
$help_model = new HelpModel();
return $help_model->modifyHelpSort($sort, $help_id);
}
}
/**
* 推广
* @return array
*/
public function promote()
{
if (request()->isJson()) {
$help_id = input('help_id', 0);
$app_type = input('app_type', 'all');
$help_model = new HelpModel();
$help_info = $help_model->getHelpInfo($help_id, 'id')[ 'data' ];
if (!empty($help_info)) {
$res = $help_model->urlQrcode([ 'id' => $help_id ], $app_type, $this->site_id);
return $res;
}
}
}
<?php
namespace app\shop\controller;
use app\model\web\Help as HelpModel;
/**
* 网站帮助
*/
class Help extends BaseShop
{
/**
* 分类列表
*/
public function classList()
{
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 ] ];
$condition[] = [ 'class_name', 'like', '%' . $search_text . '%' ];
$condition[] = [ 'app_module', '=', $this->app_module ];
$field = '*';
//排序
$link_sort = input('order', 'sort');
$sort = input('sort', 'desc');
if ($link_sort == 'sort') {
$order_by = $link_sort . ' ' . $sort;
} else {
$order_by = $link_sort . ' ' . $sort . ',sort desc';
}
$help_model = new HelpModel();
return $help_model->getHelpClassPageList($condition, $page, $page_size, $order_by, $field);
} else {
return $this->fetch('help/class_list');
}
}
/**
* 分类添加
*/
public function addClass()
{
if (request()->isJson()) {
$data = [
'site_id' => $this->site_id,
'app_module' => $this->app_module,
'class_name' => input('class_name', ''),
'sort' => input('sort', 0),
];
$help_model = new HelpModel();
return $help_model->addHelpClass($data);
} else {
return $this->fetch('help/add_class');
}
}
/**
* 分类编辑
*/
public function editClass()
{
$help_model = new HelpModel();
if (request()->isJson()) {
$data = [
'site_id' => $this->site_id,
'app_module' => $this->app_module,
'class_name' => input('class_name', ''),
'sort' => input('sort', 0),
];
$class_id = input('class_id', 0);
return $help_model->editHelpClass($data, $class_id);
} else {
$class_id = input('class_id', 0);
$this->assign('class_id', $class_id);
//帮助详情
$class_info = $help_model->getHelpClassInfo([ [ 'class_id', '=', $class_id ], [ 'site_id', '=', $this->site_id ], [ 'app_module', '=', $this->app_module ] ]);
$this->assign('class_info', $class_info);
return $this->fetch('help/edit_class');
}
}
/**
* 分类删除
*/
public function deleteClass()
{
if (request()->isJson()) {
$class_id = input('class_id', 0);
$help_model = new HelpModel();
return $help_model->deleteHelpClass([ [ 'class_id', '=', $class_id ] ]);
}
}
/**
* 修改分类排序
*/
public function modifyClassSort()
{
if (request()->isJson()) {
$sort = input('sort', 0);
$class_id = input('class_id', 0);
$help_model = new HelpModel();
return $help_model->modifyHelpClassSort($sort, $class_id);
}
}
/**
* 帮助列表
*/
public function helpList()
{
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 ] ];
$condition[] = [ 'title', 'like', '%' . $search_text . '%' ];
$condition[] = [ 'app_module', '=', $this->app_module ];
$field = 'id,title,class_id,class_name,sort,create_time';
//排序
$link_sort = input('order', 'sort');
$sort = input('sort', 'desc');
if ($link_sort == 'sort') {
$order_by = $link_sort . ' ' . $sort;
} else {
$order_by = $link_sort . ' ' . $sort . ',sort desc';
}
$help_model = new HelpModel();
return $help_model->getHelpPageList($condition, $page, $page_size, $order_by, $field);
} else {
return $this->fetch('help/help_list');
}
}
/**
* 帮助添加
*/
public function addHelp()
{
$help_model = new HelpModel();
if (request()->isJson()) {
$data = [
'site_id' => $this->site_id,
'app_module' => $this->app_module,
'title' => input('title', ''),
'link_address' => input('link_address', ''),
'content' => input('content', ''),
'class_id' => input('class_id', ''),
'class_name' => input('class_name', ''),
'sort' => input('sort', ''),
'create_time' => time(),
];
return $help_model->addHelp($data);
} else {
//帮助分类
$help_class_list = $help_model->getHelpClassList([ [ 'app_module', '=', $this->app_module ], [ 'site_id', '=', $this->site_id ] ], 'class_id, class_name');
$this->assign('help_class_list', $help_class_list[ 'data' ]);
return $this->fetch('help/add_help');
}
}
/**
* 帮助编辑
*/
public function editHelp()
{
$id = input('id', 0);
$help_model = new HelpModel();
if (request()->isJson()) {
$data = [
'site_id' => $this->site_id,
'app_module' => $this->app_module,
'title' => input('title', ''),
'link_address' => input('link_address', ''),
'content' => input('content', ''),
'class_id' => input('class_id', ''),
'class_name' => input('class_name', ''),
'sort' => input('sort', ''),
'modify_time' => time(),
];
return $help_model->editHelp($data, [ [ 'id', '=', $id ] ]);
} else {
$this->assign('id', $id);
$help_info = $help_model->getHelpInfo($id);
$this->assign('help_info', $help_info[ 'data' ]);
//帮助分类
$help_class_list = $help_model->getHelpClassList([ [ 'app_module', '=', $this->app_module ], [ 'site_id', '=', $this->site_id ] ], 'class_id, class_name');
$this->assign('help_class_list', $help_class_list[ 'data' ]);
return $this->fetch('help/edit_help');
}
}
/**
* 帮助删除
*/
public function deleteHelp()
{
if (request()->isJson()) {
$id = input('id', 0);
$help_model = new HelpModel();
return $help_model->deleteHelp([ [ 'id', '=', $id ] ]);
}
}
/**
* 修改排序
*/
public function modifySort()
{
if (request()->isJson()) {
$sort = input('sort', 0);
$help_id = input('help_id', 0);
$help_model = new HelpModel();
return $help_model->modifyHelpSort($sort, $help_id);
}
}
/**
* 推广
* @return array
*/
public function promote()
{
if (request()->isJson()) {
$help_id = input('help_id', 0);
$app_type = input('app_type', 'all');
$help_model = new HelpModel();
$help_info = $help_model->getHelpInfo($help_id, 'id')[ 'data' ];
if (!empty($help_info)) {
$res = $help_model->urlQrcode([ 'id' => $help_id ], $app_type, $this->site_id);
return $res;
}
}
}
}

View File

@@ -1,199 +1,191 @@
<?php
/**
*/
namespace app\shop\controller;
use app\model\express\ExpressDeliver;
use app\model\express\Local as LocalModel;
use app\model\shop\Shop as ShopModel;
use app\model\system\Address as AddressModel;
use app\model\web\Config as WebConfig;
use app\model\store\Store;
/**
* 配送
* Class Express
* @package app\shop\controller
*/
class Local extends BaseShop
{
/**
* 本地配送设置
*/
public function local()
{
$shop_model = new ShopModel();
$shop_info = $shop_model->getShopInfo([ [ 'site_id', '=', $this->site_id ] ])[ 'data' ];
$local_model = new LocalModel();
$store = new Store();
$default_store = $store->getStoreInfo([ [ 'site_id', '=', $this->site_id ], [ 'is_default', '=', 1 ] ], 'store_id')[ 'data' ] ?? [];
$store_id = $default_store[ 'store_id' ] ?? 0;
if (request()->isJson()) {
if (empty($shop_info)) {
return $local_model->error([], '店铺地址尚为配置');
}
$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 = array (
[ 'site_id', '=', $this->site_id ],
[ 'store_id', '=', $store_id ]
);
return $local_model->editLocal($data, $condition);
} else {
if (empty($shop_info)) {
$this->error('店铺地址尚为配置');
}
$this->assign('shop_detail', $shop_info);
$local_result = $local_model->getLocalInfo([ [ 'site_id', '=', $this->site_id ], [ 'store_id', '=', $store_id ] ]);
$district_list = [];
if ($shop_info[ 'province' ] > 0 && $shop_info[ 'city' ] > 0) {
//查询省级数据列表
$address_model = new AddressModel();
$list = $address_model->getAreaList([ ['pid', '=', $shop_info[ 'city' ] ], ['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);
return $this->fetch('local/local');
}
}
/**
* 配送员列表
*/
public function deliverLists()
{
$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
]
];
$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 {
return $this->fetch('local/deliverlists');
}
}
/**
* 添加配送员
*/
public function addDeliver()
{
$deliver_model = new ExpressDeliver();
if (request()->isJson()) {
$data = [
'deliver_name' => input('deliver_name', ''),
'deliver_mobile' => input('deliver_mobile', ''),
'store_id' => input('store_id', 0),
'site_id' => $this->site_id,
];
$result = $deliver_model->addDeliver($data);
return $result;
} else {
return $this->fetch('local/adddeliver');
}
}
/**
* 编辑配送员
*/
public function editDeliver()
{
$deliver_model = new ExpressDeliver();
$deliver_id = input('deliver_id', 0);
$site_id = $this->site_id;
if (request()->isJson()) {
$data = [
'deliver_name' => input('deliver_name', ''),
'deliver_mobile' => input('deliver_mobile', ''),
'site_id' => $site_id,
];
$result = $deliver_model->editDeliver($data, $deliver_id);
return $result;
} else {
$this->assign('deliver_id', $deliver_id);
$deliver_info = $deliver_model->getDeliverInfo($deliver_id, $site_id);
$this->assign('deliver_info', $deliver_info[ 'data' ]);
return $this->fetch('local/editdeliver');
}
}
/**
* 删除配送员
*/
public function deleteDeliver()
{
$deliver_model = new ExpressDeliver();
if (request()->isJson()) {
$deliver_ids = input('deliver_ids', 0);
$site_id = $this->site_id;
$result = $deliver_model->deleteDeliver($deliver_ids, $site_id);
return $result;
}
}
/**
* 获取配送员
*/
public function getDeliverList()
{
$deliver_model = new ExpressDeliver();
$list = $deliver_model->getDeliverLists([ [ 'site_id', '=', $this->site_id ] ]);
return $list;
}
<?php
namespace app\shop\controller;
use app\model\express\ExpressDeliver;
use app\model\express\Local as LocalModel;
use app\model\shop\Shop as ShopModel;
use app\model\system\Address as AddressModel;
use app\model\web\Config as WebConfig;
use app\model\store\Store;
/**
* 配送
* Class Express
* @package app\shop\controller
*/
class Local extends BaseShop
{
/**
* 本地配送设置
*/
public function local()
{
$shop_model = new ShopModel();
$shop_info = $shop_model->getShopInfo([ [ 'site_id', '=', $this->site_id ] ])[ 'data' ];
$local_model = new LocalModel();
$store = new Store();
$default_store = $store->getStoreInfo([ [ 'site_id', '=', $this->site_id ], [ 'is_default', '=', 1 ] ], 'store_id')[ 'data' ] ?? [];
$store_id = $default_store[ 'store_id' ] ?? 0;
if (request()->isJson()) {
if (empty($shop_info)) {
return $local_model->error([], '店铺地址尚为配置');
}
$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 = array (
[ 'site_id', '=', $this->site_id ],
[ 'store_id', '=', $store_id ]
);
return $local_model->editLocal($data, $condition);
} else {
if (empty($shop_info)) {
$this->error('店铺地址尚为配置');
}
$this->assign('shop_detail', $shop_info);
$local_result = $local_model->getLocalInfo([ [ 'site_id', '=', $this->site_id ], [ 'store_id', '=', $store_id ] ]);
$district_list = [];
if ($shop_info[ 'province' ] > 0 && $shop_info[ 'city' ] > 0) {
//查询省级数据列表
$address_model = new AddressModel();
$list = $address_model->getAreaList([ ['pid', '=', $shop_info[ 'city' ] ], ['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);
return $this->fetch('local/local');
}
}
/**
* 配送员列表
*/
public function deliverLists()
{
$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
]
];
$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 {
return $this->fetch('local/deliverlists');
}
}
/**
* 添加配送员
*/
public function addDeliver()
{
$deliver_model = new ExpressDeliver();
if (request()->isJson()) {
$data = [
'deliver_name' => input('deliver_name', ''),
'deliver_mobile' => input('deliver_mobile', ''),
'store_id' => input('store_id', 0),
'site_id' => $this->site_id,
];
$result = $deliver_model->addDeliver($data);
return $result;
} else {
return $this->fetch('local/adddeliver');
}
}
/**
* 编辑配送员
*/
public function editDeliver()
{
$deliver_model = new ExpressDeliver();
$deliver_id = input('deliver_id', 0);
$site_id = $this->site_id;
if (request()->isJson()) {
$data = [
'deliver_name' => input('deliver_name', ''),
'deliver_mobile' => input('deliver_mobile', ''),
'site_id' => $site_id,
];
$result = $deliver_model->editDeliver($data, $deliver_id);
return $result;
} else {
$this->assign('deliver_id', $deliver_id);
$deliver_info = $deliver_model->getDeliverInfo($deliver_id, $site_id);
$this->assign('deliver_info', $deliver_info[ 'data' ]);
return $this->fetch('local/editdeliver');
}
}
/**
* 删除配送员
*/
public function deleteDeliver()
{
$deliver_model = new ExpressDeliver();
if (request()->isJson()) {
$deliver_ids = input('deliver_ids', 0);
$site_id = $this->site_id;
$result = $deliver_model->deleteDeliver($deliver_ids, $site_id);
return $result;
}
}
/**
* 获取配送员
*/
public function getDeliverList()
{
$deliver_model = new ExpressDeliver();
$list = $deliver_model->getDeliverLists([ [ 'site_id', '=', $this->site_id ] ]);
return $list;
}
}

View File

@@ -1,145 +1,137 @@
<?php
/**
*/
namespace app\shop\controller;
use app\model\order\OrderCommon as OrderCommonModel;
use app\model\order\LocalOrder as LocalOrderModel;
use think\facade\Config;
use app\model\system\Promotion as PromotionModel;
/**
* 外卖订单
* Class Localorder
* @package app\shop\controller
*/
class Localorder extends BaseShop
{
/**
* 快递订单列表
*/
public function lists()
{
$order_label_list = array (
'order_no' => '订单号',
'out_trade_no' => '外部单号',
'name' => '收货人姓名',
'order_name' => '商品名称',
'mobile' => '收货人电话',
);
$order_status = input('order_status', '');//订单状态
$order_name = input('order_name', '');
$pay_type = input('pay_type', '');
$order_from = input('order_from', '');
$start_time = input('start_time', '');
$end_time = input('end_time', '');
$order_label = !empty($order_label_list[ input('order_label') ]) ? input('order_label') : '';
$search_text = input('search', '');
$promotion_type = input('promotion_type', '');
$order_common_model = new OrderCommonModel();
if (request()->isJson()) {
$page_index = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$condition = [
['order_type', '=', 3 ],
['site_id', '=', $this->site_id ]
];
//订单状态
if ($order_status != '') {
$condition[] = ['order_status', '=', $order_status ];
}
//订单内容 模糊查询
if ($order_name != '') {
$condition[] = ['order_name', 'like', "%$order_name%" ];
}
//订单来源
if ($order_from != '') {
$condition[] = ['order_from', '=', $order_from ];
}
//订单支付
if ($pay_type != '') {
$condition[] = ['pay_type', '=', $pay_type ];
}
//营销类型
if ($promotion_type != '') {
if ($promotion_type == 'empty') {
$condition[] = ['promotion_type', '=', '' ];
} else {
$condition[] = ['promotion_type', '=', $promotion_type ];
}
}
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) ] ];
}
if ($search_text != '') {
$condition[] = [ $order_label, 'like', "%$search_text%" ];
}
$list = $order_common_model->getOrderPageList($condition, $page_index, $page_size, 'create_time desc');
return $list;
} else {
$this->assign('order_label_list', $order_label_list);
$order_model = new LocalOrderModel();
$order_status_list = $order_model->order_status;
$this->assign('order_status_list', $order_status_list);//订单状态
//订单来源 (支持端口)
$order_from = Config::get('app_type');
$this->assign('order_from_list', $order_from);
$pay_type = $order_common_model->getPayType();
$this->assign('pay_type_list', $pay_type);
//营销活动类型
$promotion_model = new PromotionModel();
$promotion_type = $promotion_model->getPromotionType();
$this->assign('promotion_type', $promotion_type);
return $this->fetch('localorder/lists');
}
}
/**
* 订单详情
* @return mixed
*/
public function detail()
{
$order_id = input('order_id', 0);
$order_common_model = new OrderCommonModel();
$order_detail_result = $order_common_model->getOrderDetail($order_id);
$order_detail = $order_detail_result['data'];
$this->assign('order_detail', $order_detail);
return $this->fetch('localorder/detail');
}
/**
* 发货
*/
public function delivery()
{
$order_id = input('order_id', 0);
$deliverer = input('deliverer', '');
$deliverer_mobile = input('deliverer_mobile', '');
$local_order_model = new LocalOrderModel();
$data = [
'order_id' => $order_id,
'deliverer' => $deliverer,
'deliverer_mobile' => $deliverer_mobile,
'site_id' => $this->site_id,
'user_info' => $this->user_info
];
$result = $local_order_model->orderGoodsDelivery($data);
return $result;
}
<?php
namespace app\shop\controller;
use app\model\order\OrderCommon as OrderCommonModel;
use app\model\order\LocalOrder as LocalOrderModel;
use think\facade\Config;
use app\model\system\Promotion as PromotionModel;
/**
* 外卖订单
* Class Localorder
* @package app\shop\controller
*/
class Localorder extends BaseShop
{
/**
* 快递订单列表
*/
public function lists()
{
$order_label_list = array (
'order_no' => '订单号',
'out_trade_no' => '外部单号',
'name' => '收货人姓名',
'order_name' => '商品名称',
'mobile' => '收货人电话',
);
$order_status = input('order_status', '');//订单状态
$order_name = input('order_name', '');
$pay_type = input('pay_type', '');
$order_from = input('order_from', '');
$start_time = input('start_time', '');
$end_time = input('end_time', '');
$order_label = !empty($order_label_list[ input('order_label') ]) ? input('order_label') : '';
$search_text = input('search', '');
$promotion_type = input('promotion_type', '');
$order_common_model = new OrderCommonModel();
if (request()->isJson()) {
$page_index = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$condition = [
['order_type', '=', 3 ],
['site_id', '=', $this->site_id ]
];
//订单状态
if ($order_status != '') {
$condition[] = ['order_status', '=', $order_status ];
}
//订单内容 模糊查询
if ($order_name != '') {
$condition[] = ['order_name', 'like', "%$order_name%" ];
}
//订单来源
if ($order_from != '') {
$condition[] = ['order_from', '=', $order_from ];
}
//订单支付
if ($pay_type != '') {
$condition[] = ['pay_type', '=', $pay_type ];
}
//营销类型
if ($promotion_type != '') {
if ($promotion_type == 'empty') {
$condition[] = ['promotion_type', '=', '' ];
} else {
$condition[] = ['promotion_type', '=', $promotion_type ];
}
}
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) ] ];
}
if ($search_text != '') {
$condition[] = [ $order_label, 'like', "%$search_text%" ];
}
$list = $order_common_model->getOrderPageList($condition, $page_index, $page_size, 'create_time desc');
return $list;
} else {
$this->assign('order_label_list', $order_label_list);
$order_model = new LocalOrderModel();
$order_status_list = $order_model->order_status;
$this->assign('order_status_list', $order_status_list);//订单状态
//订单来源 (支持端口)
$order_from = Config::get('app_type');
$this->assign('order_from_list', $order_from);
$pay_type = $order_common_model->getPayType();
$this->assign('pay_type_list', $pay_type);
//营销活动类型
$promotion_model = new PromotionModel();
$promotion_type = $promotion_model->getPromotionType();
$this->assign('promotion_type', $promotion_type);
return $this->fetch('localorder/lists');
}
}
/**
* 订单详情
* @return mixed
*/
public function detail()
{
$order_id = input('order_id', 0);
$order_common_model = new OrderCommonModel();
$order_detail_result = $order_common_model->getOrderDetail($order_id);
$order_detail = $order_detail_result['data'];
$this->assign('order_detail', $order_detail);
return $this->fetch('localorder/detail');
}
/**
* 发货
*/
public function delivery()
{
$order_id = input('order_id', 0);
$deliverer = input('deliverer', '');
$deliverer_mobile = input('deliverer_mobile', '');
$local_order_model = new LocalOrderModel();
$data = [
'order_id' => $order_id,
'deliverer' => $deliverer,
'deliverer_mobile' => $deliverer_mobile,
'site_id' => $this->site_id,
'user_info' => $this->user_info
];
$result = $local_order_model->orderGoodsDelivery($data);
return $result;
}
}

View File

@@ -1,221 +1,213 @@
<?php
/**
*/
namespace app\shop\controller;
use addon\coupon\model\Coupon;
use app\model\account\Point;
use app\model\member\Member as MemberModel;
use app\model\member\MemberAccount as MemberAccountModel;
/**
* 会员账户管理 控制器
*/
class Memberaccount extends BaseShop
{
/*
* 会员积分
*/
public function point()
{
//账户类型和来源类型
$member_account_model = new MemberAccountModel();
$from_type = $member_account_model->getFromType();
$this->assign('from_type', $from_type[ 'point' ]);
$total_usable_point = ( new MemberModel() )->getMemberSum([ [ 'site_id', '=', $this->site_id ], [ 'is_delete', '=', 0 ] ], 'point')[ 'data' ];
$this->assign('total_usable_point', round($total_usable_point));
$grant_point = $member_account_model->getMemberAccountSum([ [ 'site_id', '=', $this->site_id ], [ 'account_type', '=', 'point' ], [ 'account_data', '>', 0 ] ], 'account_data')[ 'data' ];
$this->assign('grant_point', round($grant_point));
$consume_point = $member_account_model->getMemberAccountSum([ [ 'site_id', '=', $this->site_id ], [ 'account_type', '=', 'point' ], [ 'account_data', '<', 0 ] ], 'account_data')[ 'data' ];
$this->assign('consume_point', abs(round($consume_point)));
return $this->fetch('account/point');
}
/**
* 积分规则
* @return mixed
*/
public function pointConfig()
{
//账户类型和来源类型
$member_account_model = new MemberAccountModel();
$total_usable_point = ( new MemberModel() )->getMemberSum([ [ 'site_id', '=', $this->site_id ], [ 'is_delete', '=', 0 ] ], 'point')[ 'data' ];
$this->assign('total_usable_point', round($total_usable_point));
$grant_point = $member_account_model->getMemberAccountSum([ [ 'site_id', '=', $this->site_id ], [ 'account_type', '=', 'point' ], [ 'account_data', '>', 0 ] ], 'account_data')[ 'data' ];
$this->assign('grant_point', round($grant_point));
$consume_point = $member_account_model->getMemberAccountSum([ [ 'site_id', '=', $this->site_id ], [ 'account_type', '=', 'point' ], [ 'account_data', '<', 0 ] ], 'account_data')[ 'data' ];
$this->assign('consume_point', abs(round($consume_point)));
$rule = event('PointRule', [ 'site_id' => $this->site_id ]);
$this->assign('rule', $rule);
return $this->fetch('account/point_config');
}
/**
* 会员余额
*/
public function balance()
{
$member_account_model = new MemberAccountModel();
$from_type = $member_account_model->getFromType();
$this->assign('from_type', array_merge($from_type[ 'balance' ], $from_type[ 'balance_money' ]));
$member_model = new MemberModel();
$total_balance = $member_model->getMemberSum([ [ 'site_id', '=', $this->site_id ], [ 'is_delete', '=', 0 ] ], 'balance')[ 'data' ];
$this->assign('total_balance', sprintf('%.2f', $total_balance));
$total_balance_money = $member_model->getMemberSum([ [ 'site_id', '=', $this->site_id ], [ 'is_delete', '=', 0 ] ], 'balance_money')[ 'data' ];
$this->assign('total_balance_money', sprintf('%.2f', $total_balance_money));
$total_consume_money = $member_account_model->getMemberAccountSum([ [ 'site_id', '=', $this->site_id ], [ 'account_type', 'in', [ 'balance', 'balance_money' ] ], [ 'account_data', '<', 0 ], [ 'from_type', '<>', 'adjust' ] ], 'account_data')[ 'data' ];
$this->assign('total_consume_money', sprintf('%.2f', abs($total_consume_money)));
return $this->fetch('account/balance');
}
/**
* 会员成长值
*/
public function growth()
{
$member_account_model = new MemberAccountModel();
$from_type = $member_account_model->getFromType();
$this->assign('from_type', $from_type[ 'growth' ]);
return $this->fetch('account/growth');
}
/**
* 会员优惠券
*/
public function coupon()
{
$model = new Coupon();
if (request()->isJson()) {
$page = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$start_date = input('start_time', '');
$end_date = input('end_time', '');
$search_text = input('search_text', '');
$get_type = input('get_type', '');
$state = input('state', '');
$condition[] = [ 'c.site_id', '=', $this->site_id ];
if ($start_date != '' && $end_date != '') {
$condition[] = [ 'c.fetch_time', 'between', [ strtotime($start_date), strtotime($end_date) ] ];
} else if ($start_date != '' && $end_date == '') {
$condition[] = [ 'c.fetch_time', '>=', strtotime($start_date) ];
} else if ($start_date == '' && $end_date != '') {
$condition[] = [ 'c.fetch_time', '<=', strtotime($end_date) ];
}
if ($search_text) {
$condition[] = [ 'm.nickname|m.mobile', 'like', '%' . $search_text . '%' ];
}
if ($get_type) {
$condition[] = [ 'get_type', '=', $get_type ];
}
if ($state) {
$condition[] = [ 'state', '=', $state ];
}
$join = [
[ 'member m', 'm.member_id = c.member_id', 'inner' ]
];
$field = 'c.*,m.nickname,m.headimg,m.mobile';
return $model->getCouponPageList($condition, $page, $page_size, 'c.fetch_time desc', $field, 'c', $join);
} else {
$total_count = $model->getMemberCouponCount([ [ 'site_id', '=', $this->site_id ] ])[ 'data' ];
$this->assign('total_count', $total_count);
$used_count = $model->getMemberCouponCount([ [ 'site_id', '=', $this->site_id ], [ 'state', '=', 2 ] ])[ 'data' ];
$this->assign('used_count', $used_count);
$not_used_count = $model->getMemberCouponCount([ [ 'site_id', '=', $this->site_id ], [ 'state', '=', 1 ] ])[ 'data' ];
$this->assign('not_used_count', $not_used_count);
$this->assign('get_type', $model->getCouponGetType());
return $this->fetch('account/coupon');
}
}
/**
* 账户详情
*/
public function accountDetail()
{
if (request()->isJson()) {
$page = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$account_type = input('account_type', '');
$from_type = input('from_type', '');
$start_date = input('start_time', '');
$end_date = input('end_time', '');
$search_text = input('search_text', '');
$condition[] = [ 'ma.site_id', '=', $this->site_id ];
//账户类型
if ($account_type != '') {
$condition[] = [ 'ma.account_type', 'in', explode(',', $account_type) ];
}
//来源类型
if ($from_type != '') {
$condition[] = [ 'from_type', '=', $from_type ];
}
//发生时间
if ($start_date != '' && $end_date != '') {
$condition[] = [ 'ma.create_time', 'between', [ strtotime($start_date), strtotime($end_date) ] ];
} else if ($start_date != '' && $end_date == '') {
$condition[] = [ 'ma.create_time', '>=', strtotime($start_date) ];
} else if ($start_date == '' && $end_date != '') {
$condition[] = [ 'ma.create_time', '<=', strtotime($end_date) ];
}
if ($search_text) {
$condition[] = [ 'm.nickname|m.mobile', 'like', '%' . $search_text . '%' ];
}
$field = 'ma.*,m.nickname,m.headimg,m.mobile';
$join = [
[ 'member m', 'm.member_id = ma.member_id', 'left' ]
];
$member_account_model = new MemberAccountModel();
$res = $member_account_model->getMemberAccountPageList($condition, $page, $page_size, 'ma.create_time desc', $field, 'ma', $join);
return $res;
}
}
/**
* 积分清零
*/
public function pointClear()
{
$point_model = new Point();
$result = $point_model->pointClear([ 'site_id' => $this->site_id, 'remark' => input('remark', '') ]);
return $result;
}
/**
* 积分重置
*/
public function pointReset()
{
$point_model = new Point();
$result = $point_model->pointReset([ 'site_id' => $this->site_id ]);
return $result;
}
<?php
namespace app\shop\controller;
use addon\coupon\model\Coupon;
use app\model\account\Point;
use app\model\member\Member as MemberModel;
use app\model\member\MemberAccount as MemberAccountModel;
/**
* 会员账户管理 控制器
*/
class Memberaccount extends BaseShop
{
/*
* 会员积分
*/
public function point()
{
//账户类型和来源类型
$member_account_model = new MemberAccountModel();
$from_type = $member_account_model->getFromType();
$this->assign('from_type', $from_type[ 'point' ]);
$total_usable_point = ( new MemberModel() )->getMemberSum([ [ 'site_id', '=', $this->site_id ], [ 'is_delete', '=', 0 ] ], 'point')[ 'data' ];
$this->assign('total_usable_point', round($total_usable_point));
$grant_point = $member_account_model->getMemberAccountSum([ [ 'site_id', '=', $this->site_id ], [ 'account_type', '=', 'point' ], [ 'account_data', '>', 0 ] ], 'account_data')[ 'data' ];
$this->assign('grant_point', round($grant_point));
$consume_point = $member_account_model->getMemberAccountSum([ [ 'site_id', '=', $this->site_id ], [ 'account_type', '=', 'point' ], [ 'account_data', '<', 0 ] ], 'account_data')[ 'data' ];
$this->assign('consume_point', abs(round($consume_point)));
return $this->fetch('account/point');
}
/**
* 积分规则
* @return mixed
*/
public function pointConfig()
{
//账户类型和来源类型
$member_account_model = new MemberAccountModel();
$total_usable_point = ( new MemberModel() )->getMemberSum([ [ 'site_id', '=', $this->site_id ], [ 'is_delete', '=', 0 ] ], 'point')[ 'data' ];
$this->assign('total_usable_point', round($total_usable_point));
$grant_point = $member_account_model->getMemberAccountSum([ [ 'site_id', '=', $this->site_id ], [ 'account_type', '=', 'point' ], [ 'account_data', '>', 0 ] ], 'account_data')[ 'data' ];
$this->assign('grant_point', round($grant_point));
$consume_point = $member_account_model->getMemberAccountSum([ [ 'site_id', '=', $this->site_id ], [ 'account_type', '=', 'point' ], [ 'account_data', '<', 0 ] ], 'account_data')[ 'data' ];
$this->assign('consume_point', abs(round($consume_point)));
$rule = event('PointRule', [ 'site_id' => $this->site_id ]);
$this->assign('rule', $rule);
return $this->fetch('account/point_config');
}
/**
* 会员余额
*/
public function balance()
{
$member_account_model = new MemberAccountModel();
$from_type = $member_account_model->getFromType();
$this->assign('from_type', array_merge($from_type[ 'balance' ], $from_type[ 'balance_money' ]));
$member_model = new MemberModel();
$total_balance = $member_model->getMemberSum([ [ 'site_id', '=', $this->site_id ], [ 'is_delete', '=', 0 ] ], 'balance')[ 'data' ];
$this->assign('total_balance', sprintf('%.2f', $total_balance));
$total_balance_money = $member_model->getMemberSum([ [ 'site_id', '=', $this->site_id ], [ 'is_delete', '=', 0 ] ], 'balance_money')[ 'data' ];
$this->assign('total_balance_money', sprintf('%.2f', $total_balance_money));
$total_consume_money = $member_account_model->getMemberAccountSum([ [ 'site_id', '=', $this->site_id ], [ 'account_type', 'in', [ 'balance', 'balance_money' ] ], [ 'account_data', '<', 0 ], [ 'from_type', '<>', 'adjust' ] ], 'account_data')[ 'data' ];
$this->assign('total_consume_money', sprintf('%.2f', abs($total_consume_money)));
return $this->fetch('account/balance');
}
/**
* 会员成长值
*/
public function growth()
{
$member_account_model = new MemberAccountModel();
$from_type = $member_account_model->getFromType();
$this->assign('from_type', $from_type[ 'growth' ]);
return $this->fetch('account/growth');
}
/**
* 会员优惠券
*/
public function coupon()
{
$model = new Coupon();
if (request()->isJson()) {
$page = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$start_date = input('start_time', '');
$end_date = input('end_time', '');
$search_text = input('search_text', '');
$get_type = input('get_type', '');
$state = input('state', '');
$condition[] = [ 'c.site_id', '=', $this->site_id ];
if ($start_date != '' && $end_date != '') {
$condition[] = [ 'c.fetch_time', 'between', [ strtotime($start_date), strtotime($end_date) ] ];
} else if ($start_date != '' && $end_date == '') {
$condition[] = [ 'c.fetch_time', '>=', strtotime($start_date) ];
} else if ($start_date == '' && $end_date != '') {
$condition[] = [ 'c.fetch_time', '<=', strtotime($end_date) ];
}
if ($search_text) {
$condition[] = [ 'm.nickname|m.mobile', 'like', '%' . $search_text . '%' ];
}
if ($get_type) {
$condition[] = [ 'get_type', '=', $get_type ];
}
if ($state) {
$condition[] = [ 'state', '=', $state ];
}
$join = [
[ 'member m', 'm.member_id = c.member_id', 'inner' ]
];
$field = 'c.*,m.nickname,m.headimg,m.mobile';
return $model->getCouponPageList($condition, $page, $page_size, 'c.fetch_time desc', $field, 'c', $join);
} else {
$total_count = $model->getMemberCouponCount([ [ 'site_id', '=', $this->site_id ] ])[ 'data' ];
$this->assign('total_count', $total_count);
$used_count = $model->getMemberCouponCount([ [ 'site_id', '=', $this->site_id ], [ 'state', '=', 2 ] ])[ 'data' ];
$this->assign('used_count', $used_count);
$not_used_count = $model->getMemberCouponCount([ [ 'site_id', '=', $this->site_id ], [ 'state', '=', 1 ] ])[ 'data' ];
$this->assign('not_used_count', $not_used_count);
$this->assign('get_type', $model->getCouponGetType());
return $this->fetch('account/coupon');
}
}
/**
* 账户详情
*/
public function accountDetail()
{
if (request()->isJson()) {
$page = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$account_type = input('account_type', '');
$from_type = input('from_type', '');
$start_date = input('start_time', '');
$end_date = input('end_time', '');
$search_text = input('search_text', '');
$condition[] = [ 'ma.site_id', '=', $this->site_id ];
//账户类型
if ($account_type != '') {
$condition[] = [ 'ma.account_type', 'in', explode(',', $account_type) ];
}
//来源类型
if ($from_type != '') {
$condition[] = [ 'from_type', '=', $from_type ];
}
//发生时间
if ($start_date != '' && $end_date != '') {
$condition[] = [ 'ma.create_time', 'between', [ strtotime($start_date), strtotime($end_date) ] ];
} else if ($start_date != '' && $end_date == '') {
$condition[] = [ 'ma.create_time', '>=', strtotime($start_date) ];
} else if ($start_date == '' && $end_date != '') {
$condition[] = [ 'ma.create_time', '<=', strtotime($end_date) ];
}
if ($search_text) {
$condition[] = [ 'm.nickname|m.mobile', 'like', '%' . $search_text . '%' ];
}
$field = 'ma.*,m.nickname,m.headimg,m.mobile';
$join = [
[ 'member m', 'm.member_id = ma.member_id', 'left' ]
];
$member_account_model = new MemberAccountModel();
$res = $member_account_model->getMemberAccountPageList($condition, $page, $page_size, 'ma.create_time desc', $field, 'ma', $join);
return $res;
}
}
/**
* 积分清零
*/
public function pointClear()
{
$point_model = new Point();
$result = $point_model->pointClear([ 'site_id' => $this->site_id, 'remark' => input('remark', '') ]);
return $result;
}
/**
* 积分重置
*/
public function pointReset()
{
$point_model = new Point();
$result = $point_model->pointReset([ 'site_id' => $this->site_id ]);
return $result;
}
}

View File

@@ -1,319 +1,311 @@
<?php
/**
*/
namespace app\shop\controller;
use app\model\member\MemberCluster as MemberClusterModel;
use app\model\member\Member as MemberModel;
use app\model\member\MemberLevel as MemberLevelModel;
use app\model\member\MemberLabel as MemberLabelModel;
/**
* 会员群体管理 控制器
*/
class Membercluster extends BaseShop
{
/**
* 会员群体列表
* @return array|mixed
*/
public function clusterList()
{
$member_cluster_model = new MemberClusterModel();
if (request()->isJson()) {
$page = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$cluster_name = input('cluster_name', '');
$start_date = input('start_date', '');
$end_date = input('end_date', '');
$condition[] = [ 'site_id', '=', $this->site_id ];
if(!empty($cluster_name))
{
$condition[] = [ 'cluster_name', 'like', '%' . $cluster_name . '%'];
}
//更新时间
if ($start_date != '' && $end_date != '') {
$condition[] = [ 'update_time', 'between', [ strtotime($start_date), strtotime($end_date) ] ];
} else if ($start_date != '' && $end_date == '') {
$condition[] = [ 'update_time', '>=', strtotime($start_date) ];
} else if ($start_date == '' && $end_date != '') {
$condition[] = [ 'update_time', '<=', strtotime($end_date) ];
}
$order = 'create_time desc';
$field = '*';
$list = $member_cluster_model->getMemberClusterPageList($condition, $page, $page_size, $order, $field);
return $list;
} else {
return $this->fetch('membercluster/cluster_list');
}
}
/**
* 添加会员群体
* @return array|mixed
*/
public function addCluster()
{
$member_cluster_model = new MemberClusterModel();
if (request()->isJson()) {
$data = [
'site_id' => $this->site_id,
'cluster_name' => input('cluster_name', ''),
'rule_json' => input('rule_json', ''),
'create_time' => time(),
'update_time' => time(),
];
return $member_cluster_model->addMemberCluster($data);
} else {
$basic_list = $member_cluster_model->basic;
$consume_list = $member_cluster_model->consume;
$promotion_list = $member_cluster_model->promotion;
$this->assign('basic_list', $basic_list);
$this->assign('consume_list', $consume_list);
$this->assign('promotion_list', $promotion_list);
//会员等级
$member_level_model = new MemberLevelModel();
$member_level_list = $member_level_model->getMemberLevelList([ [ 'site_id', '=', $this->site_id ] ], 'level_id, level_name', 'growth asc');
$this->assign('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');
$this->assign('member_label_list', $member_label_list[ 'data' ]);
return $this->fetch('membercluster/add_cluster');
}
}
/**
* 编辑会员群体
* @return array|mixed
*/
public function editCluster()
{
$member_cluster_model = new MemberClusterModel();
$cluster_id = input('cluster_id', 0);
if (request()->isJson()) {
$data = [
'site_id' => $this->site_id,
'cluster_name' => input('cluster_name', ''),
'rule_json' => input('rule_json', ''),
'update_time' => time(),
];
return $member_cluster_model->editMemberCluster($data, [ 'cluster_id' => $cluster_id ]);
} else {
$cluster_info = $member_cluster_model->getMemberClusterDetail([ [ 'cluster_id', '=', $cluster_id ] ]);
$this->assign('cluster_info', $cluster_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');
$this->assign('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');
$this->assign('member_label_list', $member_label_list[ 'data' ]);
return $this->fetch('membercluster/edit_cluster');
}
}
/**
* 删除会员群体
*/
public function deleteCluster()
{
$cluster_ids = input('cluster_ids', '');
$member_cluster_model = new MemberClusterModel();
return $member_cluster_model->deleteMemberCluster([ 'cluster_id' => $cluster_ids ]);
}
/**
* 刷新操作
* @return array|mixed
*/
public function refreshCluster()
{
if (request()->isJson()) {
$member_cluster_model = new MemberClusterModel();
return $member_cluster_model->refreshMemberCluster();
}
}
/**
* 导出会员
*/
public function exportClusterMember()
{
$member_cluster_model = new MemberClusterModel();
$cluster_id = input('cluster_id', 0);
$cluster_condition[] = [ 'site_id', '=', $this->site_id ];
$cluster_condition[] = [ 'cluster_id', '=', $cluster_id ];
$cluster_info = $member_cluster_model->getMemberClusterInfo($cluster_condition, 'member_ids,cluster_name');
$order = 'reg_time desc';
$field = 'username,nickname,realname,mobile,sex,birthday,email,member_level_name,member_label_name,
qq,location,balance,balance_money,point,growth,reg_time,last_login_ip,last_login_time';
$member_model = new MemberModel();
$condition[] = ['member_id', 'in', $cluster_info[ 'data' ]['member_ids'] ];
$condition[] = ['site_id', '=', $this->site_id ];
$list = $member_model->getMemberList($condition, $field, $order);
// 实例化excel
$phpExcel = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
$phpExcel->getProperties()->setTitle('会员信息');
$phpExcel->getProperties()->setSubject('会员信息');
// 对单元格设置居中效果
$phpExcel->getActiveSheet()->getStyle('A')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$phpExcel->getActiveSheet()->getStyle('B')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$phpExcel->getActiveSheet()->getStyle('C')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$phpExcel->getActiveSheet()->getStyle('D')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$phpExcel->getActiveSheet()->getStyle('E')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$phpExcel->getActiveSheet()->getStyle('F')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$phpExcel->getActiveSheet()->getStyle('G')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$phpExcel->getActiveSheet()->getStyle('H')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$phpExcel->getActiveSheet()->getStyle('I')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$phpExcel->getActiveSheet()->getStyle('J')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$phpExcel->getActiveSheet()->getStyle('K')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$phpExcel->getActiveSheet()->getStyle('L')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$phpExcel->getActiveSheet()->getStyle('M')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$phpExcel->getActiveSheet()->getStyle('N')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$phpExcel->getActiveSheet()->getStyle('O')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$phpExcel->getActiveSheet()->getStyle('P')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
//单独添加列名称
$phpExcel->setActiveSheetIndex(0);
$phpExcel->getActiveSheet()->setCellValue('A1', '会员账号');//可以指定位置
$phpExcel->getActiveSheet()->setCellValue('B1', '会员昵称');
$phpExcel->getActiveSheet()->setCellValue('C1', '真实姓名');
$phpExcel->getActiveSheet()->setCellValue('D1', '手机号');
$phpExcel->getActiveSheet()->setCellValue('E1', '性别');
$phpExcel->getActiveSheet()->setCellValue('F1', '生日');
$phpExcel->getActiveSheet()->setCellValue('G1', '会员等级');
$phpExcel->getActiveSheet()->setCellValue('H1', '会员标签');
$phpExcel->getActiveSheet()->setCellValue('I1', 'qq');
$phpExcel->getActiveSheet()->setCellValue('J1', '地址');
$phpExcel->getActiveSheet()->setCellValue('K1', '余额');
$phpExcel->getActiveSheet()->setCellValue('L1', '积分');
$phpExcel->getActiveSheet()->setCellValue('M1', '成长值');
$phpExcel->getActiveSheet()->setCellValue('N1', '上次登录时间');
$phpExcel->getActiveSheet()->setCellValue('O1', '上次登录ip');
$phpExcel->getActiveSheet()->setCellValue('P1', '注册时间');
//循环添加数据(根据自己的逻辑)
$sex = [ '保密', '男', '女' ];
foreach ($list[ 'data' ] as $k => $v) {
$i = $k + 2;
$phpExcel->getActiveSheet()->setCellValue('A' . $i, $v[ 'username' ]);
$phpExcel->getActiveSheet()->setCellValue('B' . $i, $v[ 'nickname' ]);
$phpExcel->getActiveSheet()->setCellValue('C' . $i, $v[ 'realname' ]);
$phpExcel->getActiveSheet()->setCellValue('D' . $i, $v[ 'mobile' ]);
$phpExcel->getActiveSheet()->setCellValue('E' . $i, $sex[ $v[ 'sex' ] ]);
$phpExcel->getActiveSheet()->setCellValue('F' . $i, date('Y-m-d', $v[ 'birthday' ]));
$phpExcel->getActiveSheet()->setCellValue('G' . $i, $v[ 'member_level_name' ]);
$phpExcel->getActiveSheet()->setCellValue('H' . $i, $v[ 'member_label_name' ]);
$phpExcel->getActiveSheet()->setCellValue('I' . $i, $v[ 'qq' ]);
$phpExcel->getActiveSheet()->setCellValue('J' . $i, $v[ 'location' ]);
$phpExcel->getActiveSheet()->setCellValue('K' . $i, $v[ 'balance' ] + $v[ 'balance_money' ]);
$phpExcel->getActiveSheet()->setCellValue('L' . $i, $v[ 'point' ]);
$phpExcel->getActiveSheet()->setCellValue('M' . $i, $v[ 'growth' ]);
$phpExcel->getActiveSheet()->setCellValue('N' . $i, date('Y-m-d H:i:s', $v[ 'last_login_time' ]));
$phpExcel->getActiveSheet()->setCellValue('O' . $i, $v[ 'last_login_ip' ]);
$phpExcel->getActiveSheet()->setCellValue('P' . $i, date('Y-m-d H:i:s', $v[ 'reg_time' ]));
}
// 重命名工作sheet
$phpExcel->getActiveSheet()->setTitle('会员信息');
// 设置第一个sheet为工作的sheet
$phpExcel->setActiveSheetIndex(0);
// 保存Excel 2007格式文件保存路径为当前路径名字为export.xlsx
$objWriter = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($phpExcel, 'Xlsx');
$file = date('Y年m月d日-会员信息表', time()) . '.xlsx';
$objWriter->save($file);
header('Content-type:application/octet-stream');
$filename = basename($file);
header('Content-Disposition:attachment;filename = ' . $filename);
header('Accept-ranges:bytes');
header('Accept-length:' . filesize($file));
readfile($file);
unlink($file);
exit;
}
/**
* 发放优惠券
*/
public function sendCoupon()
{
if (request()->isJson()) {
$member_cluster_model = new MemberClusterModel();
$cluster_id = input('cluster_id', 0);
$coupon_data = json_decode(input('coupon_data', '[]'), true);
return $member_cluster_model->sendCoupon($coupon_data, $cluster_id);
}
}
/**
* 发放红包
*/
public function sendBalance()
{
if (request()->isJson()) {
$member_cluster_model = new MemberClusterModel();
$cluster_id = input('cluster_id', 0);
$adjust_num = input('adjust_num', 0);
$remark = input('remark', '');
return $member_cluster_model->sendBalance($adjust_num, $cluster_id, $remark);
}
}
/**
* 发放积分
*/
public function sendPoint()
{
if (request()->isJson()) {
$member_cluster_model = new MemberClusterModel();
$cluster_id = input('cluster_id', 0);
$adjust_num = input('adjust_num', 0);
$remark = input('remark', '');
return $member_cluster_model->sendPoint($adjust_num, $cluster_id, $remark);
}
}
/**
* 计算人数
* @return array
*/
public function calculate()
{
$member_cluster_model = new MemberClusterModel();
if (request()->isJson()) {
$data = [
'site_id' => $this->site_id,
'rule_json' => input('rule_json', ''),
];
return $member_cluster_model->calculate($data);
}
}
<?php
namespace app\shop\controller;
use app\model\member\MemberCluster as MemberClusterModel;
use app\model\member\Member as MemberModel;
use app\model\member\MemberLevel as MemberLevelModel;
use app\model\member\MemberLabel as MemberLabelModel;
/**
* 会员群体管理 控制器
*/
class Membercluster extends BaseShop
{
/**
* 会员群体列表
* @return array|mixed
*/
public function clusterList()
{
$member_cluster_model = new MemberClusterModel();
if (request()->isJson()) {
$page = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$cluster_name = input('cluster_name', '');
$start_date = input('start_date', '');
$end_date = input('end_date', '');
$condition[] = [ 'site_id', '=', $this->site_id ];
if(!empty($cluster_name))
{
$condition[] = [ 'cluster_name', 'like', '%' . $cluster_name . '%'];
}
//更新时间
if ($start_date != '' && $end_date != '') {
$condition[] = [ 'update_time', 'between', [ strtotime($start_date), strtotime($end_date) ] ];
} else if ($start_date != '' && $end_date == '') {
$condition[] = [ 'update_time', '>=', strtotime($start_date) ];
} else if ($start_date == '' && $end_date != '') {
$condition[] = [ 'update_time', '<=', strtotime($end_date) ];
}
$order = 'create_time desc';
$field = '*';
$list = $member_cluster_model->getMemberClusterPageList($condition, $page, $page_size, $order, $field);
return $list;
} else {
return $this->fetch('membercluster/cluster_list');
}
}
/**
* 添加会员群体
* @return array|mixed
*/
public function addCluster()
{
$member_cluster_model = new MemberClusterModel();
if (request()->isJson()) {
$data = [
'site_id' => $this->site_id,
'cluster_name' => input('cluster_name', ''),
'rule_json' => input('rule_json', ''),
'create_time' => time(),
'update_time' => time(),
];
return $member_cluster_model->addMemberCluster($data);
} else {
$basic_list = $member_cluster_model->basic;
$consume_list = $member_cluster_model->consume;
$promotion_list = $member_cluster_model->promotion;
$this->assign('basic_list', $basic_list);
$this->assign('consume_list', $consume_list);
$this->assign('promotion_list', $promotion_list);
//会员等级
$member_level_model = new MemberLevelModel();
$member_level_list = $member_level_model->getMemberLevelList([ [ 'site_id', '=', $this->site_id ] ], 'level_id, level_name', 'growth asc');
$this->assign('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');
$this->assign('member_label_list', $member_label_list[ 'data' ]);
return $this->fetch('membercluster/add_cluster');
}
}
/**
* 编辑会员群体
* @return array|mixed
*/
public function editCluster()
{
$member_cluster_model = new MemberClusterModel();
$cluster_id = input('cluster_id', 0);
if (request()->isJson()) {
$data = [
'site_id' => $this->site_id,
'cluster_name' => input('cluster_name', ''),
'rule_json' => input('rule_json', ''),
'update_time' => time(),
];
return $member_cluster_model->editMemberCluster($data, [ 'cluster_id' => $cluster_id ]);
} else {
$cluster_info = $member_cluster_model->getMemberClusterDetail([ [ 'cluster_id', '=', $cluster_id ] ]);
$this->assign('cluster_info', $cluster_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');
$this->assign('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');
$this->assign('member_label_list', $member_label_list[ 'data' ]);
return $this->fetch('membercluster/edit_cluster');
}
}
/**
* 删除会员群体
*/
public function deleteCluster()
{
$cluster_ids = input('cluster_ids', '');
$member_cluster_model = new MemberClusterModel();
return $member_cluster_model->deleteMemberCluster([ 'cluster_id' => $cluster_ids ]);
}
/**
* 刷新操作
* @return array|mixed
*/
public function refreshCluster()
{
if (request()->isJson()) {
$member_cluster_model = new MemberClusterModel();
return $member_cluster_model->refreshMemberCluster();
}
}
/**
* 导出会员
*/
public function exportClusterMember()
{
$member_cluster_model = new MemberClusterModel();
$cluster_id = input('cluster_id', 0);
$cluster_condition[] = [ 'site_id', '=', $this->site_id ];
$cluster_condition[] = [ 'cluster_id', '=', $cluster_id ];
$cluster_info = $member_cluster_model->getMemberClusterInfo($cluster_condition, 'member_ids,cluster_name');
$order = 'reg_time desc';
$field = 'username,nickname,realname,mobile,sex,birthday,email,member_level_name,member_label_name,
qq,location,balance,balance_money,point,growth,reg_time,last_login_ip,last_login_time';
$member_model = new MemberModel();
$condition[] = ['member_id', 'in', $cluster_info[ 'data' ]['member_ids'] ];
$condition[] = ['site_id', '=', $this->site_id ];
$list = $member_model->getMemberList($condition, $field, $order);
// 实例化excel
$phpExcel = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
$phpExcel->getProperties()->setTitle('会员信息');
$phpExcel->getProperties()->setSubject('会员信息');
// 对单元格设置居中效果
$phpExcel->getActiveSheet()->getStyle('A')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$phpExcel->getActiveSheet()->getStyle('B')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$phpExcel->getActiveSheet()->getStyle('C')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$phpExcel->getActiveSheet()->getStyle('D')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$phpExcel->getActiveSheet()->getStyle('E')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$phpExcel->getActiveSheet()->getStyle('F')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$phpExcel->getActiveSheet()->getStyle('G')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$phpExcel->getActiveSheet()->getStyle('H')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$phpExcel->getActiveSheet()->getStyle('I')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$phpExcel->getActiveSheet()->getStyle('J')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$phpExcel->getActiveSheet()->getStyle('K')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$phpExcel->getActiveSheet()->getStyle('L')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$phpExcel->getActiveSheet()->getStyle('M')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$phpExcel->getActiveSheet()->getStyle('N')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$phpExcel->getActiveSheet()->getStyle('O')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$phpExcel->getActiveSheet()->getStyle('P')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
//单独添加列名称
$phpExcel->setActiveSheetIndex(0);
$phpExcel->getActiveSheet()->setCellValue('A1', '会员账号');//可以指定位置
$phpExcel->getActiveSheet()->setCellValue('B1', '会员昵称');
$phpExcel->getActiveSheet()->setCellValue('C1', '真实姓名');
$phpExcel->getActiveSheet()->setCellValue('D1', '手机号');
$phpExcel->getActiveSheet()->setCellValue('E1', '性别');
$phpExcel->getActiveSheet()->setCellValue('F1', '生日');
$phpExcel->getActiveSheet()->setCellValue('G1', '会员等级');
$phpExcel->getActiveSheet()->setCellValue('H1', '会员标签');
$phpExcel->getActiveSheet()->setCellValue('I1', 'qq');
$phpExcel->getActiveSheet()->setCellValue('J1', '地址');
$phpExcel->getActiveSheet()->setCellValue('K1', '余额');
$phpExcel->getActiveSheet()->setCellValue('L1', '积分');
$phpExcel->getActiveSheet()->setCellValue('M1', '成长值');
$phpExcel->getActiveSheet()->setCellValue('N1', '上次登录时间');
$phpExcel->getActiveSheet()->setCellValue('O1', '上次登录ip');
$phpExcel->getActiveSheet()->setCellValue('P1', '注册时间');
//循环添加数据(根据自己的逻辑)
$sex = [ '保密', '男', '女' ];
foreach ($list[ 'data' ] as $k => $v) {
$i = $k + 2;
$phpExcel->getActiveSheet()->setCellValue('A' . $i, $v[ 'username' ]);
$phpExcel->getActiveSheet()->setCellValue('B' . $i, $v[ 'nickname' ]);
$phpExcel->getActiveSheet()->setCellValue('C' . $i, $v[ 'realname' ]);
$phpExcel->getActiveSheet()->setCellValue('D' . $i, $v[ 'mobile' ]);
$phpExcel->getActiveSheet()->setCellValue('E' . $i, $sex[ $v[ 'sex' ] ]);
$phpExcel->getActiveSheet()->setCellValue('F' . $i, date('Y-m-d', $v[ 'birthday' ]));
$phpExcel->getActiveSheet()->setCellValue('G' . $i, $v[ 'member_level_name' ]);
$phpExcel->getActiveSheet()->setCellValue('H' . $i, $v[ 'member_label_name' ]);
$phpExcel->getActiveSheet()->setCellValue('I' . $i, $v[ 'qq' ]);
$phpExcel->getActiveSheet()->setCellValue('J' . $i, $v[ 'location' ]);
$phpExcel->getActiveSheet()->setCellValue('K' . $i, $v[ 'balance' ] + $v[ 'balance_money' ]);
$phpExcel->getActiveSheet()->setCellValue('L' . $i, $v[ 'point' ]);
$phpExcel->getActiveSheet()->setCellValue('M' . $i, $v[ 'growth' ]);
$phpExcel->getActiveSheet()->setCellValue('N' . $i, date('Y-m-d H:i:s', $v[ 'last_login_time' ]));
$phpExcel->getActiveSheet()->setCellValue('O' . $i, $v[ 'last_login_ip' ]);
$phpExcel->getActiveSheet()->setCellValue('P' . $i, date('Y-m-d H:i:s', $v[ 'reg_time' ]));
}
// 重命名工作sheet
$phpExcel->getActiveSheet()->setTitle('会员信息');
// 设置第一个sheet为工作的sheet
$phpExcel->setActiveSheetIndex(0);
// 保存Excel 2007格式文件保存路径为当前路径名字为export.xlsx
$objWriter = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($phpExcel, 'Xlsx');
$file = date('Y年m月d日-会员信息表', time()) . '.xlsx';
$objWriter->save($file);
header('Content-type:application/octet-stream');
$filename = basename($file);
header('Content-Disposition:attachment;filename = ' . $filename);
header('Accept-ranges:bytes');
header('Accept-length:' . filesize($file));
readfile($file);
unlink($file);
exit;
}
/**
* 发放优惠券
*/
public function sendCoupon()
{
if (request()->isJson()) {
$member_cluster_model = new MemberClusterModel();
$cluster_id = input('cluster_id', 0);
$coupon_data = json_decode(input('coupon_data', '[]'), true);
return $member_cluster_model->sendCoupon($coupon_data, $cluster_id);
}
}
/**
* 发放红包
*/
public function sendBalance()
{
if (request()->isJson()) {
$member_cluster_model = new MemberClusterModel();
$cluster_id = input('cluster_id', 0);
$adjust_num = input('adjust_num', 0);
$remark = input('remark', '');
return $member_cluster_model->sendBalance($adjust_num, $cluster_id, $remark);
}
}
/**
* 发放积分
*/
public function sendPoint()
{
if (request()->isJson()) {
$member_cluster_model = new MemberClusterModel();
$cluster_id = input('cluster_id', 0);
$adjust_num = input('adjust_num', 0);
$remark = input('remark', '');
return $member_cluster_model->sendPoint($adjust_num, $cluster_id, $remark);
}
}
/**
* 计算人数
* @return array
*/
public function calculate()
{
$member_cluster_model = new MemberClusterModel();
if (request()->isJson()) {
$data = [
'site_id' => $this->site_id,
'rule_json' => input('rule_json', ''),
];
return $member_cluster_model->calculate($data);
}
}
}

View File

@@ -1,117 +1,109 @@
<?php
/**
*/
namespace app\shop\controller;
use app\model\member\MemberLabel as MemberLabelModel;
/**
* 会员标签管理 控制器
*/
class Memberlabel extends BaseShop
{
/**
* 会员标签列表
*/
public function labelList()
{
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 ] ];
$condition[] = [ 'label_name', 'like', '%' . $search_text . '%'];
$field = '*';
//排序
$link_sort = input('order', 'sort');
$sort = input('sort', 'desc');
if ($link_sort == 'sort') {
$order_by = $link_sort . ' ' . $sort;
} else {
$order_by = $link_sort . ' ' . $sort . ',sort desc';
}
$member_label_model = new MemberLabelModel();
$list = $member_label_model->getMemberLabelPageList($condition, $page, $page_size, $order_by, $field);
return $list;
} else {
return $this->fetch('memberlabel/label_list');
}
}
/**
* 会员标签添加
*/
public function addLabel()
{
if (request()->isJson()) {
$data = [
'site_id' => $this->site_id,
'label_name' => input('label_name', ''),
'remark' => input('remark', ''),
'sort' => input('sort', 0),
'create_time' => time(),
];
$member_label_model = new MemberLabelModel();
return $member_label_model->addMemberLabel($data);
} else {
return $this->fetch('memberlabel/add_label');
}
}
/**
* 会员标签修改
*/
public function editLabel()
{
$member_label_model = new MemberLabelModel();
$label_id = input('label_id', 0);
if (request()->isJson()) {
$data = [
'label_name' => input('label_name', ''),
'remark' => input('remark', ''),
'sort' => input('sort', 0),
'modify_time' => time(),
];
return $member_label_model->editMemberLabel($data, [ [ 'label_id', '=', $label_id ], [ 'site_id', '=', $this->site_id ] ]);
} else {
$label_info = $member_label_model->getMemberLabelInfo([ [ 'label_id', '=', $label_id ], [ 'site_id', '=', $this->site_id ] ]);
if (empty($label_info[ 'data' ])) $this->error('未获取到标签数据', href_url('shop/memberlabel/labellist'));
$this->assign('label_info', $label_info);
return $this->fetch('memberlabel/edit_label');
}
}
/**
* 会员标签删除
*/
public function deleteLabel()
{
$label_ids = input('label_ids', '');
$member_label_model = new MemberLabelModel();
return $member_label_model->deleteMemberLabel([ [ 'label_id', 'in', $label_ids ] ]);
}
/**
* 修改排序
*/
public function modifySort()
{
$sort = input('sort', 0);
$label_id = input('label_id', 0);
$member_label_model = new MemberLabelModel();
return $member_label_model->modifyMemberLabelSort($sort, $label_id);
}
<?php
namespace app\shop\controller;
use app\model\member\MemberLabel as MemberLabelModel;
/**
* 会员标签管理 控制器
*/
class Memberlabel extends BaseShop
{
/**
* 会员标签列表
*/
public function labelList()
{
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 ] ];
$condition[] = [ 'label_name', 'like', '%' . $search_text . '%'];
$field = '*';
//排序
$link_sort = input('order', 'sort');
$sort = input('sort', 'desc');
if ($link_sort == 'sort') {
$order_by = $link_sort . ' ' . $sort;
} else {
$order_by = $link_sort . ' ' . $sort . ',sort desc';
}
$member_label_model = new MemberLabelModel();
$list = $member_label_model->getMemberLabelPageList($condition, $page, $page_size, $order_by, $field);
return $list;
} else {
return $this->fetch('memberlabel/label_list');
}
}
/**
* 会员标签添加
*/
public function addLabel()
{
if (request()->isJson()) {
$data = [
'site_id' => $this->site_id,
'label_name' => input('label_name', ''),
'remark' => input('remark', ''),
'sort' => input('sort', 0),
'create_time' => time(),
];
$member_label_model = new MemberLabelModel();
return $member_label_model->addMemberLabel($data);
} else {
return $this->fetch('memberlabel/add_label');
}
}
/**
* 会员标签修改
*/
public function editLabel()
{
$member_label_model = new MemberLabelModel();
$label_id = input('label_id', 0);
if (request()->isJson()) {
$data = [
'label_name' => input('label_name', ''),
'remark' => input('remark', ''),
'sort' => input('sort', 0),
'modify_time' => time(),
];
return $member_label_model->editMemberLabel($data, [ [ 'label_id', '=', $label_id ], [ 'site_id', '=', $this->site_id ] ]);
} else {
$label_info = $member_label_model->getMemberLabelInfo([ [ 'label_id', '=', $label_id ], [ 'site_id', '=', $this->site_id ] ]);
if (empty($label_info[ 'data' ])) $this->error('未获取到标签数据', href_url('shop/memberlabel/labellist'));
$this->assign('label_info', $label_info);
return $this->fetch('memberlabel/edit_label');
}
}
/**
* 会员标签删除
*/
public function deleteLabel()
{
$label_ids = input('label_ids', '');
$member_label_model = new MemberLabelModel();
return $member_label_model->deleteMemberLabel([ [ 'label_id', 'in', $label_ids ] ]);
}
/**
* 修改排序
*/
public function modifySort()
{
$sort = input('sort', 0);
$label_id = input('label_id', 0);
$member_label_model = new MemberLabelModel();
return $member_label_model->modifyMemberLabelSort($sort, $label_id);
}
}

View File

@@ -1,240 +1,232 @@
<?php
/**
*/
namespace app\shop\controller;
use app\model\member\MemberLevel as MemberLevelModel;
use addon\coupon\model\CouponType;
use app\model\member\Member as MemberModel;
use app\model\member\Config;
/**
* 会员等级管理 控制器
*/
class Memberlevel extends BaseShop
{
/**
* 会员等级列表
*/
public function levelList()
{
if (request()->isJson()) {
$page = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$search_text = input('search_text', '');
$level_type = input('level_type', 0);
$condition = [
[ 'site_id', '=', $this->site_id ],
[ 'level_type', '=', $level_type ]
];
if (!empty($search_text)) $condition[] = [ 'level_name', 'like', '%' . $search_text . '%'];
$order = 'growth asc';
$field = '*';
$member_level_model = new MemberLevelModel();
$level_list = $member_level_model->getMemberLevelList($condition, $field , $order);
$list = $level_list;
unset($list['data']);
$list['data']['list'] = $level_list['data'];
$level_count = count($list[ 'data' ][ 'list' ]);
$list_count = MEMBER_LEVEL - $level_count;
$member_level = array ();
for ($i = 1; $i <= $list_count; $i++) {
$member_level[ $i ][ 'level_vip' ] = '等级' . ( $i + count($list[ 'data' ][ 'list' ]) );
}
$list[ 'data' ][ 'list' ] = array_merge($list[ 'data' ][ 'list' ], $member_level);
$member_status = 0;
if (!empty($list[ 'data' ][ 'list' ])) {
//根据会员等级查询会员数量
$member_level_array = $member_level_model->getMemberCountGroupByLevel();
foreach ($list[ 'data' ][ 'list' ] as $k => $item) {
$list[ 'data' ][ 'list' ][ $k ][ 'member_num' ] = 0;
if (isset($item[ 'level_id' ])) {
$list[ 'data' ][ 'list' ][ $k ][ 'member_num' ] = $member_level_array[$item[ 'level_id' ]]['count'] ?? 0;
}
$list[ 'data' ][ 'list' ][ $k ][ 'level_vip' ] = '等级' . ( $k + 1 );
$list[ 'data' ][ 'list' ][ $k ][ 'is_show' ] = 0;
if ($k > 1 && $k == $level_count && $k < MEMBER_LEVEL) {
if ($list[ 'data' ][ 'list' ][ $k - 1 ][ 'status' ] == 1) $list[ 'data' ][ 'list' ][ $k ][ 'is_add' ] = 1;
}
if ($k > 0 && $k < $level_count && $member_status == 0) {
$list[ 'data' ][ 'list' ][ $k ][ 'is_one' ] = 0;
if ($item[ 'status' ] == 0) {
$list[ 'data' ][ 'list' ][ $k ][ 'is_show' ] = 1;
$list[ 'data' ][ 'list' ][ $k - 1 ][ 'is_show' ] = 1;
$member_status = 1;
}
if ($k == $level_count - 1 && $list[ 'data' ][ 'list' ][ $level_count - 1 ] [ 'status' ] == 1) {
$list[ 'data' ][ 'list' ][ $k ][ 'is_show' ] = 1;
}
}
}
if ($level_count == 1) {
$list[ 'data' ][ 'list' ][ $level_count ][ 'is_add' ] = 1;
}
$list[ 'data' ][ 'list' ][ 0 ][ 'is_show' ] = 0;
}
return $list;
} else {
$config = ( new Config )->getMemberConfig($this->site_id, $this->app_module)[ 'data' ] ?? [];
$this->assign('is_update', $config[ 'value' ][ 'is_update' ] ?? 1);
return $this->fetch('memberlevel/level_list');
}
}
/**
* 会员等级添加
*/
public function addLevel()
{
$member_level_model = new MemberLevelModel();
if (request()->isJson()) {
$data = [
'site_id' => $this->site_id,
'level_name' => input('level_name', ''),
'growth' => input('growth', 0),
'remark' => input('remark', ''),
'is_free_shipping' => input('is_free_shipping', 0),
'consume_discount' => input('consume_discount', 100),
'point_feedback' => input('point_feedback', 0),
'send_point' => input('send_point', 0),
'send_balance' => input('send_balance', 0),
'send_coupon' => input('send_coupon', ''),
'level_type' => 0,
'charge_rule' => '',
'charge_type' => 0,
'bg_color' => input('bg_color', '#333333'),
'level_text_color' => input('level_text_color', '#ffffff'),
'level_picture' => input('level_picture', ''),
];
$this->addLog('会员等级添加:' . $data[ 'level_name' ]);
$res = $member_level_model->addMemberLevel($data);
( new Config )->setMemberConfig([ 'is_update' => 1 ], $this->site_id, $this->app_module);
return $res;
} else {
//获取优惠券列表
$coupon_model = new CouponType();
$condition = [
[ 'status', '=', 1 ],
[ 'site_id', '=', $this->site_id ],
];
//优惠券字段
$coupon_field = 'coupon_type_id,type,coupon_name,image,money,discount,validity_type,fixed_term,status,is_limit,at_least,count,lead_count,end_time,goods_type,max_fetch';
$coupon_list = $coupon_model->getCouponTypeList($condition, $coupon_field);
$this->assign('coupon_list', $coupon_list);
$this->assign('level_time', $member_level_model->level_time);
$growth_up = $member_level_model->getFirstMemberLevel([ [ 'site_id', '=', $this->site_id ], [ 'level_type', '=', '0' ] ], 'growth', 'growth desc')[ 'data' ][ 'growth' ] ?? 0;
$this->assign('growth_up', $growth_up);
return $this->fetch('memberlevel/add_level');
}
}
/**
* 会员等级修改
*/
public function editLevel()
{
$member_level_model = new MemberLevelModel();
if (request()->isJson()) {
$data = [
'level_name' => input('level_name', ''),
'growth' => input('growth', 0.00),
'remark' => input('remark', ''),
'is_free_shipping' => input('is_free_shipping', 0),
'consume_discount' => input('consume_discount', 100),
'point_feedback' => input('point_feedback', 0),
'send_point' => input('send_point', 0),
'send_balance' => input('send_balance', 0),
'send_coupon' => input('send_coupon', ''),
'charge_rule' => '',
'bg_color' => input('bg_color', '#333333'),
'level_text_color' => input('level_text_color', '#ffffff'),
'level_picture' => input('level_picture', ''),
];
$level_id = input('level_id', 0);
$this->addLog('会员等级修改:' . $data[ 'level_name' ]);
( new Config )->setMemberConfig([ 'is_update' => 1 ], $this->site_id, $this->app_module);
return $member_level_model->editMemberLevel($data, [ [ 'level_id', '=', $level_id ], [ 'site_id', '=', $this->site_id ] ]);
} else {
$level_id = input('get.level_id', 0);
$level_info = $member_level_model->getMemberLevelInfo([ [ 'level_id', '=', $level_id ], [ 'site_id', '=', $this->site_id ] ]);
if (empty($level_info[ 'data' ])) $this->error('未获取到等级数据', href_url('shop/memberlevel/levellist'));
$this->assign('level_info', $level_info[ 'data' ]);
$this->assign('level_time', $member_level_model->level_time);
//获取优惠券列表
$coupon_model = new CouponType();
$condition = [
[ 'status', '=', 1 ],
[ 'site_id', '=', $this->site_id ],
];
//优惠券字段
$coupon_field = 'coupon_type_id,type,coupon_name,image,money,discount,validity_type,fixed_term,status,is_limit,at_least,count,lead_count,end_time,goods_type,max_fetch';
$coupon_list = $coupon_model->getCouponTypeList($condition, $coupon_field);
$this->assign('coupon_list', $coupon_list);
$growth_up = $member_level_model->getFirstMemberLevel([ [ 'growth', '<', $level_info[ 'data' ][ 'growth' ] ], [ 'site_id', '=', $this->site_id ], [ 'level_type', '=', '0' ] ], 'growth', 'growth desc')[ 'data' ];
//下级
$growth_down = $member_level_model->getFirstMemberLevel([ [ 'growth', '>', $level_info[ 'data' ][ 'growth' ] ], [ 'site_id', '=', $this->site_id ], [ 'level_type', '=', '0' ] ], 'growth', 'growth asc')[ 'data' ];
$this->assign('growth_up', $growth_up ? $growth_up[ 'growth' ] : 0);
$this->assign('growth_down', $growth_down ? $growth_down[ 'growth' ] : 0);
return $this->fetch('memberlevel/edit_level');
}
}
/**
* 会员等级删除
*/
public function deleteLevel()
{
$level_id = input('level_id', '');
$member_level_model = new MemberLevelModel();
$this->addLog('会员等级删除id:' . $level_id);
return $member_level_model->deleteMemberLevel($level_id, $this->site_id);
}
/**
* 会员等级状态
*/
public function statusLevel()
{
$level_id = input('level_id', '');
$status = input('status', '');
$member_level_model = new MemberLevelModel();
$this->addLog('会员等级修改id:' . $level_id);
return $member_level_model->editMemberLevel([ 'status' => $status ], [ [ 'level_id', '=', $level_id ], [ 'site_id', '=', $this->site_id ] ]);
}
/**
* 更新会员等级状态
*/
public function startlevel()
{
$member_level_model = new MemberLevelModel();
( new Config )->setMemberConfig([ 'is_update' => 0 ], $this->site_id, $this->app_module)[ 'data' ] ?? [];
return $member_level_model->startlevel($this->site_id);
}
<?php
namespace app\shop\controller;
use app\model\member\MemberLevel as MemberLevelModel;
use addon\coupon\model\CouponType;
use app\model\member\Member as MemberModel;
use app\model\member\Config;
/**
* 会员等级管理 控制器
*/
class Memberlevel extends BaseShop
{
/**
* 会员等级列表
*/
public function levelList()
{
if (request()->isJson()) {
$page = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$search_text = input('search_text', '');
$level_type = input('level_type', 0);
$condition = [
[ 'site_id', '=', $this->site_id ],
[ 'level_type', '=', $level_type ]
];
if (!empty($search_text)) $condition[] = [ 'level_name', 'like', '%' . $search_text . '%'];
$order = 'growth asc';
$field = '*';
$member_level_model = new MemberLevelModel();
$level_list = $member_level_model->getMemberLevelList($condition, $field , $order);
$list = $level_list;
unset($list['data']);
$list['data']['list'] = $level_list['data'];
$level_count = count($list[ 'data' ][ 'list' ]);
$list_count = MEMBER_LEVEL - $level_count;
$member_level = array ();
for ($i = 1; $i <= $list_count; $i++) {
$member_level[ $i ][ 'level_vip' ] = '等级' . ( $i + count($list[ 'data' ][ 'list' ]) );
}
$list[ 'data' ][ 'list' ] = array_merge($list[ 'data' ][ 'list' ], $member_level);
$member_status = 0;
if (!empty($list[ 'data' ][ 'list' ])) {
//根据会员等级查询会员数量
$member_level_array = $member_level_model->getMemberCountGroupByLevel();
foreach ($list[ 'data' ][ 'list' ] as $k => $item) {
$list[ 'data' ][ 'list' ][ $k ][ 'member_num' ] = 0;
if (isset($item[ 'level_id' ])) {
$list[ 'data' ][ 'list' ][ $k ][ 'member_num' ] = $member_level_array[$item[ 'level_id' ]]['count'] ?? 0;
}
$list[ 'data' ][ 'list' ][ $k ][ 'level_vip' ] = '等级' . ( $k + 1 );
$list[ 'data' ][ 'list' ][ $k ][ 'is_show' ] = 0;
if ($k > 1 && $k == $level_count && $k < MEMBER_LEVEL) {
if ($list[ 'data' ][ 'list' ][ $k - 1 ][ 'status' ] == 1) $list[ 'data' ][ 'list' ][ $k ][ 'is_add' ] = 1;
}
if ($k > 0 && $k < $level_count && $member_status == 0) {
$list[ 'data' ][ 'list' ][ $k ][ 'is_one' ] = 0;
if ($item[ 'status' ] == 0) {
$list[ 'data' ][ 'list' ][ $k ][ 'is_show' ] = 1;
$list[ 'data' ][ 'list' ][ $k - 1 ][ 'is_show' ] = 1;
$member_status = 1;
}
if ($k == $level_count - 1 && $list[ 'data' ][ 'list' ][ $level_count - 1 ] [ 'status' ] == 1) {
$list[ 'data' ][ 'list' ][ $k ][ 'is_show' ] = 1;
}
}
}
if ($level_count == 1) {
$list[ 'data' ][ 'list' ][ $level_count ][ 'is_add' ] = 1;
}
$list[ 'data' ][ 'list' ][ 0 ][ 'is_show' ] = 0;
}
return $list;
} else {
$config = ( new Config )->getMemberConfig($this->site_id, $this->app_module)[ 'data' ] ?? [];
$this->assign('is_update', $config[ 'value' ][ 'is_update' ] ?? 1);
return $this->fetch('memberlevel/level_list');
}
}
/**
* 会员等级添加
*/
public function addLevel()
{
$member_level_model = new MemberLevelModel();
if (request()->isJson()) {
$data = [
'site_id' => $this->site_id,
'level_name' => input('level_name', ''),
'growth' => input('growth', 0),
'remark' => input('remark', ''),
'is_free_shipping' => input('is_free_shipping', 0),
'consume_discount' => input('consume_discount', 100),
'point_feedback' => input('point_feedback', 0),
'send_point' => input('send_point', 0),
'send_balance' => input('send_balance', 0),
'send_coupon' => input('send_coupon', ''),
'level_type' => 0,
'charge_rule' => '',
'charge_type' => 0,
'bg_color' => input('bg_color', '#333333'),
'level_text_color' => input('level_text_color', '#ffffff'),
'level_picture' => input('level_picture', ''),
];
$this->addLog('会员等级添加:' . $data[ 'level_name' ]);
$res = $member_level_model->addMemberLevel($data);
( new Config )->setMemberConfig([ 'is_update' => 1 ], $this->site_id, $this->app_module);
return $res;
} else {
//获取优惠券列表
$coupon_model = new CouponType();
$condition = [
[ 'status', '=', 1 ],
[ 'site_id', '=', $this->site_id ],
];
//优惠券字段
$coupon_field = 'coupon_type_id,type,coupon_name,image,money,discount,validity_type,fixed_term,status,is_limit,at_least,count,lead_count,end_time,goods_type,max_fetch';
$coupon_list = $coupon_model->getCouponTypeList($condition, $coupon_field);
$this->assign('coupon_list', $coupon_list);
$this->assign('level_time', $member_level_model->level_time);
$growth_up = $member_level_model->getFirstMemberLevel([ [ 'site_id', '=', $this->site_id ], [ 'level_type', '=', '0' ] ], 'growth', 'growth desc')[ 'data' ][ 'growth' ] ?? 0;
$this->assign('growth_up', $growth_up);
return $this->fetch('memberlevel/add_level');
}
}
/**
* 会员等级修改
*/
public function editLevel()
{
$member_level_model = new MemberLevelModel();
if (request()->isJson()) {
$data = [
'level_name' => input('level_name', ''),
'growth' => input('growth', 0.00),
'remark' => input('remark', ''),
'is_free_shipping' => input('is_free_shipping', 0),
'consume_discount' => input('consume_discount', 100),
'point_feedback' => input('point_feedback', 0),
'send_point' => input('send_point', 0),
'send_balance' => input('send_balance', 0),
'send_coupon' => input('send_coupon', ''),
'charge_rule' => '',
'bg_color' => input('bg_color', '#333333'),
'level_text_color' => input('level_text_color', '#ffffff'),
'level_picture' => input('level_picture', ''),
];
$level_id = input('level_id', 0);
$this->addLog('会员等级修改:' . $data[ 'level_name' ]);
( new Config )->setMemberConfig([ 'is_update' => 1 ], $this->site_id, $this->app_module);
return $member_level_model->editMemberLevel($data, [ [ 'level_id', '=', $level_id ], [ 'site_id', '=', $this->site_id ] ]);
} else {
$level_id = input('get.level_id', 0);
$level_info = $member_level_model->getMemberLevelInfo([ [ 'level_id', '=', $level_id ], [ 'site_id', '=', $this->site_id ] ]);
if (empty($level_info[ 'data' ])) $this->error('未获取到等级数据', href_url('shop/memberlevel/levellist'));
$this->assign('level_info', $level_info[ 'data' ]);
$this->assign('level_time', $member_level_model->level_time);
//获取优惠券列表
$coupon_model = new CouponType();
$condition = [
[ 'status', '=', 1 ],
[ 'site_id', '=', $this->site_id ],
];
//优惠券字段
$coupon_field = 'coupon_type_id,type,coupon_name,image,money,discount,validity_type,fixed_term,status,is_limit,at_least,count,lead_count,end_time,goods_type,max_fetch';
$coupon_list = $coupon_model->getCouponTypeList($condition, $coupon_field);
$this->assign('coupon_list', $coupon_list);
$growth_up = $member_level_model->getFirstMemberLevel([ [ 'growth', '<', $level_info[ 'data' ][ 'growth' ] ], [ 'site_id', '=', $this->site_id ], [ 'level_type', '=', '0' ] ], 'growth', 'growth desc')[ 'data' ];
//下级
$growth_down = $member_level_model->getFirstMemberLevel([ [ 'growth', '>', $level_info[ 'data' ][ 'growth' ] ], [ 'site_id', '=', $this->site_id ], [ 'level_type', '=', '0' ] ], 'growth', 'growth asc')[ 'data' ];
$this->assign('growth_up', $growth_up ? $growth_up[ 'growth' ] : 0);
$this->assign('growth_down', $growth_down ? $growth_down[ 'growth' ] : 0);
return $this->fetch('memberlevel/edit_level');
}
}
/**
* 会员等级删除
*/
public function deleteLevel()
{
$level_id = input('level_id', '');
$member_level_model = new MemberLevelModel();
$this->addLog('会员等级删除id:' . $level_id);
return $member_level_model->deleteMemberLevel($level_id, $this->site_id);
}
/**
* 会员等级状态
*/
public function statusLevel()
{
$level_id = input('level_id', '');
$status = input('status', '');
$member_level_model = new MemberLevelModel();
$this->addLog('会员等级修改id:' . $level_id);
return $member_level_model->editMemberLevel([ 'status' => $status ], [ [ 'level_id', '=', $level_id ], [ 'site_id', '=', $this->site_id ] ]);
}
/**
* 更新会员等级状态
*/
public function startlevel()
{
$member_level_model = new MemberLevelModel();
( new Config )->setMemberConfig([ 'is_update' => 0 ], $this->site_id, $this->app_module)[ 'data' ] ?? [];
return $member_level_model->startlevel($this->site_id);
}
}

View File

@@ -1,256 +1,248 @@
<?php
/**
*/
namespace app\shop\controller;
use app\model\member\Withdraw as MemberWithdrawModel;
use app\model\system\Pay;
use app\model\web\Account as AccountModel;
/**
* 会员管理 控制器
*/
class Memberwithdraw extends BaseShop
{
/**
* 会员提现配置
*/
public function config()
{
$config_model = new MemberWithdrawModel();
if (request()->isJson()) {
if (empty(input('transfer_type'))) {
$transfer_type = '';
} else {
$transfer_type = implode(',', input('transfer_type'));
}
//订单提现
$data = [
'is_auto_audit' => input('is_auto_audit', 0),//是否需要审核 1 手动审核 2 自动审核
'rate' => input('rate', 0),//提现手续费比率 (0-100)
'transfer_type' => $transfer_type,//转账方式,
'is_auto_transfer' => input('is_auto_transfer', 0),//是否自动转账 1 手动转账 2 自动转账
'min' => input('min', 0),//提现最低额度
'max' => input('max', 0),//提现最高额度
];
$this->addLog('设置会员提现配置');
$is_use = input('is_use', 0);//是否启用
$res = $config_model->setConfig($data, $is_use, $this->site_id, $this->app_module);
return $res;
} else {
$this->assign('is_exist', addon_is_exit('memberwithdraw', $this->site_id));
//会员提现
$config_result = $config_model->getConfig($this->site_id, $this->app_module);
$this->assign('config', $config_result[ 'data' ]);
$pay_model = new Pay();
$transfer_type_list = $pay_model->getTransferType($this->site_id);
$this->assign('transfer_type_list', $transfer_type_list);
return $this->fetch('memberwithdraw/config');
}
}
/**
* 会员提现列表
* @return mixed
*/
public function lists()
{
$withdraw_model = new MemberWithdrawModel();
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', '');//提现转账方式
$member_name = input('member_name', '');//提现转账方式
$payment_start_date = input('payment_start_date', '');
$payment_end_time = input('payment_end_time', '');
$condition = [ [ '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 ($status != 'all') {
$condition[] = [ 'status', '=', $status ];
}
if (!empty($member_name)) {
$condition[] = [ 'member_name', '=', $member_name ];
}
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 ($payment_start_date != '' && $payment_end_time != '') {
$condition[] = [ 'payment_time', 'between', [ strtotime($payment_start_date), strtotime($payment_end_time) ] ];
} else if ($payment_start_date != '' && $payment_end_time == '') {
$condition[] = [ 'payment_time', '>=', strtotime($payment_start_date) ];
} else if ($payment_start_date == '' && $payment_end_time != '') {
$condition[] = [ 'payment_time', '<=', strtotime($payment_end_time) ];
}
$order = 'apply_time desc';
return $withdraw_model->getMemberWithdrawPageList($condition, $page, $page_size, $order);
} else {
$this->assign('is_exist', addon_is_exit('memberwithdraw', $this->site_id));
$pay_model = new Pay();
$transfer_type_list = $pay_model->getTransferType($this->site_id);
$this->assign('transfer_type_list', $transfer_type_list);
$account_model = new AccountModel();
$member_balance_sum = $account_model->getMemberBalanceSum($this->site_id);
$this->assign('member_balance_sum', $member_balance_sum[ 'data' ]);
return $this->fetch('memberwithdraw/lists');
}
}
/**
* 详情
*/
public function detail()
{
$id = input('id', 0);
$withdraw_model = new MemberWithdrawModel();
$withdraw_info_result = $withdraw_model->getMemberWithdrawInfo([ ['id', '=', $id ], [ 'site_id', '=', $this->site_id ] ]);
$withdraw_info = $withdraw_info_result['data'];
if (empty($withdraw_info)) $this->error('未获取到提现数据', href_url('shop/memberwithdraw/lists'));
$this->assign('withdraw_info', $withdraw_info);
return $this->fetch('memberwithdraw/detail');
}
/**
* 同意
* @return array
*/
public function agree()
{
if (request()->isJson()) {
$id = input('id', 0);
$withdraw_model = new MemberWithdrawModel();
$condition = array (
[ 'site_id', '=', $this->site_id ],
['id', '=', $id ],
[ 'status', '=', 0 ]
);
$result = $withdraw_model->agree($condition);
return $result;
}
}
/**
* 拒绝
* @return array
*/
public function refuse()
{
if (request()->isJson()) {
$id = input('id', 0);
$refuse_reason = input('refuse_reason', '');
$withdraw_model = new MemberWithdrawModel();
$condition = array (
[ 'site_id', '=', $this->site_id ],
['id', '=', $id ],
[ 'status', '=', 0 ]
);
$data = array (
'refuse_reason' => $refuse_reason
);
$result = $withdraw_model->refuse($condition, $data);
return $result;
}
}
/**
* 转账
*/
public function transferFinish()
{
if (request()->isJson()) {
$id = input('id', 0);
$certificate = input('certificate', '');
$certificate_remark = input('certificate_remark', '');
$withdraw_model = new MemberWithdrawModel();
$data = array (
'id' => $id,
'site_id' => $this->site_id,
'certificate' => $certificate,
'certificate_remark' => $certificate_remark,
);
$result = $withdraw_model->transferFinish($data);
return $result;
}
}
public function export(){
$withdraw_model = new MemberWithdrawModel();
$withdraw_no = input('withdraw_no', '');
$start_date = input('start_date', '');
$end_date = input('end_date', '');
$status = input('status', 'all');//提现状态
$transfer_type = input('transfer_type', '');//提现转账方式
$member_name = input('member_name', '');//提现转账方式
$payment_start_date = input('payment_start_date', '');
$payment_end_time = input('payment_end_time', '');
$condition = [ [ '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 ($status != 'all') {
$condition[] = [ 'status', '=', $status ];
}
if (!empty($member_name)) {
$condition[] = [ 'member_name', '=', $member_name ];
}
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 ($payment_start_date != '' && $payment_end_time != '') {
$condition[] = [ 'payment_time', 'between', [ strtotime($payment_start_date), strtotime($payment_end_time) ] ];
} else if ($payment_start_date != '' && $payment_end_time == '') {
$condition[] = [ 'payment_time', '>=', strtotime($payment_start_date) ];
} else if ($payment_start_date == '' && $payment_end_time != '') {
$condition[] = [ 'payment_time', '<=', strtotime($payment_end_time) ];
}
$order = 'apply_time desc';
$withdraw_model->exportWithdraw($condition, $order);
}
<?php
namespace app\shop\controller;
use app\model\member\Withdraw as MemberWithdrawModel;
use app\model\system\Pay;
use app\model\web\Account as AccountModel;
/**
* 会员管理 控制器
*/
class Memberwithdraw extends BaseShop
{
/**
* 会员提现配置
*/
public function config()
{
$config_model = new MemberWithdrawModel();
if (request()->isJson()) {
if (empty(input('transfer_type'))) {
$transfer_type = '';
} else {
$transfer_type = implode(',', input('transfer_type'));
}
//订单提现
$data = [
'is_auto_audit' => input('is_auto_audit', 0),//是否需要审核 1 手动审核 2 自动审核
'rate' => input('rate', 0),//提现手续费比率 (0-100)
'transfer_type' => $transfer_type,//转账方式,
'is_auto_transfer' => input('is_auto_transfer', 0),//是否自动转账 1 手动转账 2 自动转账
'min' => input('min', 0),//提现最低额度
'max' => input('max', 0),//提现最高额度
];
$this->addLog('设置会员提现配置');
$is_use = input('is_use', 0);//是否启用
$res = $config_model->setConfig($data, $is_use, $this->site_id, $this->app_module);
return $res;
} else {
$this->assign('is_exist', addon_is_exit('memberwithdraw', $this->site_id));
//会员提现
$config_result = $config_model->getConfig($this->site_id, $this->app_module);
$this->assign('config', $config_result[ 'data' ]);
$pay_model = new Pay();
$transfer_type_list = $pay_model->getTransferType($this->site_id);
$this->assign('transfer_type_list', $transfer_type_list);
return $this->fetch('memberwithdraw/config');
}
}
/**
* 会员提现列表
* @return mixed
*/
public function lists()
{
$withdraw_model = new MemberWithdrawModel();
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', '');//提现转账方式
$member_name = input('member_name', '');//提现转账方式
$payment_start_date = input('payment_start_date', '');
$payment_end_time = input('payment_end_time', '');
$condition = [ [ '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 ($status != 'all') {
$condition[] = [ 'status', '=', $status ];
}
if (!empty($member_name)) {
$condition[] = [ 'member_name', '=', $member_name ];
}
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 ($payment_start_date != '' && $payment_end_time != '') {
$condition[] = [ 'payment_time', 'between', [ strtotime($payment_start_date), strtotime($payment_end_time) ] ];
} else if ($payment_start_date != '' && $payment_end_time == '') {
$condition[] = [ 'payment_time', '>=', strtotime($payment_start_date) ];
} else if ($payment_start_date == '' && $payment_end_time != '') {
$condition[] = [ 'payment_time', '<=', strtotime($payment_end_time) ];
}
$order = 'apply_time desc';
return $withdraw_model->getMemberWithdrawPageList($condition, $page, $page_size, $order);
} else {
$this->assign('is_exist', addon_is_exit('memberwithdraw', $this->site_id));
$pay_model = new Pay();
$transfer_type_list = $pay_model->getTransferType($this->site_id);
$this->assign('transfer_type_list', $transfer_type_list);
$account_model = new AccountModel();
$member_balance_sum = $account_model->getMemberBalanceSum($this->site_id);
$this->assign('member_balance_sum', $member_balance_sum[ 'data' ]);
return $this->fetch('memberwithdraw/lists');
}
}
/**
* 详情
*/
public function detail()
{
$id = input('id', 0);
$withdraw_model = new MemberWithdrawModel();
$withdraw_info_result = $withdraw_model->getMemberWithdrawInfo([ ['id', '=', $id ], [ 'site_id', '=', $this->site_id ] ]);
$withdraw_info = $withdraw_info_result['data'];
if (empty($withdraw_info)) $this->error('未获取到提现数据', href_url('shop/memberwithdraw/lists'));
$this->assign('withdraw_info', $withdraw_info);
return $this->fetch('memberwithdraw/detail');
}
/**
* 同意
* @return array
*/
public function agree()
{
if (request()->isJson()) {
$id = input('id', 0);
$withdraw_model = new MemberWithdrawModel();
$condition = array (
[ 'site_id', '=', $this->site_id ],
['id', '=', $id ],
[ 'status', '=', 0 ]
);
$result = $withdraw_model->agree($condition);
return $result;
}
}
/**
* 拒绝
* @return array
*/
public function refuse()
{
if (request()->isJson()) {
$id = input('id', 0);
$refuse_reason = input('refuse_reason', '');
$withdraw_model = new MemberWithdrawModel();
$condition = array (
[ 'site_id', '=', $this->site_id ],
['id', '=', $id ],
[ 'status', '=', 0 ]
);
$data = array (
'refuse_reason' => $refuse_reason
);
$result = $withdraw_model->refuse($condition, $data);
return $result;
}
}
/**
* 转账
*/
public function transferFinish()
{
if (request()->isJson()) {
$id = input('id', 0);
$certificate = input('certificate', '');
$certificate_remark = input('certificate_remark', '');
$withdraw_model = new MemberWithdrawModel();
$data = array (
'id' => $id,
'site_id' => $this->site_id,
'certificate' => $certificate,
'certificate_remark' => $certificate_remark,
);
$result = $withdraw_model->transferFinish($data);
return $result;
}
}
public function export(){
$withdraw_model = new MemberWithdrawModel();
$withdraw_no = input('withdraw_no', '');
$start_date = input('start_date', '');
$end_date = input('end_date', '');
$status = input('status', 'all');//提现状态
$transfer_type = input('transfer_type', '');//提现转账方式
$member_name = input('member_name', '');//提现转账方式
$payment_start_date = input('payment_start_date', '');
$payment_end_time = input('payment_end_time', '');
$condition = [ [ '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 ($status != 'all') {
$condition[] = [ 'status', '=', $status ];
}
if (!empty($member_name)) {
$condition[] = [ 'member_name', '=', $member_name ];
}
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 ($payment_start_date != '' && $payment_end_time != '') {
$condition[] = [ 'payment_time', 'between', [ strtotime($payment_start_date), strtotime($payment_end_time) ] ];
} else if ($payment_start_date != '' && $payment_end_time == '') {
$condition[] = [ 'payment_time', '>=', strtotime($payment_start_date) ];
} else if ($payment_start_date == '' && $payment_end_time != '') {
$condition[] = [ 'payment_time', '<=', strtotime($payment_end_time) ];
}
$order = 'apply_time desc';
$withdraw_model->exportWithdraw($condition, $order);
}
}

View File

@@ -1,243 +1,235 @@
<?php
/**
*/
namespace app\shop\controller;
use app\model\message\Message as MessageModel;
use app\model\order\Config as OrderConfigModel;
use app\model\message\Sms;
use addon\wechat\model\Config as WechatConfig;
use addon\weapp\model\Config as WeappConfig;
use addon\aliapp\model\Config as AliappConfig;
use addon\niusms\model\Config as NiuSmsConfig;
use addon\niusms\model\Sms as NiuSms;
/**
* 消息管理 控制器
*/
class Message extends BaseShop
{
/**
* 消息管理 列表
*/
public function lists()
{
$message_model = new MessageModel();
//买家消息
$member_message_list_result = $message_model->getMessageList($this->site_id, 1);
$member_message_list = $member_message_list_result['data'];
$this->assign('member_message_list', $member_message_list);
//卖家通知
$shop_message_list_result = $message_model->getMessageList($this->site_id, 2);
$shop_message_list = $shop_message_list_result['data'];
$this->assign('shop_message_list', $shop_message_list);
//核销配置
$config_model = new OrderConfigModel();
$verify_config = $config_model->getOrderVerifyConfig($this->site_id, $this->app_module)[ 'data' ][ 'value' ];
$this->assign('verify_config', $verify_config);
// 公众号配置查询
$wechat_config = ( new WechatConfig() )->getWechatConfig($this->site_id)[ 'data' ][ 'value' ];
$this->assign('wechat_config', $wechat_config);
// 小程序配置查询
$weapp_config = ( new WeappConfig() )->getWeappConfig($this->site_id)[ 'data' ][ 'value' ];
$this->assign('weapp_config', $weapp_config);
if (addon_is_exit('niusms', $this->site_id)) {
$sms_config = ( new NiuSmsConfig() )->getSmsConfig($this->site_id)[ 'data' ];
if ($sms_config[ 'is_use' ]) {
$account_info = ( new NiuSms() )->getChildAccountInfo([
'username' => $sms_config[ 'value' ][ 'username' ],
]);
$this->assign('sms_num', $account_info[ 'data' ][ 'balance' ] ?? 0);
}
}
// 支付宝小程序
$aliapp_is_exit = addon_is_exit('aliapp', $this->site_id);
if ($aliapp_is_exit) {
$aliapp_config = ( new AliappConfig() )->getAliappConfig($this->site_id)[ 'data' ][ 'value' ];
$this->assign('aliapp_config', $aliapp_config);
}
$this->assign('aliapp_is_exit', $aliapp_is_exit);
return $this->fetch('message/lists');
}
/**
* 编辑短信模板(跳转)
*/
public function editSmsMessage()
{
$keywords = input('keywords', '');
$sms_model = new Sms();
$edit_data_result = $sms_model->doEditSmsMessage($this->site_id);
if (empty($edit_data_result['data'][ 0 ]))
$this->error('没有开启的短信方式!');
$edit_data = $edit_data_result['data'][ 0 ];
$edit_url = $edit_data['shop_url'];
// file_put_contents(__DIR__ . '/debug.txt', var_export($edit_url,true));
$this->redirect(addon_url($edit_url, [ 'keywords' => $keywords ]));
}
/**
* 短信管理
*/
public function sms()
{
$sms_model = new Sms();
$list = $sms_model->getSmsType();
if (request()->isJson()) {
return $list;
} else {
$list = $list[ 'data' ];
if (count($list) == 1) {
foreach ($list as $k => $v) {
if ($v[ 'sms_type' ] == 'niusms') {
$this->redirect(addon_url('niusms://shop/sms/index'));
}
}
}
return $this->fetch('message/sms');
}
}
/**
* 短信记录
*/
public function smsRecords()
{
if (request()->isJson()) {
$sms_model = new Sms();
$page = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$search_text = input('search_text', '');
$status = input('status', 'all');
$condition = [ [ 'site_id', '=', $this->site_id ] ];
if (!empty($search_text)) {
$condition[] = ['keywords_name', 'like', '%' . $search_text . '%'];
}
if (!empty($status) && $status != 'all') {
if ($status == -1) {
$condition[] = [ 'status', 'not in', [ 0, 1, '' ] ];
} else {
$condition[] = [ 'status', '=', $status - 1 ];
}
}
$list = $sms_model->getSmsRecordsPageList($condition, $page, $page_size);
return $list;
} else {
$sms_data = [
'total_num' => 0,
'sms_num' => 0,
'sms_used_num' => 0
];
$this->assign('sms_data', $sms_data);
return $this->fetch('message/smsrecords');
}
}
/**
* 删除短信记录
*/
public function deleteSmsRecords()
{
if (request()->isJson()) {
$ids = input('ids', '');
$sms_model = new Sms();
$condition = array (
['id', 'in', $ids ]
);
$result = $sms_model->deleteSmsRecords($condition);
return $result;
}
}
/**
* 编辑短信模板(跳转)
*/
public function editEmailMessage()
{
$message_model = new MessageModel();
$keywords = input('keywords', '');
$info_result = $message_model->getMessageInfo($this->site_id, $keywords);
$info = $info_result['data'];
if (request()->isJson()) {
if (empty($info))
return error(-1, '不存在的模板信息!');
$email_title = input('email_title', '');//邮件标题
$email_content = input('email_content', '');//邮件内容
$email_is_open = input('email_is_open', 0);//邮件开关
$data = array (
'email_title' => $email_title,
'email_content' => $email_content,
'email_is_open' => $email_is_open,
);
$condition = array (
['keywords', '=', $keywords ],
[ 'site_id', '=', $this->site_id ],
[ 'app_module', '=', $this->app_module ]
);
$this->addLog('编辑邮箱模板:' . $keywords);
$res = $message_model->editMessage($data, $condition);
return $res;
} else {
if (empty($info))
$this->error('不存在的模板信息!');
$email_title = $info['email_title'];//邮件标题
$email_content = $info['email_content'];//邮件内容
$email_is_open = $info['email_is_open'];//邮件开关
$this->assign('email_title', $email_title);
$this->assign('email_content', $email_content);
$this->assign('email_is_open', $email_is_open);
$this->assign('keywords', $keywords);
//模板变量
$message_variable_list = $info['message_json_array'];
$this->assign('message_variable_list', $message_variable_list);
return $this->fetch('message/edit_email_message');
}
}
/**
* 消息通知时间设置
*/
public function remindTimeSetting()
{
if (request()->isJson()) {
$keyword = input('keyword', '');
$hour = input('hour', 24);
$config_model = new OrderConfigModel();
$data = $config_model->getOrderVerifyConfig($this->site_id, $this->app_module)[ 'data' ][ 'value' ];
$data[ $keyword ] = $hour;
return $config_model->setOrderVerifyConfig($data, $this->site_id, $this->app_module);
} else {
return $this->fetch('message/lists');
}
}
<?php
namespace app\shop\controller;
use app\model\message\Message as MessageModel;
use app\model\order\Config as OrderConfigModel;
use app\model\message\Sms;
use addon\wechat\model\Config as WechatConfig;
use addon\weapp\model\Config as WeappConfig;
use addon\aliapp\model\Config as AliappConfig;
use addon\niusms\model\Config as NiuSmsConfig;
use addon\niusms\model\Sms as NiuSms;
/**
* 消息管理 控制器
*/
class Message extends BaseShop
{
/**
* 消息管理 列表
*/
public function lists()
{
$message_model = new MessageModel();
//买家消息
$member_message_list_result = $message_model->getMessageList($this->site_id, 1);
$member_message_list = $member_message_list_result['data'];
$this->assign('member_message_list', $member_message_list);
//卖家通知
$shop_message_list_result = $message_model->getMessageList($this->site_id, 2);
$shop_message_list = $shop_message_list_result['data'];
$this->assign('shop_message_list', $shop_message_list);
//核销配置
$config_model = new OrderConfigModel();
$verify_config = $config_model->getOrderVerifyConfig($this->site_id, $this->app_module)[ 'data' ][ 'value' ];
$this->assign('verify_config', $verify_config);
// 公众号配置查询
$wechat_config = ( new WechatConfig() )->getWechatConfig($this->site_id)[ 'data' ][ 'value' ];
$this->assign('wechat_config', $wechat_config);
// 小程序配置查询
$weapp_config = ( new WeappConfig() )->getWeappConfig($this->site_id)[ 'data' ][ 'value' ];
$this->assign('weapp_config', $weapp_config);
if (addon_is_exit('niusms', $this->site_id)) {
$sms_config = ( new NiuSmsConfig() )->getSmsConfig($this->site_id)[ 'data' ];
if ($sms_config[ 'is_use' ]) {
$account_info = ( new NiuSms() )->getChildAccountInfo([
'username' => $sms_config[ 'value' ][ 'username' ],
]);
$this->assign('sms_num', $account_info[ 'data' ][ 'balance' ] ?? 0);
}
}
// 支付宝小程序
$aliapp_is_exit = addon_is_exit('aliapp', $this->site_id);
if ($aliapp_is_exit) {
$aliapp_config = ( new AliappConfig() )->getAliappConfig($this->site_id)[ 'data' ][ 'value' ];
$this->assign('aliapp_config', $aliapp_config);
}
$this->assign('aliapp_is_exit', $aliapp_is_exit);
return $this->fetch('message/lists');
}
/**
* 编辑短信模板(跳转)
*/
public function editSmsMessage()
{
$keywords = input('keywords', '');
$sms_model = new Sms();
$edit_data_result = $sms_model->doEditSmsMessage($this->site_id);
if (empty($edit_data_result['data'][ 0 ]))
$this->error('没有开启的短信方式!');
$edit_data = $edit_data_result['data'][ 0 ];
$edit_url = $edit_data['shop_url'];
// file_put_contents(__DIR__ . '/debug.txt', var_export($edit_url,true));
$this->redirect(addon_url($edit_url, [ 'keywords' => $keywords ]));
}
/**
* 短信管理
*/
public function sms()
{
$sms_model = new Sms();
$list = $sms_model->getSmsType();
if (request()->isJson()) {
return $list;
} else {
$list = $list[ 'data' ];
if (count($list) == 1) {
foreach ($list as $k => $v) {
if ($v[ 'sms_type' ] == 'niusms') {
$this->redirect(addon_url('niusms://shop/sms/index'));
}
}
}
return $this->fetch('message/sms');
}
}
/**
* 短信记录
*/
public function smsRecords()
{
if (request()->isJson()) {
$sms_model = new Sms();
$page = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$search_text = input('search_text', '');
$status = input('status', 'all');
$condition = [ [ 'site_id', '=', $this->site_id ] ];
if (!empty($search_text)) {
$condition[] = ['keywords_name', 'like', '%' . $search_text . '%'];
}
if (!empty($status) && $status != 'all') {
if ($status == -1) {
$condition[] = [ 'status', 'not in', [ 0, 1, '' ] ];
} else {
$condition[] = [ 'status', '=', $status - 1 ];
}
}
$list = $sms_model->getSmsRecordsPageList($condition, $page, $page_size);
return $list;
} else {
$sms_data = [
'total_num' => 0,
'sms_num' => 0,
'sms_used_num' => 0
];
$this->assign('sms_data', $sms_data);
return $this->fetch('message/smsrecords');
}
}
/**
* 删除短信记录
*/
public function deleteSmsRecords()
{
if (request()->isJson()) {
$ids = input('ids', '');
$sms_model = new Sms();
$condition = array (
['id', 'in', $ids ]
);
$result = $sms_model->deleteSmsRecords($condition);
return $result;
}
}
/**
* 编辑短信模板(跳转)
*/
public function editEmailMessage()
{
$message_model = new MessageModel();
$keywords = input('keywords', '');
$info_result = $message_model->getMessageInfo($this->site_id, $keywords);
$info = $info_result['data'];
if (request()->isJson()) {
if (empty($info))
return error(-1, '不存在的模板信息!');
$email_title = input('email_title', '');//邮件标题
$email_content = input('email_content', '');//邮件内容
$email_is_open = input('email_is_open', 0);//邮件开关
$data = array (
'email_title' => $email_title,
'email_content' => $email_content,
'email_is_open' => $email_is_open,
);
$condition = array (
['keywords', '=', $keywords ],
[ 'site_id', '=', $this->site_id ],
[ 'app_module', '=', $this->app_module ]
);
$this->addLog('编辑邮箱模板:' . $keywords);
$res = $message_model->editMessage($data, $condition);
return $res;
} else {
if (empty($info))
$this->error('不存在的模板信息!');
$email_title = $info['email_title'];//邮件标题
$email_content = $info['email_content'];//邮件内容
$email_is_open = $info['email_is_open'];//邮件开关
$this->assign('email_title', $email_title);
$this->assign('email_content', $email_content);
$this->assign('email_is_open', $email_is_open);
$this->assign('keywords', $keywords);
//模板变量
$message_variable_list = $info['message_json_array'];
$this->assign('message_variable_list', $message_variable_list);
return $this->fetch('message/edit_email_message');
}
}
/**
* 消息通知时间设置
*/
public function remindTimeSetting()
{
if (request()->isJson()) {
$keyword = input('keyword', '');
$hour = input('hour', 24);
$config_model = new OrderConfigModel();
$data = $config_model->getOrderVerifyConfig($this->site_id, $this->app_module)[ 'data' ][ 'value' ];
$data[ $keyword ] = $hour;
return $config_model->setOrderVerifyConfig($data, $this->site_id, $this->app_module);
} else {
return $this->fetch('message/lists');
}
}
}

View File

@@ -1,203 +1,195 @@
<?php
/**
*/
namespace app\shop\controller;
use app\model\web\Notice as NoticeModel;
/**
* 网站公告
*/
class Notice extends BaseShop
{
/**
* 公告管理
* @return \think\mixed
*/
public function index()
{
if (request()->isJson()) {
$page = input('page', 1);
$limit = input('page_size', PAGE_LIST_ROWS);
$search_text = input('search_text', '');
$condition = [ [ 'site_id', '=', $this->site_id ] ];
$notice = new NoticeModel();
if ($search_text) $condition[] = [ 'title', 'like', '%' . $search_text . '%' ];
//排序
$link_sort = input('order', 'sort');
$sort = input('sort', 'desc');
if ($link_sort == 'sort') {
$order_by = $link_sort . ' ' . $sort;
} else {
$order_by = $link_sort . ' ' . $sort . ',sort desc';
}
$list = $notice->getNoticePageList($condition, $page, $limit, $order_by);
foreach ($list[ 'data' ][ 'list' ] as $key => $val) {
$list[ 'data' ][ 'list' ][ $key ][ 'content' ] = preg_replace('/[^\x{4e00}-\x{9fa5}^0-9^A-Z^a-z]+/u', '', $val[ 'content' ]);
}
return $list;
} else {
return $this->fetch('notice/index');
}
}
/**
* 公告管理
* @return \think\mixed
*/
public function noticeSelect()
{
if (request()->isJson()) {
$page = input('page', 1);
$limit = input('page_size', PAGE_LIST_ROWS);
$condition = [ [ 'site_id', '=', $this->site_id ] ];
$notice = new NoticeModel();
$list = $notice->getNoticePageList($condition, $page, $limit);
return $list;
} else {
$select_id = input('select_id', '');
$this->assign('select_id', $select_id);
return $this->fetch('notice/notice_select');
}
}
/**
* 公告add
*/
public function addNotice()
{
if (request()->isJson()) {
$data = [
'site_id' => $this->site_id,
'title' => input('title', ''),
'content' => input('content', ''),
'is_top' => input('is_top', 0),
'create_time' => time(),
'receiving_type' => input('receiving_type', 'mobile'),
'receiving_name' => input('receiving_name', '手机端')
];
// if (!empty($data['receiving_type'])) {
// $data['receiving_name'] .= in_array('mobile', $data['receiving_type']) ? ' 手机端' : '';
// $data['receiving_type'] = implode(',', $data['receiving_type']);
// }
$notice = new NoticeModel();
$this->addLog('发布公告:' . $data[ 'title' ]);
$res = $notice->addNotice($data);
return $res;
} else {
return $this->fetch('notice/add_notice');
}
}
/**
* 公告编辑
*/
public function editNotice()
{
$notice = new NoticeModel();
if (request()->isJson()) {
$id = input('id', 0);
$data = [
'site_id' => $this->site_id,
'title' => input('title', ''),
'content' => input('content', ''),
'is_top' => input('is_top', 0),
'receiving_type' => input('receiving_type', 'mobile'),
'receiving_name' => input('receiving_name', '手机端')
];
// if (!empty($data['receiving_type'])) {
// $data['receiving_name'] .= in_array('mobile', $data['receiving_type']) ? ' 手机端' : '';
// $data['receiving_type'] = implode(',', $data['receiving_type']);
// }
$res = $notice->editNotice($data, [ [ 'id', '=', $id ] ]);
return $res;
} else {
$id = input('id', 0);
$info = $notice->getNoticeInfo([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ]);
$this->assign('info', $info[ 'data' ]);
echo $this->fetch('notice/edit_notice');
}
}
/**
* 公告删除
* @return string[]|array
*/
public function deleteNotice()
{
if (request()->isJson()) {
$id = input('id', '');
$notice = new NoticeModel();
$res = $notice->deleteNotice([ [ 'id', 'in', $id ], [ 'site_id', '=', $this->site_id ] ]);
return $res;
}
}
/**
* 公告置顶
*/
public function modifyNoticeTop()
{
$id = input('id', '');
$notice = new NoticeModel();
$res = $notice->editNotice([ 'is_top' => 1 ], [ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ]);
return $res;
}
/**
* 公告详情
*/
public function detail()
{
$id = input('id', 1);
$notice_model = new NoticeModel();
$info = $notice_model->getNoticeInfo([ [ 'id', '=', $id ] ]);
$this->assign('info', $info[ 'data' ]);
return $this->fetch('notice/detail');
}
/**
* 修改排序
*/
public function modifySort()
{
$sort = input('sort', 0);
$id = input('id', 0);
$notice_model = new NoticeModel();
return $notice_model->modifyNoticeSort($sort, $id);
}
/**
* 推广
* @return array
*/
public function promote()
{
if (request()->isJson()) {
$notice_id = input('notice_id', 0);
$app_type = input('app_type', 'all');
$notice_model = new NoticeModel();
$notice_info = $notice_model->getNoticeInfo([ [ 'id', '=', $notice_id ] ], 'id')[ 'data' ];
if (!empty($notice_info)) {
$res = $notice_model->urlQrcode([ 'notice_id' => $notice_id ], $app_type, $this->site_id);
return $res;
}
}
}
<?php
namespace app\shop\controller;
use app\model\web\Notice as NoticeModel;
/**
* 网站公告
*/
class Notice extends BaseShop
{
/**
* 公告管理
* @return \think\mixed
*/
public function index()
{
if (request()->isJson()) {
$page = input('page', 1);
$limit = input('page_size', PAGE_LIST_ROWS);
$search_text = input('search_text', '');
$condition = [ [ 'site_id', '=', $this->site_id ] ];
$notice = new NoticeModel();
if ($search_text) $condition[] = [ 'title', 'like', '%' . $search_text . '%' ];
//排序
$link_sort = input('order', 'sort');
$sort = input('sort', 'desc');
if ($link_sort == 'sort') {
$order_by = $link_sort . ' ' . $sort;
} else {
$order_by = $link_sort . ' ' . $sort . ',sort desc';
}
$list = $notice->getNoticePageList($condition, $page, $limit, $order_by);
foreach ($list[ 'data' ][ 'list' ] as $key => $val) {
$list[ 'data' ][ 'list' ][ $key ][ 'content' ] = preg_replace('/[^\x{4e00}-\x{9fa5}^0-9^A-Z^a-z]+/u', '', $val[ 'content' ]);
}
return $list;
} else {
return $this->fetch('notice/index');
}
}
/**
* 公告管理
* @return \think\mixed
*/
public function noticeSelect()
{
if (request()->isJson()) {
$page = input('page', 1);
$limit = input('page_size', PAGE_LIST_ROWS);
$condition = [ [ 'site_id', '=', $this->site_id ] ];
$notice = new NoticeModel();
$list = $notice->getNoticePageList($condition, $page, $limit);
return $list;
} else {
$select_id = input('select_id', '');
$this->assign('select_id', $select_id);
return $this->fetch('notice/notice_select');
}
}
/**
* 公告add
*/
public function addNotice()
{
if (request()->isJson()) {
$data = [
'site_id' => $this->site_id,
'title' => input('title', ''),
'content' => input('content', ''),
'is_top' => input('is_top', 0),
'create_time' => time(),
'receiving_type' => input('receiving_type', 'mobile'),
'receiving_name' => input('receiving_name', '手机端')
];
// if (!empty($data['receiving_type'])) {
// $data['receiving_name'] .= in_array('mobile', $data['receiving_type']) ? ' 手机端' : '';
// $data['receiving_type'] = implode(',', $data['receiving_type']);
// }
$notice = new NoticeModel();
$this->addLog('发布公告:' . $data[ 'title' ]);
$res = $notice->addNotice($data);
return $res;
} else {
return $this->fetch('notice/add_notice');
}
}
/**
* 公告编辑
*/
public function editNotice()
{
$notice = new NoticeModel();
if (request()->isJson()) {
$id = input('id', 0);
$data = [
'site_id' => $this->site_id,
'title' => input('title', ''),
'content' => input('content', ''),
'is_top' => input('is_top', 0),
'receiving_type' => input('receiving_type', 'mobile'),
'receiving_name' => input('receiving_name', '手机端')
];
// if (!empty($data['receiving_type'])) {
// $data['receiving_name'] .= in_array('mobile', $data['receiving_type']) ? ' 手机端' : '';
// $data['receiving_type'] = implode(',', $data['receiving_type']);
// }
$res = $notice->editNotice($data, [ [ 'id', '=', $id ] ]);
return $res;
} else {
$id = input('id', 0);
$info = $notice->getNoticeInfo([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ]);
$this->assign('info', $info[ 'data' ]);
echo $this->fetch('notice/edit_notice');
}
}
/**
* 公告删除
* @return string[]|array
*/
public function deleteNotice()
{
if (request()->isJson()) {
$id = input('id', '');
$notice = new NoticeModel();
$res = $notice->deleteNotice([ [ 'id', 'in', $id ], [ 'site_id', '=', $this->site_id ] ]);
return $res;
}
}
/**
* 公告置顶
*/
public function modifyNoticeTop()
{
$id = input('id', '');
$notice = new NoticeModel();
$res = $notice->editNotice([ 'is_top' => 1 ], [ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ]);
return $res;
}
/**
* 公告详情
*/
public function detail()
{
$id = input('id', 1);
$notice_model = new NoticeModel();
$info = $notice_model->getNoticeInfo([ [ 'id', '=', $id ] ]);
$this->assign('info', $info[ 'data' ]);
return $this->fetch('notice/detail');
}
/**
* 修改排序
*/
public function modifySort()
{
$sort = input('sort', 0);
$id = input('id', 0);
$notice_model = new NoticeModel();
return $notice_model->modifyNoticeSort($sort, $id);
}
/**
* 推广
* @return array
*/
public function promote()
{
if (request()->isJson()) {
$notice_id = input('notice_id', 0);
$app_type = input('app_type', 'all');
$notice_model = new NoticeModel();
$notice_info = $notice_model->getNoticeInfo([ [ 'id', '=', $notice_id ] ], 'id')[ 'data' ];
if (!empty($notice_info)) {
$res = $notice_model->urlQrcode([ 'notice_id' => $notice_id ], $app_type, $this->site_id);
return $res;
}
}
}
}

View File

@@ -1,285 +1,277 @@
<?php
/**
*/
namespace app\shop\controller;
use app\model\order\OrderImportFile as OrderImportFileModel;
use app\model\order\OrderCommon as OrderCommonModel;
use app\model\order\Order as OrderModel;
use addon\electronicsheet\model\ExpressElectronicsheet as ExpressElectronicsheetModel;
use app\model\express\ExpressCompany;
use phpoffice\phpexcel\Classes\PHPExcel;
use phpoffice\phpexcel\Classes\PHPExcel\Writer\Excel2007;
/**
* 配送
* Class Express
* @package app\shop\controller
*/
class Orderimportfile extends BaseShop
{
/**
* 批量发货(订单导入)
* @return array|mixed
*/
public function lists()
{
//电子面单插件
$addon_is_exit = addon_is_exit('electronicsheet', $this->site_id);
if (request()->isJson()) {
$page_index = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$model = new OrderImportFileModel();
$list = $model->getOrderImportFilePageList([ [ 'site_id', '=', $this->site_id ] ], $page_index, $page_size);
return $list;
}
$this->assign('addon_is_exit', $addon_is_exit);
return $this->fetch('orderimportfile/lists');
}
/**
* 导出待发货订单
*/
public function exportDeliveryOrder()
{
//电子面单插件
$addon_is_exit = addon_is_exit('electronicsheet', $this->site_id);
$order_model = new OrderModel();
$order_status_list = $order_model->delivery_order_status;
$condition = [
[ 'order_status', 'in', array_keys($order_status_list) ],
[ 'order_type', '=', 1 ],
[ 'site_id', '=', $this->site_id ],
[ 'is_delete', '=', 0 ]
];
$order_common_model = new OrderCommonModel();
$field = 'order_no,order_name,full_address,address,name,mobile';
$list_result = $order_common_model->getOrderList($condition, $field, 'create_time desc');
$list = $list_result[ 'data' ];
// 实例化excel
$phpExcel = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
$phpExcel->getProperties()->setTitle('待发货订单');
$phpExcel->getProperties()->setSubject('待发货订单');
//单独添加列名称
$phpExcel->setActiveSheetIndex(0);
$phpExcel->getActiveSheet()->getColumnDimension('A')->setWidth(20);
$phpExcel->getActiveSheet()->getColumnDimension('B')->setWidth(50);
$phpExcel->getActiveSheet()->getColumnDimension('C')->setWidth(20);
$phpExcel->getActiveSheet()->getColumnDimension('D')->setWidth(32);
$phpExcel->getActiveSheet()->getColumnDimension('E')->setWidth(70);
$phpExcel->getActiveSheet()->getColumnDimension('F')->setWidth(32);
$phpExcel->getActiveSheet()->getColumnDimension('G')->setWidth(50);
$phpExcel->getActiveSheet()->getColumnDimension('H')->setWidth(48);
$phpExcel->getActiveSheet()->setCellValue('A1', '订单编号');
$phpExcel->getActiveSheet()->setCellValue('B1', '订单内容');
$phpExcel->getActiveSheet()->setCellValue('C1', '收件人姓名');
$phpExcel->getActiveSheet()->setCellValue('D1', '收件人电话');
$phpExcel->getActiveSheet()->setCellValue('E1', '收件人地址');
if ($addon_is_exit == 1) {
$phpExcel->getActiveSheet()->setCellValue('F1', '发货方式(手动发货/电子面单)');
$phpExcel->getActiveSheet()->setCellValue('G1', '物流公司名称(电子面单发货时为面单模板名称)');
$phpExcel->getActiveSheet()->setCellValue('H1', '物流单号(手动发货无需物流和电子面单时为空)');
} else {
$phpExcel->getActiveSheet()->setCellValue('F1', '发货方式');
$phpExcel->getActiveSheet()->setCellValue('G1', '物流公司名称');
$phpExcel->getActiveSheet()->setCellValue('H1', '物流单号(无需物流时为空)');
}
foreach ($list as $k => $v) {
$start = $k + 2;
$phpExcel->getActiveSheet()->setCellValue('A' . $start, $v[ 'order_no' ] . ' ');
$phpExcel->getActiveSheet()->setCellValue('B' . $start, $v[ 'order_name' ] . "\t");
$phpExcel->getActiveSheet()->setCellValue('C' . $start, $v[ 'name' ] . ' ');
$phpExcel->getActiveSheet()->setCellValue('D' . $start, $v[ 'mobile' ] . ' ');
$phpExcel->getActiveSheet()->setCellValue('E' . $start, $v[ 'full_address' ] . $v[ 'address' ] . "\t");
$phpExcel->getActiveSheet()->setCellValue('F' . $start, '');
$phpExcel->getActiveSheet()->setCellValue('G' . $start, '');
$phpExcel->getActiveSheet()->setCellValue('H' . $start, '');
}
// 重命名工作sheet
$phpExcel->getActiveSheet()->setTitle('待发货订单');
// 设置第一个sheet为工作的sheet
$phpExcel->setActiveSheetIndex(0);
// 保存Excel 2007格式文件保存路径为当前路径名字为export.xlsx
$objWriter = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($phpExcel, 'Xlsx');
$file = date('Y年m月d日-待发货订单', time()) . '.xlsx';
$objWriter->save($file);
header('Content-type:application/octet-stream');
$filename = basename($file);
header('Content-Disposition:attachment;filename = ' . $filename);
header('Accept-ranges:bytes');
header('Accept-length:' . filesize($file));
readfile($file);
unlink($file);
exit;
}
/**
* 导出物流公司和电子面单模板
*/
public function exportExpressTemplate()
{
//电子面单插件
$addon_is_exit = addon_is_exit('electronicsheet', $this->site_id);
$express_company_model = new ExpressCompany();
//店铺物流公司
$result = $express_company_model->getExpressCompanyList([ ['site_id', '=', $this->site_id ] ]);
$list = $result[ 'data' ];
// 实例化excel
$phpExcel = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
//单独添加列名称
$phpExcel->setActiveSheetIndex(0);
$phpExcel->getActiveSheet()->getColumnDimension('A')->setWidth(30);
$phpExcel->getActiveSheet()->getColumnDimension('B')->setWidth(15);
$phpExcel->getActiveSheet()->setCellValue('A1', '物流公司');
$phpExcel->getActiveSheet()->setCellValue('B1', '物流公司编码');
foreach ($list as $k => $v) {
$start = $k + 2;
$phpExcel->getActiveSheet()->setCellValue('A' . $start, $v[ 'company_name' ] . "\t");
$phpExcel->getActiveSheet()->setCellValue('B' . $start, $v[ 'express_no' ]);
}
// 重命名工作sheet
$phpExcel->getActiveSheet()->setTitle('物流公司');
if ($addon_is_exit == 1) {
//获取电子面单模板
$electronicsheet_model = new ExpressElectronicsheetModel();
$condition[] = [ 'site_id', '=', $this->site_id ];
$field = 'id,template_name,company_name';
$electronicsheet_list_result = $electronicsheet_model->getExpressElectronicsheetList($condition, $field, 'is_default desc');
$electronicsheet_list = $electronicsheet_list_result[ 'data' ];
$phpExcel->createSheet();
$phpExcel->setActiveSheetIndex(1);
$phpExcel->getActiveSheet()->getColumnDimension('A')->setWidth(30);
$phpExcel->getActiveSheet()->getColumnDimension('B')->setWidth(30);
$phpExcel->getActiveSheet()->setCellValue('A1', '电子面单模板名称');
$phpExcel->getActiveSheet()->setCellValue('B1', '物流公司');
foreach ($electronicsheet_list as $k => $v) {
$start = $k + 2;
$phpExcel->getActiveSheet()->setCellValue('A' . $start, $v[ 'template_name' ] . "\t");
$phpExcel->getActiveSheet()->setCellValue('B' . $start, $v[ 'company_name' ] . "\t");
}
$phpExcel->getActiveSheet()->setTitle('电子面单');
}
// 设置第一个sheet为工作的sheet
$phpExcel->setActiveSheetIndex(0);
// 保存Excel 2007格式文件保存路径为当前路径名字为export.xlsx
$objWriter = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($phpExcel, 'Xlsx');
if ($addon_is_exit == 1) {
$file = date('Y年m月d日-物流公司和电子面单对照表', time()) . '.xlsx';
} else {
$file = date('Y年m月d日-物流公司对照表', time()) . '.xlsx';
}
$objWriter->save($file);
header('Content-type:application/octet-stream');
$filename = basename($file);
header('Content-Disposition:attachment;filename = ' . $filename);
header('Accept-ranges:bytes');
header('Accept-length:' . filesize($file));
readfile($file);
unlink($file);
exit;
}
/**
* 导入订单发货
*/
public function importOrder()
{
if (request()->isJson()) {
$filename = input('filename', '');
$path = input('path', '');
$order_model = new OrderModel();
$res = $order_model->orderFileDelivery([ 'filename' => $filename, 'path' => $path ], $this->site_id, $this->uid);
return $res;
}
}
/**
* 删除导入的订单文件记录
*/
public function delete()
{
if (request()->isJson()) {
$id = input('id', '');
$model = new OrderimportfileModel();
$res = $model->deleteOrderImportFile($id, $this->site_id);
return $res;
}
}
/**
* 导入记录
* @return array|mixed
*/
public function detail()
{
$model = new OrderImportFileModel();
$file_id = input('file_id', 0);
if (request()->isJson()) {
$condition = [
[ 'oif.site_id', '=', $this->site_id ],
[ 'oif.file_id', '=', $file_id ]
];
$page_index = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$status = input('status', '');
if ($status !== '') {
$condition[] = [ 'oif.status', '=', $status ];
}
$field = 'oif.*, o.order_id';
$alias = 'oif';
$join = [
[ 'order o', 'oif.order_no = o.order_no', 'left' ]
];
$list = $model->getOrderImportFilePageLogList($condition, $page_index, $page_size, 'oif.id desc', $field, $alias, $join);
return $list;
}
$this->assign('file_id', $file_id);
$info = $model->getOrderImportFileInfo([ [ 'id', '=', $file_id ], [ 'site_id', '=', $this->site_id ] ]);
if (empty($info[ 'data' ])) $this->error('未获取到导入数据', href_url('shop/orderimportfile/lists'));
$this->assign('info', $info[ 'data' ]);
return $this->fetch('orderimportfile/detail');
}
<?php
namespace app\shop\controller;
use app\model\order\OrderImportFile as OrderImportFileModel;
use app\model\order\OrderCommon as OrderCommonModel;
use app\model\order\Order as OrderModel;
use addon\electronicsheet\model\ExpressElectronicsheet as ExpressElectronicsheetModel;
use app\model\express\ExpressCompany;
use phpoffice\phpexcel\Classes\PHPExcel;
use phpoffice\phpexcel\Classes\PHPExcel\Writer\Excel2007;
/**
* 配送
* Class Express
* @package app\shop\controller
*/
class Orderimportfile extends BaseShop
{
/**
* 批量发货(订单导入)
* @return array|mixed
*/
public function lists()
{
//电子面单插件
$addon_is_exit = addon_is_exit('electronicsheet', $this->site_id);
if (request()->isJson()) {
$page_index = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$model = new OrderImportFileModel();
$list = $model->getOrderImportFilePageList([ [ 'site_id', '=', $this->site_id ] ], $page_index, $page_size);
return $list;
}
$this->assign('addon_is_exit', $addon_is_exit);
return $this->fetch('orderimportfile/lists');
}
/**
* 导出待发货订单
*/
public function exportDeliveryOrder()
{
//电子面单插件
$addon_is_exit = addon_is_exit('electronicsheet', $this->site_id);
$order_model = new OrderModel();
$order_status_list = $order_model->delivery_order_status;
$condition = [
[ 'order_status', 'in', array_keys($order_status_list) ],
[ 'order_type', '=', 1 ],
[ 'site_id', '=', $this->site_id ],
[ 'is_delete', '=', 0 ]
];
$order_common_model = new OrderCommonModel();
$field = 'order_no,order_name,full_address,address,name,mobile';
$list_result = $order_common_model->getOrderList($condition, $field, 'create_time desc');
$list = $list_result[ 'data' ];
// 实例化excel
$phpExcel = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
$phpExcel->getProperties()->setTitle('待发货订单');
$phpExcel->getProperties()->setSubject('待发货订单');
//单独添加列名称
$phpExcel->setActiveSheetIndex(0);
$phpExcel->getActiveSheet()->getColumnDimension('A')->setWidth(20);
$phpExcel->getActiveSheet()->getColumnDimension('B')->setWidth(50);
$phpExcel->getActiveSheet()->getColumnDimension('C')->setWidth(20);
$phpExcel->getActiveSheet()->getColumnDimension('D')->setWidth(32);
$phpExcel->getActiveSheet()->getColumnDimension('E')->setWidth(70);
$phpExcel->getActiveSheet()->getColumnDimension('F')->setWidth(32);
$phpExcel->getActiveSheet()->getColumnDimension('G')->setWidth(50);
$phpExcel->getActiveSheet()->getColumnDimension('H')->setWidth(48);
$phpExcel->getActiveSheet()->setCellValue('A1', '订单编号');
$phpExcel->getActiveSheet()->setCellValue('B1', '订单内容');
$phpExcel->getActiveSheet()->setCellValue('C1', '收件人姓名');
$phpExcel->getActiveSheet()->setCellValue('D1', '收件人电话');
$phpExcel->getActiveSheet()->setCellValue('E1', '收件人地址');
if ($addon_is_exit == 1) {
$phpExcel->getActiveSheet()->setCellValue('F1', '发货方式(手动发货/电子面单)');
$phpExcel->getActiveSheet()->setCellValue('G1', '物流公司名称(电子面单发货时为面单模板名称)');
$phpExcel->getActiveSheet()->setCellValue('H1', '物流单号(手动发货无需物流和电子面单时为空)');
} else {
$phpExcel->getActiveSheet()->setCellValue('F1', '发货方式');
$phpExcel->getActiveSheet()->setCellValue('G1', '物流公司名称');
$phpExcel->getActiveSheet()->setCellValue('H1', '物流单号(无需物流时为空)');
}
foreach ($list as $k => $v) {
$start = $k + 2;
$phpExcel->getActiveSheet()->setCellValue('A' . $start, $v[ 'order_no' ] . ' ');
$phpExcel->getActiveSheet()->setCellValue('B' . $start, $v[ 'order_name' ] . "\t");
$phpExcel->getActiveSheet()->setCellValue('C' . $start, $v[ 'name' ] . ' ');
$phpExcel->getActiveSheet()->setCellValue('D' . $start, $v[ 'mobile' ] . ' ');
$phpExcel->getActiveSheet()->setCellValue('E' . $start, $v[ 'full_address' ] . $v[ 'address' ] . "\t");
$phpExcel->getActiveSheet()->setCellValue('F' . $start, '');
$phpExcel->getActiveSheet()->setCellValue('G' . $start, '');
$phpExcel->getActiveSheet()->setCellValue('H' . $start, '');
}
// 重命名工作sheet
$phpExcel->getActiveSheet()->setTitle('待发货订单');
// 设置第一个sheet为工作的sheet
$phpExcel->setActiveSheetIndex(0);
// 保存Excel 2007格式文件保存路径为当前路径名字为export.xlsx
$objWriter = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($phpExcel, 'Xlsx');
$file = date('Y年m月d日-待发货订单', time()) . '.xlsx';
$objWriter->save($file);
header('Content-type:application/octet-stream');
$filename = basename($file);
header('Content-Disposition:attachment;filename = ' . $filename);
header('Accept-ranges:bytes');
header('Accept-length:' . filesize($file));
readfile($file);
unlink($file);
exit;
}
/**
* 导出物流公司和电子面单模板
*/
public function exportExpressTemplate()
{
//电子面单插件
$addon_is_exit = addon_is_exit('electronicsheet', $this->site_id);
$express_company_model = new ExpressCompany();
//店铺物流公司
$result = $express_company_model->getExpressCompanyList([ ['site_id', '=', $this->site_id ] ]);
$list = $result[ 'data' ];
// 实例化excel
$phpExcel = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
//单独添加列名称
$phpExcel->setActiveSheetIndex(0);
$phpExcel->getActiveSheet()->getColumnDimension('A')->setWidth(30);
$phpExcel->getActiveSheet()->getColumnDimension('B')->setWidth(15);
$phpExcel->getActiveSheet()->setCellValue('A1', '物流公司');
$phpExcel->getActiveSheet()->setCellValue('B1', '物流公司编码');
foreach ($list as $k => $v) {
$start = $k + 2;
$phpExcel->getActiveSheet()->setCellValue('A' . $start, $v[ 'company_name' ] . "\t");
$phpExcel->getActiveSheet()->setCellValue('B' . $start, $v[ 'express_no' ]);
}
// 重命名工作sheet
$phpExcel->getActiveSheet()->setTitle('物流公司');
if ($addon_is_exit == 1) {
//获取电子面单模板
$electronicsheet_model = new ExpressElectronicsheetModel();
$condition[] = [ 'site_id', '=', $this->site_id ];
$field = 'id,template_name,company_name';
$electronicsheet_list_result = $electronicsheet_model->getExpressElectronicsheetList($condition, $field, 'is_default desc');
$electronicsheet_list = $electronicsheet_list_result[ 'data' ];
$phpExcel->createSheet();
$phpExcel->setActiveSheetIndex(1);
$phpExcel->getActiveSheet()->getColumnDimension('A')->setWidth(30);
$phpExcel->getActiveSheet()->getColumnDimension('B')->setWidth(30);
$phpExcel->getActiveSheet()->setCellValue('A1', '电子面单模板名称');
$phpExcel->getActiveSheet()->setCellValue('B1', '物流公司');
foreach ($electronicsheet_list as $k => $v) {
$start = $k + 2;
$phpExcel->getActiveSheet()->setCellValue('A' . $start, $v[ 'template_name' ] . "\t");
$phpExcel->getActiveSheet()->setCellValue('B' . $start, $v[ 'company_name' ] . "\t");
}
$phpExcel->getActiveSheet()->setTitle('电子面单');
}
// 设置第一个sheet为工作的sheet
$phpExcel->setActiveSheetIndex(0);
// 保存Excel 2007格式文件保存路径为当前路径名字为export.xlsx
$objWriter = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($phpExcel, 'Xlsx');
if ($addon_is_exit == 1) {
$file = date('Y年m月d日-物流公司和电子面单对照表', time()) . '.xlsx';
} else {
$file = date('Y年m月d日-物流公司对照表', time()) . '.xlsx';
}
$objWriter->save($file);
header('Content-type:application/octet-stream');
$filename = basename($file);
header('Content-Disposition:attachment;filename = ' . $filename);
header('Accept-ranges:bytes');
header('Accept-length:' . filesize($file));
readfile($file);
unlink($file);
exit;
}
/**
* 导入订单发货
*/
public function importOrder()
{
if (request()->isJson()) {
$filename = input('filename', '');
$path = input('path', '');
$order_model = new OrderModel();
$res = $order_model->orderFileDelivery([ 'filename' => $filename, 'path' => $path ], $this->site_id, $this->uid);
return $res;
}
}
/**
* 删除导入的订单文件记录
*/
public function delete()
{
if (request()->isJson()) {
$id = input('id', '');
$model = new OrderimportfileModel();
$res = $model->deleteOrderImportFile($id, $this->site_id);
return $res;
}
}
/**
* 导入记录
* @return array|mixed
*/
public function detail()
{
$model = new OrderImportFileModel();
$file_id = input('file_id', 0);
if (request()->isJson()) {
$condition = [
[ 'oif.site_id', '=', $this->site_id ],
[ 'oif.file_id', '=', $file_id ]
];
$page_index = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$status = input('status', '');
if ($status !== '') {
$condition[] = [ 'oif.status', '=', $status ];
}
$field = 'oif.*, o.order_id';
$alias = 'oif';
$join = [
[ 'order o', 'oif.order_no = o.order_no', 'left' ]
];
$list = $model->getOrderImportFilePageLogList($condition, $page_index, $page_size, 'oif.id desc', $field, $alias, $join);
return $list;
}
$this->assign('file_id', $file_id);
$info = $model->getOrderImportFileInfo([ [ 'id', '=', $file_id ], [ 'site_id', '=', $this->site_id ] ]);
if (empty($info[ 'data' ])) $this->error('未获取到导入数据', href_url('shop/orderimportfile/lists'));
$this->assign('info', $info[ 'data' ]);
return $this->fetch('orderimportfile/detail');
}
}

View File

@@ -1,404 +1,396 @@
<?php
/**
*/
namespace app\shop\controller;
use app\dict\order_refund\OrderRefundDict;
use app\model\order\multitype;
use app\model\order\OrderCommon;
use app\model\order\OrderRefund as OrderRefundModel;
use app\model\order\OrderExport;
use app\model\member\Member;
/**
* 订单维权
* Class Orderrefund
* @package app\shop\controller
*/
class Orderrefund extends BaseShop
{
/**
* 维权订单列表
* @return mixed
*/
public function lists()
{
$refund_status = input('refund_status', '');//退款状态
$sku_name = input('sku_name', '');//商品名称
$refund_type = input('refund_type', '');//退款方式
$start_time = input('start_time', '');//开始时间
$end_time = input('end_time', '');//结束时间
$order_no = input('order_no', '');//订单编号
$delivery_status = input('delivery_status', '');//物流状态
$refund_no = input('refund_no', '');//退款编号
$delivery_no = input('delivery_no', '');//物流编号
$refund_delivery_no = input('refund_delivery_no', '');//退款物流编号
$refund_mode = input('refund_mode', '');//退款类型
$order_refund_model = new OrderRefundModel();
if (request()->isJson()) {
$page_index = input('page', 1);
$page_size = input('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', '<>', OrderRefundDict::REFUND_NOT_APPLY ];
}
//物流状态
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 ($refund_mode == 1) {
$condition[] = ['nop.refund_mode', 'in', [ 0, 1 ] ];
} else if ($refund_mode == 2) {
$condition[] = ['nop.refund_mode', '=', 2 ];
}
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) ] ];
}
return $order_refund_model->getRefundOrderGoodsPageList($condition, $page_index, $page_size, 'nop.refund_action_time desc');
} else {
$this->assign('refund_status_list', OrderRefundDict::getStatus());//退款状态
$this->assign('refund_type_list', OrderRefundDict::getRefundType());//退款方式
return $this->fetch('orderrefund/lists');
}
}
/**
* 维权订单详情
* @return mixed
*/
public function detail()
{
$order_goods_id = input('order_goods_id', 0);
//维权订单项信息
$order_refund_model = new OrderRefundModel();
$detail = $order_refund_model->getRefundDetail($order_goods_id)[ 'data' ];
if (empty($detail))
$this->error('未获取到维权信息', href_url('shop/orderrefund/lists'));
$order_common_model = new OrderCommon();
// $order_info_result = $order_common_model->getOrderInfo([["order_id", "=", $detail["order_id"]]]);
$order_info_result = $order_common_model->getOrderDetail($detail['order_id']);
$order_info = $order_info_result['data'];
if (empty($order_info))
$this->error('未获取到维权信息', href_url('shop/orderrefund/lists'));
$template = 'orderrefund/detail';
if ($order_info['order_type'] == 4) {
$template = 'orderrefund/virtualdetail';
}
//添加会员昵称
$member = new Member();
$member_info = $member->getMemberInfo([ ['member_id', '=', $order_info[ 'member_id' ] ] ], 'nickname')[ 'data' ] ?? [];
$order_info[ 'nickname' ] = $member_info[ 'nickname' ] ?? '';
$this->assign('detail', $detail);
$this->assign('order_info', $order_info);
return $this->fetch($template);
}
/**
* 维权拒绝
* @return array
*/
public function refuse()
{
$order_goods_id = input('order_goods_id', 0);
$refund_refuse_reason = input('refund_refuse_reason', '');
$order_refund_model = new OrderRefundModel();
$data = [
'order_goods_id' => $order_goods_id,
'refund_refuse_reason' => $refund_refuse_reason
];
$log_data = [
'uid' => $this->user_info[ 'uid' ],
'nick_name' => $this->user_info[ 'username' ],
'action' => '商家拒绝了维权',
'action_way' => 2
];
return $order_refund_model->orderRefundRefuse($data, $this->user_info, $refund_refuse_reason, $log_data);
}
/**
* 维权同意
* @return array
*/
public function agree()
{
$order_goods_id = input('order_goods_id', 0);
$order_refund_model = new OrderRefundModel();
$data = [
'order_goods_id' => $order_goods_id
];
return $order_refund_model->orderRefundConfirm($data, $this->user_info);
}
/**
* 维权收货
* @return array
*/
public function receive()
{
$order_goods_id = input('order_goods_id', 0);
$is_refund_stock = input('is_refund_stock', 0);//是否入库
$order_refund_model = new OrderRefundModel();
$data = [
'order_goods_id' => $order_goods_id,
'is_refund_stock' => $is_refund_stock
];
return $order_refund_model->orderRefundTakeDelivery($data, $this->user_info);
}
/**
* 维权通过
* @return array|null
*/
public function complete()
{
$order_goods_id = input('order_goods_id', 0);
$refund_money_type = input('refund_money_type', '');
$shop_refund_remark = input('shop_refund_remark', '');
$refund_real_money = input('refund_real_money', 0);
$is_deposit_back = input('is_deposit_back', 1);
$order_refund_model = new OrderRefundModel();
$data = [
'order_goods_id' => $order_goods_id,
'refund_money_type' => $refund_money_type,
'shop_refund_remark' => $shop_refund_remark,
'refund_real_money' => $refund_real_money,
'is_deposit_back' => $is_deposit_back
];
$log_data = [
'uid' => $this->user_info[ 'uid' ],
'nick_name' => $this->user_info[ 'username' ],
'action' => '商家对维权进行了转账,维权结束',
'action_way' => 2
];
return $order_refund_model->orderRefundFinish($data, $this->user_info, $log_data);
}
/**
* 订单导出(维权订单)
*/
public function exportRefundOrder()
{
$refund_status = input('refund_status', '');//退款状态
$sku_name = input('sku_name', '');//商品名称
$refund_type = input('refund_type', '');//退款方式
$start_time = input('start_time', '');//开始时间
$end_time = input('end_time', '');//结束时间
$order_no = input('order_no', '');//订单编号
$delivery_status = input('delivery_status', '');//物流状态
$refund_no = input('refund_no', '');//退款编号
$order_refund_model = new OrderRefundModel();
$delivery_no = input('delivery_no', '');//物流编号
$refund_delivery_no = input('refund_delivery_no', '');//退款物流编号
$condition_desc = [];
$condition[] = [ 'og.site_id', '=', $this->site_id ];
//退款状态
$refund_status_list = OrderRefundDict::getStatus();
$refund_status_name = '全部';
if ($refund_status != '') {
$condition[] = ['og.refund_status', '=', $refund_status ];
$refund_status_name = $refund_status_list[ $refund_status ][ 'name' ] ?? '';
} else {
$condition[] = ['og.refund_status', '<>', OrderRefundDict::REFUND_NOT_APPLY ];
}
$condition_desc[] = [ 'name' => '维权状态', 'value' => $refund_status_name ];
//物流状态
if ($delivery_status != '') {
$condition[] = ['og.delivery_status', '=', $delivery_status ];
}
//商品名称
$sku_name_value = '';
if ($sku_name != '') {
$condition[] = ['og.sku_name', 'like', "%$sku_name%" ];
$sku_name_value = $sku_name;
}
$condition_desc[] = [ 'name' => '商品名称', 'value' => $sku_name_value ];
//退款方式
$refund_type_name = '全部';
if ($refund_type != '') {
$condition[] = ['og.refund_type', '=', $refund_type ];
$refund_type_name = $order_refund_model->refund_type[ $refund_type ];
}
$condition_desc[] = [ 'name' => '退款方式', 'value' => $refund_type_name ];
//退款编号
if ($refund_no != '') {
$condition[] = [ 'og.refund_no', 'like', "%$refund_no%" ];
}
$condition_desc[] = [ 'name' => '退款编号', 'value' => $refund_no ];
//订单编号
if ($order_no != '') {
$condition[] = [ 'og.order_no', 'like', "%$order_no%" ];
}
$condition_desc[] = [ 'name' => '订单编号', 'value' => $order_no ];
//物流编号
if ($delivery_no != '') {
$condition[] = [ 'og.delivery_no', 'like', "%$delivery_no%" ];
}
//退款物流编号
if ($refund_delivery_no != '') {
$condition[] = [ 'og.refund_delivery_no', 'like', "%$refund_delivery_no%" ];
}
$time_name = '';
if (!empty($start_time) && empty($end_time)) {
$condition[] = [ 'og.refund_action_time', '>=', date_to_time($start_time) ];
$time_name = $start_time . '起';
} elseif (empty($start_time) && !empty($end_time)) {
$condition[] = [ 'og.refund_action_time', '<=', date_to_time($end_time) ];
$time_name = '至' . $end_time;
} elseif (!empty($start_time) && !empty($end_time)) {
$condition[] = [ 'og.refund_action_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
$time_name = $start_time . ' 至 ' . $end_time;
}
$condition_desc[] = [ 'name' => '申请时间', 'value' => $time_name ];
$order_export_model = new OrderExport();
return $order_export_model->orderRefundExport($condition, $condition_desc, $this->site_id);
}
/**
* 订单导出记录
* @return mixed
*/
public function export()
{
if (request()->isJson()) {
$page_index = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$export_model = new OrderExport();
$condition = [
[ 'site_id', '=', $this->site_id ]
];
return $export_model->getRefundExportPageList($condition, $page_index, $page_size, 'create_time desc', '*');
} else {
return $this->fetch('orderrefund/export');
}
}
/**
* 删除订单导出记录
*/
public function deleteExport()
{
if (request()->isJson()) {
$export_ids = input('export_ids', '');
$export_model = new OrderExport();
$condition = [
[ 'site_id', '=', $this->site_id ],
[ 'export_id', 'in', (string) $export_ids ]
];
return $export_model->deleteRefundExport($condition);
}
}
/**
* 关闭维权
* @return array|void
*/
public function close()
{
if (request()->isJson()) {
$order_goods_id = input('order_goods_id', 0);
$order_refund_model = new OrderRefundModel();
return $order_refund_model->orderRefundClose($order_goods_id, $this->site_id, $this->user_info);
}
}
/**
* 获取订单项退款信息
*/
public function getOrderGoodsRefundInfo()
{
if (request()->isJson()) {
$order_goods_id = input('order_goods_id', '');
$order_refund_model = new OrderRefundModel();
return $order_refund_model->getOrderGoodsRefundInfo($order_goods_id, $this->site_id);
}
}
/**
* 主动退款
* @return array|null
*/
public function shopActiveRefund()
{
$order_goods_id = input('order_goods_id', 0);
$refund_money_type = input('refund_money_type', '');
$shop_refund_remark = input('shop_refund_remark', '');
$do_refund_money = input('do_refund_money', '');
$order_refund_model = new OrderRefundModel();
$params = [
'site_id' => $this->site_id,
'app_module' => $this->app_module,
'refund_money_type' => $refund_money_type,
'shop_refund_remark' => $shop_refund_remark,
'user_info' => $this->user_info,
'order_goods_id' => $order_goods_id,
'do_refund_money' => $do_refund_money
];
return $order_refund_model->doOrderOrderRefund($params);
}
<?php
namespace app\shop\controller;
use app\dict\order_refund\OrderRefundDict;
use app\model\order\multitype;
use app\model\order\OrderCommon;
use app\model\order\OrderRefund as OrderRefundModel;
use app\model\order\OrderExport;
use app\model\member\Member;
/**
* 订单维权
* Class Orderrefund
* @package app\shop\controller
*/
class Orderrefund extends BaseShop
{
/**
* 维权订单列表
* @return mixed
*/
public function lists()
{
$refund_status = input('refund_status', '');//退款状态
$sku_name = input('sku_name', '');//商品名称
$refund_type = input('refund_type', '');//退款方式
$start_time = input('start_time', '');//开始时间
$end_time = input('end_time', '');//结束时间
$order_no = input('order_no', '');//订单编号
$delivery_status = input('delivery_status', '');//物流状态
$refund_no = input('refund_no', '');//退款编号
$delivery_no = input('delivery_no', '');//物流编号
$refund_delivery_no = input('refund_delivery_no', '');//退款物流编号
$refund_mode = input('refund_mode', '');//退款类型
$order_refund_model = new OrderRefundModel();
if (request()->isJson()) {
$page_index = input('page', 1);
$page_size = input('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', '<>', OrderRefundDict::REFUND_NOT_APPLY ];
}
//物流状态
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 ($refund_mode == 1) {
$condition[] = ['nop.refund_mode', 'in', [ 0, 1 ] ];
} else if ($refund_mode == 2) {
$condition[] = ['nop.refund_mode', '=', 2 ];
}
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) ] ];
}
return $order_refund_model->getRefundOrderGoodsPageList($condition, $page_index, $page_size, 'nop.refund_action_time desc');
} else {
$this->assign('refund_status_list', OrderRefundDict::getStatus());//退款状态
$this->assign('refund_type_list', OrderRefundDict::getRefundType());//退款方式
return $this->fetch('orderrefund/lists');
}
}
/**
* 维权订单详情
* @return mixed
*/
public function detail()
{
$order_goods_id = input('order_goods_id', 0);
//维权订单项信息
$order_refund_model = new OrderRefundModel();
$detail = $order_refund_model->getRefundDetail($order_goods_id)[ 'data' ];
if (empty($detail))
$this->error('未获取到维权信息', href_url('shop/orderrefund/lists'));
$order_common_model = new OrderCommon();
// $order_info_result = $order_common_model->getOrderInfo([["order_id", "=", $detail["order_id"]]]);
$order_info_result = $order_common_model->getOrderDetail($detail['order_id']);
$order_info = $order_info_result['data'];
if (empty($order_info))
$this->error('未获取到维权信息', href_url('shop/orderrefund/lists'));
$template = 'orderrefund/detail';
if ($order_info['order_type'] == 4) {
$template = 'orderrefund/virtualdetail';
}
//添加会员昵称
$member = new Member();
$member_info = $member->getMemberInfo([ ['member_id', '=', $order_info[ 'member_id' ] ] ], 'nickname')[ 'data' ] ?? [];
$order_info[ 'nickname' ] = $member_info[ 'nickname' ] ?? '';
$this->assign('detail', $detail);
$this->assign('order_info', $order_info);
return $this->fetch($template);
}
/**
* 维权拒绝
* @return array
*/
public function refuse()
{
$order_goods_id = input('order_goods_id', 0);
$refund_refuse_reason = input('refund_refuse_reason', '');
$order_refund_model = new OrderRefundModel();
$data = [
'order_goods_id' => $order_goods_id,
'refund_refuse_reason' => $refund_refuse_reason
];
$log_data = [
'uid' => $this->user_info[ 'uid' ],
'nick_name' => $this->user_info[ 'username' ],
'action' => '商家拒绝了维权',
'action_way' => 2
];
return $order_refund_model->orderRefundRefuse($data, $this->user_info, $refund_refuse_reason, $log_data);
}
/**
* 维权同意
* @return array
*/
public function agree()
{
$order_goods_id = input('order_goods_id', 0);
$order_refund_model = new OrderRefundModel();
$data = [
'order_goods_id' => $order_goods_id
];
return $order_refund_model->orderRefundConfirm($data, $this->user_info);
}
/**
* 维权收货
* @return array
*/
public function receive()
{
$order_goods_id = input('order_goods_id', 0);
$is_refund_stock = input('is_refund_stock', 0);//是否入库
$order_refund_model = new OrderRefundModel();
$data = [
'order_goods_id' => $order_goods_id,
'is_refund_stock' => $is_refund_stock
];
return $order_refund_model->orderRefundTakeDelivery($data, $this->user_info);
}
/**
* 维权通过
* @return array|null
*/
public function complete()
{
$order_goods_id = input('order_goods_id', 0);
$refund_money_type = input('refund_money_type', '');
$shop_refund_remark = input('shop_refund_remark', '');
$refund_real_money = input('refund_real_money', 0);
$is_deposit_back = input('is_deposit_back', 1);
$order_refund_model = new OrderRefundModel();
$data = [
'order_goods_id' => $order_goods_id,
'refund_money_type' => $refund_money_type,
'shop_refund_remark' => $shop_refund_remark,
'refund_real_money' => $refund_real_money,
'is_deposit_back' => $is_deposit_back
];
$log_data = [
'uid' => $this->user_info[ 'uid' ],
'nick_name' => $this->user_info[ 'username' ],
'action' => '商家对维权进行了转账,维权结束',
'action_way' => 2
];
return $order_refund_model->orderRefundFinish($data, $this->user_info, $log_data);
}
/**
* 订单导出(维权订单)
*/
public function exportRefundOrder()
{
$refund_status = input('refund_status', '');//退款状态
$sku_name = input('sku_name', '');//商品名称
$refund_type = input('refund_type', '');//退款方式
$start_time = input('start_time', '');//开始时间
$end_time = input('end_time', '');//结束时间
$order_no = input('order_no', '');//订单编号
$delivery_status = input('delivery_status', '');//物流状态
$refund_no = input('refund_no', '');//退款编号
$order_refund_model = new OrderRefundModel();
$delivery_no = input('delivery_no', '');//物流编号
$refund_delivery_no = input('refund_delivery_no', '');//退款物流编号
$condition_desc = [];
$condition[] = [ 'og.site_id', '=', $this->site_id ];
//退款状态
$refund_status_list = OrderRefundDict::getStatus();
$refund_status_name = '全部';
if ($refund_status != '') {
$condition[] = ['og.refund_status', '=', $refund_status ];
$refund_status_name = $refund_status_list[ $refund_status ][ 'name' ] ?? '';
} else {
$condition[] = ['og.refund_status', '<>', OrderRefundDict::REFUND_NOT_APPLY ];
}
$condition_desc[] = [ 'name' => '维权状态', 'value' => $refund_status_name ];
//物流状态
if ($delivery_status != '') {
$condition[] = ['og.delivery_status', '=', $delivery_status ];
}
//商品名称
$sku_name_value = '';
if ($sku_name != '') {
$condition[] = ['og.sku_name', 'like', "%$sku_name%" ];
$sku_name_value = $sku_name;
}
$condition_desc[] = [ 'name' => '商品名称', 'value' => $sku_name_value ];
//退款方式
$refund_type_name = '全部';
if ($refund_type != '') {
$condition[] = ['og.refund_type', '=', $refund_type ];
$refund_type_name = $order_refund_model->refund_type[ $refund_type ];
}
$condition_desc[] = [ 'name' => '退款方式', 'value' => $refund_type_name ];
//退款编号
if ($refund_no != '') {
$condition[] = [ 'og.refund_no', 'like', "%$refund_no%" ];
}
$condition_desc[] = [ 'name' => '退款编号', 'value' => $refund_no ];
//订单编号
if ($order_no != '') {
$condition[] = [ 'og.order_no', 'like', "%$order_no%" ];
}
$condition_desc[] = [ 'name' => '订单编号', 'value' => $order_no ];
//物流编号
if ($delivery_no != '') {
$condition[] = [ 'og.delivery_no', 'like', "%$delivery_no%" ];
}
//退款物流编号
if ($refund_delivery_no != '') {
$condition[] = [ 'og.refund_delivery_no', 'like', "%$refund_delivery_no%" ];
}
$time_name = '';
if (!empty($start_time) && empty($end_time)) {
$condition[] = [ 'og.refund_action_time', '>=', date_to_time($start_time) ];
$time_name = $start_time . '起';
} elseif (empty($start_time) && !empty($end_time)) {
$condition[] = [ 'og.refund_action_time', '<=', date_to_time($end_time) ];
$time_name = '至' . $end_time;
} elseif (!empty($start_time) && !empty($end_time)) {
$condition[] = [ 'og.refund_action_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
$time_name = $start_time . ' 至 ' . $end_time;
}
$condition_desc[] = [ 'name' => '申请时间', 'value' => $time_name ];
$order_export_model = new OrderExport();
return $order_export_model->orderRefundExport($condition, $condition_desc, $this->site_id);
}
/**
* 订单导出记录
* @return mixed
*/
public function export()
{
if (request()->isJson()) {
$page_index = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$export_model = new OrderExport();
$condition = [
[ 'site_id', '=', $this->site_id ]
];
return $export_model->getRefundExportPageList($condition, $page_index, $page_size, 'create_time desc', '*');
} else {
return $this->fetch('orderrefund/export');
}
}
/**
* 删除订单导出记录
*/
public function deleteExport()
{
if (request()->isJson()) {
$export_ids = input('export_ids', '');
$export_model = new OrderExport();
$condition = [
[ 'site_id', '=', $this->site_id ],
[ 'export_id', 'in', (string) $export_ids ]
];
return $export_model->deleteRefundExport($condition);
}
}
/**
* 关闭维权
* @return array|void
*/
public function close()
{
if (request()->isJson()) {
$order_goods_id = input('order_goods_id', 0);
$order_refund_model = new OrderRefundModel();
return $order_refund_model->orderRefundClose($order_goods_id, $this->site_id, $this->user_info);
}
}
/**
* 获取订单项退款信息
*/
public function getOrderGoodsRefundInfo()
{
if (request()->isJson()) {
$order_goods_id = input('order_goods_id', '');
$order_refund_model = new OrderRefundModel();
return $order_refund_model->getOrderGoodsRefundInfo($order_goods_id, $this->site_id);
}
}
/**
* 主动退款
* @return array|null
*/
public function shopActiveRefund()
{
$order_goods_id = input('order_goods_id', 0);
$refund_money_type = input('refund_money_type', '');
$shop_refund_remark = input('shop_refund_remark', '');
$do_refund_money = input('do_refund_money', '');
$order_refund_model = new OrderRefundModel();
$params = [
'site_id' => $this->site_id,
'app_module' => $this->app_module,
'refund_money_type' => $refund_money_type,
'shop_refund_remark' => $shop_refund_remark,
'user_info' => $this->user_info,
'order_goods_id' => $order_goods_id,
'do_refund_money' => $do_refund_money
];
return $order_refund_model->doOrderOrderRefund($params);
}
}

View File

@@ -1,37 +1,29 @@
<?php
/**
*/
namespace app\shop\controller;
use app\Controller;
use app\model\order\OrderCommon as OrderCommonModel;
/**
* 打印
* Class Printer
* @package app\shop\controller
*/
class Printer extends Controller
{
/**
* 批量打印发货单
* @return mixed
*/
public function batchPrintOrder()
{
$order_id = input('order_id', 0);
$order_common_model = new OrderCommonModel();
$order_detail = $order_common_model->getUnRefundOrderDetail($order_id)['data'];
$this->assign('order_detail', $order_detail);
return $this->fetch('order/batch_print_order');
}
<?php
namespace app\shop\controller;
use app\Controller;
use app\model\order\OrderCommon as OrderCommonModel;
/**
* 打印
* Class Printer
* @package app\shop\controller
*/
class Printer extends Controller
{
/**
* 批量打印发货单
* @return mixed
*/
public function batchPrintOrder()
{
$order_id = input('order_id', 0);
$order_common_model = new OrderCommonModel();
$order_detail = $order_common_model->getUnRefundOrderDetail($order_id)['data'];
$this->assign('order_detail', $order_detail);
return $this->fetch('order/batch_print_order');
}
}

View File

@@ -1,193 +1,185 @@
<?php
/**
*/
namespace app\shop\controller;
use addon\coupon\model\Coupon;
use app\model\member\MemberAccount;
use app\model\order\Order;
use app\model\system\Addon;
use app\model\system\AddonQuick;
use app\model\system\Promotion as PromotionModel;
use think\App;
/**
* 营销
* Class Promotion
* @package app\shop\controller
*/
class Promotion extends BaseShop
{
/**
* 营销概况
*/
public function index()
{
$promotion_model = new PromotionModel();
$length = input('length', 0);
$start_time = date('Y-m-01', strtotime($length . ' month'));
$end_time = date('Y-m-d', strtotime("$start_time +1 month -1 day"));
$start_time = strtotime($start_time . ' 00:00:00');
$end_time = strtotime($end_time . ' 23:59:59');
$this->assign('month', date('Y/m', $start_time));
$this->assign('days', date('t', $start_time));
$this->assign('start_time', $start_time);
//营销配置
$promotion_config = $promotion_model->getPromotionConfig($start_time, $end_time, $this->site_id)['data'];
$this->assign('promotion_config', $promotion_config);
//营销活动
$all_promotion = array_column($promotion_model->getSitePromotions($this->site_id), null, 'name');
$all_promotion = array_filter(array_map(function($item) {
if ($item[ 'show_type' ] == 'shop' || $item[ 'show_type' ] == 'member') return $item;
}, $all_promotion));
$this->assign('all_promotion', $all_promotion);
return $this->fetch('promotion/index');
}
/**
* 营销工具
* @return mixed
*/
public function tool()
{
$promotion_model = new PromotionModel();
$promotions = $promotion_model->getPromotions();
$this->assign('promotion', $promotions[ 'shop' ]);
return $this->fetch('promotion/tool');
}
public function summary()
{
if (request()->isJson()) {
$coupon_model = new Coupon();
$order_model = new Order();
$account_model = new MemberAccount();
$promotion = event('ShowPromotion', [ 'count' => 1, 'site_id' => $this->site_id ]);
$promotion = array_map(function($item) {
if (isset($item[ 'shop' ]) && !empty($item[ 'shop' ]) && isset($item[ 'shop' ][ 0 ][ 'summary' ]) && !empty($item[ 'shop' ][ 0 ][ 'summary' ])) return $item[ 'shop' ][ 0 ][ 'summary' ][ 'count' ];
}, $promotion);
$data = [
'promotion_num' => array_sum($promotion),
'coupon_total_count' => $coupon_model->getMemberCouponCount([ [ 'site_id', '=', $this->site_id ] ])[ 'data' ],
'coupon_used_count' => $coupon_model->getMemberCouponCount([ [ 'site_id', '=', $this->site_id ], [ 'state', '=', 2 ] ])[ 'data' ],
'buyer_num' => $order_model->getOrderCount([ [ 'site_id', '=', $this->site_id ], [ 'promotion_type', '<>', '' ] ], 'order_id', 'a', null, 'member_id')[ 'data' ],
'deal_num' => $order_model->getOrderCount([ [ 'site_id', '=', $this->site_id ], [ 'promotion_type', '<>', '' ], [ 'pay_status', '=', 1 ] ], 'order_id', 'a', null, 'member_id')[ 'data' ],
'order_num' => $order_model->getOrderCount([ [ 'site_id', '=', $this->site_id ], [ 'promotion_type', '<>', '' ], [ 'pay_status', '=', 1 ] ], 'order_id')[ 'data' ],
'order_money' => $order_model->getOrderMoneySum([ [ 'site_id', '=', $this->site_id ], [ 'promotion_type', '<>', '' ], [ 'pay_status', '=', 1 ] ])[ 'data' ],
'grant_point' => round($account_model->getMemberAccountSum([ [ 'site_id', '=', $this->site_id ], [ 'account_data', '>', 0 ], [ 'from_type', 'not in', [ 'adjust', 'refund', 'pointexchangerefund', 'presale_refund' ] ] ], 'account_data')[ 'data' ])
];
return success(0, '', $data);
}
}
/**
* 常用功能设置
*/
public function commonAddonSetting()
{
if (request()->isJson()) {
$addon_model = new Addon();
$res = $addon_model->setAddonQuickMenuConfig([
'site_id' => $this->site_id,
'app_module' => $this->app_module,
'addon' => input('addon', ''),
'type' => input('type', 'promotion')
]);
return $res;
}
}
/**
* 活动专区页配置
* @return mixed
*/
public function zoneConfig()
{
$promotion_model = new PromotionModel();
if (request()->isJson()) {
$data = [
'name' => input('name', ''),
'title' => input('title', ''),
'bg_color' => input('bg_color', ''), // 背景色
];
$res = $promotion_model->setPromotionZoneConfig($data, $this->site_id, $this->app_module);
return $res;
} else {
$promotion_zone_list = event('PromotionZoneConfig');
$this->assign('promotion_zone_list', $promotion_zone_list);
$promotion_config_list = []; // 活动专区页面配置列表
$config = []; // 第一个活动页面配置
if (!empty($promotion_zone_list)) {
foreach ($promotion_zone_list as $k => $v) {
$promotion_config_list[ $v[ 'name' ] ] = $promotion_model->getPromotionZoneConfig($v[ 'name' ], $this->site_id, $this->app_module)[ 'data' ][ 'value' ];
if ($k == 0) {
$config = $promotion_config_list[ $v[ 'name' ] ];
}
}
}
$this->assign('config', $config);
$this->assign('promotion_config_list', $promotion_config_list);
return $this->fetch('promotion/zone_config');
}
}
/**
* 营销统计
* @return array
*/
public function getPromotionStat()
{
$promotion_model = new PromotionModel();
$length = input('length', 0);
$start_time = date('Y-m-01', strtotime($length . ' month'));
$end_time = date('Y-m-d', strtotime("$start_time +1 month -1 day"));
$start_time = strtotime($start_time . ' 00:00:00');
$end_time = strtotime($end_time . ' 23:59:59');
$promotion = $promotion_model->getPromotionStat($start_time, $end_time, $this->site_id);
return $promotion;
}
/**
* 营销信息
* @return array
*/
public function getPromotion()
{
$length = input('length', 0);
$start_time = date('Y-m-01', strtotime($length . ' month'));
$end_time = date('Y-m-d', strtotime("$start_time +1 month -1 day"));
$start_time = strtotime($start_time . ' 00:00:00');
$end_time = strtotime($end_time . ' 23:59:59');
$promotion_model = new PromotionModel();
$summary = $promotion_model->getPromotionSummary($start_time, $end_time, $this->site_id)[ 'data' ];
return success(0, '', [
'month' => date('Y/m', $start_time),
'days' => (int) date('t', $start_time),
'start_time' => $start_time,
'data' => $summary
]);
}
<?php
namespace app\shop\controller;
use addon\coupon\model\Coupon;
use app\model\member\MemberAccount;
use app\model\order\Order;
use app\model\system\Addon;
use app\model\system\AddonQuick;
use app\model\system\Promotion as PromotionModel;
use think\App;
/**
* 营销
* Class Promotion
* @package app\shop\controller
*/
class Promotion extends BaseShop
{
/**
* 营销概况
*/
public function index()
{
$promotion_model = new PromotionModel();
$length = input('length', 0);
$start_time = date('Y-m-01', strtotime($length . ' month'));
$end_time = date('Y-m-d', strtotime("$start_time +1 month -1 day"));
$start_time = strtotime($start_time . ' 00:00:00');
$end_time = strtotime($end_time . ' 23:59:59');
$this->assign('month', date('Y/m', $start_time));
$this->assign('days', date('t', $start_time));
$this->assign('start_time', $start_time);
//营销配置
$promotion_config = $promotion_model->getPromotionConfig($start_time, $end_time, $this->site_id)['data'];
$this->assign('promotion_config', $promotion_config);
//营销活动
$all_promotion = array_column($promotion_model->getSitePromotions($this->site_id), null, 'name');
$all_promotion = array_filter(array_map(function($item) {
if ($item[ 'show_type' ] == 'shop' || $item[ 'show_type' ] == 'member') return $item;
}, $all_promotion));
$this->assign('all_promotion', $all_promotion);
return $this->fetch('promotion/index');
}
/**
* 营销工具
* @return mixed
*/
public function tool()
{
$promotion_model = new PromotionModel();
$promotions = $promotion_model->getPromotions();
$this->assign('promotion', $promotions[ 'shop' ]);
return $this->fetch('promotion/tool');
}
public function summary()
{
if (request()->isJson()) {
$coupon_model = new Coupon();
$order_model = new Order();
$account_model = new MemberAccount();
$promotion = event('ShowPromotion', [ 'count' => 1, 'site_id' => $this->site_id ]);
$promotion = array_map(function($item) {
if (isset($item[ 'shop' ]) && !empty($item[ 'shop' ]) && isset($item[ 'shop' ][ 0 ][ 'summary' ]) && !empty($item[ 'shop' ][ 0 ][ 'summary' ])) return $item[ 'shop' ][ 0 ][ 'summary' ][ 'count' ];
}, $promotion);
$data = [
'promotion_num' => array_sum($promotion),
'coupon_total_count' => $coupon_model->getMemberCouponCount([ [ 'site_id', '=', $this->site_id ] ])[ 'data' ],
'coupon_used_count' => $coupon_model->getMemberCouponCount([ [ 'site_id', '=', $this->site_id ], [ 'state', '=', 2 ] ])[ 'data' ],
'buyer_num' => $order_model->getOrderCount([ [ 'site_id', '=', $this->site_id ], [ 'promotion_type', '<>', '' ] ], 'order_id', 'a', null, 'member_id')[ 'data' ],
'deal_num' => $order_model->getOrderCount([ [ 'site_id', '=', $this->site_id ], [ 'promotion_type', '<>', '' ], [ 'pay_status', '=', 1 ] ], 'order_id', 'a', null, 'member_id')[ 'data' ],
'order_num' => $order_model->getOrderCount([ [ 'site_id', '=', $this->site_id ], [ 'promotion_type', '<>', '' ], [ 'pay_status', '=', 1 ] ], 'order_id')[ 'data' ],
'order_money' => $order_model->getOrderMoneySum([ [ 'site_id', '=', $this->site_id ], [ 'promotion_type', '<>', '' ], [ 'pay_status', '=', 1 ] ])[ 'data' ],
'grant_point' => round($account_model->getMemberAccountSum([ [ 'site_id', '=', $this->site_id ], [ 'account_data', '>', 0 ], [ 'from_type', 'not in', [ 'adjust', 'refund', 'pointexchangerefund', 'presale_refund' ] ] ], 'account_data')[ 'data' ])
];
return success(0, '', $data);
}
}
/**
* 常用功能设置
*/
public function commonAddonSetting()
{
if (request()->isJson()) {
$addon_model = new Addon();
$res = $addon_model->setAddonQuickMenuConfig([
'site_id' => $this->site_id,
'app_module' => $this->app_module,
'addon' => input('addon', ''),
'type' => input('type', 'promotion')
]);
return $res;
}
}
/**
* 活动专区页配置
* @return mixed
*/
public function zoneConfig()
{
$promotion_model = new PromotionModel();
if (request()->isJson()) {
$data = [
'name' => input('name', ''),
'title' => input('title', ''),
'bg_color' => input('bg_color', ''), // 背景色
];
$res = $promotion_model->setPromotionZoneConfig($data, $this->site_id, $this->app_module);
return $res;
} else {
$promotion_zone_list = event('PromotionZoneConfig');
$this->assign('promotion_zone_list', $promotion_zone_list);
$promotion_config_list = []; // 活动专区页面配置列表
$config = []; // 第一个活动页面配置
if (!empty($promotion_zone_list)) {
foreach ($promotion_zone_list as $k => $v) {
$promotion_config_list[ $v[ 'name' ] ] = $promotion_model->getPromotionZoneConfig($v[ 'name' ], $this->site_id, $this->app_module)[ 'data' ][ 'value' ];
if ($k == 0) {
$config = $promotion_config_list[ $v[ 'name' ] ];
}
}
}
$this->assign('config', $config);
$this->assign('promotion_config_list', $promotion_config_list);
return $this->fetch('promotion/zone_config');
}
}
/**
* 营销统计
* @return array
*/
public function getPromotionStat()
{
$promotion_model = new PromotionModel();
$length = input('length', 0);
$start_time = date('Y-m-01', strtotime($length . ' month'));
$end_time = date('Y-m-d', strtotime("$start_time +1 month -1 day"));
$start_time = strtotime($start_time . ' 00:00:00');
$end_time = strtotime($end_time . ' 23:59:59');
$promotion = $promotion_model->getPromotionStat($start_time, $end_time, $this->site_id);
return $promotion;
}
/**
* 营销信息
* @return array
*/
public function getPromotion()
{
$length = input('length', 0);
$start_time = date('Y-m-01', strtotime($length . ' month'));
$end_time = date('Y-m-d', strtotime("$start_time +1 month -1 day"));
$start_time = strtotime($start_time . ' 00:00:00');
$end_time = strtotime($end_time . ' 23:59:59');
$promotion_model = new PromotionModel();
$summary = $promotion_model->getPromotionSummary($start_time, $end_time, $this->site_id)[ 'data' ];
return success(0, '', [
'month' => date('Y/m', $start_time),
'days' => (int) date('t', $start_time),
'start_time' => $start_time,
'data' => $summary
]);
}
}

View File

@@ -1,137 +1,129 @@
<?php
/**
*/
namespace app\shop\controller;
use addon\wechat\model\Wechat;
use app\model\shop\ShopAcceptMessage as ShopAcceptMessageModel;
use think\facade\Cache;
/**
* 商家接受会员消息管理
* Class Shopacceptmessage
* @package app\shop\controller
*/
class Shopacceptmessage extends BaseShop
{
/**
* 商家接受会员消息列表
*/
public function lists()
{
if (request()->isJson()) {
$page = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$search_text_type = input('search_text_type', 'nickname');
$search_text = input('search_text', '');
$condition = [];
if ($search_text) {
$condition[] = [ $search_text_type, 'like', '%' . $search_text . '%' ];
}
$model = new ShopAcceptMessageModel();
$list = $model->getShopAcceptMessagePageList($condition, $page, $page_size);
return $list;
} else {
return $this->fetch('shopacceptmessage/lists');
}
}
/**
* 添加
*/
public function add()
{
if (request()->isJson()) {
$model = new ShopAcceptMessageModel();
$data = [
'site_id' => $this->site_id,
'mobile' => input('mobile', ''),
'wx_openid' => input('wx_openid', ''),
'nickname' => input('nickname', ''),
];
$res = $model->addShopAcceptMessage($data);
return $res;
}
}
/**
* 编辑
* @return array
*/
public function edit()
{
if (request()->isJson()) {
$id = input('id', 0);
$model = new ShopAcceptMessageModel();
$data = [
'mobile' => input('mobile', ''),
'wx_openid' => input('wx_openid', ''),
'nickname' => input('nickname', ''),
];
$res = $model->editShopAcceptMessage($data, [ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ]);
return $res;
}
}
/**
* 删除
*/
public function delete()
{
if (request()->isJson()) {
$model = new ShopAcceptMessageModel();
$id = input('id', 0);
$res = $model->deleteShopAcceptMessage([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ]);
return $res;
}
}
/**
* 创建绑定二维码
*/
public function createBindQrcode()
{
if (request()->isJson()) {
$key = 'verify_' . unique_random(6) . $this->site_id;
$wechat = new Wechat($this->site_id);
$res = $wechat->getTempQrcode($key, 600);
if ($res[ 'code' ] != 0) return $res;
return success(0, '', [ 'key' => $key, 'path' => $res[ 'data' ] ]);
}
}
/**
* 获取扫码绑定数据
* @return array
*/
public function getBindData()
{
if (request()->isJson()) {
$key = input('key', '');
$cache = Cache::pull($key);
if ($cache) {
return success(0, '', $cache);
} else {
return error();
}
}
}
<?php
namespace app\shop\controller;
use addon\wechat\model\Wechat;
use app\model\shop\ShopAcceptMessage as ShopAcceptMessageModel;
use think\facade\Cache;
/**
* 商家接受会员消息管理
* Class Shopacceptmessage
* @package app\shop\controller
*/
class Shopacceptmessage extends BaseShop
{
/**
* 商家接受会员消息列表
*/
public function lists()
{
if (request()->isJson()) {
$page = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$search_text_type = input('search_text_type', 'nickname');
$search_text = input('search_text', '');
$condition = [];
if ($search_text) {
$condition[] = [ $search_text_type, 'like', '%' . $search_text . '%' ];
}
$model = new ShopAcceptMessageModel();
$list = $model->getShopAcceptMessagePageList($condition, $page, $page_size);
return $list;
} else {
return $this->fetch('shopacceptmessage/lists');
}
}
/**
* 添加
*/
public function add()
{
if (request()->isJson()) {
$model = new ShopAcceptMessageModel();
$data = [
'site_id' => $this->site_id,
'mobile' => input('mobile', ''),
'wx_openid' => input('wx_openid', ''),
'nickname' => input('nickname', ''),
];
$res = $model->addShopAcceptMessage($data);
return $res;
}
}
/**
* 编辑
* @return array
*/
public function edit()
{
if (request()->isJson()) {
$id = input('id', 0);
$model = new ShopAcceptMessageModel();
$data = [
'mobile' => input('mobile', ''),
'wx_openid' => input('wx_openid', ''),
'nickname' => input('nickname', ''),
];
$res = $model->editShopAcceptMessage($data, [ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ]);
return $res;
}
}
/**
* 删除
*/
public function delete()
{
if (request()->isJson()) {
$model = new ShopAcceptMessageModel();
$id = input('id', 0);
$res = $model->deleteShopAcceptMessage([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ]);
return $res;
}
}
/**
* 创建绑定二维码
*/
public function createBindQrcode()
{
if (request()->isJson()) {
$key = 'verify_' . unique_random(6) . $this->site_id;
$wechat = new Wechat($this->site_id);
$res = $wechat->getTempQrcode($key, 600);
if ($res[ 'code' ] != 0) return $res;
return success(0, '', [ 'key' => $key, 'path' => $res[ 'data' ] ]);
}
}
/**
* 获取扫码绑定数据
* @return array
*/
public function getBindData()
{
if (request()->isJson()) {
$key = input('key', '');
$cache = Cache::pull($key);
if ($cache) {
return success(0, '', $cache);
} else {
return error();
}
}
}
}

View File

@@ -1,62 +1,54 @@
<?php
/**
*/
namespace app\shop\controller;
use app\model\web\Help as HelpModel;
/**
* 商家帮助
*/
class Shophelp extends BaseShop
{
/**
* 帮助列表
*/
public function helpList()
{
$help_model = new HelpModel();
if (request()->isJson()) {
$page = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$search_text = input('search_text', '');
$class_id = input('class_id', '');
$condition = [
[ 'app_module', '=', 'shop' ]
];
if (!empty($class_id)) {
$condition[] = [ 'class_id', '=', $class_id ];
}
$condition[] = [ 'title', 'like', '%' . $search_text . '%' ];
$order = 'create_time desc';
$field = 'id,title,class_id,class_name,sort,create_time';
return $help_model->getHelpPageList($condition, $page, $page_size, $order, $field);
} else {
$class_list = $help_model->getHelpClassList();
$this->assign('class_list', $class_list);
return $this->fetch('shophelp/help_list');
}
}
/**
* 帮助列表
*/
public function helpDetail()
{
$help_id = input('help_id', 1);
$help_model = new HelpModel();
$help_info = $help_model->getHelpInfo($help_id);
$this->assign('help_info', $help_info[ 'data' ]);
return $this->fetch('shophelp/help_detail');
}
<?php
namespace app\shop\controller;
use app\model\web\Help as HelpModel;
/**
* 商家帮助
*/
class Shophelp extends BaseShop
{
/**
* 帮助列表
*/
public function helpList()
{
$help_model = new HelpModel();
if (request()->isJson()) {
$page = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$search_text = input('search_text', '');
$class_id = input('class_id', '');
$condition = [
[ 'app_module', '=', 'shop' ]
];
if (!empty($class_id)) {
$condition[] = [ 'class_id', '=', $class_id ];
}
$condition[] = [ 'title', 'like', '%' . $search_text . '%' ];
$order = 'create_time desc';
$field = 'id,title,class_id,class_name,sort,create_time';
return $help_model->getHelpPageList($condition, $page, $page_size, $order, $field);
} else {
$class_list = $help_model->getHelpClassList();
$this->assign('class_list', $class_list);
return $this->fetch('shophelp/help_list');
}
}
/**
* 帮助列表
*/
public function helpDetail()
{
$help_id = input('help_id', 1);
$help_model = new HelpModel();
$help_info = $help_model->getHelpInfo($help_id);
$this->assign('help_info', $help_info[ 'data' ]);
return $this->fetch('shophelp/help_detail');
}
}

View File

@@ -1,391 +1,383 @@
<?php
/**
*/
namespace app\shop\controller;
use app\model\express\Config as ExpressConfig;
use app\model\express\ExpressDeliver;
use app\model\express\Local as LocalModel;
use app\model\shop\Shop as ShopModel;
use app\model\store\Store as StoreModel;
use app\model\system\Address as AddressModel;
use app\model\web\Config as ConfigModel;
use app\model\web\Config as WebConfig;
/**
* 门店
* Class Store
* @package app\shop\controller
*/
class Store extends BaseShop
{
/**
* 门店列表
* @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->getStorePageList($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 ? '门店' : '自提点');
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', '');
$status = input('status', 0);
$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);
$open_date = input('open_date', '');
$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 = 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,
'open_date' => $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,
'time_interval' => input('time_interval', 30),
'delivery_time' => input('delivery_time', ''),
'advance_day' => input('advance_day', 0),
'most_day' => input('most_day', 7)
);
//判断是否开启多门店
if ($is_store == 1) {
$user_data = [
'username' => input('username', ''),
'password' => data_md5(input('password', '')),
];
} 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);
return $this->fetch('store/add_store');
}
}
/**
* 编辑门店
* @return mixed
*/
public function editStore()
{
$is_exit = addon_is_exit('store');
$store_id = input('store_id', 0);
$condition = array (
['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', '');
$status = input('status', 0);
$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);
$open_date = input('open_date', '');
$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 = 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,
'open_date' => $open_date,
'start_time' => $start_time,
'end_time' => $end_time,
'time_type' => $time_type,
'time_week' => $time_week,
'stock_type' => $stock_type,
'time_interval' => input('time_interval', 30),
'delivery_time' => input('delivery_time', ''),
'advance_day' => input('advance_day', 0),
'most_day' => input('most_day', 7)
);
$user_type = input('user_type', 1);
if ($is_exit == 1 && $user_type == 0) {
$user_data = [
'username' => input('username', ''),
'password' => data_md5(input('password', '')),
];
} else {
$user_data = [];
}
$result = $store_model->editStore($data, $condition, $user_data, $is_exit, $user_type);
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('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);
return $this->fetch('store/edit_store');
}
}
/**
* 删除门店
* @return mixed
*/
public function deleteStore()
{
if (request()->isJson()) {
$store_id = input('store_id', 0);
$condition = array (
['site_id', '=', $this->site_id ],
['store_id', '=', $store_id ]
);
$store_model = new StoreModel();
$result = $store_model->deleteStore($condition);
return $result;
}
}
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 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('local/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('local/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');
}
<?php
namespace app\shop\controller;
use app\model\express\Config as ExpressConfig;
use app\model\express\ExpressDeliver;
use app\model\express\Local as LocalModel;
use app\model\shop\Shop as ShopModel;
use app\model\store\Store as StoreModel;
use app\model\system\Address as AddressModel;
use app\model\web\Config as ConfigModel;
use app\model\web\Config as WebConfig;
/**
* 门店
* Class Store
* @package app\shop\controller
*/
class Store extends BaseShop
{
/**
* 门店列表
* @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->getStorePageList($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 ? '门店' : '自提点');
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', '');
$status = input('status', 0);
$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);
$open_date = input('open_date', '');
$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 = 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,
'open_date' => $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,
'time_interval' => input('time_interval', 30),
'delivery_time' => input('delivery_time', ''),
'advance_day' => input('advance_day', 0),
'most_day' => input('most_day', 7)
);
//判断是否开启多门店
if ($is_store == 1) {
$user_data = [
'username' => input('username', ''),
'password' => data_md5(input('password', '')),
];
} 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);
return $this->fetch('store/add_store');
}
}
/**
* 编辑门店
* @return mixed
*/
public function editStore()
{
$is_exit = addon_is_exit('store');
$store_id = input('store_id', 0);
$condition = array (
['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', '');
$status = input('status', 0);
$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);
$open_date = input('open_date', '');
$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 = 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,
'open_date' => $open_date,
'start_time' => $start_time,
'end_time' => $end_time,
'time_type' => $time_type,
'time_week' => $time_week,
'stock_type' => $stock_type,
'time_interval' => input('time_interval', 30),
'delivery_time' => input('delivery_time', ''),
'advance_day' => input('advance_day', 0),
'most_day' => input('most_day', 7)
);
$user_type = input('user_type', 1);
if ($is_exit == 1 && $user_type == 0) {
$user_data = [
'username' => input('username', ''),
'password' => data_md5(input('password', '')),
];
} else {
$user_data = [];
}
$result = $store_model->editStore($data, $condition, $user_data, $is_exit, $user_type);
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('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);
return $this->fetch('store/edit_store');
}
}
/**
* 删除门店
* @return mixed
*/
public function deleteStore()
{
if (request()->isJson()) {
$store_id = input('store_id', 0);
$condition = array (
['site_id', '=', $this->site_id ],
['store_id', '=', $store_id ]
);
$store_model = new StoreModel();
$result = $store_model->deleteStore($condition);
return $result;
}
}
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 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('local/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('local/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');
}
}

View File

@@ -1,85 +1,77 @@
<?php
/**
*/
namespace app\shop\controller;
use app\model\order\OrderCommon as OrderCommonModel;
/**
* 自提订单
* Class storeorder
* @package app\shop\controller
*/
class Storeorder extends BaseShop
{
/**
* 订单详情
* @return mixed
*/
public function detail()
{
$order_id = input('order_id', 0);
$order_common_model = new OrderCommonModel();
$order_detail_result = $order_common_model->getOrderDetail($order_id);
$order_detail = $order_detail_result['data'];
$this->assign('order_detail', $order_detail);
$this->assign('http_type', get_http_type());
return $this->fetch('storeorder/detail');
}
/**
* 订单关闭
* @return mixed
*/
public function close()
{
}
/**
* 订单调价
* @return mixed
*/
public function adjustprice()
{
}
/**
* 直接提货
*/
public function storeOrderTakedelivery()
{
$order_id = input('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 $result;
}
<?php
namespace app\shop\controller;
use app\model\order\OrderCommon as OrderCommonModel;
/**
* 自提订单
* Class storeorder
* @package app\shop\controller
*/
class Storeorder extends BaseShop
{
/**
* 订单详情
* @return mixed
*/
public function detail()
{
$order_id = input('order_id', 0);
$order_common_model = new OrderCommonModel();
$order_detail_result = $order_common_model->getOrderDetail($order_id);
$order_detail = $order_detail_result['data'];
$this->assign('order_detail', $order_detail);
$this->assign('http_type', get_http_type());
return $this->fetch('storeorder/detail');
}
/**
* 订单关闭
* @return mixed
*/
public function close()
{
}
/**
* 订单调价
* @return mixed
*/
public function adjustprice()
{
}
/**
* 直接提货
*/
public function storeOrderTakedelivery()
{
$order_id = input('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 $result;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,471 +1,463 @@
<?php
/**
*/
namespace app\shop\controller;
use app\model\upload\Upload as UploadModel;
use app\model\upload\Config as ConfigModel;
use app\model\upload\Album as AlbumModel;
use think\App;
use think\Exception;
use app\model\BaseModel;
/**
* 图片上传
* Class Verify
* @package app\shop\controller
*/
class Upload extends BaseShop
{
public $site_id = 0;
protected $app_module = 'shop';
public function __construct(App $app = null)
{
//执行父类构造函数
parent::__construct($app);
$this->site_id = request()->siteid();
if (empty($this->site_id)) {
$this->site_id = input('site_id', 0);
request()->siteid($this->site_id);
}
}
/**
* 上传配置
*/
public function config()
{
$config_model = new ConfigModel();
if (request()->isJson()) {
//基础上传
$max_filesize = input('max_filesize', '10240');//允许上传大小 默认kb
$compress = trim(input('compress', ''));//图片压缩
/*************************************************************************** 缩略图 *******************************************************************/
$thumb_big_width = input('thumb_big_width', 400);//缩略大图 宽
$thumb_big_height = input('thumb_big_height', 400);//缩略大图 高
$thumb_mid_width = input('thumb_mid_width', 200);//缩略中图 宽
$thumb_mid_height = input('thumb_mid_height', 200);//缩略中图 高
$thumb_small_width = input('thumb_small_width', 100);//缩略小图 宽
$thumb_small_height = input('thumb_small_height', 100);//缩略小图 高
/*************************************************************************** 水印 *******************************************************************/
$is_watermark = input('is_watermark', 0);//是否开启水印
$watermark_type = input('watermark_type', '1');//水印类型 1图片 2文字
$watermark_source = input('watermark_source', '');//水印图片来源
$watermark_position = input('watermark_position', 'top-left');//水印图片位置(相对于当前图像)top-left(默认)top top-right left center right bottom-left bottom bottom-right
$watermark_x = input('watermark_x', 0);//水印图片横坐标偏移量
$watermark_y = input('watermark_y', 0);//水印图片纵坐标偏移量
$watermark_opacity = input('watermark_opacity', '0');//水印图片透明度
$watermark_rotate = input('watermark_rotate', '0');//水印图片倾斜度
$watermark_text = input('watermark_text', '');//水印文字
$watermark_text_file = input('watermark_text_file', '');//水印文字 字体文件。设置True Type Font文件的路径或者GD库内部字体之一的1到5之间的整数值。 默认值1
$watermark_text_size = input('watermark_text_size', '12');//水印文字 字体大小。字体大小仅在设置字体文件时可用,否则将被忽略。 默认值12
$watermark_text_color = input('watermark_text_color', '#000000');//水印文字 字体颜色
$watermark_text_align = input('watermark_text_align', 'left');//水印文字水平对齐方式 水平对齐方式left,right,center。默认left
$watermark_text_valign = input('watermark_text_valign', 'bottom');//水印文字垂直对齐方式 垂直对齐方式top,bottom,middle。默认bottom
$watermark_text_angle = input('watermark_text_angle', '0');//文本旋转角度。文本将围绕垂直和水平对齐点逆时针旋转。 旋转仅在设置字体文件时可用,否则将被忽略
$data = array (
//上传相关配置
'upload' => array (
'max_filesize' => $max_filesize * 1024,//最大上传限制,
'compress' => $compress
),
//缩略图相关配置
'thumb' => array (
'thumb_big_width' => $thumb_big_width,
'thumb_big_height' => $thumb_big_height,
'thumb_mid_width' => $thumb_mid_width,
'thumb_mid_height' => $thumb_mid_height,
'thumb_small_width' => $thumb_small_width,
'thumb_small_height' => $thumb_small_height,
),
//水印相关配置
'water' => array (
'is_watermark' => $is_watermark,
'watermark_type' => $watermark_type,
'watermark_source' => $watermark_source,
'watermark_position' => $watermark_position,
'watermark_x' => $watermark_x,
'watermark_y' => $watermark_y,
'watermark_opacity' => $watermark_opacity,
'watermark_rotate' => $watermark_rotate,
'watermark_text' => $watermark_text,
'watermark_text_file' => $watermark_text_file,
'watermark_text_size' => $watermark_text_size,
'watermark_text_color' => $watermark_text_color,
'watermark_text_align' => $watermark_text_align,
'watermark_text_valign' => $watermark_text_valign,
'watermark_text_angle' => $watermark_text_angle,
),
);
$this->addLog('修改上传配置');
$result = $config_model->setUploadConfig($data);
return $result;
} else {
$config_result = $config_model->getUploadConfig();
$config = $config_result[ 'data' ];
$config[ 'value' ][ 'upload' ][ 'max_filesize' ] = $config[ 'value' ][ 'upload' ][ 'max_filesize' ] / 1024;
$this->assign('config', $config);
//图片水印位置
$position = array (
'top-left' => '上左',
'top' => '上中',
'top-right' => '上右',
'left' => '左',
'center' => '中',
'right' => '右',
'bottom-left' => '下左',
'bottom' => '下中',
'bottom-right' => '下右',
);
$this->assign('position', $position);
//文字水印位置
$text_position = array (
'top-left' => '上左',
'top-center' => '上中',
'top-right' => '上右',
'middle-left' => '左',
'middle-center' => '中',
'middle-right' => '右',
'bottom-left' => '下左',
'bottom-center' => '下中',
'bottom-right' => '下右',
);
$this->assign('text_position', $text_position);
return $this->fetch('upload/config');
}
}
/**
* 云上传方式
*/
public function oss()
{
if (request()->isJson()) {
$config_model = new ConfigModel();
$list = event('OssType', []);
return $config_model->success($list);
} else {
return $this->fetch('upload/oss');
}
}
/**
* 上传(不存入相册)
* @return \app\model\upload\Ambigous|\multitype
*/
public function image()
{
$upload_model = new UploadModel($this->site_id, $this->app_module);
$thumb_type = input('thumb', '');
$name = input('name', '');
$width = input('width', '');
$height = input('height', '');
$watermark = input('watermark', 0); // 是否需生成水印
$cloud = input('cloud', 1); // 是否需上传到云存储
$param = array (
'thumb_type' => '',
'name' => 'file',
'watermark' => $watermark,
'cloud' => $cloud,
'width' => $width,
'height' => $height
);
$path = $this->site_id > 0 ? 'common/images/' . date('Ymd') . '/' : 'common/images/' . date('Ymd') . '/';
$result = $upload_model->setPath($path)->image($param);
return $result;
}
/**
* 上传 存入相册
* @return \multitype
*/
public function album()
{
$upload_model = new UploadModel($this->site_id);
$album_id = input('album_id', 0);
$name = input('name', '');
$is_thumb = input('is_thumb', 0);
$param = array (
'thumb_type' => [ 'BIG', 'MID', 'SMALL' ],
'name' => 'file',
'album_id' => $album_id,
'is_thumb' => $is_thumb
);
$result = $upload_model->setPath('common/images/' . date('Ymd') . '/')->imageToAlbum($param);
return $result;
}
/**
* 视频上传到素材
* @return \multitype
*/
public function videoToAlbum()
{
$upload_model = new UploadModel($this->site_id);
$name = input('name', '');
$album_id = input('album_id', 0);
$param = array (
'name' => 'file',
'album_id' => $album_id,
);
$result = $upload_model->setPath('common/video/' . date('Ymd') . '/')->videoToAlbum($param);
return $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;
}
/**
* 音频上传
* @return \multitype
*/
public function audio()
{
$upload_model = new UploadModel($this->site_id);
$name = input('name', '');
$album_id = input('album_id', 0);
if($album_id == 0){
$base_model = new BaseModel();
return json($base_model->error('', '请先添加一个分组'));
}
/*if($album_id == 0){
$album_id = model("album")->add([
'site_id'=>$this->site_id,
'album_name'=>'新分组',
'is_default'=>1,
'type'=>'audio'
]);
}*/
$param = array (
'name' => 'file',
'album_id' => $album_id,
);
$result = $upload_model->setPath('common/audio/' . date('Ymd') . '/')->audio($param);
return $result;
}
/*
* 替换视频文件
* */
public function modifyVideoFile()
{
// 实例化响应数据结构生成类
$base_model = new BaseModel();
try {
// 参数
$album_id = input('album_id', '');
$pic_id = input('pic_id', '');
// 获取视频信息
$album_model = new AlbumModel();
$get_pic_info = array (
[ 'pic_id', '=', $pic_id ],
[ 'site_id', '=', $this->site_id ],
);
// 视频信息
$pic_info = $album_model->getAlbumPicInfo($get_pic_info);
// 判断是否找到有效视频
if (empty($pic_info) || empty($pic_info[ 'data' ])) {
return json($base_model->error('', 'FAIL'));
}
// 实例化文件上传类
$upload_model = new UploadModel($this->site_id);
$upload_param = array (
'name' => 'file',
'album_id' => $album_id,
'pic_id' => $pic_id,
);
$result = $upload_model->setPath('common/video/' . date('Ymd') . '/')->modifyVideoFile($upload_param);
return json($result);
} catch (\Exception $e) {
return json($base_model->error($e, 'FAIL'));
}
}
/**
* 上传(不存入相册)
* @return \app\model\upload\Ambigous|\multitype
*/
public function upload()
{
$upload_model = new UploadModel();
$thumb_type = input('thumb', '');
$name = input('name', '');
$param = array (
'thumb_type' => '',
'name' => 'file'
);
$result = $upload_model->setPath('common/images/' . date('Ymd') . '/')->image($param);
return $result;
}
/**
* 校验文件
*/
public function checkfile()
{
$upload_model = new UploadModel();
$result = $upload_model->domainCheckFile([ 'name' => 'file' ]);
return $result;
}
/**
* 上传文件
*/
public function file()
{
$upload_model = new UploadModel($this->site_id);
$param = array (
'name' => 'file',
'extend_type' => [ 'xlsx' ]
);
$result = $upload_model->setPath('common/file/' . date('Ymd') . '/')->file($param);
return $result;
}
/**
* 删除文件
*/
public function deleteFile()
{
if (request()->isJson()) {
$path = input('path', '');
$res = false;
if (!empty($path)) {
$res = delFile($path);
}
return $res;
}
}
/*
* 替换图片文件
* */
public function modifyFile()
{
// 实例化响应数据结构生成类
$base_model = new BaseModel();
try {
// 参数
$album_id = input('album_id', '');
$pic_id = input('pic_id', '');
// 获取图片信息
$album_model = new AlbumModel();
$get_pic_info = array (
[ 'pic_id', '=', $pic_id ],
[ 'site_id', '=', $this->site_id ],
);
// 图片信息
$pic_info = $album_model->getAlbumPicInfo($get_pic_info);
// 判断是否找到有效图片
if (empty($pic_info) || empty($pic_info[ 'data' ])) {
return json($base_model->error('', 'FAIL'));
}
$file_full_name = basename($pic_info[ 'data' ][ 'pic_path' ]);
$pic_path = str_replace($file_full_name, '', $pic_info[ 'data' ][ 'pic_path' ]);
$pic_path = str_replace('upload/1/', '', $pic_path);
// 文件名及后缀
$filename_arr = explode('.', $file_full_name);
$filename = $filename_arr[ 0 ];
$suffix = $filename_arr[ 1 ];
// 实例化文件上传类
$upload_model = new UploadModel($this->site_id);
$upload_param = array (
'name' => 'file',
'album_id' => $album_id,
'pic_id' => $pic_id,
'thumb_type' => [ 'BIG', 'MID', 'SMALL' ],
'filename' => $filename,
'suffix' => $suffix
);
$parse_res = parse_url($pic_path);
$pic_path = ltrim($parse_res[ 'path' ], '/');
$result = $upload_model->setPath($pic_path)->modifyFile($upload_param);
return json($result);
} catch (\Exception $e) {
return json($base_model->error($e, 'FAIL'));
}
}
/**
* 下载图片
*/
public function download()
{
$filename = input('img_url', '');
$filename = urldecode($filename);
// 文件类型,作为头部发送给浏览器
// $type = filetype($filename);
$type = pathinfo($filename)[ 'extension' ];
if ($type == 'png' || $type == 'jpg') {
// 发送文件头部
header("Content-type: $type");
header("Content-Disposition: attachment;filename=$filename");
header('Content-Transfer-Encoding: binary');
header('Pragma: no-cache');
header('Expires: 0');
// 发送文件内容
set_time_limit(0);
readfile($filename);
} else {
$this->error();
}
}
<?php
namespace app\shop\controller;
use app\model\upload\Upload as UploadModel;
use app\model\upload\Config as ConfigModel;
use app\model\upload\Album as AlbumModel;
use think\App;
use think\Exception;
use app\model\BaseModel;
/**
* 图片上传
* Class Verify
* @package app\shop\controller
*/
class Upload extends BaseShop
{
public $site_id = 0;
protected $app_module = 'shop';
public function __construct(App $app = null)
{
//执行父类构造函数
parent::__construct($app);
$this->site_id = request()->siteid();
if (empty($this->site_id)) {
$this->site_id = input('site_id', 0);
request()->siteid($this->site_id);
}
}
/**
* 上传配置
*/
public function config()
{
$config_model = new ConfigModel();
if (request()->isJson()) {
//基础上传
$max_filesize = input('max_filesize', '10240');//允许上传大小 默认kb
$compress = trim(input('compress', ''));//图片压缩
/*************************************************************************** 缩略图 *******************************************************************/
$thumb_big_width = input('thumb_big_width', 400);//缩略大图 宽
$thumb_big_height = input('thumb_big_height', 400);//缩略大图 高
$thumb_mid_width = input('thumb_mid_width', 200);//缩略中图 宽
$thumb_mid_height = input('thumb_mid_height', 200);//缩略中图 高
$thumb_small_width = input('thumb_small_width', 100);//缩略小图 宽
$thumb_small_height = input('thumb_small_height', 100);//缩略小图 高
/*************************************************************************** 水印 *******************************************************************/
$is_watermark = input('is_watermark', 0);//是否开启水印
$watermark_type = input('watermark_type', '1');//水印类型 1图片 2文字
$watermark_source = input('watermark_source', '');//水印图片来源
$watermark_position = input('watermark_position', 'top-left');//水印图片位置(相对于当前图像)top-left(默认)top top-right left center right bottom-left bottom bottom-right
$watermark_x = input('watermark_x', 0);//水印图片横坐标偏移量
$watermark_y = input('watermark_y', 0);//水印图片纵坐标偏移量
$watermark_opacity = input('watermark_opacity', '0');//水印图片透明度
$watermark_rotate = input('watermark_rotate', '0');//水印图片倾斜度
$watermark_text = input('watermark_text', '');//水印文字
$watermark_text_file = input('watermark_text_file', '');//水印文字 字体文件。设置True Type Font文件的路径或者GD库内部字体之一的1到5之间的整数值。 默认值1
$watermark_text_size = input('watermark_text_size', '12');//水印文字 字体大小。字体大小仅在设置字体文件时可用,否则将被忽略。 默认值12
$watermark_text_color = input('watermark_text_color', '#000000');//水印文字 字体颜色
$watermark_text_align = input('watermark_text_align', 'left');//水印文字水平对齐方式 水平对齐方式left,right,center。默认left
$watermark_text_valign = input('watermark_text_valign', 'bottom');//水印文字垂直对齐方式 垂直对齐方式top,bottom,middle。默认bottom
$watermark_text_angle = input('watermark_text_angle', '0');//文本旋转角度。文本将围绕垂直和水平对齐点逆时针旋转。 旋转仅在设置字体文件时可用,否则将被忽略
$data = array (
//上传相关配置
'upload' => array (
'max_filesize' => $max_filesize * 1024,//最大上传限制,
'compress' => $compress
),
//缩略图相关配置
'thumb' => array (
'thumb_big_width' => $thumb_big_width,
'thumb_big_height' => $thumb_big_height,
'thumb_mid_width' => $thumb_mid_width,
'thumb_mid_height' => $thumb_mid_height,
'thumb_small_width' => $thumb_small_width,
'thumb_small_height' => $thumb_small_height,
),
//水印相关配置
'water' => array (
'is_watermark' => $is_watermark,
'watermark_type' => $watermark_type,
'watermark_source' => $watermark_source,
'watermark_position' => $watermark_position,
'watermark_x' => $watermark_x,
'watermark_y' => $watermark_y,
'watermark_opacity' => $watermark_opacity,
'watermark_rotate' => $watermark_rotate,
'watermark_text' => $watermark_text,
'watermark_text_file' => $watermark_text_file,
'watermark_text_size' => $watermark_text_size,
'watermark_text_color' => $watermark_text_color,
'watermark_text_align' => $watermark_text_align,
'watermark_text_valign' => $watermark_text_valign,
'watermark_text_angle' => $watermark_text_angle,
),
);
$this->addLog('修改上传配置');
$result = $config_model->setUploadConfig($data);
return $result;
} else {
$config_result = $config_model->getUploadConfig();
$config = $config_result[ 'data' ];
$config[ 'value' ][ 'upload' ][ 'max_filesize' ] = $config[ 'value' ][ 'upload' ][ 'max_filesize' ] / 1024;
$this->assign('config', $config);
//图片水印位置
$position = array (
'top-left' => '上左',
'top' => '上中',
'top-right' => '上右',
'left' => '左',
'center' => '中',
'right' => '右',
'bottom-left' => '下左',
'bottom' => '下中',
'bottom-right' => '下右',
);
$this->assign('position', $position);
//文字水印位置
$text_position = array (
'top-left' => '上左',
'top-center' => '上中',
'top-right' => '上右',
'middle-left' => '左',
'middle-center' => '中',
'middle-right' => '右',
'bottom-left' => '下左',
'bottom-center' => '下中',
'bottom-right' => '下右',
);
$this->assign('text_position', $text_position);
return $this->fetch('upload/config');
}
}
/**
* 云上传方式
*/
public function oss()
{
if (request()->isJson()) {
$config_model = new ConfigModel();
$list = event('OssType', []);
return $config_model->success($list);
} else {
return $this->fetch('upload/oss');
}
}
/**
* 上传(不存入相册)
* @return \app\model\upload\Ambigous|\multitype
*/
public function image()
{
$upload_model = new UploadModel($this->site_id, $this->app_module);
$thumb_type = input('thumb', '');
$name = input('name', '');
$width = input('width', '');
$height = input('height', '');
$watermark = input('watermark', 0); // 是否需生成水印
$cloud = input('cloud', 1); // 是否需上传到云存储
$param = array (
'thumb_type' => '',
'name' => 'file',
'watermark' => $watermark,
'cloud' => $cloud,
'width' => $width,
'height' => $height
);
$path = $this->site_id > 0 ? 'common/images/' . date('Ymd') . '/' : 'common/images/' . date('Ymd') . '/';
$result = $upload_model->setPath($path)->image($param);
return $result;
}
/**
* 上传 存入相册
* @return \multitype
*/
public function album()
{
$upload_model = new UploadModel($this->site_id);
$album_id = input('album_id', 0);
$name = input('name', '');
$is_thumb = input('is_thumb', 0);
$param = array (
'thumb_type' => [ 'BIG', 'MID', 'SMALL' ],
'name' => 'file',
'album_id' => $album_id,
'is_thumb' => $is_thumb
);
$result = $upload_model->setPath('common/images/' . date('Ymd') . '/')->imageToAlbum($param);
return $result;
}
/**
* 视频上传到素材
* @return \multitype
*/
public function videoToAlbum()
{
$upload_model = new UploadModel($this->site_id);
$name = input('name', '');
$album_id = input('album_id', 0);
$param = array (
'name' => 'file',
'album_id' => $album_id,
);
$result = $upload_model->setPath('common/video/' . date('Ymd') . '/')->videoToAlbum($param);
return $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;
}
/**
* 音频上传
* @return \multitype
*/
public function audio()
{
$upload_model = new UploadModel($this->site_id);
$name = input('name', '');
$album_id = input('album_id', 0);
if($album_id == 0){
$base_model = new BaseModel();
return json($base_model->error('', '请先添加一个分组'));
}
/*if($album_id == 0){
$album_id = model("album")->add([
'site_id'=>$this->site_id,
'album_name'=>'新分组',
'is_default'=>1,
'type'=>'audio'
]);
}*/
$param = array (
'name' => 'file',
'album_id' => $album_id,
);
$result = $upload_model->setPath('common/audio/' . date('Ymd') . '/')->audio($param);
return $result;
}
/*
* 替换视频文件
* */
public function modifyVideoFile()
{
// 实例化响应数据结构生成类
$base_model = new BaseModel();
try {
// 参数
$album_id = input('album_id', '');
$pic_id = input('pic_id', '');
// 获取视频信息
$album_model = new AlbumModel();
$get_pic_info = array (
[ 'pic_id', '=', $pic_id ],
[ 'site_id', '=', $this->site_id ],
);
// 视频信息
$pic_info = $album_model->getAlbumPicInfo($get_pic_info);
// 判断是否找到有效视频
if (empty($pic_info) || empty($pic_info[ 'data' ])) {
return json($base_model->error('', 'FAIL'));
}
// 实例化文件上传类
$upload_model = new UploadModel($this->site_id);
$upload_param = array (
'name' => 'file',
'album_id' => $album_id,
'pic_id' => $pic_id,
);
$result = $upload_model->setPath('common/video/' . date('Ymd') . '/')->modifyVideoFile($upload_param);
return json($result);
} catch (\Exception $e) {
return json($base_model->error($e, 'FAIL'));
}
}
/**
* 上传(不存入相册)
* @return \app\model\upload\Ambigous|\multitype
*/
public function upload()
{
$upload_model = new UploadModel();
$thumb_type = input('thumb', '');
$name = input('name', '');
$param = array (
'thumb_type' => '',
'name' => 'file'
);
$result = $upload_model->setPath('common/images/' . date('Ymd') . '/')->image($param);
return $result;
}
/**
* 校验文件
*/
public function checkfile()
{
$upload_model = new UploadModel();
$result = $upload_model->domainCheckFile([ 'name' => 'file' ]);
return $result;
}
/**
* 上传文件
*/
public function file()
{
$upload_model = new UploadModel($this->site_id);
$param = array (
'name' => 'file',
'extend_type' => [ 'xlsx' ]
);
$result = $upload_model->setPath('common/file/' . date('Ymd') . '/')->file($param);
return $result;
}
/**
* 删除文件
*/
public function deleteFile()
{
if (request()->isJson()) {
$path = input('path', '');
$res = false;
if (!empty($path)) {
$res = delFile($path);
}
return $res;
}
}
/*
* 替换图片文件
* */
public function modifyFile()
{
// 实例化响应数据结构生成类
$base_model = new BaseModel();
try {
// 参数
$album_id = input('album_id', '');
$pic_id = input('pic_id', '');
// 获取图片信息
$album_model = new AlbumModel();
$get_pic_info = array (
[ 'pic_id', '=', $pic_id ],
[ 'site_id', '=', $this->site_id ],
);
// 图片信息
$pic_info = $album_model->getAlbumPicInfo($get_pic_info);
// 判断是否找到有效图片
if (empty($pic_info) || empty($pic_info[ 'data' ])) {
return json($base_model->error('', 'FAIL'));
}
$file_full_name = basename($pic_info[ 'data' ][ 'pic_path' ]);
$pic_path = str_replace($file_full_name, '', $pic_info[ 'data' ][ 'pic_path' ]);
$pic_path = str_replace('upload/1/', '', $pic_path);
// 文件名及后缀
$filename_arr = explode('.', $file_full_name);
$filename = $filename_arr[ 0 ];
$suffix = $filename_arr[ 1 ];
// 实例化文件上传类
$upload_model = new UploadModel($this->site_id);
$upload_param = array (
'name' => 'file',
'album_id' => $album_id,
'pic_id' => $pic_id,
'thumb_type' => [ 'BIG', 'MID', 'SMALL' ],
'filename' => $filename,
'suffix' => $suffix
);
$parse_res = parse_url($pic_path);
$pic_path = ltrim($parse_res[ 'path' ], '/');
$result = $upload_model->setPath($pic_path)->modifyFile($upload_param);
return json($result);
} catch (\Exception $e) {
return json($base_model->error($e, 'FAIL'));
}
}
/**
* 下载图片
*/
public function download()
{
$filename = input('img_url', '');
$filename = urldecode($filename);
// 文件类型,作为头部发送给浏览器
// $type = filetype($filename);
$type = pathinfo($filename)[ 'extension' ];
if ($type == 'png' || $type == 'jpg') {
// 发送文件头部
header("Content-type: $type");
header("Content-Disposition: attachment;filename=$filename");
header('Content-Transfer-Encoding: binary');
header('Pragma: no-cache');
header('Expires: 0');
// 发送文件内容
set_time_limit(0);
readfile($filename);
} else {
$this->error();
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,339 +1,331 @@
<?php
/**
*/
namespace app\shop\controller;
use addon\form\model\Form;
use addon\supply\model\Supplier as SupplierModel;
use app\model\goods\Goods as GoodsModel;
use app\model\goods\GoodsAttribute as GoodsAttributeModel;
use app\model\goods\GoodsBrand as GoodsBrandModel;
use app\model\goods\GoodsCategory as GoodsCategoryModel;
use app\model\goods\GoodsLabel as GoodsLabelModel;
use app\model\goods\GoodsService as GoodsServiceModel;
use app\model\goods\VirtualGoods as VirtualGoodsModel;
use app\model\store\Store as StoreModel;
use app\model\web\Config as ConfigModel;
/**
* 虚拟商品
* Class Virtualgoods
* @package app\shop\controller
*/
class Virtualgoods extends BaseShop
{
/**
* 添加商品
* @return mixed
*/
public function addGoods()
{
if (request()->isJson()) {
$category_id = input('category_id', 0);// 分类id
$category_json = json_encode($category_id);//分类字符串
$category_id = ',' . implode(',', $category_id) . ',';
$data = [
'goods_name' => input('goods_name', ''),// 商品名称,
'goods_attr_class' => input('goods_attr_class', ''),// 商品类型id,
'goods_attr_name' => input('goods_attr_name', ''),// 商品类型名称,
'is_limit' => input('is_limit', '0'),// 商品是否限购,
'limit_type' => input('limit_type', '1'),// 商品限购类型,
'site_id' => $this->site_id,
'category_id' => $category_id,
'category_json' => $category_json,
'goods_image' => input('goods_image', ''),// 商品主图路径
'goods_content' => input('goods_content', ''),// 商品详情
'goods_state' => input('goods_state', ''),// 商品状态1.正常0下架
'price' => input('price', 0),// 商品价格取第一个sku
'market_price' => input('market_price', 0),// 市场价格取第一个sku
'cost_price' => input('cost_price', 0),// 成本价取第一个sku
'sku_no' => input('sku_no', ''),// 商品sku编码
'weight' => input('weight', ''),// 重量
'volume' => input('volume', ''),// 体积
'goods_stock' => input('goods_stock', 0),// 商品库存(总和)
'goods_stock_alarm' => input('goods_stock_alarm', 0),// 库存预警
'goods_spec_format' => input('goods_spec_format', ''),// 商品规格格式
'goods_attr_format' => input('goods_attr_format', ''),// 商品参数格式
'introduction' => input('introduction', ''),// 促销语
'keywords' => input('keywords', ''),// 关键词
'unit' => input('unit', ''),// 单位
'sort' => input('sort', 0),// 排序,
'video_url' => input('video_url', ''),// 视频
'goods_sku_data' => input('goods_sku_data', ''),// SKU商品数据
'goods_service_ids' => input('goods_service_ids', ''),// 商品服务id集合
'label_id' => input('label_id', ''),// 商品分组id
'brand_id' => input('brand_id', 0),//品牌id
'virtual_sale' => input('virtual_sale', 0),// 虚拟销量
'max_buy' => input('max_buy', 0),// 限购
'min_buy' => input('min_buy', 0),// 起售
'recommend_way' => input('recommend_way', 0), // 推荐方式1新品2精品3推荐
'timer_on' => strtotime(input('timer_on', 0)),//定时上架
'timer_off' => strtotime(input('timer_off', 0)),//定时下架
'is_consume_discount' => input('is_consume_discount', 0),//是否参与会员折扣
'is_need_verify' => input('is_need_verify', 0),// 是否需要核销
'verify_validity_type' => input('verify_validity_type', 0),// 核销有效期类型
'virtual_indate' => 0,// 虚拟商品有效期
'qr_id' => input('qr_id', 0),// 社群二维码id
'template_id' => input('template_id', 0), // 商品海报id
'sale_show' => input('sale_show', 0),//
'stock_show' => input('stock_show', 0),//
'market_price_show' => input('market_price_show', 0),//
'barrage_show' => input('barrage_show', 0),//
'virtual_deliver_type' => input('virtual_deliver_type', ''),
'virtual_receive_type' => input('virtual_receive_type', ''),
'form_id' => input('form_id', 0),
'sale_channel' => input('sale_channel', 'all'),
'sale_store' => input('sale_store', 'all'),
'supplier_id' => input('supplier_id', 0)
];
if ($data[ 'verify_validity_type' ] == 1) {
$data[ 'virtual_indate' ] = input('virtual_indate', 0);
} else if ($data[ 'verify_validity_type' ] == 2) {
$data[ 'virtual_indate' ] = strtotime(input('virtual_time', ''));
}
$virtual_goods_model = new VirtualGoodsModel();
$res = $virtual_goods_model->addGoods($data);
return $res;
} else {
//获取一级商品分类
$goods_category_model = new GoodsCategoryModel();
$condition = [
[ 'pid', '=', 0 ],
[ 'site_id', '=', $this->site_id ]
];
$goods_category_list = $goods_category_model->getCategoryList($condition, 'category_id,category_name,level,commission_rate')[ 'data' ];
$this->assign('goods_category_list', $goods_category_list);
//获取商品类型
$goods_attr_model = new GoodsAttributeModel();
$attr_class_list = $goods_attr_model->getAttrClassList([ [ 'site_id', '=', $this->site_id ] ], 'class_id,class_name')[ 'data' ];
$this->assign('attr_class_list', $attr_class_list);
// 商品服务
$goods_service_model = new GoodsServiceModel();
$service_list = $goods_service_model->getServiceList([ [ 'site_id', '=', $this->site_id ] ], 'id,service_name,icon')[ 'data' ];
$this->assign('service_list', $service_list);
// 商品分组
$goods_label_model = new GoodsLabelModel();
$label_list = $goods_label_model->getLabelList([ [ 'site_id', '=', $this->site_id ] ], 'id,label_name', 'sort ASC')[ 'data' ];
$this->assign('label_list', $label_list);
// 商品品牌
$goods_brand_model = new GoodsBrandModel();
$brand_list = $goods_brand_model->getBrandList([ [ 'site_id', '=', $this->site_id ] ], 'brand_id,brand_name', 'sort asc')[ 'data' ];
$this->assign('brand_list', $brand_list);
//商品默认排序值
$config_model = new ConfigModel();
$sort_config = $config_model->getGoodsSort($this->site_id)[ 'data' ][ 'value' ];
$this->assign('sort_config', $sort_config);
//获取商品海报
$poster_list = event('PosterTemplate', [ 'site_id' => $this->site_id ], true);
if (!empty($poster_list)) {
$poster_list = $poster_list[ 'data' ];
}
$this->assign('poster_list', $poster_list);
$this->assign('virtualcard_exit', addon_is_exit('virtualcard', $this->site_id));
$form_is_exit = addon_is_exit('form', $this->site_id);
if ($form_is_exit) {
$form_list = ( new Form() )->getFormList([ [ 'site_id', '=', $this->site_id ], [ 'form_type', '=', 'goods' ], [ 'is_use', '=', 1 ] ], 'id desc', 'id, form_name')[ 'data' ];
$this->assign('form_list', $form_list);
}
$this->assign('form_is_exit', $form_is_exit);
$this->assign('all_goodsclass', event('GoodsClass'));
$this->assign('goods_class', ( new VirtualGoodsModel() )->getGoodsClass());
$this->assign('store_is_exit', addon_is_exit('store', $this->site_id));
$is_install_supply = addon_is_exit('supply');
if ($is_install_supply) {
$supplier_model = new SupplierModel();
$supplier_list = $supplier_model->getSupplyList([ [ 'supplier_site_id', '=', $this->site_id ] ], 'supplier_id,title', 'supplier_id desc')['data'];
$this->assign('supplier_list', $supplier_list);
}
$this->assign('is_install_supply', $is_install_supply);
return $this->fetch('virtualgoods/add_goods');
}
}
/**
* 编辑商品
* @return mixed
*/
public function editGoods()
{
$virtual_goods_model = new VirtualGoodsModel();
if (request()->isJson()) {
$category_id = input('category_id', 0);// 分类id
$category_json = json_encode($category_id);//分类字符串
$category_id = ',' . implode(',', $category_id) . ',';
$data = [
'goods_id' => input('goods_id', 0),// 商品id
'goods_name' => input('goods_name', ''),// 商品名称,
'goods_attr_class' => input('goods_attr_class', ''),// 商品类型id,
'goods_attr_name' => input('goods_attr_name', ''),// 商品类型名称,
'is_limit' => input('is_limit', '0'),// 商品是否限购,
'limit_type' => input('limit_type', '1'),// 商品限购类型,
'site_id' => $this->site_id,
'category_id' => $category_id,
'category_json' => $category_json,
'goods_image' => input('goods_image', ''),// 商品主图路径
'goods_content' => input('goods_content', ''),// 商品详情
'goods_state' => input('goods_state', ''),// 商品状态1.正常0下架
'price' => input('price', 0),// 商品价格取第一个sku
'market_price' => input('market_price', 0),// 市场价格取第一个sku
'cost_price' => input('cost_price', 0),// 成本价取第一个sku
'sku_no' => input('sku_no', ''),// 商品sku编码
'weight' => input('weight', ''),// 重量
'volume' => input('volume', ''),// 体积
'goods_stock' => input('goods_stock', 0),// 商品库存(总和)
'goods_stock_alarm' => input('goods_stock_alarm', 0),// 库存预警
'goods_spec_format' => input('goods_spec_format', ''),// 商品规格格式
'goods_attr_format' => input('goods_attr_format', ''),// 商品参数格式
'introduction' => input('introduction', ''),// 促销语
'keywords' => input('keywords', ''),// 关键词
'unit' => input('unit', ''),// 单位
'sort' => input('sort', 0),// 排序,
'video_url' => input('video_url', ''),// 视频
'goods_sku_data' => input('goods_sku_data', ''),// SKU商品数据
'goods_service_ids' => input('goods_service_ids', ''),// 商品服务id集合
'label_id' => input('label_id', ''),// 商品分组id
'brand_id' => input('brand_id', 0),//品牌id
'virtual_sale' => input('virtual_sale', 0),// 虚拟销量
'max_buy' => input('max_buy', 0),// 限购
'min_buy' => input('min_buy', 0),// 起售
'recommend_way' => input('recommend_way', 0), // 推荐方式1新品2精品3推荐
'timer_on' => strtotime(input('timer_on', 0)),//定时上架
'timer_off' => strtotime(input('timer_off', 0)),//定时下架
'spec_type_status' => input('spec_type_status', 0),
'is_consume_discount' => input('is_consume_discount', 0),//是否参与会员折扣
'is_need_verify' => input('is_need_verify', 0),// 是否需要核销
'verify_validity_type' => input('verify_validity_type', 0),// 核销有效期类型
'virtual_indate' => 0,// 虚拟商品有效期
'verify_num' => input('verify_num', 1), // 核销次数
'qr_id' => input('qr_id', 0),// 社群二维码id
'template_id' => input('template_id', 0), // 商品海报id
'sale_show' => input('sale_show', 0),//
'stock_show' => input('stock_show', 0),//
'market_price_show' => input('market_price_show', 0),//
'barrage_show' => input('barrage_show', 0),//
'virtual_deliver_type' => input('virtual_deliver_type', ''),
'virtual_receive_type' => input('virtual_receive_type', ''),
'form_id' => input('form_id', 0),
'sale_channel' => input('sale_channel', 'all'),
'sale_store' => input('sale_store', 'all'),
'supplier_id' => input('supplier_id', 0)
];
if ($data[ 'verify_validity_type' ] == 1) {
$data[ 'virtual_indate' ] = input('virtual_indate', 0);
} else if ($data[ 'verify_validity_type' ] == 2) {
$data[ 'virtual_indate' ] = strtotime(input('virtual_time', ''));
}
$res = $virtual_goods_model->editGoods($data);
return $res;
} else {
$goods_model = new GoodsModel();
$goods_id = input('goods_id', 0);
$goods_info = $goods_model->editGetGoodsInfo([ [ 'goods_id', '=', $goods_id ], [ 'site_id', '=', $this->site_id ] ])[ 'data' ];
if (empty($goods_info)) $this->error('未获取到商品数据', href_url('shop/goods/lists'));
$goods_sku_list = $virtual_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,virtual_indate,sku_image,sku_images,goods_spec_format,spec_name,stock_alarm,is_default,verify_num', '')[ 'data' ];
$goods_info[ 'sku_list' ] = $goods_sku_list;
$this->assign('goods_info', $goods_info);
//获取一级商品分类
$goods_category_model = new GoodsCategoryModel();
$condition = [
[ 'pid', '=', 0 ],
[ 'site_id', '=', $this->site_id ]
];
$goods_category_list = $goods_category_model->getCategoryList($condition, 'category_id,category_name,level,commission_rate')[ 'data' ];
$this->assign('goods_category_list', $goods_category_list);
//获取商品类型
$goods_attr_model = new GoodsAttributeModel();
$attr_class_list = $goods_attr_model->getAttrClassList([ [ 'site_id', '=', $this->site_id ] ], 'class_id,class_name')[ 'data' ];
$this->assign('attr_class_list', $attr_class_list);
// 商品服务
$goods_service_model = new GoodsServiceModel();
$service_list = $goods_service_model->getServiceList([ [ 'site_id', '=', $this->site_id ] ], 'id,service_name,icon')[ 'data' ];
$this->assign('service_list', $service_list);
//获取品牌
$goods_brand_model = new GoodsBrandModel();
$brand_list = $goods_brand_model->getBrandList([ [ 'site_id', '=', $this->site_id ] ], 'brand_id, brand_name')[ 'data' ];
$this->assign('brand_list', $brand_list);
// 商品标签
$goods_label_model = new GoodsLabelModel();
$label_list = $goods_label_model->getLabelList([ [ 'site_id', '=', $this->site_id ] ], 'id,label_name', 'sort ASC')[ 'data' ];
$this->assign('label_list', $label_list);
//获取商品海报
$poster_list = event('PosterTemplate', [ 'site_id' => $this->site_id ], true);
if (!empty($poster_list)) {
$poster_list = $poster_list[ 'data' ];
}
$this->assign('poster_list', $poster_list);
$form_is_exit = addon_is_exit('form', $this->site_id);
if ($form_is_exit) {
$form_list = ( new Form() )->getFormList([ [ 'site_id', '=', $this->site_id ], [ 'form_type', '=', 'goods' ], [ 'is_use', '=', 1 ] ], 'id desc', 'id, form_name')[ 'data' ];
$this->assign('form_list', $form_list);
}
$this->assign('form_is_exit', $form_is_exit);
$store_is_exit = addon_is_exit('store', $this->site_id);
if ($store_is_exit && $goods_info[ 'sale_store' ] != 'all') {
$store_list = ( new StoreModel() )->getStoreList([ [ 'site_id', '=', $this->site_id ], [ 'store_id', 'in', $goods_info[ 'sale_store' ] ] ], 'store_id,store_name,status,address,full_address,is_frozen');
$this->assign('store_list', $store_list[ 'data' ]);
}
$this->assign('store_is_exit', $store_is_exit);
$is_install_supply = addon_is_exit('supply');
if ($is_install_supply) {
$supplier_model = new SupplierModel();
$supplier_list = $supplier_model->getSupplyList([ [ 'supplier_site_id', '=', $this->site_id ] ], 'supplier_id,title', 'supplier_id desc')['data'];
$this->assign('supplier_list', $supplier_list);
}
$this->assign('is_install_supply', $is_install_supply);
if (addon_is_exit('stock')) {
// 检查库存是否需要调整
$stock_model = new \addon\stock\model\stock\Stock();
$has_stock_records = $stock_model->getGoodsIsHasStockRecords($goods_id, $this->site_id);
$this->assign('has_stock_records', $has_stock_records[ 'code' ]);
}
return $this->fetch('virtualgoods/edit_goods');
}
}
<?php
namespace app\shop\controller;
use addon\form\model\Form;
use addon\supply\model\Supplier as SupplierModel;
use app\model\goods\Goods as GoodsModel;
use app\model\goods\GoodsAttribute as GoodsAttributeModel;
use app\model\goods\GoodsBrand as GoodsBrandModel;
use app\model\goods\GoodsCategory as GoodsCategoryModel;
use app\model\goods\GoodsLabel as GoodsLabelModel;
use app\model\goods\GoodsService as GoodsServiceModel;
use app\model\goods\VirtualGoods as VirtualGoodsModel;
use app\model\store\Store as StoreModel;
use app\model\web\Config as ConfigModel;
/**
* 虚拟商品
* Class Virtualgoods
* @package app\shop\controller
*/
class Virtualgoods extends BaseShop
{
/**
* 添加商品
* @return mixed
*/
public function addGoods()
{
if (request()->isJson()) {
$category_id = input('category_id', 0);// 分类id
$category_json = json_encode($category_id);//分类字符串
$category_id = ',' . implode(',', $category_id) . ',';
$data = [
'goods_name' => input('goods_name', ''),// 商品名称,
'goods_attr_class' => input('goods_attr_class', ''),// 商品类型id,
'goods_attr_name' => input('goods_attr_name', ''),// 商品类型名称,
'is_limit' => input('is_limit', '0'),// 商品是否限购,
'limit_type' => input('limit_type', '1'),// 商品限购类型,
'site_id' => $this->site_id,
'category_id' => $category_id,
'category_json' => $category_json,
'goods_image' => input('goods_image', ''),// 商品主图路径
'goods_content' => input('goods_content', ''),// 商品详情
'goods_state' => input('goods_state', ''),// 商品状态1.正常0下架
'price' => input('price', 0),// 商品价格取第一个sku
'market_price' => input('market_price', 0),// 市场价格取第一个sku
'cost_price' => input('cost_price', 0),// 成本价取第一个sku
'sku_no' => input('sku_no', ''),// 商品sku编码
'weight' => input('weight', ''),// 重量
'volume' => input('volume', ''),// 体积
'goods_stock' => input('goods_stock', 0),// 商品库存(总和)
'goods_stock_alarm' => input('goods_stock_alarm', 0),// 库存预警
'goods_spec_format' => input('goods_spec_format', ''),// 商品规格格式
'goods_attr_format' => input('goods_attr_format', ''),// 商品参数格式
'introduction' => input('introduction', ''),// 促销语
'keywords' => input('keywords', ''),// 关键词
'unit' => input('unit', ''),// 单位
'sort' => input('sort', 0),// 排序,
'video_url' => input('video_url', ''),// 视频
'goods_sku_data' => input('goods_sku_data', ''),// SKU商品数据
'goods_service_ids' => input('goods_service_ids', ''),// 商品服务id集合
'label_id' => input('label_id', ''),// 商品分组id
'brand_id' => input('brand_id', 0),//品牌id
'virtual_sale' => input('virtual_sale', 0),// 虚拟销量
'max_buy' => input('max_buy', 0),// 限购
'min_buy' => input('min_buy', 0),// 起售
'recommend_way' => input('recommend_way', 0), // 推荐方式1新品2精品3推荐
'timer_on' => strtotime(input('timer_on', 0)),//定时上架
'timer_off' => strtotime(input('timer_off', 0)),//定时下架
'is_consume_discount' => input('is_consume_discount', 0),//是否参与会员折扣
'is_need_verify' => input('is_need_verify', 0),// 是否需要核销
'verify_validity_type' => input('verify_validity_type', 0),// 核销有效期类型
'virtual_indate' => 0,// 虚拟商品有效期
'qr_id' => input('qr_id', 0),// 社群二维码id
'template_id' => input('template_id', 0), // 商品海报id
'sale_show' => input('sale_show', 0),//
'stock_show' => input('stock_show', 0),//
'market_price_show' => input('market_price_show', 0),//
'barrage_show' => input('barrage_show', 0),//
'virtual_deliver_type' => input('virtual_deliver_type', ''),
'virtual_receive_type' => input('virtual_receive_type', ''),
'form_id' => input('form_id', 0),
'sale_channel' => input('sale_channel', 'all'),
'sale_store' => input('sale_store', 'all'),
'supplier_id' => input('supplier_id', 0)
];
if ($data[ 'verify_validity_type' ] == 1) {
$data[ 'virtual_indate' ] = input('virtual_indate', 0);
} else if ($data[ 'verify_validity_type' ] == 2) {
$data[ 'virtual_indate' ] = strtotime(input('virtual_time', ''));
}
$virtual_goods_model = new VirtualGoodsModel();
$res = $virtual_goods_model->addGoods($data);
return $res;
} else {
//获取一级商品分类
$goods_category_model = new GoodsCategoryModel();
$condition = [
[ 'pid', '=', 0 ],
[ 'site_id', '=', $this->site_id ]
];
$goods_category_list = $goods_category_model->getCategoryList($condition, 'category_id,category_name,level,commission_rate')[ 'data' ];
$this->assign('goods_category_list', $goods_category_list);
//获取商品类型
$goods_attr_model = new GoodsAttributeModel();
$attr_class_list = $goods_attr_model->getAttrClassList([ [ 'site_id', '=', $this->site_id ] ], 'class_id,class_name')[ 'data' ];
$this->assign('attr_class_list', $attr_class_list);
// 商品服务
$goods_service_model = new GoodsServiceModel();
$service_list = $goods_service_model->getServiceList([ [ 'site_id', '=', $this->site_id ] ], 'id,service_name,icon')[ 'data' ];
$this->assign('service_list', $service_list);
// 商品分组
$goods_label_model = new GoodsLabelModel();
$label_list = $goods_label_model->getLabelList([ [ 'site_id', '=', $this->site_id ] ], 'id,label_name', 'sort ASC')[ 'data' ];
$this->assign('label_list', $label_list);
// 商品品牌
$goods_brand_model = new GoodsBrandModel();
$brand_list = $goods_brand_model->getBrandList([ [ 'site_id', '=', $this->site_id ] ], 'brand_id,brand_name', 'sort asc')[ 'data' ];
$this->assign('brand_list', $brand_list);
//商品默认排序值
$config_model = new ConfigModel();
$sort_config = $config_model->getGoodsSort($this->site_id)[ 'data' ][ 'value' ];
$this->assign('sort_config', $sort_config);
//获取商品海报
$poster_list = event('PosterTemplate', [ 'site_id' => $this->site_id ], true);
if (!empty($poster_list)) {
$poster_list = $poster_list[ 'data' ];
}
$this->assign('poster_list', $poster_list);
$this->assign('virtualcard_exit', addon_is_exit('virtualcard', $this->site_id));
$form_is_exit = addon_is_exit('form', $this->site_id);
if ($form_is_exit) {
$form_list = ( new Form() )->getFormList([ [ 'site_id', '=', $this->site_id ], [ 'form_type', '=', 'goods' ], [ 'is_use', '=', 1 ] ], 'id desc', 'id, form_name')[ 'data' ];
$this->assign('form_list', $form_list);
}
$this->assign('form_is_exit', $form_is_exit);
$this->assign('all_goodsclass', event('GoodsClass'));
$this->assign('goods_class', ( new VirtualGoodsModel() )->getGoodsClass());
$this->assign('store_is_exit', addon_is_exit('store', $this->site_id));
$is_install_supply = addon_is_exit('supply');
if ($is_install_supply) {
$supplier_model = new SupplierModel();
$supplier_list = $supplier_model->getSupplyList([ [ 'supplier_site_id', '=', $this->site_id ] ], 'supplier_id,title', 'supplier_id desc')['data'];
$this->assign('supplier_list', $supplier_list);
}
$this->assign('is_install_supply', $is_install_supply);
return $this->fetch('virtualgoods/add_goods');
}
}
/**
* 编辑商品
* @return mixed
*/
public function editGoods()
{
$virtual_goods_model = new VirtualGoodsModel();
if (request()->isJson()) {
$category_id = input('category_id', 0);// 分类id
$category_json = json_encode($category_id);//分类字符串
$category_id = ',' . implode(',', $category_id) . ',';
$data = [
'goods_id' => input('goods_id', 0),// 商品id
'goods_name' => input('goods_name', ''),// 商品名称,
'goods_attr_class' => input('goods_attr_class', ''),// 商品类型id,
'goods_attr_name' => input('goods_attr_name', ''),// 商品类型名称,
'is_limit' => input('is_limit', '0'),// 商品是否限购,
'limit_type' => input('limit_type', '1'),// 商品限购类型,
'site_id' => $this->site_id,
'category_id' => $category_id,
'category_json' => $category_json,
'goods_image' => input('goods_image', ''),// 商品主图路径
'goods_content' => input('goods_content', ''),// 商品详情
'goods_state' => input('goods_state', ''),// 商品状态1.正常0下架
'price' => input('price', 0),// 商品价格取第一个sku
'market_price' => input('market_price', 0),// 市场价格取第一个sku
'cost_price' => input('cost_price', 0),// 成本价取第一个sku
'sku_no' => input('sku_no', ''),// 商品sku编码
'weight' => input('weight', ''),// 重量
'volume' => input('volume', ''),// 体积
'goods_stock' => input('goods_stock', 0),// 商品库存(总和)
'goods_stock_alarm' => input('goods_stock_alarm', 0),// 库存预警
'goods_spec_format' => input('goods_spec_format', ''),// 商品规格格式
'goods_attr_format' => input('goods_attr_format', ''),// 商品参数格式
'introduction' => input('introduction', ''),// 促销语
'keywords' => input('keywords', ''),// 关键词
'unit' => input('unit', ''),// 单位
'sort' => input('sort', 0),// 排序,
'video_url' => input('video_url', ''),// 视频
'goods_sku_data' => input('goods_sku_data', ''),// SKU商品数据
'goods_service_ids' => input('goods_service_ids', ''),// 商品服务id集合
'label_id' => input('label_id', ''),// 商品分组id
'brand_id' => input('brand_id', 0),//品牌id
'virtual_sale' => input('virtual_sale', 0),// 虚拟销量
'max_buy' => input('max_buy', 0),// 限购
'min_buy' => input('min_buy', 0),// 起售
'recommend_way' => input('recommend_way', 0), // 推荐方式1新品2精品3推荐
'timer_on' => strtotime(input('timer_on', 0)),//定时上架
'timer_off' => strtotime(input('timer_off', 0)),//定时下架
'spec_type_status' => input('spec_type_status', 0),
'is_consume_discount' => input('is_consume_discount', 0),//是否参与会员折扣
'is_need_verify' => input('is_need_verify', 0),// 是否需要核销
'verify_validity_type' => input('verify_validity_type', 0),// 核销有效期类型
'virtual_indate' => 0,// 虚拟商品有效期
'verify_num' => input('verify_num', 1), // 核销次数
'qr_id' => input('qr_id', 0),// 社群二维码id
'template_id' => input('template_id', 0), // 商品海报id
'sale_show' => input('sale_show', 0),//
'stock_show' => input('stock_show', 0),//
'market_price_show' => input('market_price_show', 0),//
'barrage_show' => input('barrage_show', 0),//
'virtual_deliver_type' => input('virtual_deliver_type', ''),
'virtual_receive_type' => input('virtual_receive_type', ''),
'form_id' => input('form_id', 0),
'sale_channel' => input('sale_channel', 'all'),
'sale_store' => input('sale_store', 'all'),
'supplier_id' => input('supplier_id', 0)
];
if ($data[ 'verify_validity_type' ] == 1) {
$data[ 'virtual_indate' ] = input('virtual_indate', 0);
} else if ($data[ 'verify_validity_type' ] == 2) {
$data[ 'virtual_indate' ] = strtotime(input('virtual_time', ''));
}
$res = $virtual_goods_model->editGoods($data);
return $res;
} else {
$goods_model = new GoodsModel();
$goods_id = input('goods_id', 0);
$goods_info = $goods_model->editGetGoodsInfo([ [ 'goods_id', '=', $goods_id ], [ 'site_id', '=', $this->site_id ] ])[ 'data' ];
if (empty($goods_info)) $this->error('未获取到商品数据', href_url('shop/goods/lists'));
$goods_sku_list = $virtual_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,virtual_indate,sku_image,sku_images,goods_spec_format,spec_name,stock_alarm,is_default,verify_num', '')[ 'data' ];
$goods_info[ 'sku_list' ] = $goods_sku_list;
$this->assign('goods_info', $goods_info);
//获取一级商品分类
$goods_category_model = new GoodsCategoryModel();
$condition = [
[ 'pid', '=', 0 ],
[ 'site_id', '=', $this->site_id ]
];
$goods_category_list = $goods_category_model->getCategoryList($condition, 'category_id,category_name,level,commission_rate')[ 'data' ];
$this->assign('goods_category_list', $goods_category_list);
//获取商品类型
$goods_attr_model = new GoodsAttributeModel();
$attr_class_list = $goods_attr_model->getAttrClassList([ [ 'site_id', '=', $this->site_id ] ], 'class_id,class_name')[ 'data' ];
$this->assign('attr_class_list', $attr_class_list);
// 商品服务
$goods_service_model = new GoodsServiceModel();
$service_list = $goods_service_model->getServiceList([ [ 'site_id', '=', $this->site_id ] ], 'id,service_name,icon')[ 'data' ];
$this->assign('service_list', $service_list);
//获取品牌
$goods_brand_model = new GoodsBrandModel();
$brand_list = $goods_brand_model->getBrandList([ [ 'site_id', '=', $this->site_id ] ], 'brand_id, brand_name')[ 'data' ];
$this->assign('brand_list', $brand_list);
// 商品标签
$goods_label_model = new GoodsLabelModel();
$label_list = $goods_label_model->getLabelList([ [ 'site_id', '=', $this->site_id ] ], 'id,label_name', 'sort ASC')[ 'data' ];
$this->assign('label_list', $label_list);
//获取商品海报
$poster_list = event('PosterTemplate', [ 'site_id' => $this->site_id ], true);
if (!empty($poster_list)) {
$poster_list = $poster_list[ 'data' ];
}
$this->assign('poster_list', $poster_list);
$form_is_exit = addon_is_exit('form', $this->site_id);
if ($form_is_exit) {
$form_list = ( new Form() )->getFormList([ [ 'site_id', '=', $this->site_id ], [ 'form_type', '=', 'goods' ], [ 'is_use', '=', 1 ] ], 'id desc', 'id, form_name')[ 'data' ];
$this->assign('form_list', $form_list);
}
$this->assign('form_is_exit', $form_is_exit);
$store_is_exit = addon_is_exit('store', $this->site_id);
if ($store_is_exit && $goods_info[ 'sale_store' ] != 'all') {
$store_list = ( new StoreModel() )->getStoreList([ [ 'site_id', '=', $this->site_id ], [ 'store_id', 'in', $goods_info[ 'sale_store' ] ] ], 'store_id,store_name,status,address,full_address,is_frozen');
$this->assign('store_list', $store_list[ 'data' ]);
}
$this->assign('store_is_exit', $store_is_exit);
$is_install_supply = addon_is_exit('supply');
if ($is_install_supply) {
$supplier_model = new SupplierModel();
$supplier_list = $supplier_model->getSupplyList([ [ 'supplier_site_id', '=', $this->site_id ] ], 'supplier_id,title', 'supplier_id desc')['data'];
$this->assign('supplier_list', $supplier_list);
}
$this->assign('is_install_supply', $is_install_supply);
if (addon_is_exit('stock')) {
// 检查库存是否需要调整
$stock_model = new \addon\stock\model\stock\Stock();
$has_stock_records = $stock_model->getGoodsIsHasStockRecords($goods_id, $this->site_id);
$this->assign('has_stock_records', $has_stock_records[ 'code' ]);
}
return $this->fetch('virtualgoods/edit_goods');
}
}
}

View File

@@ -1,160 +1,152 @@
<?php
/**
*/
namespace app\shop\controller;
use app\model\order\OrderCommon as OrderCommonModel;
use app\model\order\VirtualOrder as VirtualOrderModel;
use think\facade\Config;
use app\model\system\Promotion as PromotionModel;
/**
* 虚拟订单
* Class Virtualorder
* @package app\shop\controller
*/
class Virtualorder extends BaseShop
{
/**
* 快递订单列表
*/
public function lists()
{
$order_label_list = array (
'order_no' => '订单号',
'out_trade_no' => '外部单号',
'name' => '收货人姓名',
'order_name' => '商品名称',
'mobile' => '收货人电话',
);
$order_status = input('order_status', '');//订单状态
$order_name = input('order_name', '');
$pay_type = input('pay_type', '');
$order_from = input('order_from', '');
$start_time = input('start_time', '');
$end_time = input('end_time', '');
$order_label = !empty($order_label_list[ input('order_label') ]) ? input('order_label') : '';
$search_text = input('search', '');
$promotion_type = input('promotion_type', '');
$order_common_model = new OrderCommonModel();
if (request()->isJson()) {
$page_index = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$condition = [
['order_type', '=', 4 ],
['site_id', '=', $this->site_id ]
];
//订单状态
if ($order_status != '') {
$condition[] = ['order_status', '=', $order_status ];
}
//订单内容 模糊查询
if ($order_name != '') {
$condition[] = ['order_name', 'like', "%$order_name%" ];
}
//订单来源
if ($order_from != '') {
$condition[] = ['order_from', '=', $order_from ];
}
//订单支付
if ($pay_type != '') {
$condition[] = ['pay_type', '=', $pay_type ];
}
//营销类型
if ($promotion_type != '') {
if ($promotion_type == 'empty') {
$condition[] = ['promotion_type', '=', '' ];
} else {
$condition[] = ['promotion_type', '=', $promotion_type ];
}
}
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) ] ];
}
if ($search_text != '') {
$condition[] = [ $order_label, 'like', "%$search_text%" ];
}
$list = $order_common_model->getOrderPageList($condition, $page_index, $page_size, 'create_time desc');
return $list;
} else {
$this->assign('order_label_list', $order_label_list);
$order_model = new VirtualOrderModel();
$order_status_list = $order_model->order_status;
$this->assign('order_status_list', $order_status_list);//订单状态
//订单来源 (支持端口)
$order_from = Config::get('app_type');
$this->assign('order_from_list', $order_from);
$pay_type = $order_common_model->getPayType();
$this->assign('pay_type_list', $pay_type);
//营销活动类型
$promotion_model = new PromotionModel();
$promotion_type = $promotion_model->getPromotionType();
$this->assign('promotion_type', $promotion_type);
return $this->fetch('virtualorder/lists');
}
}
/**
* 订单详情
* @return mixed
*/
public function detail()
{
$order_id = input('order_id', 0);
$order_common_model = new OrderCommonModel();
$order_detail_result = $order_common_model->getOrderDetail($order_id);
$order_detail = $order_detail_result['data'];
$this->assign('order_detail', $order_detail);
return $this->fetch('virtualorder/detail');
}
/**
* 订单关闭
* @return mixed
*/
public function close()
{
}
/**
* 订单调价
* @return mixed
*/
public function adjustprice()
{
}
/**
* 订单发货
*/
public function delivery()
{
$virtual_order_model = new VirtualOrderModel();
$params = array (
'order_id' => input('order_id', 0),
'site_id' => $this->site_id
);
$result = $virtual_order_model->virtualDelivery($params);
return $result;
}
<?php
namespace app\shop\controller;
use app\model\order\OrderCommon as OrderCommonModel;
use app\model\order\VirtualOrder as VirtualOrderModel;
use think\facade\Config;
use app\model\system\Promotion as PromotionModel;
/**
* 虚拟订单
* Class Virtualorder
* @package app\shop\controller
*/
class Virtualorder extends BaseShop
{
/**
* 快递订单列表
*/
public function lists()
{
$order_label_list = array (
'order_no' => '订单号',
'out_trade_no' => '外部单号',
'name' => '收货人姓名',
'order_name' => '商品名称',
'mobile' => '收货人电话',
);
$order_status = input('order_status', '');//订单状态
$order_name = input('order_name', '');
$pay_type = input('pay_type', '');
$order_from = input('order_from', '');
$start_time = input('start_time', '');
$end_time = input('end_time', '');
$order_label = !empty($order_label_list[ input('order_label') ]) ? input('order_label') : '';
$search_text = input('search', '');
$promotion_type = input('promotion_type', '');
$order_common_model = new OrderCommonModel();
if (request()->isJson()) {
$page_index = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$condition = [
['order_type', '=', 4 ],
['site_id', '=', $this->site_id ]
];
//订单状态
if ($order_status != '') {
$condition[] = ['order_status', '=', $order_status ];
}
//订单内容 模糊查询
if ($order_name != '') {
$condition[] = ['order_name', 'like', "%$order_name%" ];
}
//订单来源
if ($order_from != '') {
$condition[] = ['order_from', '=', $order_from ];
}
//订单支付
if ($pay_type != '') {
$condition[] = ['pay_type', '=', $pay_type ];
}
//营销类型
if ($promotion_type != '') {
if ($promotion_type == 'empty') {
$condition[] = ['promotion_type', '=', '' ];
} else {
$condition[] = ['promotion_type', '=', $promotion_type ];
}
}
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) ] ];
}
if ($search_text != '') {
$condition[] = [ $order_label, 'like', "%$search_text%" ];
}
$list = $order_common_model->getOrderPageList($condition, $page_index, $page_size, 'create_time desc');
return $list;
} else {
$this->assign('order_label_list', $order_label_list);
$order_model = new VirtualOrderModel();
$order_status_list = $order_model->order_status;
$this->assign('order_status_list', $order_status_list);//订单状态
//订单来源 (支持端口)
$order_from = Config::get('app_type');
$this->assign('order_from_list', $order_from);
$pay_type = $order_common_model->getPayType();
$this->assign('pay_type_list', $pay_type);
//营销活动类型
$promotion_model = new PromotionModel();
$promotion_type = $promotion_model->getPromotionType();
$this->assign('promotion_type', $promotion_type);
return $this->fetch('virtualorder/lists');
}
}
/**
* 订单详情
* @return mixed
*/
public function detail()
{
$order_id = input('order_id', 0);
$order_common_model = new OrderCommonModel();
$order_detail_result = $order_common_model->getOrderDetail($order_id);
$order_detail = $order_detail_result['data'];
$this->assign('order_detail', $order_detail);
return $this->fetch('virtualorder/detail');
}
/**
* 订单关闭
* @return mixed
*/
public function close()
{
}
/**
* 订单调价
* @return mixed
*/
public function adjustprice()
{
}
/**
* 订单发货
*/
public function delivery()
{
$virtual_order_model = new VirtualOrderModel();
$params = array (
'order_id' => input('order_id', 0),
'site_id' => $this->site_id
);
$result = $virtual_order_model->virtualDelivery($params);
return $result;
}
}

View File

@@ -1,12 +1,11 @@
<link rel="stylesheet" href="SHOP_CSS/order_detail.css"/>
<!-- 订单详情、订单状态 -->
<div class="order-detail">
<div class="title">订单详情</div>
<div class="order-information order-information-bottom">
<div class="order-detail layui-card card-common card-brief">
<div class="layui-card-header">
<span class="card-title">订单详情</span>
</div>
<div class="order-information order-information-bottom layui-card-body">
<div class="order-information-contentOne">
<div class="contentOne-content">
<div class="contentOne-content-title">交易流水号:</div>
@@ -68,21 +67,26 @@
<div class="order-information-contentTwo"></div>
</div>
<div class="title">订单状态</div>
<div class="order-information-contentOne order-orderStatus-contentOne ">
<div class="layui-card-header">
<span class="card-title">订单状态</span>
</div>
<div class="order-information-contentOne order-orderStatus-contentOne layui-card-body">
<div class="contentOne-content">
<div class="contentOne-content-title">订单状态:</div>
<div class="contentOne-content-text contentOne-content-textNew">{$order_detail.order_status_name}</div>
</div>
<div class="contentTow-operation">
<div class="contentTow-operation-content" onclick="orderRemark('{$order_detail.order_id}')">备注</div>
<div class="contentTow-operation-content bg-color-light-9 contentTow-operation-new" onclick="orderRemark('{$order_detail.order_id}')">备注</div>
{php}
$order_json_data = json_decode($order_detail['order_status_action'], true);
$action = $order_json_data['action'];
{/php}
{foreach $action as $action_k => $action_item}
<a class="contentTow-operation-content contentTow-operation-new" href="javascript:orderAction('{$action_item.action}', '{$order_detail.order_id}')">{$action_item.title}</a>
<a class="contentTow-operation-content bg-color-light-9 contentTow-operation-new" href="javascript:orderAction('{$action_item.action}', '{$order_detail.order_id}')">{$action_item.title}</a>
{/foreach}
{if addon_is_exit("printer") && $order_detail.order_status != -1}
<a class="contentTow-operation-content bg-color-light-9 contentTow-operation-new bg-color-light-9" href="javascript:printTicket('{$order_detail.order_id}');" >打印小票</a>
{/if}
</div>
<div class="orderStatus">
<div class="orderStatus-content-title">提醒:</div>
@@ -96,8 +100,10 @@
{if isset($order_detail.form)}
<!-- 表单信息 -->
<div class="formFields">
<div class="title">表单信息</div>
<div class="order-information order-formFields">
<div class="layui-card-header">
<span class="card-title">表单信息</span>
</div>
<div class="order-information order-formFields layui-card-body">
{foreach name="$order_detail.form" item="vo"}
<div class="contentOne-content">
<div class="contentOne-content-title">{$vo.title}</div>
@@ -125,8 +131,10 @@
{if $order_detail['is_invoice'] == 1}
<!-- 发票信息 -->
<div class="formFields">
<div class="title">发票信息</div>
<div class="order-information order-formFields">
<div class="layui-card-header">
<span class="card-title">发票信息</span>
</div>
<div class="order-information order-formFields layui-card-body">
<div class="contentOne-content">
<div class="contentOne-content-title">发票类型:</div>
<div class="contentOne-content-text">{if $order_detail['invoice_type'] == 1}纸质{else/}电子{/if}{if $order_detail['is_tax_invoice'] == 1}专票{else/}普票{/if}</div>
@@ -178,9 +186,11 @@
</div>
<!-- 商品信息、订单操作日志 -->
<div class="shop-information">
<div class="title">商品信息</div>
<div class="shop-information-table">
<div class="shop-information layui-card card-common card-brief">
<div class="layui-card-header">
<span class="card-title">商品信息</span>
</div>
<div class="shop-information-table layui-card-body">
<table lay-filter="parse-table-order-product" lay-skin="line">
<thead>
<tr class="table-trOne">
@@ -250,9 +260,11 @@
{notempty name="$order_detail.order_log"}
<!-- 订单操作 -->
<div class="shop-operation">
<div class="title">订单操作日志</div>
<div class="shop-operation-time">
<div class="shop-operation layui-card card-common card-brief">
<div class="layui-card-header">
<span class="card-title">订单操作日志</span>
</div>
<div class="shop-operation-time layui-card-body">
<ul class="layui-timeline">
{foreach name="$order_detail.order_log" item="vo"}
<li class="layui-timeline-item">
@@ -276,5 +288,3 @@
{include file="order/order_common_action" /}
<!-- 修改订单收货地址 -->
{include file="order/order_action" /}

View File

@@ -0,0 +1,167 @@
<style>
.marked-message{height: 48px;background: #FFF5ED;font-size: 14px;font-family: Source Han Sans SC;font-weight: 400;color: #666;line-height: 50px;padding: 0 16px;display: flex;}
.promote-flex{display: flex;margin-top: 15px;padding: 0 10px 0;}
.promote-img{background-color: #f8f8f8;display: flex;justify-content: center;align-items: center;width: 200px;height: 200px;}
.promote-img img{width: 160px;height: 160px;}
.label-width{width: 100px;}
.block-left{margin-left: 100px !important;display: flex;}
.promote-download{margin-left: 20px;}
.h5-path{margin-left: 20px;width: 300px;}
.h5-path .fuzhi{width: 1px;height: 0px;border: 0px;}
.h5-path span{display: block;margin-bottom: 10px;}
.h5-path p input{height: 30px;line-height: 30px;border: 1px solid #e6e6e5;width: 150px;padding: 0px 5px;border-radius: 5px;margin-right: 10px;}
</style>
<script type="text/html" id="promote">
<div>
<div class="marked-message">
<p>活动可分享至多个渠道推广增加曝光率提升分享打开率</p>
</div>
<div class="promote-flex">
<div class="promote-img">
<img src="{{ ns.img(d.h5.path) }}" alt="推广二维码">
</div>
<div class="layui-form">
<div class="layui-form-item">
<label class="layui-form-label label-width">选择渠道</label>
<div class="layui-input-block block-left">
<input type="radio" name="promote_type" value="h5" title="H5" checked lay-filter="promote_type" data-config='{{JSON.stringify(d.h5)}}'/>
{if addon_is_exit('weapp', request()->siteid()) == 1}
<input type="radio" name="promote_type" value="weapp" title="微信小程序" lay-filter="promote_type" data-config='{"type":"weapp","load":"true"}' />
{/if}
{if addon_is_exit('pc', request()->siteid()) == 1}
{{# if(d.pc && d.pc.path){ }}
<input type="radio" name="promote_type" value="pc" title="PC" lay-filter="promote_type" />
{{# } }}
{/if}
{if addon_is_exit('aliapp', request()->siteid()) == 1 }
<input type="radio" name="promote_type" value="aliapp" title="支付宝小程序" lay-filter="promote_type" data-config='{"type":"weapp","load":"true"}' />
{/if}
</div>
</div>
<div class="h5-path">
<span>推广链接</span>
<p class="tips text-color"><input type="text" value="{{d.h5.url}}" readonly /><a class="layui-btn" href="javascript:ns.copy('h5_url_{{ d.id }}');">复制</a></p>
<input type="text" id="h5_url_{{ d.id }}" value="{{d.h5.url}}" readonly class="fuzhi"/>
</div>
<div class="promote-download">
<a class="text-color" href="{{ ns.img(d.h5.path) }}" download>下载二维码</a>
</div>
</div>
</div>
</div>
</script>
<script>
function PromoteShow(param){
param = param || {};
let that = this;
that.getPromoteUrl = param.url;
that.getPromoteParam = param.param;
that.promoteData = {};
that.getQrcode('h5', ()=>{
that.open(()=>{
that.getOtherQrcode();
that.onSwitch();
})
})
}
PromoteShow.prototype.onSwitch = function (){
let that = this;
window.form.on('radio(promote_type)', function(radio){
that.switchAction(radio.value);
});
}
PromoteShow.prototype.getOtherQrcode = function (){
let that = this;
var app_type_arr = ['weapp','aliapp'];
app_type_arr.forEach((app_type)=>{
that.getQrcode(app_type,function () {
let radio_dom = $('input[name="promote_type"][value="'+app_type+'"]');
if(that.promoteData[app_type]){
radio_dom.attr('data-config',JSON.stringify(that.promoteData[app_type]))
}else{
radio_dom.attr('data-config',JSON.stringify({ type : app_type, path : '' }))
}
if(radio_dom.prop('checked')){
that.switchAction(app_type);
}
});
})
}
PromoteShow.prototype.getQrcode = function (app_type, callback){
let that = this;
let data = ns.deepclone(that.getPromoteParam);
data.app_type = app_type;
$.ajax({
type: "POST",
url: that.getPromoteUrl,
data: data,
dataType: 'JSON',
success: function (res) {
if (res.code >= 0){
if(res.data[app_type]){
that.promoteData[app_type] = res.data[app_type];
}
callback();
}else{
layer.msg(res.message);
}
}
});
}
PromoteShow.prototype.open = function (callback){
let that = this;
laytpl($("#promote").html()).render(that.promoteData, function (html) {
layer.open({
type: 1,
area: ['730px', '450px'],
offset: '155px',
title: ['推广'],
content: html,
success: function(){
form.render();
callback();
}
})
})
}
PromoteShow.prototype.switchAction = function (app_type){
var dom = $('input[name="promote_type"][value="'+app_type+'"]');
var data = $(dom).attr('data-config');
if(data) data = JSON.parse(data);
else data = {};
if(app_type == 'h5' || app_type == 'pc') {
var html = '<img src="'+ ns.img(data.path) +'"/>';
$('.promote-img').html(html);
$('.promote-download a').attr('href',ns.img(data.path)).show();
$(".h5-path").show().find('input').val(data.url);
}else {
if(data.load){
var html = '<div class="common-loading-wrap">';
html += '<i class="common-loading-layer layui-icon layui-icon-loading layui-anim layui-anim-rotate layui-anim-loop"></i>';
html += '</div>';
$('.promote-img').html(html);
$('.promote-download a').hide();
}else if(data.path){
var html = '<img src="'+ ns.img(data.path) +'"/>';
$('.promote-img').html(html);
$('.promote-download a').attr('href',ns.img(data.path)).show();
}else{
var html = '<span>小程序配置错误</span>';
$('.promote-img').html(html);
$('.promote-download a').hide();
}
$(".h5-path").hide();
}
}
</script>

View File

@@ -1,12 +1,7 @@
<style type="text/css">
.inline-block{display: inline-block;}
</style>
<div class="layui-form form-wrap">
<div class="layui-form-item">
<label class="layui-form-label">腾讯地图KEY</label>
@@ -16,6 +11,7 @@
</div>
<div class="word-aux">
<p>平台腾讯定位地图应用KEY</p>
<p>使用场景:手机端收货地址选择、查询距离最近的门店,管理端店铺联系地址,管理端-门店地图选择</p>
</div>
</div>
<div class="layui-form-item">
@@ -25,6 +21,16 @@
</div>
<div class="word-aux">开启后,进入首页将获取定位信息</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">定位有效期:</label>
<div class="layui-input-block">
<div class="layui-input-inline">
<input type="number" class="layui-input len-short" name="wap_valid_time" value="{$info.wap_valid_time}" />
</div>
<span class="layui-form-mid">分钟</span>
</div>
<div class="word-aux">过期后将重新获取定位信息0为不过期</div>
</div>
<div class="form-row">
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
@@ -32,8 +38,6 @@
</div>
<script>
layui.use('form', function() {
var form = layui.form,

View File

@@ -1,7 +1,3 @@
<!-- 列表 -->
<table id="pay_list" lay-filter="pay_list"></table>
@@ -24,8 +20,6 @@
</div>
</script>
<script>
var table = new Table({
elem: '#pay_list',
@@ -48,8 +42,16 @@
}, {
field: 'desc',
title: '支付方式描述',
width: '60%',
width: '45%',
unresize: 'false'
},{
field: 'status',
title: '支付状态',
width: '15%',
unresize: 'false',
templet: function (data){
return data.pay_status == 1 ? '已开启✅' : '未开启';
}
}, {
title: '操作',
toolbar: '#operation',

View File

@@ -191,7 +191,7 @@
{if condition="!empty($diy_view_info)"}
<input type="hidden" id="id" value="{$diy_view_info.id}">
<input type="hidden" id="info" value='{$diy_view_info.value ?? ""}' />
<input type="hidden" id="info" value='' />
{/if}
<input type="hidden" id="name" value="{$name}" />
<input type="hidden" id="title" value="{$title}" />
@@ -201,6 +201,8 @@
<script>
var requestUrl = '{$request_url}';
var storeIsExit = '{$store_is_exit}';
//直接在隐藏域中写入,有些单引号和双引号会无法解析,导致字符串被截断
$("#info").val(JSON.stringify({php}echo $diy_view_info['value'] ?? '';{/php}));
</script>
<script src="STATIC_JS/vue.js"></script>
<script src="STATIC_EXT/colorPicker/js/colorpicker.js"></script>

View File

@@ -105,10 +105,6 @@
text-align: right;
}
.heat-map-wrap .manage-wrap .list-wrap .item div {
}
.heat-map-wrap .manage-wrap .list-wrap .item div span {
cursor: pointer;
}
@@ -119,8 +115,6 @@
}
</style>
<div class="layui-form heat-map-wrap">
<div class="content-box" id="content_box"><!-- 热区列表 --></div>
<div class="manage-wrap">
@@ -130,7 +124,6 @@
</div>
</div>
<script type="text/html" id="dragBoxHtml">
{{# for(let i=0;i<d.length;i++){ }}
<div id="box_{{ i }}" class="area-box" style="left:{{ d[i].left }}{{ d[i].unit }};top:{{ d[i].top }}{{ d[i].unit }};width:{{ d[i].width }}{{ d[i].unit }};height:{{ d[i].height }}{{ d[i].unit }}" onmousedown="mouseDown(event,{{ i }})">
@@ -773,4 +766,3 @@
}
</script>

View File

@@ -1,5 +1,3 @@
<style>
.icon-img-box{
width: 48px;
@@ -14,8 +12,6 @@
}
</style>
<div id="{$id}">
<div class="icon-img-box" v-if="myData.iconType == 'img'">
<img :src="changeImgUrl(myData.imageUrl) || changeImgUrl('public/static/img/default_img/square.png')" alt="">
@@ -25,8 +21,6 @@
</div>
</div>
<script src="STATIC_EXT/colorPicker/js/colorpicker.js"></script>
<script src="STATIC_JS/vue.js"></script>
{include file="diy/iconfont_component"/}

View File

@@ -1,6 +1,3 @@
<style>
.layui-form {
padding: 15px;
@@ -95,8 +92,6 @@
}
</style>
<div id="app" class="layui-form icon-style-set">
<div class="layui-form-item">
<label class="layui-form-label">图标:</label>
@@ -168,8 +163,6 @@
</div>
</div>
<script src="STATIC_EXT/colorPicker/js/colorpicker.js"></script>
<script src="STATIC_JS/vue.js"></script>
{include file="diy/iconfont_component"/}

View File

@@ -65,7 +65,7 @@
},
iconStyle(){
if (!this.value) return {};
console.log(this.value)
var style = {
fontSize: this.value.fontSize + '%'
}

View File

@@ -65,7 +65,7 @@ function loadMenu(url) {
if (window.currentMenu) {
// 菜单树结构,面包屑
getMenuTree(window.currentMenu.name)
getMenuTree(window.currentMenu.name);
window.crumbs.sort((a, b) => {
return a.level - b.level;
});
@@ -96,7 +96,7 @@ function renderMenu() {
window.secondMenu = item.child_list;
window.firstMenu = item;
}
})
});
// 加载一级菜单
$('.menu-first-wrap').html(html);
@@ -104,6 +104,9 @@ function renderMenu() {
// 顶部面包屑
$('.layui-header-crumbs-first span').text(window.firstMenu.title);
// 删除四级菜单
$('.forth-menu-wrap').remove();
// 加载二、三、四级菜单
if (window.secondMenu.length) {
@@ -154,16 +157,15 @@ function renderMenu() {
//优化四级菜单
// 加载四级菜单
$('.forth-menu-wrap').remove();
if (window.forthMenu.length) {
var forthMenuHtml = '';
forthMenuHtml += `<div class="fourstage-nav layui-tab layui-tab-brief forth-menu-wrap">`;
forthMenuHtml += `<ul class="layui-tab-title">`;
window.forthMenu.forEach(function (item, index) {
let query = getRoute().query;
let arr = [];
let href = item.url;
for (let key in query) {
var query = getRoute().query;
var arr = [];
var href = item.url;
for (var key in query) {
arr.push(`${key}=${query[key]}`)
}
if (arr.length) {
@@ -222,7 +224,7 @@ function renderMenu() {
}
// a标签跳转点击事件
$('body').on('click', 'a', (function () {
$('.layui-side').on('click', 'a', (function () {
var href = $(this).attr('href'); // 跳转链接
var target = $(this).attr('target');
var level = $(this).attr('data-menu-level'); // 菜单等级,滚动定位
@@ -256,7 +258,7 @@ $('body').on('click', 'a', (function () {
hash = arr[1];
// 找到当前页面地址
var query = hash.split('&');
for (let i = 0; i < query.length; i++) {
for (var i = 0; i < query.length; i++) {
if (query[i].indexOf('url=') != -1) {
url = query[i].replace('url=', '');
break;
@@ -300,10 +302,14 @@ function getHashArr() {
// 监听hash值变化加载页面
function listenerHash(isLoadMenu = true) {
var params = getRoute();
//有的客户会出现同一个链接,直接页面访问 和 ajax访问 无法区分的情况,特此做区分
params.query._type = 'html';
var url = params.url;
// 加载页面前,显示加载动画进行过渡
let html = '<div class="loader-inner ball-clip-rotate"><p></p></div>';
var html = '<div class="common-loading-wrap">';
html += '<i class="common-loading-layer layui-icon layui-icon-loading layui-anim layui-anim-rotate layui-anim-loop"></i>';
html += '</div>';
$('.layui-layout-admin .layui-body .body-content').html(html);
// 切换页面,删除弹框、依赖
@@ -346,7 +352,7 @@ function listenerHash(isLoadMenu = true) {
}, 20);
// 是否加载菜单
if (isLoadMenu) {
if (html !== '权限不足,请联系管理员' && isLoadMenu) {
loadMenu(url);
}
}
@@ -427,10 +433,10 @@ function getMenuTree(name) {
}
function initForthMenu() {
if (window.crumbs.length == 0) return;
//应用中心直接跳过不显示四级
if(window.crumbs[0].name == 'PROMOTION_ROOT') return;
if (window.crumbs.length == 0) return;
var child = window.crumbs[window.crumbs.length - 1];
if (child.is_show == 0) return;
@@ -450,10 +456,10 @@ function initForthMenu() {
// 处理营销活动菜单
function handlePromotionMenu(index, key) {
let emptyAddon = []; // 保留营销活动主菜单
let promotionAddon = []; // 快捷方式中的有效插件菜单
let currentAddon = []; // 当前选中插件菜单,不在快捷方式中,要展示出来
let addon = window.crumbs[window.crumbs.length - 1].addon;
var emptyAddon = []; // 保留营销活动主菜单
var promotionAddon = []; // 快捷方式中的有效插件菜单
var currentAddon = []; // 当前选中插件菜单,不在快捷方式中,要展示出来
var addon = window.crumbs[window.crumbs.length - 1].addon;
window.secondMenu[index].child_list.forEach(function (menuItem, menuIndex) {
if (menuItem.addon == '') {