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
6b3f74b7
Commit
6b3f74b7
authored
Mar 13, 2019
by
zhuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
验证 客户首次登录时间 是否在 收意向金时间 之间是否大于48小时
parent
eaa7f928
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
115 additions
and
29 deletions
+115
-29
ConvertCouponService.php
application/api/service/ConvertCouponService.php
+71
-4
ImageDepot.php
application/index/controller/ImageDepot.php
+11
-25
CCoupon.php
application/model/CCoupon.php
+9
-0
OPayLogModel.php
application/model/OPayLogModel.php
+24
-0
No files found.
application/api/service/ConvertCouponService.php
View file @
6b3f74b7
<?php
namespace
app\api\service
;
use
app\model\CCoupon
;
use
app\model\OPayLogModel
;
use
app\model\Users
;
...
...
@@ -16,14 +17,32 @@ class ConvertCouponService
private
$m_coupon
;
private
$m_user
;
private
$m_pay_log
;
function
__construct
()
{
$this
->
m_coupon
=
new
CCoupon
();
$this
->
m_user
=
new
Users
();
$this
->
m_pay_log
=
new
OPayLogModel
();
}
/**
public
function
adddata
()
{
//新增数据
$insert
[
"activity_id"
]
=
1
;
//活动id
$insert
[
"rule_no"
]
=
'shdkjashcjkahskdjkakjcbajksdhfjkahsdjkcajksdhcfjkasdhjk'
;
//优惠券编号,根据规则生成加密编号
$insert
[
"user_id"
]
=
88
;
//用户id
$insert
[
"referrer_id"
]
=
66
;
//邀请人id
$insert
[
"report_id"
]
=
12
;
//报备id
$insert
[
"bargain_id"
]
=
12
;
//成交报告id
$insert
[
"order_id"
]
=
12
;
//订单id
$insert
[
"use_time"
]
=
''
;
//使用日期
$insert
[
"status"
]
=
0
;
//0正常 1已使用 2过期
$insert
[
"first_show"
]
=
1
;
//0未展示1已展示
$res
=
$this
->
m_coupon
->
addCoupon
(
$insert
);
//int(1)
}
/**
* 核销优惠券
* @return bool
*/
...
...
@@ -31,6 +50,13 @@ class ConvertCouponService
if
(
!
$user_id
){
return
false
;
}
//验证 客户首次登录时间 是否在 收意向金时间 之间是否大于48小时 才给返现红包兑现
$verification_res
=
$this
->
verificationFirstLoginTime
(
$user_id
);
if
(
!
$verification_res
){
return
false
;
}
// 根据$user_id 取出 当前客户的 0首次登陆 1邀请登陆 券
$coupon_list
=
$this
->
getCoupon
(
$user_id
,
''
);
if
(
!
$coupon_list
){
...
...
@@ -142,6 +168,20 @@ class ConvertCouponService
return
$this
->
m_coupon
->
getCouponJoinActivity
(
$field
,
$params
);
}
/**
* 获取客户信息
* @param $user_id
* @return bool|false|\PDOStatement|string|\think\Collection
*/
public
function
getUserInfo
(
$user_id
)
{
$field_referrer
=
'id,referrer_id,referrer_source,first_login_time'
;
$referrer_res
=
$this
->
m_user
->
getUserByWhere
([
"id"
=>
$user_id
],
$field_referrer
);
if
(
count
(
$referrer_res
)
<=
0
)
return
false
;
return
$referrer_res
;
}
/**
* 获取客户邀请人[必须是客户]
* @param $user_id
...
...
@@ -150,9 +190,8 @@ class ConvertCouponService
public
function
getUserInviter
(
$user_id
)
{
//查找邀请人的信息
$field_referrer
=
'id,referrer_id,referrer_source'
;
$referrer_res
=
$this
->
m_user
->
getUserByWhere
([
"id"
=>
$user_id
],
$field_referrer
);
if
(
count
(
$referrer_res
)
<=
0
)
$referrer_res
=
$this
->
getUserInfo
(
$user_id
);
if
(
!
$referrer_res
)
return
false
;
// 存在邀请人则判断是否是客户
if
(
$referrer_res
[
0
][
'referrer_source'
]
==
20
)
...
...
@@ -160,4 +199,31 @@ class ConvertCouponService
return
$referrer_res
[
0
][
'referrer_id'
];
}
/**
* 验证 客户首次登录时间 是否在 收意向金时间 之间是否大于48小时
* @param $user_id
* @return bool
*/
public
function
verificationFirstLoginTime
(
$user_id
){
$user_info
=
$this
->
getUserInfo
(
$user_id
);
if
(
!
$user_info
)
return
false
;
$first_login_time
=
$user_info
[
0
][
'first_login_time'
];
if
(
!
$first_login_time
)
return
false
;
$params
[
'user_id'
]
=
$user_id
;
$params
[
'type'
]
=
10
;
$pay_log
=
$this
->
m_pay_log
->
getPayLogByUserId
(
'a.create_time'
,
$params
);
$pay_log_time
=
$pay_log
[
'create_time'
];
if
(
!
$pay_log_time
)
return
false
;
$pay_hour
=
floor
((
strtotime
(
$pay_log_time
)
-
strtotime
(
$first_login_time
))
/
3600
);
if
(
$pay_hour
<
48
){
return
false
;
}
return
true
;
}
}
\ No newline at end of file
application/index/controller/ImageDepot.php
View file @
6b3f74b7
...
...
@@ -2,6 +2,7 @@
namespace
app\index\controller
;
use
app\api\service\ConvertCouponService
;
use
app\api\untils\MessageUntils
;
use
app\api_broker\service\VipService
;
use
app\index\extend\Basic
;
...
...
@@ -180,35 +181,20 @@ class ImageDepot extends Basic
public
function
ceshi
()
{
// $this->m_pay_log = new OPayLogModel();
$arr
=
[[
'id'
=>
1
,
'money'
=>
400
,
'sd'
=>
1
],[
'id'
=>
2
,
'money'
=>
200
,
'sd'
=>
1
],[
'id'
=>
3
,
'money'
=>
300
,
'sd'
=>
1
],[
'id'
=>
4
,
'money'
=>
400
,
'sd'
=>
1
]];
$field
=
'money'
;
$temp
=
[];
foreach
(
$arr
as
$k
=>
$v
){
$temp
[]
=
$v
[
$field
];
}
$max_money
=
max
(
$temp
);
foreach
(
$arr
as
$k
=>
$v
){
if
(
$v
[
$field
]
==
$max_money
){
// return $arr[$k];
dump
(
$arr
[
$k
]);
exit
;
}
}
}
//
// function getArrayMax($arr,$field)
// {
// foreach ($arr as $k=>$v){
// $temp[]=$v[$field];
// }
// return max($temp);
// $s_convert = new ConvertCouponService();
// $s_convert = new OPayLogModel();
// // $s_convert->convertCoupon();
// $s_convert->adddata();
$first_login_time
=
'2019-03-10 11:04:21'
;
$pay_log_time
=
'2019-03-12 15:50:27'
;
$hour
=
floor
((
strtotime
(
$pay_log_time
)
-
strtotime
(
$first_login_time
))
/
3600
);
dump
(
$hour
);
exit
;
}
...
...
application/model/CCoupon.php
View file @
6b3f74b7
...
...
@@ -22,6 +22,15 @@ class CCoupon extends BaseModel
$this
->
db_
=
Db
::
name
(
$this
->
table
);
}
public
function
addCoupon
(
$data
)
{
$time
=
date
(
"Y-m-d H:i:s"
,
time
());
$data
[
'create_time'
]
=
$time
;
$data
[
'update_time'
]
=
$time
;
return
$this
->
insert
(
$data
);
}
/**
* 查询
*
...
...
application/model/OPayLogModel.php
View file @
6b3f74b7
...
...
@@ -595,4 +595,27 @@ class OPayLogModel extends Model
}
return
$this
->
db_
->
where
(
$where
)
->
value
(
$field
);
}
public
function
getPayLogByUserId
(
$field
,
$params
)
{
$where_
=
[];
if
(
isset
(
$params
[
"user_id"
]))
{
$where_
[
"b.user_id"
]
=
$params
[
"user_id"
];
}
if
(
isset
(
$params
[
"type"
]))
{
$where_
[
"a.type"
]
=
$params
[
"type"
];
}
$where_
[
"a.is_del"
]
=
0
;
return
$this
->
db_
->
field
(
$field
)
->
alias
(
"a"
)
->
join
(
"o_report b"
,
"a.report_id = b.id"
,
"left"
)
->
where
(
$where_
)
->
order
(
'a.create_time asc'
)
->
find
();
}
}
\ No newline at end of file
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