setter
parent
3c2ab4fe85
commit
bb4e60e5db
|
@ -6,6 +6,7 @@ use app\model\Account;
|
|||
use app\model\Coupon as CouponModel;
|
||||
use app\model\CouponBill;
|
||||
use app\model\CouponMain;
|
||||
use app\model\CouponType as CouponTypeModel;
|
||||
use app\model\Deduction;
|
||||
use app\model\Redpack;
|
||||
use app\model\Business as BusinessModel;
|
||||
|
@ -559,6 +560,8 @@ class Coupon extends Base
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//验证通过 不管是商家还是工作人员 都可以发布优惠券
|
||||
$couponMain = [
|
||||
"name" => $data['name'] ?? '',
|
||||
|
@ -596,6 +599,12 @@ class Coupon extends Base
|
|||
return $this->json(4001, $usingRuleValidate->getError());
|
||||
}
|
||||
|
||||
//检查类型
|
||||
if(CouponTypeModel::checkType($couponMain['type']) !== true){
|
||||
return $this->json(4001, '优惠券类型不存在');
|
||||
}
|
||||
|
||||
|
||||
//验证通过
|
||||
$couponMain['business_type'] = $account->business['type'];
|
||||
$couponMain['business_name'] = $account->business['business_name'];
|
||||
|
@ -689,6 +698,10 @@ class Coupon extends Base
|
|||
return $this->json(4001, $usingRuleValidate->getError());
|
||||
}
|
||||
|
||||
//检查类型
|
||||
if(CouponTypeModel::checkType($couponMainData['type']) !== true){
|
||||
return $this->json(4001, '优惠券类型不存在');
|
||||
}
|
||||
|
||||
//验证通过
|
||||
Db::startTrans();
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace app\controller\manager;
|
||||
|
||||
use app\repository\BusinessRepository;
|
||||
use app\repository\CmsRepository;
|
||||
use app\model\Log;
|
||||
use app\model\Category as CategoryModel;
|
||||
|
@ -53,16 +54,7 @@ class Category extends Base
|
|||
|
||||
Db::startTrans();
|
||||
try {
|
||||
$oldPath = $info['path'] ?? '';
|
||||
$item['path'] = CategoryModel::getPath($item['pid']);
|
||||
$info->save($item);
|
||||
|
||||
//刷新所有路径
|
||||
$oldPath = $oldPath.','.$id;
|
||||
$newPath = $item['path'].','.$id;
|
||||
if ($oldPath != $newPath) {
|
||||
CategoryModel::refreshPath();
|
||||
}
|
||||
Db::commit();
|
||||
return $this->json();
|
||||
} catch (ValidateException $e) {
|
||||
|
@ -123,8 +115,13 @@ class Category extends Base
|
|||
|
||||
$ids = $this->request->param('ids/a', []);
|
||||
if(!empty(CategoryModel::findOne([["pid","in",$ids]]))){
|
||||
return $this->json(5001,"该栏目还有下级 不能删除");
|
||||
return $this->json(4001,"该栏目还有下级,不能删除");
|
||||
}
|
||||
$business = BusinessRepository::getInstance()->findOneByWhere([["type","in",$ids]]);
|
||||
if(!empty($business)){
|
||||
return $this->json(4001,"该栏目还有商家存在,不能删除");
|
||||
}
|
||||
|
||||
CategoryModel::destroy($ids);
|
||||
return $this->json();
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace app\controller\manager;
|
|||
use app\exception\RepositoryException;
|
||||
|
||||
use app\model\CouponMain;
|
||||
use app\model\CouponType as CouponTypeModel;
|
||||
use app\model\Business as BusinessModel;
|
||||
use app\model\Member as MemberModel;
|
||||
use app\repository\BusinessRepository;
|
||||
|
@ -197,6 +198,10 @@ class Coupon extends Base
|
|||
}
|
||||
}
|
||||
|
||||
//检查类型
|
||||
if(CouponTypeModel::checkType($data['type']) !== true){
|
||||
return $this->json(4001, '优惠券类型不存在');
|
||||
}
|
||||
|
||||
|
||||
$data['business_type'] = $business['type'];
|
||||
|
@ -206,11 +211,8 @@ class Coupon extends Base
|
|||
$data['business_circle_id'] = $business['business_circle_id'];
|
||||
|
||||
|
||||
$type = CouponRepository::getInstance()->getCouponTypeAll();
|
||||
$type = array_column($type->toArray(), null, "id");
|
||||
if (!isset($type[$data['type']])) {
|
||||
return $this->json(4001, '优惠券类型不存在');
|
||||
}
|
||||
|
||||
|
||||
$data['commission_agency'] = input("item.commission_agency/d", 0);
|
||||
$data['commission_admin'] = input("item.commission_admin/d", 0);
|
||||
$data['commission_consumer'] = input("item.commission_consumer/d", 0);
|
||||
|
@ -294,6 +296,12 @@ class Coupon extends Base
|
|||
if (empty($business)) {
|
||||
return $this->json(4001, '商家不存在');
|
||||
}
|
||||
|
||||
//检查类型
|
||||
if(CouponTypeModel::checkType($data['type']) !== true){
|
||||
return $this->json(4001, '优惠券类型不存在');
|
||||
}
|
||||
|
||||
//更新经纬度
|
||||
$data['business_type'] = $business['type'];
|
||||
$data['business_name'] = $business['business_name'];
|
||||
|
@ -339,4 +347,6 @@ class Coupon extends Base
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,143 @@
|
|||
<?php
|
||||
|
||||
namespace app\controller\manager;
|
||||
|
||||
use app\model\CouponMain;
|
||||
use app\repository\BusinessRepository;
|
||||
use app\repository\CmsRepository;
|
||||
use app\model\CouponType as CouponTypeModel;
|
||||
|
||||
use Exception;
|
||||
use think\facade\Db;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use think\exception\ValidateException;
|
||||
use think\response\Json;
|
||||
use think\response\View;
|
||||
|
||||
/**
|
||||
* 优惠券类型
|
||||
*
|
||||
* Class CouponType
|
||||
* @package app\controller\manager
|
||||
*/
|
||||
class CouponType extends Base
|
||||
{
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @return Json|View
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$id = input('id/d', 0);
|
||||
|
||||
if (!$info = CouponTypeModel::findById($id)) {
|
||||
return $this->json(4001, '记录不存在');
|
||||
}
|
||||
|
||||
if ($this->request->isPost()) {
|
||||
$item = input('post.');
|
||||
$validate = $this->validateByApi($item, [
|
||||
'name|标题' => 'require|max:100|unique:coupon_type,name,'.$id,
|
||||
]);
|
||||
|
||||
if ($validate !== true) {
|
||||
return $validate;
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
$info->save($item);
|
||||
Db::commit();
|
||||
return $this->json();
|
||||
} catch (ValidateException $e) {
|
||||
Db::rollback();
|
||||
return $this->json(4001, $e->getError());
|
||||
}
|
||||
}
|
||||
|
||||
$this->data['item'] = $info;
|
||||
|
||||
return $this->view();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @return Json|View
|
||||
* @throws Exception
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$item = input('post.');
|
||||
$validate = $this->validateByApi($item, [
|
||||
'name|标题' => 'require|max:100',
|
||||
]);
|
||||
|
||||
if ($validate !== true) {
|
||||
return $validate;
|
||||
}
|
||||
try {
|
||||
CouponTypeModel::create($item);
|
||||
return $this->json();
|
||||
} catch (ValidateException $e) {
|
||||
return $this->json(4001, $e->getError());
|
||||
}
|
||||
}
|
||||
|
||||
return $this->view();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @return Json
|
||||
*/
|
||||
public function del()
|
||||
{
|
||||
if (!$this->request->isPost()) {
|
||||
return $this->json(4000, '非法请求');
|
||||
}
|
||||
|
||||
$ids = $this->request->param('ids/a', []);
|
||||
|
||||
$couponMain = CouponMain::findOne([["type","in",$ids]]);
|
||||
if(!empty($couponMain)){
|
||||
return $this->json(4001,"该优惠券绑定了该类型,不能删除");
|
||||
}
|
||||
|
||||
CouponTypeModel::destroy($ids);
|
||||
return $this->json();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @return Json|View
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$menus = CouponTypeModel::getList();
|
||||
$res = [
|
||||
'code' => 0,
|
||||
'msg' => 'success',
|
||||
'count' => $menus->count(),
|
||||
'data' => $menus->toArray(),
|
||||
];
|
||||
return json($res);
|
||||
}
|
||||
return $this->view();
|
||||
}
|
||||
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace app\model;
|
||||
|
||||
use app\repository\CouponRepository;
|
||||
use think\Collection;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
|
@ -14,5 +15,28 @@ use think\db\exception\ModelNotFoundException;
|
|||
*/
|
||||
class CouponType extends Base
|
||||
{
|
||||
/**
|
||||
* 获取全部列表
|
||||
*
|
||||
* @return Collection
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public static function getList()
|
||||
{
|
||||
return self::field('id,name')->order('id', 'desc')->select();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查类型
|
||||
* */
|
||||
public static function checkType($valueData){
|
||||
$type = CouponRepository::getInstance()->getCouponTypeAll();
|
||||
$type = array_column($type->toArray(), null, "id");
|
||||
if (!isset($type[$valueData])) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -32,7 +32,7 @@ layui.use(['laytpl', 'treeTable','jquery', 'form', 'miniTab', 'xmSelect'], funct
|
|||
cols: [[
|
||||
{type: 'checkbox'},
|
||||
{field: 'name', minWidth: 200, title: '名称'},
|
||||
{field: 'commision', width: 80, align: 'center', title: '默认佣金', edit: 'text'},
|
||||
// {field: 'commision', width: 80, align: 'center', title: '默认佣金', edit: 'text'},
|
||||
{templet: '#menu-operate', width: 150, align: 'center', title: '操作'}
|
||||
]],
|
||||
done: function () {
|
||||
|
|
|
@ -0,0 +1,184 @@
|
|||
layui.use(['laytpl', 'treeTable','jquery', 'form', 'miniTab', 'xmSelect'], function () {
|
||||
let $ = layui.jquery,
|
||||
form = layui.form,
|
||||
treeTable = layui.treeTable,
|
||||
layer = layui.layer,
|
||||
miniTab = layui.miniTab,
|
||||
xmSelect = layui.xmSelect;
|
||||
|
||||
let modifyUrl = $('#row-modify').data('url');
|
||||
|
||||
/**** index begin ***/
|
||||
//index页面
|
||||
if ($('.location-index-page').length > 0) {
|
||||
miniTab.listen();
|
||||
|
||||
// 渲染表格
|
||||
let listUrl = $('#menu-table').data('url');
|
||||
let insTb = treeTable.render({
|
||||
elem: '#menu-table',
|
||||
toolbar: '#toolbar-tpl',
|
||||
defaultToolbar: [],
|
||||
method: 'POST',
|
||||
skin: 'line',
|
||||
url: listUrl,
|
||||
page: false,
|
||||
tree: false,
|
||||
cols: [[
|
||||
{type: 'checkbox'},
|
||||
{field: 'name', minWidth: 200, title: '名称'},
|
||||
// {field: 'commision', width: 80, align: 'center', title: '默认佣金', edit: 'text'},
|
||||
{templet: '#menu-operate', width: 150, align: 'center', title: '操作'}
|
||||
]],
|
||||
done: function () {
|
||||
}
|
||||
});
|
||||
|
||||
//监听单元格编辑
|
||||
treeTable.on('edit(menu-table)', function(obj){
|
||||
$.post(modifyUrl, {id: obj.data.id, field: obj.field, value: obj.value}, function (res) {
|
||||
layer.msg(res.msg)
|
||||
if (res.code === 0) {
|
||||
insTb.refresh();
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
//监听工具条 注意区别toolbar和tool toolbar是表头上的工具条 tool是行中的工具条
|
||||
treeTable.on('toolbar(menu-table)', function (obj) {
|
||||
let layEvent = obj.event;
|
||||
|
||||
if (layEvent === 'expand') {
|
||||
insTb.expandAll();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (layEvent === 'fold') {
|
||||
insTb.foldAll();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (layEvent === 'del') {
|
||||
let selected = insTb.checkStatus(false);
|
||||
let ids = [];
|
||||
let url = $(obj.elem.context).data('href')
|
||||
$.each(selected, function (index, val) {
|
||||
ids.push(val.id);
|
||||
})
|
||||
|
||||
del(url, ids);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (layEvent === 'add') {
|
||||
let url = $(obj.elem.context).data('href');
|
||||
let title = $(obj.elem.context).data('title');
|
||||
let index = layer.open({
|
||||
title: title,
|
||||
type: 2,
|
||||
shade: 0.2,
|
||||
maxmin: true,
|
||||
shadeClose: true,
|
||||
area: ['100%', '100%'],
|
||||
content: url,
|
||||
});
|
||||
$(window).on("resize", function () {
|
||||
layer.full(index);
|
||||
});
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
//刷新
|
||||
$('body').on('click', '[data-table-refresh]', function () {
|
||||
insTb.refresh();
|
||||
});
|
||||
|
||||
//删除
|
||||
function del(url, ids) {
|
||||
let index = layer.confirm('确认删除吗?', {
|
||||
btn: ['确认','取消'], //按钮
|
||||
title: '操作提示',
|
||||
}, function() {
|
||||
$.post(url, {ids: ids}, function (res) {
|
||||
layer.msg(res.msg)
|
||||
if (res.code === 0) {
|
||||
insTb.refresh();
|
||||
}
|
||||
})
|
||||
}, function(){
|
||||
layer.close(index)
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
//监听工具条
|
||||
treeTable.on('tool(menu-table)', function (obj) {
|
||||
let data = obj.data;
|
||||
let layEvent = obj.event;
|
||||
let url = $(obj.tr.context).data('href');
|
||||
let title = $(obj.tr.context).data('title');
|
||||
|
||||
if (layEvent === 'del') {
|
||||
let ids = [data.id];
|
||||
del(url, ids);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (layEvent === 'edit') {
|
||||
let index = layer.open({
|
||||
title: title,
|
||||
type: 2,
|
||||
shade: 0.2,
|
||||
maxmin: true,
|
||||
shadeClose: true,
|
||||
area: ['100%', '100%'],
|
||||
content: url,
|
||||
});
|
||||
|
||||
$(window).on("resize", function () {
|
||||
layer.full(index);
|
||||
});
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
/*** index end ***/
|
||||
|
||||
|
||||
// add和edit页面
|
||||
if ($('.location-operate-page').length > 0) {
|
||||
let parentMenu = $('#parent-menu');
|
||||
let menuList = parentMenu.data('menu') ? parentMenu.data('menu') : [];
|
||||
xmSelect.render({
|
||||
el: '#parent-menu',
|
||||
paging: false,
|
||||
autoRow: true,
|
||||
radio: true,
|
||||
clickClose: true,
|
||||
name: 'pid',
|
||||
tips: '请选择上级分类',
|
||||
direction: 'auto',
|
||||
height: 'auto',
|
||||
model: {
|
||||
icon: 'hidden',
|
||||
},
|
||||
prop: {
|
||||
name: 'name',
|
||||
value: 'id',
|
||||
},
|
||||
tree: {
|
||||
show: true,
|
||||
strict: false,
|
||||
clickCheck: true,
|
||||
expandedKeys: true,
|
||||
clickExpand: false
|
||||
},
|
||||
theme: {
|
||||
color: '#1e84ff',
|
||||
},
|
||||
data: menuList
|
||||
});
|
||||
}
|
||||
});
|
|
@ -22,11 +22,13 @@ function getAddress(lat,lng,obj){
|
|||
// console.log(address)
|
||||
$(obj).text(data.result.address + address);
|
||||
} else {
|
||||
alert("位置获取错误,请联系管理员!")
|
||||
console.log(data)
|
||||
alert("位置获取错误,可能用户信息不完整")
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
alert("位置获取错误,请联系管理员!")
|
||||
error: function (e) {
|
||||
console.log(e)
|
||||
alert("位置获取错误,map服务出错")
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
<div class="layui-form-item">
|
||||
<label class="layui-form-label required">商家类型</label>
|
||||
<div class="layui-input-block">
|
||||
<select name="type">
|
||||
<option value="">请选择问题</option>
|
||||
<select name="type" >
|
||||
<option value="">请选择</option>
|
||||
|
||||
{foreach $type as $value}
|
||||
<optgroup label="{$value['name']}">
|
||||
|
@ -68,7 +68,7 @@
|
|||
<input type="hidden" id="input-province-text" name="province_text" value="{$item.province_text ?? ''}">
|
||||
<input type="hidden" id="input-city-text" name="city_text" value="{$item.city_text ?? ''}">
|
||||
<input type="hidden" id="input-county-text" name="county_text" value="{$item.county_text ?? ''}">
|
||||
<div id="target" style="z-index: 1111"></div>
|
||||
<div id="target" style="z-index: 898"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
{layout name="manager/layout" /}
|
||||
<style>
|
||||
.layui-iconpicker-body.layui-iconpicker-body-page .hide {display: none;}
|
||||
</style>
|
||||
<div class="layuimini-container location-operate-page">
|
||||
<div class="layuimini-main">
|
||||
<div class="layui-form layuimini-form">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label required">标题</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="name" lay-verify="required" lay-reqtext="标题不能为空" placeholder="请输入标题" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn layui-btn-normal" data-url="/manager/coupon-type/add" lay-submit lay-filter="saveBtn">确认保存</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="__MANAGER__/js/coupon_type.js?v={:mt_rand()}"></script>
|
|
@ -0,0 +1,24 @@
|
|||
{layout name="manager/layout" /}
|
||||
<style>
|
||||
.layui-iconpicker-body.layui-iconpicker-body-page .hide {display: none;}
|
||||
</style>
|
||||
<div class="layuimini-container location-operate-page">
|
||||
<div class="layuimini-main">
|
||||
<div class="layui-form layuimini-form">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label required">标题</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="name" lay-verify="required" value="{$item.name ?? ''}" lay-reqtext="标题不能为空" placeholder="请输入标题" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn layui-btn-normal" data-url="/manager/coupon-type/edit?id={$item.id}" lay-submit lay-filter="saveBtn">确认保存</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="__MANAGER__/js/coupon_type.js?v={:mt_rand()}"></script>
|
|
@ -0,0 +1,27 @@
|
|||
{layout name="manager/layout" /}
|
||||
|
||||
<div class="layuimini-container location-index-page">
|
||||
<div class="layuimini-main">
|
||||
<div>
|
||||
<table id="menu-table" class="layui-table" data-url="/manager/coupon-type" lay-filter="menu-table"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 隐藏列 -->
|
||||
<!-- 编辑单元格提交url -->
|
||||
<input type="hidden" id="row-modify" data-url="/manager/coupon-type/modify">
|
||||
|
||||
<!-- 操作列 -->
|
||||
<script type="text/html" id="menu-operate">
|
||||
<a class="layui-btn layui-btn-primary layui-btn-xs menu-edit" data-href="/manager/coupon-type/edit.html?id={{d.id}}" data-title="编辑" lay-event="edit">编辑</a>
|
||||
<a class="layui-btn layui-btn-danger layui-btn-xs" data-href="/manager/coupon-type/del.html" lay-event="del">删除</a>
|
||||
</script>
|
||||
|
||||
<!-- toolbar -->
|
||||
<script type="text/html" id="toolbar-tpl">
|
||||
<a class="layui-btn layui-btn-primary layui-btn-sm" data-table-refresh><i class="fa fa-refresh"></i></a>
|
||||
<a class="layui-btn layui-btn-normal layui-btn-sm" data-href="/manager/coupon-type/add.html" data-title="添加" lay-event="add">添加</a>
|
||||
<!-- <a class="layui-btn layui-btn-danger layui-btn-sm" data-href="/manager/coupon-type/del.html" lay-event="del">批量删除</a>-->
|
||||
</script>
|
||||
<script src="__MANAGER__/js/coupon_type.js?v={:mt_rand()}"></script>
|
Loading…
Reference in New Issue