为了方便我们所有的逻辑您都按照我下面的走,然后就会都走余额的控制,这样在一个地方写就可以了,然后如果不懂的可以加我微信或手机咨询17854945210
>自提不会走一下逻辑
[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)
```
## 支付宝支付成功走的逻辑
/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) ;
```
- 【11.18更新】人人商城弹出框
- 人人常用方法
- 人人分销【12.13更新】
- 分销走的升级逻辑
- 获取无限上级
- 【12.13更新】获取无限下级
- 统计伞下客户所有业绩
- 关于会员
- 注册走的逻辑
- 会员等级升级
- 关于商品
- 关于小程序
- 人人运费模板逻辑
- 订单创建
- 导入导出
- 导入
- 导出
- 人人快速导出
- 修改收货地址
- 人人客服消息
- 人人商城企业支付到零钱
- 人人商城DIY页面
- 订单【20201210更新】
- 支付逻辑【2020 12月10日更新】
- 订单创建1【20201210更新】
- 订单完成
- 人人权限修复
- 人人权限应用不出来修复
- 微信API
- 获取access_token
- 获取openid
- 修改公众号推送消息
- 问题修复
- 打印机开发
- 拼团
- 订单
- 拼团常用方法
- 余额详细不详细更改
- 修改菜单
- 关于微擎的事务处理逻辑
- 【11.20更新】余额记录不显示前端获得的余额
- BUG集合【2020年12月11日更新】
- 海报黑屏或者出不来
- 人人商城多商户无法上传图片解决办法
- 秒杀超卖解决方案【20210225更新】