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
a6089334
Commit
a6089334
authored
Mar 19, 2019
by
zhuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
核销优惠券
parent
1de948b5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
22 deletions
+51
-22
ConvertCouponService.php
application/api/service/ConvertCouponService.php
+51
-22
No files found.
application/api/service/ConvertCouponService.php
View file @
a6089334
...
...
@@ -61,75 +61,88 @@ class ConvertCouponService
}
big_log
(
'=============客户DI:'
.
$user_id
.
' START================='
);
#验证 同一订单是否存在核销记录
$verification_order
=
$this
->
verificationOrderId
(
$user_id
,
$order_id
);
if
(
!
$verification_order
){
return
false
;
}
//验证 客户首次登录时间 是否在 收意向金时间 大于48小时给返现红包兑现
#验证 客户首次登录时间 是否在 收意向金时间 之间是否大于48小时
$verification_res
=
$this
->
verificationFirstLoginTime
(
$user_id
);
if
(
!
$verification_res
){
return
false
;
}
//
根据$user_id 取出 当前客户的 0首次登陆 1邀请登陆 券
#
根据$user_id 取出 当前客户的 0首次登陆 1邀请登陆 券
$coupon_list
=
$this
->
getCoupon
(
$user_id
,
''
);
big_log
(
'1'
.
json_encode
(
$coupon_list
));
if
(
!
$coupon_list
){
return
false
;
}
//
去除已经过期的优惠券
#
去除已经过期的优惠券
$coupon_list
=
$this
->
filterExpireData
(
$coupon_list
);
big_log
(
'2'
.
json_encode
(
$coupon_list
));
//
存在未过期 券数等于1直接核销
#
存在未过期 券数等于1直接核销
$coupon_list_count
=
count
(
$coupon_list
);
if
(
$coupon_list_count
==
0
){
return
false
;
}
elseif
(
$coupon_list_count
>
1
){
//
券数大于1
选取金额最大的核销
$
coupon_list_new
=
$this
->
getMaxCoupon
(
$coupon_list
);
//
券不止一张
选取金额最大的核销
$
max_coupon
=
$this
->
getMaxCoupon
(
$coupon_list
);
big_log
(
'3'
.
json_encode
(
$coupon_list
));
$coupon_list
=
[];
$coupon_list
[]
=
$
coupon_list_new
;
$coupon_list
[]
=
$
max_coupon
;
big_log
(
'4'
.
json_encode
(
$coupon_list
));
}
big_log
(
'5'
.
json_encode
(
$coupon_list
));
big_log
(
'6'
.
json_encode
(
$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
->
s_account_balance
->
addUserBalance
(
$coupon_list
[
0
][
'money'
],
$user_id
,
0
,
$coupon_list
[
0
][
'id'
],
0
);
//
查询当前客户的是否有邀请人
#
查询当前客户的是否有邀请人
$invite_user
=
$this
->
getUserInviter
(
$user_id
);
if
(
!
$invite_user
){
return
false
;
}
//
是客户 根据邀请人user_id 和被邀请人user_id 取出 2邀请成交 券
#
是客户 根据邀请人user_id 和被邀请人user_id 取出 2邀请成交 券
$invite_user_coupon_list
=
$this
->
getCoupon
(
$user_id
,
$invite_user
);
if
(
!
$invite_user_coupon_list
){
return
false
;
}
//
去除已经过期的优惠券
#
去除已经过期的优惠券
$invite_user_coupon_list
=
$this
->
filterExpireData
(
$invite_user_coupon_list
);
//
存在未过期
#
存在未过期
$invite_user_coupon_list_count
=
count
(
$invite_user_coupon_list
);
if
(
$invite_user_coupon_list_count
==
0
){
return
false
;
}
elseif
(
$invite_user_coupon_list_count
==
1
){
// 修改券状态为已使用
$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']
$this
->
s_account_balance
->
addUserBalance
(
$invite_user_coupon_list
[
0
][
'money'
],
$invite_user
,
0
,
$invite_user_coupon_list
[
0
][
'id'
],
0
);
//券不止一张选取金额最大的核销
$max_invite_user_coupon
=
$this
->
getMaxCoupon
(
$invite_user_coupon_list
);
$invite_user_coupon_list
=
[];
$invite_user_coupon_list
[]
=
$max_invite_user_coupon
;
}
// 修改券状态为已使用
$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']
$this
->
s_account_balance
->
addUserBalance
(
$invite_user_coupon_list
[
0
][
'money'
],
$invite_user
,
0
,
$invite_user_coupon_list
[
0
][
'id'
],
0
);
return
true
;
}
/**
* 获取最大优惠券
* @return mixed
...
...
@@ -222,8 +235,7 @@ class ConvertCouponService
return
false
;
}
// 存在邀请人则判断是否是客户
if
(
$referrer_res
[
0
][
'referrer_source'
]
==
20
)
{
if
(
$referrer_res
[
0
][
'referrer_source'
]
==
20
)
{
big_log
(
'客户邀请人为经纪人'
);
return
false
;
}
...
...
@@ -244,8 +256,7 @@ class ConvertCouponService
return
false
;
}
$first_login_time
=
$user_info
[
0
][
'first_login_time'
];
if
(
!
$first_login_time
)
{
if
(
!
$first_login_time
)
{
big_log
(
'客户首次登录时间为空'
);
return
false
;
}
...
...
@@ -265,4 +276,21 @@ class ConvertCouponService
}
return
true
;
}
/**
* 判断同一订单是否存在核销记录
* @param $user_id
* @param $order_id
* @return bool
*/
public
function
verificationOrderId
(
$user_id
,
$order_id
){
$field
=
'a.id'
;
$params
[
'a.user_id'
]
=
$user_id
;
$params
[
'a.order_id'
]
=
$order_id
;
if
(
$this
->
m_coupon
->
getCouponJoinActivity
(
$field
,
$params
)){
return
false
;
}
return
true
;
}
}
\ 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