Пример #1
0
 static function getGupiaoDay($zqdm, $date)
 {
     $id = $zqdm . "_{$date}";
     $mc = DbConfig::getMongodb('dayklineinfo');
     if ($ret = $mc->findOne(array('_id' => $id))) {
         return $ret;
     }
     $pre = App::zqdmPre($zqdm);
     if (!$pre) {
         echo $error = "{$zqdm} no  marcket pre get\n";
         return $ret;
     }
     //
     $todate = date('Ymd');
     $kline = static::getDayK($pre . $zqdm, $date, $todate);
     $ret = array();
     if ($kline) {
         foreach ($kline as $info) {
             $day = date('Ymd', strtotime($info['time']));
             $id = $zqdm . "_{$day}";
             $info['day'] = $day;
             $info['zqdm'] = $zqdm;
             if (!$ret) {
                 $ret = $info;
             }
             $mc->findAndModify(array('_id' => $id), array('$set' => $info), array(), array('upsert' => true));
         }
     }
     return $ret;
 }
Пример #2
0
 /**
  * actionCashierGetInfo
  * @author cq
  * @date 2014/07/01
  * @param
  *      id:uid或者pid
  * @return
  *      s
  *      info
  *          uid
  *          create_t
  *          pid
  *          istest
  *          sections
  *              s1
  *                  name
  *                  level
  *                  vip
  *                  gem
  *                  defaul
  *              s2
  *                  ...
  *      payment_config
  *          系统的payment_config
  */
 public function actionCashierGetInfo()
 {
     $now = getApp()->now;
     //$ip = getApp()->getClientIP();
     //验证消息来源是否合法
     $valid_ip_list = array('115.29.193.89', '115.29.225.243', '115.29.229.132', '115.29.229.113', '117.121.10.35');
     /*
     		if(!in_array($ip, $valid_ip_list)){
     		return array('s'=>StatusCode::invalid_ip);
     		}*/
     $id = $_POST['id'];
     if (empty($id)) {
         echo json_encode(array('s' => StatusCode::invalid_param));
         return;
     }
     $mon = new PL_Db_Mongo(DbConfig::getMongodb('userlogin'));
     $um = $mon->findOne(array('email' => $id));
     if (!$um) {
         $um = $mon->findOne(array('pid' => $id));
     }
     if (!$um) {
         echo json_encode(array('s' => StatusCode::invalid_param));
         return;
     }
     $ret = array();
     $ret['s'] = StatusCode::ok;
     //获取用户登录信息
     $ret['info'] = array();
     $ret['info']['uid'] = $um['_id'];
     //接口中需要添加pid by zhangjun
     $ret['info']['pid'] = $um['pid'];
     $ret['info']['create_t'] = $um['_ct'];
     $ret['info']['istest'] = 0;
     $ret['info']['istest'] = $um['istest'] ? 'istest' : 0;
     $ret['info']['istest'] = $um['isdev'] ? 'isdev' : $ret['info']['istest'];
     //获取用户各个分区信息
     $section_config = getApp()->getSectionConfig();
     $ret['info']['sections'] = array();
     if (isset($um['secs'])) {
         foreach ($um['secs'] as $sec => $last_t) {
             $um_mc = new model_Player($um['_id'], $sec);
             $um_data = $um_mc->getFields(array('name', 'level', 'vip', 'gem', '_it'));
             $um_data['vip'] = $um_data['vip']['lvl'];
             $um_data['default'] = $sec == $um['_ld']['sec'] ? 1 : 0;
             $um_data['section_name'] = $section_config[$sec]['name'];
             $ret['info']['sections'][$sec] = $um_data;
         }
     }
     //获取支付信息
     $ret['payment_config'] = getApp()->getPaymentConifg();
     //NULL, $um['source']);
     $ret['payment_unit'] = '元宝';
     $list = $ret['payment_config'];
     //添加自定义支付项
     $max_product_config = array('cash' => -1);
     foreach ($ret['payment_config'] as $index => $p_config) {
         //修改一下提示信息
         $trans_config = PL_Config_Numeric::get('translate', $p_config['desc']);
         $ret['payment_config'][$index]['desc'] = $trans_config['zh_CN'];
         if ($p_config['cash'] > $max_product_config['cash']) {
             $max_product_config = $p_config;
             $product_config_list[] = $p_config;
         }
     }
     $ret['payment_config'] = array();
     $max_product = 1000;
     if ($max_product_config['cash'] > 0) {
         $custom_config = array('type' => 'define', 'gt' => $max_product, 'inputdesc' => '首次充值翻倍额度以游戏内最高可充值额度为准', 'gemcalc' => "Math.ceil(cash*10 + cash*1300/998)", 'product_id' => 'custom');
         $ret['payment_config'][] = $custom_config;
     }
     foreach ($list as $k => $v) {
         //if($v['gemaward'] > 0 && !isset($v['hide'])){
         if (isset($v['forweb'])) {
             $ret['payment_config'][] = $v;
         }
     }
     echo json_encode($ret);
 }
