コード例 #1
0
ファイル: user_charge.php プロジェクト: RenzcPHP/3dproduct
 /**
  * 改变状态
  */
 function do_active($id)
 {
     //权限验证
     role::check('user_charge');
     if (!$id) {
         remind::set(Kohana::lang('o_global.bad_request'), 'user/user_charge');
     }
     $db = Database::instance();
     $data = array_shift($db->query('SELECT * FROM user_charge_order WHERE id=' . $id)->result_array(false));
     if ($data['id'] <= 0 || $data['status'] > 0) {
         remind::set(Kohana::lang('o_global.bad_request'), 'user/user_charge');
     }
     $logodata = array();
     $logodata['manager_id'] = $this->manager_id;
     $logodata['ip'] = tool::get_str_ip();
     $logodata['user_log_type'] = 27;
     $logodata['method'] = __CLASS__ . '::' . __METHOD__ . '()';
     $logodata['memo'] = "充值订单号:" . $data['order_num'] . ", 购买拍点数:" . $data['price'] . ", 充值金额:" . $data['money'];
     $sql = "UPDATE user_charge_order SET status=1 WHERE id='" . $id . "' ";
     if ($db->query($sql)) {
         //充值用户Money
         $sql_reward = "UPDATE users \r\n                            SET user_money = user_money+" . $data['price'] . "\r\n                            WHERE id='" . $data['user_id'] . "'\r\n                          ";
         $db->query($sql_reward);
         //操作log
         ulog::add($logodata);
         remind::set(Kohana::lang('o_global.update_success'), 'user/user_charge', 'success');
     } else {
         //操作log
         ulog::add($logodata, 1);
         remind::set(Kohana::lang('o_global.update_error'), 'user/user_charge', 'error');
     }
 }
コード例 #2
0
 /**
  * 更新或添加信息
  *
  * @param  array $data 数据包
  * @return true or false
  */
 public function add($data)
 {
     $obj = ORM::factory('account_virtual_log');
     if (!$obj->validate($data)) {
         return FALSE;
     }
     !empty($data['order_num']) && ($obj->order_num = $data['order_num']);
     $obj->user_id = $data['user_id'];
     $obj->log_type = $data['log_type'];
     empty($data['is_in']) && ($data['is_in'] = 0);
     $obj->is_in = $data['is_in'];
     $obj->price = $data['price'];
     $obj->user_money = $data['user_money'];
     $obj->memo = $data['memo'];
     $obj->method = serialize(array('url' => 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER["REQUEST_URI"], 'method' => $_SERVER['REQUEST_METHOD']));
     $obj->ip = tool::get_str_ip();
     $obj->save();
     if ($obj->saved) {
         //更新用户表金额
         $userobj = user::get_instance();
         if ($data['is_in'] == 0) {
             $usermoney = $obj->user_money + $obj->price;
         } else {
             $usermoney = $obj->user_money - $obj->price;
         }
         $userobj->update_virtual_money($data['user_id'], $usermoney);
         return TRUE;
     } else {
         return FALSE;
     }
 }
コード例 #3
0
ファイル: ulog.php プロジェクト: RenzcPHP/3dproduct
 public static function change_password($manager_id = 0, $status = 0)
 {
     $user_log_type_id = 26;
     $ip = tool::get_str_ip();
     $data = array();
     $data['manager_id'] = $manager_id;
     $data['ip'] = $ip;
     $data['user_log_type'] = $user_log_type_id;
     $data['status'] = $status;
     return Myuser_log::instance()->add($data);
 }
