应用场景:
有这么一个返现的系统,当前端客户发起提现的时候,后端就要通过审核这笔返现订单,才可以返现到客户的账号里。
来看看下面的截图
这里的业务场景就是经过两轮审核:销售审核,财务审核都通过后,后端就会付款一笔钱到客户,当然,这里财务审核会有很多种情况,不通过与通过,通过后直接付款又有很多种情况,详细可以查看微信付款到零钱的文档。下面就来看看具体你的代码实现
微信支付配置
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, `appsecret` 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 CHARSET=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 = WeixinConfigBaseModel::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']) "htmlcode">/** * 获取微信支付配置 * 这里我是把配置信息存储在数据表里,方便调用 * $param是从controller里传值过来:weixin_config_id,notify_url * @return array */ public function getWechatConfig($param) { $weixin = WeixinConfigBaseModel::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']) "htmlcode">//财务审核 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->insertWithdrawLog($param['withdraw_id'], $business->status, $business->audit_status, $param['rebate_remark'], $param['admin_id']); }else{ //提现的各种返回结果 $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 PayLogBaseService(); $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'].")"; }elseif ($res['err_code'] == "MONEY_LIMIT"){ $business->audit_status = 3; $business->status = 3; $param['rebate_remark'] = "提现失败,已达到付款给此用户额度上限"; //throw new \Exception($param['rebate_remark']); }elseif ($res['err_code'] == "AMOUNT_LIMIT"){ $business->audit_status = 3; $business->status = 3; $param['rebate_remark'] = "提现失败,低于最低付款金额或者高于最高付款金额"; //throw new \Exception($param['rebate_remark']); egdf }elseif ($res['err_code'] == "NOTENOUGH"){ $business->audit_status = 3; $business->status = 3; $param['rebate_remark'] = "提现失败,付款帐号余额不足或资金未到账"; //throw new \Exception($param['rebate_remark']); }elseif ($res['err_code'] == "SIGN_ERROR"){ $business->audit_status = 3; $business->status = 3; $param['rebate_remark'] = "提现失败,签名错误"; }elseif ($res['err_code'] == "PARAM_ERROR"){ $business->audit_status = 3; $business->status = 3; $param['rebate_remark'] = "提现失败,参数错误"; }elseif ($res['err_code'] == "OPENID_ERROR"){ $business->audit_status = 3; $business->status = 3; $param['rebate_remark'] = "提现失败,Openid错误"; }elseif ($res['err_code'] == "FATAL_ERROR"){ $business->audit_status = 3; $business->status = 3; $param['rebate_remark'] = "提现失败,两次请求参数不一致"; }elseif ($res['err_code'] == "CA_ERROR"){ $business->audit_status = 3; $business->status = 3; $param['rebate_remark'] = "提现失败,商户API证书校验出错"; }elseif ($res['err_code'] == "V2_ACCOUNT_SIMPLE_BAN"){ $business->audit_status = 3; $business->status = 3; $param['rebate_remark'] = "提现失败,无法给非实名用户付款"; }else{ $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 = GroupBusinessWithdrawBaseModel::find($param['withdraw_id']); if(empty($business)){ throw new \Exception("不存在!"); } if($business->audit_status != 3){ throw new \Exception("状态有错误"); } //提现的各种返回结果 $this->payReturnResult($business,$param); }总结
以上所述是小编给大家介绍的PHP实现财务审核通过后返现金额到客户的功能,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com
暂无“PHP实现财务审核通过后返现金额到客户的功能”评论...
稳了!魔兽国服回归的3条重磅消息!官宣时间再确认!
昨天有一位朋友在大神群里分享,自己亚服账号被封号之后居然弹出了国服的封号信息对话框。
这里面让他访问的是一个国服的战网网址,com.cn和后面的zh都非常明白地表明这就是国服战网。
而他在复制这个网址并且进行登录之后,确实是网易的网址,也就是我们熟悉的停服之后国服发布的暴雪游戏产品运营到期开放退款的说明。这是一件比较奇怪的事情,因为以前都没有出现这样的情况,现在突然提示跳转到国服战网的网址,是不是说明了简体中文客户端已经开始进行更新了呢?