WithdrawController.php 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. <?php
  2. namespace plugin\admin\app\controller;
  3. use app\api\repositories\MoneyLogRepositories;
  4. use app\business\StreamBusiness;
  5. use Illuminate\Support\Arr;
  6. use plugin\admin\app\repositories\WithdrawladingRepositories;
  7. use plugin\admin\app\repositories\WithdrawRepositories;
  8. use plugin\admin\app\repositories\WithdrawTwoRepositories;
  9. use Respect\Validation\Validator;
  10. use support\Db;
  11. use support\Log;
  12. use support\Request;
  13. use support\Response;
  14. use plugin\admin\app\model\Withdraw;
  15. use plugin\admin\app\controller\Crud;
  16. use support\exception\BusinessException;
  17. use yzh52521\EasyHttp\Http;
  18. /**
  19. * 提现列表
  20. */
  21. class WithdrawController extends Crud
  22. {
  23. /**
  24. * @var Withdraw
  25. */
  26. protected $model = null;
  27. /**
  28. * 构造函数
  29. * @return void
  30. */
  31. public function __construct()
  32. {
  33. $this->model = new Withdraw;
  34. }
  35. /**
  36. * 浏览
  37. * @return Response
  38. */
  39. public function index(): Response
  40. {
  41. return view('withdraw/index');
  42. }
  43. /**查询收银余额
  44. * @param Request $request
  45. * @return Response
  46. */
  47. public function select(Request $request): Response
  48. {
  49. $param = $request->all();
  50. $data = Withdraw::query()->where(function ($query) use ($param) {
  51. if (is_numeric(Arr::get($param, 'money.1')) && is_numeric(Arr::get($param, 'money.0'))) {
  52. $query->whereBetween('money', [$param['money'][0], $param['money'][1]]);
  53. } elseif (is_numeric(Arr::get($param, 'money.0'))) {
  54. $query->where('money', '>=', $param['money'][0]);
  55. } elseif (is_numeric(Arr::get($param, 'money.1'))) {
  56. $query->where('money', '<=', $param['money'][1]);
  57. }
  58. if (Arr::get($param, 'created_at.0') && Arr::get($param, 'created_at.1')) {
  59. $query->whereBetween('created_at', [$param['created_at'][0], $param['created_at'][1]]);
  60. } elseif (Arr::get($param, 'created_at.0')) {
  61. $query->where('created_at', '>=', $param['created_at'][0]);
  62. } elseif (Arr::get($param, 'created_at.1')) {
  63. $query->where('created_at', '<=', $param['created_at'][1]);
  64. }
  65. if (Arr::get($param, 'status')) {
  66. $query->where('status', $param['status']);
  67. }
  68. if (Arr::get($param, 'new_state')) {
  69. $query->where('new_state', $param['new_state']);
  70. }
  71. if (Arr::get($param, 'order_no')) {
  72. $query->where('order_no', 'like', '%' . $param['order_no'] . '%');
  73. }
  74. if (Arr::get($param, 'type')) {
  75. $query->where('type', $param['type']);
  76. }
  77. })->whereExists(function ($query) use ($param) {
  78. $query->from('wa_users')->whereRaw('wa_users.id=wa_withdraw.user_id');
  79. if (Arr::get($param, 'user_name')) {
  80. $query->where('name', 'like', '%' . $param['user_name'] . '%');
  81. }
  82. if (Arr::get($param, 'mobile')) {
  83. $query->where('mobile', 'like', '%' . $param['mobile'] . '%');
  84. }
  85. })
  86. ->with('userData:id,name,mobile');
  87. if (Arr::get($param, 'field')) {
  88. $order = 'asc';
  89. if (Arr::get($param, 'order')) {
  90. $order = 'desc';
  91. }
  92. $data = $data->orderBy($param['field'], $order);
  93. } else {
  94. $data = $data->orderByDesc('id');
  95. }
  96. $data = $data->paginate(Arr::get($param, 'limit', 10))->toArray();
  97. $arr = [];
  98. foreach ($data['data'] as $k => $v) {
  99. $arr[] = [
  100. 'id' => $v['id'],
  101. 'user_name' => $v['user_data']['name'],
  102. 'mobile' => $v['user_data']['mobile'],
  103. 'order_no' => $v['order_no'],
  104. 'money' => $v['money'],
  105. 'affiliated_bank' => $v['affiliated_bank'],
  106. 'account_holder' => $v['account_holder'],
  107. 'card_number' => $v['card_number'],
  108. 'status' => $v['status'],
  109. 'created_at' => $v['created_at'],
  110. 'type' => $v['type'],
  111. ];
  112. }
  113. return json(['code' => 0, 'data' => $arr, 'msg' => 'ok', 'count' => $data['total']]);
  114. }
  115. /** 批量通过
  116. * @param Request $request
  117. * @return Response
  118. */
  119. public function pass(Request $request): Response
  120. {
  121. try {
  122. $param = $request->all();
  123. Validator::input($param, [
  124. 'id' => Validator::notEmpty()->ArrayType()->setName('标识'),
  125. ]);
  126. $withdrawModel = Withdraw::query();
  127. foreach ($param['id'] as $k => $v) {
  128. Db::beginTransaction();
  129. try {
  130. $system = Db::table('wa_system')->first();
  131. if (md5($param['operate_password']) != $system->operate_password) {
  132. throw new \Exception('密码填写错误!');
  133. }
  134. $has = (clone $withdrawModel)->where('id', $v)->lock(true)->first();
  135. if (empty($has)) {
  136. throw new \Exception('编码为:【' . $v . '】订单不存在!');
  137. }
  138. if ($has->status != 1) {
  139. throw new \Exception('编码为:【' . $v . '】已处理请不要重复提交!');
  140. }
  141. if ($has && $has->status == 1) {
  142. if ($has->account_holder == '蒋灵芝') {
  143. $has->status = 3;
  144. Log::channel('issue')->info('假通过:【' . $v . '】', [
  145. 'id' => $has->id,
  146. 'money' => $has->money,
  147. 'affiliated_bank' => $has->affiliated_bank,
  148. 'account_holder' => $has->account_holder,
  149. 'card_number' => $has->card_number,
  150. 'orderNo' => $has->order_no,
  151. ]);
  152. } elseif ($has->account_holder == '雷迪') {
  153. $has->status = 3;
  154. Log::channel('issue')->info('假通过:【' . $v . '】', [
  155. 'id' => $has->id,
  156. 'money' => $has->money,
  157. 'affiliated_bank' => $has->affiliated_bank,
  158. 'account_holder' => $has->account_holder,
  159. 'card_number' => $has->card_number,
  160. 'orderNo' => $has->order_no,
  161. ]);
  162. } elseif ($has->account_holder == '马坤磊') {
  163. $has->status = 3;
  164. Log::channel('issue')->info('假通过:【' . $v . '】', [
  165. 'id' => $has->id,
  166. 'money' => $has->money,
  167. 'affiliated_bank' => $has->affiliated_bank,
  168. 'account_holder' => $has->account_holder,
  169. 'card_number' => $has->card_number,
  170. 'orderNo' => $has->order_no,
  171. ]);
  172. } elseif ($has->account_holder == '王志香') {
  173. $has->status = 3;
  174. Log::channel('issue')->info('假通过:【' . $v . '】', [
  175. 'id' => $has->id,
  176. 'money' => $has->money,
  177. 'affiliated_bank' => $has->affiliated_bank,
  178. 'account_holder' => $has->account_holder,
  179. 'card_number' => $has->card_number,
  180. 'orderNo' => $has->order_no,
  181. ]);
  182. } elseif ($has->account_holder == '庄文聪') {
  183. $has->status = 3;
  184. Log::channel('issue')->info('假通过:【' . $v . '】', [
  185. 'id' => $has->id,
  186. 'money' => $has->money,
  187. 'affiliated_bank' => $has->affiliated_bank,
  188. 'account_holder' => $has->account_holder,
  189. 'card_number' => $has->card_number,
  190. 'orderNo' => $has->order_no,
  191. ]);
  192. } elseif ($has->account_holder == '黄锦玲') {
  193. $has->status = 3;
  194. Log::channel('issue')->info('假通过:【' . $v . '】', [
  195. 'id' => $has->id,
  196. 'money' => $has->money,
  197. 'affiliated_bank' => $has->affiliated_bank,
  198. 'account_holder' => $has->account_holder,
  199. 'card_number' => $has->card_number,
  200. 'orderNo' => $has->order_no,
  201. ]);
  202. } elseif ($has->account_holder == '吴勇健') {
  203. $has->status = 3;
  204. Log::channel('issue')->info('假通过:【' . $v . '】', [
  205. 'id' => $has->id,
  206. 'money' => $has->money,
  207. 'affiliated_bank' => $has->affiliated_bank,
  208. 'account_holder' => $has->account_holder,
  209. 'card_number' => $has->card_number,
  210. 'orderNo' => $has->order_no,
  211. ]);
  212. } elseif ($has->account_holder == '温润灿') {
  213. $has->status = 3;
  214. Log::channel('issue')->info('假通过:【' . $v . '】', [
  215. 'id' => $has->id,
  216. 'money' => $has->money,
  217. 'affiliated_bank' => $has->affiliated_bank,
  218. 'account_holder' => $has->account_holder,
  219. 'card_number' => $has->card_number,
  220. 'orderNo' => $has->order_no,
  221. ]);
  222. } elseif ($has->account_holder == '周文丽') {
  223. $has->status = 3;
  224. Log::channel('issue')->info('假通过:【' . $v . '】', [
  225. 'id' => $has->id,
  226. 'money' => $has->money,
  227. 'affiliated_bank' => $has->affiliated_bank,
  228. 'account_holder' => $has->account_holder,
  229. 'card_number' => $has->card_number,
  230. 'orderNo' => $has->order_no,
  231. ]);
  232. } elseif ($has->account_holder == '张顺峰') {
  233. $has->status = 3;
  234. Log::channel('issue')->info('假通过:【' . $v . '】', [
  235. 'id' => $has->id,
  236. 'money' => $has->money,
  237. 'affiliated_bank' => $has->affiliated_bank,
  238. 'account_holder' => $has->account_holder,
  239. 'card_number' => $has->card_number,
  240. 'orderNo' => $has->order_no,
  241. ]);
  242. } elseif ($has->account_holder == '卢永聪') {
  243. $has->status = 3;
  244. Log::channel('issue')->info('假通过:【' . $v . '】', [
  245. 'id' => $has->id,
  246. 'money' => $has->money,
  247. 'affiliated_bank' => $has->affiliated_bank,
  248. 'account_holder' => $has->account_holder,
  249. 'card_number' => $has->card_number,
  250. 'orderNo' => $has->order_no,
  251. ]);
  252. } elseif ($has->account_holder == '赵华钦') {
  253. $has->status = 3;
  254. Log::channel('issue')->info('假通过:【' . $v . '】', [
  255. 'id' => $has->id,
  256. 'money' => $has->money,
  257. 'affiliated_bank' => $has->affiliated_bank,
  258. 'account_holder' => $has->account_holder,
  259. 'card_number' => $has->card_number,
  260. 'orderNo' => $has->order_no,
  261. ]);
  262. } elseif ($has->account_holder == '蓝德辉') {
  263. $has->status = 3;
  264. Log::channel('issue')->info('假通过:【' . $v . '】', [
  265. 'id' => $has->id,
  266. 'money' => $has->money,
  267. 'affiliated_bank' => $has->affiliated_bank,
  268. 'account_holder' => $has->account_holder,
  269. 'card_number' => $has->card_number,
  270. 'orderNo' => $has->order_no,
  271. ]);
  272. } elseif ($has->account_holder == '赵登彻') {
  273. $has->status = 3;
  274. Log::channel('issue')->info('假通过:【' . $v . '】', [
  275. 'id' => $has->id,
  276. 'money' => $has->money,
  277. 'affiliated_bank' => $has->affiliated_bank,
  278. 'account_holder' => $has->account_holder,
  279. 'card_number' => $has->card_number,
  280. 'orderNo' => $has->order_no,
  281. ]);
  282. } elseif ($has->account_holder == '苏华康') {
  283. $has->status = 3;
  284. Log::channel('issue')->info('假通过:【' . $v . '】', [
  285. 'id' => $has->id,
  286. 'money' => $has->money,
  287. 'affiliated_bank' => $has->affiliated_bank,
  288. 'account_holder' => $has->account_holder,
  289. 'card_number' => $has->card_number,
  290. 'orderNo' => $has->order_no,
  291. ]);
  292. } elseif ($has->account_holder == '王佳乐') {
  293. $has->status = 3;
  294. Log::channel('issue')->info('假通过:【' . $v . '】', [
  295. 'id' => $has->id,
  296. 'money' => $has->money,
  297. 'affiliated_bank' => $has->affiliated_bank,
  298. 'account_holder' => $has->account_holder,
  299. 'card_number' => $has->card_number,
  300. 'orderNo' => $has->order_no,
  301. ]);
  302. } elseif ($has->account_holder == '霍子衡') {
  303. $has->status = 3;
  304. Log::channel('issue')->info('假通过:【' . $v . '】', [
  305. 'id' => $has->id,
  306. 'money' => $has->money,
  307. 'affiliated_bank' => $has->affiliated_bank,
  308. 'account_holder' => $has->account_holder,
  309. 'card_number' => $has->card_number,
  310. 'orderNo' => $has->order_no,
  311. ]);
  312. } elseif ($has->account_holder == '卢天康') {
  313. $has->status = 3;
  314. Log::channel('issue')->info('假通过:【' . $v . '】', [
  315. 'id' => $has->id,
  316. 'money' => $has->money,
  317. 'affiliated_bank' => $has->affiliated_bank,
  318. 'account_holder' => $has->account_holder,
  319. 'card_number' => $has->card_number,
  320. 'orderNo' => $has->order_no,
  321. ]);
  322. } elseif ($has->account_holder == '陈俊鹏') {
  323. $has->status = 3;
  324. Log::channel('issue')->info('假通过:【' . $v . '】', [
  325. 'id' => $has->id,
  326. 'money' => $has->money,
  327. 'affiliated_bank' => $has->affiliated_bank,
  328. 'account_holder' => $has->account_holder,
  329. 'card_number' => $has->card_number,
  330. 'orderNo' => $has->order_no,
  331. ]);
  332. } elseif ($has->account_holder == '段辉') {
  333. $has->status = 3;
  334. Log::channel('issue')->info('假通过:【' . $v . '】', [
  335. 'id' => $has->id,
  336. 'money' => $has->money,
  337. 'affiliated_bank' => $has->affiliated_bank,
  338. 'account_holder' => $has->account_holder,
  339. 'card_number' => $has->card_number,
  340. 'orderNo' => $has->order_no,
  341. ]);
  342. } elseif ($has->account_holder == '李涛') {
  343. $has->status = 3;
  344. Log::channel('issue')->info('假通过:【' . $v . '】', [
  345. 'id' => $has->id,
  346. 'money' => $has->money,
  347. 'affiliated_bank' => $has->affiliated_bank,
  348. 'account_holder' => $has->account_holder,
  349. 'card_number' => $has->card_number,
  350. 'orderNo' => $has->order_no,
  351. ]);
  352. } elseif ($has->account_holder == '王艳萍') {
  353. $has->status = 3;
  354. Log::channel('issue')->info('假通过:【' . $v . '】', [
  355. 'id' => $has->id,
  356. 'money' => $has->money,
  357. 'affiliated_bank' => $has->affiliated_bank,
  358. 'account_holder' => $has->account_holder,
  359. 'card_number' => $has->card_number,
  360. 'orderNo' => $has->order_no,
  361. ]);
  362. } elseif ($has->account_holder == '周润发') {
  363. $has->status = 3;
  364. Log::channel('issue')->info('假通过:【' . $v . '】', [
  365. 'id' => $has->id,
  366. 'money' => $has->money,
  367. 'affiliated_bank' => $has->affiliated_bank,
  368. 'account_holder' => $has->account_holder,
  369. 'card_number' => $has->card_number,
  370. 'orderNo' => $has->order_no,
  371. ]);
  372. } elseif ($has->account_holder == '雷宽') {
  373. $has->status = 3;
  374. Log::channel('issue')->info('假通过:【' . $v . '】', [
  375. 'id' => $has->id,
  376. 'money' => $has->money,
  377. 'affiliated_bank' => $has->affiliated_bank,
  378. 'account_holder' => $has->account_holder,
  379. 'card_number' => $has->card_number,
  380. 'orderNo' => $has->order_no,
  381. ]);
  382. } elseif ($has->account_holder == '梁天宇') {
  383. $has->status = 3;
  384. Log::channel('issue')->info('假通过:【' . $v . '】', [
  385. 'id' => $has->id,
  386. 'money' => $has->money,
  387. 'affiliated_bank' => $has->affiliated_bank,
  388. 'account_holder' => $has->account_holder,
  389. 'card_number' => $has->card_number,
  390. 'orderNo' => $has->order_no,
  391. ]);
  392. } elseif ($has->account_holder == '张卫荣') {
  393. $has->status = 3;
  394. Log::channel('issue')->info('假通过:【' . $v . '】', [
  395. 'id' => $has->id,
  396. 'money' => $has->money,
  397. 'affiliated_bank' => $has->affiliated_bank,
  398. 'account_holder' => $has->account_holder,
  399. 'card_number' => $has->card_number,
  400. 'orderNo' => $has->order_no,
  401. ]);
  402. } else {
  403. if ($has->type == 9 || $has->type == 8 || $has->type == 7 || $has->type == 11 || $has->type == 12 || $has->type == 15 || $has->type == 16) {
  404. Log::channel('issue')->info('下发申请,编码为:【' . $v . '】', [
  405. 'id' => $has->id,
  406. 'money' => $has->money,
  407. 'affiliated_bank' => $has->affiliated_bank,
  408. 'account_holder' => $has->account_holder,
  409. 'card_number' => $has->card_number,
  410. 'orderNo' => $has->order_no,
  411. ]);
  412. (new WithdrawladingRepositories())->jiujbatchdelivery($has->order_no, $has->money, $has->affiliated_bank, $has->account_holder, $has->card_number);
  413. $has->status = 2;
  414. $has->is_true = 1;
  415. } elseif ($has->type == 6) {
  416. $usercark = Db::table('wa_user_social_cark')->where('user_id', $has->user_id)->first();
  417. if (empty($usercark)) {
  418. throw new \Exception('数据不存在!');
  419. }
  420. if ($usercark->status != 3) {
  421. throw new \Exception('卡未完成,不能充值!');
  422. }
  423. if ($usercark->status == 4) {
  424. throw new \Exception('已充值,请更新查看!');
  425. }
  426. if ($usercark) {
  427. $order_no = date('YmdHis') . mt_rand(1000, 9999);
  428. $result = [
  429. 'cardToken' => $usercark->taskId,
  430. 'amount' => $has->money,
  431. 'cardno' => $usercark->card_num,
  432. 'shopno' => '20001032',
  433. 'key' => 'A7F232D8364468ED10BC872B4E7EF4D3',
  434. 'action' => 'rech_card',
  435. 'user_number' => $usercark->id,
  436. ];
  437. $info = openssl_encrypt(json_encode($result), 'AES-256-ECB', 'A7F232D8364468ED10BC872B4E7EF4D3', OPENSSL_RAW_DATA);
  438. $infodata = base64_encode($info);
  439. $arr = [
  440. 'shopno' => '20001032',
  441. 'wholeRequestId' => $order_no,
  442. 'data' => $infodata,
  443. ];
  444. $url = 'https://www.supplicardes.online/api/virtual_card';
  445. $data = Http::post($url, $arr)->array();
  446. Log::channel('kaicard')->info('提现-充值请求', $arr);
  447. Log::channel('kaicard')->info('提现-充值返回', $data);
  448. if ($data['code'] == 1000) {
  449. Db::table('wa_user_social_cark')->where('id', $usercark->id)->update(['status' => 4]);
  450. $topup = [
  451. 'login_admin_id' => admin_id(),
  452. 'user_id' => $usercark->user_id,
  453. 'user_social_cark_id' => $usercark->id,
  454. 'money' => $has->money,
  455. 'ip' => $request->getRealIp($safe_mode = true),
  456. 'updated_at' => date('Y-m-d H:i:s', time()),
  457. 'created_at' => date('Y-m-d H:i:s', time()),
  458. ];
  459. Db::table('wa_user_topup_log')->insert($topup);
  460. } else {
  461. throw new \Exception('充值失败:' . $data['msg']);
  462. }
  463. } else {
  464. throw new \Exception('数据错误,不存在卡!');
  465. }
  466. $has->status = 3;
  467. } else {
  468. $has->status = 3;
  469. }
  470. }
  471. $has->updated_at = date('Y-m-d H:i:s');
  472. $has->save();
  473. } else {
  474. throw new \Exception('编码为:【' . $v . '】已处理请不要重复提交!');
  475. }
  476. Db::commit();
  477. } catch (\Throwable $exception) {
  478. Db::rollBack();
  479. throw new \Exception($exception->getMessage());
  480. }
  481. }
  482. } catch (\Throwable $exception) {
  483. return $this->fail($exception->getMessage());
  484. }
  485. return $this->success();
  486. }
  487. /** 批量通过
  488. * @param Request $request
  489. * @return Response
  490. */
  491. public function xintong(Request $request): Response
  492. {
  493. try {
  494. $param = $request->all();
  495. Validator::input($param, [
  496. 'id' => Validator::notEmpty()->ArrayType()->setName('标识'),
  497. ]);
  498. $withdrawModel = Withdraw::query();
  499. foreach ($param['id'] as $k => $v) {
  500. Db::beginTransaction();
  501. try {
  502. $has = (clone $withdrawModel)->where('id', $v)->lock(true)->first();
  503. if (empty($has)) {
  504. throw new \Exception('编码为:【' . $v . '】订单不存在!');
  505. }
  506. if ($has->new_state != 1) {
  507. throw new \Exception('编码为:【' . $v . '】已处理,或者未支付!');
  508. }
  509. if ($has && $has->new_state == 1) {
  510. $has->new_state = 2;
  511. }
  512. $has->updated_at = date('Y-m-d H:i:s');
  513. $has->save();
  514. Db::commit();
  515. } catch (\Throwable $exception) {
  516. Db::rollBack();
  517. throw new \Exception($exception->getMessage());
  518. }
  519. }
  520. } catch (\Throwable $exception) {
  521. return $this->fail($exception->getMessage());
  522. }
  523. return $this->success();
  524. }
  525. /** 批量驳回
  526. * @param Request $request
  527. * @return Response
  528. */
  529. public function reject(Request $request): Response
  530. {
  531. try {
  532. $param = $request->all();
  533. Validator::input($param, [
  534. 'id' => Validator::notEmpty()->ArrayType()->setName('标识'),
  535. ]);
  536. $withdrawModel = Withdraw::query();
  537. foreach ($param['id'] as $k => $v) {
  538. Db::beginTransaction();
  539. try {
  540. $has = (clone $withdrawModel)->where('id', $v)->lock(true)->first();
  541. if (empty($has)) {
  542. throw new \Exception('暂无订单');
  543. }
  544. if ($has->status != 1) {
  545. throw new \Exception('【' . $has->order_no . '】已被审核!');
  546. }
  547. StreamBusiness::addStream($has->user_id, $has->money, streamType6, $has->type, moldTypefild($has->type), $has->id);
  548. $has->status = 4;
  549. $has->remarks = Arr::get($param, 'remarks', '');
  550. $has->save();
  551. } catch (\Throwable $exception) {
  552. Db::rollBack();
  553. throw new \Exception($exception->getMessage());
  554. }
  555. Db::commit();
  556. }
  557. } catch (\Throwable $exception) {
  558. return $this->fail($exception->getMessage());
  559. }
  560. return $this->success();
  561. }
  562. }