success('获取成功',UserGroup::where('cid',$this->cid)->where('status','normal')->where("pay_price",'>',0)->select()); } public function create(Request $request) { $where = UtilService::postMore( [ ['cid',$this->cid], ['user_id',$this->auth->getUserinfo()['id']], ['level_id',0], ['body',''], ['pay_type',0], ['name',''], ['pay_price',0], ['from','weixin'], ],$request ); $order = OrderLevel::order_create($where); if(!$order) $this->error(OrderLevel::getErrorInfo()); $orderId = $order['order_id']; $info = compact('orderId'); if ($orderId) { $orderInfo = OrderLevel::where('order_id', $orderId)->find(); if (!$orderInfo || !isset($orderInfo['paid'])) $this->error('支付订单不存在!'); if ($orderInfo['paid']) $this->error('支付已支付!'); try { if ($where['from'] == 'routine') { $jsConfig = LevelRepository::jsPay($orderId); //创建订单jspay } else if ($where['from'] == 'weixinh5') { $jsConfig = LevelRepository::h5Pay($orderId); } else { $jsConfig = LevelRepository::wxPay($orderId); } } catch (\Exception $e) { return $this->error( $e->getMessage()); } $info['jsConfig'] = $jsConfig; return $this->success('订单创建成功'); } else $this->error(OrderLevel::getErrorInfo()); } public function mylst(Request $request) { $where = UtilService::getMore( [ ['page',1], ['limit',10], ['cid',$this->cid], ['user_id',$this->auth->getUserinfo()['id']], ['paid',-1], ],$request ); $this->success('获取成功',OrderLevel::lst($where)); } /** * 订单支付 * @param Request $request * @return mixed */ public function pay(Request $request) { list($uni, $paytype, $from) = UtilService::postMore([ ['uni', ''], ['paytype', '0'], ['from', 'weixin'] ], $request, true); if (!$uni) $this->error('参数错误!'); $order = OrderLevel::where('cid',$this->cid)->where('order_id',$uni)->find(); if (!$order) $this->error('订单不存在!'); if ($order['paid']) $this->error('该订单已支付!'); $order['pay_type'] = $paytype; //重新支付选择支付方式 switch ($order['pay_type']) { case '0': try { if ($from == 'routine') { $jsConfig = OrderLevel::jsPay($order); //订单列表发起支付 } else if ($from == 'weixinh5') { $jsConfig = OrderLevel::h5Pay($order); } else { $jsConfig = OrderLevel::wxPay($order); } } catch (\Exception $e) { $this->error($e->getMessage()); } $this->success('获取成功',$jsConfig); break; } return $this->error('支付方式错误'); } }