作者 郭文星
... ... @@ -323,12 +323,57 @@ class Business extends Base
/**
* 12、业绩查询
* 11、个人业绩 当前门店下的业绩查询
* page = 1分页
*/
public function selectPerformance(){
$store_id=$this->store_id;
$row='';
$this->success("查询成功",$row);
$user_id = $this->auth->id;
//验证
$r1 = Db::name('_verification_staff')->where(['user_id'=>$user_id,'type'=>'0','verification_store_id'=>$store_id])->find();
if(empty($r1)){ return $this->error('仅店长可查自己店铺信息'); }
//当前店铺下的代理人,及代理人的推广数量
$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){
$item['count'] = Db::name('user')->where(['pid'=>$item['user_id']])->count();
return $item;
});
$this->success("查询成功",$rows);
}
/**
* 12、业绩查询 当前门店下的业绩查询
* page = 1分页
* date 日期
*/
public function select_performance_all(){
$store_id=$this->store_id;
$user_id = $this->auth->id;
$user_id = 4;
//参数
$param = request()->param();
//验证
if(empty($param['date'])){$param['date'] = date("Y-m-d"); }
$dates = [strtotime($param['date']." 00:00:00"),strtotime($param['date']." 23:59:59")];
$r1 = Db::name('_verification_staff')->where(['user_id'=>$user_id,'type'=>'0','verification_store_id'=>$store_id])->find();
if(empty($r1)){ return $this->error('仅店长可查自己店铺信息'); }
//当前店铺下的代理人,及代理人的推广数量
$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){
//一级统计
$count_1 = Db::name('user')->where(['pid'=>$item['user_id'],'updatetime'=>['between',$dates]])->field("id")->select();
$item['count_1'] = count($count_1);
//二级统计
$item['count_2'] = 0;
if(!empty($count_1)){
$ids = array_column($count_1,'id');
$item['count_2'] =Db::name('user')->where(['pid'=>['in',$ids],'updatetime'=>['between',$dates]])->field("id")->count();
}
//全部
$item['count_0'] = $item['count_1']+$item['count_2'];
return $item;
});
$this->success("查询成功",$rows);
}
}
... ...
... ... @@ -217,6 +217,7 @@ class Wechat extends Api
*/
public function register_relation(){
//参数
$time = time();
$param = request()->param();
if(!request()->isPost()){
return $this->error('请求错误');
... ... @@ -242,7 +243,7 @@ class Wechat extends Api
return $this->error('我是代理不记录');
}
Db::name('user')->where($w)->update(['pid'=>$param['share_id']]);
Db::name('user')->where($w)->update(['pid'=>$param['share_id'],'updatetime'=>$time]);
return $this->success('更新关系');
}else{
if($myInfo['pid'] == $param['share_id']){
... ... @@ -447,6 +448,8 @@ class Wechat extends Api
// 发放佣金 企业付款到零钱
public function grant_commission($pid=0,$order_id=0){
//测试 https://coupon.xp.yn.cn/api/v1/wechat/grant_commission
$order_id = 14;
try{
$send_result = 0;
$verification_order = Db::name('verification_order')->where(['id'=>$order_id])->find();
... ... @@ -463,6 +466,8 @@ class Wechat extends Api
'amount' => 1, // 企业付款金额,单位为分
'desc' => '分销佣金', // 企业付款操作说明信息。必填
]);
return json($result);
die;
if($result['return_code'] == 'SUCCESS' && $result['result_code'] == 'SUCCESS'){
//记录佣金表 后台没有配置
$send_result = 1;
... ... @@ -484,6 +489,8 @@ class Wechat extends Api
// 发放红包
public function grant_red_packets($pid=0,$order_id=0){
try{
//测试 https://coupon.xp.yn.cn/api/v1/wechat/grant_red_packets
$order_id = 14;
$verification_order = Db::name('verification_order')->where(['id'=>$order_id])->find();
$app = WehcatModule::getInstance()->initWechatPay();
$result = $app->redpack->sendNormal([
... ...