示例#1
0
 public function action_chongzhi()
 {
     $mon = getApp()->getPaymentMongoConnection();
     //$begin = 1351530000;
     $begin = strtotime("2012-12-02 01:00:00");
     $rows = $mon->find(array('status' => StatusCode::payment_finished, 'action' => 'recharge_gem', '_sec' => 's1', 'finish_t' => array('$gte' => $begin)), array(), array('_tm' => 1));
     //$rows = $mon->find(array('status'=>StatusCode::payment_finished,'action'=>'recharge_gem'),array(),array('_tm'=>1));
     $payments = array();
     $payments_check = array();
     foreach ($rows as $r) {
         $uid = $r['_u'];
         $section_id = $r['_sec'];
         if (0) {
             if ($r['finish_t'] >= $begin) {
                 if (empty($payments[$section_id][$uid])) {
                     $player = new model_Player($uid, $section_id);
                     $payments[$section_id][$uid] = $player->numberGet('base', 'total_gem_added');
                 }
                 $payments[$section_id][$uid] += $r['agem'];
             }
             $payments_check[$section_id][$uid] += $r['agem'];
         } else {
             //echo json_encode($r)."\n";
             $player = new model_Player($uid, $section_id);
             $data = $player->getFields(array('vip', 'gem', 'total_gem_added', 'total_gem_rewarded', 'total_gem_rewarded2', 'total_gem_used'));
             echo "before: {$uid},{$section_id}," . json_encode($data) . "\n";
             $player->process_payment2($r);
             foreach (array('vip', 'gem', 'total_gem_added', 'total_gem_rewarded', 'total_gem_rewarded2', 'total_gem_used') as $k) {
                 $data2[$k] = $player->objectGet('base', $k);
             }
             echo "after: " . json_encode($data2) . "\n";
             $player->commit();
             echo "======\n\n";
         }
     }
     /*
             foreach($payments as $section_id=>$xxx){
        foreach($xxx as $uid=>$added_gem){
            if($payments_check[$section_id][$uid]!=$added_gem){
                echo "$section_id,$uid, right :{$payments_check[$section_id][$uid]}, $added_gem\n";
            }
        }
             }
     */
     /*
      */
     /*
             var_dump($payments);
             foreach($payments as $section_id=>$xxx){
        foreach($xxx as $uid=>$added_gem){
            $player = new model_Player($uid,$section_id);
            $total_gem_added = $player->numberGet('base','total_gem_added');
            //$total_gem_added + $added_gem 
     
            $rows = $mon->find(array('_sec'=>$section_id),'status'=>StatusCode::payment_finished,'action'=>'recharge_gem','finish_t'=>array('$gte'=>$begin)),array(),array('_tm'=>1));
     
        }
             }
     */
 }