作者 郭盛
1 个管道 的构建 通过 耗费 10 秒

修改统计老师下了多少单

@@ -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 }
@@ -9583,7 +9583,7 @@ @@ -9583,7 +9583,7 @@
9583 9583
9584 <div class="row mt0 footer"> 9584 <div class="row mt0 footer">
9585 <div class="col-md-6" align="left"> 9585 <div class="col-md-6" align="left">
9586 - Generated on 2020-03-20 10:08:28 </div> 9586 + Generated on 2020-03-20 11:27:27 </div>
9587 <div class="col-md-6" align="right"> 9587 <div class="col-md-6" align="right">
9588 <a href="https://www.fastadmin.net" target="_blank">FastAdmin</a> 9588 <a href="https://www.fastadmin.net" target="_blank">FastAdmin</a>
9589 </div> 9589 </div>
@@ -28,6 +28,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin @@ -28,6 +28,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
28 // {field: 'teacher.thumbnail', title: __('Teacher.thumbnail'), operate:false, events: Table.api.events.image, formatter: Table.api.formatter.image}, 28 // {field: 'teacher.thumbnail', title: __('Teacher.thumbnail'), operate:false, events: Table.api.events.image, formatter: Table.api.formatter.image},
29 {field: 'contype.title', title: __('擅长领域名称')}, 29 {field: 'contype.title', title: __('擅长领域名称')},
30 {field: 'money', title: __('价格')}, 30 {field: 'money', title: __('价格')},
  31 + {field: 'buynum', title: __('购买次数')},
31 // {field: 'content', title: __('领域优势')}, 32 // {field: 'content', title: __('领域优势')},
32 // {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime}, 33 // {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
33 // {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime}, 34 // {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
@@ -58,6 +58,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin @@ -58,6 +58,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
58 {field: 'income', title: __('总收入'), operate:false}, 58 {field: 'income', title: __('总收入'), operate:false},
59 {field: 'withdraw', title: __('提现金额'), operate:false}, 59 {field: 'withdraw', title: __('提现金额'), operate:false},
60 {field: 'balance', title: __('账号余额'), operate:false}, 60 {field: 'balance', title: __('账号余额'), operate:false},
  61 + {field: 'count', title: __('总订单数'), operate:false},
61 // {field: 'level', title: __('Level'), operate:false}, 62 // {field: 'level', title: __('Level'), operate:false},
62 {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime}, 63 {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
63 {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime}, 64 {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},