Example #1
0
     }
     //查询模式一最高享受的层数
     $highlayer = $sqlhelper->getmodel1_highlayer();
     if ($highlayer < $i) {
         break;
     }
     $b1 = $sqlhelper->execute_dql1("select parent_id from ydcom_users where user_id={$b1}");
     //b1为上家
 }
 //模式二分成
 $b2 = $sqlhelper->execute_dql1("select parent_id from ydcom_users where user_id={$user_id}");
 //b2就是上家id
 //$a2为买家id
 $a2 = $user_id;
 for (; $b2 > 0;) {
     $d1 = $sqlhelper->getuser_fenxiaorank($a2);
     $d2 = $sqlhelper->getuser_fenxiaorank($b2);
     //a2为当前,b2为上家,d1为当前分销等级,d2为上家等级
     $gomodel2_minrank = $sqlhelper->gomodel2();
     if ($d2 > $d1 && $d2 >= $gomodel2_minrank) {
         //$up_commission为上家分销等级佣金比
         $res11 = $sqlhelper->execute_dql1("select discount from ydcom_user_yongjin where fenxiao_rank={$d2}");
         $up_commission = $res11 / 100;
         //当前用户模式二分销等级佣金比
         $res112 = $sqlhelper->execute_dql1("select discount from ydcom_user_yongjin where fenxiao_rank={$d1}");
         $present_commission = $res112 / 100;
         //canget_commission可获得的比例
         $canget_commission = $up_commission - $present_commission;
         //f2分销2的最终佣金
         $f2 = $fencheng2 * $canget_commission;
         //将分成2写入写入数据库