Commit 05d42acf by 杨树贤

添加通知

parent 238877ed
......@@ -42,6 +42,8 @@ REDIS_READ_HOST=192.168.1.235
REDIS_READ_PASSWORD=icDb29mLy2s
REDIS_READ_PORT=6379
IC_AUTH_API=http://authapi.icsales.cc
RobotUrl=https://oapi.dingtalk.com/robot/send?access_token=a7255513c160f20d65c0c00d939fe88712233bbda0dc520563705bf721072d11
......@@ -68,6 +68,8 @@ class AssistsController extends Controller
if ($canAssist) {
$result = $assist->addAssist($data);
if ($result) {
//好友助力成功一次就要向用户添加一条站内信
$assist->sendNotice($data['user_id']);
return $this->Export(0, 'ok');
} else {
return $this->Export(ErrorCode(20, 5), '新增好友助力记录失败');
......
......@@ -8,6 +8,8 @@ use App\Http\Filters\CodeFilter;
use App\Models\CheckIn;
use App\Models\Code;
use App\Models\Integral;
use App\Tasks\SendNoticeTask;
use Hhxsv5\LaravelS\Swoole\Task\Task;
use Illuminate\Http\Request;
//红包码兑换管理
......@@ -55,6 +57,8 @@ class CodesController extends Controller
if ($canAddCode) {
$res = $code->addCode($data);
if ($res) {
//向被兑换红包码所属用户发送通知
$code->sendNotice($data['code']);
return $this->Export(0, 'ok');
} else {
return $this->Export(ErrorCode(21, 5), '红包码兑换失败');
......
......@@ -6,6 +6,7 @@ namespace App\Models;
use App\Http\Filters\QueryFilter;
use App\Tasks\IntegralBillTask;
use App\Tasks\SendNoticeTask;
use Common\Model\RedisModel;
use Carbon\Carbon;
use Hhxsv5\LaravelS\Swoole\Task\Task;
......@@ -120,4 +121,16 @@ class Assist extends Model
//不存在记录的话就代表可以直接插入
return true;
}
//添加通知
public function sendNotice($userId)
{
$redis = new RedisModel();
$user = $redis->hget('ic_user',$userId);
if ($user) {
//发送通知
$task = new SendNoticeTask('IC_Code_Exchange', $user, $userId);
Task::deliver($task);
}
}
}
\ No newline at end of file
......@@ -5,7 +5,9 @@ namespace App\Models;
use App\Http\Filters\QueryFilter;
use App\Tasks\SendNoticeTask;
use Common\Model\RedisModel;
use Hhxsv5\LaravelS\Swoole\Task\Task;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
......@@ -130,4 +132,19 @@ class Code extends Model
return $result;
}
//发送通知
public function sendNotice($code)
{
//找出红包码所属的userId
$codeUserId = substr($code, 2);
//找到用户信息
$redis = new RedisModel();
$user = $redis->hget('ic_user', $codeUserId);
if ($user) {
//发送通知
$task = new SendNoticeTask('IC_Code_Exchange', $user, $codeUserId);
Task::deliver($task);
}
}
}
\ No newline at end of file
......@@ -5,4 +5,5 @@ return [
'RobotUrl' => 'https://oapi.dingtalk.com/robot/send?access_token=245f39f3b18bfcb8d739068327a32327f5c0c868529b5d5ba357f919567ef1fd',
'SystemName' => env('SYSTEM_NAME','这家伙没设置系统'),//系统名称
"at" => env('AT'),
'IC_AUTH_API'=>env('IC_AUTH_API'),
];
\ No newline at end of file
19158
\ No newline at end of file
19880
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment