Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujun
tl_estate
Commits
58334147
Commit
58334147
authored
Mar 13, 2019
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
返现红包列表
parent
803c13e3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
4 deletions
+58
-4
Coupon.php
application/api/controller/Coupon.php
+34
-0
CouponService.php
application/api/service/CouponService.php
+22
-4
route.php
application/route.php
+2
-0
No files found.
application/api/controller/Coupon.php
View file @
58334147
...
...
@@ -70,4 +70,37 @@ class Coupon extends Basic{
}
return
$this
->
response
(
200
,
''
,
$data
);
}
/**
* 返现红包列表
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
couponList
()
{
$page_no
=
empty
(
$this
->
params
[
'page_no'
])
?
1
:
$this
->
params
[
'page_no'
];
$page_size
=
empty
(
$this
->
params
[
'page_size'
])
?
15
:
$this
->
params
[
'page_size'
];
if
(
empty
(
$this
->
userId
))
{
return
$this
->
response
(
101
,
'参数错误'
);
}
$data
=
[];
$where
[
'user_id'
]
=
$this
->
userId
;
$where
[
'user_id'
]
=
1
;
$field
=
'rule_no,activity_id,status,create_time'
;
$list
=
$this
->
m_coupon
->
getList
(
$page_no
,
$page_size
,
'id desc'
,
$field
,
$where
);
$field_activity
=
'title,money,use_period'
;
foreach
(
$list
as
$k
=>
$v
)
{
$data
[
$k
][
'id'
]
=
$v
[
'rule_no'
];
$data
[
$k
][
'status'
]
=
$v
[
'status'
];
$activity_data
=
$this
->
m_activity
->
getFind
(
$field_activity
,
[
'id'
=>
$v
[
'activity_id'
]]);
$create_time
=
strtotime
(
$v
[
'create_time'
]);
$validity
=
$create_time
+
$activity_data
[
'use_period'
]
*
86400
;
$data
[
$k
][
'validity'
]
=
date
(
'Y.m.d'
,
$create_time
)
.
'-'
.
date
(
'Y.m.d'
,
$validity
);
$data
[
$k
][
'money'
]
=
$activity_data
[
'money'
];
$data
[
$k
][
'title'
]
=
$activity_data
[
'title'
];
}
return
$this
->
response
(
200
,
''
,
$data
);
}
}
\ No newline at end of file
application/api/service/CouponService.php
View file @
58334147
...
...
@@ -53,14 +53,22 @@ class CouponService{
}
try
{
$
is_exist
=
$this
->
m_user
->
getUserByWhereValue
(
'id'
,
[
'id'
=>
$user_id
]);
if
(
empty
(
$
is_exist
))
{
$
user_data
=
$this
->
m_user
->
getUserById
(
'id,first_login_time'
,
$user_id
,
[
'status'
=>
0
]);
if
(
empty
(
$
user_data
[
'id'
]
))
{
$result
[
'status'
]
=
'fail'
;
$result
[
'msg'
]
=
'该用户不存在'
;
return
$result
;
}
$activity_data
=
$this
->
checkUserCoupon
(
$user_id
,
$type
);
//该笔订单的收意向金时间48小时前 才给成交人和邀请人的返现红包兑现
$time
=
time
()
-
172800
;
if
(
$type
==
0
&&
strtotime
(
$user_data
[
'first_login_time'
])
<
$time
)
{
$result
[
'status'
]
=
'fail'
;
$result
[
'msg'
]
=
'该用户首次登陆时间未超过48小时'
;
return
$result
;
}
$activity_data
=
$this
->
checkUserCoupon
(
$user_id
,
$type
,
$order_id
);
if
(
empty
(
$activity_data
))
{
$result
[
'status'
]
=
'fail'
;
$result
[
'msg'
]
=
'没有可参加的活动'
;
...
...
@@ -132,12 +140,13 @@ class CouponService{
*
* @param int $user_id
* @param int $type
* @param $order_id
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
checkUserCoupon
(
int
$user_id
,
int
$type
)
public
function
checkUserCoupon
(
int
$user_id
,
int
$type
,
$order_id
)
{
$return_activity
=
[];
$time
=
time
();
...
...
@@ -148,6 +157,15 @@ class CouponService{
continue
;
}
//单个订单只奖励一次
if
(
$type
==
2
)
{
$count_where
[
'order_id'
]
=
$order_id
;
$num
=
$this
->
m_coupon
->
getCount
(
$count_where
);
if
(
$num
>
0
)
{
continue
;
}
}
if
(
strtotime
(
$v
[
'activity_start_time'
])
<
$time
&&
strtotime
(
$v
[
'activity_end_time'
])
>
$time
)
{
$return_activity
[]
=
$v
;
}
...
...
application/route.php
View file @
58334147
...
...
@@ -306,6 +306,7 @@ Route::group('index', [
'receivables'
=>
[
'index/Finance/receivables'
,
[
'method'
=>
'GET'
]],
//获取实收日期
'adjustment'
=>
[
'index/Finance/adjustment'
,
[
'method'
=>
'GET'
]],
//获取实收日期
'getPayLogData'
=>
[
'index/Finance/getPayLogData'
,
[
'method'
=>
'GET'
]],
//收款各种详情
'getActivityCoupon'
=>
[
'index/Finance/getActivityCoupon'
,
[
'method'
=>
'GET'
]],
//收款各种详情
'evaluationList'
=>
[
'index/Evaluation/evaluationList'
,
[
'method'
=>
'POST|GET'
]
],
//评价列表 朱伟 2018-06-13
'marchInList'
=>
[
'index/MarchIn/marchInList'
,
[
'method'
=>
'POST|GET'
]
],
//进场记录列表 朱伟 2018-06-13
...
...
@@ -437,6 +438,7 @@ Route::group('api', [
'check_code'
=>
[
'api/member/check_code'
,
[
'method'
=>
'get'
]],
//检测短信
'index'
=>
[
'api/member/index'
,
[
'method'
=>
'get'
]],
'getHomeCoupon'
=>
[
'api/Coupon/getHomeCoupon'
,
[
'method'
=>
'get'
]],
'couponList'
=>
[
'api/Coupon/couponList'
,
[
'method'
=>
'get'
]],
//返现红包列表
'getBroker'
=>
[
'api/broker/index'
,
[
'method'
=>
'get'
]],
//获取当前商铺或街铺的经纪人评论信息列表
'getBrokerV2'
=>
[
'api/broker/indexV2'
,
[
'method'
=>
'get'
]],
//获取当前商铺或街铺的经纪人评论信息列表
// 'test' => ['api/broker/testtest', ['method' => 'get']], //获取当前商铺或街铺的经纪人评论信息列表
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment