where('status', 1)->get(); return $this->success($lists); } public function createOrder() { try { \DB::beginTransaction(); $comboId = \request()->input('id'); $app = $this->getUniFactory(\user()->info->platform); $combo = VipCombo::find($comboId); // 避免重复创建订单 $vip = UserVipRecord::where('user_id', \user()->id) ->where('combo_id', $combo->id) ->where('status', 0) ->where('created_at','like', Carbon::now()->toDateString()."%") ->first(); if($vip){ $pay = Pay::find($vip->pay_id); $res = [ 'order_id' => $pay->prepay_id, 'order_token' => $pay->token, 'pay_id' => $pay->pay_id, ]; }else{ $res = app(Pay::class)->create($app, $combo->price,Pay::SOURCE_BUY_VIP); $recharge = new UserVipRecord(); $recharge->user_id = \user()->id; $recharge->combo_id = $combo->id; $recharge->valid_day = $combo->valid_day; $recharge->pay_id = $res['pay_id']; $recharge->status = 0; $recharge->save(); } \DB::commit(); return $this->success($res); }catch (QueryException $e){ \DB::rollBack(); return $this->error('下单失败'); }catch (\Exception $e){ \DB::rollBack(); return $this->error($e->getMessage()); } } }