PublicApi.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\wap\controller;
  12. use service\JsonService;
  13. use service\SystemConfigService;
  14. class PublicApi
  15. {
  16. public function wechat_media_id_by_image($mediaIds = '')
  17. {
  18. if (!$mediaIds) return JsonService::fail('参数错误');
  19. try {
  20. $mediaIds = explode(',', $mediaIds);
  21. $temporary = \service\WechatService::materialTemporaryService();
  22. $pathList = [];
  23. foreach ($mediaIds as $mediaId) {
  24. if (!$mediaId) continue;
  25. try {
  26. $content = $temporary->getStream($mediaId);
  27. } catch (\Exception $e) {
  28. continue;
  29. }
  30. $name = substr(md5($mediaId), 12, 20) . '.jpg';
  31. $res = \Api\AliyunOss::instance([
  32. 'AccessKey' => SystemConfigService::get('accessKeyId'),
  33. 'AccessKeySecret' => SystemConfigService::get('accessKeySecret'),
  34. 'OssEndpoint' => SystemConfigService::get('end_point'),
  35. 'OssBucket' => SystemConfigService::get('OssBucket'),
  36. 'uploadUrl' => SystemConfigService::get('uploadUrl'),
  37. ])->stream($content, $name);
  38. if ($res !== false) {
  39. $pathList[] = $res['url'];
  40. }
  41. }
  42. return JsonService::successful($pathList);
  43. } catch (\Exception $e) {
  44. return JsonService::fail('上传失败', ['msg' => $e->getMessage(), 'line' => $e->getLine(), 'file' => $e->getFile()]);
  45. }
  46. }
  47. /**网站统计
  48. * @return bool|mixed
  49. */
  50. public function get_website_statistics()
  51. {
  52. return SystemConfigService::get('website_statistics');
  53. }
  54. /**
  55. * 公用数据
  56. */
  57. public function public_data()
  58. {
  59. $customer_service = SystemConfigService::get('customer_service_configuration');//客服配置1=微信客服2=crmeb客服3=拨打电话
  60. $data['customer_service'] = $customer_service;//客服配置1=微信客服2=crmeb客服3=拨打电话
  61. $data['site_service_phone'] = SystemConfigService::get('site_service_phone');//客服电话
  62. return JsonService::successful($data);
  63. }
  64. }