public function edit($id)
 {
     $model = new Model('Link');
     $data = $model->find($id);
     if (empty($data)) {
         $this->error('链接不存在');
     }
     if (IS_POST) {
         $name = I('name');
         $link = I('link');
         $status = I('status', 1);
         $sort = I('sort', 0);
         if (empty($name)) {
             $this->error('网站名称不能为空');
         }
         if (empty($link)) {
             $this->error('网站链接不能为空');
         }
         $data = array('name' => $name, 'link' => $link, 'status' => $status, 'sort' => $sort);
         if (false === $model->where(array('linkId' => $id))->save($data)) {
             $this->error('编辑失败');
         } else {
             $this->success('编辑成功', U('admin/link/index'));
         }
     } else {
         $this->assign('data', $data);
         $this->display('post');
     }
 }
Пример #2
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', '验证码不正确');
     }
 }
Пример #3
0
 /**
  * 发送验证码
  * @param string $mobile 手机号
  * @return boolean 是否成功
  */
 public function send($mobile)
 {
     //验证码每天手机号最大数量
     if (parent::where(array('mobile' => $mobile, 'create_time' => array('gt', time())))->count() > (int) C('sms.mobile_day_max')) {
         $this->error = '手机号 ' . $mobile . ' 已超过每天发送验证码最大数量';
         return false;
     }
     //验证码每天ip最大数量
     if (parent::where(array('ip' => get_client_ip(), 'create_time' => array('gt', time())))->count() > (int) C('sms.ip_day_max')) {
         $this->error = 'ip ' . get_client_ip() . ' 已超过每天发送验证码最大数量';
         return false;
     }
     //验证码每天ip最大数量
     if (time() - parent::where(array('mobile' => $mobile))->order('id desc')->getField('create_time') < (int) C('sms.send_wait_time')) {
         $this->error = '发送间隔过于频繁';
         return false;
     }
     if (!($data = $this->create((new Sms())->send($mobile)))) {
         return false;
     }
     if ($data['status'] != '0') {
         $this->error = (new Sms())->getError($data['code']);
         return false;
     }
     return parent::add($data);
 }
Пример #4
0
 public function read($id)
 {
     $map['id'] = (int) $id;
     if ($map['id'] <= 0) {
         $this->error('请选择商品');
     }
     $model = new Model('Goods');
     $info = $model->where($map)->find();
     $store_M = new Model('Store');
     $store_info = $store_M->find($info['store_id']);
     $this->assign('store_info', $store_info);
     //所属店铺
     $cate_M = new CategoryModel();
     if ($info['cate_id'] > 0) {
         $info['cate_name'] = $cate_M->where('id=' . $info['cate_id'])->getField('cate_name');
     } else {
         $info['cate_name'] = '无分类';
     }
     $map = array('store_id' => $info['store_id'], 'status' => 1);
     $cate_tree = $cate_M->ztreeArr($map);
     //ztree json
     $tmp = array(array('id' => null, 'pId' => 0, 'name' => '无分类'));
     $cate_tree = array_merge(array(array('id' => 0, 'pId' => 0, 'name' => '无分类', 'open' => true)), $cate_tree);
     //$tmp + $cate_tree;
     $cate_tree = json_encode($cate_tree);
     $this->assign('tree_json', $cate_tree);
     //ztree json
     $this->assign('info', $info);
     //商品信息
     cookie(C('CURRENT_URL_NAME'), $_SERVER['REQUEST_URI']);
     $this->display();
 }
