Browse Source

会员等级和充值设置

shish 9 tháng trước cách đây
mục cha
commit
545cbac124

+ 3 - 0
app-hd/controllers/OrderController.php

@@ -538,6 +538,9 @@ class OrderController extends BaseController
         $post['shopId'] = $this->shopId;
         $post['mainId'] = $this->mainId ?? 0;
         $shop = $this->shop;
+        if ($shop->memberLevelSet == 0) {
+            util::fail('请先设置会员等级');
+        }
         $now = time();
         $orderValidTime = 600;
         $expireTime = $now + $orderValidTime;

+ 20 - 15
app-hd/controllers/RechargeController.php

@@ -77,24 +77,24 @@ class RechargeController extends BaseController
         // 海报尺寸: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;
+        // 将小程序码放到右下角白色区域,大小与白色区域一致(可按需微调)
+        $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' => 220, 'y' => 655], 'give' => ['x' => 500, 'y' => 655]],
             ['recharge' => ['x' => 220, 'y' => 840], 'give' => ['x' => 500, 'y' => 840]],
             ['recharge' => ['x' => 220, 'y' => 1020], 'give' => ['x' => 500, 'y' => 1020]],
         ];
         $fontSize = 50; // 数值字号
-		if (!empty($recharge)) {
-			// 先生成同一张图片上的文字水印串,最后再与$posterProcess合并
-			$textProcess = '';
+        if (!empty($recharge)) {
+            // 先生成同一张图片上的文字水印串,最后再与$posterProcess合并
+            $textProcess = '';
             $topThree = array_slice($recharge, 0, 3);
             foreach ($topThree as $index => $val) {
                 $pos = $positions[$index] ?? null;
@@ -105,14 +105,14 @@ class RechargeController extends BaseController
                 $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_333333,type_' . stringUtil::ossBase64('fangzhengheiti');
+                    $textProcess .= '/watermark,text_' . $rechargeBase64 . ',g_nw,x_' . $pos['recharge']['x'] . ',y_' . $pos['recharge']['y'] . ',size_' . $fontSize . ',color_333333,type_' . stringUtil::ossBase64('fangzhengheiti');
                 }
                 if ($giveText !== '') {
                     $giveBase64 = stringUtil::ossBase64($giveText);
-					$textProcess .= '/watermark,text_' . $giveBase64 . ',g_nw,x_' . $pos['give']['x'] . ',y_' . $pos['give']['y'] . ',size_' . $fontSize . ',color_8B0000,type_' . stringUtil::ossBase64('fangzhengheiti');
+                    $textProcess .= '/watermark,text_' . $giveBase64 . ',g_nw,x_' . $pos['give']['x'] . ',y_' . $pos['give']['y'] . ',size_' . $fontSize . ',color_8B0000,type_' . stringUtil::ossBase64('fangzhengheiti');
                 }
             }
-			$posterProcess .= $textProcess;
+            $posterProcess .= $textProcess;
         }
         $posterUrl .= $posterProcess;
 
@@ -132,6 +132,11 @@ class RechargeController extends BaseController
         $staffId = $shopAdmin->id;
         $staffName = $shopAdmin->name;
 
+        $shop = $this->shop;
+        if ($shop->rechargeWeal == 0) {
+            util::fail('请先设置充值规则');
+        }
+
         $connection = Yii::$app->db;
         $transaction = $connection->beginTransaction();
         try {