/**
  * 
  * @param $username 手机号 OR 邮箱
  * @param $type     发送类型repwd(修改密码) 
  * @param $code   验证码
  */
 public static function send($condition)
 {
     if (!is_array($condition)) {
         return FALSE;
     }
     extract($condition, EXTR_SKIP);
     if (empty($type) || empty($content) || empty($username)) {
         return FALSE;
     }
     //记录日志表
     $request = Request::current();
     $patternMobile = Sp_Dictionary::getOtherOption('patternMobile');
     $patternEmail = Sp_Dictionary::getOtherOption('patternEmail');
     $row = array('sms_id' => $type, 'content' => $content, 'ip' => $request->getIp(), 'crttime' => time());
     //邮箱发送
     if (preg_match($patternEmail, $username)) {
         $row['email'] = $username;
         self::sendEmail($username, $content);
     }
     //手机发送
     if (preg_match($patternMobile, $username)) {
         $row['phone'] = $username;
         self::sendPhone($username, $content);
     }
     //验证码
     if (!empty($code)) {
         $row['code'] = $code;
     }
     //用户id
     if (!empty($user_id)) {
         $row['user_id'] = $user_id;
     }
     $ret = Da_Wrapper::insert()->table(self::DB_TABLE_MSM)->data($row)->execute();
     return $ret;
 }
 public static function add($uid, $type)
 {
     $info['type'] = $type;
     $info['user_id'] = $uid;
     $info['addtime'] = time();
     $ret = Da_Wrapper::insert()->table(self::DB_TABLE_LOG)->data($info)->execute();
     return $ret;
 }
 /**
  * 添加邀请函
  */
 public static function add($row)
 {
     if (empty($row['crttime'])) {
         $row['crttime'] = time();
     }
     $data = Da_Wrapper::insert()->table(self::DB_TABLE_LETTER)->data($row)->execute();
     return $data;
 }
 public static function insertInfo($row, $type = 'payment')
 {
     if ($type == 'payment') {
         $table = self::DB_TABLE_PAYMENT;
     } elseif ($type == 'bank') {
         $table = self::DB_TABLE_BANK;
     } else {
         $table = self::DB_TABLE_BANK_PAYMENT;
     }
     if (is_array($row)) {
         $ret = Da_Wrapper::insert()->table($table)->data($row)->execute();
     }
     if ($ret && $type == 'payment') {
         $banks = self::getAllPayment('', '', 'bsort DESC', 'bank', false);
         foreach ($banks as $k => $v) {
             $info = array('bank_id' => $v['id'], 'pay_id' => $ret);
             self::insertInfo($info, 'bank_pay');
         }
     }
     return $ret;
 }
 /**
  * function description
  *
  * @param
  * @return void
  */
 public static function store($id = 0, $row = array())
 {
     if (count($row) < 1) {
         return false;
     }
     //set password
     if (!empty($row['password'])) {
         $current_user = Sp_Admin_Account::current();
         $row['password'] = $current_user->hashPassword($row['username'], $row['password']);
     } else {
         unset($row['password']);
     }
     if (!$id) {
         // create
         $ret = Da_Wrapper::insert()->table(self::DB_TABLE_ADMIN_USER)->data($row)->execute();
     } else {
         $ret = Da_Wrapper::update()->table(self::DB_TABLE_ADMIN_USER)->data($row)->where('id', $id)->execute();
         if ($ret > 0) {
             $ret = $id;
         }
     }
     return $ret;
 }
 public static function getUniqueId()
 {
     $row = array('tid' => 1);
     $ret = Da_Wrapper::insert()->table(self::DB_TABLE_USER)->data($row)->execute();
     return $ret;
 }
 /**
  * 存储用户基本信息
  *
  * @param array
  * @return int
  */
 public static function storeUser($row)
 {
     $row['pwd'] = self::encrypt($row['pwd'], $row['kid']);
     if (is_array($row)) {
         $ret = Da_Wrapper::insert()->table(self::DB_TABLE_USER)->data($row)->execute();
     } else {
         return false;
     }
     return true;
     //        $uid = self::getUid($row['userid']);
     //		return $uid;
 }
 public static function uploadLog($data = array())
 {
     return Da_Wrapper::insert()->table("sp.huitong.ht_apply_upload_log")->data($data)->execute();
 }