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
215 lines
7.4 KiB
PHP
215 lines
7.4 KiB
PHP
<?php
|
|
|
|
namespace app\jobs\out;
|
|
|
|
use app\services\out\OutStoreOrderRefundServices;
|
|
use app\services\out\OutStoreOrderServices;
|
|
use app\services\out\OutAccountServices;
|
|
use app\services\user\UserServices;
|
|
use crmeb\basic\BaseJobs;
|
|
use crmeb\services\CacheService;
|
|
use crmeb\services\HttpService;
|
|
use crmeb\traits\QueueTrait;
|
|
use think\facade\Log;
|
|
|
|
/**
|
|
* 外部推送队列
|
|
* Class OutPushJob
|
|
* @package app\jobs\out
|
|
*/
|
|
class OutPushJob extends BaseJobs
|
|
{
|
|
use QueueTrait;
|
|
|
|
/**
|
|
* 执行推送任务
|
|
* @param string $type 推送类型
|
|
* @param array $data 推送数据
|
|
* @return bool
|
|
*/
|
|
public function push($type, $data)
|
|
{
|
|
/** @var OutAccountServices $outAccountServices */
|
|
$outAccountServices = app()->make(OutAccountServices::class);
|
|
$outAccountList = $outAccountServices->selectList(['is_del' => 0, 'status' => 1])->toArray();
|
|
foreach ($outAccountList as $item) {
|
|
if ($item['push_open'] == 1) {
|
|
$token = $this->getPushToken($item);
|
|
if ($type == 'order_create_push') {
|
|
OutPushJob::dispatchDo('orderCreate', [$data['order_id'], $item['order_create_push'] . '?pushToken=' . $token]);
|
|
} elseif ($type == 'order_pay_push') {
|
|
OutPushJob::dispatchDo('paySuccess', [$data['order_id'], $item['order_pay_push'] . '?pushToken=' . $token]);
|
|
} elseif ($type == 'refund_create_push') {
|
|
OutPushJob::dispatchDo('refundCreate', [$data['order_id'], $item['refund_create_push'] . '?pushToken=' . $token]);
|
|
} elseif ($type == 'refund_cancel_push') {
|
|
OutPushJob::dispatchDo('refundCancel', [$data['order_id'], $item['refund_cancel_push'] . '?pushToken=' . $token]);
|
|
} elseif ($type == 'user_update_push') {
|
|
OutPushJob::dispatchDo('userUpdate', [$data, $item['user_update_push'] . '?pushToken=' . $token]);
|
|
}
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* 获取推送token
|
|
* @param array $info
|
|
* @return false|mixed
|
|
*/
|
|
public function getPushToken(array $info)
|
|
{
|
|
$token = CacheService::redisHandler()->get('pushToken' . $info['id']);
|
|
if (!$token) {
|
|
$param = json_encode(['push_account' => $info['push_account'], 'push_password' => $info['push_password']], JSON_UNESCAPED_UNICODE);
|
|
$res = HttpService::postRequest($info['push_token_url'], $param, ['Content-Type:application/json', 'Content-Length:' . strlen($param)], 5);
|
|
$res = $res ? json_decode($res, true) : [];
|
|
if (!$res || !isset($res['code']) || $res['code'] != 0) {
|
|
Log::error('获取token失败',['msg' => $info['title']]);
|
|
return false;
|
|
}
|
|
CacheService::redisHandler()->set('pushToken' . $info['id'], $res['token'], $res['time']);
|
|
return $res['token'];
|
|
} else {
|
|
return $token;
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* 订单推送
|
|
* @param int $oid
|
|
* @param string $pushUrl
|
|
* @param int $step
|
|
* @return bool
|
|
*/
|
|
public function orderCreate(int $oid, string $pushUrl, int $step = 0): bool
|
|
{
|
|
if ($step > 2) {
|
|
Log::error('订单' . $oid . '推送失败');
|
|
return true;
|
|
}
|
|
|
|
try {
|
|
/** @var OutStoreOrderServices $services */
|
|
$services = app()->make(OutStoreOrderServices::class);
|
|
if (!$services->orderCreatePush($oid, $pushUrl)) {
|
|
OutPushJob::dispatchSece(($step + 1) * 5, 'orderCreate', [$oid, $pushUrl, $step + 1]);
|
|
}
|
|
} catch (\Exception $e) {
|
|
Log::error('订单' . $oid . '推送失败,失败原因:' . $e->getMessage());
|
|
OutPushJob::dispatchSece(($step + 1) * 5, 'orderCreate', [$oid, $pushUrl, $step + 1]);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* 订单支付推送
|
|
* @param int $oid
|
|
* @param string $pushUrl
|
|
* @param int $step
|
|
* @return bool
|
|
*/
|
|
public function paySuccess(int $oid, string $pushUrl, int $step = 0): bool
|
|
{
|
|
if ($step > 2) {
|
|
Log::error('订单支付' . $oid . '推送失败');
|
|
return true;
|
|
}
|
|
|
|
try {
|
|
/** @var OutStoreOrderServices $services */
|
|
$services = app()->make(OutStoreOrderServices::class);
|
|
if (!$services->paySuccessPush($oid, $pushUrl)) {
|
|
OutPushJob::dispatchSece(($step + 1) * 5, 'paySuccess', [$oid, $pushUrl, $step + 1]);
|
|
}
|
|
} catch (\Exception $e) {
|
|
Log::error('订单支付' . $oid . '推送失败,失败原因:' . $e->getMessage());
|
|
OutPushJob::dispatchSece(($step + 1) * 5, 'paySuccess', [$oid, $pushUrl, $step + 1]);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* 售后单生成
|
|
* @param int $oid
|
|
* @param string $pushUrl
|
|
* @param int $step
|
|
* @return bool
|
|
*/
|
|
public function refundCreate(int $oid, string $pushUrl, int $step = 0): bool
|
|
{
|
|
if ($step > 2) {
|
|
Log::error('售后单' . $oid . '推送失败');
|
|
return true;
|
|
}
|
|
|
|
try {
|
|
/** @var OutStoreOrderRefundServices $services */
|
|
$services = app()->make(OutStoreOrderRefundServices::class);
|
|
if (!$services->refundCreatePush($oid, $pushUrl)) {
|
|
OutPushJob::dispatchSece(($step + 1) * 5, 'refundCreate', [$oid, $pushUrl, $step + 1]);
|
|
}
|
|
} catch (\Exception $e) {
|
|
Log::error('售后单' . $oid . '推送失败,失败原因:' . $e->getMessage());
|
|
OutPushJob::dispatchSece(($step + 1) * 5, 'refundCreate', [$oid, $pushUrl, $step + 1]);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* 取消申请
|
|
* @param int $oid
|
|
* @param string $pushUrl
|
|
* @param int $step
|
|
* @return bool
|
|
*/
|
|
public function refundCancel(int $oid, string $pushUrl, int $step = 0): bool
|
|
{
|
|
if ($step > 2) {
|
|
Log::error('取消售后单' . $oid . '推送失败');
|
|
return true;
|
|
}
|
|
|
|
try {
|
|
/** @var OutStoreOrderRefundServices $services */
|
|
$services = app()->make(OutStoreOrderRefundServices::class);
|
|
if (!$services->cancelApplyPush($oid, $pushUrl)) {
|
|
OutPushJob::dispatchSece(($step + 1) * 5, 'refundCancel', [$oid, $pushUrl, $step + 1]);
|
|
}
|
|
} catch (\Exception $e) {
|
|
Log::error('取消售后单' . $oid . '推送失败,失败原因:' . $e->getMessage());
|
|
OutPushJob::dispatchSece(($step + 1) * 5, 'refundCancel', [$oid, $pushUrl, $step + 1]);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* 余额,积分,佣金,经验变动推送
|
|
* @param array $data
|
|
* @param string $pushUrl
|
|
* @param int $step
|
|
* @return bool
|
|
*/
|
|
public function userUpdate(array $data, string $pushUrl, int $step = 0): bool
|
|
{
|
|
if ($step > 2) {
|
|
Log::error('用户变动推送失败');
|
|
return true;
|
|
}
|
|
|
|
try {
|
|
/** @var UserServices $services */
|
|
$services = app()->make(UserServices::class);
|
|
if (!$services->userUpdate($data, $pushUrl)) {
|
|
OutPushJob::dispatchSece(($step + 1) * 5, 'userUpdate', [$data, $pushUrl, $step + 1]);
|
|
}
|
|
} catch (\Exception $e) {
|
|
OutPushJob::dispatchSece(($step + 1) * 5, 'userUpdate', [$data, $pushUrl, $step + 1]);
|
|
}
|
|
return true;
|
|
}
|
|
}
|