示例#1
0
<?php

function send_wechat_msg_pe($staff_openid, $template_id, $url_ticket_id, $first_data, $remark_data, $keyword1_data, $keyword2_data, $keyword3_data = null)
{
    $notice_data = ["touser" => $staff_openid, "template_id" => $template_id, "url" => "https://wechat.gds-services.com/static/html/query_req_detail.html?tid=" . $url_ticket_id, "topcolor" => "#000", "data" => ["first" => ["value" => $first_data, "color" => "#000"], "remark" => ["value" => $remark_data, "color" => "#000"], "keyword1" => ["value" => $keyword1_data, "color" => "#000"], "keyword2" => ["value" => $keyword2_data, "color" => "#000"]]];
    if (!empty($keyword3_data) && $keyword3_data != null) {
        $notice_data->data->keyword3 = ["value" => $keyword3_data, "color" => "#000"];
    }
    $options = ['token' => 'nizhidaoma', 'encodingaeskey' => 'IXR7m0K8Q7KOIC4z9s1CRHNQBqrJfFGTUT86CECPaXM', 'appid' => 'wx6bc0c53a3a1c150d', 'appsecret' => '3888ccc01ec4e5d6e0e673308e92e627', 'debug' => true, 'logcallback' => '_log'];
    include dirname(__FILE__) . "/../qy-sdk/wechat.class.php";
    $weObj = new Wechat($options);
    return $weObj->sendTemplateMessage($notice_data);
}
var_dump(send_wechat_msg_pe('okOSbji9QwaX_rab0r5x5AcItELA', 'IKVsdmBRSPYGAXsHFCdiS9GnwgazohOl7RxMncaCfXw', 1111, '您的客户【赵瑞】创建了一个服务请求!', '感谢你对GDS的理解和支持', 'WO0000000086246', '[华瑞银行公司][2016-03-14 08:49:37]人员设备请求单'));
示例#2
0
     $result_sms = send_sms_csc($notifications['notice_id'], $to_mobile, $url_ticket_id, $first_data, $remark_data, $keyword1_data);
 }
 // To ADM
 _log('Processing ADM notification...');
 list($prefer_wechat, $prefer_email, $prefer_mobile) = get_notice_prefer_adm($notifications['ADM_email'], $ticket_stage);
 _log('ADM prefer... ' . json_encode(['ticket_id' => $notifications['t_ticketid'], 'ticket_stage' => $ticket_stage, 'ADM' => $notifications['ADM_email'], 'wechat' => $prefer_wechat, 'email' => $prefer_email, 'mobile' => $prefer_mobile]));
 if ($prefer_wechat) {
     $template_id = 'OFBb_0E6Zy5diGu-ofzsmynT0uySj6-PCU7dPv4sm6o';
     $first_data = '您的客户【' . $notifications['t_custorgname'] . '】的服务请求已被处理完结';
     $remark_data = '请点击详情查看具体信息';
     $keyword1_data = $notifications['t_maskid'];
     $keyword2_data = $notifications['n_create_ts'];
     $openids = get_pe_wechat($notifications['ADM_email']);
     if (!empty($openids)) {
         foreach ($openids as $user_openid) {
             $result_wechat = send_wechat_msg_pe($notifications['notice_id'], $user_openid, 'adm', $template_id, $notifications['t_ticketid'], $first_data, $remark_data, $keyword1_data, $keyword2_data);
         }
     } else {
         _log('No openid binded for ADM ' . $notifications['ADM_email'] . '...');
     }
 }
 if ($prefer_email) {
     $to_addr = $notifications['ADM_email'];
     $to_name = $notifications['ADM_name'];
     $subject = '服务请求处理完结通知【' . $notifications['t_maskid'] . '】';
     $url_ticket_id = $notifications['t_ticketid'];
     $first_data = '您的客户【' . $notifications['t_custorgname'] . '】的服务请求已被处理完结!请悉知。';
     $remark_data = ' ';
     $keyword1_data = '服务单号:' . $notifications['t_maskid'];
     $keyword2_data = '完成时间:' . $notifications['n_create_ts'];
     $result_mail = send_mail_pe($notifications['notice_id'], $to_addr, 'adm', $to_name, $subject, $url_ticket_id, $first_data, $remark_data, $keyword1_data, $keyword2_data);
if ($p_user_type == 'csc') {
    _log('Processing CSC notification...');
    list($prefer_wechat, $prefer_email, $prefer_mobile) = get_notice_prefer_dcs_csc($p_user_mail, $p_stage_val);
    _log('CSC prefer... ' . json_encode(['ticket_id' => $p_ky_ticketid, 'ticket_stage' => $p_stage_val, 'CSC' => $p_user_mail, 'wechat' => $prefer_wechat, 'email' => $prefer_email, 'mobile' => $prefer_mobile]));
    if ($p_method_wechat == '1') {
        if ($prefer_wechat == true || $p_stage == 'wo_delay' || $p_stage == 'manual' || $p_stage == 'manual_1') {
            $template_id = 'nbebyqwxlPD6QdICK7Z6Di8dV7-HyTbSGGzrk-Mvd4A';
            $first_data = $p_stage != 'manual_1' ? $p_first . "\n\n单号:" . $p_ky_maskid : "";
            $remark_data = ($p_stage != 'manual_1' ? "客户:" . $p_cust_org . "\n联系人:" . $p_cust_name . "\nCSC:" . $p_csc_name . "\nADM:" . $p_adm_name . "\nDCS:" . $p_dcs_name . "\n" : $p_first) . "\n" . $p_remark . "\n";
            $keyword1_data = $p_stage != 'manual_1' ? $p_title : '平台通知';
            $keyword2_data = $p_date;
            $openids = get_pe_wechat($p_user_mail);
            _log('Open ids for CSC are ' . var_export($openids, true));
            if (!empty($openids)) {
                foreach ($openids as $user_openid) {
                    $result_wechat = send_wechat_msg_pe($notice_id, $user_openid, 'csc', $template_id, $p_ky_ticketid, $first_data, $remark_data, $keyword1_data, $keyword2_data);
                    if ($result_wechat != 1) {
                        array_push($error, '向CSC发送微信失败');
                    } else {
                        array_push($sent, '发送微信成功');
                    }
                }
            } else {
                _log('No openid binded for CSC ' . $p_user_mail . '...');
                array_push($error, 'CSC没有绑定微信');
            }
        } else {
            _log('CSC设置了不通过【微信】接收【' . $p_stage_text . '】有关的消息');
            array_push($error, 'CSC设置了不通过【微信】接收【' . $p_stage_text . '】有关的消息');
        }
    }