Files
huangjingfen/pro_v3.5.1_副本/app/services/supplier/finance/SupplierExtractServices.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

233 lines
8.7 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\supplier\finance;
use app\dao\supplier\finance\SupplierExtractDao;
use app\services\BaseServices;
use app\services\supplier\SystemSupplierServices;
use app\services\system\admin\SystemAdminServices;
use crmeb\services\FormBuilder as Form;
use think\annotation\Inject;
use think\exception\ValidateException;
use think\facade\Route as Url;
/**
* 门店提现
* Class StoreExtractServices
* @package app\services\store\finance
* @mixin SupplierExtractDao
*/
class SupplierExtractServices extends BaseServices
{
/**
* @var SupplierExtractDao
*/
#[Inject]
protected SupplierExtractDao $dao;
/**
* 获取一条提现记录
* @param int $id
* @param array $field
* @return array|\think\Model|null
*/
public function getExtract(int $id, array $field = [])
{
return $this->dao->get($id, $field);
}
/**
* 显示资源列表
* @param array $where
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index(array $where, array $whereData = [])
{
$list = $this->getStoreExtractList($where);
//待审核金额
$where['status'] = 0;
$extract_statistics['price'] = $this->dao->getExtractMoneyByWhere($where, 'extract_price');
//待转账金额
$where['status'] = 1;
$where['pay_status'] = 0;
$extract_statistics['unPayPrice'] = $this->dao->getExtractMoneyByWhere($where, 'extract_price');
//累计提现
$where['status'] = 1;
$where['pay_status'] = 1;
$extract_statistics['paidPrice'] = $this->dao->getExtractMoneyByWhere($where, 'extract_price');
$extract_statistics['price_count'] = 0;
//未提现金额
/** @var SupplierFlowingWaterServices $financeFlowServices */
$financeFlowServices = app()->make(SupplierFlowingWaterServices::class);
$price_not = $financeFlowServices->getSumFinance(['supplier_id' => isset($where['supplier_id']) && $where['supplier_id'] ? $where['supplier_id'] : 0], $whereData);
$extract_statistics['price_not'] = max($price_not, 0);
$extract_statistics['extract_min_price'] = sys_config('supplier_extract_min_price');
$extract_statistics['extract_max_price'] = sys_config('supplier_extract_max_price');
return compact('extract_statistics', 'list');
}
/**
* 获取提现列表
* @param array $where
* @param string $field
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getStoreExtractList(array $where, string $field = '*')
{
[$page, $limit] = $this->getPageValue();
$list = $this->dao->getExtractList($where, $field, ['supplier'], $page, $limit);
if ($list) {
/** @var SystemAdminServices $adminServices */
$adminServices = app()->make(SystemAdminServices::class);
$adminIds = array_unique(array_column($list, 'admin_id'));
$adminInfos = [];
if ($adminIds) $adminInfos = $adminServices->getColumn([['id', 'in', $adminIds]], 'id,real_name', 'id');
foreach ($list as &$item) {
$item['add_time'] = $item['add_time'] ? date("Y-m-d H:i:s", $item['add_time']) : '';
$item['admin_name'] = $item['admin_id'] ? ($adminInfos[$item['admin_id']]['real_name'] ?? '') : '';
}
}
$count = $this->dao->count($where);
return compact('list', 'count');
}
/**
* 提现申请
* @param int $supplierId
* @param array $data
* @return bool
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function cash(int $supplierId, array $data)
{
/** @var SystemSupplierServices $systemSupplier */
$systemSupplier = app()->make(SystemSupplierServices::class);
$supplierInfo = $systemSupplier->getSupplierInfo($supplierId);
$insertData = [];
switch ($data['extract_type']) {
case 'bank':
if (!$supplierInfo['bank_code'] || !$supplierInfo['bank_address']) {
throw new ValidateException('请先设置提现银行与开户行信息');
}
$insertData['bank_code'] = $supplierInfo['bank_code'];
$insertData['bank_address'] = $supplierInfo['bank_address'];
break;
case 'alipay':
if (!$supplierInfo['alipay_account'] || !$supplierInfo['alipay_qrcode_url']) {
throw new ValidateException('请先设置提现支付宝信息');
}
$insertData['alipay_account'] = $supplierInfo['alipay_account'];
$insertData['qrcode_url'] = $supplierInfo['alipay_qrcode_url'];
break;
case 'weixin':
if (!$supplierInfo['wechat'] || !$supplierInfo['wechat_qrcode_url']) {
throw new ValidateException('请先设置提现微信信息');
}
$insertData['wechat'] = $supplierInfo['wechat'];
$insertData['qrcode_url'] = $supplierInfo['wechat_qrcode_url'];
break;
default:
throw new ValidateException('暂不支持该类型提现');
break;
}
$insertData['supplier_id'] = $supplierInfo['id'];
$insertData['extract_type'] = $data['extract_type'];
$insertData['extract_price'] = $data['money'];
$insertData['add_time'] = time();
$insertData['supplier_mark'] = $data['mark'];
$insertData['status'] = 0;
if (!$this->dao->save($insertData)) {
return false;
}
return true;
}
/**
* 拒绝
* @param $id
* @return mixed
*/
public function refuse(int $id, string $message, int $adminId)
{
$extract = $this->getExtract($id);
if (!$extract) {
throw new ValidateException('操作记录不存在!');
}
if ($extract->status == 1) {
throw new ValidateException('已经提现,错误操作');
}
if ($extract->status == -1) {
throw new ValidateException('您的提现申请已被拒绝,请勿重复操作!');
}
if ($this->dao->update($id, ['fail_time' => time(), 'fail_msg' => $message, 'status' => -1, 'admin_id' => $adminId])) {
return true;
} else {
throw new ValidateException('操作失败!');
}
}
/**
* 通过
* @param $id
* @return mixed
*/
public function adopt(int $id, int $adminId)
{
$extract = $this->getExtract($id);
if (!$extract) {
throw new ValidateException('操作记录不存!');
}
if ($extract->status == 1) {
throw new ValidateException('您已提现,请勿重复提现!');
}
if ($extract->status == -1) {
throw new ValidateException('您的提现申请已被拒绝!');
}
if ($this->dao->update($id, ['status' => 1, 'admin_id' => $adminId])) {
return true;
} else {
throw new ValidateException('操作失败!');
}
}
/**
* 转账页面
* @param int $id
* @return string
*/
public function add_transfer(int $id)
{
$field = array();
$title = '转账信息';
$field[] = Form::input('voucher_title', '转账说明', '')->maxlength(30)->required();
$field[] = Form::frameImage('voucher_image', '转账凭证', Url::buildUrl(config('admin.admin_prefix') . '/widget.images/index', array('fodder' => 'voucher_image')), '')->icon('ios-add')->width('960px')->height('505px')->modal(['footer-hide' => true]);
return create_form($title, $field, Url::buildUrl('/supplier/extract/save_transfer/' . $id), 'POST');
}
}