Ejemplo n.º 1
0
Archivo: area.php Proyecto: ptphp/ptphp
 static function remove($id)
 {
     $row['del_time'] = Utils::date_time_now();
     $row['is_del'] = 1;
     self::_db()->update(self::TABLE, $row, array("id" => $id));
     self::_redis()->del(self::KEY . $id);
 }
Ejemplo n.º 2
0
 static function add($_row)
 {
     $row = self::getSaveRow($_row);
     $row['add_time'] = Utils::date_time_now();
     $row['op_uid'] = Model_Admin_Auth::get_user_id();
     return self::_db()->insert(self::TABLE_REVISIT, $row);
 }
Ejemplo n.º 3
0
Archivo: Task.php Proyecto: ptphp/ptphp
 function action_do_verify($mission_id, $task_key, $pics, $note)
 {
     $task_key = intval($task_key);
     if (!$task_key) {
         _throw("task_key 不能为空");
     }
     $user_id = Auth::get_user_id();
     if (!$user_id) {
         _throw("您还没有登陆", 9001);
     }
     $table = self::_table("user_mission");
     $row = self::_db()->row("select * from {$table} where user_id = ? and mission_id = ?", $user_id, $mission_id);
     if (!$row) {
         _throw("您还没有参与过此任务");
     }
     if ($row['task_key'] != $task_key) {
         _throw("请按数序提交任务审核");
     }
     $table_verify = self::_table("user_mission_verify");
     $_pics = array();
     if (1) {
         $pics = explode("|", $pics);
         foreach ($pics as $pic) {
             $_pics[] = \Controller\Mission\Tool::upload_content($pic);
         }
     }
     $_pics = implode("|", $_pics);
     self::_debug($_pics);
     $verify_id = self::_db()->insert($table_verify, array("user_id" => $user_id, "mission_id" => $mission_id, "task_key" => $task_key, "pics" => $_pics, "note" => $note, "add_time" => Utils::date_time_now()));
     self::_db()->update($table, array("verify_id" => $verify_id), array("id" => $row['id']));
     return array("msg" => "提交审核成功");
 }
Ejemplo n.º 4
0
Archivo: user.php Proyecto: ptphp/ptphp
 static function bind_user($openid, $user_id)
 {
     $table = self::table("user_wx_rel");
     $row = self::_db()->row("select * from {$table} where user_id = ? and openid = ?", $user_id, $openid);
     if (empty($row)) {
         self::_db()->insert($table, array("user_id" => $user_id, "openid" => $openid, "bind_time" => Utils::date_time_now()));
     }
 }
Ejemplo n.º 5
0
 static function add($_row)
 {
     $row = self::getPorderSaveRow($_row);
     $row['orderno'] = self::get_orderno(self::TABLE_PORDER);
     $row['add_time'] = Utils::date_time_now();
     $row['op_uid'] = Model_Admin_Auth::get_user_id();
     return self::_db()->insert(self::TABLE_PORDER, $row);
 }
Ejemplo n.º 6
0
Archivo: log.php Proyecto: ptphp/ptphp
 static function add($msg, $method)
 {
     $ip = Utils::ip();
     $date = Utils::date_time_now();
     //        $row = array(
     //            "ip"       => $ip,
     //            "add_time" => $date,
     //            "msg"      => $msg,
     //            "method"   => $method,
     //            "user_id"  => Model_Admin_Auth::get_user_id(),
     //        );
     $row = array("action_ip" => Utils::ip(true), "create_time" => time(), "remark" => $msg, "model" => $method, "user_id" => Model_Admin_Auth::get_user_id());
     self::_db()->insert(self::TABLE, $row);
 }
Ejemplo n.º 7
0
 static function add($_row)
 {
     $row = self::getOrderSaveRow($_row);
     if ($row['orderno']) {
         $table = self::TABLE_ORDER;
         $order = self::_db()->select_row("select * from {$table} where orderno = ?", $row['orderno']);
         if ($order) {
             _throw("订单号:" . $row['orderno'] . " 已存在");
         }
     }
     $row['add_time'] = Utils::date_time_now();
     $row['op_uid'] = Model_Admin_Auth::get_user_id();
     $staff_info = Model_Admin_Staff::detail_by_uid($row['op_uid']);
     $row['op_name'] = $staff_info['name'];
     $items = self::getOrderItemsSaveRows($_row);
     $id = self::_db()->insert(self::TABLE_ORDER, $row);
     foreach ($items as &$item) {
         $item['order_id'] = $id;
     }
     if ($items) {
         self::_db()->insert("crm_client_order_item", $items);
     }
     return $id;
 }
