Commit f2acb572 authored by zhuwei's avatar zhuwei

核销优惠券 添加日志

parent 3a8c8182
......@@ -59,32 +59,24 @@ class ConvertCouponService
if(!$user_id or !$report_id or !$bargain_id or !$order_id){
return false;
}
big_log('==================$user_id'.$user_id);
//验证 客户首次登录时间 是否在 收意向金时间 大于48小时给返现红包兑现
$verification_res = $this->verificationFirstLoginTime($user_id);
if(!$verification_res){
big_log('false========68');
return false;
}
// 根据$user_id 取出 当前客户的 0首次登陆 1邀请登陆 券
$coupon_list = $this->getCoupon($user_id,'');
if(!$coupon_list){
big_log('false========75');
return false;
}
big_log('user优惠券list'.json_encode($coupon_list));
//去除已经过期的优惠券
$coupon_list = $this->filterExpireData($coupon_list);
// 存在未过期 券数等于1直接核销
$coupon_list_count = count($coupon_list);
if($coupon_list_count == 0){
big_log('false 行号 81');
return false;
}elseif($coupon_list_count > 1){
// 券数大于1 选取金额最大的核销
......@@ -92,7 +84,6 @@ class ConvertCouponService
$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()));
......@@ -103,18 +94,12 @@ class ConvertCouponService
// 查询当前客户的是否有邀请人
$invite_user = $this->getUserInviter($user_id);
if(!$invite_user){
big_log('查询当前客户的是否有邀请人 挂了');
big_log('false 行号 102');
return false;
}
//是客户 根据邀请人user_id 和被邀请人user_id 取出 2邀请成交 券
$invite_user_coupon_list = $this->getCoupon($user_id,$invite_user);
if(!$invite_user_coupon_list){
big_log('取出 2邀请成交 券 挂了');
big_log('false 行号 111');
return false;
}
......@@ -123,16 +108,10 @@ class ConvertCouponService
// 存在未过期
$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){
big_log('inviteruser 无2邀请成交券'.json_encode(''));
big_log('false 行号 124');
return false;
}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()));
// 将活动奖励金额写入账户余额 $coupon_list[0]['money']
......@@ -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'])))){
big_log('过期券');
big_log('优惠券已经过期');
$this->m_coupon->updateStatus($v['id'],2);
unset($coupon_list[$k]);
continue;
......@@ -194,7 +169,6 @@ class ConvertCouponService
* @return false|\PDOStatement|string|\think\Collection
*/
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';
if($referrer_id){
$params['a.user_id'] = $referrer_id;
......@@ -207,8 +181,6 @@ class ConvertCouponService
}
$params['a.status'] = 0;
big_log('获取优惠券查询条件'.json_encode($params));
return $this->m_coupon->getCouponJoinActivity($field,$params);
}
......@@ -235,11 +207,16 @@ class ConvertCouponService
{
//查找邀请人的信息
$referrer_res = $this->getUserInfo($user_id);
if (!$referrer_res)
if (!$referrer_res){
big_log('为查询到邀请人');
return false;
}
// 存在邀请人则判断是否是客户
if ($referrer_res[0]['referrer_source'] == 20)
{
big_log('客户邀请人为经纪人');
return false;
}
return $referrer_res[0]['referrer_id'];
}
......@@ -256,16 +233,22 @@ class ConvertCouponService
return false;
$first_login_time = $user_info[0]['first_login_time'];
if (!$first_login_time)
{
big_log('客户首次登录时间为空');
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)
if (!$pay_log_time){
big_log('客户首次登录时间为空');
return false;
}
$pay_hour = (strtotime($pay_log_time)-strtotime($first_login_time))/3600;
if($pay_hour < 48 ){
big_log('客户首次登录时间 和 收意向金时间 小于48小时');
return false;
}
return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment