model = new \app\model\Order(); } // 无需登录的接口,*表示全部 public $noNeedLogin = []; public function create() { global $_GPC; $payPrice = 0; $post = $this->request->post(); $linkId = $this->request->post('link_id',0); $mode = $this->request->post('mode','member'); $type = $this->request->post('type',1); // $post['uniacid'] = $_GPC['uniacid']; $loginUserInfo = UserServiceFacade::getUserInfo(); if($mode == 'direct'){ if($type == 1){ }else{ $payPrice = ConfServiceFacade::get('system.plan.pic_price'); } }else{ if(!$linkId){ return $this->error('请选择需要开通的会员卡'); } // 获得信息 $taskinfo = \app\model\Member::findOrEmpty($linkId)->toArray(); if($taskinfo['price'] <= 0){ return $this->error('金额需要大于0'); } $payPrice = $taskinfo['price']; } //生成订单 $ordernumber = Random::numeric(20); //拼接订单信息 $post['uid'] = $loginUserInfo['id']; $post['pay_price'] = $payPrice; $post['order_number'] = $ordernumber; $post['uniacid'] = $_GPC['uniacid']; $post['pay_type'] ='wechat'; Db::startTrans(); try{ $saveRes = $this->model->save($post); if (!$saveRes) throw new \Exception('保存基础信息失败'); Db::commit(); $post['id'] = $this->model->id; return $this->success('操作成功',$post); }catch (\Exception $e) { Db::rollback(); return $this->error('数据库异常,操作失败'); } } public function createSettle() { global $_GPC; $modelSettle = new \app\model\commission\Settle(); $modelUser = new \app\model\commission\User(); $payPrice = 0; $realName = $this->request->post('real_name',''); $telnum = $this->request->post('telnum',''); if(!$realName || !$telnum){ return $this->error('请上传姓名或手机号'); } // $post['uniacid'] = $_GPC['uniacid']; $loginUserInfo = UserServiceFacade::getUserInfo(); // print_r($loginUserInfo); $payPrice = ConfServiceFacade::get('system.commission.commission_price'); if(!$payPrice || $payPrice==0){ return $this->error('订单金额错误'); } $res = $modelUser::where('uid','=',$loginUserInfo['id'])->find(); if(!empty($res) && $res['status'] == 1){ return $this->error('已经入驻过'); } //生成订单 $ordernumber = Random::numeric(20); //拼接订单信息 $post['uid'] = $loginUserInfo['id']; $post['pay_price'] = $payPrice; $post['order_number'] = $ordernumber; $post['uniacid'] = $_GPC['uniacid']; $post['real_name'] = $realName; $post['telnum'] = $telnum; $post['pay_type'] ='wechat'; Db::startTrans(); try{ $saveRes = $modelSettle->save($post); if (!$saveRes) throw new \Exception('保存基础信息失败'); Db::commit(); $post['id'] = $modelSettle->id; return $this->success('操作成功',$post); }catch (\Exception $e) { Db::rollback(); return $this->error('数据库异常,操作失败'); } } public function detail() { global $_GPC; $order_id = $this->request->param('id'); if(!$order_id){ return $this->error('请上传订单编号'); } $order_info = $this->model->where('id','=',$order_id)->find(); if(!$order_info){ return $this->error('无数据'); } return $this->success('返回成功',$order_info); } public function detailSettle() { global $_GPC; $modelSettle = new \app\model\commission\Settle(); $order_id = $this->request->param('id'); if(!$order_id){ return $this->error('请上传订单编号'); } $order_info = $modelSettle->where('id','=',$order_id)->find(); if(!$order_info){ return $this->error('无数据'); } return $this->success('返回成功',$order_info); } public function my(){ global $_GPC; $order = ['id' => 'desc']; $loginUserInfo = UserServiceFacade::getUserInfo(); $where = ['uid'=>$loginUserInfo['id'],'paid'=>1,'uniacid'=>$_GPC['uniacid']]; $limit = $this->request->param('limit', 10); $data = $this->model->order($order)->where($where)->with('memberInfo')->paginate($limit)->toArray(); if(!$data){ return $this->error('数据获取失败',2); } return $this->success('数据获取成功', $data); } }