添加热销榜单和新品推荐
This commit is contained in:
parent
0b1ede276f
commit
6680ce989d
80
app/admin/logic/HotListLogic.php
Normal file
80
app/admin/logic/HotListLogic.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
use app\common\basics\Logic;
|
||||
use app\common\model\HotList;
|
||||
|
||||
class HotListLogic extends Logic
|
||||
{
|
||||
public static function lists($get)
|
||||
{
|
||||
$where = [];
|
||||
if (!empty($get['name']) and $get['name']) {
|
||||
$where[] = ['g.name', 'like', '%' . $get['name'] . '%'];
|
||||
}
|
||||
|
||||
$model = new HotList();
|
||||
$lists = $model->with(['goods'])
|
||||
->where('delete_time', 0)
|
||||
->paginate([
|
||||
'page' => $get['page'],
|
||||
'list_rows' => $get['limit'],
|
||||
'var_page' => 'page'
|
||||
])->toArray();;
|
||||
return ['count' => $lists['total'], 'lists' => $lists['data']];
|
||||
}
|
||||
|
||||
// 获取详情
|
||||
public static function detail($id)
|
||||
{
|
||||
$result = HotList::with('goods')->where(['id' => $id, 'delete_time' => 0])->find();
|
||||
return $result;
|
||||
}
|
||||
|
||||
// 添加表单信息
|
||||
public static function create($form)
|
||||
{
|
||||
if (!empty($form['sort']) && !is_numeric($form['sort'])) {
|
||||
return ['code' => -1, 'msg' => '请输入整数'];
|
||||
}
|
||||
|
||||
$result = HotList::create([
|
||||
'goods_id' => $form['goods_id'],
|
||||
'sort' => $form['sort'],
|
||||
'create_time' => time()
|
||||
]);
|
||||
|
||||
if ($result) {
|
||||
return ['code' => 1, 'msg' => '添加成功'];
|
||||
}
|
||||
|
||||
return ['code' => -1, 'msg' => '添加失败'];
|
||||
}
|
||||
|
||||
// 修改表单信息
|
||||
public static function edit($form)
|
||||
{
|
||||
$result = HotList::where(['id' => $form['id']])->update([
|
||||
'goods_id' => $form['goods_id'],
|
||||
'sort' => $form['sort'],
|
||||
'update_time' => time()
|
||||
]);
|
||||
|
||||
if ($result) {
|
||||
return ['code' => 1, 'msg' => '修改成功'];
|
||||
}
|
||||
|
||||
return ['code' => -1, 'msg' => '修改失败'];
|
||||
}
|
||||
|
||||
// 删除文章
|
||||
public static function del($id)
|
||||
{
|
||||
$result = HotList::where(['id' => $id])->update(['delete_time' => time()]);
|
||||
if ($result) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
82
app/admin/logic/NewGoodsLogic.php
Normal file
82
app/admin/logic/NewGoodsLogic.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
use app\common\basics\Logic;
|
||||
use app\common\model\NewGoods;
|
||||
|
||||
class NewGoodsLogic extends Logic
|
||||
{
|
||||
public static function lists($get)
|
||||
{
|
||||
$where = [];
|
||||
if (!empty($get['title']) and $get['title']) {
|
||||
$where[] = ['title', 'like', '%' . $get['title'] . '%'];
|
||||
}
|
||||
|
||||
$model = new NewGoods();
|
||||
$lists = $model->with(['goods' => function ($query) use ($where) {
|
||||
$query->where($where);
|
||||
}])
|
||||
->where('delete_time', 0)
|
||||
->paginate([
|
||||
'page' => $get['page'],
|
||||
'list_rows' => $get['limit'],
|
||||
'var_page' => 'page'
|
||||
])->toArray();;
|
||||
return ['count' => $lists['total'], 'lists' => $lists['data']];
|
||||
}
|
||||
|
||||
// 获取详情
|
||||
public static function detail($id)
|
||||
{
|
||||
$result = NewGoods::with('goods')->where(['id' => $id, 'delete_time' => 0])->find();
|
||||
return $result;
|
||||
}
|
||||
|
||||
// 添加表单信息
|
||||
public static function create($form)
|
||||
{
|
||||
if (!empty($form['sort']) && !is_numeric($form['sort'])) {
|
||||
return ['code' => -1, 'msg' => '请输入整数'];
|
||||
}
|
||||
|
||||
$result = NewGoods::create([
|
||||
'goods_id' => $form['goods_id'],
|
||||
'sort' => $form['sort'],
|
||||
'create_time' => time()
|
||||
]);
|
||||
|
||||
if ($result) {
|
||||
return ['code' => 1, 'msg' => '添加成功'];
|
||||
}
|
||||
|
||||
return ['code' => -1, 'msg' => '添加失败'];
|
||||
}
|
||||
|
||||
// 修改表单信息
|
||||
public static function edit($form)
|
||||
{
|
||||
$result = NewGoods::where(['id' => $form['id']])->update([
|
||||
'goods_id' => $form['goods_id'],
|
||||
'sort' => $form['sort'],
|
||||
'update_time' => time()
|
||||
]);
|
||||
|
||||
if ($result) {
|
||||
return ['code' => 1, 'msg' => '修改成功'];
|
||||
}
|
||||
|
||||
return ['code' => -1, 'msg' => '修改失败'];
|
||||
}
|
||||
|
||||
// 删除文章
|
||||
public static function del($id)
|
||||
{
|
||||
$result = NewGoods::where(['id' => $id])->update(['delete_time' => time()]);
|
||||
if ($result) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
80
app/admin/view/hot_list/add.html
Normal file
80
app/admin/view/hot_list/add.html
Normal file
@ -0,0 +1,80 @@
|
||||
{layout name="layout2" /}
|
||||
<style>
|
||||
.layui-form {padding: 20px 30px;background-color: #ffffff;}
|
||||
.layui-form-item .layui-form-label { width: 95px; }
|
||||
.layui-form-item .layui-input-inline { width: 240px; }
|
||||
.layui-form-item .map-container{ width: 600px; height: 400px; margin-left: 100px; margin-top: 20px; }
|
||||
#video-block {position: relative; width: 700px;height: 300px}
|
||||
.del-video-btn {
|
||||
visibility: hidden;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: absolute;
|
||||
z-index: 100;
|
||||
top: -11px;
|
||||
right: -9px;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
color: #FFFFFF;
|
||||
border-radius: 50%;
|
||||
background: hsla(0, 0%, 60%, .6)
|
||||
}
|
||||
.select-goods {margin-left: 10px}
|
||||
</style>
|
||||
|
||||
<div class="layui-card layui-form">
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">商品:</label>
|
||||
<div class="layui-input-inline" style="display: flex">
|
||||
<div id="shop_name"></div>
|
||||
<input type="hidden" id="goods_id" name="goods_id">
|
||||
<a class="layui-btn layui-btn-normal select-goods">选择商品</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label for="sort" class="layui-form-label">排序:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="sort" id="sort" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-hide">
|
||||
<input type="button" lay-submit lay-filter="addSubmit" id="addSubmit" value="确认">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script src="__PUBLIC__/static/common/js/area.js"></script>
|
||||
<script>
|
||||
layui.config({
|
||||
base: "/static/lib/"
|
||||
}).extend({
|
||||
likeedit: "likeedit/likeedit",
|
||||
likeArea: "likeArea/likeArea",
|
||||
txMap: "likeMap/txMap"
|
||||
}).use(["form", "laydate", "likeArea", "txMap", 'likeedit', 'upload', 'element'], function(){
|
||||
var $ = layui.$;
|
||||
var form = layui.form;
|
||||
|
||||
// 选择商品
|
||||
$(document).on('click','.select-goods',function () {
|
||||
layer.open({
|
||||
type: 2
|
||||
,title: '选择商品'
|
||||
,content: '{:url("hotList/goods")}'
|
||||
,area: ['90%', '90%']
|
||||
,btn: ['确认', '取消']
|
||||
,yes: function(index, layero){
|
||||
var data = window["layui-layer-iframe" + index].callbackdata();
|
||||
$('#shop_name').html(data[0].name)
|
||||
$('#goods_id').val(data[0].id)
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
</script>
|
||||
80
app/admin/view/hot_list/audit.html
Normal file
80
app/admin/view/hot_list/audit.html
Normal file
@ -0,0 +1,80 @@
|
||||
{layout name="layout2" /}
|
||||
<style>
|
||||
.layui-form {padding: 20px 30px;background-color: #ffffff;}
|
||||
.layui-form-item .layui-form-label { width: 95px; }
|
||||
.layui-form-item .layui-input-inline { width: 240px; }
|
||||
.layui-form-item .map-container{ width: 600px; height: 400px; margin-left: 100px; margin-top: 20px; }
|
||||
#video-block {position: relative; width: 700px;height: 300px}
|
||||
.del-video-btn {
|
||||
visibility: hidden;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: absolute;
|
||||
z-index: 100;
|
||||
top: -11px;
|
||||
right: -9px;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
color: #FFFFFF;
|
||||
border-radius: 50%;
|
||||
background: hsla(0, 0%, 60%, .6)
|
||||
}
|
||||
.select-goods {margin-left: 10px}
|
||||
</style>
|
||||
|
||||
<div class="layui-card layui-form">
|
||||
<input type="hidden" value="{$detail.id}" name="id">
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">商品:</label>
|
||||
<div class="layui-input-inline" style="display: flex">
|
||||
<div id="shop_name">{$detail.goods['name']}</div>
|
||||
<input type="hidden" id="goods_id" name="goods_id" value="{$detail.goods_id}">
|
||||
<a class="layui-btn layui-btn-normal select-goods">选择商品</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label for="sort" class="layui-form-label">排序:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="sort" id="sort" autocomplete="off" class="layui-input" value="{$detail.sort}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-hide">
|
||||
<input type="button" lay-submit lay-filter="addSubmit" id="addSubmit" value="确认">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="__PUBLIC__/static/common/js/area.js"></script>
|
||||
<script>
|
||||
layui.config({
|
||||
base: "/static/lib/"
|
||||
}).extend({
|
||||
likeedit: "likeedit/likeedit",
|
||||
likeArea: "likeArea/likeArea",
|
||||
txMap: "likeMap/txMap"
|
||||
}).use(["form", "laydate", "likeArea", "txMap", 'likeedit', 'upload', 'element'], function(){
|
||||
var $ = layui.$;
|
||||
var form = layui.form;
|
||||
|
||||
// 选择商品
|
||||
$(document).on('click','.select-goods',function () {
|
||||
layer.open({
|
||||
type: 2
|
||||
,title: '选择商品'
|
||||
,content: '{:url("hotList/goods")}'
|
||||
,area: ['90%', '90%']
|
||||
,btn: ['确认', '取消']
|
||||
,yes: function(index, layero){
|
||||
var data = window["layui-layer-iframe" + index].callbackdata();
|
||||
$('#shop_name').html(data[0].name)
|
||||
$('#goods_id').val(data[0].id)
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
</script>
|
||||
105
app/admin/view/hot_list/goods.html
Normal file
105
app/admin/view/hot_list/goods.html
Normal file
@ -0,0 +1,105 @@
|
||||
{layout name="layout1" /}
|
||||
<div class="layui-fluid">
|
||||
<div class="layui-card">
|
||||
<div class="layui-tab layui-tab-card" lay-filter="tab-all">
|
||||
<div class="layui-tab-item layui-show">
|
||||
<div class="layui-card">
|
||||
<div class="layui-form layui-card-header layuiadmin-card-header-auto">
|
||||
<div class="layui-form-item type">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">商品名称:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="goods_name" id="keyword" placeholder="请输入关键词" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<button class="layui-btn layuiadmin-btn-goods {$view_theme_color}" lay-submit lay-filter="goods-search">查询</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<table id="goods-lists" lay-filter="goods-lists"></table>
|
||||
<script type="text/html" id="goods-info">
|
||||
<img src="{{d.image}}" style="height:60px;width: 60px" class="image-show"> {{d.name}}
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-hide">
|
||||
<input type="button" lay-submit lay-filter="select-submit" class="select-submit" id="select-submit" value="确认">
|
||||
</div>
|
||||
</div>
|
||||
<style>
|
||||
.layui-table-cell {
|
||||
height: auto;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
var table;
|
||||
layui.config({
|
||||
version:"{$front_version}",
|
||||
base: '/static/lib/' //静态资源所在路径
|
||||
}).use(['table','form'], function(){
|
||||
var $ = layui.$
|
||||
,form = layui.form
|
||||
,element = layui.element;
|
||||
|
||||
//监听搜索
|
||||
form.on('submit(goods-search)', function(data){
|
||||
var field = data.field;
|
||||
//执行重载
|
||||
table.reload('goods-lists', {
|
||||
where: field
|
||||
});
|
||||
});
|
||||
//清空查询
|
||||
form.on('submit(goods-clear-search)', function(){
|
||||
$('#keyword').val(''); //清空输入框
|
||||
$('#status_search').val(''); //清空输入框
|
||||
form.render('select');
|
||||
//刷新列表
|
||||
table.reload('goods-lists', {
|
||||
where: []
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
layui.define(['table', 'form'], function (exports) {
|
||||
var $ = layui.$
|
||||
, form = layui.form;
|
||||
table = layui.table;
|
||||
|
||||
table.render({
|
||||
id: 'goods-lists'
|
||||
, elem: '#goods-lists'
|
||||
, url: '{:url("hotList/goods")}' //模拟接口
|
||||
, cols: [[
|
||||
{type: 'radio'}
|
||||
, {field: 'name', title: '商品名称', toolbar: '#goods-info'}
|
||||
]]
|
||||
, page: true
|
||||
, text: {none: '暂无数据!'}
|
||||
, parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
|
||||
return {
|
||||
"code": res.code,
|
||||
"msg": res.msg,
|
||||
"count": res.data.count, //解析数据长度
|
||||
"data": res.data.lists, //解析数据列表
|
||||
};
|
||||
},
|
||||
response: {
|
||||
statusCode: 1
|
||||
}
|
||||
});
|
||||
})
|
||||
var callbackdata = function () {
|
||||
var data = table.checkStatus('goods-lists').data
|
||||
,index = parent.layer.getFrameIndex(window.name);
|
||||
parent.layer.close(index);
|
||||
return data;
|
||||
}
|
||||
|
||||
</script>
|
||||
181
app/admin/view/hot_list/lists.html
Normal file
181
app/admin/view/hot_list/lists.html
Normal file
@ -0,0 +1,181 @@
|
||||
{layout name="layout1" /}
|
||||
<style>
|
||||
.layui-table-cell {
|
||||
height: auto;
|
||||
white-space: normal;
|
||||
}
|
||||
</style>
|
||||
<div class="wrapper">
|
||||
<div class="layui-card">
|
||||
<div class="layui-tab layui-tab-card" lay-filter="tab-all">
|
||||
<div class="layui-tab-item layui-show">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<button type="button" id="add-mail-news" class="layui-btn layui-btn-normal layui-btn-sm layEvent">添加</button>
|
||||
<table id="like-table-lists" lay-filter="like-table-lists"></table>
|
||||
<script type="text/html" id="operation">
|
||||
<a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="audit">编辑</a>
|
||||
<a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del">删除</a>
|
||||
</script>
|
||||
<!-- 商品名称 -->
|
||||
<script type="text/html" id="goods-name">
|
||||
<div >
|
||||
{{d.goods.name}}
|
||||
</div>
|
||||
</script>
|
||||
<!-- 商品图片 -->
|
||||
<script type="text/html" id="goods-image">
|
||||
<div>
|
||||
<img src="{{d.goods.image}}" style="height:60px;width: 60px;margin-right: 5px;" class="image-show">
|
||||
</div>
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
layui.use(['table', 'laydate', 'form'], function () {
|
||||
var $ = layui.$
|
||||
, table = layui.table
|
||||
, element = layui.element
|
||||
, form = layui.form
|
||||
, status = 'all';
|
||||
|
||||
|
||||
form.on("submit(search)", function(data){
|
||||
table.reload("like-table-lists", {
|
||||
where: data.field,
|
||||
page: {
|
||||
curr: 1
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
form.on("submit(clear-search)", function(){
|
||||
$("#goods_name").val("");
|
||||
$("#shop_id").val("");
|
||||
form.render();
|
||||
table.reload("like-table-lists", {
|
||||
where: {},
|
||||
page: {
|
||||
curr: 1
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
getList();
|
||||
element.on('tab(tab-all)', function (data) {
|
||||
status = $(this).attr('data-type');
|
||||
getList();
|
||||
});
|
||||
|
||||
function getList() {
|
||||
like.tableLists("#like-table-lists", '{:url("hotList/lists")}', [
|
||||
{field: 'id', width: 80, title: 'ID', sort: true, hide: true}
|
||||
, {field: 'name', title: '商品名称', width: 300,templet: '#goods-name'}
|
||||
, {field: 'image', title: '商品图片', width: 200, align: 'center',templet: '#goods-image'}
|
||||
, {field: 'sort', title: '排序', width: 320, align: 'center'}
|
||||
, {fixed: 'right', title: '操作', width: 400, align: 'center', toolbar: '#operation'}
|
||||
]);
|
||||
}
|
||||
|
||||
//添加商品
|
||||
$(document).on('click', '#add-mail-news', function () {
|
||||
layer.open({
|
||||
type: 2
|
||||
, title: '添加商品'
|
||||
, content: '{:url("hotList/add")}'
|
||||
, area: ['90%', '90%']
|
||||
,btn: ['确定', '取消']
|
||||
, yes: function (index, layero) {
|
||||
var iframeWindow = window['layui-layer-iframe' + index]
|
||||
, submitID = 'addSubmit'
|
||||
, submit = layero.find('iframe').contents().find('#' + submitID);
|
||||
iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
|
||||
var field = data.field;
|
||||
like.ajax({
|
||||
url: '{:url("hotList/add")}',
|
||||
data: field,
|
||||
type: "post",
|
||||
success: function (res) {
|
||||
if (res.code === 1) {
|
||||
layui.layer.msg(res.msg, {offset: '15px', icon: 1, time: 1000});
|
||||
layer.close(index);
|
||||
table.reload('like-table-lists');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
submit.trigger('click');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//事件
|
||||
var active = {
|
||||
audit: function (obj) {
|
||||
layer.open({
|
||||
type: 2
|
||||
, title: '编辑'
|
||||
, content: '{:url("hotList/audit")}?id=' + obj.data.id
|
||||
, area: ['90%', '90%']
|
||||
,btn: ['确定', '取消']
|
||||
, yes: function (index, layero) {
|
||||
var iframeWindow = window['layui-layer-iframe' + index]
|
||||
, submitID = 'addSubmit'
|
||||
, submit = layero.find('iframe').contents().find('#' + submitID);
|
||||
iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
|
||||
var field = data.field;
|
||||
like.ajax({
|
||||
url: '{:url("hotList/audit")}',
|
||||
data: field,
|
||||
type: "post",
|
||||
success: function (res) {
|
||||
if (res.code === 1) {
|
||||
layui.layer.msg(res.msg, {offset: '15px', icon: 1, time: 1000});
|
||||
layer.close(index);
|
||||
table.reload('like-table-lists');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
submit.trigger('click');
|
||||
}
|
||||
});
|
||||
},
|
||||
// 删除
|
||||
del: function (obj) {
|
||||
layer.confirm('确定要删除该商品吗?', function (index) {
|
||||
like.ajax({
|
||||
url: '{:url("hotList/del")}',
|
||||
data: {id: obj.data.id},
|
||||
type: "post",
|
||||
success: function (res) {
|
||||
if (res.code === 1) {
|
||||
layui.layer.msg(res.msg, {offset: '15px', icon: 1, time: 1000});
|
||||
layer.close(index);
|
||||
obj.del();
|
||||
}
|
||||
}
|
||||
});
|
||||
layer.close(index);
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
// 监听表格右侧工具条
|
||||
table.on('tool(like-table-lists)', function (obj) {
|
||||
var type = obj.event;
|
||||
active[type] ? active[type].call(this, obj) : '';
|
||||
});
|
||||
|
||||
// 绑定点击按钮事件
|
||||
$('.layui-btn.layuiadmin-btn').on('click', function () {
|
||||
var type = $(this).data('type');
|
||||
active[type] ? active[type].call(this) : '';
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@ -90,7 +90,7 @@
|
||||
<label class="layui-form-label">商品:</label>
|
||||
<div class="layui-input-inline" style="display: flex">
|
||||
<div id="shop_name">{$detail.shop ? $detail.shop['name'] : ''}</div>
|
||||
<input type="hidden" id="shop_id" name="shop_id" style="margin-right: 10px;">
|
||||
<input type="hidden" id="shop_id" name="shop_id" style="margin-right: 10px;" value="{$detail.shop_id}">
|
||||
<a class="layui-btn layui-btn-normal select-goods">选择商品</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
80
app/admin/view/new_goods/audit.html
Normal file
80
app/admin/view/new_goods/audit.html
Normal file
@ -0,0 +1,80 @@
|
||||
{layout name="layout2" /}
|
||||
<style>
|
||||
.layui-form {padding: 20px 30px;background-color: #ffffff;}
|
||||
.layui-form-item .layui-form-label { width: 95px; }
|
||||
.layui-form-item .layui-input-inline { width: 240px; }
|
||||
.layui-form-item .map-container{ width: 600px; height: 400px; margin-left: 100px; margin-top: 20px; }
|
||||
#video-block {position: relative; width: 700px;height: 300px}
|
||||
.del-video-btn {
|
||||
visibility: hidden;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: absolute;
|
||||
z-index: 100;
|
||||
top: -11px;
|
||||
right: -9px;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
color: #FFFFFF;
|
||||
border-radius: 50%;
|
||||
background: hsla(0, 0%, 60%, .6)
|
||||
}
|
||||
.select-goods {margin-left: 10px}
|
||||
</style>
|
||||
|
||||
<div class="layui-card layui-form">
|
||||
<input type="hidden" value="{$detail.id}" name="id">
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">商品:</label>
|
||||
<div class="layui-input-inline" style="display: flex">
|
||||
<div id="shop_name">{$detail.goods['name']}</div>
|
||||
<input type="hidden" id="goods_id" name="goods_id" value="{$detail.goods_id}">
|
||||
<a class="layui-btn layui-btn-normal select-goods">选择商品</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label for="sort" class="layui-form-label">排序:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="sort" id="sort" autocomplete="off" class="layui-input" value="{$detail.sort}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-hide">
|
||||
<input type="button" lay-submit lay-filter="addSubmit" id="addSubmit" value="确认">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="__PUBLIC__/static/common/js/area.js"></script>
|
||||
<script>
|
||||
layui.config({
|
||||
base: "/static/lib/"
|
||||
}).extend({
|
||||
likeedit: "likeedit/likeedit",
|
||||
likeArea: "likeArea/likeArea",
|
||||
txMap: "likeMap/txMap"
|
||||
}).use(["form", "laydate", "likeArea", "txMap", 'likeedit', 'upload', 'element'], function(){
|
||||
var $ = layui.$;
|
||||
var form = layui.form;
|
||||
|
||||
// 选择商品
|
||||
$(document).on('click','.select-goods',function () {
|
||||
layer.open({
|
||||
type: 2
|
||||
,title: '选择商品'
|
||||
,content: '{:url("newGoods/goods")}'
|
||||
,area: ['90%', '90%']
|
||||
,btn: ['确认', '取消']
|
||||
,yes: function(index, layero){
|
||||
var data = window["layui-layer-iframe" + index].callbackdata();
|
||||
$('#shop_name').html(data[0].name)
|
||||
$('#goods_id').val(data[0].id)
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
</script>
|
||||
105
app/admin/view/new_goods/goods.html
Normal file
105
app/admin/view/new_goods/goods.html
Normal file
@ -0,0 +1,105 @@
|
||||
{layout name="layout1" /}
|
||||
<div class="layui-fluid">
|
||||
<div class="layui-card">
|
||||
<div class="layui-tab layui-tab-card" lay-filter="tab-all">
|
||||
<div class="layui-tab-item layui-show">
|
||||
<div class="layui-card">
|
||||
<div class="layui-form layui-card-header layuiadmin-card-header-auto">
|
||||
<div class="layui-form-item type">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">商品名称:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="goods_name" id="keyword" placeholder="请输入关键词" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<button class="layui-btn layuiadmin-btn-goods {$view_theme_color}" lay-submit lay-filter="goods-search">查询</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<table id="goods-lists" lay-filter="goods-lists"></table>
|
||||
<script type="text/html" id="goods-info">
|
||||
<img src="{{d.image}}" style="height:60px;width: 60px" class="image-show"> {{d.name}}
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-hide">
|
||||
<input type="button" lay-submit lay-filter="select-submit" class="select-submit" id="select-submit" value="确认">
|
||||
</div>
|
||||
</div>
|
||||
<style>
|
||||
.layui-table-cell {
|
||||
height: auto;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
var table;
|
||||
layui.config({
|
||||
version:"{$front_version}",
|
||||
base: '/static/lib/' //静态资源所在路径
|
||||
}).use(['table','form'], function(){
|
||||
var $ = layui.$
|
||||
,form = layui.form
|
||||
,element = layui.element;
|
||||
|
||||
//监听搜索
|
||||
form.on('submit(goods-search)', function(data){
|
||||
var field = data.field;
|
||||
//执行重载
|
||||
table.reload('goods-lists', {
|
||||
where: field
|
||||
});
|
||||
});
|
||||
//清空查询
|
||||
form.on('submit(goods-clear-search)', function(){
|
||||
$('#keyword').val(''); //清空输入框
|
||||
$('#status_search').val(''); //清空输入框
|
||||
form.render('select');
|
||||
//刷新列表
|
||||
table.reload('goods-lists', {
|
||||
where: []
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
layui.define(['table', 'form'], function (exports) {
|
||||
var $ = layui.$
|
||||
, form = layui.form;
|
||||
table = layui.table;
|
||||
|
||||
table.render({
|
||||
id: 'goods-lists'
|
||||
, elem: '#goods-lists'
|
||||
, url: '{:url("newGoods/goods")}' //模拟接口
|
||||
, cols: [[
|
||||
{type: 'radio'}
|
||||
, {field: 'name', title: '商品名称', toolbar: '#goods-info'}
|
||||
]]
|
||||
, page: true
|
||||
, text: {none: '暂无数据!'}
|
||||
, parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
|
||||
return {
|
||||
"code": res.code,
|
||||
"msg": res.msg,
|
||||
"count": res.data.count, //解析数据长度
|
||||
"data": res.data.lists, //解析数据列表
|
||||
};
|
||||
},
|
||||
response: {
|
||||
statusCode: 1
|
||||
}
|
||||
});
|
||||
})
|
||||
var callbackdata = function () {
|
||||
var data = table.checkStatus('goods-lists').data
|
||||
,index = parent.layer.getFrameIndex(window.name);
|
||||
parent.layer.close(index);
|
||||
return data;
|
||||
}
|
||||
|
||||
</script>
|
||||
181
app/admin/view/new_goods/lists.html
Normal file
181
app/admin/view/new_goods/lists.html
Normal file
@ -0,0 +1,181 @@
|
||||
{layout name="layout1" /}
|
||||
<style>
|
||||
.layui-table-cell {
|
||||
height: auto;
|
||||
white-space: normal;
|
||||
}
|
||||
</style>
|
||||
<div class="wrapper">
|
||||
<div class="layui-card">
|
||||
<div class="layui-tab layui-tab-card" lay-filter="tab-all">
|
||||
<div class="layui-tab-item layui-show">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<button type="button" id="add-mail-news" class="layui-btn layui-btn-normal layui-btn-sm layEvent">添加</button>
|
||||
<table id="like-table-lists" lay-filter="like-table-lists"></table>
|
||||
<script type="text/html" id="operation">
|
||||
<a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="audit">编辑</a>
|
||||
<a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del">删除</a>
|
||||
</script>
|
||||
<!-- 商品名称 -->
|
||||
<script type="text/html" id="goods-name">
|
||||
<div >
|
||||
{{d.goods.name}}
|
||||
</div>
|
||||
</script>
|
||||
<!-- 商品图片 -->
|
||||
<script type="text/html" id="goods-image">
|
||||
<div>
|
||||
<img src="{{d.goods.image}}" style="height:60px;width: 60px;margin-right: 5px;" class="image-show">
|
||||
</div>
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
layui.use(['table', 'laydate', 'form'], function () {
|
||||
var $ = layui.$
|
||||
, table = layui.table
|
||||
, element = layui.element
|
||||
, form = layui.form
|
||||
, status = 'all';
|
||||
|
||||
|
||||
form.on("submit(search)", function(data){
|
||||
table.reload("like-table-lists", {
|
||||
where: data.field,
|
||||
page: {
|
||||
curr: 1
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
form.on("submit(clear-search)", function(){
|
||||
$("#goods_name").val("");
|
||||
$("#shop_id").val("");
|
||||
form.render();
|
||||
table.reload("like-table-lists", {
|
||||
where: {},
|
||||
page: {
|
||||
curr: 1
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
getList();
|
||||
element.on('tab(tab-all)', function (data) {
|
||||
status = $(this).attr('data-type');
|
||||
getList();
|
||||
});
|
||||
|
||||
function getList() {
|
||||
like.tableLists("#like-table-lists", '{:url("newGoods/lists")}', [
|
||||
{field: 'id', width: 80, title: 'ID', sort: true, hide: true}
|
||||
, {field: 'name', title: '商品名称', width: 300,templet: '#goods-name'}
|
||||
, {field: 'image', title: '商品图片', width: 200, align: 'center',templet: '#goods-image'}
|
||||
, {field: 'sort', title: '排序', width: 320, align: 'center'}
|
||||
, {fixed: 'right', title: '操作', width: 400, align: 'center', toolbar: '#operation'}
|
||||
]);
|
||||
}
|
||||
|
||||
//添加商品
|
||||
$(document).on('click', '#add-mail-news', function () {
|
||||
layer.open({
|
||||
type: 2
|
||||
, title: '添加商品'
|
||||
, content: '{:url("newGoods/add")}'
|
||||
, area: ['90%', '90%']
|
||||
,btn: ['确定', '取消']
|
||||
, yes: function (index, layero) {
|
||||
var iframeWindow = window['layui-layer-iframe' + index]
|
||||
, submitID = 'addSubmit'
|
||||
, submit = layero.find('iframe').contents().find('#' + submitID);
|
||||
iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
|
||||
var field = data.field;
|
||||
like.ajax({
|
||||
url: '{:url("newGoods/add")}',
|
||||
data: field,
|
||||
type: "post",
|
||||
success: function (res) {
|
||||
if (res.code === 1) {
|
||||
layui.layer.msg(res.msg, {offset: '15px', icon: 1, time: 1000});
|
||||
layer.close(index);
|
||||
table.reload('like-table-lists');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
submit.trigger('click');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//事件
|
||||
var active = {
|
||||
audit: function (obj) {
|
||||
layer.open({
|
||||
type: 2
|
||||
, title: '编辑'
|
||||
, content: '{:url("newGoods/audit")}?id=' + obj.data.id
|
||||
, area: ['90%', '90%']
|
||||
,btn: ['确定', '取消']
|
||||
, yes: function (index, layero) {
|
||||
var iframeWindow = window['layui-layer-iframe' + index]
|
||||
, submitID = 'addSubmit'
|
||||
, submit = layero.find('iframe').contents().find('#' + submitID);
|
||||
iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
|
||||
var field = data.field;
|
||||
like.ajax({
|
||||
url: '{:url("newGoods/audit")}',
|
||||
data: field,
|
||||
type: "post",
|
||||
success: function (res) {
|
||||
if (res.code === 1) {
|
||||
layui.layer.msg(res.msg, {offset: '15px', icon: 1, time: 1000});
|
||||
layer.close(index);
|
||||
table.reload('like-table-lists');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
submit.trigger('click');
|
||||
}
|
||||
});
|
||||
},
|
||||
// 删除
|
||||
del: function (obj) {
|
||||
layer.confirm('确定要删除该商品吗?', function (index) {
|
||||
like.ajax({
|
||||
url: '{:url("newGoods/del")}',
|
||||
data: {id: obj.data.id},
|
||||
type: "post",
|
||||
success: function (res) {
|
||||
if (res.code === 1) {
|
||||
layui.layer.msg(res.msg, {offset: '15px', icon: 1, time: 1000});
|
||||
layer.close(index);
|
||||
obj.del();
|
||||
}
|
||||
}
|
||||
});
|
||||
layer.close(index);
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
// 监听表格右侧工具条
|
||||
table.on('tool(like-table-lists)', function (obj) {
|
||||
var type = obj.event;
|
||||
active[type] ? active[type].call(this, obj) : '';
|
||||
});
|
||||
|
||||
// 绑定点击按钮事件
|
||||
$('.layui-btn.layuiadmin-btn').on('click', function () {
|
||||
var type = $(this).data('type');
|
||||
active[type] ? active[type].call(this) : '';
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@ -290,14 +290,25 @@ class Goods extends Api
|
||||
}
|
||||
}
|
||||
|
||||
// 根据商品名称搜索
|
||||
public function searchByName()
|
||||
{
|
||||
if($this->request->isGet()) {
|
||||
$shop_name = $this->request->get('shop_name');
|
||||
$data = GoodsLogic::searchByName($shop_name);
|
||||
$data = GoodsLogic::searchByName($shop_name, $this->user_id);
|
||||
return JsonServer::success('获取成功', $data);
|
||||
}else{
|
||||
return JsonServer::error('请求方式错误');
|
||||
}
|
||||
}
|
||||
|
||||
// 2024-07-26 新版获取热销榜单
|
||||
public function hotList()
|
||||
{
|
||||
$page = $this->request->get('page_no', $this->page_no);
|
||||
$size = $this->request->get('page_size', $this->page_size);
|
||||
$list = GoodsLogic::hotList($page, $size);
|
||||
|
||||
return JsonServer::success('获取成功', $list);
|
||||
}
|
||||
}
|
||||
20
app/api/controller/HotList.php
Normal file
20
app/api/controller/HotList.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\basics\Api;
|
||||
use app\api\logic\HotListLogic;
|
||||
|
||||
class HotList extends Api
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
// 取6条数据,按照日销售
|
||||
|
||||
}
|
||||
|
||||
public function lists()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
13
app/api/controller/NewGoods.php
Normal file
13
app/api/controller/NewGoods.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\basics\Api;
|
||||
|
||||
class NewGoods extends Api
|
||||
{
|
||||
public function lists()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@ -31,6 +31,7 @@ use app\common\server\ConfigServer;
|
||||
use app\common\server\UrlServer;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
class GoodsLogic extends Logic
|
||||
{
|
||||
/**
|
||||
@ -854,10 +855,10 @@ class GoodsLogic extends Logic
|
||||
];
|
||||
}
|
||||
|
||||
public static function searchByName($shop_name)
|
||||
public static function searchByName($shop_name, $user_id)
|
||||
{
|
||||
if (!$shop_name) {
|
||||
return false;
|
||||
return [];
|
||||
}
|
||||
|
||||
$onSaleWhere = [
|
||||
@ -866,12 +867,87 @@ class GoodsLogic extends Logic
|
||||
'audit_status' => GoodsEnum::AUDIT_STATUS_OK, // 审核通过
|
||||
];
|
||||
|
||||
$where[] = ['name', 'like', '%' . $shop_name . '%'];
|
||||
$where[] = ['name', 'like', '%' . trim($shop_name) . '%'];
|
||||
|
||||
SearchRecord::create([
|
||||
'user_id'=>$user_id,
|
||||
'keyword'=>$shop_name,
|
||||
'count' => 1,
|
||||
'update_time' => time(),
|
||||
'del' => 0
|
||||
]);
|
||||
|
||||
$goods = Goods::field('id, name')
|
||||
->where($onSaleWhere)
|
||||
->where($where)
|
||||
->order('id desc')
|
||||
->select()->toArray();
|
||||
if ($goods) {
|
||||
return $goods;
|
||||
}
|
||||
|
||||
return $goods;
|
||||
return [];
|
||||
}
|
||||
|
||||
public static function hotList($page, $size)
|
||||
{
|
||||
$hot_list = [];
|
||||
if ($page == 1) {
|
||||
$hot_list = Db::name('hot_list')
|
||||
->alias('hl')
|
||||
->join('goods g', 'hl.goods_id = g.id')
|
||||
->where('delete_time', 0)
|
||||
->field('hl.id as hl_id, hl.goods_id, g.id as id, g.name, g.image, g.issuing_price, g.market_price, g.min_price, g.purchase_price, g.wholesale_price')
|
||||
->select()
|
||||
->toArray();
|
||||
foreach ($hot_list as &$v) {
|
||||
if (isset($v['image'])) {
|
||||
$v['image'] = UrlServer::getFileUrl($v['image']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$where[] = ['og.create_time', '>=', strtotime("today")];
|
||||
$where[] = ['og.create_time', '<=', strtotime("tomorrow") - 1];
|
||||
|
||||
$order_goods = Db::name('order_goods')
|
||||
->alias('og')
|
||||
->join('goods g', 'og.goods_id = g.id')
|
||||
->where($where)
|
||||
->field('og.goods_id, count(*) as count, g.id as gid, g.name, g.image, g.issuing_price, g.market_price, g.min_price, g.purchase_price, g.wholesale_price')
|
||||
->group('og.goods_id')
|
||||
->order('count desc, og.create_time desc')
|
||||
->page($page, $size)
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$count = Db::name('order_goods')
|
||||
->alias('og')
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
foreach ($order_goods as &$v) {
|
||||
if (isset($v['image'])) {
|
||||
$v['image'] = UrlServer::getFileUrl($v['image']);
|
||||
}
|
||||
}
|
||||
|
||||
$more = is_more($count, $page, $size); //是否有下一页
|
||||
|
||||
$list = $order_goods;
|
||||
if ($page == 1) {
|
||||
$list = array_merge($hot_list, $order_goods);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'lists' => $list,
|
||||
'hot_list' => $hot_list,
|
||||
'page_no' => $page,
|
||||
'page_size' => $size,
|
||||
'count' => $count,
|
||||
'more' => $more
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
21
app/api/logic/HotListLogic.php
Normal file
21
app/api/logic/HotListLogic.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\logic;
|
||||
|
||||
use app\common\basics\Logic;
|
||||
use think\facade\Db;
|
||||
|
||||
class HotListLogic extends Logic
|
||||
{
|
||||
public static function index()
|
||||
{
|
||||
$result = Db::name('hot_list')
|
||||
->alias('hl')
|
||||
->join('goods g', 'hl.goods_id = g.id')
|
||||
->where('delete_time', 0)
|
||||
->field('hl.*, g.id as gid, g.name, g.image, g.issuing_price, g.market_price, g.min_price, g.purchase_price, g.wholesale_price')
|
||||
->limit(6)
|
||||
->select();
|
||||
|
||||
}
|
||||
}
|
||||
@ -230,6 +230,10 @@ class IndexLogic extends Logic
|
||||
}
|
||||
}
|
||||
|
||||
// 热销榜单
|
||||
$hot_list = self::getIndexHotList();
|
||||
|
||||
|
||||
return [
|
||||
'headlines' => $headlines,
|
||||
'hots' => $hots,
|
||||
@ -243,6 +247,7 @@ class IndexLogic extends Logic
|
||||
'set_price_type'=>$set_price_type,
|
||||
// 'mall_news' => [],
|
||||
'mall_news' => $mall_news,
|
||||
'hot_list' => $hot_list,
|
||||
];
|
||||
}
|
||||
|
||||
@ -965,4 +970,42 @@ class IndexLogic extends Logic
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
private static function getIndexHotList()
|
||||
{
|
||||
$hot_list = Db::name('hot_list')
|
||||
->alias('hl')
|
||||
->join('goods g', 'hl.goods_id = g.id')
|
||||
->where('delete_time', 0)
|
||||
->field('hl.*, g.id as gid, g.name, g.image, g.issuing_price, g.market_price, g.min_price, g.purchase_price, g.wholesale_price')
|
||||
->limit(6)
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$count = count($hot_list);
|
||||
if ($count < 6) {
|
||||
$where[] = ['og.create_time', '>=', strtotime("today")];
|
||||
$where[] = ['og.create_time', '<=', strtotime("tomorrow") - 1];
|
||||
|
||||
$order_goods = Db::name('order_goods')
|
||||
->alias('og')
|
||||
->join('goods g', 'og.goods_id = g.id')
|
||||
->where($where)
|
||||
->field('og.goods_id, count(*) as count, g.id as gid, g.name, g.image, g.issuing_price, g.market_price, g.min_price, g.purchase_price, g.wholesale_price')
|
||||
->group('og.goods_id')
|
||||
->limit(6 - $count)
|
||||
->order('count desc, og.create_time desc')
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
$result = array_merge($hot_list, $order_goods);
|
||||
foreach ($result as &$v) {
|
||||
if (isset($v['image'])) {
|
||||
$v['image'] = UrlServer::getFileUrl($v['image']);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
10
app/api/logic/NewGoodsLogic.php
Normal file
10
app/api/logic/NewGoodsLogic.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\logic;
|
||||
|
||||
use app\common\basics\Logic;
|
||||
|
||||
class NewGoodsLogic extends Logic
|
||||
{
|
||||
|
||||
}
|
||||
16
app/common/model/HotList.php
Normal file
16
app/common/model/HotList.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use app\common\basics\Models;
|
||||
use app\common\model\goods\Goods;
|
||||
|
||||
class HotList extends Models
|
||||
{
|
||||
protected $table = 'ls_hot_list';
|
||||
|
||||
public function goods()
|
||||
{
|
||||
return $this->belongsTo(Goods::class,'goods_id', 'id')->field('id, name, image');
|
||||
}
|
||||
}
|
||||
16
app/common/model/NewGoods.php
Normal file
16
app/common/model/NewGoods.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use app\common\basics\Models;
|
||||
use app\common\model\goods\Goods;
|
||||
|
||||
class NewGoods extends Models
|
||||
{
|
||||
protected $table = 'ls_new_goods';
|
||||
|
||||
public function goods()
|
||||
{
|
||||
return $this->belongsTo(Goods::class,'goods_id', 'id')->field('id, name, image');
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user