Update MediaService.php

This commit is contained in:
邹景立 2021-09-15 23:43:27 +08:00
parent bf8a55e53b
commit f96035eccc

View File

@ -71,7 +71,7 @@ class MediaService extends Service
{ {
$map = ['md5' => md5($url), 'appid' => WechatService::instance()->getAppid()]; $map = ['md5' => md5($url), 'appid' => WechatService::instance()->getAppid()];
if (($mediaId = $this->app->db->name('WechatMedia')->where($map)->value('media_id'))) return $mediaId; if (($mediaId = $this->app->db->name('WechatMedia')->where($map)->value('media_id'))) return $mediaId;
$result = WechatService::WeChatMedia()->addMaterial(self::_buildCurlFile($url), $type, $video); $result = WechatService::WeChatMedia()->addMaterial(self::buildCurlFile($url), $type, $video);
data_save('WechatMedia', [ data_save('WechatMedia', [
'local_url' => $url, 'md5' => $map['md5'], 'type' => $type, 'appid' => $map['appid'], 'local_url' => $url, 'md5' => $map['md5'], 'type' => $type, 'appid' => $map['appid'],
'media_url' => $result['url'] ?? '', 'media_id' => $result['media_id'], 'media_url' => $result['url'] ?? '', 'media_id' => $result['media_id'],
@ -85,7 +85,7 @@ class MediaService extends Service
* @return MyCurlFile * @return MyCurlFile
* @throws \WeChat\Exceptions\LocalCacheException * @throws \WeChat\Exceptions\LocalCacheException
*/ */
private function _buildCurlFile(string $local): MyCurlFile private function buildCurlFile(string $local): MyCurlFile
{ {
if (file_exists($local)) { if (file_exists($local)) {
return new MyCurlFile($local); return new MyCurlFile($local);