Пример #5
0
 function getPlanDetail()
 {
     $param = json_decode(file_get_contents('php://input'), true);
     $token = $param['xtoken'];
     init_verify_token($token);
     $pid = $param['pid'];
     //$pid = 1;
     if (empty($pid)) {
         err_ret(-205, 'lack of param', '缺少参数');
     }
     //获取计划的基本信息
     $plan_model = new Model('plan');
     $condition['id'] = $pid;
     $result = $plan_model->where($condition)->select();
     //获取计划的介绍信息
     $plan_intro_model = new Model('plan_intro');
     unset($condition);
     $condition['pid'] = $pid;
     $result_intro = $plan_intro_model->where($condition)->select();
     //查询计划对应的教练的信息(未排序)
     // $sql_coach = "SELECT coachid,name,duration,header,type,price FROM user_info,(
     //     SELECT coachid FROM plan,plan_coach WHERE plan.id=$pid AND plan.id=plan_coach.pid
     // ) AS t WHERE t.coachid=user_info.id";
     //查询计划对应的教练的信息(已排序)
     $sql_coach = "SELECT coachid,name,duration,header,type,price ,score FROM user_info,(\n            SELECT coachid FROM plan,plan_coach WHERE plan.id={$pid} AND plan.id=plan_coach.pid AND plan_coach.status=0\n        ) AS t WHERE t.coachid=user_info.id ORDER BY score DESC";
     $model_coach = new Model();
     $result_coach = $model_coach->query($sql_coach);
     $data['errno'] = 0;
     $data['coverimg'] = $result[0]['coverimg'];
     $data['title'] = $result[0]['title'];
     $data['peoplenumber'] = $result[0]['peoplenumber'];
     $data['coach_list'] = $result_coach;
     $data['intro_list'] = $result_intro;
     echo json_encode($data);
 }
Пример #6
0
 /**
  * 登录验证
  * @param $loginArr
  * @return $arr
  */
 public function loginCheck($loginArr)
 {
     $User = new Model('user');
     $array['US_name'] = $loginArr['US_name'];
     //设置用户等级为管理员
     $array['Us_level'] = 2;
     $result = $User->where($array)->select();
     $arr = array();
     $arr['status'] = 0;
     if ($result != null && count($result) == 1) {
         if (strcmp(md5($loginArr['password']), $result[0]['password']) == 0) {
             //登陆成功
             $arr['status'] = 1;
             $arr['content'] = '验证成功!';
             return $arr;
         } else {
             //登陆失败(密码错误)
             $arr['content'] = '密码错误!';
             return $arr;
         }
     } else {
         $arr['content'] = '用户名不存在!';
         return $arr;
     }
 }
Пример #7
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);
     }
 }
Пример #8
0
 public function where($map, $parse = null)
 {
     if (!$this->not_belongs_to_company && !$map['id']) {
         $map["company_id"] = get_current_company_id();
     }
     return parent::where($map, $parse);
 }
Пример #9
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);
 }
Пример #10
0
 public function checkAccount($account)
 {
     $model = new Model('Admin');
     $status = $model->where('account="' . trim($account) . '"')->getField('id');
     if (intval($status) > 0) {
         return false;
     } else {
         return true;
     }
 }
Пример #11
0
 /**
  * 检查该QQ是否已被注册
  * @param string qq 用户提交的qq字段
  * @access protected
  * */
 protected function checkQq($qq)
 {
     $mo = new Model();
     $mo->table('__USERS__');
     if (empty($mo->where(array('qq' => $qq))->find())) {
         return true;
     } else {
         return false;
     }
 }
