setter
parent
4887313fc9
commit
0fbd584ac0
|
@ -2,7 +2,9 @@
|
|||
namespace app\controller\api;
|
||||
|
||||
use app\model\CouponMain;
|
||||
use app\model\Member;
|
||||
use app\model\Slide;
|
||||
use app\model\Business;
|
||||
use app\repository\AccountRepository;
|
||||
use app\repository\BusinessRepository;
|
||||
use app\repository\CouponRepository;
|
||||
|
@ -180,10 +182,45 @@ class Consumer extends Base
|
|||
public function advertisement()
|
||||
{
|
||||
$repo = OperationRepository::getInstance();
|
||||
$whereMap = [];
|
||||
|
||||
$orders = ['sort'=>'asc'];
|
||||
$page = input("page/d",1);
|
||||
$size = input("size/d",1000);
|
||||
|
||||
$couponId = input("coupon_id/d",0);
|
||||
$coupon = CouponRepository::getInstance()->findById($couponId, [], function ($q) {
|
||||
return $q->with([
|
||||
"business" => function ($q) {
|
||||
$q->field("code,id,business_name,business_subtitle,is_assign,agency_code");
|
||||
}
|
||||
]);
|
||||
});
|
||||
if(empty($coupon)){
|
||||
return $this->json(4001,"优惠券不存在");
|
||||
}
|
||||
if(!isset($coupon->business)||empty($coupon->business)){
|
||||
return $this->json(4001,"优惠券商家不存在");
|
||||
}
|
||||
|
||||
//如果优惠券所属商家指派了渠道商
|
||||
if ($coupon->business->is_assign == Business::COMMON_ON && !empty($coupon->business->agency_code)) {
|
||||
$agency = Member::findOne([["business_code","=",$coupon->business->agency_code]]);
|
||||
if(empty($agency)){
|
||||
$awhereMap = [];
|
||||
$awhereMap[] = ['position', '=', Slide::advertisement];
|
||||
$awhereMap[] = ['agency_id', '=', $agency["id"]];
|
||||
$list = $repo->slideList($awhereMap, ["id","title","src as image","url","url_type as type"], $page, $size, function ($q){
|
||||
return $q->withAttr("image",function ($value){
|
||||
return $this->request->domain() . $value;
|
||||
});
|
||||
}, $orders);
|
||||
|
||||
return $this->json(1,"ok",$list["list"]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$whereMap = [];
|
||||
$whereMap[] = ['position', '=', Slide::advertisement];
|
||||
$list = $repo->slideList($whereMap, ["id","title","src as image","url","url_type as type"], $page, $size, function ($q){
|
||||
return $q->withAttr("image",function ($value){
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace app\controller\manager;
|
||||
|
||||
use app\model\Log;
|
||||
use app\model\Slide as MSlide;
|
||||
use app\repository\CmsRepository;
|
||||
use app\repository\OperationRepository;
|
||||
use app\validate\Slide as VSlide;
|
||||
|
@ -89,7 +90,9 @@ class Slide extends Base
|
|||
$page = $this->request->param('page/d', 1);
|
||||
$size = $this->request->param('size/d', 30);
|
||||
|
||||
$whereMap = [];
|
||||
$whereMap = [
|
||||
['agency_id', '=', 0]
|
||||
];
|
||||
$orders = ['sort'=>'asc'];
|
||||
if (!empty($position)) {
|
||||
$whereMap[] = ['position', '=', $position];
|
||||
|
@ -274,4 +277,132 @@ class Slide extends Base
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @return Json|View
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function agencyPosterEdit()
|
||||
{
|
||||
$id = $this->request->param('id/d', 0);
|
||||
|
||||
if (!$slide = OperationRepository::getInstance()->findSlideById($id)) {
|
||||
return $this->json(4001, '数据不存在');
|
||||
}
|
||||
|
||||
if ($this->request->isPost()) {
|
||||
$item = input('post.item/a');
|
||||
$item["position"] = MSlide::advertisement;
|
||||
$validate = new VSlide();
|
||||
if (!$validate->scene('slide')->check($item)) {
|
||||
return $this->json(4002, $validate->getError());
|
||||
}
|
||||
|
||||
unset($item['id']);
|
||||
OperationRepository::getInstance()->updateSlide($item, $id);
|
||||
return $this->json();
|
||||
}
|
||||
|
||||
$this->data['item'] = $slide;
|
||||
$this->data['id'] = $id;
|
||||
|
||||
return $this->view();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @return View|Json
|
||||
*/
|
||||
public function agencyPosterAdd()
|
||||
{
|
||||
$repo = OperationRepository::getInstance();
|
||||
|
||||
if ($this->request->isPost()) {
|
||||
$item = input('post.item/a');
|
||||
$item["position"] = MSlide::advertisement;
|
||||
$item["agency_id"] = $this->auth["user_id"];
|
||||
$validate = new VSlide();
|
||||
if (!$validate->scene('slide')->check($item)) {
|
||||
return $this->json(4002, $validate->getError());
|
||||
}
|
||||
|
||||
$item['type'] = $item['type'] ?? 'img';
|
||||
$repo->createSlide($item);
|
||||
return $this->json();
|
||||
}
|
||||
|
||||
$this->data['positionsJson'] = $this->xmSelectPositionsJson();
|
||||
return $this->view();
|
||||
}
|
||||
|
||||
/**
|
||||
* 轮播图列表
|
||||
*
|
||||
* @return Json|View
|
||||
* @throws Exception
|
||||
*/
|
||||
public function agencyPoster()
|
||||
{
|
||||
$repo = OperationRepository::getInstance();
|
||||
if ($this->request->isPost()) {
|
||||
$position = MSlide::advertisement;
|
||||
$page = $this->request->param('page/d', 1);
|
||||
$size = $this->request->param('size/d', 30);
|
||||
|
||||
$whereMap = [
|
||||
['agency_id', '=', $this->auth["user_id"]],
|
||||
['position', '=', $position]
|
||||
];
|
||||
$orders = ['sort'=>'asc'];
|
||||
$list = $repo->slideList($whereMap, [], $page, $size, null, $orders);
|
||||
return $this->json(0, 'success', $list);
|
||||
}
|
||||
return $this->view();
|
||||
}
|
||||
|
||||
/**
|
||||
* 排序
|
||||
* @return Json
|
||||
*/
|
||||
public function agencyPosterSort()
|
||||
{
|
||||
if (!$this->request->isPost()) {
|
||||
return $this->json(4000, '非法请求');
|
||||
}
|
||||
try {
|
||||
$id = $this->request->param('id/d', 0);
|
||||
$sort = $this->request->param('sort/d', 0);
|
||||
OperationRepository::getInstance()->updateSlide(['sort'=>$sort], $id);
|
||||
} catch (Exception $e) {
|
||||
return $this->json(4001, '排序失败');
|
||||
}
|
||||
return $this->json();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @return Json
|
||||
*/
|
||||
public function agencyPosterDel()
|
||||
{
|
||||
if (!$this->request->isPost()) {
|
||||
return $this->json(4000, '非法请求');
|
||||
}
|
||||
|
||||
$ids = $this->request->param('ids/a', []);
|
||||
if (empty($ids)) {
|
||||
$ids[] = $this->request->param('id/d', 0);
|
||||
$ids = array_filter($ids);
|
||||
}
|
||||
|
||||
if (count($ids)) {
|
||||
OperationRepository::getInstance()->deleteSlides($ids);
|
||||
Log::write(get_class(), 'del', '删除了轮播图,涉及到的ID为:'.implode(',', $ids));
|
||||
}
|
||||
return $this->json();
|
||||
}
|
||||
|
||||
}
|
|
@ -324,6 +324,23 @@ class Base extends Model
|
|||
|
||||
|
||||
|
||||
/**
|
||||
* 刷新路径
|
||||
*
|
||||
* @param int $pid
|
||||
* @param array $data 默认全部 若data不为空 至少包含[id,path, $pidField]
|
||||
* @param string $pidField 父级ID字段名 默认 pid
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function refreshPath(int $pid = 0, array $data = [], string $pidField = 'pid')
|
||||
{
|
||||
$data = !empty($data) ? $data : self::column('id,path,'.$pidField);
|
||||
$updateAllPaths = [];
|
||||
self::recursionPath($pid, $data, $updateAllPaths);
|
||||
|
||||
(new static())->saveAll($updateAllPaths);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取递归最新路径
|
||||
*
|
||||
|
|
|
@ -13,6 +13,7 @@ layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect'], function
|
|||
|
||||
// 渲染表格
|
||||
let listUrl = $('#table-container').data('url');
|
||||
let sort = $('#table-container-sort').data('url');
|
||||
let insTb = table.render({
|
||||
elem: '#table-container',
|
||||
toolbar: '#toolbar-tpl',
|
||||
|
@ -43,11 +44,11 @@ layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect'], function
|
|||
{field: 'id', width: 80, title: 'ID'},
|
||||
{field: 'title', minWidth: 200, title: '标题'},
|
||||
{templet: '#row-cover', minWidth:150, title: '轮播图', style: 'height: 90px;'},
|
||||
{field: 'url', minWidth: 250, title: '跳转链接'},
|
||||
{field: 'position', minWidth: 150, title: '位置标识'},
|
||||
{field: 'url', title: '跳转链接'},
|
||||
{field: 'position', title: '位置标识'},
|
||||
{field: 'created_at', width: 170, title: '创建时间'},
|
||||
{field: 'sort', width: 80, title: '排序', edit: 'text'},
|
||||
{templet: '#row-operate', minWidth: 150, field: 'right', align: 'center', title: '操作', fixed: 'right'}
|
||||
{templet: '#row-operate', minWidth: 150, align: 'center', title: '操作',}
|
||||
]],
|
||||
done: function () {
|
||||
Tools.setInsTb(insTb);
|
||||
|
@ -70,7 +71,7 @@ layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect'], function
|
|||
table.on('edit(table-container)', function (obj) {
|
||||
let id = obj.data.id;
|
||||
if (obj.field == 'sort') {
|
||||
$.ajax('/manager/slide/sort', {
|
||||
$.ajax(sort, {
|
||||
data: {
|
||||
"sort": obj.value,
|
||||
"id": id
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
{layout name="manager/layout" /}
|
||||
<style>
|
||||
.layui-table-cell{
|
||||
height: auto;
|
||||
white-space: normal;
|
||||
}
|
||||
.layui-table .layui-layer-photos {height: 90px;}
|
||||
.layui-table img{
|
||||
max-height: 100%;
|
||||
object-fit: cover;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
display: block;
|
||||
max-width: 150px;
|
||||
vertical-align: middle;
|
||||
border: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="layui-row layui-col-space12">
|
||||
<div class="layui-col-xs12 layui-col-md12">
|
||||
<div id="echarts-records" style="background-color:#ffffff;min-height:600px;">
|
||||
<div class="layuimini-container location-index-page">
|
||||
<div class="layuimini-main">
|
||||
<div>
|
||||
<table id="table-container" class="layui-table" data-url="/manager/slide/agency-poster" lay-filter="table-container"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="table-container-sort" data-url="/manager/slide/agency-poster-sort" ></div>
|
||||
|
||||
<!-- 操作列 -->
|
||||
<script type="text/html" id="row-operate">
|
||||
<a class="layui-btn layui-btn-primary layui-btn-xs" data-href="/manager/slide/agency-poster-edit.html?id={{d.id}}" data-title="编辑轮播图" lay-event="edit">编辑</a>
|
||||
<a class="layui-btn layui-btn-danger layui-btn-xs" data-href="/manager/slide/agency-poster-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 lay-event="refresh"><i class="fa fa-refresh"></i></a>
|
||||
<a class="layui-btn layui-btn-normal layui-btn-sm" data-href="/manager/slide/agency-poster-add.html" data-title="添加轮播图" lay-event="add">添加</a>
|
||||
<a class="layui-btn layui-btn-danger layui-btn-sm" data-href="/manager/slide/agency-poster-del.html" lay-event="del">删除</a>
|
||||
</script>
|
||||
|
||||
<!-- 列 轮播图 -->
|
||||
<script type="text/html" id="row-cover">
|
||||
<div class="layui-layer-photos">
|
||||
<img src="{{ getFileRequestUrl(d.src) }}" layer-src="{{ getFileRequestUrl(d.src) }}" alt="">
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script src="__MANAGER__/js/slide.js?v={:mt_rand()}"></script>
|
|
@ -0,0 +1,69 @@
|
|||
{layout name="manager/layout" /}
|
||||
|
||||
<div class="layuimini-container location-operate-page">
|
||||
<div class="layuimini-main">
|
||||
<div class="layui-form layuimini-form">
|
||||
|
||||
|
||||
<div class="layui-form-item field-div">
|
||||
<label class="layui-form-label required">标题</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="item[title]" placeholder="请输入标题" class="layui-input" value="">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="layui-form-item field-div">
|
||||
<label class="layui-form-label">跳转链接</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="item[url]" placeholder="请输入跳转链接[选填]" class="layui-input" value="">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item field-div">
|
||||
<label class="layui-form-label required">跳转类型</label>
|
||||
<div class="layui-input-block">
|
||||
|
||||
<input type="radio" name="item[url_type]" value="1" title="小程序(跳转链接需传入签到券id)" />
|
||||
<input type="radio" name="item[url_type]" checked value="0" title="网页" />
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-row field-div" >
|
||||
<label class="layui-form-label required">轮播图:</label>
|
||||
<div class="layui-inline layui-col-xs12 layui-col-md8">
|
||||
<div class="layui-row upload-file-div">
|
||||
<div class=" layui-col-xs12 layui-col-md8">
|
||||
<input class="layui-input upload-file-value" name="item[src]" type="text" value="">
|
||||
<div class="layui-form-mid layui-word-aux">图片尺寸:最低高度为200px</div>
|
||||
</div>
|
||||
<div class="layui-col-xs12 layui-col-md3">
|
||||
<span>
|
||||
<button type="button" class="layui-btn layui-btn-danger upload-btn">
|
||||
<i class="fa fa-upload"></i> 上传
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
<ul class="layui-row layui-col-xs12 layui-col-md9 preview-list layui-col-space5"></ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-form-text field-div current-field-content"}>
|
||||
<label class="layui-form-label">描述</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea name="item[description]" class="layui-textarea"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn layui-btn-normal" data-url="/manager/slide/agency-poster-add.html" lay-submit lay-filter="saveBtn">确认保存</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="__MANAGER__/js/slide.js?v={:mt_rand()}"></script>
|
|
@ -0,0 +1,69 @@
|
|||
{layout name="manager/layout" /}
|
||||
|
||||
<div class="layuimini-container location-operate-page">
|
||||
<div class="layuimini-main">
|
||||
<div class="layui-form layuimini-form">
|
||||
<!-- 显示位置 -->
|
||||
|
||||
<div class="layui-form-item field-div ">
|
||||
<label class="layui-form-label required">标题</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="item[title]" placeholder="请输入标题" class="layui-input" value="{$item.title ?? ''}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item field-div ">
|
||||
<label class="layui-form-label">跳转链接</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="item[url]" placeholder="请输入跳转链接[选填]" class="layui-input" value="{$item.url ?? ''}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item field-div">
|
||||
<label class="layui-form-label required">跳转类型</label>
|
||||
<div class="layui-input-block">
|
||||
|
||||
<input type="radio" {if $item['url_type'] == 1}checked="checked"{/if} name="item[url_type]" value="1" title="小程序(跳转链接需传入签到券id)" />
|
||||
<input type="radio" {if $item['url_type'] == 0}checked="checked"{/if} name="item[url_type]" value="0" title="网页" />
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-row field-div " >
|
||||
<label class="layui-form-label required">轮播图:</label>
|
||||
<div class="layui-inline layui-col-xs12 layui-col-md8">
|
||||
<div class="layui-row upload-file-div">
|
||||
<div class=" layui-col-xs12 layui-col-md8">
|
||||
<input class="layui-input upload-file-value" name="item[src]" type="text" value="{$item.src ?? ''}">
|
||||
<div class="layui-form-mid layui-word-aux">图片尺寸:最低高度为200px</div>
|
||||
</div>
|
||||
<div class="layui-col-xs12 layui-col-md3">
|
||||
<span>
|
||||
<button type="button" class="layui-btn layui-btn-danger upload-btn">
|
||||
<i class="fa fa-upload"></i> 上传
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
<ul class="layui-row layui-col-xs12 layui-col-md9 preview-list layui-col-space5"></ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-form-text field-div current-field-content"}>
|
||||
<label class="layui-form-label">描述</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea name="item[description]" class="layui-textarea">{$item.description ?? ''}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" name="id" value="{$id ?? 0}">
|
||||
<button class="layui-btn layui-btn-normal" data-url="/manager/slide/agency-poster-edit.html" lay-submit lay-filter="saveBtn">确认保存</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="__MANAGER__/js/slide.js?v={:mt_rand()}"></script>
|
|
@ -55,7 +55,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="table-container-sort" data-url="/manager/slide/sort" ></div>
|
||||
<!-- 操作列 -->
|
||||
<script type="text/html" id="row-operate">
|
||||
<a class="layui-btn layui-btn-primary layui-btn-xs" data-href="/manager/slide/edit.html?id={{d.id}}" data-title="编辑轮播图" lay-event="edit">编辑</a>
|
||||
|
|
Loading…
Reference in New Issue