예제 #1
0
 /**
  * 获取所有票据
  *
  * @return CommonUtilReturnVar
  */
 function getall()
 {
     $retCode = 0;
     $retCode_Str = 'SUCC';
     $data = array();
     // class err_dbs_applereceiptcenter_getall{}
     $db = DBPools::default_Db_pools()->dbconnect();
     $ret = $db->query(Data::DBKey_tablename);
     // code
     succ:
     return CommonUtilReturnVar::Ret(true, $retCode, $data, $retCode_Str);
     failed:
     return CommonUtilReturnVar::Ret(false, $retCode, $data, $retCode_Str);
 }
예제 #2
0
 /**
  *
  * @param string $tableName
  * @param array $db_field_keys
  *            关键字数组,key=>defalutvalue
  * @param array $db_field_primary_key
  *            主键 [key1,key2]
  * @param bool $auto_save
  *            是否自动保存
  * @param bool $auto_load
  *            是否自动加载,也就是判断isExistDBID 后 ,执行loadfromDB
  */
 function __construct($tableName = self::EMPTY_TABLE_NAME, $db_field_keys = array(), $db_field_primary_key = array(), $auto_save = true, $auto_load = true)
 {
     parent::__construct($db_field_keys);
     // 数据库连接
     $this->db_ins = DBPools::default_Db_pools()->dbconnect();
     $this->table_name = $tableName;
     if (is_array($db_field_primary_key)) {
         $this->set_primary_key($db_field_primary_key);
     }
     // 是否支持自动保存
     if ($auto_save) {
         self::db_pools()->push($this);
     }
     $this->flag_db_autoload = $auto_load;
 }
예제 #3
0
 /**
  * 获取充值数据
  * @param string $orderId 订单id
  * @param null $unique_identifier
  * @return RechargeData|null
  */
 public function get_rechargedata($orderId, $unique_identifier = NULL)
 {
     $orderId = strval($orderId);
     $db = DBPools::default_Db_pools()->dbconnect();
     $where = array();
     array_push($where, array(RechargeData::DBKey_orderid => $orderId));
     if (!is_null($unique_identifier)) {
         array_push($where, array(RechargeData::DBKey_unique_identifier => $unique_identifier));
     }
     $ret = $db->query(RechargeData::DBKey_tablename, array('$or' => $where));
     if (count($ret) == 0) {
         return null;
     }
     $dbRet = $ret[0];
     $data = new RechargeData();
     $data->fromArray($dbRet);
     return $data;
 }
예제 #4
0
 private function __processMessages($messages)
 {
     $timeHelper = new CommonUtilRuntime();
     $timeHelper->start();
     if (!is_array($messages)) {
         return "f:" . __LINE__;
     }
     if (count($messages) > config('app')[Constants::ONCE_PROCESS_MESSAGE_MAX_COUNT]) {
         return "f:" . __LINE__;
     }
     // 数据池
     DBPools::default_Db_pools()->begin();
     if (config(Constants::ENABLE_SCHEDULE)) {
         // 定时器调用
         Manager::getInstance()->update();
     }
     foreach ($messages as $value) {
         $this->__processMessage($value);
     }
     DBPools::default_Db_pools()->save();
     DBPools::default_Db_pools()->end();
     // 处理消息返回
     $returnMessages = array();
     while (NULL != ($returnMessage = CommonUtilMessage::popS2CMessage())) {
         $returnMessages[] = $returnMessage->toArray();
     }
     // 没有消息返回
     if (count($returnMessages) == 0) {
         return "f:" . __LINE__;
     }
     $compressedMessage = CommonUtilMessage::encodeMessage($returnMessages);
     $timeHelper->stop();
     CommonUtilLog::record(CommonUtilLog::DEBUG, 'command_run_oncetime', ['totaltime' => $timeHelper->spent(), 'core_time' => array_sum($this->call_commands) . 'ms', 'cmd' => $this->call_commands]);
     return $compressedMessage;
 }