OrderController.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: zilongs
  5. * Date: 20-9-30
  6. * Time: 下午10:58
  7. */
  8. namespace App\Http\Controllers\Api\V1;
  9. use App\Models\Nurse;
  10. use App\Models\Order;
  11. use App\Models\OrderNurse;
  12. use App\Models\OrderPack;
  13. use App\Models\OrderPatient;
  14. use App\Models\OrderVaccine;
  15. use App\Models\Patient;
  16. use App\Models\Payment;
  17. use App\Models\ServicePack;
  18. use App\Models\TimePeriod;
  19. use App\Models\User;
  20. use App\Models\UserCoupon;
  21. use App\Models\Vaccine;
  22. use EasyWeChat\Factory;
  23. use DB;
  24. class OrderController extends AuthController
  25. {
  26. public function consultPlaceOrder()
  27. {
  28. $req = request()->post();
  29. $this->validate(request(), [
  30. 'payment_type' => 'required|in:1,2',
  31. 'product_type' => 'required|in:1,2',
  32. 'docter_id' => 'required|integer',
  33. 'patient_id' => 'required|integer',
  34. 'total_amount' => 'required|integer',
  35. 'user_coupon_id' => 'integer',
  36. 'phone' => 'required_if:product_type,1',
  37. 'phone_minutes' => 'required_if:product_type,1|integer',
  38. 'symptoms' => 'required_if:product_type,2|max:2000',
  39. 'medical_imgs' => 'required_if:product_type,2|json|max:3000',
  40. 'pay_password|支付密码' => 'required_if:payment_type,2|integer',
  41. ]);
  42. $user = $this->user;
  43. if (!empty($req['pay_password'])) {
  44. if (empty($user['pay_password'])) {
  45. return out(null, 60010, '未设置支付密码');
  46. }
  47. if (sha1(md5($req['pay_password'])) !== $user['pay_password']) {
  48. return out(null, 10001, '密码错误');
  49. }
  50. }
  51. $discount_amount = 0;
  52. if (!empty($req['user_coupon_id'])) {
  53. //计算优惠金额
  54. $discount_amount = UserCoupon::getDiscountAmount($req['user_coupon_id'], $user['id'], $req['total_amount'], $req['product_type']);
  55. }
  56. $payment_amount = $req['total_amount'] - $discount_amount;
  57. $payment_amount = $payment_amount < 0 ? 0 : $payment_amount;
  58. if ($req['payment_type'] == 2) {
  59. if ($user['balance'] < $payment_amount) {
  60. return out(null, 601, '余额不足');
  61. }
  62. }
  63. $order_status = $payment_status = 1;
  64. $payment_time = 0;
  65. if ($payment_amount == 0 || $req['payment_type'] == 2) {
  66. $order_status = $payment_status = 2;
  67. $payment_time = time();
  68. }
  69. $config = null;
  70. DB::beginTransaction();
  71. try {
  72. //保存订单数据
  73. $order = Order::create([
  74. 'user_id' => $user['id'],
  75. 'payment_type' => $req['payment_type'],
  76. 'product_type' => $req['product_type'],
  77. 'docter_id' => $req['docter_id'],
  78. 'total_amount' => $req['total_amount'],
  79. 'payment_amount' => $payment_amount,
  80. 'discount_amount' => $discount_amount,
  81. 'patient_id' => $req['patient_id'],
  82. 'order_status' => $order_status,
  83. 'payment_status' => $payment_status,
  84. 'payment_time' => $payment_time,
  85. ]);
  86. $order_sn = build_sn($order['id']);
  87. Order::where('id', $order['id'])->update(['order_sn' => $order_sn]);
  88. //保存订单患者信息
  89. $addPatient = Patient::select(['name', 'sex', 'avatar', 'birthday', 'relationship_type', 'info', 'card_type', 'card_number', 'card_img_url', 'card_back_img_url'])->where('id', $req['patient_id'])->first()->getOriginal();
  90. $addPatient['order_id'] = $order['id'];
  91. $addPatient['patient_id'] = $req['patient_id'];
  92. if ($req['product_type'] == 1) {
  93. $addPatient['phone'] = $req['phone'];
  94. $addPatient['phone_minutes'] = $req['phone_minutes'];
  95. }
  96. elseif ($req['product_type'] == 2) {
  97. $addPatient['symptoms'] = $req['symptoms'];
  98. $addPatient['medical_imgs'] = $req['medical_imgs'];
  99. }
  100. OrderPatient::create($addPatient);
  101. //判断是微信支付
  102. if ($req['payment_type'] == 1) {
  103. //生成支付交易单
  104. if ($payment_amount > 0) {
  105. $trade_sn = build_sn($order['id'], 3, 'T');
  106. $payBody = '超级宝妈-'.config('config.product_type_map')[$req['product_type']];
  107. Payment::create([
  108. 'user_id' => $user['id'],
  109. 'order_id' => $order['id'],
  110. 'trade_sn' => $trade_sn,
  111. 'amount' => $payment_amount,
  112. 'remark' => $payBody,
  113. ]);
  114. //请求支付
  115. $payment = Factory::payment(config('config.wechat_pay'));
  116. $result = $payment->order->unify([
  117. 'body' => $payBody,
  118. 'out_trade_no' => $trade_sn,
  119. 'total_fee' => $payment_amount,
  120. 'trade_type' => 'JSAPI',
  121. 'openid' => $user['openid'],
  122. ]);
  123. if (empty($result['prepay_id'])) {
  124. $errorMsg = !empty($result['err_code_des']) ? $result['err_code_des'] : $result['return_msg'];
  125. return out(null, 702, $errorMsg);
  126. }
  127. $config = $payment->jssdk->bridgeConfig($result['prepay_id'], false);
  128. }
  129. }
  130. //判断是余额支付
  131. elseif ($req['payment_type'] == 2) {
  132. if ($payment_amount > 0) {
  133. //改变用户余额
  134. $change_amount = 0 - $payment_amount;
  135. User::changeBalance($user['id'], $change_amount, 1, $order['id'], '咨询订单消费');
  136. Order::payCompletedHandle($order['id']);
  137. }
  138. }
  139. DB::commit();
  140. } catch (\Exception $e) {
  141. DB::rollBack();
  142. return out(null, 500, '下单失败,请稍后重试', $e->getMessage());
  143. }
  144. return out($config);
  145. }
  146. public function appointPlaceOrder()
  147. {
  148. $req = request()->post();
  149. $this->validate(request(), [
  150. 'payment_type' => 'required|in:1,2',
  151. 'product_type' => 'required|in:3,4,5',
  152. 'patient_id' => 'required|integer',
  153. 'organization_id' => 'required|integer',
  154. 'schedule_date' => 'required|date',
  155. 'time_period_id' => 'required|integer',
  156. 'total_amount' => 'required|integer',
  157. 'user_coupon_id' => 'integer',
  158. 'docter_id' => 'required_if:product_type,3|integer',
  159. 'vaccine_id' => 'required_if:product_type,4|integer',
  160. 'nurse_ids' => 'required_if:product_type,5|json',
  161. 'pay_password|支付密码' => 'required_if:payment_type,2|integer',
  162. ]);
  163. $user = $this->user;
  164. if (!empty($req['pay_password'])) {
  165. if (empty($user['pay_password'])) {
  166. return out(null, 60010, '未设置支付密码');
  167. }
  168. if (sha1(md5($req['pay_password'])) !== $user['pay_password']) {
  169. return out(null, 10001, '密码错误');
  170. }
  171. }
  172. $product_type = $req['product_type'];
  173. if ($req['product_type'] == 4) {
  174. $vaccine = Vaccine::select(['type'])->where('id', $req['vaccine_id'])->first();
  175. if ($vaccine['type'] == 2) {
  176. if (empty($req['total_amount'])) {
  177. return out(null, 10001, '总价不能为0');
  178. }
  179. }
  180. }
  181. $discount_amount = 0;
  182. if (!empty($req['user_coupon_id'])) {
  183. //计算优惠金额
  184. $discount_amount = UserCoupon::getDiscountAmount($req['user_coupon_id'], $user['id'], $req['total_amount'], $product_type);
  185. }
  186. $payment_amount = $req['total_amount'] - $discount_amount;
  187. $payment_amount = $payment_amount < 0 ? 0 : $payment_amount;
  188. if ($req['payment_type'] == 2) {
  189. if ($user['balance'] < $payment_amount) {
  190. return out(null, 601, '余额不足');
  191. }
  192. }
  193. $order_status = $payment_status = 1;
  194. $payment_time = 0;
  195. if ($payment_amount == 0 || $req['payment_type'] == 2) {
  196. $order_status = 3;
  197. $payment_status = 2;
  198. $payment_time = time();
  199. }
  200. $config = null;
  201. DB::beginTransaction();
  202. try {
  203. //保存订单数据
  204. $order = Order::create([
  205. 'user_id' => $user['id'],
  206. 'docter_id' => $req['docter_id'] ?? 0,
  207. 'patient_id' => $req['patient_id'],
  208. 'organization_id' => $req['organization_id'],
  209. 'payment_type' => $req['payment_type'],
  210. 'product_type' => $product_type,
  211. 'order_status' => $order_status,
  212. 'payment_status' => $payment_status,
  213. 'total_amount' => $req['total_amount'],
  214. 'payment_amount' => $payment_amount,
  215. 'discount_amount' => $discount_amount,
  216. 'payment_time' => $payment_time,
  217. ]);
  218. $order_sn = build_sn($order['id']);
  219. Order::where('id', $order['id'])->update(['order_sn' => $order_sn]);
  220. //保存订单患者信息
  221. $addPatient = Patient::select(['name', 'sex', 'avatar', 'birthday', 'relationship_type', 'info', 'card_type', 'card_number', 'card_img_url', 'card_back_img_url'])->where('id', $req['patient_id'])->first()->getOriginal();
  222. $addPatient['order_id'] = $order['id'];
  223. $addPatient['patient_id'] = $req['patient_id'];
  224. $addPatient['organization_id'] = $req['organization_id'];
  225. $addPatient['time_period_id'] = $req['time_period_id'];
  226. $timePeriod = TimePeriod::where('id', $req['time_period_id'])->first();
  227. $addPatient['appoint_start_time'] = strtotime($req['schedule_date'].' '.$timePeriod['start_time_period'].':00');
  228. $addPatient['appoint_end_time'] = strtotime($req['schedule_date'].' '.$timePeriod['end_time_period'].':00');
  229. $orderPatient = OrderPatient::create($addPatient);
  230. //保存订单疫苗信息
  231. if ($req['product_type'] == 4) {
  232. $addVaccine = Vaccine::select(['id as vaccine_id', 'type as vaccine_type', 'price as vaccine_price', 'name as vaccine_name', 'remark as vaccine_remark', 'supplier as vaccine_supplier'])->where('id', $req['vaccine_id'])->first()->getOriginal();
  233. $addVaccine['order_id'] = $order['id'];
  234. $addVaccine['order_patient_id'] = $orderPatient['id'];
  235. OrderVaccine::create($addVaccine);
  236. }
  237. //保存儿保订单信息
  238. if ($req['product_type'] == 5) {
  239. $nurse_ids = json_decode($req['nurse_ids'], true);
  240. foreach ($nurse_ids as $k => $v) {
  241. $addNurse = Nurse::select(['id as nurse_id', 'price as nurse_price', 'name as nurse_name', 'remark as nurse_remark'])->where('id', $v)->first()->getOriginal();
  242. $addNurse['order_id'] = $order['id'];
  243. $addNurse['order_patient_id'] = $orderPatient['id'];
  244. OrderNurse::create($addNurse);
  245. }
  246. }
  247. //判断是微信支付
  248. if ($req['payment_type'] == 1) {
  249. //生成支付交易单
  250. if ($payment_amount > 0) {
  251. $trade_sn = build_sn($order['id'], 3, 'T');
  252. $payBody = '超级宝妈-'.config('config.product_type_map')[$product_type];
  253. Payment::create([
  254. 'user_id' => $user['id'],
  255. 'order_id' => $order['id'],
  256. 'trade_sn' => $trade_sn,
  257. 'amount' => $payment_amount,
  258. 'remark' => $payBody,
  259. ]);
  260. //请求支付
  261. $payment = Factory::payment(config('config.wechat_pay'));
  262. $result = $payment->order->unify([
  263. 'body' => $payBody,
  264. 'out_trade_no' => $trade_sn,
  265. 'total_fee' => $payment_amount,
  266. 'trade_type' => 'JSAPI',
  267. 'openid' => $user['openid'],
  268. ]);
  269. if (empty($result['prepay_id'])) {
  270. $errorMsg = !empty($result['err_code_des']) ? $result['err_code_des'] : $result['return_msg'];
  271. return out(null, 702, $errorMsg);
  272. }
  273. $config = $payment->jssdk->bridgeConfig($result['prepay_id'], false);
  274. }
  275. }
  276. //判断是余额支付
  277. elseif ($req['payment_type'] == 2) {
  278. if ($payment_amount > 0) {
  279. //改变用户余额
  280. $change_amount = 0 - $payment_amount;
  281. User::changeBalance($user['id'], $change_amount, 1, $order['id'], '预约订单消费');
  282. Order::payCompletedHandle($order['id']);
  283. }
  284. }
  285. DB::commit();
  286. } catch (\Exception $e) {
  287. DB::rollBack();
  288. return out(null, 500, '下单失败,请稍后重试', $e->getMessage());
  289. }
  290. return out($config);
  291. }
  292. public function packPlaceOrder()
  293. {
  294. $req = request()->post();
  295. $this->validate(request(), [
  296. 'payment_type' => 'required|in:1,2',
  297. 'patient_id' => 'required|integer',
  298. 'total_amount' => 'required|integer',
  299. 'user_coupon_id' => 'integer',
  300. 'service_pack_id' => 'required|integer',
  301. 'is_security' => 'required|in:0,1',
  302. 'guardian_name' => 'required|max:50',
  303. 'relationship_type' => 'required|integer',
  304. 'pay_password|支付密码' => 'required_if:payment_type,2|integer',
  305. ]);
  306. $user = $this->user;
  307. if (!empty($req['pay_password'])) {
  308. if (empty($user['pay_password'])) {
  309. return out(null, 60010, '未设置支付密码');
  310. }
  311. if (sha1(md5($req['pay_password'])) !== $user['pay_password']) {
  312. return out(null, 10001, '密码错误');
  313. }
  314. }
  315. $discount_amount = 0;
  316. if (!empty($req['user_coupon_id'])) {
  317. //计算优惠金额
  318. $discount_amount = UserCoupon::getDiscountAmount($req['user_coupon_id'], $user['id'], $req['total_amount'], 6);
  319. }
  320. $addPatient = Patient::select(['name', 'sex', 'avatar', 'birthday', 'relationship_type', 'info', 'card_type', 'card_number', 'card_img_url', 'card_back_img_url'])->where('id', $req['patient_id'])->first()->getOriginal();
  321. if (empty($addPatient['card_img_url'])) {
  322. return out(null, 70011, '该患者未上传身份证');
  323. }
  324. $payment_amount = $req['total_amount'] - $discount_amount;
  325. $payment_amount = $payment_amount < 0 ? 0 : $payment_amount;
  326. if ($req['payment_type'] == 2) {
  327. if ($user['balance'] < $payment_amount) {
  328. return out(null, 601, '余额不足');
  329. }
  330. }
  331. $order_status = $payment_status = 1;
  332. $payment_time = 0;
  333. if ($payment_amount == 0 || $req['payment_type'] == 2) {
  334. $order_status = 3;
  335. $payment_status = 2;
  336. $payment_time = time();
  337. }
  338. $config = null;
  339. DB::beginTransaction();
  340. try {
  341. //保存订单数据
  342. $order = Order::create([
  343. 'user_id' => $user['id'],
  344. 'patient_id' => $req['patient_id'],
  345. 'payment_type' => $req['payment_type'],
  346. 'product_type' => 6,
  347. 'total_amount' => $req['total_amount'],
  348. 'payment_amount' => $payment_amount,
  349. 'discount_amount' => $discount_amount,
  350. 'order_status' => $order_status,
  351. 'payment_status' => $payment_status,
  352. 'payment_time' => $payment_time,
  353. ]);
  354. $order_sn = build_sn($order['id']);
  355. Order::where('id', $order['id'])->update(['order_sn' => $order_sn]);
  356. //保存订单患者信息
  357. $addPatient['order_id'] = $order['id'];
  358. $addPatient['patient_id'] = $req['patient_id'];
  359. OrderPatient::create($addPatient);
  360. //保存订单服务包表
  361. $addPack = ServicePack::select(['id as service_pack_id', 'name as pack_name', 'intro as pack_intro', 'price as pack_price', 'insurance_policy', 'insurance_img_url', 'team_id', 'phone_minutes', 'chat_num', 'appoint_num', 'vaccine_limit_amount', 'nurses_limit_amount', 'effective_days'])->where('id', $req['service_pack_id'])->first()->getOriginal();
  362. $addPack['order_id'] = $order['id'];
  363. $addPack['is_security'] = $req['is_security'];
  364. $addPack['guardian_name'] = $req['guardian_name'];
  365. $addPack['relationship_type'] = $req['relationship_type'];
  366. $addPack['start_time'] = time();
  367. $addPack['end_time'] = time() + $addPack['effective_days']*24*3600;
  368. OrderPack::create($addPack);
  369. //判断是微信支付
  370. if ($req['payment_type'] == 1) {
  371. //生成支付交易单
  372. if ($payment_amount > 0) {
  373. $trade_sn = build_sn($order['id'], 3, 'T');
  374. $payBody = '超级宝妈-'.config('config.product_type_map')[6];
  375. Payment::create([
  376. 'user_id' => $user['id'],
  377. 'order_id' => $order['id'],
  378. 'trade_sn' => $trade_sn,
  379. 'amount' => $payment_amount,
  380. 'remark' => $payBody,
  381. ]);
  382. //请求支付
  383. $payment = Factory::payment(config('config.wechat_pay'));
  384. $result = $payment->order->unify([
  385. 'body' => $payBody,
  386. 'out_trade_no' => $trade_sn,
  387. 'total_fee' => $payment_amount,
  388. 'trade_type' => 'JSAPI',
  389. 'openid' => $user['openid'],
  390. ]);
  391. if (empty($result['prepay_id'])) {
  392. $errorMsg = !empty($result['err_code_des']) ? $result['err_code_des'] : $result['return_msg'];
  393. return out(null, 702, $errorMsg);
  394. }
  395. $config = $payment->jssdk->bridgeConfig($result['prepay_id'], false);
  396. }
  397. }
  398. //判断是余额支付
  399. elseif ($req['payment_type'] == 2) {
  400. if ($payment_amount > 0) {
  401. //改变用户余额
  402. $change_amount = 0 - $payment_amount;
  403. User::changeBalance($user['id'], $change_amount, 1, $order['id'], '购买服务包');
  404. Order::payCompletedHandle($order['id']);
  405. }
  406. }
  407. DB::commit();
  408. } catch (\Exception $e) {
  409. DB::rollBack();
  410. return out(null, 500, '下单失败,请稍后重试', $e->getMessage());
  411. }
  412. return out($config);
  413. }
  414. public function orderList()
  415. {
  416. $req = request()->post();
  417. $this->validate(request(), [
  418. 'list_type' => 'required|in:0,1,2',
  419. 'product_type' => 'integer',
  420. 'order_status' => 'integer',
  421. 'time_sort' => 'in:0,1',
  422. 'is_pack_expire' => 'in:0,1,2',
  423. ]);
  424. $user = $this->user;
  425. $builder = Order::with(['docter.office', 'docter.qualification', 'orderPatient', 'orderPack', 'orderNurse', 'orderVaccine', 'organization.docter'])->where('user_id', $user['id']);
  426. if (!empty($req['product_type'])) {
  427. $builder->where('product_type', $req['product_type']);
  428. }
  429. else {
  430. if (!empty($req['list_type'])) {
  431. if ($req['list_type'] == 1) {
  432. $builder->whereIn('product_type', [1,2]);
  433. }
  434. elseif ($req['list_type'] == 2) {
  435. $builder->whereIn('product_type', [3,4,5]);
  436. }
  437. }
  438. else {
  439. $builder->where('product_type', '<', 7);
  440. }
  441. }
  442. if (!empty($req['order_status'])) {
  443. $builder->where('order_status', $req['order_status']);
  444. }
  445. if (!empty($req['is_pack_expire'])) {
  446. $tmpBuilder = OrderPack::join('orders as o', 'o.id', '=', 'order_packs.order_id')->where('o.user_id', $user['id']);
  447. if ($req['is_pack_expire'] == 1) {
  448. $tmpBuilder->where('order_packs.end_time', '<', time());
  449. }
  450. else {
  451. $tmpBuilder->where('order_packs.end_time', '>=', time());
  452. }
  453. $order_ids = $tmpBuilder->pluck('o.id')->toArray();
  454. $builder->whereIn('id', $order_ids);
  455. }
  456. if (!empty($req['time_sort'])) {
  457. $builder->orderBy('id', 'desc');
  458. }
  459. else {
  460. $builder->orderBy('id', 'asc');
  461. }
  462. $data = $builder->paginate();
  463. return out($data);
  464. }
  465. public function orderDetail()
  466. {
  467. $req = request()->post();
  468. $this->validate(request(), [
  469. 'order_id' => 'required|integer'
  470. ]);
  471. $user = $this->user;
  472. $data = Order::with(['docter.office', 'docter.qualification', 'orderPatient', 'orderPack.team.docter', 'orderNurse', 'orderVaccine', 'organization.docter'])->where('id', $req['order_id'])->where('user_id', $user['id'])->first();
  473. return out($data);
  474. }
  475. public function topup()
  476. {
  477. $req = request()->post();
  478. $this->validate(request(), [
  479. 'amount' => 'required|integer',
  480. ]);
  481. $user = $this->user;
  482. DB::beginTransaction();
  483. try {
  484. //保存订单数据
  485. $order = Order::create([
  486. 'user_id' => $user['id'],
  487. 'product_type' => 7,
  488. 'total_amount' => $req['amount'],
  489. 'payment_amount' => $req['amount'],
  490. ]);
  491. $order_sn = build_sn($order['id']);
  492. Order::where('id', $order['id'])->update(['order_sn' => $order_sn]);
  493. //生成支付交易单
  494. $trade_sn = build_sn($order['id'], 3, 'T');
  495. $payBody = '超级宝妈-'.config('config.product_type_map')[7];
  496. Payment::create([
  497. 'user_id' => $user['id'],
  498. 'order_id' => $order['id'],
  499. 'trade_sn' => $trade_sn,
  500. 'amount' => $req['amount'],
  501. 'remark' => $payBody,
  502. ]);
  503. //请求支付
  504. $payment = Factory::payment(config('config.wechat_pay'));
  505. $result = $payment->order->unify([
  506. 'body' => $payBody,
  507. 'out_trade_no' => $trade_sn,
  508. 'total_fee' => $req['amount'],
  509. 'trade_type' => 'JSAPI',
  510. 'openid' => $user['openid'],
  511. ]);
  512. if (empty($result['prepay_id'])) {
  513. $errorMsg = !empty($result['err_code_des']) ? $result['err_code_des'] : $result['return_msg'];
  514. return out(null, 702, $errorMsg);
  515. }
  516. $config = $payment->jssdk->bridgeConfig($result['prepay_id'], false);
  517. DB::commit();
  518. } catch (\Exception $e) {
  519. DB::rollBack();
  520. return out(null, 500, '下单失败,请稍后重试', $e->getMessage());
  521. }
  522. return out($config);
  523. }
  524. }