切换导航条
此项目
正在载入...
登录
李忠强
/
temporaryfood
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
何书鹏
3 years ago
提交
8471a51518e259cab6066bd2c4192d6940b00e84
1 个父辈
cca83e3a
发送优惠券
隐藏空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
74 行增加
和
7 行删除
application/admin/controller/Coupon.php
application/admin/controller/litestore/Litestoreorder.php
application/admin/view/coupon/send_coupon.html
application/admin/view/litestore/litestoreorder/render.html → application/admin/view/litestore/litestoreorder/rider.html
public/assets/js/backend/coupon.js
public/assets/js/backend/litestore/litestoreorder.js
application/admin/controller/Coupon.php
查看文件 @
8471a51
...
...
@@ -3,6 +3,7 @@
namespace
app\admin\controller
;
use
app\common\controller\Backend
;
use
think\Db
;
/**
* 优惠券
...
...
@@ -35,6 +36,38 @@ class Coupon extends Backend
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
/**
* 发送优惠券
*/
public
function
send_coupon
()
{
if
(
$this
->
request
->
isPost
())
{
$params
=
$this
->
request
->
post
(
"row/a"
);
if
(
$params
)
{
$user_ids
=
$params
[
'user_ids'
];
empty
(
$user_ids
)
&&
$this
->
error
(
'请选择用户'
);
$coupon_id
=
$this
->
request
->
get
(
'coupon_id'
);
empty
(
$coupon_id
)
&&
$this
->
error
(
'请选择优惠券'
);
$coupon
=
$this
->
model
->
where
(
'id'
,
$coupon_id
)
->
field
(
'id,name,price,full_price,days'
)
->
find
();
$add_data
=
[];
$time
=
time
();
foreach
(
explode
(
','
,
$user_ids
)
as
$user_id
){
$add_data
[]
=
[
'user_id'
=>
$user_id
,
'coupon_id'
=>
$coupon
[
'id'
],
'name'
=>
$coupon
[
'name'
],
'price'
=>
$coupon
[
'price'
],
'full_price'
=>
$coupon
[
'full_price'
],
'endtime'
=>
$time
+
$coupon
[
'days'
]
*
86400
,
'createtime'
=>
$time
,
];
}
Db
::
name
(
'user_coupon'
)
->
insertAll
(
$add_data
);
$this
->
success
();
}
$this
->
error
(
__
(
'Parameter %s can not be empty'
,
''
));
}
return
$this
->
view
->
fetch
();
}
}
...
...
application/admin/controller/litestore/Litestoreorder.php
查看文件 @
8471a51
...
...
@@ -2,6 +2,7 @@
namespace
app\admin\controller\litestore
;
use
app\api\model\User
;
use
app\api\model\RiderOrder
;
use
app\common\controller\Backend
;
...
...
@@ -27,6 +28,8 @@ class Litestoreorder extends Backend
$this
->
view
->
assign
(
"freightStatusList"
,
$this
->
model
->
getFreightStatusList
());
$this
->
view
->
assign
(
"receiptStatusList"
,
$this
->
model
->
getReceiptStatusList
());
$this
->
view
->
assign
(
"orderStatusList"
,
$this
->
model
->
getOrderStatusList
());
$riderList
=
User
::
where
(
'rider'
,
'2'
)
->
column
(
'nickname'
,
'id'
);
$this
->
assignConfig
(
"riderList"
,
$riderList
);
}
/**
...
...
@@ -67,11 +70,12 @@ class Litestoreorder extends Backend
->
select
();
foreach
(
$list
as
$row
)
{
$row
->
visible
([
'id'
,
'order_no'
,
'total_price'
,
'pay_price'
,
'pay_status'
,
'pay_time'
,
'express_price'
,
'freight_status'
,
'freight_time'
,
'receipt_time'
,
'order_status'
,
'updatetime'
]);
$row
->
visible
([
'id'
,
'order_no'
,
'total_price'
,
'pay_price'
,
'pay_status'
,
'pay_time'
,
'express_price'
,
'freight_status'
,
'freight_time'
,
'receipt_time'
,
'order_status'
,
'
rider_user_id'
,
'
updatetime'
]);
$row
->
visible
([
'address'
]);
$row
->
getRelation
(
'address'
)
->
visible
([
'name'
]);
$row
->
visible
([
'rider'
]);
$row
->
getRelation
(
'rider'
)
->
visible
([
'nickname'
]);
$row
->
rider_user_id
=
$row
->
rider_user_id
>
0
?
$row
->
rider_user_id
:
''
;
}
$list
=
collection
(
$list
)
->
toArray
();
$result
=
array
(
"total"
=>
$total
,
"rows"
=>
$list
);
...
...
@@ -109,7 +113,7 @@ class Litestoreorder extends Backend
}
// 快捷匹配骑手
public
function
r
en
der
(){
public
function
r
i
der
(){
if
(
$this
->
request
->
isPost
())
{
$id
=
input
(
'get.ids'
);
...
...
application/admin/view/coupon/send_coupon.html
0 → 100644
查看文件 @
8471a51
<form
id=
"add-form"
class=
"form-horizontal"
role=
"form"
data-toggle=
"validator"
method=
"POST"
action=
""
>
<div
class=
"form-group"
>
<label
class=
"control-label col-xs-12 col-sm-2"
>
{:__('选择用户')}:
</label>
<div
class=
"col-xs-12 col-sm-8"
>
<input
id=
"c-user_ids"
data-rule=
"required"
data-source=
"user/user/index"
data-field=
"nickname"
data-multiple=
"true"
class=
"form-control selectpage"
name=
"row[user_ids]"
type=
"text"
value=
""
>
</div>
</div>
<div
class=
"form-group layer-footer"
>
<label
class=
"control-label col-xs-12 col-sm-2"
></label>
<div
class=
"col-xs-12 col-sm-8"
>
<button
type=
"submit"
class=
"btn btn-success btn-embossed disabled"
>
{:__('OK')}
</button>
<button
type=
"reset"
class=
"btn btn-default btn-embossed"
>
{:__('Reset')}
</button>
</div>
</div>
</form>
...
...
application/admin/view/litestore/litestoreorder/r
en
der.html → application/admin/view/litestore/litestoreorder/r
i
der.html
查看文件 @
8471a51
public/assets/js/backend/coupon.js
查看文件 @
8471a51
...
...
@@ -37,7 +37,17 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{
field
:
'days'
,
title
:
__
(
'Days'
)},
{
field
:
'createtime'
,
title
:
__
(
'Createtime'
),
operate
:
'RANGE'
,
addclass
:
'datetimerange'
,
autocomplete
:
false
,
formatter
:
Table
.
api
.
formatter
.
datetime
},
{
field
:
'endtime'
,
title
:
__
(
'Endtime'
),
operate
:
'RANGE'
,
addclass
:
'datetimerange'
,
autocomplete
:
false
,
formatter
:
Table
.
api
.
formatter
.
datetime
},
{
field
:
'operate'
,
title
:
__
(
'Operate'
),
table
:
table
,
events
:
Table
.
api
.
events
.
operate
,
formatter
:
Table
.
api
.
formatter
.
operate
}
{
field
:
'operate'
,
title
:
__
(
'Operate'
),
table
:
table
,
events
:
Table
.
api
.
events
.
operate
,
formatter
:
Table
.
api
.
formatter
.
operate
,
buttons
:
[
{
name
:
'send_coupon'
,
text
:
'发送优惠券'
,
classname
:
'btn btn-info btn-xs btn-dialog'
,
icon
:
'fa fa-plus'
,
url
:
'coupon/send_coupon?coupon_id={ids}'
}
]
}
]
]
});
...
...
@@ -51,6 +61,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
edit
:
function
()
{
Controller
.
api
.
bindevent
();
},
send_coupon
:
function
()
{
Controller
.
api
.
bindevent
();
},
api
:
{
bindevent
:
function
()
{
Form
.
api
.
bindevent
(
$
(
"form[role=form]"
));
...
...
public/assets/js/backend/litestore/litestoreorder.js
查看文件 @
8471a51
...
...
@@ -43,6 +43,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
field
:
'rider.nickname'
,
title
:
__
(
'选择配送骑手'
),
table
:
table
,
operate
:
false
,
events
:
Table
.
api
.
events
.
operate
,
buttons
:
[
{
...
...
@@ -51,7 +52,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
title
:
__
(
'选择配送骑手'
),
classname
:
'btn btn-xs btn-primary btn-dialog'
,
icon
:
'fa fa-fighter-jet'
,
url
:
'litestore/litestoreorder/r
en
der?ids={ids}'
,
url
:
'litestore/litestoreorder/r
i
der?ids={ids}'
,
callback
:
function
(
data
)
{
Layer
.
alert
(
"接收到回传数据:"
+
JSON
.
stringify
(
data
),
{
title
:
"回传数据"
});
},
...
...
@@ -65,7 +66,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
],
formatter
:
Table
.
api
.
formatter
.
buttons
},
{
field
:
'rider
.nickname'
,
title
:
__
(
'骑手'
)
},
{
field
:
'rider
_user_id'
,
title
:
__
(
'骑手'
),
searchList
:
Config
.
riderList
,
operate
:
'IN'
,
formatter
:
Table
.
api
.
formatter
.
flag
},
{
field
:
'operate'
,
title
:
__
(
'Operate'
),
table
:
table
,
buttons
:
[
{
name
:
'send'
,
text
:
__
(
'view'
),
icon
:
'fa fa-eye'
,
classname
:
'btn btn-xs btn-warning btn-dialog chakan'
,
url
:
'litestore/litestoreorder/detail'
},
],
events
:
Table
.
api
.
events
.
operate
,
formatter
:
Table
.
api
.
formatter
.
operate
}
...
...
@@ -116,7 +117,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
});
Controller
.
api
.
bindevent
();
},
r
en
der
:
function
()
{
r
i
der
:
function
()
{
Controller
.
api
.
bindevent
();
},
api
:
{
...
...
请
注册
或
登录
后发表评论