Compare commits
2 Commits
a93dc86036
...
ba7be8797b
Author | SHA1 | Date |
---|---|---|
wangxinglong | ba7be8797b | |
wangxinglong | 794aaf0abd |
|
@ -90,10 +90,54 @@ class Coupon extends Base
|
|||
return $this->json(4001, "优惠券不存在");
|
||||
}
|
||||
|
||||
if (in_array($on_shelf, [CouponMain::COMMON_OFF, CouponMain::COMMON_ON])) {
|
||||
if (!in_array($on_shelf, [CouponMain::COMMON_OFF, CouponMain::COMMON_ON])) {
|
||||
return $this->json(4001, "状态错误");
|
||||
}
|
||||
$coupon->save(["on_shelf"=>$on_shelf]);
|
||||
$coupon->save(["on_shelf" => $on_shelf]);
|
||||
return $this->json();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @return Json|View
|
||||
* @throws Exception
|
||||
*/
|
||||
public function info()
|
||||
{
|
||||
|
||||
if ($this->request->isPost()) {
|
||||
$model = new CouponMain();
|
||||
$repo = CouponRepository::getInstance($model);
|
||||
$id = input("id/d");
|
||||
$keyword = $this->request->param('keyword/s', '');
|
||||
$page = $this->request->param('page/d', 1);
|
||||
$size = $this->request->param('size/d', 30);
|
||||
|
||||
$list = $repo->couponMainHasList($id, $keyword, $page, $size);
|
||||
$time = time();
|
||||
$list["list"]->each(function ($item) use ($time) {
|
||||
if (strtotime($item['end_time']) < $time) {
|
||||
$item->time_state = '已过期';
|
||||
} else {
|
||||
$item->time_state = '未过期';
|
||||
}
|
||||
|
||||
});
|
||||
return $this->json(0, 'success', $list);
|
||||
}
|
||||
$id = input("id/d");
|
||||
$model = new CouponMain();
|
||||
$repo = CouponRepository::getInstance($model);
|
||||
$coupon = $repo->getModel()->with(["business" => function ($query) {
|
||||
$query->field("code,business_name,business_subtitle,type")
|
||||
->with('category');
|
||||
}, "couponType"])->where("id", $id)->find();
|
||||
if (empty($coupon)) {
|
||||
return $this->error("优惠券不存在");
|
||||
}
|
||||
$this->data["coupon"] = $coupon;
|
||||
return $this->view();
|
||||
}
|
||||
|
||||
}
|
|
@ -23,4 +23,13 @@ class Coupon extends Base
|
|||
{
|
||||
return $this->hasOne(CouponBill::class,"coupon_id","id");
|
||||
}
|
||||
public function account()
|
||||
{
|
||||
return $this->hasOne(Account::class,"user_code","consumer_code");
|
||||
}
|
||||
|
||||
public function business()
|
||||
{
|
||||
return $this->hasOne(Business::class,"code","business_code");
|
||||
}
|
||||
}
|
|
@ -23,4 +23,8 @@ class CouponMain extends Base
|
|||
{
|
||||
return $this->hasOne(Business::class, 'code',"business_code");
|
||||
}
|
||||
public function couponType()
|
||||
{
|
||||
return $this->hasOne(CouponType::class, 'id',"type_id");
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@
|
|||
namespace app\repository;
|
||||
|
||||
use app\exception\RepositoryException;
|
||||
use app\model\Coupon;
|
||||
use app\model\CouponMain;
|
||||
use app\service\Repository;
|
||||
use think\Model;
|
||||
|
@ -17,16 +18,29 @@ use think\Model;
|
|||
class CouponRepository extends Repository
|
||||
{
|
||||
/**
|
||||
* 优惠券列表
|
||||
* 优惠券持有信息列表
|
||||
*
|
||||
* @param string $businessCode 商家code
|
||||
* @param array $order
|
||||
* @param $id
|
||||
* @param $keyword
|
||||
* @param $page
|
||||
* @param $size
|
||||
* @return array
|
||||
* @throws RepositoryException
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function businessCouponModel($where)
|
||||
public function couponMainHasList($id, $keyword, $page, $size)
|
||||
{
|
||||
return CouponMain::where($where);
|
||||
|
||||
return Coupon::findList(["id" => $id], [], $page, $size, function ($q) use ($keyword) {
|
||||
if (!empty($keyword)) {
|
||||
return $q::hasWhere('account', function ($q) use ($keyword) {
|
||||
$q->where('nick_name', 'like', "%" . $keyword . "%")->field("nick_name,avatar_url");
|
||||
});
|
||||
} else {
|
||||
return $q->with(["account" => function ($query) {
|
||||
$query->field("nick_name,avatar_url");
|
||||
}]);
|
||||
}
|
||||
}, ["id" => "desc"]);
|
||||
}
|
||||
|
||||
}
|
|
@ -42,7 +42,6 @@ layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect'], function
|
|||
{templet: '#row-received_map', title: '领取位置'},
|
||||
{field: 'money', title: '金额'},
|
||||
{field: 'business_name', title: '商家名称'},
|
||||
{field: 'business_name', title: '商家名称'},
|
||||
{templet: '#row-sign_map', title: '签到位置'},
|
||||
{templet: '#row-state', title: '状态'},
|
||||
]],
|
||||
|
|
|
@ -92,7 +92,30 @@ layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect','laydate']
|
|||
elem: '#end_time'
|
||||
,type: 'date'
|
||||
});
|
||||
//监听工具条
|
||||
table.on('tool(table-container)', function (obj) {
|
||||
let data = obj.data;
|
||||
let layEvent = obj.event;
|
||||
let url = $($(this).context).data('href');
|
||||
let title = $($(this).context).data('title');
|
||||
let width = $($(this).context).data('width') ? $($(this).context).data('width') : '100%';
|
||||
let height = $($(this).context).data('height') ? $($(this).context).data('height') : '100%';
|
||||
let insTb = Tools.getInsTb();
|
||||
|
||||
if (layEvent === 'shelf') {
|
||||
$.post(url, null, function (res) {
|
||||
layer.msg(res.msg)
|
||||
if (res.code === 0) {
|
||||
insTb.reload();
|
||||
}
|
||||
})
|
||||
return false;
|
||||
}
|
||||
if (layEvent === 'info') {
|
||||
openLayer(url, title, width, height);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
/*** index end ***/
|
||||
|
|
|
@ -37,14 +37,19 @@ layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect'], function
|
|||
cols: [[
|
||||
// {type: 'checkbox'},
|
||||
{field: 'id' , width: 80, title: 'ID'},
|
||||
{field: 'name', title: '名称'},
|
||||
{field: 'type_name', title: '优惠券类型'},
|
||||
{templet: '#row-received_map', title: '领取位置'},
|
||||
{field: 'money', title: '金额'},
|
||||
{field: 'business_name', title: '商家名称'},
|
||||
{field: 'business_name', title: '商家名称'},
|
||||
{templet: '#row-sign_map', title: '签到位置'},
|
||||
{templet: '#row-cover', title: '头像'},
|
||||
{templet:function(d){
|
||||
if(d.account!=undefined&&d.account){
|
||||
return d.account.nick_name;
|
||||
}
|
||||
return d.consumer_name;
|
||||
}, title: '昵称'},
|
||||
|
||||
{field: 'received_time', title: '领取时间'},
|
||||
|
||||
|
||||
{templet: '#row-state', title: '状态'},
|
||||
{field: 'verificate_time', title: '验证时间'},
|
||||
]],
|
||||
done: function () {
|
||||
Tools.setInsTb(insTb);
|
||||
|
|
|
@ -87,7 +87,7 @@
|
|||
|
||||
<!-- 操作列 -->
|
||||
<script type="text/html" id="row-operate">
|
||||
<a class="layui-btn layui-btn-primary layui-btn-xs" data-href="/manager/coupon/info.html?id={{d.id}}" data-title="消费者【{{ d.nick_name }}】领取日志" lay-event="">领取日志</a>
|
||||
<a class="layui-btn layui-btn-primary layui-btn-xs" data-href="/manager/coupon/info.html?id={{d.id}}" data-title="【{{ d.name }}】详情" lay-event="info">详情</a>
|
||||
{{# if(d.on_shelf == 1){ }}
|
||||
<a class="layui-btn layui-btn-primary layui-btn-xs" data-href="/manager/coupon/shelf.html?id={{d.id}}&&on_shelf=0" lay-event="shelf">上架</a>
|
||||
{{# }else{ }}
|
||||
|
@ -101,7 +101,7 @@
|
|||
</script>
|
||||
<!-- 列 性别 -->
|
||||
<script type="text/html" id="row-on_shelf">
|
||||
{{# if(d.gender==1){ }}
|
||||
{{# if(d.on_shelf==1){ }}
|
||||
下架
|
||||
{{# }else{ }}
|
||||
上架
|
||||
|
|
|
@ -26,63 +26,89 @@
|
|||
<div class="layui-row layui-col-space15">
|
||||
<div class="layui-col-md2">
|
||||
<div class="layui-col-md12">
|
||||
|
||||
<div class="layui-layer-photos">
|
||||
<img id="avatar" src="{$consumer.avatar_url}" layer-src="{$consumer.avatar_url}" alt="">
|
||||
<img id="avatar" src="{$coupon.image_url}" layer-src="{$coupon.image_url}" alt="">
|
||||
<img id="avatar" src="http://yhq.taikoosoft.com:8888/2020-12-08/50b734a826b955fd42d19acddce63b84.jpg" layer-src="http://yhq.taikoosoft.com:8888/2020-12-08/50b734a826b955fd42d19acddce63b84.jpg" alt="">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-md10">
|
||||
<div class="layui-col-md12">
|
||||
<div class="layui-col-md4">
|
||||
<div class="layui-panel" style="border-radius: 8px;">
|
||||
<div class="layui-row" style="padding: 5% 0;text-align: center">
|
||||
<h3><strong>评论数</strong></h3>
|
||||
<span style="font-size: 36px">{$totalComment ?? 0}</span>
|
||||
<div class="layui-row" >
|
||||
<div class="layui-panel layui-row" style="border-radius: 8px;padding: 8px; ">
|
||||
<div class="layui-inline layui-col-md6">
|
||||
<label class="layui-form-label">名称</label>
|
||||
<div class="layui-inline">
|
||||
<input type="text" name="keyword" disabled class="layui-input" value="{$coupon['name']}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-md4">
|
||||
<div class="layui-panel" style="border-radius: 8px;">
|
||||
<div class="layui-row" style="padding: 5% 0;text-align: center">
|
||||
<h3><strong>本月评论数</strong></h3>
|
||||
<span style="font-size: 36px">{$totalTheMonthComment ?? 0}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-md4">
|
||||
<div class="layui-panel" style="border-radius: 8px;">
|
||||
<div class="layui-row" style="padding: 5% 0;text-align: center">
|
||||
<h3><strong>标签</strong></h3>
|
||||
<span style="font-size: 32px">{$consumer["tag"]["name"] ?? '无'}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-md4">
|
||||
<div class="layui-panel" style="border-radius: 8px;">
|
||||
<div class="layui-row" style="padding: 5% 0;text-align: center">
|
||||
<h3><strong>优惠券领取总数</strong></h3>
|
||||
<span style="font-size: 36px">{$couponTotalCount ?? 0}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-md4">
|
||||
<div class="layui-panel" style="border-radius: 8px;">
|
||||
<div class="layui-row" style="padding: 5% 0;text-align: center">
|
||||
<h3><strong>优惠券使用总数</strong></h3>
|
||||
<span style="font-size: 36px">{$couponUsedTotalCount ?? 0}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-md4">
|
||||
<div class="layui-panel" style="border-radius: 8px;">
|
||||
<div class="layui-row" style="padding: 5% 0;text-align: center">
|
||||
<h3><strong>优惠券未使用总数</strong></h3>
|
||||
<span style="font-size: 36px">{$couponNotUsedTotalCount ?? 0}</span>
|
||||
</div>
|
||||
<div class="layui-inline layui-col-md6">
|
||||
<label class="layui-form-label">商家名称</label>
|
||||
<div class="layui-inline">
|
||||
<input type="text" name="keyword" disabled class="layui-input" value="{$coupon['business']['business_name']??''}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline layui-col-md6">
|
||||
<label class="layui-form-label">优惠券类型</label>
|
||||
<div class="layui-inline">
|
||||
<input type="text" name="keyword" disabled class="layui-input" value="{$coupon['couponType']['name']??$coupon['type_name']}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="layui-inline layui-col-md6">
|
||||
<label class="layui-form-label">优惠券金额</label>
|
||||
<div class="layui-inline">
|
||||
<input type="text" name="keyword" disabled class="layui-input" value="{$coupon['money']}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline layui-col-md6">
|
||||
<label class="layui-form-label">优惠券数量</label>
|
||||
<div class="layui-inline">
|
||||
<input type="text" name="keyword" disabled class="layui-input" value="{$coupon['count']}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline layui-col-md6">
|
||||
<label class="layui-form-label">扣除金额</label>
|
||||
<div class="layui-inline">
|
||||
<input type="text" name="keyword" disabled class="layui-input" value="{$coupon['deduction_money']}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="layui-inline layui-col-md6">
|
||||
<label class="layui-form-label">开始时间</label>
|
||||
<div class="layui-inline">
|
||||
<input type="text" name="keyword" disabled class="layui-input" value="{$coupon['start_time']}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="layui-inline layui-col-md6">
|
||||
<label class="layui-form-label">结束时间</label>
|
||||
<div class="layui-inline">
|
||||
<input type="text" name="keyword" disabled class="layui-input" value="{$coupon['end_time']}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">使用规则</label>
|
||||
<div class="layui-inline">
|
||||
<textarea name="" cols="100" rows="3" disabled>{$coupon['using_rule']}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">处罚规则</label>
|
||||
<div class="layui-inline">
|
||||
<textarea name="" cols="100" rows="3" disabled>{$coupon['punishing_rule']}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -95,7 +121,7 @@
|
|||
<div class="layuimini-container location-index-page">
|
||||
<div class="layuimini-main">
|
||||
<div>
|
||||
<table id="table-container" class="layui-table" data-url="/manager/consumer/info.html?id={$consumer.id}&&sign={$sign}" lay-filter="table-container"></table>
|
||||
<table id="table-container" class="layui-table" data-url="/manager/coupon/info.html?id={$coupon.id}" lay-filter="table-container"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -106,12 +132,10 @@
|
|||
|
||||
<!-- 操作列 -->
|
||||
<script type="text/html" id="row-state">
|
||||
{{ d.time_state }}
|
||||
|
|
||||
{{# if(d.is_verificated == 1){ }}
|
||||
已验证
|
||||
{{# }else{ }}
|
||||
未验证
|
||||
未使用
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
|
@ -130,5 +154,11 @@
|
|||
<a class="layui-btn layui-btn-primary layui-btn-sm" data-table-refresh lay-event="refresh"><i class="fa fa-refresh"></i></a>
|
||||
</script>
|
||||
|
||||
<!-- 列 轮播图 -->
|
||||
<script type="text/html" id="row-cover">
|
||||
<div class="layui-layer-photos">
|
||||
<img src="{{ d.account?d.account.avatar_url:'' }}" layer-src="{{ d.account?d.account.avatar_url:'' }}" alt="">
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script src="__MANAGER__/js/consumer/info.js?v={:mt_rand()}"></script>
|
||||
<script src="__MANAGER__/js/coupon/info.js?v={:mt_rand()}"></script>
|
Loading…
Reference in New Issue