function up()
 {
     $id = $this->_post('id', 'img_url');
     $ids = $this->_post('ids', 0);
     $dir = $this->_get('path', '');
     if (!checkPath($dir)) {
         $dir = 'user';
     }
     if (isHave($_FILES['upimg']) && !isHave($_FILES['upimg']['error'])) {
         load('upload');
         $myUpload = new Myupload();
         $upload = $myUpload->upload($dir . '/u' . steadmin::$adminInfo['user_id']);
         $upload = parent::_sendImageToYunServer($upload);
         //同步图片到云存储
         if ($upload) {
             if (!$upload[0]) {
                 echo "<script>alert('" . $myUpload->getErrorMsg() . "');history.go(-1);</script>";
                 exit;
             }
             $upload[0]['savepath'] = str_replace('./', '', $upload[0]['savepath']);
             echo "<script>window.parent.document.getElementById('" . $id . "').value='" . $upload[0]['savepath'] . "';\r\n";
             echo "window.location.href='" . U('upload/index', array('id' => $id, 'ids' => $ids, 'path' => $dir)) . "';</script>\r\n";
             exit;
         }
     } else {
         echo "<script>alert('" . $_FILES['upimg']['error'] . "');history.go(-1);</script>";
         exit;
     }
 }
 public function delAdmin($id)
 {
     //获取管理员信息
     $admin = $this->getUserInfoById($id);
     if (!$admin || !isHave($admin['aid'])) {
         return false;
     }
     //需要删除信息的表
     $list = array('access_log' => 'aid', 'access_stat' => 'aid', 'admin' => 'aid', 'admin_count' => 'aid', 'album_setting' => 'aid', 'article' => 'aid', 'article_class' => 'aid', 'notice' => 'aid', 'notice_count' => 'aid', 'weixin_reply' => 'aid', 'weixin_setting' => 'aid');
     foreach ($list as $k => $v) {
         M($k)->delete(array($v => $admin['aid']));
     }
     return true;
 }
 static function getLoginUser($field = '', $auth = '', $saltKey = '')
 {
     if (!self::$userInfo['uid']) {
         if (!$auth && !$saltKey && myCookie('auth') && myCookie('saltkey')) {
             $auth = myCookie('auth');
             $saltKey = myCookie('saltkey');
         }
         if ($auth) {
             $auth = explode("\t", getDecode($auth, self::getAuthKey($saltKey)));
             list($uid, $aid) = empty($auth) || count($auth) < 2 ? array(0, 0) : $auth;
             if ($uid) {
                 self::$userInfo = self::getUserById($uid);
                 if (!self::$userInfo) {
                     showError('抱歉,你的帐号存在异常,无法登陆');
                 }
                 switch (self::$userInfo['status']) {
                     case 0:
                         //异常
                         self::setUserLoginOut();
                         showError('抱歉,你的帐号存在异常,无法登陆');
                         break;
                     case 1:
                         //帐号正常
                         break;
                     case 2:
                         //冻结
                         self::setUserLoginOut();
                         showError('抱歉,你的帐号已被冻结,无法登陆');
                         break;
                     case 3:
                         //取消关注
                         self::setUserLoginOut();
                         break;
                     default:
                         //未知情况
                         self::setUserLoginOut();
                         showError('抱歉,你的帐号存在异常,无法登陆');
                 }
                 //附加登陆来源
                 self::$userInfo['loginFrom'] = isHave($auth[2]) ? $auth[2] : 'wx';
                 if (getUserAgent() == 'weixin' && self::$userInfo['loginFrom'] != 'wx') {
                     self::setUserLoginOut();
                 }
             }
         }
     }
     return $field && isset(self::$userInfo[$field]) ? self::$userInfo[$field] : self::$userInfo;
 }
 public function addphoto($data)
 {
     $objData = array();
     $list = $this->getTableFields();
     //        print_r($list);exit;
     foreach ($list['fields'] as $key => $val) {
         $objData[$key] = isHave($data[$key]) ? $data[$key] : $val['value'];
     }
     $objData['infotime'] = TIME;
     $objData['status'] = 1;
     $objData['real_size'] = $objData['real_size'];
     if (!$objData['real_size'] && $this->isLocationImg($objData['url'])) {
         $objData['real_size'] = abs(filesize(ROOT . $objData['url']));
     }
     return $this->insert($objData);
 }
                </div>
              </div>
              <div class="form-group">
                <label for="" class="col-sm-1 control-label">反馈内容</label>
                <div class="col-lg-5">
                  <pre><?php 
echo $servicelog['servicelog'];
?>
</pre>
                </div>
              </div>
              <div class="form-group">
                <label for="" class="col-sm-1 control-label">附件</label>
                <div class="col-lg-2">
                  <?php 
