赞
踩
企业付款到零钱
protected function transfer($userId,$activity, $money,$type=0) { // $activity = model('app\api\model\redenvelope\Activity')->get(1); $ordersn = model('app\api\model\redenvelope\Transfer')->getOrdersn(); $config = \addons\epay\library\Service::getConfig('wechat'); $openid = ''; $thirdInfo = \addons\third\model\Third::where('user_id', $userId)->where('platform', 'wechat')->where('apptype', 'mp')->find(); $openid = $thirdInfo ? $thirdInfo['openid'] : ''; if(empty($openid)) { return false; } $transfer = \app\api\model\redenvelope\Transfer::create([ 'order_sn' => $ordersn, 'user_id' => $userId, 'publisher_id' => $activity['user_id'], 'activity_id' => $activity['id'], 'type' => $type, 'money' => $money, 'paystate' => 0 ]); $order = [ 'partner_trade_no' => $ordersn, //商户订单号 'openid' => $openid, //收款人的openid 'check_name' => 'NO_CHECK', //NO_CHECK:不校验真实姓名\FORCE_CHECK:强校验真实姓名 // 're_user_name'=>'张三', //check_name为 FORCE_CHECK 校验实名的时候必须提交 'amount' => $money*100, //企业付款金额,单位为分 'desc' => '活动阅读红包', //付款说明 ]; if($type == 1) { $order['desc'] = '活动拓展红包'; } // $pay = \Yansongda\Pay\Pay::wechat($config); // $result = $pay->Transfer($order); $result = [ "return_code"=>"SUCCESS", "return_msg"=>[], "mch_appid"=>"wx28ae16bbb81ecd19", "mchid"=>"1498681322", "nonce_str"=>"uaAPXBPXmQRSmkjE", "result_code"=>"SUCCESS", "partner_trade_no"=>"202108024UvAem6MdNoL", "payment_no"=>"10100949350682108022319953542814", "payment_time"=>"2021-08-02 18:50:40" ]; // 更新记录 if($result['result_code'] == 'SUCCESS') { $transfer->paystate = 1; $transfer->paytime = strtotime($result['payment_time']); $transfer->detailid = $result['payment_no']; $transfer->save(); }else{ return false; } return true; } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。