首页 > 作文

PHP实现财务审核通过后返现金额到客户的功能

更新时间:2023-04-07 15:02:32 阅读: 评论:0

应用场景:

有这么一个返现的系统,当前端客户发起提现的时候,后端就要通过审核这笔返现订单,才可以返现到客户的账号里。

来看看下面的截图

这里的业务场景就是经过两轮审核:销售审核,财务审核都通过后,后端就会付款一笔钱到客户,当然,这里财务审核会有很多种情况,不通过与通过,通过后直接付款又有很多种情况,详细可以查看微信付款到零钱的文档。下面就来看看具体你的代码实现

微信支付配置

1,数据表大概如下

create table `zmq_weixin_config` ( `id` int(1) unsigned not null auto_increment comment '微信公众平台编号,自增id', `weixin_name` varchar(10) not null comment '微信公众平台名称', `token` varchar(100) not null, `appid` char(18) not null, `appcret` char(32) not null, `access_token` varchar(300) not null, `api_ticket` varchar(300) default null comment '微信卡包api_ticket', `api_ticket_expired_at` datetime default null comment '微信卡包api_ticket过期时间', `mchid` varchar(20) default null comment '商户号', `mchkey` varchar(50) default null comment '支付密钥', `expired_at` timestamp null default null comment 'access_token过期时间,会自动更新', `updated_at` timestamp null default null comment '记录更新时间', `created_at` timestamp null default null comment '创建时间', `sort_order` smallint(5) not null default '0' comment '排序', `points_url` varchar(100) default null, primary key (`id`)) engine=myisam auto_increment=11 default chart=utf8 checksum=1 delay_key_write=1 row_format=dynamic comment='微信配置表';

2 .config的配置方法

