public function getPaymentList() { $user_id = ISafe::get('user_id'); $where = 'status = 0'; if (!$user_id) { $where .= " and class_name != 'balance'"; } switch (IClient::getDevice()) { //移动支付 case IClient::MOBILE: //如果是微信客户端,必须用微信专用支付 if (IClient::isWechat() == true) { $where .= " and class_name = 'wap_wechat'"; } else { $where .= " and client_type in(2,3) and class_name != 'wap_wechat' "; } break; //pc支付 //pc支付 case IClient::PC: $where .= ' and client_type in(1,3) '; break; } $paymentDB = new IModel('payment'); return $paymentDB->query($where); }
/** * @see paymentplugin::callback() */ public function callback($ExternalData, &$paymentId, &$money, &$message, &$orderNo) { $partnerKey = Payment::getConfigParam($paymentId, 'M_PartnerKey'); $user_id = ISafe::get('user_id'); ksort($ExternalData); $temp = array(); foreach ($ExternalData as $k => $v) { if ($k != 'sign') { $temp[] = $k . '=' . urlencode($v); } } $encryptKey = isset(IWeb::$app->config['encryptKey']) ? IWeb::$app->config['encryptKey'] : 'iwebshop'; $testStr = join('&', $temp) . '&' . $user_id . $partnerKey . $encryptKey; $orderNo = $ExternalData['order_no']; $money = $ExternalData['total_fee']; if ($ExternalData['sign'] == md5($testStr)) { //支付单号 switch ($ExternalData['is_success']) { case 'T': $log = new AccountLog(); $config = array('user_id' => $user_id, 'event' => 'pay', 'note' => '通过余额支付方式进行商品购买', 'num' => '-' . $money, 'order_id' => $orderNo); $log->write($config); return true; break; case 'F': return false; break; } } else { $message = '校验码不正确'; } return false; }
function callback($in, &$paymentId, &$money, &$message, &$tradeno) { //比对md5码 $pKey = $this->getConf($paymentId, 'PrivateKey'); $user_id = ISafe::get('user_id'); ksort($in); unset($in['controller']); unset($in['action']); unset($in['payment_name']); $temp = array(); foreach ($in as $k => $v) { if ($k != 'sign') { $temp[] = $k . '=' . urlencode($v); } } $testStr = join('&', $temp) . '&' . $user_id . $pKey; $tradeno = $in['order_no']; $money = $in['total_fee']; if ($in['sign'] == md5($testStr)) { //支付单号 switch ($in['is_success']) { case 'T': $log = new AccountLog(); $config = array('user_id' => ISafe::get('user_id'), 'event' => 'pay', 'note' => '通过余额支付方式进行商品购买', 'num' => '-' . $money, 'order_id' => $tradeno); $log->write($config); return PAY_SUCCESS; break; case 'F': return PAY_FAILED; break; } } else { IError::show(403, '校验码不正确'); } }
/** * @brief 根据用户的权限过滤菜单 * @return array */ private function filterMenu() { $rights = ISafe::get('admin_right'); //如果不是超级管理员则要过滤菜单 if ($rights != 'administrator') { foreach (self::$menu as $firstKey => $firstVal) { if (is_array($firstVal)) { foreach ($firstVal as $secondKey => $secondVal) { if (is_array($secondVal)) { foreach ($secondVal as $thirdKey => $thirdVal) { if (!in_array($thirdKey, self::$commonMenu) && stripos(str_replace('@', '/', $rights), ',' . substr($thirdKey, 1) . ',') === false) { unset(self::$menu[$firstKey][$secondKey][$thirdKey]); } } if (empty(self::$menu[$firstKey][$secondKey])) { unset(self::$menu[$firstKey][$secondKey]); } } } if (empty(self::$menu[$firstKey])) { unset(self::$menu[$firstKey]); } } } } }
public function init() { CheckRights::checkUserRights(); if (ISafe::get('user_id') == '') { $this->redirect('/simple/login'); } }
function user_ico_upload() { $user_id = ISafe::get('user_id'); $result = array('isError' => true); if (isset($_FILES['attach']['name']) && $_FILES['attach']['name'] != '') { $photoObj = new PhotoUpload(); $photoObj->setThumb(100, 100, 'user_ico'); $photo = $photoObj->run(); if (!empty($photo['attach']['thumb']['user_ico'])) { $user_id = ISafe::get('user_id'); $user_obj = new IModel('user'); $dataArray = array('head_ico' => $photo['attach']['thumb']['user_ico']); $user_obj->setData($dataArray); $where = 'id = ' . $user_id; $isSuss = $user_obj->update($where); if ($isSuss !== false) { $result['isError'] = false; $result['data'] = IUrl::creatUrl() . $photo['attach']['thumb']['user_ico']; ISafe::set('head_ico', $dataArray['head_ico']); } else { $result['message'] = '上传失败'; } } else { $result['message'] = '上传失败'; } } else { $result['message'] = '请选择图片'; } echo '<script type="text/javascript">parent.callback_user_ico(' . JSON::encode($result) . ');</script>'; }
/** * @brief theme和skin进行选择 */ public static function onCreateController() { $controller = func_num_args() > 0 && func_get_arg(0) ? func_get_arg(0) : IWeb::$app->controller; /** * 对于theme和skin的判断流程 * 1,直接从URL中获取是否已经设定了方案__theme,__skin * 2,从cookie获取数据 */ $urlTheme = IReq::get('__theme'); $urlSkin = IReq::get('__skin'); if ($urlTheme && $urlSkin && preg_match('|^\\w+$|', $urlTheme) && preg_match('|^\\w+$|', $urlSkin)) { ISafe::set('__theme', $theme = $urlTheme); ISafe::set('__skin', $skin = $urlSkin); } elseif (ISafe::get('__theme') && ISafe::get('__skin')) { $theme = ISafe::get('__theme'); $skin = ISafe::get('__skin'); } if (isset($theme) && isset($skin)) { $themePath = IWeb::$app->getViewPath() . $theme . "/" . IWeb::$app->controller->getId(); if (is_dir($themePath)) { $controller->theme = $theme; $controller->skin = $skin; } } }
/** * 获取版权信息,存储到缓存中进行比对 * @return boolean */ public static function getAuthorize() { $iwebshopAuthorize = ISafe::get('iwebshopAuthorize'); if ($iwebshopAuthorize === null) { $return = self::send('_c=system&_a=authorize&host=' . IUrl::getHost()); $iwebshopAuthorize = isset($return['success']) && $return['success'] == 1 ? true : false; ISafe::set('iwebshopAuthorize', $iwebshopAuthorize); } return $iwebshopAuthorize; }
/** * @brief theme和skin进行选择 */ public static function onCreateController() { $controller = func_num_args() > 0 ? func_get_arg(0) : IWeb::$app->controller; //判断是否为后台管理控制器 if (in_array($controller->getId(), self::$syscontroller)) { defined("IWEB_SCENE") ? "" : define("IWEB_SCENE", self::SCENE_SYSDEFAULT); $controller->theme = self::$sysTheme; $controller->skin = self::$sysSkin; } elseif (in_array($controller->getId(), self::$sellercontroller)) { defined("IWEB_SCENE") ? "" : define("IWEB_SCENE", self::SCENE_SYSSELLER); $controller->theme = self::$sysSellerTheme; $controller->skin = self::$sysSellerSkin; } else { defined("IWEB_SCENE") ? "" : define("IWEB_SCENE", self::SCENE_SITE); /** * 对于theme和skin的判断流程 * 1,直接从URL中获取是否已经设定了方案__theme,__skin * 2,获取cookie中的方案名称 * 3,读取config配置中的默认方案 */ $urlTheme = IReq::get('__theme'); $urlSkin = IReq::get('__skin'); if ($urlTheme && $urlSkin && preg_match('|^\\w+$|', $urlTheme) && preg_match('|^\\w+$|', $urlSkin)) { ISafe::set('__theme', $controller->theme = $urlTheme); ISafe::set('__skin', $controller->skin = $urlSkin); } elseif (ISafe::get('__theme') && ISafe::get('__skin')) { $controller->theme = ISafe::get('__theme'); $controller->skin = ISafe::get('__skin'); } else { if (isset(IWeb::$app->config['theme'])) { //根据不同的客户端进行智能选择 if (is_array(IWeb::$app->config['theme'])) { $client = IClient::getDevice(); $controller->theme = isset(IWeb::$app->config['theme'][$client]) ? IWeb::$app->config['theme'][$client] : current(IWeb::$app->config['theme']); } else { $controller->theme = IWeb::$app->config['theme']; } } if (isset(IWeb::$app->config['skin'])) { //根据不同的客户端进行智能选择 if (is_array(IWeb::$app->config['skin'])) { $client = IClient::getDevice(); $controller->skin = isset(IWeb::$app->config['skin'][$client]) ? IWeb::$app->config['skin'][$client] : current(IWeb::$app->config['skin']); } else { $controller->skin = IWeb::$app->config['skin']; } } } } //修正runtime配置 IWeb::$app->runtimePath = IWeb::$app->getRuntimePath() . $controller->theme . '/'; IWeb::$app->webRunPath = IWeb::$app->getWebRunPath() . $controller->theme . '/'; }
/** * @brief 展示插件 * @param string $name 用户名 * @param string $pwd 密码 */ public function show($name = '', $pwd = '') { $sessionName = ISafe::name(); $sessionId = ISafe::id(); $uploadUrl = IUrl::creatUrl($this->submit); $admin_name = $name == '' ? ISafe::get('admin_name') : $name; $admin_pwd = $pwd == '' ? ISafe::get('admin_pwd') : $pwd; echo <<<OEF \t\t<script type="text/javascript"> \t\twindow.onload = function() \t\t{ \t\t\tnew SWFUpload({ \t\t\t\t// Backend Settings \t\t\t\tupload_url: "{$uploadUrl}", \t\t\t\tpost_params: {"{$sessionName}": "{$sessionId}","admin_name":"{$admin_name}","admin_pwd":"{$admin_pwd}"}, \t\t\t\t// File Upload Settings \t\t\t\tfile_types : "*.jpg;*.jpge;*.png;*.gif", \t\t\t\t// Event Handler Settings - these functions as defined in Handlers.js \t\t\t\t// The handlers are not part of SWFUpload but are part of my website and control how \t\t\t\t// my website reacts to the SWFUpload events. \t\t\t\tswfupload_preload_handler : preLoad, \t\t\t\tswfupload_load_failed_handler : loadFailed, \t\t\t\tfile_queue_error_handler : fileQueueError, \t\t\t\tfile_dialog_complete_handler : fileDialogComplete, \t\t\t\tupload_progress_handler : uploadProgress, \t\t\t\tupload_error_handler : uploadError, \t\t\t\tupload_success_handler : uploadSuccess, \t\t\t\tupload_complete_handler : uploadComplete, \t\t\t\t// Button Settings \t\t\t\tbutton_placeholder_id : "uploadButton", \t\t\t\tbutton_width: 50, \t\t\t\tbutton_height: 21, \t\t\t\tbutton_text : '选择...', \t\t\t\tbutton_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT, \t\t\t\tbutton_cursor: SWFUpload.CURSOR.HAND, \t\t\t\t// Flash Settings \t\t\t\tflash_url : "{$this->path}swfupload.swf", \t\t\t\tcustom_settings : { \t\t\t\t\tupload_target : "divFileProgressContainer" \t\t\t\t}, \t\t\t\t// Debug Settings \t\t\t\tdebug: false \t\t\t}); \t\t}; \t\t</script> OEF; }
/** * 构造函数 */ public function __construct($user_id = null) { $this->user_id = $user_id ? $user_id : ISafe::get('user_id'); //获取用户组ID及组的折扣率 if ($this->user_id != null) { $groupObj = new IModel('member as m , user_group as g'); $groupRow = $groupObj->getObj('m.user_id = ' . $this->user_id . ' and m.group_id = g.id', 'g.*'); if ($groupRow) { $this->group_id = $groupRow['id']; $this->group_discount = $groupRow['discount'] * 0.01; } } }
/** * @brief 获取通用的注册用户数组 */ public static function getUser() { $user = array('user_id' => ISafe::get('user_id'), 'username' => ISafe::get('username'), 'head_ico' => ISafe::get('head_ico'), 'user_pwd' => ISafe::get('user_pwd')); if (self::isValidUser($user['username'], $user['user_pwd'])) { return $user; } else { ISafe::clear('user_id'); ISafe::clear('username'); ISafe::clear('head_ico'); ISafe::clear('user_pwd'); return null; } }
function login_act() { $admin_name = IFilter::act(IReq::get('admin_name')); $password = IReq::get('password'); $captcha = IReq::get('captcha', 'post'); $message = ''; if ($admin_name == '') { $message = '登录名不能为空'; } else { if ($password == '') { $message = '密码不能为空'; } else { if ($captcha != ISafe::get('Captcha')) { $message = '验证码输入不正确'; } else { $adminObj = new IModel('admin'); $adminRow = $adminObj->getObj('admin_name = "' . $admin_name . '"'); if (!empty($adminRow) && $adminRow['password'] == md5($password) && $adminRow['is_del'] == 0) { $dataArray = array('last_ip' => IClient::getIp(), 'last_time' => ITime::getDateTime()); $adminObj->setData($dataArray); $where = 'id = ' . $adminRow["id"]; $adminObj->update($where); //根据角色分配权限 if ($adminRow['role_id'] == 0) { ISafe::set('admin_right', 'administrator'); ISafe::set('admin_role_name', '超级管理员'); } else { $roleObj = new IModel('admin_role'); $where = 'id = ' . $adminRow["role_id"] . ' and is_del = 0'; $roleRow = $roleObj->getObj($where); ISafe::set('admin_right', $roleRow['rights']); ISafe::set('admin_role_name', $roleRow['name']); } ISafe::set('admin_id', $adminRow['id']); ISafe::set('admin_name', $adminRow['admin_name']); ISafe::set('admin_pwd', $adminRow['password']); $this->redirect('/system/default'); } else { $message = '用户名与密码不匹配'; } } } } if ($message != '') { $this->admin_name = $admin_name; $this->redirect('index', false); Util::showMessage($message); } }
public function checkUserRights() { $object = $this->ctrlObj; $user = array(); $user['user_id'] = intval(ISafe::get('user_id')); $user['username'] = ISafe::get('username'); $user['head_ico'] = ISafe::get('head_ico'); $user['user_pwd'] = ISafe::get('user_pwd'); if (self::isValidUser($user['username'], $user['user_pwd'])) { $object->user = $user; } else { ISafe::clear('user_id'); ISafe::clear('user_pwd'); ISafe::clear('username'); ISafe::clear('head_ico'); } }
public static function checkUserRights() { $object = IWeb::$app->getController(); $user = array(); $user['user_id'] = intval(ISafe::get('user_id')); $user['username'] = ISafe::get('username'); $user['head_ico'] = ISafe::get('head_ico'); $user['user_pwd'] = ISafe::get('user_pwd'); if (self::isValidUser($user['username'], $user['user_pwd'])) { $object->user = $user; } else { ISafe::clear('user_id'); ISafe::clear('user_pwd'); ISafe::clear('username'); ISafe::clear('head_ico'); } }
<div class="price f_r t_r"> <b class="block">¥<%=data['sell_price']%> x <%=data['count']%></b> <input class="del" type="button" value="删除" onclick="removeCart('<?php echo IUrl::creatUrl("/simple/removeCart"); ?> ','<%=data['id']%>','<%=data['type']%>');$('#site_cart_dd_<%=item%>').hide('slow');" /> </div> </dd> <%}%> <dd class="static"><span>共<b name="mycart_count"><%=goodsCount%></b>件商品</span>金额总计:<b name="mycart_sum">¥<%=goodsSum%></b></dd> <%if(goodsData){%> <dd class="static"> <?php if (ISafe::get('user_id')) { ?> <a class="f_l" href="javascript:void(0)" onclick="deposit_ajax('<?php echo IUrl::creatUrl("/simple/deposit_cart_set"); ?> ');">寄存购物车>></a> <?php } ?> <label class="btn_orange"><input type="button" value="去购物车结算" onclick="window.location.href='<?php echo IUrl::creatUrl("/simple/cart"); ?> ';" /></label> </dd> <%}%> </dl>
/** * @brief 支付回调测试[同步] * define ( "PAY_FAILED", - 1);支付失败 * define ( "PAY_TIMEOUT", 0);支付超时 * define ( "PAY_SUCCESS", 1);支付成功 * define ( "PAY_CANCEL", 2);支付取消 * define ( "PAY_ERROR", 3);支付错误 * define ( "PAY_PROGRESS", 4);支付进行 * define ( "PAY_INVALID", 5);支付无效 * define ( "PAY_MANUAL", 0);手工支付 */ public function callback() { $payment_name = is_array($payment_name = IReq::get('payment_name')) ? IFilter::act($payment_name[0]) : IFilter::act(IReq::get('payment_name')); //初始化参数 $money = null; $message = '支付失败'; $tradeno = null; //获取支付payment的id值 $pObj = new IModel('payment as a,pay_plugin as b'); $paymentRow = $pObj->getObj('b.file_path = "' . $payment_name . '" and a.plugin_id = b.id', 'a.id'); //载入支付接口文件 $paymentObj = new Payment(); $payObj = $paymentObj->loadMethod($payment_name); if (!is_object($payObj)) { IError::show(403, '支付方式不存在'); } //执行接口回调函数 $return = $payObj->callback(array_merge($_POST, $_GET), $paymentRow['id'], $money, $message, $tradeno); //判断返回状态 if ($return == 1) { if (stripos($tradeno, 'recharge_') !== false) { $tradenoArray = explode('_', $tradeno); $recharge_no = isset($tradenoArray[1]) ? $tradenoArray[1] : 0; if (payment::updateRecharge($recharge_no)) { $this->redirect('/site/success/message/' . urlencode("充值成功") . '/?callback=/ucenter/account_log'); } else { IError::show(403, '充值失败'); } } else { $order_id = payment::updateOrder($tradeno); if ($order_id != '') { $url = '/site/success/message/' . urlencode("支付成功"); $url .= ISafe::get('user_id') ? '/?callback=/ucenter/order_detail/id/' . $order_id : ''; $this->redirect($url); } else { IError::show(403, '订单修改失败'); } } } else { IError::show(403, $message); } }
/** * @brief 获取订单中的支付信息 M:必要信息; R表示店铺; P表示用户; * @param $payment_id int 支付方式ID * @param $type string 信息获取方式 order:订单支付;recharge:在线充值; * @param $argument mix 参数 * @return array 支付提交信息 */ public static function getPaymentInfo($payment_id, $type, $argument) { //最终返回值 $payment = array(); //获取公共信息 $paymentRow = self::getPaymentById($payment_id); $payment['M_PartnerId'] = $paymentRow['partner_id']; $payment['M_PartnerKey'] = $paymentRow['partner_key']; if ($type == 'order') { $order_id = $argument; //获取订单信息 $orderObj = new IModel('order'); $orderRow = $orderObj->getObj('id = ' . $order_id . ' and status = 1'); if (empty($orderRow)) { IError::show(403, '订单信息不正确,不能进行支付'); } $payment['M_Remark'] = $orderRow['postscript']; $payment['M_OrderId'] = $orderRow['id']; $payment['M_OrderNO'] = $orderRow['order_no']; $payment['M_Amount'] = $orderRow['order_amount']; //用户信息 $payment['P_Mobile'] = $orderRow['mobile']; $payment['P_Name'] = $orderRow['accept_name']; $payment['P_PostCode'] = $orderRow['postcode']; $payment['P_Telephone'] = $orderRow['telphone']; $payment['P_Address'] = $orderRow['address']; } else { if ($type == 'recharge') { if (ISafe::get('user_id') == null) { IError::show(403, '请登录系统'); } if (!isset($argument['account']) || $argument['account'] <= 0) { IError::show(403, '请填入正确的充值金额'); } $rechargeObj = new IModel('online_recharge'); $reData = array('user_id' => ISafe::get('user_id'), 'recharge_no' => Order_Class::createOrderNum(), 'account' => $argument['account'], 'time' => ITime::getDateTime(), 'payment_name' => $argument['paymentName']); $rechargeObj->setData($reData); $r_id = $rechargeObj->add(); //充值时用户id跟随交易号一起发送,以"_"分割 $payment['M_OrderNO'] = 'recharge_' . $reData['recharge_no']; $payment['M_OrderId'] = $r_id; $payment['M_Amount'] = $reData['account']; } } $siteConfigObj = new Config("site_config"); $site_config = $siteConfigObj->getInfo(); //交易信息 $payment['M_Time'] = time(); $payment['M_Paymentid'] = $payment_id; //店铺信息 $payment['R_Address'] = isset($site_config['address']) ? $site_config['address'] : ''; $payment['R_Name'] = isset($site_config['name']) ? $site_config['name'] : ''; $payment['R_Mobile'] = isset($site_config['mobile']) ? $site_config['mobile'] : ''; $payment['R_Telephone'] = isset($site_config['phone']) ? $site_config['phone'] : ''; return $payment; }
/** * @brief 获取订单中的支付信息 M:必要信息; R表示店铺; P表示用户; * @param $payment_id int 支付方式ID * @param $type string 信息获取方式 order:订单支付;recharge:在线充值; * @param $argument mix 参数 * @return array 支付提交信息 */ public static function getPaymentInfo($payment_id, $type, $argument) { //最终返回值 $payment = array(); //初始化配置参数 $paymentInstance = Payment::createPaymentInstance($payment_id); $configParam = $paymentInstance->configParam(); foreach ($configParam as $key => $val) { $payment[$key] = ''; } //获取公共信息 $paymentRow = self::getPaymentById($payment_id, 'config_param'); if ($paymentRow) { $paymentRow = JSON::decode($paymentRow); foreach ($paymentRow as $key => $item) { $payment[$key] = $item; } } //print_r($payment);die; if ($type == 'order') { $order_id = $argument; //获取订单信息 $orderObj = new IModel('order'); $orderRow = $orderObj->getObj('id = ' . $order_id . ' and status = 1'); if (empty($orderRow)) { IError::show(403, '订单信息不正确,不能进行支付'); } //是商家的订单的话,收款信息为商家个人 if ($orderRow['seller_id'] > 0) { $configParam = $paymentInstance->sellerConfigParam($orderRow['seller_id']); if ($configParam == 0) { IError::show(403, '商家收款信息未填写,不能进行支付'); } else { //重写收款信息 foreach ($configParam as $key => $val) { $payment[$key] = $val; } } } $payment['M_Remark'] = $orderRow['postscript']; $payment['M_OrderId'] = $orderRow['id']; $payment['M_OrderNO'] = $orderRow['order_no']; $payment['M_Amount'] = $orderRow['order_amount']; //用户信息 $payment['P_Mobile'] = $orderRow['mobile']; $payment['P_Name'] = $orderRow['accept_name']; $payment['P_PostCode'] = $orderRow['postcode']; $payment['P_Telephone'] = $orderRow['telphone']; $payment['P_Address'] = $orderRow['address']; } else { if ($type == 'recharge') { if (ISafe::get('user_id') == null) { IError::show(403, '请登录系统'); } if (!isset($argument['account']) || $argument['account'] <= 0) { IError::show(403, '请填入正确的充值金额'); } $rechargeObj = new IModel('online_recharge'); $reData = array('user_id' => ISafe::get('user_id'), 'recharge_no' => Order_Class::createOrderNum(), 'account' => $argument['account'], 'time' => ITime::getDateTime(), 'payment_name' => $argument['paymentName']); $rechargeObj->setData($reData); $r_id = $rechargeObj->add(); //充值时用户id跟随交易号一起发送,以"_"分割 $payment['M_OrderNO'] = 'recharge_' . $reData['recharge_no']; $payment['M_OrderId'] = $r_id; $payment['M_Amount'] = $reData['account']; } } $siteConfigObj = new Config("site_config"); $site_config = $siteConfigObj->getInfo(); //交易信息 $payment['M_Time'] = time(); $payment['M_Paymentid'] = $payment_id; //店铺信息 $payment['R_Address'] = isset($site_config['address']) ? $site_config['address'] : ''; $payment['R_Name'] = isset($site_config['name']) ? $site_config['name'] : ''; $payment['R_Mobile'] = isset($site_config['mobile']) ? $site_config['mobile'] : ''; $payment['R_Telephone'] = isset($site_config['phone']) ? $site_config['phone'] : ''; return $payment; }
/** * @brief 获取订单中的支付信息 * @payment_id 支付方式信息 * @type 信息获取方式 order:订单支付;recharge:在线充值; * @argument 参数 * @return array 支付提交信息 * R表示店铺 ; P表示用户; */ public function getPaymentInfo($payment_id, $type, $argument) { if ($type == 'order') { $order_id = $argument; //获取订单信息 $orderObj = new IModel('order'); $orderRow = $orderObj->getObj('id = ' . $order_id . ' and status = 1'); if (empty($orderRow)) { IError::show(403, '订单信息不正确,不能进行支付'); } //团购 if ($orderRow['type'] == 1) { $regimentRelationObj = new IModel('regiment_user_relation'); $relationRow = $regimentRelationObj->getObj('order_no = "' . $orderRow['order_no'] . '"'); if (empty($relationRow)) { IError::show(403, '团购订单已经失效'); exit; } else { if (abs(ITime::getDiffSec($relationRow['join_time'])) > regiment::time_limit() * 60) { IError::show(403, '支付时间已经过期'); exit; } } } $payment['M_Remark'] = $orderRow['postscript']; $payment['M_OrderId'] = $orderRow['id']; $payment['M_OrderNO'] = $orderRow['order_no']; $payment['M_Amount'] = $orderRow['order_amount']; //用户信息 $payment['P_Mobile'] = $orderRow['mobile']; $payment['P_Name'] = $orderRow['accept_name']; $payment['P_PostCode'] = $orderRow['postcode']; $payment['P_Telephone'] = $orderRow['telphone']; $payment['P_Address'] = $orderRow['address']; $payment['P_Email'] = ''; } else { if ($type == 'recharge') { if (ISafe::get('user_id') == null) { IError::show(403, '请登录系统'); } if (!isset($argument['account']) || $argument['account'] <= 0) { IError::show(403, '请填入正确的充值金额'); } $rechargeObj = new IModel('online_recharge'); $reData = array('user_id' => ISafe::get('user_id'), 'recharge_no' => Block::createOrderNum(), 'account' => $argument['account'], 'time' => ITime::getDateTime(), 'payment_name' => $argument['payment_type'], 'status' => 0); $rechargeObj->setData($reData); $r_id = $rechargeObj->add(); //充值时用户id跟随交易号一起发送,以"_"分割 $payment['M_OrderNO'] = 'recharge_' . $reData['recharge_no']; $payment['M_OrderId'] = $r_id; $payment['M_Amount'] = $reData['account']; } } $siteConfigObj = new Config("site_config"); $site_config = $siteConfigObj->getInfo(); //交易信息 $payment['M_Def_Amount'] = 0.01; $payment['M_Time'] = time(); $payment['M_Goods'] = ''; $payment['M_Language'] = "zh_CN"; $payment['M_Paymentid'] = $payment_id; //店铺信息 $payment['R_Address'] = isset($site_config['address']) ? $site_config['address'] : ''; $payment['R_Name'] = isset($site_config['name']) ? $site_config['name'] : ''; $payment['R_Mobile'] = isset($site_config['mobile']) ? $site_config['mobile'] : ''; $payment['R_Telephone'] = isset($site_config['phone']) ? $site_config['phone'] : ''; $payment['R_Postcode'] = ''; $payment['R_Email'] = ''; return $payment; }
function discussUpdate() { $goods_id = IFilter::act(IReq::get('id'), 'int'); $content = IFilter::act(IReq::get('content'), 'text'); $captcha = IReq::get('captcha'); $return = array('isError' => true, 'message' => ''); if (!$this->user['user_id']) { $return['message'] = '请先登录系统'; } else { if ($captcha != ISafe::get('captcha')) { $return['message'] = '验证码输入不正确'; } else { if (trim($content) == '') { $return['message'] = '内容不能为空'; } else { $return['isError'] = false; //插入讨论表 $tb_discussion = new IModel('discussion'); $dataArray = array('goods_id' => $goods_id, 'user_id' => $this->user['user_id'], 'time' => date('Y-m-d H:i:s'), 'contents' => $content); $tb_discussion->setData($dataArray); $tb_discussion->add(); $return['time'] = $dataArray['time']; $return['contents'] = $content; $return['username'] = $this->user['username']; } } } echo JSON::encode($return); }
/** * @brief 【重要】支付回调[同步] */ public function callback() { //从URL中获取支付方式 $payment_id = IFilter::act(IReq::get('_id'), 'int'); $paymentInstance = Payment::createPaymentInstance($payment_id); if (!is_object($paymentInstance)) { IError::show(403, '支付方式不存在'); } //初始化参数 $money = ''; $message = '支付失败'; $orderNo = ''; //执行接口回调函数 $callbackData = array_merge($_POST, $_GET); unset($callbackData['controller']); unset($callbackData['action']); unset($callbackData['_id']); $return = $paymentInstance->callback($callbackData, $payment_id, $money, $message, $orderNo); //支付成功 if ($return == 1) { //充值方式 if (stripos($orderNo, 'recharge_') !== false) { $tradenoArray = explode('_', $orderNo); $recharge_no = isset($tradenoArray[1]) ? $tradenoArray[1] : 0; if (payment::updateRecharge($recharge_no)) { $this->redirect('/site/success/message/' . urlencode("充值成功") . '/?callback=/ucenter/account_log'); exit; } IError::show(403, '充值失败'); } else { $order_id = Order_Class::updateOrderStatus($orderNo); if ($order_id) { $url = '/site/success/message/' . urlencode("支付成功"); $url .= ISafe::get('user_id') ? '/?callback=/ucenter/order_detail/id/' . $order_id : ''; $this->redirect($url); exit; } IError::show(403, '订单修改失败'); } } else { $message = $message ? $message : '支付失败'; IError::show(403, $message); } }
/** * 操作数据库 * * @param float $num 操作金额 * @return bool|array 返回true代表成功,返回array代表着本次操作的错误信息 */ private function log($num) { if (!is_numeric($num)) { $this->error[] = "错误的操作金额:{$num}"; return $this->error; } $num = sprintf("%.2f", $num); $this->num = $num; if ($this->_note === null) { $this->note(); } if ($this->error) { return $this->error; } $tb_account_log = new IModel("account_log"); $arr = array(); $arr['admin_id'] = $this->admin['id']; $arr['user_id'] = $this->user['id']; $arr['event'] = $this->allow_event[$this->event]; $arr['note'] = addslashes($this->_note); $arr['amount'] = $num; $arr['amount_log'] = $this->user['balance']; $arr['type'] = $num >= 0 ? 0 : 1; $arr['time'] = $this->time; $tb_account_log->setData($arr); $tb_account_log->add(); //后台管理员操作记录 if ($arr['admin_id']) { $logObj = new Log(); $logObj->write('operation', array("管理员:" . ISafe::get('admin_name'), "对账户金额进行了修改", $arr['note'])); } return true; }
public function bind_nexists_user() { $username = IFilter::act(IReq::get('username')); $email = IFilter::act(IReq::get('email')); $oauth_id = IFilter::act(ISession::get('oauth_id')); $oauth_userInfo = IFilter::act(ISession::get('oauth_userInfo')); /*注册信息校验*/ if (IValidate::email($email) == false) { $message = '邮箱格式不正确'; } else { if (!Util::is_username($username)) { $message = '用户名必须是由2-20个字符,可以为字数,数字下划线和中文'; } else { $userObj = new IModel('user'); $where = 'email = "' . $email . '" or username = "******" or username = "******"'; $userRow = $userObj->getObj($where); if (!empty($userRow)) { if ($email == $userRow['email']) { $message = '此邮箱已经被注册过,请重新更换'; } else { $message = "此用户名已经被注册过,请重新更换"; } } else { $userData = array('email' => $email, 'username' => $username, 'password' => md5(ITime::getDateTime())); $userObj->setData($userData); $user_id = $userObj->add(); $memberObj = new IModel('member'); $memberData = array('user_id' => $user_id, 'true_name' => $oauth_userInfo['name'], 'last_login' => ITime::getDateTime(), 'sex' => isset($oauth_userInfo['sex']) ? $oauth_userInfo['sex'] : 1, 'time' => ITime::getDateTime()); $memberObj->setData($memberData); $memberObj->add(); $oauthUserObj = new IModel('oauth_user'); //插入关系表 $oauthUserData = array('oauth_user_id' => $oauth_userInfo['id'], 'oauth_id' => $oauth_id, 'user_id' => $user_id, 'datetime' => ITime::getDateTime()); $oauthUserObj->setData($oauthUserData); $oauthUserObj->add(); $userRow = CheckRights::isValidUser($userData['email'], $userData['password']); CheckRights::loginAfter($userRow); //自定义跳转页面 $callback = ISafe::get('callback'); $this->redirect('/site/success?message=' . urlencode("注册成功!") . '&callback=' . $callback); } } } if ($message != '') { $this->message = $message; $this->redirect('bind_user', false); } }
public function upgrade_5() { //执行sql等清理 $version = ISafe::get("upgrade_version"); $upgrade_zip_path = ISafe::get("upgrade_zip_path"); if ($version == null || $upgrade_zip_path == null) { die; } $upgrade_zip_path = realpath($upgrade_zip_path); $upgrade = new IWebUpgrade('shop', $version); $upgrade->upgrade($upgrade_zip_path); echo "success"; exit; }
/** * 列表展示 * @author keenhome@126.com * @date 2013-4-30 */ public function buy() { $gid = IFilter::act(IReq::get('gid'), 'int'); $tb_goods = new IModel('goods'); //增加点击次数 if (!ISafe::get('visit' . $gid)) { $tb_goods->setData(array('click' => 'click + 1')); $tb_goods->update('id = ' . $gid, 'click'); ISafe::set('click' . $gid, '1'); } $goodsRow = $tb_goods->getObj('ID = ' . $gid, 'url'); if (count($goodsRow) > 0 && $goodsRow['url']) { header("Location:" . $goodsRow['url']); } else { header("Location:/"); } }
/** * @brief 订单删除功能_删除回收站中的数据,彻底删除 */ public function order_recycle_del() { //post数据 $id = IFilter::act(IReq::get('id'), 'int'); //生成order对象 $tb_order = new IModel('order'); if ($id) { $id = is_array($id) ? join(',', $id) : $id; Order_class::resetOrderProp($id); //删除订单 $tb_order->del('id in (' . $id . ')'); //记录日志 $logObj = new log('db'); $logObj->write('operation', array("管理员:" . ISafe::get('admin_name'), "删除回收站中退货单", '退货单ID:' . $id)); $this->redirect('order_recycle_list'); } else { $this->redirect('order_recycle_list', false); Util::showMessage('请选择要删除的数据'); } }
public function order_recycle_del() { //post数据 $id = IFilter::act(IReq::get('id'), 'int'); $id_str = $id; //生成order对象 $tb_order = new IModel('order'); if (!empty($id)) { $where = ''; $prop = ''; $order_id = ''; if (is_array($id) && isset($id[0]) && $id[0] != '') { $id_str = join(',', $id); $where = ' id in (' . $id_str . ')'; $prop = ' id in (' . $id_str . ') and pay_status =0 and prop is not null'; $order_id = ' order_id in (' . $id_str . ')'; } else { $where = 'id = ' . $id; $prop = 'id = ' . $id . ' and pay_status =0 and prop is not null'; $order_id = 'id = ' . $id; } //先修改红包 $order_info = $tb_order->query($prop); if (count($order_info) > 0) { $tb_prop = new IModel('prop'); foreach ($order_info as $value) { $tb_prop->setData(array('is_close' => 0)); if ($value['prop']) { $tb_prop->update('id=' . $value['prop']); } } } //删除订单商品 $tb_order_goods = new IQuery('order_goods'); $tb_order_goods->fields = 'id'; $tb_order_goods->where = $order_id; $order_info = $tb_order_goods->find(); if (count($order_info) > 0) { $tb_order_go = new IModel('order_goods'); foreach ($order_info as $value) { if ($value['id']) { $tb_order_go->del('id=' . $value['id']); } } } //删除订单 $tb_order->del($where); $logObj = new log('db'); $logObj->write('operation', array("管理员:" . ISafe::get('admin_name'), "删除回收站中退货单", '退货单ID:' . $id_str)); $this->redirect('order_recycle_list'); } else { $this->redirect('order_recycle_list', false); Util::showMessage('请选择要删除的数据'); } }
/** * @brief 获取订单中的支付信息 M:必要信息; R表示店铺; P表示用户; * @param $payment_id int 支付方式ID * @param $type string 信息获取方式 order:订单支付;recharge:在线充值; * @param $argument mix 参数 * @return array 支付提交信息 */ public static function getPaymentInfo($payment_id, $type, $argument) { //最终返回值 $payment = array(); //初始化配置参数 $paymentInstance = Payment::createPaymentInstance($payment_id); $configParam = $paymentInstance->configParam(); foreach ($configParam as $key => $val) { $payment[$key] = ''; } //获取公共信息 $paymentRow = self::getPaymentById($payment_id, 'config_param'); if ($paymentRow) { $paymentRow = JSON::decode($paymentRow); foreach ($paymentRow as $key => $item) { $payment[$key] = $item; } } if ($type == 'order') { $orderIdArray = $argument; $M_Amount = 0; $M_OrderNO = array(); foreach ($orderIdArray as $key => $order_id) { //获取订单信息 $orderObj = new IModel('order'); $orderRow = $orderObj->getObj('id = ' . $order_id . ' and status = 1'); if (empty($orderRow)) { IError::show(403, '订单信息不正确,不能进行支付'); } //判断商品库存 $orderGoodsDB = new IModel('order_goods'); $orderGoodsList = $orderGoodsDB->query('order_id = ' . $order_id); foreach ($orderGoodsList as $key => $val) { if (!goods_class::checkStore($val['goods_nums'], $val['goods_id'], $val['product_id'])) { IError::show(403, '商品库存不足无法支付,请重新下单'); } } $M_Amount += $orderRow['order_amount']; $M_OrderNO[] = $orderRow['order_no']; } $payment['M_Remark'] = $orderRow['postscript']; $payment['M_OrderId'] = $orderRow['id']; $payment['M_OrderNO'] = $orderRow['order_no']; $payment['M_Amount'] = $M_Amount; //用户信息 $payment['P_Mobile'] = $orderRow['mobile']; $payment['P_Name'] = $orderRow['accept_name']; $payment['P_PostCode'] = $orderRow['postcode']; $payment['P_Telephone'] = $orderRow['telphone']; $payment['P_Address'] = $orderRow['address']; //订单批量结算缓存机制 $cacheObj = new ICache('file'); $cacheObj->set($payment['M_OrderNO'], join(",", $M_OrderNO)); } else { if ($type == 'recharge') { if (ISafe::get('user_id') == null) { IError::show(403, '请登录系统'); } if (!isset($argument['account']) || $argument['account'] <= 0) { IError::show(403, '请填入正确的充值金额'); } $rechargeObj = new IModel('online_recharge'); $reData = array('user_id' => ISafe::get('user_id'), 'recharge_no' => Order_Class::createOrderNum(), 'account' => $argument['account'], 'time' => ITime::getDateTime(), 'payment_name' => $argument['paymentName']); $rechargeObj->setData($reData); $r_id = $rechargeObj->add(); //充值时用户id跟随交易号一起发送,以"_"分割 $payment['M_OrderNO'] = 'recharge' . $reData['recharge_no']; $payment['M_OrderId'] = $r_id; $payment['M_Amount'] = $reData['account']; } } $siteConfigObj = new Config("site_config"); $site_config = $siteConfigObj->getInfo(); //交易信息 $payment['M_Time'] = time(); $payment['M_Paymentid'] = $payment_id; //店铺信息 $payment['R_Address'] = isset($site_config['address']) ? $site_config['address'] : ''; $payment['R_Name'] = isset($site_config['name']) ? $site_config['name'] : ''; $payment['R_Mobile'] = isset($site_config['mobile']) ? $site_config['mobile'] : ''; $payment['R_Telephone'] = isset($site_config['phone']) ? $site_config['phone'] : ''; return $payment; }
function spec_md5() { $cid = IFilter::act(IReq::get('cid')); $cidArray = explode(',', trim($cid, ',')); sort($cidArray); $gid = IFilter::act(IReq::get('gid')); $tb_products = new IModel('products'); $procducts_info = $tb_products->query(" goods_id='" . $gid . "' and spec_md5='" . md5(serialize($cidArray)) . "'"); //获得货品的会员价格 $user_id = ISafe::get('user_id'); $group_price = 0; if ($user_id) { $tb_group_price = new IQuery('group_price as g'); $tb_group_price->join = 'left join member as m on m.group_id=g.group_id'; $tb_group_price->fields = 'g.price'; $tb_group_price->where = 'g.goods_id=' . $gid . ' and g.products_id=' . $procducts_info[0]['id'] . ' and m.user_id=' . $user_id; $group_price_info = $tb_group_price->find(); if (count($group_price_info) > 0) { $group_price = $group_price_info[0]['price']; } } $pid = 0; if (count($procducts_info) > 0) { $pid = $procducts_info[0]['id'] . ',' . $procducts_info[0]['sell_price'] . ',' . $procducts_info[0]['market_price'] . ',' . $procducts_info[0]['store_nums'] . ',' . $procducts_info[0]['products_no'] . ',' . $group_price; } echo $pid; }