refund
This commit is contained in:
parent
ede7b1e4df
commit
0ed540ccd8
@ -1543,45 +1543,43 @@ class OrderController extends Controller
|
||||
$result = Http::post($url, $data);
|
||||
Log::info("退款:" . $result);
|
||||
$result = json_decode($result, true);
|
||||
if (isset($result["code"]) && $result["code"] == 0) {//退款成功
|
||||
$refund->update(['is_hook' => 1]);
|
||||
DB::commit();
|
||||
$admin_id = $request->merchant_admin_id;
|
||||
$user_id = $this->matchFulinkUser($order->account_id);
|
||||
$result_type = $this->getOrderType($order);
|
||||
if ($user_id) {
|
||||
$maker_user_id = 0;//福恋操作人id
|
||||
$admin = !empty($admin_id) ? MerchantAdmins::find($admin_id) : MerchantAccount::find($merchant_id);
|
||||
$maker_user_id = User::where('mobile', $admin->mobile)->value('id');
|
||||
$maker_user_id = $maker_user_id ?? 0;
|
||||
$text = '订单类型:' . $result_type . ' 订单号:' . $order->trade_no . ' 发起退款' . $refund_price . '元 理由:' . $request->remark;
|
||||
if ($maker_user_id) {
|
||||
$nickname = User::where('id', $maker_user_id)->value('nickname');
|
||||
$text = $text . ' 操作人【' . $nickname . '】';
|
||||
}
|
||||
//同步一条该订单用户的用户备注
|
||||
ClientComment::create([
|
||||
'user_id' => $user_id,
|
||||
'maker_user_id' => $maker_user_id,
|
||||
'type' => 'mobile',
|
||||
'comment' => $text,
|
||||
]);
|
||||
}
|
||||
\CommonUtilsService::refundNotice($order, $refund_price, $result_type);
|
||||
//未结算订单重新计算收益
|
||||
if ($order->pay_status == 1) {//重新计算预分成
|
||||
SendEarningMessageV2::dispatch($order->id)->onQueue('order');
|
||||
} elseif ($order->pay_status == 3) {//删除预分成记录
|
||||
MAdvanceEarning::where('m_order_id', $order->id)->delete();
|
||||
}
|
||||
return $this->success('退款成功');
|
||||
} elseif (isset($result["code"]) && $result['code'] == 1) {
|
||||
if (isset($result["code"]) && $result["code"] == 1) {//退款失败
|
||||
$refund->update(['err_msg' => $result['message']]);
|
||||
DB::commit();
|
||||
return $this->failure('退款失败,', $result['message']);
|
||||
} else {
|
||||
return $this->failure('退款失败');
|
||||
}
|
||||
$refund->update(['is_hook' => 1]);
|
||||
DB::commit();
|
||||
$admin_id = $request->merchant_admin_id;
|
||||
$user_id = $this->matchFulinkUser($order->account_id);
|
||||
$result_type = $this->getOrderType($order);
|
||||
if ($user_id) {
|
||||
$maker_user_id = 0;//福恋操作人id
|
||||
$admin = !empty($admin_id) ? MerchantAdmins::find($admin_id) : MerchantAccount::find($merchant_id);
|
||||
$maker_user_id = User::where('mobile', $admin->mobile)->value('id');
|
||||
$maker_user_id = $maker_user_id ?? 0;
|
||||
$text = '订单类型:' . $result_type . ' 订单号:' . $order->trade_no . ' 发起退款' . $refund_price . '元 理由:' . $request->remark;
|
||||
if ($maker_user_id) {
|
||||
$nickname = User::where('id', $maker_user_id)->value('nickname');
|
||||
$text = $text . ' 操作人【' . $nickname . '】';
|
||||
}
|
||||
//同步一条该订单用户的用户备注
|
||||
ClientComment::create([
|
||||
'user_id' => $user_id,
|
||||
'maker_user_id' => $maker_user_id,
|
||||
'type' => 'mobile',
|
||||
'comment' => $text,
|
||||
]);
|
||||
}
|
||||
\CommonUtilsService::refundNotice($order, $refund_price, $result_type);
|
||||
//未结算订单重新计算收益
|
||||
if ($order->pay_status == 1) {//重新计算预分成
|
||||
SendEarningMessageV2::dispatch($order->id)->onQueue('order');
|
||||
} elseif ($order->pay_status == 3) {//删除预分成记录
|
||||
MAdvanceEarning::where('m_order_id', $order->id)->delete();
|
||||
}
|
||||
DB::commit();
|
||||
return $this->success('退款成功');
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
$this->getError($e);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user