|
|
@@ -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'];
|
|
|
}
|