PosterUtil.php 20 KB

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