Пример #3
0
<?php

$cond = array();
$mon = new PL_Db_Mongo(DbConfig::getMongodb($coll));
$limit = $this->getParam('rows', 20);
$page = $this->getParam('page', 0);
//prcoess sort as string "0 dec,1"
$sort = array();
$sidx = $this->getParam('sidx');
$sord = $this->getParam('sord');
if ($sidx) {
    $sidx .= $sord;
    preg_match_all('/[\\s]*([\\w]+)[\\s]+([\\w]+)[\\s]*/', $sidx, $mout);
    foreach ((array) $mout[1] as $k => $v) {
        if ($mout[2][$k] == 'asc') {
            $sort[$v] = 1;
        } else {
            $sort[$v] = -1;
        }
    }
} else {
    if ($sord == 'desc') {
        $sort[0] = -1;
    } else {
        if ($sord == 'asc') {
            $sort[0] = 1;
        }
    }
}
//process query
//todo procecess all ops
Пример #4
0
 function actionSendSystemMsg()
 {
     //$uid = (int)self::getParam('uid');
     $userstr = self::getParam('uid');
     $sec = self::getParam('sec');
     $content = self::getParam('content');
     $desc = self::getParam('desc');
     $items = self::getParam('items');
     $ready_id = self::getParam('ready_id');
     foreach ((array) $items as $value) {
         $tag = $value['tag'];
         $num = intval($value['num']);
         if ($tag == 'gem' && $num > 100000) {
             echo "error, 元宝不能大于100000";
             exit;
         }
     }
     $key = uniqid();
     $msg = array('key' => $key, 'time' => app()->now, 'content' => $content, 'type' => 'system');
     if ($userstr != "all") {
         $uids = explode(',', $userstr);
         $itemmsg = "";
         foreach ($uids as $uid) {
             $uid = getApp()->getRealUid($uid, $sec);
             $sec = getApp()->getRealSec($sec);
             $player = new model_Player($uid, $sec);
             $level = $player->objectGet("base", "level");
             foreach ((array) $items as $key => $value) {
                 $tag = $value['tag'];
                 $num = intval($value['num']);
                 if ($tag == 'qiyu_zhidian') {
                     $zhidian_lvl = max(1, $level * 3 - 34);
                     for ($i = 0; $i < $num; $i++) {
                         $items[] = array('tag' => 'qiyu_zhidian', 'level' => $zhidian_lvl, 'num' => 1);
                     }
                     unset($items[$key]);
                 }
             }
             if (is_array($items) && count($items) > 0) {
                 $msg['status'] = 'award';
                 #$msg['content'].="\n$desc";
                 $cdkey = model_Cdkey::gen($items, $desc, 1, 'def');
                 $msg['cdkey'] = $cdkey;
             }
             $r = model_Chat::sendMsg($msg, $uid, 'origin', $sec);
         }
     } else {
         $r = model_Chat::send($msg, 2, "", "toall", $sec);
     }
     if ($r) {
         $mon = new PL_Db_Mongo(DbConfig::getMongodb('userlogin'));
         $mon->switchColl('msgready');
         $mon = $mon->getmc();
         $id = $mon->update(array('ready_id' => (int) $ready_id), array('$set' => array('applicant_status' => 0, 'check_man' => $_SERVER['PHP_AUTH_USER'])));
         echo json_encode(array('s' => 'OK'));
     }
 }
