PosterUtil.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. <?php
  2. namespace common\components;
  3. /**
  4. * 散客分享海报(OSS:poster/blank.png 动态画布 + 水印合成,布局参考快团团)
  5. */
  6. class PosterUtil
  7. {
  8. const BLANK_CANVAS = 'poster/blank.png';
  9. const FONT = 'd3F5LW1pY3JvaGVp';
  10. const POSTER_W = 750;
  11. const CANVAS_PAD_X = 20;
  12. const CANVAS_PAD_Y = 20;
  13. /** 文案每行最多字数(商品名、注意事项) */
  14. const TEXT_CHARS_PER_LINE = 17;
  15. /** OSS 单段文字水印长度上限(约 64,汉字按 3 计,17 字/行安全) */
  16. const OSS_WATERMARK_TEXT_MAX = 21;
  17. const SLOT_W = 710;
  18. const FOOTER_H = 300;
  19. const IMG_H_MIN = 240;
  20. const IMG_H_MAX = 880;
  21. const TOTAL_H_MAX = 2000;
  22. const CANVAS_COLOR = 'FFFFFF';
  23. /** 整张海报四角圆角(px) */
  24. const POSTER_CORNER_RADIUS = 16;
  25. /** 海报内商品主图圆角(px) */
  26. const COVER_CORNER_RADIUS = 12;
  27. const SHOP_LOGO_SIZE = 72;
  28. const SHOP_LOGO_GAP = 12;
  29. const SHOP_TITLE_SIZE = 36;
  30. const SHOP_TITLE_MAX_LEN = 18;
  31. const HEADER_BOTTOM_GAP = 16;
  32. const MID_AFTER_COVER_GAP = 16;
  33. /** 商品名称与备注之间的间距 */
  34. const MID_BLOCK_GAP = 18;
  35. const MID_LINE_GAP = 6;
  36. const MID_NAME_SIZE = 42;
  37. const MID_REMARK_SIZE = 26;
  38. const QR_SIZE = 220;
  39. const QR_PAD_RIGHT = 36;
  40. const QR_PAD_BOTTOM = 32;
  41. /** 价格下方提示文案(与价格左对齐,无背景条) */
  42. const FOOTER_BUY_HINT = '长按识别小程序购买';
  43. const FOOTER_BUY_HINT_SIZE = 30;
  44. const FOOTER_TEXT_GAP = 12;
  45. const FOOTER_PRICE_SIZE = 72;
  46. /**
  47. * 与 admin/home/me 一致:门店展示名、Logo 对象路径、itemRemark
  48. */
  49. public static function withShopAndRemark(array $options, $shop, $sj, $itemOrRemark = null)
  50. {
  51. $meta = self::resolveShopPosterMeta($shop, $sj);
  52. $options['shopTitle'] = $meta['shopTitle'];
  53. $options['shopLogo'] = $meta['shopLogo'];
  54. if (is_string($itemOrRemark)) {
  55. $options['itemRemark'] = self::filterPosterUtf8Text($itemOrRemark);
  56. } elseif ($itemOrRemark !== null) {
  57. $options['itemRemark'] = self::filterPosterUtf8Text($itemOrRemark->itemRemark ?? '');
  58. } else {
  59. $options['itemRemark'] = self::filterPosterUtf8Text($options['itemRemark'] ?? '');
  60. }
  61. return $options;
  62. }
  63. /**
  64. * hdApp/ghsApp me 页门店标题:sjName·shopName(首店仅 sjName)
  65. */
  66. public static function buildShopDisplayTitle($sjName, $shopName)
  67. {
  68. $sjName = trim((string)$sjName);
  69. $shopName = trim((string)$shopName);
  70. if ($shopName === '' || $shopName === '首店') {
  71. return $sjName;
  72. }
  73. return $sjName . '·' . $shopName;
  74. }
  75. public static function resolveShopPosterMeta($shop, $sj = null)
  76. {
  77. $sjName = '';
  78. if ($shop) {
  79. $sjName = trim((string)($shop->merchantName ?? ''));
  80. }
  81. if ($sj !== null) {
  82. if (is_array($sj)) {
  83. $sjName = trim((string)($sj['name'] ?? $sjName));
  84. } elseif (is_object($sj) && isset($sj->name)) {
  85. $sjName = trim((string)$sj->name);
  86. }
  87. }
  88. $shopName = $shop ? trim((string)($shop->shopName ?? '')) : '';
  89. $title = self::filterPosterUtf8Text(self::buildShopDisplayTitle($sjName, $shopName));
  90. if (mb_strlen($title, 'UTF-8') > self::SHOP_TITLE_MAX_LEN) {
  91. $title = mb_substr($title, 0, self::SHOP_TITLE_MAX_LEN, 'UTF-8') . '…';
  92. }
  93. return [
  94. 'shopTitle' => $title,
  95. 'shopLogo' => self::resolveShopLogoObjectPath($shop),
  96. ];
  97. }
  98. public static function resolveShopLogoObjectPath($shop)
  99. {
  100. $avatar = '';
  101. if ($shop && !empty($shop->avatar)) {
  102. $avatar = $shop->avatar;
  103. }
  104. return imgUtil::normalizeOssObjectPath($avatar);
  105. }
  106. /**
  107. * 海报文案 UTF-8 清洗:剔除非法字节、替换符及常见乱码字符
  108. */
  109. public static function filterPosterUtf8Text($text)
  110. {
  111. $text = trim((string)$text);
  112. if ($text === '') {
  113. return '';
  114. }
  115. if (function_exists('iconv')) {
  116. $fixed = @iconv('UTF-8', 'UTF-8//IGNORE', $text);
  117. if ($fixed !== false) {
  118. $text = $fixed;
  119. }
  120. }
  121. if (function_exists('mb_convert_encoding')) {
  122. $converted = @mb_convert_encoding($text, 'UTF-8', 'UTF-8');
  123. if (is_string($converted) && $converted !== '') {
  124. $text = $converted;
  125. }
  126. }
  127. $text = preg_replace('/[\x{FFFD}\x{FFF0}-\x{FFFF}]/u', '', $text);
  128. $text = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/u', '', $text);
  129. $text = preg_replace(
  130. '/[^\x{4e00}-\x{9fff}a-zA-Z0-9\s,。、!?:;…·~%()【】\[\]\/\-_+|《》「」\'\"\.#&@\x{3000}-\x{303F}\x{FF01}-\x{FF5E}]/u',
  131. '',
  132. $text
  133. );
  134. $text = trim(preg_replace('/\s+/u', ' ', $text));
  135. return $text;
  136. }
  137. public static function truncateText($text, $maxLen = 14)
  138. {
  139. $text = self::filterPosterUtf8Text($text);
  140. if ($text === '') {
  141. return '';
  142. }
  143. if (mb_strlen($text, 'UTF-8') > $maxLen) {
  144. return mb_substr($text, 0, $maxLen, 'UTF-8') . '…';
  145. }
  146. return $text;
  147. }
  148. /**
  149. * 按行宽拆成多行(供多条 OSS 文字水印使用,不使用 \n)
  150. *
  151. * @return string[]
  152. */
  153. public static function splitPosterTextToLines($text, $maxPerLine = self::TEXT_CHARS_PER_LINE)
  154. {
  155. $text = self::filterPosterUtf8Text($text);
  156. if ($text === '') {
  157. return [];
  158. }
  159. $maxPerLine = (int)$maxPerLine;
  160. if ($maxPerLine < 1) {
  161. $maxPerLine = self::TEXT_CHARS_PER_LINE;
  162. }
  163. $maxPerLine = min($maxPerLine, self::OSS_WATERMARK_TEXT_MAX);
  164. $lines = [];
  165. $len = mb_strlen($text, 'UTF-8');
  166. $offset = 0;
  167. while ($offset < $len) {
  168. $remain = $len - $offset;
  169. if ($remain <= $maxPerLine) {
  170. $lines[] = mb_substr($text, $offset, null, 'UTF-8');
  171. break;
  172. }
  173. $lines[] = mb_substr($text, $offset, $maxPerLine, 'UTF-8');
  174. $offset += $maxPerLine;
  175. }
  176. return $lines;
  177. }
  178. /**
  179. * @return array{0:string,1:string}
  180. * @deprecated 仅兼容旧调用,新逻辑请用 splitPosterTextToLines
  181. */
  182. public static function splitPosterTextLines($text, $maxPerLine = self::TEXT_CHARS_PER_LINE)
  183. {
  184. $lines = self::splitPosterTextToLines($text, $maxPerLine);
  185. $line1 = $lines[0] ?? '';
  186. $line2 = $lines[1] ?? '';
  187. if (count($lines) > 2) {
  188. $line2 = ($lines[1] ?? '') . '…';
  189. }
  190. return [$line1, $line2];
  191. }
  192. /** @deprecated 兼容旧调用 */
  193. public static function splitPosterNameLines($name, $maxPerLine = self::TEXT_CHARS_PER_LINE)
  194. {
  195. return self::splitPosterTextLines($name, $maxPerLine);
  196. }
  197. /** @deprecated 兼容旧调用,返回首行文案 */
  198. public static function buildPosterTwoLineText($text, $maxPerLine = self::TEXT_CHARS_PER_LINE)
  199. {
  200. $lines = self::splitPosterTextToLines($text, $maxPerLine);
  201. return $lines[0] ?? '';
  202. }
  203. /**
  204. * 商品名(图下,多行,每行独立 OSS 文字水印)
  205. *
  206. * @return string[]
  207. */
  208. public static function buildPosterNameLines($name, $flowerNum = 0, $subtitle = '')
  209. {
  210. $name = self::filterPosterUtf8Text($name);
  211. $subtitle = self::filterPosterUtf8Text($subtitle);
  212. $lines = self::splitPosterTextToLines($name);
  213. $suffix = '';
  214. if ($flowerNum > 0) {
  215. $suffix = ' · ' . (int)$flowerNum . '支';
  216. } elseif (trim((string)$subtitle) !== '') {
  217. $suffix = ' · ' . trim((string)$subtitle);
  218. }
  219. if ($suffix !== '') {
  220. if ($lines === []) {
  221. $lines = self::splitPosterTextToLines($suffix);
  222. } else {
  223. $last = count($lines) - 1;
  224. $merged = $lines[$last] . $suffix;
  225. if (mb_strlen($merged, 'UTF-8') <= self::TEXT_CHARS_PER_LINE) {
  226. $lines[$last] = $merged;
  227. } else {
  228. $lines = array_merge($lines, self::splitPosterTextToLines($suffix));
  229. }
  230. }
  231. }
  232. return $lines;
  233. }
  234. /** @deprecated 请用 buildPosterNameLines */
  235. public static function buildPosterNameText($name, $flowerNum = 0, $subtitle = '')
  236. {
  237. $lines = self::buildPosterNameLines($name, $flowerNum, $subtitle);
  238. return $lines[0] ?? '';
  239. }
  240. /**
  241. * 注意事项(图下、名称下,多行)
  242. *
  243. * @return string[]
  244. */
  245. public static function buildPosterRemarkLines($itemRemark)
  246. {
  247. $itemRemark = self::filterPosterUtf8Text($itemRemark);
  248. if ($itemRemark === '') {
  249. return [];
  250. }
  251. return self::splitPosterTextToLines($itemRemark);
  252. }
  253. /** @deprecated 请用 buildPosterRemarkLines */
  254. public static function buildPosterRemarkText($itemRemark)
  255. {
  256. $lines = self::buildPosterRemarkLines($itemRemark);
  257. return $lines[0] ?? '';
  258. }
  259. private static function textLineStep($fontSize)
  260. {
  261. return (int)ceil($fontSize * 1.2) + self::MID_LINE_GAP;
  262. }
  263. /**
  264. * 多条文字水印纵向排列(OSS 不支持 \n 换行)
  265. */
  266. private static function appendTextLineWatermarks($url, array $lines, $startY, $fontSize, $colorHex)
  267. {
  268. $step = self::textLineStep($fontSize);
  269. foreach ($lines as $i => $line) {
  270. $line = trim((string)$line);
  271. if ($line === '') {
  272. continue;
  273. }
  274. $y = (int)$startY + $i * $step;
  275. $url .= '/watermark,text_' . stringUtil::ossBase64($line)
  276. . ',g_nw,x_' . self::CANVAS_PAD_X . ',y_' . $y
  277. . ',color_' . $colorHex . ',type_' . self::FONT . ',size_' . (int)$fontSize;
  278. }
  279. return $url;
  280. }
  281. private static function textBlockHeight($lineCount, $fontSize)
  282. {
  283. if ($lineCount <= 0) {
  284. return 0;
  285. }
  286. $lineH = (int)ceil($fontSize * 1.2);
  287. return $lineCount * $lineH + max(0, $lineCount - 1) * self::MID_LINE_GAP;
  288. }
  289. private static function calcMidSectionHeight(array $nameLines, array $remarkLines)
  290. {
  291. $h = 0;
  292. $nameCount = count($nameLines);
  293. if ($nameCount > 0) {
  294. $h += self::MID_AFTER_COVER_GAP + self::textBlockHeight($nameCount, self::MID_NAME_SIZE);
  295. }
  296. $remarkCount = count($remarkLines);
  297. if ($remarkCount > 0) {
  298. $h += ($nameCount > 0 ? self::MID_BLOCK_GAP : self::MID_AFTER_COVER_GAP);
  299. $h += self::textBlockHeight($remarkCount, self::MID_REMARK_SIZE);
  300. }
  301. return $h;
  302. }
  303. private static function coverStartY()
  304. {
  305. return self::CANVAS_PAD_Y + self::SHOP_LOGO_SIZE + self::HEADER_BOTTOM_GAP;
  306. }
  307. /**
  308. * 底部左侧(价格 + 提示文案)与右侧太阳码垂直居中对齐,均左对齐
  309. *
  310. * @return array{buyHintY:int,priceY:int,qrY:int}
  311. */
  312. private static function calcFooterLayout()
  313. {
  314. $qrCenterFromBottom = self::QR_PAD_BOTTOM + (int)(self::QR_SIZE / 2);
  315. $buyHintH = (int)ceil(self::FOOTER_BUY_HINT_SIZE * 1.2);
  316. $priceH = (int)ceil(self::FOOTER_PRICE_SIZE * 1.3);
  317. $gap = self::FOOTER_TEXT_GAP;
  318. $blockH = $priceH + $gap + $buyHintH;
  319. $buyHintY = max(16, $qrCenterFromBottom - (int)($blockH / 2));
  320. $priceY = $buyHintY + $buyHintH + $gap;
  321. $qrY = max(16, $qrCenterFromBottom - (int)(self::QR_SIZE / 2));
  322. return [
  323. 'buyHintY' => $buyHintY,
  324. 'priceY' => $priceY,
  325. 'qrY' => $qrY,
  326. ];
  327. }
  328. /**
  329. * @return array{imgH:int,totalH:int,scaledH:int,posterW:int,coverY:int,nameY:int,remarkY:int}
  330. */
  331. public static function calcPosterLayout($coverWidth, $coverHeight, array $textOptions = [])
  332. {
  333. $coverWidth = (int)$coverWidth;
  334. $coverHeight = (int)$coverHeight;
  335. $scaledH = 0;
  336. if ($coverWidth > 0 && $coverHeight > 0) {
  337. $scaledH = (int)round($coverHeight * (self::SLOT_W / $coverWidth));
  338. $imgH = max(self::IMG_H_MIN, min(self::IMG_H_MAX, $scaledH));
  339. } else {
  340. $scaledH = self::IMG_H_MIN;
  341. $imgH = self::IMG_H_MIN;
  342. }
  343. $nameLines = self::buildPosterNameLines(
  344. $textOptions['name'] ?? '',
  345. (int)($textOptions['flowerNum'] ?? 0),
  346. $textOptions['subtitle'] ?? ''
  347. );
  348. $remarkLines = self::buildPosterRemarkLines($textOptions['itemRemark'] ?? '');
  349. $coverY = self::coverStartY();
  350. $midH = self::calcMidSectionHeight($nameLines, $remarkLines);
  351. $totalH = $coverY + $imgH + $midH + self::FOOTER_H;
  352. $absoluteMin = self::coverStartY() + self::IMG_H_MIN + self::FOOTER_H;
  353. $totalH = max($absoluteMin, min(self::TOTAL_H_MAX, $totalH));
  354. $nameY = $coverY + $imgH + (count($nameLines) > 0 ? self::MID_AFTER_COVER_GAP : 0);
  355. $remarkY = 0;
  356. if (count($remarkLines) > 0) {
  357. $remarkY = $nameY;
  358. if (count($nameLines) > 0) {
  359. $remarkY += self::textBlockHeight(count($nameLines), self::MID_NAME_SIZE);
  360. $remarkY += self::MID_BLOCK_GAP;
  361. } else {
  362. $remarkY = $coverY + $imgH + self::MID_AFTER_COVER_GAP;
  363. }
  364. }
  365. return [
  366. 'imgH' => $imgH,
  367. 'totalH' => $totalH,
  368. 'scaledH' => $scaledH,
  369. 'posterW' => self::POSTER_W,
  370. 'coverY' => $coverY,
  371. 'nameY' => $nameY,
  372. 'remarkY' => $remarkY,
  373. ];
  374. }
  375. private static function buildCoverWatermarkPath($cover, $scaledH)
  376. {
  377. $scaledH = (int)$scaledH;
  378. $r = self::COVER_CORNER_RADIUS;
  379. if ($scaledH > self::IMG_H_MAX) {
  380. return $cover . '?x-oss-process=image/resize,m_fill,w_' . self::SLOT_W . ',h_' . self::IMG_H_MAX
  381. . ',limit_0/rounded-corners,r_' . $r;
  382. }
  383. return $cover . '?x-oss-process=image/resize,m_lfit,w_' . self::SLOT_W
  384. . ',limit_0/rounded-corners,r_' . $r;
  385. }
  386. private static function buildShopLogoWatermarkPath($logoObject)
  387. {
  388. $logoObject = imgUtil::normalizeOssObjectPath($logoObject);
  389. return $logoObject . '?x-oss-process=image/resize,m_fill,h_' . self::SHOP_LOGO_SIZE
  390. . ',w_' . self::SHOP_LOGO_SIZE . ',limit_0';
  391. }
  392. private static function shopTitleY()
  393. {
  394. return self::CANVAS_PAD_Y + (int)((self::SHOP_LOGO_SIZE - self::SHOP_TITLE_SIZE) / 2);
  395. }
  396. public static function buildCanvasBaseUrl($prefix, $totalH)
  397. {
  398. $absoluteMin = self::coverStartY() + self::IMG_H_MIN + self::FOOTER_H;
  399. $totalH = max($absoluteMin, min(self::TOTAL_H_MAX, (int)$totalH));
  400. $process = '?x-oss-process=image/resize,m_pad,w_' . self::POSTER_W . ',h_' . $totalH
  401. . ',color_' . self::CANVAS_COLOR;
  402. return $prefix . self::BLANK_CANVAS . $process;
  403. }
  404. public static function buildHyxhLogoWatermark($mainId)
  405. {
  406. if (!in_array((int)$mainId, [52, 1459, 13495], true)) {
  407. return '';
  408. }
  409. $logo = 'poster/hyxh_ncd_logo.png?x-oss-process=image/resize,m_fill,h_72,w_72';
  410. if ($mainId == 1459) {
  411. $logo = 'poster/hyxh_gcd_logo.png?x-oss-process=image/resize,m_fill,h_72,w_72';
  412. }
  413. if ($mainId == 13495) {
  414. $logo = 'poster/hyxh_hzd_logo.png?x-oss-process=image/resize,m_fill,h_72,w_72';
  415. }
  416. return stringUtil::ossBase64($logo);
  417. }
  418. public static function buildMallGoodsPosterUrl($prefix, array $options)
  419. {
  420. return self::buildMallSharePosterUrl($prefix, $options);
  421. }
  422. public static function buildMallItemPosterUrl($prefix, array $options)
  423. {
  424. return self::buildMallSharePosterUrl($prefix, $options);
  425. }
  426. public static function buildGhsHdItemPosterUrl($prefix, array $options)
  427. {
  428. return self::buildMallSharePosterUrl($prefix, $options);
  429. }
  430. private static function buildMallSharePosterUrl($prefix, array $options)
  431. {
  432. $cover = $options['cover'] ?? '';
  433. $miniCode = $options['miniCode'] ?? '';
  434. $priceText = $options['priceText'] ?? '';
  435. $name = self::filterPosterUtf8Text($options['name'] ?? '');
  436. $mainId = (int)($options['mainId'] ?? 0);
  437. $flowerNum = (int)($options['flowerNum'] ?? 0);
  438. $subtitle = self::filterPosterUtf8Text($options['subtitle'] ?? '');
  439. $itemRemark = self::filterPosterUtf8Text($options['itemRemark'] ?? '');
  440. $shopTitle = self::filterPosterUtf8Text($options['shopTitle'] ?? '');
  441. $shopLogo = trim((string)($options['shopLogo'] ?? ''));
  442. $coverW = (int)($options['coverWidth'] ?? 0);
  443. $coverH = (int)($options['coverHeight'] ?? 0);
  444. if ($coverW <= 0 || $coverH <= 0) {
  445. list($coverW, $coverH) = imgUtil::getOssImageSize($cover, $prefix);
  446. }
  447. $layout = self::calcPosterLayout($coverW, $coverH, [
  448. 'name' => $name,
  449. 'flowerNum' => $flowerNum,
  450. 'subtitle' => $subtitle,
  451. 'itemRemark' => $itemRemark,
  452. ]);
  453. $nameLines = self::buildPosterNameLines($name, $flowerNum, $subtitle);
  454. $remarkLines = self::buildPosterRemarkLines($itemRemark);
  455. $footer = self::calcFooterLayout();
  456. $coverWatermark = self::buildCoverWatermarkPath($cover, $layout['scaledH']);
  457. $qrWatermark = $miniCode . '?x-oss-process=image/resize,m_fill,h_' . self::QR_SIZE . ',w_' . self::QR_SIZE;
  458. $url = self::buildCanvasBaseUrl($prefix, $layout['totalH']);
  459. if ($shopLogo !== '') {
  460. $url .= '/watermark,image_' . stringUtil::ossBase64(self::buildShopLogoWatermarkPath($shopLogo))
  461. . ',g_nw,x_' . self::CANVAS_PAD_X . ',y_' . self::CANVAS_PAD_Y;
  462. }
  463. if ($shopTitle !== '') {
  464. $titleX = self::CANVAS_PAD_X + self::SHOP_LOGO_SIZE + self::SHOP_LOGO_GAP;
  465. $url .= '/watermark,text_' . stringUtil::ossBase64($shopTitle)
  466. . ',g_nw,x_' . $titleX . ',y_' . self::shopTitleY()
  467. . ',color_333333,type_' . self::FONT . ',size_' . self::SHOP_TITLE_SIZE;
  468. }
  469. $url .= '/watermark,image_' . stringUtil::ossBase64($coverWatermark)
  470. . ',g_nw,x_' . self::CANVAS_PAD_X . ',y_' . $layout['coverY'];
  471. if (count($nameLines) > 0) {
  472. $url = self::appendTextLineWatermarks($url, $nameLines, $layout['nameY'], self::MID_NAME_SIZE, '333333');
  473. }
  474. if (count($remarkLines) > 0) {
  475. $url = self::appendTextLineWatermarks($url, $remarkLines, $layout['remarkY'], self::MID_REMARK_SIZE, '888888');
  476. }
  477. $url .= '/watermark,image_' . stringUtil::ossBase64($qrWatermark)
  478. . ',g_se,x_' . self::QR_PAD_RIGHT . ',y_' . $footer['qrY'];
  479. $logoB64 = self::buildHyxhLogoWatermark($mainId);
  480. if ($logoB64 !== '') {
  481. $url .= '/watermark,image_' . $logoB64 . ',g_se,x_210,y_48';
  482. }
  483. $url .= '/watermark,text_' . stringUtil::ossBase64(self::FOOTER_BUY_HINT)
  484. . ',g_sw,x_' . self::CANVAS_PAD_X . ',y_' . $footer['buyHintY']
  485. . ',color_888888,type_' . self::FONT . ',size_' . self::FOOTER_BUY_HINT_SIZE;
  486. $url .= '/watermark,text_' . stringUtil::ossBase64($priceText)
  487. . ',g_sw,x_' . self::CANVAS_PAD_X . ',y_' . $footer['priceY']
  488. . ',color_EE2C2C,type_' . self::FONT . ',size_' . self::FOOTER_PRICE_SIZE;
  489. $url .= '/rounded-corners,r_' . self::POSTER_CORNER_RADIUS;
  490. return $url;
  491. }
  492. }