コード例 #1
0
 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);
 }
コード例 #2
0
 function checkTradeStatus()
 {
     $param = json_decode(file_get_contents('php://input'), true);
     $token = $param['xtoken'];
     init_verify_token($token);
     $nonceStr = $param['noncestr'];
     if (empty($nonceStr)) {
         err_ret(-205, 'lack of param', '缺少参数');
     }
     $model = new Model('xorder');
     $condition['nonce_str'] = $nonceStr;
     $result = $model->where($condition)->select();
     if (count($result) > 0 && $result[0]['status'] == 1) {
         $data['errno'] = 0;
         $data['noncestr'] = $nonceStr;
         echo json_encode($data);
     } else {
         err_ret(-401, 'No the record', '数据库中无记录');
     }
 }
コード例 #3
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);
 }
コード例 #4
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);
 }
コード例 #5
0
 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", "添加体能评估失败");
     }
 }
コード例 #6
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);
 }
コード例 #7
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);
 }