Ejemplo n.º 8
0
 static function note_add($id, $note, $op_uid)
 {
     $table = self::TABLE_TRACE;
     $row = array("note" => $note, "ip" => Utils::ip(), "store_id" => $id, "op_uid" => $op_uid, "add_time" => Utils::date_time_now());
     return self::_db()->insert($table, $row);
 }
Ejemplo n.º 9
0
 function action_add($row)
 {
     $res = self::getSaveRow($row);
     $table = self::table();
     $pk = self::pk();
     $res['row']['add_time'] = Utils::date_time_now();
     $id = self::_db()->insert($table, $res['row']);
     return array($pk => $id);
 }
Ejemplo n.º 10
0
Archivo: User.php Proyecto: ptphp/ptphp
 function action_add($row)
 {
     $res = self::getSaveRow($row);
     $table = self::table();
     $pk = self::pk();
     $res['row']['add_time'] = Utils::date_time_now();
     if (!Utils::is_mobile($res['row']['mobile'])) {
         _throw("手机号不合法");
     }
     $mobile = $res['row']['mobile'];
     $user_mobile = self::_db()->row("select mobile from {$table} where mobile = ?", $mobile);
     if ($user_mobile) {
         _throw("手机号已存在");
     }
     if (!empty($res['row']['password'])) {
         $password = $res['row']['password'];
         $salt = \Model_Admin_Auth::gen_salt();
         $res['row']['password'] = \Model_Admin_Auth::gen_password($password, $salt);
         $res['row']['salt'] = $salt;
     } else {
         _throw("密码不能为空");
     }
     $user_id = self::_db()->insert($table, $res['row']);
     $stf_id = Model_Admin_Staff::get_staff_id_by_mobile($mobile);
     if ($stf_id) {
         Model_Admin_Staff::bind_staff_user($stf_id, $user_id);
     }
     $res = $this->action_row($user_id);
     $res['row'][$pk] = $user_id;
     return $res;
 }
Ejemplo n.º 11
0
Archivo: Log.php Proyecto: ptphp/ptphp
 static function add($content, $method, $user_id, $ip = null)
 {
     self::_db()->insert(self::table(), array("content" => $content, "method" => $method, "ip" => $ip, "user_id" => $user_id, "add_time" => Utils::date_time_now()));
 }
Ejemplo n.º 12
0
Archivo: Auth.php Proyecto: ptphp/ptphp
 /**
  * 微信绑定手机号
  * @return string
  */
 function action_wechat_bind_mobile()
 {
     Model_Session::session_start(true);
     $mobile = Utils::I("mobile");
     $nick_name = Utils::I("nick_name");
     $captcha = Utils::I("captcha");
     $oauth_id = Utils::I("oauth_id");
     self::_debug(array($oauth_id));
     $safe_token = Utils::I(Model_Auth::ENCRYPT_FIELD_NAME);
     if (!$safe_token) {
         _throw("safe_token is null");
     }
     //Model_Auth::login_safe($username,$password,$safe_token);
     $encrypt_data = self::_redis()->get(Model_Auth::ENCRYPT_CACEH_KEY . $safe_token);
     if (empty($encrypt_data)) {
         _throw("加密信息已过期");
     }
     $encrypt_data = json_decode($encrypt_data);
     $private_key = $encrypt_data->private_key;
     $reqData = array('mobile' => $mobile, 'captcha' => $captcha, 'nick_name' => $nick_name);
     $reqData = Safe::decrypt($reqData, $private_key);
     self::_debug($reqData);
     if (!$reqData) {
         _throw("解密失败");
     }
     $mobile = $reqData['mobile'];
     $nick_name = $reqData['nick_name'];
     $captcha = $reqData['captcha'];
     if (!Utils::is_mobile($mobile)) {
         _throw("手机号不合法");
     }
     $key = Controller_Captcha::get_captcha_session_key($mobile, "wechat_bind_mobile");
     self::_debug($key);
     if (empty($_SESSION[$key])) {
         _throw("验证码已过期");
     }
     $_captcha_session = $_SESSION[$key];
     self::_debug($_captcha_session);
     list($_captcha, $time) = explode("|", $_captcha_session);
     if (time() - $time > 60 * 60 * 5) {
         unset($_SESSION[$key]);
         _throw("验证码已过期");
     }
     self::_debug($_captcha_session);
     if ($captcha != $_captcha) {
         _throw("验证码不正确");
     }
     if (!($user_id = Model_User::check_user_exsits($mobile))) {
         $user = array("password" => null, "mobile" => $mobile, "nick_name" => $nick_name, "add_time" => Utils::date_time_now(), "email" => null);
         self::_debug("create user");
         self::_debug($user);
         $user_id = self::_db()->insert(Model_User::TABLE, $user);
     }
     self::_debug(array("update", Model_Wechat_User::TABLE, $user_id, $oauth_id));
     self::_db()->update(Model_Wechat_User::TABLE, array("uid" => $user_id), array("id" => $oauth_id));
     $wx_auth_info = $_SESSION['wx_auth_info'];
     $wx_auth_info['uid'] = $user_id;
     $_SESSION['wx_auth_info'] = $wx_auth_info;
     self::_debug($user_id);
     Model_Admin_Auth::set_login_session($user_id);
     //set login
     unset($_SESSION[$key]);
     Controller_Captcha::clear_status_key("wechat_bind_mobile");
     $redirect = self::get_redirect_url();
     return array("message" => "绑定成功", "redirect" => $redirect);
 }
