Phase1 后端核心:
- 新增 fsgx_v1.sql 迁移脚本(is_queue_goods/frozen_points/available_points/no_assess)
- SystemConfigServices 返佣设置扩展(周期人数/分档比例/范围/时机)
- StoreOrderCreateServices 周期循环佣金计算
- StoreOrderTakeServices 佣金发放后同步冻结积分
- StoreProductServices/StoreProduct 保存 is_queue_goods
Phase2 后端接口:
- GET /api/hjf/brokerage/progress 佣金周期进度
- GET /api/hjf/assets/overview 资产总览
- HjfPointsServices 每日 frozen_points 0.4‰ 释放定时任务
- PUT /adminapi/hjf/member/{uid}/no_assess 不考核接口
- GET /adminapi/hjf/points/release_log 积分日志接口
Phase3 前端清理:
- hjfCustom.js 路由精简(仅保留 points/log)
- hjfQueue.js/hjfMember.js API 清理/重定向至 CRMEB 原生接口
- pages.json 公排→推荐佣金/佣金记录/佣金规则
Phase4-5 前端改造:
- queue/status.vue 推荐佣金进度页整体重写
- 商品详情/订单确认/支付结果页文案与逻辑改造
- 个人中心/资产页/引导页/规则页文案改造
- HjfQueueProgress/HjfRefundNotice/HjfAssetCard 组件改造
- 推广中心嵌入佣金进度摘要
- hjfMockData.js 全量更新(公排字段→佣金字段)
Phase6 Admin 增强:
- 用户列表新增 frozen_points/available_points 列及不考核操作按钮
- hjfPoints.js USE_MOCK=false 对接真实积分日志接口
Phase7 配置文档:
- docs/fsgx-phase7-config-checklist.md 后台配置与全链路验收清单
Made-with: Cursor
217 lines
7.4 KiB
PHP
217 lines
7.4 KiB
PHP
<?php
|
||
// +----------------------------------------------------------------------
|
||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||
// +----------------------------------------------------------------------
|
||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||
// +----------------------------------------------------------------------
|
||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||
// +----------------------------------------------------------------------
|
||
// | Author: CRMEB Team <admin@crmeb.com>
|
||
// +----------------------------------------------------------------------
|
||
|
||
namespace app\services\store;
|
||
|
||
|
||
use app\dao\store\StoreConfigDao;
|
||
use app\services\BaseServices;
|
||
use app\services\system\config\SystemConfigServices;
|
||
use crmeb\form\Build;
|
||
use think\annotation\Inject;
|
||
use think\exception\ValidateException;
|
||
|
||
/**
|
||
* Class StoreConfigServices
|
||
* @package app\services\store
|
||
* @mixin StoreConfigDao
|
||
*/
|
||
class StoreConfigServices extends BaseServices
|
||
{
|
||
|
||
/**
|
||
* 表单数据切割符号
|
||
* @var string
|
||
*/
|
||
protected $cuttingStr = '=>';
|
||
|
||
//打印机配置
|
||
const PRINTER_KEY = [
|
||
'store_printing_timing', 'store_terminal_number', 'store_printing_client_id',
|
||
'store_printing_api_key', 'store_develop_id', 'store_pay_success_printing_switch',
|
||
'store_print_type', 'store_fey_user', 'store_fey_ukey', 'store_fey_sn',
|
||
];
|
||
//快递发货配置
|
||
const EXPRESS_KEY = [
|
||
'store_config_export_id', 'store_config_export_temp_id', 'store_config_export_to_name',
|
||
'store_config_export_to_tel', 'store_config_export_to_address', 'store_config_export_siid', 'store_config_export_open'
|
||
];
|
||
|
||
const CONFIG_TYPE = [
|
||
'store_printing_deploy' => self::PRINTER_KEY,
|
||
'store_electronic_sheet' => self::EXPRESS_KEY,
|
||
];
|
||
|
||
/**
|
||
* @var StoreConfigDao
|
||
*/
|
||
#[Inject]
|
||
protected StoreConfigDao $dao;
|
||
|
||
/**
|
||
* 保存或者更新门店配置
|
||
* @param array $data
|
||
* @param int $storeId
|
||
*/
|
||
public function saveConfig(array $data, int $storeId)
|
||
{
|
||
$config = [];
|
||
foreach ($data as $key => $value) {
|
||
if ($this->dao->count(['key_name' => $key, 'store_id' => $storeId])) {
|
||
$this->dao->update(['key_name' => $key, 'store_id' => $storeId], ['value' => json_encode($value)]);
|
||
} else {
|
||
$config[] = [
|
||
'key_name' => $key,
|
||
'store_id' => $storeId,
|
||
'value' => json_encode($value)
|
||
];
|
||
}
|
||
}
|
||
if ($config) {
|
||
$this->dao->saveAll($config);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 获取配置
|
||
* @param string $key
|
||
* @param int $type
|
||
* @param int $relation_id
|
||
* @param $default
|
||
* @return mixed|null
|
||
*/
|
||
public function getConfig(string $key, int $type = 0, int $relation_id = 0, $default = null)
|
||
{
|
||
$value = $this->dao->value(['key_name' => $key, 'type' => $type, 'relation_id' => $relation_id], 'value');
|
||
return is_null($value) ? $default : json_decode($value, true);
|
||
}
|
||
|
||
/**
|
||
* 获取门店配置
|
||
* @param int $storeId
|
||
* @param array $keys
|
||
*/
|
||
public function getConfigAll(array $keys, int $type = 0, int $relation_id = 0)
|
||
{
|
||
$confing = $this->dao->searchs($keys, $type, $relation_id)->column('value', 'key_name');
|
||
return array_map(function ($item) {
|
||
return json_decode($item, true);
|
||
}, $confing);
|
||
}
|
||
|
||
/**
|
||
* 解析配置参数生成选项列表
|
||
* @param string $parameter 参数字符串
|
||
* @return array
|
||
*/
|
||
public function getOptions(string $parameter)
|
||
{
|
||
$parameter = explode("\n", $parameter);
|
||
$options = [];
|
||
foreach ($parameter as $v) {
|
||
if (strstr($v, $this->cuttingStr) !== false) {
|
||
$pdata = explode($this->cuttingStr, $v);
|
||
$options[] = ['label' => $pdata[1], 'value' => (int)$pdata[0]];
|
||
}
|
||
}
|
||
return $options;
|
||
}
|
||
|
||
/**
|
||
* @param array $configName
|
||
* @param int $type
|
||
* @param int $relation_id
|
||
* @param int $group
|
||
* @return array
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
*/
|
||
public function getConfigAllField(array $configName = [], int $type = 0, int $relation_id = 0, int $group = 0)
|
||
{
|
||
/** @var SystemConfigServices $systemConfigServices */
|
||
$systemConfigServices = app()->make(SystemConfigServices::class);
|
||
$list = $systemConfigServices->getConfigAllListByWhere(['menu_name' => $configName], $type, $relation_id, ['menu_name', 'info', 'type', 'value', 'desc', 'parameter']);
|
||
if ($list) {
|
||
foreach ($list as &$item) {
|
||
if ($relation_id != 0) {
|
||
$item['value'] = $item['store_value'] ?? '';
|
||
}
|
||
$item['value'] = json_decode($item['value'], true);
|
||
}
|
||
$list = array_combine(array_column($list, 'menu_name'), $list);
|
||
}
|
||
|
||
$value = [];
|
||
foreach ($configName as $key) {
|
||
if ($group) {
|
||
$value[$key] = $list[$key]['value'] ?? '';
|
||
} else {
|
||
$value[$key] = $list[$key] ?? ['info' => '', 'type' => 'text', 'value' => '', 'desc' => '', 'parameter' => ''];
|
||
}
|
||
}
|
||
return $value;
|
||
}
|
||
|
||
/**
|
||
* 获取表单
|
||
* @param string $name
|
||
* @param int $type
|
||
* @param int $relation_id
|
||
* @return array
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
*/
|
||
public function getFormBuildRule(string $name, int $type = 0, int $relation_id = 0)
|
||
{
|
||
switch ($name) {
|
||
case 'third'://第三方
|
||
$data = $this->thirdPartyFormBuild($type, $relation_id);
|
||
break;
|
||
default:
|
||
throw new ValidateException('类型错误');
|
||
}
|
||
return $data;
|
||
}
|
||
|
||
/**
|
||
* 第三方配置
|
||
* @return array
|
||
*/
|
||
public function thirdPartyFormBuild(int $type = 0, int $relation_id = 0)
|
||
{
|
||
$build = new Build();
|
||
$build->url('system/config');
|
||
if ($type == 1) {
|
||
$data = $this->getConfigAllField([
|
||
'store_pay_success_printing_switch', 'store_develop_id', 'store_printing_api_key', 'store_printing_client_id', 'store_terminal_number',
|
||
'store_print_type', 'store_fey_user', 'store_fey_ukey', 'store_fey_sn',
|
||
'store_printing_timing',
|
||
'store_config_export_open', 'store_config_export_siid', 'store_config_export_to_name', 'store_config_export_to_tel', 'store_config_export_to_address',
|
||
], $type, $relation_id);
|
||
|
||
$build->rule([
|
||
Build::tabs()->option('电子面单', [
|
||
Build::radio('store_config_export_open', $data['store_config_export_open']['info'], (int)($data['store_config_export_open']['value'] ?? 0))->control(1, [
|
||
Build::input('store_config_export_to_name', $data['store_config_export_to_name']['info'], $data['store_config_export_to_name']['value'])->info($data['store_config_export_to_name']['desc']),
|
||
Build::input('store_config_export_to_tel', $data['store_config_export_to_tel']['info'], $data['store_config_export_to_tel']['value'])->info($data['store_config_export_to_tel']['desc']),
|
||
Build::input('store_config_export_to_address', $data['store_config_export_to_address']['info'], $data['store_config_export_to_address']['value'])->info($data['store_config_export_to_address']['desc']),
|
||
Build::input('store_config_export_siid', $data['store_config_export_siid']['info'], $data['store_config_export_siid']['value'])->info($data['store_config_export_siid']['desc']),
|
||
])->options($this->getOptions($data['store_config_export_open']['parameter']))->info($data['store_config_export_open']['desc'])
|
||
])
|
||
]);
|
||
}
|
||
return $build->toArray();
|
||
}
|
||
|
||
}
|