فهرست منبع

Merge branch 'redesign‌-260706' into dev

ouyang 14 ساعت پیش
والد
کامیت
a838fac4d4
3فایلهای تغییر یافته به همراه159 افزوده شده و 0 حذف شده
  1. 135 0
      app-ghs/controllers/MainInviteController.php
  2. 4 0
      biz-hd/shop/classes/MainInviteFlowClass.php
  3. 20 0
      sql/20260706_redesign.sql

+ 135 - 0
app-ghs/controllers/MainInviteController.php

@@ -0,0 +1,135 @@
+<?php
+/**
+ * ghsApp 门店邀请 / 我的分佣(邀请花店开店)
+ * 数据与 hd 共用 xhMainInvite、xhMainInviteFlow 等表
+ */
+namespace ghs\controllers;
+
+use bizHd\shop\classes\MainInviteClass;
+use bizHd\shop\classes\MainInviteCommissionClass;
+use bizHd\shop\classes\MainInviteFlowClass;
+use bizHd\wx\classes\WxOpenClass;
+use common\components\dict;
+use common\components\imgUtil;
+use common\components\miniUtil;
+use common\components\util;
+use Yii;
+
+class MainInviteController extends BaseController
+{
+
+    public $guestAccess = [];
+
+    /**
+     * 我的分佣首页
+     */
+    public function actionIndex()
+    {
+        $mainId = (int) $this->mainId;
+        $invite = MainInviteClass::getByMainId($mainId);
+        $inviteData = [
+            'inviteCode' => '',
+            'inviteCodeMask' => '',
+            'totalCommission' => '0.00',
+            'ableCommission' => '0.00',
+            'commissionAmount' => '0.00',
+            'hdDiscountAmount' => '0.00',
+            'inviteCount' => 0,
+        ];
+        if (!empty($invite)) {
+            $code = $invite['inviteCode'] ?? '';
+            $inviteData = [
+                'inviteCode' => $code,
+                'inviteCodeMask' => MainInviteCommissionClass::maskInviteCode($code),
+                'totalCommission' => round((float) ($invite['totalCommission'] ?? 0), 2),
+                'ableCommission' => round((float) ($invite['ableCommission'] ?? 0), 2),
+                'commissionAmount' => round((float) ($invite['commissionAmount'] ?? 0), 2),
+                'hdDiscountAmount' => round((float) ($invite['hdDiscountAmount'] ?? 0), 2),
+                'inviteCount' => (int) ($invite['inviteCount'] ?? 0),
+            ];
+        }
+
+        $recentRaw = MainInviteCommissionClass::getRecentList($mainId, 5);
+        $recentList = [];
+        foreach ($recentRaw as $row) {
+            $recentList[] = MainInviteCommissionClass::formatRecentRow($row);
+        }
+
+        util::success([
+            'invite' => $inviteData,
+            'recentList' => $recentList,
+        ]);
+    }
+
+    /**
+     * 邀约花店列表
+     */
+    public function actionInviteShopList()
+    {
+        $get = Yii::$app->request->get();
+        $keyword = trim($get['keyword'] ?? '');
+        $data = MainInviteCommissionClass::getInviteShopList($this->mainId, $keyword);
+        util::success($data);
+    }
+
+    /**
+     * 佣金变动明细分页
+     */
+    public function actionCommissionList()
+    {
+        $list = MainInviteFlowClass::getFlowList($this->mainId);
+        util::success($list);
+    }
+
+    /**
+     * 可提现佣金全额存入中央钱包余额
+     */
+    public function actionDepositBalance()
+    {
+        $mainId = (int) $this->mainId;
+        $shopId = (int) $this->shopId;
+        $shopName = trim((string) ($this->shop->name ?? ''));
+        try {
+            $result = MainInviteClass::depositAbleCommissionToWallet($mainId, $shopId, $shopName);
+            $invite = MainInviteClass::getByMainId($mainId);
+            $inviteData = [
+                'totalCommission' => round((float) ($invite['totalCommission'] ?? 0), 2),
+                'ableCommission' => round((float) ($invite['ableCommission'] ?? 0), 2),
+            ];
+            util::success(array_merge($result, ['invite' => $inviteData]));
+        } catch (\Exception $e) {
+            util::fail($e->getMessage());
+        }
+    }
+
+    /**
+     * 生成 hdApp 邀请开店小程序码(落地 applyInvite,scene 带 inviteCode)
+     * GET:可选 envVersion=develop|trial|release
+     */
+    public function actionInviteHdMiniCode()
+    {
+        $invite = MainInviteClass::getByMainId((int) $this->mainId);
+        $inviteCode = trim((string) ($invite['inviteCode'] ?? ''));
+        if ($inviteCode === '') {
+            util::fail('暂无邀请码');
+        }
+
+        $get = Yii::$app->request->get();
+        $envVersion = trim((string) ($get['envVersion'] ?? ''));
+        if ($envVersion === '') {
+            $envVersion = getenv('YII_ENV') === 'production' ? 'release' : 'develop';
+        }
+
+        $merchant = WxOpenClass::getWxInfo();
+        $page = 'pagesClient/official/applyInvite';
+        $ptStyle = dict::getDict('ptStyle', 'hd');
+        $scene = 'inviteCode=' . $inviteCode;
+        $imgPath = miniUtil::generateUnlimitedMiniCode($merchant, $page, $scene, $ptStyle, $envVersion);
+
+        util::success([
+            'imgUrl' => imgUtil::groupImg($imgPath),
+            'inviteCode' => $inviteCode,
+        ]);
+    }
+
+}

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

