|
|
@@ -11,7 +11,6 @@ use bizGhs\custom\classes\CustomClass;
|
|
|
use bizHd\custom\classes\HdClass;
|
|
|
use bizHd\member\classes\MemberWealClass;
|
|
|
use bizHd\order\classes\OrderClass;
|
|
|
-use bizHd\order\classes\SettleClass;
|
|
|
use bizHd\wx\classes\WxOpenClass;
|
|
|
use bizMall\wx\classes\WxMiniClass;
|
|
|
use common\components\dict;
|
|
|
@@ -53,13 +52,11 @@ class RechargeController extends BaseController
|
|
|
util::success(['rechargeAccountLink' => $link, 'orderLink' => $orderLink]);
|
|
|
}
|
|
|
|
|
|
- //获取扫码充值的小程序码 ssh 20250307
|
|
|
+ //获取扫码充值的小程序码
|
|
|
public function actionGetRechargeCode()
|
|
|
{
|
|
|
-
|
|
|
$shopId = $this->shopId;
|
|
|
- $recharge = MemberWealClass::getAllByCondition(['shopId' => $shopId], 'recharge asc', '*', null, true);
|
|
|
- //这里取前面三个放在海报里,对应表名是 xhMemberRecharge 不是 MemberWeal
|
|
|
+ $recharge = MemberWealClass::getAllByCondition(['shopId' => $shopId], 'recharge asc', '*', null); //这里取前面三个放在海报里,对应表名是 xhMemberRecharge 不是 MemberWeal
|
|
|
|
|
|
$merchant = WxOpenClass::getMallWxInfo();
|
|
|
$page = 'pages/member/recharge';
|
|
|
@@ -68,15 +65,59 @@ class RechargeController extends BaseController
|
|
|
$imgUrl = miniUtil::generateUnlimitedRechargeMiniCode($merchant, $page, $scene, $ptStyle);
|
|
|
|
|
|
$prefix = imgUtil::getPrefix();
|
|
|
- $titleBase64 = stringUtil::ossBase64('扫码充值');
|
|
|
|
|
|
- $memberUrl = $prefix . 'shop/miniCodeBg.jpg?x-oss-process=image';
|
|
|
+ $titleBase64 = stringUtil::ossBase64('扫码充值');
|
|
|
$memberMiniCodeBase64 = stringUtil::ossBase64($imgUrl);
|
|
|
+ $memberUrl = $prefix . 'shop/miniCodeBg.jpg?x-oss-process=image';
|
|
|
$memberUrl .= '/watermark,image_' . $memberMiniCodeBase64 . ',g_north,x_0,y_40';
|
|
|
$memberUrl .= '/watermark,text_' . $titleBase64 . ',g_north,x_0,y_530,size_50';
|
|
|
|
|
|
- $respond = ['imgUrl' => $memberUrl];
|
|
|
+ $posterUrl = $prefix . 'poster/recharge_poster.jpg';
|
|
|
+ // 组合充值海报:将前3条充值活动写入海报对应位置
|
|
|
+ // 海报尺寸:955x1439;以下坐标为在设计稿上测得的三行“进店充值/获得”数值区大致位置
|
|
|
+ // 位置从上到下三行,左列为“进店充值”,中列为“获得”
|
|
|
+ $posterProcess = '?x-oss-process=image';
|
|
|
+ // 将小程序码放到右下角白色区域,大小与白色区域一致(可按需微调)
|
|
|
+ $qrWidth = 230; // 白色区域宽度,像素
|
|
|
+ $qrRightPadding = 144; // 距离右边的留白
|
|
|
+ $qrBottomPadding = 72; // 距离底部的留白
|
|
|
+ // 先用 $imgUrl 生成按宽度缩放后的小程序码图片,再拼接到海报
|
|
|
+ $miniCodeResizeUrl = $imgUrl . (strpos($imgUrl, '?') === false ? '?x-oss-process=image' : '&x-oss-process=image');
|
|
|
+ $miniCodeResizeUrl .= '/resize,w_' . $qrWidth;
|
|
|
+ $miniCodeResizeBase64 = stringUtil::ossBase64($miniCodeResizeUrl);
|
|
|
+ $posterProcess .= '/watermark,image_' . $miniCodeResizeBase64 . ',g_se,x_' . $qrRightPadding . ',y_' . $qrBottomPadding;
|
|
|
+ $positions = [
|
|
|
+ ['recharge' => ['x' => 240, 'y' => 665], 'give' => ['x' => 520, 'y' => 665]],
|
|
|
+ ['recharge' => ['x' => 220, 'y' => 845], 'give' => ['x' => 500, 'y' => 845]],
|
|
|
+ ['recharge' => ['x' => 220, 'y' => 1030], 'give' => ['x' => 500, 'y' => 1030]],
|
|
|
+ ];
|
|
|
+ $fontSize = 44; // 数值字号
|
|
|
+ $fontColor = '333333';
|
|
|
+ if (!empty($recharge)) {
|
|
|
+ // 先生成同一张图片上的文字水印串,最后再与$posterProcess合并
|
|
|
+ $textProcess = '';
|
|
|
+ $topThree = array_slice($recharge, 0, 3);
|
|
|
+ foreach ($topThree as $index => $val) {
|
|
|
+ $pos = $positions[$index] ?? null;
|
|
|
+ if ($pos === null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $rechargeText = (string)(intval($val['recharge']) ?? '');
|
|
|
+ $giveText = (string)(intval($val['give']) ?? '');
|
|
|
+ if ($rechargeText !== '') {
|
|
|
+ $rechargeBase64 = stringUtil::ossBase64($rechargeText);
|
|
|
+ $textProcess .= '/watermark,text_' . $rechargeBase64 . ',g_nw,x_' . $pos['recharge']['x'] . ',y_' . $pos['recharge']['y'] . ',size_' . $fontSize . ',color_' . $fontColor;
|
|
|
+ }
|
|
|
+ if ($giveText !== '') {
|
|
|
+ $giveBase64 = stringUtil::ossBase64($giveText);
|
|
|
+ $textProcess .= '/watermark,text_' . $giveBase64 . ',g_nw,x_' . $pos['give']['x'] . ',y_' . $pos['give']['y'] . ',size_' . $fontSize . ',color_' . $fontColor;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $posterProcess .= $textProcess;
|
|
|
+ }
|
|
|
+ $posterUrl .= $posterProcess;
|
|
|
|
|
|
+ $respond = ['imgUrl' => $memberUrl, 'posterUrl' => $posterUrl];
|
|
|
util::success($respond);
|
|
|
}
|
|
|
|