Tools.php 1.05 KB
<?php

/**
 * Created by PhpStorm.
 * User: Ziy
 * Date: 14/9/2
 * Time: 下午6:31
 */
class YHMUtils_Tools
{
    /**
     * @param $depotName
     * @return Q_Db_Mongo_Core_Base
     */
    static function mongo($depotName)
    {
        return Q_Db::mongo($depotName);
    }

    static function loggers(array $package, $collection = 'alipay', $depotName = 'PayLoggers')
    {
        try {
            $logPackage = array(
                'mongo_date' => new MongoDate(),
                'create_time' => time(),
                'package' => $package
            );
            YHMUtils_Tools::mongo($depotName)->collection($collection)->insert($logPackage);
        } catch (Exception $e) {

        }
    }

    static function makeAgreementKey($packageData)
    {
        ksort($packageData);
        reset($packageData);
        $packageList = array();
        foreach ($packageData as $key => $val) {
            $packageList[] = trim($key . '=' . $val);
        };
        return md5(Q_Utils_Function::generateIdHex() . strtolower(implode('&', $packageList)));
    }
}