/** * @brief 商家登录动作 */ public function login() { $seller_name = IFilter::act(IReq::get('username')); $password = IReq::get('password'); $message = ''; if ($seller_name == '') { $message = '登录名不能为空'; } else { if ($password == '') { $message = '密码不能为空'; } else { $sellerObj = new IModel('seller'); $sellerRow = $sellerObj->getObj('seller_name = "' . $seller_name . '" and is_del = 0 and is_lock = 0'); if ($sellerRow && $sellerRow['password'] == md5($password)) { $dataArray = array('login_time' => ITime::getDateTime()); $sellerObj->setData($dataArray); $where = 'id = ' . $sellerRow["id"]; $sellerObj->update($where); //存入私密数据 ISafe::set('seller_id', $sellerRow['id']); ISafe::set('seller_name', $sellerRow['seller_name']); ISafe::set('seller_pwd', $sellerRow['password']); $this->redirect('/seller/index'); } else { $message = '用户名与密码不匹配'; } } } if ($message != '') { $this->redirect('index', false); Util::showMessage($message); } }
public static function help_edit($data) { if (!isset($data['name']) || $data['name'] === null || !preg_match('!^.{1,50}$!u', $data['name'])) { return array('flag' => false, 'data' => '标题不能为空,且不能超过50个文字'); } $data['name'] = htmlspecialchars($data['name'], ENT_QUOTES); if (!isset($data['cat_id']) || $data['cat_id'] === null) { return array('flag' => false, 'data' => '分类不能为空'); } $data['cat_id'] = intval($data['cat_id']); $data['content'] = strval($data['content']); $data['content'] = addslashes($data['content']); $data['sort'] = abs(intval($data['sort'])); $id = $data['id']; unset($data['id']); $tb_help = new IModel("help"); $tb_help->setData($data); if ($id === null) { $data['dateline'] = ITime::getNow(); $tb_help->setData($data); $tb_help->add(); } else { $tb_help->update("id={$id}"); } return array('flag' => true, 'data' => 'success'); }
public function write($type, $logs = array()) { $logInfo = $this->logInfo; if (!isset($logInfo[$type])) { return false; } $className = get_class($this->log); switch ($className) { //文件日志 case "IFileLog": //设置路径 $path = isset(IWeb::$app->config['logs']['path']) ? IWeb::$app->config['logs']['path'] : 'backup/log'; $fileName = rtrim($path, '\\/') . '/' . $type . '/' . date('Y/m') . '/' . date('d') . '.log'; $this->log->setPath($fileName); $logs = array_merge(array(ITime::getDateTime()), $logs); return $this->log->write($logs); break; //数据库日志 //数据库日志 case "IDBLog": $content['datetime'] = ITime::getDateTime(); $tableName = $logInfo[$type]['table']; foreach ($logInfo[$type]['cols'] as $key => $val) { $content[$val] = isset($logs[$val]) ? $logs[$val] : isset($logs[$key]) ? $logs[$key] : ''; } $this->log->setTableName($tableName); return $this->log->write($content); break; default: return false; break; } }
/** * @brief 自定时间格式散列,书写与date()函数相同 当$rand 为false时生成format的散列,为true时生成format+5位随机数的散列,这也是默认方式 * @param string $format 默认是 Y/m/d/His * @param bool $rand true加5位随机数,false 不加随机数 默认为true * @return String */ public static function time($format = 'Y/m/d/His', $rand = true) { if ($rand) { return ITime::getNow($format) . rand(10000, 99999); } else { return ITime::getNow($format); } }
/** * @brief 日志记录 * @param array $config => array('user_id' => 用户ID , 'point' => 积分增减(正,负区分) , 'log' => 日志记录内容) */ private function writeLog($config) { //修改pointLog表 $poinLogObj = new IModel('point_log'); $pointLogArray = array('user_id' => $config['user_id'], 'datetime' => ITime::getDateTime(), 'value' => $config['point'], 'intro' => $config['log']); $poinLogObj->setData($pointLogArray); return $poinLogObj->add(); }
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 static function ucenter_order() { $siteConfig = new Config('site_config'); $order_cancel_time = $siteConfig->order_cancel_time !== "" ? intval($siteConfig->order_cancel_time) : 7; $order_finish_time = $siteConfig->order_finish_time !== "" ? intval($siteConfig->order_finish_time) : 20; $orderModel = new IModel('order'); $orderCancelData = $order_cancel_time >= 0 ? $orderModel->query(" if_del = 0 and pay_type != 0 and status in(1) and datediff(NOW(),create_time) >= {$order_cancel_time} ", "id,order_no,4 as type_data") : array(); $orderCreateData = $order_finish_time >= 0 ? $orderModel->query(" if_del = 0 and distribution_status = 1 and status in(1,2) and datediff(NOW(),send_time) >= {$order_finish_time} ", "id,order_no,5 as type_data") : array(); $resultData = array_merge($orderCreateData, $orderCancelData); if ($resultData) { foreach ($resultData as $key => $val) { $type = $val['type_data']; $order_id = $val['id']; $order_no = $val['order_no']; //oerder表的对象 $tb_order = new IModel('order'); $tb_order->setData(array('status' => $type, 'completion_time' => ITime::getDateTime())); $tb_order->update('id=' . $order_id); //生成订单日志 $tb_order_log = new IModel('order_log'); //订单自动完成 if ($type == '5') { $action = '完成'; $note = '订单【' . $order_no . '】完成成功'; //完成订单并且进行支付 Order_Class::updateOrderStatus($order_no); //增加用户评论商品机会 Order_Class::addGoodsCommentChange($order_id); $logObj = new log('db'); $logObj->write('operation', array("系统自动", "订单更新为完成", '订单号:' . $order_no)); } else { $action = '作废'; $note = '订单【' . $order_no . '】作废成功'; //订单重置取消 Order_class::resetOrderProp($order_id); $logObj = new log('db'); $logObj->write('operation', array("系统自动", "订单更新为作废", '订单号:' . $order_no)); } $tb_order_log->setData(array('order_id' => $order_id, 'user' => "系统自动", 'action' => $action, 'result' => '成功', 'note' => $note, 'addtime' => ITime::getDateTime())); $tb_order_log->add(); } } }
/** * 写入日志并且更新账户余额 * @param array $config config数据类型 * @return string|bool */ public function write($config) { if (isset($config['user_id'])) { $this->setUser($config['user_id']); } else { throw new IException("用户信息不存在"); } isset($config['seller_id']) ? $this->setSeller($config['seller_id']) : ""; isset($config['admin_id']) ? $this->setAdmin($config['admin_id']) : ""; isset($config['event']) ? $this->setEvent($config['event']) : ""; if (isset($config['num']) && is_numeric($config['num'])) { $this->amount = abs(round($config['num'], 2)); //金额正负值处理 if (in_array($this->allow_event[$this->event], array(2, 3))) { $this->amount = '-' . abs($this->amount); } } else { throw new IException("金额必须大于0元"); } $this->config = $config; $this->noteData = isset($config['note']) ? $config['note'] : $this->note(); //写入数据库 $finnalAmount = $this->user['balance'] + $this->amount; if ($finnalAmount < 0) { throw new IException("用户余额不足"); } $memberDB = new IModel('member'); $memberDB->setData(array("balance" => $finnalAmount)); $memberDB->update("user_id = " . $this->user['id']); $tb_account_log = new IModel("account_log"); $insertData = array('admin_id' => $this->admin ? $this->admin['id'] : 0, 'user_id' => $this->user['id'], 'event' => $this->allow_event[$this->event], 'note' => $this->noteData, 'amount' => $this->amount, 'amount_log' => $finnalAmount, 'type' => $this->amount >= 0 ? 0 : 1, 'time' => ITime::getDateTime()); $tb_account_log->setData($insertData); $result = $tb_account_log->add(); //后台管理员操作记录 if ($insertData['admin_id']) { $logObj = new log('db'); $logObj->write('operation', array("管理员:" . $this->admin['admin_name'], "对账户金额进行了修改", $insertData['note'])); } return $result; }
/** * @brief 发送到货通知邮件 */ function notify_send() { $smtp = new SendMail(); $error = $smtp->getError(); if ($error) { $return = array('isError' => true, 'message' => $error); echo JSON::encode($return); exit; } $notify_ids = IFilter::act(IReq::get('notifyid')); $message = ''; if ($notify_ids && is_array($notify_ids)) { $ids = join(',', $notify_ids); $query = new IQuery("notify_registry as notify"); $query->join = "right join goods as goods on notify.goods_id=goods.id left join user as u on notify.user_id = u.id"; $query->fields = "notify.*,u.username,goods.name as goods_name,goods.store_nums"; $query->where = "notify.id in(" . $ids . ")"; $items = $query->find(); //库存大于0,且处于未发送状态的 发送通知 $succeed = 0; $failed = 0; $tb_notify_registry = new IModel('notify_registry'); foreach ($items as $value) { $body = mailTemplate::notify(array('{goodsName}' => $value['goods_name'], '{url}' => IUrl::getHost() . IUrl::creatUrl('/site/products/id/' . $value['goods_id']))); $status = $smtp->send($value['email'], "到货通知", $body); if ($status) { //发送成功 $succeed++; $data = array('notify_time' => ITime::getDateTime(), 'notify_status' => '1'); $tb_notify_registry->setData($data); $tb_notify_registry->update('id=' . $value['id']); } else { //发送失败 $failed++; } } } $return = array('isError' => false, 'count' => count($items), 'succeed' => $succeed, 'failed' => $failed); echo JSON::encode($return); }
/** * @brief 处理条件 * @param IQuery $db 数据库IQuery对象 * @param string $timeCols 时间字段名称 * @param string $start 开始日期 Y-m-d * @param string $end 结束日期 Y-m-d */ private static function ParseCondition($db, $timeCols = 'time', $start = '', $end = '') { $result = array(); //获取时间段 $date = self::dateParse($start, $end); $startArray = explode('-', $date[0]); $endArray = explode('-', $date[1]); $diffSec = ITime::getDiffSec($date[0], $date[1]); switch (self::groupByCondition($diffSec)) { //按照年 case "y": $startCondition = $startArray[0]; $endCondition = $endArray[0] + 1; $db->fields .= ',DATE_FORMAT(`' . $timeCols . '`,"%Y") as xValue'; $db->group = "DATE_FORMAT(`" . $timeCols . "`,'%Y') having `" . $timeCols . "` >= '{$startCondition}' and `" . $timeCols . "` < '{$endCondition}'"; break; //按照月 //按照月 case "m": $startCondition = $startArray[0] . '-' . $startArray[1]; $endCondition = $endArray[0] . '-' . ($endArray[1] + 1); $db->fields .= ',DATE_FORMAT(`' . $timeCols . '`,"%Y-%m") as xValue'; $db->group = "DATE_FORMAT(`" . $timeCols . "`,'%Y-%m') having `" . $timeCols . "` >= '{$startCondition}' and `" . $timeCols . "` < '{$endCondition}'"; break; //按照日 //按照日 case "d": $startCondition = $startArray[0] . '-' . $startArray[1] . '-' . $startArray[2]; $endCondition = $endArray[0] . '-' . $endArray[1] . '-' . ($endArray[2] + 1); $db->fields .= ',DATE_FORMAT(`' . $timeCols . '`,"%m-%d") as xValue'; $db->group = "DATE_FORMAT(`" . $timeCols . "`,'Y-%m-%d') having `" . $timeCols . "` >= '{$startCondition}' and `" . $timeCols . "` < '{$endCondition}'"; break; } $data = $db->find(); foreach ($data as $key => $val) { $result[$val['xValue']] = intval($val['yValue']); } return $result; }
function upload() { //图片上传 $upObj = new IUpload(); //目录散列 $dir = IWeb::$app->config['upload'] . '/' . date('Y') . "/" . date('m') . "/" . date('d'); $upObj->setDir($dir); $upState = $upObj->execute(); //实例化 $obj = new IModel('spec_photo'); //检查上传状态 foreach ($upState['attach'] as $val) { if ($val['flag'] == 1) { $insertData = array('address' => $val['dir'] . $val['name'], 'name' => $val['ininame'], 'create_time' => ITime::getDateTime()); $obj->setData($insertData); $obj->add(); } } if (count($upState['attach']) == 1) { return $upState['attach'][0]; } else { return $upState['attach']; } }
/** * @brief 获取当前时间段正在使用的广告数据 * @param $position int 广告位ID * @param $goods_cat_id 商品分类ID * @return array */ public static function getAdList($position, $goods_cat_id = 0) { $now = date("Y-m-d H:i:s", ITime::getNow()); $adDB = new IModel("ad_manage"); return $adDB->query("position_id={$position} and goods_cat_id = {$goods_cat_id} and start_time < '{$now}' AND end_time > '{$now}' ORDER BY `order` ASC "); }
/** * 支付成功后修改订单状态 * @param $orderNo string 订单编号 * @param $admin_id int 管理员ID * @param $note string 收款的备注 * @return false or int order_id */ public static function updateOrderStatus($orderNo, $admin_id = '', $note = '') { //获取订单信息 $orderObj = new IModel('order'); $orderRow = $orderObj->getObj('order_no = "' . $orderNo . '"'); if (empty($orderRow)) { return false; } if ($orderRow['pay_status'] == 1) { return $orderRow['id']; } else { if ($orderRow['pay_status'] == 0) { $dataArray = array('status' => 2, 'pay_time' => ITime::getDateTime(), 'pay_status' => 1); $orderObj->setData($dataArray); $is_success = $orderObj->update('order_no = "' . $orderNo . '"'); if ($is_success == '') { return false; } //删除订单中使用的道具 $ticket_id = trim($orderRow['prop']); if ($ticket_id != '') { $propObj = new IModel('prop'); $propData = array('is_userd' => 1); $propObj->setData($propData); $propObj->update('id = ' . $ticket_id); } if (intval($orderRow['user_id']) != 0) { $user_id = $orderRow['user_id']; //获取用户信息 $memberObj = new IModel('member'); $memberRow = $memberObj->getObj('user_id = ' . $user_id, 'prop,group_id'); //(1)删除订单中使用的道具 if ($ticket_id != '') { $finnalTicket = str_replace(',' . $ticket_id . ',', ',', ',' . trim($memberRow['prop'], ',') . ','); $memberData = array('prop' => $finnalTicket); $memberObj->setData($memberData); $memberObj->update('user_id = ' . $user_id); } if ($memberRow) { //(2)进行促销活动奖励 $proObj = new ProRule($orderRow['real_amount']); $proObj->setUserGroup($memberRow['group_id']); $proObj->setAward($user_id); //(3)增加经验值 $memberData = array('exp' => 'exp + ' . $orderRow['exp']); $memberObj->setData($memberData); $memberObj->update('user_id = ' . $user_id, 'exp'); //(4)增加积分 $pointConfig = array('user_id' => $user_id, 'point' => $orderRow['point'], 'log' => '成功购买了订单号:' . $orderRow['order_no'] . '中的商品,奖励积分' . $orderRow['point']); $pointObj = new Point(); $pointObj->update($pointConfig); } } //插入收款单 $collectionDocObj = new IModel('collection_doc'); $collectionData = array('order_id' => $orderRow['id'], 'user_id' => $orderRow['user_id'], 'amount' => $orderRow['order_amount'], 'time' => ITime::getDateTime(), 'payment_id' => $orderRow['pay_type'], 'pay_status' => 1, 'if_del' => 0, 'note' => $note, 'admin_id' => $admin_id ? $admin_id : 0); $collectionDocObj->setData($collectionData); $collectionDocObj->add(); /*同步数据*/ //同步团购的数据 if ($orderRow['type'] == 1) { $regimentUserObj = new IModel('regiment_user_relation'); $regimentUserObj->setData(array('is_over' => 1)); $regimentUserObj->update("order_no = '" . $orderRow['order_no'] . "'"); } //更改购买商品的库存数量 self::updateStore($orderRow['id'], 'reduce'); return $orderRow['id']; } else { return false; } } }
/** * @brief 商户的增加动作 */ public function seller_add() { $seller_id = IFilter::act(IReq::get('id'), 'int'); $seller_name = IFilter::act(IReq::get('seller_name')); $email = IFilter::act(IReq::get('email')); $password = IFilter::act(IReq::get('password')); $repassword = IFilter::act(IReq::get('repassword')); $truename = IFilter::act(IReq::get('true_name')); $phone = IFilter::act(IReq::get('phone')); $mobile = IFilter::act(IReq::get('mobile')); $province = IFilter::act(IReq::get('province'), 'int'); $city = IFilter::act(IReq::get('city'), 'int'); $area = IFilter::act(IReq::get('area'), 'int'); $cash = IFilter::act(IReq::get('cash'), 'float'); $is_vip = IFilter::act(IReq::get('is_vip'), 'int'); $is_lock = IFilter::act(IReq::get('is_lock'), 'int'); $address = IFilter::act(IReq::get('address')); $account = IFilter::act(IReq::get('account')); $server_num = IFilter::act(IReq::get('server_num')); $home_url = IFilter::act(IReq::get('home_url')); $sort = IFilter::act(IReq::get('sort'), 'int'); if (!$seller_id && $password == '') { $errorMsg = '请输入密码!'; } if ($password != $repassword) { $errorMsg = '两次输入的密码不一致!'; } //创建商家操作类 $sellerDB = new IModel("seller"); if ($sellerDB->getObj("seller_name = '{$seller_name}' and id != {$seller_id}")) { $errorMsg = "登录用户名重复"; } else { if ($sellerDB->getObj("true_name = '{$truename}' and id != {$seller_id}")) { $errorMsg = "商户真实全程重复"; } } //操作失败表单回填 if (isset($errorMsg)) { $this->sellerRow = $_POST; $this->redirect('seller_edit', false); Util::showMessage($errorMsg); } //待更新的数据 $sellerRow = array('true_name' => $truename, 'account' => $account, 'phone' => $phone, 'mobile' => $mobile, 'email' => $email, 'address' => $address, 'is_vip' => $is_vip, 'is_lock' => $is_lock, 'cash' => $cash, 'province' => $province, 'city' => $city, 'area' => $area, 'server_num' => $server_num, 'home_url' => $home_url, 'sort' => $sort); //商户资质上传 if (isset($_FILES['paper_img']['name']) && $_FILES['paper_img']['name']) { $uploadObj = new PhotoUpload(); $uploadObj->setIterance(false); $photoInfo = $uploadObj->run(); if (isset($photoInfo['paper_img']['img']) && file_exists($photoInfo['paper_img']['img'])) { $sellerRow['paper_img'] = $photoInfo['paper_img']['img']; } } //添加新会员 if (!$seller_id) { $sellerRow['seller_name'] = $seller_name; $sellerRow['password'] = md5($password); $sellerRow['create_time'] = ITime::getDateTime(); $sellerDB->setData($sellerRow); $sellerDB->add(); } else { //修改密码 if ($password) { $sellerRow['password'] = md5($password); } $sellerDB->setData($sellerRow); $sellerDB->update("id = " . $seller_id); } $this->redirect('seller_list'); }
/** * @brief 登录后的处理 * @param array $userRow 用户数组信息 */ public static function loginAfter($userRow) { //用户私密数据 ISafe::set('user_id', $userRow['id']); ISafe::set('username', $userRow['username']); ISafe::set('head_ico', $userRow['head_ico']); ISafe::set('user_pwd', $userRow['password']); ISafe::set('last_login', isset($userRow['last_login']) ? $userRow['last_login'] : ''); //更新最后一次登录时间 $memberObj = new IModel('member'); $dataArray = array('last_login' => ITime::getDateTime()); $memberObj->setData($dataArray); $where = 'user_id = ' . $userRow["id"]; $memberObj->update($where); $memberRow = $memberObj->getObj($where, 'exp'); //根据经验值分会员组 $groupObj = new IModel('user_group'); $groupRow = $groupObj->getObj($memberRow['exp'] . ' between minexp and maxexp and minexp > 0 and maxexp > 0', 'id', 'discount', 'desc'); if (!empty($groupRow)) { $dataArray = array('group_id' => $groupRow['id']); $memberObj->setData($dataArray); $memberObj->update('user_id = ' . $userRow["id"]); } }
/** * @brief 商品上下架 */ function goods_stats() { //post数据 $id = IFilter::act(IReq::get('id'), 'int'); $type = IFilter::act(IReq::get('type')); //生成goods对象 $tb_goods = new IModel('goods'); if ($type == 'up') { $updateData = array('is_del' => 0, 'up_time' => ITime::getDateTime(), 'down_time' => null); } else { if ($type == 'down') { $updateData = array('is_del' => 2, 'up_time' => null, 'down_time' => ITime::getDateTime()); } else { if ($type == 'check') { $updateData = array('is_del' => 3, 'up_time' => null, 'down_time' => null); } } } $tb_goods->setData($updateData); if ($id) { $tb_goods->update(Util::joinStr($id)); } else { Util::showMessage('请选择要操作的数据'); } if (IClient::isAjax() == false) { $this->redirect("goods_list"); } }
/** * @brief 完成或作废订单页面 **/ public function order_complete() { //去掉左侧菜单和上部导航 $this->layout = ''; $order_id = IFilter::act(IReq::get('id'), 'int'); $type = IFilter::act(IReq::get('type'), 'int'); $order_no = IFilter::act(IReq::get('order_no')); //oerder表的对象 $tb_order = new IModel('order'); $tb_order->setData(array('status' => $type, 'completion_time' => ITime::getDateTime())); $tb_order->update('id=' . $order_id); //生成订单日志 $tb_order_log = new IModel('order_log'); $action = '作废'; $note = '订单【' . $order_no . '】作废成功'; if ($type == '5') { $action = '完成'; $note = '订单【' . $order_no . '】完成成功'; //完成订单并且进行支付 Order_Class::updateOrderStatus($order_no); //增加用户评论商品机会 Order_Class::addGoodsCommentChange($order_id); $logObj = new log('db'); $logObj->write('operation', array("管理员:" . ISafe::get('admin_name'), "订单更新为完成", '订单号:' . $order_no)); } else { Order_class::resetOrderProp($order_id); $logObj = new log('db'); $logObj->write('operation', array("管理员:" . ISafe::get('admin_name'), "订单更新为作废", '订单号:' . $order_no)); } $tb_order_log->setData(array('order_id' => $order_id, 'user' => $this->admin['admin_name'], 'action' => $action, 'result' => '成功', 'note' => $note, 'addtime' => ITime::getDateTime())); $tb_order_log->add(); die('success'); }
/** * @brief 订单退款操作 * @param int $refundId 退款单ID * @param int $authorId 操作人ID * @param string $type admin:管理员;seller:商家 * @param int $isNotBalance 是否充值到余额, 0:退款余额; 1:不退款到余额 * @return */ public static function refund($refundId, $authorId, $type = 'admin', $isNotBalance = 0) { $orderGoodsDB = new IModel('order_goods'); $refundDB = new IModel('refundment_doc'); //获取goods_id和product_id用于给用户减积分,经验 $refundsRow = $refundDB->getObj('id = ' . $refundId); $order_id = $refundsRow['order_id']; $order_no = $refundsRow['order_no']; $user_id = $refundsRow['user_id']; $orderGoodsRow = $orderGoodsDB->getObj('order_id = ' . $order_id . ' and goods_id = ' . $refundsRow['goods_id'] . ' and product_id = ' . $refundsRow['product_id'] . ' and is_send != 2'); if (!$orderGoodsRow) { return false; } $order_goods_id = $orderGoodsRow['id']; //如果管理员(商家)自定义了退款金额。否则就使用默认的付款商品金额 $amount = $refundsRow['amount'] > 0 ? $refundsRow['amount'] : $orderGoodsRow['goods_nums'] * $orderGoodsRow['real_price']; //库存增加 self::updateStore($order_goods_id, 'add'); //更新退款状态 $orderGoodsDB->setData(array('is_send' => 2)); $orderGoodsDB->update('id = ' . $order_goods_id); //更新order表状态 $isSendData = $orderGoodsDB->getObj('order_id = ' . $order_id . ' and is_send != 2'); $orderStatus = 6; //全部退款 if ($isSendData) { $orderStatus = 7; //部分退款 } $tb_order = new IModel('order'); $tb_order->setData(array('status' => $orderStatus)); $tb_order->update('id=' . $order_id); /** * 进行用户的余额增加操作,积分,经验的减少操作, * 1,当全部退款时候,减少订单中记录的积分和经验;且如果没有发货的商品直接退回订单中的运费,报价,税金等 * 2,当部分退款时候,查询商品表中积分和经验 */ if ($orderStatus == 6) { Order_class::resetOrderProp($order_id); $orderRow = $tb_order->getObj('id = ' . $order_id); //是否返还运费,报价,税金 $isDeliveryData = $orderGoodsDB->getObj('order_id = ' . $order_id . ' and delivery_id > 0'); if (!$isDeliveryData) { $amount += $orderRow['real_freight'] + $orderRow['insured'] + $orderRow['taxes']; } } //退款积分,经验 $goodsDB = new IModel('goods'); $goodsRow = $goodsDB->getObj('id = ' . $orderGoodsRow['goods_id']); $orderRow = array('exp' => $goodsRow['exp'] * $orderGoodsRow['goods_nums'], 'point' => $goodsRow['point'] * $orderGoodsRow['goods_nums'], 'order_no' => $order_no); //更新退款表 $updateData = array('amount' => $amount, 'pay_status' => 2, 'dispose_time' => ITime::getDateTime()); $refundDB->setData($updateData); $refundDB->update('id = ' . $refundId); //更新用户的信息 $obj = new IModel('member'); $memberObj = $obj->getObj('user_id = ' . $user_id, 'exp,point'); $exp = $memberObj['exp'] - $orderRow['exp']; $obj->setData(array('exp' => $exp <= 0 ? 0 : $exp)); $obj->update('user_id = ' . $user_id); //积分记录日志 $pointConfig = array('user_id' => $user_id, 'point' => '-' . $orderRow['point'], 'log' => '退款订单号:' . $orderRow['order_no'] . '中的商品,减掉积分 -' . $orderRow['point']); $pointObj = new Point(); $pointObj->update($pointConfig); //用户余额进行的操作记入account_log表 $log = new AccountLog(); $config = array('user_id' => $user_id, 'event' => 'drawback', 'num' => $amount, 'order_no' => $order_no); if ($type == 'admin') { $config['admin_id'] = $authorId; $adminObj = new IModel('admin'); $adminRow = $adminObj->getObj('id = ' . $authorId); $authorName = $adminRow['admin_name']; } else { if ($type == 'seller') { $config['seller_id'] = $authorId; $sellerObj = new IModel('seller'); $sellerRow = $sellerObj->getObj('id = ' . $authorId); $authorName = $sellerRow['seller_name']; } } //生成订单日志 $tb_order_log = new IModel('order_log'); $tb_order_log->setData(array('order_id' => $order_id, 'user' => $authorName, 'action' => '退款', 'result' => '成功', 'note' => '订单【' . $order_no . '】退款,退款金额:¥' . $amount, 'addtime' => ITime::getDateTime())); $tb_order_log->add(); return $isNotBalance == 0 ? $log->write($config) : true; }
/** * @brief 开始执行上传 * @return array 包含上传成功信息的数组 * $file = array( * name 如果上传成功,则返回上传后的文件名称,如果失败,则返回客户端名称 * size 上传附件大小 * fileSrc 上传文件完整路径 * dir 上传目录 * ininame 上传图片名 * flag -1:文件类型不允许; -2:文件大小超出限制; 1:上传成功 * ext 上传附件扩展名 * ); */ public function execute() { //总的文件上传信息 $info = array(); foreach ($_FILES as $field => $file) { $fileInfo = array(); //不存在上传的文件名 if (!isset($_FILES[$field]['name']) || $_FILES[$field]['name'] == '' || !isset($_FILES[$field]['tmp_name'])) { continue; } //上传控件为数组格式 file[]格式 if (is_array($_FILES[$field]['name'])) { $keys = array_keys($_FILES[$field]['name']); foreach ($keys as $key) { if (!isset($_FILES[$field]['name'][$key]) || $_FILES[$field]['name'][$key] == '') { continue; } //获取扩展名 $fileext = IFile::getFileType($_FILES[$field]['tmp_name'][$key]); if (is_array($fileext) || $fileext == null) { $fileext = IFile::getFileSuffix($_FILES[$field]['name'][$key]); } /*开始上传文件*/ //(1)上传类型不符合 if (!in_array($fileext, $this->allowType)) { $fileInfo[$key]['name'] = $_FILES[$field]['name'][$key]; $fileInfo[$key]['flag'] = -1; } else { if ($_FILES[$field]['size'][$key] > $this->maxsize) { $fileInfo[$key]['name'] = $_FILES[$field]['name'][$key]; $fileInfo[$key]['flag'] = -2; } else { //修改图片状态值 $fileInfo[$key]['name'] = ITime::getDateTime('Ymdhis') . mt_rand(100, 999) . '.' . $fileext; $fileInfo[$key]['dir'] = $this->dir; $fileInfo[$key]['size'] = $_FILES[$field]['size'][$key]; $fileInfo[$key]['ininame'] = $_FILES[$field]['name'][$key]; $fileInfo[$key]['ext'] = $fileext; $fileInfo[$key]['fileSrc'] = $fileInfo[$key]['dir'] . $fileInfo[$key]['name']; if (is_uploaded_file($_FILES[$field]['tmp_name'][$key])) { if (move_uploaded_file($_FILES[$field]['tmp_name'][$key], $this->dir . $fileInfo[$key]['name'])) { if (file_exists($_FILES[$field]['tmp_name'][$key])) { IFile::unlink($_FILES[$field]['tmp_name'][$key]); } $fileInfo[$key]['flag'] = 1; } } } } } } else { if ($_FILES[$field]['name'] == '' || $_FILES[$field]['tmp_name'] == '') { continue; } //获取扩展名 $fileext = IFile::getFileType($_FILES[$field]['tmp_name']); if (is_array($fileext) || $fileext == null) { $fileext = IFile::getFileSuffix($_FILES[$field]['name']); } /*开始上传文件*/ //(1)上传类型不符合 if (!in_array($fileext, $this->allowType)) { $fileInfo[0]['name'] = $_FILES[$field]['name']; $fileInfo[0]['flag'] = -1; } else { if ($_FILES[$field]['size'] > $this->maxsize) { $fileInfo[0]['name'] = $_FILES[$field]['name']; $fileInfo[0]['flag'] = -2; } else { //修改图片状态值 $fileInfo[0]['name'] = ITime::getDateTime('Ymdhis') . mt_rand(100, 999) . '.' . $fileext; $fileInfo[0]['dir'] = $this->dir; $fileInfo[0]['size'] = $_FILES[$field]['size']; $fileInfo[0]['ininame'] = $_FILES[$field]['name']; $fileInfo[0]['ext'] = $fileext; $fileInfo[0]['fileSrc'] = $fileInfo[0]['dir'] . $fileInfo[0]['name']; if (is_uploaded_file($_FILES[$field]['tmp_name'])) { if (move_uploaded_file($_FILES[$field]['tmp_name'], $this->dir . $fileInfo[0]['name'])) { if (file_exists($_FILES[$field]['tmp_name'])) { IFile::unlink($_FILES[$field]['tmp_name']); } $fileInfo[0]['flag'] = 1; } } } } } $info[$field] = $fileInfo; } return $info; }
function refundment_update() { $id = IFilter::act(IReq::get('id'), 'int'); $pay_status = IFilter::act(IReq::get('pay_status'), 'int'); $dispose_idea = IFilter::act(IReq::get('dispose_idea')); //商户处理退款 if ($id && Order_Class::isSellerRefund($id, $this->seller['seller_id']) == 2) { $tb_refundment_doc = new IModel('refundment_doc'); $updateData = array('dispose_time' => ITime::getDateTime(), 'dispose_idea' => $dispose_idea, 'pay_status' => $pay_status); $tb_refundment_doc->setData($updateData); $tb_refundment_doc->update('id = ' . $id); if ($pay_status == 2) { $result = Order_Class::refund($id, $this->seller['seller_id'], 'seller'); if (!$result) { die('退款失败'); } } } $this->redirect('refundment_list'); }
function article_edit_act() { $id = intval(IReq::get('id', 'post')); $articleObj = new IModel('article'); $DataArray = array('title' => IFilter::act(IReq::get('title', 'post')), 'content' => IFilter::act(IReq::get('content', 'post'), 'text'), 'category_id' => IFilter::act(IReq::get('category_id', 'post'), 'int'), 'create_time' => ITime::getDateTime(), 'keywords' => IFilter::act(IReq::get('keywords', 'post')), 'description' => IFilter::act(IReq::get('description', 'post'), 'text'), 'visibility' => IFilter::act(IReq::get('visibility', 'post'), 'int'), 'top' => IFilter::act(IReq::get('top', 'post'), 'int'), 'sort' => IFilter::act(IReq::get('sort', 'post'), 'int'), 'style' => IFilter::act(IReq::get('style', 'post')), 'color' => IFilter::act(IReq::get('color', 'post'))); //检查catid是否为空 if ($DataArray['category_id'] == 0) { $this->articleRow = $DataArray; $this->redirect('article_edit', false); Util::showMessage('请选择分类'); } $articleObj->setData($DataArray); if ($id) { //开始更新操作 $where = 'id = ' . $id; $is_success = $articleObj->update($where); } else { $id = $articleObj->add(); $is_success = $id ? true : false; } if ($is_success) { /*article关联商品操作*/ //获取新 article关联goods ID $newGoodsIdArray = array(); $goodsIdStr = IFilter::act(IReq::get('relation_goods', 'post')); if ($goodsIdStr != null) { $newGoodsIdArray = explode(',', $goodsIdStr); } $ralationObj = new IModel('relation'); $where = 'article_id = ' . $id; $ralationObj->del($where); if (!empty($newGoodsIdArray)) { foreach ($newGoodsIdArray as $rs) { $reData = array('goods_id' => $rs, 'article_id' => $id); $ralationObj->setData($reData); $ralationObj->add(); } } } else { $this->articleRow = $DataArray; $this->redirect('article_edit', false); Util::showMessage('插入数据时发生错误'); } $this->redirect('article_list'); }
function ad_list() { $data = array('flag' => false, 'data' => ''); $id = IReq::get('id'); if ($id === null) { die(JSON::encode($data)); } $id = intval($id); $now = date("Y-m-d H:i:s", ITime::getNow()); $tb = new IModel("ad_manage"); $re = $tb->query("position_id={$id} AND start_time < '{$now}' AND end_time > '{$now}' ORDER BY `order` ASC "); if (!$re) { echo JSON::encode($data); die; } $data['flag'] = true; $data['data'] = $re; echo JSON::encode($data); die; }
/** * @brief 开始执行上传 * @return array 包含上传成功信息的数组 * $file = array( * name 如果上传成功,则返回上传后的文件名称,如果失败,则返回客户端名称 * size 上传附件大小 * fileSrc 上传文件完整路径 * dir 上传目录 * ininame 上传图片名 * flag -1:上传的文件超出服务器限制; -2:上传的文件超出浏览器限制; -3:上传的文件被部分上传; -4:没有找到上传的文件; -5:上传的文件丢失; * -6:上传的临时文件没有正确写入; -7:扩展名不允许上传; -8:上传的文件超出了程序的限制; -9:上传的文件中有木马病毒 ; 1:上传成功; * ext 上传附件扩展名 * ); */ public function execute() { //总的文件上传信息 $info = array(); foreach ($_FILES as $field => $file) { $fileInfo = array(); //不存在上传的文件名 if (!isset($_FILES[$field]['name']) || $_FILES[$field]['name'] == '') { continue; } //上传控件为数组格式 file[]格式 if (is_array($_FILES[$field]['name'])) { $keys = array_keys($_FILES[$field]['name']); foreach ($keys as $key) { $fileInfo[$key]['name'] = $_FILES[$field]['name'][$key]; //上传出现错误 if (isset($_FILES[$field]['error'][$key]) && $_FILES[$field]['error'][$key] != 0) { $fileInfo[$key]['flag'] = 0 - $_FILES[$field]['error'][$key]; } else { //获取扩展名 $fileext = IFile::getFileType($_FILES[$field]['tmp_name'][$key]); if (is_array($fileext) || $fileext == null) { $fileext = IFile::getFileSuffix($_FILES[$field]['name'][$key]); } //图片木马检测 if (in_array($fileext, $this->checkType) && !IFilter::checkHex($_FILES[$field]['tmp_name'][$key])) { $fileInfo[$key]['flag'] = -9; } else { /*开始上传文件*/ //(1)上传类型不符合 if (!in_array($fileext, $this->allowType)) { $fileInfo[$key]['flag'] = -7; } else { if ($_FILES[$field]['size'][$key] > $this->maxsize) { $fileInfo[$key]['flag'] = -8; } else { //修改图片状态值 $fileInfo[$key]['name'] = ITime::getDateTime('Ymdhis') . mt_rand(100, 999) . '.' . $fileext; $fileInfo[$key]['dir'] = $this->dir; $fileInfo[$key]['size'] = $_FILES[$field]['size'][$key]; $fileInfo[$key]['ininame'] = $_FILES[$field]['name'][$key]; $fileInfo[$key]['ext'] = $fileext; $fileInfo[$key]['fileSrc'] = $fileInfo[$key]['dir'] . $fileInfo[$key]['name']; $fileInfo[$key]['flag'] = 1; if ($this->isForge == false) { if (is_uploaded_file($_FILES[$field]['tmp_name'][$key])) { IFile::mkdir($this->dir); move_uploaded_file($_FILES[$field]['tmp_name'][$key], $this->dir . $fileInfo[$key]['name']); } } else { IFile::xcopy($_FILES[$field]['tmp_name'][$key], $this->dir . $fileInfo[$key]['name']); } } } } } } } else { $fileInfo[0]['name'] = $_FILES[$field]['name']; //上传出现错误 if (isset($_FILES[$field]['error']) && $_FILES[$field]['error'] != 0) { $fileInfo[0]['flag'] = 0 - $_FILES[$field]['error']; } else { //获取扩展名 $fileext = IFile::getFileType($_FILES[$field]['tmp_name']); if (is_array($fileext) || $fileext == null) { $fileext = IFile::getFileSuffix($_FILES[$field]['name']); } //图片木马检测 if (in_array($fileext, $this->checkType) && !IFilter::checkHex($_FILES[$field]['tmp_name'])) { $fileInfo[0]['flag'] = -9; } else { /*开始上传文件*/ //(1)上传类型不符合 if (!in_array($fileext, $this->allowType)) { $fileInfo[0]['flag'] = -7; } else { if ($_FILES[$field]['size'] > $this->maxsize) { $fileInfo[0]['flag'] = -8; } else { //修改图片状态值 $fileInfo[0]['name'] = ITime::getDateTime('YmdHis') . mt_rand(100, 999) . '.' . $fileext; $fileInfo[0]['dir'] = $this->dir; $fileInfo[0]['size'] = $_FILES[$field]['size']; $fileInfo[0]['ininame'] = $_FILES[$field]['name']; $fileInfo[0]['ext'] = $fileext; $fileInfo[0]['fileSrc'] = $fileInfo[0]['dir'] . $fileInfo[0]['name']; $fileInfo[0]['flag'] = 1; if ($this->isForge == false) { if (is_uploaded_file($_FILES[$field]['tmp_name'])) { IFile::mkdir($this->dir); move_uploaded_file($_FILES[$field]['tmp_name'], $this->dir . $fileInfo[0]['name']); } } else { IFile::xcopy($_FILES[$field]['tmp_name'], $this->dir . $fileInfo[0]['name']); } } } } } } $info[$field] = $fileInfo; } return $info; }
if ($promo == 'groupon') { ?> <?php if (isset($regiment)) { ?> <!--团购正常--> <li class="current"> <span class="bold red2">团购价:</span><b class="price red2"><span class="f30">¥</span><?php echo isset($regiment['regiment_price']) ? $regiment['regiment_price'] : ""; ?> </b> <?php $item = Api::run('getRegimentRowById', array('#id#', $active_id)); ?> <?php $free_time = ITime::getDiffSec($item['end_time']); ?> <span class="time" id="promotionb">还剩 <i class="bold red2" id='cd_hour_promotionb'><?php echo floor($free_time / 3600); ?> </i>小时<i class="bold red2" id='cd_minute_promotionb'><?php echo floor($free_time % 3600 / 60); ?> </i>分<i class="bold red2" id='cd_second_promotionb'><?php echo $free_time % 60; ?> </i>秒结束</span> </li> <li> 销售价:<span class="price light_gray"><s class="f30">¥<label id="data_sellPrice"><?php echo isset($sell_price) ? $sell_price : "";
function trade_ticket() { $ticketId = IFilter::act(IReq::get('ticket_id', 'post'), 'int'); $message = ''; if (intval($ticketId) == 0) { $message = '请选择要兑换的代金券'; } else { $nowTime = ITime::getDateTime(); $ticketObj = new IModel('ticket'); $ticketRow = $ticketObj->getObj('id = ' . $ticketId . ' and point > 0 and start_time <= "' . $nowTime . '" and end_time > "' . $nowTime . '"'); if (empty($ticketRow)) { $message = '对不起,此代金券不能兑换'; } else { $memberObj = new IModel('member'); $where = 'user_id = ' . $this->user['user_id']; $memberRow = $memberObj->getObj($where, 'point'); if ($ticketRow['point'] > $memberRow['point']) { $message = '对不起,您的积分不足,不能兑换此类代金券'; } else { //生成红包 $dataArray = array('condition' => $ticketRow['id'], 'name' => $ticketRow['name'], 'card_name' => 'T' . IHash::random(8), 'card_pwd' => IHash::random(8), 'value' => $ticketRow['value'], 'start_time' => $ticketRow['start_time'], 'end_time' => $ticketRow['end_time'], 'is_send' => 1); $propObj = new IModel('prop'); $propObj->setData($dataArray); $insert_id = $propObj->add(); //用户prop字段值null时 $memberArray = array('prop' => ',' . $insert_id . ','); $memberObj->setData($memberArray); $result = $memberObj->update('user_id = ' . $this->user["user_id"] . ' and ( prop is NULL or prop = "" )'); //用户prop字段值非null时 if (!$result) { $memberArray = array('prop' => 'concat(prop,"' . $insert_id . ',")'); $memberObj->setData($memberArray); $result = $memberObj->update('user_id = ' . $this->user["user_id"], 'prop'); } //代金券成功 if ($result) { $pointConfig = array('user_id' => $this->user['user_id'], 'point' => '-' . $ticketRow['point'], 'log' => '积分兑换代金券,扣除了 -' . $ticketRow['point'] . '积分'); $pointObj = new Point(); $pointObj->update($pointConfig); } } } } //展示 if ($message != '') { $this->integral(); Util::showMessage($message); } else { $this->redirect('redpacket'); } }
/** * @brief 修改商品数据 * @param int $id 商品ID * @param array $paramData 商品所需数据 */ public function update($id, $paramData) { $postData = array(); $nowDataTime = ITime::getDateTime(); foreach ($paramData as $key => $val) { $postData[$key] = $val; //数据过滤分组 if (strpos($key, 'attr_id_') !== false) { $goodsAttrData[ltrim($key, 'attr_id_')] = IFilter::act($val); } else { if ($key == 'content') { $goodsUpdateData['content'] = IFilter::addSlash($val); } else { if ($key[0] != '_') { $goodsUpdateData[$key] = IFilter::act($val, 'text'); } } } } //商家发布商品默认设置 if ($this->seller_id) { $goodsUpdateData['seller_id'] = $this->seller_id; $goodsUpdateData['is_del'] = $goodsUpdateData['is_del'] == 2 ? 2 : 3; //如果商户是VIP则无需审核商品 if ($goodsUpdateData['is_del'] == 3) { $sellerDB = new IModel('seller'); $sellerRow = $sellerDB->getObj('id = ' . $this->seller_id); if ($sellerRow['is_vip'] == 1) { $goodsUpdateData['is_del'] = 0; } } } //上架或者下架处理 if (isset($goodsUpdateData['is_del'])) { //上架 if ($goodsUpdateData['is_del'] == 0) { $goodsUpdateData['up_time'] = $nowDataTime; $goodsUpdateData['down_time'] = null; } else { if ($goodsUpdateData['is_del'] == 2) { $goodsUpdateData['up_time'] = null; $goodsUpdateData['down_time'] = $nowDataTime; } else { $goodsUpdateData['up_time'] = null; $goodsUpdateData['down_time'] = null; } } } //是否存在货品 $goodsUpdateData['spec_array'] = ''; if (isset($postData['_spec_array'])) { //生成goods中的spec_array字段数据 $goods_spec_array = array(); foreach ($postData['_spec_array'] as $key => $val) { foreach ($val as $v) { $tempSpec = JSON::decode($v); if (!isset($goods_spec_array[$tempSpec['id']])) { $goods_spec_array[$tempSpec['id']] = array('id' => $tempSpec['id'], 'name' => $tempSpec['name'], 'type' => $tempSpec['type'], 'value' => array()); } $goods_spec_array[$tempSpec['id']]['value'][] = $tempSpec['value']; } } foreach ($goods_spec_array as $key => $val) { $val['value'] = array_unique($val['value']); $goods_spec_array[$key]['value'] = join(',', $val['value']); } $goodsUpdateData['spec_array'] = JSON::encode($goods_spec_array); } $goodsUpdateData['goods_no'] = isset($postData['_goods_no']) ? current($postData['_goods_no']) : ''; $goodsUpdateData['store_nums'] = array_sum($postData['_store_nums']); $goodsUpdateData['market_price'] = isset($postData['_market_price']) ? current($postData['_market_price']) : 0; $goodsUpdateData['sell_price'] = isset($postData['_sell_price']) ? current($postData['_sell_price']) : 0; $goodsUpdateData['cost_price'] = isset($postData['_cost_price']) ? current($postData['_cost_price']) : 0; $goodsUpdateData['weight'] = isset($postData['_weight']) ? current($postData['_weight']) : 0; //处理商品 $goodsDB = new IModel('goods'); if ($id) { $goodsDB->setData($goodsUpdateData); $where = " id = {$id} "; if ($this->seller_id) { $where .= " and seller_id = " . $this->seller_id; } if ($goodsDB->update($where) === false) { die("更新商品错误"); } } else { $goodsUpdateData['create_time'] = $nowDataTime; $goodsDB->setData($goodsUpdateData); $id = $goodsDB->add(); } //处理商品属性 $goodsAttrDB = new IModel('goods_attribute'); $goodsAttrDB->del('goods_id = ' . $id); if (isset($goodsAttrData) && $goodsAttrData) { foreach ($goodsAttrData as $key => $val) { $attrData = array('goods_id' => $id, 'model_id' => $goodsUpdateData['model_id'], 'attribute_id' => $key, 'attribute_value' => is_array($val) ? join(',', $val) : $val); $goodsAttrDB->setData($attrData); $goodsAttrDB->add(); } } //是否存在货品 $productsDB = new IModel('products'); $productsDB->del('goods_id = ' . $id); if (isset($postData['_spec_array'])) { $productIdArray = array(); //创建货品信息 foreach ($postData['_goods_no'] as $key => $rs) { $productsData = array('goods_id' => $id, 'products_no' => $postData['_goods_no'][$key], 'store_nums' => $postData['_store_nums'][$key], 'market_price' => $postData['_market_price'][$key], 'sell_price' => $postData['_sell_price'][$key], 'cost_price' => $postData['_cost_price'][$key], 'weight' => $postData['_weight'][$key], 'spec_array' => "[" . join(',', $postData['_spec_array'][$key]) . "]"); $productsDB->setData($productsData); $productIdArray[$key] = $productsDB->add(); } } //处理商品分类 $categoryDB = new IModel('category_extend'); $categoryDB->del('goods_id = ' . $id); if (isset($postData['_goods_category']) && $postData['_goods_category']) { foreach ($postData['_goods_category'] as $item) { $categoryDB->setData(array('goods_id' => $id, 'category_id' => $item)); $categoryDB->add(); } } //处理商品促销 $commendDB = new IModel('commend_goods'); $commendDB->del('goods_id = ' . $id); if (isset($postData['_goods_commend']) && $postData['_goods_commend']) { foreach ($postData['_goods_commend'] as $item) { $commendDB->setData(array('goods_id' => $id, 'commend_id' => $item)); $commendDB->add(); } } //处理商品关键词 keywords::add($goodsUpdateData['search_words']); //处理商品图片 $photoRelationDB = new IModel('goods_photo_relation'); $photoRelationDB->del('goods_id = ' . $id); if (isset($postData['_imgList']) && $postData['_imgList']) { $postData['_imgList'] = str_replace(',', '","', trim($postData['_imgList'], ',')); $photoDB = new IModel('goods_photo'); $photoData = $photoDB->query('img in ("' . $postData['_imgList'] . '")', 'id'); if ($photoData) { foreach ($photoData as $item) { $photoRelationDB->setData(array('goods_id' => $id, 'photo_id' => $item['id'])); $photoRelationDB->add(); } } } //处理会员组的价格 $groupPriceDB = new IModel('group_price'); $groupPriceDB->del('goods_id = ' . $id); if (isset($productIdArray) && $productIdArray) { foreach ($productIdArray as $index => $value) { if (isset($postData['_groupPrice'][$index]) && $postData['_groupPrice'][$index]) { $temp = JSON::decode($postData['_groupPrice'][$index]); foreach ($temp as $k => $v) { $groupPriceDB->setData(array('goods_id' => $id, 'product_id' => $value, 'group_id' => $k, 'price' => $v)); $groupPriceDB->add(); } } } } else { if (isset($postData['_groupPrice'][0]) && $postData['_groupPrice'][0]) { $temp = JSON::decode($postData['_groupPrice'][0]); foreach ($temp as $k => $v) { $groupPriceDB->setData(array('goods_id' => $id, 'group_id' => $k, 'price' => $v)); $groupPriceDB->add(); } } } return true; }
/** * @brief 商户的增加动作 */ public function seller_reg() { $seller_name = IFilter::act(IReq::get('seller_name')); $email = IFilter::act(IReq::get('email')); $password = IFilter::act(IReq::get('password')); $repassword = IFilter::act(IReq::get('repassword')); $truename = IFilter::act(IReq::get('true_name')); $phone = IFilter::act(IReq::get('phone')); $mobile = IFilter::act(IReq::get('mobile')); $province = IFilter::act(IReq::get('province'), 'int'); $city = IFilter::act(IReq::get('city'), 'int'); $area = IFilter::act(IReq::get('area'), 'int'); $address = IFilter::act(IReq::get('address')); $home_url = IFilter::act(IReq::get('home_url')); if ($password == '') { $errorMsg = '请输入密码!'; } if ($password != $repassword) { $errorMsg = '两次输入的密码不一致!'; } //创建商家操作类 $sellerDB = new IModel("seller"); if ($sellerDB->getObj("seller_name = '{$seller_name}'")) { $errorMsg = "登录用户名重复"; } else { if ($sellerDB->getObj("true_name = '{$truename}'")) { $errorMsg = "商户真实全称重复"; } } //操作失败表单回填 if (isset($errorMsg)) { $this->sellerRow = $_POST; $this->redirect('seller', false); Util::showMessage($errorMsg); } //待更新的数据 $sellerRow = array('true_name' => $truename, 'phone' => $phone, 'mobile' => $mobile, 'email' => $email, 'address' => $address, 'province' => $province, 'city' => $city, 'area' => $area, 'home_url' => $home_url, 'is_lock' => 1); //商户资质上传 if (isset($_FILES['paper_img']['name']) && $_FILES['paper_img']['name']) { $uploadObj = new PhotoUpload(); $uploadObj->setIterance(false); $photoInfo = $uploadObj->run(); if (isset($photoInfo['paper_img']['img']) && file_exists($photoInfo['paper_img']['img'])) { $sellerRow['paper_img'] = $photoInfo['paper_img']['img']; } } $sellerRow['seller_name'] = $seller_name; $sellerRow['password'] = md5($password); $sellerRow['create_time'] = ITime::getDateTime(); $sellerDB->setData($sellerRow); $sellerDB->add(); //短信通知商城平台 $siteConfig = new Config('site_config'); if ($siteConfig->mobile) { $content = smsTemplate::sellerReg(array('{true_name}' => $truename)); $result = Hsms::send($mobile, $content); } $this->redirect('/site/success?message=' . urlencode("申请成功!请耐心等待管理员的审核")); }
function admin_edit_act() { $id = IFilter::act(IReq::get('id', 'post')); $adminObj = new IModel('admin'); //错误信息 $message = null; $dataArray = array('id' => $id, 'admin_name' => IFilter::string(IReq::get('admin_name', 'post')), 'role_id' => IFilter::act(IReq::get('role_id', 'post')), 'email' => IFilter::string(IReq::get('email', 'post'))); //检查管理员name唯一性 $isPass = $this->check_admin($dataArray['admin_name'], $id); if ($isPass == false) { $message = $dataArray['admin_name'] . '管理员已经存在,请更改名字'; } //提取密码 [ 密码设置 ] $password = IReq::get('password', 'post'); $repassword = IReq::get('repassword', 'post'); //修改操作 if ($id) { if ($password != null || $repassword != null) { if ($password == null || $repassword == null || $password != $repassword) { $message = '密码不能为空,并且二次输入的必须一致'; } else { $dataArray['password'] = md5($password); } } //有错误 if ($message != null) { $this->adminRow = $dataArray; $this->redirect('admin_edit', false); Util::showMessage($message); } else { $where = 'id = ' . $id; $adminObj->setData($dataArray); $adminObj->update($where); //同步更新safe ISafe::set('admin_name', $dataArray['admin_name']); ISafe::set('admin_pwd', $dataArray['password']); } } else { if ($password == null || $repassword == null || $password != $repassword) { $message = '密码不能为空,并且二次输入的必须一致'; } else { $dataArray['password'] = md5($password); } if ($message != null) { $this->adminRow = $dataArray; $this->redirect('admin_edit', false); Util::showMessage($message); } else { $dataArray['create_time'] = ITime::getDateTime(); $adminObj->setData($dataArray); $adminObj->add(); } } $this->redirect('admin_list'); }
<td>¥<?php echo $item['sell_price'] - $item['regiment_price']; ?> </td> </tr> </tbody> </table> </div> <?php if ($item['store_nums'] > $item['sum_count']) { ?> <div class="orange_box"> <p>团购倒计时:</p> <?php $free_time = strtotime($item['end_time']) - ITime::getNow(); ?> <p class="t_c f14"><span id="cd_hour_<?php echo isset($item['id']) ? $item['id'] : ""; ?> " class="red2 bold"><?php echo floor($free_time / 3600); ?> </span>小时<span id="cd_minute_<?php echo isset($item['id']) ? $item['id'] : ""; ?> " class="red2 bold"><?php echo floor($free_time % 3600 / 60); ?> </span>分钟<span id="cd_second_<?php echo isset($item['id']) ? $item['id'] : "";
/** * @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; }