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
233 lines
7.8 KiB
PHP
233 lines
7.8 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\controller\supplier;
|
||
|
||
|
||
use app\Request;
|
||
use app\services\order\StoreOrderRefundServices;
|
||
use app\services\order\StoreOrderServices;
|
||
use app\services\user\UserServices;
|
||
use think\annotation\Inject;
|
||
|
||
/**
|
||
* Class Refund
|
||
* @package app\controller\supplier
|
||
*/
|
||
class Refund extends AuthController
|
||
{
|
||
|
||
/**
|
||
* @var StoreOrderRefundServices
|
||
*/
|
||
#[Inject]
|
||
protected StoreOrderRefundServices $services;
|
||
|
||
/**
|
||
* 退款订单列表
|
||
* @return mixed
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
*/
|
||
public function getRefundList()
|
||
{
|
||
$where = $this->request->getMore([
|
||
['order_id', ''],
|
||
['time', ''],
|
||
['apply_type', ''],
|
||
['refund_type', ''],
|
||
['refund_reason','']
|
||
]);
|
||
$where['supplier_id'] = $this->supplierId;
|
||
return $this->success($this->services->refundList($where));
|
||
}
|
||
|
||
/**
|
||
* 订单详情
|
||
* @param UserServices $userServices
|
||
* @param $id
|
||
* @return mixed
|
||
*/
|
||
public function detail(UserServices $userServices, $id)
|
||
{
|
||
$order = $this->services->refundDetail($id);
|
||
$data['orderInfo'] = $order;
|
||
$userInfo = ['spread_uid' => '', 'spread_name' => '无'];
|
||
if ($order['uid']) {
|
||
$userInfo = $userServices->get((int)$order['uid']);
|
||
if (!$userInfo) return app('json')->fail('用户信息不存在');
|
||
$userInfo = $userInfo->hidden(['pwd', 'add_ip', 'last_ip', 'login_type']);
|
||
$userInfo = $userInfo->toArray();
|
||
$userInfo['spread_name'] = '无';
|
||
if ($order['spread_uid']) {
|
||
$spreadName = $userServices->value(['uid' => $order['spread_uid']], 'nickname');
|
||
if ($spreadName) {
|
||
$userInfo['spread_name'] = $order['uid'] == $order['spread_uid'] ? $spreadName . '(自购)' : $spreadName;
|
||
$userInfo['spread_uid'] = $order['spread_uid'];
|
||
} else {
|
||
$userInfo['spread_uid'] = '';
|
||
}
|
||
} else {
|
||
$userInfo['spread_uid'] = '';
|
||
}
|
||
}
|
||
$data['userInfo'] = $userInfo;
|
||
return app('json')->successful('ok', $data);
|
||
}
|
||
|
||
/**
|
||
* 退款表单生成
|
||
* @param $id
|
||
* @return mixed
|
||
* @throws \FormBuilder\Exception\FormBuilderException
|
||
*/
|
||
public function refund($id)
|
||
{
|
||
if (!$id) {
|
||
return app('json')->fail('Data does not exist!');
|
||
}
|
||
return app('json')->success($this->services->refundOrderForm((int)$id));
|
||
}
|
||
|
||
/**
|
||
* 订单退款
|
||
* @param Request $request
|
||
* @param StoreOrderServices $services
|
||
* @param $id
|
||
* @return mixed
|
||
*/
|
||
public function update_refund(Request $request, StoreOrderServices $services, $id)
|
||
{
|
||
$data = $request->postMore([
|
||
['refund_price', 0],
|
||
['type', 1]
|
||
]);
|
||
if (!$id) {
|
||
return app('json')->fail('Data does not exist!');
|
||
}
|
||
$data['refund_price'] = sprintf("%.2f", $data['refund_price']);
|
||
$orderRefund = $this->services->get($id);
|
||
if (!$orderRefund) {
|
||
return app('json')->fail('Data does not exist!');
|
||
}
|
||
if ($orderRefund['is_cancel'] == 1) {
|
||
return app('json')->fail('用户已取消申请');
|
||
}
|
||
$order = $services->get((int)$orderRefund['store_order_id']);
|
||
if (!$order) {
|
||
return app('json')->fail('Data does not exist!');
|
||
}
|
||
if (!in_array($orderRefund['refund_type'], [0, 1, 2, 5]) && !($orderRefund['refund_type'] == 4 && $orderRefund['apply_type'] == 3)) {
|
||
return app('json')->fail('售后订单状态不支持该操作');
|
||
}
|
||
|
||
if ($data['type'] == 1) {
|
||
$data['refund_type'] = 6;
|
||
} else if ($data['type'] == 2) {
|
||
$data['refund_type'] = 3;
|
||
}
|
||
$data['refunded_time'] = time();
|
||
$type = $data['type'];
|
||
//拒绝退款
|
||
if ($type == 2) {
|
||
$this->services->refuseRefund((int)$orderRefund['id'], $data, $orderRefund);
|
||
return app('json')->successful('修改退款状态成功!');
|
||
} else {
|
||
//0元退款
|
||
if ($orderRefund['refund_price'] == 0) {
|
||
$refund_price = 0;
|
||
} else {
|
||
if (!$data['refund_price']) {
|
||
return app('json')->fail('请输入退款金额');
|
||
}
|
||
if ($orderRefund['refund_price'] == $orderRefund['refunded_price']) {
|
||
return app('json')->fail('已退完支付金额!不能再退款了');
|
||
}
|
||
$refund_price = $data['refund_price'];
|
||
|
||
$data['refunded_price'] = bcadd($data['refund_price'], $orderRefund['refunded_price'], 2);
|
||
$bj = bccomp((string)$orderRefund['refund_price'], (string)$data['refunded_price'], 2);
|
||
if ($bj < 0) {
|
||
return app('json')->fail('退款金额大于支付金额,请修改退款金额');
|
||
}
|
||
}
|
||
|
||
unset($data['type']);
|
||
$refund_data['pay_price'] = $order['pay_price'];
|
||
$refund_data['refund_price'] = $refund_price;
|
||
|
||
//修改订单退款状态
|
||
unset($data['refund_price']);
|
||
if ($this->services->agreeRefund($id, $refund_data)) {
|
||
//退款处理
|
||
$this->services->update($id, $data);
|
||
return app('json')->success('退款成功');
|
||
}
|
||
// else {
|
||
// $this->services->storeProductOrderRefundYFasle((int)$id, $refund_price);
|
||
// return app('json')->fail('退款失败');
|
||
// }
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 商家同意退货退款
|
||
* @return mixed
|
||
*/
|
||
public function agreeRefund()
|
||
{
|
||
[$id] = $this->request->getMore([
|
||
['order_id', '']
|
||
], true);
|
||
$this->services->agreeRefundProdcut((int)$id);
|
||
return app('json')->success('操作成功');
|
||
}
|
||
|
||
/**
|
||
* 修改备注
|
||
* @param $id
|
||
* @return mixed
|
||
*/
|
||
public function remark($id)
|
||
{
|
||
$data = $this->request->postMore([['remark', '']]);
|
||
if (!$data['remark'])
|
||
return app('json')->fail('请输入要备注的内容');
|
||
if (!$id)
|
||
return app('json')->fail('缺少参数');
|
||
|
||
if (!$order = $this->services->get($id)) {
|
||
return app('json')->fail('修改的订单不存在!');
|
||
}
|
||
$order->remark = $data['remark'];
|
||
if ($order->save()) {
|
||
return app('json')->success('备注成功');
|
||
} else
|
||
return app('json')->fail('备注失败');
|
||
}
|
||
|
||
/**
|
||
* 售后原因
|
||
* @return \think\Response
|
||
* User: liusl
|
||
* DateTime: 2024/9/7 14:21
|
||
*/
|
||
public function refund_reason()
|
||
{
|
||
$reason = sys_config('stor_reason') ?: [];//退款理由
|
||
$reason = str_replace("\r\n", "\n", $reason);//防止不兼容
|
||
$reason = explode("\n", $reason);
|
||
return app('json')->successful($reason);
|
||
}
|
||
}
|
||
|