Пример #5
0
$mon = new PL_Db_Mongo(DbConfig::getMongodb('jgd'));
$sort = array('0' => 1, '_fnorder' => 1);
$limit = 1000000;
$skip = 0;
$datestr = $argv[1];
if (!$datestr) {
    $datestr = PL_Server::getParam('date', date('Ymd'));
}
$cond['$and'][] = (object) array('0' => array('$lte' => $datestr));
$c = $mon->findByIndex($coll, (object) $cond, $limit, $skip, array(), (object) $sort, true);
//
//申购代码和正式上市代码统一转换后处理
//
//
//按日期正序
$mon = new PL_Db_Mongo(DbConfig::getMongodb('calcc'));
while ($row = $c->getNext()) {
    $ywmc = $row[1];
    //业务名称
    $zqdm = $row[2];
    //证券代码
    $jgrq = $row[0];
    //交割日期
    //echo "$jgrq \n";continue;
    if (!$ywmc) {
        echo "no ywmc {$jgrq} {$ywmc} {$zqdm} \n";
        continue;
    }
    if ($prejgrq != $jgrq) {
        //
        if ($prejgrq) {
Пример #6
0
<?php

//add comment
$zqdm = $this->getParam('zqdm');
$content = $this->getParam('content');
$doq = $this->getParam('doq');
$coll = 'czbz';
$dconf =& App::getDataconf($coll);
$mc = DbConfig::getMongodb('czbz');
if ($zqdm && $content) {
    $zqmc = $this->getParam('zqmc');
    $ts = $this->getParam('ts');
    $oper = $this->getParam('oper');
    $cond = array('_id' => $ts);
    if ($oper == 'del') {
        $mc->del($cond);
        exit;
    }
    if ($content) {
        if (!$ts) {
            $ts = $_SERVER['REQUEST_TIME'];
        }
        $datestr = @date('Ymd H:i:s', $ts);
        $bzo = array('time' => $datestr, 'ts' => $ts, 'zqmc' => $zqmc, 'zqdm' => $zqdm, 'content' => $content);
        $mc->findAndModify($cond, array('$set' => $bzo), array(), array('upsert' => true));
    }
    exit;
} elseif ($doq) {
    static::processGridAjaxParams($sort, $cond, $limit, $skip, $filterstr, $sidx);
    $mon = new PL_Db_Mongo($mc);
    $c = $mon->findByIndex($coll, (object) $cond, $limit, $skip, array(), (object) $sort, true);
Пример #7
0
function clipbordExcelImportTotal($content, &$coll, &$myerrorno)
{
    $coll = 'zjgf';
    $dataconf =& App::getDataconf();
    $collconf = $dataconf['zjgf'];
    $lines = explode("\n", $content);
    $mc = DbConfig::getMongodb('zjgf');
    $datestr = date('Ymd');
    foreach ($lines as $k => $l) {
        $row = explode("\t", trim($l));
        $fnum = count($row);
        if ($k == 0) {
            foreach ($collconf['theader'] as $kk => $v) {
                if ($v != $row[$kk]) {
                    $myerrorno = 'noheader';
                    return $error = "theader not match {$kk} [{$v}] [{$row[$kk]}]";
                }
            }
        } elseif (1 == $k) {
            $id = $datestr . '_total';
            $row['date'] = $datestr;
            $row['istotal'] = 1;
            $cond['_id'] = $id;
            $rid = md5($datestr . $row[0] . $row[1] . $row[2] . $row[3] . $row[4] . $row[5]);
            $old = $mc->findOne($cond);
            if ($old) {
                //合并
                if ($old['rids'][$rid] == 1) {
                    return $error .= "{$id} imported";
                }
                for ($i = 1; $i < 6; $i++) {
                    $row[$i] += $old[$i];
                }
            }
            $row['rids'] = $old['rids'];
            $row['rids'][$rid] = 1;
            $mc->findAndModify($cond, array('$set' => $row), array(), array('upsert' => true));
        } elseif (3 == $k) {
            if ($row[5] != '参考保本价') {
                // rr
                $isrr = 1;
                $coll = 'zjgf_rr';
                $error .= "isrr 1\n";
            }
            if ($isrr) {
                foreach ($collconf['rr'] as $mk => $v) {
                    // echo "$mk $v\n";
                    $nrow[$mk] = $row[$v];
                }
                $row = $nrow;
            }
            foreach ($collconf['header'] as $kk => $v) {
                $nk = $kk;
                if ($isrr) {
                    $nk = $collconf['rr'][$kk];
                }
                if ($nk === '') {
                    continue;
                }
                if ($v != $row[$kk]) {
                    if ($kk < 10) {
                        $myerrorno = 'noheader';
                        $error .= "header not compact kk[{$kk}] nk[{$nk}] [{$v}] [{$row[$kk]}]\n";
                        return $error;
                    }
                }
            }
        } else {
            if ($fnum < 8) {
                continue;
            }
            if ($isrr) {
                foreach ($collconf['rr'] as $mk => $v) {
                    $nrow[$mk] = $row[$v];
                }
                $row = $nrow;
            }
            $id = $datestr . '_' . $row[12];
            //股东代码
            $rid = md5($row[0] . $row[1] . $row[3] . $row[4] . $row[7] . $row[10]);
            $row['date'] = $datestr;
            $row['istotal'] = 0;
            $cond['_id'] = $id;
            $old = $mc->findOne($cond);
            if ($old) {
                $findi += 1;
            }
            if ($old && $old['rids'][$rid] == 1) {
                //合并
                continue;
            }
            if ($old) {
                $mergei += 1;
                $totalcb = $row[4] * $row[2] + $old[4] * $old[2];
                $row[1] += $old[1];
                $row[2] += $old[2];
                //库存数量
                $row[3] += $old[3];
                $row[7] += $old[7];
                $row[8] += $old[8];
                $row[10] += $old[10];
                $row[11] += $old[11];
                $row['chengben'] = $totalcb;
                $row[4] = number_format($totalcb / $row[2], 3);
                //成本价
                $row[5] = number_format($row[4] * 1.002, 3);
                $row[9] = number_format($row[8] * 100 / $totalcb, 3);
                //算盈亏比例
            } else {
                $newi += 1;
            }
            $row['rids'] = $old['rids'];
            $row['rids'][$rid] = 1;
            App::normalTodb($row, $collconf['numfields']);
            $mc->findAndModify($cond, array('$set' => $row), array(), array('upsert' => true));
        }
    }
    $error .= "\n {$counterror} improt [{$newi}] new records, [{$findi}] old records ,[{$mergei}] merge {$coll}\n";
    return $error;
}
Пример #8
0
 /**
  * @author 符璨
  * @desc
  *      从cdkey_task取出待处理的cdkey任务进行处理 
  *      批量生成cdkey
  */
 public static function action_gen_cdkey()
 {
     $redis = DbConfig::getRedis('realtime_stat');
     $process_id = getmypid();
     //从cdkey中取出一条状态为0(未处理cdkey生成记录),并更新为1(正在处理)
     $mc = new PL_Db_Mongo(DbConfig::getMongodb('userlogin'));
     $mc->switchColl('cdkey_task');
     $cdkey_task = $mc->findOne(array('status' => 0));
     //没有待处理的任务
     if ($cdkey_task == NULL) {
         return;
     }
     glog::info("[{$process_id}] gen cdkey worker started", 'cdkey');
     $task_id = $cdkey_task['_id'];
     $mc->update(array('_id' => $task_id), array('$set' => array('status' => 1)));
     $pa = $cdkey_task;
     unset($pa['status']);
     $num = $pa['num'];
     $task_id = $cdkey_task['_id'];
     //根据cdkey_task的内容生成cdkey
     $mc->switchColl('cdkey');
     while ($num--) {
         $pa['_id'] = model_Cdkey::genCdkey(13);
         $pa['task_id'] = $task_id->__toString();
         //try以防有重复的cdkey
         try {
             $cdkey = $mc->insert($pa);
             //redis中统计当前已生成的cdkey数目
             $redis->hIncrBy('cdkey_task', $task_id, 1);
             $redis->lpush("cdkey_{$task_id}", $pa['_id']);
         } catch (Exception $ex) {
             $exception_cnt--;
             $num++;
             glog::info("[{$process_id}] gen cdkey worker:Duplicated _id {$pa['_id']}", 'cdkey');
             if (!$exception_cnt) {
                 break;
             }
             continue;
         }
         $exception_cnt = 10;
     }
     $mc->switchColl('cdkey_task');
     $mc->update(array('_id' => $task_id), array('$set' => array('status' => 2)));
     $redis->hDel('cdkey_task', $task_id);
     glog::info("[{$process_id}] gen cdkey worker completed", 'cdkey');
 }
Пример #9
0
<?php

include __DIR__ . '/../base.php';
$dataconf = (include './dataconf.php');
$files = glob(__DIR__ . "/raw/newq/*.csv");
foreach ($files as $afn) {
    echo "{$afn}  \n";
    $fn = basename($afn, '.txt');
    $finfo = explode('_', $fn);
    $coll = $finfo[0];
    $collconf =& $dataconf[$coll];
    if (!$finfo[1] || !$collconf) {
        echo "{$fn} ignore [name not get coll] \n";
        continue;
    }
    $mc = DbConfig::getMongodb($coll);
    $fd = fopen($afn, "r");
    if (!$fd) {
        echo "import {$coll} -- {$collconf['name']} failed!!!! -- ";
        echo "file {$afn} not open\n";
        continue;
    }
    $idfs = $collconf['idfs'];
    $header = $collconf['header'];
    $colcnt = count($header);
    $headerfind = false;
    $i = 0;
    while ($row = fgetcsv($fd)) {
        $vstr = '';
        foreach ($idfs as $v) {
            $vstr .= $row[$v];