|
@@ -60,10 +60,11 @@ class Pay extends Api |
|
@@ -60,10 +60,11 @@ class Pay extends Api |
60
|
$update['transaction_id'] = $notify->transaction_id;
|
60
|
$update['transaction_id'] = $notify->transaction_id;
|
61
|
//判断用户是否有邀请人
|
61
|
//判断用户是否有邀请人
|
62
|
$invite = Db::name('user')->where('id',$order['user_id'])->find();
|
62
|
$invite = Db::name('user')->where('id',$order['user_id'])->find();
|
|
|
63
|
+ //没有邀请人
|
63
|
if(empty($invite['invite_id'])){
|
64
|
if(empty($invite['invite_id'])){
|
64
|
// 用户是否支付成功
|
65
|
// 用户是否支付成功
|
65
|
if ($successful) {
|
66
|
if ($successful) {
|
66
|
- if(empty($order['coupon_id'])){
|
67
|
+ if(!empty($order['coupon_id'])){
|
67
|
//修改优惠劵为已使用
|
68
|
//修改优惠劵为已使用
|
68
|
Db::name('coupon')->where('id',$order['coupon_id'])->update(['is_use'=>1]);
|
69
|
Db::name('coupon')->where('id',$order['coupon_id'])->update(['is_use'=>1]);
|
69
|
}
|
70
|
}
|
|
@@ -74,6 +75,8 @@ class Pay extends Api |
|
@@ -74,6 +75,8 @@ class Pay extends Api |
74
|
$update['expirationtime'] = $update['paytime'] + 86400*7;
|
75
|
$update['expirationtime'] = $update['paytime'] + 86400*7;
|
75
|
$update['finish_status'] = 1;
|
76
|
$update['finish_status'] = 1;
|
76
|
Db::name('teacher')->where('id',$order['teacher_id'])->setInc('help_num');
|
77
|
Db::name('teacher')->where('id',$order['teacher_id'])->setInc('help_num');
|
|
|
78
|
+ Db::name('teacher')->where('id',$order['teacher_id'])->setInc('count');
|
|
|
79
|
+ Db::name('territory')->where('id',$order['territory_id'])->setInc('buynum');
|
77
|
// 创建融云用户、群组
|
80
|
// 创建融云用户、群组
|
78
|
$teacher_id = Db::name('teacher')->where('id',$order['teacher_id'])->value('user_id');
|
81
|
$teacher_id = Db::name('teacher')->where('id',$order['teacher_id'])->value('user_id');
|
79
|
$rongyun_chat = $this->rongyun_handle($order['user_id'].','.$teacher_id,$order['id']);
|
82
|
$rongyun_chat = $this->rongyun_handle($order['user_id'].','.$teacher_id,$order['id']);
|
|
@@ -88,6 +91,7 @@ class Pay extends Api |
|
@@ -88,6 +91,7 @@ class Pay extends Api |
88
|
Db::commit();
|
91
|
Db::commit();
|
89
|
return true; // 返回处理完成
|
92
|
return true; // 返回处理完成
|
90
|
}else{
|
93
|
}else{
|
|
|
94
|
+ //有邀请人
|
91
|
//判断邀请的用户是否第一次购买
|
95
|
//判断邀请的用户是否第一次购买
|
92
|
$is_one = Db::name('order')->where('user_id',$order['user_id'])->where('status',2)->find();
|
96
|
$is_one = Db::name('order')->where('user_id',$order['user_id'])->where('status',2)->find();
|
93
|
|
97
|
|
|
@@ -111,6 +115,8 @@ class Pay extends Api |
|
@@ -111,6 +115,8 @@ class Pay extends Api |
111
|
$coupon['expirationtime'] = $coupon['createtime']+7*86400;
|
115
|
$coupon['expirationtime'] = $coupon['createtime']+7*86400;
|
112
|
Db::name('coupon')->insertGetId($coupon);
|
116
|
Db::name('coupon')->insertGetId($coupon);
|
113
|
Db::name('teacher')->where('id',$order['teacher_id'])->setInc('help_num');
|
117
|
Db::name('teacher')->where('id',$order['teacher_id'])->setInc('help_num');
|
|
|
118
|
+ Db::name('teacher')->where('id',$order['teacher_id'])->setInc('count');
|
|
|
119
|
+ Db::name('territory')->where('id',$order['territory_id'])->setInc('buynum');
|
114
|
// 创建融云用户、群组
|
120
|
// 创建融云用户、群组
|
115
|
$teacher_id = Db::name('teacher')->where('id',$order['teacher_id'])->value('user_id');
|
121
|
$teacher_id = Db::name('teacher')->where('id',$order['teacher_id'])->value('user_id');
|
116
|
$rongyun_chat = $this->rongyun_handle($order['user_id'].','.$teacher_id,$order['id']);
|
122
|
$rongyun_chat = $this->rongyun_handle($order['user_id'].','.$teacher_id,$order['id']);
|
|
@@ -138,6 +144,8 @@ class Pay extends Api |
|
@@ -138,6 +144,8 @@ class Pay extends Api |
138
|
$update['expirationtime'] = $update['paytime'] + 86400*7;
|
144
|
$update['expirationtime'] = $update['paytime'] + 86400*7;
|
139
|
$update['finish_status'] = 1;
|
145
|
$update['finish_status'] = 1;
|
140
|
Db::name('teacher')->where('id',$order['teacher_id'])->setInc('help_num');
|
146
|
Db::name('teacher')->where('id',$order['teacher_id'])->setInc('help_num');
|
|
|
147
|
+ Db::name('teacher')->where('id',$order['teacher_id'])->setInc('count');
|
|
|
148
|
+ Db::name('territory')->where('id',$order['territory_id'])->setInc('buynum');
|
141
|
// 创建融云用户、群组
|
149
|
// 创建融云用户、群组
|
142
|
$teacher_id = Db::name('teacher')->where('id',$order['teacher_id'])->value('user_id');
|
150
|
$teacher_id = Db::name('teacher')->where('id',$order['teacher_id'])->value('user_id');
|
143
|
|
151
|
|
|
@@ -179,7 +187,7 @@ class Pay extends Api |
|
@@ -179,7 +187,7 @@ class Pay extends Api |
179
|
}
|
187
|
}
|
180
|
// 用户是否支付成功
|
188
|
// 用户是否支付成功
|
181
|
if ($successful) {
|
189
|
if ($successful) {
|
182
|
- if(empty($order['coupon_id'])){
|
190
|
+ if(!empty($order['coupon_id'])){
|
183
|
//修改优惠劵为已使用
|
191
|
//修改优惠劵为已使用
|
184
|
Db::name('coupon')->where('id',$order['coupon_id'])->update(['is_use'=>1]);
|
192
|
Db::name('coupon')->where('id',$order['coupon_id'])->update(['is_use'=>1]);
|
185
|
}
|
193
|
}
|
|
@@ -203,6 +211,8 @@ class Pay extends Api |
|
@@ -203,6 +211,8 @@ class Pay extends Api |
203
|
->where('id',$order['order_id'])
|
211
|
->where('id',$order['order_id'])
|
204
|
->update(['expirationtime'=>$update['paytime'] + 86400*7,'finish_status'=>1]);
|
212
|
->update(['expirationtime'=>$update['paytime'] + 86400*7,'finish_status'=>1]);
|
205
|
}
|
213
|
}
|
|
|
214
|
+ Db::name('teacher')->where('id',$info['teacher_id'])->setInc('count');
|
|
|
215
|
+ Db::name('territory')->where('id',$info['territory_id'])->setInc('buynum');
|
206
|
} else { // 用户支付失败
|
216
|
} else { // 用户支付失败
|
207
|
$update['status']=1;
|
217
|
$update['status']=1;
|
208
|
}
|
218
|
}
|