筛选加个
parent
5563e22e8d
commit
d548d90f27
|
|
@ -1,7 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\service\ScreeningPriceService;
|
||||
|
||||
/**
|
||||
* 筛选价格管理
|
||||
* @author Devil
|
||||
|
|
@ -39,8 +40,10 @@ class ScreeningPrice extends Common
|
|||
*/
|
||||
public function Index()
|
||||
{
|
||||
// 是否启用
|
||||
$this->assign('common_is_enable_list', lang('common_is_enable_list'));
|
||||
$this->display('Index');
|
||||
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -58,54 +61,15 @@ class ScreeningPrice extends Common
|
|||
$this->error('非法访问');
|
||||
}
|
||||
|
||||
// 获取数据
|
||||
$field = array('id', 'name', 'sort', 'is_enable', 'min_price', 'max_price');
|
||||
$data = db('ScreeningPrice')->field($field)->where(array('pid'=>intval(I('id', 0))))->select();
|
||||
if(!empty($data))
|
||||
{
|
||||
foreach($data as $k=>$v)
|
||||
{
|
||||
$alias = '';
|
||||
if(!empty($v['min_price']) && !empty($v['max_price']))
|
||||
{
|
||||
$alias = $v['min_price'].'-'.$v['max_price'];
|
||||
}
|
||||
if(empty($v['min_price']) && !empty($v['max_price']))
|
||||
{
|
||||
$alias = $v['max_price'].'以下';
|
||||
}
|
||||
if(!empty($v['min_price']) && empty($v['max_price']))
|
||||
{
|
||||
$alias = $v['min_price'].'以上';
|
||||
}
|
||||
$alias = empty($alias) ? '' : '<span class="mini-tips-text">('.$alias.')</span>';
|
||||
$data[$k]['name_alias'] = $v['name'].' '.$alias;
|
||||
$data[$k]['is_son'] = $this->IsExistSon($v['id']);
|
||||
$data[$k]['ajax_url'] = url('Admin/ScreeningPrice/GetNodeSon', array('id'=>$v['id']));
|
||||
$data[$k]['delete_url'] = url('Admin/ScreeningPrice/Delete');
|
||||
$data[$k]['json'] = json_encode($v);
|
||||
}
|
||||
}
|
||||
$msg = empty($data) ? '没有相关数据' : '操作成功';
|
||||
$this->ajaxReturn($msg, 0, $data);
|
||||
}
|
||||
// 开始操作
|
||||
$ret = ScreeningPriceService::ScreeningPriceNodeSon(input());
|
||||
return json($ret);
|
||||
|
||||
/**
|
||||
* [IsExistSon 节点是否存在子数据]
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-25T15:22:47+0800
|
||||
* @param [int] $id [节点id]
|
||||
* @return [string] [有数据ok, 则no]
|
||||
*/
|
||||
private function IsExistSon($id)
|
||||
{
|
||||
if(!empty($id))
|
||||
// 是否ajax请求
|
||||
if(!IS_AJAX)
|
||||
{
|
||||
return (db('ScreeningPrice')->where(array('pid'=>$id))->count() > 0) ? 'ok' : 'no';
|
||||
$this->error('非法访问');
|
||||
}
|
||||
return 'no';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -123,54 +87,9 @@ class ScreeningPrice extends Common
|
|||
$this->error('非法访问');
|
||||
}
|
||||
|
||||
// id为空则表示是新增
|
||||
$m = D('ScreeningPrice');
|
||||
|
||||
// 公共额外数据处理
|
||||
$m->sort = intval(I('sort'));
|
||||
|
||||
// 添加
|
||||
if(empty($_POST['id']))
|
||||
{
|
||||
if($m->create($_POST, 1))
|
||||
{
|
||||
// 额外数据处理
|
||||
$m->add_time = time();
|
||||
$m->min_price = intval(I('min_price'));
|
||||
$m->max_price = intval(I('max_price'));
|
||||
$m->name = I('name');
|
||||
|
||||
// 写入数据库
|
||||
if($m->add())
|
||||
{
|
||||
$this->ajaxReturn('新增成功');
|
||||
} else {
|
||||
$this->ajaxReturn('新增失败', -100);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 编辑
|
||||
if($m->create($_POST, 2))
|
||||
{
|
||||
// 额外数据处理
|
||||
$m->name = I('name');
|
||||
$m->min_price = intval(I('min_price'));
|
||||
$m->max_price = intval(I('max_price'));
|
||||
$m->upd_time = time();
|
||||
|
||||
// 移除 id
|
||||
unset($m->id);
|
||||
|
||||
// 更新数据库
|
||||
if($m->where(array('id'=>I('id')))->save())
|
||||
{
|
||||
$this->ajaxReturn('编辑成功');
|
||||
} else {
|
||||
$this->ajaxReturn('编辑失败或数据未改变', -100);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->ajaxReturn($m->getError(), -1);
|
||||
// 开始操作
|
||||
$ret = ScreeningPriceService::ScreeningPriceSave(input());
|
||||
return json($ret);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -182,23 +101,17 @@ class ScreeningPrice extends Common
|
|||
*/
|
||||
public function Delete()
|
||||
{
|
||||
// 是否ajax
|
||||
if(!IS_AJAX)
|
||||
{
|
||||
$this->error('非法访问');
|
||||
return $this->error('非法访问');
|
||||
}
|
||||
|
||||
$m = D('ScreeningPrice');
|
||||
if($m->create($_POST, 5))
|
||||
{
|
||||
if($m->delete(I('id')))
|
||||
{
|
||||
$this->ajaxReturn('删除成功');
|
||||
} else {
|
||||
$this->ajaxReturn('删除失败或资源不存在', -100);
|
||||
}
|
||||
} else {
|
||||
$this->ajaxReturn($m->getError(), -1);
|
||||
}
|
||||
// 开始操作
|
||||
$params = input('post.');
|
||||
$params['admin'] = $this->admin;
|
||||
$ret = ScreeningPriceService::ScreeningPriceDelete($params);
|
||||
return json($ret);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -130,7 +130,7 @@
|
|||
<ul class="plug-file-upload-view goods-recommended-images-view" data-form-name="home_recommended_images" data-max-number="1" data-dialog-type="images">
|
||||
{{if !empty($data['home_recommended_images'])}}
|
||||
<li>
|
||||
<input type="hidden" name="home_recommended_images" value="{{$data.home_recommended_images}}" />
|
||||
<input type="text" name="home_recommended_images" value="{{$data.home_recommended_images}}" />
|
||||
<img src="{{$data.home_recommended_images}}" />
|
||||
<i>×</i>
|
||||
</li>
|
||||
|
|
@ -254,7 +254,7 @@
|
|||
{{if !empty($data['photo'])}}
|
||||
{{foreach $data.photo as $v}}
|
||||
<li>
|
||||
<input type="hidden" name="photo[]" value="{{$v.images_old}}" />
|
||||
<input type="text" name="photo[]" value="{{$v.images_old}}" />
|
||||
<img src="{{$v.images}}" />
|
||||
<i>×</i>
|
||||
</li>
|
||||
|
|
@ -272,7 +272,7 @@
|
|||
<ul class="plug-file-upload-view plug-file-upload-view-video goods-video-view" data-form-name="video" data-max-number="1" data-dialog-type="video">
|
||||
{{if !empty($data['video'])}}
|
||||
<li>
|
||||
<input type="hidden" name="video" value="{{$data.video}}" />
|
||||
<input type="text" name="video" value="{{$data.video}}" />
|
||||
<video src="{{$data.video}}" controls>your browser does not support the video tag</video>
|
||||
<i>×</i>
|
||||
</li>
|
||||
|
|
@ -295,7 +295,7 @@
|
|||
<ul class="plug-file-upload-view goods-content-app-images-view-{{$v.id}}" data-form-name="content_app_images_{{$v.id}}" data-max-number="1" data-dialog-type="images">
|
||||
{{if !empty($v['images'])}}
|
||||
<li>
|
||||
<input type="hidden" name="content_app_images_{{$v.id}}" value="{{$v.images_old}}" />
|
||||
<input type="text" name="content_app_images_{{$v.id}}" value="{{$v.images_old}}" />
|
||||
<img src="{{$v.images}}" />
|
||||
<i>×</i>
|
||||
</li>
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@
|
|||
<label>顺序</label>
|
||||
<input type="number" placeholder="顺序" name="sort" min="0" max="255" data-validation-message="顺序 0~255 之间的数值" class="am-radius" value="0" required />
|
||||
</div>
|
||||
<include file="Lib/Enable" />
|
||||
{{include file="lib/enable" /}}
|
||||
<div class="am-form-group">
|
||||
<input type="hidden" name="id" />
|
||||
<input type="hidden" name="pid" value="0" />
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
<label>顺序</label>
|
||||
<input type="number" placeholder="顺序" name="sort" min="0" max="255" data-validation-message="顺序 0~255 之间的数值" class="am-radius" value="0" required />
|
||||
</div>
|
||||
<include file="Lib/Enable" />
|
||||
{{include file="lib/enable" /}}
|
||||
<div class="am-form-group">
|
||||
<input type="hidden" name="id" />
|
||||
<button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm w100" data-am-loading="{loadingText:'处理中...'}">保存</button>
|
||||
|
|
@ -51,7 +51,7 @@
|
|||
<!-- list start -->
|
||||
<div id="tree" class="m-t-15" data-additional='[{"field":"min_price", "value":"0", "type":"input"}, {"field":"max_price", "value":"0", "type":"input"}]'>
|
||||
<div class="m-t-30 t-c">
|
||||
<img src="__PUBLIC__/Common/Images/loading.gif" />
|
||||
<img src="{{$image_host}}/static/common/images/loading.gif" />
|
||||
<p>处理中...</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -64,5 +64,5 @@
|
|||
{{include file="public/footer" /}}
|
||||
<!-- footer end -->
|
||||
<script>
|
||||
Tree(0, "{{:url('Admin/ScreeningPrice/GetNodeSon')}}", 0);
|
||||
Tree(0, "{{:url('admin/screeningprice/getnodeson')}}", 0);
|
||||
</script>
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
|
||||
namespace app\service;
|
||||
|
||||
use think\Db;
|
||||
|
|
|
|||
|
|
@ -987,12 +987,12 @@ class GoodsService
|
|||
'give_integral' => intval($params['give_integral']),
|
||||
'buy_min_number' => intval($params['buy_min_number']),
|
||||
'buy_max_number' => intval($params['buy_max_number']),
|
||||
'is_deduction_inventory' => intval($params['is_deduction_inventory']),
|
||||
'is_shelves' => intval($params['is_shelves']),
|
||||
'is_deduction_inventory' => isset($params['is_deduction_inventory']) ? intval($params['is_deduction_inventory']) : 0,
|
||||
'is_shelves' => isset($params['is_shelves']) ? intval($params['is_shelves']) : 0,
|
||||
'content_web' => ResourcesService::ContentStaticReplace($params['content_web'], 'add'),
|
||||
'images' => isset($photo['data'][0]) ? $photo['data'][0] : '',
|
||||
'photo_count' => count($photo['data']),
|
||||
'is_home_recommended' => intval($params['is_home_recommended']),
|
||||
'is_home_recommended' => isset($params['is_home_recommended']) ? intval($params['is_home_recommended']) : 0,
|
||||
'home_recommended_images' => $attachment['data']['home_recommended_images'],
|
||||
'brand_id' => intval($params['brand_id']),
|
||||
'video' => $attachment['data']['video'],
|
||||
|
|
@ -1174,9 +1174,9 @@ class GoodsService
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if(empty($data[0][0]))
|
||||
if(empty($data[0][0]) || $data[0][0] <= 0)
|
||||
{
|
||||
return DataReturn('请填写规格销售价格', -1);
|
||||
return DataReturn('请填写有效的规格销售价格', -1);
|
||||
}
|
||||
if(empty($data[0][1]))
|
||||
{
|
||||
|
|
@ -1201,6 +1201,11 @@ class GoodsService
|
|||
*/
|
||||
private static function GetFormGoodsPhotoParams($params = [])
|
||||
{
|
||||
if(empty($params['photo']))
|
||||
{
|
||||
return DataReturn('请上传相册', -1);
|
||||
}
|
||||
|
||||
$result = [];
|
||||
if(!empty($params['photo']) && is_array($params['photo']))
|
||||
{
|
||||
|
|
@ -1905,6 +1910,7 @@ class GoodsService
|
|||
'bg_color' => isset($params['bg_color']) ? $params['bg_color'] : '',
|
||||
'is_home_recommended' => isset($params['is_home_recommended']) ? intval($params['is_home_recommended']) : 0,
|
||||
'sort' => isset($params['sort']) ? intval($params['sort']) : 0,
|
||||
'is_enable' => isset($params['is_enable']) ? intval($params['is_enable']) : 0,
|
||||
'icon' => $attachment['data']['icon'],
|
||||
'big_images' => $attachment['data']['big_images'],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -0,0 +1,144 @@
|
|||
<?php
|
||||
namespace app\service;
|
||||
|
||||
|
||||
/**
|
||||
* 筛选价格服务层
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-01T21:51:08+0800
|
||||
*/
|
||||
class ScreeningPriceService
|
||||
{
|
||||
/**
|
||||
* 获取节点数据
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2018-12-16T23:54:46+0800
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function ScreeningPriceNodeSon($params = [])
|
||||
{
|
||||
// id
|
||||
$id = isset($params['id']) ? intval($params['id']) : 0;
|
||||
|
||||
// 获取数据
|
||||
$field = 'id,name,sort,is_enable,min_price,max_price';
|
||||
$data = db('ScreeningPrice')->field($field)->where(['pid'=>$id])->select();
|
||||
if(!empty($data))
|
||||
{
|
||||
$image_host = config('IMAGE_HOST');
|
||||
foreach($data as &$v)
|
||||
{
|
||||
$v['is_son'] = (db('ScreeningPrice')->where(['pid'=>$v['id']])->count() > 0) ? 'ok' : 'no';
|
||||
$v['ajax_url'] = url('admin/screeningprice/getnodeson', array('id'=>$v['id']));
|
||||
$v['delete_url'] = url('admin/screeningprice/delete');
|
||||
$v['json'] = json_encode($v);
|
||||
}
|
||||
return DataReturn('操作成功', 0, $data);
|
||||
}
|
||||
return DataReturn('没有相关数据', -100);
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据保存
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2018-12-17T01:04:03+0800
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function ScreeningPriceSave($params = [])
|
||||
{
|
||||
// 请求参数
|
||||
$p = [
|
||||
[
|
||||
'checked_type' => 'length',
|
||||
'key_name' => 'name',
|
||||
'checked_data' => '2,16',
|
||||
'error_msg' => '名称格式 2~16 个字符',
|
||||
],
|
||||
];
|
||||
$ret = params_checked($params, $p);
|
||||
if($ret !== true)
|
||||
{
|
||||
return DataReturn($ret, -1);
|
||||
}
|
||||
|
||||
// 其它附件
|
||||
$data_fields = ['icon', 'big_images'];
|
||||
$attachment = ResourcesService::AttachmentParams($params, $data_fields);
|
||||
if($attachment['code'] != 0)
|
||||
{
|
||||
return $attachment;
|
||||
}
|
||||
|
||||
// 数据
|
||||
$data = [
|
||||
'name' => $params['name'],
|
||||
'pid' => isset($params['pid']) ? intval($params['pid']) : 0,
|
||||
'min_price' => intval($params['min_price']),
|
||||
'max_price' => intval($params['max_price']),
|
||||
'sort' => isset($params['sort']) ? intval($params['sort']) : 0,
|
||||
'is_enable' => isset($params['is_enable']) ? intval($params['is_enable']) : 0,
|
||||
];
|
||||
|
||||
// 添加
|
||||
if(empty($params['id']))
|
||||
{
|
||||
$data['add_time'] = time();
|
||||
if(db('ScreeningPrice')->insertGetId($data) > 0)
|
||||
{
|
||||
return DataReturn('添加成功', 0);
|
||||
}
|
||||
return DataReturn('添加失败', -100);
|
||||
} else {
|
||||
$data['upd_time'] = time();
|
||||
if(db('ScreeningPrice')->where(['id'=>intval($params['id'])])->update($data))
|
||||
{
|
||||
return DataReturn('编辑成功', 0);
|
||||
}
|
||||
return DataReturn('编辑失败', -100);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2018-12-17T02:40:29+0800
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function ScreeningPriceDelete($params = [])
|
||||
{
|
||||
// 请求参数
|
||||
$p = [
|
||||
[
|
||||
'checked_type' => 'empty',
|
||||
'key_name' => 'id',
|
||||
'error_msg' => '删除数据id有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'empty',
|
||||
'key_name' => 'admin',
|
||||
'error_msg' => '用户信息有误',
|
||||
],
|
||||
];
|
||||
$ret = params_checked($params, $p);
|
||||
if($ret !== true)
|
||||
{
|
||||
return DataReturn($ret, -1);
|
||||
}
|
||||
|
||||
// 开始删除
|
||||
if(db('ScreeningPrice')->where(['id'=>intval($params['id'])])->delete())
|
||||
{
|
||||
return DataReturn('删除成功', 0);
|
||||
}
|
||||
return DataReturn('删除失败', 0);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -148,12 +148,6 @@ class SlideService
|
|||
*/
|
||||
public static function SlideSave($params = [])
|
||||
{
|
||||
// 是否启用值处理
|
||||
if(!isset($params['is_enable']))
|
||||
{
|
||||
$params['is_enable'] = 0;
|
||||
}
|
||||
|
||||
// 请求类型
|
||||
$p = [
|
||||
[
|
||||
|
|
@ -192,12 +186,6 @@ class SlideService
|
|||
'checked_data' => '3',
|
||||
'error_msg' => '顺序 0~255 之间的数值',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'in',
|
||||
'key_name' => 'is_enable',
|
||||
'checked_data' => [0,1],
|
||||
'error_msg' => '是否显示范围值有误',
|
||||
],
|
||||
];
|
||||
$ret = params_checked($params, $p);
|
||||
if($ret !== true)
|
||||
|
|
@ -218,7 +206,7 @@ class SlideService
|
|||
'images_url' => $attachment['data']['images_url'],
|
||||
'bg_color' => isset($params['bg_color']) ? $params['bg_color'] : '',
|
||||
'sort' => intval($params['sort']),
|
||||
'is_enable' => intval($params['is_enable']),
|
||||
'is_enable' => isset($params['is_enable']) ? intval($params['is_enable']) : 0,
|
||||
];
|
||||
|
||||
if(empty($params['id']))
|
||||
|
|
|
|||
Loading…
Reference in New Issue