Files
huangjingfen/pro_v3.5.1_副本/app/services/article/ArticleServices.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

204 lines
6.1 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\services\article;
use app\dao\article\ArticleDao;
use app\services\BaseServices;
use app\services\wechat\WechatNewsCategoryServices;
use app\services\user\UserRelationServices;
use crmeb\exceptions\AdminException;
use think\annotation\Inject;
/**
* 文章
* Class ArticleServices
* @package app\services\article
* @mixin ArticleDao
*/
class ArticleServices extends BaseServices
{
/**
* @var ArticleDao
*/
#[Inject]
protected ArticleDao $dao;
/**
* 获取列表
* @param array $where
* @return array
*/
public function getList(array $where, int $page = 0, int $limit = 0)
{
if (!$limit) {
[$page, $limit] = $this->getPageValue();
}
/** @var WechatNewsCategoryServices $services */
$services = app()->make(WechatNewsCategoryServices::class);
$where['ids'] = $services->getNewIds();
$list = $this->dao->getList($where, $page, $limit);
foreach ($list as &$item) {
$item['store_name'] = $item['storeInfo']['store_name'] ?? '';
}
$count = $this->dao->count($where);
return compact('list', 'count');
}
/**
* 新增编辑文章
* @param array $data
*/
public function save(array $data)
{
/** @var ArticleContentServices $articleContentService */
$articleContentService = app()->make(ArticleContentServices::class);
$content['content'] = $data['content'];
$id = $data['id'];
unset($data['content'], $data['id']);
$info = $this->transaction(function () use ($id, $data, $articleContentService, $content) {
if ($id) {
$info = $this->dao->update($id, $data);
$content['nid'] = $id;
$res = $info && $articleContentService->update($id, $content, 'nid');
} else {
unset($data['id']);
$data['add_time'] = time();
$info = $this->dao->save($data);
$content['nid'] = $info->id;
$res = $info && $articleContentService->save($content);
}
if (!$res) {
throw new AdminException('保存失败');
} else {
return $info;
}
});
return $info;
}
/**
* 获取商品详情
* @param $id
* @return array
*/
public function read(int $id)
{
$info = $this->dao->read($id);
$info['cid'] = (int)$info['cid'];
return compact('info');
}
/**
* 删除商品
* @param int $id
*/
public function del(int $id)
{
/** @var ArticleContentServices $articleContentService */
$articleContentService = app()->make(ArticleContentServices::class);
$this->transaction(function () use ($id, $articleContentService) {
$res = $this->dao->delete($id);
$res = $res && $articleContentService->del($id);
if (!$res) {
throw new AdminException('删除失败');
}
});
}
/**
* 文章关联商品
* @param int $id
* @param int $product_id
* @return mixed
*/
public function bindProduct(int $id, int $product_id = 0)
{
return $this->dao->update($id, ['product_id' => $product_id]);
}
/**
* 获取数量
* @param array $where
* @return int
*/
public function count(array $where)
{
return $this->dao->count($where);
}
/**
* 获取一条数据
* @param int $id
* @return mixed
*/
public function getInfo(int $uid, int $id)
{
$info = $this->dao->read($id);
if (!$info) {
throw new AdminException('文章不存在或已删除');
}
$info->visit = ($info->visit ?? 0) + 1;
if (!$info->save())
throw new AdminException('请稍后查看');
if ($info) {
$info = $info->toArray();
$info['visit'] = (int)$info['visit'];
$info['add_time'] = date('Y-m-d', $info['add_time']);
}
/** @var UserRelationServices $relationServices */
$relationServices = app()->make(UserRelationServices::class);
$info['is_like'] = $relationServices->isProductRelation(['uid' => $uid, 'relation_id' => $id, 'type' => 'like', 'category' => 'article']);
return $info;
}
/**
* 文章点赞 添加、取消
* @param int $id
* @param array $where
* @param int $uid
* @return bool
*/
public function userArticleLikes(int $id, array $where, int $uid)
{
$info = $this->dao->read($id);
if (!$info) {
throw new AdminException('文章不存在或已删除');
}
$info->likes = $where['status'] > 0 ? ($info->likes ?? 0) + 1 : ($info->likes > 1 ? $info->likes - 1 : 0);
if (!$info->save()) throw new AdminException('请稍后查看');
$ids = [$id];
/** @var UserRelationServices $relationServices */
$relationServices = app()->make(UserRelationServices::class);
return $relationServices->productRelation($uid, $ids, 'like', 'article', $where['status'] <= 0);
}
/**
* 获取文章列表
* @param $new_id
* @return int
*/
public function articleList($new_id)
{
return $this->dao->articleLists($new_id);
}
/**图文详情
* @param $new_id
* @return mixed
*/
public function articlesList($new_id)
{
return $this->dao->articleContentList($new_id);
}
}