OutsideAppController.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Name: 芸众商城系统
  5. * Author: 广州市芸众信息科技有限公司
  6. * Profile: 广州市芸众信息科技有限公司位于国际商贸中心的广州,专注于移动电子商务生态系统打造,拥有芸众社交电商系统、区块链数字资产管理系统、供应链管理系统、电子合同等产品/服务。官网 :www.yunzmall.com www.yunzshop.com
  7. * Date: 2022/1/6
  8. * Time: 17:08
  9. */
  10. namespace app\backend\modules\setting\controllers;
  11. use app\common\components\BaseController;
  12. use app\outside\modes\OutsideAppSetting;
  13. use app\outside\services\OutsideAppService;
  14. class OutsideAppController extends BaseController
  15. {
  16. public function index()
  17. {
  18. $data['set'] = OutsideAppSetting::current()?OutsideAppSetting::current()->toArray():[];
  19. return view('setting.outside.application', [
  20. 'data' => json_encode($data),
  21. ]);
  22. }
  23. public function createApp()
  24. {
  25. $app = OutsideAppSetting::current()?: new OutsideAppSetting();
  26. $app_id = OutsideAppSetting::uniqueApp();
  27. $app_secret = OutsideAppSetting::uniqueSecret($app_id);
  28. $createData = [
  29. 'uniacid' => \YunShop::app()->uniacid,
  30. 'is_open' => 1,
  31. 'app_id' => $app_id,
  32. 'app_secret' => $app_secret,
  33. ];
  34. $app->fill($createData);
  35. $bool = $app->save();
  36. if ($bool) {
  37. return $this->successJson('成功');
  38. }
  39. return $this->errorJson('失败');
  40. }
  41. public function updateSecret()
  42. {
  43. $app = OutsideAppSetting::current();
  44. if (!$app) {
  45. return $this->errorJson('APP应用不存在');
  46. }
  47. $bool = $app->fill(['app_secret' => OutsideAppSetting::uniqueSecret($app->app_id)])->save();
  48. if ($bool) {
  49. return $this->successJson('密钥更新成功');
  50. }
  51. return $this->errorJson('密钥生成失败');
  52. }
  53. public function store()
  54. {
  55. $data = request()->input('data');
  56. $app = OutsideAppSetting::current();
  57. if (!$app) {
  58. return $this->errorJson('APP应用不存在');
  59. }
  60. $bool = $app->fill($data)->save();
  61. if ($bool) {
  62. return $this->successJson('成功');
  63. }
  64. return $this->errorJson('操作不存在');
  65. }
  66. }