Example #1
0
 function checkCoachMaxUsers()
 {
     $param = json_decode(file_get_contents('php://input'), true);
     $token = $param['xtoken'];
     // init_verify_token($token);
     $coachid = $param['coachid'];
     // $coachid = 53;
     if (empty($coachid)) {
         err_ret(-205, 'lack of param', '缺少参数');
     }
     //判断教练的客户是否超过10个
     $model = new Model();
     $sql_user = '******' . $coachid;
     $result_user = $model->query($sql_user);
     $studentNums = M("user_info")->where("type=1 and id={$coachid}")->getField("studentnums");
     if (count($result_user) >= $studentNums) {
         $model_user = new Model('user_info');
         $save_data['status'] = 1;
         $where_data['id'] = $coachid;
         $where_data['type'] = 1;
         $model_user->where($where_data)->save($save_data);
         $data['errno'] = 0;
         $data['is_max'] = 1;
         $data['coachid'] = $coachid;
         echo json_encode($data);
     } else {
         $data['errno'] = 0;
         $data['is_max'] = 0;
         $data['coachid'] = $coachid;
         echo json_encode($data);
     }
 }
Example #2
0
function resize_upload($imagick)
{
    global $_CONFIG_MAX_SIZE;
    $width = $imagick->getImageWidth();
    $height = $imagick->getImageHeight();
    if ($width > $height && $width > $_CONFIG_MAX_SIZE) {
        $width = $_CONFIG_MAX_SIZE;
        $imagick->resizeImage($_CONFIG_MAX_SIZE, $_CONFIG_MAX_SIZE, Imagick::FILTER_CATROM, 1, true);
        $height = $imagick->getImageHeight();
    } elseif ($height > $width && $height > $_CONFIG_MAX_SIZE) {
        $height = $_CONFIG_MAX_SIZE;
        $imagick->resizeImage($_CONFIG_MAX_SIZE, $_CONFIG_MAX_SIZE, Imagick::FILTER_CATROM, 1, true);
        $width = $imagick->getImageWidth();
    }
    $file_ext_name = strtolower($imagick->getImageFormat());
    if (!$file_ext_name || $file_ext_name == 'jpeg') {
        $imagick->setImageFormat('jpeg');
        $file_ext_name = 'jpg';
    }
    $buff = $imagick->getImageBlob();
    if ($ret = fastdfs_storage_upload_by_filebuff1($buff, $file_ext_name)) {
        $ret = '/' . $ret;
        ok_ret($ret, $width, $height);
        exit;
    } else {
        err_ret('upload fail.');
    }
}
Example #3
0
function init_verify_token($token)
{
    if ($token == '') {
        err_ret(-205, 'lack of param xtoken', '缺少xtoken参数');
    }
    $model = new Model('user_info');
    $condition['xtoken'] = $token;
    $result = $model->where($condition)->select();
    if (count($result) <= 0) {
        err_ret(-505, 'tokan is invalid', 'token 失效');
    }
}
 function updateDeviceToken()
 {
     $param = json_decode(file_get_contents('php://input'), true);
     $xtoken = $param['xtoken'];
     init_verify_token($xtoken);
     $uid = $param['uid'];
     if (empty($uid)) {
         err_ret(-205, 'lack of param', '缺少参数');
     }
     $device_token = $param['device_token'];
     if (empty($device_token)) {
         err_ret(-205, 'lack of param', '缺少参数');
     }
     //设备类型 1安卓手机  2苹果手机
     $type = $param['type'];
     if ($type != 1 && $type != 2) {
         err_ret(-205, 'param is error', '参数错误');
     }
     $model = new Model('apns_user');
     $where_data['uid'] = $uid;
     $result = $model->where($where_data)->select();
     if (count($result) > 0) {
         //如果已经有了deviceToken
         $old_type = $param[0]['type'];
         $old_device_token = $param[0]['device_token'];
         if ($old_device_token != $device_token) {
             $type = $old_type == 1 ? 2 : 1;
             $condition['uid'] = $uid;
             $save_data['device_token'] = $device_token;
             $save_data['type'] = $type;
             $model->where($condition)->save($save_data);
         }
     } else {
         $add_data['device_token'] = $device_token;
         $add_data['uid'] = $uid;
         $add_data['type'] = $type;
         $result = $model->add($add_data);
     }
     $data['errno'] = 0;
     $data['uid'] = $uid;
     $data['type'] = $type;
     $data['device_token'] = $device_token;
     echo json_encode($data);
 }
