<?php
namespace liuniu;
use app\admin\model\wechat\TemplateInfo;

class WechatTempleService
{
    /**
     * 主营行业：IT科技 互联网|电子商务
     * 副营行业：IT科技 IT软件与服务
     */

    //培训提醒通知
    const RAINING_REMINDER  = 'OPENTM412298968';

    //服务续费提醒通知
    const RENWAL_REINDER = 'TM202168523';

    //订单会员通知
    const BECOME_VIP  = 'OPENTM406048156';

    //工单受理提醒
    const WORK_STATUS = 'OPENTM417758252';

    //报名成功通知
    const  REGISTRATION_SUCCESS = 'OPENTM413131902';

    //工单超时通知
    const WORK_TIMEOUT = 'OPENTM418425938';

    //申请拒绝通知
    const REQUEXST_REFUSE = 'OPENTM418263428';

    //支援者应答通知
    const SUPPAORTER_REPLY = 'OPENTM415748334';

    //紧急救援通知
    const EMERGANCY_RESCUE = 'OPENTM415748326';

    /**
     * 发送模板消息
     */
    public static function sendTemplate($cid,$openid, $templateId, array $data, $url = null)
    {

        $tempid = TemplateInfo::where('cid',$cid)->where('tempkey', $templateId)->value('tempid');
        if (!$tempid) return false;
        try {
            return WechatService::sendTemplate($openid,$tempid,$data,$url,$cid);
        } catch (\Exception $e) {
            return false;
        }

    }

}