初始上传
This commit is contained in:
96
app/shop/controller/Account.php
Executable file
96
app/shop/controller/Account.php
Executable file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shop\controller;
|
||||
|
||||
use app\model\member\Withdraw;
|
||||
use app\model\order\Order as OrderModel;
|
||||
use app\model\order\OrderCommon;
|
||||
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 OrderCommon() )->getOrderGoodsInfo([
|
||||
[ 'o.site_id', '=', $this->site_id ],
|
||||
[ 'og.refund_status', '<>', 0 ],
|
||||
[ 'og.refund_time', 'between', [ $start_time, $end_time ] ],
|
||||
], 'sum((og.refund_pay_money + IF(o.order_money > 0, og.shop_active_refund_money * o.pay_money / o.order_money, 0.00))) as refund_money', 'og', [['order o', 'o.order_id = og.order_id', 'inner']])[ 'data' ]['refund_money'] ?? '0.00',
|
||||
'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);
|
||||
}
|
||||
}
|
||||
194
app/shop/controller/Address.php
Executable file
194
app/shop/controller/Address.php
Executable file
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shop\controller;
|
||||
|
||||
use app\model\system\Address as AddressModel;
|
||||
use app\model\web\Config as ConfigModel;
|
||||
use app\Controller;
|
||||
|
||||
/**
|
||||
* 地址控制器
|
||||
* Class Order
|
||||
* @package app\shop\controller
|
||||
*/
|
||||
class Address extends BaseShop
|
||||
{
|
||||
/**
|
||||
* 通过ajax得到运费模板的地区数据
|
||||
*/
|
||||
public function getAreaList()
|
||||
{
|
||||
$address_model = new AddressModel();
|
||||
$level = input('level', 1);
|
||||
$pid = input('pid', 0);
|
||||
$child = input('child', 0);
|
||||
$condition = array(
|
||||
'level' => $level,
|
||||
'pid' => $pid
|
||||
);
|
||||
$list = $address_model->getAreaList($condition, 'id, pid, name, shortname, level', 'id asc');
|
||||
if (!empty($list['data']) && $child) {
|
||||
foreach ($list['data'] as $k => $item) {
|
||||
$list['data'][$k]['child_num'] = $address_model->getAreaCount([ ['pid', '=', $item['id'] ] ])['data'];
|
||||
}
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取地理位置id
|
||||
*/
|
||||
public function getGeographicId()
|
||||
{
|
||||
$address_model = new AddressModel();
|
||||
$address = request()->post('address', ',,');
|
||||
$address_array = explode(',', $address);
|
||||
$province = $address_array[0];
|
||||
$city = $address_array[1];
|
||||
$district = $address_array[2];
|
||||
$subdistrict = $address_array[3];
|
||||
$province_list = $address_model->getAreaList(['name' => $province, 'level' => 1], 'id', '');
|
||||
$province_id = !empty($province_list['data']) ? $province_list['data'][0]['id'] : 0;
|
||||
$city_list = ($province_id > 0) && !empty($city) ? $address_model->getAreaList(['name' => $city, 'level' => 2, 'pid' => $province_id], 'id', '') : [];
|
||||
$city_id = !empty($city_list['data']) ? $city_list['data'][0]['id'] : 0;
|
||||
$district_list = !empty($district) && $city_id > 0 && $province_id > 0 ? $address_model->getAreaList(['name' => $district, 'level' => 3, 'pid' => $city_id], 'id', '') : [];
|
||||
$district_id = !empty($district_list['data']) ? $district_list['data'][0]['id'] : 0;
|
||||
|
||||
$subdistrict_list = !empty($subdistrict) && $city_id > 0 && $province_id > 0 && $district_id > 0 ? $address_model->getAreaList(['name' => $subdistrict, 'level' => 4, 'pid' => $district_id], 'id', '') : [];
|
||||
$subdistrict_id = !empty($subdistrict_list['data']) ? $subdistrict_list['data'][0]['id'] : 0;
|
||||
return ['province_id' => $province_id, 'city_id' => $city_id, 'district_id' => $district_id, 'subdistrict_id' => $subdistrict_id];
|
||||
}
|
||||
|
||||
/**
|
||||
* 地区管理
|
||||
* @return mixed
|
||||
*/
|
||||
public function manage()
|
||||
{
|
||||
$address_model = new AddressModel();
|
||||
$list = $address_model->getAreaList([['level', '=', 1]], 'id, pid, name, shortname, level', 'id asc')['data'];
|
||||
if (!empty($list)) {
|
||||
foreach ($list as $k => $item) {
|
||||
$list[$k]['child_num'] = $address_model->getAreaCount([ ['pid', '=', $item['id'] ] ])['data'];
|
||||
}
|
||||
}
|
||||
$this->assign('area', $list);
|
||||
|
||||
return $this->fetch('address/manage');
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存地区
|
||||
*/
|
||||
public function saveArea(){
|
||||
if (request()->isJson()) {
|
||||
$address_model = new AddressModel();
|
||||
$data = [
|
||||
'id' => input('id'),
|
||||
'name' => input('name', ''),
|
||||
'shortname' => input('shortname', ''),
|
||||
'pid' => input('pid', 0),
|
||||
'level' => input('level', 1),
|
||||
];
|
||||
return $address_model->saveArea($data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除地区
|
||||
* @return array
|
||||
*/
|
||||
public function deleteArea(){
|
||||
if (request()->isJson()) {
|
||||
$address_model = new AddressModel();
|
||||
$id = input('id');
|
||||
$level = input('level');
|
||||
return $address_model->deleteArae($id, $level);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 地址字符串获取详情
|
||||
*/
|
||||
public function addressToDetail()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$address = input('address', '');
|
||||
$qq_map = new \app\model\map\QqMap();
|
||||
$res = $qq_map->addressToDetail([
|
||||
'address' => $address,
|
||||
]);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 经纬度获取详情
|
||||
*/
|
||||
public function locationToDetail()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$location = input('location', '');
|
||||
$qq_map = new \app\model\map\QqMap();
|
||||
$res = $qq_map->locationToDetail([
|
||||
'location' => $location,
|
||||
]);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 地区树
|
||||
*/
|
||||
public function getAreaTree()
|
||||
{
|
||||
if(request()->isJson()){
|
||||
$tree_level = input('tree_level', 3);
|
||||
$tree_ids = input('tree_ids', '');
|
||||
|
||||
$condition = [];
|
||||
$condition[] = ['level', '<=', $tree_level];
|
||||
if(!empty($tree_ids)){
|
||||
$condition[] = ['id', 'in', $tree_ids];
|
||||
}
|
||||
|
||||
$category_model = new AddressModel();
|
||||
$list = $category_model->getAreaList($condition, "id, name as title, pid, level", "id asc")['data'];
|
||||
$tree = list_to_tree($list, 'id', 'pid', 'children', 0);
|
||||
$tree = keyArrToIndexArr($tree, 'children');
|
||||
return $category_model->success($tree);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 解析地址
|
||||
*/
|
||||
public function analysesAddress()
|
||||
{
|
||||
if(request()->isJson()){
|
||||
$address = input('address', '');
|
||||
$address_model = new AddressModel();
|
||||
return $address_model->analysesAddress($address);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function geMapConfig(){
|
||||
$map_model = new \app\model\map\QqMap();
|
||||
$res = [
|
||||
'key'=>$map_model->getKey()
|
||||
];
|
||||
|
||||
return success(0,'请求成功',$res);
|
||||
}
|
||||
}
|
||||
326
app/shop/controller/Adv.php
Executable file
326
app/shop/controller/Adv.php
Executable file
@@ -0,0 +1,326 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shop\controller;
|
||||
|
||||
use app\model\web\Adv as AdvModel;
|
||||
use app\model\web\AdvPosition;
|
||||
|
||||
|
||||
/**
|
||||
* 广告管理
|
||||
*/
|
||||
class Adv extends BaseShop
|
||||
{
|
||||
|
||||
/**
|
||||
* 广告位管理
|
||||
* @return mixed
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$adv_position = new AdvPosition();
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$search_text = input('search_text', '');
|
||||
$type = input('type', '');//位置类型 1 电脑端 2 手机端
|
||||
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'type', '=', 2 ]
|
||||
];
|
||||
if (!empty($search_text)) {
|
||||
$condition[] = [ 'ap_name', 'like', '%' . $search_text . '%' ];
|
||||
}
|
||||
if ($type !== '') {
|
||||
$condition[] = [ 'type', '=', $type ];
|
||||
}
|
||||
return $adv_position->getAdvPositionPageList($condition, $page, $page_size);
|
||||
} else {
|
||||
|
||||
return $this->fetch('adv/index');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加广告位
|
||||
*/
|
||||
public function addPosition()
|
||||
{
|
||||
$adv_position = new AdvPosition();
|
||||
if (request()->isJson()) {
|
||||
$data = [
|
||||
'ap_name' => input('ap_name', ''),
|
||||
'keyword' => input('keyword', ''),
|
||||
'ap_intro' => input('ap_intro', ''),
|
||||
'ap_height' => input('ap_height', 0),
|
||||
'ap_width' => input('ap_width', 0),
|
||||
'default_content' => input('default_content', ''),
|
||||
'ap_background_color' => input('ap_background_color', ''),
|
||||
'type' => input('type', 2),
|
||||
'state' => input('state', 0),
|
||||
'site_id' => $this->site_id
|
||||
];
|
||||
return $adv_position->addAdvPosition($data);
|
||||
} else {
|
||||
return $this->fetch('adv/add_position');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑广告位
|
||||
*/
|
||||
public function editPosition()
|
||||
{
|
||||
$adv_position = new AdvPosition();
|
||||
$ap_id = input('ap_id', 0);
|
||||
if (request()->isJson()) {
|
||||
$data = [
|
||||
'ap_name' => input('ap_name', ''),
|
||||
'keyword' => input('keyword', ''),
|
||||
'ap_intro' => input('ap_intro', ''),
|
||||
'ap_height' => input('ap_height', 0),
|
||||
'ap_width' => input('ap_width', 0),
|
||||
'default_content' => input('default_content', ''),
|
||||
'ap_background_color' => input('ap_background_color', ''),
|
||||
'state' => input('state', 0),
|
||||
];
|
||||
return $adv_position->editAdvPosition($data, [ [ 'ap_id', '=', $ap_id ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
} else {
|
||||
$ap_info = $adv_position->getAdvPositionInfo([ [ 'ap_id', '=', $ap_id ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
$this->assign('info', $ap_info[ 'data' ]);
|
||||
return $this->fetch('adv/edit_position');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改广告位字段
|
||||
*/
|
||||
public function editPositionField()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$adv_position = new AdvPosition();
|
||||
$type = input('type', '');
|
||||
$value = input('value', 0);
|
||||
$ap_id = input('ap_id', 0);
|
||||
$data = [
|
||||
$type => $value
|
||||
];
|
||||
return $adv_position->editAdvPosition($data, [ [ 'ap_id', '=', $ap_id ] ]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除广告位
|
||||
*/
|
||||
public function deletePosition()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$ap_ids = input('ap_ids', 0);
|
||||
$adv_position = new AdvPosition();
|
||||
return $adv_position->deleteAdvPosition([ [ 'ap_id', 'in', $ap_ids ], [ 'site_id', '=', $this->site_id ] ], $ap_ids);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 广告列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$adv = new AdvModel();
|
||||
$adv_position = new AdvPosition();
|
||||
|
||||
$ap_id = input('ap_id', '');
|
||||
$keyword = input('keyword', '');
|
||||
if (!empty($keyword)) {
|
||||
$info = $adv_position->getAdvPositionInfo([ [ 'keyword', '=', $keyword ] ], 'ap_id')[ 'data' ];
|
||||
if (!empty($info)) {
|
||||
$ap_id = $info[ 'ap_id' ];
|
||||
}
|
||||
}
|
||||
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$search_text = input('search_text', '');
|
||||
$slide_sort = input('sort', '');
|
||||
//查询所有手机端广告位
|
||||
$conditions[] = [ 'type', '=', 2 ];
|
||||
$positions = $adv_position->getAdvPositionList($conditions);
|
||||
$positions_ids = array_column($positions[ 'data' ], 'ap_id');
|
||||
$condition = [
|
||||
[ 'a.site_id', '=', $this->site_id ],
|
||||
[ 'a.ap_id', 'in', $positions_ids ]
|
||||
];
|
||||
if (!empty($search_text)) {
|
||||
$condition[] = [ 'a.adv_title', 'like', '%' . $search_text . '%' ];
|
||||
}
|
||||
if ($ap_id !== '') {
|
||||
$condition[] = [ 'a.ap_id', '=', $ap_id ];
|
||||
}
|
||||
|
||||
//排序
|
||||
$slide_sort = input('order', 'slide_sort');
|
||||
$sort = input('sort', 'desc');
|
||||
if ($slide_sort == 'slide_sort') {
|
||||
$order_by = 'a.' . $slide_sort . ' ' . $sort;
|
||||
} else {
|
||||
$order_by = 'a.' . $slide_sort . ' ' . $sort . ',a.slide_sort desc';
|
||||
}
|
||||
|
||||
return $adv->getAdvPageList($condition, $page, $page_size, $order_by);
|
||||
} else {
|
||||
$this->assign('ap_id', $ap_id);
|
||||
|
||||
|
||||
$adv_position = new AdvPosition();
|
||||
$adv_position_list = $adv_position->getAdvPositionList([ [ 'site_id', '=', $this->site_id ], [ 'type', '=', 2 ] ], 'ap_id,ap_name')[ 'data' ];
|
||||
$this->assign('adv_position', $adv_position_list);
|
||||
|
||||
return $this->fetch('adv/lists');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加广告
|
||||
*/
|
||||
public function addAdv()
|
||||
{
|
||||
$adv = new AdvModel();
|
||||
if (request()->isJson()) {
|
||||
$data = [
|
||||
'ap_id' => input('ap_id', 0),
|
||||
'adv_title' => input('adv_title', ''),
|
||||
'adv_url' => input('adv_url', ''),
|
||||
'adv_image' => input('adv_image', ''),
|
||||
'slide_sort' => input('slide_sort', 0),
|
||||
'price' => input('price', 0),
|
||||
'background' => input('background', ''),
|
||||
'state' => input('state', 0),
|
||||
'site_id' => $this->site_id
|
||||
];
|
||||
return $adv->addAdv($data);
|
||||
} else {
|
||||
$adv_position = new AdvPosition();
|
||||
$adv_position_list = $adv_position->getAdvPositionList([ [ 'site_id', '=', $this->site_id ], [ 'type', '=', 2 ] ]);
|
||||
$this->assign('adv_position_list', $adv_position_list[ 'data' ]);
|
||||
|
||||
$ap_id = input('ap_id', 0);
|
||||
$this->assign('ap_id', $ap_id);
|
||||
|
||||
return $this->fetch('adv/add_adv');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑广告
|
||||
*/
|
||||
public function editAdv()
|
||||
{
|
||||
$adv_id = input('adv_id', '');
|
||||
$adv = new AdvModel();
|
||||
if (request()->isJson()) {
|
||||
$data = [
|
||||
'ap_id' => input('ap_id', 0),
|
||||
'adv_title' => input('adv_title', ''),
|
||||
'adv_url' => input('adv_url', ''),
|
||||
'adv_image' => input('adv_image', ''),
|
||||
'slide_sort' => input('slide_sort', 0),
|
||||
'price' => input('price', 0),
|
||||
'background' => input('background', ''),
|
||||
// 'state' => input('state', 0),
|
||||
];
|
||||
return $adv->editAdv($data, [ [ 'adv_id', '=', $adv_id ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
} else {
|
||||
$adv_position = new AdvPosition();
|
||||
$adv_position_list = $adv_position->getAdvPositionList([ [ 'site_id', '=', $this->site_id ], [ 'type', '=', 2 ] ]);
|
||||
$this->assign('adv_position_list', $adv_position_list[ 'data' ]);
|
||||
$adv_info = $adv->getAdvInfo($adv_id);
|
||||
$this->assign('adv_info', $adv_info[ 'data' ]);
|
||||
// 得到当前广告图类型
|
||||
$type = 2;// 1 pc、2 wap
|
||||
foreach ($adv_position_list[ 'data' ] as $k => $v) {
|
||||
if ($v[ 'ap_id' ] == $adv_info[ 'data' ][ 'ap_id' ]) {
|
||||
$type = $v[ 'type' ];
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->assign('type', $type);
|
||||
|
||||
$ap_id = input('ap_id', 0);
|
||||
$this->assign('ap_id', $ap_id);
|
||||
|
||||
return $this->fetch('adv/edit_adv');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改广告字段
|
||||
*/
|
||||
public function editAdvField()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$adv = new AdvModel();
|
||||
$type = input('type', '');
|
||||
$value = input('value', '');
|
||||
$adv_id = input('adv_id', '');
|
||||
$data = [
|
||||
$type => $value
|
||||
];
|
||||
return $adv->editAdv($data, [ [ 'adv_id', '=', $adv_id ] ]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除广告
|
||||
*/
|
||||
public function deleteAdv()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$adv_ids = input('adv_ids', 0);
|
||||
$adv = new AdvModel();
|
||||
return $adv->deleteAdv([ [ 'adv_id', 'in', $adv_ids ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改广告位状态
|
||||
* @return array
|
||||
*/
|
||||
public function alterAdvPositionState()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$ap_id = input('ap_id', 0);
|
||||
$state = input('state', 0);
|
||||
$ap_model = new AdvPosition();
|
||||
return $ap_model->editAdvPosition([ 'state' => $state ], [ [ 'ap_id', '=', $ap_id ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改广告状态
|
||||
* @return array
|
||||
*/
|
||||
public function alterAdvState()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$adv_id = input('adv_id', 0);
|
||||
$state = input('state', 0);
|
||||
$ap_model = new AdvModel();
|
||||
return $ap_model->editAdv([ 'state' => $state ], [ [ 'adv_id', '=', $adv_id ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
277
app/shop/controller/Album.php
Executable file
277
app/shop/controller/Album.php
Executable file
@@ -0,0 +1,277 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shop\controller;
|
||||
|
||||
use app\model\upload\Album as AlbumModel;
|
||||
use think\App;
|
||||
|
||||
/**
|
||||
* 相册
|
||||
* @package app\shop\controller
|
||||
*/
|
||||
class Album extends BaseShop
|
||||
{
|
||||
|
||||
/**
|
||||
* 图像
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
header('Expires:-1');
|
||||
header('Cache-Control:no_cache');
|
||||
header('Pragma:no-cache');
|
||||
$type = input('type', 'img');
|
||||
$album_model = new AlbumModel();
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$limit = input('limit', PAGE_LIST_ROWS);
|
||||
$album_id = input('album_id', '');
|
||||
$pic_name = input('pic_name', '');
|
||||
$order = input('order', 'update_time desc');
|
||||
$condition = array (
|
||||
['site_id', '=', $this->site_id],
|
||||
['album_id', 'in', $album_id],
|
||||
);
|
||||
if (!empty($pic_name)) {
|
||||
$condition[] = ['pic_name', 'like', '%' . $pic_name . '%'];
|
||||
}
|
||||
return $album_model->getAlbumPicPageList($condition, $page, $limit, $order);
|
||||
} else {
|
||||
$album_list = $album_model->getAlbumList([['site_id', '=', $this->site_id], ['type', '=', $type]]);
|
||||
$album_list_tree = $album_model->getAlbumListTree([['site_id', '=', $this->site_id], ['type', '=', $type]]);
|
||||
$this->assign('album_list', $album_list[ 'data' ]);
|
||||
$this->assign('album_list_tree', $album_list_tree[ 'data' ]);
|
||||
$this->assign('type_list', $album_model->getType());
|
||||
$this->assign('type', $type);
|
||||
return $this->fetch('album/lists');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取相册分组
|
||||
*/
|
||||
function getAlbumListTree()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$album_model = new AlbumModel();
|
||||
$type = input('type', 'img');
|
||||
return $album_model->getAlbumListTree([['site_id', "=", $this->site_id], ['type', '=', $type]]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取相册分组
|
||||
*/
|
||||
function getAlbumList()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$type = input('type', 'img');
|
||||
$album_model = new AlbumModel();
|
||||
$album_list = $album_model->getAlbumList([['site_id', '=', $this->site_id], ['type', '=', $type]]);
|
||||
return $album_list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加分组
|
||||
*/
|
||||
public function addAlbum()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$album_name = input('album_name', '');
|
||||
$pid = input('pid', '0');
|
||||
$type = input('type', '0');
|
||||
$data = array (
|
||||
'site_id' => $this->site_id,
|
||||
'album_name' => $album_name,
|
||||
'pid' => $pid,
|
||||
'type' => $type,
|
||||
'level' => empty($pid) ? 1 : 2
|
||||
);
|
||||
$album_model = new AlbumModel();
|
||||
return $album_model->addAlbum($data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改分组
|
||||
*/
|
||||
public function editAlbum()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$album_name = input('album_name');
|
||||
$album_id = input('album_id');
|
||||
$data = array (
|
||||
'album_name' => $album_name
|
||||
);
|
||||
$condition = array (
|
||||
['site_id', '=', $this->site_id],
|
||||
['album_id', '=', $album_id]
|
||||
);
|
||||
$album_model = new AlbumModel();
|
||||
return $album_model->editAlbum($data, $condition);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除分组
|
||||
*/
|
||||
public function deleteAlbum()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$album_id = input('album_id');
|
||||
$album_model = new AlbumModel();
|
||||
$condition = array (
|
||||
['album_id', '=', $album_id],
|
||||
['site_id', '=', $this->site_id]
|
||||
);
|
||||
return $album_model->deleteAlbum($condition);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分组详情
|
||||
*/
|
||||
public function albumInfo()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$album_id = input('album_id');
|
||||
$album_model = new AlbumModel();
|
||||
$condition = array (
|
||||
['album_id', '=', $album_id],
|
||||
['site_id', '=', $this->site_id]
|
||||
);
|
||||
$res = $album_model->getAlbumInfo($condition);
|
||||
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改文件名
|
||||
*/
|
||||
public function modifyPicName()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$pic_id = input('pic_id', 0);
|
||||
$pic_name = input('pic_name', '');
|
||||
$album_id = input('album_id', 0);
|
||||
|
||||
$album_model = new AlbumModel();
|
||||
$condition = array (
|
||||
['pic_id', '=', $pic_id],
|
||||
['site_id', '=', $this->site_id],
|
||||
['album_id', '=', $album_id]
|
||||
);
|
||||
$data = array (
|
||||
'pic_name' => $pic_name
|
||||
);
|
||||
return $album_model->editAlbumPic($data, $condition);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改图片分组
|
||||
*/
|
||||
public function modifyFileAlbum()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$pic_id = input('pic_id', 0);//图片id
|
||||
$album_id = input('album_id', 0);//相册id
|
||||
$album_model = new AlbumModel();
|
||||
$condition = array (
|
||||
['pic_id', 'in', $pic_id],
|
||||
['site_id', '=', $this->site_id]
|
||||
);
|
||||
return $album_model->modifyAlbumPicAlbum($album_id, $condition);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除图片
|
||||
*/
|
||||
public function deleteFile()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$pic_id = input('pic_id', 0);//图片id
|
||||
$album_model = new AlbumModel();
|
||||
$condition = array (
|
||||
['pic_id', 'in', $pic_id],
|
||||
['site_id', '=', $this->site_id],
|
||||
);
|
||||
return $album_model->deleteAlbumPic($condition);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 相册管理界面
|
||||
* @return mixed
|
||||
*/
|
||||
public function album()
|
||||
{
|
||||
$album_model = new AlbumModel();
|
||||
$type = input('type', 'img');
|
||||
$display_type = input('display_type', 'img');
|
||||
$is_thumb = input('is_thumb', 0);
|
||||
if (request()->isJson()) {
|
||||
$page_index = input('page', 1);
|
||||
$list_rows = input('limit', PAGE_LIST_ROWS);
|
||||
$album_id = input('album_id', '');
|
||||
$pic_name = input('pic_name', '');
|
||||
$condition = array (
|
||||
['site_id', '=', $this->site_id],
|
||||
['album_id', 'in', $album_id],
|
||||
);
|
||||
if (!empty($pic_name)) {
|
||||
$condition[] = ['pic_name', 'like', '%' . $pic_name . '%'];
|
||||
}
|
||||
return $album_model->getAlbumPicPageList($condition, $page_index, $list_rows, 'update_time desc');
|
||||
} else {
|
||||
$album_list = $album_model->getAlbumList([['site_id', '=', $this->site_id]]);
|
||||
$this->assign('album_list', $album_list[ 'data' ]);
|
||||
|
||||
$album_tree_list = $album_model->getAlbumListTree([['site_id', '=', $this->site_id], ['type', '=', $type]]);
|
||||
$this->assign('album_tree_list', $album_tree_list[ 'data' ]);
|
||||
|
||||
$this->assign('type_list', $album_model->getType());
|
||||
$this->assign('type', $type);
|
||||
$this->assign('display_type', $display_type);
|
||||
$this->assign('is_thumb', $is_thumb);
|
||||
return $this->fetch('album/album');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成缩略图
|
||||
*/
|
||||
public function createThumb()
|
||||
{
|
||||
ignore_user_abort(true);
|
||||
if (request()->isJson()) {
|
||||
$upload_model = new AlbumModel();
|
||||
$pic_ids = input('pic_ids', '');
|
||||
return $upload_model->createThumbBatch($this->site_id, $pic_ids);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新相册数量
|
||||
*/
|
||||
public function refreshAlbumNum()
|
||||
{
|
||||
ignore_user_abort(true);
|
||||
$upload_model = new AlbumModel();
|
||||
$upload_model->refreshAlbumNum($this->site_id);
|
||||
}
|
||||
|
||||
}
|
||||
215
app/shop/controller/Article.php
Executable file
215
app/shop/controller/Article.php
Executable file
@@ -0,0 +1,215 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shop\controller;
|
||||
|
||||
use app\model\article\Article as ArticleModel;
|
||||
use app\model\article\ArticleCategory;
|
||||
use app\model\web\Config as ConfigModel;
|
||||
|
||||
/**
|
||||
* 文章
|
||||
* @package app\shop\controller
|
||||
*/
|
||||
class Article extends BaseShop
|
||||
{
|
||||
|
||||
/**
|
||||
* 文章列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$search_text = input('search_text', '');
|
||||
$condition = [ [ 'pn.site_id', '=', $this->site_id ], [ 'status', '=', 1 ] ];
|
||||
$condition[] = [ 'pn.article_title', 'like', '%' . $search_text . '%' ];
|
||||
$order_by = 'pn.create_time desc';
|
||||
|
||||
$article_model = new ArticleModel();
|
||||
return $article_model->getArticlePageList($condition, $page, $page_size, $order_by);
|
||||
} else {
|
||||
return $this->fetch('article/lists');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 推广
|
||||
* @return array
|
||||
*/
|
||||
public function promote()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$article_id = input('article_id', 0);
|
||||
$app_type = input('app_type', 'all');
|
||||
$article_model = new ArticleModel();
|
||||
$article_info = $article_model->getArticleInfo([ [ 'article_id', '=', $article_id ] ], 'article_id')[ 'data' ];
|
||||
if (!empty($article_info)) {
|
||||
return $article_model->urlQrcode([ 'article_id' => $article_id ], $app_type, $this->site_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 草稿箱
|
||||
*/
|
||||
public function drafts()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$search_text = input('search_text', '');
|
||||
$condition = [ [ 'pn.site_id', '=', $this->site_id ], [ 'status', '=', 0 ] ];
|
||||
$condition[] = [ 'pn.article_title', 'like', '%' . $search_text . '%' ];
|
||||
$order_by = 'pn.create_time desc';
|
||||
|
||||
$article_model = new ArticleModel();
|
||||
return $article_model->getArticlePageList($condition, $page, $page_size, $order_by);
|
||||
} else {
|
||||
|
||||
return $this->fetch('article/drafts');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 文章添加
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$article_model = new ArticleModel();
|
||||
if (request()->isJson()) {
|
||||
$articles_data = [
|
||||
'site_id' => $this->site_id,
|
||||
'article_title' => input('article_title', ''),
|
||||
'article_abstract' => input('article_abstract', ''),
|
||||
'category_id' => input('category_id', ''),
|
||||
'cover_img' => input('cover_img', ''),
|
||||
'article_content' => input('article_content', ''),
|
||||
'status' => input('status', ''),
|
||||
'sort' => input('sort', '0'),
|
||||
'is_show_release_time' => input('is_show_release_time', ''),
|
||||
'is_show_read_num' => input('is_show_read_num', ''),
|
||||
'is_show_dianzan_num' => input('is_show_dianzan_num', ''),
|
||||
'initial_read_num' => input('initial_read_num', ''),
|
||||
'initial_dianzan_num' => input('initial_dianzan_num', '')
|
||||
];
|
||||
return $article_model->addArticle($articles_data);
|
||||
} else {
|
||||
$article_category_model = new ArticleCategory();
|
||||
$article_category_list = $article_category_model->getArticleCategoryList([ [ 'site_id', '=', $this->site_id ] ], 'category_id, category_name')[ 'data' ];
|
||||
$this->assign('category_list', $article_category_list);
|
||||
|
||||
return $this->fetch('article/add');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 帮助编辑
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$article_id = input('article_id', 0);
|
||||
$article_model = new ArticleModel();
|
||||
if (request()->isJson()) {
|
||||
$articles_data = [
|
||||
'article_id' => $article_id,
|
||||
'site_id' => $this->site_id,
|
||||
'article_title' => input('article_title', ''),
|
||||
'article_abstract' => input('article_abstract', ''),
|
||||
'category_id' => input('category_id', ''),
|
||||
'cover_img' => input('cover_img', ''),
|
||||
'article_content' => input('article_content', ''),
|
||||
'status' => input('status', ''),
|
||||
'sort' => input('sort', '0'),
|
||||
'is_show_release_time' => input('is_show_release_time', ''),
|
||||
'is_show_read_num' => input('is_show_read_num', ''),
|
||||
'is_show_dianzan_num' => input('is_show_dianzan_num', ''),
|
||||
'initial_read_num' => input('initial_read_num', ''),
|
||||
'initial_dianzan_num' => input('initial_dianzan_num', '')
|
||||
];
|
||||
return $article_model->editArticle($articles_data);
|
||||
} else {
|
||||
$this->assign('article_id', $article_id);
|
||||
|
||||
$article_info = $article_model->getArticleInfo([ [ 'article_id', '=', $article_id ] ]);
|
||||
$this->assign('info', $article_info[ 'data' ]);
|
||||
|
||||
$article_category_model = new ArticleCategory();
|
||||
$article_category_list = $article_category_model->getArticleCategoryList([ [ 'site_id', '=', $this->site_id ] ], 'category_id, category_name')[ 'data' ];
|
||||
$this->assign('category_list', $article_category_list);
|
||||
return $this->fetch('article/edit');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 文章删除
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$article_id = input('article_id', 0);
|
||||
$article_model = new ArticleModel();
|
||||
return $article_model->deleteArticle([ [ 'article_id', '=', $article_id ] ]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改排序
|
||||
*/
|
||||
public function modifySort()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$sort = input('sort', 0);
|
||||
$article_id = input('article_id', 0);
|
||||
$article_model = new ArticleModel();
|
||||
return $article_model->modifyArticleSort($sort, $article_id, $this->site_id);
|
||||
}
|
||||
}
|
||||
|
||||
//todo 移至草稿箱 或 草稿箱发布
|
||||
|
||||
/**
|
||||
* 文章选择
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function articleSelect()
|
||||
{
|
||||
$article_model = new ArticleModel();
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$search_text = input('search_text', '');
|
||||
$article_ids = input('article_ids', '');
|
||||
$condition = [
|
||||
[ 'pn.site_id', '=', $this->site_id ],
|
||||
[ 'pn.status', '=', 1 ]
|
||||
];
|
||||
if (!empty($search_text)) {
|
||||
$condition[] = [ 'pn.article_title', 'like', '%' . $search_text . '%' ];
|
||||
}
|
||||
if (!empty($article_ids)) {
|
||||
$condition[] = [ 'pn.article_id', 'in', $article_ids ];
|
||||
}
|
||||
return $article_model->getArticlePageList($condition, $page, $page_size, 'pn.create_time desc', 'pn.article_id,pn.article_title,pn.article_abstract,pn.cover_img,pn.read_num,pn.create_time,png.category_name');
|
||||
} else {
|
||||
//已经选择的商品sku数据
|
||||
$select_id = input('select_id', '');
|
||||
$this->assign('select_id', $select_id);
|
||||
$article_list = $article_model->getArticleList([
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'article_id', 'in', $select_id ]
|
||||
], 'article_id,article_title,article_abstract,cover_img,read_num')[ 'data' ];
|
||||
$this->assign('article_list', $article_list);
|
||||
return $this->fetch('article/article_select');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
116
app/shop/controller/Articlecategory.php
Executable file
116
app/shop/controller/Articlecategory.php
Executable file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
268
app/shop/controller/BaseShop.php
Executable file
268
app/shop/controller/BaseShop.php
Executable file
@@ -0,0 +1,268 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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->user_info[ 'is_admin' ] == 1 || $this->group_info['is_system'] == 1)) {
|
||||
$check_res = $user_model->checkAndGetRedirectUrl(['url' => $this->url, 'app_module' => $this->app_module], $this->group_info);
|
||||
if(!$check_res['is_auth']){
|
||||
$error_tips = '权限不足,请联系管理员';
|
||||
if (request()->isJson()) {
|
||||
echo json_encode(error(-1, $error_tips));exit;
|
||||
} elseif (request()->isAjax()) {
|
||||
if(request()->type() == 'html') $this->error($error_tips);
|
||||
}else{
|
||||
if(!empty($check_res[ 'redirect_url' ])){
|
||||
$this->redirect(addon_url($check_res[ 'redirect_url' ]));
|
||||
}else{
|
||||
$this->error($error_tips, url('shop/login/login'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//获取店铺信息
|
||||
$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_model = new ConfigModel();
|
||||
$theme_config = $config_model->getThemeConfig()[ 'data' ][ 'value' ];
|
||||
$this->assign('theme_config', $theme_config);
|
||||
|
||||
// 在设置模板布局之前,设置变量输出
|
||||
$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 (empty($this->group_info)) {
|
||||
$this->redirect(url('shop/login/login'));
|
||||
}
|
||||
if ($this->app_module == 'store') {
|
||||
//门店登录,用户权限对应站点id是门店id
|
||||
$this->store_id = $this->group_info[ 'site_id' ];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜单
|
||||
*/
|
||||
private function getMenuList()
|
||||
{
|
||||
$field = 'id, app_module, addon, title, name, parent, level, url, is_show, sort, picture, picture_select,type';
|
||||
$menu_model = new Menu();
|
||||
if ($this->user_info[ 'is_admin' ] || $this->group_info[ 'is_system' ] == 1) {
|
||||
$menus = $menu_model->getMenuList([ [ 'app_module', '=', $this->app_module ], ], $field, 'level asc,sort asc');
|
||||
} else {
|
||||
$menu_array = "'".str_replace(',',"','", $this->group_info[ 'menu_array' ])."'";
|
||||
$menus = $menu_model->getMenuList([
|
||||
[ 'app_module', '=', $this->app_module ],
|
||||
['', 'exp', \think\facade\Db::raw("name in ({$menu_array}) or is_control = 0")]
|
||||
], $field, 'level asc,sort asc');
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
// 请求方式,空:返回菜单+内容,iframe:iframe标签模式,返回内容,download:返回下载资源
|
||||
$request_mode = input('request_mode', '');
|
||||
if (empty($request_mode)) {
|
||||
echo $this->fetch($this->template);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询菜单列表
|
||||
* @return array
|
||||
*/
|
||||
public function menu()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$res = [];
|
||||
$menus = $this->getMenuList();
|
||||
$addon_model = new Addon();
|
||||
$res['quick_addon_menu'] = $addon_model->getAddonQuickMenuConfig($this->site_id, $this->app_module)[ 'data' ][ 'value' ];
|
||||
$res['user_is_admin'] = $this->user_info[ 'is_admin' ] || $this->group_info[ 'is_system' ] == 1 ? 1 : 0;
|
||||
$res['yuan_menu'] = $menus;
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getUserInfo($uid = null)
|
||||
{
|
||||
$condition = array (
|
||||
['uid', '=', $uid ?? $this->uid],
|
||||
['site_id', '=', $this->site_id],
|
||||
['app_module', '=', $this->app_module],
|
||||
);
|
||||
$user_model = new UserModel();
|
||||
$user_info = $user_model->getUserInfo($condition, '*')['data'];
|
||||
return $user_info;
|
||||
}
|
||||
}
|
||||
38
app/shop/controller/Cashorder.php
Executable file
38
app/shop/controller/Cashorder.php
Executable file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
}
|
||||
295
app/shop/controller/Config.php
Executable file
295
app/shop/controller/Config.php
Executable file
@@ -0,0 +1,295 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shop\controller;
|
||||
|
||||
use app\model\goods\Config as GoodsConfigModel;
|
||||
use app\model\system\Pay;
|
||||
use app\model\system\Servicer as ServicerModel;
|
||||
use app\model\web\Config as ConfigModel;
|
||||
use app\model\system\Api;
|
||||
use extend\RSA;
|
||||
use app\model\system\Upgrade;
|
||||
use app\model\system\Config as SystemConfig;
|
||||
|
||||
/**
|
||||
* 设置 控制器
|
||||
*/
|
||||
class Config extends BaseShop
|
||||
{
|
||||
public function copyright()
|
||||
{
|
||||
$upgrade_model = new Upgrade();
|
||||
$auth_info = $upgrade_model->authInfo();
|
||||
|
||||
$config_model = new ConfigModel();
|
||||
$copyright = $config_model->getCopyright($this->site_id, $this->app_module);
|
||||
if (request()->isJson()) {
|
||||
$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', ''),
|
||||
'logo' => '',
|
||||
'company_name' => '',
|
||||
'copyright_link' => '',
|
||||
'copyright_desc' => ''
|
||||
];
|
||||
if ($auth_info[ 'code' ] == 0) {
|
||||
$data[ 'logo' ] = input('logo', '');
|
||||
$data[ 'company_name' ] = input('company_name', '');
|
||||
$data[ 'copyright_link' ] = input('copyright_link', '');
|
||||
$data[ 'copyright_desc' ] = input('copyright_desc', '');
|
||||
}
|
||||
$this->addLog('修改版权配置');
|
||||
$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('copyright_config', $copyright[ 'data' ][ 'value' ]);
|
||||
return $this->fetch('config/copyright');
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付管理
|
||||
*/
|
||||
public function pay()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$pay_model = new Pay();
|
||||
$list = $pay_model->getPayType([]);
|
||||
return $list;
|
||||
} else {
|
||||
return $this->fetch('config/pay');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认图设置
|
||||
*/
|
||||
public function defaultPicture()
|
||||
{
|
||||
$upload_config_model = new ConfigModel();
|
||||
if (request()->isJson()) {
|
||||
$data = array (
|
||||
'goods' => input('goods', ''),
|
||||
'head' => input('head', ''),
|
||||
'store' => input('store', ''),
|
||||
'article' => input('article', ''),
|
||||
);
|
||||
$this->addLog('修改默认图配置');
|
||||
$res = $upload_config_model->setDefaultImg($data, $this->site_id, $this->app_module);
|
||||
return $res;
|
||||
} else {
|
||||
|
||||
$upload_config_result = $upload_config_model->getDefaultImg($this->site_id, $this->app_module);
|
||||
$this->assign('default_img', $upload_config_result[ 'data' ][ 'value' ]);
|
||||
return $this->fetch('config/default_picture');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 售后保障
|
||||
*/
|
||||
public function aftersale()
|
||||
{
|
||||
$goods_config_model = new GoodsConfigModel();
|
||||
if (request()->isJson()) {
|
||||
$content = input('content', '');//售后保障协议
|
||||
$is_display = input('is_display', 1);//默认显
|
||||
return $goods_config_model->setAfterSaleConfig('售后保障', $content, $this->site_id, $is_display);
|
||||
} else {
|
||||
|
||||
$content = $goods_config_model->getAfterSaleConfig($this->site_id);
|
||||
$this->assign('content', $content[ 'data' ]);
|
||||
return $this->fetch('config/aftersale');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证码设置
|
||||
*/
|
||||
public function captcha()
|
||||
{
|
||||
$config_model = new ConfigModel();
|
||||
if (request()->isJson()) {
|
||||
$data = [
|
||||
'shop_login' => input('shop_login', 0), // 后台登陆验证码是否启用 1:启用 0:不启用
|
||||
'shop_reception_login' => input('shop_reception_login', 0), // 前台登陆验证码是否启用 1:启用 0:不启用
|
||||
'shop_reception_register' => input('shop_reception_register', 0), // 前台注册验证码是否启用 1:启用 0:不启用
|
||||
];
|
||||
return $config_model->setCaptchaConfig($data);
|
||||
} else {
|
||||
|
||||
$config_info = $config_model->getCaptchaConfig();
|
||||
$this->assign('config_info', $config_info[ 'data' ][ 'value' ]);
|
||||
return $this->fetch('config/captcha');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* api安全
|
||||
*/
|
||||
public function api()
|
||||
{
|
||||
$api_model = new Api();
|
||||
if (request()->isJson()) {
|
||||
$is_use = input('is_use', 1);
|
||||
$public_key = input('public_key', '');
|
||||
$private_key = input('private_key', '');
|
||||
$long_time = input('long_time', '0');#限制时长 0位不限制 单位小时
|
||||
$data = array (
|
||||
'public_key' => $public_key,
|
||||
'private_key' => $private_key,
|
||||
'long_time' => $long_time
|
||||
);
|
||||
$result = $api_model->setApiConfig($data, $is_use);
|
||||
return $result;
|
||||
} else {
|
||||
$config_result = $api_model->getApiConfig();
|
||||
$config = $config_result[ 'data' ];
|
||||
$this->assign('config', $config);
|
||||
return $this->fetch('config/api');
|
||||
}
|
||||
}
|
||||
|
||||
public function generateRSA()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
return RSA::getSecretKey();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 地图配置
|
||||
* @return mixed
|
||||
*/
|
||||
public function map()
|
||||
{
|
||||
$config_model = new ConfigModel();
|
||||
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_valid_time' => $wap_valid_time
|
||||
]);
|
||||
return $result;
|
||||
} else {
|
||||
|
||||
$config = $config_model->getMapConfig()[ 'data' ][ 'value' ];
|
||||
$this->assign('info', $config);
|
||||
return $this->fetch('config/map');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 客服配置
|
||||
*/
|
||||
public function servicer()
|
||||
{
|
||||
$servicer_model = new ServicerModel();
|
||||
if (request()->isJson()) {
|
||||
$data = [
|
||||
'h5' => input('h5', []),
|
||||
'weapp' => input('weapp', []),
|
||||
'pc' => input('pc', []),
|
||||
'aliapp' => input('aliapp', []),
|
||||
];
|
||||
return $servicer_model->setServicerConfig($data);
|
||||
} else {
|
||||
$config = $servicer_model->getServicerConfig()[ 'data' ] ?? [];
|
||||
$this->assign('config', $config[ 'value' ] ?? []);
|
||||
return $this->fetch('config/servicer');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 域名跳转配置
|
||||
*/
|
||||
public function domainJumpConfig()
|
||||
{
|
||||
$config_model = new ConfigModel();
|
||||
if (request()->isJson()) {
|
||||
$jump_type = input('jump_type', '1');
|
||||
$result = $config_model->setDomainJumpConfig([
|
||||
'jump_type' => $jump_type
|
||||
]);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 网站部署
|
||||
*/
|
||||
public function siteDeploy()
|
||||
{
|
||||
$this->assign('root_url', __ROOT__);
|
||||
|
||||
// 域名跳转配置
|
||||
$config_model = new ConfigModel();
|
||||
$config = $config_model->getDomainJumpConfig()[ 'data' ][ 'value' ];
|
||||
$this->assign('config', $config);
|
||||
|
||||
// 后台主题风格列表
|
||||
$theme_list = $config_model->getThemeList()[ 'data' ];
|
||||
$this->assign('theme_list', $theme_list);
|
||||
|
||||
// 后台主题风格
|
||||
$theme_config = $config_model->getThemeConfig()[ 'data' ][ 'value' ];
|
||||
$this->assign('theme_config', $theme_config);
|
||||
|
||||
// 检测授权
|
||||
$upgrade_model = new Upgrade();
|
||||
$auth_info = $upgrade_model->authInfo();
|
||||
$this->assign('is_auth', ($auth_info[ 'code' ] >= 0 ? 1 : 0));
|
||||
|
||||
return $this->fetch('config/site_deploy');
|
||||
}
|
||||
|
||||
public function modifyConfigIsUse()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$is_use = input('is_use', 1);
|
||||
$config_key = input('config_key', '');
|
||||
return (new SystemConfig())->modifyConfigIsUse($is_use, [['site_id', '=', $this->site_id], ['app_module', '=', $this->app_module], ['config_key', '=', $config_key]]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置后台主题风格配置
|
||||
* @return array
|
||||
*/
|
||||
public function setThemeConfig()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$config_model = new ConfigModel();
|
||||
$data = [
|
||||
'title' => input('title', ''),
|
||||
'name' => input('name', ''),
|
||||
'color' => input('color', ''),
|
||||
'url' => input('url', '')
|
||||
];
|
||||
$res = $config_model->setThemeConfig($data, $this->site_id);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
364
app/shop/controller/Delivery.php
Executable file
364
app/shop/controller/Delivery.php
Executable file
@@ -0,0 +1,364 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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 array
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
648
app/shop/controller/Diy.php
Executable file
648
app/shop/controller/Diy.php
Executable file
@@ -0,0 +1,648 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shop\controller;
|
||||
|
||||
use addon\weapp\model\Config as WeappConfig;
|
||||
use addon\aliapp\model\Config as AliappConfig;
|
||||
use app\model\diy\Template;
|
||||
use app\model\diy\Theme;
|
||||
use app\model\goods\GoodsCategory;
|
||||
use app\model\goods\ServiceCategory;
|
||||
use app\model\shop\Shop as ShopModel;
|
||||
use app\model\web\DiyView as DiyViewModel;
|
||||
use addon\wechat\model\Config as WechatConfig;
|
||||
use app\model\web\DiyViewLink;
|
||||
use think\App;
|
||||
|
||||
/**
|
||||
* 网站装修控制器
|
||||
*/
|
||||
class Diy extends BaseShop
|
||||
{
|
||||
|
||||
/**
|
||||
* 管理预览
|
||||
* @return mixed
|
||||
*/
|
||||
public function management()
|
||||
{
|
||||
|
||||
$shop_model = new ShopModel();
|
||||
$qrcode_info = $shop_model->qrcode($this->site_id)[ 'data' ];
|
||||
$this->assign('qrcode_info', $qrcode_info[ 'path' ][ 'h5' ] ?? '');
|
||||
|
||||
$wechat_config_model = new WechatConfig();
|
||||
$wechat_config_result = $wechat_config_model->getWechatConfig($this->site_id)['data'][ 'value' ];
|
||||
$this->assign('wechat_config', $wechat_config_result);
|
||||
|
||||
$weapp_config_model = new WeappConfig();
|
||||
$weapp_config_result = $weapp_config_model->getWeappConfig($this->site_id)[ 'data' ][ 'value' ];
|
||||
$this->assign('weapp_config', $weapp_config_result);
|
||||
|
||||
if (addon_is_exit('aliapp', $this->site_id)) {
|
||||
$aliapp_config_model = new AliappConfig();
|
||||
$aliapp_config_result = $aliapp_config_model->getAliappConfig($this->site_id)[ 'data' ][ 'value' ];
|
||||
$this->assign('aliapp_config', $aliapp_config_result);
|
||||
}
|
||||
|
||||
$store_business = 'shop'; // 店铺运营模式
|
||||
|
||||
// 检测店铺运营模式
|
||||
if (addon_is_exit('store')) {
|
||||
$config_model = new \addon\store\model\Config();
|
||||
$business_config = $config_model->getStoreBusinessConfig($this->site_id)[ 'data' ][ 'value' ];
|
||||
$store_business = $business_config[ 'store_business' ];
|
||||
}
|
||||
|
||||
$this->assign('store_is_exit', addon_is_exit('store'));
|
||||
$this->assign('store_business', $store_business);
|
||||
|
||||
return $this->fetch('diy/management');
|
||||
}
|
||||
|
||||
/**
|
||||
* 网站主页
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$data = [
|
||||
'site_id' => $this->site_id,
|
||||
'name' => 'DIY_VIEW_INDEX'
|
||||
];
|
||||
$edit_view = event('DiyViewEdit', $data, true);
|
||||
return $edit_view;
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品分类页面
|
||||
*/
|
||||
public function goodsCategory()
|
||||
{
|
||||
$data = [
|
||||
'site_id' => $this->site_id,
|
||||
'name' => 'DIY_VIEW_GOODS_CATEGORY'
|
||||
];
|
||||
$edit_view = event('DiyViewEdit', $data, true);
|
||||
return $edit_view;
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员中心
|
||||
*/
|
||||
public function memberIndex()
|
||||
{
|
||||
$data = [
|
||||
'site_id' => $this->site_id,
|
||||
'name' => 'DIY_VIEW_MEMBER_INDEX'
|
||||
];
|
||||
$edit_view = event('DiyViewEdit', $data, true);
|
||||
return $edit_view;
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
if(env('IS_RELEASE_WEAPP')){
|
||||
return error(-1, '发布小程序期间禁止操作');
|
||||
}
|
||||
$res = 0;
|
||||
$id = input('id', 0);
|
||||
$name = input('name', '');
|
||||
$title = input('title', '');
|
||||
$value = input('value', '');
|
||||
$template_id = input('template_id', 0); // 所属模板id
|
||||
$page_type = input('page_type', ''); // 页面类型
|
||||
if (!empty($name) && !empty($title) && !empty($value)) {
|
||||
$diy_view = new DiyViewModel();
|
||||
$data = [
|
||||
'site_id' => $this->site_id,
|
||||
'name' => $name,
|
||||
'title' => $title,
|
||||
'value' => $value,
|
||||
'template_id' => $template_id
|
||||
];
|
||||
if (!empty($page_type)) {
|
||||
$diy_template_model = new Template();
|
||||
$template_info = $diy_template_model->getTemplateInfo([ [ 'name', '=', $page_type ] ], 'title,name')[ 'data' ];
|
||||
$data[ 'type' ] = $template_info[ 'name' ];
|
||||
$data[ 'type_name' ] = $template_info[ 'title' ];
|
||||
} else {
|
||||
$data[ 'is_default' ] = 1; // 自定义页面,默认为1
|
||||
}
|
||||
if ($id == 0) {
|
||||
$res = $diy_view->addSiteDiyView($data);
|
||||
} else {
|
||||
$res = $diy_view->editSiteDiyView($data, [ [ 'id', '=', $id ] ]);
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
} else {
|
||||
$id = input('id', 0);
|
||||
$template_id = input('template_id', 0);
|
||||
$title = input('title', '');
|
||||
$page_type = input('page_type', ''); // 页面类型
|
||||
|
||||
$data = [
|
||||
'site_id' => $this->site_id,
|
||||
'id' => $id,
|
||||
'template_id' => $template_id,
|
||||
'title' => $title,
|
||||
'page_type' => $page_type
|
||||
];
|
||||
$edit_view = event('DiyViewEdit', $data, true);
|
||||
|
||||
return $edit_view;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 微页面
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$type = input('type', ''); // 页面类型
|
||||
|
||||
$diy_template_goods_model = new Template();
|
||||
|
||||
// 页面类型
|
||||
$template_list = $diy_template_goods_model->getTemplateList([], 'id,title,name')[ 'data' ];
|
||||
$template_list_arr = array_column($template_list, 'name');
|
||||
|
||||
if (request()->isJson()) {
|
||||
$page_index = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$search_text = input('search_text', ''); // 页面名称
|
||||
$template_id = input('template_id', 0); // 所属模板id
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
// [ 'name', 'like', [ '%DIY_VIEW_RANDOM_%', 'DIY_VIEW_INDEX' ], 'or' ]
|
||||
];
|
||||
|
||||
if (!empty($search_text)) {
|
||||
$condition[] = [ 'title', 'like', '%' . $search_text . '%' ];
|
||||
}
|
||||
|
||||
if (!empty($type) && $type != 'ALL') {
|
||||
$condition[] = [ 'type', '=', $type ];
|
||||
}
|
||||
|
||||
if (!empty($template_id)) {
|
||||
$condition[] = [ 'template_id', '=', $template_id ];
|
||||
}
|
||||
|
||||
$field = 'id, name, title, template_id, template_item_id, type, type_name, click_num, is_default, sort, create_time';
|
||||
|
||||
$order_by = "is_default desc,INSTR('" . implode(',', $template_list_arr) . "', name) desc, create_time desc";
|
||||
|
||||
$diy_view = new DiyViewModel();
|
||||
$list = $diy_view->getSiteDiyViewPageList($condition, $page_index, $page_size, $order_by, $field);
|
||||
return $list;
|
||||
} else {
|
||||
if (empty($type)) {
|
||||
$type = 'ALL';
|
||||
}
|
||||
$this->assign('type', $type);
|
||||
|
||||
// 店铺模板
|
||||
$template_goods_list = $diy_template_goods_model->getTemplateGoodsList([], 'goods_id, title, name')[ 'data' ];
|
||||
$this->assign('template_goods_list', $template_goods_list);
|
||||
|
||||
// 选择页面类型
|
||||
$page_type_list = [];
|
||||
foreach ($template_list as $k => $v) {
|
||||
$icon = '';
|
||||
if ($v[ 'name' ] == 'DIY_VIEW_INDEX') {
|
||||
$icon = 'iconfont icondianpushouye';
|
||||
} elseif ($v[ 'name' ] == 'DIY_VIEW_GOODS_CATEGORY') {
|
||||
$icon = 'iconfont iconshangpinfenlei2';
|
||||
} elseif ($v[ 'name' ] == 'DIY_VIEW_MEMBER_INDEX') {
|
||||
$icon = 'iconfont iconhuiyuanzhongxin';
|
||||
} elseif ($v[ 'name' ] == 'DIY_STORE') {
|
||||
$icon = 'iconfont iconmendianzhuye';
|
||||
}
|
||||
|
||||
$page_type_list[] = [
|
||||
'title' => $v[ 'title' ],
|
||||
'name' => $v[ 'name' ],
|
||||
'preview' => 'public/static/ext/diyview/img/preview/' . strtolower($v[ 'name' ]) . '.jpg',
|
||||
'icon' => $icon
|
||||
];
|
||||
}
|
||||
$page_type_list[] = [
|
||||
'title' => '自定义页面',
|
||||
'name' => 'DIY_PAGE',
|
||||
'preview' => 'public/static/ext/diyview/img/preview/diy_page.jpg',
|
||||
'icon' => 'iconfont iconzidingyiyemian'
|
||||
];
|
||||
$this->assign('page_type_list', $page_type_list);
|
||||
|
||||
$this->getPageCount();
|
||||
|
||||
return $this->fetch('diy/lists');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取页面数量
|
||||
* @return array
|
||||
*/
|
||||
public function getPageCount()
|
||||
{
|
||||
$diy_view = new DiyViewModel();
|
||||
$diy_template_goods_model = new Template();
|
||||
$template_list = $diy_template_goods_model->getTemplateList([], 'id,title,name')[ 'data' ];
|
||||
|
||||
array_unshift($template_list, [
|
||||
'id' => 0,
|
||||
'title' => '全部页面',
|
||||
'name' => 'ALL'
|
||||
]);
|
||||
$template_list[] = [
|
||||
'id' => 0,
|
||||
'title' => '自定义页面',
|
||||
'name' => 'DIY_PAGE'
|
||||
];
|
||||
foreach ($template_list as $k => $v) {
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ]
|
||||
];
|
||||
if ($v[ 'name' ] != 'ALL') {
|
||||
$condition[] = [ 'type', '=', $v[ 'name' ] ];
|
||||
}
|
||||
$template_list[ $k ][ 'count' ] = $diy_view->getSiteViewCount($condition)[ 'data' ];
|
||||
}
|
||||
if (request()->isJson()) {
|
||||
return success(0, '', $template_list);
|
||||
} else {
|
||||
$this->assign('template_list', $template_list);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 页面路径
|
||||
* @return mixed
|
||||
*/
|
||||
public function route()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$page_index = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$search_text = input('search_text', '');
|
||||
$condition = [
|
||||
[ 'wap_url', '<>', '' ]
|
||||
];
|
||||
|
||||
if (!empty($search_text)) {
|
||||
$condition[] = [ 'title', 'like', '%' . $search_text . '%' ];
|
||||
}
|
||||
|
||||
$order_by = 'id asc';
|
||||
$field = 'id, name, title, wap_url';
|
||||
|
||||
$link_model = new DiyViewLink();
|
||||
$list = $link_model->getLinkPageList($condition, $page_index, $page_size, $order_by, $field);
|
||||
return $list;
|
||||
} else {
|
||||
$h5_domain = getH5Domain();
|
||||
$this->assign('h5_domain', $h5_domain);
|
||||
return $this->fetch('diy/route');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据页面路径生成推广链接
|
||||
* @return array
|
||||
*/
|
||||
public function promoteRoute()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$name = input('name', ''); // 链接标识
|
||||
$path = input('path', ''); // 链接地址
|
||||
$app_type = input('app_type', 'all'); // 端口类型
|
||||
$diy_view = new DiyViewModel();
|
||||
$res = $diy_view->qrcodeRoute([
|
||||
'site_id' => $this->site_id,
|
||||
'name' => $name,
|
||||
'path' => $path,
|
||||
'app_type' => $app_type
|
||||
]);
|
||||
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 链接选择
|
||||
*/
|
||||
public function link()
|
||||
{
|
||||
$link = input('link', '');
|
||||
$link_model = new DiyViewLink();
|
||||
$tree_params = [
|
||||
'site_id' => $this->site_id,
|
||||
];
|
||||
$list = $link_model->getLinkTree($tree_params)[ 'data' ];
|
||||
$this->assign('list', $list);
|
||||
|
||||
$select_link = json_decode($link, true);
|
||||
$this->assign('select_link', $select_link);
|
||||
|
||||
// 商品分类
|
||||
$goods_category_model = new GoodsCategory();
|
||||
$goods_category_field = 'category_id,category_name,short_name,pid,level,image';
|
||||
$category_list = $goods_category_model->getCategoryTree([
|
||||
[ 'site_id', '=', $this->site_id ]
|
||||
], $goods_category_field)[ 'data' ];
|
||||
$this->assign('category_list', $category_list);
|
||||
|
||||
if(addon_is_exit('cardservice')){
|
||||
$service_category_model = new ServiceCategory();
|
||||
$service_category_field = 'category_id,category_name,short_name,pid,level,image';
|
||||
$service_category_list = $service_category_model->getCategoryTree([
|
||||
[ 'site_id', '=', $this->site_id ]
|
||||
], $service_category_field)[ 'data' ];
|
||||
$this->assign('service_category_list', $service_category_list);
|
||||
}
|
||||
|
||||
return $this->fetch('diy/link');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除自定义模板页面
|
||||
*/
|
||||
public function deleteSiteDiyView()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$diy_view = new DiyViewModel();
|
||||
$id_array = input('id', 0);
|
||||
$condition = [
|
||||
[ 'id', 'in', $id_array ]
|
||||
];
|
||||
$res = $diy_view->deleteSiteDiyView($condition);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制自定义模板页面
|
||||
*/
|
||||
public function copySiteDiyView()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$diy_view = new DiyViewModel();
|
||||
$id_array = input('id', 0);
|
||||
$condition = [
|
||||
[ 'id', '=', $id_array ]
|
||||
];
|
||||
// 获取被复制数据
|
||||
$data = $diy_view->getSiteDiyViewInfo($condition, '*');
|
||||
$data = $data[ 'data' ];
|
||||
unset($data[ 'id' ]);
|
||||
// 对数据进行处理
|
||||
$value = json_decode($data[ 'value' ], true);
|
||||
$data[ 'title' ] .= '_副本';
|
||||
$value[ 'global' ][ 'title' ] = $data[ 'title' ];
|
||||
$data[ 'value' ] = json_encode($value, JSON_UNESCAPED_UNICODE);
|
||||
$data[ 'create_time' ] = time();
|
||||
$data[ 'click_num' ] = 0;
|
||||
if ($data[ 'type' ] == 'DIY_PAGE') {
|
||||
$data[ 'is_default' ] = 1;
|
||||
$data[ 'name' ] = 'DIY_VIEW_RANDOM_' . time();
|
||||
} else {
|
||||
$data[ 'is_default' ] = 0; // 特定页面设为0
|
||||
}
|
||||
// 新增新数据
|
||||
$res = $diy_view->addSiteDiyView($data);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 底部导航
|
||||
*/
|
||||
public function bottomNavDesign()
|
||||
{
|
||||
$diy_view = new DiyViewModel();
|
||||
if (request()->isJson()) {
|
||||
$value = json_decode(input('value', ''), true);
|
||||
$res = $diy_view->setBottomNavConfig($value, $this->site_id);
|
||||
return $res;
|
||||
} else {
|
||||
$bottom_nav_info = $diy_view->getBottomNavConfig($this->site_id);
|
||||
$this->assign('bottom_nav_info', $bottom_nav_info[ 'data' ][ 'value' ]);
|
||||
return $this->fetch('diy/bottom_nav_design');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 店铺风格
|
||||
*/
|
||||
public function style()
|
||||
{
|
||||
$diy_view = new DiyViewModel();
|
||||
$diy_theme_model = new Theme();
|
||||
if (request()->isJson()) {
|
||||
$data = [
|
||||
'id' => input('id', 0),
|
||||
'title' => input('title', ''),
|
||||
'name' => input('name', ''),
|
||||
'main_color' => input('main_color', ''),
|
||||
'aux_color' => input('aux_color', '')
|
||||
];
|
||||
$res = $diy_view->setStyleConfig($data, $this->site_id);
|
||||
$bottom_nav = $diy_view->getBottomNavConfig($this->site_id)[ 'data' ][ 'value' ];
|
||||
|
||||
// 修改底部导航配色
|
||||
if ($bottom_nav[ 'type' ] == 1 || $bottom_nav[ 'type' ] == 2) {
|
||||
$bottom_nav[ 'textHoverColor' ] = $data[ 'main_color' ];
|
||||
}
|
||||
foreach ($bottom_nav[ 'list' ] as $k => $v) {
|
||||
if ($v[ 'selected_icon_type' ] == 'icon') {
|
||||
$bottom_nav[ 'list' ][ $k ][ 'selected_style' ][ 'iconColor' ] = [ $data[ 'main_color' ] ];
|
||||
}
|
||||
}
|
||||
$diy_view->setBottomNavConfig($bottom_nav, $this->site_id);
|
||||
return $res;
|
||||
} else {
|
||||
// 主题风格
|
||||
$theme_list = $diy_theme_model->getThemeList([], 'id,title,name,main_color,aux_color,preview,color_img')[ 'data' ];
|
||||
if (!empty($theme_list)) {
|
||||
foreach ($theme_list as $k => $v) {
|
||||
if (!empty($v[ 'preview' ])) {
|
||||
$theme_list[ $k ][ 'preview' ] = explode(',', $v[ 'preview' ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->assign('theme_list', $theme_list);
|
||||
|
||||
$style = $diy_view->getStyleConfig($this->site_id)[ 'data' ][ 'value' ];
|
||||
$this->assign('style', $style);
|
||||
|
||||
return $this->fetch('diy/style');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义模板选择
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function template()
|
||||
{
|
||||
$diy_view = new DiyViewModel();
|
||||
$diy_theme_model = new Theme();
|
||||
|
||||
// 主题风格
|
||||
$theme_list = $diy_theme_model->getThemeList([], 'id,title,name,main_color,aux_color,preview,color_img')[ 'data' ];
|
||||
if (!empty($theme_list)) {
|
||||
foreach ($theme_list as $k => $v) {
|
||||
if (!empty($v[ 'preview' ])) {
|
||||
$theme_list[ $k ][ 'preview' ] = explode(',', $v[ 'preview' ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->assign('theme_list', $theme_list);
|
||||
|
||||
$style = $diy_view->getStyleConfig($this->site_id)[ 'data' ][ 'value' ];
|
||||
$this->assign('style', $style);
|
||||
|
||||
$diy_template = new Template();
|
||||
|
||||
// 查询店铺正在使用的模板
|
||||
$site_diy_template_info = $diy_template->getSiteDiyTemplateInfo([
|
||||
[ 'is_default', '=', 1 ],
|
||||
[ 'site_id', '=', $this->site_id ]
|
||||
], 'id,name,template_goods_id')[ 'data' ];
|
||||
|
||||
$template_goods_list = $diy_template->getTemplateGoodsList([], 'goods_id,title,name,cover,preview,desc,goods_item_id')[ 'data' ];
|
||||
if (!empty($site_diy_template_info)) {
|
||||
foreach ($template_goods_list as $k => $v) {
|
||||
$template_goods_list[ $k ][ 'is_default' ] = 0;
|
||||
if ($v[ 'goods_id' ] == $site_diy_template_info[ 'template_goods_id' ]) {
|
||||
$template_goods_list[ $k ][ 'is_default' ] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->assign('template', $template_goods_list);
|
||||
|
||||
return $this->fetch('diy/template');
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
if(env('IS_RELEASE_WEAPP')){
|
||||
return error(-1, '发布小程序期间禁止操作');
|
||||
}
|
||||
$goods_id = input('goods_id', 0);
|
||||
$diy_template = new Template();
|
||||
$res = $diy_template->useTemplate([
|
||||
'site_id' => $this->site_id,
|
||||
'goods_id' => $goods_id,
|
||||
]);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设为使用
|
||||
*/
|
||||
public function setUse()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$diy_view = new DiyViewModel();
|
||||
$id = input('id', 0);
|
||||
$res = $diy_view->setUse($id, $this->site_id);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改排序
|
||||
*/
|
||||
public function modifySort()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$sort = input('sort', 0);
|
||||
$id = input('id', 0);
|
||||
$diy_view = new DiyViewModel();
|
||||
return $diy_view->modifyDiyViewSort($sort, $id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 热区设置
|
||||
*/
|
||||
public function heatMap()
|
||||
{
|
||||
return $this->fetch('diy/heat_map');
|
||||
}
|
||||
|
||||
/**
|
||||
* 矢量图库
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function iconfont()
|
||||
{
|
||||
$diy_view = new DiyViewModel();
|
||||
$icon = input('icon', '');
|
||||
if (request()->isJson()) {
|
||||
$type = input('type', 'icon'); // 图标类型
|
||||
$icon_list = $diy_view->getIconList($type);
|
||||
return $icon_list;
|
||||
} else {
|
||||
$icon_type = $diy_view->getIconType();
|
||||
$this->assign('icon_type', $icon_type);
|
||||
$this->assign('icon', $icon);
|
||||
return $this->fetch('diy/iconfont');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* icon风格设置
|
||||
* @return mixed
|
||||
*/
|
||||
public function iconStyleSet()
|
||||
{
|
||||
$icon = input('icon', '');
|
||||
$this->assign('icon', $icon);
|
||||
$this->assign('icon_style', ( new DiyViewModel() )->iconStyle());
|
||||
return $this->fetch('diy/icon_style');
|
||||
}
|
||||
|
||||
public function selectIconStyle()
|
||||
{
|
||||
$icon = input('icon', '');
|
||||
$this->assign('icon', $icon);
|
||||
$this->assign('icon_style', ( new DiyViewModel() )->iconStyle());
|
||||
return $this->fetch('diy/select_icon_style');
|
||||
}
|
||||
|
||||
public function selectLabel()
|
||||
{
|
||||
$this->assign('data', input());
|
||||
return $this->fetch('diy/select_label');
|
||||
}
|
||||
|
||||
public function getImgIcon()
|
||||
{
|
||||
$data = input('data', '');
|
||||
$this->assign('data', urldecode($data));
|
||||
$this->assign('id', 'id_' . time() . mt_rand(0000, 9999));
|
||||
return $this->fetch('diy/icon_img_view');
|
||||
}
|
||||
|
||||
}
|
||||
26
app/shop/controller/Error.php
Executable file
26
app/shop/controller/Error.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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');
|
||||
}
|
||||
}
|
||||
84
app/shop/controller/Export.php
Executable file
84
app/shop/controller/Export.php
Executable file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shop\controller;
|
||||
|
||||
use app\model\system\Export as ExportModel;
|
||||
|
||||
class Export extends BaseShop
|
||||
{
|
||||
/**
|
||||
* 导出记录
|
||||
* @return mixed
|
||||
*/
|
||||
public function lists($param = [])
|
||||
{
|
||||
//传参格式
|
||||
/*$param = [
|
||||
'from_type_list' => [
|
||||
['id' => 'store_account', 'name' => '门店账户'],
|
||||
],
|
||||
'lists_url' => 'store://shop/account/exportList',
|
||||
'delete_url' => 'store://shop/account/deleteExport',
|
||||
];*/
|
||||
if (request()->isJson()) {
|
||||
$page_index = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$from_type = input('from_type', '');
|
||||
$status = input('status', 'all');
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
|
||||
$export_model = new ExportModel();
|
||||
$condition = array (
|
||||
['site_id', '=', $this->site_id],
|
||||
['from_type', 'in', $from_type],
|
||||
);
|
||||
if($status !== 'all'){
|
||||
$condition[] = ['status', '=', $status];
|
||||
}
|
||||
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) ] ];
|
||||
}
|
||||
|
||||
$result = $export_model->getExportPageList($condition, $page_index, $page_size, 'create_time desc', '*');
|
||||
return $result;
|
||||
} else {
|
||||
$this->assign('from_type_list', $param['from_type_list']);
|
||||
$this->assign('lists_url', $param['lists_url']);
|
||||
$this->assign('delete_url', $param['delete_url']);
|
||||
$this->assign('status_list', ExportModel::getStatus());
|
||||
return $this->fetch('app/shop/view/export/lists.html');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除导出记录
|
||||
*/
|
||||
public function delete($from_type)
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$export_ids = input('export_ids', '');
|
||||
|
||||
$export_model = new ExportModel();
|
||||
$condition = array (
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'export_id', 'in', (string) $export_ids ],
|
||||
['from_type', 'in', $from_type],
|
||||
);
|
||||
$result = $export_model->deleteExport($condition);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
439
app/shop/controller/Express.php
Executable file
439
app/shop/controller/Express.php
Executable file
@@ -0,0 +1,439 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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');
|
||||
$kd_100_is_use = 0;
|
||||
$kd_bird_is_use = 0;
|
||||
if ($trace == 'kd100') {
|
||||
$kd_100_is_use = 1;
|
||||
$kd_bird_is_use = 0;
|
||||
}
|
||||
|
||||
if ($trace == 'kdbird') {
|
||||
$kd_100_is_use = 0;
|
||||
$kd_bird_is_use = 1;
|
||||
}
|
||||
|
||||
$data = array (
|
||||
'appkey' => input('appkey', ''),
|
||||
'customer' => input('customer', ''),
|
||||
);
|
||||
$result = $kd100_model->setKd100Config($data, $kd_100_is_use, $this->site_id);
|
||||
|
||||
$data = array (
|
||||
'EBusinessID' => input('EBusinessID', ''),
|
||||
'AppKey' => input('AppKey', ''),
|
||||
'RequestType' => input('kdniao_request_type', ''),
|
||||
);
|
||||
$result = $kdbird_model->setKdbirdConfig($data, $kd_bird_is_use, $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');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
61
app/shop/controller/Gamesrecords.php
Executable file
61
app/shop/controller/Gamesrecords.php
Executable file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shop\controller;
|
||||
|
||||
use app\model\games\Record as RecordModel;
|
||||
|
||||
class GamesRecords extends BaseShop
|
||||
{
|
||||
/*
|
||||
* 抽奖记录
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$game_id = input('game_id', '');
|
||||
if (request()->isJson()) {
|
||||
$condition = [
|
||||
['site_id', '=', $this->site_id],
|
||||
['game_id', '=', $game_id]
|
||||
];
|
||||
|
||||
//中奖状态
|
||||
$is_winning = input('status', '');
|
||||
if ($is_winning !== '') {
|
||||
$condition[] = ['is_winning', '=', $is_winning];
|
||||
}
|
||||
//会员昵称
|
||||
$member_nick_name = input('member_nick_name', '');
|
||||
if ($member_nick_name) {
|
||||
$condition[] = ['member_nick_name', 'like', '%' . $member_nick_name . '%'];
|
||||
}
|
||||
//参与时间
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
if ($start_time && $end_time) {
|
||||
$condition[] = ['create_time', 'between', [date_to_time($start_time), date_to_time($end_time)]];
|
||||
} elseif (!$start_time && $end_time) {
|
||||
$condition[] = ['create_time', '<=', date_to_time($end_time)];
|
||||
} elseif ($start_time && !$end_time) {
|
||||
$condition[] = ['create_time', '>=', date_to_time($start_time)];
|
||||
}
|
||||
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
|
||||
$model = new RecordModel();
|
||||
$list = $model->getGamesDrawRecordPageList($condition, $page, $page_size, 'record_id desc');
|
||||
return $list;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
1856
app/shop/controller/Goods.php
Executable file
1856
app/shop/controller/Goods.php
Executable file
File diff suppressed because it is too large
Load Diff
334
app/shop/controller/Goodsattr.php
Executable file
334
app/shop/controller/Goodsattr.php
Executable file
@@ -0,0 +1,334 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
52
app/shop/controller/Goodsbatchset.php
Executable file
52
app/shop/controller/Goodsbatchset.php
Executable file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy riht 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shop\controller;
|
||||
|
||||
use app\model\goods\Batch;
|
||||
|
||||
/**
|
||||
* 实物商品
|
||||
* Class Goods
|
||||
* @package app\shop\controller
|
||||
*/
|
||||
class Goodsbatchset extends BaseShop
|
||||
{
|
||||
|
||||
/**
|
||||
*编辑商品价格(批量)
|
||||
*/
|
||||
public function setPrice()
|
||||
{
|
||||
$type = input('type', '');// 金额 money 公式计算 calculate
|
||||
$price_type = input('price_type', '');// 价格字段 sale 销售价 cost 成本价 market 划线价
|
||||
$goods_ids = input('goods_ids', '');
|
||||
$calculate_price_type = input('calculate_price_type', '');//计算所用价格字段 sale 销售价 cost 成本价 market 划线价
|
||||
$price = input('price', 0);//设置的价格
|
||||
$sign = input('sign', '');//运算符号 add 加法subtract减法 multiply 乘法 division 除法
|
||||
$precise = input('precise', '');//精度 1 全部保留 2 抹分 3 抹角 4 四舍五入到分 5 四舍五入到角 6 四舍五入到元 7
|
||||
$calculate_price = input('calculate_price', 0);
|
||||
$params = array(
|
||||
'site_id' => $this->site_id,
|
||||
'type' => $type,
|
||||
'price_type' => $price_type,
|
||||
'goods_ids' => $goods_ids,
|
||||
'price' => $price,
|
||||
'sign' => $sign,
|
||||
'precise' => $precise,
|
||||
'calculate_price_type' => $calculate_price_type,
|
||||
'calculate_price' => $calculate_price
|
||||
);
|
||||
$batch_model = new Batch();
|
||||
$result = $batch_model->setPrice($params);
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
182
app/shop/controller/Goodsbrand.php
Executable file
182
app/shop/controller/Goodsbrand.php
Executable file
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shop\controller;
|
||||
|
||||
use app\model\goods\GoodsBrand as GoodsBrandModel;
|
||||
|
||||
/**
|
||||
* 商品品牌管理 控制器
|
||||
*/
|
||||
class Goodsbrand 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 = [
|
||||
[ 'site_id', '=', $this->site_id ]
|
||||
];
|
||||
if (!empty($search_keys)) {
|
||||
$condition[] = [ 'brand_name', 'like', '%' . $search_keys . '%' ];
|
||||
}
|
||||
$goods_brand_model = new GoodsBrandModel();
|
||||
$list = $goods_brand_model->getBrandPageList($condition, $page_index, $page_size, 'create_time desc', 'brand_id,brand_name,brand_initial,image_url,banner,sort,create_time');
|
||||
return $list;
|
||||
} else {
|
||||
return $this->fetch('goodsbrand/lists');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品品牌添加
|
||||
*/
|
||||
public function addBrand()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$brand_name = input('brand_name', '');
|
||||
$brand_initial = input('brand_initial', '');
|
||||
$image_url = input('image_url', '');
|
||||
$banner = input('banner', '');
|
||||
$brand_desc = input('brand_desc', '');
|
||||
$sort = input('sort', 0);
|
||||
$data = [
|
||||
'site_id' => $this->site_id,
|
||||
'brand_name' => $brand_name,
|
||||
'brand_initial' => $brand_initial,
|
||||
'image_url' => $image_url,
|
||||
'banner' => $banner,
|
||||
'brand_desc' => $brand_desc,
|
||||
'sort' => $sort
|
||||
];
|
||||
$goods_brand_model = new GoodsBrandModel();
|
||||
$res = $goods_brand_model->addBrand($data);
|
||||
return $res;
|
||||
} else {
|
||||
return $this->fetch('goodsbrand/add_brand');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品品牌编辑
|
||||
*/
|
||||
public function editBrand()
|
||||
{
|
||||
$goods_brand_model = new GoodsBrandModel();
|
||||
if (request()->isJson()) {
|
||||
$brand_id = input('brand_id', 0);
|
||||
$brand_name = input('brand_name', '');
|
||||
$brand_initial = input('brand_initial', '');
|
||||
$image_url = input('image_url', '');
|
||||
$banner = input('banner', '');
|
||||
$brand_desc = input('brand_desc', '');
|
||||
$sort = input('sort', 0);
|
||||
$data = [
|
||||
'brand_id' => $brand_id,
|
||||
'brand_name' => $brand_name,
|
||||
'brand_initial' => $brand_initial,
|
||||
'image_url' => $image_url,
|
||||
'banner' => $banner,
|
||||
'brand_desc' => $brand_desc,
|
||||
'sort' => $sort
|
||||
];
|
||||
$condition = array (
|
||||
[ 'brand_id', '=', $data[ 'brand_id' ] ],
|
||||
[ 'site_id', '=', $this->site_id ]
|
||||
);
|
||||
$res = $goods_brand_model->editBrand($data, $condition);
|
||||
return $res;
|
||||
} else {
|
||||
$brand_id = input('brand_id', 0);
|
||||
$brand_info = $goods_brand_model->getBrandInfo([ [ 'brand_id', '=', $brand_id ] ])[ 'data' ];
|
||||
$this->assign('brand_info', $brand_info);
|
||||
return $this->fetch('goodsbrand/edit_brand');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品品牌删除
|
||||
*/
|
||||
public function deleteBrand()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$brand_id = input('brand_id', 0);
|
||||
$goods_brand_model = new GoodsBrandModel();
|
||||
$condition = [
|
||||
[ 'brand_id', '=', $brand_id ],
|
||||
[ 'site_id', '=', $this->site_id ]
|
||||
];
|
||||
$res = $goods_brand_model->deleteBrand($condition);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改排序
|
||||
*/
|
||||
public function modifySort()
|
||||
{
|
||||
$sort = input('sort', 0);
|
||||
$brand_id = input('brand_id', 0);
|
||||
$goods_brand_model = new GoodsBrandModel();
|
||||
$condition = array (
|
||||
[ 'brand_id', '=', $brand_id ],
|
||||
[ 'site_id', '=', $this->site_id ]
|
||||
);
|
||||
$res = $goods_brand_model->modifyBrandSort($sort, $condition);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 品牌选择
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function brandSelect()
|
||||
{
|
||||
$goods_brand_model = new GoodsBrandModel();
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$search_text = input('search_text', '');
|
||||
$brand_ids = input('brand_ids', '');
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ]
|
||||
];
|
||||
if (!empty($search_text)) {
|
||||
if (!empty($brand_ids)) {
|
||||
$search_text = paramFilter($search_text);
|
||||
$condition[] = [ '', 'exp', \think\facade\Db::raw("brand_name like '%{$search_text}%' or brand_id in ({$brand_ids})") ];
|
||||
} else {
|
||||
$condition[] = [ 'brand_name', 'like', '%' . $search_text . '%' ];
|
||||
}
|
||||
}
|
||||
|
||||
$list = $goods_brand_model->getBrandPageList($condition, $page, $page_size, 'create_time desc', 'brand_id,brand_name,brand_initial,image_url');
|
||||
return $list;
|
||||
} else {
|
||||
//已经选择的商品sku数据
|
||||
$select_id = input('select_id', '');
|
||||
$this->assign('select_id', $select_id);
|
||||
$brand_list = $goods_brand_model->getBrandList([
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'brand_id', 'in', $select_id ]
|
||||
], 'brand_id,brand_name,brand_initial,image_url')[ 'data' ];
|
||||
$this->assign('brand_list', $brand_list);
|
||||
return $this->fetch('goodsbrand/brand_select');
|
||||
}
|
||||
}
|
||||
}
|
||||
344
app/shop/controller/Goodscategory.php
Executable file
344
app/shop/controller/Goodscategory.php
Executable file
@@ -0,0 +1,344 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shop\controller;
|
||||
|
||||
use app\model\goods\GoodsAttribute as GoodsAttributeModel;
|
||||
use app\model\goods\GoodsCategory as GoodsCategoryModel;
|
||||
|
||||
/**
|
||||
* 商品分类管理 控制器
|
||||
*/
|
||||
class Goodscategory extends BaseShop
|
||||
{
|
||||
/**
|
||||
* 商品分类列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$goods_category_model = new GoodsCategoryModel();
|
||||
$condition[] = [ 'site_id', '=', $this->site_id ];
|
||||
$field = 'category_id,category_name,short_name,pid,level,is_recommend,is_show,sort,image,attr_class_name,category_id_1,category_id_2,category_id_3,commission_rate,icon';
|
||||
$list = $goods_category_model->getCategoryTree($condition, $field);
|
||||
if (request()->isJson()) return $list;
|
||||
$list = $list[ 'data' ];
|
||||
$this->assign('list', $list);
|
||||
return $this->fetch('goodscategory/lists');
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品分类添加
|
||||
*/
|
||||
public function addCategory()
|
||||
{
|
||||
$goods_category_model = new GoodsCategoryModel();
|
||||
if (request()->isJson()) {
|
||||
$category_name = input('category_name', ''); // 分类名称
|
||||
$short_name = input('short_name', ''); // 简称
|
||||
$pid = input('pid', 0); //默认添加的商品分类为顶级
|
||||
$level = input('level', 1); // 层级
|
||||
$is_recommend = input('is_recommend', 0); // 是否推荐
|
||||
$icon = input('icon', 0); // 图标
|
||||
$is_show = input('is_show', ''); // 是否显示
|
||||
// $sort = input('sort', ''); // 排序
|
||||
$image = input('image', ''); // 分类图片
|
||||
$image_adv = input('image_adv', ''); // 分类广告图片
|
||||
$keywords = input('keywords', ''); // 分类页面关键字
|
||||
$description = input('description', ''); // 分类介绍
|
||||
$attr_class_id = input('attr_class_id', ''); // 关联商品类型id
|
||||
$attr_class_name = input('attr_class_name', ''); // 关联商品类型名称
|
||||
$commission_rate = input('commission_rate', ''); // 佣金比率%
|
||||
$category_id_1 = input('category_id_1', 0); // 一级分类id
|
||||
$category_id_2 = input('category_id_2', 0); // 二级分类id
|
||||
$category_full_name = input('category_full_name', ''); // 组装名称
|
||||
$link_url = input('link_url', '');// 广告链接
|
||||
|
||||
$data = [
|
||||
'site_id' => $this->site_id,
|
||||
'category_name' => $category_name,
|
||||
'short_name' => $short_name,
|
||||
'pid' => $pid,
|
||||
'level' => $level,
|
||||
'is_recommend' => $is_recommend,
|
||||
'is_show' => $is_show,
|
||||
// 'sort' => $sort,
|
||||
'image' => $image,
|
||||
'image_adv' => $image_adv,
|
||||
'keywords' => $keywords,
|
||||
'description' => $description,
|
||||
'attr_class_id' => $attr_class_id,
|
||||
'attr_class_name' => $attr_class_name,
|
||||
'commission_rate' => $commission_rate,
|
||||
'category_id_1' => $category_id_1,
|
||||
'category_id_2' => $category_id_2,
|
||||
'category_full_name' => $category_full_name,
|
||||
'link_url' => $link_url,
|
||||
'icon' => $icon
|
||||
];
|
||||
$res = $goods_category_model->addCategory($data);
|
||||
if (!empty($res[ 'data' ])) {
|
||||
|
||||
//修改category_id_
|
||||
$update_data = [
|
||||
'category_id' => $res[ 'data' ],
|
||||
'category_id_' . $level => $res[ 'data' ],
|
||||
'site_id' => $this->site_id
|
||||
];
|
||||
$goods_category_model->editCategory($update_data);
|
||||
|
||||
}
|
||||
return $res;
|
||||
} else {
|
||||
$goods_attribute_model = new GoodsAttributeModel();
|
||||
|
||||
// 商品类型列表
|
||||
$attr_class_list = $goods_attribute_model->getAttrClassList([ [ 'site_id', '=', $this->site_id ] ], 'class_id,class_name')[ 'data' ];
|
||||
$this->assign('attr_class_list', $attr_class_list);
|
||||
|
||||
return $this->fetch('goodscategory/add_category');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品分类编辑
|
||||
*/
|
||||
public function editCategory()
|
||||
{
|
||||
$category_id = input('category_id', '');// 分类id
|
||||
$goods_category_model = new GoodsCategoryModel();
|
||||
if (request()->isJson()) {
|
||||
$category_name = input('category_name', '');// 分类名称
|
||||
$short_name = input('short_name', '');// 简称
|
||||
$pid = input('pid', 0);//默认添加的商品分类为顶级
|
||||
$level = input('level', 1);// 层级
|
||||
$is_recommend = input('is_recommend', 0); // 是否推荐
|
||||
$is_show = input('is_show', 0);// 是否显示
|
||||
// $sort = input('sort', 0);// 排序
|
||||
$image = input('image', '');// 分类图片
|
||||
$image_adv = input('image_adv', '');// 分类广告图片
|
||||
$keywords = input('keywords', '');// 分类页面关键字
|
||||
$description = input('description', '');// 分类介绍
|
||||
$attr_class_id = input('attr_class_id', '');// 关联商品类型id
|
||||
$attr_class_name = input('attr_class_name', '');// 关联商品类型名称
|
||||
$commission_rate = input('commission_rate', '');// 佣金比率%
|
||||
// $category_id_1 = input('category_id_1', 0);// 一级分类id
|
||||
// $category_id_2 = input('category_id_2', 0);// 二级分类id
|
||||
// $category_id_3 = input('category_id_3', 0);// 三级分类id
|
||||
// $category_full_name = input('category_full_name', '');// 组装名称
|
||||
$link_url = input('link_url', '');// 广告链接
|
||||
$icon = input('icon', '');
|
||||
$data = [
|
||||
'site_id' => $this->site_id,
|
||||
'category_id' => $category_id,
|
||||
'category_name' => $category_name,
|
||||
'short_name' => $short_name,
|
||||
'pid' => $pid,
|
||||
'level' => $level,
|
||||
'is_recommend' => $is_recommend,
|
||||
'is_show' => $is_show,
|
||||
// 'sort' => $sort,
|
||||
'image' => $image,
|
||||
'image_adv' => $image_adv,
|
||||
'keywords' => $keywords,
|
||||
'description' => $description,
|
||||
'attr_class_id' => $attr_class_id,
|
||||
'attr_class_name' => $attr_class_name,
|
||||
'commission_rate' => $commission_rate,
|
||||
// 'category_id_1' => $category_id_1,
|
||||
// 'category_id_2' => $category_id_2,
|
||||
// 'category_id_3' => $category_id_3,
|
||||
// 'category_full_name' => $category_full_name,
|
||||
'link_url' => $link_url,
|
||||
'icon' => $icon
|
||||
];
|
||||
$this->addLog('编辑商品分类:' . $category_name);
|
||||
$res = $goods_category_model->editCategory($data);
|
||||
return $res;
|
||||
} else {
|
||||
if (empty($category_id)) {
|
||||
$this->error('缺少参数category_id');
|
||||
}
|
||||
|
||||
$goods_category_info = $goods_category_model->getCategoryInfo([ [ 'category_id', '=', $category_id ], [ 'site_id', '=', $this->site_id ] ])[ 'data' ];
|
||||
if (empty($goods_category_info)) $this->error('未获取到分类数据', href_url('shop/goodscategory/lists'));
|
||||
|
||||
$this->assign('goods_category_info', $goods_category_info);
|
||||
|
||||
//父级
|
||||
$goods_category_parent_info = $goods_category_model->getCategoryInfo([ [ 'category_id', '=', $goods_category_info[ 'pid' ] ], [ 'site_id', '=', $this->site_id ] ], 'category_name');
|
||||
$this->assign('goods_category_parent_info', $goods_category_parent_info[ 'data' ]);
|
||||
$goods_attribute_model = new GoodsAttributeModel();
|
||||
|
||||
// 商品类型列表
|
||||
$attr_class_list = $goods_attribute_model->getAttrClassList([ [ 'site_id', '=', $this->site_id ] ], 'class_id,class_name');
|
||||
$this->assign('attr_class_list', $attr_class_list[ 'data' ]);
|
||||
|
||||
$condition = [];
|
||||
$condition[] = [ 'site_id', '=', $this->site_id ];
|
||||
$condition[] = [ 'category_id', '<>', $category_id ];
|
||||
$field = 'category_id,category_name,short_name,pid,level,is_show,sort,image,attr_class_name,category_id_1,category_id_2,category_id_3,commission_rate';
|
||||
$list = $goods_category_model->getCategoryTree($condition, $field);
|
||||
$this->assign('list', $list[ 'data' ]);
|
||||
return $this->fetch('goodscategory/edit_category');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品分类删除
|
||||
*/
|
||||
public function deleteCategory()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$category_id = input('category_id', '');// 分类id
|
||||
$goods_category_model = new GoodsCategoryModel();
|
||||
$res = $goods_category_model->deleteCategory($category_id, $this->site_id);
|
||||
$this->addLog('删除商品分类id:' . $category_id);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品分类列表
|
||||
* @return \multitype
|
||||
*/
|
||||
public function getCategoryList()
|
||||
{
|
||||
$pid = input('pid', 0);// 上级id
|
||||
$level = input('level', 0);// 层级
|
||||
$goods_category_model = new GoodsCategoryModel();
|
||||
if (!empty($level)) {
|
||||
$condition = [
|
||||
[ 'level', '=', $level ]
|
||||
];
|
||||
} else {
|
||||
$condition = [
|
||||
[ 'pid', '=', $pid ]
|
||||
];
|
||||
}
|
||||
$condition[] = [ 'site_id', '=', $this->site_id ];
|
||||
$list = $goods_category_list = $goods_category_model->getCategoryList($condition, 'category_id,category_name,pid,level,category_id_1,category_id_2,category_id_3', 'sort asc,category_id desc');
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品分类信息
|
||||
* @return \multitype
|
||||
*/
|
||||
public function getCategoryInfo()
|
||||
{
|
||||
$category_id = input('category_id', '');// 分类id
|
||||
$goods_category_model = new GoodsCategoryModel();
|
||||
$condition = [
|
||||
[ 'category_id', '=', $category_id ]
|
||||
];
|
||||
$res = $goods_category_model->getCategoryInfo($condition, 'category_name');
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取商品分类
|
||||
* @return \multitype
|
||||
*/
|
||||
public function getCategoryByParent()
|
||||
{
|
||||
$pid = input('pid', 0);// 上级id
|
||||
$level = input('level', 0);// 层级
|
||||
$goods_category_model = new GoodsCategoryModel();
|
||||
if (!empty($level)) {
|
||||
$condition[] = [ 'level', '=', $level ];
|
||||
}
|
||||
if (!empty($pid)) {
|
||||
$condition[] = [ 'pid', '=', $pid ];
|
||||
}
|
||||
$condition[] = [ 'site_id', '=', $this->site_id ];
|
||||
$list = $goods_category_list = $goods_category_model->getCategoryByParent($condition, 'category_id,category_name,pid,level,category_id_1,category_id_2,category_id_3');
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改商品分类排序
|
||||
*/
|
||||
public function modifySort()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$sort = input('sort', 0);
|
||||
$category_id = input('category_id', 0);
|
||||
$category_sort_array = input('category_sort_array', '');
|
||||
$goods_category_model = new GoodsCategoryModel();
|
||||
if (!empty($category_sort_array)) {
|
||||
$category_sort_array = json_decode($category_sort_array, true);
|
||||
foreach ($category_sort_array as $k => $v) {
|
||||
$res = $goods_category_model->modifyGoodsCategorySort($v[ 'sort' ], $v[ 'category_id' ], $this->site_id);
|
||||
}
|
||||
} else {
|
||||
$res = $goods_category_model->modifyGoodsCategorySort($sort, $category_id, $this->site_id);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
public function checkEditCategory()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$pid = input('pid', 0);
|
||||
$category_id = input('category_id', 0);
|
||||
$goods_category_model = new GoodsCategoryModel();
|
||||
$res = $goods_category_model->checkEditCategory([
|
||||
'pid' => $pid,
|
||||
'category_id' => $category_id,
|
||||
'site_id' => $this->site_id
|
||||
]);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类树
|
||||
*/
|
||||
public function getCategoryTree()
|
||||
{
|
||||
if(request()->isJson()){
|
||||
$tree_level = input('tree_level', 3);
|
||||
$tree_ids = input('tree_ids', '');
|
||||
$children = input('children', 'children');
|
||||
$category_id = input('category_id', 'id');
|
||||
$category_name = input('category_name', 'title');
|
||||
|
||||
$condition = [];
|
||||
$condition[] = ['level', '<=', $tree_level];
|
||||
$condition[] = ['site_id', '=', $this->site_id];
|
||||
if(!empty($tree_ids)){
|
||||
$condition[] = ['category_id', 'in', $tree_ids];
|
||||
}
|
||||
|
||||
$category_model = new GoodsCategoryModel();
|
||||
$list = $category_model->getCategoryList($condition, "category_id as {$category_id}, category_name as {$category_name}, pid, level", "sort asc,category_id desc")['data'];
|
||||
$tree = list_to_tree($list, $category_id, 'pid', $children, 0);
|
||||
$tree = keyArrToIndexArr($tree, $children);
|
||||
return $category_model->success($tree);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改分类展示状态
|
||||
*/
|
||||
|
||||
public function modifyShow(){
|
||||
if(request()->isJson()){
|
||||
$category_id = input('id','');
|
||||
$is_show = input('is_show',0);
|
||||
|
||||
$category_model = new GoodsCategoryModel();
|
||||
return $category_model->modifyGoodsCategoryShow($category_id,$is_show);
|
||||
}
|
||||
}
|
||||
}
|
||||
115
app/shop/controller/Goodslabel.php
Executable file
115
app/shop/controller/Goodslabel.php
Executable file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
89
app/shop/controller/Goodsservice.php
Executable file
89
app/shop/controller/Goodsservice.php
Executable file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
130
app/shop/controller/H5.php
Executable file
130
app/shop/controller/H5.php
Executable file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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, 'niuteam.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, 'niuteam.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' ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
262
app/shop/controller/Help.php
Executable file
262
app/shop/controller/Help.php
Executable file
@@ -0,0 +1,262 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
362
app/shop/controller/Index.php
Executable file
362
app/shop/controller/Index.php
Executable file
@@ -0,0 +1,362 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shop\controller;
|
||||
|
||||
use addon\fenxiao\model\FenxiaoApply;
|
||||
use addon\fenxiao\model\FenxiaoWithdraw;
|
||||
use addon\niusms\model\Config as NiuSmsConfig;
|
||||
use addon\niusms\model\Sms as NiuSms;
|
||||
use addon\weapp\model\Config as WeappConfigModel;
|
||||
use app\dict\order_refund\OrderRefundDict;
|
||||
use app\model\goods\Goods as GoodsModel;
|
||||
use app\model\member\Member;
|
||||
use app\model\member\Member as MemberModel;
|
||||
use app\model\order\OrderCommon;
|
||||
use app\model\shop\Shop as ShopModel;
|
||||
use app\model\system\Addon;
|
||||
use app\model\system\Promotion as PromotionModel;
|
||||
use app\model\system\Stat;
|
||||
use app\model\system\SystemConfig;
|
||||
use app\model\web\Config as WebConfigModel;
|
||||
use Carbon\Carbon;
|
||||
use app\model\order\OrderRefund as OrderRefundModel;
|
||||
use think\facade\Cache;
|
||||
use addon\wechat\model\Config as WechatConfig;
|
||||
use addon\weapp\model\Config as WeappConfig;
|
||||
use addon\alipay\model\Config as AlipayConfig;
|
||||
use addon\wechatpay\model\Config as WechatpayConfig;
|
||||
use app\model\order\Order;
|
||||
|
||||
class Index extends BaseShop
|
||||
{
|
||||
|
||||
/**
|
||||
* 首页
|
||||
* @return mixed
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
|
||||
$this->assign('shop_status', 1);
|
||||
|
||||
$this->handlePromotion();
|
||||
//分销插件是否存在
|
||||
$is_fenxiao = addon_is_exit('fenxiao', $this->site_id);
|
||||
$this->assign('is_fenxiao', $is_fenxiao);
|
||||
|
||||
//基础统计信息
|
||||
$today = Carbon::now();
|
||||
$this->assign('today', $today);
|
||||
|
||||
$this->assign('guide_close', cookie('guideClose'));
|
||||
if (!cookie('guideClose')) {
|
||||
$this->assign('goods_complete', 1);
|
||||
|
||||
$wechat_config = ( new WechatConfig() )->getWechatConfig($this->site_id)[ 'data' ][ 'value' ];
|
||||
$this->assign('wechat_complete', !empty($wechat_config));
|
||||
if (addon_is_exit('weapp', $this->site_id)) {
|
||||
$weapp_config = ( new WeappConfig() )->getWeappConfig($this->site_id)[ 'data' ][ 'value' ];
|
||||
$this->assign('weapp_complete', !empty($weapp_config));
|
||||
} else {
|
||||
$this->assign('weapp_complete', false);
|
||||
}
|
||||
|
||||
$alipay_config = addon_is_exit('alipay', $this->site_id) ? ( new AlipayConfig() )->getPayConfig($this->site_id, $this->app_module, true)[ 'data' ][ 'value' ] : [];
|
||||
$wechatpay_config = ( new WechatpayConfig() )->getPayConfig($this->site_id, $this->app_module, true)[ 'data' ][ 'value' ];
|
||||
unset($wechatpay_config[ 'transfer_type' ]);
|
||||
$this->assign('pay_complete', ( !( empty($alipay_config) ) || !( empty($wechatpay_config) ) ));
|
||||
|
||||
$this->assign('site_complete', !empty($this->shop_info[ 'logo' ]));
|
||||
}
|
||||
$this->init();
|
||||
$this->assign('img_extension_error', config('upload.driver') == 'imagick' && !extension_loaded('imagick'));
|
||||
|
||||
return $this->fetch('index/index');
|
||||
}
|
||||
|
||||
|
||||
private function init()
|
||||
{
|
||||
$is_new_version = 0; // 检查小程序是否有新版本
|
||||
if (addon_is_exit('weapp')) {
|
||||
$weapp_config_model = new WeappConfigModel();
|
||||
// 获取站点小程序版本信息
|
||||
$version_info = $weapp_config_model->getWeappVersion($this->site_id)[ 'data' ][ 'value' ];
|
||||
$current_version_info = config('info');
|
||||
if (!isset($version_info[ 'version' ]) || ( isset($version_info[ 'version' ]) && $version_info[ 'version' ] != $current_version_info[ 'version_no' ] )) {
|
||||
$is_new_version = 1;
|
||||
}
|
||||
}
|
||||
$this->assign('is_new_version', $is_new_version);
|
||||
|
||||
$is_admin = $this->user_info[ 'is_admin' ] || $this->group_info[ 'is_system' ] == 1;
|
||||
$this->assign('is_admin', $is_admin);
|
||||
|
||||
$is_new_domain = 0; // 检查域名是否发生变化
|
||||
|
||||
$web_config_model = new WebConfigModel();
|
||||
$shop_domain_config = $web_config_model->getShopDomainConfig()[ 'data' ][ 'value' ];
|
||||
if ($shop_domain_config[ 'domain_name' ] != __ROOT__) {
|
||||
$is_new_domain = 1;
|
||||
}
|
||||
$this->assign('is_new_domain', $is_new_domain);
|
||||
|
||||
//商城状态
|
||||
$shop_model = new ShopModel();
|
||||
$shop_status = $shop_model->getShopStatus($this->site_id, $this->app_module)[ 'data' ][ 'value' ];
|
||||
$this->assign('shop_status', $shop_status);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取营销活动 添加快捷菜单的优先排序
|
||||
*/
|
||||
public function handlePromotion()
|
||||
{
|
||||
$promotion_model = new PromotionModel();
|
||||
$promotions = $promotion_model->getSitePromotions($this->site_id);
|
||||
|
||||
$promotion = array_values(array_filter(array_map(function($item) { if ($item[ 'show_type' ] == 'shop' || $item[ 'show_type' ] == 'member') return $item; }, $promotions)));
|
||||
$tool = array_values(array_filter(array_map(function($item) { if ($item[ 'show_type' ] == 'tool') return $item; }, $promotions)));
|
||||
$promotion = array_column($promotion, null, 'name');
|
||||
$tool = array_column($tool, null, 'name');
|
||||
|
||||
$addon_model = new Addon();
|
||||
$value = $addon_model->getAddonQuickMenuConfig($this->site_id, $this->app_module)[ 'data' ][ 'value' ];
|
||||
$promotion_addon = $value[ 'promotion' ];
|
||||
$tool_addon = $value[ 'tool' ];
|
||||
|
||||
if (!empty($promotion_addon)) {
|
||||
foreach ($promotion_addon as $name) {
|
||||
if (isset($promotion[ $name ])) {
|
||||
array_unshift($promotion, $promotion[ $name ]);
|
||||
unset($promotion[ $name ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($tool_addon)) {
|
||||
foreach ($tool_addon as $name) {
|
||||
if (isset($tool[ $name ])) {
|
||||
array_unshift($tool, $tool[ $name ]);
|
||||
unset($tool[ $name ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->assign('promotion', $promotion);
|
||||
$this->assign('tool', $tool);
|
||||
}
|
||||
|
||||
/**
|
||||
* 今日昨日统计
|
||||
* @return array
|
||||
*/
|
||||
public function dayCount()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
//基础统计信息
|
||||
$stat_shop_model = new Stat();
|
||||
$today = Carbon::now();
|
||||
$yesterday = Carbon::yesterday();
|
||||
$stat_today = $stat_shop_model->getShopStatSum($this->site_id, $today->startOfDay()->timestamp, $today->endOfDay()->timestamp);
|
||||
$stat_yesterday = $stat_shop_model->getShopStatSum($this->site_id, $yesterday->startOfDay()->timestamp, $yesterday->endOfDay()->timestamp);
|
||||
$order = new Order();
|
||||
//获取总数
|
||||
$shop_stat_sum = $stat_shop_model->getShopStatSum($this->site_id);
|
||||
$goods_model = new GoodsModel();
|
||||
$goods_sum = $goods_model->getGoodsTotalCount([ [ 'site_id', '=', $this->site_id ], [ 'is_delete', '=', 0 ] ]);
|
||||
$shop_stat_sum[ 'data' ][ 'goods_count' ] = $goods_sum[ 'data' ];
|
||||
$shop_stat_sum[ 'data' ][ 'member_count' ] = ( new Member() )->getMemberCount([ [ 'site_id', '=', $this->site_id ], [ 'is_delete', '=', 0 ] ])[ 'data' ];
|
||||
$shop_stat_sum[ 'data' ][ 'order_pay_count' ] = $order->getOrderCount([ [ 'site_id', '=', $this->site_id ], [ 'is_delete', '=', 0 ], [ 'pay_status', '=', 1 ] ])[ 'data' ];
|
||||
$shop_stat_sum[ 'data' ][ 'earnings_total_money' ] = $order->getOrderMoneySum([ [ 'site_id', '=', $this->site_id ], [ 'is_delete', '=', 0 ], [ 'pay_status', '=', 1 ] ], 'pay_money')[ 'data' ];
|
||||
|
||||
//日同比
|
||||
$day_rate[ 'order_pay_count' ] = diff_rate($stat_today[ 'data' ][ 'order_pay_count' ], $stat_yesterday[ 'data' ][ 'order_pay_count' ]);
|
||||
$day_rate[ 'order_total' ] = diff_rate($stat_today[ 'data' ][ 'order_total' ], $stat_yesterday[ 'data' ][ 'order_total' ]);
|
||||
$day_rate[ 'earnings_total_money' ] = diff_rate($stat_today[ 'data' ][ 'earnings_total_money' ], $stat_yesterday[ 'data' ][ 'earnings_total_money' ]);
|
||||
$day_rate[ 'collect_goods' ] = diff_rate($stat_today[ 'data' ][ 'collect_goods' ], $stat_yesterday[ 'data' ][ 'collect_goods' ]);
|
||||
$day_rate[ 'visit_count' ] = diff_rate($stat_today[ 'data' ][ 'visit_count' ], $stat_yesterday[ 'data' ][ 'visit_count' ]);
|
||||
$day_rate[ 'member_count' ] = diff_rate($stat_today[ 'data' ][ 'member_count' ], $stat_yesterday[ 'data' ][ 'member_count' ]);
|
||||
|
||||
//会员总数
|
||||
$member_model = new MemberModel();
|
||||
$member_count = $member_model->getMemberCount([ [ 'site_id', '=', $this->site_id ] ]);
|
||||
|
||||
$res = [
|
||||
'stat_day' => $stat_today[ 'data' ],
|
||||
'stat_yesterday' => $stat_yesterday[ 'data' ],
|
||||
'today' => $today,
|
||||
'shop_stat_sum' => $shop_stat_sum[ 'data' ],
|
||||
'day_rate' => $day_rate,
|
||||
'member_count' => $member_count[ 'data' ]
|
||||
];
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 综合统计
|
||||
* @return array
|
||||
*/
|
||||
public function sumCount()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$goods_model = new GoodsModel();
|
||||
$order = new OrderCommon();
|
||||
$waitpay = $order->getOrderCount([ [ 'order_status', '=', 0 ], [ 'site_id', '=', $this->site_id ], [ 'is_delete', '=', 0 ], [ 'order_scene', '=', 'online' ] ]);
|
||||
$waitsend = $order->getOrderCount([ [ 'order_status', '=', 1 ], [ 'site_id', '=', $this->site_id ], [ 'is_delete', '=', 0 ] ]);
|
||||
$order_refund_model = new OrderRefundModel();
|
||||
$refund_num = $order_refund_model->getRefundOrderGoodsCount([
|
||||
['site_id', '=', $this->site_id ],
|
||||
['refund_status', 'not in', [ OrderRefundDict::REFUND_NOT_APPLY, OrderRefundDict::REFUND_COMPLETE, OrderRefundDict::PARTIAL_REFUND ] ]
|
||||
]);
|
||||
$goods_stock_alarm = $goods_model->getGoodsStockAlarm($this->site_id);
|
||||
$goods_total = $goods_model->getGoodsTotalCount([ [ 'goods_state', '=', 1 ], [ 'site_id', '=', $this->site_id ], [ 'is_delete', '=', 0 ] ]);
|
||||
$warehouse_goods = $goods_model->getGoodsTotalCount([ [ 'goods_state', '=', 0 ], [ 'site_id', '=', $this->site_id ], [ 'is_delete', '=', 0 ] ]);
|
||||
|
||||
$num_data = [
|
||||
'waitpay' => $waitpay[ 'data' ],
|
||||
'waitsend' => $waitsend[ 'data' ],
|
||||
'refund' => $refund_num[ 'data' ],
|
||||
'goods_stock_alarm' => count($goods_stock_alarm[ 'data' ]),
|
||||
'goods_total' => $goods_total[ 'data' ],
|
||||
'warehouse_goods' => $warehouse_goods[ 'data' ]
|
||||
];
|
||||
|
||||
//分销插件是否存在
|
||||
$is_fenxiao = addon_is_exit('fenxiao', $this->site_id);
|
||||
$this->assign('is_fenxiao', $is_fenxiao);
|
||||
if ($is_fenxiao) {
|
||||
//提现待审核
|
||||
$fenxiao_model = new FenxiaoWithdraw();
|
||||
$withdraw_count = $fenxiao_model->getFenxiaoWithdrawCount([ [ 'site_id', '=', $this->site_id ], [ 'status', '=', 1 ] ], 'id');
|
||||
$num_data[ 'withdraw_count' ] = $withdraw_count[ 'data' ];
|
||||
|
||||
//分销商申请
|
||||
$fenxiao_apply_model = new FenxiaoApply();
|
||||
$fenxiao_count = $fenxiao_apply_model->getFenxiaoApplyCount([ [ 'site_id', '=', $this->site_id ], [ 'status', '=', 1 ] ], 'apply_id');
|
||||
$num_data[ 'apply_count' ] = $fenxiao_count[ 'data' ];
|
||||
} else {
|
||||
$waitconfirm = $order->getOrderCount([ [ 'order_status', '=', 3 ], [ 'site_id', '=', $this->site_id ], [ 'is_delete', '=', 0 ] ]);
|
||||
$complete = $order->getOrderCount([ [ 'order_status', '=', 10 ], [ 'site_id', '=', $this->site_id ], [ 'is_delete', '=', 0 ] ]);
|
||||
$num_data[ 'waitconfirm' ] = $waitconfirm[ 'data' ];
|
||||
$num_data[ 'complete' ] = $complete[ 'data' ];
|
||||
}
|
||||
}
|
||||
return $num_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 图形统计
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function chartCount()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
//近十天的订单数以及销售金额
|
||||
$stat_shop_model = new Stat();
|
||||
$date_day = getweeks();
|
||||
$order_total = '';
|
||||
$order_pay_count = '';
|
||||
foreach ($date_day as $k => $day) {
|
||||
$dayarr = explode('-', $day);
|
||||
$stat_day[ $k ] = $stat_shop_model->getStatShop($this->site_id, $dayarr[ 0 ], $dayarr[ 1 ], $dayarr[ 2 ]);
|
||||
$order_total .= $stat_day[ $k ][ 'data' ][ 'order_total' ] . ',';
|
||||
$order_pay_count .= $stat_day[ $k ][ 'data' ][ 'order_pay_count' ] . ',';
|
||||
}
|
||||
$ten_day[ 'order_total' ] = explode(',', substr($order_total, 0, strlen($order_total) - 1));
|
||||
$ten_day[ 'order_pay_count' ] = explode(',', substr($order_pay_count, 0, strlen($order_pay_count) - 1));
|
||||
return $ten_day;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 营销插件
|
||||
* @return array
|
||||
*/
|
||||
public function marketingPlug()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
//营销活动
|
||||
$promotion_model = new PromotionModel();
|
||||
$promotions = $promotion_model->getSitePromotions($this->site_id);
|
||||
$toolcount = 0;
|
||||
$shopcount = 0;
|
||||
//营销插件数量
|
||||
foreach ($promotions as $k => $v) {
|
||||
if ($v['show_type'] == 'tool') {
|
||||
$toolcount += 1;
|
||||
}
|
||||
if ($v['show_type'] == 'member' || $v['show_type'] == 'shop') {
|
||||
$shopcount += 1;
|
||||
}
|
||||
}
|
||||
$count = [
|
||||
'toolcount' => $toolcount,
|
||||
'shopcount' => $shopcount
|
||||
];
|
||||
$res = [
|
||||
'count' => $count,
|
||||
'promotions' => $promotions
|
||||
];
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
public function test()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function getZoneCode($str)
|
||||
{
|
||||
$zoneCode = '';
|
||||
for ($i = 0; $i < mb_strlen($str); $i++) {
|
||||
$char = mb_substr($str, $i, 1);
|
||||
if (ord($char) > 128) {
|
||||
$zoneCode .= sprintf('%02X%02X', ord(substr($char, 0, 1)), ord(substr($char, 1, 1)));
|
||||
}
|
||||
}
|
||||
return $zoneCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取牛云短信信息
|
||||
*/
|
||||
public function checkSms()
|
||||
{
|
||||
$data = [
|
||||
'sms_num' => '',
|
||||
'is_admin' => $this->user_info[ 'is_admin' ] || $this->group_info[ 'is_system' ] == 1
|
||||
];
|
||||
|
||||
// 牛云短信余额查询
|
||||
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' ],
|
||||
]);
|
||||
$data[ 'sms_num' ] = $account_info[ 'data' ][ 'balance' ] ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测是否开启Redis
|
||||
*/
|
||||
public function checkRedis()
|
||||
{
|
||||
return (new SystemConfig())->checkJob();
|
||||
}
|
||||
}
|
||||
199
app/shop/controller/Local.php
Executable file
199
app/shop/controller/Local.php
Executable file
@@ -0,0 +1,199 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
144
app/shop/controller/Localorder.php
Executable file
144
app/shop/controller/Localorder.php
Executable file
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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 = $order_common_model->getOrderDetail($order_id)['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;
|
||||
}
|
||||
|
||||
}
|
||||
231
app/shop/controller/Login.php
Executable file
231
app/shop/controller/Login.php
Executable file
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shop\controller;
|
||||
|
||||
use app\Controller;
|
||||
use app\model\system\Site;
|
||||
use app\model\system\User as UserModel;
|
||||
use app\model\web\Config as ConfigModel;
|
||||
use extend\QRcode as QRcodeExtend;
|
||||
use think\App;
|
||||
use think\captcha\facade\Captcha as ThinkCaptcha;
|
||||
use think\facade\Cache;
|
||||
use think\facade\Session;
|
||||
|
||||
/**
|
||||
* 登录
|
||||
* Class Login
|
||||
* @package app\shop\controller
|
||||
*/
|
||||
class Login extends Controller
|
||||
{
|
||||
|
||||
protected $app_module = 'shop';
|
||||
protected $login_module;
|
||||
protected $site_id;
|
||||
protected $uid;
|
||||
protected $user_info;
|
||||
protected $app;
|
||||
|
||||
/**
|
||||
* 模板布局
|
||||
* @var string|bool
|
||||
*/
|
||||
protected $layout = 'layout/base';
|
||||
|
||||
public function __construct(App $app = null)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->app = $app;
|
||||
|
||||
//检测基础登录
|
||||
$this->site_id = request()->siteid();
|
||||
if (empty($this->site_id)) {
|
||||
$this->site_id = input('site_id', 0);
|
||||
request()->siteid($this->site_id);
|
||||
}
|
||||
|
||||
// 后台主题风格
|
||||
$config_model = new ConfigModel();
|
||||
$theme_config = $config_model->getThemeConfig()[ 'data' ][ 'value' ];
|
||||
$this->assign('theme_config', $theme_config);
|
||||
|
||||
// 设置模版布局
|
||||
$this->app->view->engine()->layout($this->layout);
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录首页
|
||||
* @return mixed
|
||||
*/
|
||||
public function login()
|
||||
{
|
||||
//如果登录状态还在就直接进入后台
|
||||
if (!request()->isJson()) {
|
||||
$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);
|
||||
$this->user_info = $user_model->userInfo($this->app_module, $this->site_id);
|
||||
if(!empty($this->uid) && !empty($this->user_info)) $this->redirect(addon_url('shop/index/index'));
|
||||
}
|
||||
|
||||
$site_id = request()->siteid();
|
||||
$config_model = new ConfigModel();
|
||||
$config_info = $config_model->getCaptchaConfig();
|
||||
$config = $config_info[ 'data' ][ 'value' ];
|
||||
$this->assign('shop_login', $config[ 'shop_login' ]);
|
||||
if (request()->isJson()) {
|
||||
$username = input('username', '');
|
||||
$password = input('password', '');
|
||||
$login_module = input('login_module', 'shop');
|
||||
$user_model = new UserModel();
|
||||
if ($config['shop_login'] == 1) {
|
||||
$captcha_result = $this->checkCaptcha();
|
||||
//验证码
|
||||
if ($captcha_result['code'] != 0) {
|
||||
return $captcha_result;
|
||||
}
|
||||
}
|
||||
$result = $user_model->login($username, $password, $login_module, $site_id);
|
||||
//登录后查看补丁
|
||||
Session::set('SYS_PATCH_ALERT',true);
|
||||
return $result;
|
||||
} else {
|
||||
//平台配置信息
|
||||
$site_model = new Site();
|
||||
$shop_info = $site_model->getSiteInfo([ [ 'site_id', '=', $site_id ] ], 'site_name,logo,seo_keywords,seo_description, create_time');
|
||||
|
||||
$this->assign('shop_info', $shop_info[ 'data' ]);
|
||||
|
||||
//加载版权信息
|
||||
$copyright = $config_model->getCopyright();
|
||||
$this->assign('copyright', $copyright[ 'data' ][ 'value' ]);
|
||||
|
||||
//获取其他端 访问二维码
|
||||
$addon = [];
|
||||
$resultData = [];
|
||||
if (addon_is_exit('mobileshop', $site_id)) {
|
||||
$config_model = new \addon\mobileshop\model\Config();
|
||||
$addon[ 'mobileshop' ] = $config_model->getMShopDomainName($site_id);
|
||||
$addon[ 'weapp' ] = $config_model->getWeappConfig($site_id);
|
||||
if ($addon[ 'mobileshop' ][ 'code' ] == 0 && !empty($addon[ 'mobileshop' ][ 'data' ])) {
|
||||
$path = 'upload/qrcode/shop' . '/';
|
||||
$name = 'shop_qrcode_' . $site_id . '_' . 'mobileshop' . '.png';
|
||||
$filename = $path . $name;
|
||||
if (!file_exists($path)) {
|
||||
mkdir($path, intval('0755', 8), true);
|
||||
}
|
||||
if (!file_exists($filename)) {
|
||||
$url = $addon[ 'mobileshop' ][ 'data' ][ 'value' ][ 'domain_name_mobileshop' ];
|
||||
QRcodeExtend::png($url, $filename, 'L', 4, 1);
|
||||
}
|
||||
$resultData[ 0 ][ 'message' ] = 'H5端';
|
||||
$resultData[ 0 ][ 'img' ] = $filename;
|
||||
}
|
||||
if ($addon[ 'weapp' ][ 'code' ] == 0 && !empty($addon[ 'weapp' ][ 'data' ][ 'value' ]) && !empty($addon[ 'weapp' ][ 'data' ][ 'value' ][ 'qrcode' ])) {
|
||||
$resultData[ 1 ][ 'message' ] = '小程序端';
|
||||
$resultData[ 1 ][ 'img' ] = $addon[ 'weapp' ][ 'data' ][ 'value' ][ 'qrcode' ];
|
||||
}
|
||||
}
|
||||
|
||||
// 验证码
|
||||
$captcha = $this->captcha()[ 'data' ];
|
||||
$this->assign('captcha', $captcha);
|
||||
$this->assign('port_data', $resultData);
|
||||
|
||||
return $this->fetch('login/login');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出操作
|
||||
*/
|
||||
public function logout()
|
||||
{
|
||||
$site_id = request()->siteid();
|
||||
$user_model = new UserModel();
|
||||
$login_module = $user_model->loginModule($site_id);
|
||||
$user_model->clearLogin($login_module, $site_id);
|
||||
$this->redirect(url('shop/login/login'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证码
|
||||
*/
|
||||
public function captcha()
|
||||
{
|
||||
$captcha_data = ThinkCaptcha::create(null, true);
|
||||
$captcha_id = md5(uniqid(null, true));
|
||||
// 验证码10分钟有效
|
||||
Cache::set($captcha_id, $captcha_data[ 'code' ], 600);
|
||||
return success(0, '', [ 'id' => $captcha_id, 'img' => $captcha_data[ 'img' ] ]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证码验证
|
||||
*/
|
||||
public function checkCaptcha()
|
||||
{
|
||||
$captcha = input('captcha', '');
|
||||
$captcha_id = input('captcha_id', '');
|
||||
|
||||
if (empty($captcha)) return error(-1, '请输入验证码');
|
||||
|
||||
$captcha_data = Cache::pull($captcha_id);
|
||||
if (empty($captcha_data)) return error(-1, '验证码已失效');
|
||||
|
||||
if ($captcha != $captcha_data) return error(-1, '验证码错误');
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理缓存
|
||||
*/
|
||||
public function clearCache()
|
||||
{
|
||||
Cache::clear();
|
||||
return success('', '缓存更新成功', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
* */
|
||||
public function modifyPassword()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$site_id = request()->siteid();
|
||||
$user_model = new UserModel();
|
||||
$uid = $user_model->uid($this->app_module, $site_id);
|
||||
|
||||
$old_pass = input('old_pass', '');
|
||||
$new_pass = input('new_pass', '123456');
|
||||
|
||||
$condition = [
|
||||
[ 'uid', '=', $uid ],
|
||||
[ 'password', '=', data_md5($old_pass) ],
|
||||
[ 'site_id', '=', $site_id ]
|
||||
];
|
||||
|
||||
$res = $user_model->modifyAdminUserPassword($condition, $new_pass);
|
||||
if ($res[ 'code' ] == 0) {
|
||||
// 更新密码
|
||||
$user_info = $user_model->userInfo($this->app_module, $site_id);
|
||||
$user_info[ 'password' ] = data_md5($new_pass);
|
||||
$user_model->setUserInfo($user_info);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
1225
app/shop/controller/Member.php
Executable file
1225
app/shop/controller/Member.php
Executable file
File diff suppressed because it is too large
Load Diff
250
app/shop/controller/Memberaccount.php
Executable file
250
app/shop/controller/Memberaccount.php
Executable file
@@ -0,0 +1,250 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shop\controller;
|
||||
|
||||
use addon\coupon\model\Coupon;
|
||||
use addon\coupon\model\CouponType;
|
||||
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);
|
||||
|
||||
//积分任务配置
|
||||
$point_model = new Point();
|
||||
$point_task_config = $point_model->getPointTaskConfig($this->site_id)['data']['value'];
|
||||
$this->assign('point_task_config', $point_task_config);
|
||||
|
||||
return $this->fetch('account/point_config');
|
||||
}
|
||||
|
||||
public function pointTaskConfig()
|
||||
{
|
||||
if(request()->isJson()){
|
||||
$data = [
|
||||
'status' => input('status', 0),
|
||||
'type' => input('type', 'clear'),
|
||||
'time' => input('time', '1/1'),
|
||||
'time_type' => input('time_type', 1),
|
||||
];
|
||||
$point_model = new Point();
|
||||
$res = $point_model->setPointTaskConfig($data, $this->site_id);
|
||||
if($res['code'] < 0) return $res;
|
||||
$res['data'] = $point_model->getPointTaskConfig($this->site_id)['data']['value'];
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员余额
|
||||
*/
|
||||
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';
|
||||
$list = $model->getCouponPageList($condition, $page, $page_size, 'c.fetch_time desc', $field, 'c', $join);
|
||||
$coupon_type_model = new CouponType();
|
||||
foreach($list['data']['list'] as &$val){
|
||||
unset($val['use_store']);
|
||||
$val = $coupon_type_model->getCouponSubData($val);
|
||||
}
|
||||
return $list;
|
||||
} 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;
|
||||
}
|
||||
|
||||
}
|
||||
319
app/shop/controller/Membercluster.php
Executable file
319
app/shop/controller/Membercluster.php
Executable file
@@ -0,0 +1,319 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
117
app/shop/controller/Memberlabel.php
Executable file
117
app/shop/controller/Memberlabel.php
Executable file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
229
app/shop/controller/Memberlevel.php
Executable file
229
app/shop/controller/Memberlevel.php
Executable file
@@ -0,0 +1,229 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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' ] = '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' ] = '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);
|
||||
|
||||
$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' ] : -1);
|
||||
$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);
|
||||
}
|
||||
}
|
||||
269
app/shop/controller/Memberwithdraw.php
Executable file
269
app/shop/controller/Memberwithdraw.php
Executable file
@@ -0,0 +1,269 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shop\controller;
|
||||
|
||||
|
||||
use addon\wechatpay\model\Config as WechatPayConfig;
|
||||
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 = [ [ 'mw.site_id', '=', $this->site_id ] ];
|
||||
|
||||
if (!empty($withdraw_no)) {
|
||||
$condition[] = [ 'mw.withdraw_no', 'like', '%' . $withdraw_no . '%' ];
|
||||
}
|
||||
if (!empty($transfer_type)) {
|
||||
$condition[] = [ 'mw.transfer_type', '=', $transfer_type ];
|
||||
}
|
||||
if ($status != 'all') {
|
||||
$condition[] = [ 'mw.status', '=', $status ];
|
||||
}
|
||||
if (!empty($member_name)) {
|
||||
$condition[] = [ 'mw.member_name', '=', $member_name ];
|
||||
}
|
||||
if ($start_date != '' && $end_date != '') {
|
||||
$condition[] = [ 'mw.apply_time', 'between', [ strtotime($start_date), strtotime($end_date) ] ];
|
||||
} else if ($start_date != '' && $end_date == '') {
|
||||
$condition[] = [ 'mw.apply_time', '>=', strtotime($start_date) ];
|
||||
} else if ($start_date == '' && $end_date != '') {
|
||||
$condition[] = [ 'mw.apply_time', '<=', strtotime($end_date) ];
|
||||
}
|
||||
|
||||
if ($payment_start_date != '' && $payment_end_time != '') {
|
||||
$condition[] = [ 'mw.payment_time', 'between', [ strtotime($payment_start_date), strtotime($payment_end_time) ] ];
|
||||
} else if ($payment_start_date != '' && $payment_end_time == '') {
|
||||
$condition[] = [ 'mw.payment_time', '>=', strtotime($payment_start_date) ];
|
||||
} else if ($payment_start_date == '' && $payment_end_time != '') {
|
||||
$condition[] = [ 'mw.payment_time', '<=', strtotime($payment_end_time) ];
|
||||
}
|
||||
|
||||
$order = 'apply_time desc';
|
||||
|
||||
$alias = 'mw';
|
||||
$join = [
|
||||
[ 'member m', 'm.member_id = mw.member_id', 'left' ]
|
||||
];
|
||||
$field = "mw.*,m.nickname,m.mobile";
|
||||
return $withdraw_model->getMemberWithdrawPageList($condition, $page, $page_size, $order,$field,$alias,$join);
|
||||
} else {
|
||||
$this->assign('memberwithdraw_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' ]);
|
||||
|
||||
//提现状态
|
||||
$this->assign('status_list', $withdraw_model->status);
|
||||
|
||||
$config_model = new WechatPayConfig();
|
||||
$config = $config_model->getPayConfig($this->site_id)[ 'data' ][ 'value' ];;
|
||||
$transfer_v3_type = $config['transfer_type'] == 'v3' && $config['transfer_v3_type'] == $config_model::TRANSFER_V3_TYPE_USER ;
|
||||
$this->assign("transfer_v3_type",$transfer_v3_type);
|
||||
return $this->fetch('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 ],
|
||||
);
|
||||
$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);
|
||||
}
|
||||
|
||||
}
|
||||
243
app/shop/controller/Message.php
Executable file
243
app/shop/controller/Message.php
Executable file
@@ -0,0 +1,243 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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();
|
||||
|
||||
if (empty($edit_data_result['data'][ 0 ]))
|
||||
$this->error('没有开启的短信方式!');
|
||||
|
||||
$edit_data = $edit_data_result['data'][ 0 ];
|
||||
$edit_url = $edit_data['shop_url'];
|
||||
$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');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
203
app/shop/controller/Notice.php
Executable file
203
app/shop/controller/Notice.php
Executable file
@@ -0,0 +1,203 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
1797
app/shop/controller/Order.php
Executable file
1797
app/shop/controller/Order.php
Executable file
File diff suppressed because it is too large
Load Diff
285
app/shop/controller/Orderimportfile.php
Executable file
285
app/shop/controller/Orderimportfile.php
Executable file
@@ -0,0 +1,285 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
}
|
||||
423
app/shop/controller/Orderrefund.php
Executable file
423
app/shop/controller/Orderrefund.php
Executable file
@@ -0,0 +1,423 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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_time', '>=', date_to_time($start_time) ];
|
||||
} elseif (empty($start_time) && !empty($end_time)) {
|
||||
$condition[] = ['nop.refund_time', '<=', date_to_time($end_time) ];
|
||||
} elseif (!empty($start_time) && !empty($end_time)) {
|
||||
$condition[] = [ 'nop.refund_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
|
||||
}
|
||||
|
||||
$res = $order_refund_model->getRefundOrderGoodsPageList($condition, $page_index, $page_size, 'nop.refund_action_time desc');
|
||||
|
||||
//查询退款总金额
|
||||
$join = [
|
||||
[
|
||||
'order no',
|
||||
'nop.order_id = no.order_id',
|
||||
'left'
|
||||
],
|
||||
[
|
||||
'member m',
|
||||
'm.member_id = no.member_id',
|
||||
'left'
|
||||
],
|
||||
];
|
||||
$total_refund_pay_money = $order_refund_model->getRefundSum($condition, 'nop.refund_pay_money', 'nop', $join)['data'];
|
||||
$res['data']['total_refund_pay_money'] = $total_refund_pay_money;
|
||||
return $res;
|
||||
} 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);
|
||||
$shop_active_refund_money_type = input('shop_active_refund_money_type', '');
|
||||
$shop_active_refund_remark = input('shop_active_refund_remark', '');
|
||||
$shop_active_refund_money = input('shop_active_refund_money', '');
|
||||
$refund_status = input('refund_status', '');
|
||||
|
||||
$order_refund_model = new OrderRefundModel();
|
||||
$params = [
|
||||
'site_id' => $this->site_id,
|
||||
'app_module' => $this->app_module,
|
||||
'shop_active_refund_money_type' => $shop_active_refund_money_type,
|
||||
'shop_active_refund_remark' => $shop_active_refund_remark,
|
||||
'user_info' => $this->user_info,
|
||||
'order_goods_id' => $order_goods_id,
|
||||
'shop_active_refund_money' => $shop_active_refund_money,
|
||||
'refund_status' => $refund_status,
|
||||
];
|
||||
return $order_refund_model->shopActiveRefund($params);
|
||||
}
|
||||
}
|
||||
37
app/shop/controller/Printer.php
Executable file
37
app/shop/controller/Printer.php
Executable file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
}
|
||||
300
app/shop/controller/Promotion.php
Executable file
300
app/shop/controller/Promotion.php
Executable file
@@ -0,0 +1,300 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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\Menu;
|
||||
use app\model\system\Promotion as PromotionModel;
|
||||
use app\model\system\User as UserModel;
|
||||
use think\App;
|
||||
|
||||
/**
|
||||
* 营销
|
||||
* Class Promotion
|
||||
* @package app\shop\controller
|
||||
*/
|
||||
class Promotion extends BaseShop
|
||||
{
|
||||
protected $addons = [];
|
||||
|
||||
/**
|
||||
* 获取插件
|
||||
*/
|
||||
protected function getAddons()
|
||||
{
|
||||
if ($this->user_info[ 'is_admin' ] || $this->group_info[ 'is_system' ] == 1) {
|
||||
$this->addons = [];
|
||||
} else {
|
||||
$field = 'addon';
|
||||
$menu_model = new Menu();
|
||||
$menu_array = "'".str_replace(',',"','", $this->group_info[ 'menu_array' ])."'";
|
||||
$menu_list = $menu_model->getMenuList([
|
||||
[ 'app_module', '=', $this->app_module ],
|
||||
['', 'exp', \think\facade\Db::raw("name in ({$menu_array}) or is_control = 0")]
|
||||
], $field)['data'];
|
||||
$this->addons = array_unique(array_column($menu_list, 'addon'));
|
||||
}
|
||||
return $this->addons;
|
||||
}
|
||||
|
||||
/**
|
||||
* 营销概况
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->getAddons();
|
||||
$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, $this->addons)['data'];
|
||||
$promotion_config = $this->dealWithRedirect($promotion_config);
|
||||
$this->assign('promotion_config', $promotion_config);
|
||||
//营销活动
|
||||
$all_promotion = array_column($promotion_model->getSitePromotions($this->site_id, $this->addons), null, 'name');
|
||||
$all_promotion = array_filter(array_map(function($item) {
|
||||
if ($item[ 'show_type' ] == 'shop' || $item[ 'show_type' ] == 'member') return $item;
|
||||
}, $all_promotion));
|
||||
$all_promotion = $this->dealWithRedirect($all_promotion);
|
||||
$this->assign('all_promotion', $all_promotion);
|
||||
|
||||
|
||||
return $this->fetch('promotion/index');
|
||||
}
|
||||
|
||||
/**
|
||||
* 营销活动
|
||||
* @return mixed
|
||||
*/
|
||||
public function market()
|
||||
{
|
||||
$this->getAddons();
|
||||
$promotion_model = new PromotionModel();
|
||||
$promotions = $promotion_model->getSitePromotions($this->site_id, $this->addons);
|
||||
$promotions = $this->dealWithRedirect($promotions);
|
||||
$this->assign('promotion', $promotions);
|
||||
|
||||
$user_info = $this->user_info;
|
||||
$this->assign('user_info', $user_info);
|
||||
|
||||
$addon_quick_model = new AddonQuick();
|
||||
|
||||
//店铺促销
|
||||
$shop_addon = $addon_quick_model->getAddonQuickByAddonType($promotions, 'shop');
|
||||
$this->assign('shop_addon', $shop_addon);
|
||||
|
||||
$member_addon = $addon_quick_model->getAddonQuickByAddonType($promotions, 'member');
|
||||
$this->assign('member_addon', $member_addon);
|
||||
|
||||
$addon_model = new Addon();
|
||||
$value = $addon_model->getAddonQuickMenuConfig($this->site_id, $this->app_module)[ 'data' ][ 'value' ];
|
||||
$promotion_addon = $value[ 'promotion' ];
|
||||
|
||||
$this->assign('common_addon', $promotion_addon);
|
||||
|
||||
return $this->fetch('promotion/market');
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员营销
|
||||
* @return mixed
|
||||
*/
|
||||
public function member()
|
||||
{
|
||||
$promotion_model = new PromotionModel();
|
||||
$promotions = $promotion_model->getSitePromotions($this->site_id);
|
||||
$addon_quick_model = new AddonQuick();
|
||||
$addon = $addon_quick_model->getAddonQuickByAddonType($promotions, 'member');
|
||||
$this->assign('tool_addon', $addon);
|
||||
$user_info = $this->user_info;
|
||||
$this->assign('user_info', $user_info);
|
||||
$this->assign('promotion', $promotions);
|
||||
return $this->fetch('promotion/member');
|
||||
}
|
||||
|
||||
/**
|
||||
* 营销工具
|
||||
* @return mixed
|
||||
*/
|
||||
public function tool()
|
||||
{
|
||||
$this->getAddons();
|
||||
$promotion_model = new PromotionModel();
|
||||
$promotions = $promotion_model->getPromotions($this->addons);
|
||||
$promotions['shop'] = $this->dealWithRedirect($promotions['shop']);
|
||||
$this->assign('promotion', $promotions[ 'shop' ]);
|
||||
|
||||
$addon_quick_model = new AddonQuick();
|
||||
$addon = $addon_quick_model->getAddonQuickByAddonType($promotions[ 'shop' ], 'tool');
|
||||
$this->assign('tool_addon', $addon);
|
||||
|
||||
$user_info = $this->user_info;
|
||||
$this->assign('user_info', $user_info);
|
||||
|
||||
$addon_model = new Addon();
|
||||
$value = $addon_model->getAddonQuickMenuConfig($this->site_id, $this->app_module)[ 'data' ][ 'value' ];
|
||||
$tool_addon = $value[ 'tool' ];
|
||||
|
||||
$this->assign('common_addon', $tool_addon);
|
||||
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()
|
||||
{
|
||||
$this->getAddons();
|
||||
$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, $this->addons)[ 'data' ];
|
||||
|
||||
return success(0, '', [
|
||||
'month' => date('Y/m', $start_time),
|
||||
'days' => (int) date('t', $start_time),
|
||||
'start_time' => $start_time,
|
||||
'data' => $summary
|
||||
]);
|
||||
}
|
||||
|
||||
public function dealWithRedirect($promotions)
|
||||
{
|
||||
if(!($this->user_info['is_admin'] == 1 || $this->group_info['is_system'] == 1)){
|
||||
$user_model = new UserModel();
|
||||
foreach($promotions as $key=>$promotion){
|
||||
if(in_array($promotion['name'], ['coupon', 'bargain', 'pintuan', 'blindbox', 'fenxiao', 'giftcard', 'jielong', 'pinfan', 'presale', 'seckill', 'form', 'live', 'notes', 'printer', 'virtualevaluation'])){
|
||||
$check_res = $user_model->checkAndGetRedirectUrl(['url' => $promotion['url'], 'app_module' => $this->app_module], $this->group_info);
|
||||
if($check_res['redirect_url']){
|
||||
$promotions[$key]['url'] = $check_res[ 'redirect_url' ];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $promotions;
|
||||
}
|
||||
}
|
||||
197
app/shop/controller/Shop.php
Executable file
197
app/shop/controller/Shop.php
Executable file
@@ -0,0 +1,197 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shop\controller;
|
||||
|
||||
use app\model\shop\Shop as ShopModel;
|
||||
use app\model\system\Address as AddressModel;
|
||||
use app\model\system\Site;
|
||||
use app\model\web\Config as ConfigModel;
|
||||
|
||||
/**
|
||||
* 店铺
|
||||
* Class Shop
|
||||
* @package app\shop\controller
|
||||
*/
|
||||
class Shop extends BaseShop
|
||||
{
|
||||
|
||||
/**
|
||||
* 店铺设置
|
||||
* @return mixed
|
||||
*/
|
||||
public function config()
|
||||
{
|
||||
$shop_model = new ShopModel();
|
||||
$site_model = new Site();
|
||||
$condition = array (
|
||||
['site_id', '=', $this->site_id ]
|
||||
);
|
||||
if (request()->isJson()) {
|
||||
$site_name = input('site_name', '');
|
||||
$logo = input('logo', '');//店铺logo
|
||||
$logo_square = input('logo_square', '');//店铺方形logo
|
||||
$avatar = input('avatar', '');//店铺头像(大图)
|
||||
$banner = input('banner', '');//店铺条幅
|
||||
$seo_keywords = input('seo_keywords', '');//店铺关键字
|
||||
$seo_description = input('seo_description', '');//店铺简介
|
||||
$qq = input('qq', '');//qq
|
||||
$ww = input('ww', '');//ww
|
||||
$telephone = input('telephone', '');//联系电话
|
||||
$shop_pc_status = input('shop_pc_status', 1);//商城pc端状态
|
||||
$shop_h5_status = input('shop_h5_status', 1);//商城h5端状态
|
||||
$shop_weapp_status = input('shop_weapp_status', 1);//商城小程序端状态
|
||||
$seo_title = input('seo_title', '');
|
||||
|
||||
$site_tel = input('site_tel', '');//服务电话
|
||||
|
||||
$data_site = array (
|
||||
'site_name' => $site_name,
|
||||
'logo' => $logo,
|
||||
'logo_square' => $logo_square,
|
||||
'seo_keywords' => $seo_keywords,
|
||||
'seo_description' => $seo_description,
|
||||
'site_tel' => $site_tel,
|
||||
'seo_title' => $seo_title
|
||||
);
|
||||
|
||||
$work_week = input('work_week', '');//工作日 例如 : 1,2,3,4,5,6,7
|
||||
$start_time = input('start_time', 0);//开始时间
|
||||
$end_time = input('end_time', 0);//结束时间
|
||||
|
||||
$data_shop = array (
|
||||
'avatar' => $avatar,
|
||||
'banner' => $banner,
|
||||
'qq' => $qq,
|
||||
'ww' => $ww,
|
||||
'telephone' => $telephone,
|
||||
'work_week' => $work_week,
|
||||
'start_time' => $start_time,
|
||||
'end_time' => $end_time,
|
||||
);
|
||||
$site_model->editSite($data_site, $condition);
|
||||
$res = $shop_model->editShop($data_shop, $condition, $this->site_id);
|
||||
if ($res[ 'code' ] >= 0) {
|
||||
$shop_model->setShopStatus([ 'shop_pc_status' => $shop_pc_status, 'shop_h5_status' => $shop_h5_status, 'shop_weapp_status' => $shop_weapp_status ], $this->site_id, $this->app_module);
|
||||
}
|
||||
return $res;
|
||||
} else {
|
||||
|
||||
$shop_info_result = $shop_model->getShopInfo($condition);
|
||||
$site_info = $site_model->getSiteInfo($condition);
|
||||
|
||||
//商城状态
|
||||
$shop_status_result = $shop_model->getShopStatus($this->site_id, $this->app_module);
|
||||
|
||||
$shop_status = $shop_status_result[ 'data' ][ 'value' ];
|
||||
$this->assign('shop_status', $shop_status);
|
||||
|
||||
$config_model = new ConfigModel();
|
||||
$info = $config_model->getH5DomainName();
|
||||
$this->assign('domain_name_h5', $info[ 'data' ][ 'value' ][ 'domain_name_h5' ]);
|
||||
|
||||
$shop_info = array_merge($shop_info_result['data'], $site_info[ 'data' ]);
|
||||
$this->assign('shop_info', $shop_info);
|
||||
return $this->fetch('shop/config');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 联系方式
|
||||
* @return mixed
|
||||
*/
|
||||
public function contact()
|
||||
{
|
||||
$shop_model = new ShopModel();
|
||||
$condition = array (
|
||||
['site_id', '=', $this->site_id ]
|
||||
);
|
||||
if (request()->isJson()) {
|
||||
$province = input('province', 0);//省级地址
|
||||
$province_name = input('province_name', '');//省级地址
|
||||
$city = input('city');//市级地址
|
||||
$city_name = input('city_name', '');//市级地址
|
||||
$district = input('district', 0);//县级地址
|
||||
$district_name = input('district_name', '');//县级地址
|
||||
$community = input('community', 0);//乡镇地址
|
||||
$community_name = input('community_name', '');//乡镇地址
|
||||
$address = input('address', 0);//详细地址
|
||||
$full_address = input('full_address', 0);//完整地址
|
||||
$longitude = input('longitude', '');//经度
|
||||
$latitude = input('latitude', '');//纬度
|
||||
|
||||
$qq = input('qq', '');//qq号
|
||||
$ww = input('ww', '');//阿里旺旺
|
||||
$email = input('email', '');//邮箱
|
||||
$telephone = input('telephone', '');//联系电话
|
||||
$name = input('name', '');//联系人姓名
|
||||
$mobile = input('mobile', '');//联系人手机号
|
||||
|
||||
$data = array (
|
||||
'province' => $province,
|
||||
'province_name' => $province_name,
|
||||
'city' => $city,
|
||||
'city_name' => $city_name,
|
||||
'district' => $district,
|
||||
'district_name' => $district_name,
|
||||
'community' => $community,
|
||||
'community_name' => $community_name,
|
||||
'address' => $address,
|
||||
'full_address' => $full_address,
|
||||
'longitude' => $longitude,
|
||||
'latitude' => $latitude,
|
||||
'qq' => $qq,
|
||||
'ww' => $ww,
|
||||
'email' => $email,
|
||||
'telephone' => $telephone,
|
||||
'name' => $name,
|
||||
'mobile' => $mobile
|
||||
);
|
||||
$res = $shop_model->editShop($data, $condition, $this->site_id);
|
||||
return $res;
|
||||
} else {
|
||||
|
||||
$shop_info_result = $shop_model->getShopInfo($condition);
|
||||
$shop_info = $shop_info_result['data'];
|
||||
$this->assign('info', $shop_info);
|
||||
|
||||
//查询省级数据列表
|
||||
$address_model = new AddressModel();
|
||||
$list = $address_model->getAreaList([ ['pid', '=', 0 ], ['level', '=', 1 ] ]);
|
||||
$this->assign('province_list', $list['data']);
|
||||
$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);
|
||||
|
||||
return $this->fetch('shop/contact');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 店铺推广
|
||||
* return
|
||||
*/
|
||||
public function shopUrl()
|
||||
{
|
||||
//获取商品sku_id
|
||||
$shop_model = new ShopModel();
|
||||
$res = $shop_model->qrcode($this->site_id);
|
||||
// dump($res);exit;
|
||||
return $res;
|
||||
}
|
||||
|
||||
}
|
||||
137
app/shop/controller/Shopacceptmessage.php
Executable file
137
app/shop/controller/Shopacceptmessage.php
Executable file
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
62
app/shop/controller/Shophelp.php
Executable file
62
app/shop/controller/Shophelp.php
Executable file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
}
|
||||
195
app/shop/controller/Siteaddress.php
Executable file
195
app/shop/controller/Siteaddress.php
Executable file
@@ -0,0 +1,195 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shop\controller;
|
||||
|
||||
use app\model\system\Address as AddressModel;
|
||||
use app\model\shop\SiteAddress as SiteAddressModel;
|
||||
|
||||
/**
|
||||
* 商家地址库
|
||||
* Class Siteaddress
|
||||
* @package app\shop\controller
|
||||
*/
|
||||
class Siteaddress extends BaseShop
|
||||
{
|
||||
/**
|
||||
* 商家地址库列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function siteAddress()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$search_keys = input('search_keys', '');
|
||||
|
||||
$condition = array (
|
||||
[ 'site_id', '=', $this->site_id ]
|
||||
);
|
||||
if (!empty($search_keys)) {
|
||||
$condition[] = [ 'contact_name|full_address', 'like', '%' . $search_keys . '%' ];
|
||||
}
|
||||
|
||||
$site_address_model = new SiteAddressModel();
|
||||
$list = $site_address_model->getAddressPageList($condition, $page, $page_size, 'id desc');
|
||||
return $list;
|
||||
} else {
|
||||
|
||||
return $this->fetch('siteaddress/site_address_list');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加商家地址库
|
||||
* @return mixed
|
||||
*/
|
||||
public function addSiteAddress()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$contact_name = input('contact_name', '');//联系人
|
||||
$mobile = input('mobile', '');//手机号码
|
||||
$postcode = input('postcode', '');//邮编
|
||||
$province_id = input('province_id', '');//省id
|
||||
$city_id = input('city_id', '');//市id
|
||||
$district_id = input('district_id', '');//区id
|
||||
$community_id = input('community_id', '');//乡镇id
|
||||
$address = input('address', '');//详细地址
|
||||
$full_address = input('full_address', '');//完整地址
|
||||
$is_return = input('is_return', 0);//是否退货地址
|
||||
$is_return_default = input('is_return_default', 0);//是否是默认退货地址
|
||||
$is_delivery = input('is_delivery', 0);//是否发货地址
|
||||
|
||||
$site_address_model = new SiteAddressModel();
|
||||
$data = array (
|
||||
'site_id' => $this->site_id,
|
||||
'contact_name' => $contact_name,
|
||||
'mobile' => $mobile,
|
||||
'postcode' => $postcode,
|
||||
'province_id' => $province_id,
|
||||
'city_id' => $city_id,
|
||||
'district_id' => $district_id,
|
||||
'community_id' => $community_id,
|
||||
'address' => $address,
|
||||
'full_address' => $full_address,
|
||||
'is_return' => $is_return,
|
||||
'is_return_default' => $is_return_default,
|
||||
'is_delivery' => $is_delivery
|
||||
);
|
||||
$result = $site_address_model->addAddress($data);
|
||||
return $result;
|
||||
} else {
|
||||
//查询省级数据列表
|
||||
$address_model = new AddressModel();
|
||||
$list = $address_model->getAreaList([ ['pid', '=', 0 ], ['level', '=', 1 ] ]);
|
||||
$this->assign('province_list', $list['data']);
|
||||
return $this->fetch('siteaddress/add_site_address');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑商家地址库
|
||||
* @return mixed
|
||||
*/
|
||||
public function editSiteAddress()
|
||||
{
|
||||
$site_address_model = new SiteAddressModel();
|
||||
$id = input('id', 0);//地址库id
|
||||
if (request()->isJson()) {
|
||||
$contact_name = input('contact_name', '');//联系人
|
||||
$mobile = input('mobile', '');//手机号码
|
||||
$postcode = input('postcode', '');//邮编
|
||||
$province_id = input('province_id', '');//省id
|
||||
$city_id = input('city_id', '');//市id
|
||||
$district_id = input('district_id', '');//区id
|
||||
$community_id = input('community_id', '');//乡镇id
|
||||
$address = input('address', '');//详细地址
|
||||
$full_address = input('full_address', '');//完整地址
|
||||
$is_return = input('is_return', 0);//是否退货地址
|
||||
$is_return_default = input('is_return_default', 0);//是否是默认退货地址
|
||||
$is_delivery = input('is_delivery', 0);//是否发货地址
|
||||
|
||||
$data = array (
|
||||
'contact_name' => $contact_name,
|
||||
'mobile' => $mobile,
|
||||
'postcode' => $postcode,
|
||||
'province_id' => $province_id,
|
||||
'city_id' => $city_id,
|
||||
'district_id' => $district_id,
|
||||
'community_id' => $community_id,
|
||||
'address' => $address,
|
||||
'full_address' => $full_address,
|
||||
'is_return' => $is_return,
|
||||
'is_return_default' => $is_return_default,
|
||||
'is_delivery' => $is_delivery
|
||||
);
|
||||
|
||||
$condition = array (
|
||||
['id', '=', $id ],
|
||||
['site_id', '=', $this->site_id ],
|
||||
);
|
||||
$result = $site_address_model->editAddress($data, $condition);
|
||||
return $result;
|
||||
} else {
|
||||
//查询省级数据列表
|
||||
$address_model = new AddressModel();
|
||||
$list = $address_model->getAreaList([ ['pid', '=', 0 ], ['level', '=', 1 ] ]);
|
||||
$this->assign('province_list', $list['data']);
|
||||
$condition = array (
|
||||
['id', '=', $id ],
|
||||
['site_id', '=', $this->site_id ]
|
||||
);
|
||||
$site_address_info = $site_address_model->getAddressInfo($condition);
|
||||
$this->assign('site_address_info', $site_address_info[ 'data' ]);
|
||||
return $this->fetch('siteaddress/edit_site_address');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商家地址库
|
||||
*/
|
||||
public function deleteSiteAddress()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$id = input('id', '');
|
||||
$condition = array (
|
||||
['id', '=', $id ],
|
||||
['site_id', '=', $this->site_id ],
|
||||
);
|
||||
$site_address_model = new SiteAddressModel();
|
||||
$result = $site_address_model->deleteAddress($condition);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 退货地址
|
||||
* @return array
|
||||
*/
|
||||
public function getSiteAddressList()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$is_return = input('is_refund', 0);
|
||||
$condition = array (
|
||||
[ 'site_id', '=', $this->site_id ]
|
||||
);
|
||||
if ($is_return) {
|
||||
$condition[] = [ 'is_return', '=', $is_return ];
|
||||
}
|
||||
//商家地址列表
|
||||
$site_address_model = new SiteAddressModel();
|
||||
$res = $site_address_model->getAddressList($condition, '*', 'id desc');
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
258
app/shop/controller/Stat.php
Executable file
258
app/shop/controller/Stat.php
Executable file
@@ -0,0 +1,258 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shop\controller;
|
||||
|
||||
use app\model\stat\GoodsStat;
|
||||
use app\model\system\Stat as StatModel;
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
* 数据统计
|
||||
* Class Stat
|
||||
* @package app\shop\controller
|
||||
*/
|
||||
class Stat extends BaseShop
|
||||
{
|
||||
/**
|
||||
* 店铺统计
|
||||
* @return mixed
|
||||
*/
|
||||
public function shop()
|
||||
{
|
||||
$this->assign('today', Carbon::today()->toDateString());
|
||||
$this->assign('yesterday', Carbon::yesterday()->toDateString());
|
||||
return $this->fetch('stat/shop');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取时间段内统计数据总和
|
||||
*/
|
||||
public function getStatTotal()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$start_time = input('start_time', strtotime(date('Y-m-d', time())));
|
||||
$end_time = input('end_time', time());
|
||||
|
||||
if ($start_time > $end_time) {
|
||||
$start_time = input('end_time');
|
||||
$end_time = input('start_time');
|
||||
}
|
||||
|
||||
$stat_model = new StatModel();
|
||||
$data = $stat_model->getShopStatSum($this->site_id, $start_time, $end_time);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取天统计趋势数据
|
||||
*/
|
||||
public function getStatData()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$start_time = input('start_time', strtotime(date('Y-m-d', strtotime('-6 day'))));
|
||||
$end_time = input('end_time', time());
|
||||
|
||||
if ($start_time > $end_time) {
|
||||
$start_time = input('end_time');
|
||||
$end_time = input('start_time');
|
||||
}
|
||||
|
||||
$stat_model = new StatModel();
|
||||
$fields = $stat_model->getStatField();
|
||||
$fields[] = 'cashier_order_pay_money';
|
||||
|
||||
$stat_list = $stat_model->getShopStatList($this->site_id, $start_time, $end_time)[ 'data' ];
|
||||
$stat_list = array_map(function($item) {
|
||||
$item[ 'day_time' ] = date('Y-m-d', $item[ 'day_time' ]);
|
||||
return $item;
|
||||
}, $stat_list);
|
||||
$stat_list = array_column($stat_list, null, 'day_time');
|
||||
|
||||
$day = ceil(( $end_time - $start_time ) / 86400);
|
||||
|
||||
foreach ($fields as $field) {
|
||||
$value = [];
|
||||
$time = [];
|
||||
for ($i = 0; $i < $day; $i++) {
|
||||
$date = date('Y-m-d', $start_time + $i * 86400);
|
||||
$time[] = $date;
|
||||
$value[] = isset($stat_list[ $date ]) && isset($stat_list[ $date ][ $field ]) ? $stat_list[ $date ][ $field ] : 0;
|
||||
}
|
||||
$data[ $field ] = $value;
|
||||
$data[ 'time' ] = $time;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小时统计趋势数据
|
||||
*/
|
||||
public function getStatHourData()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$time = input('start_time', time());
|
||||
$carbon = Carbon::createFromTimestamp($time);
|
||||
|
||||
$stat_model = new StatModel();
|
||||
$fields = $stat_model->getStatHourField();
|
||||
$fields[] = 'cashier_order_pay_money';
|
||||
|
||||
$stat_list = $stat_model->getShopStatHourList($this->site_id, $carbon->year, $carbon->month, $carbon->day)[ 'data' ];
|
||||
|
||||
$data = [];
|
||||
$empty = array_map(function() { return 0; }, range(0, 23, 1));
|
||||
if (!empty($stat_list)) {
|
||||
$stat_list = array_column($stat_list, null, 'hour');
|
||||
foreach ($fields as $field) {
|
||||
$value = [];
|
||||
for ($i = 0; $i < 24; $i++) {
|
||||
$value[ $i ] = isset($stat_list[ $i ]) && isset($stat_list[ $i ][ $field ]) ? $stat_list[ $i ][ $field ] : 0;
|
||||
}
|
||||
$data[ $field ] = $value;
|
||||
}
|
||||
} else {
|
||||
foreach ($fields as $field) {
|
||||
$data[ $field ] = $empty;
|
||||
}
|
||||
}
|
||||
$data[ 'time' ] = array_map(function($value) { return $value . '时'; }, range(0, 23, 1));
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品统计
|
||||
* @return mixed
|
||||
*/
|
||||
public function goods()
|
||||
{
|
||||
$this->assign('today', Carbon::today()->toDateString());
|
||||
$this->assign('yesterday', Carbon::yesterday()->toDateString());
|
||||
return $this->fetch('stat/goods');
|
||||
}
|
||||
|
||||
/**
|
||||
* 交易统计
|
||||
* @return mixed
|
||||
*/
|
||||
public function order()
|
||||
{
|
||||
$this->assign('today', Carbon::today()->toDateString());
|
||||
$this->assign('yesterday', Carbon::yesterday()->toDateString());
|
||||
return $this->fetch('stat/order');
|
||||
}
|
||||
|
||||
/**
|
||||
* 访问统计
|
||||
* @return mixed
|
||||
*/
|
||||
public function visit()
|
||||
{
|
||||
$this->assign('today', Carbon::today()->toDateString());
|
||||
$this->assign('yesterday', Carbon::yesterday()->toDateString());
|
||||
|
||||
$stat_shop_model = new \app\model\system\Stat();
|
||||
$today = Carbon::now();
|
||||
$yesterday = Carbon::yesterday();
|
||||
$stat_today = $stat_shop_model->getStatShop($this->site_id, $today->year, $today->month, $today->day)[ 'data' ];
|
||||
$stat_yesterday = $stat_shop_model->getStatShop($this->site_id, $yesterday->year, $yesterday->month, $yesterday->day)[ 'data' ];
|
||||
$stat_today[ 'conversion_ratio' ] = $stat_today[ 'visit_count' ] > 0 ? round($stat_today[ 'order_member_count' ] / $stat_today[ 'visit_count' ], 2) : 0;
|
||||
$stat_yesterday[ 'conversion_ratio' ] = $stat_yesterday[ 'visit_count' ] > 0 ? round($stat_yesterday[ 'order_member_count' ] / $stat_yesterday[ 'visit_count' ], 2) : 0;
|
||||
$this->assign('stat_today', $stat_today);
|
||||
$this->assign('stat_yesterday', $stat_yesterday);
|
||||
|
||||
$day_rate = [];
|
||||
$day_rate[ 'order_member_count' ] = diff_rate($stat_today[ 'order_member_count' ], $stat_yesterday[ 'order_member_count' ]);
|
||||
$day_rate[ 'visit_count' ] = diff_rate($stat_today[ 'visit_count' ], $stat_yesterday[ 'visit_count' ]);
|
||||
$day_rate[ 'member_count' ] = diff_rate($stat_today[ 'member_count' ], $stat_yesterday[ 'member_count' ]);
|
||||
$day_rate[ 'conversion_ratio' ] = diff_rate($stat_today[ 'conversion_ratio' ], $stat_yesterday[ 'conversion_ratio' ]);
|
||||
$this->assign('day_rate', $day_rate);
|
||||
|
||||
return $this->fetch('stat/visit');
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员统计
|
||||
* @return mixed
|
||||
*/
|
||||
public function member()
|
||||
{
|
||||
$this->assign('today', Carbon::today()->toDateString());
|
||||
$this->assign('yesterday', Carbon::yesterday()->toDateString());
|
||||
return $this->fetch('stat/member');
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品排行榜 销量
|
||||
* */
|
||||
public function countGoodsSale()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
$page_index = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$stat_model = new StatModel();
|
||||
$res = $stat_model->getGoodsSaleNumRankingList($this->site_id, $start_time, $end_time, $page_index, $page_size);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品排行榜 销售额
|
||||
* */
|
||||
public function countGoodsSaleMoney()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
$page_index = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$stat_model = new StatModel();
|
||||
$res = $stat_model->getGoodsSaleMoneyRankingList($this->site_id, $start_time, $end_time, $page_index, $page_size);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 销售额排行
|
||||
* @return array
|
||||
*/
|
||||
public function getGoodsOrderMoneyStat(){
|
||||
$goods_stat_model = new GoodsStat();
|
||||
$params = array(
|
||||
'site_id' => $this->site_id,
|
||||
'start_time' => input('start_time', 0),
|
||||
'end_time'=> input('end_time', 0),
|
||||
'limit' => input('limit', 5)
|
||||
);
|
||||
$result = $goods_stat_model->getGoodsOrderMoneyStat($params);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 销售量排行
|
||||
* @return array
|
||||
*/
|
||||
public function getGoodsOrderNumStat(){
|
||||
$goods_stat_model = new GoodsStat();
|
||||
$params = array(
|
||||
'site_id' => $this->site_id,
|
||||
'start_time' => input('start_time', 0),
|
||||
'end_time'=> input('end_time', 0),
|
||||
'limit' => input('limit', 5)
|
||||
);
|
||||
$result = $goods_stat_model->getGoodsOrderNumStat($params);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
416
app/shop/controller/Store.php
Executable file
416
app/shop/controller/Store.php
Executable file
@@ -0,0 +1,416 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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),
|
||||
'store_images' => input('store_images', ''),
|
||||
);
|
||||
|
||||
//判断是否开启多门店
|
||||
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),
|
||||
'store_images' => input('store_images', ''),
|
||||
);
|
||||
$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_ids = input('store_ids', '');
|
||||
$multiple_type = input('multiple_type', 0);//0多选 1单选
|
||||
$condition = [ [ 'site_id', '=', $this->site_id ] ];
|
||||
if($store_ids !== '' && $store_ids !== 'all'){
|
||||
$condition[] = ['store_id', 'in', $store_ids];
|
||||
}
|
||||
|
||||
$is_express = input('is_express', '');
|
||||
$is_pickup = input('is_pickup', '');
|
||||
$is_o2o = input('is_o2o', '');
|
||||
|
||||
if($is_express !== ''){
|
||||
$condition[] = ['is_express', '=', $is_express];
|
||||
}
|
||||
if($is_pickup !== ''){
|
||||
$condition[] = ['is_pickup', '=', $is_pickup];
|
||||
}
|
||||
if($is_o2o !== ''){
|
||||
$condition[] = ['is_o2o', '=', $is_o2o];
|
||||
}
|
||||
$store_list = ( new StoreModel() )->getStoreList($condition, '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);
|
||||
$this->assign('multiple_type', $multiple_type);
|
||||
return $this->fetch('store/select');
|
||||
}
|
||||
}
|
||||
85
app/shop/controller/Storeorder.php
Executable file
85
app/shop/controller/Storeorder.php
Executable file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
659
app/shop/controller/System.php
Executable file
659
app/shop/controller/System.php
Executable file
@@ -0,0 +1,659 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shop\controller;
|
||||
|
||||
use app\model\system\Addon;
|
||||
use app\model\system\Database;
|
||||
use app\model\system\Menu;
|
||||
use app\model\web\Config as ConfigModel;
|
||||
use app\model\web\DiyView as DiyViewModel;
|
||||
use extend\database\Database as dbdatabase;
|
||||
use think\facade\Cache;
|
||||
|
||||
|
||||
class System extends BaseShop
|
||||
{
|
||||
/*********************************************************系统缓存与数据库管理***************************************************/
|
||||
/**
|
||||
* 缓存设置
|
||||
*/
|
||||
public function cache()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$type = input('key', '');
|
||||
$type_list = explode(',', $type);
|
||||
$res = [];
|
||||
$msg = '';
|
||||
foreach ($type_list as $k => $v) {
|
||||
switch ( $v ) {
|
||||
case 'content':
|
||||
Cache::clear();
|
||||
$msg = '数据缓存清除成功';
|
||||
break;
|
||||
case 'data_table_cache':
|
||||
// 数据表缓存清除
|
||||
if (is_dir('runtime/schema')) {
|
||||
rmdirs('schema');
|
||||
}
|
||||
$msg = '数据表缓存清除成功';
|
||||
break;
|
||||
case 'template_cache':
|
||||
// 模板缓存清除
|
||||
if (is_dir('runtime/temp')) {
|
||||
rmdirs('temp');
|
||||
}
|
||||
$msg = '模板缓存清除成功';
|
||||
break;
|
||||
case 'menu_cache':
|
||||
$addon_model = new Addon();
|
||||
|
||||
$menu = new Menu();
|
||||
$menu->truncateMenu();
|
||||
$menu->truncateCashierAuth();
|
||||
|
||||
$menu->refreshMenu('shop', '');
|
||||
|
||||
$addon_model->cacheAddonMenu();
|
||||
|
||||
$addon_model->cacheAddon();
|
||||
Cache::clear();
|
||||
$msg = '刷新菜单成功';
|
||||
break;
|
||||
case 'diy_view':
|
||||
$res = $this->refreshDiy();
|
||||
Cache::clear();
|
||||
$msg = '刷新自定义模板成功';
|
||||
break;
|
||||
case 'all':
|
||||
// 清除缓存
|
||||
$msg = '一键刷新成功';
|
||||
break;
|
||||
}
|
||||
}
|
||||
return success(0, $msg, $res);
|
||||
} else {
|
||||
$config_model = new ConfigModel();
|
||||
$cache_list = $config_model->getCacheList();
|
||||
$this->assign('cache_list', $cache_list);
|
||||
return $this->fetch('system/cache');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function cach1e()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$type = input('key', '');
|
||||
$type_list = explode(',', $type);
|
||||
$msg = '';
|
||||
foreach ($type_list as $k => $v) {
|
||||
switch ( $v ) {
|
||||
case 'all':
|
||||
$msg = '一键刷新成功';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return success(0, $msg, '');
|
||||
} else {
|
||||
$config_model = new ConfigModel();
|
||||
$cache_list = $config_model->getCacheList();
|
||||
$this->assign('cache_list', $cache_list);
|
||||
return $this->fetch('system/cache');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 插件管理
|
||||
*/
|
||||
public function addon()
|
||||
{
|
||||
$addon = new Addon();
|
||||
if (request()->isJson()) {
|
||||
$addon_name = input('addon_name');
|
||||
$tag = input('tag', 'install');
|
||||
if ($tag == 'install') {
|
||||
$res = $addon->install($addon_name);
|
||||
return $res;
|
||||
} else {
|
||||
$res = $addon->uninstall($addon_name);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
$addon = $addon->getAddonAllList();
|
||||
|
||||
$this->assign('addons', $addon[ 'data' ][ 'install' ]);
|
||||
$this->assign('uninstall', $addon[ 'data' ][ 'uninstall' ]);
|
||||
return $this->fetch('system/addon');
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据库管理
|
||||
*/
|
||||
public function database()
|
||||
{
|
||||
$database = new Database();
|
||||
$table = $database->getDatabaseList();
|
||||
$this->assign('list', $table);
|
||||
|
||||
return $this->fetch('system/database');
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据库还原页面展示
|
||||
*/
|
||||
public function importlist()
|
||||
{
|
||||
$database = new Database();
|
||||
|
||||
$path = $database->backup_path;
|
||||
if (!is_dir($path)) {
|
||||
$mode = intval('0777', 8);
|
||||
mkdir($path, $mode, true);
|
||||
}
|
||||
|
||||
$flag = \FilesystemIterator::KEY_AS_FILENAME;
|
||||
$glob = new \FilesystemIterator($path, $flag);
|
||||
$list = array ();
|
||||
|
||||
foreach ($glob as $name => $file) {
|
||||
|
||||
if (preg_match('/^\d{8,8}-\d{6,6}-\d+\.sql(?:\.gz)?$/', $name)) {
|
||||
|
||||
$name = sscanf($name, '%4s%2s%2s-%2s%2s%2s-%d');
|
||||
$date = "{$name[0]}-{$name[1]}-{$name[2]}";
|
||||
$time = "{$name[3]}:{$name[4]}:{$name[5]}";
|
||||
$part = $name[ 6 ];
|
||||
|
||||
if (isset($list[ "{$date} {$time}" ])) {
|
||||
$info = $list[ "{$date} {$time}" ];
|
||||
$info[ 'part' ] = max($info[ 'part' ], $part);
|
||||
$info[ 'size' ] = $info[ 'size' ] + $file->getSize();
|
||||
$info[ 'size' ] = $database->format_bytes($info[ 'size' ]);
|
||||
} else {
|
||||
$info[ 'part' ] = $part;
|
||||
$info[ 'size' ] = $file->getSize();
|
||||
$info[ 'size' ] = $database->format_bytes($info[ 'size' ]);
|
||||
}
|
||||
|
||||
$info[ 'name' ] = date('Ymd-His', strtotime("{$date} {$time}"));
|
||||
$extension = strtoupper(pathinfo($file->getFilename(), PATHINFO_EXTENSION));
|
||||
$info[ 'compress' ] = ( $extension === 'SQL' ) ? '-' : $extension;
|
||||
$info[ 'time' ] = strtotime("{$date} {$time}");
|
||||
|
||||
$list[] = $info;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($list)) {
|
||||
$list = $database->my_array_multisort($list, 'time');
|
||||
}
|
||||
$this->assign('list', $list);
|
||||
|
||||
return $this->fetch('system/importlist');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 还原数据库
|
||||
*/
|
||||
public function importData()
|
||||
{
|
||||
|
||||
$time = request()->post('time', '');
|
||||
$part = request()->post('part', 0);
|
||||
$start = request()->post('start', 0);
|
||||
|
||||
$database = new Database();
|
||||
if (is_numeric($time) && ( is_null($part) || empty($part) ) && ( is_null($start) || empty($start) )) { // 初始化
|
||||
// 获取备份文件信息
|
||||
$name = date('Ymd-His', $time) . '-*.sql*';
|
||||
$path = realpath($database->backup_path) . DIRECTORY_SEPARATOR . $name;
|
||||
$files = glob($path);
|
||||
$list = array ();
|
||||
foreach ($files as $name) {
|
||||
$basename = basename($name);
|
||||
$match = sscanf($basename, '%4s%2s%2s-%2s%2s%2s-%d');
|
||||
$gz = preg_match('/^\d{8,8}-\d{6,6}-\d+\.sql.gz$/', $basename);
|
||||
$list[ $match[ 6 ] ] = array (
|
||||
$match[ 6 ],
|
||||
$name,
|
||||
$gz
|
||||
);
|
||||
}
|
||||
ksort($list);
|
||||
// 检测文件正确性
|
||||
$last = end($list);
|
||||
if (count($list) === $last[ 0 ]) {
|
||||
session('backup_list', $list); // 缓存备份列表
|
||||
$return_data = [
|
||||
'code' => 1,
|
||||
'message' => '初始化完成',
|
||||
'data' => [ 'part' => 1, 'start' => 0 ]
|
||||
];
|
||||
return $return_data;
|
||||
} else {
|
||||
$return_data = [
|
||||
'code' => -1,
|
||||
'message' => '备份文件可能已经损坏,请检查!',
|
||||
];
|
||||
return $return_data;
|
||||
}
|
||||
} elseif (is_numeric($part) && is_numeric($start)) {
|
||||
$list = session('backup_list');
|
||||
$db = new dbdatabase($list[ $part ], array (
|
||||
'path' => realpath($database->backup_path) . DIRECTORY_SEPARATOR,
|
||||
'compress' => $list[ $part ][ 2 ]
|
||||
));
|
||||
|
||||
$start = $db->import($start);
|
||||
if ($start === false) {
|
||||
$return_data = [
|
||||
'code' => -1,
|
||||
'message' => '还原数据出错!',
|
||||
];
|
||||
return $return_data;
|
||||
} elseif ($start === 0) { // 下一卷
|
||||
if (isset($list[ ++$part ])) {
|
||||
$data = array (
|
||||
'part' => $part,
|
||||
'start' => 0
|
||||
);
|
||||
$return_data = [
|
||||
'code' => -1,
|
||||
'message' => "正在还原...#{$part}",
|
||||
'data' => $data
|
||||
];
|
||||
return $return_data;
|
||||
} else {
|
||||
session('backup_list', null);
|
||||
$return_data = [
|
||||
'code' => -1,
|
||||
'message' => '还原完成!',
|
||||
];
|
||||
return $return_data;
|
||||
}
|
||||
} else {
|
||||
$data = array (
|
||||
'part' => $part,
|
||||
'start' => $start[ 0 ]
|
||||
);
|
||||
if ($start[ 1 ]) {
|
||||
$rate = floor(100 * ( $start[ 0 ] / $start[ 1 ] ));
|
||||
|
||||
$return_data = [
|
||||
'code' => 1,
|
||||
'message' => "正在还原...#{$part} ({$rate}%)",
|
||||
];
|
||||
return $return_data;
|
||||
} else {
|
||||
$data[ 'gz' ] = 1;
|
||||
$return_data = [
|
||||
'code' => 1,
|
||||
'message' => "正在还原...#{$part}",
|
||||
'data' => $data
|
||||
];
|
||||
return $return_data;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$return_data = [
|
||||
'code' => -1,
|
||||
'message' => '参数有误',
|
||||
];
|
||||
return $return_data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据表修复
|
||||
*/
|
||||
public function tablerepair()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$table_str = input('tables', '');
|
||||
$database = new Database();
|
||||
$res = $database->repair($table_str);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 数据表备份
|
||||
*/
|
||||
public function backup()
|
||||
{
|
||||
$database = new Database();
|
||||
$tables = input('tables', []);
|
||||
$id = input('id', '');
|
||||
$start = input('start', '');
|
||||
|
||||
if (!empty($tables) && is_array($tables)) { // 初始化
|
||||
// 读取备份配置
|
||||
$config = array (
|
||||
'path' => $database->backup_path . DIRECTORY_SEPARATOR,
|
||||
'part' => 20971520,
|
||||
'compress' => 1,
|
||||
'level' => 9
|
||||
);
|
||||
// 检查是否有正在执行的任务
|
||||
$lock = "{$config['path']}backup.lock";
|
||||
if (is_file($lock)) {
|
||||
return error(-1, '检测到有一个备份任务正在执行,请稍后再试!');
|
||||
} else {
|
||||
$mode = intval('0777', 8);
|
||||
if (!file_exists($config[ 'path' ]) || !is_dir($config[ 'path' ]))
|
||||
mkdir($config[ 'path' ], $mode, true); // 创建锁文件
|
||||
|
||||
file_put_contents($lock, date('Ymd-His', time()));
|
||||
}
|
||||
// 自动创建备份文件夹
|
||||
// 检查备份目录是否可写
|
||||
is_writeable($config[ 'path' ]) || exit('backup_not_exist_success');
|
||||
session('backup_config', $config);
|
||||
// 生成备份文件信息
|
||||
$file = array (
|
||||
'name' => date('Ymd-His', time()),
|
||||
'part' => 1
|
||||
);
|
||||
|
||||
session('backup_file', $file);
|
||||
|
||||
// 缓存要备份的表
|
||||
session('backup_tables', $tables);
|
||||
|
||||
$dbdatabase = new dbdatabase($file, $config);
|
||||
if (false !== $dbdatabase->create()) {
|
||||
|
||||
$data = array ();
|
||||
$data[ 'status' ] = 1;
|
||||
$data[ 'message' ] = '初始化成功';
|
||||
$data[ 'tables' ] = $tables;
|
||||
$data[ 'tab' ] = array (
|
||||
'id' => 0,
|
||||
'start' => 0
|
||||
);
|
||||
return $data;
|
||||
} else {
|
||||
return error(-1, '初始化失败,备份文件创建失败!');
|
||||
}
|
||||
} elseif (is_numeric($id) && is_numeric($start)) { // 备份数据
|
||||
$tables = session('backup_tables');
|
||||
// 备份指定表
|
||||
$dbdatabase = new dbdatabase(session('backup_file'), session('backup_config'));
|
||||
$start = $dbdatabase->backup($tables[ $id ], $start);
|
||||
if (false === $start) { // 出错
|
||||
return error(-1, '备份出错!');
|
||||
} elseif (0 === $start) { // 下一表
|
||||
if (isset($tables[ ++$id ])) {
|
||||
$tab = array (
|
||||
'id' => $id,
|
||||
'table' => $tables[ $id ],
|
||||
'start' => 0
|
||||
);
|
||||
$data = array ();
|
||||
$data[ 'rate' ] = 100;
|
||||
$data[ 'status' ] = 1;
|
||||
$data[ 'message' ] = '备份完成!';
|
||||
$data[ 'tab' ] = $tab;
|
||||
return $data;
|
||||
} else { // 备份完成,清空缓存
|
||||
unlink($database->backup_path . DIRECTORY_SEPARATOR . 'backup.lock');
|
||||
session('backup_tables', null);
|
||||
session('backup_file', null);
|
||||
session('backup_config', null);
|
||||
return success(1);
|
||||
}
|
||||
} else {
|
||||
$tab = array (
|
||||
'id' => $id,
|
||||
'table' => $tables[ $id ],
|
||||
'start' => $start[ 0 ]
|
||||
);
|
||||
$rate = floor(100 * ( $start[ 0 ] / $start[ 1 ] ));
|
||||
$data = array ();
|
||||
$data[ 'status' ] = 1;
|
||||
$data[ 'rate' ] = $rate;
|
||||
$data[ 'message' ] = "正在备份...({$rate}%)";
|
||||
$data[ 'tab' ] = $tab;
|
||||
return $data;
|
||||
}
|
||||
} else { // 出错
|
||||
return error(-1, '参数有误!');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除备份文件
|
||||
*/
|
||||
public function deleteData()
|
||||
{
|
||||
$name_time = input('time', '');
|
||||
if ($name_time) {
|
||||
$database = new Database();
|
||||
$name = date('Ymd-His', $name_time) . '-*.sql*';
|
||||
$path = realpath($database->backup_path) . DIRECTORY_SEPARATOR . $name;
|
||||
array_map('unlink', glob($path));
|
||||
if (count(glob($path))) {
|
||||
return error(-1, '备份文件删除失败,请检查权限!');
|
||||
} else {
|
||||
return success(1, '备份文件删除成功!');
|
||||
}
|
||||
} else {
|
||||
return error(-1, '参数有误!');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新菜单 测试
|
||||
*/
|
||||
public function refresh()
|
||||
{
|
||||
$menu = new Menu();
|
||||
$res = $menu->refreshAllMenu();
|
||||
dd($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新自定义组件
|
||||
*/
|
||||
public function refreshDiy()
|
||||
{
|
||||
$menu = new Menu();
|
||||
$addon = new Addon();
|
||||
|
||||
$menu->truncateDiyView();
|
||||
$addon_list = $addon->getAddonList([], 'name')[ 'data' ];
|
||||
$res = [];
|
||||
$res[] = $addon->refreshDiyView('');
|
||||
|
||||
foreach ($addon_list as $k => $v) {
|
||||
$res[] = $addon->refreshDiyView($v[ 'name' ]);
|
||||
}
|
||||
|
||||
// 处理升级版本数据遇到的数据问题
|
||||
$this->handleVersionData();
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理升级版本数据遇到的数据问题
|
||||
*/
|
||||
public function handleVersionData()
|
||||
{
|
||||
$msg = '处理成功';
|
||||
try {
|
||||
|
||||
model('site_diy_view')->startTrans();
|
||||
|
||||
// 处理微页面数据、图标显示问题
|
||||
$page = model('site_diy_view')->getList([], 'id,value');
|
||||
foreach ($page as $k => $v) {
|
||||
if (!empty($v[ 'value' ])) {
|
||||
$value = json_decode($v[ 'value' ], true);
|
||||
|
||||
foreach ($value[ 'value' ] as $ck => $cv) {
|
||||
|
||||
if ($cv[ 'componentName' ] == 'Text') {
|
||||
// 标题组件
|
||||
} elseif ($cv[ 'componentName' ] == 'Search') {
|
||||
|
||||
// 搜索框组件,v5.1.7新增
|
||||
if (!isset($cv[ 'searchLink' ])) {
|
||||
$value[ 'value' ][ $ck ][ 'searchLink' ] = [
|
||||
'name' => ''
|
||||
];
|
||||
}
|
||||
|
||||
} elseif ($cv[ 'componentName' ] == 'GraphicNav') {
|
||||
// 图文导航组件
|
||||
} elseif ($cv[ 'componentName' ] == 'GoodsList') {
|
||||
// 商品列表组件
|
||||
} elseif ($cv[ 'componentName' ] == 'ManyGoodsList') {
|
||||
// 多商品组组件,v5.1.9新增
|
||||
if (!isset($value[ 'value' ][ $ck ][ 'headStyle' ])) {
|
||||
$value[ 'value' ][ $ck ][ 'headStyle' ] = [
|
||||
'titleColor' => '#303133'
|
||||
];
|
||||
}
|
||||
|
||||
} elseif ($cv[ 'componentName' ] == 'GoodsRecommend') {
|
||||
// 商品推荐组件
|
||||
|
||||
} elseif ($cv[ 'componentName' ] == 'Seckill') {
|
||||
// 秒杀组件
|
||||
|
||||
} elseif ($cv[ 'componentName' ] == 'Notice') {
|
||||
// 公告组件,v5.1.7新增
|
||||
if (!empty($cv[ 'list' ])) {
|
||||
foreach ($cv[ 'list' ] as $notice_k => $notice_v) {
|
||||
$cv[ 'list' ][ $notice_k ][ 'id' ] = unique_random(12) . $notice_k;
|
||||
}
|
||||
$value[ 'value' ][ $ck ][ 'list' ] = $cv[ 'list' ];
|
||||
}
|
||||
// v5.2.2新增
|
||||
if (!isset($cv[ 'count' ])) {
|
||||
$value[ 'value' ][ $ck ][ 'count' ] = 6;
|
||||
}
|
||||
|
||||
} elseif ($cv[ 'componentName' ] == 'ImageAds') {
|
||||
// 图片广告组件,v5.1.6新增
|
||||
if (!isset($cv[ 'indicatorIsShow' ])) {
|
||||
$value[ 'value' ][ $ck ][ 'indicatorIsShow' ] = true;
|
||||
}
|
||||
// v5.2.3新增
|
||||
if (!isset($cv[ 'interval' ])) {
|
||||
$value[ 'value' ][ $ck ][ 'interval' ] = 5000;
|
||||
}
|
||||
|
||||
} elseif ($cv[ 'componentName' ] == 'MemberMyOrder') {
|
||||
// 会员中心 我的订单组件,v5.1.7新增
|
||||
if ($cv[ 'style' ] == 4) {
|
||||
$value[ 'value' ][ $ck ][ 'icon' ] = [
|
||||
'waitPay' => [
|
||||
'title' => '待支付',
|
||||
'icon' => 'icondiy icon-system-daizhifu',
|
||||
'style' => [
|
||||
'bgRadius' => 0,
|
||||
'fontSize' => 90,
|
||||
'iconBgColor' => [],
|
||||
'iconBgColorDeg' => 0,
|
||||
'iconBgImg' => '',
|
||||
'iconColor' => ['#20DA86', '#03B352'],
|
||||
'iconColorDeg' => 0
|
||||
]
|
||||
],
|
||||
'waitSend' => [
|
||||
'title' => '备货中',
|
||||
'icon' => 'icondiy icon-system-beihuozhong',
|
||||
'style' => [
|
||||
'bgRadius' => 0,
|
||||
'fontSize' => 90,
|
||||
'iconBgColor' => [],
|
||||
'iconBgColorDeg' => 0,
|
||||
'iconBgImg' => '',
|
||||
'iconColor' => ['#20DA86', '#03B352'],
|
||||
'iconColorDeg' => 0
|
||||
]
|
||||
],
|
||||
'waitConfirm' => [
|
||||
'title' => '配送中',
|
||||
'icon' => 'icondiy icon-system-paisongzhong',
|
||||
'style' => [
|
||||
'bgRadius' => 0,
|
||||
'fontSize' => 90,
|
||||
'iconBgColor' => [],
|
||||
'iconBgColorDeg' => 0,
|
||||
'iconBgImg' => '',
|
||||
'iconColor' => ['#20DA86', '#03B352'],
|
||||
'iconColorDeg' => 0
|
||||
]
|
||||
],
|
||||
'waitUse' => [
|
||||
'title' => '待评价',
|
||||
'icon' => 'icondiy icon-system-daishiyong2',
|
||||
'style' => [
|
||||
'bgRadius' => 0,
|
||||
'fontSize' => 90,
|
||||
'iconBgColor' => [],
|
||||
'iconBgColorDeg' => 0,
|
||||
'iconBgImg' => '',
|
||||
'iconColor' => ['#20DA86', '#03B352'],
|
||||
'iconColorDeg' => 0
|
||||
]
|
||||
],
|
||||
'refunding' => [
|
||||
'title' => '退换货',
|
||||
'icon' => 'icondiy icon-system-tuihuoguanli',
|
||||
'style' => [
|
||||
'bgRadius' => 0,
|
||||
'fontSize' => 90,
|
||||
'iconBgColor' => [],
|
||||
'iconBgColorDeg' => 0,
|
||||
'iconBgImg' => '',
|
||||
'iconColor' => ['#20DA86', '#03B352'],
|
||||
'iconColorDeg' => 0
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
} elseif ($cv[ 'componentName' ] == 'FloatBtn') {
|
||||
// 浮动按钮 组件,v5.1.7新增
|
||||
if (!isset($cv[ 'imageSize' ])) {
|
||||
$value[ 'value' ][ $ck ][ 'imageSize' ] = 40;
|
||||
}
|
||||
|
||||
} elseif ($cv[ 'componentName' ] == 'TopCategory') {
|
||||
// 分类导航 组件,v5.1.7新增
|
||||
if (!isset($cv[ 'moreColor' ])) {
|
||||
$value[ 'value' ][ $ck ][ 'moreColor' ] = '#333333';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
model('site_diy_view')->update([ 'value' => json_encode($value) ], [ [ 'id', '=', $v[ 'id' ] ] ]);
|
||||
}
|
||||
}
|
||||
|
||||
model('site_diy_view')->commit();
|
||||
Cache::clear();
|
||||
} catch (\Exception $e) {
|
||||
model('site_diy_view')->rollback();
|
||||
$msg = 'File:' . $e->getFile() . ',Line:' . $e->getLine() . ',Message:' . $e->getMessage() . ',Code:' . $e->getCode();
|
||||
}
|
||||
return $msg;
|
||||
}
|
||||
|
||||
}
|
||||
511
app/shop/controller/Ueditor.php
Executable file
511
app/shop/controller/Ueditor.php
Executable file
@@ -0,0 +1,511 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shop\controller;
|
||||
|
||||
use app\Controller;
|
||||
use app\model\upload\Upload as UploadModel;
|
||||
|
||||
/**
|
||||
* 百度编辑器上传
|
||||
* 版本 1.0.6
|
||||
*/
|
||||
class Ueditor extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
date_default_timezone_set('Asia/chongqing');
|
||||
error_reporting(E_ERROR);
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
|
||||
$CONFIG = json_decode(preg_replace('/\/\*[\s\S]+?\*\//', '', file_get_contents('./public/static/ext/ueditor/php/config.json')), true);
|
||||
$action = $_GET[ 'action' ];
|
||||
|
||||
switch ( $action ) {
|
||||
case 'config':
|
||||
$result = json_encode($CONFIG);
|
||||
break;
|
||||
/* 上传图片 */
|
||||
case 'uploadimage':
|
||||
$fieldName = $CONFIG[ 'imageFieldName' ];
|
||||
$result = $this->upImage($fieldName);
|
||||
break;
|
||||
/* 上传涂鸦 */
|
||||
case 'uploadscrawl':
|
||||
$config = array (
|
||||
'pathFormat' => $CONFIG[ 'scrawlPathFormat' ],
|
||||
'maxSize' => $CONFIG[ 'scrawlMaxSize' ],
|
||||
'allowFiles' => $CONFIG[ 'scrawlAllowFiles' ],
|
||||
'oriName' => 'scrawl.png'
|
||||
);
|
||||
$fieldName = $CONFIG[ 'scrawlFieldName' ];
|
||||
$base64 = 'base64';
|
||||
$result = $this->upBase64($config, $fieldName);
|
||||
break;
|
||||
/* 上传视频 */
|
||||
case 'uploadvideo':
|
||||
$fieldName = $CONFIG[ 'videoFieldName' ];
|
||||
$result = $this->upVideo($fieldName, $CONFIG[ 'videoMaxSize' ]);
|
||||
break;
|
||||
/* 上传文件 */
|
||||
case 'uploadfile':
|
||||
$fieldName = $CONFIG[ 'fileFieldName' ];
|
||||
$result = $this->upFile($fieldName);
|
||||
break;
|
||||
/* 列出图片 */
|
||||
case 'listimage':
|
||||
$allowFiles = $CONFIG[ 'imageManagerAllowFiles' ];
|
||||
$listSize = $CONFIG[ 'imageManagerListSize' ];
|
||||
$path = $CONFIG[ 'imageManagerListPath' ];
|
||||
$get = $_GET;
|
||||
$result = $this->fileList($allowFiles, $listSize, $get);
|
||||
break;
|
||||
/* 列出文件 */
|
||||
case 'listfile':
|
||||
$allowFiles = $CONFIG[ 'fileManagerAllowFiles' ];
|
||||
$listSize = $CONFIG[ 'fileManagerListSize' ];
|
||||
$path = $CONFIG[ 'fileManagerListPath' ];
|
||||
$get = $_GET;
|
||||
$result = $this->fileList($allowFiles, $listSize, $get);
|
||||
break;
|
||||
/* 抓取远程文件 */
|
||||
case 'catchimage':
|
||||
$config = array (
|
||||
'pathFormat' => $CONFIG[ 'catcherPathFormat' ],
|
||||
'maxSize' => $CONFIG[ 'catcherMaxSize' ],
|
||||
'allowFiles' => $CONFIG[ 'catcherAllowFiles' ],
|
||||
'oriName' => 'remote.png'
|
||||
);
|
||||
$fieldName = $CONFIG[ 'catcherFieldName' ];
|
||||
/* 抓取远程图片 */
|
||||
$list = array ();
|
||||
isset($_POST[ $fieldName ]) ? $source = $_POST[ $fieldName ] : $source = $_GET[ $fieldName ];
|
||||
|
||||
foreach ($source as $imgUrl) {
|
||||
$info = json_decode($this->saveRemote($config, $imgUrl), true);
|
||||
$list[] = array(
|
||||
"state" => $info["state"],
|
||||
"url" => $info["url"],
|
||||
"size" => $info["size"],
|
||||
"title" => htmlspecialchars($info["title"]),
|
||||
"original" => htmlspecialchars($info["original"]),
|
||||
"source" => htmlspecialchars($imgUrl)
|
||||
);
|
||||
}
|
||||
|
||||
$result = json_encode(array (
|
||||
'state' => count($list) ? 'SUCCESS' : 'ERROR',
|
||||
'list' => $list
|
||||
));
|
||||
break;
|
||||
default:
|
||||
$result = json_encode(array (
|
||||
'state' => '请求地址出错'
|
||||
));
|
||||
break;
|
||||
}
|
||||
|
||||
/* 输出结果 */
|
||||
if (isset($_GET['callback'])) {
|
||||
if (preg_match('/^[\w_]+$/', $_GET['callback'])) {
|
||||
echo htmlspecialchars($_GET['callback']) . '(' . $result . ')';
|
||||
} else {
|
||||
echo json_encode(array (
|
||||
'state' => 'callback参数不合法'
|
||||
));
|
||||
}
|
||||
} else {
|
||||
echo $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
* @param unknown $fieldName
|
||||
*/
|
||||
private function upFile($fieldName)
|
||||
{
|
||||
$upload_service = new Upload();
|
||||
$upload_path = 'ueditor/file/' . date('Ymd');
|
||||
if (!empty($_FILES[ $fieldName ])) {//上传成功
|
||||
$info = $upload_service->file($_FILES[ $fieldName ], $upload_path);
|
||||
if ($info[ 'code' ] > 0) {
|
||||
$data = array (
|
||||
'state' => 'SUCCESS',
|
||||
'url' => $info[ 'data' ][ 'path' ],
|
||||
'title' => $info[ 'data' ][ 'file_name' ],
|
||||
'original' => $info[ 'data' ][ 'file_name' ],
|
||||
'type' => '.' . $info[ 'data' ][ 'file_ext' ],
|
||||
'size' => $info[ 'data' ][ 'size' ]
|
||||
);
|
||||
} else {
|
||||
$data = array (
|
||||
'state' => $info[ 'message' ]
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$data = array (
|
||||
'state' => '上传文件为空',
|
||||
);
|
||||
}
|
||||
return json_encode($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传图片
|
||||
* @param unknown $fieldName
|
||||
* @return string
|
||||
*/
|
||||
private function upImage($fieldName)
|
||||
{
|
||||
$upload_service = new UploadModel();
|
||||
$upload_path = 'ueditor/image/' . date('Ymd');
|
||||
if (!empty($_FILES[ $fieldName ])) {//上传成功
|
||||
$info = $upload_service->setPath('common/images/' . date('Ymd') . '/')->image([
|
||||
'name' => $fieldName,
|
||||
'thumb_type' => '',
|
||||
'cloud' => 1
|
||||
]);
|
||||
if ($info[ 'code' ] >= 0) {
|
||||
$data = array (
|
||||
'state' => 'SUCCESS',
|
||||
'url' => $info[ 'data' ][ 'pic_path' ],
|
||||
'title' => $info[ 'data' ][ 'pic_name' ],
|
||||
'original' => $info[ 'data' ][ 'pic_name' ],
|
||||
'type' => '.' . $info[ 'data' ][ 'file_ext' ],
|
||||
);
|
||||
} else {
|
||||
$data = array (
|
||||
'state' => $info[ 'message' ]
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$data = array (
|
||||
'state' => '上传文件为空',
|
||||
);
|
||||
}
|
||||
return json_encode($data);
|
||||
}
|
||||
|
||||
public function upVideo($fieldName, $size)
|
||||
{
|
||||
$upload_service = new UploadModel();
|
||||
if (!empty($_FILES[ $fieldName ])) {//上传成功
|
||||
$info = $upload_service->setPath('common/video/' . date('Ymd') . '/')->video([
|
||||
'name' => $fieldName,
|
||||
]);
|
||||
if ($info[ 'code' ] >= 0) {
|
||||
$data = array (
|
||||
'state' => 'SUCCESS',
|
||||
'url' => $info[ 'data' ][ 'path' ],
|
||||
'title' => $info[ 'data' ][ 'path' ],
|
||||
'original' => $info[ 'data' ][ 'path' ]
|
||||
);
|
||||
} else {
|
||||
$data = array (
|
||||
'state' => 'FAIL'
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$data = array (
|
||||
'state' => '上传文件为空',
|
||||
);
|
||||
}
|
||||
return json_encode($data);
|
||||
}
|
||||
|
||||
//列出图片
|
||||
private function fileList($allowFiles, $listSize, $get)
|
||||
{
|
||||
$dirname = __UPLOAD__ . '/ueditor/';
|
||||
$allowFiles = substr(str_replace('.', '|', join('', $allowFiles)), 1);
|
||||
|
||||
/* 获取参数 */
|
||||
$size = isset($get[ 'size' ]) ? htmlspecialchars($get[ 'size' ]) : $listSize;
|
||||
$start = isset($get[ 'start' ]) ? htmlspecialchars($get[ 'start' ]) : 0;
|
||||
$end = $start + $size;
|
||||
|
||||
/* 获取文件列表 */
|
||||
$path = $dirname;
|
||||
$files = $this->getFiles($path, $allowFiles);
|
||||
if (!count($files)) {
|
||||
return json_encode(array (
|
||||
'state' => 'no match file',
|
||||
'list' => array (),
|
||||
'start' => $start,
|
||||
'total' => count($files)
|
||||
));
|
||||
}
|
||||
|
||||
/* 获取指定范围的列表 */
|
||||
$len = count($files);
|
||||
for ($i = min($end, $len) - 1, $list = array (); $i < $len && $i >= 0 && $i >= $start; $i--) {
|
||||
$list[] = $files[ $i ];
|
||||
}
|
||||
|
||||
/* 返回数据 */
|
||||
$result = json_encode(array (
|
||||
'state' => 'SUCCESS',
|
||||
'list' => $list,
|
||||
'start' => $start,
|
||||
'total' => count($files)
|
||||
));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/*
|
||||
* 遍历获取目录下的指定类型的文件
|
||||
* @param $path
|
||||
* @param array $files
|
||||
* @return array
|
||||
*/
|
||||
private function getFiles($path, $allowFiles, &$files = array ())
|
||||
{
|
||||
if (!is_dir($path)) return null;
|
||||
if (substr($path, strlen($path) - 1) != '/') $path .= '/';
|
||||
$handle = opendir($path);
|
||||
|
||||
while (false !== ( $file = readdir($handle) )) {
|
||||
if ($file != '.' && $file != '..') {
|
||||
$path2 = $path . $file;
|
||||
if (is_dir($path2)) {
|
||||
$this->getFiles($path2, $allowFiles, $files);
|
||||
} else {
|
||||
if (preg_match('/\.(' . $allowFiles . ')$/i', $file)) {
|
||||
$files[] = array (
|
||||
'url' => $path2, //substr($path2,1),
|
||||
'mtime' => filemtime($path2)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
private function saveRemote($config, $fieldName)
|
||||
{
|
||||
$imgUrl = htmlspecialchars($fieldName);
|
||||
$imgUrl = str_replace('&', '&', $imgUrl);
|
||||
|
||||
//http开头验证
|
||||
if (strpos($imgUrl, 'http') !== 0) {
|
||||
$data = array (
|
||||
'state' => '链接不是http链接',
|
||||
);
|
||||
return json_encode($data);
|
||||
}
|
||||
//获取请求头并检测死链
|
||||
$heads = get_headers($imgUrl);
|
||||
if (!( stristr($heads[ 0 ], '200') && stristr($heads[ 0 ], 'OK') )) {
|
||||
$data = array (
|
||||
'state' => '链接不可用',
|
||||
);
|
||||
return json_encode($data);
|
||||
}
|
||||
//格式验证(扩展名验证和Content-Type验证)
|
||||
$fileType = strtolower(strrchr($imgUrl, '.'));
|
||||
if (!in_array($fileType, $config[ 'allowFiles' ]) || stristr($heads[ 'Content-Type' ], 'image')) {
|
||||
$data = array (
|
||||
'state' => '链接contentType不正确',
|
||||
);
|
||||
return json_encode($data);
|
||||
}
|
||||
|
||||
$upload_service = new UploadModel();
|
||||
$res = $upload_service->setPath('common/images/' . date('Ymd') . '/')->remotePull($imgUrl);
|
||||
|
||||
if ($res[ 'code' ] != 0) {
|
||||
return json_encode([ 'state' => $res[ 'message' ] ]);
|
||||
}
|
||||
preg_match('/[\/]([^\/]*)[\.]?[^\.\/]*$/', $imgUrl, $m);
|
||||
|
||||
return json_encode([
|
||||
'state' => 'SUCCESS',
|
||||
'url' => img($res[ 'data' ][ 'pic_path' ]),
|
||||
'title' => $res[ 'data' ][ 'pic_path' ],
|
||||
'original' => $m ? $m[ 1 ] : '',
|
||||
'type' => strtolower(strrchr($config[ 'oriName' ], '.')),
|
||||
'size' => 0,
|
||||
]);
|
||||
}
|
||||
|
||||
//抓取远程图片
|
||||
private function saveRemoteBackup($config, $fieldName)
|
||||
{
|
||||
$imgUrl = htmlspecialchars($fieldName);
|
||||
$imgUrl = str_replace('&', '&', $imgUrl);
|
||||
|
||||
//http开头验证
|
||||
if (strpos($imgUrl, 'http') !== 0) {
|
||||
$data = array (
|
||||
'state' => '链接不是http链接',
|
||||
);
|
||||
return json_encode($data);
|
||||
}
|
||||
//获取请求头并检测死链
|
||||
$heads = get_headers($imgUrl);
|
||||
if (!( stristr($heads[ 0 ], '200') && stristr($heads[ 0 ], 'OK') )) {
|
||||
$data = array (
|
||||
'state' => '链接不可用',
|
||||
);
|
||||
return json_encode($data);
|
||||
}
|
||||
//格式验证(扩展名验证和Content-Type验证)
|
||||
$fileType = strtolower(strrchr($imgUrl, '.'));
|
||||
if (!in_array($fileType, $config[ 'allowFiles' ]) || stristr($heads[ 'Content-Type' ], 'image')) {
|
||||
$data = array (
|
||||
'state' => '链接contentType不正确',
|
||||
);
|
||||
return json_encode($data);
|
||||
}
|
||||
|
||||
//打开输出缓冲区并获取远程图片
|
||||
ob_start();
|
||||
$context = stream_context_create(
|
||||
array ( 'http' => array (
|
||||
'follow_location' => false // don't follow redirects
|
||||
) )
|
||||
);
|
||||
readfile($imgUrl, false, $context);
|
||||
$img = ob_get_contents();
|
||||
ob_end_clean();
|
||||
preg_match('/[\/]([^\/]*)[\.]?[^\.\/]*$/', $imgUrl, $m);
|
||||
|
||||
$dirname = __UPLOAD__ . '/ueditor/image/' . date('Ymd');
|
||||
$file[ 'oriName' ] = $m ? $m[ 1 ] : '';
|
||||
$file[ 'filesize' ] = strlen($img);
|
||||
$file[ 'ext' ] = strtolower(strrchr($config[ 'oriName' ], '.'));
|
||||
$file[ 'name' ] = uniqid() . $file[ 'ext' ];
|
||||
$file[ 'fullName' ] = $dirname . '/' . $file[ 'name' ];
|
||||
$fullName = $file[ 'fullName' ];
|
||||
|
||||
//检查文件大小是否超出限制
|
||||
if ($file[ 'filesize' ] >= ( $config['maxSize'] )) {
|
||||
$data = array (
|
||||
'state' => '文件大小超出网站限制',
|
||||
);
|
||||
return json_encode($data);
|
||||
}
|
||||
|
||||
//创建目录失败
|
||||
if (!file_exists($dirname) && !mkdir($dirname, 0777, true)) {
|
||||
$data = array (
|
||||
'state' => '目录创建失败',
|
||||
);
|
||||
return json_encode($data);
|
||||
} else if (!is_writeable($dirname)) {
|
||||
$data = array (
|
||||
'state' => '目录没有写权限',
|
||||
);
|
||||
return json_encode($data);
|
||||
}
|
||||
|
||||
//移动文件
|
||||
if (!( file_put_contents($fullName, $img) && file_exists($fullName) )) { //移动失败
|
||||
$data = array (
|
||||
'state' => '写入文件内容错误',
|
||||
);
|
||||
return json_encode($data);
|
||||
} else {
|
||||
//先拉取到本地在上传到云端
|
||||
$upload_service = new Upload();
|
||||
$info = $upload_service->fileStore($dirname, $file[ 'name' ]);
|
||||
if ($info[ 'code' ] > 0) {
|
||||
$file[ 'fullName' ] = $info[ 'path' ];
|
||||
} else {
|
||||
$data = array (
|
||||
'state' => $info[ 'message' ],
|
||||
);
|
||||
return json_encode($data);
|
||||
}
|
||||
$data = array (
|
||||
'state' => 'SUCCESS',
|
||||
'url' => $file[ 'fullName' ],
|
||||
'title' => $file[ 'name' ],
|
||||
'original' => $file[ 'oriName' ],
|
||||
'type' => $file[ 'ext' ],
|
||||
'size' => $file[ 'filesize' ],
|
||||
);
|
||||
}
|
||||
|
||||
return json_encode($data);
|
||||
}
|
||||
|
||||
/*
|
||||
* 处理base64编码的图片上传
|
||||
* 例如:涂鸦图片上传
|
||||
*/
|
||||
private function upBase64($config, $fieldName)
|
||||
{
|
||||
$base64Data = $_POST[ $fieldName ];
|
||||
$img = base64_decode($base64Data);
|
||||
|
||||
$dirname = __UPLOAD__ . '/ueditor/scrawl/' . date('Ymd');
|
||||
$file[ 'filesize' ] = strlen($img);
|
||||
$file[ 'oriName' ] = $config[ 'oriName' ];
|
||||
$file[ 'ext' ] = strtolower(strrchr($config[ 'oriName' ], '.'));
|
||||
$file[ 'name' ] = uniqid() . $file[ 'ext' ];
|
||||
$file[ 'fullName' ] = $dirname . '/' . $file[ 'name' ];
|
||||
$fullName = $file[ 'fullName' ];
|
||||
|
||||
//检查文件大小是否超出限制
|
||||
if ($file[ 'filesize' ] >= ( $config['maxSize'] )) {
|
||||
$data = array (
|
||||
'state' => '文件大小超出网站限制',
|
||||
);
|
||||
return json_encode($data);
|
||||
}
|
||||
|
||||
//创建目录失败
|
||||
if (!file_exists($dirname) && !mkdir($dirname, 0777, true)) {
|
||||
$data = array (
|
||||
'state' => '目录创建失败',
|
||||
);
|
||||
return json_encode($data);
|
||||
} else if (!is_writeable($dirname)) {
|
||||
$data = array (
|
||||
'state' => '目录没有写权限',
|
||||
);
|
||||
return json_encode($data);
|
||||
}
|
||||
|
||||
//移动文件
|
||||
if (!( file_put_contents($fullName, $img) && file_exists($fullName) )) { //移动失败
|
||||
$data = array (
|
||||
'state' => '写入文件内容错误',
|
||||
);
|
||||
} else {
|
||||
//先拉取到本地在上传到云端
|
||||
$upload_service = new Upload();
|
||||
$info = $upload_service->fileStore($dirname, $file[ 'name' ]);
|
||||
if ($info[ 'code' ] > 0) {
|
||||
$file[ 'fullName' ] = $info[ 'path' ];
|
||||
} else {
|
||||
$data = array (
|
||||
'state' => $info[ 'message' ],
|
||||
);
|
||||
return json_encode($data);
|
||||
}
|
||||
$data = array (
|
||||
'state' => 'SUCCESS',
|
||||
'url' => substr($file[ 'fullName' ], 1),
|
||||
'title' => $file[ 'name' ],
|
||||
'original' => $file[ 'oriName' ],
|
||||
'type' => $file[ 'ext' ],
|
||||
'size' => $file[ 'filesize' ],
|
||||
);
|
||||
}
|
||||
|
||||
return json_encode($data);
|
||||
}
|
||||
}
|
||||
934
app/shop/controller/Upgrade.php
Executable file
934
app/shop/controller/Upgrade.php
Executable file
@@ -0,0 +1,934 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shop\controller;
|
||||
|
||||
use app\model\system\Database;
|
||||
use app\model\system\H5;
|
||||
use app\model\system\Menu;
|
||||
use app\model\system\Upgrade as UpgradeModel;
|
||||
use think\facade\Cache;
|
||||
use think\facade\Db;
|
||||
use app\model\system\Addon;
|
||||
use app\model\web\Config;
|
||||
use extend\FileManage;
|
||||
use think\facade\Session;
|
||||
|
||||
/**
|
||||
* 系统升级
|
||||
* @author Administrator
|
||||
* 版本 1.0.1
|
||||
*/
|
||||
class Upgrade extends BaseShop
|
||||
{
|
||||
/**
|
||||
* 系统授权信息
|
||||
*/
|
||||
public function auth()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$code = input('code', '');
|
||||
$upgrade_model = new UpgradeModel($code);
|
||||
$res = $upgrade_model->authInfo();
|
||||
if ($res[ 'code' ] == 0) {
|
||||
$config = new Config();
|
||||
$config->setAuth([ 'code' => $code ]);
|
||||
}
|
||||
return is_null($res) ? error() : $res;
|
||||
}
|
||||
//系统信息 获取自配置文件
|
||||
$app_info = config('info');
|
||||
$this->assign('app_info', $app_info);
|
||||
|
||||
//授权文件 获取自接口
|
||||
$upgrade_model = new UpgradeModel();
|
||||
$auth_info = $upgrade_model->authInfo();
|
||||
$this->assign('auth_info', $auth_info);
|
||||
|
||||
return $this->fetch('upgrade/auth');
|
||||
}
|
||||
|
||||
/************************************************系统升级 START*****************************************/
|
||||
|
||||
/**
|
||||
* 获取真实存在的目录 检测权限使用
|
||||
* @param $path
|
||||
* @return false|string
|
||||
*/
|
||||
protected function getRealPath($path)
|
||||
{
|
||||
while (!is_dir($path) && strrpos($path, '/')) {
|
||||
$path = substr($path, 0, strrpos($path, '/'));
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统升级
|
||||
*/
|
||||
public function upgrade()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$upgrade_model = new UpgradeModel();
|
||||
$res = $upgrade_model->getSystemUpgradeInfo();
|
||||
if ($res[ 'code' ] != 0) return $res;
|
||||
|
||||
$auth_info = $upgrade_model->authInfo();
|
||||
session('system_upgrade_new_version', $auth_info[ 'data' ][ 'newest_version' ]);
|
||||
$errors = $this->checkSystemUpgradeRight($res[ 'data' ]);
|
||||
session('system_upgrade_info_ready', $res[ 'data' ]);
|
||||
return success(0, '操作成功', [
|
||||
'system_upgrade_info_ready' => $res[ 'data' ],
|
||||
'right_check' => $errors,
|
||||
]);
|
||||
} else {
|
||||
return $this->fetch('upgrade/upgrade');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测系统升级权限
|
||||
*/
|
||||
protected function checkSystemUpgradeRight($system_upgrade_info_ready)
|
||||
{
|
||||
$errors = [];
|
||||
|
||||
//检测下载文件目录权限
|
||||
$download_root = 'upload/upgrade';
|
||||
$download_root = $this->getRealPath($download_root);
|
||||
if (!is_writeable($download_root)) {
|
||||
$errors[] = [
|
||||
'path' => $download_root,
|
||||
'type' => 'dir',
|
||||
'type_name' => '文件夹',
|
||||
];
|
||||
}
|
||||
|
||||
//检测备份文件目录权限
|
||||
$backup_root = 'upload/backup';
|
||||
$backup_root = $this->getRealPath($backup_root);
|
||||
if (!is_writeable($backup_root)) {
|
||||
$errors[] = [
|
||||
'path' => $backup_root,
|
||||
'type' => 'dir',
|
||||
'type_name' => '文件夹',
|
||||
];
|
||||
}
|
||||
|
||||
//检测证书文件权限
|
||||
$cert_key_path = './cert.key';
|
||||
if (!is_writeable($cert_key_path)) {
|
||||
$errors[] = [
|
||||
'path' => $cert_key_path,
|
||||
'type' => 'file',
|
||||
'type_name' => '文件',
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($system_upgrade_info_ready as $info) {
|
||||
//判断文件夹是否可写
|
||||
if ($info[ 'type' ] == 'addon' && $info[ 'action' ] == 'install') {
|
||||
$addon_path = 'addon';
|
||||
if (!is_writeable($addon_path)) {
|
||||
$errors[] = [
|
||||
'path' => $addon_path,
|
||||
'type' => 'dir',
|
||||
'type_name' => '文件夹',
|
||||
];
|
||||
}
|
||||
}
|
||||
//遍历文件 检测权限
|
||||
if (is_array($info[ 'files' ])) {
|
||||
foreach ($info[ 'files' ] as $val) {
|
||||
$file_path = '';
|
||||
if ($info[ 'action' ] == 'upgrade') {
|
||||
if ($info[ 'type' ] == 'system') {
|
||||
$file_path = $val[ 'file_path' ];
|
||||
} else {
|
||||
$file_path = "addon/{$val['file_path']}";
|
||||
}
|
||||
}
|
||||
if ($info[ 'action' ] == 'download' && $info[ 'type' ] == 'client') {
|
||||
$file_path = "public/{$val['file_path']}";
|
||||
}
|
||||
if ($file_path) {
|
||||
if (file_exists($file_path)) {
|
||||
if (!is_writeable($file_path)) {
|
||||
$errors[] = [
|
||||
'path' => $file_path,
|
||||
'type' => 'file',
|
||||
'type_name' => '文件',
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$dir_path = dirname($file_path);
|
||||
$dir_path = $this->getRealPath($dir_path);
|
||||
if (!is_writeable($dir_path)) {
|
||||
$errors[] = [
|
||||
'path' => $dir_path,
|
||||
'type' => 'dir',
|
||||
'type_name' => '文件夹',
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* 升级操作页面
|
||||
*/
|
||||
public function upgradeAction()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$system_upgrade_info_ready = session('system_upgrade_info_ready');
|
||||
|
||||
$app_info = config('info');
|
||||
$system_upgrade_info_ready = session('system_upgrade_info_ready');
|
||||
$name_text = $app_info[ 'version' ] . '_' . $system_upgrade_info_ready[ 0 ][ 'latest_version_name' ];
|
||||
|
||||
//将系统和插件的文件及sql都整合到一起
|
||||
$files = [];
|
||||
$sqls = '';
|
||||
// $upgrade_no = uniqid();
|
||||
|
||||
//合并文件和sql
|
||||
foreach ($system_upgrade_info_ready as $info) {
|
||||
foreach ($info[ 'files' ] as $val) {
|
||||
$val[ 'type' ] = $info[ 'type' ];
|
||||
$val[ 'code' ] = $info[ 'code' ];
|
||||
$files[] = $val;
|
||||
}
|
||||
if (isset($info[ 'sqls' ]) && !empty($info[ 'sqls' ])) {
|
||||
$sqls .= "\n";//防止脚本没有换行导致sql解析完成后将多条sql一起执行,导致出错
|
||||
$sqls .= $info[ 'sqls' ];
|
||||
}
|
||||
}
|
||||
|
||||
$system_upgrade_info = [
|
||||
'files' => $files,
|
||||
'sqls' => $sqls,
|
||||
'upgrade_no' => $name_text,
|
||||
];
|
||||
|
||||
session('system_upgrade_info', $system_upgrade_info);
|
||||
return success(0, '操作成功', session('system_upgrade_info'));
|
||||
} else {
|
||||
$system_upgrade_info_ready = session('system_upgrade_info_ready');
|
||||
if (empty($system_upgrade_info_ready)) {
|
||||
$this->error('没有可以升级的内容');
|
||||
}
|
||||
return $this->fetch('upgrade/upgrade_action');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 升级操作--备份原文件
|
||||
* @return array
|
||||
*/
|
||||
public function backupFile()
|
||||
{
|
||||
$system_upgrade_info = session('system_upgrade_info');
|
||||
$upgrade_no = $system_upgrade_info[ 'upgrade_no' ];
|
||||
//备份文件的根目录
|
||||
$backup_root = "upload/backup/{$upgrade_no}/file";
|
||||
if (!is_dir($backup_root)) {
|
||||
dir_mkdir($backup_root);
|
||||
}
|
||||
try {
|
||||
if (!empty($system_upgrade_info)) {
|
||||
foreach ($system_upgrade_info[ 'files' ] as $k => $v) {
|
||||
$type = $v[ 'type' ];
|
||||
if ($type == 'system') {
|
||||
//如果是系统升级 备份的文件是和根目录比对 下载文件类似 b2c_saas/index.php 要把前面的b2c_saas去掉
|
||||
$file_path = $v[ 'file_path' ];
|
||||
} else {
|
||||
//如果是插件升级 备份的文件是和插件目录比对 下载文件类似 test/index.php 需要补充前缀addon
|
||||
$file_path = "addon/{$v['file_path']}";
|
||||
}
|
||||
if (preg_match('/[\x{4e00}-\x{9fa5}]/u', $file_path) > 0) {
|
||||
$file_path = iconv('utf-8', 'gbk', $file_path);
|
||||
}
|
||||
if (file_exists($file_path)) {
|
||||
$dest_file_path = "{$backup_root}/{$file_path}";
|
||||
$dest_dir_path = substr($dest_file_path, 0, strrpos($dest_file_path, '/'));
|
||||
//要先创建文件夹才可以执行copy操作
|
||||
if (!is_dir($dest_dir_path)) {
|
||||
dir_mkdir($dest_dir_path);
|
||||
}
|
||||
copy($file_path, $dest_file_path);
|
||||
}
|
||||
}
|
||||
//备份客户端
|
||||
$client_type_arr = [ 'h5', 'weapp' ];
|
||||
foreach ($client_type_arr as $client_type) {
|
||||
$client_path = "{$backup_root}/public/{$client_type}";
|
||||
if (!is_dir($client_path)) {
|
||||
dir_mkdir($client_path);
|
||||
}
|
||||
dir_copy("public/{$client_type}", $client_path);
|
||||
}
|
||||
}
|
||||
return success();
|
||||
} catch (\Exception $e) {
|
||||
return error(-1, [], $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 升级操作---备份数据库
|
||||
*/
|
||||
public function backupSql()
|
||||
{
|
||||
try {
|
||||
$system_upgrade_info = session('system_upgrade_info');
|
||||
$upgrade_no = $system_upgrade_info[ 'upgrade_no' ];
|
||||
|
||||
$database = new Database();
|
||||
ini_set('memory_limit', '500M');
|
||||
$size = 300;
|
||||
$volumn = 1024 * 1024 * 2;
|
||||
$dump = '';
|
||||
$last_table = input('last_table', '');
|
||||
$series = max(1, input('series', 1));
|
||||
if (empty($last_table)) {
|
||||
$catch = true;
|
||||
} else {
|
||||
$catch = false;
|
||||
}
|
||||
$back_sql_root = "upload/backup/{$upgrade_no}/sql";
|
||||
if (!is_dir($back_sql_root)) {
|
||||
dir_mkdir($back_sql_root);
|
||||
}
|
||||
$tables = $database->getDatabaseList();
|
||||
if (empty($tables)) {
|
||||
return success();
|
||||
}
|
||||
foreach ($tables as $table) {
|
||||
$table = array_shift($table);
|
||||
if (!empty($last_table) && $table == $last_table) {
|
||||
$catch = true;
|
||||
}
|
||||
if (!$catch) {
|
||||
continue;
|
||||
}
|
||||
if (!empty($dump)) {
|
||||
$dump .= "\n\n";
|
||||
}
|
||||
$index = 0;
|
||||
if (!empty(input('index'))) {
|
||||
$index = input('index');
|
||||
}
|
||||
if ($table != $last_table) {
|
||||
$row = $database->getTableSchemas($table);
|
||||
$dump .= $row;
|
||||
$index = 0;
|
||||
}
|
||||
//枚举所有表的INSERT语句
|
||||
while (true) {
|
||||
$start = $index * $size;
|
||||
$result = $database->getTableInsertSql($table, $start, $size);
|
||||
if (!empty($result)) {
|
||||
$dump .= $result[ 'data' ];
|
||||
if (strlen($dump) > $volumn) {
|
||||
$back_file = "{$back_sql_root}/backup-{$series}.sql";
|
||||
$dump .= "\n\n";
|
||||
file_put_contents($back_file, $dump);
|
||||
++$series;
|
||||
++$index;
|
||||
$current = array (
|
||||
'is_backup_end' => 0,
|
||||
'last_table' => $table,
|
||||
'index' => $index,
|
||||
'series' => $series,
|
||||
);
|
||||
$current_series = $series - 1;
|
||||
return success(0, '正在导出数据, 请不要关闭浏览器, 当前第 ' . $current_series . ' 卷.', $current);
|
||||
}
|
||||
}
|
||||
if (empty($result) || count($result[ 'result' ]) < $size) {
|
||||
break;
|
||||
}
|
||||
++$index;
|
||||
}
|
||||
}
|
||||
$back_file = "{$back_sql_root}/backup-{$series}.sql";
|
||||
$dump .= "\n\n----MySQL Dump End";
|
||||
file_put_contents($back_file, $dump);
|
||||
return success(0, '数据库备份完成', [ 'is_backup_end' => 1 ]);
|
||||
} catch (\Exception $e) {
|
||||
return error(-1, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 升级操作---下载文件
|
||||
*/
|
||||
public function download()
|
||||
{
|
||||
ini_set('memory_limit', '-1');
|
||||
set_time_limit(300);
|
||||
|
||||
$action_type = input('action_type', 'upgrade');
|
||||
$system_upgrade_info = session('system_upgrade_info');
|
||||
$download_file_index = input('download_file_index', 0);
|
||||
$file_path = $system_upgrade_info[ 'files' ][ $download_file_index ][ 'file_path' ];
|
||||
$token = $system_upgrade_info[ 'files' ][ $download_file_index ][ 'token' ];
|
||||
$type = $system_upgrade_info[ 'files' ][ $download_file_index ][ 'type' ];
|
||||
$code = $system_upgrade_info[ 'files' ][ $download_file_index ][ 'code' ];
|
||||
$upgrade_no = $system_upgrade_info[ 'upgrade_no' ];
|
||||
|
||||
$app_info = config('info');
|
||||
$system_upgrade_info_ready = session('system_upgrade_info_ready');
|
||||
|
||||
if ($type == 'system') {
|
||||
$download_root = "upload/upgrade/{$upgrade_no}";//框架
|
||||
} else if ($type == 'client') {
|
||||
$download_root = "upload/upgrade/{$upgrade_no}";//客户端
|
||||
} else if ($type == 'addon') {
|
||||
$download_root = "upload/upgrade/{$upgrade_no}/addon";//插件
|
||||
}
|
||||
|
||||
try {
|
||||
$up_model = new UpgradeModel();
|
||||
$data = array (
|
||||
'file' => $file_path,
|
||||
'token' => $token
|
||||
);
|
||||
|
||||
$info = $up_model->download($data);//异步下载更新文件
|
||||
|
||||
//下载文件失败
|
||||
if ($info['code'] < 0) {
|
||||
return json($info);
|
||||
}
|
||||
|
||||
$dir_path = dirname($file_path);
|
||||
$dir_make = dir_mkdir($download_root . '/' . $dir_path);
|
||||
if ($dir_make) {
|
||||
if ($action_type == 'download' && $download_file_index == 0 && !empty($system_upgrade_info[ 'sqls' ])) {
|
||||
$sqls = str_replace('{{prefix}}', config('database.connections.mysql.prefix'), $system_upgrade_info[ 'sqls' ]);
|
||||
file_put_contents("upload/upgrade/{$upgrade_no}/upgrade.sql", $sqls);
|
||||
}
|
||||
if (!empty($info)) {
|
||||
$temp_path = $download_root . '/' . $file_path;
|
||||
if (preg_match('/[\x{4e00}-\x{9fa5}]/u', $temp_path) > 0) {
|
||||
$temp_path = iconv('utf-8', 'gbk', $temp_path);
|
||||
}
|
||||
file_put_contents($temp_path, base64_decode($info[ 'data' ]));
|
||||
return json([
|
||||
'code' => 0,
|
||||
'message' => $file_path,
|
||||
'download_root' => "upload/upgrade/{$upgrade_no}/",
|
||||
'current' => $app_info[ 'version' ],
|
||||
'upgrade' => $system_upgrade_info_ready[ 0 ][ 'latest_version_name' ],
|
||||
'newVersion' => session('system_upgrade_new_version')
|
||||
]);
|
||||
} else {
|
||||
return json([ 'code' => -1, 'message' => '升级文件不存在' ]);
|
||||
}
|
||||
} else {
|
||||
return json([ 'code' => -1, 'message' => '文件读写权限不足' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return json([ 'code' => -1, 'message' => $e->getMessage() ]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 升级操作---更新文件覆盖
|
||||
*/
|
||||
public function executeFile()
|
||||
{
|
||||
$system_upgrade_info = session('system_upgrade_info');
|
||||
$upgrade_no = $system_upgrade_info[ 'upgrade_no' ];
|
||||
try {
|
||||
//下载目录和要覆盖的目录
|
||||
$download_root = "upload/upgrade/{$upgrade_no}";
|
||||
// 先解压客户端文件
|
||||
$client_type_arr = [ 'h5', 'weapp' ];
|
||||
$file_manage = new FileManage();
|
||||
foreach ($client_type_arr as $client_type) {
|
||||
$client_path = $download_root . '/' . $client_type . '.zip';
|
||||
if (file_exists($client_path)) {
|
||||
$to_path = "public/{$client_type}/";
|
||||
if (!is_dir($to_path)) {
|
||||
dir_mkdir($to_path);
|
||||
} else {
|
||||
deleteDir($to_path);
|
||||
}
|
||||
$file_manage->unzip($client_path, $to_path);
|
||||
unlink($client_path);
|
||||
}
|
||||
}
|
||||
|
||||
$to_path = './';
|
||||
//文件替换
|
||||
dir_copy($download_root, $to_path, ['download.lock']);
|
||||
|
||||
return json([ 'code' => 0, 'message' => '操作成功' ]);
|
||||
} catch (\Exception $e) {
|
||||
//升级失败
|
||||
$upgrade_model = new UpgradeModel();
|
||||
$upgrade_model->editUpgradeLog([ 'status' => 2, 'error_message' => $e->getMessage() ], [ 'upgrade_no' => $upgrade_no ]);
|
||||
return json([ 'code' => -1, 'message' => $e->getMessage() ]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新操作---sql执行
|
||||
*/
|
||||
public function executeSql()
|
||||
{
|
||||
$system_upgrade_info = session('system_upgrade_info');
|
||||
$sqls = $system_upgrade_info[ 'sqls' ];
|
||||
$upgrade_no = $system_upgrade_info[ 'upgrade_no' ];
|
||||
|
||||
try {
|
||||
if (!empty($sqls)) {
|
||||
$sqls = str_replace('{{prefix}}', config('database.connections.mysql.prefix'), $sqls);
|
||||
file_put_contents("upload/upgrade/{$upgrade_no}/upgrade.sql", $sqls);
|
||||
|
||||
//执行sql
|
||||
$sql_arr = parse_sql($sqls);
|
||||
foreach ($sql_arr as $k => $v) {
|
||||
$v = trim($v);
|
||||
if (!empty($v) && $v != '') {
|
||||
Db::execute($v);
|
||||
}
|
||||
}
|
||||
return json(success());
|
||||
} else {
|
||||
return json(success());
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
//升级失败
|
||||
$upgrade_model = new UpgradeModel();
|
||||
$upgrade_model->editUpgradeLog([ 'status' => 2, 'error_message' => $e->getMessage() ], [ 'upgrade_no' => $upgrade_no ]);
|
||||
return json(error(-1, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 升级开始
|
||||
* @return array
|
||||
*/
|
||||
public function upgradeStart()
|
||||
{
|
||||
// 升级前先清除表结构缓存
|
||||
if (is_dir('runtime/schema')) {
|
||||
rmdirs('schema');
|
||||
}
|
||||
|
||||
$system_upgrade_info_ready = session('system_upgrade_info_ready');
|
||||
$system_upgrade_info = session('system_upgrade_info');
|
||||
$upgrade_no = $system_upgrade_info[ 'upgrade_no' ];
|
||||
|
||||
// 添加升级日志
|
||||
$version_info = [];
|
||||
foreach ($system_upgrade_info_ready as $key => $val) {
|
||||
$version_info[] = [
|
||||
'action' => $val[ 'action' ],
|
||||
'action_name' => $val[ 'action_name' ],
|
||||
'type' => $val[ 'type' ],
|
||||
'type_name' => $val[ 'type_name' ],
|
||||
'current_version_name' => $val[ 'current_version_name' ],
|
||||
'latest_version_name' => $val[ 'latest_version_name' ],
|
||||
'scripts' => $val[ 'scripts' ],
|
||||
'goods_name' => $val[ 'goods_name' ],
|
||||
];
|
||||
}
|
||||
|
||||
$data = [
|
||||
'upgrade_no' => $upgrade_no,
|
||||
'upgrade_time' => time(),
|
||||
'backup_root' => "upload/backup/{$upgrade_no}",
|
||||
'download_root' => "upload/download_root/{$upgrade_no}",
|
||||
'version_info' => json_encode($version_info),
|
||||
'status' => 0
|
||||
];
|
||||
|
||||
$upgrade_model = new UpgradeModel();
|
||||
$res = $upgrade_model->addUpgradeLog($data);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 升级完成
|
||||
*/
|
||||
public function upgradeEnd()
|
||||
{
|
||||
$system_upgrade_info_ready = session('system_upgrade_info_ready');
|
||||
$system_upgrade_info = session('system_upgrade_info');
|
||||
$upgrade_no = $system_upgrade_info[ 'upgrade_no' ];
|
||||
|
||||
$upgrade_model = new UpgradeModel();
|
||||
try {
|
||||
|
||||
$menu = new Menu();
|
||||
|
||||
// 清空表,防止自增ID越来越大
|
||||
$menu->truncateMenu();
|
||||
$menu->truncateDiyView();
|
||||
|
||||
//更新系统菜单
|
||||
$menu->refreshMenu('shop', '');
|
||||
|
||||
//修改插件信息
|
||||
$addon_model = new Addon();
|
||||
$addon_model->refreshDiyView('');
|
||||
|
||||
//刷新插件菜单
|
||||
$addon_list = $addon_model->getAddonList([], 'name');
|
||||
$addon_list = $addon_list[ 'data' ];
|
||||
foreach ($addon_list as $k => $v) {
|
||||
$menu->refreshMenu('shop', $v[ 'name' ]);
|
||||
$addon_model->refreshDiyView($v[ 'name' ]);
|
||||
}
|
||||
|
||||
foreach ($system_upgrade_info_ready as $key => $val) {
|
||||
if ($val[ 'type' ] == 'addon') {
|
||||
if ($val[ 'action' ] == 'upgrade') {
|
||||
if(addon_is_exit($val[ 'code'])){
|
||||
//如果插件没有卸载,则卸载再安装
|
||||
$addon_model->uninstall($val[ 'code' ]);
|
||||
$addon_model->install($val[ 'code' ]);
|
||||
}
|
||||
} else {
|
||||
$addon_model->install($val[ 'code' ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//升级成功
|
||||
$upgrade_model->editUpgradeLog([ 'status' => 1 ], [ 'upgrade_no' => $upgrade_no ]);
|
||||
|
||||
//刷新h5
|
||||
$h5 = new H5();
|
||||
$h5->refresh();
|
||||
|
||||
// 处理升级版本数据遇到的数据问题
|
||||
$system = new System();
|
||||
$system->handleVersionData();
|
||||
|
||||
//清空session数据
|
||||
session('system_upgrade_info_ready', null);
|
||||
session('system_upgrade_info', null);
|
||||
|
||||
return json(success());
|
||||
} catch (\Exception $e) {
|
||||
//升级失败
|
||||
$upgrade_model->editUpgradeLog([ 'status' => 2, 'error_message' => $e->getMessage() ], [ 'upgrade_no' => $upgrade_no ]);
|
||||
return json(error(-1, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行恢复
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function executeRecovery()
|
||||
{
|
||||
$system_upgrade_info_ready = session('system_upgrade_info_ready');
|
||||
$system_upgrade_info = session('system_upgrade_info');
|
||||
$upgrade_no = $system_upgrade_info[ 'upgrade_no' ];
|
||||
try {
|
||||
$upgrade_model = new UpgradeModel();
|
||||
$log_info = $upgrade_model->getUpgradeLogInfo([ 'upgrade_no' => $upgrade_no ]);
|
||||
if (empty($log_info)) {
|
||||
return json([ 'code' => -1, '回滚信息有误' ]);
|
||||
}
|
||||
$backup_file_path = "{$log_info['backup_root']}/file/";
|
||||
$backup_sql_path = "{$log_info['backup_root']}/sql/";
|
||||
|
||||
//回滚备份的文件
|
||||
if (dir_is_empty($backup_file_path)) {
|
||||
return json([ 'code' => -1, '没有可回滚的备份文件!' ]);
|
||||
}
|
||||
dir_copy($backup_file_path, './');
|
||||
|
||||
//回滚执行的sql语句
|
||||
$flag = \FilesystemIterator::KEY_AS_FILENAME;
|
||||
$glob = new \FilesystemIterator($backup_sql_path, $flag);
|
||||
foreach ($glob as $name => $sql) {
|
||||
$sql_path = $backup_sql_path . '/' . $name;
|
||||
$sql = file_get_contents($sql_path);
|
||||
//执行sql
|
||||
$sql_arr = parse_sql($sql);
|
||||
foreach ($sql_arr as $k => $v) {
|
||||
$v = trim($v);
|
||||
if (!empty($v) && $v != '') {
|
||||
Db::execute($v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//删除已安装的插件
|
||||
foreach ($system_upgrade_info_ready as $val) {
|
||||
if ($val[ 'action' ] == 'install' && $val[ 'type' ] == 'addon') {
|
||||
$addon_dir_path = "addon/{$val['code']}";
|
||||
if (is_dir($addon_dir_path)) {
|
||||
deleteDir($addon_dir_path);
|
||||
@rmdir($addon_dir_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
return json([ 'code' => 0, 'message' => '备份回滚成功!' ]);
|
||||
} catch (\Exception $e) {
|
||||
return json([ 'code' => -1, 'message' => $e->getMessage() ]);
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************系统升级 END*****************************************/
|
||||
|
||||
/************************************************系统回滚 START*****************************************/
|
||||
|
||||
/**
|
||||
* 系统回滚
|
||||
*/
|
||||
public function recovery()
|
||||
{
|
||||
$upgrade_model = new UpgradeModel();
|
||||
$upgrade_log_list = $upgrade_model->getUpgradeLogList([ 'status' => 1 ], '*', 'upgrade_time desc', '1');
|
||||
|
||||
if (!empty($upgrade_log_list[ 'data' ])) {
|
||||
$upgrade_log_info = $upgrade_log_list[ 'data' ][ 0 ];
|
||||
$upgrade_log_info[ 'version_info' ] = json_decode($upgrade_log_info[ 'version_info' ], true);
|
||||
} else {
|
||||
$upgrade_log_info = null;
|
||||
}
|
||||
if (request()->isJson()) {
|
||||
try {
|
||||
$log_info = $upgrade_log_info;
|
||||
if (empty($log_info)) {
|
||||
return json([ 'code' => -1, '回滚信息有误' ]);
|
||||
}
|
||||
$backup_file_path = "{$log_info['backup_root']}/file/";
|
||||
$backup_sql_path = "{$log_info['backup_root']}/sql/";
|
||||
|
||||
//回滚备份的文件
|
||||
if (dir_is_empty($backup_file_path)) {
|
||||
return json([ 'code' => -1, '没有可回滚的备份文件!' ]);
|
||||
}
|
||||
dir_copy($backup_file_path, './');
|
||||
|
||||
//回滚执行的sql语句
|
||||
$flag = \FilesystemIterator::KEY_AS_FILENAME;
|
||||
$glob = new \FilesystemIterator($backup_sql_path, $flag);
|
||||
foreach ($glob as $name => $sql) {
|
||||
$sql_path = $backup_sql_path . '/' . $name;
|
||||
$sql = file_get_contents($sql_path);
|
||||
//执行sql
|
||||
$sql_arr = parse_sql($sql);
|
||||
foreach ($sql_arr as $k => $v) {
|
||||
$v = trim($v);
|
||||
if (!empty($v) && $v != '') {
|
||||
Db::execute($v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return json([ 'code' => 0, 'message' => '备份回滚成功!' ]);
|
||||
} catch (\Exception $e) {
|
||||
return json([ 'code' => -1, 'message' => $e->getMessage() ]);
|
||||
}
|
||||
} else {
|
||||
$this->assign('upgrade_log_info', $upgrade_log_info);
|
||||
return $this->fetch('upgrade/recovery');
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************系统回滚 END*****************************************/
|
||||
|
||||
/************************************************ 更新日志 START*****************************************/
|
||||
|
||||
public function versionLog()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$upgrade_model = new UpgradeModel();
|
||||
$info = $upgrade_model->getUpdateLog();
|
||||
return $info;
|
||||
} else {
|
||||
return $this->fetch('upgrade/version_log');
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************ 更新日志 END*****************************************/
|
||||
|
||||
/**
|
||||
* 版本恢复
|
||||
*/
|
||||
public function versionRecovery()
|
||||
{
|
||||
try {
|
||||
//回滚备份的文件
|
||||
if (dir_is_empty('upload/backup/')) {
|
||||
return json([ 'code' => -1, '没有可回滚的备份!' ]);
|
||||
}
|
||||
dir_copy('upload/backup/release', './');
|
||||
//回滚执行的sql语句
|
||||
$path = 'upload/backup/sql';
|
||||
$flag = \FilesystemIterator::KEY_AS_FILENAME;
|
||||
$glob = new \FilesystemIterator($path, $flag);
|
||||
foreach ($glob as $name => $sql) {
|
||||
$sql_path = $path . '/' . $name;
|
||||
$sql = file_get_contents($sql_path);
|
||||
Db::execute($sql);
|
||||
}
|
||||
return json([ 'code' => 0, 'message' => '备份回滚成功!' ]);
|
||||
} catch (\Exception $e) {
|
||||
return json([ 'code' => -1, 'message' => $e->getMessage() ]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理缓存、刷新菜单、自定义组件
|
||||
* @return array
|
||||
*/
|
||||
public function refresh()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
|
||||
try {
|
||||
Cache::clear();
|
||||
if (is_dir('runtime/schema')) {
|
||||
rmdirs('schema');
|
||||
}
|
||||
|
||||
if (is_dir('runtime/temp')) {
|
||||
rmdirs('temp');
|
||||
}
|
||||
|
||||
$menu = new Menu();
|
||||
|
||||
// 清空表,防止自增ID越来越大
|
||||
$menu->truncateMenu();
|
||||
$menu->truncateDiyView();
|
||||
|
||||
$menu->refreshMenu('shop', '');
|
||||
|
||||
if (addon_is_exit('store', $this->site_id) == 1) {
|
||||
$menu->refreshMenu('store', 'store');
|
||||
}
|
||||
|
||||
$addon_model = new Addon();
|
||||
$addon_model->refreshDiyView('');
|
||||
|
||||
$addon_model->installAllAddon();
|
||||
|
||||
//刷新插件菜单
|
||||
$addon_list = $addon_model->getAddonList([], 'name')[ 'data' ];
|
||||
foreach ($addon_list as $k => $v) {
|
||||
$menu->refreshMenu('shop', $v[ 'name' ]);
|
||||
$addon_model->refreshDiyView($v[ 'name' ]);
|
||||
}
|
||||
|
||||
return success('', '刷新成功', '');
|
||||
} catch (\Exception $e) {
|
||||
return error('', 'File:' . $e->getFile() . ',Line:' . $e->getLine() . ',message:' . $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function downComplete()
|
||||
{
|
||||
$system_upgrade_info = session('system_upgrade_info');
|
||||
$upgrade_no = $system_upgrade_info[ 'upgrade_no' ];
|
||||
$download_root = "upload/upgrade/{$upgrade_no}";
|
||||
|
||||
file_put_contents($download_root . '/download.lock', '');
|
||||
}
|
||||
|
||||
public function verificationDown()
|
||||
{
|
||||
$system_upgrade_info = session('system_upgrade_info');
|
||||
$upgrade_no = $system_upgrade_info[ 'upgrade_no' ];
|
||||
$download_root = "upload/upgrade/{$upgrade_no}";
|
||||
|
||||
if (file_exists($download_root . '/download.lock')) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 补丁列表
|
||||
*/
|
||||
public function patchLists()
|
||||
{
|
||||
if(request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$upgrade_model = new UpgradeModel();
|
||||
return $upgrade_model->getPatchLists([
|
||||
'page' => $page,
|
||||
'page_size' => $page_size,
|
||||
]);
|
||||
}else{
|
||||
return $this->fetch('upgrade/patch_lists');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 补丁处理
|
||||
*/
|
||||
public function patchRes()
|
||||
{
|
||||
if(request()->isJson()) {
|
||||
$patch_id = input('patch_id', 0);
|
||||
$patch_res = input('patch_res', '');
|
||||
$upgrade_model = new UpgradeModel();
|
||||
return $upgrade_model->dealPatchRes($patch_id, $patch_res);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 补丁下载
|
||||
*/
|
||||
public function patchDownload()
|
||||
{
|
||||
if(request()->isJson()) {
|
||||
$patch_id = input('patch_id', 0);
|
||||
$patch_link = input('patch_link', '');
|
||||
$upgrade_model = new UpgradeModel();
|
||||
return $upgrade_model->downloadPatch($patch_id, $patch_link);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 需要弹窗提示的补丁列表
|
||||
*/
|
||||
public function patchAlertLists()
|
||||
{
|
||||
if(request()->isJson()) {
|
||||
$upgrade_model = new UpgradeModel();
|
||||
if(Session::get('SYS_PATCH_ALERT')){
|
||||
Session::set('SYS_PATCH_ALERT', false);
|
||||
$list = $upgrade_model->getPatchLists([
|
||||
'page' => 1,
|
||||
'page_size' => 0,
|
||||
])['data']['list'];
|
||||
foreach($list as $key=>$val){
|
||||
if($val['patch_res'] && $val['patch_res']['patch_res'] != 'not') unset($list[$key]);
|
||||
}
|
||||
$list = array_values($list);
|
||||
}else{
|
||||
$list = [];
|
||||
}
|
||||
return $upgrade_model->success($list);
|
||||
}
|
||||
}
|
||||
}
|
||||
460
app/shop/controller/Upload.php
Executable file
460
app/shop/controller/Upload.php
Executable file
@@ -0,0 +1,460 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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_percent = input('watermark_percent', 20);//水印图片缩放比例
|
||||
|
||||
$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_percent' => $watermark_percent,
|
||||
'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 = 1;
|
||||
$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', '');
|
||||
$param = array (
|
||||
'name' => 'file'
|
||||
);
|
||||
$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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
621
app/shop/controller/User.php
Executable file
621
app/shop/controller/User.php
Executable file
@@ -0,0 +1,621 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shop\controller;
|
||||
|
||||
use app\model\store\Store;
|
||||
use app\model\system\Group;
|
||||
use app\model\system\Menu;
|
||||
use app\model\system\User as UserModel;
|
||||
use addon\cashier\model\Group as StoreUserGroup;
|
||||
use app\model\system\UserGroup;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 用户
|
||||
* Class User
|
||||
* @package app\shop\controller
|
||||
*/
|
||||
class User extends BaseShop
|
||||
{
|
||||
/**
|
||||
* 用户列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$status = input('status', '');
|
||||
$search_keys = input('search_keys', '');
|
||||
|
||||
$condition = [];
|
||||
$condition[] = ['', 'exp', Db::raw("uid = ".$this->uid." or create_user_data like '%\"".$this->uid."\"%'")];
|
||||
$condition[] = ['site_id', '=', $this->site_id];
|
||||
$condition[] = ['app_module', '=', $this->app_module];
|
||||
if (!empty($search_keys)) {
|
||||
$condition[] = ['username', 'like', '%' . $search_keys . '%'];
|
||||
}
|
||||
if ($status != '') {
|
||||
$condition['status'] = ['status', '=', $status];
|
||||
}
|
||||
|
||||
$user_model = new UserModel();
|
||||
$list = $user_model->getUserPageList($condition, $page, $page_size, 'create_time desc', '*');
|
||||
if (!empty($list['data']['list']) && addon_is_exit('cashier', $this->site_id)) {
|
||||
$uids = '';
|
||||
foreach ($list['data']['list'] as $k => $v) {
|
||||
if (empty($uids)) {
|
||||
$uids = $v['uid'];
|
||||
} else {
|
||||
$uids = $uids . ',' . $v['uid'];
|
||||
}
|
||||
}
|
||||
$join = [
|
||||
['store s', 's.store_id = ug.store_id', 'left'],
|
||||
['cashier_auth_group cag', 'cag.group_id = ug.group_id', 'left']
|
||||
];
|
||||
$user_group_list = (new UserGroup())->getUserList([['ug.uid', 'in', $uids]], 'ug.uid,s.store_name,cag.group_name', '', 'ug', $join)['data'];
|
||||
foreach ($list['data']['list'] as $k => $v) {
|
||||
$list['data']['list'][$k]['user_group_list'] = [];
|
||||
foreach ($user_group_list as $k_user_group => $v_user_group) {
|
||||
if ($v['uid'] == $v_user_group['uid']) {
|
||||
$list['data']['list'][$k]['user_group_list'][] = $v_user_group;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $list;
|
||||
} else {
|
||||
$this->assign('store_is_exist', addon_is_exit('store', $this->site_id));
|
||||
$this->assign('cashier_is_exist', addon_is_exit('cashier', $this->site_id));
|
||||
return $this->fetch('user/user_list');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加用户
|
||||
* @return mixed
|
||||
*/
|
||||
public function addUser()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
|
||||
$username = input("username", "");
|
||||
$password = input("password", "");
|
||||
$group_id = input("group_id", "");
|
||||
$store = input("store", "[]");
|
||||
|
||||
$user_model = new UserModel();
|
||||
$data = array (
|
||||
"username" => $username,
|
||||
"password" => $password,
|
||||
"group_id" => $group_id,
|
||||
"app_module" => $this->app_module,
|
||||
"site_id" => $this->site_id,
|
||||
"store" => json_decode($store, true),
|
||||
"create_uid" => $this->uid,
|
||||
);
|
||||
|
||||
$result = $user_model->addUser($data, '', 'add');
|
||||
return $result;
|
||||
} else {
|
||||
//当前用户信息
|
||||
$create_user_info = $this->getUserInfo();
|
||||
if(empty($create_user_info)){
|
||||
$this->error('用户信息有误');
|
||||
}
|
||||
$create_user_store_group = array_column($create_user_info['user_group_list'], null, 'store_id');
|
||||
$this->assign('create_user_store_group', $create_user_store_group);
|
||||
|
||||
$group_model = new Group();
|
||||
$group_condition = [
|
||||
['site_id', '=', $this->site_id],
|
||||
['app_module', '=', $this->app_module],
|
||||
['', 'exp', Db::raw("group_id = ".$this->user_info['group_id']." or create_user_data like '%\"".$this->uid."\"%'")],
|
||||
];
|
||||
$group_list_result = $group_model->getGroupList($group_condition);
|
||||
$group_list = $group_list_result['data'];
|
||||
$this->assign('group_list', $group_list);
|
||||
|
||||
$cashier_is_exist = addon_is_exit('cashier', $this->site_id);
|
||||
$this->assign('store_is_exist', addon_is_exit('store', $this->site_id));
|
||||
$this->assign('cashier_is_exist', $cashier_is_exist);
|
||||
if ($cashier_is_exist) {
|
||||
$store_user_group_condition = [
|
||||
['', 'exp', Db::raw("keyword = '' OR site_id = {$this->site_id}")],
|
||||
];
|
||||
if($create_user_info['create_uid'] == 0){
|
||||
$store_user_group_condition[] = ['create_uid', 'in', [0,$this->uid]];
|
||||
}else{
|
||||
$create_user_group_ids = array_column($create_user_info['user_group_list'], 'group_id');
|
||||
if(empty($create_user_group_ids)) $create_user_group_ids = [-1];
|
||||
$create_user_group_ids = join(',', $create_user_group_ids);
|
||||
$store_user_group_condition[] = ['', 'exp', Db::raw("group_id in (".$create_user_group_ids.") or create_uid = ".$create_user_info['uid'])];
|
||||
}
|
||||
$store_user_group = (new StoreUserGroup())->getGroupList($store_user_group_condition, 'group_id,group_name,store_id')['data'];
|
||||
$this->assign('store_user_group', $store_user_group);
|
||||
$store_info = (new Store())->getDefaultStore($this->site_id)['data'] ?? [];
|
||||
$this->assign('default_store_id', $store_info['store_id'] ?? 0);
|
||||
|
||||
//可以管理的门店
|
||||
if($create_user_info['create_uid'] > 0){
|
||||
$store_ids = array_column($create_user_info['user_group_list'], 'store_id');
|
||||
if(empty($store_ids)) $store_ids = [-1];
|
||||
$store_ids = join(',', $store_ids);
|
||||
}else{
|
||||
$store_ids = '';
|
||||
}
|
||||
$this->assign('store_ids', $store_ids);
|
||||
}
|
||||
|
||||
return $this->fetch('user/add_user');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑用户
|
||||
* @return mixed
|
||||
*/
|
||||
public function editUser()
|
||||
{
|
||||
$user_model = new UserModel();
|
||||
if (request()->isJson()) {
|
||||
$group_id = input("group_id", "");
|
||||
$status = input("status", "");
|
||||
$uid = input("uid", 0);
|
||||
$store = input("store", "[]");
|
||||
|
||||
//用户信息
|
||||
$condition = array (
|
||||
['uid', '=', $uid],
|
||||
['site_id', '=', $this->site_id],
|
||||
['app_module', '=', $this->app_module],
|
||||
);
|
||||
$user_info_result = $user_model->getUserInfo($condition, 'is_admin, uid');
|
||||
$user_info = $user_info_result['data'];
|
||||
|
||||
if ($user_info['is_admin']) {
|
||||
return error('-1', '超级管理员不可编辑');
|
||||
}
|
||||
|
||||
$condition = array (
|
||||
['uid', '=', $uid],
|
||||
['site_id', '=', $this->site_id],
|
||||
['app_module', '=', $this->app_module],
|
||||
);
|
||||
$data = array (
|
||||
"group_id" => $group_id,
|
||||
"status" => $status,
|
||||
"store" => json_decode($store, true),
|
||||
);
|
||||
|
||||
$this->addLog('编辑用户:' . $uid);
|
||||
|
||||
$result = $user_model->editUser($data, $condition);
|
||||
return $result;
|
||||
} else {
|
||||
$uid = input('uid', 0);
|
||||
//用户信息
|
||||
$condition = array (
|
||||
['uid', '=', $uid],
|
||||
['site_id', '=', $this->site_id],
|
||||
['app_module', '=', $this->app_module],
|
||||
);
|
||||
$user_info_result = $user_model->getUserInfo($condition, '*');
|
||||
$user_info = $user_info_result['data'];
|
||||
|
||||
if (empty($user_info)) $this->error('未获取到用户数据', href_url('shop/user/user'));
|
||||
if ($user_info['is_admin']) $this->error('超级管理员不可编辑');
|
||||
|
||||
$this->assign('uid', $uid);
|
||||
$this->assign('edit_user_info', $user_info);
|
||||
|
||||
//创建用户数据
|
||||
$create_user_info = $this->getUserInfo($user_info['create_uid']);
|
||||
if(empty($create_user_info)) $create_user_info = ['uid' => $user_info['create_uid'], 'create_uid' => 0, 'group_id' => 0, 'user_group_list' => []];
|
||||
$create_user_store_group = array_column($create_user_info['user_group_list'], null, 'store_id');
|
||||
$this->assign('create_user_store_group', $create_user_store_group);
|
||||
|
||||
//用户组
|
||||
$group_model = new Group();
|
||||
$group_condition = [
|
||||
['site_id', '=', $this->site_id],
|
||||
['app_module', '=', $this->app_module],
|
||||
['', 'exp', Db::raw("group_id = ".$create_user_info['group_id']." or create_user_data like '%\"".$create_user_info['uid']."\"%'")],
|
||||
];
|
||||
$group_list_result = $group_model->getGroupList($group_condition);
|
||||
$group_list = $group_list_result['data'];
|
||||
$this->assign('group_list', $group_list);
|
||||
|
||||
$cashier_is_exist = addon_is_exit('cashier', $this->site_id);
|
||||
$this->assign('store_is_exist', addon_is_exit('store', $this->site_id));
|
||||
$this->assign('cashier_is_exist', $cashier_is_exist);
|
||||
if ($cashier_is_exist) {
|
||||
$store_user_group_condition = [
|
||||
['', 'exp', Db::raw("keyword = '' OR site_id = {$this->site_id}")],
|
||||
];
|
||||
if($create_user_info['create_uid'] == 0){
|
||||
$store_user_group_condition[] = ['create_uid', 'in', [0,$this->uid]];
|
||||
}else{
|
||||
$create_user_group_ids = array_column($create_user_info['user_group_list'], 'group_id');
|
||||
if(empty($create_user_group_ids)) $create_user_group_ids = [-1];
|
||||
$create_user_group_ids = join(',', $create_user_group_ids);
|
||||
$store_user_group_condition[] = ['', 'exp', Db::raw("group_id in (".$create_user_group_ids.") or create_uid = ".$create_user_info['uid'])];
|
||||
}
|
||||
$store_user_group = (new StoreUserGroup())->getGroupList($store_user_group_condition, 'group_id,group_name,store_id')['data'];
|
||||
$this->assign('store_user_group', $store_user_group);
|
||||
$store_info = (new Store())->getDefaultStore($this->site_id)['data'] ?? [];
|
||||
$this->assign('default_store_id', $store_info['store_id'] ?? 0);
|
||||
|
||||
//可以管理的门店
|
||||
if($create_user_info['create_uid'] > 0){
|
||||
$store_ids = array_column($create_user_info['user_group_list'], 'store_id');
|
||||
if(empty($store_ids)) $store_ids = [-1];
|
||||
$store_ids = join(',', $store_ids);
|
||||
}else{
|
||||
$store_ids = '';
|
||||
}
|
||||
$this->assign('store_ids', $store_ids);
|
||||
}
|
||||
|
||||
return $this->fetch('user/edit_user');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
*/
|
||||
public function deleteUser()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$uid = input('uid', 0);
|
||||
$user_model = new UserModel();
|
||||
|
||||
//用户信息
|
||||
$condition = array (
|
||||
['uid', '=', $uid],
|
||||
['site_id', '=', $this->site_id],
|
||||
['app_module', '=', $this->app_module],
|
||||
);
|
||||
$user_info_result = $user_model->getUserInfo($condition, 'is_admin, uid');
|
||||
$user_info = $user_info_result['data'];
|
||||
|
||||
if ($user_info['is_admin']) {
|
||||
return error('-1', '超级管理员不可编辑');
|
||||
}
|
||||
|
||||
$condition = array (
|
||||
['uid', '=', $uid],
|
||||
['app_module', '=', $this->app_module],
|
||||
['site_id', '=', $this->site_id],
|
||||
);
|
||||
$result = $user_model->deleteUser($condition);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
public function childUserCount()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$uid = input('uid', 0);
|
||||
$user_model = new UserModel();
|
||||
$uid_arr = $user_model->getUserColumn([['create_user_data', 'like', '%"'.$uid.'"%']], 'uid');
|
||||
return $user_model->success(count($uid_arr));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除后台所有用户的登录信息
|
||||
*/
|
||||
public function deleteUserLoginInfo()
|
||||
{
|
||||
$app_module = $this->app_module;
|
||||
$site_id = $this->site_id;
|
||||
$user_model = new UserModel();
|
||||
$result = $user_model->deleteUserLoginInfo($app_module, $site_id);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑管理员状态
|
||||
*/
|
||||
public function modifyUserStatus()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$uid = input('uid', 0);
|
||||
$status = input('status', 0);
|
||||
$user_model = new UserModel();
|
||||
|
||||
//用户信息
|
||||
$condition = [
|
||||
['uid', '=', $uid],
|
||||
['site_id', '=', $this->site_id],
|
||||
['app_module', '=', $this->app_module],
|
||||
];
|
||||
$user_info_result = $user_model->getUserInfo($condition, 'is_admin, uid');
|
||||
$user_info = $user_info_result['data'];
|
||||
|
||||
if ($user_info['is_admin']) {
|
||||
return error('-1', '超级管理员不可编辑');
|
||||
}
|
||||
|
||||
$condition = array (
|
||||
['uid', '=', $uid],
|
||||
['site_id', '=', $this->site_id],
|
||||
['app_module', '=', $this->app_module],
|
||||
);
|
||||
$result = $user_model->modifyUserStatus($status, $condition);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
*/
|
||||
public function modifyPassword()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$password = input('password', '123456');
|
||||
$uid = input('uid', 0);
|
||||
$site_id = $this->site_id;
|
||||
$user_model = new UserModel();
|
||||
|
||||
//用户信息
|
||||
$condition = [
|
||||
['uid', '=', $uid],
|
||||
['site_id', '=', $this->site_id],
|
||||
['app_module', '=', $this->app_module]
|
||||
];
|
||||
$user_info_result = $user_model->getUserInfo($condition, 'is_admin, uid');
|
||||
$user_info = $user_info_result['data'];
|
||||
|
||||
if ($user_info['is_admin']) {
|
||||
return error('-1', '超级管理员不可编辑');
|
||||
}
|
||||
|
||||
return $user_model->modifyUserPassword($password, [['uid', '=', $uid], ['site_id', '=', $site_id]]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function group()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$search_keys = input('search_keys', '');
|
||||
|
||||
$condition = [
|
||||
['site_id', '=', $this->site_id],
|
||||
['app_module', '=', $this->app_module],
|
||||
['', 'exp', Db::raw("group_id = ".$this->user_info['group_id']." or create_user_data like '%\"".$this->uid."\"%'")],
|
||||
];
|
||||
$group_model = new Group();
|
||||
$list = $group_model->getGroupPageList($condition, $page, $page_size, 'group_id desc', '*');
|
||||
return $list;
|
||||
} else {
|
||||
return $this->fetch('user/group_list');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加用户组
|
||||
* @return mixed
|
||||
*/
|
||||
public function addGroup()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$group_name = input('group_name', '');
|
||||
$menu_array = input('menu_array', '');
|
||||
$desc = input('desc', '');
|
||||
$group_model = new Group();
|
||||
$data = array (
|
||||
'group_name' => $group_name,
|
||||
'site_id' => $this->site_id,
|
||||
'app_module' => $this->app_module,
|
||||
'group_status' => 1,
|
||||
'menu_array' => $menu_array,
|
||||
'desc' => $desc,
|
||||
'is_system' => 0,
|
||||
'create_time' => time(),
|
||||
'create_uid' => $this->uid,
|
||||
);
|
||||
$result = $group_model->addGroup($data);
|
||||
return $result;
|
||||
} else {
|
||||
$menu_model = new Menu();
|
||||
$condition = [
|
||||
['app_module', '=', $this->app_module],
|
||||
['is_control', '=', 1],
|
||||
];
|
||||
if(!empty($this->group_info['menu_array'])){
|
||||
$condition[] = ['name', 'in', $this->group_info['menu_array']];
|
||||
}
|
||||
$menu_list = $menu_model->getMenuList($condition, '*', 'level asc,sort ASC');
|
||||
$menu_tree = list_to_tree($menu_list['data'], 'name', 'parent', 'child_list', '');
|
||||
$this->assign('tree_data', $menu_tree);
|
||||
return $this->fetch('user/add_group');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑用户组
|
||||
* @return mixed
|
||||
*/
|
||||
public function editGroup()
|
||||
{
|
||||
$group_model = new Group();
|
||||
if (request()->isJson()) {
|
||||
$group_name = input('group_name', '');
|
||||
$menu_array = input('menu_array', '');
|
||||
$group_id = input('group_id', 0);
|
||||
$desc = input('desc', '');
|
||||
|
||||
$data = array (
|
||||
'group_name' => $group_name,
|
||||
'menu_array' => $menu_array,
|
||||
'desc' => $desc,
|
||||
);
|
||||
$condition = array (
|
||||
['group_id', '=', $group_id],
|
||||
['site_id', '=', $this->site_id],
|
||||
['app_module', '=', $this->app_module]
|
||||
);
|
||||
$result = $group_model->editGroup($data, $condition);
|
||||
return $result;
|
||||
} else {
|
||||
$group_id = input('group_id', 0);
|
||||
$condition = array (
|
||||
['group_id', '=', $group_id],
|
||||
['site_id', '=', $this->site_id],
|
||||
['app_module', '=', $this->app_module]
|
||||
);
|
||||
$group_info_result = $group_model->getGroupInfo($condition);
|
||||
$group_info = $group_info_result['data'];
|
||||
|
||||
if (empty($group_info)) $this->error('未获取到用户组数据', href_url('shop/user/group'));
|
||||
|
||||
$this->assign('group_info', $group_info);
|
||||
$this->assign('group_id', $group_id);
|
||||
|
||||
//创建用户
|
||||
$create_user_info = $this->getUserInfo($group_info['create_uid']);
|
||||
$create_user_group_info = $group_model->getGroupInfo([
|
||||
['group_id', '=', $create_user_info['group_id']],
|
||||
['site_id', '=', $this->site_id],
|
||||
['app_module', '=', $this->app_module],
|
||||
])['data'];
|
||||
|
||||
//获取菜单权限
|
||||
$menu_model = new Menu();
|
||||
$condition = [
|
||||
['app_module', '=', $this->app_module],
|
||||
['is_control', '=', 1],
|
||||
];
|
||||
if(!empty($create_user_group_info['menu_array'])){
|
||||
$menu_array = $group_info['menu_array'].','.$create_user_group_info['menu_array'];
|
||||
$menu_array = array_unique(explode(',', $menu_array));
|
||||
$condition[] = ['name', 'in', $menu_array];
|
||||
}
|
||||
$menu_list = $menu_model->getMenuList($condition, '*', 'level asc,sort ASC');
|
||||
|
||||
//处理选中数据
|
||||
$group_array = $group_info['menu_array'];
|
||||
$checked_array = explode(',', $group_array);
|
||||
foreach ($menu_list['data'] as $key => $val) {
|
||||
if (in_array($val['name'], $checked_array)) {
|
||||
$menu_list['data'][$key]['checked'] = true;
|
||||
} else {
|
||||
$menu_list['data'][$key]['checked'] = false;
|
||||
}
|
||||
}
|
||||
$menu_tree = list_to_tree($menu_list['data'], 'name', 'parent', 'child_list', '');
|
||||
$this->assign('tree_data', $menu_tree);
|
||||
|
||||
return $this->fetch('user/edit_group');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户组
|
||||
*/
|
||||
public function deleteGroup()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$group_id = input('group_id', '');
|
||||
$condition = array (
|
||||
['group_id', '=', $group_id],
|
||||
['site_id', '=', $this->site_id],
|
||||
['app_module', '=', $this->app_module],
|
||||
);
|
||||
$group_model = new Group();
|
||||
$result = $group_model->deleteGroup($condition);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户组状态
|
||||
*/
|
||||
public function modifyGroupStatus()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$group_id = input('group_id', 0);
|
||||
$status = input('status', 0);
|
||||
$group_model = new Group();
|
||||
$condition = array (
|
||||
['group_id', '=', $group_id],
|
||||
['site_id', '=', $this->site_id],
|
||||
['app_module', '=', $this->app_module],
|
||||
);
|
||||
$result = $group_model->modifyGroupStatus($status, $condition);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户日志
|
||||
*/
|
||||
public function userLog()
|
||||
{
|
||||
$user_model = new UserModel();
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$uid = input('uid', '0');
|
||||
|
||||
$condition = [];
|
||||
$condition[] = ['site_id', '=', $this->site_id];
|
||||
$search_keys = input('search_keys', '');
|
||||
if (!empty($search_keys)) {
|
||||
$condition[] = ['action_name', 'like', '%' . $search_keys . '%'];
|
||||
}
|
||||
if ($uid > 0) {
|
||||
$condition[] = ['uid', '=', $uid];
|
||||
}
|
||||
|
||||
$list = $user_model->getUserLogPageList($condition, $page, $page_size, 'create_time desc');
|
||||
return $list;
|
||||
} else {
|
||||
//获取站点所有用户
|
||||
$condition = [];
|
||||
$condition[] = ['site_id', '=', $this->site_id];
|
||||
$condition[] = ['app_module', '=', $this->app_module];
|
||||
$user_list_result = $user_model->getUserList($condition);
|
||||
$user_list = $user_list_result['data'];
|
||||
$this->assign('user_list', $user_list);
|
||||
|
||||
return $this->fetch('user/user_log');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除日志
|
||||
*/
|
||||
public function deleteUserLog()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$user_model = new UserModel();
|
||||
$id = input('id', '');
|
||||
$condition = array (
|
||||
['id', 'in', $id],
|
||||
['site_id', '=', $this->site_id],
|
||||
);
|
||||
$res = $user_model->deleteUserLog($condition);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
}
|
||||
545
app/shop/controller/Verify.php
Executable file
545
app/shop/controller/Verify.php
Executable file
@@ -0,0 +1,545 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\shop\controller;
|
||||
|
||||
use app\model\member\Member;
|
||||
use app\model\store\Store;
|
||||
use app\model\verify\Verifier;
|
||||
use app\model\verify\Verify as VerifyModel;
|
||||
use app\model\verify\VerifyRecord;
|
||||
use app\model\web\Config as ConfigModel;
|
||||
|
||||
/**
|
||||
* 核销
|
||||
* Class Verify
|
||||
* @package app\shop\controller
|
||||
*/
|
||||
class Verify extends BaseShop
|
||||
{
|
||||
|
||||
/**
|
||||
* 核销码
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$verify_model = new VerifyModel();
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$order = input('order', 'create_time desc');
|
||||
$verify_type = input('verify_type', '');//验证类型
|
||||
$verify_code = input('verify_code', '');//验证码
|
||||
$verifier_name = input('verifier_name', '');
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
$verify_from = input('verify_from', '');
|
||||
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'is_verify', '=', 1 ]
|
||||
];
|
||||
if (!empty($verify_type)) {
|
||||
$condition[] = ['verify_type', '=', $verify_type ];
|
||||
}
|
||||
if (!empty($verify_from)) {
|
||||
$condition[] = ['verify_from', '=', $verify_from ];
|
||||
}
|
||||
if (!empty($verify_code)) {
|
||||
$condition[] = ['verify_code', 'like', '%' . $verify_code . '%' ];
|
||||
}
|
||||
if (!empty($verifier_name)) {
|
||||
$condition[] = [ 'verifier_name', 'like', '%' . $verifier_name . '%' ];
|
||||
}
|
||||
if (!empty($start_time) && empty($end_time)) {
|
||||
$condition[] = [ 'verify_time', '>=', date_to_time($start_time) ];
|
||||
} elseif (empty($start_time) && !empty($end_time)) {
|
||||
$condition[] = ['verify_time', '<=', date_to_time($end_time) ];
|
||||
} elseif (!empty($start_time) && !empty($end_time)) {
|
||||
$condition[] = [ 'verify_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
|
||||
}
|
||||
$list = $verify_model->getVerifyPageList($condition, $page, $page_size, $order, $field = 'id, verify_code, verify_type, verify_type_name, verify_content_json, verifier_id, verifier_name,verify_from,verify_remark, is_verify, create_time, verify_time');
|
||||
return $list;
|
||||
} else {
|
||||
$verify_type = $verify_model->getVerifyType();
|
||||
$verify_from = $verify_model->verifyFrom;
|
||||
$this->assign('verify_from', $verify_from);
|
||||
$this->assign('verify_type', $verify_type);
|
||||
return $this->fetch('verify/lists');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 核销记录
|
||||
* @return mixed
|
||||
*/
|
||||
public function records()
|
||||
{
|
||||
$verify_model = new VerifyModel();
|
||||
$verify_record_model = new VerifyRecord();
|
||||
$verify_code = input('verify_code', '');//验证码
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$order = input('order', 'create_time desc');
|
||||
$verify_type = input('verify_type', '');//验证类型
|
||||
$verifier_name = input('verifier_name', '');
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
$store_id = input('store_id', '');
|
||||
|
||||
$condition = [
|
||||
[ 'vr.site_id', '=', $this->site_id ],
|
||||
// ['is_verify', '=', 1]
|
||||
];
|
||||
if (!empty($verify_type)) {
|
||||
$condition[] = ['v.verify_type', '=', $verify_type ];
|
||||
}
|
||||
if (!empty($store_id)) {
|
||||
$condition[] = ['vr.store_id', '=', $store_id ];
|
||||
}
|
||||
if (!empty($verify_code)) {
|
||||
$condition[] = ['vr.verify_code', 'like', '%' . $verify_code . '%' ];
|
||||
}
|
||||
if (!empty($verifier_name)) {
|
||||
$condition[] = [ 'vr.verifier_name', 'like', '%' . $verifier_name . '%' ];
|
||||
}
|
||||
if (!empty($start_time) && empty($end_time)) {
|
||||
$condition[] = [ 'vr.verify_time', '>=', date_to_time($start_time) ];
|
||||
} elseif (empty($start_time) && !empty($end_time)) {
|
||||
$condition[] = ['vr.verify_time', '<=', date_to_time($end_time) ];
|
||||
} elseif (!empty($start_time) && !empty($end_time)) {
|
||||
$condition[] = [ 'vr.verify_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
|
||||
}
|
||||
$list = $verify_record_model->getVerifyRecordsViewPageList($condition, $page, $page_size, $order, $field = 'id, verify_code, verify_type, verify_type_name, verify_content_json, verifier_id, verifier_name,verify_from,verify_remark, is_verify, create_time, verify_time');
|
||||
return $list;
|
||||
} else {
|
||||
$verify_type = $verify_model->getVerifyType();
|
||||
$verify_from = $verify_model->verifyFrom;
|
||||
$this->assign('verify_code', $verify_code);
|
||||
$this->assign('verify_from', $verify_from);
|
||||
$this->assign('verify_type', $verify_type);
|
||||
$store_list = ( new Store() )->getStoreList([ [ 'site_id', '=', $this->site_id ] ], 'store_name,store_id');
|
||||
$this->assign('store_list', $store_list[ 'data' ]);
|
||||
return $this->fetch('verify/records');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单核销
|
||||
* @return mixed
|
||||
*/
|
||||
public function orderverify()
|
||||
{
|
||||
$verify_model = new VerifyModel();
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$verify_code = input('verify_code', '');
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
$verify_from = input('verify_from', '');
|
||||
$verify_type = input('verify_type', '');
|
||||
$is_verify = input('is_verify', '');
|
||||
$member_field = input('member_field', '');
|
||||
$member_field_value = input('member_field_value', '');
|
||||
|
||||
$alias = 'v';
|
||||
$join = [
|
||||
['member m', 'm.member_id = v.member_id', 'inner'],
|
||||
];
|
||||
$condition = [
|
||||
[ 'v.site_id', '=', $this->site_id ],
|
||||
|
||||
];
|
||||
if (!empty($verify_type)) {
|
||||
$condition[] = ['v.verify_type', '=', $verify_type ];
|
||||
}
|
||||
if ($is_verify !== '') {
|
||||
$condition[] = ['v.is_verify', '=', $is_verify ];
|
||||
}
|
||||
if (!empty($verify_from)) {
|
||||
$condition[] = ['v.verify_from', '=', $verify_from ];
|
||||
}
|
||||
if (!empty($verify_code)) {
|
||||
$condition[] = ['v.verify_code', 'like', '%' . $verify_code . '%' ];
|
||||
}
|
||||
|
||||
if (!empty($start_time) && empty($end_time)) {
|
||||
$condition[] = [ 'v.create_time', '>=', date_to_time($start_time) ];
|
||||
} elseif (empty($start_time) && !empty($end_time)) {
|
||||
$condition[] = ['v.create_time', '<=', date_to_time($end_time) ];
|
||||
} elseif (!empty($start_time) && !empty($end_time)) {
|
||||
$condition[] = [ 'v.create_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
|
||||
}
|
||||
switch($member_field){
|
||||
case 'nickname':
|
||||
$condition[] = ['m.nickname', 'like', '%'.$member_field_value.'%'];
|
||||
break;
|
||||
case 'mobile':
|
||||
$condition[] = ['m.mobile', '=', $member_field_value];
|
||||
break;
|
||||
}
|
||||
|
||||
$list = $verify_model->getVerifyPageList($condition, $page, $page_size, 'v.id desc','v.*', $alias, $join);
|
||||
return $list;
|
||||
} else {
|
||||
$verify_type = $verify_model->getVerifyType();
|
||||
$this->assign('verify_type', $verify_type);
|
||||
$status_list = $verify_model::getStatus();
|
||||
$this->assign('status_list', $status_list);
|
||||
return $this->fetch('verify/order_verify');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 核销信息
|
||||
*/
|
||||
public function verifyInfo()
|
||||
{
|
||||
$id = input('id', '');
|
||||
|
||||
$verify_model = new VerifyModel();
|
||||
$info = $verify_model->getVerifyInfo([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* 核销台
|
||||
* @return mixed
|
||||
*/
|
||||
public function verifyCard()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$verify_code = input('verify_code', '');
|
||||
$verify_model = new VerifyModel();
|
||||
$res = $verify_model->getVerifyInfo([ ['verify_code', '=', $verify_code ], ['site_id', '=', $this->site_id ] ]);
|
||||
return $res;
|
||||
} else {
|
||||
return $this->fetch('verify/verify_card');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 核销人员
|
||||
* @return mixed
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$verifier = new Verifier();
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$order = input('order', 'v.create_time desc');
|
||||
$verifier_name = input('verifier_name', '');
|
||||
$verifier_type = input('verifier_type', 0);
|
||||
$store_id = input('store_id', 0);
|
||||
$condition = [];
|
||||
$condition[] = [ 'v.site_id', '=', $this->site_id ];
|
||||
if ($verifier_name) {
|
||||
$condition[] = [ 'v.verifier_name', '=', $verifier_name ];
|
||||
}
|
||||
if ($verifier_type != '') {
|
||||
$condition[] = [ 'v.verifier_type', '=', $verifier_type ];
|
||||
}
|
||||
if ($store_id) {
|
||||
$condition[] = [ 'v.store_id', '=', $store_id ];
|
||||
}
|
||||
$list = $verifier->getVerifierPageList($condition, $page, $page_size, $order);
|
||||
return $list;
|
||||
} else {
|
||||
// 门店列表
|
||||
$store_model = new Store();
|
||||
$store_list = $store_model->getStoreList([ [ 'site_id', '=', $this->site_id ], [ 'is_frozen', '=', 0 ] ], 'store_id,store_name', 'store_id desc')[ 'data' ];
|
||||
$this->assign('store_list', $store_list);
|
||||
return $this->fetch('verify/user');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加核销人员
|
||||
* @return mixed
|
||||
*/
|
||||
public function addUser()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$verifier_name = input('verifier_name', '');
|
||||
$member_id = input('member_id', 0);//会员账号
|
||||
$uid = input('uid', 0);//管理员账号
|
||||
$verifier_type = input('verifier_type', 0);//核销员类型:0平台核销员,1门店核销员
|
||||
$store_id = input('store_id', 0);//门店ID
|
||||
$model = new Verifier();
|
||||
$data = [
|
||||
'site_id' => $this->site_id,
|
||||
'verifier_name' => $verifier_name,
|
||||
'member_id' => $member_id,
|
||||
'uid' => $uid,
|
||||
'verifier_type' => $verifier_type,
|
||||
'store_id' => $store_id
|
||||
];
|
||||
$result = $model->addVerifier($data);
|
||||
return $result;
|
||||
} else {
|
||||
$upload_config_model = new ConfigModel();
|
||||
$upload_config_result = $upload_config_model->getDefaultImg($this->site_id, $this->app_module)[ 'data' ][ 'value' ];
|
||||
$this->assign('default_headimg', $upload_config_result[ 'head' ]);
|
||||
|
||||
// 门店列表
|
||||
$store_model = new Store();
|
||||
$store_list = $store_model->getStoreList([ [ 'site_id', '=', $this->site_id ], [ 'is_frozen', '=', 0 ] ], 'store_id,store_name', 'store_id desc')[ 'data' ];
|
||||
$this->assign('store_list', $store_list);
|
||||
|
||||
return $this->fetch('verify/add_user');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑核销人员
|
||||
* @return mixed
|
||||
*/
|
||||
public function editUser()
|
||||
{
|
||||
$verifier_id = input('verifier_id', 0);//核销员id
|
||||
$model = new Verifier();
|
||||
|
||||
if (request()->isJson()) {
|
||||
$verifier_name = input('verifier_name', '');
|
||||
$member_id = input('member_id', 0);//会员账号
|
||||
$verifier_type = input('verifier_type', 0);//核销员类型:0平台核销员,1门店核销员
|
||||
$store_id = input('store_id', 0);//门店ID
|
||||
$data = [
|
||||
'verifier_name' => $verifier_name,
|
||||
'member_id' => $member_id,
|
||||
'uid' => 0,
|
||||
'verifier_type' => $verifier_type,
|
||||
'store_id' => $verifier_type == 1 ? $store_id : 0
|
||||
];
|
||||
$condition = array (
|
||||
[ 'verifier_id', '=', $verifier_id ],
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
);
|
||||
|
||||
$result = $model->editVerifier($data, $condition);
|
||||
return $result;
|
||||
} else {
|
||||
$this->assign('verifier_id', $verifier_id);
|
||||
|
||||
//用户信息
|
||||
$info = $model->getVerifierInfo([
|
||||
['verifier_id', '=', $verifier_id ],
|
||||
['site_id', '=', $this->site_id ],
|
||||
])[ 'data' ];
|
||||
|
||||
if (empty($info)) $this->error('未获取到核销员数据', href_url('shop/verify/user'));
|
||||
|
||||
$info['member_name'] = '';
|
||||
if (!empty($info['member_id'])) {
|
||||
$member_model = new Member();
|
||||
$member_info = $member_model->getMemberInfo([ ['member_id', '=', $info['member_id'] ] ], 'username,mobile')['data'];
|
||||
$info['member_name'] = $member_info['username'] ? $member_info['username'] : $member_info['mobile'];
|
||||
}
|
||||
|
||||
if ($info[ 'verifier_type' ] == 1) {
|
||||
// 门店列表
|
||||
$store_model = new Store();
|
||||
$store = $store_model->getStoreInfo([ [ 'store_id', '=', $info[ 'store_id' ] ] ], 'store_name')[ 'data' ];
|
||||
$info[ 'store_name' ] = $store[ 'store_name' ];
|
||||
}
|
||||
|
||||
$this->assign('data', $info);
|
||||
|
||||
$upload_config_model = new ConfigModel();
|
||||
$upload_config_result = $upload_config_model->getDefaultImg($this->site_id, $this->app_module)[ 'data' ][ 'value' ];
|
||||
$this->assign('default_headimg', $upload_config_result[ 'head' ]);
|
||||
|
||||
// 门店列表
|
||||
$store_model = new Store();
|
||||
$store_list = $store_model->getStoreList([ [ 'site_id', '=', $this->site_id ], [ 'is_frozen', '=', 0 ] ], 'store_id,store_name', 'store_id desc')[ 'data' ];
|
||||
$this->assign('store_list', $store_list);
|
||||
|
||||
return $this->fetch('verify/edit_user');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除核销人员
|
||||
* @return mixed
|
||||
*/
|
||||
public function deleteUser()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$verifier = new Verifier();
|
||||
$verifier_id = input('ids', 0);
|
||||
$res = $verifier->deleteVerifier($verifier_id, $this->site_id);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 核销
|
||||
*/
|
||||
public function verify()
|
||||
{
|
||||
$info = array (
|
||||
'verifier_id' => $this->uid,
|
||||
'verifier_name' => $this->user_info[ 'username' ],
|
||||
'verify_from' => 'shop'
|
||||
);
|
||||
$verify_code = input('verify_code', '');
|
||||
$verify_model = new VerifyModel();
|
||||
$res = $verify_model->verify($info, $verify_code);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索会员
|
||||
* 不是菜单 不入权限
|
||||
*/
|
||||
public function searchMember()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$search_text = input('search_text', '');
|
||||
$member_model = new Member();
|
||||
$member_info = $member_model->getMemberInfo([ [ 'username|mobile', '=', $search_text ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
return $member_info;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 核销记录导出
|
||||
*/
|
||||
public function exportVerify()
|
||||
{
|
||||
$verify_model = new VerifyModel();
|
||||
$page = input('page', 1);
|
||||
$page_size = 0;
|
||||
$order = input('order', 'create_time desc');
|
||||
$verify_type = input('verify_type', '');//验证类型
|
||||
$verify_code = input('verify_code', '');//验证码
|
||||
$verifier_name = input('verifier_name', '');
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'is_verify', '=', 1 ]
|
||||
];
|
||||
if (!empty($verify_type)) {
|
||||
$condition[] = ['verify_type', '=', $verify_type ];
|
||||
}
|
||||
if (!empty($verify_code)) {
|
||||
$condition[] = ['verify_code', 'like', '%' . $verify_code . '%' ];
|
||||
}
|
||||
if (!empty($verifier_name)) {
|
||||
$condition[] = [ 'verifier_name', 'like', '%' . $verifier_name . '%' ];
|
||||
}
|
||||
if (!empty($start_time) && empty($end_time)) {
|
||||
$condition[] = [ 'verify_time', '>=', date_to_time($start_time) ];
|
||||
} elseif (empty($start_time) && !empty($end_time)) {
|
||||
$condition[] = ['verify_time', '<=', date_to_time($end_time) ];
|
||||
} elseif (!empty($start_time) && !empty($end_time)) {
|
||||
$condition[] = [ 'verify_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
|
||||
}
|
||||
$list_result = $verify_model->getVerifyPageList($condition, $page, $page_size, $order, $field = 'id, verify_code, verify_type, verify_type_name, verify_content_json, verifier_id, verifier_name, is_verify, create_time, verify_time');
|
||||
$list = $list_result[ 'data' ][ 'list' ];
|
||||
|
||||
// 实例化excel
|
||||
$phpExcel = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
|
||||
$phpExcel->getProperties()->setTitle('核销记录');
|
||||
$phpExcel->getProperties()->setSubject('核销记录');
|
||||
//单独添加列名称
|
||||
$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', '核销时间');
|
||||
|
||||
if (!empty($list)) {
|
||||
foreach ($list as $k => $v) {
|
||||
$start = $k + 2;
|
||||
$phpExcel->getActiveSheet()->setCellValue('A' . $start, $v[ 'verify_code' ] . "\t");
|
||||
$phpExcel->getActiveSheet()->setCellValue('B' . $start, $v[ 'verify_type_name' ] . "\t");
|
||||
$phpExcel->getActiveSheet()->setCellValue('C' . $start, $v[ 'verifier_name' ] . "\t");
|
||||
if ($v[ 'is_verify' ] == 1) {
|
||||
$verify_status = '已核销';
|
||||
} else {
|
||||
$verify_status = '尚未核销';
|
||||
}
|
||||
$phpExcel->getActiveSheet()->setCellValue('D' . $start, $verify_status . "\t");
|
||||
$phpExcel->getActiveSheet()->setCellValue('E' . $start, time_to_date($v[ 'create_time' ]) . "\t");
|
||||
$phpExcel->getActiveSheet()->setCellValue('F' . $start, time_to_date($v[ 'verify_time' ]) . "\t");
|
||||
}
|
||||
}
|
||||
|
||||
// 重命名工作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 stat()
|
||||
{
|
||||
$data = [
|
||||
'total_count' => 0,
|
||||
'verify_use_num' => 0,
|
||||
'verify_goods_num' => 0,
|
||||
'verify_goods_count' => 0,
|
||||
'pickup_num' => 0,
|
||||
'pickup_count' => 0,
|
||||
'card_goods_num' => 0,
|
||||
'card_goods_count' => 0
|
||||
];
|
||||
$verify_model = new VerifyModel();
|
||||
$verify_count = $verify_model->getVerifyInfo([ [ 'site_id', '=', $this->site_id ] ], 'count(id) as total_count, sum(verify_use_num) as verify_use_num,is_verify,verify_content_json')[ 'data' ] ?? [];
|
||||
$data['total_count'] = $verify_count[ 'total_count' ] ?? 0;
|
||||
$data['verify_use_num'] = $verify_count[ 'verify_use_num' ] ?? 0;
|
||||
|
||||
$verify_info = $verify_model->getVerifyInfo([ [ 'site_id', '=', $this->site_id ], [ 'verify_type', '=', 'virtualgoods' ] ], 'count(id) as total_count, sum(verify_total_count) as verify_total_count, sum(verify_use_num) as verify_use_num,is_verify,verify_content_json')[ 'data' ] ?? [];
|
||||
$data['verify_goods_num'] = (int) abs($verify_info[ 'verify_total_count' ] - $verify_info[ 'verify_use_num' ]);
|
||||
$data['verify_goods_count'] = $verify_info[ 'total_count' ];
|
||||
|
||||
$verify_info = $verify_model->getVerifyInfo([ [ 'site_id', '=', $this->site_id ], [ 'verify_type', '=', 'pickup' ] ], 'count(id) as total_count,sum(verify_total_count) as verify_total_count, sum(verify_use_num) as verify_use_num,is_verify,verify_content_json')[ 'data' ] ?? [];
|
||||
$data['pickup_num'] = (int) abs($verify_info[ 'verify_total_count' ] - $verify_info[ 'verify_use_num' ]);
|
||||
$data['pickup_count'] = $verify_info[ 'total_count' ];
|
||||
|
||||
$card_goods_count = $verify_model->getVerifyCount([ [ 'site_id', '=', $this->site_id ], [ 'verify_type', '=', 'cardgoods' ] ], 'id')[ 'data' ] ?? [];
|
||||
$verify_info = $verify_model->getVerifyInfo([ [ 'site_id', '=', $this->site_id ], [ 'verify_type', '=', 'cardgoods' ], [ 'verify_total_count', '>', 0 ] ], 'sum(verify_total_count) as verify_total_count, sum(verify_use_num) as verify_use_num,is_verify,verify_content_json')[ 'data' ] ?? [];
|
||||
$card_goods_num = (int) abs($verify_info[ 'verify_total_count' ] - $verify_info[ 'verify_use_num' ]);
|
||||
$card_goods_num += $verify_model->getVerifyCount([ [ 'site_id', '=', $this->site_id ], [ 'verify_type', '=', 'cardgoods' ], [ 'verify_total_count', '=', 0 ], [ 'expire_time', '>', 0 ], [ 'expire_time', '<', time() ] ], 'id')[ 'data' ];
|
||||
$data['card_goods_num'] = $card_goods_num;
|
||||
$data['card_goods_count'] = $card_goods_count;
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
339
app/shop/controller/Virtualgoods.php
Executable file
339
app/shop/controller/Virtualgoods.php
Executable file
@@ -0,0 +1,339 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
166
app/shop/controller/Virtualorder.php
Executable file
166
app/shop/controller/Virtualorder.php
Executable file
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
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
|
||||
);
|
||||
$log_data = [
|
||||
'uid' => $this->user_info[ 'uid' ],
|
||||
'nick_name' => $this->user_info[ 'username' ],
|
||||
'action' => '商家对订单进行了发货',
|
||||
'action_way' => 2,
|
||||
];
|
||||
$result = $virtual_order_model->virtualDelivery($params, $log_data);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user