初始上传
This commit is contained in:
48
addon/wechatpay/event/AuthcodePay.php
Executable file
48
addon/wechatpay/event/AuthcodePay.php
Executable file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
// +---------------------------------------------------------------------+
|
||||
// | NiuCloud | [ WE CAN DO IT JUST NiuCloud ] |
|
||||
// +---------------------------------------------------------------------+
|
||||
// | Copy right 2019-2029 www.niucloud.com |
|
||||
// +---------------------------------------------------------------------+
|
||||
// | Author | NiuCloud <niucloud@outlook.com> |
|
||||
// +---------------------------------------------------------------------+
|
||||
// | Repository | https://github.com/niucloud/framework.git |
|
||||
// +---------------------------------------------------------------------+
|
||||
|
||||
namespace addon\wechatpay\event;
|
||||
|
||||
use addon\wechatpay\model\Pay as PayModel;
|
||||
use app\model\system\Pay as PayCommon;
|
||||
|
||||
/**
|
||||
* 支付回调
|
||||
*/
|
||||
class AuthcodePay
|
||||
{
|
||||
/**
|
||||
* 支付方式及配置
|
||||
*/
|
||||
public function handle($params)
|
||||
{
|
||||
$out_trade_no = $params[ 'out_trade_no' ] ?? '';
|
||||
$auth_code_array = [ 10, 11, 12, 13, 14, 15 ];
|
||||
if (!empty($out_trade_no)) {
|
||||
$auth_code = $params[ 'auth_code' ];
|
||||
$sub_str = substr($auth_code, 0, 2);
|
||||
if (in_array($sub_str, $auth_code_array)) {
|
||||
$pay = new PayCommon();
|
||||
$pay_info = $pay->getPayInfo($out_trade_no)[ 'data' ] ?? [];
|
||||
if (!empty($pay_info)) {
|
||||
$site_id = $pay_info[ 'site_id' ] ?? 0;
|
||||
$pay_model = new PayModel(0, $site_id);
|
||||
|
||||
$result = $pay_model->micropay(array_merge($params, $pay_info));
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
25
addon/wechatpay/event/Install.php
Executable file
25
addon/wechatpay/event/Install.php
Executable file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\wechatpay\event;
|
||||
|
||||
/**
|
||||
* 应用安装
|
||||
*/
|
||||
class Install
|
||||
{
|
||||
/**
|
||||
* 执行安装
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return success();
|
||||
}
|
||||
}
|
||||
56
addon/wechatpay/event/Pay.php
Executable file
56
addon/wechatpay/event/Pay.php
Executable file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\wechatpay\event;
|
||||
|
||||
use addon\wechatpay\model\Pay as PayModel;
|
||||
|
||||
/**
|
||||
* 生成支付
|
||||
*/
|
||||
class Pay
|
||||
{
|
||||
/**
|
||||
* 支付
|
||||
*/
|
||||
public function handle($params)
|
||||
{
|
||||
if ($params[ "pay_type" ] == "wechatpay") {
|
||||
|
||||
$app_type = $params[ 'app_type' ];
|
||||
$is_weapp = 0;
|
||||
switch ( $app_type ) {
|
||||
case 'h5' :
|
||||
$trade_type = "MWEB";
|
||||
break;
|
||||
case 'wechat' :
|
||||
$trade_type = "JSAPI";
|
||||
break;
|
||||
case 'weapp' :
|
||||
$is_weapp = 1;
|
||||
$trade_type = "APPLET";
|
||||
break;
|
||||
case 'app' :
|
||||
$trade_type = "APP";
|
||||
break;
|
||||
case 'pc' :
|
||||
$trade_type = "NATIVE";
|
||||
break;
|
||||
case 'cashier':
|
||||
$trade_type = "NATIVE";
|
||||
break;
|
||||
}
|
||||
$params[ "trade_type" ] = $trade_type;
|
||||
$pay_model = new PayModel($is_weapp, $params[ 'site_id' ]);
|
||||
$result = $pay_model->pay($params);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
42
addon/wechatpay/event/PayClose.php
Executable file
42
addon/wechatpay/event/PayClose.php
Executable file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\wechatpay\event;
|
||||
|
||||
use addon\wechatpay\model\Pay as PayModel;
|
||||
|
||||
/**
|
||||
* 关闭支付
|
||||
*/
|
||||
class PayClose
|
||||
{
|
||||
/**
|
||||
* 关闭支付
|
||||
* @param $params
|
||||
* @return array
|
||||
*/
|
||||
public function handle($params)
|
||||
{
|
||||
$mch_info = json_decode($params['mch_info'], true);
|
||||
$pay_type = $mch_info['pay_type'] ?? '';
|
||||
$is_weapp = $mch_info['is_weapp'] ?? 0;
|
||||
if($pay_type == 'wechatpay'){
|
||||
try {
|
||||
$pay_model = new PayModel($is_weapp, $params[ 'site_id' ]);
|
||||
$result = $pay_model->close($params);
|
||||
return $result;
|
||||
} catch (\Exception $e) {
|
||||
return error(-1, $e->getMessage());
|
||||
} catch (\Throwable $e) {
|
||||
return error(-1, $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
31
addon/wechatpay/event/PayNotify.php
Executable file
31
addon/wechatpay/event/PayNotify.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\wechatpay\event;
|
||||
|
||||
use addon\wechatpay\model\Pay as PayModel;
|
||||
use think\facade\Log;
|
||||
|
||||
/**
|
||||
* 支付回调
|
||||
*/
|
||||
class PayNotify
|
||||
{
|
||||
/**
|
||||
* 支付方式及配置
|
||||
*/
|
||||
public function handle($param)
|
||||
{
|
||||
$reqData = empty($GLOBALS[ 'HTTP_RAW_POST_DATA' ]) ? file_get_contents('php://input') : $GLOBALS[ 'HTTP_RAW_POST_DATA' ];
|
||||
Log::write('微信支付回调数据');
|
||||
Log::write($reqData);
|
||||
return ( new PayModel() )->payNotify();
|
||||
}
|
||||
}
|
||||
47
addon/wechatpay/event/PayOrderQuery.php
Executable file
47
addon/wechatpay/event/PayOrderQuery.php
Executable file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\wechatpay\event;
|
||||
|
||||
use addon\wechat\model\Config as WechatConfig;
|
||||
use addon\wechatpay\model\Config;
|
||||
use addon\wechatpay\model\Pay as PayModel;
|
||||
use addon\wechatpay\model\V2;
|
||||
use app\model\system\Pay;
|
||||
|
||||
/**
|
||||
* 查询支付结果
|
||||
*/
|
||||
class PayOrderQuery
|
||||
{
|
||||
public function handle(array $params)
|
||||
{
|
||||
try {
|
||||
$res = success();
|
||||
$pay_info = ( new Pay() )->getInfo([ [ 'id', '=', $params[ 'relate_id' ] ]])[ 'data' ];
|
||||
if (!empty($pay_info) && $pay_info['is_delete'] == 0) {
|
||||
$mch_info = json_decode($pay_info['mch_info'], true);
|
||||
$pay_type = $mch_info['pay_type'] ?? 'wechatpay';
|
||||
if($pay_type == 'wechatpay'){
|
||||
$pay_config = ( new Config() )->getPayConfig($pay_info[ 'site_id' ])[ 'data' ][ 'value' ];
|
||||
$wechat_config = ( new WechatConfig() )->getWechatConfig($pay_info[ 'site_id' ])[ 'data' ][ 'value' ];
|
||||
$pay_config[ 'appid' ] = $wechat_config[ 'appid' ] ?? '';
|
||||
if (!empty($pay_config) && $pay_config[ 'pay_status' ] == 1) {
|
||||
$res = ( new V2($pay_config) )->orderQuery($pay_info);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
}catch (\Throwable $e) {
|
||||
return error(-1, $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
47
addon/wechatpay/event/PayRefund.php
Executable file
47
addon/wechatpay/event/PayRefund.php
Executable file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\wechatpay\event;
|
||||
|
||||
use addon\wechatpay\model\Pay as PayModel;
|
||||
use addon\shopcomponent\model\Weapp;
|
||||
|
||||
/**
|
||||
* 原路退款
|
||||
*/
|
||||
class PayRefund
|
||||
{
|
||||
/**
|
||||
* 原路退款
|
||||
*/
|
||||
public function handle($params)
|
||||
{
|
||||
if ($params[ "pay_info" ][ "pay_type" ] == "wechatpay") {
|
||||
|
||||
if ($params[ 'is_video_number' ] == 1) {
|
||||
$weapp_model = new Weapp($params[ 'site_id' ]);
|
||||
$refund_params = [
|
||||
"out_aftersale_id" => $params[ 'out_aftersale_id' ]
|
||||
];
|
||||
$info = $weapp_model->getAftersale($refund_params);
|
||||
if ($info[ 'code' ] == 0 && !empty($info[ 'data' ])) {
|
||||
$result = $weapp_model->orderRefund($refund_params);
|
||||
} else {
|
||||
$pay_model = new PayModel(0, $params[ 'site_id' ]);
|
||||
$result = $pay_model->refund($params);
|
||||
}
|
||||
} else {
|
||||
$pay_model = new PayModel(0, $params[ 'site_id' ]);
|
||||
$result = $pay_model->refund($params);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
33
addon/wechatpay/event/PayTransfer.php
Executable file
33
addon/wechatpay/event/PayTransfer.php
Executable file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\wechatpay\event;
|
||||
|
||||
use addon\wechatpay\model\Pay;
|
||||
|
||||
class PayTransfer
|
||||
{
|
||||
public function handle(array $params)
|
||||
{
|
||||
if ($params[ 'transfer_type' ] == 'wechatpay') {
|
||||
//TODO 本地测试流程
|
||||
// if(request()->ip() == '127.0.0.1'){
|
||||
// $pay_transfer_model = new \app\model\system\PayTransfer();
|
||||
// return $pay_transfer_model->success([
|
||||
// 'status' => $pay_transfer_model::STATUS_IN_PROCESS,
|
||||
// ]);
|
||||
// }
|
||||
$is_weapp = $params[ 'is_weapp' ] ?? 0;
|
||||
$pay = new Pay($is_weapp, $params[ 'site_id' ]);
|
||||
$res = $pay->transfer($params);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
}
|
||||
31
addon/wechatpay/event/PayTransferResult.php
Executable file
31
addon/wechatpay/event/PayTransferResult.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
namespace addon\wechatpay\event;
|
||||
|
||||
use addon\wechatpay\model\Config;
|
||||
use addon\wechatpay\model\V3;
|
||||
use app\model\member\Withdraw;
|
||||
|
||||
class PayTransferResult
|
||||
{
|
||||
public function handle($params)
|
||||
{
|
||||
//TODO 本地测试流程
|
||||
// if(request()->ip() == '127.0.0.1'){
|
||||
// $pay_transfer_model = new \app\model\system\PayTransfer();
|
||||
// /*return $pay_transfer_model->success([
|
||||
// 'status' => $pay_transfer_model::STATUS_SUCCESS,
|
||||
// ]);*/
|
||||
// /*return $pay_transfer_model->success([
|
||||
// 'status' => $pay_transfer_model::STATUS_FAIL,
|
||||
// 'fail_reason' => '用户姓名校验失败',
|
||||
// 'fail_code' => 'NAME_NOT_CORRECT',
|
||||
// ]);*/
|
||||
// }
|
||||
$pay_config = (new Config())->getPayConfig($params['site_id'])['data']['value'];
|
||||
$pay_config['site_id'] = $params['site_id'];
|
||||
if (!empty($pay_config) && $pay_config['transfer_v3_type'] == Config::TRANSFER_V3_TYPE_SHOP) {
|
||||
return (new V3($pay_config))->getTransferResult($params);
|
||||
}
|
||||
return (new V3($pay_config))->success();
|
||||
}
|
||||
}
|
||||
52
addon/wechatpay/event/PayType.php
Executable file
52
addon/wechatpay/event/PayType.php
Executable file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\wechatpay\event;
|
||||
|
||||
use addon\wechatpay\model\Config;
|
||||
|
||||
/**
|
||||
* 支付方式 (前后台调用)
|
||||
*/
|
||||
class PayType
|
||||
{
|
||||
/**
|
||||
* 支付方式及配置
|
||||
*/
|
||||
public function handle($params)
|
||||
{
|
||||
$config_model = new Config();
|
||||
$config_result = $config_model->getPayConfig($params[ 'site_id' ] ?? 1);
|
||||
$config = $config_result[ "data" ][ "value" ] ?? [];
|
||||
$pay_status = $config[ "pay_status" ] ?? 0;
|
||||
|
||||
$app_type = $params['app_type'] ?? '';
|
||||
if (!empty($app_type)) {
|
||||
$app_type_array = [ 'h5', 'wechat', 'weapp', 'pc' ];
|
||||
if (!in_array($app_type, $app_type_array)) {
|
||||
return '';
|
||||
}
|
||||
if ($pay_status == 0) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
$info = array (
|
||||
"pay_type" => "wechatpay",
|
||||
"pay_type_name" => "微信支付",
|
||||
"edit_url" => "wechatpay://shop/pay/config",
|
||||
"shop_url" => "wechatpay://shop/pay/config",
|
||||
"logo" => "addon/wechatpay/icon.png",
|
||||
"desc" => "微信支付,用户通过扫描二维码、微信内打开商品页面购买等多种方式调起微信支付模块完成支付。",
|
||||
"pay_status" => $pay_status,
|
||||
);
|
||||
return $info;
|
||||
|
||||
}
|
||||
}
|
||||
43
addon/wechatpay/event/TransferType.php
Executable file
43
addon/wechatpay/event/TransferType.php
Executable file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\wechatpay\event;
|
||||
|
||||
use addon\wechatpay\model\Config;
|
||||
|
||||
/**
|
||||
* 转账方式 (前后台调用)
|
||||
*/
|
||||
class TransferType
|
||||
{
|
||||
public function handle($params)
|
||||
{
|
||||
$app_type = $params['app_type'] ?? '';
|
||||
if (!empty($app_type)) {
|
||||
$config_model = new Config();
|
||||
$app_type_array = $config_model->app_type;
|
||||
if (!in_array($app_type, $app_type_array)) {
|
||||
return '';
|
||||
}
|
||||
$config_result = $config_model->getPayConfig($params[ 'site_id' ]);
|
||||
$config = $config_result[ "data" ][ "value" ] ?? [];
|
||||
$transfer_status = $config[ "transfer_status" ] ?? 0;
|
||||
if ($transfer_status == 0) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
$info = array (
|
||||
"type" => "wechatpay",
|
||||
"type_name" => "微信零钱",
|
||||
);
|
||||
return $info;
|
||||
|
||||
}
|
||||
}
|
||||
25
addon/wechatpay/event/UnInstall.php
Executable file
25
addon/wechatpay/event/UnInstall.php
Executable file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\wechatpay\event;
|
||||
|
||||
/**
|
||||
* 应用卸载
|
||||
*/
|
||||
class UnInstall
|
||||
{
|
||||
/**
|
||||
* 执行卸载
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return success();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user