Explorar o código

feat(lakala): 支持子商户列表配置及默认商户号获取

- 新增 sub_merchant_list 配置项用于存储多个子商户信息
- 重写 getConfig 方法以支持从子商户列表中获取默认 merchant_no 和 term_no
- 保留原有 ConfigTrait 的 getConfig 功能并进行扩展
- 更新类注释以反映新的属性结构
runphp hai 4 meses
pai
achega
e447b9f065
Modificáronse 1 ficheiros con 15 adicións e 1 borrados
  1. 15 1
      src/Config.php

+ 15 - 1
src/Config.php

@@ -17,10 +17,24 @@ use SixShop\System\Trait\ConfigTrait;
  * @property string $sub_appid 子商户公众账号ID
  * @property string $receiver_agreement_file 默认合作协议文件
  * @property string $random_discount_max 随机立减金额上限
+ * @property array{merchant_no:string,term_no:string}[] $sub_merchant_list 子商户列表
  */
 class Config
 {
-    use ConfigTrait;
+    use ConfigTrait {
+        getConfig as traitGetConfig;
+    }
+
+    public function getConfig(string $key = null, mixed $default = null): mixed
+    {
+        if ($key == 'merchant_no') {
+            return $this->getConfig('sub_merchant_list')[0]['merchant_no'];
+        }
+        if ($key == 'term_no') {
+            return $this->getConfig('sub_merchant_list')[0]['term_no'];
+        }
+        return $this->traitGetConfig($key, $default);
+    }
 
     public function getExtensionID(): string
     {