You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.5 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php
namespace tencent\wechat\pay;
use EasyWeChat\Factory;
use think\Request;
class Redpack extends Base
{
/**
* 发放红包
* @param string $openid 用户openid
* @param double $money 企业付款金额
* @param string $order_number 订单号
* @param string $act_name 活动名称
* @param string $remark 备注信息
* @param string $send_name 红包发送者名称
* @param string $wishing 红包祝福语
* @param string $scene_id 发放红包使用场景红包金额大于200或者小于1元时必传 PRODUCT_1:商品促销PRODUCT_2:抽奖PRODUCT_3:虚拟物品兑奖PRODUCT_4:企业内部福利PRODUCT_5:渠道分润PRODUCT_6:保险回馈PRODUCT_7:彩票派奖PRODUCT_8:税务刮奖
* @date 2022-11-04
*/
public function sendNorMalRedpack($openid, $money, $order_number, $act_name = '红包活动', $remark = '红包', $send_name = '平台', $wishing = '恭喜获得一个红包', $scene_id = '')
{
$payment = Factory::payment($this->wxpayConfig);
$data = [
// 商户订单号
'mch_billno' => $order_number,
// 红包发送者名称
'send_name' => $send_name,
// 接受红包的用户openid
're_openid' => $openid,
// 红包发放总人数固定为1
'total_num' => 1,
// 付款金额,单位分
'total_amount' => (int)($money * 100),
// 红包祝福语
'wishing' => $wishing,
// 可不传,不传则由 SDK 取当前客户端 IP
// 'client_ip' => getClientIp(),
// 活动名称
'act_name' => $act_name,
// 备注信息
'remark' => $remark
];
if (!empty($scene_id)) {
$data['scene_id'] = $scene_id;
}
$result = $payment->redpack->sendNormal($data);
// 记录日志
$uid = defined('UID') ? UID : '';
platformLog($data, $result, 'easywechat_wxpay_send_normal_redpack_uid_' . $uid);
return $result;
}
/**
* 查询红包信息
* @param string $order_number 订单号
* @date 2022-11-04
*/
public function queryRedpack($order_number)
{
$payment = Factory::payment($this->wxpayConfig);
$result = $payment->redpack->info($order_number);
// 记录日志
$uid = defined('UID') ? UID : '';
platformLog($order_number, $result, 'easywechat_wxpay_query_redpack_uid_' . $uid);
return $result;
}
}