当前位置:   article > 正文

fastadmin epay

fastadmin epay

企业付款到零钱

    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;
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/132109
推荐阅读
相关标签
  

闽ICP备14008679号