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
f2acb572
Commit
f2acb572
authored
Mar 13, 2019
by
zhuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
核销优惠券 添加日志
parent
3a8c8182
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
31 deletions
+14
-31
ConvertCouponService.php
application/api/service/ConvertCouponService.php
+14
-31
No files found.
application/api/service/ConvertCouponService.php
View file @
f2acb572
...
@@ -59,32 +59,24 @@ class ConvertCouponService
...
@@ -59,32 +59,24 @@ class ConvertCouponService
if
(
!
$user_id
or
!
$report_id
or
!
$bargain_id
or
!
$order_id
){
if
(
!
$user_id
or
!
$report_id
or
!
$bargain_id
or
!
$order_id
){
return
false
;
return
false
;
}
}
big_log
(
'==================$user_id'
.
$user_id
);
//验证 客户首次登录时间 是否在 收意向金时间 大于48小时给返现红包兑现
//验证 客户首次登录时间 是否在 收意向金时间 大于48小时给返现红包兑现
$verification_res
=
$this
->
verificationFirstLoginTime
(
$user_id
);
$verification_res
=
$this
->
verificationFirstLoginTime
(
$user_id
);
if
(
!
$verification_res
){
if
(
!
$verification_res
){
big_log
(
'false========68'
);
return
false
;
return
false
;
}
}
// 根据$user_id 取出 当前客户的 0首次登陆 1邀请登陆 券
// 根据$user_id 取出 当前客户的 0首次登陆 1邀请登陆 券
$coupon_list
=
$this
->
getCoupon
(
$user_id
,
''
);
$coupon_list
=
$this
->
getCoupon
(
$user_id
,
''
);
if
(
!
$coupon_list
){
if
(
!
$coupon_list
){
big_log
(
'false========75'
);
return
false
;
return
false
;
}
}
big_log
(
'user优惠券list'
.
json_encode
(
$coupon_list
));
//去除已经过期的优惠券
//去除已经过期的优惠券
$coupon_list
=
$this
->
filterExpireData
(
$coupon_list
);
$coupon_list
=
$this
->
filterExpireData
(
$coupon_list
);
// 存在未过期 券数等于1直接核销
// 存在未过期 券数等于1直接核销
$coupon_list_count
=
count
(
$coupon_list
);
$coupon_list_count
=
count
(
$coupon_list
);
if
(
$coupon_list_count
==
0
){
if
(
$coupon_list_count
==
0
){
big_log
(
'false 行号 81'
);
return
false
;
return
false
;
}
elseif
(
$coupon_list_count
>
1
){
}
elseif
(
$coupon_list_count
>
1
){
// 券数大于1 选取金额最大的核销
// 券数大于1 选取金额最大的核销
...
@@ -92,7 +84,6 @@ class ConvertCouponService
...
@@ -92,7 +84,6 @@ class ConvertCouponService
$coupon_list
[]
=
$this
->
getMaxCoupon
(
$coupon_list
);
$coupon_list
[]
=
$this
->
getMaxCoupon
(
$coupon_list
);
}
}
//修改券状态为已使用
//修改券状态为已使用
big_log
(
'user修改券状态为已使用id'
.
$coupon_list
[
0
][
'id'
]);
$this
->
m_coupon
->
updateUseStatus
(
$coupon_list
[
0
][
'id'
],
1
,
$report_id
,
$bargain_id
,
$order_id
,
date
(
"Y-m-d H:i:s"
,
time
()));
$this
->
m_coupon
->
updateUseStatus
(
$coupon_list
[
0
][
'id'
],
1
,
$report_id
,
$bargain_id
,
$order_id
,
date
(
"Y-m-d H:i:s"
,
time
()));
...
@@ -103,18 +94,12 @@ class ConvertCouponService
...
@@ -103,18 +94,12 @@ class ConvertCouponService
// 查询当前客户的是否有邀请人
// 查询当前客户的是否有邀请人
$invite_user
=
$this
->
getUserInviter
(
$user_id
);
$invite_user
=
$this
->
getUserInviter
(
$user_id
);
if
(
!
$invite_user
){
if
(
!
$invite_user
){
big_log
(
'查询当前客户的是否有邀请人 挂了'
);
big_log
(
'false 行号 102'
);
return
false
;
return
false
;
}
}
//是客户 根据邀请人user_id 和被邀请人user_id 取出 2邀请成交 券
//是客户 根据邀请人user_id 和被邀请人user_id 取出 2邀请成交 券
$invite_user_coupon_list
=
$this
->
getCoupon
(
$user_id
,
$invite_user
);
$invite_user_coupon_list
=
$this
->
getCoupon
(
$user_id
,
$invite_user
);
if
(
!
$invite_user_coupon_list
){
if
(
!
$invite_user_coupon_list
){
big_log
(
'取出 2邀请成交 券 挂了'
);
big_log
(
'false 行号 111'
);
return
false
;
return
false
;
}
}
...
@@ -123,16 +108,10 @@ class ConvertCouponService
...
@@ -123,16 +108,10 @@ class ConvertCouponService
// 存在未过期
// 存在未过期
$invite_user_coupon_list_count
=
count
(
$invite_user_coupon_list
);
$invite_user_coupon_list_count
=
count
(
$invite_user_coupon_list
);
big_log
(
'inviteruser存在未过期'
.
json_encode
(
$invite_user_coupon_list
));
if
(
$invite_user_coupon_list_count
==
0
){
if
(
$invite_user_coupon_list_count
==
0
){
big_log
(
'inviteruser 无2邀请成交券'
.
json_encode
(
''
));
big_log
(
'false 行号 124'
);
return
false
;
return
false
;
}
elseif
(
$invite_user_coupon_list_count
==
1
){
}
elseif
(
$invite_user_coupon_list_count
==
1
){
big_log
(
'inviteruser 修改券状态为已使用'
.
json_encode
(
$invite_user_coupon_list
[
0
][
'id'
]));
// 修改券状态为已使用
// 修改券状态为已使用
$this
->
m_coupon
->
updateUseStatus
(
$invite_user_coupon_list
[
0
][
'id'
],
1
,
$report_id
,
$bargain_id
,
$order_id
,
date
(
"Y-m-d H:i:s"
,
time
()));
$this
->
m_coupon
->
updateUseStatus
(
$invite_user_coupon_list
[
0
][
'id'
],
1
,
$report_id
,
$bargain_id
,
$order_id
,
date
(
"Y-m-d H:i:s"
,
time
()));
// 将活动奖励金额写入账户余额 $coupon_list[0]['money']
// 将活动奖励金额写入账户余额 $coupon_list[0]['money']
...
@@ -173,12 +152,8 @@ class ConvertCouponService
...
@@ -173,12 +152,8 @@ class ConvertCouponService
}
}
#发券日期大于最后使用日期
#发券日期大于最后使用日期
big_log
(
'有效期天'
.
$v
[
'use_period'
]);
big_log
(
'发券日期'
.
$v
[
'create_time'
]);
big_log
(
'过期日期'
.
date
(
"Y-m-d H:i:s"
,
strtotime
(
"+
{
$v
[
'use_period'
]
}
day"
,
strtotime
(
$v
[
'create_time'
]))));
if
(
$v
[
'create_time'
]
>
date
(
"Y-m-d H:i:s"
,
strtotime
(
"+
{
$v
[
'use_period'
]
}
day"
,
strtotime
(
$v
[
'create_time'
])))){
if
(
$v
[
'create_time'
]
>
date
(
"Y-m-d H:i:s"
,
strtotime
(
"+
{
$v
[
'use_period'
]
}
day"
,
strtotime
(
$v
[
'create_time'
])))){
big_log
(
'
过期券
'
);
big_log
(
'
优惠券已经过期
'
);
$this
->
m_coupon
->
updateStatus
(
$v
[
'id'
],
2
);
$this
->
m_coupon
->
updateStatus
(
$v
[
'id'
],
2
);
unset
(
$coupon_list
[
$k
]);
unset
(
$coupon_list
[
$k
]);
continue
;
continue
;
...
@@ -194,7 +169,6 @@ class ConvertCouponService
...
@@ -194,7 +169,6 @@ class ConvertCouponService
* @return false|\PDOStatement|string|\think\Collection
* @return false|\PDOStatement|string|\think\Collection
*/
*/
public
function
getCoupon
(
$user_id
,
$referrer_id
){
public
function
getCoupon
(
$user_id
,
$referrer_id
){
big_log
(
'获取优惠券'
.
$user_id
.
'邀请人ID'
.
$referrer_id
);
$field
=
'a.id,a.activity_id,a.create_time,b.money,b.use_period'
;
$field
=
'a.id,a.activity_id,a.create_time,b.money,b.use_period'
;
if
(
$referrer_id
){
if
(
$referrer_id
){
$params
[
'a.user_id'
]
=
$referrer_id
;
$params
[
'a.user_id'
]
=
$referrer_id
;
...
@@ -207,8 +181,6 @@ class ConvertCouponService
...
@@ -207,8 +181,6 @@ class ConvertCouponService
}
}
$params
[
'a.status'
]
=
0
;
$params
[
'a.status'
]
=
0
;
big_log
(
'获取优惠券查询条件'
.
json_encode
(
$params
));
return
$this
->
m_coupon
->
getCouponJoinActivity
(
$field
,
$params
);
return
$this
->
m_coupon
->
getCouponJoinActivity
(
$field
,
$params
);
}
}
...
@@ -235,11 +207,16 @@ class ConvertCouponService
...
@@ -235,11 +207,16 @@ class ConvertCouponService
{
{
//查找邀请人的信息
//查找邀请人的信息
$referrer_res
=
$this
->
getUserInfo
(
$user_id
);
$referrer_res
=
$this
->
getUserInfo
(
$user_id
);
if
(
!
$referrer_res
)
if
(
!
$referrer_res
){
big_log
(
'为查询到邀请人'
);
return
false
;
return
false
;
}
// 存在邀请人则判断是否是客户
// 存在邀请人则判断是否是客户
if
(
$referrer_res
[
0
][
'referrer_source'
]
==
20
)
if
(
$referrer_res
[
0
][
'referrer_source'
]
==
20
)
{
big_log
(
'客户邀请人为经纪人'
);
return
false
;
return
false
;
}
return
$referrer_res
[
0
][
'referrer_id'
];
return
$referrer_res
[
0
][
'referrer_id'
];
}
}
...
@@ -256,16 +233,22 @@ class ConvertCouponService
...
@@ -256,16 +233,22 @@ class ConvertCouponService
return
false
;
return
false
;
$first_login_time
=
$user_info
[
0
][
'first_login_time'
];
$first_login_time
=
$user_info
[
0
][
'first_login_time'
];
if
(
!
$first_login_time
)
if
(
!
$first_login_time
)
{
big_log
(
'客户首次登录时间为空'
);
return
false
;
return
false
;
}
$params
[
'user_id'
]
=
$user_id
;
$params
[
'user_id'
]
=
$user_id
;
$params
[
'type'
]
=
10
;
$params
[
'type'
]
=
10
;
$pay_log
=
$this
->
m_pay_log
->
getPayLogByUserId
(
'a.create_time'
,
$params
);
$pay_log
=
$this
->
m_pay_log
->
getPayLogByUserId
(
'a.create_time'
,
$params
);
$pay_log_time
=
$pay_log
[
'create_time'
];
$pay_log_time
=
$pay_log
[
'create_time'
];
if
(
!
$pay_log_time
)
if
(
!
$pay_log_time
){
big_log
(
'客户首次登录时间为空'
);
return
false
;
return
false
;
}
$pay_hour
=
(
strtotime
(
$pay_log_time
)
-
strtotime
(
$first_login_time
))
/
3600
;
$pay_hour
=
(
strtotime
(
$pay_log_time
)
-
strtotime
(
$first_login_time
))
/
3600
;
if
(
$pay_hour
<
48
){
if
(
$pay_hour
<
48
){
big_log
(
'客户首次登录时间 和 收意向金时间 小于48小时'
);
return
false
;
return
false
;
}
}
return
true
;
return
true
;
...
...
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