コード例 #1
0
ファイル: biz.class.php プロジェクト: ekdd1987/panda
 public function user_upgrade()
 {
     //获取各等级投资额
     $bizset = new bizset();
     $bizsetinfo = $bizset->get_bizset_bykey("STOCKUPDATE1");
     $stockprice1 = $bizsetinfo["bizvalue"];
     $bizsetinfo = $bizset->get_bizset_bykey("STOCKUPDATE2");
     $stockprice2 = $bizsetinfo["bizvalue"];
     $bizsetinfo = $bizset->get_bizset_bykey("STOCKUPDATE3");
     $stockprice3 = $bizsetinfo["bizvalue"];
     $bizsetinfo = $bizset->get_bizset_bykey("STOCKUPDATE4");
     $stockprice4 = $bizsetinfo["bizvalue"];
     $db = new DB();
     $db->Connect(DBHOST, DBUSER, DBPW, DBNAME);
     $sql = "select * from users where states = 1 and id !=100000 ";
     $query = $db->query($sql);
     $count = $db->num_rows($query);
     for ($i = 0; $i < $count; $i++) {
         $row = $db->fetch_array($query);
         $id = $row["id"];
         $stock = $row["stock"];
         $productcount = $row["productcount"];
         //会员等级
         //获取最新股价
         $stockinfo = new stock();
         $new_price = $stockinfo->get_newprice(1);
         //用户投资额
         $user_stock_price = $stock * $new_price;
         if ($productcount < 4) {
             if ($productcount == 3) {
                 if ($user_stock_price >= $stockprice4) {
                     $sql = "update users set productcount = 4  where id=" . $id . "";
                     $db->query($sql);
                 }
             }
             if ($productcount == 2) {
                 if ($user_stock_price >= $stockprice3) {
                     $sql = "update users set productcount = 3  where id=" . $id . "";
                     $db->query($sql);
                 }
                 if ($user_stock_price >= $stockprice4) {
                     $sql = "update users set productcount = 4  where id=" . $id . "";
                     $db->query($sql);
                 }
             }
             if ($productcount == 1) {
                 if ($user_stock_price >= $stockprice2) {
                     $sql = "update users set productcount = 2  where id=" . $id . "";
                     $db->query($sql);
                 }
                 if ($user_stock_price >= $stockprice3) {
                     $sql = "update users set productcount = 3  where id=" . $id . "";
                     $db->query($sql);
                 }
                 if ($user_stock_price >= $stockprice4) {
                     $sql = "update users set productcount = 4  where id=" . $id . "";
                     $db->query($sql);
                 }
             }
         }
     }
     //会员根据投资额升级 团队级别升级
     self::user_upgrade_stand();
 }
