فهرست منبع

删除无用代码

lizhen_gitee 9 ماه پیش
والد
کامیت
1248273940
2فایلهای تغییر یافته به همراه0 افزوده شده و 3134 حذف شده
  1. 0 1171
      application/api/controller/Index.php
  2. 0 1963
      application/api/controller/User.php

+ 0 - 1171
application/api/controller/Index.php

@@ -30,1178 +30,7 @@ class Index extends Api
         $this->success('请求成功');
     }
 
-    //轮播图
-    public function banner()
-    {
-        $list = Db::name('banner')->field('id, title, image, url')->where(['status' => 0])->order('weigh', 'desc')->select();
-        $list = list_domain_image($list, ['image']);
-
-        $this->success('轮播图', $list);
-    }
-
-    //活动列表
-    public function activelist() {
-        $type = input('type', 0, 'intval'); //分类:1=休闲,2=中度
-        $keyword = input('keyword', '', 'trim'); //关键字
-
-//        $where['signupendtime'] = ['gt', time()];
-        $where['status'] = ['neq', 3];
-        $where['showstatus'] = 1;
-        if ($type) {
-            $where['type'] = $type;
-        }
-        if ($keyword !== '') {
-            $where['title|desc|remark|collectionplace|leader'] = ['like', '%'.$keyword.'%'];
-        }
-
-        $list = Db::name('active')->field('id, type, title, desc, remark, image, price, maxperson, currentperson, status')
-            ->where($where)->page($this->page, $this->pagenum)->order('weigh, createtime desc')->select();
-
-        $list = list_domain_image($list, ['image']);
-        foreach ($list as &$v) {
-            if ($v['maxperson'] <= $v['currentperson']) {
-                $v['is_full'] = 1;
-            } else {
-                $v['is_full'] = 0;
-            }
-            $v['surplusperson'] = $v['maxperson'] - $v['currentperson'];
-        }
-
-        $this->success('活动列表', $list);
-    }
-
-    //活动详情
-    public function activeinfo() {
-        $id = input('id', 0, 'intval');
-        if (!$id) {
-            $this->error('参数缺失');
-        }
-
-        $info = Db::name('active')->find($id);
-        if (!$info) {
-            $this->error('数据不存在');
-        }
-
-        $info = info_domain_image($info, ['image']);
-        $info['starttime'] = date('Y-m-d H:i', $info['starttime']);
-        $info['endtime'] = date('Y-m-d H:i', $info['endtime']);
-        $info['collectiontime'] = date('Y-m-d H:i', $info['collectiontime']);
-        $info['signupendtime'] = date('Y-m-d H:i', $info['signupendtime']);
-        $info['refundendtime'] = date('Y-m-d H:i', $info['refundendtime']);
-        //查询已报名列表
-        $active_people = Db::name('active_people')->where(['active_id' => $id, 'status' => ['neq', 3]])->field('user_id, name, createtime')->select();
-        $user = Db::name('user');
-        foreach ($active_people as &$v) {
-            $user_info = $user->field('nickname, avatar')->where(['id' => $v['user_id']])->find();
-            $v['name'] = $user_info['nickname'];
-            $v['avatar'] = $user_info['avatar'];
-            $v['createtime'] = date('Y-m-d H:i:s', $v['createtime']);
-        }
-
-        $info['active_people'] = $active_people;
-        $info['customer_service'] = config('site.customer_service') ? config('site.customer_service') : ''; //客服电话
-
-        $this->success('活动详情', $info);
-    }
-
-    //报名活动之前检查
-    public function beforesignup() {
-        $id = input('id', 0, 'intval'); //活动id
-        if (!$id) {
-            $this->error('请选择要报名的活动');
-        }
-        $info = Db::name('active')->find($id);
-        if (!$info) {
-            $this->error('活动不存在');
-        }
-        if ($info['status'] == 2) {
-            $this->error('活动已经结束');
-        }
-        if ($info['status'] == 3) {
-            $this->error('活动已经取消');
-        }
-        if ($info['showstatus'] != 1) {
-            $this->error('活动暂时不能报名');
-        }
-        if ($info['signupendtime'] < time()) {
-            $this->error('活动报名已经截止');
-        }
-        if ($info['currentperson'] >= $info['maxperson']) {
-            $this->error('活动名额已满');
-        }
-        //检查自己信息是否完善
-        if (!$this->auth->realname) {
-            $this->success('请在个人资料中完善真实姓名', ['code' => 3]);
-        }
-        if (!$this->auth->idcard) {
-            $this->success('请在个人资料中完善身份证号', ['code' => 3]);
-        }
-        if (!$this->auth->emergencycontact) {
-            $this->success('请在个人资料中完善紧急联系人', ['code' => 3]);
-        }
-        if (!$this->auth->contactmobile) {
-            $this->success('请在个人资料中完善紧急联系方式', ['code' => 3]);
-        }
-
-        $this->success('检查通过');
-    }
-
-    //查询可用优惠券
-    public function canusercoupon() {
-        $price = input('price', '', 'trim'); //价格
-        if (!preg_match('/^[0-9]+(.[0-9]{1,2})?$/', $price) || $price < 0) {
-            $this->error('价格错误');
-        }
-
-        $where['user_id'] = $this->auth->id;
-        $where['endtime'] = ['egt', time()];
-        $where['status'] = 0;
-        $map = 'type = 1 or (type = 2 and minmoney <= '.$price.')';
-
-        $list = Db::name('user_coupon')->field('id, title, desc, type, money, minmoney')->where($where)->where($map)->select();
-//        p(\db()->getLastSql());
-
-        $this->success('查询可用优惠券', $list);
-    }
-    
-    //报名活动
-    public function signupactive() {
-        //检查自己信息是否完善
-        if (!$this->auth->realname || !$this->auth->idcard || !$this->auth->emergencycontact || !$this->auth->contactmobile) {
-            $this->success('请在个人资料中完善资料', ['code' => 3]);
-        }
-
-        $id = input('id', 0, 'intval'); //活动id
-//        $collectionplace = input('collectionplace', '', 'trim'); //集合地点
-        //人员信息json串:
-        // name姓名 credtype证件类型 idcard身份证号 mobile手机号 emergencycontact紧急联系人 contactmobile紧急联系方式
-        // insurance保险 originalprice原价  vipprice会员价 coupon_id用户优惠券ID is_free是否使用免费次数:0=否,1=是
-        // price小计  is_self是否本人:0=否,1=是  collectionplace集合地点
-        $active_people = input('active_people', '', 'trim');
-        $paytype = input('paytype', 0, 'intval'); //支付方式:0=余额,1=微信
-        $total_price = input('total_price', 0, 'trim'); //总价格
-
-//        if ($collectionplace === '' || iconv_strlen($collectionplace, 'utf-8') > 255) {
-//            $this->error('请选择集合地点');
-//        }
-        if (!preg_match('/^[0-9]+(.[0-9]{1,2})?$/', $total_price) || $total_price < 0) {
-            $this->error('合计价格错误');
-        }
-        if (!in_array($paytype, [0, 1])) {
-            $this->error('支付错误');
-        }
-        if ($total_price == 0 && $paytype != 0) {
-            $this->error('请选择余额支付');
-        }
-        //检查活动信息
-        if (!$id) {
-            $this->error('请选择要报名的活动');
-        }
-        $info = Db::name('active')->find($id);
-        if (!$info) {
-            $this->error('活动不存在');
-        }
-        if ($info['status'] == 2) {
-            $this->error('活动已经结束');
-        }
-        if ($info['status'] == 3) {
-            $this->error('活动已经取消');
-        }
-        if ($info['showstatus'] != 1) {
-            $this->error('活动暂时不能报名');
-        }
-        if ($info['signupendtime'] < time()) {
-            $this->error('活动报名已经截止');
-        }
-        if ($info['currentperson'] >= $info['maxperson']) {
-            $this->error('活动名额已满');
-        }
-        //检查人员信息
-        if (!$active_people) {
-            $this->error('请添加报名人员信息');
-        }
-        $active_people_arr = json_decode($active_people, true);
-        if (!$active_people_arr) {
-            $this->error('请添加报名人员信息');
-        }
-        if ($info['currentperson'] + count($active_people_arr) > $info['maxperson']) {
-            $this->error('活动名额不足');
-        }
-        //会员信息
-        $vip_info = Db::name('vip')->find($this->auth->maxlevel);
-        if (!$vip_info) {
-            $this->error('会员信息缺失,请联系管理员');
-        }
-        $_data = [];
-        $total_amount = 0; //总价格验证
-        $active_people = Db::name('active_people'); //报名人员表
-        $active_people_modify = Db::name('active_people_modify'); //报名修改信息表
-        $user_coupon = Db::name('user_coupon');
-        foreach ($active_people_arr as $k => &$v) {
-            $data = [];
-            //检查信息
-            if (!$v['name'] || iconv_strlen($v['name'], 'utf-8') > 50) {
-                $this->error('请输入正确姓名');
-                break;
-            }
-            if (iconv_strlen($v['idcard'], 'utf-8') != 18) {
-                $this->error('请输入正确身份证号');
-                break;
-            }
-            if (!is_mobile($v['mobile'])) {
-                $this->error('请输入正确手机号');
-                break;
-            }
-            if (!$v['emergencycontact'] || iconv_strlen($v['emergencycontact'], 'utf-8') > 50) {
-                $this->error('请输入紧急联系人');
-                break;
-            }
-            if (!is_mobile($v['contactmobile'])) {
-                $this->error('请输入正确紧急联系人方式');
-                break;
-            }
-            //判断是否报名过
-            $count = $active_people->where(['active_id' => $id, 'idcard' => $v['idcard'], 'status' => ['neq', 3]])->count('id');
-            if ($count) {
-                $this->error($v['name'] . $v['idcard'] . '已报名过该活动');
-                break;
-            }
-            $count2 = $active_people_modify->where(['active_id' => $id, 'idcard' => $v['idcard'], 'status' => 0])->count('id');
-            if ($count2) {
-                $this->error($v['name'] . $v['idcard'] . '已提交过修改,请等待审核');
-                break;
-            }
-            //判断证件类型和保险
-            if (!$v['credtype'] || iconv_strlen($v['credtype'], 'utf-8') > 50) {
-                $this->error('证件类型错误');
-                break;
-            }
-            if (!$v['insurance'] || iconv_strlen($v['insurance'], 'utf-8') > 50) {
-                $this->error('保险信息错误');
-                break;
-            }
-            //判断集合地点
-            if ($v['collectionplace'] === '' || iconv_strlen($v['collectionplace'] , 'utf-8') > 255) {
-                $this->error($v['name'] . '请选择集合地点');
-                break;
-            }
-            //判断用户信息
-            if ($v['is_self'] && $k == 0) {
-                //判断用户信息
-                if ($v['name'] != $this->auth->realname || $v['idcard'] != $this->auth->idcard || $v['mobile'] != $this->auth->mobile || $v['emergencycontact'] != $this->auth->emergencycontact || $v['contactmobile'] != $this->auth->contactmobile) {
-                    $this->error('本人信息错误');
-                    break;
-                }
-                //本人判断年龄 价格
-                if ($info['maxage'] > 0) {
-                    $age = $this->idcardage($this->auth->idcard);
-                    if ($age < $info['minage'] || $age > $info['maxage']) {
-                        $this->error('活动年龄限制为' . $info['minage'] . '-' . $info['maxage']);
-                        break;
-                    }
-                }
-                if ($v['is_free'] == 1) { //使用免费次数
-                    if ($info['is_free'] != 1) {
-                        $this->error('活动暂不支持免费体验');
-                        break;
-                    }
-                    if ($this->auth->freenumber <= 0) {
-                        $this->error('您的免费次数不足');
-                        break;
-                    }
-                    //检查当月是否用过免费次数
-                    $month_time = strtotime(date('Y-m-1', time()));
-                    $count = $active_people->where(['user_id' => $this->auth->id, 'is_free' => 1, 'createtime' => ['egt', $month_time]])->count('id');
-                    if ($count) {
-                        $this->error('您当月已使用过免费次数');
-                        break;
-                    }
-                    if ($v['vipprice'] != 0 || $v['price'] != 0) {
-                        $this->error($this->auth->realname . '价格错误');
-                        break;
-                    }
-                    if ($v['coupon_id']) {
-                        $this->error('使用免费体验,无法使用优惠券');
-                        break;
-                    }
-                } else { //不使用免费次数
-                    //会员价和优惠券是否可以叠加使用:0=否,1=是
-                    if ($info['is_overlying'] == 0 && $v['vipprice'] != $info['price'] && $v['coupon_id']) {
-                        $this->error('该活动不支持会员价和优惠券同时使用');
-                        break;
-                    }
-                    //计算会员价, 会员价优先顺序: 生日 > 女生特权日 > 会员价格
-                    $birthday = date('md', strtotime($this->auth->birthday));
-                    $now_day = date('md', $info['starttime']); //活动当天生日
-                    if ($birthday == $now_day) {
-                        //生日折扣
-                        if ($vip_info['birthdiscount'] > 100 || $vip_info['birthdiscount'] < 0) {
-                            $this->error('会员生日折扣错误,请联系管理员');
-                            break;
-                        }
-                        $discount = $vip_info['birthdiscount'];
-                    } elseif ($info['girldiscount'] < 100 && $info['girldiscount'] > 0 && $this->auth->gender == 2) {
-                        //女生特权日折扣
-                        $discount = $info['girldiscount'];
-                    } else {
-                        //会员折扣
-                        if ($vip_info['vipdiscount'] > 100 || $vip_info['vipdiscount'] < 0) {
-                            $this->error('会员折扣错误,请联系管理员');
-                            break;
-                        }
-                        $discount = $vip_info['vipdiscount'];
-                    }
-                    $vipprice = number_format($info['price'] * $discount / 100, 2, '.', ''); //会员价
-                    //查询优惠券
-                    if ($v['coupon_id']) {
-                        $user_coupon_info = $user_coupon->where(['id' => $v['coupon_id'], 'user_id' => $this->auth->id])->find();
-                        if (!$user_coupon_info) {
-                            $this->error('优惠券不存在');
-                        }
-                        if ($user_coupon_info['status'] != 0) {
-                            $this->error('优惠券已使用');
-                        }
-                        if ($user_coupon_info['endtime'] < time()) {
-                            $this->error('优惠券已过期');
-                        }
-                        if ($user_coupon_info['type'] == 1) {
-                            //打折券
-                            if ($user_coupon_info['money'] < 0 || $user_coupon_info['money'] > 100) {
-                                $this->error('优惠券折扣错误,请联系管理员');
-                                break;
-                            }
-                        } else {
-                            //抵扣券
-                            //会员价和优惠券是否可以叠加使用:0=否,1=是
-                            if ($info['is_overlying'] == 0) {
-                                if ($info['price'] < $user_coupon_info['minmoney']) {
-                                    $this->error('优惠券使用条件不满足');
-                                    break;
-                                }
-                            } else {
-                                if ($vipprice < $user_coupon_info['minmoney']) {
-                                    $this->error('优惠券使用条件不满足');
-                                    break;
-                                }
-                            }
-                        }
-                    }
-                    //判断价格
-                    //会员价和优惠券是否可以叠加使用:0=否,1=是
-                    if ($info['is_overlying'] == 0) {
-                        if ($v['coupon_id']) { //使用优惠券
-                            if ($v['vipprice'] != $info['price']) {
-                                $this->error('会员价显示错误');
-                                break;
-                            }
-                            if ($user_coupon_info['type'] == 1) {
-                                //打折券
-                                $coupon_price = number_format($info['price'] * (100 - $user_coupon_info['money']) / 100, 2, '.', '');
-                                $price = number_format($info['price'] - $coupon_price, 2, '.', '');
-                            } else {
-                                //抵扣券
-                                $price = number_format($info['price'] - $user_coupon_info['money'], 2, '.', '');
-                            }
-                        } else {
-                            $price = $vipprice;
-                        }
-                    } else {
-                        if ($vipprice != $v['vipprice']) {
-                            $this->error('会员价显示错误');
-                            break;
-                        }
-                        if ($v['coupon_id']) { //使用优惠券
-                            if ($user_coupon_info['type'] == 1) {
-                                //打折券
-                                $coupon_price = number_format($vipprice * (100 - $user_coupon_info['money']) / 100, 2, '.', '');
-                                $price = number_format($vipprice - $coupon_price, 2, '.', '');
-                            } else {
-                                //抵扣券
-                                $price = number_format($vipprice - $user_coupon_info['money'], 2, '.', '');
-                            }
-                        } else {
-                            $price = $vipprice;
-                        }
-                    }
-
-                    //判断小计
-                    if ($price != $v['price']) {
-                        $this->error('小计显示错误');
-                        break;
-                    }
-
-                    $data['vipprice'] = $v['vipprice']; //会员价
-                    $data['coupon_id'] = $v['coupon_id']; //优惠券id
-                    if ($v['coupon_id']) {
-                        $data['coupontype'] = $user_coupon_info['type'];
-                        $data['couponprice'] = $user_coupon_info['money'];
-                    }
-                }
-
-                $data['name'] = $this->auth->realname;
-                $data['idcard'] = $this->auth->idcard;
-                $data['mobile'] = $this->auth->mobile;
-                $data['emergencycontact'] = $this->auth->emergencycontact;
-                $data['contactmobile'] = $this->auth->contactmobile;
-            } else {
-                //帮人报名判断年龄 报名信息
-                if ($info['maxage'] > 0) {
-                    $age = $this->idcardage($v['idcard']);
-                    if ($age < $info['minage'] || $age > $info['maxage']) {
-                        $this->error('活动年龄限制为' . $info['minage'] . '-' . $info['maxage']);
-                        break;
-                    }
-                }
-                //判断是否符合满几人减免一人费用
-                //会员权限
-                if ($vip_info['manypeople'] > 1 && $k == $vip_info['manypeople'] - 1) {
-                    if ($v['price'] != 0) {
-                        $this->error('小计显示错误');
-                        break;
-                    }
-                } else {
-                    if ($v['price'] != $info['price']) {
-                        $this->error('小计显示错误');
-                        break;
-                    }
-                }
-
-                $data['name'] = $v['name'];
-                $data['idcard'] = $v['idcard'];
-                $data['mobile'] = $v['mobile'];
-                $data['emergencycontact'] = $v['emergencycontact'];
-                $data['contactmobile'] = $v['contactmobile'];
-                $data['vipprice'] = $v['price']; //会员价
-            }
-
-            $data['active_id'] = $id;
-            $data['user_id'] = $this->auth->id;
-            $data['collectionplace'] = $v['collectionplace'];
-            $data['credtype'] = $v['credtype'];
-            $data['insurance'] = $v['insurance'];
-            $data['originalprice'] = $info['price'];
-            $data['is_free'] = $v['is_free'];
-            $data['price'] = $v['price']; //小计
-            $data['is_self'] = $v['is_self'];
-            $data['createtime'] = time();
-
-            array_push($_data, $data);
-            $total_amount += $v['price'];
-        }
-
-        if ($total_amount != $total_price) {
-            $this->error('合计价格错误');
-        }
-        if ($paytype == 0) { //余额支付
-            if ($this->auth->money < $total_amount) {
-                $this->success('您的余额不足,请先去充值', ['code' => 2]);
-            }
-        }
-
-        //构建订单信息
-        $order_data['order_sn'] = date('YmdHis', time()) . rand(10000000, 99999999);
-        $order_data['active_id'] = $id;
-        $order_data['user_id'] = $this->auth->id;
-//        $order_data['collectionplace'] = $collectionplace;
-        $order_data['paytype'] = $paytype;
-        $order_data['price'] = $total_amount;
-        $order_data['number'] = count($active_people_arr);
-        $order_data['status'] = $paytype == 1 ? 0 : 1;
-        $order_data['createtime'] = time();
-        //构建活动信息
-        $active_data['currentperson'] = $info['currentperson'] + count($active_people_arr);
-        if ($info['currentperson'] + count($active_people_arr) >= $info['minperson'] && $info['status'] == 0) {
-            $active_data['status'] = 1;
-        }
-
-        //开始事务
-        Db::startTrans();
-        //修改活动表数据
-        $active_rs = Db::name('active')->where(['id' => $id, 'status' => $info['status'],'currentperson' => $info['currentperson']])->setField($active_data);
-        if (!$active_rs) {
-            Db::rollback();
-            $this->error('网络延迟,请稍后再试');
-        }
-        //添加订单
-        $rs = Db::name('active_order')->insertGetId($order_data);
-        if (!$rs) {
-            Db::rollback();
-            $this->error('网络延迟,请稍后再试');
-        }
-        //添加人员信息
-        foreach ($_data as &$v) {
-            $v['order_id'] = $rs;
-            $v['status'] = $order_data['status'];
-            $rt = $active_people->insertGetId($v);
-            if (!$rt) {
-                Db::rollback();
-                $this->error('网络延迟,请稍后再试');
-            }
-        }
-        //扣除免费次数
-        if ($info['is_free'] == 1 && $active_people_arr[0]['is_self'] == 1 && $active_people_arr[0]['is_free'] == 1) {
-            $freenumber = $this->auth->freenumber - 1;
-            $user_rs = Db::name('user')->where(['id' => $this->auth->id, 'freenumber' => $this->auth->freenumber])->setField('freenumber', $freenumber);
-            if (!$user_rs) {
-                Db::rollback();
-                $this->error('网络延迟,请稍后再试');
-            }
-        }
-        //扣除优惠券
-        if ($active_people_arr[0]['is_self'] == 1 && $active_people_arr[0]['coupon_id']) {
-            $user_coupon_rs = Db::name('user_coupon')->where(['id' => $active_people_arr[0]['coupon_id'], 'user_id' => $this->auth->id, 'status' => 0])->setField(['active_id' => $id, 'order_id' => $rs, 'status' => 1]);
-            if (!$user_coupon_rs) {
-                Db::rollback();
-                $this->error('网络延迟,请稍后再试');
-            }
-        }
-        //扣款 支付方式:0=余额,1=微信
-        if ($paytype == 0) {
-            $res = create_log(-$total_amount, '支付活动订单', $this->auth->id, 2, $rs);
-            if ($res != 1) {
-                Db::rollback();
-                $this->error('余额资金异常,请联系管理员');
-            }
-            //给上级发送优惠券
-            if ($this->auth->pre_user_id) {
-                //查询报名活动优惠券
-                $invite_coupon = Db::name('coupon')->where(['purpose' => 5, 'status' => 1])->order('weigh desc, id desc')->find();
-                if ($invite_coupon) {
-                    $invite_coupon_data = [
-                        'user_id' => $this->auth->pre_user_id,
-                        'coupon_id' => $invite_coupon['id'],
-                        'title' => $invite_coupon['title'],
-                        'desc' => $invite_coupon['desc'],
-                        'type' => $invite_coupon['type'],
-                        'money' => $invite_coupon['money'],
-                        'minmoney' => $invite_coupon['minmoney'],
-                        'purpose' => $invite_coupon['purpose'],
-                        'starttime' => time(),
-                        'endtime' => time() + $invite_coupon['effectiveday'] * 86400,
-                        'active_id' => $id,
-                        'order_id' => $rs,
-                        'createtime' => time()
-                    ];
-
-                    $invite_coupon_rs = Db::name('user_coupon')->insertGetId($invite_coupon_data);
-                    if (!$invite_coupon_rs) {
-                        Db::rollback();
-                        $this->error('发放优惠券失败');
-                    }
-                }
-            }
-
-            //发送消息
-            $data = [
-                'user_id' => $this->auth->id,
-                'type' => 1,
-                'title' => '活动通知',
-                'content' => '您已成功报名' . $info['title'] . '活动',
-                'createtime' => time()
-            ];
-            $sys_rs = Db::name('sys_msg')->insertGetId($data);
-            if (!$sys_rs) {
-                Db::rollback();
-                $this->error('网络延迟,请稍后再试');
-            }
-
-            Db::commit();
-            $this->success('报名成功');
-        } else {
-            //生成支付订单记录
-            $rechar_order['user_id'] = $this->auth->id;
-            $rechar_order['order_no'] = date('YmdHis', time()) . rand(10000000, 99999999); //微信订单编号
-            $rechar_order['money'] = $total_amount;
-            $rechar_order['purpose'] = 1; //充值用途:1=支付订单,2=充值,3=开通会员
-            $rechar_order['pay_type'] = 'wechat';
-            $rechar_order['relation_id'] = $rs;
-            $rechar_order['createtime'] = time();
-
-            $result = Db::name('rechar_order')->insertGetId($rechar_order);
-            if (!$result) {
-                Db::rollback();
-                $this->error('网络延迟,请稍后再试');
-            }
-
-            Db::commit();
-
-            //构建支付链接数据
-            $wxData['body'] = '报名活动支付';
-            $wxData['out_trade_no'] = $rechar_order['order_no'];
-            $wxData['total_fee'] = $total_amount;
-//            $wxData['total_fee'] = 0.01;
-            $wxData['openid'] = $this->auth->openid;
-
-//            require_once($_SERVER['DOCUMENT_ROOT'] . '/Plugins/Weixin/WxPay/WxPay.php');
-            $wxPay = new wxpay\WxPay(config('wxchatpay'));
-            $doResult = $wxPay->WxPayJs($wxData);
-
-            $this->success('微信支付参数返回成功', $doResult);
-        }
-    }
-
-    //根据身份证号获取年龄
-    public function idcardage($idcard = '') {
-        //截取身份证里的出生日期
-        $year = substr($idcard, 6, 4);
-        $month = substr($idcard, 10, 2);
-        $day = substr($idcard, 12, 2);
-        //获取当前日期
-        $current_year = date('Y');
-        $current_month = date('m');
-        $current_day = date('d');
-        //计算年龄
-        $age = $current_year - $year;//今年减去生日年
-        if ($month > $current_month || ($month == $current_month && $day > $current_day)) {
-            //如果出生月大于当前月或出生月等于当前月但出生日大于当前日则减一岁
-            $age--;
-        }
-
-        return $age;
-    }
-
-    //私人订制类型
-    public function personaltype() {
-        $list = Db::name('personal_type')->field('id, name')->order('weigh', 'desc')->select();
-
-        $this->success('私人订制类型', $list);
-    }
-
-    //私人订制活动类型
-    public function personalactivetype() {
-        $list = Db::name('personal_active_type')->field('id, name')->where(['pid' => 0])->order('weigh', 'desc')->select();
-
-        $list = $this->getchildtype($list);
-        $this->success('私人订制活动类型', $list);
-    }
-
-    //无限级私人订制活动类型
-    public function getchildtype($list = [])
-    {
-        $complaint_type = Db::name('personal_active_type');
-        foreach ($list as &$v) {
-            $child = $complaint_type->field('id, name')->where(['pid' => $v['id']])->order('weigh', 'desc')->select();
-            if ($child) {
-                $child = $this->getchildtype($child);
-            }
-
-            $v['child'] = $child;
-        }
-
-        return $list;
-    }
-
-    //车辆类型
-    public function car() {
-        $list = Db::name('car')->field('id, name, desc')->order('weigh', 'desc')->select();
-
-        $this->success('车辆类型', $list);
-    }
-
-    //领队
-    public function leader() {
-        $list = Db::name('leader')->field('id, name')->order('weigh', 'desc')->select();
-
-        $this->success('领队', $list);
-    }
-    
-    //私人订制出行方向
-    public function personaldirection() {
-        $list = Db::name('personal_direction')->field('id, name')->order('weigh', 'desc')->select();
-
-        $this->success('私人订制出行方向', $list);
-    }
-
-    //私人订制
-    public function personalactive() {
-        $type = input('type', '', 'trim'); //类型
-        $number = input('number', 0, 'intval'); //出行人数
-        $traveltime = input('traveltime', '', 'strtotime'); //出行时间
-        $traveday = input('traveday', 0, 'intval'); //出行天数
-        $activetype = input('activetype', '', 'trim'); //活动类型
-        $car = input('car', '', 'trim'); //车辆
-        $leader = input('leader', '', 'trim'); //领队
-        $travedirection = input('travedirection', '', 'trim'); //出行方向
-        $freerange = input('freerange', '', 'trim'); //空闲时段
-        $remark = input('remark', '', 'trim'); //留言
-
-        if (!$type || iconv_strlen($type, 'utf-8') > 50) {
-            $this->error('请选择类型');
-        }
-        if ($number <= 0) {
-            $this->error('请填写出行人数');
-        }
-        if ($traveltime < time()) {
-            $this->error('请选择正确出行时间');
-        }
-        if ($traveday <= 0) {
-            $this->error('请填写正确出行天数');
-        }
-        if (!$activetype || iconv_strlen($activetype, 'utf-8') > 50) {
-            $this->error('请选择活动类型');
-        }
-        if ($car && iconv_strlen($car, 'utf-8') > 50) {
-            $this->error('请选择车辆');
-        }
-        if ($leader && iconv_strlen($leader, 'utf-8') > 50) {
-            $this->error('请选择领队');
-        }
-        if (!$travedirection || iconv_strlen($travedirection, 'utf-8') > 50) {
-            $this->error('请选择出行方向');
-        }
-        if (!$freerange || iconv_strlen($freerange, 'utf-8') > 50) {
-            $this->error('请选择空闲时段');
-        }
-        if (iconv_strlen($remark, 'utf-8') > 500) {
-            $this->error('留言最多500字');
-        }
-
-        $data['user_id'] = $this->auth->id;
-        $data['type'] = $type;
-        $data['number'] = $number;
-        $data['traveltime'] = $traveltime;
-        $data['traveday'] = $traveday;
-        $data['activetype'] = $activetype;
-        $data['car'] = $car;
-        $data['leader'] = $leader;
-        $data['travedirection'] = $travedirection;
-        $data['freerange'] = $freerange;
-        $data['remark'] = $remark;
-        $data['createtime'] = time();
-
-        $rs = Db::name('personal_order')->insertGetId($data);
-        if (!$rs) {
-            $this->error('提交失败');
-        }
-
-        $this->success('提交成功');
-    }
-
-    //查询轮播图优惠券列表
-    public function bannercoupon() {
-        $list = Db::name('coupon')->field('id, title, desc, type, money')
-            ->where(['purpose' => 4, 'status' => 1])->page($this->page, $this->pagenum)->order('weigh desc, id desc')->select();
-
-        $user_coupon = Db::name('user_coupon');
-        foreach ($list as &$v) {
-            $v['is_receive'] = $user_coupon->where(['user_id' => $this->auth->id, 'coupon_id' => $v['id']])->count('id');
-        }
-
-        $this->success('查询轮播图优惠券列表', $list);
-    }
-
-    //领取轮播图优惠券
-    public function receivebannercoupon() {
-        $id = input('id', 0, 'intval'); //优惠券id
-
-        if (!$id) {
-            $this->error('参数缺失');
-        }
-
-        $info = Db::name('coupon')->where(['id' => $id, 'purpose' => 4])->find();
-        if (!$info) {
-            $this->error('优惠券不存在');
-        }
-        if ($info['status'] != 1) {
-            $this->error('优惠券已下架');
-        }
-
-        //查询是否已领取
-        $count = Db::name('user_coupon')->where(['user_id' => $this->auth->id, 'coupon_id' => $id])->count('id');
-        if ($count) {
-            $this->error('您已经领取过了');
-        }
-
-        $data['user_id'] = $this->auth->id;
-        $data['coupon_id'] = $id;
-        $data['title'] = $info['title'];
-        $data['desc'] = $info['desc'];
-        $data['type'] = $info['type'];
-        $data['money'] = $info['money'];
-        $data['minmoney'] = $info['minmoney'];
-        $data['purpose'] = $info['purpose'];
-        $data['starttime'] = time();
-        $data['endtime'] = time() + $info['effectiveday'] * 86400;
-        $data['createtime'] = time();
-
-        //开启事务
-        Db::startTrans();
-
-        //添加领取记录
-        $rs = Db::name('user_coupon')->insertGetId($data);
-        if (!$rs) {
-            Db::rollback();
-            $this->error('领取失败');
-        }
-
-        $rt = Db::name('user_coupon')->where(['user_id' => $this->auth->id, 'coupon_id' => $id])->count('id');
-        if ($rt != 1) {
-            Db::rollback();
-            $this->error('领取失败');
-        }
-
-        Db::commit();
-        $this->success('领取成功');
-    }
-    
-    //体验会员列表
-    public function experiencevip() {
-        $where = [];
-        if ($this->auth->maxlevel != 5) {
-            $where['id'] = ['neq', 5];
-        }
-
-        $list = Db::name('vip')->where(['id' => ['gt', $this->auth->maxlevel], 'status' => 1])->where($where)->select();
-
-        $vip_privilege = Db::name('vip_privilege');
-        foreach ($list as &$v) {
-            $v['vip_privilege'] = $vip_privilege->field('id, title, desc')
-                ->where(['vip_id' => $v['id']])->order('weigh desc')->select();
-        }
-
-        $this->success('体验会员列表', $list);
-    }
-
-    //购买体验会员
-    public function buyexperiencevip() {
-        //检查是否已经开通体验会员
-        if ($this->auth->experiencetime >= time()) {
-            $this->error('您已开通体验会员,不能重复开通');
-        }
-
-        $id = input('id', 0, 'intval');
-        if (!$id) {
-            $this->error('参数缺失');
-        }
-
-        $info = Db::name('vip')->where(['id' => $id])->find();
-        if (!$info) {
-            $this->error('会员不存在');
-        }
-        if ($info['status'] != 1) {
-            $this->error('体验会员已下架');
-        }
-        if ($info['price'] <= 0) {
-            $this->error('会员价格异常');
-        }
-        //体验会员等级必须大于成长值会员
-        if ($id <= $this->auth->maxlevel) {
-            $this->error('请开通更高等级体验会员');
-        }
-        //判断余额
-        if ($this->auth->money < $info['price']) {
-            $this->success('您的余额不足,请先去充值', ['code' => 2]);
-        }
-
-        $data['user_id'] = $this->auth->id;
-        $data['vip_id'] = $id;
-        $data['title'] = $info['title'];
-        $data['level'] = $info['level'];
-        $data['growthvalue'] = $info['growthvalue'];
-        $data['free'] = $info['free'];
-        $data['price'] = $info['price'];
-        $data['endtime'] = time() + $info['day'] * 86400;
-        $data['vipdiscount'] = $info['vipdiscount'];
-        $data['birthdiscount'] = $info['birthdiscount'];
-        $data['manypeople'] = $info['manypeople'];
-        $data['createtime'] = time();
-
-        //开启事务
-        Db::startTrans();
-
-        //添加开通记录
-        $rs = Db::name('vip_log')->insertGetId($data);
-        if (!$rs) {
-            Db::rollback();
-            $this->error('开通失败');
-        }
-        //扣除余额
-        $result = create_log(-$info['price'], '开通会员', $this->auth->id, 4, $rs);
-        if ($result != 1) {
-            Db::rollback();
-            $this->error('资金异常,请联系管理员');
-        }
-        //成长值会员信息
-        $growth_vip_info = Db::name('vip')->find($this->auth->growthlevel);
-        //修改用户表信息
-        $user_data['experiencelevel'] = $id;
-        $user_data['experiencetime'] = $data['endtime'];
-        $user_data['maxlevel'] = $id;
-        $freenumber = $this->auth->freenumber + $info['free'] - $growth_vip_info['free'];
-        $user_data['freenumber'] = $freenumber > 0 ? $freenumber : 0;
-
-        $rt = Db::name('user')->where([
-                'id' => $this->auth->id,
-                'experiencelevel' => $this->auth->experiencelevel,
-                'maxlevel' => $this->auth->maxlevel,
-                'freenumber' => $this->auth->freenumber])->setField($user_data);
-        if (!$rt) {
-            Db::rollback();
-            $this->error('开通失败');
-        }
-
-        Db::commit();
-        $this->success('开通成功');
-    }
-
-    //获取活动分享链接
-    public function activelink() {
-        $id = input('id', 0, 'intval'); //活动id
-        if (!$id) {
-            $this->error('参数缺失');
-        }
-        $info = Db::name('active')->find($id);
-        if (!$info) {
-            $this->error('活动不存在');
-        }
-        if ($info['status'] == 2) {
-            $this->error('活动已结束');
-        }
-        if ($info['status'] == 3) {
-            $this->error('活动已取消');
-        }
-        if ($info['showstatus'] != 1) {
-            $this->error('活动暂时不能报名');
-        }
-
-        $access_token = Cache::get('access_token');
-        if (!$access_token) {
-            //获取$access_token
-            $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.config('wxchatpay.app_id').'&secret='.config('wxchatpay.app_secret');
-            $result = file_get_contents($url);
-            $result = json_decode($result, true);
-            $access_token = $result['access_token'];
-            //缓存
-            Cache::set('access_token', $access_token, 7000);
-        }
-        if (!$access_token) {
-            $this->error('参数缺失');
-        }
-
-        $data['page_url'] = 'pages/home/detail?id='.$id.'&code='.$this->auth->invite_no;
-        $data['page_title'] = $info['title'];
-        $data = json_encode($data, 320);
-
-        $url = 'https://api.weixin.qq.com/wxa/genwxashortlink?access_token='.$access_token;
-        $rs = httpRequest($url, 'POST', $data);
-        $rs = json_decode($rs, true);
-        if ($rs['errcode'] != 0) {
-            $this->error('网络延迟');
-        }
-
-        $this->success('分享链接', $rs['link']);
-    }
-
-    //生成小程序邀请二维码
-    public function getqrcode($id = 0) {
-        $access_token = Cache::get('access_token');
-//        $access_token = '';
-        if (!$access_token) {
-            //获取$access_token
-            $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.config('wxchatpay.app_id').'&secret='.config('wxchatpay.app_secret');
-//            $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx326ed0bf442d2773&secret=33609a3bc45bb407f0b26816158405b8';
-            $result = file_get_contents($url);
-            $result = json_decode($result, true);
-            $access_token = $result['access_token'];
-            //缓存
-            Cache::set('access_token', $access_token, 7000);
-        }
-        if (!$access_token) {
-            $this->error('参数缺失');
-        }
-
-        $data['scene'] = 'id='.$id.'&code='.$this->auth->invite_no;
-//        $data['scene'] = 'id=AVwvR&code='.$this->auth->invite_no;
-        $data['page'] = 'pages/home/detail';
-//        $data['page'] = 'pages/product/product';
-
-        $url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" . $access_token;
-        $ch = curl_init($url);
-        $timeout = 6000;
-        curl_setopt($ch, CURLOPT_POST, 1);
-        curl_setopt($ch, CURLOPT_HEADER, 0);
-        curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
-        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
-        curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
-        curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
-        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
-        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
-        $ret = curl_exec($ch);
-        curl_close($ch);
-
-        if (is_array($ret)) {
-            return '';
-        }
-        if (json_decode($ret)) {
-            $this->error('生成失败');
-        }
-
-        $secretId = "AKIDhDTSBdoTs0rS4bx3rQijSu61f3B2cv3y"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
-        $secretKey = "f3A1btufAOL2SbT4ORDiwtZy7yYooY1D"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
-        $region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket
-        $cosClient = new Client(
-            array(
-                'region' => $region,
-                'schema' => 'https', //协议头部,默认为http
-                'credentials'=> array(
-                    'secretId'  => $secretId ,
-                    'secretKey' => $secretKey)));
-//        $local_path = "/Users/xxx/Desktop/exampleobject.txt"; //保存到用户本地路径
-        $path = "qrcode/";     // 二维码文件流存放位置
-        $fileName = time() . rand(10000,99999) . ".png";
-        $result = $cosClient->putObject(array(
-            'Bucket' => 'fireflytra-1309974405', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
-            'Key' => $path . $fileName,//'exampleobject',
-            'Body' => $ret,//fopen($local_path, 'rb'),
-        ));
-        // 请求成功
-        return 'https://' . $result['Location'];
-
-//        //上传到阿里云oss
-//        require_once './Plugins/Aliyun/aliyun-oss-php-sdk-2.3.0/autoload.php';
-//        require_once './Plugins/Aliyun/aliyun-oss-php-sdk-2.3.0/src/OSS/OssClient.php';
-//        $config = C('ALIOSS_CONFIG');
-//
-//        $oss = new \OSS\OssClient($config['KEY_ID'], $config['KEY_SECRET'], $config['END_POINT']);
-//
-//        $path = "shopqrcode/";     // 二维码文件流存放位置
-//        $fileName = time() . rand(10000,99999) . ".png";
-//
-//        // 上传到oss
-//        $result = $oss->putObject($config['BUCKET'], $path . $fileName, $ret);
-//
-//        // 获取图片url地址
-//        $oss_url = json_decode(json_encode($result), true);
-//
-//        return $oss_url['oss-request-url'];
-    }
-
-    //生成活动海报
-    public function activeposter() {
-//        $poster = Db::name('poster')->find(1);
-//        p($poster);die;
-        $id = input('id', 0, 'intval'); //活动id
-        if (!$id) {
-            $this->error('参数缺失');
-        }
-        $info = Db::name('active')->find($id);
-        if (!$info) {
-            $this->error('活动不存在');
-        }
-        if ($info['status'] == 2) {
-            $this->error('活动已结束');
-        }
-        if ($info['status'] == 3) {
-            $this->error('活动已取消');
-        }
-        if ($info['showstatus'] != 1) {
-            $this->error('活动暂时不能报名');
-        }
-
-        $data = [
-            [
-                "left" => "4px",
-                "top" => "4px",
-                "type" => "img",
-                "width" => "310px",
-                "height" => "235px",
-                "src" => one_domain_image($info['image']) //主图
-            ],
-            [
-                "left" => "100px",
-                "top" => "347px",
-                "type" => "img",
-                "width" => "115px",
-                "height" => "115px",
-                "src" => $this->getqrcode($id) //小程序二维码'https://fireflytra-1309974405.cos.ap-beijing.myqcloud.com/qrcode/165405491386733.png'
-            ]
-        ];
-        //处理标题字符
-        $child = [
-            "left" => "11px",
-            "top" => "253px",
-            "type" => "nickname",
-            "width" => "296px",
-            "height" => "50px",
-            "size" => "16px",
-            "color" => "#000",
-            "content" => mb_substr($info['title'], 0, 14)
-        ];
-        array_push($data, $child);
-        if (iconv_strlen($info['title'], 'utf-8') > 14) {
-            $child = [
-                "left" => "11px",
-                "top" => "285px",
-                "type" => "nickname",
-                "width" => "296px",
-                "height" => "50px",
-                "size" => "16px",
-                "color" => "#000",
-                "content" => mb_substr($info['title'], 14, 14)
-            ];
-
-            if (iconv_strlen($info['title'], 'utf-8') <= 28) {
-                $child['content'] = mb_substr($info['title'], 14, 14);
-            } else {
-                $child['content'] = mb_substr($info['title'], 14, 11) . '...';
-            }
-
-            array_push($data, $child);
-        }
-        //添加价格
-        $child = [
-            "left" => "11px",
-            "top" => "318px",
-            "type" => "nickname",
-            "width" => "296px",
-            "height" => "50px",
-            "size" => "16px",
-            "color" => "#FF0000",
-            "content" => $info['price'] . '元'
-        ];
-        array_push($data, $child);
-
-        $data = json_encode($data, 320);
-
-        $poster = [
-            'id' => 1,
-            'title' => '测试',
-            'waittext' => '您的专属海报正在拼命生成中,请等待片刻...',
-            'bg_image' => '/assets/img/bg.png',
-            'data' => $data,
-            'status' => 'normal',
-            'weigh' => 0,
-            'createtime' => 1653993709,
-            'updatetime' => 1653994259,
-        ];
-
-        $image = new \addons\poster\library\Image();
-        $imgurl = $image->createPosterImage($poster, $this->auth->getUser());
-
-        if (!$imgurl) {
-            $this->error('生成海报出错');
-        }
-        $imgurl = $_SERVER["REQUEST_SCHEME"]."://".$_SERVER["HTTP_HOST"] . '/' . $imgurl;
-        $this->success('', $imgurl);
-    }
-    
-    //查询帮报名过的人员信息
-    public function getpeopleinfo() {
-        $name = input('name', '', 'trim'); //名称
-        if (!$name) {
-            $this->success('信息', (object)[]);
-        }
-
-        $info = Db::name('active_people')->field('name, idcard, mobile, emergencycontact, contactmobile')->where(['user_id' => $this->auth->id, 'name' => $name])->find();
-
-        if (!$info) {
-            $info = (object)[];
-        }
-
-        $this->success('信息', $info);
-    }
 
