分销功能提交
This commit is contained in:
@@ -21,6 +21,7 @@ use app\common\service\AuthService;
|
||||
use app\common\service\WechatAccountHealthScoreService;
|
||||
use app\api\controller\WebSocketController;
|
||||
use Workerman\Lib\Timer;
|
||||
use app\cunkebao\service\DistributionRewardService;
|
||||
|
||||
class Adapter implements WeChatServiceInterface
|
||||
{
|
||||
@@ -375,9 +376,26 @@ class Adapter implements WeChatServiceInterface
|
||||
|
||||
if ($passedWeChatId && !empty($task_info['msgConf'])) {
|
||||
|
||||
// 更新状态为4(已通过并已发消息)
|
||||
Db::name('task_customer')
|
||||
->where('id', $task['id'])
|
||||
->update(['status' => 4,'passTime' => time(), 'updateTime' => time()]);
|
||||
|
||||
// 记录添加好友奖励(如果之前没有记录过,status从其他状态变为4时)
|
||||
// 注意:如果status已经是2,说明已经记录过奖励,这里不再重复记录
|
||||
if ($task['status'] != 2 && !empty($task['channelId'])) {
|
||||
try {
|
||||
DistributionRewardService::recordAddFriendReward(
|
||||
$task['task_id'],
|
||||
$task['id'],
|
||||
$task['phone'],
|
||||
intval($task['channelId'])
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
// 记录错误但不影响主流程
|
||||
Log::error('记录添加好友奖励失败:' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$wechatFriendRecord = $this->getWeChatAccoutIdAndFriendIdByWeChatIdAndFriendPhone($passedWeChatId, $task['phone']);
|
||||
$msgConf = is_string($task_info['msgConf']) ? json_decode($task_info['msgConf'], 1) : $task_info['msgConf'];
|
||||
@@ -395,9 +413,26 @@ class Adapter implements WeChatServiceInterface
|
||||
|
||||
// 已经执行成功的话,直接break,同时更新对应task_customer的状态为2(添加成功)
|
||||
if (isset($latestFriendTask['status']) && $latestFriendTask['status'] == 1) {
|
||||
// 更新状态
|
||||
Db::name('task_customer')
|
||||
->where('id', $task['id'])
|
||||
->update(['status' => 2, 'updateTime' => time()]);
|
||||
|
||||
// 记录添加好友奖励(异步处理,不影响主流程)
|
||||
if (!empty($task['channelId'])) {
|
||||
try {
|
||||
DistributionRewardService::recordAddFriendReward(
|
||||
$task['task_id'],
|
||||
$task['id'],
|
||||
$task['phone'],
|
||||
intval($task['channelId'])
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
// 记录错误但不影响主流程
|
||||
Log::error('记录添加好友奖励失败:' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user