function index() { if ($this->_checkLogin(true)) { if (parent::_checkIsAdmin()) { jumpTo(U('home/index')); } else { jumpTo(U('index/index')); } } $this->assign('refer', $this->_get('refer', urlencode(U('home/index')))); $this->display('index'); }
function index() { if (parent::_checkIsAdmin()) { //访问统计数据展示 $p = $this->_getid('p', 1); $startTime = $this->_get('stime', '', 'urldecode'); //开始时间 $endTime = $this->_get('etime', '', 'urldecode'); //结束时间 $recordId = $this->_getid('id', ''); // $rs = array(); $data = array(); $code = setEnocde(array('a' => 0, 's' => 1, 'city_id' => steadmin::$adminInfo['city_id'])); $url = U('steward/wxapi/index') . '?token=' . $code; $code = urldecode($code); V('db/mongo'); $db = mongoApi::getInstance(); $pageShow = 20; $where = array(); $sort = array('infotime' => -1); if ($startTime && $endTime) { if ($startTime == $endTime) { $endTimeDay = 60 * 60 * 24 - 1; } else { $endTimeDay = 0; } $where['infotime'] = array('$gte' => inTime($startTime), '$lte' => inTime($endTime) + $endTimeDay); } if ($startTime) { $_GET['stime'] = urlencode($startTime); } else { unset($_GET['stime']); } if ($endTime) { $_GET['etime'] = urlencode($endTime); } else { unset($_GET['etime']); } if (!$recordId) { unset($_GET['id']); } if ($recordId) { $where['record_id'] = $recordId; } $count = $db->table('steadminLog')->where($where)->count(); $rsLog = $db->table('steadminLog')->where($where)->order($sort)->limit($pageShow)->skip(($p - 1) * $pageShow)->findAll(); $this->assign(array('rs' => $rs, 'data' => $data, 'url' => $url, 'token' => md5($code . VCODE), 'p' => $p, 'recordId' => $recordId, 'total' => $count, 'rsLog' => $rsLog, 'pageShow' => $pageShow, 'startTime' => $startTime, 'endTime' => $endTime)); $this->display(); } else { jumpTo(U('index/index')); } }
function index() { if (!$this->_checkLogin(true)) { jumpTo(U('login/index')); } if (parent::_checkIsAdmin() && steadmin::$adminInfo['isAdmin']) { jumpTo(U('home/index')); } else { $this->assign(array('group' => C('steward/admin', 'group'))); $this->display('index'); } }
public function edit_worker_save() { parent::_authUser(array(1, 2, 9)); $id = $this->_postid('order_id', 0); $type = $this->_postid('type', 1); $workerUid = $this->_postid('worker_uid', 0); if (!$id) { $this->JsonReturn('参数丢失'); } $rs = M('ste_order')->where(array('order_id' => $id))->find(); if (!$rs) { $this->JsonReturn('订单不存在'); } if (parent::_checkIsPresident()) { //社长 if ($rs['service_id'] != steadmin::$adminInfo['service_id']) { $this->JsonReturn('没有操作权限!'); } } elseif (!parent::_checkIsAdmin()) { $this->JsonReturn('没有操作权限'); } //判断当前订单是否可以修改 if (!in_array($rs['status'], array(3, 4, 5, 6))) { $this->JsonReturn('该订单当前状态不可编辑'); } $field = ''; switch ($type) { case 1: if ($workerUid == $rs['deployment_uid']) { $this->JsonReturn('配货员未变更'); } $field = 'deployment_uid'; $msgId = 1; $oldUid = $rs['deployment_uid']; break; case 2: if ($workerUid == $rs['worker_uid']) { $this->JsonReturn('小管家未变更'); } $field = 'worker_uid'; $msgId = 2; $oldUid = $rs['worker_uid']; break; } if (!$field) { $this->JsonReturn('参数有误'); } //更新数据 $info = M('ste_order')->update(array($field => $workerUid), array('order_id' => $id)); if (!$info) { $this->JsonReturn('编辑失败'); } $res = array(); //通知小管家 $res['deployment'] = $this->_sendQIYENotice($rs, $msgId, $workerUid); $res['deployment_old'] = $this->_sendQIYENotice($rs, 4, $oldUid); //===记录操作日志==== parent::saveSySLog(2, array('field' => $field, 'user_id' => $workerUid, 'old_user_id' => $oldUid), $id, array(), '订单管理-更换小管家'); //===记录操作日志==== //返回结果 $this->JsonReturn('ok', $res, 1); }
public function report() { $startTime = $this->_get('stime', ''); //开始时间 $endTime = $this->_get('etime', ''); //结束时间 $serviceId = $this->_getid('service_id', 0); //服务社 $isOutput = $this->_getid('is_output', 0); //是否导出数据 $cateId = $this->_getid('cid', 0); //类目 $cateList = array(275 => '半成品菜', 273 => '预定下午茶'); if (!isset($cateList[$cateId])) { showError('抱歉,该类目不允许查看'); } if (!parent::_checkIsAdmin()) { if ($cateId != 275 || steadmin::$adminInfo['user_id'] != 291) { //半成品菜店长 showError('抱歉,暂无权限'); } } //取类目及所有子类目 $cateAllList = M('ste_goods_cate')->where(array('city_id' => steadmin::$adminInfo['city_id'], 'is_del' => 0))->order('sort DESC')->select('id'); $tidList = D('tree')->getSubs($cateAllList, $cateId, true); $cateId = $tidList['list'] ? implode(',', $tidList['list']) : $cateId; //默认报表时间为今天 $today = mktime(0, 0, 0, date('m'), date('d'), date('Y')); $stime = mktime(0, 0, 0, date('m'), date('d') + 1, date('Y')); if (!$startTime) { $startTime = date('Y-m-d', $stime); } if (!$endTime) { $endTime = date('Y-m-d', $stime); } if ($startTime && $endTime) { $startTime = inTime($startTime); $endTime = inTime($endTime) + 60 * 60 * 24 - 1; } if ($serviceId) { $where = ' AND a.service_id=' . $serviceId; $sWhere = ' AND service_id=' . $serviceId; } else { $where = ''; $sWhere = ''; } if ($startTime < $today) { $statusList = '1,3,4,5,6,7,8,9,10,11'; } else { $statusList = '1,3,4,5,6,7,8,9,10,11'; //搜索状态:已支付、已审核、正在配货 } //根据类目搜索所有的商品gid $where = ''; $rs = M('ste_order')->query('SELECT a.order_id,a.order_sn,a.order_type,a.service_id,a.village_id,a.uid,a.address,a.phone,a.username,' . 'a.desc,a.arrive_date,a.arrive_time,a.order_source,a.status,a.order_time,a.goods_counts AS goods_total,b.gid,b.shop_id,b.goods_name,b.goods_counts,b.goods_price' . ' FROM __TABLE__ AS a LEFT JOIN __PRE__ste_order_goods AS b ON a.order_id=b.order_id WHERE a.arrive_date>=' . $startTime . ' AND a.arrive_date<=' . $endTime . ' AND a.status IN (' . $statusList . ') AND b.gid IN ( SELECT gid FROM __PRE__ste_goods WHERE cate_id IN (' . $cateId . ') ' . $sWhere . ' )' . $where . ' ORDER BY service_id ASC'); // z(M('ste_order')->getAllSql()); // z($rs); $orderList = array(); $orderTotal = array(); $serviceList = array(); if ($rs) { foreach ($rs as $val) { //统计各个菜的数量 $goodsName = md5($val['goods_name']); if (!isset($orderTotal[$goodsName])) { $orderTotal[$goodsName] = array('name' => $val['goods_name'], 'counts' => $val['goods_counts'], 'item' => array()); } else { $orderTotal[$goodsName]['counts'] += $val['goods_counts']; } if (!isset($orderTotal[$goodsName]['item'][$val['service_id']])) { $orderTotal[$goodsName]['item'][$val['service_id']] = array('name' => $this->serviceData[$val['service_id']]['stitle'], 'counts' => $val['goods_counts']); } else { $orderTotal[$goodsName]['item'][$val['service_id']]['counts'] += $val['goods_counts']; } //按服务社统计菜单 if (!isset($serviceList[$val['service_id']])) { $serviceList[$val['service_id']] = array('service_name' => $this->serviceData[$val['service_id']]['stitle'], 'counts' => $val['goods_counts'], 'item' => array()); } else { $serviceList[$val['service_id']]['counts'] += $val['goods_counts']; } if (!isset($serviceList[$val['service_id']]['item'][$val['gid']])) { $serviceList[$val['service_id']]['item'][$val['gid']] = array('name' => $val['goods_name'], 'counts' => $val['goods_counts']); } else { $serviceList[$val['service_id']]['item'][$val['gid']]['counts'] += $val['goods_counts']; } //按订单号归类商品 if (!isset($orderList[$val['order_id']])) { $orderList[$val['order_id']] = array('order_id' => $val['order_id'], 'order_sn' => $val['order_sn'], 'order_type' => $val['order_type'], 'service_id' => $val['service_id'], 'service_name' => $this->serviceData[$val['service_id']]['stitle'], 'village_id' => $val['village_id'], 'village_name' => parent::getVillageName($val['village_id']), 'address' => $val['address'], 'phone' => $val['phone'], 'username' => $val['username'], 'desc' => $val['desc'], 'arrive_date' => $val['arrive_date'], 'arrive_time' => $val['arrive_time'], 'order_source' => $val['order_source'], 'status' => $val['status'], 'order_time' => $val['order_time'], 'goods_total' => $val['goods_total'], 'select_goods_total' => 0, 'list' => array()); } $orderList[$val['order_id']]['list'][] = array('goods_name' => $val['goods_name'], 'goods_counts' => $val['goods_counts'], 'goods_price' => $val['goods_price']); $orderList[$val['order_id']]['select_goods_total'] += $val['goods_counts']; } } // z($orderTotal); // z($serviceList); if ($isOutput) { $dataList = array(); $title = array('订单号', '收货人', '手机', '地址', '配送时间', '商品列表', '留言', '混合订单'); foreach ($orderList as $val) { $list = array(); foreach ($val['list'] as $v) { $list[] = $v['goods_name'] . ' (x ' . $v['goods_counts'] . ')'; } $dataList[] = array($val['order_sn'], $val['username'], $val['phone'], $val['address'], outTime($val['arrive_date'], 2) . ' ' . $val['arrive_time'], implode("\r\n", $list), $val['desc'], $val['goods_total'] == $val['select_goods_total'] ? '否' : '是'); } if (isset($this->serviceData[$serviceId])) { $tname = $this->serviceData[$serviceId]['stitle']; } else { $tname = '全部'; } $dataList[] = array('', '', '', '', '', '', '', ''); $dataList[] = array('', '', '', '', '', '', '', ''); $dataList[] = array('品类', '详细', '数量', '', '', '', '', ''); //将统计信息附加到报表中 foreach ($orderTotal as $val) { $list = array(); foreach ($val['item'] as $v) { $list[] = $v['name'] . ' (' . $v['counts'] . '份)'; } $dataList[] = array($val['name'], implode('、', $list), $val['counts'], '', '', '', '', ''); } $dataList[] = array('', '', '', '', '', '', '', ''); $dataList[] = array('', '', '', '', '', '', '', ''); $dataList[] = array('服务社', '详细', '数量', '', '', '', '', ''); //将统计信息附加到报表中 foreach ($serviceList as $val) { $list = array(); foreach ($val['item'] as $v) { $list[] = $v['name'] . ' (' . $v['counts'] . '份)'; } $dataList[] = array($val['service_name'], implode("\r\n", $list), $val['counts'], '', '', '', '', ''); } load('csv'); $csv = new csv(); $csv->write($title, $dataList, $cateList[$cateId] . '订单_' . $tname . date('Y-m-d H/i/s')); } else { $this->assign(array('rs' => $orderList, 'orderTotal' => $orderTotal, 'cid' => $cateId, 'service_id' => $serviceId, 'startTime' => $startTime, 'endTime' => $endTime, 'serviceList' => $serviceList, 'service' => $this->serviceData, 'setting' => $this->steSetting)); $this->display(); } }
function delete() { $id = $this->_postid('id'); if (!$id) { showError('参数丢失'); } if (!parent::_checkIsAdmin()) { showError('没有编辑权限'); } D('serviceLog')->delete(array('fid' => $id)); //===记录操作日志==== parent::saveSySLog(3, array(), $id, array('id' => $id), '客服日报-删除'); //===记录操作日志==== $this->JsonReturn('ok', null, 1); }
function delete() { $id = $this->_postid('id'); if (!$id) { showError('参数丢失'); } $rs = D('steadmin')->where(array('user_id' => $id))->find(); if (!parent::_checkIsAdmin() || $rs['city_id'] != steadmin::$adminInfo['city_id']) { showError('权限不足'); } if ($this->isLocal) { D('steadmin')->delAdmin(array('user_id' => $id)); } else { //从企业号通讯录删除 T('weixin/qy/qyWeixin.api'); qyApi::init(steadmin::$adminInfo['city_id']); //是否只存在于小管家部门 if (strpos($rs['openid'], 'steward_') !== false) { if (!qyApi::userDelete($rs['openid']) && strpos(qyApi::$errorMsg, '60111') !== 0) { $this->JsonReturn('从企业号通讯录删除失败 ' . qyApi::$errorMsg); } else { D('steadmin')->delAdmin(array('user_id' => $id)); } } else { $corp_info = $this->_getAdminSetting('corp_info'); $onlineinfo = qyApi::userGet($rs['openid']); foreach ($onlineinfo['department'] as $dk => $dv) { if ($dv == $corp_info['departmentId']) { unset($onlineinfo['department'][$dk]); break; } } $qiyehaoinfo['userid'] = $rs['openid']; $qiyehaoinfo['department'] = $onlineinfo['department']; if (!qyApi::userUpdate($qiyehaoinfo) && strpos(qyApi::$errorMsg, '60111') !== 0) { $this->JsonReturn('从企业号小管家通讯录删除失败 ' . qyApi::$errorMsg); } else { D('steadmin')->delAdmin(array('user_id' => $id)); } } } //===记录操作日志==== parent::saveSySLog(3, array(), $id, array('user_id' => $id), '帐号管理-删除'); //===记录操作日志==== //DOTO:清除相关数据 $this->JsonReturn('ok', null, 1); }
public function deal() { $id = $this->_postid('id', 0); $act = $this->_postid('act', 0); if (!$id) { showError('参数丢失'); } if (!isset($this->setOrderStatus[$act])) { $this->JsonReturn('参数错误'); } $rs = M('ste_order')->where(array('order_id' => $id))->find(); if (!$rs) { $this->JsonReturn('订单不存在'); } if (parent::_checkIsPresident()) { //社长 if ($rs['service_id'] != steadmin::$adminInfo['service_id']) { showError('没有操作权限!'); } } elseif (!parent::_checkIsAdmin()) { showError('没有操作权限'); } M('ste_order')->update(array('status' => $act), array('order_id' => $id)); //===记录操作日志==== parent::saveSySLog(4, array('status' => $act), $id, array('order_id' => $id), '订单管理-处理状态'); //===记录操作日志==== $this->JsonReturn('ok', $this->setOrderStatus[$act], 1); }
/** * 编辑 */ public function edit() { parent::_checkLogin(); parent::_authUser(array(1, 2, 5, 7, 8)); $id = $this->_getid('id', 0); if (!$id) { showError('参数丢失'); } $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('没有编辑权限'); } $rs['goods_tips'] = explode(',', trim($rs['goods_tips'], ',')); if ($rs['goods_parameter']) { $rs['goods_parameter'] = json_decode($rs['goods_parameter'], true); } $cate = M('ste_goods_cate')->where(array('is_del' => 0, 'city_id' => steadmin::$adminInfo['city_id']))->order('`id`')->findAll(false); $mainCate = M('ste_goods_cate')->field('id,name')->where(array('is_del' => 0, 'city_id' => steadmin::$adminInfo['city_id'], 'pid' => $this->rootCateId))->order('`id`')->findAll(false); if (steadmin::$adminInfo['groupid'] == 8) { //店长 $shop = M('ste_shop')->field('shop_id,shop_name,shop_alt_name')->where(array('shop_id' => steadmin::$adminInfo['shop_id'], 'status' => 1))->findAll(); } elseif (parent::_checkIsAdmin() || parent::_checkIsPresident()) { //管理员 $shop = M('ste_shop')->field('shop_id,shop_name,shop_alt_name')->where(array('status' => 1))->findAll(); } else { //商家、总店 $shop = M('ste_shop')->field('shop_id,shop_name,shop_alt_name')->where(array('user_id' => steadmin::$adminInfo['user_id'], 'status' => 1))->findAll(); } V('tree/catetree'); $ctree = TreeTool::tree($cate, $rs['cate_id'], 'pid', 'id'); //找到当前项目的父类 $parentId = 0; if ($ctree) { foreach ($ctree as $val) { if ($val['pid'] == $this->rootCateId) { $parentId = $val['id']; break; } } } $this->assign(array('rs' => $rs, 'cate' => $mainCate, 'parentId' => $parentId, 'shop' => $shop, 'setting' => $this->steSetting)); // z($this->tVar); $this->display(); }