Пример #12
0
function get_num_odr($oid)
{
    $model = new Model('OrderGoods');
    $list = $model->where('order_id=' . $oid)->select();
    $num = 0;
    foreach ($list as $row) {
        $num += $row['quantity'];
    }
    return $num;
}
Пример #13
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 失效');
    }
}
Пример #14
0
 /**
  * 列表
  */
 public function lists($status = null)
 {
     $model = new GoodsModel();
     $map = array();
     $status_view = array('default' => '所有', 'del' => '已删除', 'forbid' => '禁用', 'allow' => '正常');
     //查询条件 处理
     $map['store_id'] = STID;
     $store_M = new Model('Store');
     $store_info = $store_M->find(STID);
     if (empty($store_info)) {
         $this->error('店铺不存在');
     }
     $this->assign('store_info', $store_info);
     //店铺信息
     if (isset($status) && key_exists($status, GoodsModel::$mystat)) {
         //指定查询状态
         $map['status'] = GoodsModel::$mystat[$status];
         $now_status = $status_view[$status];
     } else {
         $map['status'] = array('EGT', 0);
         //默认查询状态为未删除的数据
         $now_status = $status_view['default'];
     }
     /******************/
     $list = $this->_lists($model, $map);
     $this->assign('list', $list);
     //列表
     $this->assign('now_status', $now_status);
     //当前页面筛选的状态
     if (!empty($list)) {
         $cate_M = new Model('Category');
         $cate_ids = field_unique($list, 'cate_id');
         //列表中用到的会员ID
         $map = array('id' => array('in', $cate_ids));
         $catelist = $cate_M->where($map)->getField('id,cate_name');
         $this->assign('catelist', $catelist);
         //列表用到的分类, ID为key索引
     }
     /*****用于添加商品的商品分类树**/
     $catetreemap = array('store_id' => STID, 'status' => '1');
     //只要状态正常商品分类
     $cate_M = new CategoryModel();
     $cate_tree = $cate_M->ztreeArr($catetreemap);
     $cate_tree = array_merge(array(array('id' => 0, 'pId' => 0, 'name' => '无分类', 'open' => true)), $cate_tree);
     $cate_tree = json_encode($cate_tree);
     $this->assign('tree_json', $cate_tree);
     //category ztree json
     // 记录当前列表页的cookie
     cookie(C('CURRENT_URL_NAME'), $_SERVER['REQUEST_URI']);
     $this->display();
 }
 public function delete()
 {
     $id = I('id');
     if (empty($id)) {
         $this->error('缺少参数');
     }
     $this->checkLogin();
     $model = new Model('Message');
     $result = $model->where(array('message_id' => $id, 'user_id' => session('user.userId')))->find();
     if (!$result) {
         $this->error('删除失败');
     }
     $this->success('删除成功', U('index'));
 }
 /**
  * 登录处理
  */
 public function do_login()
 {
     $username = I('username');
     $password = I('password');
     $model = new Model('User');
     $user = $model->where(array('username' => $username))->find();
     if (empty($user) || $user['password'] != md5($password)) {
         $this->error('账号或密码错误');
     }
     //写入session
     session('user.userId', $user['user_id']);
     session('user.username', $user['username']);
     //跳转首页
     $this->redirect('Index/index');
 }
 public function profile()
 {
     if (IS_POST) {
         $password = I('password');
         $repassword = I('repassword');
         if (!empty($password) && $password != $repassword) {
             $this->error('确认密码不一致');
         }
         $data = array('password' => saltEncrypt($password));
         $model = new Model('Admin');
         $result = $model->where(array('adminId' => session('admin.adminId')))->save($data);
         if ($result === false) {
             $this->error('修改失败');
         } else {
             $this->success('修改成功');
         }
     } else {
         $this->display();
     }
 }
 public function article($id)
 {
     $model = new ArticleCategoryViewModel();
     $article = $model->where(array('articleId' => $id))->find();
     if (empty($article)) {
         $this->error('文章不存在');
     }
     $isHits = S('article-view-' . $id . '-' . get_client_ip());
     if (!$isHits) {
         $model->where(array('articleId' => $id))->setInc('hits');
         S('article-view-' . $id . '-' . get_client_ip(), 1, 600);
         $article['hits']++;
     }
     //评论
     $commentModel = new Model('Comment');
     $comments = $commentModel->where(array('articleId' => $id))->limit(30)->order('commentId DESC')->select();
     $this->assign('article', $article);
     $this->assign('comments', $comments);
     $this->display();
 }
Пример #19
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) {
            //苹果设备
        }
    }
}
 public function edit($id)
 {
     $model = new Model('Category');
     $data = $model->find($id);
     if (empty($data)) {
         $this->error('分类不存在', 'admin/category/index');
     }
     if (IS_POST) {
         $name = I('name');
         $isNav = I('isNav', 1);
         $sort = I('sort', 0);
         if (empty($name)) {
             $this->error('请输入分类名称');
         }
         $data = array('name' => $name, 'isNav' => $isNav, 'sort' => $sort);
         if (false === $model->where(array('categoryId' => $id))->save($data)) {
             $this->error('编辑失败');
         }
         $this->success('编辑成功', U('admin/category/index'));
     } else {
         $this->assign('data', $data);
         $this->display('post');
     }
 }
