Răsfoiți Sursa

Merge branch 'redesign‌-260706' of http://git.huaml.com/zhh/huahuibao into redesign‌-260706

shish 1 zi în urmă
părinte
comite
64e96f0d05

+ 138 - 1
app-mall/controllers/ShopController.php

@@ -8,6 +8,7 @@ use bizHd\custom\classes\CustomClass;
 use bizHd\custom\classes\HdClass;
 use bizMall\invite\services\InviteService;
 use bizMall\user\services\UserService;
+use common\components\dict;
 use common\components\imgUtil;
 use Yii;
 use common\components\util;
@@ -15,7 +16,143 @@ use common\components\util;
 class ShopController extends BaseController
 {
 
-    public $guestAccess = ['info'];
+    public $guestAccess = ['info', 'search', 'recommend'];
+
+    /**
+     * 未登录首页「推荐花店」:内容后端写死,按 YII_ENV 区分测试/正式
+     * 返回 shopId、名称、地址、营业时间、封面完整 URL;进店用 account=shopId
+     */
+    public function actionRecommend()
+    {
+        $isProd = getenv('YII_ENV') === 'production';
+        // 测试 / 正式各写死 3 家;shopId 请换成真实 xhShop.id(ptStyle=1)
+        $rows = $isProd
+            ? [
+                [
+                    'shopId' => 4458,
+                    'name' => '花语鲜花店',
+                    'address' => '北京市朝阳区望京街道广顺北大街33号',
+                    'businessHours' => '09:00-22:00',
+                    'cover' => 'hhb/images/guest/shop1.jpg',
+                ],
+                [
+                    'shopId' => 4458,
+                    'name' => '初见花艺',
+                    'address' => '北京市朝阳区望京SOHO塔1-B座底商',
+                    'businessHours' => '09:00-22:00',
+                    'cover' => 'hhb/images/guest/shop2.jpg',
+                ],
+                [
+                    'shopId' => 4458,
+                    'name' => '拾光花坊',
+                    'address' => '北京市朝阳区利泽西街6号院底商',
+                    'businessHours' => '09:00-22:00',
+                    'cover' => 'hhb/images/guest/shop3.jpg',
+                ],
+            ]
+            : [
+                [
+                    'shopId' => 36524,
+                    'name' => '花语鲜花店',
+                    'address' => '北京市朝阳区望京街道广顺北大街33号',
+                    'businessHours' => '09:00-22:00',
+                    'cover' => 'hhb/images/guest/shop1.jpg',
+                ],
+                [
+                    'shopId' => 36524,
+                    'name' => '初见花艺',
+                    'address' => '北京市朝阳区望京SOHO塔1-B座底商',
+                    'businessHours' => '09:00-22:00',
+                    'cover' => 'hhb/images/guest/shop2.jpg',
+                ],
+                [
+                    'shopId' => 36524,
+                    'name' => '拾光花坊',
+                    'address' => '北京市朝阳区利泽西街6号院底商',
+                    'businessHours' => '09:00-22:00',
+                    'cover' => 'hhb/images/guest/shop3.jpg',
+                ],
+            ];
+
+        $list = [];
+        foreach ($rows as $row) {
+            $shopId = (int)($row['shopId'] ?? 0);
+            $list[] = [
+                'shopId' => $shopId,
+                'account' => $shopId,
+                'id' => $shopId,
+                'name' => (string)($row['name'] ?? ''),
+                'address' => (string)($row['address'] ?? ''),
+                'businessHours' => (string)($row['businessHours'] ?? ''),
+                'cover' => imgUtil::groupImg($row['cover'] ?? ''),
+                'avatar' => imgUtil::groupImg($row['cover'] ?? ''),
+            ];
+        }
+
+        util::success([
+            'banner' => imgUtil::groupImg('hhb/images/guest/banner.jpg'),
+            'list' => $list,
+        ]);
+    }
+
+    /**
+     * 未登录首页按花店名称搜索(xhShop.ptStyle=1 零售花店)
+     * 仅匹配 shopName / merchantName,不按城市搜
+     */
+    public function actionSearch()
+    {
+        $keyword = trim((string)Yii::$app->request->get('keyword', ''));
+        if ($keyword === '') {
+            util::success(['list' => []]);
+        }
+        // 限制长度,避免超长 like 拖垮查询
+        if (mb_strlen($keyword) > 30) {
+            $keyword = mb_substr($keyword, 0, 30);
+        }
+
+        $ptStyle = (int)dict::getDict('ptStyle', 'hd'); // 1=零售花店
+        $rows = \biz\shop\models\Shop::find()
+            ->select(['id', 'shopName', 'merchantName', 'city', 'address', 'floor', 'avatar', 'openStartTime', 'openEndTime', 'open'])
+            ->where(['ptStyle' => $ptStyle])
+            ->andWhere([
+                'or',
+                ['like', 'shopName', $keyword],
+                ['like', 'merchantName', $keyword],
+            ])
+            ->orderBy(['id' => SORT_DESC])
+            ->limit(30)
+            ->asArray()
+            ->all();
+
+        $list = [];
+        foreach ($rows as $row) {
+            $shopName = trim((string)($row['shopName'] ?? ''));
+            $merchantName = trim((string)($row['merchantName'] ?? ''));
+            // 展示名:首店只显示商家名,否则「商家名 店名」
+            $name = ($shopName === '' || $shopName === '首店')
+                ? ($merchantName !== '' ? $merchantName : $shopName)
+                : ($merchantName !== '' ? ($merchantName . ' ' . $shopName) : $shopName);
+            $avatarShort = $row['avatar'] ?? '';
+            $start = trim((string)($row['openStartTime'] ?? ''));
+            $end = trim((string)($row['openEndTime'] ?? ''));
+            $hours = '';
+            if ($start !== '' && $end !== '') {
+                $hours = $start . '-' . $end;
+            }
+            $list[] = [
+                'id' => (int)$row['id'],
+                'account' => (int)$row['id'],
+                'name' => $name,
+                'address' => trim(($row['city'] ?? '') . ($row['address'] ?? '') . ($row['floor'] ?? '')),
+                'avatar' => empty($avatarShort)
+                    ? ''
+                    : imgUtil::groupImg($avatarShort) . '?x-oss-process=image/resize,m_fill,h_200,w_200',
+                'businessHours' => $hours,
+                'open' => isset($row['open']) ? (int)$row['open'] : 1,
+            ];
+        }
+        util::success(['list' => $list]);
+    }
 
     //门店详情 ssh 20230210
     public function actionInfo()

+ 24 - 5
biz-hd/order/classes/PsMethodClass.php

@@ -52,7 +52,7 @@ class PsMethodClass extends BaseClass
     }
 
     /**
-     * 获取指定配送方式的配置(不存在则按字典默认初始化)
+     * 获取指定配送方式的配置(不存在则按字典 psMethod 默认初始化)
      * @param int $shopId 门店ID
      * @param int $mainId 商户ID
      * @param int $style 配送类型 0-4
@@ -60,10 +60,10 @@ class PsMethodClass extends BaseClass
      */
     public static function getConfig($shopId, $mainId, $style)
     {
-        // 复杂分支/关键逻辑:按 mainId + style 查 xhPsMethod,无记录则写入默认配置
+        // 无记录时按 dict.psMethod 写入:新店默认仅跑腿(自定义)+自取启用
         $config = self::getByCondition(['mainId' => $mainId, 'style' => $style]);
         if (empty($config)) {
-            $defaultConfig = dict::getDict('shMethod', $style);
+            $defaultConfig = dict::getDict('psMethod', $style);
 
             $initData = array_merge([
                 'shopId' => $shopId,
@@ -94,6 +94,23 @@ class PsMethodClass extends BaseClass
         return $config;
     }
 
+    /**
+     * 新店开店时初始化五种 xhPsMethod(按 dict.psMethod,仅缺的 style 才插入)
+     * 谁用:ShopClass::addShop;保证注册当下落库,不必等首次打开配送设置
+     * @param int $shopId
+     * @param int $mainId
+     * @return void
+     */
+    public static function initDefaultMethods($shopId, $mainId)
+    {
+        $shopId = (int)$shopId;
+        $mainId = (int)$mainId;
+        if ($shopId <= 0 || $mainId <= 0) {
+            return;
+        }
+        self::getAllConfigs($shopId, $mainId);
+    }
+
     /**
      * 客户 homeRule=1 时,用 xhCustom/xhHd 上的送货上门字段覆盖 style=0 配置
      * @param array $config xhPsMethod 送货配置
@@ -118,6 +135,7 @@ class PsMethodClass extends BaseClass
 
     /**
      * 一次性获取商户全部配送方式配置(含 xhPsExplain / xhPsReduceRule)
+     * 缺哪种 style 就按 dict.psMethod 补齐写入 xhPsMethod
      * @param int $shopId 门店ID
      * @param int $mainId 商户ID
      * @return array
@@ -126,9 +144,10 @@ class PsMethodClass extends BaseClass
     {
         $configsMap = self::getAllByCondition(['mainId' => $mainId], 'sort asc', '*', 'style', true);
 
+        // 补齐缺失 style:新店默认仅跑腿+自取启用,见 dict.psMethod
         for ($style = 0; $style <= 4; $style++) {
             if (!isset($configsMap[$style])) {
-                $defaultConfig = dict::getDict('shMethod', $style);
+                $defaultConfig = dict::getDict('psMethod', $style);
                 $initData = array_merge([
                     'shopId' => $shopId,
                     'mainId' => $mainId,
@@ -435,7 +454,7 @@ class PsMethodClass extends BaseClass
                 $saveData['shopId'] = $shopId;
                 $saveData['mainId'] = $mainId;
                 $saveData['style'] = $style;
-                $defaultConfig = dict::getDict('shMethod', $style);
+                $defaultConfig = dict::getDict('psMethod', $style);
                 if (!empty($defaultConfig['originName'])) {
                     $saveData['originName'] = $defaultConfig['originName'];
                 }

+ 4 - 0
biz-hd/shop/classes/ShopClass.php

@@ -8,6 +8,7 @@ use bizHd\admin\classes\AdminClass;
 use bizHd\goods\classes\CategoryClass;
 use bizHd\goods\classes\GoodsSettingClass;
 use bizHd\merchant\classes\SjClass;
+use bizHd\order\classes\PsMethodClass;
 use bizHd\saas\classes\ApplyClass;
 use common\components\dict;
 use common\components\imgUtil;
@@ -213,6 +214,9 @@ class ShopClass extends BaseClass
         $setData = ['mainId' => $mainId, 'riseType' => 0, 'riseAmount' => 0];
         GoodsSettingClass::add($setData);
 
+        // 配送方式默认:跑腿(自定义计费)位置1 + 自取位置2,其余禁用
+        PsMethodClass::initDefaultMethods($newShopId, $mainId);
+
         //初始化员工和角色
         $adminId = $data['adminId'] ?? 0;
         $mobile = $data['mobile'] ?? 0;

+ 100 - 0
common/components/dict.php

@@ -97,6 +97,106 @@ class dict
                 'changeRate' => 0.00
             ],
         ],
+        // 花店配送方式默认配置(xhPsMethod):与 ghs shMethod 独立,新店注册/首次拉配置时写入
+        // 默认仅启用跑腿(用自定义计费)+自取;送货/物流/快递禁用
+        'psMethod' => [
+            0 => [
+                'name' => '送货',
+                'originName' => '送货',
+                'calcType' => 0,
+                'status' => 0,
+                'sort' => 3,
+                'minAmount' => 0.00,
+                'minNum' => 0,
+                'unMeet' => 0,
+                'unMeetFee' => 0.00,
+                'unMeetLockType' => 0,
+                'unMeetLockSeconds' => 1800,
+                'startKm' => 0.00,
+                'startPrice' => 0.00,
+                'perKmPrice' => 0.00,
+                'changeRate' => 0.00,
+                'hsFreeKm' => 0.00,
+                'hsPerKmPrice' => 0.00,
+            ],
+            1 => [
+                'name' => '自取',
+                'originName' => '自取',
+                'calcType' => 0,
+                'status' => 1,
+                'sort' => 2,
+                'minAmount' => 0.00,
+                'minNum' => 0,
+                'unMeet' => 0,
+                'unMeetFee' => 0.00,
+                'unMeetLockType' => 0,
+                'unMeetLockSeconds' => 1800,
+                'startKm' => 0.00,
+                'startPrice' => 0.00,
+                'perKmPrice' => 0.00,
+                'changeRate' => 0.00,
+                'hsFreeKm' => 0.00,
+                'hsPerKmPrice' => 0.00,
+            ],
+            2 => [
+                'name' => '跑腿',
+                'originName' => '跑腿',
+                // 新店默认用自定义计费,避免未绑定跑腿商户无法下单
+                'calcType' => 1,
+                'status' => 1,
+                'sort' => 1,
+                'minAmount' => 0.00,
+                'minNum' => 0,
+                'unMeet' => 0,
+                'unMeetFee' => 0.00,
+                'unMeetLockType' => 0,
+                'unMeetLockSeconds' => 1800,
+                'startKm' => 5.00,
+                'startPrice' => 15.00,
+                'perKmPrice' => 3.00,
+                'changeRate' => 0.00,
+                'hsFreeKm' => 0.00,
+                'hsPerKmPrice' => 0.00,
+            ],
+            3 => [
+                'name' => '物流',
+                'originName' => '物流',
+                'calcType' => 0,
+                'status' => 0,
+                'sort' => 5,
+                'minAmount' => 0.00,
+                'minNum' => 0,
+                'unMeet' => 0,
+                'unMeetFee' => 0.00,
+                'unMeetLockType' => 0,
+                'unMeetLockSeconds' => 1800,
+                'startKm' => 0.00,
+                'startPrice' => 0.00,
+                'perKmPrice' => 0.00,
+                'changeRate' => 0.00,
+                'hsFreeKm' => 0.00,
+                'hsPerKmPrice' => 0.00,
+            ],
+            4 => [
+                'name' => '快递',
+                'originName' => '快递',
+                'calcType' => 0,
+                'status' => 0,
+                'sort' => 4,
+                'minAmount' => 0.00,
+                'minNum' => 0,
+                'unMeet' => 0,
+                'unMeetFee' => 0.00,
+                'unMeetLockType' => 0,
+                'unMeetLockSeconds' => 1800,
+                'startKm' => 0.00,
+                'startPrice' => 0.00,
+                'perKmPrice' => 0.00,
+                'changeRate' => 0.00,
+                'hsFreeKm' => 0.00,
+                'hsPerKmPrice' => 0.00,
+            ],
+        ],
         //APP通知打开关闭状态 1打开 0关闭
         'appNotice' => 1,
         //微信通知打开关闭状态 1打开 0关闭

+ 3 - 6
sql/20260706_redesign.sql

@@ -354,9 +354,9 @@ CREATE TABLE IF NOT EXISTS `xhMainInviteCommission` (
     `commissionSn` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '分佣单号(如 FY202607210001)',
     `inviterMainId` int(11) NOT NULL DEFAULT '0' COMMENT '获佣人中央 id(批发商 xhMain.id)',
     `pfShopId` int(11) NOT NULL DEFAULT '0' COMMENT '批发店shopId',
-    `pfShopName` varchar(100) NOT NULL DEFAULT '0' COMMENT '批发店名称',
+    `pfShopName` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0' COMMENT '批发店名称',
     `lsShopId` int(11) NOT NULL DEFAULT '0' COMMENT '零售店shopId',
-    `lsShopName` varchar(100) NOT NULL DEFAULT '0' COMMENT '批发店名称',
+    `lsShopName` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0' COMMENT '批发店名称',
     `inviterShopName` varchar(80) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '获佣人门店名(快照)',
     `inviteeMainId` int(11) NOT NULL DEFAULT '0' COMMENT '受邀花店中央 id(xhMain.id)',
     `inviteeShopName` varchar(80) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '受邀花店名(快照)',
@@ -379,10 +379,7 @@ CREATE TABLE IF NOT EXISTS `xhMainInviteCommission` (
     `updateTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
     PRIMARY KEY (`id`) USING BTREE,
     UNIQUE KEY `uk_commissionSn` (`commissionSn`) USING BTREE,
-    KEY `idx_inviter_settle_occur` (`inviterMainId`, `settleStatus`) USING BTREE,
-    KEY `idx_invitee_occur` (`inviteeShopId`) USING BTREE,
-    KEY `idx_inviteCode` (`inviteCode`) USING BTREE,
-    KEY `idx_relateOrderId` (`relateOrderId`) USING BTREE
+    KEY `idx_inviter_settle_occur` (`inviterMainId`,`settleStatus`) USING BTREE
     ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='门店邀请记录';
 
 CREATE TABLE IF NOT EXISTS `xhMainInviteFlow` (