notify.php完成你的逻辑,支付逻辑【2020 12月10日更新】

为了方便我们所有的逻辑您都按照我下面的走,然后就会都走余额的控制,这样在一个地方写就可以了,然后如果不懂的可以加我微信或手机咨询18553925869

>自提不会走一下逻辑

[TOC]

## 小程序订单微信支付逻辑

``/ewei_shopv2/payment/wechat/notify.php``

```

/**

* 小程序 订单支付

*/

public function wxapp_order()

{

$tid = $this->get['out_trade_no'];

$transaction_id = $this->get['transaction_id'];

if (strexists($tid, 'GJ')) {

$tids = explode('GJ', $tid);

$tid = $tids[0];

}

$sql = 'SELECT * FROM ' . tablename('core_paylog') . ' WHERE `module`=:module AND `tid`=:tid limit 1';

$params = array();

$params[':tid'] = $tid;

$params[':module'] = 'ewei_shopv2';

$log = pdo_fetch($sql, $params);

if (!empty($log) && $log['status'] == '0' && $log['fee'] == $this->total_fee) {

$site = WeUtility::createModuleSite($log['module']);

if (!is_error($site)) {

$method = 'payResult';

if (method_exists($site, $method)) {

$ret = array();

$ret['acid'] = $log['acid'];

$ret['uniacid'] = $log['uniacid'];

$ret['result'] = 'success';

$ret['type'] = $log['type'];

$ret['from'] = 'return';

$ret['tid'] = $log['tid'];

$ret['user'] = $log['openid'];

$ret['fee'] = $log['fee'];

$ret['tag'] = $log['tag'];

pdo_update('ewei_shop_order', array('paytype' => 21, 'apppay' => 2, 'transid' => $transaction_id), array('ordersn' => $log['tid'], 'uniacid' => $log['uniacid']));

$result = $site->{$method}($ret);

if ($result) {

//----------------------------------------------------------------------------------------订单成功逻辑

//

$log['tag'] = iunserializer($log['tag']);

$log['tag']['transaction_id'] = $this->get['transaction_id'];

$record = array();

$record['status'] = '1';

$record['tag'] = iserializer($log['tag']);

pdo_update('core_paylog', $record, array('plid' => $log['plid']));

}

}

}

}

else {

$this->fail();

}

}

```

## 余额支付成功走的控制器

路径

``/addons/ewei_shopv2/core/model/order.php``

```

public function payResult($params)

```

## 支付宝支付成功走的逻辑

/www/wwwroot/www.doujiao.su/addons/ewei_shopv2/payment/alipay/notify.php

在这个位置,然后走payResult的余额逻辑,所有逻辑写在payResult即可

```

![](https://img.kancloud.cn/d4/da/d4dacd379001929818b8af832bf81656_773x308.png)

/**

* 订单支付

*/

public function order()

{

if (!$this->publicMethod()) {

exit('order');

}

$tid = $this->post['out_trade_no'];

if (strexists($tid, 'GJ')) {

$tids = explode('GJ', $tid);

$tid = $tids[0];

}

$sql = 'SELECT * FROM ' . tablename('core_paylog') . ' WHERE `tid`=:tid and `module`=:module limit 1';

$params = array();

$params[':tid'] = $tid;

$params[':module'] = 'ewei_shopv2';

$log = pdo_fetch($sql, $params);

if (!$this->isapp && $this->post['sign_type'] == 'RSA') {

if ($this->post['total_amount'] != $log['fee']) {

exit('fail');

}

}

else {

$total_fee = $this->post['total_fee'];

if (empty($total_fee)) {

$total_fee = $this->post['total_amount'];

}

if ($total_fee != $log['fee']) {

exit('fail');

}

}

if (!empty($log) && $log['status'] == '0') {

$site = WeUtility::createModuleSite($log['module']);

if (!is_error($site)) {

$method = 'payResult';

if (method_exists($site, $method)) {

$ret = array();

$ret['acid'] = $log['acid'];

$ret['uniacid'] = $log['uniacid'];

$ret['result'] = 'success';

$ret['type'] = 'alipay';

$ret['from'] = 'return';

$ret['tid'] = $log['tid'];

$ret['user'] = $log['openid'];

$ret['fee'] = $log['fee'];

$ret['is_usecard'] = $log['is_usecard'];

$ret['card_type'] = $log['card_type'];

$ret['card_fee'] = $log['card_fee'];

$ret['card_id'] = $log['card_id'];

pdo_update('ewei_shop_order', array('paytype' => 22), array('uniacid' => $log['uniacid'], 'ordersn' => $log['tid']));

$result = $site->{$method}($ret);

if ($result) {

$log['tag'] = iunserializer($log['tag']);

$log['tag']['transid'] = $this->post['trade_no'];

$record = array();

$record['status'] = '1';

$record['type'] = 'alipay';

$record['tag'] = iserializer($log['tag']);

---------------------------------------------------------把这行代码加进去

//这里写逻辑

$pay_result = m('order')->payResult($ret);

---------------------------------------------------------------

pdo_update('core_paylog', $record, array('plid' => $log['plid']));

pdo_update('ewei_shop_order', array('paytype' => 22, 'apppay' => $this->isapp ? 1 : 0, 'transid' => $this->post['trade_no']), array('ordersn' => $log['tid'], 'uniacid' => $log['uniacid']));

exit('success');

}

}

}

}

}

```

