Skip to content

Commit

Permalink
[更新]完善现金红包接口
Browse files Browse the repository at this point in the history
  • Loading branch information
zoujingli committed Apr 12, 2017
1 parent e04062d commit eb8ee1a
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions Wechat/WechatPay.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ public function queryOrder($out_trade_no) {
return $result;
}

/**
/**
* 订单退款接口
* @param string $out_trade_no 商户订单号
* @param string $transaction_id 微信订单号
Expand Down Expand Up @@ -350,35 +350,50 @@ public function getBill($bill_date, $bill_type = 'ALL') {
/**
* 发送现金红包
* @param string $openid 红包接收者OPENID
* @param int $amount 红包总金额
* @param string $billno 商户订单号
* @param int $total_amount 红包总金额
* @param string $mch_billno 商户订单号
* @param string $sendname 商户名称
* @param string $wishing 红包祝福语
* @param string $actname 活动名称
* @param string $act_name 活动名称
* @param string $remark 备注信息
* @return bool|array
* @param null|int $total_num 红包发放总人数(大于1为裂变红包)
* @param null|string $scene_id 场景id
* @param string $risk_info 活动信息
* @param null|string $consume_mch_id 资金授权商户号
* @return array|bool
* @link https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_5
*/
public function sendRedPack($openid, $amount, $billno, $sendname, $wishing, $actname, $remark) {
public function sendRedPack($openid, $total_amount, $mch_billno, $sendname, $wishing, $act_name, $remark, $total_num = 1, $scene_id = null, $risk_info = '', $consume_mch_id = null) {
$data = array();
$data['mch_billno'] = $billno; // 商户订单号 mch_id+yyyymmdd+10位一天内不能重复的数字
$data['mch_billno'] = $mch_billno; // 商户订单号 mch_id+yyyymmdd+10位一天内不能重复的数字
$data['wxappid'] = $this->appid;
$data['send_name'] = $sendname; //商户名称
$data['re_openid'] = $openid; //红包接收者
$data['total_amount'] = $amount; //红包金额
$data['total_amount'] = $total_amount; //红包总金额
$data['total_num'] = '1'; //发放人数据
$data['wishing'] = $wishing; //红包祝福语
$data['client_ip'] = Tools::getAddress(); //调用接口的机器Ip地址
$data['act_name'] = $actname; //活动名称
$data['act_name'] = $act_name; //活动名称
$data['remark'] = $remark; //备注信息
$result = $this->postXmlSSL($data, self::MCH_BASE_URL . '/mmpaymkttransfers/sendredpack');
$data['total_num'] = $total_num;
!empty($scene_id) && $data['scene_id'] = $scene_id;
!empty($risk_info) && $data['risk_info'] = $risk_info;
!empty($consume_mch_id) && $data['consume_mch_id'] = $consume_mch_id;
if ($total_num > 1) {
$data['amt_type'] = 'ALL_RAND';
$api = self::MCH_BASE_URL . '/mmpaymkttransfers/sendgroupredpack';
} else {
$api = self::MCH_BASE_URL . '/mmpaymkttransfers/sendredpack';
}
$result = $this->postXmlSSL($data, $api);
$json = Tools::xml2arr($result);
if (!empty($json) && false === $this->_parseResult($json)) {
return false;
}
return $json;
}


/**
* 现金红包状态查询
* @param string $billno
Expand Down

0 comments on commit eb8ee1a

Please sign in to comment.