function sendMsgToElink($msg, $apiKey, $mKey, $partner, $machine_code) { $params = array('partner' => $partner, 'machine_code' => $machine_code, 'content' => $msg); $sign = generateSign($params, $apiKey, $mKey); $params['sign'] = $sign; $return = httppost1($params); return $return; }
public function wxprint() { $id = $_GET["id"]; $msg = ''; $result = D("Order")->where(array("id" => $id))->relation(true)->find(); if ($result["pay_status"] == 0) { $pay_status = "未付款"; } else { $pay_status = "已付款"; } $msgtitle = '欢迎您订购 订单编号:' . $result["orderid"] . ' 条目 单价(元) 数量 -------------------------------------------- '; $detail = ''; for ($j = 0; $j < count($result["cartdata"]); $j++) { $row = $result["cartdata"][$j]; $title = $row['name']; $price = $row['price']; $num = $row['num']; $detail .= $title . ' ' . $price . ' ' . $num . ' '; } $msgcontent = $detail; $msgfooter = ' 备注:' . $result["note"] . ' -------------------------------------------- 合计:' . $result["totalprice"] . '元 付款状态:' . $pay_status . ' 联系用户:' . $result["contact"]["name"] . ' 送货地址:' . $result["contact"]["city"] . $result["contact"]["area"] . $result["contact"]["address"] . ' 联系电话:' . $result["contact"]["phone"] . ' 订购时间:' . $result["time"] . ' '; //自由输出 $msg .= $msgtitle . $msgcontent . $msgfooter; // print_r($msg); // return; $apiKey = ""; //apiKey $mKey = ""; //秘钥 $partner = ""; //用户id $machine_code = ""; //机器码 import('wxPrint', APP_PATH . 'Common', '.php'); $params = array('partner' => $partner, 'machine_code' => $machine_code, 'content' => $msg); $sign = generateSign($params, $apiKey, $mKey); $params['sign'] = $sign; echo httppost1($params); $this->success("操作成功"); }