示例#1
0
 private function sendShareMsg($openid, $prize = '')
 {
     $companyInfo = $this->getCompanyInfo();
     $options = array('appid' => $companyInfo['weixin_AppId'], 'appsecret' => $companyInfo['weixin_AppSecret'], 'partnerid' => $companyInfo['weixin_PartnerID'], 'partnerkey' => $companyInfo['weixin_PartnerKey'], 'paysignkey' => $companyInfo['weixin_PaySignKey']);
     if ($prize) {
         $prize = '恭喜您获得({$prize})一个';
     } else {
         $prize = '感谢参与!';
     }
     $data = array('touser' => $openid, 'template_id' => 'tuan_68XdmLt57-J_k0Au3Qw7Y_Hh3uUdjclzcuhbcA', 'url' => '', 'topcolor' => '#000000', 'data' => array('first' => array('value' => '感谢您参加分享抽奖活动', "color" => "#173177"), 'keyword1' => array('value' => '蒂罗尔全新升级…八重惊喜等你来', "color" => "#173177"), 'keyword2' => array('value' => date('Y-m-d H:i:s'), "color" => "#173177"), 'remark' => array('value' => $prize, "color" => "#173177")));
     $wechat = new TPWechat($options);
     $wechat->sendTemplateMessage($data);
 }
示例#2
0
 private function sendOrderMsg($orderInfo)
 {
     $uid = $orderInfo['uId'];
     $m = M('Company_888_user_info');
     $userInfo = $m->find($uid);
     $goods = json_decode($orderInfo['goods'], true);
     dump($goods);
     for ($i = 0; $i < count($goods); $i++) {
         if ($i > 0) {
             $goodsText .= ',';
         }
         $goodsText .= "{$goods[$i]['name']}({$goods[$i]['type']}) * {$goods[$i]['num']}";
     }
     $address = json_decode($orderInfo['address'], true);
     $title = "您好,你的订单【{$orderInfo['orderNo']}】已成功支付,我们将尽快处理。";
     if ($userInfo) {
         $companyInfo = $this->getCompanyInfo();
         $options = array('appid' => $companyInfo['weixin_AppId'], 'appsecret' => $companyInfo['weixin_AppSecret'], 'partnerid' => $companyInfo['weixin_PartnerID'], 'partnerkey' => $companyInfo['weixin_PartnerKey'], 'paysignkey' => $companyInfo['weixin_PaySignKey']);
         $data = array('touser' => $userInfo['openId'], 'template_id' => 'GtKtiZJnnt98LYKpdo6Pu6_4o1CkkGbyjdr5GuVpy9o', 'url' => '', 'topcolor' => '#000000', 'data' => array('first' => array('value' => $title, "color" => "#173177"), 'keyword1' => array('value' => date('Y-m-d H:i:s'), "color" => "#173177"), 'keyword2' => array('value' => (int) $orderInfo['price'] + (int) $orderInfo['expressPrice'] . '元', "color" => "#173177"), 'keyword3' => array('value' => $goodsText, "color" => "#173177"), 'keyword4' => array('value' => $address['tel'], "color" => "#173177"), 'keyword5' => array('value' => $address['province'] . $address['city'] . $address['district'] . $address['address'], "color" => "#173177"), 'remark' => array('value' => "如有疑问,请拨打客服电话4009633517或添加微信客服 lp87170871”", "color" => "#173177")));
         $wechat = new TPWechat($options);
         $wechat->sendTemplateMessage($data);
     }
 }