コード例 #2
0
ファイル: biz.class.bak.php プロジェクト: ekdd1987/panda
 public function standard_settle($db, $standardcount)
 {
     $users = new users();
     $bizset = new bizset();
     $award = new award();
     //获取最新结算号
     $settle_no = self::get_settle_no();
     //获取最新股价
     $stockinfo = new stock();
     $new_price = $stockinfo->get_newprice(1);
     //根据等级获取达标金额
     $bizsetinfo = $bizset->get_bizset_bykey("STANDARD_PRICE2");
     $standard_price2 = $bizsetinfo["bizvalue"];
     $bizsetinfo = $bizset->get_bizset_bykey("STANDARD_PRICE3");
     $standard_price3 = $bizsetinfo["bizvalue"];
     $bizsetinfo = $bizset->get_bizset_bykey("STANDARD_PRICE4");
     $standard_price4 = $bizsetinfo["bizvalue"];
     $bizsetinfo = $bizset->get_bizset_bykey("STANDARD_PRICE5");
     $standard_price5 = $bizsetinfo["bizvalue"];
     $bizsetinfo = $bizset->get_bizset_bykey("STANDARD_PRICE6");
     $standard_price6 = $bizsetinfo["bizvalue"];
     $bizsetinfo = $bizset->get_bizset_bykey("STANDARD_PRICE7");
     $standard_price7 = $bizsetinfo["bizvalue"];
     $bizsetinfo = $bizset->get_bizset_bykey("STANDARD_PRICE8");
     $standard_price8 = $bizsetinfo["bizvalue"];
     $bizsetinfo = $bizset->get_bizset_bykey("STANDARD_PRICE9");
     $standard_price9 = $bizsetinfo["bizvalue"];
     $bizsetinfo = $bizset->get_bizset_bykey("STANDARD_PRICE10");
     $standard_price10 = $bizsetinfo["bizvalue"];
     $bizsetinfo = $bizset->get_bizset_bykey("STANDARD_PRICE11");
     $standard_price11 = $bizsetinfo["bizvalue"];
     //根据等级获取达标分红比例
     $bizsetinfo = $bizset->get_bizset_bykey("STANDARD_PERCENT2");
     $standard_percent2 = $bizsetinfo["bizvalue"];
     $bizsetinfo = $bizset->get_bizset_bykey("STANDARD_PERCENT3");
     $standard_percent3 = $bizsetinfo["bizvalue"];
     $bizsetinfo = $bizset->get_bizset_bykey("STANDARD_PERCENT4");
     $standard_percent4 = $bizsetinfo["bizvalue"];
     $bizsetinfo = $bizset->get_bizset_bykey("STANDARD_PERCENT5");
     $standard_percent5 = $bizsetinfo["bizvalue"];
     $bizsetinfo = $bizset->get_bizset_bykey("STANDARD_PERCENT6");
     $standard_percent6 = $bizsetinfo["bizvalue"];
     $bizsetinfo = $bizset->get_bizset_bykey("STANDARD_PERCENT7");
     $standard_percent7 = $bizsetinfo["bizvalue"];
     $bizsetinfo = $bizset->get_bizset_bykey("STANDARD_PERCENT8");
     $standard_percent8 = $bizsetinfo["bizvalue"];
     $bizsetinfo = $bizset->get_bizset_bykey("STANDARD_PERCENT9");
     $standard_percent9 = $bizsetinfo["bizvalue"];
     $bizsetinfo = $bizset->get_bizset_bykey("STANDARD_PERCENT10");
     $standard_percent10 = $bizsetinfo["bizvalue"];
     $bizsetinfo = $bizset->get_bizset_bykey("STANDARD_PERCENT11");
     $standard_percent11 = $bizsetinfo["bizvalue"];
     //遍历users
     $query = $db->query("select * from users where states = 1");
     $count = $db->num_rows($query);
     for ($i = 0; $i < $count; $i++) {
         $row = $db->fetch_array($query);
         $uid = $row["id"];
         $usersinfo = $users->get_user_byid($uid);
         $stock = $usersinfo["stock"];
         //用户投资额
         //$user_stock_price = $stock*$new_price;
         //获取达标个数
         $pidcount = $users->get_usercount_bypid($uid);
         if ($pidcount == $standardcount) {
             //判断三个市场是否都达标 获取达标系数
             $sql_standard = "select * from users where states = 1 and pid = " . $uid;
             $query_standard = $db->query($sql_standard);
             for ($i = 0; $i < $standardcount; $i++) {
                 $row_standard = $db->fetch_array($query_standard);
                 $uid_standard = $row_standard["id"];
                 $usersids = $users->getrecursiveallusersid($uid_standard);
                 $usersids = substr($usersids, 0, strlen($usersids) - 1);
                 if (strlen($usersids) <= 0) {
                     $usersids = "0";
                 }
                 if ($usersids != "0") {
                     //$sql = "select sum(stock) as price from users where id in ($usersids) ";
                     //获取投资者投资额
                     $sql = "select abs(sum(amount)) as price  from income where types='BUYSTOCK' and userid = {$uid}";
                     $query_s = $db->query($sql);
                     $result = $db->fetch_array($query_s);
                     $sumamount = $result["price"];
                     //用户投资额
                     //$sumamount = $sumamount*$new_price;
                     //达标分红比例
                     if ($sumamount >= $standard_price11) {
                         $percent = $standard_percent11;
                         $standard_amout = $standard_price11;
                     } else {
                         if ($sumamount >= $standard_price10) {
                             $percent = $standard_percent10;
                             $standard_amout = $standard_price10;
                         } else {
                             if ($sumamount >= $standard_price9) {
                                 $percent = $standard_percent9;
                                 $standard_amout = $standard_price9;
                             } else {
                                 if ($sumamount >= $standard_price8) {
                                     $percent = $standard_percent8;
                                     $standard_amout = $standard_price8;
                                 } else {
                                     if ($sumamount >= $standard_price7) {
                                         $percent = $standard_percent7;
                                         $standard_amout = $standard_price7;
                                     } else {
                                         if ($sumamount >= $standard_price6) {
                                             $percent = $standard_percent6;
                                             $standard_amout = $standard_price6;
                                         } else {
                                             if ($sumamount >= $standard_price5) {
                                                 $percent = $standard_percent5;
                                                 $standard_amout = $standard_price5;
                                             } else {
                                                 if ($sumamount >= $standard_price4) {
                                                     $percent = $standard_percent4;
                                                     $standard_amout = $standard_price4;
                                                 } else {
                                                     if ($sumamount >= $standard_price3) {
                                                         $percent = $standard_percent3;
                                                         $standard_amout = $standard_price3;
                                                     } else {
                                                         if ($sumamount >= $standard_price2) {
                                                             $percent = $standard_percent2;
                                                             $standard_amout = $standard_price2;
                                                         } else {
                                                             $percent = 0;
                                                             break;
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             //根据分红比例加权分红
             $usersids_all = $users->getrecursiveallusersid($uid);
             $usersids_all = substr($usersids_all, 0, strlen($usersids_all) - 1);
             if (strlen($usersids_all) <= 0) {
                 $usersids_all = "0";
             }
             if ($usersids_all != "0" && $percent > 0) {
                 self::award_standard_settle($db, $uid, $usersids_all, $percent, $settle_no, $standard_amout);
             }
         }
         //更新结算状态变成已结算,并将结算期号增加到income表
         $sql = "update income set  settlementno = '" . $settle_no . "' where  (settlementno is null or settlementno='') and userid ={$uid} ";
         $db->query($sql);
     }
     //将本次结算设置为已结算
     $sql = "update settlement set states = 1 where numbers = '" . $settle_no . "'";
     $db->query($sql);
 }