Files
huangjingfen/pro_v3.5.1_副本/crmeb/form/Build.php

263 lines
8.0 KiB
PHP
Raw Normal View History

feat(fsgx): 完成全部24项开发任务 Phase1-7 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
2026-03-23 22:32:19 +08:00
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace crmeb\form;
use crmeb\form\components\Address;
use crmeb\form\components\Alert;
use crmeb\form\components\Card;
use crmeb\form\components\CheckBox;use crmeb\form\components\DiyTable;
use crmeb\form\components\Input;
use crmeb\form\components\InputNumber;
use crmeb\form\components\Map;
use crmeb\form\components\Radio;
use crmeb\form\components\Select;
use crmeb\form\components\Switchs;
use crmeb\form\components\Tabs;
use crmeb\form\components\Time;
use crmeb\form\components\UploadFrame;
use crmeb\form\components\UploadImage;
/**
* Class Build
* @package crmeb\form
* @method Input input(string $field, string $title, $value = null)
* @method Tabs tabs(array $options = [])
* @method Card card(string $title)
* @method InputNumber inputNum(string $field, string $title, $value = null)
* @method Select select(string $field, string $title, $value = null)
* @method UploadFrame uploadFrame(string $field, string $title, $value = null)
* @method UploadImage uploadImage(string $field, string $title, $value = null)
* @method Radio radio(string $field, string $title, $value = null)
* @method CheckBox checkbox(string $field, string $title, $value = null)
* @method Switchs switch (string $field, string $title, $value = null)
* @method Alert alert (string $title, string $type = '', bool $closable = false, bool $showIcon = false)
* @method DiyTable diyTable(string $field, string $title, array $value = [], array $options = [])
* @method Map map(string $field, string $title, $value = null)
* @method Address address(string $field, string $title, $value = null)
* @method Time time(string $field, string $title, $value = null)
*/
class Build
{
/**
* 挂载组件
* @var string[]
*/
protected static array $components = [
'input' => Input::class,
'tabs' => Tabs::class,
'card' => Card::class,
'inputNum' => InputNumber::class,
'select' => Select::class,
'uploadFrame' => UploadFrame::class,
'uploadImage' => UploadImage::class,
'radio' => Radio::class,
'switch' => Switchs::class,
'alert' => Alert::class,
'diyTable' => DiyTable::class,
'address' => Address::class,
'map' => Map::class,
'time' => Time::class,
];
/**
* @var array
*/
protected array $rule = [];
/**
* 请求地址
* @var
*/
protected ?string $url;
/**
* @var string
*/
protected string $method = 'POST';
/**
* @var array
*/
protected array $data = [];
/**
* Build constructor.
* @param string|null $url
* @param array $rule
* @param string|null $method
* @param array $data
*/
public function __construct(string $url = null, array $rule = [], string $method = null, array $data = [])
{
$this->url = $url;
$this->rule = $rule;
$this->method = $method ?: 'POST';
$this->data = $data;
}
/**
* @param array $rule
* @return $this
*/
public function rule(array $rule = [])
{
$this->rule = $rule;
return $this;
}
/**
* @param string $url
* @return $this
*/
public function url(string $url)
{
$this->url = $url;
return $this;
}
/**
* @param string $method
* @return $this
*/
public function method(string $method)
{
$this->method = $method;
return $this;
}
/**
* @param array $data
* @return Build
*/
public function data(array $data)
{
$this->data = $data;
return $this;
}
/**
* 批量设置数据
* @param $rule
* @return mixed
*/
public function setValue($rule)
{
if (!$this->data) {
return $rule;
}
foreach ($rule as &$value) {
if (isset($value['value']) && $value['value'] !== '' && isset($value['field'])) {
$value['value'] = $this->data[$value['field']];
}
if (isset($value['options']) && $value['options']) {
foreach ($value['options'] as $i => $option) {
if (isset($option['componentsModel']) && $option['componentsModel']) {
$value['options'][$i] = $this->setValue($option['componentsModel']);
}
}
}
if (isset($value['control']) && $value['control']) {
foreach ($value['control'] as $ii => $control) {
if (isset($control['componentsModel']) && $control['componentsModel']) {
$value['control'][$ii] = $this->setValue($control['componentsModel']);
}
}
}
if (isset($value['componentsModel']) && $value['componentsModel']) {
$value['componentsModel'] = $this->setValue($value['componentsModel']);
}
}
return $rule;
}
/**
* 提取验证值
* @param $rule
* @return array
*/
protected function getValidate($rule)
{
$validate = [];
foreach ($rule as $value) {
if (isset($value['field']) && isset($value['validate']) && $value['validate']) {
$validate[$value['field']] = $value['validate'];
}
if (isset($value['options']) && $value['options']) {
foreach ($value['options'] as $option) {
if (isset($option['componentsModel']) && $option['componentsModel']) {
$validate = array_merge($validate, $this->getValidate($option['componentsModel']));
}
}
}
if (isset($value['control']) && $value['control']) {
foreach ($value['control'] as $control) {
if (isset($control['componentsModel']) && $control['componentsModel']) {
$validate = array_merge($validate, $this->getValidate($control['componentsModel']));
}
}
}
if (isset($value['componentsModel']) && $value['componentsModel']) {
$validate = array_merge($validate, $this->getValidate($value['componentsModel']));
}
}
return $validate;
}
/**
* @return array
*/
public function toArray()
{
$rule = [];
foreach ($this->rule as $item) {
if ($item instanceof BuildInterface) {
$rule[] = $item->toArray();
}
}
$data = [
'rules' => $this->setValue($rule),
'validate' => $this->getValidate($rule),
'url' => $this->url,
'method' => $this->method
];
$data['validate'] = $data['validate'] ?: (object)[];
$this->url = null;
$this->rule = [];
$this->method = 'POST';
return $data;
}
/**
* @return false|string
*/
public function toString()
{
return json_encode($this->toArray());
}
/**
* @param $name
* @param $arguments
* @return mixed
*/
public static function __callStatic($name, $arguments)
{
$compKeys = array_keys(self::$components);
if (in_array($name, $compKeys)) {
return new self::$components[$name](...$arguments);
}
throw new BuildException('Method does not exist');
}
}