コード例 #4
0
ファイル: user_money.php プロジェクト: RenzcPHP/3dproduct
 public function minus_money($user_id, $money, $arrmoney, $logtype, $order_num = NULL, $memo = NULL)
 {
     $user_id = intval($user_id);
     $logtype = intval($logtype);
     //参数检测
     if ($user_id <= 0 || $logtype < 0 || $money < 0 || !is_array($arrmoney) || empty($arrmoney)) {
         return -1;
     }
     $testmoney = 0;
     foreach ($arrmoney as $row) {
         $testmoney += $row;
     }
     if ($money != $testmoney) {
         return -2;
     }
     //获取用户所有总资金
     $userobj = user::get_instance();
     $user_moneys = $userobj->get_user_moneys($user_id);
     $old_user_moneys = $user_moneys;
     //当出现异常
     if (empty($user_moneys)) {
         return -3;
     }
     $logobj = ORM::factory('account_log');
     $data = array();
     $data['order_num'] = $order_num;
     $data['log_type'] = $logtype;
     $data['user_id'] = $user_id;
     $data['price'] = $money;
     $data['user_money'] = $user_moneys['all_money'];
     $data['is_in'] = 1;
     $data['memo'] = $memo;
     $data['method'] = serialize(array('url' => 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER["REQUEST_URI"], 'method' => $_SERVER['REQUEST_METHOD']));
     $data['ip'] = tool::get_str_ip();
     //$data['user_money'] = $data['user_money'] - $money;
     if ($data['user_money'] < 0) {
         return -4;
     }
     if (!$logobj->validate($data, FALSE)) {
         return -5;
     }
     $logobj->save();
     if (!$logobj->saved) {
         return -6;
     }
     if (!empty($arrmoney['USER_MONEY'])) {
         $user_moneys['user_money'] = $user_moneys['user_money'] - $arrmoney['USER_MONEY'];
     }
     if (!empty($arrmoney['BONUS_MONEY'])) {
         $user_moneys['bonus_money'] = $user_moneys['bonus_money'] - $arrmoney['BONUS_MONEY'];
     }
     if (!empty($arrmoney['FREE_MONEY'])) {
         $user_moneys['free_money'] = $user_moneys['free_money'] - $arrmoney['FREE_MONEY'];
     }
     //更新会员资金
     if (!$userobj->update_moneys($user_id, $user_moneys)) {
         return -7;
     }
     //当资金记录有变化时则记录详细日志
     $this->add_detail_log($user_moneys, $old_user_moneys, $user_id, $logobj->id);
     return $money;
 }
コード例 #5
0
ファイル: user_invite.php プロジェクト: RenzcPHP/3dproduct
 /**
  * 修改用户信息
  */
 function edit($id)
 {
     //权限检查 得到所有可管理站点ID列表
     role::check('user_edit');
     if ($_POST) {
         //标签过滤
         tool::filter_strip_tags($_POST);
         if (Myuser::instance($id)->set_money($_POST['invite_user_id'], $_POST['reward_money'])) {
             $arr['guest_user_id'] = intval($_POST['user_id']);
             $arr['user_id'] = intval($_POST['invite_user_id']);
             $arr['reward_money'] = intval($_POST['reward_money']);
             $arr['memo'] = '邀请用户奖励';
             $arr['reward_type'] = 'invite';
             $arr['time_stamp'] = date("Y-m-d H:i:s", time());
             User_inviteService::get_instance()->insert($arr);
             $logodata = array();
             $logodata['manager_id'] = $this->manager_id;
             $logodata['ip'] = tool::get_str_ip();
             $logodata['user_log_type'] = 28;
             $logodata['method'] = __CLASS__ . '::' . __METHOD__ . '()';
             $logodata['memo'] = "邀请奖励审核通过, 奖励:" . $_POST['reward_money'];
             ulog::add($logodata);
             remind::set(Kohana::lang('o_global.update_success'), request::referrer(), 'success');
         } else {
             remind::set(Kohana::lang('o_global.update_error'), request::referrer(), 'error');
         }
     }
     $this->template->content = new View("user/user_invite_edit");
     $id = intval($id);
     $data = Myuser::instance($id)->get();
     $data['invite'] = Myuser::instance($data['invite_user_id'])->get();
     $sql = " SELECT COUNT(id) AS id FROM user_reward  WHERE guest_user_id = " . $data['id'] . " AND user_id = " . $data['invite']['id'] . "  AND reward_type = 'invite' ";
     $data['reward'] = User_inviteService::get_instance()->get_one($sql);
     $data['reward'] = $data['reward']['id'];
     $this->template->content->data = $data;
 }
コード例 #6
0
ファイル: user.php プロジェクト: RenzcPHP/3dproduct
 public function get_user_charge_order($user_id, $price)
 {
     $obj = ORM::factory('user_charge_order');
     $ordernum = '';
     do {
         $ordernum = date('YmdHis') . rand(0, 99999);
         if (!$this->charge_exist($ordernum)) {
             break;
         }
     } while (1);
     $obj->status = 0;
     $obj->user_id = $user_id;
     $obj->money = $price;
     $obj->order_num = $ordernum;
     $obj->ip = tool::get_str_ip();
     $obj->save();
     return $ordernum;
 }