if (isHave($servicelog['upload'])) {
    ?>
                    <?php 
    if (preg_match('/^.*?\\.(jpg|png|gif|jpeg|bmp|jpe)$/', $servicelog['upload'])) {
        ?>
                      <img src="<?php 
        echo getImgUrl($servicelog['upload']);
        ?>
" />
                    <?php 
    } else {
        ?>
                      <p class="form-control"><a href="<?php 
        echo getImgUrl($servicelog['upload']);
        ?>
"><i class="fa fa-download"></i>
 function saveFeedback()
 {
     if (load('string')) {
         $fb_time = removeXss($this->_post('fbtime', ''));
         $fb_type = strtolower(removeXss($this->_post('fbtype', '')));
         $fb_result = removeXss($this->_post('fbresult', ''));
         $fb_content = trim(removeXss($this->_post('feedbackContent', '')));
         $fb_upload = trim($this->_post('fb_upload', ''));
         $feedbackConfig = C('feedback');
         if (!isHave($feedbackConfig['type']) || !is_array($feedbackConfig['type']) || !isHave($feedbackConfig['maxLen']) || !is_numeric($feedbackConfig['maxLen'])) {
             return $this->JsonReturn('配置信息错误');
         }
         if (!preg_match('/^[_a-z]+$/', $fb_type)) {
             return $this->JsonReturn('反馈类型错误');
         }
         if (!isHave($feedbackConfig['type'][$fb_type])) {
             return $this->JsonReturn('无该反馈类型');
         }
         if (!preg_match('/^[_a-z]+$/', $fb_result)) {
             return $this->JsonReturn('请选择正确的处理结果');
         }
         if (!isHave($feedbackConfig['result'][$fb_result])) {
             return $this->JsonReturn('无该处理结果');
         }
         if (!strtotime($fb_time)) {
             return $this->JsonReturn('时间错误');
         }
         if (strlen($fb_content) <= 0) {
             return $this->JsonReturn('请填写反馈内容,最大长度2000字符');
         }
         if (strlen($fb_content) >= $feedbackConfig['maxLen']) {
             return $this->JsonReturn('反馈内容超出限制');
         }
         /* TODO
          * 对于upload应该怎么样检查
          */
         $feedback = array('worker_uid' => steadmin::$adminInfo['user_id'], 'type' => $feedbackConfig['type'][$fb_type]['id'], 'result' => $feedbackConfig['result'][$fb_result]['id'], 'content' => $fb_content, 'fb_time' => inTime($fb_time), 'fb_upload' => $fb_upload);
         if (D('feedback')->save($feedback)) {
             return $this->JsonReturn('保存成功,可继续添加反馈', null, 1);
         } else {
             return $this->JsonReturn('保存失败');
         }
     } else {
         $this->JsonReturn('加载string函数库时发生了错误');
     }
 }
 function save()
 {
     if (load('string')) {
         $feedback = array();
         $feedback['fb_time'] = $this->_post('fbtime', '');
         $feedback['fb_type'] = $this->_postid('fbtype', 0);
         $feedback['fb_status'] = $this->_postid('fbstatus', 0);
         $feedback['fb_content'] = $this->_post('fbcontent', '');
         $feedback['fb_upload'] = $this->_post('fbupload', '');
         $feedbackConfig = C('feedback');
         if (!isHave($feedbackConfig['type']) || !is_array($feedbackConfig['type']) || !isHave($feedbackConfig['maxLen']) || !is_numeric($feedbackConfig['maxLen'])) {
             return $this->JsonReturn('配置信息错误');
         }
         T('content/validate');
         $validation = array(array('fb_time', 'required', '请选择时间'), array('fb_type', 'required', '请选择类型'), array('fb_status', 'required', '请选择处理状态'), array('fb_content', 'required', '填填写反馈'), array('fb_content', 'max_length', '反馈内容请不要超过' . $feedbackConfig['maxLen'] . '个字符', $feedbackConfig['maxLen']));
         if (!isHave($feedbackConfig['type'][$feedback['fb_type']])) {
             return $this->JsonReturn('无该反馈类型' . $feedback['fb_type']);
         }
         if (!isHave($feedbackConfig['status'][$feedback['fb_status']])) {
             return $this->JsonReturn('无该处理结果');
         }
         if (!validate::check($validation, $feedback)) {
             return $this->JsonReturn(validate::getError());
         }
         // validate 中并没有如 2015-08-03 这样的无时间格式检查
         if (!strtotime($feedback['fb_time'])) {
             return $this->JsonReturn('时间错误');
         }
         /* TODO
          * 对于upload应该怎么样检查
          */
         $fb_insert = array('worker_uid' => steadmin::$adminInfo['user_id'], 'type_id' => $feedback['fb_type'], 'status_id' => $feedback['fb_status'], 'feedback' => $feedback['fb_content'], 'fb_time' => inTime($feedback['fb_time']), 'upload' => $feedback['fb_upload'], 'ct_time' => TIME);
         if (D('feedback')->insert($fb_insert)) {
             return $this->JsonReturn('保存成功,可继续添加反馈', null, 1);
         } else {
             return $this->JsonReturn('保存失败');
         }
     } else {
         $this->JsonReturn('加载string函数库时发生了错误');
     }
 }
 /**
  * 输出自定义提示信息
  */
 private function halt($msg = '', $errMsg = '')
 {
     if (isHave($this->config['save_errlog'])) {
         saveLog('db/error', var_export($msg, true) . ':' . $errMsg);
     }
     showError($msg);
 }
 function daily()
 {
     $today = $this->_get('date', '');
     if (!isHave($today)) {
         return showError('请传入一个日期');
     }
     $query = array();
     $timestamp = inTime($today);
     $query['fb_time[>=]'] = $timestamp;
     $query['fb_time[<]'] = $timestamp + 86400;
     //
     $rs = D('serviceLog')->where($query)->findAll();
     $feedbackConfig = C('steward/service_log');
     foreach ($rs as $key => $value) {
         $rs[$key]['fb_time'] = outTime($value['fb_time'], 2);
         $rs[$key]['ct_time'] = outTime($value['ct_time'], 2);
     }
     $this->assign(array('today' => $today, 'rs' => $rs, 'type' => $feedbackConfig['type'], 'status' => $feedbackConfig['status']));
     $this->display();
 }
//set_exception_handler('showErrorFun');
//开启gzip页面压缩
$System['gzip'] ? ob_start('obGzip') : ob_start();
include XLPHP_PATH . 'lib/core/base.class.php';
define('SCRIPT_NAME', basename($_SERVER['SCRIPT_NAME']));
$dirName = str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME']));
define('URL', getSiteUrl());
define('MAIN_URL', getSiteUrl('main'));
define('BASE_URL', rtrim(MAIN_URL, SCRIPT_NAME));
define('WEB_URL', isHave($System['main_url']) ? $System['main_url'] : ($dirName == '/' ? $dirName : $dirName . '/'));
define('WEB_TITLE', $System['title']);
define('VCODE', $System['vcode']);
define('IS_CGI', substr(PHP_SAPI, 0, 3) == 'cgi' ? 1 : 0);
define('IS_WIN', strstr(PHP_OS, 'WIN') ? 1 : 0);
define('IS_CLI', PHP_SAPI == 'cli' ? 1 : 0);
$url = parse_url($dirName);
$url = isset($url['path']) ? $url['path'] : '';
define('SITE_PATH', isHave($System['main_path']) ? $System['main_path'] : ($url == '/' ? $url : $url . '/'));
define('WEB_PATH', $url == '/' ? $url : $url . '/');
unset($url, $dirName);
define('TIME', $_SERVER['REQUEST_TIME']);
define('USER_AGENT', isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '');
xlphp::run();
if (TRACE && !isAjax()) {
    load('sys.fun');
    getRunInfo();
}
if ($System['gzip']) {
    ob_end_flush();
    //页面gzip压缩
}
 static function run()
 {
     $sys = C('System');
     if ($sys['path_mod'] == 3 && isHave($_GET['s']) && !isHave($_SERVER['PATH_INFO'])) {
         $_SERVER['PATH_INFO'] = $_GET['s'];
     }
     if (isHave($_SERVER['PATH_INFO'])) {
         $pathinfo = explode($sys['delimiter'], $_SERVER['PATH_INFO']);
         $count = count($pathinfo);
         if ($count) {
             if (strExists($pathinfo[0], $sys['delimiter'])) {
                 $pathinfo[0] = trim($pathinfo[0], $sys['delimiter']);
                 array_unshift($pathinfo, '');
             }
             $count = $count - 1;
             if (empty($pathinfo[$count - 1])) {
                 unset($pathinfo[$count - 1]);
             }
             if (!empty($sys['postfix']) && strExists($pathinfo[$count], $sys['postfix'])) {
                 $pathinfo[$count] = strtr($pathinfo[$count], array($sys['postfix'] => ''));
             }
             if (isHave($pathinfo[1]) && $pathinfo[1] != $sys['default_group'] && $sys['group_list'] && in_array($pathinfo[1], $sys['group_list'])) {
                 $_GET['g'] = $pathinfo[1];
                 if (isHave($pathinfo[2])) {
                     $_GET['c'] = $pathinfo[2];
                 }
                 if (isHave($pathinfo[3])) {
                     $_GET['m'] = $pathinfo[3];
                 }
                 $goIndex = 4;
             } else {
                 if (isHave($pathinfo[1])) {
                     $_GET['c'] = $pathinfo[1];
                 }
                 if (isHave($pathinfo[2])) {
                     $_GET['m'] = $pathinfo[2];
                 }
                 $goIndex = 3;
             }
             if ($count > $goIndex) {
                 for ($foo = $goIndex; $foo < $count; $foo += 2) {
                     $_GET[$pathinfo[$foo]] = $pathinfo[$foo + 1];
                 }
             }
         }
     }
     $_GET['c'] = isHave($_GET['c']) ? trim($_GET['c']) : $sys['c'];
     $_GET['m'] = isHave($_GET['m']) ? trim($_GET['m']) : $sys['m'];
     $_GET['g'] = isHave($_GET['g']) ? trim($_GET['g']) : $sys['default_group'];
     define('GROUP_NAME', $_GET['g']);
     define('ACTION_NAME', $_GET['c']);
     define('MODEL_NAME', $_GET['m']);
     $GLOBALS['System']['g'] = GROUP_NAME;
     $GLOBALS['System']['c'] = ACTION_NAME;
     $GLOBALS['System']['m'] = MODEL_NAME;
     $c = ACTION_NAME . 'Action';
     $path = APP_PATH . 'lib/action/' . (GROUP_NAME == 'index' || !GROUP_NAME ? 'index/' : GROUP_NAME . '/') . $c . '.class.php';
     if (checkPath($c) && is_file($path)) {
         if (isHave($sys['autoload_action'])) {
             foreach ($sys['autoload_action'] as $key => $val) {
                 if (!is_string($key) || $key == GROUP_NAME) {
                     if (!is_array($val)) {
                         $val = array($val);
                     }
                     foreach ($val as $v) {
                         if (!$key || $key == 'index') {
                             $key = 'index/';
                         } else {
                             $key .= '/';
                         }
                         $autoPath = APP_PATH . 'lib/action/' . $key . $v . 'Action.class.php';
                         if (is_file($autoPath)) {
                             include $autoPath;
                         } else {
                             showError('自动加载控制器:' . $v . '不存在');
                         }
                     }
                 }
             }
         }
         include $path;
         $control = '';
         if (class_exists($c)) {
             $control = new $c();
         }
         if (checkPath(MODEL_NAME) && method_exists($control, MODEL_NAME)) {
             return $control->{$_GET}['m']();
         } elseif (method_exists($control, '_empty')) {
             return $control->_empty();
         } elseif (method_exists($control, '_error')) {
             return $control->_error();
         } else {
             showError('模型 ' . htmlspecialchars(strip_tags(MODEL_NAME)) . ' 不存在');
         }
     }
     showError('控制器 ' . htmlspecialchars(strip_tags(ACTION_NAME)) . ' 不存在');
 }
 private function _resetDetail($v, $service)
 {
     //z($v, false);
     static $package = array();
     if (isHave($v['template'])) {
         switch ($v['template']) {
             case '2':
                 if (!isHave($package[$v['content']['pid']])) {
                     $rs = M('ste_goods_inter')->field('serverinfo')->where(array('id' => $v['content']['pid']))->find();
                     $serviceinfo = json_decode($rs['serverinfo'], true);
                     $package[$v['content']['pid']] = $serviceinfo;
                 } else {
                     $serviceinfo = $package[$v['content']['pid']];
                 }
                 foreach ($serviceinfo as $sk => $sv) {
                     if ($sk == $service) {
                         $v['content']['mode'] = 'steward_good';
                         $v['content']['para'] = 'id=' . $sv;
                         $goodInfo = M('ste_goods')->field('gid,cate_id,shop_id,goods_name,goods_subtitle,goods_spec,goods_pic,' . 'original_price,price_pre,price,credits,sale_counts,storage_counts,is_hot,is_new,is_recommend,' . 'limit_counts,is_realtime,goods_desc,is_limited')->where(array('gid' => $sv))->find();
                         $v['content']['goodinfo'] = $goodInfo;
                     }
                 }
                 break;
             case '3':
                 switch ($v['content']['mode']) {
                     //套餐商品转变
                     case 'package_good':
                         if (!isHave($package[$v['content']['para']])) {
                             $rs = M('ste_goods_inter')->field('serverinfo')->where(array('id' => $v['content']['para']))->find();
                             $serviceinfo = json_decode($rs['serverinfo'], true);
                             $package[$v['content']['para']] = $serviceinfo;
                         } else {
                             $serviceinfo = $package[$v['content']['para']];
                         }
                         foreach ($serviceinfo as $sk => $sv) {
                             if ($sk == $service) {
                                 $v['content']['mode'] = 'steward_good';
                                 $v['content']['para'] = 'id=' . $sv;
                             }
                         }
                         break;
                         //论坛转变
                     //论坛转变
                     case 'forum_thread':
                         $v['content']['para'] = 'fid=' . $v['content']['para'];
                         break;
                         //雷锋转变
                     //雷锋转变
                     case 'event':
                         $v['content']['para'] = 'id=' . $v['content']['para'];
                         break;
                         //商品分类转变,只有一家店铺时自动转化为店铺跳转。
                     //商品分类转变,只有一家店铺时自动转化为店铺跳转。
                     case 'steward_cate':
                         $tid = $v['content']['para'];
                         $v['content']['para'] = 'tid=' . $tid;
                         //查询是否一家店铺
                         $cates = $this->getSubs($this->cateList, $tid);
                         if (isHave($cates['list'][$tid])) {
                             $shop = array();
                             $shop = M('ste_goods')->field('shop_id')->where(array('service_id' => $service, 'status' => 1, 'cate_id' => $cates['list'][$tid]))->group('shop_id')->select('shop_id');
                             $shop = array_values($shop);
                             //类目下只有一个商家时直接跳转到商品列表
                             if (count($shop) == 1) {
                                 $v['content']['mode'] = 'steward_shop';
                                 $v['content']['para'] = 'shop_id=' . $shop[0]['shop_id'] . '&tid=' . $tid;
                                 if (isHave($v['content']['view']) && $v['content']['view'] == 'image') {
                                     //echo $k.'--'.$tid.'--'.count($shop).'<br/>';
                                     $v['content']['para'] = $v['content']['para'] . '&view=image';
                                 }
                             }
                         }
                         break;
                 }
                 break;
         }
     } else {
         switch ($v['mode']) {
             //套餐商品转变
             case 'package_good':
                 if (!isHave($package[$v['para']])) {
                     $rs = M('ste_goods_inter')->field('serverinfo')->where(array('id' => $v['para']))->find();
                     $serviceinfo = json_decode($rs['serverinfo'], true);
                     $package[$v['para']] = $serviceinfo;
                 } else {
                     $serviceinfo = $package[$v['para']];
                 }
                 foreach ($serviceinfo as $sk => $sv) {
                     if ($sk == $service) {
                         $gid = $sv;
                         $v['mode'] = 'steward_good';
                         $v['para'] = 'id=' . $gid;
                     }
                 }
                 unset($v['template']);
                 break;
                 //论坛转变
             //论坛转变
             case 'forum_thread':
                 $v['para'] = 'fid=' . $v['para'];
                 unset($v['template']);
                 break;
                 //雷锋转变
             //雷锋转变
             case 'event':
                 $v['para'] = 'id=' . $v['para'];
                 unset($v['template']);
                 break;
                 //商品分类转变,只有一家店铺时自动转化为店铺跳转。
             //商品分类转变,只有一家店铺时自动转化为店铺跳转。
             case 'steward_cate':
                 $tid = $v['para'];
                 $v['para'] = 'tid=' . $tid;
                 unset($v['template']);
                 //查询是否一家店铺
                 $cates = $this->getSubs($this->cateList, $tid);
                 if (isHave($cates['list'][$tid])) {
                     $shop = array();
                     $shop = M('ste_goods')->field('shop_id')->where(array('service_id' => $service, 'status' => 1, 'cate_id' => $cates['list'][$tid]))->group('shop_id')->select('shop_id');
                     $shop = array_values($shop);
                     //类目下只有一个商家时直接跳转到商品列表
                     if (count($shop) == 1) {
                         $v['content']['mode'] = 'steward_shop';
                         $v['content']['para'] = 'shop_id=' . $shop[0]['shop_id'] . '&tid=' . $tid;
                         if (isHave($v['content']['view']) && $v['content']['view'] == 'image') {
                             //echo $k.'--'.$tid.'--'.count($shop).'<br/>';
                             $v['content']['para'] = $v['content']['para'] . '&view=image';
                         }
                     }
                 }
                 break;
         }
     }
     return $v;
 }
function myCookie($var, $value = '', $life = 0)
{
    global $System;
    if ('' === $value) {
        if (isHave($_COOKIE[$System['cookie']['pre'] . $var])) {
            return $_COOKIE[$System['cookie']['pre'] . $var];
        } else {
            return NULL;
        }
    } else {
        if (is_null($value)) {
            setcookie($System['cookie']['pre'] . $var, '', TIME - 3600, $System['cookie']['path'], $System['cookie']['domain'], $_SERVER['SERVER_PORT'] == 443 ? 1 : 0);
            unset($_COOKIE[$var]);
            // 删除指定cookie
        } else {
            // 设置cookie
            setcookie($System['cookie']['pre'] . $var, $value, $life ? TIME + $life : 0, $System['cookie']['path'], $System['cookie']['domain'], $_SERVER['SERVER_PORT'] == 443 ? 1 : 0);
            $_COOKIE[$var] = $value;
        }
    }
}
 function setUserScore($data = array(), $type = 'event')
 {
     if (!isHave($data['uid']) && class_exists('user')) {
         $data['uid'] = user::$userInfo['uid'];
     }
     if (!$data['uid']) {
         return -1;
     }
     if ($data['credit'] <= 0) {
         return -2;
     }
     $user = $this->getUserInfoById($data['uid']);
     if (!$user) {
         return -3;
     }
     $data['infotime'] = TIME;
     //设置表和字段名
     if ($type == 'shopping') {
         $field = 'shopping_credit';
         $table = 'shopping_credit_log';
     } else {
         $field = 'event_credit';
         $table = 'event_credit_log';
     }
     if ($data['act']) {
         //增加积分
         $this->where(array('uid' => $data['uid']))->setInc($field, $data['credit']);
     } else {
         //减少积分
         if ($data['credit'] > $user[$field]) {
             $data['credit'] = $user[$field];
         }
         $this->where(array('uid' => $data['uid']))->setDec($field, $data['credit']);
     }
     //积分日志
     if (M($table)->insert($data)) {
         return 1;
     } else {
         return 0;
     }
 }
 function save()
 {
     $id = $this->_postid('id', 0);
     if (!$id) {
         $this->JsonReturn('参数丢失');
     }
     $objData = array();
     $noFields = array('logincount', 'loginip', 'logintime', 'regdateline', 'build_uid', 'shop_id', 'unionid');
     if (!parent::_checkIsAdmin()) {
         $noFields = array_merge($noFields, array('city_id', 'service_id'));
     }
     //获取字段内容
     $fieldList = D('steadmin')->getTableFields($noFields);
     foreach ($fieldList['fields'] as $key => $val) {
         $objData[$key] = $val['type'] == 'int' ? $this->_postid($key, $val['value']) : $this->_post($key, $val['value']);
     }
     $objData['repsw'] = $this->_post('repsw');
     $rs = D('steadmin')->where(array('user_id' => $id))->find();
     if (!parent::_checkIsPresident() && !parent::_checkIsAdmin() && $rs['user_id'] != steadmin::$adminInfo['user_id'] && $rs['build_uid'] !== steadmin::$adminInfo['user_id']) {
         $this->JsonReturn('权限不足');
     }
     //社长
     if (parent::_checkIsPresident()) {
         if ($rs['service_id'] !== steadmin::$adminInfo['service_id']) {
             $this->JsonReturn('权限不足');
         } else {
             $objData['service_id'] = steadmin::$adminInfo['service_id'];
         }
     }
     //内容规则检查
     T('content/validate');
     $validate = array(array('username', 'username', '帐户名称不符合要求', 2, 30), array('real_name', 'username', '真实姓名不符合要求', 2, 30), array('phone', 'phone', '手机号码不符合要求'));
     if ($objData['psw']) {
         $validate[] = array('psw', 'min_length', '密码长度必须大于4位', 4);
     }
     $infoData = array('nick_name' => $this->_post('nick_name'), 'user_avatar' => $this->_post('user_avatar'), 'total_service' => $this->_postid('total_service'), 'average_times' => $this->_postid('average_times'), 'score_service' => $this->_post('score_service'), 'score_speed' => $this->_post('score_speed'), 'total_comment' => $this->_postid('total_comment'), 'wechat_id' => $this->_post('wechat_id'));
     //工作人员完善资料
     if (isset($objData['groupid']) && in_array($objData['groupid'], $this->hasWorkerInfo)) {
         $validateInData = array(array('nick_name', 'username', '称呼不符合要求', 2, 30), array('user_avatar', 'required', '用户头像不能为空'), array('total_service', 'int', '总服务次数不符合要求'), array('average_times', 'int', '服务时间不符合要求'), array('score_service', 'double', '服务评分不符合要求'), array('score_speed', 'double', '速度评分不符合要求'), array('total_comment', 'int', '评论人次不符合要求'));
         if (!validate::check($validateInData, $infoData)) {
             $this->JsonReturn(validate::getError());
         }
         $validate[] = array('service_id', 'int', '商圈不能为空');
     }
     if (!validate::check($validate, $objData)) {
         $this->JsonReturn(validate::getError());
     }
     if ($objData['psw'] && $objData['psw'] != $objData['repsw']) {
         $this->JsonReturn('两次密码不一致');
     }
     if ($objData['psw']) {
         $objData['psw'] = D('admin')->setUserPassword($objData['psw']);
     } else {
         unset($objData['psw']);
     }
     //检测账户名或手机号是否重复
     $exist = D('steadmin')->field('user_id')->where(array('city_id' => steadmin::$adminInfo['city_id'], 'username' => $objData['username']))->find();
     if ($exist && $exist['user_id'] != $id) {
         $this->JsonReturn('该帐户名已存在');
     }
     //        $exist = D('steadmin')->field('user_id')
     //                        ->where(array('city_id' => steadmin::$adminInfo['city_id'], 'phone' => $objData['phone']))->find();
     //        if ($exist && $exist['user_id'] != $id) {
     //            $this->JsonReturn('该手机号已经存在');
     //        }
     //        if ($infoData['wechat_id']) {
     //            $exist = M('ste_worker')->field('user_id')
     //                            ->where(array('wechat_id' => $infoData['wechat_id']))->find();
     //            if ($exist && $exist['user_id'] != $id) {
     //                $this->JsonReturn('该微信号已经存在');
     //            }
     //        }
     if ($this->isLocal) {
         $syncToQyh = false;
     } else {
         $syncToQyh = true;
     }
     if (parent::_checkIsAdmin()) {
         $objData['effective'] = $this->_post('effective', 0);
         if ($objData['effective']) {
             $objData['effective'] = inTime($objData['effective']);
         } else {
             $objData['effective'] = 0;
         }
         $objData['status'] = $objData['status'] ? $objData['status'] : 0;
     }
     if ($objData['groupid'] == 8) {
         //店长身份需要设置店铺
         $objData['shop_id'] = $this->_postid('shop_id', 0);
     } else {
         $objData['shop_id'] = 0;
     }
     if ($objData['groupid'] == 9) {
         //社长身份必须设置服务中心
         $objData['service_id'] = $this->_postid('service_id', 0);
     }
     //社长必须有服务中心
     if ($objData['groupid'] == 9 && !$objData['service_id']) {
         $this->JsonReturn('服务中心不能为空');
     }
     //社长必须有服务中心
     if ($objData['groupid'] == 9) {
         if (!$objData['service_id']) {
             $this->JsonReturn('服务中心不能为空');
         }
         $checkWhere = array('city_id' => steadmin::$adminInfo['city_id'], 'service_id' => $objData['service_id'], 'groupid' => 9, 'status' => 1);
         $hasUser = D('steadmin')->where($checkWhere)->getField('user_id');
         if ($hasUser && $hasUser != $id || D('steadmin')->where($checkWhere)->count() > 1) {
             $this->JsonReturn('该服务中心已有社长帐号');
         }
     }
     $objData['city_id'] = steadmin::$adminInfo['city_id'];
     unset($objData['repsw']);
     //        z($objData);
     D('steadmin')->update($objData, array('user_id' => $id));
     //===记录操作日志====
     parent::saveSySLog(2, $objData, $id, array('user_id' => $id), '帐号管理-编辑');
     //===记录操作日志====
     if (in_array($objData['groupid'], $this->hasWorkerInfo)) {
         if (!M('ste_worker')->field('user_id')->where(array('user_id' => $id))->find()) {
             $infoData['user_id'] = $id;
             //插入员工信息
             D('steadmin')->addUserDetailInfo($infoData);
         } else {
             M('ste_worker')->update($infoData, array('user_id' => $id));
         }
     }
     if ($syncToQyh) {
         T('weixin/qy/qyWeixin.api');
         qyApi::init(steadmin::$adminInfo['city_id']);
         $qiyehaoinfo['userid'] = $objData['openid'];
         $qiyehaoinfo['name'] = $objData['real_name'];
         $qiyehaoinfo['mobile'] = $objData['phone'];
         if (isHave($infoData['wechat_id'])) {
             $qiyehaoinfo['weixinid'] = $infoData['wechat_id'];
         }
         $groupidname = $this->adminConfig['group'];
         $qiyehaoinfo['position'] = $groupidname[$objData['groupid']];
         if (!qyApi::userUpdate($qiyehaoinfo) && strpos(qyApi::$errorMsg, '60111') !== 0) {
             $this->JsonReturn('同步到企业号通讯录失败 ' . qyApi::$errorMsg);
         }
     }
     $this->JsonReturn('ok', null, 1);
 }
 public function thankpromotion($uid, $oid)
 {
     //是否App新下单用户
     $rs = M('ste_order')->where(array('uid' => $uid, 'order_source[!]' => 0, 'order_id[!]' => $oid, 'status' => array(7, 11)))->find();
     if ($rs) {
         return false;
     } else {
         $refer = M('invite')->where(array('beuid' => $uid))->find();
         if ($refer) {
             //判断邀请人为地推人员直接返回false
             if ($refer['uid'] >= 112856 && $refer['uid'] <= 112955 || $refer['uid'] >= 151609 && $refer['uid'] <= 151708) {
                 M('invite')->update(array('is_order' => 1), array('beuid' => $uid));
                 return false;
             }
             if (!$refer['status'] && $refer['coupon_money'] && isset($refer['coupon_info'])) {
                 $coupon_info = json_decode($refer['coupon_info'], true);
                 //判断是否为多张券
                 if (isHave($coupon_info[0])) {
                     foreach ($coupon_info as $ck => $cv) {
                         if ($cv['coupon_title'] && $refer['coupon_money']) {
                             $data = array('stype' => $cv['stype'], 'smod' => $cv['smod'], 'use_client' => $cv['use_client'], 'city_id' => $cv['city_id'], 'coupon_title' => $cv['coupon_title'], 'coupon_code' => $this->getCouponCode(), 'start_amount' => $cv['start_amount'], 'coupon_money' => $cv['coupon_money'], 'used_uid' => $refer['uid'], 'start_time' => TIME, 'end_time' => mktime(23, 59, 59, date('m'), date('d') + $cv['passday'], date('Y')), 'info_time' => TIME);
                         } else {
                             return false;
                         }
                         $this->addPrizeCoupon($data);
                     }
                     //改变邀请状态
                     M('invite')->update(array('status' => 1, 'is_order' => 1), array('beuid' => $uid));
                     return true;
                 } else {
                     if ($coupon_info['coupon_title'] && $refer['coupon_money']) {
                         $data = array('stype' => $coupon_info['stype'], 'smod' => $coupon_info['smod'], 'use_client' => $coupon_info['use_client'], 'city_id' => $coupon_info['city_id'], 'coupon_title' => $coupon_info['coupon_title'], 'coupon_code' => $this->getCouponCode(), 'start_amount' => $coupon_info['start_amount'], 'coupon_money' => $refer['coupon_money'], 'used_uid' => $refer['uid'], 'start_time' => TIME, 'end_time' => mktime(23, 59, 59, date('m'), date('d') + 15, date('Y')), 'info_time' => TIME);
                     } else {
                         return false;
                     }
                     $infoData = $this->addPrizeCoupon($data);
                     if ($infoData['status']) {
                         //改变邀请状态
                         M('invite')->update(array('status' => 1, 'is_order' => 1), array('beuid' => $uid));
                         return true;
                     } else {
                         return false;
                     }
                 }
             } else {
                 return false;
             }
         } else {
             return false;
         }
     }
 }
 function setDec($field, $num = 1)
 {
     if (isHave($this->opts['where'])) {
         $where = array_merge($this->opts['where'], $where);
         unset($this->opts['where']);
     } else {
         $where = array();
     }
     return $this->update(array('$inc' => array($field => $num)), $where);
 }
 fa-lg"></i><span><?php 
        echo $value['title'];
        ?>
</span></a>
  <?php 
        if ($value['item']) {
            ?>
    <ul class="dropdown-menu">
    <?php 
            foreach ($value['item'] as $val) {
                ?>
      <li><a href="<?php 
                echo $val['url'];
                ?>
" <?php 
                if (isHave($val['new'])) {
                    echo 'target="_blank"';
                }
                ?>
><?php 
                echo $val['title'];
                ?>
</a></li>
      <?php 
            }
            ?>
    </ul>
    <?php 
        }
        ?>
  </li>
    margin:3px
}
.show-pop-content {
    overflow-y:scroll;
    overflow-x:hidden;
    table-layout: fixed;
    word-wrap:break-word;
    word-break:break-all;
}
</style>
<div class="table-responsive show-pop-content" style="width:650px; height:400px;">
<section class="panel portlet-item"> 
<header class="panel-heading">详细信息</header> 
<ul class="list-group"> 
<li class="list-group-item" style="text-align:center"><?php 
if (isHave($rs['upload'])) {
    ?>
                    <?php 
    if (preg_match('/^.*?\\.(jpg|png|gif|jpeg|bmp|jpe)$/', $rs['upload'])) {
        ?>
                      <img src="<?php 
        echo getImgUrl($rs['upload']);
        ?>
" width="150" height="150"/>
                    <?php 
    } else {
        ?>
                      <p class="form-control"><a href="<?php 
        echo getImgUrl($rs['upload']);
        ?>
" target="_blank"><i class="fa fa-download"></i>
                
              </div>
              <div class="form-group">
                <label for="" class="col-sm-1 control-label">反馈内容</label>
                <div class="col-lg-5">
                  <p class="form-control"><?php 
echo $feedback['feedback'];
?>
</p>
                </div>
              </div>
              <div class="form-group">
                <label for="" class="col-sm-1 control-label">附件</label>
                <div class="col-lg-2">
                  <?php 
if (isHave($feedback['upload'])) {
    ?>
                    <?php 
    if (preg_match('/^.*?\\.(jpg|png|gif|jpeg|bmp|jpe)$/', $feedback['upload'])) {
        ?>
                      <img src="<?php 
        echo getImgUrl($feedback['upload']);
        ?>
" />
                    <?php 
    } else {
        ?>
                      <p class="form-control"><a href="<?php 
        echo getImgUrl($feedback['upload']);
        ?>
"><i class="fa fa-download"></i>
 protected function _setAdminSetting($field, $arr = array())
 {
     $list = $this->_getDefaultSetting();
     $isHave = M('ste_setting')->where(array('city_id' => steadmin::$adminInfo['city_id']))->find();
     if ($isHave) {
         $isHave[$field] = isHave($isHave[$field]) ? json_decode($isHave[$field], true) : $list[$field];
         if ($isHave[$field]) {
             $isHave[$field] = array_merge($isHave[$field], $arr);
         } else {
             $isHave[$field] = $arr;
         }
         return M('ste_setting')->update(array($field => json_encode($isHave[$field])), array('city_id' => steadmin::$adminInfo['city_id']));
     } else {
         $list = array_merge($list, array($field => $arr));
         foreach ($list as $k => $v) {
             $list[$k] = json_encode($v);
         }
         $list['city_id'] = steadmin::$adminInfo['city_id'];
         return M('ste_setting')->insert($list);
     }
 }
 public function delAdmin($id)
 {
     //获取管理员信息
     $admin = $this->getUserInfoById($id);
     if (!$admin || !isHave($admin['user_id'])) {
         return false;
     }
     $this->update(array('status' => 0, 'work_status' => 2), array('user_id' => $id));
     //需要删除信息的表
     //        $list = array(
     //            'ste_goods' => 'user_id',
     //            'ste_order_log' => 'user_id',
     //            'ste_shop' => 'user_id',
     //            'ste_user' => 'user_id',
     //            'ste_worker' => 'user_id',
     //        );
     //        foreach ($list as $k => $v) {
     //            M($k)->delete(array($v => $admin['user_id']));
     //        }
     return true;
 }
 private function _getdbtable()
 {
     if (isHave($this->opts['table'])) {
         $this->dbTable = $this->opts['table'];
         unset($this->opts['table']);
     }
     if (empty($this->dbTable)) {
         showError('缺少必要的参数:table');
     }
     return $this->dbTable;
 }
 function address()
 {
     $x = $this->_get('x');
     $y = $this->_get('y');
     if (!$x || !$y) {
         $this->JsonReturn('参数不正确');
     }
     $rs = json_decode(getHttp('http://apis.map.qq.com/ws/geocoder/v1/?location=' . $y . ',' . $x . '&key=' . $this->key), true);
     if (isset($rs['status']) && $rs['status'] == 0) {
         //            z($rs['result']);
         if (isHave($rs['result']['address_component']['street_number'])) {
             $path = $rs['result']['address_component']['city'] . $rs['result']['address_component']['district'] . $rs['result']['address_component']['street_number'];
         } else {
             $path = $rs['result']['address_component']['city'] . $rs['result']['address_component']['district'] . $rs['result']['address_component']['street'];
         }
         return $this->JsonReturn('ok', array('location' => $rs['result']['location'], 'address' => $rs['result']['address'], 'component' => $rs['result']['address_component'], 'path' => $path), 1);
     } else {
         return $this->JsonReturn('error');
     }
 }
    ?>
" rel="pop"><?php 
    echo $value['feedback'];
    ?>
</a></td>
                        <td><?php 
    echo $value['worker_name'];
    ?>
</td>
                        <td><?php 
    echo $value['ct_time'];
    ?>
</td>
                        <td>
                          <?php 
    if (isHave($value['upload'])) {
        ?>
                            <?php 
        if (preg_match('/^.*?\\.(jpg|png|gif|jpeg|bmp|jpe)$/', $value['upload'])) {
            ?>
                              <a href="<?php 
            echo getImgUrl($value['upload']);
            ?>
" rel="pop">查看图片</a>
                            <?php 
        } else {
            ?>
                              <a href="<?php 
            echo getImgUrl($value['upload']);
            ?>
" target="_blank">下载附件</a>
 public function save()
 {
     parent::_checkLogin();
     parent::_authUser(array(1, 2, 5, 7, 8));
     $id = $this->_postid('id', 0);
     if (!$id) {
         $this->JsonReturn('参数丢失');
     }
     $rs = M('ste_goods')->where(array('gid' => $id))->find();
     if (!$rs) {
         showError('商品不存在');
     }
     if (!parent::_checkUser($rs['user_id'], $rs['shop_id']) && (parent::_checkIsPresident() && $rs['service_id'] != steadmin::$adminInfo['service_id'])) {
         showError('没有编辑权限');
     }
     $objData = array();
     $noField = array('goods_sn', 'user_id', 'sale_counts', 'hits_counts', 'love_counts', 'info_time', 'shop_id', 'status', 'service_id');
     //获取字段内容
     $fieldList = M('ste_goods')->getTableFields($noField);
     foreach ($fieldList['fields'] as $key => $val) {
         $objData[$key] = $val['type'] == 'int' ? $this->_postid($key, $val['value']) : $this->_post($key, $val['value']);
     }
     $objData['goods_tips'] = $this->_post('goods_tips');
     $objData['start_times'] = $this->_post('start_times');
     $objData['end_times'] = $this->_post('end_times');
     $goodsParameter = $this->_post('goods_parameter');
     $objData['goods_desc'] = parent::_postContent('goods_desc');
     if ($objData['goods_tips']) {
         $objData['goods_tips'] = ',' . implode(',', $objData['goods_tips']) . ',';
     }
     $objData['goods_parameter'] = '';
     if ($goodsParameter) {
         $count = count($goodsParameter['n']);
         for ($i = 0; $i < $count; $i += 1) {
             isHave($goodsParameter['v'][$i]) && ($objData['goods_parameter'][] = array($goodsParameter['n'][$i], $goodsParameter['v'][$i]));
         }
     }
     if ($objData['goods_parameter']) {
         $objData['goods_parameter'] = json_encode($objData['goods_parameter']);
     }
     if (!$objData['is_realtime']) {
         $objData['booked_time'] = 0;
     }
     //内容规则检查
     T('content/validate');
     $validate = array(array('goods_name', 'range_length', '商品名称不符合要求', 2, 80), array('goods_pic', 'required', '商品小图不能为空'), array('price', 'currency', '商品价格不正确'), array('px', 'int', '排序值必须为正整数'), array('start_times', 'required', '上架时间不能为空'), array('end_times', 'required', '下架时间不能为空'));
     if ($objData['original_price']) {
         $validate[] = array('original_price', 'currency', '商品原始价格不正确');
     }
     if (!validate::check($validate, $objData)) {
         $this->JsonReturn(validate::getError());
     }
     //补充数据
     $objData['refresh_time'] = TIME;
     $objData['start_times'] = inTime($objData['start_times']);
     $objData['end_times'] = inTime($objData['end_times']);
     //        z($objData);
     //判断重复
     //        $checkHas = M('ste_goods')->where(array('goods_name' => $objData['goods_name'],
     //                    'goods_spec' => $objData['goods_spec'], 'shop_id' => $rs['shop_id'], 'status' => 1))->getField('gid');
     //        if ($checkHas && $checkHas != $id) {
     //            $this->JsonReturn('同名商品已存在,请检查');
     //        }
     //同步店铺信息
     $objData['service_id'] = M('ste_shop')->where(array('shop_id' => $rs['shop_id']))->getField('service_id');
     //        z($objData);
     M('ste_goods')->update($objData, array('gid' => $id));
     //===记录操作日志====
     parent::saveSySLog(2, $objData, $id, array('gid' => $id), '商品管理-编辑');
     //===记录操作日志====
     $this->JsonReturn('ok', null, 1);
 }