public function init() { header("Content-type: text/html; charset=" . $this->encoding); $this->model = new Model(); $safebox = Safebox::getInstance(); $this->user = $safebox->get('user'); }
/** * 构造函数 * * @access public * @param mixed $name * @param mixed $password * @return mixed */ public function __construct($name, $password) { $safebox = Safebox::getInstance(); $manager = $safebox->get('manager'); if (!isset($manager['id']) || $manager['id'] == '' || $manager['name'] != $name) { $model = new Model('manager'); $name = Filter::sql($name); $user = $model->where("name='" . $name . "'")->find(); if (!empty($user)) { $key = md5($user['validcode']); $password = substr($key, 0, 16) . $password . substr($key, 16, 16); if ($user['password'] == md5($password)) { $this->status = 'online'; $this->properties = $user; $safebox->set('manager', $this->properties); } else { $this->status = 'offline'; $this->properties = null; } } else { $this->status = 'offline'; $this->properties = null; } } else { $this->status = 'online'; $this->properties = $safebox->get('manager'); } }
public function init() { header("Content-type: text/html; charset=" . $this->encoding); $this->model = new Model(); $this->safebox = Safebox::getInstance(); $this->user = $this->safebox->get('user'); $category = Category::getInstance(); $this->category = $category->getCategory(); $cart = Cart::getCart(); $this->assign("cart_num", $cart->getNum()); $this->assign("cart", $cart->all()); $this->assign("category", $this->category); }
public static function getInstance($type = 'session') { if (!self::$obj instanceof self) { $type = strtolower($type); if ($type == 'session') { self::$box = new Session(); } else { self::$box = new Cookie(); self::$box->setSafeCode(Tiny::app()->getSafeCode()); } self::$obj = new self(); } return self::$box; }
public function init() { $menu = new Menu(); $this->assign('mainMenu', $menu->getMenu()); $menu_index = $menu->current_menu(); $this->assign('menu_index', $menu_index); $this->assign('subMenu', $menu->getSubMenu($menu_index['menu'])); $this->assign('menu', $menu); $nav_act = Req::get('act') == null ? $this->defaultAction : Req::get('act'); $nav_act = preg_replace("/(_edit)\$/", "_list", $nav_act); $this->assign('nav_link', '/' . Req::get('con') . '/' . $nav_act); $this->assign('node_index', $menu->currentNode()); $this->safebox = Safebox::getInstance(); $this->assign('manager', $this->safebox->get('manager')); $currentNode = $menu->currentNode(); if (isset($currentNode['name'])) { $this->assign('admin_title', $currentNode['name']); } }
public function packData($payment) { $partnerId = $payment['M_PartnerId']; $partnerKey = $payment['M_PartnerKey']; $safebox = Safebox::getInstance(); $user = $safebox->get('user'); $user_id = $user['id']; $return['attach'] = $payment['M_Paymentid']; $return['total_fee'] = $payment['M_Amount']; $return['order_no'] = $payment['M_OrderNO']; $return['return_url'] = $this->callbackUrl; //过虑无效参数 $filter_param = $this->filterParam($return); //对待签名参数数组排序 $para_sort = $this->argSort($filter_param); //生成签名 $mysign = $this->buildSign($para_sort, $payment['M_PartnerKey']); //签名结果与签名方式加入请求提交参数组中 $return['sign'] = $mysign; return $return; }
public function do_prom_series($goods, $prom_goods, $prom_series) { // EC 变更 2015-06-04 10:16 抢购以外的场合,促销价,销售价,优惠信息的修正 START //$price = isset($prom_goods['real_price']) ? $prom_goods['real_price'] : $goods['sell_price']; $price = isset($prom_goods["parse"]['real_price']) ? $prom_goods["parse"]['real_price'] : $goods['sell_price']; // EC 变更 2015-06-04 10:16 抢购以外的场合,促销价,销售价,优惠信息的修正 END if (isset($goods['goods_nums']) && $goods['goods_nums'] != PHP_INT_MAX && $goods['goods_nums'] > 0) { $nums = $goods['goods_nums']; } $result = array('real_price' => $price, 'note' => '', 'minus' => "-0", 'multiple' => 1); $safebox = Safebox::getInstance(); $user = $safebox->get('user'); $group_id = ',0,'; if (isset($user['group_id'])) { $group_id = ',' . $user['group_id'] . ','; } // EC 变更 2015-06-04 10:16 抢购以外的场合,促销价,销售价,优惠信息的修正 START //if ($prom_series && stripos(',' . $prom_series['group'] . ',', $group_id) !== false) { if ($prom_series) { // EC 变更 2015-06-04 10:16 抢购以外的场合,促销价,销售价,优惠信息的修正 END $type = $prom_series['type']; $expr = $prom_series['expression']; $result['prom'] = $prom_series; //0直接打折 1减价优惠 2固定金额 3买就赠优惠券 4买M件送N件 switch ($type) { case '0': $result['real_price'] = $price * $expr / 100; $result['minus'] = "*" . $expr / 100; $result['note'] = '直接' . $expr / 10 . "折"; break; case '1': $result['real_price'] = $price - $expr > 0 ? $price - $expr : 0; $result['real_price'] = sprintf("%01.2f", $result['real_price']); $result['minus'] = "-" . $expr; $result['note'] = "立减" . $expr; break; case '2': $multiple = intval($expr); $result['multiple'] = $multiple == 0 ? 1 : $multiple; $result['note'] = "送" . $expr . "倍积分"; break; case '3': $model = new Model("voucher_template"); $voucher = $model->where("id=" . $expr)->find(); if ($voucher) { $result['note'] = "送" . $voucher['name'] . "优惠券,面值" . $voucher['value']; } else { $result['note'] = "所送的优惠券已不存在"; } break; } } return $result; }
public function reg_act() { if ($this->getModule()->checkToken('reg')) { $reg_type = Req::post('reg_type'); //Tiny::log(__FILE__ . '--' . __LINE__ . '--' . $reg_type); if ($reg_type == 'email') { $email = Filter::sql(Req::post('email')); $passWord = Req::post('password'); $rePassWord = Req::post('repassword'); $this->safebox = Safebox::getInstance(); $code = $this->safebox->get($this->captchaKey); $verifyCode = Req::args("verifyCode"); $info = array('field' => 'verifyCode', 'msg' => '验证码错误!'); if ($verifyCode == $code) { if (!Validator::email($email)) { $info = array('field' => 'email', 'msg' => '邮箱不能为空!'); } elseif (strlen($passWord) < 6) { $info = array('field' => 'password', 'msg' => '密码长度必需大于6位!'); } else { if ($passWord == $rePassWord) { $model = $this->model->table("user"); $obj = $model->where("email='{$email}'")->find(); if ($obj == null) { $config = Config::getInstance(); $config_other = $config->get("other"); $user_status = 1; if (isset($config_other['other_verification_eamil']) && $config_other['other_verification_eamil'] == 1) { $user_status = 0; } $validcode = CHash::random(8); $last_id = $model->data(array('email' => $email, 'name' => $email, 'password' => CHash::md5($passWord, $validcode), 'validcode' => $validcode, 'status' => $user_status))->insert(); $time = date('Y-m-d H:i:s'); $model->table("customer")->data(array('user_id' => $last_id, 'reg_time' => $time, 'login_time' => $time))->insert(); // 推荐商户登入 add by t-btei 2015/05/04 if (!empty($_COOKIE['company_affiliate_uid'])) { $uid = intval($_COOKIE['company_affiliate_uid']); $result = $model->table("company")->where("company_id ='" . $uid . "'")->find(); if (!empty($result)) { $model->table("affiliate")->data(array('user_id' => $last_id, 'company_id' => $uid, 'create_date' => $time, 'update_date' => $time))->insert(); } setcookie('company_affiliate_uid', ''); } if ($user_status == 1) { //记录登录信息 $obj = $model->table("user as us")->join("left join customer as cu on us.id = cu.user_id")->fields("us.*,cu.group_id,cu.login_time")->where("us.email='{$email}'")->find(); $this->safebox->set('user', $obj, 1800); } else { $email_code = Crypt::encode($email); $valid_code = md5($validcode); $str_code = $valid_code . $email_code; $activation_url = Url::fullUrlFormat("/simple/activation_user/code/{$str_code}"); $msg_content = ''; $site_url = Url::fullUrlFormat('/'); $msg_title = '账户激活--' . $this->site_name; $msg_template_model = new Model("msg_template"); $msg_template = $msg_template_model->where('id=4')->find(); if ($msg_template) { $msg_content = str_replace(array('{$site_name}', '{$activation_url}', '{$site_url}', '{$current_time}'), array($this->site_name, $activation_url, $site_url, date('Y-m-d H:i:s')), $msg_template['content']); $msg_title = $msg_template['title']; $mail = new Mail(); $flag = $mail->send_email($email, $msg_title, $msg_content); if (!$flag) { $this->redirect("/index/msg", true, array('type' => "fail", "msg" => '邮件发送失败', "content" => "后台还没有成功配制邮件信息!")); } } } $mail_host = 'http://mail.' . preg_replace('/.+@/i', '', $email); $args = array("user_status" => $user_status, "mail_host" => $mail_host, 'user_name' => $email); $this->redirect("reg_result", true, $args); } else { $info = array('field' => 'email', 'msg' => '此用户已经被注册!'); } } else { $info = array('field' => 'repassword', 'msg' => '两次密码输入不一致!'); } } } $this->assign("invalid", $info); $this->redirect("reg", false, Req::args()); } elseif ($reg_type == 'mobile') { //$email = Filter::sql(Req::post('email')); $mobile = Filter::sql(Req::post('mobile')); $verifyMobileCode = Filter::sql(Req::post('verifyMobileCode')); $passWord = Req::post('password'); $rePassWord = Req::post('repassword'); $this->safebox = Safebox::getInstance(); //$code = $this->safebox->get($this->captchaKey); // 已经有手机验证码,图片验证码去掉 //$verifyCode = Req::args("verifyCode"); //$info = array('field'=>'verifyCode','msg'=>'验证码错误!'); if (!Validator::mobi($mobile)) { $info = array('field' => 'mobile', 'msg' => '手机号不能为空!'); } elseif (strlen($passWord) < 6) { $info = array('field' => 'password', 'msg' => '密码长度必需大于6位!'); } else { if ($passWord == $rePassWord) { //判断手机验证码是否正确 $ret = $this->validate_auth_code($mobile, $verifyMobileCode); if (isset($ret['status']) && $ret['status'] == true) { // 把查user 改成 添加user // email 验证 需要查user // 手机注册 上面验证完短信 直接可以 insert user $model = $this->model->table("user"); //$obj = $model->where("email='$email'")->find(); $obj = $model->where("mobile='{$mobile}'")->find(); if ($obj == null) { $config = Config::getInstance(); $config_other = $config->get("other"); $user_status = 1; // 手机验证 这个状态 是否可去掉 $validcode = CHash::random(8); $last_id = $model->data(array('mobile' => $mobile, 'name' => $mobile, 'password' => CHash::md5($passWord, $validcode), 'validcode' => $validcode, 'status' => $user_status))->insert(); $time = date('Y-m-d H:i:s'); $model->table("customer")->data(array('user_id' => $last_id, 'mobile' => $mobile, 'reg_time' => $time, 'login_time' => $time))->insert(); //Tiny::log(__FILE__.'--'.__LINE__.'--'.$last_id); if ($user_status == 1) { //记录登录信息 $obj = $model->table("user as us")->join("left join customer as cu on us.id = cu.user_id")->fields("us.*,cu.group_id,cu.login_time")->where("us.mobile='{$mobile}'")->find(); $this->safebox->set('user', $obj, 1800); } else { } //todo 下面是邮箱注册代码 发送邮箱验证码流程 已经删除 $args = array("user_status" => $user_status, 'user_name' => $mobile); $this->redirect("reg_result", true, $args); } else { $info = array('field' => 'mobile', 'msg' => '此用户已经被注册!'); //$info = array('field'=>'email','msg'=>'此用户已经被注册!'); } } else { $info = array('field' => 'verifyMobileCode', 'msg' => $ret['msg']); // 手机验证码验证失败! } } else { $info = array('field' => 'repassword', 'msg' => '两次密码输入不一致!'); } } //Tiny::log(__FILE__.'--'.__LINE__.'--'.$info['field'].'--'.$info['msg']); $this->assign("invalid", $info); $args = Req::args(); $args['invalid'] = $info; //$this->redirect("reg",true, $args); $this->redirect("reg", false, $args); } } else { $this->redirect("/index/msg", false, array('type' => "fail", "msg" => '注册无效', "content" => "非法进入注册页面!", "redirect" => "/simple/reg")); exit; } }
public function verifyCode() { $info = array('status' => false, 'msg' => '验证码错误!'); $this->safebox = Safebox::getInstance(); $code = $this->safebox->get($this->captchaKey); $verifyCode = Req::args("verifyCode"); if ($code == $verifyCode) { $info = array('status' => true, 'msg' => ''); } echo JSON::encode($info); }
/** * 登出处理动作 * * @access public */ public function logout() { $this->safebox = Safebox::getInstance(); $this->safebox->clear('manager'); //$this->safebox->clearAll(); $this->redirect('login'); }
public function upload_head() { $upfile_path = Tiny::getPath("uploads") . "/head/"; $upfile_url = preg_replace("|" . APP_URL . "|", '', Tiny::getPath("uploads_url") . "head/", 1); //$upfile_url = strtr(Tiny::getPath("uploads_url")."head/",APP_URL,''); $upfile = new UploadFile('imgFile', $upfile_path, '500k', '', 'hash', $this->user['id']); $upfile->save(); $info = $upfile->getInfo(); $result = array(); if ($info[0]['status'] == 1) { $result = array('error' => 0, 'url' => $upfile_url . $info[0]['path']); $image_url = $upfile_url . $info[0]['path']; $image = new Image(); $image->suffix = ''; $image->thumb(APP_ROOT . $image_url, 100, 100); $model = new Model('user'); $model->data(array('head_pic' => $image_url))->where("id=" . $this->user['id'])->update(); $safebox = Safebox::getInstance(); $user = $this->user; $user['head_pic'] = $image_url; $safebox->set('user', $user); } else { $result = array('error' => 1, 'message' => $info[0]['msg']); } echo JSON::encode($result); }
public function __construct() { $nodes = array('/admin/index' => array('name' => '管理首页', 'parent' => 'config'), '/admin/theme_list' => array('name' => '主题设置', 'parent' => 'config'), '/admin/config_globals' => array('name' => '站点设置', 'parent' => 'config'), '/admin/config_other' => array('name' => '其它配置', 'parent' => 'config'), '/admin/config_email' => array('name' => '邮箱配置', 'parent' => 'config'), '/admin/msg_template_list' => array('name' => '信息模板', 'parent' => 'config'), '/admin/msg_template_edit' => array('name' => '信息模板编辑', 'parent' => 'config'), '/admin/oauth_list' => array('name' => '开放登录', 'parent' => 'config'), '/admin/oauth_edit' => array('name' => '开放登录编辑', 'parent' => 'config'), '/admin/payment_list' => array('name' => '支付方式', 'parent' => 'delivery'), '/admin/payment_edit' => array('name' => '编辑支付方式', 'parent' => 'delivery'), '/admin/zoning_list' => array('name' => '区域划分', 'parent' => 'delivery'), '/admin/ext_params_list' => array('name' => '海关对接', 'parent' => 'delivery'), '/admin/area_list' => array('name' => '地区管理', 'parent' => 'delivery'), '/admin/fare_list' => array('name' => '运费模板', 'parent' => 'delivery'), '/admin/fare_edit' => array('name' => '运费模板编辑', 'parent' => 'delivery'), '/admin/express_company_list' => array('name' => '快递公司', 'parent' => 'delivery'), '/admin/express_company_edit' => array('name' => '快递公司编辑', 'parent' => 'delivery'), '/admin/manager_list' => array('name' => '管理员', 'parent' => 'safe'), '/admin/manager_edit' => array('name' => '编辑管理员', 'parent' => 'safe'), '/admin/roles_list' => array('name' => '角色管理', 'parent' => 'safe'), '/admin/roles_edit' => array('name' => '角色编辑', 'parent' => 'safe'), '/admin/resources_list' => array('name' => '权限列表', 'parent' => 'safe'), '/admin/resources_edit' => array('name' => '编辑权限资源', 'parent' => 'safe'), '/admin/log_operation_list' => array('name' => '操作日志', 'parent' => 'safe'), '/admin/update' => array('name' => '版本升级', 'parent' => 'safe'), '/admin/clear' => array('name' => '清除缓存', 'parent' => 'safe'), '/content/article_list' => array('name' => '全部文章', 'parent' => 'article'), '/content/article_edit' => array('name' => '文章编辑', 'parent' => 'article'), '/content/category_list' => array('name' => '分类管理', 'parent' => 'article'), '/content/category_edit' => array('name' => '编辑分类', 'parent' => 'article'), '/content/help_list' => array('name' => '全部帮助', 'parent' => 'help'), '/content/help_edit' => array('name' => '帮助编辑', 'parent' => 'help'), '/content/help_category_list' => array('name' => '帮助分类管理', 'parent' => 'help'), '/content/help_category_edit' => array('name' => '编辑帮助分类', 'parent' => 'help'), '/content/ad_list' => array('name' => '广告管理', 'parent' => 'banner'), '/content/wel_list' => array('name' => '欢迎页面', 'parent' => 'banner'), '/content/ad_edit' => array('name' => '编辑广告', 'parent' => 'banner'), '/content/wel_edit' => array('name' => '编辑欢迎页面', 'parent' => 'banner'), '/content/tags_list' => array('name' => '标签管理', 'parent' => 'banner'), '/content/nav_list' => array('name' => '导航管理', 'parent' => 'banner'), '/content/nav_edit' => array('name' => '导航管理', 'parent' => 'banner'), '/admin/tables_list' => array('name' => '数据库备份', 'parent' => 'database'), '/admin/back_list' => array('name' => '数据库还原', 'parent' => 'database'), '/goods/goods_category_list' => array('name' => '分类管理', 'parent' => 'goods_config'), '/goods/goods_category_edit' => array('name' => '编辑分类', 'parent' => 'goods_config'), '/goods/goods_type_list' => array('name' => '类型管理', 'parent' => 'goods_config'), '/goods/goods_type_edit' => array('name' => '类型编辑', 'parent' => 'goods_config'), '/goods/tax_type_list' => array('name' => '税种管理', 'parent' => 'goods_config'), '/goods/tax_type_edit' => array('name' => '税种编辑', 'parent' => 'goods_config'), '/goods/theme_list' => array('name' => '主题管理', 'parent' => 'goods_config'), '/goods/theme_edit' => array('name' => '主题编辑', 'parent' => 'goods_config'), '/goods/tax_country_list' => array('name' => '国别管理', 'parent' => 'goods_config'), '/goods/tax_country_edit' => array('name' => '国别编辑', 'parent' => 'goods_config'), '/goods/goods_spec_list' => array('name' => '规格管理', 'parent' => 'goods_config'), '/goods/goods_spec_edit' => array('name' => '规格编辑', 'parent' => 'goods_config'), '/goods/brand_list' => array('name' => '品牌管理', 'parent' => 'goods_config'), '/goods/brand_edit' => array('name' => '品牌编辑', 'parent' => 'goods_config'), '/goods/series_list' => array('name' => '系列管理', 'parent' => 'goods_config'), '/goods/series_edit' => array('name' => '系列编辑', 'parent' => 'goods_config'), '/goods/goods_list' => array('name' => '商品管理', 'parent' => 'goods'), '/goods/goods_edit' => array('name' => '商品编辑', 'parent' => 'goods'), '/customer/customer_list' => array('name' => '会员管理', 'parent' => 'customer'), '/customer/customer_edit' => array('name' => '添加会员', 'parent' => 'customer'), '/customer/grade_list' => array('name' => '会员等级管理', 'parent' => 'customer'), '/customer/grade_edit' => array('name' => '添加会员等级', 'parent' => 'customer'), '/customer/withdraw_list' => array('name' => '提现申请', 'parent' => 'balance'), '/customer/balance_list' => array('name' => '资金日志', 'parent' => 'balance'), '/customer/review_list' => array('name' => '商品评价', 'parent' => 'ask_reviews'), '/customer/ask_list' => array('name' => '商品咨询', 'parent' => 'ask_reviews'), '/customer/ask_edit' => array('name' => '咨询回复', 'parent' => 'ask_reviews'), '/customer/message_list' => array('name' => '信息管理', 'parent' => 'ask_reviews'), '/customer/message_edit' => array('name' => '信息发送', 'parent' => 'ask_reviews'), '/customer/notify_list' => array('name' => '到货通知', 'parent' => 'ask_reviews'), '/customer/company_list' => array('name' => '商户管理', 'parent' => 'company'), '/customer/company_edit' => array('name' => '添加商户', 'parent' => 'company'), '/order/order_list' => array('name' => '商品订单', 'parent' => 'order'), '/order/email_message_list' => array('name' => '订单通知', 'parent' => 'order'), '/order/result_list' => array('name' => '回执信息', 'parent' => 'order'), '/order/examine_list' => array('name' => '审批结果', 'parent' => 'order'), '/order/email_message_edit' => array('name' => '订单通知编辑', 'parent' => 'order'), '/order/express_template_list' => array('name' => '快递单模板', 'parent' => 'express'), '/order/express_template_edit' => array('name' => '快递单模板编辑', 'parent' => 'express'), '/order/ship_list' => array('name' => '发货点管理', 'parent' => 'express'), '/order/ship_edit' => array('name' => '发货点编辑', 'parent' => 'express'), '/order/doc_receiving_list' => array('name' => '收款单', 'parent' => 'receipt'), '/order/doc_invoice_list' => array('name' => '发货单', 'parent' => 'receipt'), '/order/doc_refund_list' => array('name' => '退款单', 'parent' => 'receipt'), '/count/index' => array('name' => '订单统计', 'parent' => 'count'), '/count/hot' => array('name' => '热销统计', 'parent' => 'count'), '/count/area_buy' => array('name' => '地区统计', 'parent' => 'count'), '/count/user_reg' => array('name' => '会员分布统计', 'parent' => 'customer_count'), '/marketing/voucher_template_list' => array('name' => '代金券模板', 'parent' => 'voucher'), '/marketing/voucher_template_edit' => array('name' => '代金券模板编辑', 'parent' => 'voucher'), '/marketing/voucher_list' => array('name' => '代金券管理', 'parent' => 'voucher'), '/marketing/voucher_edit' => array('name' => '代金券编辑', 'parent' => 'voucher'), '/marketing/prom_goods_list' => array('name' => '商品促销', 'parent' => 'promotions'), '/marketing/prom_goods_edit' => array('name' => '编辑商品促销', 'parent' => 'promotions'), '/marketing/prom_order_list' => array('name' => '订单促销', 'parent' => 'promotions'), '/marketing/prom_order_edit' => array('name' => '编辑订单促销', 'parent' => 'promotions'), '/marketing/prom_series_list' => array('name' => '系列促销', 'parent' => 'promotions'), '/marketing/prom_series_edit' => array('name' => '编辑系列促销', 'parent' => 'promotions'), '/marketing/bundling_list' => array('name' => '捆绑促销', 'parent' => 'promotions'), '/marketing/bundling_edit' => array('name' => '编辑捆绑促销', 'parent' => 'promotions'), '/marketing/groupbuy_list' => array('name' => '团购', 'parent' => 'promotions'), '/marketing/groupbuy_edit' => array('name' => '团购', 'parent' => 'promotions'), '/marketing/flash_sale_list' => array('name' => '限时抢购', 'parent' => 'promotions'), '/marketing/flash_sale_edit' => array('name' => '编辑限时抢购', 'parent' => 'promotions')); //分组菜单 $subMenu = array('config' => array('name' => '参数设定', 'parent' => 'system'), 'delivery' => array('name' => '支付与配送', 'parent' => 'system'), 'safe' => array('name' => '安全管理', 'parent' => 'system'), 'database' => array('name' => '数据库管理', 'parent' => 'system'), 'article' => array('name' => '文章管理', 'parent' => 'content'), 'help' => array('name' => '帮助中心', 'parent' => 'content'), 'banner' => array('name' => '内容管理', 'parent' => 'content'), 'goods' => array('name' => '产品管理', 'parent' => 'goods'), 'goods_config' => array('name' => '商品配置', 'parent' => 'goods'), 'company' => array('name' => '商户管理', 'parent' => 'customer'), 'customer' => array('name' => '会员管理', 'parent' => 'customer'), 'balance' => array('name' => '会员资金', 'parent' => 'customer'), 'ask_reviews' => array('name' => '咨询与评价', 'parent' => 'customer'), 'order' => array('name' => '订单管理', 'parent' => 'order'), 'receipt' => array('name' => '单据管理', 'parent' => 'order'), 'express' => array('name' => '快递单配置', 'parent' => 'order'), 'count' => array('name' => '销售统计', 'parent' => 'count'), 'customer_count' => array('name' => '客户统计', 'parent' => 'count'), 'promotions' => array('name' => '促销活动', 'parent' => 'marketing'), 'voucher' => array('name' => '代金券管理', 'parent' => 'marketing')); //主菜单 $menu = array('goods' => array('link' => '/goods/goods_list', 'name' => '商品中心'), 'order' => array('link' => '/order/order_list', 'name' => '订单中心'), 'customer' => array('link' => '/customer/company_list', 'name' => '客户中心'), 'marketing' => array('link' => '/marketing/prom_goods_list', 'name' => '营销推广'), 'count' => array('link' => '/count/index', 'name' => '统计报表'), 'content' => array('link' => '/content/article_list', 'name' => '内容管理'), 'system' => array('link' => '/admin/index', 'name' => '系统设置')); $safebox = Safebox::getInstance(); $manager = $safebox->get('manager'); if (isset($manager['roles']) && $manager['roles'] != 'administrator') { $roles = new Roles($manager['roles']); $result = $roles->getRoles(); if (isset($result['rights'])) { $rights = $result['rights']; } else { $rights = ''; } if (is_array($nodes)) { $subMenuKey = array(); foreach ($nodes as $key => $value) { $_key = trim(strtr($key, '/', '@'), '@'); if (stripos($rights, $_key) === false) { unset($nodes[$key]); } else { if (!isset($subMenuKey[$value['parent']])) { $subMenuKey[$value['parent']] = $key; } else { if (stristr($key, '_list')) { $subMenuKey[$value['parent']] = $key; } } } } $menuKey = array(); foreach ($subMenu as $key => $value) { if (isset($subMenuKey[$key])) { $menuKey[$value['parent']] = $key; } else { unset($subMenu[$key]); } } foreach ($menu as $key => $value) { if (!isset($menuKey[$key])) { unset($menu[$key]); } else { $menu[$key]['link'] = $subMenuKey[$menuKey[$key]]; } } } } //var_dump($subMenuKey,$menuKey,$menu);exit; if (is_array($nodes)) { $this->nodes = $nodes; } else { $this->nodes = array(); } if (is_array($subMenu)) { $this->subMenu = $subMenu; } else { $this->subMenu = array(); } if (is_array($menu)) { $this->menu = $menu; } else { $this->menu = array(); } foreach ($this->nodes as $key => $nodes) { $this->_subMenu[$nodes['parent']][] = array('link' => $key, 'name' => $nodes['name'], 'display' => isset($nodes['name']) ? $nodes['name'] : true); } foreach ($this->subMenu as $key => $subMenu) { $this->_menu[$subMenu['parent']][] = array('link' => $key, 'name' => $subMenu['name']); } $this->link_key = '/' . (Req::get('con') == null ? strtolower(Tiny::app()->defaultController) : Req::get('con')) . '/' . (Req::get('act') == null ? Tiny::app()->getController()->defaultAction : Req::get('act')); }
/** * @brief 获取订单中的支付信息 * @type 信息获取方式 order:订单支付;recharge:在线充值; * @argument 参数 * @return array 支付提交信息 * R表示店铺 ; P表示用户; */ public function getPaymentInfo($type, $argument) { $controller = Tiny::app()->getController(); //支付信息 $payment = array(); //取的支付商户的ID与密钥 $paymentObj = $this->getPayment(); $payment['M_PartnerId'] = $paymentObj['partner_id']; $payment['M_PartnerKey'] = $paymentObj['partner_key']; $model = new Model("order"); if ($type == 'order') { $order_id = $argument; //获取订单信息 $order = $model->where('id = ' . $order_id . ' and status = 2')->find(); if (empty($order)) { $msg = array('type' => 'fail', 'msg' => '订单信息不正确,不能进行支付!'); $controller->redirect('/index/msg', false, $msg); exit; } //商品名称 $model2 = new Model("order_goods"); $model3 = new Model("goods"); $order_goods = $model2->where('order_id = ' . $order_id . '')->findAll(); $goods_name = ''; foreach ($order_goods as $order_item) { // 如果订单详细表中行是由于捆绑促销 if (isset($order_item['prom_type']) && $order_item['prom_type'] === 'bundling') { $goods_name .= $order_item['title'] . ', '; } else { $goods_id = $order_item['goods_id']; $goods = $model3->where('id = ' . $goods_id . '')->find(); $goods_name .= $goods['name'] . ', '; } } $payment['M_Name'] = trim($goods_name, ', '); $payment['M_Remark'] = $order['user_remark']; $payment['M_OrderId'] = $order['id']; $payment['M_OrderNO'] = $order['order_no']; $payment['M_Amount'] = $order['order_amount']; //用户信息 $payment['P_Mobile'] = $order['mobile']; $payment['P_Name'] = $order['accept_name']; $payment['P_PostCode'] = $order['zip']; $payment['P_Telephone'] = $order['phone']; $payment['P_Address'] = $order['addr']; $payment['P_Email'] = ''; } else { if ($type == 'recharge') { if (!isset($argument['account']) || $argument['account'] <= 0) { $msg = array('type' => 'fail', 'msg' => '请填入正确的充值金额!'); $controller->redirect('/index/msg', false, $msg); exit; } $safebox = Safebox::getInstance(); $user = $safebox->get('user'); $recharge = new Model('recharge'); $data = array('user_id' => $user['id'], 'recharge_no' => Common::createOrderNo(), 'account' => $argument['account'], 'time' => date('Y-m-d H:i:s'), 'payment_name' => $argument['paymentName'], 'status' => 0); $r_id = $recharge->data($data)->insert(); //充值时用户id跟随交易号一起发送,以"_"分割 $payment['M_OrderNO'] = 'recharge_' . $data['recharge_no']; $payment['M_OrderId'] = $r_id; $payment['M_Amount'] = $data['account']; } } $config = Config::getInstance(); $site_config = $config->get("globals"); //交易信息 $payment['M_Def_Amount'] = 0.01; $payment['M_Time'] = time(); $payment['M_Goods'] = ''; $payment['M_Language'] = "zh_CN"; $payment['M_Paymentid'] = $this->payment_id; //商城信息 $payment['R_Address'] = isset($site_config['site_addr']) ? $site_config['site_addr'] : ''; $payment['R_Name'] = isset($site_config['site_name']) ? $site_config['site_name'] : ''; $payment['R_Mobile'] = isset($site_config['site_mobile']) ? $site_config['site_mobile'] : ''; $payment['R_Telephone'] = isset($site_config['site_phone']) ? $site_config['site_phone'] : ''; $payment['R_Postcode'] = isset($site_config['site_zip']) ? $site_config['site_zip'] : ''; $payment['R_Email'] = isset($site_config['site_email']) ? $site_config['site_email'] : ''; return $payment; }
public function only() { $hash = md5(serialize($_POST)); $safebox = Safebox::getInstance(); $__hash__ = $safebox->get('__HASH__'); if ($hash != $__hash__) { $safebox->set('__HASH__', $hash); return true; } else { return false; } }
public static function updateStatus($orderNo, $payment_id = 0, $callback_info = null) { //SKM-ORDER-STATUS 这个方法得大改 $model = new Model("order"); $order = $model->where("order_no='" . $orderNo . "'")->find(); if (isset($callback_info['trade_no'])) { $trading_info = $callback_info['trade_no']; } else { $trading_info = ''; } if (empty($order)) { return false; } if ($order['pay_status'] == 1) { return $order['id']; } else { if ($order['pay_status'] == 0) { //更新订单信息 $data = array('status' => 3, 'pay_time' => date('Y-m-d H:i:s'), 'trading_info' => $trading_info, 'pay_status' => 1); //修改用户最后选择的支付方式 if ($payment_id != 0) { $data['payment'] = $payment_id; } else { $payment_id = $order['payment']; } //更新订单支付状态 $model->table("order")->data($data)->where("id=" . $order['id'])->update(); //SKM-SMS 支付成功 发送支付完成信息 $sms_inst = new Sms(); $orderNo = $order['order_no']; $text = "【全品电台】感谢您使用全品电台。您的订单 {$orderNo} 已经支付成功,我们将会在24小时内给您发货。"; $mobile = $order['mobile']; if ($mobile != "") { // 测试时 不发送SMS $sms_inst->sendSms($text, $mobile); } /* S 二次开发 */ //发送邮件 $order_url = Url::fullUrlFormat("/ucenter/order_detail/id/{$order['id']}"); $safebox = Safebox::getInstance(); $user = $safebox->get('user'); $email_message_model = new Model('email_message'); $email_message = $email_message_model->where('`trigger`=2 and status=1')->find(); if ($email_message) { $body = str_replace(array('{$order_no}', '{$user_name}', '{$current_time}', '{$order_url}'), array($orderNo, $user['name'], date('Y-m-d H:i:s'), $order_url), $email_message['content']); $mail = new Mail(); $mail->send_email($user['email'], $email_message['title'], $body); } /* E 二次开发 */ //商品中优惠券的处理 $products = $model->table("order_goods")->where("order_id=" . $order['id'])->findAll(); $goods_ids = array(); foreach ($products as $pro) { //SKM-ORDER-STATUS 添加捆绑促销的处理 if ($pro['prom_type'] == 'bundling') { // 添加 } else { $prom = unserialize($pro['prom_goods']); if (isset($prom['prom'])) { $prom_series = isset($prom['series']['prom']) ? $prom['series']['prom'] : null; $prom = $prom['prom']; //商品中优惠券的处理 if (isset($prom['type']) && $prom['type'] == 3 && $order['type'] == 0) { $voucher_template_id = $prom['expression']; $voucher_template = $model->table("voucher_template")->where("id=" . $voucher_template_id)->find(); Common::paymentVoucher($voucher_template, $order['user_id']); //优惠券发放日志 } //二次开发部分 //系列中的优惠券 if (isset($prom_series['type']) && $prom_series['type'] == 3 && $order['type'] == 0) { $voucher_template_id = $prom_series['expression']; $voucher_template = $model->table("voucher_template")->where("id=" . $voucher_template_id)->find(); Common::paymentVoucher($voucher_template, $order['user_id']); //优惠券发放日志 } } //更新货品中的库存信息 $goods_nums = $pro['goods_nums']; $product_id = $pro['product_id']; $model->table("products")->where("id=" . $product_id)->data(array('store_nums' => "`store_nums`-" . $goods_nums))->update(); $goods_ids[$pro['goods_id']] = $pro['goods_id']; } } //更新商品表里的库存信息 foreach ($goods_ids as $id) { $objs = $model->table('products')->fields('sum(store_nums) as store_nums')->where('goods_id=' . $id)->query(); if ($objs) { $num = $objs[0]['store_nums']; $model->table('goods')->data(array('store_nums' => $num))->where('id=' . $id)->update(); } } //普通订单的处理 foreach ($products as $pro) { //SKM-ORDER-STATUS 添加捆绑促销的处理 if ($pro['prom_type'] == 'bundling') { } else { if ($order['type'] == 0) { //订单优惠券活动事后处理 $prom = unserialize($order['prom']); if (!empty($prom) && $prom['type'] == 3) { $voucher_template_id = $prom['expression']; $voucher_template = $model->table("voucher_template")->where("id=" . $voucher_template_id)->find(); Common::paymentVoucher($voucher_template, $order['user_id']); } } else { if ($order['type'] == 1) { //更新团购信息 $prom = unserialize($order['prom']); if (isset($prom['id'])) { $groupbuy = $model->table("groupbuy")->where("id=" . $prom['id'])->find(); if ($groupbuy) { $goods_num = $groupbuy['goods_num']; $order_num = $groupbuy['order_num']; $max_num = $groupbuy['max_num']; $end_time = $groupbuy['end_time']; $time_diff = time() - strtotime($end_time); foreach ($products as $pro) { $data = array('goods_num' => $goods_num + $pro['goods_nums'], 'order_num' => $order_num + 1); } if ($time_diff >= 0 || $max_num <= $data['goods_num']) { $data['is_end'] = 1; } $model->table("groupbuy")->where("id=" . $prom['id'])->data($data)->update(); } } } else { if ($order['type'] == 2) { //更新抢购信息 $prom = unserialize($order['prom']); if (isset($prom['id'])) { $flashbuy = $model->table("flash_sale")->where("id=" . $prom['id'])->find(); if ($flashbuy) { $goods_num = $flashbuy['goods_num']; $order_num = $flashbuy['order_num']; $max_num = $flashbuy['max_num']; $end_time = $flashbuy['end_time']; $time_diff = time() - strtotime($end_time); foreach ($products as $pro) { $data = array('goods_num' => $goods_num + $pro['goods_nums'], 'order_num' => $order_num + 1); } if ($time_diff >= 0 || $max_num <= $data['goods_num']) { $data['is_end'] = 1; } $model->table("flash_sale")->where("id=" . $prom['id'])->data($data)->update(); } } } } } } } //送积分 Pointlog::write($order['user_id'], $order['point'], '购买商品,订单:' . $order['order_no'] . ' 赠送' . $order['point'] . '积分'); //对使用代金券的订单,修改代金券的状态 if ($order['voucher_id']) { $model->table("voucher")->where("id=" . $order['voucher_id'])->data(array('status' => 1))->update(); } //生成收款单 $receivingData = array('order_id' => $order['id'], 'user_id' => $order['user_id'], 'amount' => $order['order_amount'], 'create_time' => date('Y-m-d H:i:s'), 'payment_time' => date('Y-m-d H:i:s'), 'doc_type' => 0, 'payment_id' => $payment_id, 'pay_status' => 1); $model->table("doc_receiving")->data($receivingData)->insert(); //统计会员规定时间内的消费金额,进行会员升级。 $config = Config::getInstance(); $config_other = $config->get('other'); $grade_days = isset($config_other['other_grade_days']) ? intval($config_other['other_grade_days']) : 365; $time = date("Y-m-d H:i:s", strtotime("-" . $grade_days . " day")); $obj = $model->table("doc_receiving")->fields("sum(amount) as amount")->where("user_id=" . $order['user_id'] . " and doc_type=0 and payment_time > '{$time}'")->query(); if (isset($obj[0])) { $amount = $obj[0]['amount']; $grade = $model->table('grade')->where('money < ' . $amount)->order('money desc')->find(); if ($grade) { $model->table('customer')->data(array('group_id' => $grade['id']))->where("user_id=" . $order['user_id'])->update(); } } return $order['id']; } else { return false; } } }
public function reg_act() { $email = Filter::sql(Req::post('email')); $passWord = Req::post('password'); $rePassWord = Req::post('repassword'); $this->safebox = Safebox::getInstance(); $code = $this->safebox->get($this->captchaKey); $verifyCode = Req::args("verifyCode"); $info = array('field' => 'verifyCode', 'msg' => '验证码错误!'); if ($verifyCode == $code) { if ($passWord == $rePassWord) { $model = $this->model->table("user"); $obj = $model->where("email='{$email}'")->find(); if ($obj == null) { $validcode = CHash::random(8); $model->data(array('email' => $email, 'name' => $email, 'password' => CHash::md5($passWord, $validcode), 'validcode' => $validcode))->insert(); $this->redirect("index"); } else { $info = array('field' => 'email', 'msg' => '此用户已经被注册!'); } } else { $info = array('field' => 'repassword', 'msg' => '两次密码输入不一致!'); } } $this->assign("invalid", $info); $this->redirect("reg", false, Req::args()); }