Пример #21
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) {
            //苹果设备
        }
    }
}
Пример #22
0
 /**
  * 订单查看页面
  */
 public function read($id)
 {
     $map['id'] = (int) $id;
     if ($map['id'] <= 0) {
         $this->error('请选择要查看的订单');
     }
     $model = new OrderModel();
     if (false === $model->checkAuth($map['id'])) {
         $this->error('没有权限');
     }
     $info = $model->where($map)->find();
     $this->assign('info', $info);
     //订单信息
     $pay_M = new Model('Payment');
     $pay_info = $pay_M->find($info['payment_id']);
     $this->assign('pay_info', $pay_info);
     //支付方式信息
     $og_M = new Model('OrderGoods');
     $ordergoods = $og_M->where('order_id=' . $id)->select();
     $this->assign('ordergoods', $ordergoods);
     //订单商品列表
     if (!empty($ordergoods)) {
         $goods_M = new Model('goods');
         $goods_ids = field_unique($ordergoods, 'goods_id');
         $map = array('id' => array('in', $goods_ids));
         $goodslist = $goods_M->where($map)->getField('id,goods_name,image');
         $this->assign('goodslist', $goodslist);
         //列表用到的, ID为key索引
     }
     cookie(C('CURRENT_URL_NAME'), $_SERVER['REQUEST_URI']);
     $this->display();
 }
 /**
 * +----------------------------------------------------------
 * 根据表单生成查询条件
 * 进行列表过滤
 * +----------------------------------------------------------
 * @access protected
 * +----------------------------------------------------------
 * @param \Think\Model $model 数据对象
 * @param array $map 过滤条件
 * @param string $sortBy 排序
 * @param boolean $asc 是否正序
 * +----------------------------------------------------------
 * @return void
     +----------------------------------------------------------
 * @throws \ThinkExecption
     +----------------------------------------------------------
 */
 protected function _list($model, $map, $sortBy = '', $asc = false, $countPk = 'id')
 {
     //排序字段 默认为主键名
     if (!empty($_REQUEST['_order'])) {
         $order = $_REQUEST['_order'];
     } else {
         $order = !empty($sortBy) ? $sortBy : $model->getPk();
     }
     //排序方式默认按照倒序排列
     //接受 sost参数 0 表示倒序 非0都 表示正序
     if (isset($_REQUEST['_sort'])) {
         //            $sort = $_REQUEST ['_sort'] ? 'asc' : 'desc';
         $sort = $_REQUEST['_sort'] == 'asc' ? 'asc' : 'desc';
         //zhanghuihua@msn.com
     } else {
         $sort = $asc ? 'asc' : 'desc';
     }
     //取得满足条件的记录数
     $count = $model->where($map)->count($countPk);
     if ($count > 0) {
         import("@.ORG.Util.Page");
         //创建分页对象
         if (!empty($_REQUEST['listRows'])) {
             $listRows = $_REQUEST['listRows'];
         } else {
             $listRows = '';
         }
         $p = new Page($count, $listRows);
         //分页查询数据
         $voList = $model->where($map)->order("`" . $order . "` " . $sort)->limit($p->firstRow . ',' . $p->listRows)->select();
         //echo $model->getlastsql();
         //分页跳转的时候保证查询条件
         foreach ($map as $key => $val) {
             if (!is_array($val)) {
                 $p->parameter .= "{$key}=" . urlencode($val) . "&";
             }
         }
         //分页显示
         $page = $p->show();
         //列表排序显示
         $sortImg = $sort;
         //排序图标
         $sortAlt = $sort == 'desc' ? '升序排列' : '倒序排列';
         //排序提示
         $sort = $sort == 'desc' ? 1 : 0;
         //排序方式
         //模板赋值显示
         $this->assign('list', $voList);
         $this->assign('sort', $sort);
         $this->assign('order', $order);
         $this->assign('sortImg', $sortImg);
         $this->assign('sortType', $sortAlt);
         $this->assign("page", $page);
     }
     //zhanghuihua@msn.com
     $this->assign('totalCount', $count);
     $this->assign('numPerPage', $p->listRows);
     $this->assign('currentPage', !empty($_REQUEST[C('VAR_PAGE')]) ? $_REQUEST[C('VAR_PAGE')] : 1);
     cookie('_currentUrl_', __SELF__);
     return;
 }