## 微信支付成功后走的逻辑 700来行

/www/wwwroot/www.doujiao.su/addons/ewei_shopv2/core/mobile/order/pay.php

```

if ($go_flag == 1) {

$pay_result = true;

-----------------------------------------------把这行代码加进去

$log = pdo_fetch('SELECT * FROM ' . tablename('core_paylog') . ' WHERE `uniacid`=:uniacid AND `module`=:module AND `tid`=:tid limit 1', array(':uniacid' => $uniacid, ':module' => 'ewei_shopv2', ':tid' => $order['ordersn']));

$ret = array();

$ret['result'] = 'success';

$ret['type'] = 'wechat';

$ret['from'] = 'return';

$ret['tid'] = $log['tid'];

$ret['user'] = $order['openid'];

$ret['fee'] = $order['price'];

$ret['weid'] = $_W['uniacid'];

$ret['uniacid'] = $_W['uniacid'];

$pay_result = m('order')->payResult($ret);

-------------------------------------------------------------------------

if ($_W['ispost']) {

$_SESSION[EWEI_SHOPV2_PREFIX . '_order_pay_complete'] = 1;

show_json(1, array('result' => $pay_result));

}

else {

header('location:' . mobileUrl('order/pay/success', array('id' => $order['id'], 'result' => $pay_result)));

exit();

}

}

```

## APP微信支付成功后走的逻辑

**ewei_shopv2/core/mobile/account/app_pay.php**

orderstatus方法里,最后几行,47行左右

```

else

{

//$orderid = intval($_GPC["globe_orderid_"]);

//$app_paytype= intval($_GPC["app_paytype"]);

$ordersn = $_GPC["ordersn"];

$tradeno = $_GPC["tradeno"];

$log = pdo_fetch('SELECT * FROM ' . tablename('core_paylog') . ' WHERE `uniacid`=:uniacid AND `module`=:module AND `tid`=:tid limit 1', array(':uniacid' => $uniacid, ':module' => 'ewei_shopv2', ':tid' => $order['ordersn']));

$ret = array();

$ret['result'] = 'success';

$ret['type'] = 'wechat';

$ret['from'] = 'return';

$ret['tid'] = $log['tid'];

$ret['user'] = $order['openid'];

$ret['fee'] = $order['price'];

$ret['weid'] = $_W['uniacid'];

$ret['uniacid'] = $_W['uniacid'];

$pay_result = m('order')->payResult($ret);

$result=pdo_update("ewei_shop_order", array( "status" =>1,"paytime"=>time(),"paytype" =>$paytype ), array( "ordersn" => $ordersn, "uniacid" => $_W["uniacid"] ));

echo json_encode($result) ;

```

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值