Example #5
0
function getuiSendDeviceUnicast($uid, $title, $text)
{
    if (empty($uid) || $title == '' || $text == '') {
        err_ret(-205, 'lack of param', '缺少参数');
    }
    $model = new Model('apns_user');
    $condition['uid'] = $uid;
    $result = $model->where($condition)->select();
    if (count($result) <= 0) {
        return false;
    }
    $type = $result[0]['type'];
    $device_token = $result[0]['device_token'];
    //    echo $device_token;
    if ($type == 1) {
        //安卓设备
        Vendor('GetuiPush.GetuiPush');
        pushMessageToSingle($device_token, $title, $text);
    } else {
        if ($type == 2) {
            //苹果设备
        }
    }
}
Example #6
0
/**
 * Created by PhpStorm.
 * User: jiulu
 * Date: 2015/12/23
 * Time: 21:58
 * @param $uid
 * @param $title
 * @param $text
 * @return bool
 */
function sendDeviceUnicast($uid, $ticker, $title, $text)
{
    if (empty($uid) || $title == '' || $text == '') {
        err_ret(-205, 'lack of param', '缺少参数');
    }
    $model = new Model('apns_user');
    $condition['uid'] = $uid;
    $result = $model->where($condition)->select();
    if (count($result) <= 0) {
        return false;
    }
    $type = $result[0]['type'];
    $device_token = $result[0]['device_token'];
    if ($type == 1) {
        //安卓设备
        Vendor('UmengPushAPI.UmengPushAPI');
        $umengPush = new \UmengPushAPI();
        $umengPush->sendAndroidUnicast($device_token, $ticker, $title, $text);
    } else {
        if ($type == 2) {
            //苹果设备
        }
    }
}
Example #7
0
 function getEvaluateInfo()
 {
     header('Access-Control-Allow-Origin:*');
     //跨域
     header("Content-type: text/html; charset=utf-8");
     $param = json_decode(file_get_contents('php://input'), true);
     $token = $param['xtoken'];
     init_verify_token($token);
     $uid = $param['uid'];
     //$uid=38;
     if (empty($uid)) {
         err_ret(-205, 'lack of param', '缺少参数');
     }
     $sql = "SELECT * FROM evaluate WHERE uid={$uid} ORDER BY time DESC LIMIT 0,1";
     $result = M()->query($sql);
     $data['errno'] = 0;
     $data['evaluateInfo'] = $result[0];
     echo json_encode($data);
 }
Example #8
0
 function getMyCoach()
 {
     $param = json_decode(file_get_contents('php://input'), true);
     $token = $param['xtoken'];
     init_verify_token($token);
     $uid = $param['uid'];
     //$uid = 1976;
     if (empty($uid)) {
         err_ret(-205, 'lack of param', '缺少参数');
     }
     $sql = "SELECT name,header,price,phone,type FROM user_info WHERE id IN\n                    (\n                        SELECT DISTINCT coachid FROM my_plan WHERE uid={$uid}\n                    )";
     $model = new Model();
     $result = $model->query($sql);
     $data['errno'] = 0;
     $data['coach_list'] = $result;
     echo json_encode($data);
 }
 public function addEvaluateMsg()
 {
     $param = json_decode(file_get_contents('php://input'), true);
     $token = $param['xtoken'];
     init_verify_token($token);
     $uid = $param['uid'];
     if (empty($uid)) {
         err_ret(-205, 'lack of param', '缺少参数');
     }
     if ($param['gender'] != 0 && $param['gender'] != 1) {
         $param['gender'] = 0;
     }
     if (empty($param['height'])) {
         err_ret(-205, 'lack of param', '缺少参数');
     }
     if (empty($param['weight'])) {
         err_ret(-205, 'lack of param', '缺少参数');
     }
     if (empty($param['bustwidth'])) {
         err_ret(-205, 'lack of param', '缺少参数');
     }
     if (empty($param['waistwidth'])) {
         err_ret(-205, 'lack of param', '缺少参数');
     }
     if (empty($param['breechwidth'])) {
         err_ret(-205, 'lack of param', '缺少参数');
     }
     $param['time'] = time();
     $param['birthday'] = strtotime($param['birthday']);
     //user_info表更新
     $user['birthday'] = $param['birthday'];
     $user['height'] = $param['height'];
     $user['weight'] = $param['weight'];
     $user['bustwidth'] = $param['bustwidth'];
     $user['waistwidth'] = $param['waistwidth'];
     $user['breechwidth'] = $param['breechwidth'];
     $aff1 = M("user_info")->where("id={$uid}")->save($user);
     $aff2 = M("evaluate")->add($param);
     if ($aff2) {
         $aff3 = M("my_plan")->where("uid={$uid} AND status<2")->save(array("status" => 2));
         $data = array();
         $data = $param;
         $data['errno'] = 0;
         echo json_encode($data);
     } else {
         err_ret(-501, "add evaluate failed", "添加体能评估失败");
     }
 }