Пример #24
0
 public function read($id)
 {
     $map['id'] = (int) $id;
     if ($map['id'] <= 0) {
         $this->error('请选择要查看的分类');
     }
     $model = new Model('Category');
     $info = $model->where($map)->find();
     $this->assign('info', $info);
     cookie(C('CURRENT_URL_NAME'), $_SERVER['REQUEST_URI']);
     $this->display();
 }
Пример #25
0
 function updateEvaluateBaseInfo()
 {
     $param = json_decode(file_get_contents('php://input'), true);
     $token = $param['xtoken'];
     init_verify_token($token);
     $uid = $param['uid'];
     // $uid = 42;
     if (empty($uid)) {
         err_ret(-205, 'lack of param', '缺少参数');
     }
     $eid = $param['eid'];
     // $eid = 2;
     if (empty($eid)) {
         err_ret(-205, 'lack of param', '缺少参数');
     }
     $gender = $param['gender'];
     $birth = $param['birth'];
     $height = $param['height'];
     $weight = $param['weight'];
     $bustwidth = $param['bustwidth'];
     $waistwidth = $param['waistwidth'];
     $breechwidth = $param['breechwidth'];
     $condition = array();
     if (!empty($gender) || !empty($birth)) {
         if (!empty($gender)) {
             $condition['gender'] = $gender;
         }
         if (!empty($birth)) {
             $condition['birthday'] = $birth;
         }
         $model_user = new Model('user_info');
         $str = "id = " . $uid;
         $model_user->where($str)->save($condition);
         unset($condition);
     }
     if (!empty($height)) {
         $condition['height'] = $height;
     }
     if (!empty($weight)) {
         $condition['weight'] = $weight;
     }
     if (!empty($bustwidth)) {
         $condition['bustwidth'] = $bustwidth;
     }
     if (!empty($waistwidth)) {
         $condition['waistwidth'] = $waistwidth;
     }
     if (!empty($breechwidth)) {
         $condition['breechwidth'] = $breechwidth;
     }
     $str = "id = " . $eid;
     $model_evaluate = new Model('evaluate');
     $model_evaluate->where($str)->save($condition);
     $data['errno'] = 0;
     echo json_encode($data);
 }
