Files
huangjingfen/pro_v3.5.1_副本/app/model/activity/promotions/StorePromotions.php
apple 434aa8c69d 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

410 lines
9.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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\model\activity\promotions;
use app\model\activity\coupon\StoreCouponIssue;
use app\model\product\product\StoreProduct;
use crmeb\basic\BaseModel;
use crmeb\traits\ModelTrait;
use think\Model;
/**
* 促销活动活动
* Class StorePromotions
* @package app\model\activity\promotions
*/
class StorePromotions extends BaseModel
{
use ModelTrait;
/**
* 数据表主键
* @var string
*/
protected $pk = 'id';
/**
* 模型名称
* @var string
*/
protected $name = 'store_promotions';
protected $updateTime = false;
/**
* 优惠叠加
* @param $value
* @return string
*/
protected function setDiscountUseAttr($value)
{
if ($value) {
return is_array($value) ? implode(',', $value) : $value;
}
return '';
}
/**
* 优惠叠加
* @param $value
* @return array|false|string[]
*/
protected function getDiscountUseAttr($value)
{
if ($value) {
return is_string($value) ? explode(',', $value) : $value;
}
return [];
}
/**
* 标签
* @param $value
* @return array|mixed
*/
protected function getLabelIdAttr($value)
{
if ($value) {
return is_string($value) ? explode(',', $value) : $value;
}
return [];
}
/**
* 关联商品
* @param $value
* @return array|mixed
*/
protected function getProductIdAttr($value)
{
if ($value) {
return is_string($value) ? explode(',', $value) : $value;
}
return [];
}
/**
* 叠加使用
* @param $value
* @return array|mixed
*/
protected function getOverlayAttr($value)
{
if ($value) {
return is_string($value) ? explode(',', $value) : $value;
}
return [];
}
/**
* 赠送优惠券
* @param $value
* @return array|mixed
*/
protected function getIGiveCouponIdAttr($value)
{
if ($value) {
return is_string($value) ? explode(',', $value) : $value;
}
return [];
}
/**
* 赠送商品
* @param $value
* @return array|mixed
*/
protected function getIGiveProductIdAttr($value)
{
if ($value) {
return is_string($value) ? explode(',', $value) : $value;
}
return [];
}
/**
* 赠送商品
* @param $value
* @return array|mixed
*/
protected function getIGiveProductUniqueAttr($value)
{
if ($value) {
return is_string($value) ? explode(',', $value) : $value;
}
return [];
}
/**
* 添加时间获取器
* @param $value
* @return false|string
*/
protected function getAddTimeAttr($value)
{
if ($value) return date('Y-m-d H:i:s', (int)$value);
return '';
}
/**
* 关联商品
* @return \think\model\relation\HasMany
*/
public function products()
{
return $this->hasMany(StorePromotionsAuxiliary::class, 'promotions_id', 'id')->where('type',1)->where('product_partake_type', 2);
}
/**
* 关联优惠券
* @return \think\model\relation\HasOne
*/
public function giveCoupon()
{
return $this->hasMany(StorePromotionsAuxiliary::class, 'promotions_id', 'id')->where('type',2);
}
/**
* 赠送商品
* @return \think\model\relation\HasOne
*/
public function giveProducts()
{
return $this->hasMany(StorePromotionsAuxiliary::class, 'promotions_id', 'id')->where('type',3);
}
/**
* 阶梯优惠
* @return \think\model\relation\HasMany
*/
public function promotions()
{
return $this->hasMany(self::class, 'pid', 'id')->order('id asc');
}
/**
* 关联品牌
* @return \think\model\relation\HasMany
*/
public function brands()
{
return $this->hasMany(StorePromotionsAuxiliary::class, 'promotions_id', 'id')->where('type',1)->where('product_partake_type', 4);
}
/**
* 关联商品标签
* @return \think\model\relation\HasMany
*/
public function productLabels()
{
return $this->hasMany(StorePromotionsAuxiliary::class, 'promotions_id', 'id')->where('type',1)->where('product_partake_type', 5);
}
/**
* ID搜索器
* @param Model $query
* @param $value
*/
public function searchIdAttr($query, $value)
{
if (is_array($value)) {
if ($value) $query->whereIn('id', $value);
} else {
if ($value) $query->where('id', $value);
}
}
/**
* pid搜索器
* @param Model $query
* @param $value
*/
public function searchPidAttr($query, $value)
{
if ($value !== '') $query->where('pid', $value);
}
/**
* type搜索器
* @param Model $query
* @param $value
*/
public function searchTypeAttr($query, $value)
{
if ($value) $query->where('type', $value);
}
/**
* store_id搜索器
* @param $query
* @param $value
*/
public function searchStoreIdAttr($query, $value)
{
if ($value !== '') $query->where('store_id', $value);
}
/**
* promotions_type搜索器
* @param $query
* @param $value
*/
public function searchPromotionsTypeAttr($query, $value)
{
if ($value !== '') {
if (is_array($value)) {
if ($value) $query->whereIn('promotions_type', $value);
} else {
if ($value) $query->where('promotions_type', $value);
}
}
}
/**
* promotions_cate搜索器
* @param Model $query
* @param $value
*/
public function searchPromotionsCateAttr($query, $value)
{
if ($value !== '') $query->where('promotions_cate', $value);
}
/**
* name搜索器
* @param Model $query
* @param $value
*/
public function searchNameAttr($query, $value)
{
if ($value !== '') $query->whereLike('id|name|desc', "%" . $value . "%");
}
/**
* threshold_type搜索器
* @param Model $query
* @param $value
*/
public function searchThresholdTypeAttr($query, $value)
{
if ($value !== '') $query->where('threshold_type', $value);
}
/**
* discount_type搜索器
* @param Model $query
* @param $value
*/
public function searchDiscountTypeAttr($query, $value)
{
if ($value !== '') $query->where('discount_type', $value);
}
/**
* n_piece_n_discount搜索器
* @param Model $query
* @param $value
*/
public function searchNPieceNDiscountAttr($query, $value)
{
if ($value !== '') $query->where('n_piece_n_discount', $value);
}
/**
* product_partake_type搜索器
* @param Model $query
* @param $value
*/
public function searchProductPartakeTypeAttr($query, $value)
{
if ($value !== '') {
if (is_array($value)) {
if ($value) $query->whereIn('product_partake_type', $value);
} else {
if ($value) $query->where('product_partake_type', $value);
}
}
}
/**
* 是否删除搜索器
* @param Model $query
* @param $value
* @param $data
*/
public function searchIsDelAttr($query, $value, $data)
{
$query->where('is_del', $value ?? 0);
}
/**
* 状态搜索器
* @param Model $query
* @param $value
* @param $data
*/
public function searchStatusAttr($query, $value, $data)
{
if ($value != '') $query->where('status', $value);
}
/**
* 活动事件搜索器
* @param $query
* @param $value
* @param $data
* @return void
*/
public function searchActivityTimeAttr($query, $value, $data)
{
if ($value) {
$startTime = $endTime = 0;
if (is_array($value)) {
$startTime = trim($value[0] ?? 0);
$endTime = trim($value[1] ?? 0);
} elseif (is_string($value)) {
if (strstr($value, '-') !== false) {
[$startTime, $endTime] = explode('-', $value);
$startTime = trim($startTime);
$endTime = trim($endTime);
}
}
if ($startTime || $endTime) {
try {
date('Y-m-d', $startTime);
} catch (\Throwable $e) {
$startTime = strtotime($startTime);
}
try {
date('Y-m-d', $endTime);
} catch (\Throwable $e) {
$endTime = strtotime($endTime);
}
if ($startTime == $endTime || $endTime == strtotime(date('Y-m-d', $endTime))) {
$endTime = $endTime + 86399;
}
$query->where(function ($b) use($startTime, $endTime) {
$b->whereBetween('start_time', [$startTime, $endTime])->whereOr(function ($q) use ($startTime, $endTime) {
$q->whereBetween('stop_time', [$startTime, $endTime]);
})->whereOr(function ($q) use ($startTime, $endTime) {
$q->where('start_time', '<=', $startTime)->where('stop_time', '>=', $endTime);
});
});
}
}
}
}