|
@@ -37,60 +37,100 @@ class Alltools {
|
|
|
$prefix = $table_enum[$table]['prefix'];
|
|
|
$remark = $table_enum[$table]['remark'];
|
|
|
|
|
|
+ //配置
|
|
|
+ $config_site = DB::table('mt_config')->whereIn('name',['shouyi_b2a_rate','shouyi_c2a_rate'])->pluck('value','name');
|
|
|
+
|
|
|
//收益者本人
|
|
|
- $userinfo = DB::table('mt_user')->select(['id','username','group_id','intro_uid','invite_uid','gender'])->where('id',$user_id)->first();
|
|
|
+ $userinfo = DB::table('mt_user')->select(['id','username','group_id','intro_uid','invite_uid','agent_id','gender'])->where('id',$user_id)->first();
|
|
|
|
|
|
- //没有推荐人,自己等级最高
|
|
|
- if(empty($userinfo->intro_uid) || $userinfo->group_id == 3){
|
|
|
- return true;
|
|
|
- }
|
|
|
+ //先确认自己的等级
|
|
|
+ if($userinfo->group_id == 1){
|
|
|
+ //充值者上级
|
|
|
+ $intro_userinfo = DB::table('mt_user')->select(['id','username','group_id','intro_uid','invite_uid','agent_id','gender'])->where('id',$userinfo->intro_uid)->first();
|
|
|
+ if(empty($intro_userinfo)){return true;}
|
|
|
|
|
|
- //充值者上级
|
|
|
- $intro_userinfo = DB::table('mt_user')->select(['id','username','group_id','intro_uid','gender'])->where('id',$userinfo->intro_uid)->first();
|
|
|
- if(empty($intro_userinfo)){return true;}
|
|
|
+ //上级是二级邀请B1,贡献给A
|
|
|
+ if($intro_userinfo->group_id == 2){
|
|
|
|
|
|
- //配置
|
|
|
- $config_site = DB::table('mt_config')->whereIn('name',['shouyi_b2a_rate','shouyi_c2a_rate'])->pluck('value','name');
|
|
|
+ //充值者上上级,也就是A
|
|
|
+ $intro_intro_userinfo = DB::table('mt_user')->select(['id','username','group_id','intro_uid','invite_uid','agent_id','gender'])->where('id',$intro_userinfo->agent_id)->first();
|
|
|
+ if(empty($intro_intro_userinfo)){return true;}
|
|
|
|
|
|
- //上级是一级邀请A,本人为B普、B1(二级邀请人),贡献给A
|
|
|
- if($intro_userinfo->group_id == 3){
|
|
|
+ if($intro_intro_userinfo->group_id == 3){
|
|
|
|
|
|
- $shouyi_b2a_rate = $config_site['shouyi_b2a_rate'];//b2a 与 b02a相等
|
|
|
- $jewelA = bcdiv(bcmul($gold,$shouyi_b2a_rate),100);
|
|
|
+ $shouyi_c2a_rate = $config_site['shouyi_c2a_rate'];
|
|
|
+ $jewelA = bcdiv(bcmul($gold,$shouyi_c2a_rate),100);
|
|
|
|
|
|
- $result = $this->lockChangeAccountRemain($intro_userinfo->id,'agentjewel',$jewelA,52, $userinfo->username.$remark,$table,$table_id);
|
|
|
- if($result['status']===false)
|
|
|
- {
|
|
|
- //Db::rollback();
|
|
|
- return false;
|
|
|
+ $result = $this->lockChangeAccountRemain($intro_intro_userinfo->id,'agentjewel',$jewelA,52, $userinfo->username.$remark,$table,$table_id);
|
|
|
+ if($result['status']===false)
|
|
|
+ {
|
|
|
+ //Db::rollback();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
}
|
|
|
+ //上级是A
|
|
|
+ if($intro_userinfo->group_id == 3){
|
|
|
|
|
|
- return true;//结束了
|
|
|
- }
|
|
|
+ $shouyi_b2a_rate = $config_site['shouyi_b2a_rate'];//b2a 与 b02a相等
|
|
|
+ $jewelA = bcdiv(bcmul($gold,$shouyi_b2a_rate),100);
|
|
|
|
|
|
- //上级是二级邀请B1,本人C1,贡献给B和A(表面上说B的钱在A那里,但是有记录,有总额,不能提现即可)
|
|
|
- if($intro_userinfo->group_id == 2 && $intro_userinfo->group_id > $userinfo->group_id){
|
|
|
+ $result = $this->lockChangeAccountRemain($intro_userinfo->id,'agentjewel',$jewelA,52, $userinfo->username.$remark,$table,$table_id);
|
|
|
+ if($result['status']===false)
|
|
|
+ {
|
|
|
+ //Db::rollback();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
- //充值者上上级,也就是A
|
|
|
- $intro_intro_userinfo = DB::table('mt_user')->select(['id','username','group_id','intro_uid','gender'])->where('id',$intro_userinfo->intro_uid)->first();
|
|
|
- if(empty($intro_intro_userinfo)){return true;}
|
|
|
+ return true;//结束了
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if($userinfo->group_id == 2){
|
|
|
+ //充值者上级
|
|
|
+ $intro_userinfo = DB::table('mt_user')->select(['id','username','group_id','intro_uid','invite_uid','agent_id','gender'])->where('id',$userinfo->intro_uid)->first();
|
|
|
+ if(empty($intro_userinfo)){return true;}
|
|
|
|
|
|
- if($intro_intro_userinfo->group_id == 3){
|
|
|
+ //上级是一级邀请A,本人为B普、B1(二级邀请人),贡献给A
|
|
|
+ /*if($intro_userinfo->group_id == 3){//不是返给一级代理,而是给上级,因为可能和上级解绑放到自己名下了 */
|
|
|
|
|
|
- $shouyi_c2a_rate = $config_site['shouyi_c2a_rate'];
|
|
|
- $jewelA = bcdiv(bcmul($gold,$shouyi_c2a_rate),100);
|
|
|
+ $shouyi_b2a_rate = $config_site['shouyi_b2a_rate'];//b2a 与 b02a相等
|
|
|
+ $jewelA = bcdiv(bcmul($gold,$shouyi_b2a_rate),100);
|
|
|
|
|
|
- $result = $this->lockChangeAccountRemain($intro_intro_userinfo->id,'agentjewel',$jewelA,52, $userinfo->username.$remark,$table,$table_id);
|
|
|
+ $result = $this->lockChangeAccountRemain($intro_userinfo->id,'agentjewel',$jewelA,52, $userinfo->username.$remark,$table,$table_id);
|
|
|
if($result['status']===false)
|
|
|
{
|
|
|
//Db::rollback();
|
|
|
return false;
|
|
|
}
|
|
|
+
|
|
|
+ return true;//结束了
|
|
|
+ /*}*/
|
|
|
+ }
|
|
|
+ //没有推荐人,自己等级最高
|
|
|
+ if($userinfo->group_id == 3 && !empty($userinfo->intro_uid)){
|
|
|
+ //充值者上级
|
|
|
+ $intro_userinfo = DB::table('mt_user')->select(['id','username','group_id','intro_uid','invite_uid','agent_id','gender'])->where('id',$userinfo->intro_uid)->first();
|
|
|
+ if(empty($intro_userinfo)){return true;}
|
|
|
+
|
|
|
+
|
|
|
+ $shouyi_b2a_rate = $config_site['shouyi_b2a_rate'];
|
|
|
+ $jewelA = bcdiv(bcmul($gold,$shouyi_b2a_rate),100);
|
|
|
+
|
|
|
+ $result = $this->lockChangeAccountRemain($intro_userinfo->id,'agentjewel',$jewelA,52, $userinfo->username.$remark,$table,$table_id);
|
|
|
+ if($result['status']===false)
|
|
|
+ {
|
|
|
+ //Db::rollback();
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
- return true;
|
|
|
+ return true;//结束了
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+//////////////////
|
|
|
+
|
|
|
return true;
|
|
|
}
|
|
|
|