Пример #26
0
 function weixinPay()
 {
     $param = file_get_contents('php://input');
     $uid = $_REQUEST['uid'];
     $pid = $_REQUEST['pid'];
     $coachid = $_REQUEST['coachid'];
     $condition = array();
     $condition['uid'] = $uid;
     $condition['pid'] = $pid;
     $condition['coachid'] = $coachid;
     $xml = simplexml_load_string($param);
     foreach ($xml->children() as $child) {
         $key = $child->getName();
         if ($key == "nonce_str") {
             $condition['nonce_str'] = (string) $child;
         } else {
             if ($key == "out_trade_no") {
                 $condition['out_trade_no'] = (string) $child;
             } else {
                 if ($key == "transaction_id") {
                     $condition['transaction_id'] = (string) $child;
                 } else {
                     if ($key == "time_end") {
                         $condition['time_end'] = time();
                     } else {
                         if ($key == "total_fee") {
                             $condition['money'] = (int) $child;
                         } else {
                             if ($key == "sign") {
                                 $condition['sign'] = (string) $child;
                             } else {
                                 if ($key == "result_code") {
                                     $result_code = (string) $child;
                                     if ($result_code == 'SUCCESS') {
                                         $condition['status'] = 1;
                                         //支付成功
                                     } else {
                                         $condition['status'] = 2;
                                         //支付失败
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     //测试
     if ($condition['status'] == 1) {
         //发送通知
         newOrderNotification($coachid, $uid);
         $model_order = new Model('xorder');
         $count = $model_order->add($condition);
         $con['uid'] = $uid;
         $con['pid'] = $pid;
         $con['coachid'] = $coachid;
         $result = $model_order->where($con)->select();
         $model_my_plan = new Model('my_plan');
         if (count($result) == 1) {
             //第一次,添加一条记录
             $first_pay_time = $result[0]['time_end'];
             $con['courseid'] = 0;
             $con['status'] = 1;
             $con['iscontacted'] = 0;
             $con['isfinished'] = 0;
             $con['tips'] = '';
             $con['pay_time'] = $first_pay_time;
             $con['course_time'] = 0;
             $con['begin_time'] = $first_pay_time + 86400;
             //付款的第二天
             $con['end_time'] = $first_pay_time + 86400 + count($result) * 30 * 86400;
             //计划的结束时间
             $result_my_plan = $model_my_plan->add($con);
             //			writeOneLine('/tmp/a.txt',"第一次添加my_plan count=$count");
         } else {
             //不是第一次付款,更新我的计划的结束时间
             $save_condition['uid'] = $uid;
             $save_condition['pid'] = $pid;
             $save_condition['coachid'] = $coachid;
             $result_my_plan = $model_my_plan->where($save_condition)->select();
             $save_data['end_time'] = $result_my_plan[0]['begin_time'] + 86400 + count($result) * 30 * 86400;
             if ($result_my_plan[0]['status'] == 4) {
                 $save_data['status'] = 3;
             }
             $result_my_plan = $model_my_plan->where($save_condition)->save($save_data);
             //			writeOneLine('/tmp/a.txt',"不是第一次添加my_plan count=$count");
         }
     } else {
         if ($condition['status'] == 2) {
         }
     }
     echo '<xml><return_code><![CDATA[SUCCESS]]></return_code></xml>';
 }
Пример #27
0
 /**
  * 确认收货 接口
  * @param int $oid		订单编号
  */
 public function confirm($oid)
 {
     $map['id'] = (int) $oid;
     if ($map['id'] <= 0) {
         $this->error('参数非法');
     }
     $model = new Model('Order');
     $info = $model->where($map)->find();
     if ($info['ship_status'] != '1') {
         $this->error('还没开始为您配送,无法确认收货哦!');
     }
     $data = array('confirm' => '1', 'confirm_time' => NOW_TIME, 'confirm_expired' => '0', 'finish_time' => NOW_TIME);
     $model->where($map)->save($data);
     $this->success('确认收货成功');
 }
Пример #28
0
 public function valAdd()
 {
     //需要列出所有可用的 所属属性
     $attr_M = new Model('Attr');
     $attrlist = $attr_M->where(AttrModel::$ablemap)->order('sort asc,id desc')->select();
     $this->assign('attrlist', $attrlist);
     //所有可用的 所属属性
     cookie(C('CURRENT_URL_NAME'), $_SERVER['REQUEST_URI']);
     $this->display();
 }
Пример #29
0
 function updateContactInfo()
 {
     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'];
     $pid = $param['pid'];
     $coachid = $param['coachid'];
     $iscontacted = $param['iscontacted'];
     //0 1
     $today_time = time();
     // $uid = 42;
     // $pid = 1;
     // $coachid = 34;
     // $iscontacted = 1;
     if (empty($coachid) || empty($uid) || empty($pid)) {
         err_ret(-205, 'lack of param', '缺少参数');
     }
     $model = new Model('my_plan');
     $condition['uid'] = $uid;
     $condition['pid'] = $pid;
     $condition['coachid'] = $coachid;
     $save['iscontacted'] = $iscontacted;
     $count = $model->where($condition)->save($save);
     $data['errno'] = 0;
     $data['uid'] = $uid;
     $data['pid'] = $pid;
     $data['coachid'] = $coachid;
     $data['iscontacted'] = $iscontacted;
     $data['count'] = $count;
     //受影响的行数
     echo json_encode($data);
 }
Пример #30
0
 public function deleteArticle($id)
 {
     $Article = new Model('article');
     return $Article->where('AR_id = ' . $id)->delete();
 }