@@ -85,6 +85,10 @@ class MainInviteFlowClass extends BaseClass
             $orderSnLabel = '存入编号';
             $orderSnLabel = '存入编号';
             $baseAmountLabel = '存余额金额';
             $baseAmountLabel = '存余额金额';
             $recordType = 'deposit';
             $recordType = 'deposit';
+            $shopName = '存入钱包余额';
+            $mobile = '';
+            $mobileMask = '-';
+            $shop = [];
         } else {
         } else {
             $orderSnLabel = '会员订单号';
             $orderSnLabel = '会员订单号';
             $baseAmountLabel = '会员实付金额';
             $baseAmountLabel = '会员实付金额';

+ 20 - 0
sql/20260706_redesign.sql

@@ -383,6 +383,26 @@ CREATE TABLE IF NOT EXISTS `xhMainInviteCommission` (
     KEY `idx_relateOrderId` (`relateOrderId`) USING BTREE
     KEY `idx_relateOrderId` (`relateOrderId`) USING BTREE
     ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='门店邀请记录';
     ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='门店邀请记录';
 
 
+CREATE TABLE IF NOT EXISTS `xhMainInviteFlow` (
+    `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+    `mainId` int(11) NOT NULL DEFAULT 0 COMMENT '邀请人 xhMain.id',
+    `flowType` tinyint(3) unsigned NOT NULL DEFAULT 1 COMMENT '1邀请获佣 2存入余额 3退款扣回',
+    `amount` decimal(15,2) NOT NULL DEFAULT 0.00 COMMENT '变动金额:获佣为正,存入/扣回为负',
+    `ableAfter` decimal(15,2) NOT NULL DEFAULT 0.00 COMMENT '变动后可提现佣金',
+    `refType` tinyint(3) unsigned NOT NULL DEFAULT 0 COMMENT '1=xhMainInviteCommission 2=xhMainWalletChange',
+    `refId` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '关联业务 id',
+    `refSn` varchar(32) NOT NULL DEFAULT '' COMMENT '分佣单号 FY… / 存入编号 CR…',
+    `inviteeShopName` varchar(80) NOT NULL DEFAULT '' COMMENT '受邀花店名快照 flowType=1',
+    `inviteeMobile` varchar(20) NOT NULL DEFAULT '' COMMENT '受邀手机号快照',
+    `lsShopId` int(11) NOT NULL DEFAULT 0 COMMENT '零售店 shopId',
+    `baseAmount` decimal(15,2) NOT NULL DEFAULT 0.00 COMMENT '会员实付或存余额金额',
+    `flowTime` datetime NOT NULL COMMENT '业务时间',
+    `remark` varchar(255) NOT NULL DEFAULT '' COMMENT '备注',
+    `addTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+    PRIMARY KEY (`id`),
+    KEY `idx_main_flowTime` (`mainId`, `flowTime`),
+    KEY `idx_ref` (`refType`, `refId`)
+    ) COMMENT='邀请佣金变动流水';
 -- 花店注册付费开通:xhApply 扩展字段
 -- 花店注册付费开通:xhApply 扩展字段
 ALTER TABLE `xhApply`
 ALTER TABLE `xhApply`
   ADD COLUMN `inviteCode` varchar(32) NOT NULL DEFAULT '' COMMENT '注册时填写的邀请码' AFTER `status`,
   ADD COLUMN `inviteCode` varchar(32) NOT NULL DEFAULT '' COMMENT '注册时填写的邀请码' AFTER `status`,