diff --git a/app/Http/Controllers/Customer/OrdersController.php b/app/Http/Controllers/Customer/OrdersController.php index ab65236..dcbd21c 100644 --- a/app/Http/Controllers/Customer/OrdersController.php +++ b/app/Http/Controllers/Customer/OrdersController.php @@ -627,7 +627,7 @@ class OrdersController extends CommonController public function recharge() { Log::channel("daily_customer_order_request")->info($this->customer->openid); - $order = (new Orders())->with("project")->find(request()->order_id); + $order = (new Orders())->with(["project", "wechatpayAccount"])->find(request()->order_id); $openid = $this->customer->openid; $unifiedOrder = new \UnifiedOrderPub($order->project_id); @@ -637,7 +637,7 @@ class OrdersController extends CommonController "money" => request()->money, "order_id" => request()->order_id, "payment" => "weixin", - "merchant_id" => env("WEIXINPAY_MCHID") + "merchant_id" => $order->wechatpayAccount->mch_id ]); $recharge = $recharge->getSerial(); @@ -657,7 +657,7 @@ class OrdersController extends CommonController $unifiedOrder->setParameter("notify_url", get_http_type() . $_SERVER["HTTP_HOST"] . "/customer/pay-callback");//通知地址 $unifiedOrder->setParameter("trade_type", "JSAPI");//交易类型 } catch (\Exception $exception) { - Log::channel("daily_customer_order_request")->info("order_id:".request()->order_id.":".$exception->getMessage()); + Log::channel("daily_customer_order_request")->info("order_id:" . request()->order_id . ":" . $exception->getMessage()); return response()->json([ "errorcode" => $exception->getCode(), "errormsg" => $exception->getMessage() diff --git a/app/Models/Project.php b/app/Models/Project.php index b78dca1..1d25e5c 100755 --- a/app/Models/Project.php +++ b/app/Models/Project.php @@ -64,6 +64,6 @@ class Project extends SoftDeletesModel public function wechatpayAccount() { - return $this->hasOne(WechatpayAccount::class, "id", "wechatpay_account_id"); + return $this->hasOne(WechatpayAccount::class, "id", "wechatpay_account_id")->withTrashed(); } } diff --git a/app/Models/Recharge.php b/app/Models/Recharge.php index 5914f5b..65ba983 100755 --- a/app/Models/Recharge.php +++ b/app/Models/Recharge.php @@ -44,6 +44,11 @@ class Recharge extends SoftDeletesModel return $this->belongsTo(Orders::class); } + public function wechatpayAccount() + { + return $this->hasOneThrough(WechatpayAccount::class, Orders::class, "id", "id", "order_id", "wechatpay_account_id"); + } + public function patient() { return $this->hasOneThrough(Patient::class, Orders::class, "id", "id", "order_id", "patient_id");