/** * 获取微信支付配置 * 这里我是把配置信息存储在数据表里,方便调用 * $param是从controller里传值过来:weixin_config_id,notify_url * @return array */public function getwechatconfig($param){  $weixin = weixinconfigbamodel::find($param['weixin_config_id']);  if (empty($weixin)) {    throw new exception('微信配置id错误');  }  return [    'wechat' =>[      $app_id => $weixin->appid,      'mch_id' => $weixin->mchid,      'notif肤色不均是什么原因y_url' => empty($param['notify_url']) ? '' : $param['notify_url'], //回调url      'key' => $weixin->mchkey,      'cert_client' => resource_path().'/wechat/'.$weixin->id.'/apiclient_cert.pem', //证书与key      'cert_key' => resource_path().'/wechat/'.$weixin->id.'/apiclient_key.pem',    ]  ];}

企业付款到个杳无音信怎么读人零钱核心代码

/** * 获取微信支付配置 * 这里我是把配置信息存储在数据表里,方便调用 学期计划* $param是从controller里传值过来:weixin_config_id,notify_url * @return array */public function getwechatconfig($param){  $weixin = weixinconfigbamodel::find($param['weixin_config_id']);  if (empty($weixin)) {    throw new exception('微信配置id错误');  }  return [    'wechat' =>[      $app_id => $weixin->appid,      'mch_id' => $weixin->mchid,      'notify_url' => empty($param['notify_url']) ? '' : $param['notify_url'], //回调url      'key' => $weixin->mchkey,      'cert_client' => resource_path().'/wechat/'.$weixin->id.'/apiclient_cert.pem', //证书与key      'cert_key' => resource_path().'/wechat/'.$weixin->id.'/apiclient_key.pem',    ]  ];}

财务审核,也就是微信返现到零钱,这个时候会返回成功结果,或者是各种不成功的结果

这里我用一个方法封装

//财务审核if($param['status'] == 2){  //判断返现金额与修改后的金额  if($before_rebate_amount != $param['rebate_amount']){    //返现金额不相等,则出款金额改变    $out_amount = $param['rebate_amount'] - $before_rebate_amount ;    $this->outmount($business->business_id,$out_amount);  }  if($param['rebate_status'] == 9){    //财务拒绝通过    $business->audit_status = $param['rebate_status'];    $business->rebate_amount = $param['rebate_amount'];    $business->status = 6;    $business->save();    //生成日志    $this->inrtwithdrawlog($param['withdraw_id'], $business->status, $business->audit_status, $param['rebate_remark'], $param['admin_id']);  }el{    //提现的各种返回结果    $this->payreturnresult($business,$param);  }}
/** * function:微信提现返回的各种结果 * author:cyw0413 * @param $res * @param $business * @param $param */public function payreturnresult($business,$param){  $input = [    'weixin_config_id' => 20 ,    'openid'      => $business->business->open_id,    'amount'      => $param['rebate_amount'] * 100,    'trade_no'     => $business->order_sn, //商户订单号    'desc'       => "微信提现"  ];  $pay = new paylogbarvice();  $res = $pay->weixinpay($input);  if($res['result_code']=="success"){    //提现成功    $business->audit_status = 4;    $business->status = 4;    $business->rebate_amount = $param['rebate_amount'];    $param['rebate_remark'] = "已付款(".$param['rebate_amount'].")";上海场地出租  }elif ($res['err_code'] == "money_limit"){    $business->audit_status = 3;    $business->status = 3;    $param['rebate_remark'] = "提现失败,已达到付款给此用户额度上限";    //throw new \exception($param['rebate_remark']);  }elif ($res['err_code'] == "amount_limit"){    $business->audit_status = 3;    $business->status = 3;    $param['rebate_remark'] = "提现失败,低于最低付款金额或者高于最高付款金额";    //throw new \exception($param['rebate_remark']);egdf  }elif ($res['err_code'] == "notenough"){    $business->audit_status = 3;    $business->status = 3;    $param['rebate_remark'] = "提现失败,付款帐号余额不足或资金未到账";    //throw new \exception($param['rebate_remark']);  }elif ($res['err_code'] == "sign_error"){    $business->audit_status = 3;    $business->status = 3;    $param['rebate_remark'] = "提现失败,签名错误";  }elif ($res['err_code'] == "param_error"){    $business->audit_status = 3冬天吃什么;    $business->status = 3;    $param['rebate_remark'] = "提现失败,参数错误";  }elif ($res['err_code'] == "openid_error"){    $business->audit_status = 3;    $business->status = 3;    $param['rebate_remark'] = "提现失败,openid错误";  }elif ($res['err_code'] == "fatal_error"){    $business->audit_status = 3;    $business->status = 3;    $param['rebate_remark'] = "提现失败,两次请求参数不一致";  }elif ($res['err_code'] == "ca_error"){    $business->audit_status = 3;    $business->status = 3;    $param['rebate_remark'] = "提现失败,商户api证书校验出错";  }elif ($res['err_code'] == "v2_account_simple_ban"){    $business->audit_status = 3;    $business->status = 3;    $param['rebate_remark'] = "提现失败,无法给非实名用户付款";  }el{    $business->audit_status = 3;    $business->status = 3;    $param['rebate_remark'] = "提现失败,服务器繁忙,请稍后再试";    //throw new \exception($param['rebate_remark']);  }  $business->save();}

当微信平台余额不足或者出现各种错误而提现失败的时候,这里还有支持重新付款的功能:其实就是点击按钮后重新调用付款到零钱的功能,知道成功付款

/** * function:重新付款 * author:cyw0413 * @param $param * @throws \exception */public function repay($param){  if(empty($param)){    throw new \exception("参数错误");  }  $business = groupbusinesswithdrawbamodel::find($param['withdraw_id']);  if(empty($business)){    throw new \exception("不存在!");  }  if($business->audit_status != 3){    throw new \exception("状态有错误");  }  //提现的各种返回结果  $this->payreturnresult($business,$param);}

总结

以上所述是www.887551.com给大家介绍的php实现财务审核通过后返现金额到客户的功能,希望对大家有所帮助

本文发布于:2023-04-07 15:02:30,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/zuowen/b2fc32202b3a27de6011e1758ba8b551.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

本文word下载地址:PHP实现财务审核通过后返现金额到客户的功能.doc

本文 PDF 下载地址:PHP实现财务审核通过后返现金额到客户的功能.pdf

标签:错误   零钱   财务   金额
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图