1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-29 13:51:37 +08:00
koogua 0336a54911 1.源文件增加版权信息
2.群组状态和课程协同
2021-06-13 15:49:47 +08:00

56 lines
1.5 KiB
PHP

<?php
/**
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
* @license https://opensource.org/licenses/GPL-2.0
* @link https://www.koogua.com
*/
namespace App\Services\Logic\Notice\DingTalk;
use App\Models\PointGift as PointGiftModel;
use App\Models\PointRedeem as PointRedeemModel;
use App\Models\Task as TaskModel;
use App\Repos\PointRedeem as PointRedeemRepo;
use App\Services\DingTalkNotice;
class PointRedeem extends DingTalkNotice
{
public function handleTask(TaskModel $task)
{
if (!$this->enabled) return;
$redeemRepo = new PointRedeemRepo();
$redeem = $redeemRepo->findById($task->item_id);
$content = kg_ph_replace("{user.name} 兑换了商品 {gift.name},不要忘记发货哦!", [
'user.name' => $redeem->user_name,
'gift.name' => $redeem->gift_name,
]);
$this->atCustomService($content);
}
public function createTask(PointRedeemModel $redeem)
{
if (!$this->enabled) return;
if ($redeem->gift_type != PointGiftModel::TYPE_GOODS) return;
$task = new TaskModel();
$itemInfo = [
'point_redeem' => ['id' => $redeem->id],
];
$task->item_id = $redeem->id;
$task->item_info = $itemInfo;
$task->item_type = TaskModel::TYPE_NOTICE_POINT_REDEEM;
$task->priority = TaskModel::PRIORITY_MIDDLE;
$task->status = TaskModel::STATUS_PENDING;
$task->create();
}
}