Ejemplo n.º 13
0
 static function note_add($id, $note, $op_uid)
 {
     $row = array("note" => $note, "ip" => Utils::ip(), "agent_id" => $id, "op_uid" => $op_uid, "add_time" => Utils::date_time_now());
     return self::_db()->insert("crm_agent_trace", $row);
 }
Ejemplo n.º 14
0
 function action_add($row)
 {
     $table = self::table();
     $res = self::getSaveRow($row);
     $res['row']['add_time'] = Utils::date_time_now();
     if (!empty($res['row']['mobile'])) {
         $mobile = $res['row']['mobile'];
         $staff = self::_db()->row("select mobile from {$table} where mobile = ?", $mobile);
         if ($staff) {
             _throw("手机号已存在");
         }
     }
     $password = null;
     if (!empty($res['row']['password'])) {
         $password = $res['row']['password'];
         unset($res['row']['password']);
     }
     unset($res['row']['password']);
     $id = self::_db()->insert($table, $res['row']);
     if ($password) {
         $table_user = self::_table("user");
         $user_mobile = self::_db()->row("select user_id from {$table_user} where mobile = ?", $res['row']['mobile']);
         if (!$user_mobile) {
             $salt = \Model_Admin_Auth::gen_salt();
             $password = \Model_Admin_Auth::gen_password($password, $salt);
             $user_row = array("password" => $password, "mobile" => $res['row']['mobile'], "salt" => $salt, "add_time" => Utils::date_time_now());
             $user_id = self::_db()->insert($table_user, $user_row);
         } else {
             $user_id = $table_user['user_id'];
         }
         self::_db()->insert(self::_table("staff_user"), array("stf_id" => $id, "user_id" => $user_id));
     }
     return array("stf_id" => $id, "row" => self::get_detail($id));
 }
Ejemplo n.º 15
0
 static function add($row)
 {
     $_row = array("add_time" => Utils::date_time_now());
     return self::_db()->insert(self::TABLE, $_row);
 }
Ejemplo n.º 16
0
 function action_add($row)
 {
     $res = self::getSaveRow($row);
     $res['row']['add_time'] = Utils::date_time_now();
     $id = self::_db()->insert("ldt_mission", $res['row']);
     if (!empty($res['tasks'])) {
         $tasks = $res['tasks'];
         foreach ($tasks as &$task) {
             unset($task['id']);
             $task['mission_id'] = $id;
         }
         //print_r($tasks);
         self::_db()->insert("ldt_mission_task", $tasks);
     }
     return array("id" => $id);
 }
Ejemplo n.º 17
0
Archivo: Bill.php Proyecto: ptphp/ptphp
 function action_add($bill_type, $bill_amount, $bill_kind, $bill_note, $user_id)
 {
     $table = self::table();
     self::_db()->insert($table, array("bill_type" => $bill_type, "bill_amount" => $bill_amount, "bill_kind" => $bill_kind, "bill_note" => $bill_note, "user_id" => $user_id, "add_time" => Utils::date_time_now()));
 }