addBetweenCondition('create_date', $today, $today . ' 23:59:59') ->setSelect('count(id) as num'); // 今日新增校方跟进记录 $ret[] = [ 'num' => DB::getScalerWithCriteria('school_follow', $cri), 'des' => '今日新增校方跟进记录', 'detail_path' => '/school/follow' ]; // 今日新增食堂跟进记录 $ret[] = [ 'num' => DB::getScalerWithCriteria('canteen_follow', $cri), 'des' => '今日新增食堂跟进记录', 'detail_path' => '/canteen/follow' ]; // 今日新增餐饮公司跟进记录 $ret[] = [ 'num' => DB::getScalerWithCriteria('company_follow', $cri), 'des' => '今日新增餐饮公司跟进记录', 'detail_path' => '/company/follow' ]; // 今日新增校方关系 $ret[] = [ 'num' => DB::getScalerWithCriteria('school_contact', $cri), 'des' => '今日新增校方关系', 'detail_path' => '/company/relation' ]; // 今日新增餐饮公司关系 $ret[] = [ 'num' => DB::getScalerWithCriteria('company_contact', $cri), 'des' => '今日新增餐饮公司关系', 'detail_path' => '/company/relation' ]; Helper::ok($ret); } /** * 图片上传 * 不同类型放到不同目录,返回格式也会不同 */ public function actionUploadImg() { $upType = ''; $maxSize = 3; if (!empty($_FILES['follow'])) { $upType = 'follow'; $upArr = $_FILES['follow']; } elseif (!empty($_FILES['editor'])) { $upType = 'editor'; $upArr = $_FILES['editor']; } elseif (!empty($_FILES['avatar'])) { $upType = 'avatar'; $upArr = $_FILES['avatar']; $maxSize = 0.3; } elseif (!empty($_FILES['canteen'])) { $upType = 'canteen'; $upArr = $_FILES['canteen']; } else { Helper::error('上传有误'); } $type = strtolower($upArr['type']); if (!Helper::hasAnyString($type, ['png', 'jpeg', 'jpg'])) { Helper::error('图片格式不正确 ' . $type); } if ($upArr['size'] > $maxSize * 1024 * 1024) { Helper::error("图片大小不能超过{$maxSize}M"); } $ext = strtolower(pathinfo($upArr['name'], PATHINFO_EXTENSION)); $upPath = "zqcrm/{$upType}/" . date('Ymd') . '/' . Helper::getRandomString(16) . '.' . $ext; $res = Helper::imageUpload($upArr['tmp_name'], $upPath); if (empty($res['code']) || $res['code'] != 200) { Helper::error($res['msg'] ?? '上传出错'); } if ($upType == 'avatar') { $info = DB::getInfoById('useradmin', \Yii::app()->user->_id); Helper::imageDelete($info['avatar']); DB::updateById('useradmin', ['avatar' => $upPath], \Yii::app()->user->_id); } if ($upType == 'editor') { exit(json_encode([ 'errno' => 0, 'data' => [ 'url' => Helper::getImageUrl($upPath), ], ])); } else { Helper::ok(['name' => $upPath, 'url' => Helper::getImageUrl($upPath)]); } } public function actionDeleteImg() { $path = Helper::getPostString('path'); if (empty($path)) { Helper::error('参数错误'); } Helper::dealCommonResult(Helper::imageDelete($path)); } public function actionChangePassword() { $old = Helper::getPostString('password'); $new = Helper::getPostString('newPassword'); $new1 = Helper::getPostString('confirmPassword'); if (!$old || !$new) { Helper::error('参数错误'); } if ( $new != $new1){ Helper::error('新密码不一致'); } $info = DB::getInfoById('useradmin', \Yii::app()->user->_id); if (!$info) { Helper::error('用户未找到'); } if (md5($old) != $info['password']) { Helper::error('旧密码错误'); } DB::updateById('useradmin', ['password' => md5($new)], \Yii::app()->user->_id); Helper::ok(); } public function actionEditUser() { $info = [ 'username' => Helper::getPostString('username'), 'phone' => Helper::getPostString('phone'), 'email' => Helper::getPostString('email'), 'descr' => Helper::getPostString('descr'), 'sex' => Helper::getPostInt('sex'), ]; if (!Helper::checkEmptyKey($info, ['username', 'phone', 'email'])) { Helper::error('参数错误'); } DB::updateById('useradmin', $info, \Yii::app()->user->_id); Helper::ok(); } /** * Logs out the current user and redirect to homepage. */ public function actionLogout() { Yii::app()->user->logout(); Helper::ok(); } }