无为清净楼资源网 Design By www.qnjia.com

应用场景:

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

来看看下面的截图

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

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

微信支付配置

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实现财务审核通过后返现金额到客户的功能,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!

标签:
php,财务审核,php,返现金额到客户

无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com

《魔兽世界》大逃杀!60人新游玩模式《强袭风暴》3月21日上线

暴雪近日发布了《魔兽世界》10.2.6 更新内容,新游玩模式《强袭风暴》即将于3月21 日在亚服上线,届时玩家将前往阿拉希高地展开一场 60 人大逃杀对战。

艾泽拉斯的冒险者已经征服了艾泽拉斯的大地及遥远的彼岸。他们在对抗世界上最致命的敌人时展现出过人的手腕,并且成功阻止终结宇宙等级的威胁。当他们在为即将于《魔兽世界》资料片《地心之战》中来袭的萨拉塔斯势力做战斗准备时,他们还需要在熟悉的阿拉希高地面对一个全新的敌人──那就是彼此。在《巨龙崛起》10.2.6 更新的《强袭风暴》中,玩家将会进入一个全新的海盗主题大逃杀式限时活动,其中包含极高的风险和史诗级的奖励。

《强袭风暴》不是普通的战场,作为一个独立于主游戏之外的活动,玩家可以用大逃杀的风格来体验《魔兽世界》,不分职业、不分装备(除了你在赛局中捡到的),光是技巧和战略的强弱之分就能决定出谁才是能坚持到最后的赢家。本次活动将会开放单人和双人模式,玩家在加入海盗主题的预赛大厅区域前,可以从强袭风暴角色画面新增好友。游玩游戏将可以累计名望轨迹,《巨龙崛起》和《魔兽世界:巫妖王之怒 经典版》的玩家都可以获得奖励。