<?php
 namespace Payment\Common\Weixin\Data; use Payment\Common\PayException; use Payment\Utils\ArrayUtil; class RedData extends WxBaseData { protected function buildData() { $this->retData = [ 'act_name' => $this->act_name, 'client_ip' => $this->client_ip, 'mch_billno' => $this->mch_billno, 'mch_id' => $this->mchId, 'nonce_str' => $this->nonceStr, 're_openid' => $this->re_openid, 'remark' => $this->remark, 'scene_id' => $this->scene_id, 'send_name' => $this->send_name, 'total_amount' => $this->total_amount, 'total_num' => $this->total_num ? $this->total_num : 1, 'wishing' => $this->wishing, 'wxappid' => $this->appId, 'msgappid' => $this->sub_appid, 'sub_mch_id' => $this->sub_mch_id, ]; $this->retData = ArrayUtil::paraFilter($this->retData); } protected function checkDataParam() { $mch_billno = $this->mch_billno; $sendName = $this->send_name; $reOpenid = $this->re_openid; $wishing = $this->wishing; $actName = $this->act_name; $remark = $this->remark; $total_amount = $this->total_amount; $sendListid = $this->send_listid; if (empty($mch_billno)) { throw new PayException('请设置单号 mch_billno'); } if (empty($sendName)) { throw new PayException('请设置发送名称 send_name'); } if (empty($reOpenid)) { throw new PayException('请设置接收者 openID'); } if (empty($wishing)) { throw new PayException("请设置祝福语"); } if (empty($actName)) { throw new PayException("请设置活动名称"); } if (empty($remark)) { throw new PayException("请设置备注信息"); } $this->total_amount = bcmul($total_amount, 100, 0); if (empty($total_amount) || $total_amount < 1) { throw new PayException('转账金额错误'); } if (empty($sendListid) && empty($mch_billno)) { throw new PayException('必须提供微信交易号或商户网站唯一订单号。建议使用微信交易号'); } $certPath = $this->appCertPem; $keyPath = $this->appKeyPem; if (empty($certPath)) { throw new PayException('红包接口，必须提供 apiclient_cert.pem 证书'); } if (empty($keyPath)) { throw new PayException('红包接口，必须提供 apiclient_key.pem 证书'); } } } 