-    ////////////////////////////////////////////////////
 
     //视频分类列表
     public function videotype() {

+ 0 - 1963
application/api/controller/User.php

@@ -30,1969 +30,6 @@ class User extends Api
 
     }
 
-    /**
-     * 会员中心
-     */
-    public function index()
-    {
-        $this->success('', ['welcome' => $this->auth->nickname]);
-    }
-
-    /**
-     * 会员登录
-     *
-     * @ApiMethod (POST)
-     * @param string $account  账号
-     * @param string $password 密码
-     */
-    public function login()
-    {
-        $account = $this->request->post('account');
-        $password = $this->request->post('password');
-        if (!$account || !$password) {
-            $this->error(__('Invalid parameters'));
-        }
-        $ret = $this->auth->login($account, $password);
-        if ($ret) {
-            $data = ['userinfo' => $this->auth->getUserinfo()];
-            $this->success(__('Logged in successful'), $data);
-        } else {
-            $this->error($this->auth->getError());
-        }
-    }
-
-    /**
-     * 手机验证码登录
-     *
-     * @ApiMethod (POST)
-     * @param string $mobile  手机号
-     * @param string $captcha 验证码
-     */
-    public function mobilelogin()
-    {
-        $mobile = $this->request->post('mobile');
-        $captcha = $this->request->post('captcha');
-        if (!$mobile || !$captcha) {
-            $this->error(__('Invalid parameters'));
-        }
-        if (!Validate::regex($mobile, "^1\d{10}$")) {
-            $this->error(__('Mobile is incorrect'));
-        }
-        if (!Sms::check($mobile, $captcha, 'mobilelogin')) {
-            $this->error(__('Captcha is incorrect'));
-        }
-        $user = \app\common\model\User::getByMobile($mobile);
-//        if (!$user) {
-//            $this->error('用户尚未注册');
-//        }
-//        if ($user['status'] != 1) {
-//            $this->error(__('Account is locked'));
-//        }
-        if ($user) {
-            if ($user->status != 1) {
-                $this->error(__('Account is locked'));
-            }
-            //如果已经有账号则直接登录
-            $ret = $this->auth->direct($user->id);
-        } else {
-            $ret = $this->auth->register($mobile, Random::alnum(), '', $mobile, []);
-        }
-//        $ret = $this->auth->direct($user->id);
-        if ($ret) {
-            Sms::flush($mobile, 'mobilelogin');
-            $data = ['userinfo' => $this->auth->getUserinfo()];
-            $this->success(__('Logged in successful'), $data);
-        } else {
-            $this->error($this->auth->getError());
-        }
-    }
-
-    /**
-     * 注册会员
-     *
-     * @ApiMethod (POST)
-     * @param string $username 用户名
-     * @param string $password 密码
-     * @param string $email    邮箱
-     * @param string $mobile   手机号
-     * @param string $code     验证码
-     */
-    /*public function register()
-    {
-        $mobile = $this->request->post('mobile', '', 'trim'); //手机号
-        $code = $this->request->post('code', '', 'trim'); //验证码
-        $password = $this->request->post('password', '' , 'trim'); //密码
-        $repassword = $this->request->post('repassword', '' , 'trim'); //确认密码
-        $nickname = $this->request->post('nickname', '', 'trim'); //姓名
-        $idcard = $this->request->post('idcard', '', 'trim,strip_tags,htmlspecialchars'); //身份证号
-        $province = $this->request->post('province', '', 'trim'); //省
-        $city = $this->request->post('city', '', 'trim'); //市
-        $area = $this->request->post('area', '', 'trim'); //区
-        $address = $this->request->post('address', '', 'trim'); //详细地址
-        $recommender = $this->request->post('recommender', '', 'trim'); //推荐人姓名
-        $recommender_mobile = $this->request->post('recommender_mobile', '', 'trim'); //推荐人手机号
-        $zimage = $this->request->post('zimage', '', 'trim,strip_tags,htmlspecialchars'); //身份证正面照
-        $fimage = $this->request->post('fimage', '', 'trim,strip_tags,htmlspecialchars'); //身份证反面照
-
-        if (!Validate::regex($mobile, "^1\d{10}$")) {
-            $this->error(__('Mobile is incorrect'));
-        }
-        $count = Db::name('user')->where(['mobile' => $mobile])->count('id');
-        if ($count) {
-            $this->error('手机号已被注册');
-        }
-        if (iconv_strlen($code, 'utf-8') != config('alisms.length')) {
-            $this->error(__('Captcha is incorrect'));
-        }
-        $ret = Sms::check($mobile, $code, 'register');
-        if (!$ret) {
-            $this->error(__('Captcha is incorrect'));
-        }
-        if (!$password) {
-            $this->error('请输入新密码');
-        }
-        //验证新密码
-        if (!Validate::make()->check(['newpassword' => $password], ['newpassword' => 'require|regex:\S{6,30}'])) {
-            $this->error(__('Password must be 6 to 30 characters'));
-        }
-        if (!$repassword) {
-            $this->error('请再次输入密码');
-        }
-        if ($repassword != $password) {
-            $this->error('两次密码不一致');
-        }
-        if (!$nickname) {
-            $this->error('请输入姓名');
-        }
-        if (iconv_strlen($nickname, 'utf-8') > 30) {
-            $this->error('姓名最多30位');
-        }
-        if (!$idcard) {
-            $this->error('请输入身份证号');
-        }
-        if (iconv_strlen($idcard, 'utf-8') != 18) {
-            $this->error('身份证号错误');
-        }
-        if (!$province || !$city || !$area) {
-            $this->error('请选择养殖场地址');
-        }
-        if (!$address) {
-            $this->error('请输入详细地址');
-        }
-        if (iconv_strlen($address, 'utf-8') > 255) {
-            $this->error('详细地址最多255位');
-        }
-        if (!$recommender) {
-            $this->error('请输入推荐人姓名');
-        }
-        if (iconv_strlen($recommender, 'utf-8') > 30) {
-            $this->error('推荐人姓名最多30位');
-        }
-        if (!$recommender_mobile || !is_mobile($recommender_mobile)) {
-            $this->error('请输入正确推荐人手机号');
-        }
-        if (!$zimage || !$fimage) {
-            $this->error('请上传身份证相关照片');
-        }
-
-        $ip = request()->ip();
-        $time = time();
-
-        $data = [
-            'nickname'  => $nickname,
-            'province' => $province,
-            'city' => $city,
-            'area' => $area,
-            'address' => $address,
-            'createtime'    => $time
-        ];
-        $params = array_merge($data, [
-            'mobile'   => $mobile,
-            'password' => $password,
-            'avatar'   => '/assets/img/avatar.png',
-            'salt'      => Random::alnum(),
-            'jointime'  => $time,
-            'joinip'    => $ip,
-            'logintime' => $time,
-            'loginip'   => $ip,
-            'prevtime'  => $time,
-            'is_auth' => 1
-        ]);
-        $params['password'] = md5(md5($password) . $params['salt']);
-
-        //开启事务
-        Db::startTrans();
-
-        $rs = Db::name('user')->insertGetId($params);
-        if (!$rs) {
-            Db::rollback();
-            $this->error('注册失败');
-        }
-
-        $data['user_id'] = $rs;
-        $data['idcard'] = $idcard;
-        $data['zimage'] = $zimage;
-        $data['fimage'] = $fimage;
-        $data['recommender'] = $recommender;
-        $data['recommender_mobile'] = $recommender_mobile;
-
-        $rt = Db::name('user_auth')->insertGetId($data);
-        if (!$rt) {
-            Db::rollback();
-            $this->error('注册失败');
-        }
-        Db::commit();
-
-        $ret = $this->auth->login($mobile, $password);
-        if ($ret) {
-            $data = ['userinfo' => $this->auth->getUserinfo()];
-            $this->success(__('Sign up successful'), $data);
-        } else {
-            $this->error($this->auth->getError());
-        }
-    }*/
-
-    //注册第一步验证
-    public function registercheck()
-    {
-        $mobile = $this->request->post('mobile'); //手机号
-        $code = $this->request->post('code'); //验证码
-        $password = $this->request->post('password'); //密码
-        $repassword = $this->request->post('repassword', '' , 'trim'); //确认密码
-
-        if (!Validate::regex($mobile, "^1\d{10}$")) {
-            $this->error(__('Mobile is incorrect'));
-        }
-        $count = Db::name('user')->where(['mobile' => $mobile])->count('id');
-        if (!$count) {
-            $this->error('手机号已被注册');
-        }
-        if (iconv_strlen($code, 'utf-8') != config('alisms.length')) {
-            $this->error(__('Captcha is incorrect'));
-        }
-        $ret = Sms::check($mobile, $code, 'register');
-        if (!$ret) {
-            $this->error(__('Captcha is incorrect'));
-        }
-        if (!$password) {
-            $this->error('请输入新密码');
-        }
-        //验证新密码
-        if (!Validate::make()->check(['newpassword' => $password], ['newpassword' => 'require|regex:\S{6,30}'])) {
-            $this->error(__('Password must be 6 to 30 characters'));
-        }
-        if (!$repassword) {
-            $this->error('请再次输入密码');
-        }
-        if ($repassword != $password) {
-            $this->error('两次密码不一致');
-        }
-
-        $this->success('验证通过');
-    }
-
-    /**
-     * 退出登录
-     * @ApiMethod (POST)
-     */
-    public function logout()
-    {
-        if (!$this->request->isPost()) {
-            $this->error(__('Invalid parameters'));
-        }
-        $this->auth->logout();
-        $this->success(__('Logout successful'));
-    }
-
-    //查询会员信息
-    public function getinfo()
-    {
-        //检查今日是否登录赠送过成长值
-        $this->checklogingrowth($this->auth->id);
-        //检查会员等级
-        $this->checkviplevel($this->auth->id);
-
-        $user = Db::name('user')->find($this->auth->id);
-
-        $data['nickname'] = $user['nickname']; //姓名
-        $data['username'] = $user['username']; //UID
-        $data['avatar'] = cdnurl($user['avatar']); //头像
-        $data['mobile'] = $user['mobile']; //手机号
-        $data['money'] = $user['money']; //余额
-        $data['realname'] = $user['realname']; //真实姓名
-        $data['gender'] = $user['gender']; //性别:1=男,2=女
-        $data['birthday'] = date('Y-m-d', $user['birthday']); //生日
-        $data['idcard'] = $user['idcard']; //身份证号
-        $data['passport'] = $user['passport']; //护照号
-        $data['emergencycontact'] = $user['emergencycontact']; //紧急联系人
-        $data['contactmobile'] = $user['contactmobile']; //紧急联系方式
-        $data['outdoorduration'] = $user['outdoorduration']; //户外时长
-        $data['maxlevel'] = $user['maxlevel']; //实际有效会员ID
-        $data['viplevel'] = Db::name('vip')->where(['id' => $user['maxlevel']])->value('level'); //会员等级
-        $data['active_count'] = Db::name('active_order')->where(['user_id' => $this->auth->id, 'status' => 2])->count('id'); //完成活动数量
-        $data['freenumber'] = $user['freenumber']; //会员免费参加活动次数
-        $data['invite_no'] = $user['invite_no']; //邀请码
-
-        $this->success('会员信息', $data);
-    }
-
-    /**
-     * 修改会员个人信息
-     *
-     * @ApiMethod (POST)
-     * @param string $avatar   头像地址
-     * @param string $username 用户名
-     * @param string $nickname 昵称
-     * @param string $bio      个人简介
-     */
-    public function profile()
-    {
-        $avatar = $this->request->post('avatar', '', 'trim,strip_tags,htmlspecialchars'); //头像
-        $nickname = $this->request->post('nickname', '', 'trim'); //昵称
-        $realname = $this->request->post('realname', '', 'trim'); //真实姓名
-        $idcard = $this->request->post('idcard', '', 'trim,strip_tags,htmlspecialchars'); //身份证号
-        $passport = $this->request->post('passport', '', 'trim,strip_tags,htmlspecialchars'); //护照号
-        $emergencycontact = $this->request->post('emergencycontact', '', 'trim'); //紧急联系人
-        $contactmobile = $this->request->post('contactmobile', '', 'trim'); //紧急联系方式
-        $outdoorduration = $this->request->post('outdoorduration', '', 'trim'); //户外时长
-        $birthday = $this->request->post('birthday', '', 'strtotime'); //生日
-        $gender = $this->request->post('gender', 0, 'intval'); //性别
-
-        $data = [];
-        if ($avatar) {
-            if (iconv_strlen($avatar, 'utf-8') > 255) {
-                $this->error('图片超出范围');
-            }
-            $data['avatar'] = $avatar;
-        }
-        if ($nickname) {
-            if (iconv_strlen($nickname, 'utf-8') > 30) {
-                $this->error('昵称最多30字');
-            }
-            $data['nickname'] = $nickname;
-        }
-        if ($realname) {
-            if(iconv_strlen($realname, 'utf-8') > 30) {
-                $this->error('真实姓名最多30字');
-            }
-            $data['realname'] = $realname;
-        }
-        if ($idcard) {
-            if (iconv_strlen($idcard, 'utf-8') != 18) {
-                $this->error('身份证号错误');
-            }
-            $data['idcard'] = $idcard;
-        }
-        if ($passport) {
-            if (iconv_strlen($passport, 'utf-8') > 30) {
-                $this->error('护照号错误');
-            }
-            $data['passport'] = $passport;
-        }
-        if ($emergencycontact) {
-            if(iconv_strlen($emergencycontact, 'utf-8') > 30) {
-                $this->error('紧急联系人最多30字');
-            }
-            $data['emergencycontact'] = $emergencycontact;
-        }
-        if ($contactmobile) {
-            if(!is_mobile($contactmobile)) {
-                $this->error('请输入正确紧急联系方式');
-            }
-            $data['contactmobile'] = $contactmobile;
-        }
-        if ($outdoorduration) {
-            if(iconv_strlen($outdoorduration, 'utf-8') > 50) {
-                $this->error('户外时长最多50字');
-            }
-            $data['outdoorduration'] = $outdoorduration;
-        }
-
-        if ($birthday) {
-            $data['birthday'] = $birthday;
-        }
-        if (in_array($gender, [1, 2])) {
-            $data['gender'] = $gender;
-        }
-
-//        $avatar = $this->request->post('avatar', '', 'trim,strip_tags,htmlspecialchars');
-//        if ($username) {
-//            $exists = \app\common\model\User::where('username', $username)->where('id', '<>', $this->auth->id)->find();
-//            if ($exists) {
-//                $this->error(__('Username already exists'));
-//            }
-//            $user->username = $username;
-//        }
-//        if ($nickname) {
-//            $exists = \app\common\model\User::where('nickname', $nickname)->where('id', '<>', $this->auth->id)->find();
-//            if ($exists) {
-//                $this->error(__('Nickname already exists'));
-//            }
-//            $user->nickname = $nickname;
-//        }
-//        $user->avatar = $avatar;
-
-        if (!$data) {
-            $this->error('暂无修改内容');
-        }
-        //修改用户表
-        $rt = Db::name('user')->where(['id' => $this->auth->id])->setField($data);
-        if ($rt === false) {
-            $this->error('修改失败');
-        }
-
-        $this->success('修改成功');
-    }
-    
-    //修改头像
-    public function changeavatar()
-    {
-        $avatar = input('avatar', '', 'trim'); //头像
-        if (!$avatar) {
-            $this->error('请上传头像');
-        }
-        if (iconv_strlen($avatar, 'utf-8') > 255) {
-            $this->error('头像长度超出限制');
-        }
-
-        $rs = Db::name('user')->where(['id' => $this->auth->id])->setField('avatar', $avatar);
-        if (!$rs) {
-            $this->error('修改失败');
-        }
-
-        $this->success('修改成功');
-    }
-
-    /**
-     * 修改邮箱
-     *
-     * @ApiMethod (POST)
-     * @param string $email   邮箱
-     * @param string $captcha 验证码
-     */
-    public function changeemail()
-    {
-        $user = $this->auth->getUser();
-        $email = $this->request->post('email');
-        $captcha = $this->request->post('captcha');
-        if (!$email || !$captcha) {
-            $this->error(__('Invalid parameters'));
-        }
-        if (!Validate::is($email, "email")) {
-            $this->error(__('Email is incorrect'));
-        }
-        if (\app\common\model\User::where('email', $email)->where('id', '<>', $user->id)->find()) {
-            $this->error(__('Email already exists'));
-        }
-        $result = Ems::check($email, $captcha, 'changeemail');
-        if (!$result) {
-            $this->error(__('Captcha is incorrect'));
-        }
-        $verification = $user->verification;
-        $verification->email = 1;
-        $user->verification = $verification;
-        $user->email = $email;
-        $user->save();
-
-        Ems::flush($email, 'changeemail');
-        $this->success();
-    }
-
-    /**
-     * 修改手机号
-     *
-     * @ApiMethod (POST)
-     * @param string $mobile  手机号
-     * @param string $captcha 验证码
-     */
-    public function changemobile()
-    {
-        $user = $this->auth->getUser();
-        $code = $this->request->post('code');
-        $mobile = $this->request->post('mobile');
-        $captcha = $this->request->post('captcha');
-        if (!$code || !$mobile || !$captcha) {
-            $this->error(__('Invalid parameters'));
-        }
-        if ($mobile == $user->mobile) {
-            $this->error('手机号没有改变');
-        }
-        $result = Sms::check($user->mobile, $code, 'changeyuanmobile');
-        if (!$result) {
-            $this->error(__('Captcha is incorrect'));
-        }
-        if (!Validate::regex($mobile, "^1\d{10}$")) {
-            $this->error(__('Mobile is incorrect'));
-        }
-        if (\app\common\model\User::where('mobile', $mobile)->where('id', '<>', $user->id)->find()) {
-            $this->error(__('手机号已存在'));
-        }
-        $result = Sms::check($mobile, $captcha, 'changemobile');
-        if (!$result) {
-            $this->error(__('Captcha is incorrect'));
-        }
-        $verification = $user->verification;
-        $verification->mobile = 1;
-        $user->verification = $verification;
-        $user->mobile = $mobile;
-        $user->save();
-
-        Sms::flush($user->mobile, 'changemobile');
-        Sms::flush($mobile, 'changemobile');
-        $this->success('修改成功');
-    }
-
-    /**
-     * 第三方登录
-     *
-     * @ApiMethod (POST)
-     * @param string $platform 平台名称
-     * @param string $code     Code码
-     */
-    public function third()
-    {
-        $url = url('user/index');
-        $platform = $this->request->post("platform");
-        $code = $this->request->post("code");
-        $config = get_addon_config('third');
-        if (!$config || !isset($config[$platform])) {
-            $this->error(__('Invalid parameters'));
-        }
-        $app = new \addons\third\library\Application($config);
-        //通过code换access_token和绑定会员
-        $result = $app->{$platform}->getUserInfo(['code' => $code]);
-        if ($result) {
-            $loginret = \addons\third\library\Service::connect($platform, $result);
-            if ($loginret) {
-                $data = [
-                    'userinfo'  => $this->auth->getUserinfo(),
-                    'thirdinfo' => $result
-                ];
-                $this->success(__('Logged in successful'), $data);
-            }
-        }
-        $this->error(__('Operation failed'), $url);
-    }
-
-    /**
-     * 重置密码
-     *
-     * @ApiMethod (POST)
-     * @param string $mobile      手机号
-     * @param string $newpassword 新密码
-     * @param string $captcha     验证码
-     */
-    public function resetpwd()
-    {
-        $type = 'mobile';//$this->request->post("type");
-        $mobile = $this->request->post("mobile");
-        $email = $this->request->post("email");
-        $newpassword = $this->request->post("newpassword");
-        $repassword = $this->request->post('repassword', '' , 'trim'); //确认密码
-        $captcha = $this->request->post("captcha");
-        if (!$newpassword || !$captcha || !$repassword) {
-            $this->error(__('Invalid parameters'));
-        }
-        //验证Token
-        if (!Validate::make()->check(['newpassword' => $newpassword], ['newpassword' => 'require|regex:\S{6,30}'])) {
-            $this->error(__('Password must be 6 to 30 characters'));
-        }
-        if ($repassword != $newpassword) {
-            $this->error('两次密码不一致');
-        }
-        if ($type == 'mobile') {
-            if (!Validate::regex($mobile, "^1\d{10}$")) {
-                $this->error(__('Mobile is incorrect'));
-            }
-            $user = \app\common\model\User::getByMobile($mobile);
-            if (!$user) {
-                $this->error(__('User not found'));
-            }
-            $ret = Sms::check($mobile, $captcha, 'resetpwd');
-            if (!$ret) {
-                $this->error(__('Captcha is incorrect'));
-            }
-            Sms::flush($mobile, 'resetpwd');
-        } else {
-            if (!Validate::is($email, "email")) {
-                $this->error(__('Email is incorrect'));
-            }
-            $user = \app\common\model\User::getByEmail($email);
-            if (!$user) {
-                $this->error(__('User not found'));
-            }
-            $ret = Ems::check($email, $captcha, 'resetpwd');
-            if (!$ret) {
-                $this->error(__('Captcha is incorrect'));
-            }
-            Ems::flush($email, 'resetpwd');
-        }
-        //模拟一次登录
-        $this->auth->direct($user->id);
-        $ret = $this->auth->changepwd($newpassword, '', true);
-        if ($ret) {
-            $this->success(__('Reset password successful'));
-        } else {
-            $this->error($this->auth->getError());
-        }
-    }
-
-    /**
-     * 修改密码
-     *
-     * @ApiMethod (POST)
-     * @param string $captcha     验证码
-     * @param string $newpassword 新密码
-     * @param string $repassword 确认密码
-     */
-    public function editpwd()
-    {
-        $captcha = $this->request->post("captcha", '', 'trim'); //验证码
-        $newpassword = $this->request->post("newpassword", '' , 'trim'); //新密码
-        $repassword = $this->request->post('repassword', '' , 'trim'); //确认密码
-
-        if (iconv_strlen($captcha, 'utf-8') != config('alisms.length')) {
-            $this->error(__('Captcha is incorrect'));
-        }
-        if (!$newpassword) {
-            $this->error('请输入新密码');
-        }
-        //验证新密码
-        if (!Validate::make()->check(['newpassword' => $newpassword], ['newpassword' => 'require|regex:\S{6,30}'])) {
-            $this->error(__('Password must be 6 to 30 characters'));
-        }
-        if (!$repassword) {
-            $this->error('请再次输入密码');
-        }
-        if ($repassword != $newpassword) {
-            $this->error('两次密码不一致');
-        }
-
-//        $user = \app\common\model\User::getById($this->auth->id);
-//        if (!$user) {
-//            $this->error(__('User not found'));
-//        }
-        $ret = Sms::check($this->auth->mobile, $captcha, 'changepwd');
-        if (!$ret) {
-            $this->error(__('Captcha is incorrect'));
-        }
-
-        //模拟一次登录
-        $this->auth->direct($this->auth->id);
-        $ret = $this->auth->changepwd($newpassword, '', true);
-        if ($ret) {
-            Sms::flush($this->auth->mobile, 'changepwd');
-
-            $this->success(__('Reset password successful'));
-        } else {
-            $this->error($this->auth->getError());
-        }
-    }
-    
-    //查询经营信息
-    public function get_businessinfo()
-    {
-        $data = Db::name('user_business_info')->field('manage, mobile, province, city, area, distribution_channel')
-            ->where(['user_id' => $this->auth->id])->find();
-
-        $this->success('经营信息', $data);
-    }
-
-    //修改经营信息
-    public function editbusinessinfo()
-    {
-        $manage = $this->request->post('manage', '', 'trim'); //采购负责人
-        $mobile = $this->request->post('mobile', '', 'trim'); //联系方式
-        $province = $this->request->post('province', '', 'trim'); //省
-        $city = $this->request->post('city', '', 'trim'); //市
-        $area = $this->request->post('area', '', 'trim'); //区
-        $distribution_channel = $this->request->post('distribution_channel', '', 'trim'); //销售渠道
-
-        $data = [];
-        if ($manage) {
-            if (iconv_strlen($manage, 'utf-8') > 50) {
-                $this->error('采购负责人最多50字');
-            }
-
-            $data['manage'] = $manage;
-        }
-        if ($mobile) {
-            if (!Validate::regex($mobile, "^1\d{10}$")) {
-                $this->error(__('Mobile is incorrect'));
-            }
-
-            $data['mobile'] = $mobile;
-        }
-        if ($province && $city && $area) {
-            $data['province'] = $province;
-            $data['city'] = $city;
-            $data['area'] = $area;
-        }
-        if ($distribution_channel) {
-            if (iconv_strlen($distribution_channel, 'utf-8') > 255) {
-                $this->error('销售渠道说明最多50字');
-            }
-
-            $data['distribution_channel'] = $distribution_channel;
-        }
-
-        if (!$data) {
-            $this->error('暂无修改内容');
-        }
-
-        $count = Db::name('user_business_info')->where(['user_id' => $this->auth->id])->count();
-        if ($count) {
-            $data['updatetime'] = time();
-
-            $rs = Db::name('user_business_info')->where(['user_id' => $this->auth->id])->setField($data);
-        } else {
-            $data['user_id'] = $this->auth->id;
-            $data['createtime'] = time();
-
-            $rs = Db::name('user_business_info')->insertGetId($data);
-        }
-
-        if (!$rs) {
-            $this->error('修改失败');
-        }
-
-        $this->success('修改成功');
-    }
-
-    //查询猪车信息
-    public function getpigcar()
-    {
-        $data = Db::name('user_pig_car')->where(['user_id' => $this->auth->id])->select();
-
-        $data = list_domain_image($data, ['images']);
-
-        $this->success('查询猪车信息', $data);
-    }
-
-    /**
-     * 添加猪车信息
-     *
-     *$data = [
-        [
-        'carnumber' => '123',
-        'carframenumber' => '344',
-        'images' => '123.jpg,234.jpg,345.jpg'
-        ],
-        [
-        'carnumber' => '123',
-        'carframenumber' => '344',
-        'images' => '123.jpg,234.jpg,345.jpg'
-        ],
-        [
-        'carnumber' => '123',
-        'carframenumber' => '344',
-        'images' => '123.jpg,234.jpg,345.jpg'
-        ]
-       ];
-     *
-     */
-    public function addpigcar()
-    {
-        $pig_car = input('pig_car', '', 'trim'); //猪车信息json串: carnumber车牌号  carframenumber车架号  images车辆照片
-        if (!$pig_car) {
-            $this->error('请添加猪车信息');
-        }
-
-        $pig_car = json_decode($pig_car, true);
-        if (!$pig_car) {
-            $this->error('请添加猪车信息');
-        }
-        if (count($pig_car) > 9) {
-            $this->error('一次最多添加9条记录');
-        }
-
-        $_data = [];
-        foreach ($pig_car as &$v) {
-            $data = [];
-            if (!$v['carnumber']) {
-                $this->error('请输入车牌号');
-                break;
-            }
-            if (iconv_strlen($v['carnumber'], 'utf-8') > 50) {
-                $this->error('车牌号最多50字');
-                break;
-            }
-            if (!$v['carframenumber']) {
-                $this->error('请输入车架号');
-                break;
-            }
-            if (iconv_strlen($v['carframenumber'], 'utf-8') > 50) {
-                $this->error('车架号最多50字');
-                break;
-            }
-            if ($v['images']) {
-                $image_arr = explode(',', $v['images']);
-                if (count($image_arr) > 9) {
-                    $this->error('每辆车照片最多9张');
-                    break;
-                }
-
-                $data['images'] = $v['images'];
-            }
-
-            $data['user_id'] = $this->auth->id;
-            $data['carnumber'] = $v['carnumber'];
-            $data['carframenumber'] = $v['carframenumber'];
-            $data['createtime'] = time();
-
-            array_push($_data, $data);
-        }
-
-        $rs = Db::name('user_pig_car')->insertAll($_data);
-        if (!$rs) {
-            $this->error('添加失败');
-        }
-
-        $this->success('添加成功');
-    }
-
-    //删除猪车信息
-    public function delpigcar()
-    {
-        $id = input('id', 0, 'intval'); //猪车id
-        if (!$id) {
-            $this->error('请选择要删除的猪车');
-        }
-
-        $info = Db::name('user_pig_car')->where(['id' => $id, 'user_id' => $this->auth->id])->find();
-        if (!$info) {
-            $this->error('这不是您的车');
-        }
-
-        $rs = Db::name('user_pig_car')->where(['id' => $id, 'user_id' => $this->auth->id])->delete();
-        if (!$rs) {
-            $this->error('删除失败');
-        }
-
-        $this->success('删除成功');
-    }
-
-    //平台介绍
-    public function getabout()
-    {
-        $info = Db::name('platform_info')->field('title, content')->where(['type' => 1])->find();
-
-        $this->success('平台介绍', $info);
-    }
-
-    //常见问题
-    public function problem()
-    {
-        $list = Db::name('problem')->field('id, title, content')
-            ->page($this->page, config('paginate.list_rows'))->order('weigh', 'desc')->select();
-
-        $this->success('常见问题', $list);
-    }
-
-    //投诉举报类型
-    public function complainttype()
-    {
-        $list = Db::name('complaint_type')->field('id, name')->where(['pid' => 0])->order('weigh', 'desc')->select();
-
-        $list = $this->getchildtype($list);
-        $this->success('常见问题', $list);
-    }
-
-    //无限级投诉举报类型
-    public function getchildtype($list = [])
-    {
-        $complaint_type = Db::name('complaint_type');
-        foreach ($list as &$v) {
-            $child = $complaint_type->field('id, name')->where(['pid' => $v['id']])->order('weigh', 'desc')->select();
-            if ($child) {
-                $child = $this->getchildtype($child);
-            }
-
-            $v['child'] = $child;
-        }
-
-        return $list;
-    }
-
-    //投诉举报
-    public function complaint()
-    {
-        $complaint_type = input('complaint_type', '', 'trim'); //投诉类型
-        $order_sn = input('order_sn', '', 'trim'); //订单号
-        $be_complaint_user = input('be_complaint_user', '', 'trim'); //被投诉人/单位
-        $complaint_user = input('complaint_user', '', 'trim'); //投诉人
-        $mobile = input('mobile', '', 'trim'); //联系电话
-        $code = input('code', '', 'trim'); //验证码
-        $content = input('content', '', 'trim'); //情况说明
-        $images = input('images', '', 'trim'); //附件材料
-
-        $data = [];
-
-        if (!$complaint_type) {
-            $this->error('请选择投诉类型');
-        }
-        if ($order_sn) {
-            if (iconv_strlen($order_sn, 'utf-8') > 255) {
-                $this->error('订单号最多255位');
-            }
-            //查询订单
-            $count = Db::name('mark_bid')->where(['user_id' => $this->auth->id, 'order_sn' => $order_sn, 'status' => 1])->count();
-            if (!$count) {
-                $this->error('请输入正确中标订单号');
-            }
-        }
-        if (!$be_complaint_user) {
-            $this->error('请输入被投诉人/单位');
-        }
-        if (iconv_strlen($be_complaint_user, 'utf-8') > 50) {
-            $this->error('被投诉人/单位最多50字');
-        }
-        if (!$complaint_user) {
-            $this->error('请输入投诉人');
-        }
-        if (iconv_strlen($complaint_user, 'utf-8') > 50) {
-            $this->error('投诉人最多50字');
-        }
-        if (!is_mobile($mobile)) {
-            $this->error('请输入正确联系电话');
-        }
-        if (iconv_strlen($code, 'utf-8') != config('alisms.length')) {
-            $this->error(__('Captcha is incorrect'));
-        }
-        $ret = Sms::check($mobile, $code, 'complaint');
-        if (!$ret) {
-            $this->error(__('Captcha is incorrect'));
-        }
-        if (!$content) {
-            $this->error('请输入情况说明');
-        }
-        if (iconv_strlen($content, 'utf-8') > 3000) {
-            $this->error('情况说明最多3000字');
-        }
-        if ($images) {
-            $image_arr = explode(',', $images);
-            if (count($image_arr) > 9) {
-                $this->error('附件照片最多9张');
-            }
-
-            $data['images'] = $images;
-        }
-
-        $data['user_id'] = $this->auth->id;
-        $data['complaint_type'] = $complaint_type;
-        $data['order_sn'] = $order_sn;
-        $data['be_complaint_user'] = $be_complaint_user;
-        $data['complaint_user'] = $complaint_user;
-        $data['mobile'] = $mobile;
-        $data['content'] = $content;
-        $data['images'] = $images;
-        $data['createtime'] = time();
-
-        $rs = Db::name('complaint')->insertGetId($data);
-        if (!$rs) {
-            $this->error('投诉失败');
-        }
-
-        Sms::flush($this->auth->mobile, 'complaint');
-
-        $this->success('投诉成功');
-    }
-
-    //评价列表
-    public function getmarkcomment()
-    {
-        $list = Db::name('mark_bid_comment')->where(['user_id' => $this->auth->id])
-            ->page($this->page, config('paginate.list_rows'))->order('createtime', 'desc')->select();
-
-        $list = list_domain_image($list, ['images']);
-
-        $mark = Db::name('mark');
-        $mark_bid = Db::name('mark_bid');
-        foreach ($list as &$v) {
-            $v['mark'] = $mark->find($v['mark_id']);
-            $v['mark'] = info_domain_image($v['mark'], ['image', 'video', 'defective_images', 'road_images', 'pig_out_images']);
-            $v['order_sn'] = $mark_bid->where(['id' => $v['mark_bid_id']])->value('order_sn');
-        }
-
-        $this->success('评论列表', $list);
-    }
-
-    //评价
-    public function markcomment()
-    {
-        $mark_id = input('mark_id', 0, 'intval'); //招标id
-        $content = input('content', '', 'trim'); //情况说明
-        $images = input('images', '', 'trim'); //附件材料
-
-        $data = [];
-
-        if (!$mark_id) {
-            $this->error('请选择要评价的数据');
-        }
-        $info = Db::name('mark')->find($mark_id);
-        if (!$info) {
-            $this->error('招标信息不存在');
-        }
-        $bid_id = Db::name('mark_bid')->where(['user_id' => $this->auth->id, 'mark_id' => $mark_id, 'status' => 1])->value('id');
-        if (!$bid_id) {
-            $this->error('您未中标,暂不能评价');
-        }
-        if (!$content) {
-            $this->error('请输入评价内容');
-        }
-        if (iconv_strlen($content, 'utf-8') > 3000) {
-            $this->error('评价内容最多3000字');
-        }
-        if ($images) {
-            $image_arr = explode(',', $images);
-            if (count($image_arr) > 9) {
-                $this->error('照片最多9张');
-            }
-
-            $data['images'] = $images;
-        }
-
-        $data['user_id'] = $this->auth->id;
-        $data['mark_id'] = $mark_id;
-        $data['mark_bid_id'] = $bid_id;
-        $data['content'] = $content;
-        $data['images'] = $images;
-        $data['createtime'] = time();
-
-        $rs = Db::name('mark_bid_comment')->insertGetId($data);
-        if (!$rs) {
-            $this->error('评价失败');
-        }
-
-        $this->success('评价成功');
-    }
-
-    //个人账单列表
-    public function getcompanymoney()
-    {
-        $list = Db::name('company')->field('id, name')->page($this->page, config('paginate.list_rows'))->select();
-
-        $company_money_log = Db::name('company_money_log');
-        foreach ($list as &$v) {
-            $log = $company_money_log->where(['company_id' => $v['id'], 'user_id' => $this->auth->id])->order('id', 'desc')->find();
-            if ($log) {
-                $v['money'] = $log['after'];
-                $v['can_money'] = $log['after'];
-            } else {
-                $v['money'] = '0';
-                $v['can_money'] = '0';
-            }
-        }
-
-        $this->success('个人账单列表', $list);
-    }
-
-    //个人账单明细
-    public function getcompanymoneydetail()
-    {
-        $company_id = input('company_id', 0, 'intval'); //公司id
-        $start_time = input('start_time', 0, 'strtotime'); //开始时间
-        $end_time = input('end_time', 0, 'strtotime'); //结束时间
-
-        if (!$company_id) {
-            $this->error('参数缺失');
-        }
-
-        $where['company_id'] = $company_id;
-        $where['user_id'] = $this->auth->id;
-        if ($start_time && $end_time) {
-            $where['createtime'] = ['between', [$start_time, $end_time]];
-        }
-
-        $list = Db::name('company_money_log')->field('id, money, memo, createtime')
-            ->where($where)->page($this->page, config('paginate.list_rows'))->order('id', 'desc')->select();
-
-        foreach ($list as &$v) {
-            $v['createtime'] = date('Y-m-d H:i:s', $v['createtime']);
-        }
-
-        $data['income'] = Db::name('company_money_log')->where($where)->where(['money' => ['gt', 0]])->sum('money');
-        $data['expend'] = Db::name('company_money_log')->where($where)->where(['money' => ['lt', 0]])->sum('money');
-        $data['list'] = $list;
-
-        $this->success('个人账单明细', $data);
-    }
-
-
-
-    //获取openid
-    public function getopenid() {
-        //code
-        $code = $this->request->param('code', '', 'trim');// code值
-        if (!$code) {
-            $this->error(__('Invalid parameters'));
-        }
-
-        $config = config('wxchatpay');
-        $getopenid_url = 'https://api.weixin.qq.com/sns/jscode2session?appid='.$config['app_id'].'&secret='.$config['app_secret'].'&js_code='.$code.'&grant_type=authorization_code';
-
-        $openidInfo = httpRequest($getopenid_url, 'GET');//$this->getJson($getopenid_url);
-        $openidInfo = json_decode($openidInfo,true);
-
-        if(!isset($openidInfo['openid'])) {
-            $this->error('用户openid获取失败', $openidInfo);
-        }
-
-        $this->success('success', $openidInfo);
-    }
-
-    //微信登录
-    public function wxlogin() {
-        $openid = input('openid', '', 'trim');
-        if (!$openid) {
-            $this->error('参数缺失');
-        }
-
-        $user = \app\common\model\User::getByOpenid($openid);
-        if (!$user) {
-            $this->success('用户尚未注册', ['code' => 5]);
-        }
-        if ($user['status'] != 1) {
-            $this->error(__('Account is locked'));
-        }
-        $ret = $this->auth->direct($user->id);
-        if ($ret) {
-            $data = ['userinfo' => $this->auth->getUserinfo()];
-            $this->success(__('Logged in successful'), $data);
-        } else {
-            $this->error($this->auth->getError());
-        }
-    }
-
-    //注册
-    public function register()
-    {
-        $realname = input('realname', '', 'trim'); //真实姓名
-        $height = input('height', 170, 'intval'); //身高
-        $weight = input('weight', 60, 'intval'); //体重
-        $birthday = $this->request->post('birthday', '', 'strtotime'); //生日
-        $province_id = input('province_id', 0, 'intval'); //省id
-        $city_id = input('city_id', 0, 'intval'); //市id
-        $area_id = input('area_id', 0, 'intval'); //区id
-        $mobile = $this->request->post('mobile', '', 'trim'); //手机号
-//        $code = $this->request->post('code', '', 'trim'); //验证码
-        $idcard = input('idcard', '', 'trim'); //身份证号
-        $excel_position = input('excel_position', '', 'trim'); //擅长位置
-//        $gender = $this->request->post('gender', 0, 'intval'); //性别:1=男,2=女
-//        $invite_no = $this->request->post('invite_no', '', 'trim'); //邀请码
-        $openid = $this->request->post('openid', '', 'trim'); //微信openid
-//        $nickname = $this->request->post('nickname', '', 'trim'); //微信昵称
-//        $avatar = $this->request->post('avatar', '', 'trim,strip_tags,htmlspecialchars'); //微信头像
-
-        $openidcount = Db::name('user')->where(['openid' => $openid])->count('id');
-        if ($openidcount) {
-            $this->error('微信已经注册,请直接登录');
-        }
-        if ($realname === '' || iconv_strlen($realname, 'utf-8') > 30) {
-            $this->error('真实姓名1-30位');
-        }
-        if ($height <= 0) {
-            $this->error('请选择正确身高');
-        }
-        if ($weight <= 0) {
-            $this->error('请选择正确体重');
-        }
-        if (!$birthday || $birthday >= time()) {
-            $this->error('请选择正确生日');
-        }
-        if (!$province_id || !$city_id || !$area_id) {
-            $this->error('请选择地区');
-        }
-        if (!Validate::regex($mobile, "^1\d{10}$")) {
-            $this->error(__('Mobile is incorrect'));
-        }
-        $count = Db::name('user')->where(['mobile' => $mobile])->count('id');
-        if ($count) {
-            $this->error('手机号已被注册');
-        }
-//        if (iconv_strlen($code, 'utf-8') != config('alisms.length')) {
-//            $this->error(__('Captcha is incorrect'));
-//        }
-//        $ret = Sms::check($mobile, $code, 'register');
-//        if (!$ret) {
-//            $this->error(__('Captcha is incorrect'));
-//        }
-
-//        if (!in_array($gender, [1, 2])) {
-//            $this->error('请选择性别');
-//        }
-//        if ($invite_no) {
-//            $invite_info = Db::name('user')->where(['invite_no' => $invite_no])->find();
-//            if (!$invite_info) {
-//                $this->error('邀请码不存在');
-//            }
-//        }
-        if (iconv_strlen($idcard, 'utf-8') != 18) {
-            $this->error('请输入正确身份证号');
-        }
-        if ($excel_position === '' || iconv_strlen($excel_position, 'utf-8') > 30) {
-            $this->error('请选择擅长位置');
-        }
-
-//        if (!$nickname || !$avatar) {
-//            $this->error('参数缺失');
-//        }
-//        if (iconv_strlen($nickname, 'utf-8') > 30 || iconv_strlen($avatar, 'utf-8') > 255) {
-//            $this->error('参数错误');
-//        }
-
-        $ip = request()->ip();
-        $time = time();
-
-        $data = [
-//            'nickname'  => $nickname,
-            'salt'      => Random::alnum(),
-            'mobile' => $mobile,
-            'avatar'   => config('logo'),//$avatar,
-            'joinip'    => $ip,
-            'jointime'  => $time,
-            'logintime' => $time,
-            'loginip'   => $ip,
-            'prevtime'  => $time,
-            'createtime'    => $time,
-//            'gender' => $gender,
-            'birthday' => $birthday,
-            'openid' => $openid,
-            'invite_no' => $this->myinvite(),
-            'pre_user_id' => isset($invite_info) ? $invite_info['id'] : 0,
-            'invite_time' => $time,
-            'realname' => $realname,
-            'height' => $height,
-            'weight' => $weight,
-            'province_id' => $province_id,
-            'city_id' => $city_id,
-            'area_id' => $area_id,
-            'idcard' => $idcard,
-            'excel_position' => $excel_position,
-        ];
-
-        //开启事务
-        Db::startTrans();
-        $rs = Db::name('user')->insertGetId($data);
-        if (!$rs) {
-            Db::rollback();
-            $this->error('注册失败');
-        }
-        //生成uid
-        $username = $this->myuid($rs);
-        $rt = Db::name('user')->where(['id' => $rs])->setField(['username' => $username, 'nickname' => '球员' . $username]);
-        if (!$rt) {
-            Db::rollback();
-            $this->error('注册失败');
-        }
-
-        Db::commit();
-
-        $ret = $this->auth->direct($rs);
-        if ($ret) {
-            $data = ['userinfo' => $this->auth->getUserinfo()];
-            $this->success(__('Sign up successful'), $data);
-        } else {
-            $this->error($this->auth->getError());
-        }
-    }
-
-    //生成邀请码
-    public function myinvite() {
-        $invite = Random::alnum(7);
-        $count = Db::name('user')->where(['invite_no' => $invite])->count('id');
-        if ($count) {
-            $this->myinvite();
-        }
-
-        return $invite;
-    }
-
-    //生成uid
-    public function myuid($id = 0) {
-        if (strlen($id) < 8) {
-            $username_len = 8 - strlen($id);
-            $username = $id . Random::numeric($username_len);
-        } else {
-            $username = $id;
-        }
-
-        $count = Db::name('user')->where(['username' => $username])->count('id');
-        if ($count) {
-            $this->myuid($id);
-        }
-
-        return $username;
-    }
-
-    //查询是否有未读消息
-    public function getreadsysmsg() {
-        $count = Db::name('sys_msg')->where(['user_id' => $this->auth->id, 'is_read' => 0])->count('id');
-
-        $this->success('查询是否有未读消息', $count);
-    }
-
-    //消息列表
-    public function sysmsg() {
-        $list = Db::name('sys_msg')->field('id, title, content, createtime')->where(['user_id' => $this->auth->id])
-            ->page($this->page, $this->pagenum)->order('id desc')->select();
-
-        foreach ($list as &$v) {
-            $v['createtime'] = date('Y-m-d H:i', $v['createtime']);
-        }
-
-        //更改消息状态
-        Db::name('sys_msg')->where(['user_id' => $this->auth->id, 'is_read' => 0])->setField('is_read', 1);
-
-        $this->success('消息列表', $list);
-    }
-
-    //查询当前会员等级信息
-    public function uservip() {
-        //更新会员等级
-        $this->checkviplevel($this->auth->id);
-        //用户信息
-        $user = Db::name('user')->find($this->auth->id);
-        //会员信息
-        $vip_info = Db::name('vip')->find($user['maxlevel']);
-        //下一级所需成长值
-        $next_vip = Db::name('vip')->where(['id' => ['gt', $user['maxlevel']]])->find();
-        if (!$next_vip || $next_vip['id'] == 5) {
-            //顶部信息
-            $vip_info['vip_desc'] = '已是最高会员';
-            //成长值百分比0-100
-            $vip_info['growthvalue_percentage'] = 100;
-        } else {
-            //顶部信息
-            $need_growthvalue = $next_vip['growthvalue'] - $user['growthvalue'];
-            $vip_info['vip_desc'] = $vip_info['title'] . '还需' . $need_growthvalue . '成长值成为' . $next_vip['title'];
-            //成长值百分比0-100
-            $vip_info['growthvalue_percentage'] = ceil($user['growthvalue'] / $next_vip['growthvalue'] * 100);
-        }
-        //体验会员到期时间
-        $vip_info['experiencetime'] = $user['experiencetime'] > time() ? date('Y-m-d', $user['experiencetime']) : '';
-        //判断是不是生日 1是  0否
-        $vip_info['is_birth'] = date('md', time()) == date('md', strtotime($this->auth->birthday)) ? 1: 0;
-
-        $this->success('查询当前会员等级信息', $vip_info);
-    }
-
-    //查询所有会员
-    public function vip() {
-        //更新会员等级
-        $this->checkviplevel($this->auth->id);
-        //用户信息
-        $user = Db::name('user')->find($this->auth->id);
-        //会员信息
-        $vip_info = Db::name('vip')->find($user['growthlevel']);
-        //下一级所需成长值
-        $next_vip = Db::name('vip')->where(['id' => ['gt', $user['growthlevel']]])->find();
-        if (!$next_vip || $next_vip['id'] == 5) {
-            //顶部信息
-            $vip_info['vip_desc'] = '已是最高会员';
-            //成长值百分比0-100
-            $vip_info['growthvalue_percentage'] = 100;
-        } else {
-            //顶部信息
-            $need_growthvalue = $next_vip['growthvalue'] - $user['growthvalue'];
-            $vip_info['vip_desc'] = $vip_info['title'] . '还需' . $need_growthvalue . '成长值成为' . $next_vip['title'];
-            //成长值百分比0-100
-            $vip_info['growthvalue_percentage'] = ceil($user['growthvalue'] / $next_vip['growthvalue'] * 100);
-        }
-        //所有会员列表
-        $where = [];
-        if ($this->auth->maxlevel != 5) {
-            $where['id'] = ['neq', 5];
-        }
-        $list = Db::name('vip')->where($where)->select();
-
-        $vip_privilege = Db::name('vip_privilege');
-        foreach ($list as $k => &$v) {
-            $v['vip_desc'] = '';  //顶部信息
-            $v['growthvalue_percentage'] = 0; //成长值百分比0-100
-            $v['experiencetime'] = ''; //体验会员到期时间
-
-            if ($v['id'] == $user['maxlevel']) {
-                $v['now_level'] = 1; //是否是当前等级 1是  0否
-                if ($user['maxlevel'] == $user['experiencelevel'] && $user['experiencetime'] > time()) {
-                    //实际有效会员ID是体验会员id时, 展示体验会员到期时间
-                    $v['experiencetime'] = '有效期至' . date('Y-m-d', $user['experiencetime']);
-                }
-            } else {
-                $v['now_level'] = 0;
-            }
-            if ($v['id'] == $user['growthlevel']) {
-                $v = array_merge($v, $vip_info);
-            }
-
-            $v['vip_privilege'] = $vip_privilege->field('id, title, desc')
-                ->where(['vip_id' => $v['id']])->order('weigh desc')->select();
-        }
-
-        $this->success('查询所有会员', $list);
-    }
-
-    //意见反馈
-    public function feedback() {
-        $content = input('content', '', 'trim'); //问题描述
-        $images = input('images', '', 'trim'); //反馈图片,最多9张用,拼接
-        $mobile = input('mobile', '', 'trim'); //联系电话
-
-        $data = [];
-
-        if (!$content) {
-            $this->error('请输入情况说明');
-        }
-        if (iconv_strlen($content, 'utf-8') > 3000) {
-            $this->error('情况说明最多3000字');
-        }
-        if ($images) {
-            $image_arr = explode(',', $images);
-            if (count($image_arr) > 9) {
-                $this->error('附件照片最多9张');
-            }
-
-            $data['images'] = $images;
-        }
-        if (!is_mobile($mobile)) {
-            $this->error('请输入正确联系电话');
-        }
-
-        $data['user_id'] = $this->auth->id;
-        $data['content'] = $content;
-        $data['images'] = $images;
-        $data['mobile'] = $mobile;
-        $data['createtime'] = time();
-
-        $rs = Db::name('feedback')->insertGetId($data);
-        if (!$rs) {
-            $this->error('反馈失败');
-        }
-
-        $this->success('反馈成功');
-    }
-
-    //我的优惠券
-    public function mycoupon() {
-        $type = input('type', 0, 'intval'); //类型:1未使用 2已使用 3已过期
-        if (!in_array($type, [1, 2, 3])) {
-            $this->error('参数错误');
-        }
-
-        $where['user_id'] = $this->auth->id;
-        if ($type == 1) {
-            $where['endtime'] = ['egt', time()];
-            $where['status'] = 0;
-        } elseif ($type == 2) {
-            $where['status'] = 1;
-        } elseif ($type == 3) {
-            $where['endtime'] = ['lt', time()];
-            $where['status'] = 0;
-        }
-
-        $list = Db::name('user_coupon')->field('id, title, desc, type, money, minmoney, endtime')->where($where)->page($this->page, $this->pagenum)->select();
-        foreach ($list as &$v) {
-            $v['endtime'] = date('Y-m-d', $v['endtime']);
-        }
-
-        $this->success('我的优惠券', $list);
-    }
-
-    //充值列表
-    public function rechargelist() {
-        $list = Db::name('recharge')->field('id, title, price, coupon_id, couponnum')->order('weigh desc')->select();
-
-        $coupon = Db::name('coupon');
-        foreach ($list as &$v) {
-            $coupon_info = $coupon->find($v['coupon_id']);
-            if ($coupon_info) {
-                if ($coupon_info['type'] == 1) {
-                    $v['coupon_title'] = $coupon_info['money'] . '折';
-                } else {
-                    $v['coupon_title'] = $coupon_info['money'] . '元';
-                }
-            } else {
-                $v['coupon_title'] = '';
-            }
-        }
-
-        $this->success('充值列表', $list);
-    }
-    
-    //资金明细
-    public function usermoneylog() {
-        $list = Db::name('user_money_log')->field('id, money, memo, createtime')
-            ->where(['user_id' => $this->auth->id])
-            ->page($this->page, $this->pagenum)
-            ->order('id desc')->select();
-
-        foreach ($list as &$v) {
-            $v['createtime'] = date('Y-m-d H:i:s', $v['createtime']);
-        }
-
-        $this->success('资金明细', $list);
-    }
-
-    //充值
-    public function recharge() {
-        $id = input('id', 0, 'intval');
-        if (!$id) {
-            $this->error('参数缺失');
-        }
-
-        $info = Db::name('recharge')->where(['id' => $id])->find();
-        if (!$info) {
-            $this->error('充值金额不存在');
-        }
-        if ($info['price'] <= 0) {
-            $this->error('充值价格异常');
-        }
-
-        //生成支付订单记录
-        $rechar_order['user_id'] = $this->auth->id;
-        $rechar_order['order_no'] = date('YmdHis', time()) . rand(10000000, 99999999); //微信订单编号
-        $rechar_order['money'] = $info['price'];
-        $rechar_order['purpose'] = 2; //充值用途:1=支付订单,2=充值,3=开通会员
-        $rechar_order['pay_type'] = 'wechat';
-        $rechar_order['relation_id'] = $id;
-        $rechar_order['createtime'] = time();
-
-        //开始事务
-        $result = Db::name('rechar_order')->insertGetId($rechar_order);
-        if (!$result) {
-            $this->error('网络延迟,请稍后再试');
-        }
-
-        //构建支付链接数据
-        $wxData['body'] = '充值';
-        $wxData['out_trade_no'] = $rechar_order['order_no'];
-        $wxData['total_fee'] = $info['price'];
-//        $wxData['total_fee'] = 0.01;
-        $wxData['openid'] = $this->auth->openid;
-
-//            require_once($_SERVER['DOCUMENT_ROOT'] . '/Plugins/Weixin/WxPay/WxPay.php');
-        $wxPay = new wxpay\WxPay(config('wxchatpay'));
-        $doResult = $wxPay->WxPayJs($wxData);
-
-        $this->success('微信支付参数返回成功', $doResult);
-    }
-
-    //邀请好友顶部信息
-    public function invitetop() {
-        $data['invite_no'] = $this->auth->invite_no; //邀请码
-        $data['invite_count'] = Db::name('user')->where(['pre_user_id' => $this->auth->id])->count('id'); //邀请人数
-        $data['coupon_count'] = Db::name('user_coupon')->where(['user_id' => $this->auth->id, 'purpose' => ['in', [2, 5]]])->count('id');
-
-        $this->success('邀请好友顶部信息', $data);
-    }
-
-    //邀请好友底部列表
-    public function invitebottom() {
-        $type = input('type', 0, 'intval'); //1邀请的好友 2报名的好友
-        if (!in_array($type, [1, 2])) {
-            $this->error('参数错误');
-        }
-
-        if ($type == 1) {
-            $list = Db::name('user')->field('id, avatar, nickname, invite_time')
-                ->where(['pre_user_id' => $this->auth->id])->page($this->page, $this->pagenum)->order('id desc')->select();
-        } else {
-            $invite_ids = Db::name('user')->where(['pre_user_id' => $this->auth->id])->column('id');
-            if (!$invite_ids) {
-                $this->success('报名好友列表', []);
-            }
-
-            $list = Db::name('active_order')->alias('a')
-                ->join('hu_user b', 'a.user_id = b.id', 'left')
-                ->field('b.id, b.avatar, b.nickname, b.invite_time')
-                ->where(['a.user_id' => ['in', $invite_ids]])
-                ->page($this->page, $this->pagenum)
-                ->order('a.id desc')->select();
-        }
-
-        $list = list_domain_image($list, ['avatar']);
-        foreach ($list as &$v) {
-            $v['invite_time'] = date('Y-m-d', $v['invite_time']);
-        }
-
-        $this->success('邀请好友底部列表', $list);
-    }
-
-    //我的订单
-    public function myorder() {
-        $type = input('type', 0, 'intval'); //状态:0=待付款,1=待出行,2=已完成,3=已取消
-        if (!in_array($type, [0, 1, 2, 3])) {
-            $this->error('参数错误');
-        }
-
-        $list = Db::name('active_order')->where(['user_id' => $this->auth->id, 'status' => $type])->page($this->page, $this->pagenum)->order('id desc')->select();
-
-        $active = Db::name('active');
-        foreach ($list as &$v) {
-            $v['button_status'] = 0;//待出行按钮: 0不展示  1退款  2修改联系人
-
-            $v['active'] = $active->find($v['active_id']);
-            $v['active'] = info_domain_image($v['active'], ['image']);
-            if ($v['status'] == 1) {
-                if ($v['active']['refundendtime'] >= time()) {
-                    $v['button_status'] = 1;
-                } elseif ($v['active']['refundendtime'] < time() && $v['active']['signupendtime'] >= time()) {
-                    $v['button_status'] = 2;
-                }
-            }
-            if ($v['active']['maxperson'] <= $v['active']['currentperson']) {
-                $v['is_full'] = 1; //已报满
-            } else {
-                $v['is_full'] = 0; //未报满
-            }
-        }
-
-        $this->success('我的订单', $list);
-    }
-
-    //我的订单详情
-    public function myorderinfo() {
-        $id = input('id', 0, 'intval'); //订单id
-        if (!$id) {
-            $this->error('参数缺失');
-        }
-        $info = Db::name('active_order')->where(['id' => $id, 'user_id' => $this->auth->id])->find();
-        if (!$info) {
-            $this->error('数据不存在');
-        }
-
-        $info['createtime'] = date('Y-m-d H:i:s', $info['createtime']);
-        //查询活动信息
-        $active = Db::name('active')->find($info['active_id']);
-
-        //待出行按钮: 0不展示  1退款  2修改联系人
-        $info['button_status'] = 0;
-        if ($info['status'] == 1) {
-            if ($active['refundendtime'] >= time()) {
-                $info['button_status'] = 1;
-            } elseif ($active['refundendtime'] < time() && $active['signupendtime'] >= time()) {
-                $info['button_status'] = 2;
-            }
-        }
-
-        $active = info_domain_image($active, ['image']);
-        $active['starttime'] = date('Y-m-d H:i', $active['starttime']);
-        $active['endtime'] = date('Y-m-d H:i', $active['endtime']);
-        $active['collectiontime'] = date('Y-m-d H:i', $active['collectiontime']);
-        $active['signupendtime'] = date('Y-m-d H:i', $active['signupendtime']);
-        $active['refundendtime'] = date('Y-m-d H:i', $active['refundendtime']);
-
-        //查询报名人员
-        $active_people = Db::name('active_people')->where(['order_id' => $id])->field('id, name, mobile')->select();
-
-        $info['active'] = $active;
-        $info['active_people'] = $active_people;
-
-        $this->success('我的订单详情', $info);
-    }
-    
-    //查看报名人信息
-    public function activepeople() {
-        $id = input('id', 0, 'intval'); //报名人员id
-        if (!$id) {
-            $this->error('参数缺失');
-        }
-        $info = Db::name('active_people')->where(['id' => $id, 'user_id' => $this->auth->id])->find();
-        if (!$info) {
-            $this->error('数据不存在');
-        }
-
-        $this->success('查看报名人信息', $info);
-    }
-
-    //修改报名人信息
-    public function modifyactivepeople() {
-        $id = input('id', 0, 'intval'); //报名人员id
-        $collectionplace = input('collectionplace', '', 'trim'); //集合地点
-        $name = input('name', '', 'trim'); //姓名
-        $idcard = input('idcard', '', 'trim'); //身份证号
-        $mobile = input('mobile', '', 'trim'); //手机号
-        $emergencycontact = input('emergencycontact', '', 'trim'); //紧急联系人
-        $contactmobile = input('contactmobile', '', 'trim'); //紧急联系方式
-
-        if (!$id) {
-            $this->error('参数缺失');
-        }
-        $info = Db::name('active_people')->where(['id' => $id, 'user_id' => $this->auth->id])->find();
-        if (!$info) {
-            $this->error('数据不存在');
-        }
-        if ($info['status'] == 2) {
-            $this->success('订单已经结束');
-        }
-        if ($info['status'] == 3) {
-            $this->success('订单已经取消');
-        }
-        if ($info['modifystatus'] == 1) {
-            $this->error('报名信息正在修改中,请等待后台审核');
-        }
-        //查询活动状态
-        $active = Db::name('active')->find($info['active_id']);
-        if (!$active) {
-            $this->success('活动不存在或已取消');
-        }
-//        if ($active['status'] == 1) {
-//            $this->error('活动已成行,不能修改信息');
-//        }
-        if (time() <= $active['refundendtime'] || time() > $active['signupendtime']) {
-            $this->error('当前时间段暂不可修改信息');
-        }
-        //查询是否申请过退款
-        $active_refund = Db::name('active_refund')->where(['order_id' => $info['active_id'], 'status' => 0])->count('id');
-        if ($active_refund) {
-            $this->error('您正在申请退款,暂不可修改信息');
-        }
-        //检查信息
-        if ($collectionplace === '' || iconv_strlen($collectionplace, 'utf-8') > 255) {
-            $this->error('请选择集合地点');
-        }
-        if (!$name || iconv_strlen($name, 'utf-8') > 50) {
-            $this->error('请输入正确姓名');
-        }
-        if (iconv_strlen($idcard, 'utf-8') != 18) {
-            $this->error('请输入正确身份证号');
-        }
-        if (!is_mobile($mobile)) {
-            $this->error('请输入正确手机号');
-        }
-        if (!$emergencycontact || iconv_strlen($emergencycontact, 'utf-8') > 50) {
-            $this->error('请输入紧急联系人');
-        }
-        if (!is_mobile($contactmobile)) {
-            $this->error('请输入正确紧急联系人方式');
-        }
-        //判断是否报名过
-        $count = Db::name('active_people')->where(['active_id' => $info['active_id'], 'idcard' => $idcard, 'status' => ['neq', 3]])->count('id');
-        if ($count) {
-            $this->error('该信息已报名过活动');
-        }
-        $count2 = Db::name('active_people_modify')->where(['active_id' => $info['active_id'], 'idcard' => $idcard, 'status' => 0])->count('id');
-        if ($count2) {
-            $this->error('该信息已提交过修改,请等待审核');
-        }
-        //构建修改数据
-        $data = [
-            'active_id' => $info['active_id'],
-            'order_id' => $info['order_id'],
-            'people_id' => $id,
-            'user_id' => $info['user_id'],
-            'collectionplace' => $collectionplace,
-            'name' => $name,
-            'credtype' => $info['credtype'],
-            'idcard' => $idcard,
-            'mobile' => $mobile,
-            'emergencycontact' => $emergencycontact,
-            'contactmobile' => $contactmobile,
-            'insurance' => $info['insurance'],
-            'originalprice' => $info['originalprice'],
-            'vipprice' => $info['vipprice'],
-            'coupon_id' => $info['coupon_id'],
-            'coupontype' => $info['coupontype'],
-            'couponprice' => $info['couponprice'],
-            'is_free' => $info['is_free'],
-            'price' => $info['price'],
-            'is_self' => $info['is_self'],
-            'createtime' => time()
-        ];
-
-        //开启事务
-        Db::startTrans();
-        //添加记录
-        $rs = Db::name('active_people_modify')->insertGetId($data);
-        if (!$rs) {
-            Db::rollback();
-            $this->error('修改失败');
-        }
-        //修改原记录状态
-        $rt = Db::name('active_people')->where(['id' => $id, 'modifystatus' => 0])->setField('modifystatus', 1);
-        if (!$rt) {
-            Db::rollback();
-            $this->error('修改失败');
-        }
-
-        Db::commit();
-        $this->success('修改成功,请等待审核');
-    }
-
-    //取消订单
-    public function cancelorder() {
-        $id = input('id', 0, 'intval'); //订单id
-        if (!$id) {
-            $this->error('参数缺失');
-        }
-        $info = Db::name('active_order')->where(['id' => $id, 'user_id' => $this->auth->id])->find();
-        if (!$info) {
-            $this->error('数据不存在');
-        }
-        if ($info['status'] != 0) {
-            $this->error('网络延迟,请刷新重试');
-        }
-        if ($info['createtime'] + 1800 < time()) {
-            $this->error('订单超时,系统将自动取消');
-        }
-        //查询活动是否存在
-        $active_info = Db::name('active')->find($info['active_id']);
-        if (!$active_info) {
-            $this->error('活动不存在');
-        }
-
-        //开启事务
-        Db::startTrans();
-        //修改订单信息
-        $rs = Db::name('active_order')->where(['id' => $id, 'status' => 0])->setField('status', 3);
-        if (!$rs) {
-            Db::rollback();
-            $this->error('网络延迟,请稍后再试');
-        }
-        //修改活动人员
-        $rt = Db::name('active_people')->where(['order_id' => $id, 'status' => 0])->setField(['status' => 3, 'modifystatus' => 0]);
-        if (!$rt) {
-            Db::rollback();
-            $this->error('网络延迟,请稍后再试');
-        }
-        //修改活动人员修改记录
-        $res = Db::name('active_people_modify')->where(['order_id' => $id, 'status' => 0])->setField('status', 2);
-        if ($res === false) {
-            Db::rollback();
-            $this->error('网络延迟,请稍后再试');
-        }
-        //减少活动已报名人数
-        $currentperson = $active_info['currentperson'] - $info['number'];
-        $active_rs = Db::name('active')->where(['id' => $info['active_id'], 'currentperson' => $active_info['currentperson']])->setField('currentperson', $currentperson);
-        if (!$active_rs) {
-            Db::rollback();
-            $this->error('网络延迟,请稍后再试');
-        }
-
-        Db::commit();
-        $this->success('修改成功');
-    }
-
-    //支付订单
-    public function payorder() {
-        $id = input('id', 0, 'intval'); //订单id
-        if (!$id) {
-            $this->error('参数缺失');
-        }
-        $info = Db::name('active_order')->where(['id' => $id, 'user_id' => $this->auth->id])->find();
-        if (!$info) {
-            $this->error('数据不存在');
-        }
-        if ($info['status'] != 0) {
-            $this->error('当前订单状态不能支付');
-        }
-        if ($info['createtime'] + 1800 < time()) {
-            $this->error('订单支付超时,请重新报名');
-        }
-        //查询活动是否存在
-        $active_info = Db::name('active')->find($info['active_id']);
-        if (!$active_info) {
-            $this->error('活动不存在');
-        }
-        if ($active_info['status'] == 2) {
-            $this->error('活动已经结束');
-        }
-        if ($active_info['status'] == 3) {
-            $this->error('活动已取消');
-        }
-
-        $pay_count = Db::name('rechar_order')->where(['user_id' => $this->auth->id, 'purpose' => 1, 'pay_type' => 'wechat', 'relation_id' => $id, 'status' => 1])->count('id');
-        if ($pay_count) {
-            $this->error('您已成功支付过,请勿重复支付');
-        }
-
-        //生成支付订单记录
-        $rechar_order['user_id'] = $this->auth->id;
-        $rechar_order['order_no'] = date('YmdHis', time()) . rand(10000000, 99999999); //微信订单编号
-        $rechar_order['money'] = $info['price'];
-        $rechar_order['purpose'] = 1; //充值用途:1=支付订单,2=充值,3=开通会员
-        $rechar_order['pay_type'] = 'wechat';
-        $rechar_order['relation_id'] = $id;
-        $rechar_order['createtime'] = time();
-
-        $result = Db::name('rechar_order')->insertGetId($rechar_order);
-        if (!$result) {
-            $this->error('网络延迟,请稍后再试');
-        }
-
-        //构建支付链接数据
-        $wxData['body'] = '报名活动支付';
-        $wxData['out_trade_no'] = $rechar_order['order_no'];
-        $wxData['total_fee'] = $info['price'];
-//        $wxData['total_fee'] = 0.01;
-        $wxData['openid'] = $this->auth->openid;
-
-//            require_once($_SERVER['DOCUMENT_ROOT'] . '/Plugins/Weixin/WxPay/WxPay.php');
-        $wxPay = new wxpay\WxPay(config('wxchatpay'));
-        $doResult = $wxPay->WxPayJs($wxData);
-
-        $this->success('微信支付参数返回成功', $doResult);
-    }
-
-    //申请退款
-    public function applyrefund() {
-        $id = input('id', 0, 'intval'); //订单id
-        if (!$id) {
-            $this->error('参数缺失');
-        }
-        $info = Db::name('active_order')->where(['id' => $id, 'user_id' => $this->auth->id])->find();
-        if (!$info) {
-            $this->error('数据不存在');
-        }
-        if ($info['status'] != 1) {
-            $this->error('当前订单状态不能退款');
-        }
-        //查询是否已经申请过
-        $count = Db::name('active_refund')->where(['order_id' => $id, 'status' => 0])->count('id');
-        if ($count) {
-            $this->error('您已申请过退款,请等待后台审核');
-        }
-
-        //查询活动是否存在
-        $active_info = Db::name('active')->find($info['active_id']);
-        if (!$active_info) {
-            $this->error('活动不存在');
-        }
-        if (time() > $active_info['refundendtime']) {
-            $this->error('已超过退款截止时间,暂不能退款');
-        }
-
-        //用户取消订单每人扣费金额(元)
-        $cancelorder_price = config('site.cancelorder');
-        if ($cancelorder_price < 0) {
-            $this->error('退款手续费异常,请联系管理员');
-        }
-        //退款金额
-        $refundprice = number_format($info['price'] - $cancelorder_price * $info['number'], 2, '.', '');
-        $refundprice = $refundprice > 0 ? $refundprice : 0;
-
-        //构建申请数据
-        $data = [
-            'active_id' => $info['active_id'],
-            'order_id' => $id,
-            'user_id' => $this->auth->id,
-            'paytype' => $info['paytype'],
-            'price' => $info['price'],
-            'number' => $info['number'],
-            'transaction_id' => $info['transaction_id'],
-            'refund_no' => $info['paytype'] ? date('YmdHis', time()) . rand(10000000, 99999999) : '', //退款单号
-            'refundprice' => $refundprice,
-            'createtime' => time()
-        ];
-
-        $rs = Db::name('active_refund')->insertGetId($data);
-        if (!$rs) {
-            $this->error('申请退款失败');
-        }
-
-        $this->success('申请退款成功,请等待审核');
-    }
-
     //////////////////////////////////////////////////////
 
     //手机号登录/注册