修改bug
This commit is contained in:
@@ -54,25 +54,27 @@ class RuleController extends AdminController
|
|||||||
|
|
||||||
$form->switch('status', '状态')->default(1);
|
$form->switch('status', '状态')->default(1);
|
||||||
$form->saving(function (Form $form) {
|
$form->saving(function (Form $form) {
|
||||||
$code = $form->code;
|
if ($form->code) {
|
||||||
|
$code = $form->code;
|
||||||
|
|
||||||
$ticket = explode('-', $code);
|
$ticket = explode('-', $code);
|
||||||
if (!is_array($ticket) || count($ticket) != 3) {
|
if (!is_array($ticket) || count($ticket) != 3) {
|
||||||
$error = new MessageBag([
|
$error = new MessageBag([
|
||||||
'title' => '错误',
|
'title' => '错误',
|
||||||
'message' => '规则编号格式错误',
|
'message' => '规则编号格式错误',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return back()->withInput()->with(compact('error'));
|
return back()->withInput()->with(compact('error'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$full = $ticket[1]; //full100
|
||||||
|
$price = $ticket[2];
|
||||||
|
preg_match('/\d+/', $full, $match);
|
||||||
|
|
||||||
|
$form->full = $match[0];
|
||||||
|
$form->take = $price;
|
||||||
}
|
}
|
||||||
|
|
||||||
$full = $ticket[1]; //full100
|
|
||||||
$price = $ticket[2];
|
|
||||||
preg_match('/\d+/', $full, $match);
|
|
||||||
|
|
||||||
$form->full = $match[0];
|
|
||||||
$form->take = $price;
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return $form;
|
return $form;
|
||||||
|
|||||||
@@ -1,67 +1,68 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Listeners;
|
namespace App\Listeners;
|
||||||
|
|
||||||
use App\Events\ConponCallback;
|
use App\Events\ConponCallback;
|
||||||
use App\Models\ActivityCouponLog;
|
use App\Models\ActivityCouponLog;
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use RuntimeException;
|
||||||
class ConponCallbackListener implements ShouldQueue
|
|
||||||
{
|
class ConponCallbackListener implements ShouldQueue
|
||||||
|
{
|
||||||
public $queue = 'LISTENER';
|
|
||||||
|
public $queue = 'LISTENER';
|
||||||
/**
|
|
||||||
* Handle the event.
|
/**
|
||||||
* @param RoomLoginDone $event
|
* Handle the event.
|
||||||
* @return void
|
* @param RoomLoginDone $event
|
||||||
*/
|
* @return void
|
||||||
public function handle(ConponCallback $event)
|
*/
|
||||||
{
|
public function handle(ConponCallback $event)
|
||||||
$acticity_coupon = $event->acticity_coupon;
|
{
|
||||||
|
$acticity_coupon = $event->acticity_coupon;
|
||||||
$user = $acticity_coupon->outlet->parent;
|
|
||||||
if ($user->callback) {
|
$user = $acticity_coupon->outlet->parent;
|
||||||
$client = new Client();
|
if ($user->callback) {
|
||||||
|
$client = new Client();
|
||||||
$response = $client->request('post', $user->callback, [
|
|
||||||
'timeout' => 30,
|
$response = $client->request('post', $user->callback, [
|
||||||
'query' => [
|
'timeout' => 30,
|
||||||
'code' => $acticity_coupon->code,
|
'query' => [
|
||||||
'status' => $acticity_coupon->status,
|
'code' => $acticity_coupon->code,
|
||||||
],
|
'status' => $acticity_coupon->status,
|
||||||
]);
|
],
|
||||||
|
]);
|
||||||
$data = [
|
|
||||||
'code' => $acticity_coupon->code,
|
$data = [
|
||||||
'type' => $acticity_coupon->status == 2 ? 'Verification' : 'Destroy',
|
'code' => $acticity_coupon->code,
|
||||||
'url' => $user->callback,
|
'type' => $acticity_coupon->status == 2 ? 'Verification' : 'Destroy',
|
||||||
];
|
'url' => $user->callback,
|
||||||
|
];
|
||||||
$error = false;
|
|
||||||
|
$error = false;
|
||||||
if ($response->getStatusCode() == 200) {
|
|
||||||
$body = $response->getBody();
|
if ($response->getStatusCode() == 200) {
|
||||||
$result = json_decode($body->getContents(), true);
|
$body = $response->getBody();
|
||||||
|
$result = json_decode($body->getContents(), true);
|
||||||
$data['status'] = $result['code'] ?? '';
|
|
||||||
$data['source'] = $result;
|
$data['status'] = $result['code'] ?? '';
|
||||||
$data['remark'] = $result['message'] ?? '';
|
$data['source'] = $result;
|
||||||
|
$data['remark'] = $result['message'] ?? '';
|
||||||
} else {
|
|
||||||
$data['status'] = 0;
|
} else {
|
||||||
$data['source'] = '';
|
$data['status'] = 0;
|
||||||
$data['remark'] = '接口错误';
|
$data['source'] = '';
|
||||||
$error = true;
|
$data['remark'] = '接口错误';
|
||||||
}
|
$error = true;
|
||||||
ActivityCouponLog::create($data);
|
}
|
||||||
|
ActivityCouponLog::create($data);
|
||||||
if ($error) {
|
|
||||||
throw new RuntimeException($data['remark']);
|
if ($error) {
|
||||||
}
|
throw new RuntimeException($data['remark']);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user