Example #10
0
 function checkMark()
 {
     $param = json_decode(file_get_contents('php://input'), true);
     $token = $param['xtoken'];
     init_verify_token($token);
     $uid = $param['uid'];
     $pid = $param['pid'];
     $coachid = $param['coachid'];
     $courseid = $param['courseid'];
     $course_time = $param['course_time'];
     if (!isset($uid) || !isset($pid) || !isset($coachid) || !isset($courseid) || !isset($course_time)) {
         err_ret(-205, 'lack of param', '缺少参数');
     }
     $model = new Model();
     $sql = "SELECT * FROM my_plan WHERE uid={$uid} AND pid={$pid} AND coachid={$coachid} AND courseid={$courseid} AND FROM_UNIXTIME(course_time,'%Y-%m-%d')=FROM_UNIXTIME({$course_time},'%Y-%m-%d')";
     $result = $model->query($sql);
     if (count($result) > 0) {
         if ($result[0]['isfinished'] == 1) {
             $data['errno'] = 1;
             $data['uid'] = $uid;
             $data['pid'] = $pid;
             $data['coachid'] = $coachid;
             $data['courseid'] = $courseid;
             echo json_encode($data);
             die;
         }
     } else {
         //这一天没有计划
         $data['errno'] = 2;
         $data['uid'] = $uid;
         $data['pid'] = $pid;
         $data['coachid'] = $coachid;
         $data['courseid'] = $courseid;
         echo json_encode($data);
         die;
     }
     $sql = "UPDATE my_plan SET isfinished=1 \n\t\tWHERE FROM_UNIXTIME(course_time,'%Y-%m-%d')=FROM_UNIXTIME({$course_time},'%Y-%m-%d') \n\t\tAND uid={$uid} AND pid={$pid} AND coachid={$coachid} AND courseid={$courseid}";
     $model->query($sql);
     $data['errno'] = 0;
     $data['uid'] = $uid;
     $data['pid'] = $pid;
     $data['coachid'] = $coachid;
     $data['courseid'] = $courseid;
     echo json_encode($data);
 }
Example #11
0
 function updateCourseHard()
 {
     header('Access-Control-Allow-Origin:*');
     //跨域
     header("Content-type: text/html; charset=utf-8");
     $param = json_decode(file_get_contents('php://input'), true);
     $token = $param['xtoken'];
     init_verify_token($token);
     $course_record_id = $param['course_record_id'];
     // $course_record_id = 293;
     if (empty($course_record_id)) {
         err_ret(-205, 'lack of param', '缺少参数');
     }
     $hard = $param['hard'];
     // $hard = 2;
     if (empty($hard)) {
         $hard = 1;
     }
     $model = new Model('course_record');
     $condition['id'] = $course_record_id;
     $save_data['hard'] = $hard;
     $model->where($condition)->save($save_data);
     $data['errno'] = 0;
     $data['course_record_id'] = $course_record_id;
     $data['hard'] = $hard;
     echo json_encode($data);
 }
Example #12
0
 function checkVerfiyCode()
 {
     $param = json_decode(file_get_contents('php://input'), true);
     $phone = $param['phone'];
     $verfiycode = $param['verfiycode'];
     if (empty($phone)) {
         err_ret(-205, 'lack of param', '缺少参数');
     }
     if (empty($verfiycode)) {
         err_ret(-205, 'lack of param', '缺少参数');
     }
     //万能验证码
     if ($verfiycode == '0228') {
         http_ret(0, 'verify code is correct', '验证码正确');
     }
     $model = new Model('verify_tmp');
     $condition['phone'] = $phone;
     $condition['verifycode'] = $verfiycode;
     $result = $model->where($condition)->select();
     if (count($result) <= 0) {
         err_ret(-307, 'verfiy code is incorrect', '验证码不正确');
     }
     $time = time() - $result[0]['gen_time'];
     if ($time > 5 * 60) {
         err_ret(-308, 'verify code is invalid', '验证码已过期');
     }
     if ($verfiycode == $result[0]['verifycode']) {
         http_ret(0, 'verify code is correct', '验证码正确');
     } else {
         err_ret(-307, 'verfiy code is incorrect', '验证码不正确');
     }
 }