作者 chencheng

0531-8

@@ -323,12 +323,57 @@ class Business extends Base @@ -323,12 +323,57 @@ class Business extends Base
323 323
324 324
325 /** 325 /**
326 - * 12、业绩查询 326 + * 11、个人业绩 当前门店下的业绩查询
  327 + * page = 1分页
327 */ 328 */
328 public function selectPerformance(){ 329 public function selectPerformance(){
329 $store_id=$this->store_id; 330 $store_id=$this->store_id;
330 - $row='';  
331 - $this->success("查询成功",$row); 331 + $user_id = $this->auth->id;
  332 +
  333 + //验证
  334 + $r1 = Db::name('_verification_staff')->where(['user_id'=>$user_id,'type'=>'0','verification_store_id'=>$store_id])->find();
  335 + if(empty($r1)){ return $this->error('仅店长可查自己店铺信息'); }
  336 + //当前店铺下的代理人,及代理人的推广数量
  337 + $rows = Db::name('_verification_staff')->where(['verification_store_id'=>$store_id,'type'=>['in',['1','3']]])->field("name,0 as count,user_id")->paginate(20)->each(function($item){
  338 + $item['count'] = Db::name('user')->where(['pid'=>$item['user_id']])->count();
  339 + return $item;
  340 + });
  341 + $this->success("查询成功",$rows);
  342 + }
  343 +
  344 +
  345 + /**
  346 + * 12、业绩查询 当前门店下的业绩查询
  347 + * page = 1分页
  348 + * date 日期
  349 + */
  350 + public function select_performance_all(){
  351 + $store_id=$this->store_id;
  352 + $user_id = $this->auth->id;
  353 + $user_id = 4;
  354 + //参数
  355 + $param = request()->param();
  356 + //验证
  357 + if(empty($param['date'])){$param['date'] = date("Y-m-d"); }
  358 + $dates = [strtotime($param['date']." 00:00:00"),strtotime($param['date']." 23:59:59")];
  359 + $r1 = Db::name('_verification_staff')->where(['user_id'=>$user_id,'type'=>'0','verification_store_id'=>$store_id])->find();
  360 + if(empty($r1)){ return $this->error('仅店长可查自己店铺信息'); }
  361 + //当前店铺下的代理人,及代理人的推广数量
  362 + $rows = Db::name('_verification_staff')->where(['verification_store_id'=>$store_id,'type'=>['in',['1','3']]])->field("name,0 as count,user_id")->paginate(20)->each(function($item) use ($dates){
  363 + //一级统计
  364 + $count_1 = Db::name('user')->where(['pid'=>$item['user_id'],'updatetime'=>['between',$dates]])->field("id")->select();
  365 + $item['count_1'] = count($count_1);
  366 + //二级统计
  367 + $item['count_2'] = 0;
  368 + if(!empty($count_1)){
  369 + $ids = array_column($count_1,'id');
  370 + $item['count_2'] =Db::name('user')->where(['pid'=>['in',$ids],'updatetime'=>['between',$dates]])->field("id")->count();
  371 + }
  372 + //全部
  373 + $item['count_0'] = $item['count_1']+$item['count_2'];
  374 + return $item;
  375 + });
  376 + $this->success("查询成功",$rows);
332 } 377 }
333 378
334 } 379 }
@@ -217,6 +217,7 @@ class Wechat extends Api @@ -217,6 +217,7 @@ class Wechat extends Api
217 */ 217 */
218 public function register_relation(){ 218 public function register_relation(){
219 //参数 219 //参数
  220 + $time = time();
220 $param = request()->param(); 221 $param = request()->param();
221 if(!request()->isPost()){ 222 if(!request()->isPost()){
222 return $this->error('请求错误'); 223 return $this->error('请求错误');
@@ -242,7 +243,7 @@ class Wechat extends Api @@ -242,7 +243,7 @@ class Wechat extends Api
242 return $this->error('我是代理不记录'); 243 return $this->error('我是代理不记录');
243 } 244 }
244 245
245 - Db::name('user')->where($w)->update(['pid'=>$param['share_id']]); 246 + Db::name('user')->where($w)->update(['pid'=>$param['share_id'],'updatetime'=>$time]);
246 return $this->success('更新关系'); 247 return $this->success('更新关系');
247 }else{ 248 }else{
248 if($myInfo['pid'] == $param['share_id']){ 249 if($myInfo['pid'] == $param['share_id']){
@@ -484,6 +485,7 @@ class Wechat extends Api @@ -484,6 +485,7 @@ class Wechat extends Api
484 // 发放红包 485 // 发放红包
485 public function grant_red_packets($pid=0,$order_id=0){ 486 public function grant_red_packets($pid=0,$order_id=0){
486 try{ 487 try{
  488 + $order_id = 14;
487 $verification_order = Db::name('verification_order')->where(['id'=>$order_id])->find(); 489 $verification_order = Db::name('verification_order')->where(['id'=>$order_id])->find();
488 $app = WehcatModule::getInstance()->initWechatPay(); 490 $app = WehcatModule::getInstance()->initWechatPay();
489 $result = $app->redpack->sendNormal([ 491 $result = $app->redpack->sendNormal([