初始上传
This commit is contained in:
38
addon/alioss/config/diy_view.php
Executable file
38
addon/alioss/config/diy_view.php
Executable file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
return [
|
||||
|
||||
// 自定义模板页面类型,格式:[ 'title' => '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
|
||||
'template' => [],
|
||||
|
||||
// 后台自定义组件——装修
|
||||
'util' => [],
|
||||
|
||||
// 自定义页面路径
|
||||
'link' => [],
|
||||
|
||||
// 自定义图标库
|
||||
'icon_library' => [],
|
||||
|
||||
// uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件
|
||||
'component' => [],
|
||||
|
||||
// uni-app 页面,多个逗号隔开
|
||||
'pages' => [],
|
||||
|
||||
// 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述'
|
||||
'info' => [],
|
||||
|
||||
// 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】
|
||||
'theme' => [],
|
||||
|
||||
// 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ]
|
||||
'data' => []
|
||||
];
|
||||
30
addon/alioss/config/event.php
Executable file
30
addon/alioss/config/event.php
Executable file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
// 事件定义文件
|
||||
return [
|
||||
'bind' => [
|
||||
|
||||
],
|
||||
|
||||
'listen' => [
|
||||
//短信方式
|
||||
'OssType' => [
|
||||
'addon\alioss\event\OssType'
|
||||
],
|
||||
'Put' => [
|
||||
'addon\alioss\event\Put'
|
||||
],
|
||||
'CloseOss' => [
|
||||
'addon\alioss\event\CloseOss'
|
||||
],
|
||||
'ClearAlbumPic' => [
|
||||
'addon\alioss\event\ClearAlbumPic'
|
||||
],
|
||||
// 展示活动
|
||||
'ShowPromotion' => [
|
||||
'addon\alioss\event\ShowPromotion',
|
||||
],
|
||||
],
|
||||
|
||||
'subscribe' => [
|
||||
],
|
||||
];
|
||||
21
addon/alioss/config/info.php
Executable file
21
addon/alioss/config/info.php
Executable file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
return [
|
||||
'name' => 'alioss',
|
||||
'title' => '阿里云OSS',
|
||||
'description' => '阿里云OSS',
|
||||
'type' => 'system', //插件类型 system :系统插件(自动安装), business:业务插件 promotion:营销插件 tool:工具插件
|
||||
'status' => 1,
|
||||
'author' => '',
|
||||
'version' => '5.5.3',
|
||||
'version_no' => '553250709001',
|
||||
'content' => '',
|
||||
];
|
||||
19
addon/alioss/config/menu_shop.php
Executable file
19
addon/alioss/config/menu_shop.php
Executable file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 平台端菜单设置
|
||||
// +----------------------------------------------------------------------
|
||||
return [
|
||||
[
|
||||
'name' => 'ALIOSS_CONFIG',
|
||||
'title' => '阿里云OSS上传配置',
|
||||
'url' => 'alioss://shop/config/config',
|
||||
'parent' => 'UPLOAD_OSS',
|
||||
'is_show' => 0,
|
||||
'is_control' => 1,
|
||||
'is_icon' => 0,
|
||||
'picture' => '',
|
||||
'picture_select' => '',
|
||||
'sort' => 1,
|
||||
'type' => 'button',
|
||||
],
|
||||
];
|
||||
39
addon/alioss/event/ClearAlbumPic.php
Executable file
39
addon/alioss/event/ClearAlbumPic.php
Executable file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\alioss\event;
|
||||
|
||||
use addon\alioss\model\Alioss;
|
||||
use addon\alioss\model\Config;
|
||||
|
||||
/**
|
||||
* 删除阿里云图片
|
||||
*/
|
||||
class ClearAlbumPic
|
||||
{
|
||||
public function handle($params)
|
||||
{
|
||||
$config_model = new Config();
|
||||
$alioss_model = new Alioss();
|
||||
|
||||
$config = $config_model->getAliossConfig($params[ 'site_id' ]);
|
||||
if (!empty($config[ 'data' ])) {
|
||||
if (!empty($config[ 'data' ][ 'value' ][ 'endpoint' ]) && strpos($params[ 'pic_path' ], $config[ 'data' ][ 'value' ][ 'endpoint' ]) === 0) {
|
||||
$result = $alioss_model->deleteAlbumPic($params[ 'pic_path' ], $config[ 'data' ][ 'value' ][ 'endpoint' ]);
|
||||
return $result;
|
||||
}
|
||||
if (!empty($config[ 'data' ][ 'value' ][ 'domain' ]) && strpos($params[ 'pic_path' ], $config[ 'data' ][ 'value' ][ 'domain' ]) === 0) {
|
||||
$result = $alioss_model->deleteAlbumPic($params[ 'pic_path' ], $config[ 'data' ][ 'value' ][ 'domain' ]);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
27
addon/alioss/event/CloseOss.php
Executable file
27
addon/alioss/event/CloseOss.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\alioss\event;
|
||||
|
||||
use addon\alioss\model\Config;
|
||||
|
||||
/**
|
||||
* 关闭云上传
|
||||
*/
|
||||
class CloseOss
|
||||
{
|
||||
public function handle()
|
||||
{
|
||||
$config_model = new Config();
|
||||
$result = $config_model->modifyConfigIsUse(0);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
26
addon/alioss/event/Install.php
Executable file
26
addon/alioss/event/Install.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\alioss\event;
|
||||
|
||||
/**
|
||||
* 应用安装
|
||||
*/
|
||||
class Install
|
||||
{
|
||||
/**
|
||||
* 执行安装
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return success();
|
||||
}
|
||||
}
|
||||
33
addon/alioss/event/OssType.php
Executable file
33
addon/alioss/event/OssType.php
Executable file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\alioss\event;
|
||||
|
||||
/**
|
||||
* 云上传方式
|
||||
*/
|
||||
class OssType
|
||||
{
|
||||
/**
|
||||
* 短信发送方式方式及配置
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$info = array(
|
||||
"sms_type" => "alioss",
|
||||
"sms_type_name" => "阿里云上传",
|
||||
"edit_url" => "alioss://shop/config/config",
|
||||
"shop_url" => "alioss://shop/config/config",
|
||||
"desc" => "阿里云上传"
|
||||
);
|
||||
return $info;
|
||||
}
|
||||
}
|
||||
31
addon/alioss/event/Put.php
Executable file
31
addon/alioss/event/Put.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\alioss\event;
|
||||
|
||||
use addon\alioss\model\Alioss;
|
||||
|
||||
/**
|
||||
* 云上传方式
|
||||
*/
|
||||
class Put
|
||||
{
|
||||
/**
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
public function handle($param)
|
||||
{
|
||||
$qiniu_model = new Alioss();
|
||||
$result = $qiniu_model->putFile($param);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
56
addon/alioss/event/ShowPromotion.php
Executable file
56
addon/alioss/event/ShowPromotion.php
Executable file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\alioss\event;
|
||||
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
*/
|
||||
class ShowPromotion
|
||||
{
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
* @param array $params
|
||||
* @return array
|
||||
*/
|
||||
public function handle($params = [])
|
||||
{
|
||||
$data = [
|
||||
'admin' => [
|
||||
|
||||
],
|
||||
'shop' => [
|
||||
[
|
||||
//插件名称
|
||||
'name' => 'alioss',
|
||||
//展示分类(根据平台端设置,admin(平台营销),shop:店铺营销,member:会员营销, tool:应用工具)
|
||||
'show_type' => 'tool',
|
||||
//展示主题
|
||||
'title' => '阿里云OSS',
|
||||
//展示介绍
|
||||
'description' => '阿里云OSS配置',
|
||||
//展示图标
|
||||
'icon' => 'addon/alioss/icon.png',
|
||||
//跳转链接
|
||||
'url' => 'alioss://shop/config/config',
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
27
addon/alioss/event/UnInstall.php
Executable file
27
addon/alioss/event/UnInstall.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\alioss\event;
|
||||
|
||||
/**
|
||||
* 应用卸载
|
||||
*/
|
||||
class UnInstall
|
||||
{
|
||||
/**
|
||||
* 执行卸载
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return success();
|
||||
}
|
||||
}
|
||||
BIN
addon/alioss/icon.png
Executable file
BIN
addon/alioss/icon.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
145
addon/alioss/model/Alioss.php
Executable file
145
addon/alioss/model/Alioss.php
Executable file
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\alioss\model;
|
||||
|
||||
use app\model\BaseModel;
|
||||
use OSS\Core\OssException;
|
||||
use OSS\OssClient;
|
||||
|
||||
/**
|
||||
* 阿里云OSS上传
|
||||
*/
|
||||
class Alioss extends BaseModel
|
||||
{
|
||||
|
||||
/**
|
||||
* 字节组上传
|
||||
* @param $data
|
||||
* @param $key
|
||||
* @return array
|
||||
*/
|
||||
public function put($param)
|
||||
{
|
||||
$data = $param['data'];
|
||||
$key = $param['key'];
|
||||
$config_model = new Config();
|
||||
$config_result = $config_model->getAliossConfig();
|
||||
$config = $config_result['data'];
|
||||
|
||||
if ($config['is_use'] == 1) {
|
||||
$config = $config['value'];
|
||||
$access_key_id = $config['access_key_id'];
|
||||
$access_key_secret = $config['access_key_secret'];
|
||||
$bucket = $config['bucket'];
|
||||
$endpoint = $config['endpoint'];
|
||||
try {
|
||||
$ossClient = new OssClient($access_key_id, $access_key_secret, $endpoint);
|
||||
|
||||
$result = $ossClient->putObject($bucket, $key, $data);
|
||||
$is_domain = $config[ 'is_domain' ] ?? 0;
|
||||
$path = $is_domain > 0 ? $config[ 'domain' ] . '/' . $key : $result['info']['url'];
|
||||
$data = array (
|
||||
'path' => $path,
|
||||
// "path" => $result["info"]["url"],
|
||||
'domain' => $endpoint,
|
||||
'bucket' => $bucket
|
||||
);
|
||||
return $this->success($data);
|
||||
} catch (OssException $e) {
|
||||
return $this->error('', $e->getErrorMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置阿里云OSS参数配置
|
||||
* @param unknown $filePath 上传图片路径
|
||||
* @param unknown $key 上传到阿里云后保存的文件名
|
||||
*/
|
||||
public function putFile($param)
|
||||
{
|
||||
$file_path = $param['file_path'];
|
||||
$key = $param['key'];
|
||||
$config_model = new Config();
|
||||
$config = $config_model->getAliossConfig()['data'];
|
||||
if ($config['is_use'] == 1) {
|
||||
$config = $config['value'];
|
||||
$access_key_id = $config['access_key_id'];
|
||||
$access_key_secret = $config['access_key_secret'];
|
||||
$bucket = $config['bucket'];
|
||||
//要上传的空间
|
||||
$endpoint = $config['endpoint'];
|
||||
try {
|
||||
$ossClient = new OssClient($access_key_id, $access_key_secret, $endpoint);
|
||||
$result = $ossClient->uploadFile($bucket, $key, $file_path);
|
||||
$is_domain = $config[ 'is_domain' ] ?? 0;
|
||||
$path = $is_domain > 0 ? $config[ 'domain' ] . '/' . $key : $result['info']['url'];
|
||||
$path = str_replace('http://', 'https://', $path);
|
||||
//返回图片的完整URL
|
||||
$data = array (
|
||||
// "path" => $this->subEndpoint($endpoint, $bucket)."/". $key,
|
||||
'path' => $path,
|
||||
'domain' => $endpoint,
|
||||
'bucket' => $bucket
|
||||
);
|
||||
return $this->success($data);
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function subEndpoint($endpoint, $bucket)
|
||||
{
|
||||
if (strpos($endpoint, 'http://') === 0) {
|
||||
$temp = 'http://';
|
||||
} else {
|
||||
$temp = 'https://';
|
||||
}
|
||||
$temp_array = explode($temp, $endpoint);
|
||||
return $temp . $bucket . '.' . $temp_array[ 1 ];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $file_path
|
||||
* @return array
|
||||
* 删除阿里云图片
|
||||
*/
|
||||
public function deleteAlbumPic($file_path, $prefix)
|
||||
{
|
||||
$config_model = new Config();
|
||||
$config_result = $config_model->getAliossConfig();
|
||||
$config = $config_result['data'];
|
||||
|
||||
if (!empty($config)) {
|
||||
$config = $config['value'];
|
||||
$access_key_id = $config['access_key_id'];
|
||||
$access_key_secret = $config['access_key_secret'];
|
||||
$bucket = $config['bucket'];
|
||||
//要上传的空间
|
||||
$endpoint = $config['endpoint'];
|
||||
try {
|
||||
$ossClient = new OssClient($access_key_id, $access_key_secret, $endpoint);
|
||||
$ossClient->deleteObject($bucket, str_replace($prefix . '/', '', $file_path));
|
||||
$ossClient->deleteObject($bucket, str_replace($prefix . '/', '', img($file_path, 'big')));
|
||||
$ossClient->deleteObject($bucket, str_replace($prefix . '/', '', img($file_path, 'mid')));
|
||||
$ossClient->deleteObject($bucket, str_replace($prefix . '/', '', img($file_path, 'small')));
|
||||
|
||||
return $this->success();
|
||||
} catch (OssException $e) {
|
||||
return $this->error('', $e->getErrorMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
56
addon/alioss/model/Config.php
Executable file
56
addon/alioss/model/Config.php
Executable file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\alioss\model;
|
||||
|
||||
use app\model\system\Config as ConfigModel;
|
||||
use app\model\BaseModel;
|
||||
|
||||
/**
|
||||
* 阿里云配置
|
||||
*/
|
||||
class Config extends BaseModel
|
||||
{
|
||||
/**
|
||||
* 设置阿里云OSS上传配置
|
||||
* array $data
|
||||
*/
|
||||
public function setAliossConfig($data, $status, $site_id = 1, $app_module = 'shop')
|
||||
{
|
||||
if ($status == 1) {
|
||||
event('CloseOss', []);//同步关闭所有云上传
|
||||
}
|
||||
|
||||
$config = new ConfigModel();
|
||||
$res = $config->setConfig($data, '阿里云OSS上传配置', $status, [ [ 'site_id', '=', $site_id ], [ 'app_module', '=', $app_module ], [ 'config_key', '=', 'ALIOSS_CONFIG' ] ]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取阿里云上传配置
|
||||
*/
|
||||
public function getAliossConfig($site_id = 1, $app_module = 'shop')
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', $app_module ], [ 'config_key', '=', 'ALIOSS_CONFIG' ] ]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置阿里云开关状态
|
||||
* @param $status
|
||||
*/
|
||||
public function modifyConfigIsUse($status, $site_id = 1, $app_module = 'shop')
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->modifyConfigIsUse($status, [ [ 'site_id', '=', $site_id ], [ 'app_module', '=', $app_module ], [ 'config_key', '=', 'ALIOSS_CONFIG' ] ]);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
56
addon/alioss/shop/controller/Config.php
Executable file
56
addon/alioss/shop/controller/Config.php
Executable file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\alioss\shop\controller;
|
||||
|
||||
use addon\alioss\model\Config as ConfigModel;
|
||||
use app\shop\controller\BaseShop;
|
||||
|
||||
/**
|
||||
* 七牛云上传管理
|
||||
*/
|
||||
class Config extends BaseShop
|
||||
{
|
||||
|
||||
/**
|
||||
* 云上传配置
|
||||
* @return mixed
|
||||
*/
|
||||
public function config()
|
||||
{
|
||||
$config_model = new ConfigModel();
|
||||
if (request()->isJson()) {
|
||||
$bucket = input('bucket', '');
|
||||
$access_key_id = input('access_key_id', '');
|
||||
$access_key_secret = input('access_key_secret', '');
|
||||
$endpoint = input('endpoint', '');
|
||||
$status = input('status', 0);
|
||||
$domain = input('domain', '');
|
||||
$is_domain = input('is_domain', 0);
|
||||
|
||||
$data = array (
|
||||
'bucket' => $bucket,
|
||||
'access_key_id' => $access_key_id,
|
||||
'access_key_secret' => $access_key_secret,
|
||||
'endpoint' => $endpoint,
|
||||
'domain' => $domain,
|
||||
'is_domain' => $is_domain
|
||||
);
|
||||
|
||||
$result = $config_model->setAliossConfig($data, $status, $this->site_id, $this->app_module);
|
||||
return $result;
|
||||
} else {
|
||||
$info_result = $config_model->getAliossConfig($this->site_id, $this->app_module);
|
||||
$info = $info_result['data'];
|
||||
$this->assign('info', $info);
|
||||
return $this->fetch('config/config');
|
||||
}
|
||||
}
|
||||
}
|
||||
120
addon/alioss/shop/view/config/config.html
Executable file
120
addon/alioss/shop/view/config/config.html
Executable file
@@ -0,0 +1,120 @@
|
||||
<div class="layui-form form-wrap">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否开启:</label>
|
||||
<div class="layui-input-block" id="isOpen">
|
||||
<input type="checkbox" name="status" lay-filter="isOpen" value="1" lay-skin="switch" {if condition="$info.is_use == 1"} checked {/if} />
|
||||
</div>
|
||||
<div class="word-aux">当前使用阿里云上传配置</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>AccessKeyID:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="access_key_id" lay-verify="required" placeholder="请输入Access Key ID" value="{$info.value.access_key_id ?? ''}" autocomplete="off" class="layui-input len-long">
|
||||
</div>
|
||||
<div class="word-aux">填写阿里云Access Key管理的(ID)。</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>AccessKeySecret:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="access_key_secret" lay-verify="required" placeholder="请输入Access Key Secret" value="{$info.value.access_key_secret ?? ''}" autocomplete="off" class="layui-input len-long">
|
||||
</div>
|
||||
<div class="word-aux">Access Key Secret是您访问阿里云API的密钥,具有该账户完全的权限,请您妥善保管。(填写完Access Key ID 和 Access Key Secret 后请选择bucket)</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>Bucket:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="bucket" lay-verify="required" placeholder="请输入存储空间的名称" value="{$info.value.bucket ?? ''}" autocomplete="off" class="layui-input len-long">
|
||||
</div>
|
||||
<div class="word-aux">与阿里云OSS开通对象名称一致</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>endpoint:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="endpoint" lay-verify="required" placeholder="请输入endpoint" value="{$info.value.endpoint ?? ''}" autocomplete="off" class="layui-input len-long">
|
||||
</div>
|
||||
<div class="word-aux">Bucket地域endpoint</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否开启自定义域名:</label>
|
||||
<div class="layui-input-block" >
|
||||
<input type="checkbox" name="is_domain" lay-filter="is_domain" value="1" lay-skin="switch" {if condition="!empty($info.value.is_domain) && $info.value.is_domain == 1"} checked {/if} />
|
||||
</div>
|
||||
<div class="word-aux">默认选关闭,官方建议开启绑定域名,域名格式:http://xx.xxxx.com/(不可绑定当前网站域名,建议新开二级域名)</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item domain-view" {if empty($info.value.is_domain) || $info.value.is_domain == 0}style="display:none;"{/if}>
|
||||
<label class="layui-form-label"><span class="required">*</span>domain:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="domain" lay-verify="domain" placeholder="请输入domain" value="{$info.value.domain ?? ''}" autocomplete="off" class="layui-input len-long">
|
||||
</div>
|
||||
<div class="word-aux">域名格式:http://xx.xxxx.com/(不可绑定当前网站域名,建议新开二级域名)</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="backOss()">返回</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
layui.use('form', function() {
|
||||
var form = layui.form,
|
||||
repeat_flag = false; //防重复标识
|
||||
|
||||
form.on('switch(is_domain)', function(data){
|
||||
if(data.elem.checked){
|
||||
$(".domain-view").show();
|
||||
}else{
|
||||
$(".domain-view").hide();
|
||||
}
|
||||
});
|
||||
form.verify({
|
||||
domain: function (value, item) {
|
||||
var is_domain = $("input[name=is_domain]").prop("checked");
|
||||
if(is_domain > 0 && value == ""){
|
||||
return '自定义域名不可为空!';
|
||||
}
|
||||
},
|
||||
});
|
||||
form.on('submit(save)', function(data) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("alioss://shop/config/config"),
|
||||
data: data.field,
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function(res) {
|
||||
repeat_flag = false;
|
||||
if (res.code >= 0) {
|
||||
layer.confirm('编辑成功', {
|
||||
title:'操作提示',
|
||||
btn: ['返回列表', '继续编辑'],
|
||||
yes: function(index, layero) {
|
||||
location.hash = ns.hash("shop/upload/oss");
|
||||
layer.close(index);
|
||||
},
|
||||
btn2: function(index, layero) {
|
||||
layer.close(index);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
form.render();
|
||||
});
|
||||
|
||||
function backOss() {
|
||||
location.hash = ns.hash("shop/upload/oss");
|
||||
}
|
||||
</script>
|
||||
38
addon/alipay/config/diy_view.php
Executable file
38
addon/alipay/config/diy_view.php
Executable file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
return [
|
||||
|
||||
// 自定义模板页面类型,格式:[ 'title' => '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
|
||||
'template' => [],
|
||||
|
||||
// 后台自定义组件——装修
|
||||
'util' => [],
|
||||
|
||||
// 自定义页面路径
|
||||
'link' => [],
|
||||
|
||||
// 自定义图标库
|
||||
'icon_library' => [],
|
||||
|
||||
// uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件
|
||||
'component' => [],
|
||||
|
||||
// uni-app 页面,多个逗号隔开
|
||||
'pages' => [],
|
||||
|
||||
// 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述'
|
||||
'info' => [],
|
||||
|
||||
// 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】
|
||||
'theme' => [],
|
||||
|
||||
// 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ]
|
||||
'data' => []
|
||||
];
|
||||
50
addon/alipay/config/event.php
Executable file
50
addon/alipay/config/event.php
Executable file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
return [
|
||||
'bind' => [
|
||||
|
||||
],
|
||||
|
||||
'listen' => [
|
||||
//支付异步回调
|
||||
'PayNotify' => [
|
||||
'addon\alipay\event\PayNotify'
|
||||
],
|
||||
//支付方式,后台查询
|
||||
'PayType' => [
|
||||
'addon\alipay\event\PayType'
|
||||
],
|
||||
//支付,前台应用
|
||||
'Pay' => [
|
||||
'addon\alipay\event\Pay'
|
||||
],
|
||||
'PayClose' => [
|
||||
'addon\alipay\event\PayClose'
|
||||
],
|
||||
'PayRefund' => [
|
||||
'addon\alipay\event\PayRefund'
|
||||
],
|
||||
'PayTransfer' => [
|
||||
'addon\alipay\event\PayTransfer'
|
||||
],
|
||||
'TransferType' => [
|
||||
'addon\alipay\event\TransferType'
|
||||
],
|
||||
'AuthcodePay' => [
|
||||
'addon\alipay\event\AuthcodePay'
|
||||
],
|
||||
'PayOrderQuery' => [
|
||||
'addon\alipay\event\PayOrderQuery'
|
||||
],
|
||||
],
|
||||
|
||||
'subscribe' => [
|
||||
],
|
||||
];
|
||||
21
addon/alipay/config/info.php
Executable file
21
addon/alipay/config/info.php
Executable file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
return [
|
||||
'name' => 'alipay',
|
||||
'title' => '支付宝支付',
|
||||
'description' => '支付宝支付功能',
|
||||
'type' => 'system', //插件类型 system :系统插件(自动安装), promotion:营销插件 tool:工具插件
|
||||
'status' => 1,
|
||||
'author' => '',
|
||||
'version' => '5.5.3',
|
||||
'version_no' => '553250709001',
|
||||
'content' => '',
|
||||
];
|
||||
24
addon/alipay/config/menu_shop.php
Executable file
24
addon/alipay/config/menu_shop.php
Executable file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
return [
|
||||
[
|
||||
'name' => 'ALI_PAY_CONFIG',
|
||||
'title' => '支付宝支付编辑',
|
||||
'url' => 'alipay://shop/pay/config',
|
||||
'parent' => 'CONFIG_PAY',
|
||||
'is_show' => 0,
|
||||
'is_control' => 1,
|
||||
'is_icon' => 0,
|
||||
'picture' => '',
|
||||
'picture_select' => '',
|
||||
'sort' => 1,
|
||||
'type' => 'button',
|
||||
],
|
||||
];
|
||||
231
addon/alipay/data/sdk/AlipayMobilePublicMultiMediaClient.php
Executable file
231
addon/alipay/data/sdk/AlipayMobilePublicMultiMediaClient.php
Executable file
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 多媒体文件客户端
|
||||
* @author yikai.hu
|
||||
* @version $Id: AlipayMobilePublicMultiMediaClient.php, v 0.1 Aug 15, 2014 10:19:01 AM yikai.hu Exp $
|
||||
*/
|
||||
|
||||
//namespace alipay\api ;
|
||||
|
||||
include("AlipayMobilePublicMultiMediaExecute.php");
|
||||
|
||||
|
||||
class AlipayMobilePublicMultiMediaClient{
|
||||
|
||||
private $DEFAULT_CHARSET = 'UTF-8';
|
||||
private $METHOD_POST = "POST";
|
||||
private $METHOD_GET = "GET";
|
||||
private $SIGN = 'sign'; //get name
|
||||
|
||||
private $timeout = 10 ;// 超时时间
|
||||
private $serverUrl;
|
||||
private $appId;
|
||||
private $privateKey;
|
||||
private $prodCode;
|
||||
private $format = 'json'; //todo
|
||||
private $sign_type = 'RSA'; //todo
|
||||
|
||||
private $charset;
|
||||
private $apiVersion = "1.0";
|
||||
private $apiMethodName = "alipay.mobile.public.multimedia.download";
|
||||
private $media_id = "L21pZnMvVDFQV3hYWGJKWFhYYUNucHJYP3Q9YW13ZiZ4c2lnPTU0MzRhYjg1ZTZjNWJmZTMxZGJiNjIzNDdjMzFkNzkw575";
|
||||
//此处写死的,实际开发中,请传入
|
||||
|
||||
private $connectTimeout = 3000;
|
||||
private $readTimeout = 15000;
|
||||
|
||||
|
||||
|
||||
function __construct($serverUrl = '', $appId = '', $partner_private_key = '', $format = '', $charset = 'GBK'){
|
||||
$this -> serverUrl = $serverUrl;
|
||||
$this -> appId = $appId;
|
||||
$this -> privateKey = $partner_private_key;
|
||||
$this -> format = $format;
|
||||
$this -> charset = $charset;
|
||||
}
|
||||
|
||||
/**
|
||||
* getContents 获取网址内容
|
||||
* @param $request
|
||||
* @return text | bin
|
||||
*/
|
||||
public function getContents(){
|
||||
//自己的服务器如果没有 curl,可用:fsockopen() 等
|
||||
|
||||
|
||||
//1:
|
||||
//2: 私钥格式
|
||||
$datas = array(
|
||||
"app_id" => $this -> appId,
|
||||
"method" => $this -> METHOD_POST,
|
||||
"sign_type" => $this -> sign_type,
|
||||
"version" => $this -> apiVersion,
|
||||
"timestamp" => date('Y-m-d H:i:s') ,//yyyy-MM-dd HH:mm:ss
|
||||
"biz_content" => '{"mediaId":"'. $this -> media_id .'"}',
|
||||
"charset" => $this -> charset
|
||||
);
|
||||
|
||||
|
||||
|
||||
//要提交的数据
|
||||
$data_sign = $this -> buildGetUrl( $datas );
|
||||
|
||||
$post_data = $data_sign;
|
||||
//初始化 curl
|
||||
$ch = curl_init();
|
||||
//设置目标服务器
|
||||
curl_setopt($ch, CURLOPT_URL, $this -> serverUrl );
|
||||
curl_setopt($ch, CURLOPT_HEADER, TRUE);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
//超时时间
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $this-> timeout);
|
||||
|
||||
if( $this-> METHOD_POST == 'POST'){
|
||||
// post数据
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
// post的变量
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$output = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
echo $output;
|
||||
|
||||
//分离头部
|
||||
//list($header, $body) = explode("\r\n\r\n", $output, 2);
|
||||
$datas = explode("\r\n\r\n", $output, 2);
|
||||
$header = $datas[0];
|
||||
|
||||
if( $httpCode == '200'){
|
||||
$body = $datas[1];
|
||||
}else{
|
||||
$body = '';
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return $this -> execute( $header, $body, $httpCode );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param $request
|
||||
* @return text | bin
|
||||
*/
|
||||
public function execute( $header = '', $body = '', $httpCode = '' ){
|
||||
$exe = new AlipayMobilePublicMultiMediaExecute( $header, $body, $httpCode );
|
||||
return $exe;
|
||||
}
|
||||
|
||||
public function buildGetUrl( $query = array() ){
|
||||
|
||||
if( ! is_array( $query ) ){
|
||||
//exit;
|
||||
}
|
||||
|
||||
//排序参数,
|
||||
$data = $this -> buildQuery( $query );
|
||||
|
||||
|
||||
|
||||
// 私钥密码
|
||||
$passphrase = '';
|
||||
$key_width = 64;
|
||||
|
||||
//私钥
|
||||
$privateKey = $this -> privateKey;
|
||||
$p_key = array();
|
||||
//如果私钥是 1行
|
||||
if( ! stripos( $privateKey, "\n" ) ){
|
||||
$i = 0;
|
||||
while( $key_str = substr( $privateKey , $i * $key_width , $key_width) ){
|
||||
$p_key[] = $key_str;
|
||||
$i ++ ;
|
||||
}
|
||||
}else{
|
||||
//echo '一行?';
|
||||
}
|
||||
$privateKey = "-----BEGIN RSA PRIVATE KEY-----\n" . implode("\n", $p_key) ;
|
||||
$privateKey = $privateKey ."\n-----END RSA PRIVATE KEY-----";
|
||||
|
||||
// echo "\n\n私钥:\n";
|
||||
// echo( $privateKey );
|
||||
// echo "\n\n\n";
|
||||
|
||||
//私钥
|
||||
$private_id = openssl_pkey_get_private( $privateKey , $passphrase);
|
||||
|
||||
|
||||
// 签名
|
||||
$signature = '';
|
||||
|
||||
if("RSA2"==$this->sign_type){
|
||||
|
||||
openssl_sign($data, $signature, $private_id, OPENSSL_ALGO_SHA256 );
|
||||
}else{
|
||||
|
||||
openssl_sign($data, $signature, $private_id, OPENSSL_ALGO_SHA1 );
|
||||
}
|
||||
|
||||
openssl_free_key( $private_id );
|
||||
|
||||
//加密后的内容通常含有特殊字符,需要编码转换下
|
||||
$signature = base64_encode($signature);
|
||||
|
||||
$signature = urlencode( $signature );
|
||||
|
||||
//$signature = 'XjUN6YM1Mc9HXebKMv7GTLy7gmyhktyOgKk2/Jf+cz4DtP6udkzTdpkjW2j/Z4ZSD7xD6CNYI1Spz4yS93HPT0a5X9LgFWYY8SaADqe+ArXg+FBSiTwUz49SE//Xd9+LEiIRsSFkbpkuiGoO6mqJmB7vXjlD5lx6qCM3nb41wb8=';
|
||||
|
||||
$out = $data .'&'. $this -> SIGN .'='. $signature;
|
||||
|
||||
// echo "\n\n 加密后:\n";
|
||||
// echo( $out );
|
||||
// echo "\n\n\n";
|
||||
|
||||
return $out ;
|
||||
}
|
||||
|
||||
/*
|
||||
* 查询参数排序 a-z
|
||||
* */
|
||||
public function buildQuery( $query ){
|
||||
if ( !$query ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//将要 参数 排序
|
||||
ksort( $query );
|
||||
|
||||
//重新组装参数
|
||||
$params = array();
|
||||
foreach($query as $key => $value){
|
||||
$params[] = $key .'='. $value ;
|
||||
}
|
||||
$data = implode('&', $params);
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
108
addon/alipay/data/sdk/AlipayMobilePublicMultiMediaExecute.php
Executable file
108
addon/alipay/data/sdk/AlipayMobilePublicMultiMediaExecute.php
Executable file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 多媒体文件客户端
|
||||
* @author yuanwai.wang
|
||||
* @version $Id: AlipayMobilePublicMultiMediaExecute.php, v 0.1 Aug 15, 2014 10:19:01 AM yuanwai.wang Exp $
|
||||
*/
|
||||
|
||||
//namespace alipay\api ;
|
||||
|
||||
|
||||
|
||||
class AlipayMobilePublicMultiMediaExecute{
|
||||
|
||||
private $code = 200 ;
|
||||
private $msg = '';
|
||||
private $body = '';
|
||||
private $params = '';
|
||||
|
||||
private $fileSuffix = array(
|
||||
"image/jpeg" => 'jpg', //+
|
||||
"text/plain" => 'text'
|
||||
);
|
||||
|
||||
/*
|
||||
* @$header : 头部
|
||||
* */
|
||||
function __construct( $header, $body, $httpCode ){
|
||||
$this -> code = $httpCode;
|
||||
$this -> msg = '';
|
||||
$this -> params = $header ;
|
||||
$this -> body = $body;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return text | bin
|
||||
*/
|
||||
public function getCode(){
|
||||
return $this -> code ;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return text | bin
|
||||
*/
|
||||
public function getMsg(){
|
||||
return $this -> msg ;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return text | bin
|
||||
*/
|
||||
public function getType(){
|
||||
$subject = $this -> params ;
|
||||
$pattern = '/Content\-Type:([^;]+)/';
|
||||
preg_match($pattern, $subject, $matches);
|
||||
if( $matches ){
|
||||
$type = $matches[1];
|
||||
}else{
|
||||
$type = 'application/download';
|
||||
}
|
||||
|
||||
return str_replace( ' ', '', $type );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return text | bin
|
||||
*/
|
||||
public function getContentLength(){
|
||||
$subject = $this -> params ;
|
||||
$pattern = '/Content-Length:\s*([^\n]+)/';
|
||||
preg_match($pattern, $subject, $matches);
|
||||
return (int)( isset($matches[1] ) ? $matches[1] : '' );
|
||||
}
|
||||
|
||||
|
||||
public function getFileSuffix( $fileType ){
|
||||
$type = isset( $this -> fileSuffix[ $fileType ] ) ? $this -> fileSuffix[ $fileType ] : 'text/plain' ;
|
||||
if( !$type ){
|
||||
$type = 'json';
|
||||
}
|
||||
return $type;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return text | bin
|
||||
*/
|
||||
public function getBody(){
|
||||
//header('Content-type: image/jpeg');
|
||||
return $this -> body ;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取参数
|
||||
* @return text | bin
|
||||
*/
|
||||
public function getParams(){
|
||||
return $this -> params ;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
1241
addon/alipay/data/sdk/AopCertClient.php
Executable file
1241
addon/alipay/data/sdk/AopCertClient.php
Executable file
File diff suppressed because it is too large
Load Diff
527
addon/alipay/data/sdk/AopCertification.php
Executable file
527
addon/alipay/data/sdk/AopCertification.php
Executable file
@@ -0,0 +1,527 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 验证支付宝公钥证书是否可信
|
||||
* @param $alipayCert 支付宝公钥证书
|
||||
* @param $rootCert 支付宝根证书
|
||||
*/
|
||||
function isTrusted($alipayCert, $rootCert)
|
||||
{
|
||||
$alipayCerts = readPemCertChain($alipayCert);
|
||||
$rootCerts = readPemCertChain($rootCert);
|
||||
if (verifyCertChain($alipayCerts, $rootCerts)) {
|
||||
return verifySignature($alipayCert, $rootCert);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function verifySignature($alipayCert, $rootCert)
|
||||
{
|
||||
$alipayCertArray = explode("-----END CERTIFICATE-----", $alipayCert);
|
||||
$rootCertArray = explode("-----END CERTIFICATE-----", $rootCert);
|
||||
$length = count($rootCertArray) - 1;
|
||||
$checkSign = isCertSigner($alipayCertArray[0] . "-----END CERTIFICATE-----", $alipayCertArray[1] . "-----END CERTIFICATE-----");
|
||||
if (!$checkSign) {
|
||||
$checkSign = isCertSigner($alipayCertArray[1] . "-----END CERTIFICATE-----", $alipayCertArray[0] . "-----END CERTIFICATE-----");
|
||||
if ($checkSign) {
|
||||
$issuer = openssl_x509_parse($alipayCertArray[0] . "-----END CERTIFICATE-----")['issuer'];
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$subject = openssl_x509_parse($rootCertArray[$i] . "-----END CERTIFICATE-----")['subject'];
|
||||
if ($issuer == $subject) {
|
||||
isCertSigner($alipayCertArray[0] . "-----END CERTIFICATE-----", $rootCertArray[$i] . $rootCertArray);
|
||||
return $checkSign;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return $checkSign;
|
||||
}
|
||||
} else {
|
||||
$issuer = openssl_x509_parse($alipayCertArray[1] . "-----END CERTIFICATE-----")['issuer'];
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$subject = openssl_x509_parse($rootCertArray[$i] . "-----END CERTIFICATE-----")['subject'];
|
||||
if ($issuer == $subject) {
|
||||
$checkSign = isCertSigner($alipayCertArray[1] . "-----END CERTIFICATE-----", $rootCertArray[$i] . "-----END CERTIFICATE-----");
|
||||
return $checkSign;
|
||||
}
|
||||
}
|
||||
return $checkSign;
|
||||
}
|
||||
}
|
||||
|
||||
function readPemCertChain($cert)
|
||||
{
|
||||
$array = explode("-----END CERTIFICATE-----", $cert);
|
||||
$certs[] = null;
|
||||
for ($i = 0; $i < count($array) - 1; $i++) {
|
||||
$certs[$i] = openssl_x509_parse($array[$i] . "-----END CERTIFICATE-----");
|
||||
}
|
||||
return $certs;
|
||||
}
|
||||
|
||||
function verifyCert($prev, $rootCerts)
|
||||
{
|
||||
$nowTime = time();
|
||||
if ($nowTime < $prev['validFrom_time_t']) {
|
||||
echo "证书未激活";
|
||||
return false;
|
||||
}
|
||||
if ($nowTime > $prev['validTo_time_t']) {
|
||||
echo "证书已经过期";
|
||||
return false;
|
||||
}
|
||||
$subjectMap = null;
|
||||
for ($i = 0; $i < count($rootCerts); $i++) {
|
||||
$subjectDN = array2string($rootCerts[$i]['subject']);
|
||||
$subjectMap[$subjectDN] = $rootCerts[$i];
|
||||
}
|
||||
$issuerDN = array2string(($prev['issuer']));
|
||||
if (!array_key_exists($issuerDN, $subjectMap)) {
|
||||
echo "证书链验证失败";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证证书链是否是信任证书库中证书签发的
|
||||
* @param $alipayCerts 目标验证证书列表
|
||||
* @param $rootCerts 可信根证书列表
|
||||
*/
|
||||
function verifyCertChain($alipayCerts, $rootCerts)
|
||||
{
|
||||
$sorted = sortByDn($alipayCerts);
|
||||
if (!$sorted) {
|
||||
echo "证书链验证失败:不是完整的证书链";
|
||||
return false;
|
||||
}
|
||||
//先验证第一个证书是不是信任库中证书签发的
|
||||
$prev = $alipayCerts[0];
|
||||
$firstOK = verifyCert($prev, $rootCerts);
|
||||
$length = count($alipayCerts);
|
||||
if (!$firstOK || $length == 1) {
|
||||
return $firstOK;
|
||||
}
|
||||
|
||||
$nowTime = time();
|
||||
//验证证书链
|
||||
for ($i = 1; $i < $length; $i++) {
|
||||
$cert = $alipayCerts[$i];
|
||||
if ($nowTime < $cert['validFrom_time_t']) {
|
||||
echo "证书未激活";
|
||||
return false;
|
||||
}
|
||||
if ($nowTime > $cert['validTo_time_t']) {
|
||||
echo "证书已经过期";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将证书链按照完整的签发顺序进行排序,排序后证书链为:[issuerA, subjectA]-[issuerA, subjectB]-[issuerB, subjectC]-[issuerC, subjectD]...
|
||||
* @param $certs 证书链
|
||||
*/
|
||||
function sortByDn(&$certs)
|
||||
{
|
||||
//是否包含自签名证书
|
||||
$hasSelfSignedCert = false;
|
||||
$subjectMap = null;
|
||||
$issuerMap = null;
|
||||
for ($i = 0; $i < count($certs); $i++) {
|
||||
if (isSelfSigned($certs[$i])) {
|
||||
if ($hasSelfSignedCert) {
|
||||
return false;
|
||||
}
|
||||
$hasSelfSignedCert = true;
|
||||
}
|
||||
$subjectDN = array2string($certs[$i]['subject']);
|
||||
$issuerDN = array2string(($certs[$i]['issuer']));
|
||||
$subjectMap[$subjectDN] = $certs[$i];
|
||||
$issuerMap[$issuerDN] = $certs[$i];
|
||||
}
|
||||
$certChain = null;
|
||||
addressingUp($subjectMap, $certChain, $certs[0]);
|
||||
addressingDown($issuerMap, $certChain, $certs[0]);
|
||||
|
||||
//说明证书链不完整
|
||||
if (count($certs) != count($certChain)) {
|
||||
return false;
|
||||
}
|
||||
//将证书链复制到原先的数据
|
||||
for ($i = 0; $i < count($certs); $i++) {
|
||||
$certs[$i] = $certChain[count($certs) - $i - 1];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证证书是否是自签发的
|
||||
* @param $cert 目标证书
|
||||
*/
|
||||
function isSelfSigned($cert)
|
||||
{
|
||||
$subjectDN = array2string($cert['subject']);
|
||||
$issuerDN = array2string($cert['issuer']);
|
||||
return ($subjectDN == $issuerDN);
|
||||
}
|
||||
|
||||
|
||||
function array2string($array)
|
||||
{
|
||||
$string = [];
|
||||
if ($array && is_array($array)) {
|
||||
foreach ($array as $key => $value) {
|
||||
$string[] = $key . '=' . $value;
|
||||
}
|
||||
}
|
||||
return implode(',', $string);
|
||||
}
|
||||
|
||||
/**
|
||||
* 向上构造证书链
|
||||
* @param $subjectMap 主题和证书的映射
|
||||
* @param $certChain 证书链
|
||||
* @param $current 当前需要插入证书链的证书,include
|
||||
*/
|
||||
function addressingUp($subjectMap, &$certChain, $current)
|
||||
{
|
||||
$certChain[] = $current;
|
||||
if (isSelfSigned($current)) {
|
||||
return;
|
||||
}
|
||||
$issuerDN = array2string($current['issuer']);
|
||||
|
||||
if (!array_key_exists($issuerDN, $subjectMap)) {
|
||||
return;
|
||||
}
|
||||
addressingUp($subjectMap, $certChain, $subjectMap[$issuerDN]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 向下构造证书链
|
||||
* @param $issuerMap 签发者和证书的映射
|
||||
* @param $certChain 证书链
|
||||
* @param $current 当前需要插入证书链的证书,exclude
|
||||
*/
|
||||
function addressingDown($issuerMap, &$certChain, $current)
|
||||
{
|
||||
$subjectDN = array2string($current['subject']);
|
||||
if (!array_key_exists($subjectDN, $issuerMap)) {
|
||||
return $certChain;
|
||||
}
|
||||
$certChain[] = $issuerMap[$subjectDN];
|
||||
addressingDown($issuerMap, $certChain, $issuerMap[$subjectDN]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract signature from der encoded cert.
|
||||
* Expects x509 der encoded certificate consisting of a section container
|
||||
* containing 2 sections and a bitstream. The bitstream contains the
|
||||
* original encrypted signature, encrypted by the public key of the issuing
|
||||
* signer.
|
||||
* @param string $der
|
||||
* @return string on success
|
||||
* @return bool false on failures
|
||||
*/
|
||||
function extractSignature($der = false)
|
||||
{
|
||||
if (strlen($der) < 5) {
|
||||
return false;
|
||||
}
|
||||
// skip container sequence
|
||||
$der = substr($der, 4);
|
||||
// now burn through two sequences and the return the final bitstream
|
||||
while (strlen($der) > 1) {
|
||||
$class = ord($der[0]);
|
||||
$classHex = dechex($class);
|
||||
switch ($class) {
|
||||
// BITSTREAM
|
||||
case 0x03:
|
||||
$len = ord($der[1]);
|
||||
$bytes = 0;
|
||||
if ($len & 0x80) {
|
||||
$bytes = $len & 0x0f;
|
||||
$len = 0;
|
||||
for ($i = 0; $i < $bytes; $i++) {
|
||||
$len = ($len << 8) | ord($der[$i + 2]);
|
||||
}
|
||||
}
|
||||
return substr($der, 3 + $bytes, $len);
|
||||
break;
|
||||
// SEQUENCE
|
||||
case 0x30:
|
||||
$len = ord($der[1]);
|
||||
$bytes = 0;
|
||||
if ($len & 0x80) {
|
||||
$bytes = $len & 0x0f;
|
||||
$len = 0;
|
||||
for ($i = 0; $i < $bytes; $i++) {
|
||||
$len = ($len << 8) | ord($der[$i + 2]);
|
||||
}
|
||||
}
|
||||
$contents = substr($der, 2 + $bytes, $len);
|
||||
$der = substr($der, 2 + $bytes + $len);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get signature algorithm oid from der encoded signature data.
|
||||
* Expects decrypted signature data from a certificate in der format.
|
||||
* This ASN1 data should contain the following structure:
|
||||
* SEQUENCE
|
||||
* SEQUENCE
|
||||
* OID (signature algorithm)
|
||||
* NULL
|
||||
* OCTET STRING (signature hash)
|
||||
* @return bool false on failures
|
||||
* @return string oid
|
||||
*/
|
||||
function getSignatureAlgorithmOid($der = null)
|
||||
{
|
||||
// Validate this is the der we need...
|
||||
if (!is_string($der) or strlen($der) < 5) {
|
||||
return false;
|
||||
}
|
||||
$bit_seq1 = 0;
|
||||
$bit_seq2 = 2;
|
||||
$bit_oid = 4;
|
||||
if (ord($der[$bit_seq1]) !== 0x30) {
|
||||
die('Invalid DER passed to getSignatureAlgorithmOid()');
|
||||
}
|
||||
if (ord($der[$bit_seq2]) !== 0x30) {
|
||||
die('Invalid DER passed to getSignatureAlgorithmOid()');
|
||||
}
|
||||
if (ord($der[$bit_oid]) !== 0x06) {
|
||||
die('Invalid DER passed to getSignatureAlgorithmOid');
|
||||
}
|
||||
// strip out what we don't need and get the oid
|
||||
$der = substr($der, $bit_oid);
|
||||
// Get the oid
|
||||
$len = ord($der[1]);
|
||||
$bytes = 0;
|
||||
if ($len & 0x80) {
|
||||
$bytes = $len & 0x0f;
|
||||
$len = 0;
|
||||
for ($i = 0; $i < $bytes; $i++) {
|
||||
$len = ($len << 8) | ord($der[$i + 2]);
|
||||
}
|
||||
}
|
||||
$oid_data = substr($der, 2 + $bytes, $len);
|
||||
// Unpack the OID
|
||||
$oid = floor(ord($oid_data[0]) / 40);
|
||||
$oid .= '.' . ord($oid_data[0]) % 40;
|
||||
$value = 0;
|
||||
$i = 1;
|
||||
while ($i < strlen($oid_data)) {
|
||||
$value = $value << 7;
|
||||
$value = $value | (ord($oid_data[$i]) & 0x7f);
|
||||
if (!(ord($oid_data[$i]) & 0x80)) {
|
||||
$oid .= '.' . $value;
|
||||
$value = 0;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
return $oid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get signature hash from der encoded signature data.
|
||||
* Expects decrypted signature data from a certificate in der format.
|
||||
* This ASN1 data should contain the following structure:
|
||||
* SEQUENCE
|
||||
* SEQUENCE
|
||||
* OID (signature algorithm)
|
||||
* NULL
|
||||
* OCTET STRING (signature hash)
|
||||
* @return bool false on failures
|
||||
* @return string hash
|
||||
*/
|
||||
function getSignatureHash($der = null)
|
||||
{
|
||||
// Validate this is the der we need...
|
||||
if (!is_string($der) or strlen($der) < 5) {
|
||||
return false;
|
||||
}
|
||||
if (ord($der[0]) !== 0x30) {
|
||||
die('Invalid DER passed to getSignatureHash()');
|
||||
}
|
||||
// strip out the container sequence
|
||||
$der = substr($der, 2);
|
||||
if (ord($der[0]) !== 0x30) {
|
||||
die('Invalid DER passed to getSignatureHash()');
|
||||
}
|
||||
// Get the length of the first sequence so we can strip it out.
|
||||
$len = ord($der[1]);
|
||||
$bytes = 0;
|
||||
if ($len & 0x80) {
|
||||
$bytes = $len & 0x0f;
|
||||
$len = 0;
|
||||
for ($i = 0; $i < $bytes; $i++) {
|
||||
$len = ($len << 8) | ord($der[$i + 2]);
|
||||
}
|
||||
}
|
||||
$der = substr($der, 2 + $bytes + $len);
|
||||
// Now we should have an octet string
|
||||
if (ord($der[0]) !== 0x04) {
|
||||
die('Invalid DER passed to getSignatureHash()');
|
||||
}
|
||||
$len = ord($der[1]);
|
||||
$bytes = 0;
|
||||
if ($len & 0x80) {
|
||||
$bytes = $len & 0x0f;
|
||||
$len = 0;
|
||||
for ($i = 0; $i < $bytes; $i++) {
|
||||
$len = ($len << 8) | ord($der[$i + 2]);
|
||||
}
|
||||
}
|
||||
return bin2hex(substr($der, 2 + $bytes, $len));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if one cert was used to sign another
|
||||
* Note that more than one CA cert can give a positive result, some certs
|
||||
* re-issue signing certs after having only changed the expiration dates.
|
||||
* @param string $cert - PEM encoded cert
|
||||
* @param string $caCert - PEM encoded cert that possibly signed $cert
|
||||
* @return bool
|
||||
*/
|
||||
function isCertSigner($certPem = null, $caCertPem = null)
|
||||
{
|
||||
if (!function_exists('openssl_pkey_get_public')) {
|
||||
die('Need the openssl_pkey_get_public() function.');
|
||||
}
|
||||
if (!function_exists('openssl_public_decrypt')) {
|
||||
die('Need the openssl_public_decrypt() function.');
|
||||
}
|
||||
if (!function_exists('hash')) {
|
||||
die('Need the php hash() function.');
|
||||
}
|
||||
if (empty($certPem) or empty($caCertPem)) {
|
||||
return false;
|
||||
}
|
||||
// Convert the cert to der for feeding to extractSignature.
|
||||
$certDer = pemToDer($certPem);
|
||||
if (!is_string($certDer)) {
|
||||
die('invalid certPem');
|
||||
}
|
||||
// Grab the encrypted signature from the der encoded cert.
|
||||
$encryptedSig = extractSignature($certDer);
|
||||
if (!is_string($encryptedSig)) {
|
||||
die('Failed to extract encrypted signature from certPem.');
|
||||
}
|
||||
// Extract the public key from the ca cert, which is what has
|
||||
// been used to encrypt the signature in the cert.
|
||||
$pubKey = openssl_pkey_get_public($caCertPem);
|
||||
if ($pubKey === false) {
|
||||
die('Failed to extract the public key from the ca cert.');
|
||||
}
|
||||
// Attempt to decrypt the encrypted signature using the CA's public
|
||||
// key, returning the decrypted signature in $decryptedSig. If
|
||||
// it can't be decrypted, this ca was not used to sign it for sure...
|
||||
$rc = openssl_public_decrypt($encryptedSig, $decryptedSig, $pubKey);
|
||||
if ($rc === false) {
|
||||
return false;
|
||||
}
|
||||
// We now have the decrypted signature, which is der encoded
|
||||
// asn1 data containing the signature algorithm and signature hash.
|
||||
// Now we need what was originally hashed by the issuer, which is
|
||||
// the original DER encoded certificate without the issuer and
|
||||
// signature information.
|
||||
$origCert = stripSignerAsn($certDer);
|
||||
if ($origCert === false) {
|
||||
die('Failed to extract unsigned cert.');
|
||||
}
|
||||
// Get the oid of the signature hash algorithm, which is required
|
||||
// to generate our own hash of the original cert. This hash is
|
||||
// what will be compared to the issuers hash.
|
||||
$oid = getSignatureAlgorithmOid($decryptedSig);
|
||||
if ($oid === false) {
|
||||
die('Failed to determine the signature algorithm.');
|
||||
}
|
||||
switch ($oid) {
|
||||
case '1.2.840.113549.2.2':
|
||||
$algo = 'md2';
|
||||
break;
|
||||
case '1.2.840.113549.2.4':
|
||||
$algo = 'md4';
|
||||
break;
|
||||
case '1.2.840.113549.2.5':
|
||||
$algo = 'md5';
|
||||
break;
|
||||
case '1.3.14.3.2.18':
|
||||
$algo = 'sha';
|
||||
break;
|
||||
case '1.3.14.3.2.26':
|
||||
$algo = 'sha1';
|
||||
break;
|
||||
case '2.16.840.1.101.3.4.2.1':
|
||||
$algo = 'sha256';
|
||||
break;
|
||||
case '2.16.840.1.101.3.4.2.2':
|
||||
$algo = 'sha384';
|
||||
break;
|
||||
case '2.16.840.1.101.3.4.2.3':
|
||||
$algo = 'sha512';
|
||||
break;
|
||||
default:
|
||||
die('Unknown signature hash algorithm oid: ' . $oid);
|
||||
break;
|
||||
}
|
||||
// Get the issuer generated hash from the decrypted signature.
|
||||
$decryptedHash = getSignatureHash($decryptedSig);
|
||||
// Ok, hash the original unsigned cert with the same algorithm
|
||||
// and if it matches $decryptedHash we have a winner.
|
||||
$certHash = hash($algo, $origCert);
|
||||
return ($decryptedHash === $certHash);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert pem encoded certificate to DER encoding
|
||||
* @return string $derEncoded on success
|
||||
* @return bool false on failures
|
||||
*/
|
||||
function pemToDer($pem = null)
|
||||
{
|
||||
if (!is_string($pem)) {
|
||||
return false;
|
||||
}
|
||||
$cert_split = preg_split('/(-----((BEGIN)|(END)) CERTIFICATE-----)/', $pem);
|
||||
if (!isset($cert_split[1])) {
|
||||
return false;
|
||||
}
|
||||
return base64_decode($cert_split[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain der cert with issuer and signature sections stripped.
|
||||
* @param string $der - der encoded certificate
|
||||
* @return string $der on success
|
||||
* @return bool false on failures.
|
||||
*/
|
||||
function stripSignerAsn($der = null)
|
||||
{
|
||||
if (!is_string($der) or strlen($der) < 8) {
|
||||
return false;
|
||||
}
|
||||
$bit = 4;
|
||||
$len = ord($der[($bit + 1)]);
|
||||
$bytes = 0;
|
||||
if ($len & 0x80) {
|
||||
$bytes = $len & 0x0f;
|
||||
$len = 0;
|
||||
for ($i = 0; $i < $bytes; $i++) {
|
||||
$len = ($len << 8) | ord($der[$bit + $i + 2]);
|
||||
}
|
||||
}
|
||||
return substr($der, 4, $len + 4);
|
||||
}
|
||||
1251
addon/alipay/data/sdk/AopClient.php
Executable file
1251
addon/alipay/data/sdk/AopClient.php
Executable file
File diff suppressed because it is too large
Load Diff
71
addon/alipay/data/sdk/AopEncrypt.php
Executable file
71
addon/alipay/data/sdk/AopEncrypt.php
Executable file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* 加密工具类
|
||||
*
|
||||
* User: jiehua
|
||||
* Date: 16/3/30
|
||||
* Time: 下午3:25
|
||||
*/
|
||||
|
||||
/**
|
||||
* 加密方法
|
||||
* @param string $str
|
||||
* @return string
|
||||
*/
|
||||
function new_encrypt($str,$screct_key){
|
||||
//AES, 128 模式加密数据 CBC
|
||||
$screct_key = base64_decode($screct_key);
|
||||
$str = trim($str);
|
||||
$str = addPKCS7Padding($str);
|
||||
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128,MCRYPT_MODE_CBC),1);
|
||||
$encrypt_str = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $screct_key, $str, MCRYPT_MODE_CBC);
|
||||
return base64_encode($encrypt_str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解密方法
|
||||
* @param string $str
|
||||
* @return string
|
||||
*/
|
||||
function new_decrypt($str,$screct_key){
|
||||
//AES, 128 模式加密数据 CBC
|
||||
$str = base64_decode($str);
|
||||
$screct_key = base64_decode($screct_key);
|
||||
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128,MCRYPT_MODE_CBC),1);
|
||||
$encrypt_str = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $screct_key, $str, MCRYPT_MODE_CBC);
|
||||
$encrypt_str = trim($encrypt_str);
|
||||
|
||||
$encrypt_str = stripPKSC7Padding($encrypt_str);
|
||||
return $encrypt_str;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充算法
|
||||
* @param string $source
|
||||
* @return string
|
||||
*/
|
||||
function addPKCS7Padding($source){
|
||||
$source = trim($source);
|
||||
$block = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
|
||||
|
||||
$pad = $block - (strlen($source) % $block);
|
||||
if ($pad <= $block) {
|
||||
$char = chr($pad);
|
||||
$source .= str_repeat($char, $pad);
|
||||
}
|
||||
return $source;
|
||||
}
|
||||
/**
|
||||
* 移去填充算法
|
||||
* @param string $source
|
||||
* @return string
|
||||
*/
|
||||
function stripPKSC7Padding($source){
|
||||
$source = trim($source);
|
||||
$char = substr($source, -1);
|
||||
$num = ord($char);
|
||||
if($num==62)return $source;
|
||||
$source = substr($source,0,-$num);
|
||||
return $source;
|
||||
}
|
||||
19
addon/alipay/data/sdk/EncryptParseItem.php
Executable file
19
addon/alipay/data/sdk/EncryptParseItem.php
Executable file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* TODO 补充说明
|
||||
*
|
||||
* User: jiehua
|
||||
* Date: 16/3/30
|
||||
* Time: 下午8:55
|
||||
*/
|
||||
|
||||
class EncryptParseItem {
|
||||
|
||||
|
||||
public $startIndex;
|
||||
|
||||
public $endIndex;
|
||||
|
||||
public $encryptContent;
|
||||
|
||||
}
|
||||
18
addon/alipay/data/sdk/EncryptResponseData.php
Executable file
18
addon/alipay/data/sdk/EncryptResponseData.php
Executable file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* TODO 补充说明
|
||||
*
|
||||
* User: jiehua
|
||||
* Date: 16/3/30
|
||||
* Time: 下午8:51
|
||||
*/
|
||||
|
||||
class EncryptResponseData {
|
||||
|
||||
|
||||
public $realContent;
|
||||
|
||||
public $returnContent;
|
||||
|
||||
|
||||
}
|
||||
17
addon/alipay/data/sdk/SignData.php
Executable file
17
addon/alipay/data/sdk/SignData.php
Executable file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
namespace addon\alipay\data\sdk;
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: jiehua
|
||||
* Date: 15/5/2
|
||||
* Time: 下午6:21
|
||||
*/
|
||||
|
||||
class SignData {
|
||||
|
||||
public $signSourceData=null;
|
||||
|
||||
|
||||
public $sign=null;
|
||||
|
||||
}
|
||||
120
addon/alipay/data/sdk/request/AlipayFundTransToaccountTransferRequest.php
Executable file
120
addon/alipay/data/sdk/request/AlipayFundTransToaccountTransferRequest.php
Executable file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
namespace addon\alipay\data\sdk\request;
|
||||
|
||||
/**
|
||||
* ALIPAY API: alipay.fund.trans.toaccount.transfer request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2018-08-14 14:05:00
|
||||
*/
|
||||
class AlipayFundTransToaccountTransferRequest
|
||||
{
|
||||
/**
|
||||
* 单笔转账到支付宝账户接口
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas["biz_content"] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.fund.trans.toaccount.transfer";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
119
addon/alipay/data/sdk/request/AlipayFundTransUniTransferRequest.php
Executable file
119
addon/alipay/data/sdk/request/AlipayFundTransUniTransferRequest.php
Executable file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
namespace addon\alipay\data\sdk\request;
|
||||
/**
|
||||
* ALIPAY API: alipay.fund.trans.uni.transfer request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2020-04-02 22:40:08
|
||||
*/
|
||||
class AlipayFundTransUniTransferRequest
|
||||
{
|
||||
/**
|
||||
* 支付宝转账支付接口
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas["biz_content"] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.fund.trans.uni.transfer";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
119
addon/alipay/data/sdk/request/AlipayTradeAppPayRequest.php
Executable file
119
addon/alipay/data/sdk/request/AlipayTradeAppPayRequest.php
Executable file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
namespace addon\alipay\data\sdk\request;
|
||||
/**
|
||||
* ALIPAY API: alipay.trade.app.pay request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2018-07-16 16:20:00
|
||||
*/
|
||||
class AlipayTradeAppPayRequest
|
||||
{
|
||||
/**
|
||||
* app支付接口2.0
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas["biz_content"] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.trade.app.pay";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
119
addon/alipay/data/sdk/request/AlipayTradeCancelRequest.php
Executable file
119
addon/alipay/data/sdk/request/AlipayTradeCancelRequest.php
Executable file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ALIPAY API: alipay.trade.cancel request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2018-07-13 17:18:06
|
||||
*/
|
||||
class AlipayTradeCancelRequest
|
||||
{
|
||||
/**
|
||||
* 统一收单交易撤销接口
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array ();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion = "1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt = false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas[ "biz_content" ] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.trade.cancel";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl = $notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl = $returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion = $apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt = $needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
120
addon/alipay/data/sdk/request/AlipayTradeCloseRequest.php
Executable file
120
addon/alipay/data/sdk/request/AlipayTradeCloseRequest.php
Executable file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
namespace addon\alipay\data\sdk\request;
|
||||
|
||||
/**
|
||||
* ALIPAY API: alipay.trade.close request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2018-07-13 17:18:06
|
||||
*/
|
||||
class AlipayTradeCloseRequest
|
||||
{
|
||||
/**
|
||||
* 统一收单交易关闭接口
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas["biz_content"] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.trade.close";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
119
addon/alipay/data/sdk/request/AlipayTradeCreateRequest.php
Executable file
119
addon/alipay/data/sdk/request/AlipayTradeCreateRequest.php
Executable file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
namespace addon\alipay\data\sdk\request;
|
||||
/**
|
||||
* ALIPAY API: alipay.trade.create request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2018-09-01 17:05:01
|
||||
*/
|
||||
class AlipayTradeCreateRequest
|
||||
{
|
||||
/**
|
||||
* 商户通过该接口进行交易的创建下单
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas["biz_content"] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.trade.create";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
118
addon/alipay/data/sdk/request/AlipayTradeCustomsDeclareRequest.php
Executable file
118
addon/alipay/data/sdk/request/AlipayTradeCustomsDeclareRequest.php
Executable file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* ALIPAY API: alipay.trade.customs.declare request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2016-12-08 00:48:24
|
||||
*/
|
||||
class AlipayTradeCustomsDeclareRequest
|
||||
{
|
||||
/**
|
||||
* 统一收单报关接口
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas["biz_content"] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.trade.customs.declare";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
118
addon/alipay/data/sdk/request/AlipayTradeCustomsQueryRequest.php
Executable file
118
addon/alipay/data/sdk/request/AlipayTradeCustomsQueryRequest.php
Executable file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* ALIPAY API: alipay.trade.customs.query request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2018-03-02 14:37:16
|
||||
*/
|
||||
class AlipayTradeCustomsQueryRequest
|
||||
{
|
||||
/**
|
||||
* 查询报关详细信息
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas["biz_content"] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.trade.customs.query";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
118
addon/alipay/data/sdk/request/AlipayTradeFastpayRefundQueryRequest.php
Executable file
118
addon/alipay/data/sdk/request/AlipayTradeFastpayRefundQueryRequest.php
Executable file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* ALIPAY API: alipay.trade.fastpay.refund.query request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2018-07-25 17:25:00
|
||||
*/
|
||||
class AlipayTradeFastpayRefundQueryRequest
|
||||
{
|
||||
/**
|
||||
* 商户可使用该接口查询自已通过alipay.trade.refund提交的退款请求是否执行成功。
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas["biz_content"] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.trade.fastpay.refund.query";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
118
addon/alipay/data/sdk/request/AlipayTradeOrderSettleRequest.php
Executable file
118
addon/alipay/data/sdk/request/AlipayTradeOrderSettleRequest.php
Executable file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* ALIPAY API: alipay.trade.order.settle request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2018-07-13 17:18:06
|
||||
*/
|
||||
class AlipayTradeOrderSettleRequest
|
||||
{
|
||||
/**
|
||||
* 统一收单交易结算接口
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas["biz_content"] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.trade.order.settle";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
118
addon/alipay/data/sdk/request/AlipayTradeOrderinfoSyncRequest.php
Executable file
118
addon/alipay/data/sdk/request/AlipayTradeOrderinfoSyncRequest.php
Executable file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* ALIPAY API: alipay.trade.orderinfo.sync request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2018-07-23 11:40:00
|
||||
*/
|
||||
class AlipayTradeOrderinfoSyncRequest
|
||||
{
|
||||
/**
|
||||
* 支付宝订单信息同步接口
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas["biz_content"] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.trade.orderinfo.sync";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
120
addon/alipay/data/sdk/request/AlipayTradePagePayRequest.php
Executable file
120
addon/alipay/data/sdk/request/AlipayTradePagePayRequest.php
Executable file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace addon\alipay\data\sdk\request;
|
||||
/**
|
||||
* ALIPAY API: alipay.trade.page.pay request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2018-08-14 15:31:43
|
||||
*/
|
||||
class AlipayTradePagePayRequest
|
||||
{
|
||||
/**
|
||||
* 统一收单下单并支付页面接口
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas["biz_content"] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.trade.page.pay";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
120
addon/alipay/data/sdk/request/AlipayTradePayRequest.php
Executable file
120
addon/alipay/data/sdk/request/AlipayTradePayRequest.php
Executable file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
namespace addon\alipay\data\sdk\request;
|
||||
/**
|
||||
* ALIPAY API: alipay.trade.pay request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2018-08-31 11:20:00
|
||||
*/
|
||||
class AlipayTradePayRequest
|
||||
{
|
||||
/**
|
||||
* 用于在线下场景交易一次创建并支付掉
|
||||
修改路由策略到R
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas["biz_content"] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.trade.pay";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
120
addon/alipay/data/sdk/request/AlipayTradePrecreateRequest.php
Executable file
120
addon/alipay/data/sdk/request/AlipayTradePrecreateRequest.php
Executable file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
namespace addon\alipay\data\sdk\request;
|
||||
/**
|
||||
* ALIPAY API: alipay.trade.precreate request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2018-06-14 17:32:25
|
||||
*/
|
||||
class AlipayTradePrecreateRequest
|
||||
{
|
||||
/**
|
||||
* 收银员通过收银台或商户后台调用支付宝接口,生成二维码后,展示给伤脑筋户,由用户扫描二维码完成订单支付。
|
||||
修改路由策略到R
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas["biz_content"] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.trade.precreate";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
121
addon/alipay/data/sdk/request/AlipayTradeQueryRequest.php
Executable file
121
addon/alipay/data/sdk/request/AlipayTradeQueryRequest.php
Executable file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
namespace addon\alipay\data\sdk\request;
|
||||
/**
|
||||
* ALIPAY API: alipay.trade.query request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2018-05-11 18:28:47
|
||||
*/
|
||||
class AlipayTradeQueryRequest
|
||||
{
|
||||
/**
|
||||
* 统一收单线下交易查询
|
||||
* 修改路由策略到R
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array ();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion = "1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt = false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas[ "biz_content" ] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.trade.query";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl = $notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl = $returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion = $apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt = $needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
120
addon/alipay/data/sdk/request/AlipayTradeRefundRequest.php
Executable file
120
addon/alipay/data/sdk/request/AlipayTradeRefundRequest.php
Executable file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace addon\alipay\data\sdk\request;
|
||||
/**
|
||||
* ALIPAY API: alipay.trade.refund request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2018-09-01 17:20:00
|
||||
*/
|
||||
class AlipayTradeRefundRequest
|
||||
{
|
||||
/**
|
||||
* 统一收单交易退款接口
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas["biz_content"] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.trade.refund";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
118
addon/alipay/data/sdk/request/AlipayTradeVendorpayDevicedataUploadRequest.php
Executable file
118
addon/alipay/data/sdk/request/AlipayTradeVendorpayDevicedataUploadRequest.php
Executable file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* ALIPAY API: alipay.trade.vendorpay.devicedata.upload request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2016-12-08 00:51:39
|
||||
*/
|
||||
class AlipayTradeVendorpayDevicedataUploadRequest
|
||||
{
|
||||
/**
|
||||
* 厂商支付授权时上传设备数据接口,目前主要包含三星支付。com
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas["biz_content"] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.trade.vendorpay.devicedata.upload";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
120
addon/alipay/data/sdk/request/AlipayTradeWapPayRequest.php
Executable file
120
addon/alipay/data/sdk/request/AlipayTradeWapPayRequest.php
Executable file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace addon\alipay\data\sdk\request;
|
||||
/**
|
||||
* ALIPAY API: alipay.trade.wap.pay request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2018-08-06 12:35:00
|
||||
*/
|
||||
class AlipayTradeWapPayRequest
|
||||
{
|
||||
/**
|
||||
* 手机网站支付接口2.0
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas["biz_content"] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.trade.wap.pay";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
47
addon/alipay/event/AuthcodePay.php
Executable file
47
addon/alipay/event/AuthcodePay.php
Executable file
@@ -0,0 +1,47 @@
|
||||
<?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\alipay\event;
|
||||
|
||||
use addon\alipay\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 = [ 25, 26, 27, 28, 29, 30 ];
|
||||
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($site_id);
|
||||
$result = $pay_model->micropay(array_merge($params, $pay_info));
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
27
addon/alipay/event/Install.php
Executable file
27
addon/alipay/event/Install.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\alipay\event;
|
||||
|
||||
/**
|
||||
* 应用安装
|
||||
*/
|
||||
class Install
|
||||
{
|
||||
/**
|
||||
* 执行安装
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return success();
|
||||
}
|
||||
}
|
||||
33
addon/alipay/event/Pay.php
Executable file
33
addon/alipay/event/Pay.php
Executable file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\alipay\event;
|
||||
|
||||
use addon\alipay\model\Pay as PayModel;
|
||||
|
||||
/**
|
||||
* 生成支付
|
||||
*/
|
||||
class Pay
|
||||
{
|
||||
/**
|
||||
* 支付方式及配置
|
||||
*/
|
||||
public function handle($param)
|
||||
{
|
||||
if ($param[ "pay_type" ] == "alipay") {
|
||||
if (in_array($param[ "app_type" ], [ "h5", "app", "pc", "aliapp", 'wechat' ])) {
|
||||
$pay_model = new PayModel($param[ 'site_id' ], $param[ "app_type" ] == 'aliapp');
|
||||
$res = $pay_model->pay($param);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
41
addon/alipay/event/PayClose.php
Executable file
41
addon/alipay/event/PayClose.php
Executable file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\alipay\event;
|
||||
|
||||
use addon\alipay\model\Pay as PayModel;
|
||||
|
||||
/**
|
||||
* 关闭支付
|
||||
*/
|
||||
class PayClose
|
||||
{
|
||||
/**
|
||||
* 关闭支付
|
||||
* @param $params
|
||||
* @return \addon\alipay\model\multitype|array
|
||||
*/
|
||||
public function handle($params)
|
||||
{
|
||||
$mch_info = json_decode($params['mch_info'], true);
|
||||
$pay_type = $mch_info['pay_type'] ?? '';
|
||||
if($pay_type == 'alipay'){
|
||||
try {
|
||||
$pay_model = new PayModel($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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
41
addon/alipay/event/PayNotify.php
Executable file
41
addon/alipay/event/PayNotify.php
Executable file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\alipay\event;
|
||||
|
||||
use addon\alipay\model\Pay as PayModel;
|
||||
use app\model\system\Pay as PayCommon;
|
||||
|
||||
/**
|
||||
* 支付回调
|
||||
*/
|
||||
class PayNotify
|
||||
{
|
||||
/**
|
||||
* 支付方式及配置
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
if (isset($_POST[ 'out_trade_no' ])) {
|
||||
$out_trade_no = $_POST[ 'out_trade_no' ];
|
||||
$pay = new PayCommon();
|
||||
$pay_info = $pay->getPayInfo($out_trade_no)[ 'data' ];
|
||||
if (empty($pay_info)) return false;
|
||||
|
||||
if ($_POST[ 'total_amount' ] != $pay_info[ 'pay_money' ]) {
|
||||
return false;
|
||||
}
|
||||
$mch_info = empty($pay_info[ 'mch_info' ]) ? [] : json_decode($pay_info[ 'mch_info' ], true);
|
||||
|
||||
$pay_model = new PayModel($pay_info[ 'site_id' ], $mch_info[ 'is_aliapp' ] ?? 0);
|
||||
$pay_model->payNotify();
|
||||
}
|
||||
}
|
||||
}
|
||||
47
addon/alipay/event/PayOrderQuery.php
Executable file
47
addon/alipay/event/PayOrderQuery.php
Executable file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\alipay\event;
|
||||
|
||||
use addon\alipay\model\Config as ConfigModel;
|
||||
use addon\alipay\model\Pay as PayModel;
|
||||
use addon\wechat\model\Config as WechatConfig;
|
||||
use addon\wechatpay\model\Config;
|
||||
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'] ?? 'alipay';
|
||||
if($pay_type == 'alipay'){
|
||||
$config_model = new ConfigModel();
|
||||
$pay_config = $config_model->getPayConfig($pay_info[ 'site_id' ])[ 'data' ][ 'value' ];
|
||||
if (!empty($pay_config) && $pay_config[ 'pay_status' ] != 2) {
|
||||
$pay_common = new PayModel($pay_info[ 'site_id' ]);
|
||||
$res = $pay_common->orderQuery($pay_info);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
}catch (\Throwable $e) {
|
||||
return error(-1, $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
33
addon/alipay/event/PayRefund.php
Executable file
33
addon/alipay/event/PayRefund.php
Executable file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\alipay\event;
|
||||
|
||||
use addon\alipay\model\Pay as PayModel;
|
||||
|
||||
/**
|
||||
* 原路退款
|
||||
*/
|
||||
class PayRefund
|
||||
{
|
||||
/**
|
||||
* 关闭支付
|
||||
*/
|
||||
public function handle($params)
|
||||
{
|
||||
if ($params[ "pay_info" ][ "pay_type" ] == "alipay") {
|
||||
$mch_info = empty($params[ 'pay_info' ][ 'mch_info' ]) ? [] : json_decode($params[ 'pay_info' ][ 'mch_info' ], true);
|
||||
|
||||
$pay_model = new PayModel($params[ 'site_id' ], $mch_info[ 'is_aliapp' ] ?? 0);
|
||||
$result = $pay_model->refund($params);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
42
addon/alipay/event/PayTransfer.php
Executable file
42
addon/alipay/event/PayTransfer.php
Executable file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\alipay\event;
|
||||
|
||||
use addon\alipay\model\Pay;
|
||||
use addon\alipay\model\Config;
|
||||
|
||||
class PayTransfer
|
||||
{
|
||||
public function handle(array $params)
|
||||
{
|
||||
if ($params[ 'transfer_type' ] == 'alipay') {
|
||||
$pay = new Pay($params[ 'site_id' ]);
|
||||
|
||||
$config_model = new Config();
|
||||
$config_result = $config_model->getPayConfig($params[ 'site_id' ]);
|
||||
$config = $config_result[ "data" ];
|
||||
if (!empty($config[ 'value' ])) {
|
||||
$config_info = $config[ "value" ];
|
||||
$countersign_type = $config_info['countersign_type'] ?? 0;
|
||||
if ($countersign_type == 0) {
|
||||
$res = $pay->payTransfer($params);
|
||||
return $res;
|
||||
} else {
|
||||
$res = $pay->payNewTransfer($params);
|
||||
return $res;
|
||||
}
|
||||
} else {
|
||||
$res = $pay->payTransfer($params);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
51
addon/alipay/event/PayType.php
Executable file
51
addon/alipay/event/PayType.php
Executable file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\alipay\event;
|
||||
|
||||
use addon\alipay\model\Config;
|
||||
|
||||
/**
|
||||
* 支付方式 (后台调用)
|
||||
*/
|
||||
class PayType
|
||||
{
|
||||
/**
|
||||
* 支付方式及配置
|
||||
*/
|
||||
public function handle($param)
|
||||
{
|
||||
$config_model = new Config();
|
||||
$config_result = $config_model->getPayConfig($param[ 'site_id' ] ?? 1);
|
||||
$config = $config_result[ "data" ][ "value" ] ?? [];
|
||||
$pay_status = $config[ "pay_status" ] ?? 0;
|
||||
|
||||
$app_type = $param['app_type'] ?? '';
|
||||
if (!empty($app_type)) {
|
||||
if (!in_array($app_type, [ "h5", "app", "pc", "aliapp", 'wechat' ])) {
|
||||
return '';
|
||||
}
|
||||
if ($app_type != 'aliapp' && $pay_status == 0) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
$info = array (
|
||||
"pay_type" => "alipay",
|
||||
"pay_type_name" => "支付宝支付",
|
||||
"edit_url" => "alipay://shop/pay/config",
|
||||
"shop_url" => "alipay://shop/pay/config",
|
||||
"logo" => "addon/alipay/icon.png",
|
||||
"desc" => "支付宝网站(www.alipay.com) 是国内先进的网上支付平台。",
|
||||
"pay_status" => $pay_status,
|
||||
);
|
||||
return $info;
|
||||
}
|
||||
}
|
||||
39
addon/alipay/event/TransferType.php
Executable file
39
addon/alipay/event/TransferType.php
Executable file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\alipay\event;
|
||||
|
||||
use addon\alipay\model\Config;
|
||||
|
||||
class TransferType
|
||||
{
|
||||
public function handle(array $param)
|
||||
{
|
||||
|
||||
$app_type = $param['app_type'] ?? '';
|
||||
if (!empty($app_type)) {
|
||||
if (!in_array($app_type, [ "h5", "app", "pc", "aliapp" ])) {
|
||||
return '';
|
||||
}
|
||||
$config_model = new Config();
|
||||
$config_result = $config_model->getPayConfig($param[ 'site_id' ]);
|
||||
$config = $config_result[ "data" ][ "value" ] ?? [];
|
||||
$transfer_status = $config[ "transfer_status" ] ?? 0;
|
||||
if ($transfer_status == 0) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
$info = array (
|
||||
"type" => "alipay",
|
||||
"type_name" => "支付宝",
|
||||
);
|
||||
return $info;
|
||||
}
|
||||
}
|
||||
26
addon/alipay/event/UnInstall.php
Executable file
26
addon/alipay/event/UnInstall.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\alipay\event;
|
||||
|
||||
/**
|
||||
* 应用卸载
|
||||
*/
|
||||
class UnInstall
|
||||
{
|
||||
/**
|
||||
* 执行卸载
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return error(-1, "系统插件不得删除");
|
||||
}
|
||||
}
|
||||
BIN
addon/alipay/icon.png
Executable file
BIN
addon/alipay/icon.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
96
addon/alipay/model/Config.php
Executable file
96
addon/alipay/model/Config.php
Executable file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\alipay\model;
|
||||
|
||||
use app\model\system\Config as ConfigModel;
|
||||
use app\model\BaseModel;
|
||||
|
||||
/**
|
||||
* 支付宝支付配置
|
||||
*/
|
||||
class Config extends BaseModel
|
||||
{
|
||||
|
||||
private $encrypt = '******';
|
||||
|
||||
/**
|
||||
* 设置支付配置
|
||||
* @param $data
|
||||
* @param int $site_id
|
||||
* @param string $app_module
|
||||
* @return array
|
||||
*/
|
||||
public function setPayConfig($data, $site_id = 0, $app_module = 'shop')
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
|
||||
// 未加密前的数据
|
||||
$original_config = $this->getPayConfig($site_id)[ 'data' ][ 'value' ];
|
||||
|
||||
// 检测数据是否发生变化,如果没有变化,则保持未加密前的数据
|
||||
if (!empty($data[ 'private_key' ]) && $data[ 'private_key' ] == $this->encrypt) {
|
||||
$data[ 'private_key' ] = $original_config[ 'private_key' ]; // 应用私钥
|
||||
}
|
||||
if (!empty($data[ 'public_key' ]) && $data[ 'public_key' ] == $this->encrypt) {
|
||||
$data[ 'public_key' ] = $original_config[ 'public_key' ]; // 应用公钥
|
||||
}
|
||||
if (!empty($data[ 'alipay_public_key' ]) && $data[ 'alipay_public_key' ] == $this->encrypt) {
|
||||
$data[ 'alipay_public_key' ] = $original_config[ 'alipay_public_key' ]; // 支付宝公钥
|
||||
}
|
||||
if (!empty($data[ 'public_key_crt' ]) && $data[ 'public_key_crt' ] == $this->encrypt) {
|
||||
$data[ 'public_key_crt' ] = $original_config[ 'public_key_crt' ]; // 应用公钥证书
|
||||
}
|
||||
if (!empty($data[ 'alipay_public_key_crt' ]) && $data[ 'alipay_public_key_crt' ] == $this->encrypt) {
|
||||
$data[ 'alipay_public_key_crt' ] = $original_config[ 'alipay_public_key_crt' ]; // 支付宝公钥证书
|
||||
}
|
||||
if (!empty($data[ 'alipay_with_crt' ]) && $data[ 'alipay_with_crt' ] == $this->encrypt) {
|
||||
$data[ 'alipay_with_crt' ] = $original_config[ 'alipay_with_crt' ]; // 支付宝根证书
|
||||
}
|
||||
|
||||
$res = $config->setConfig($data, '支付宝支付配置', 1, [ [ 'site_id', '=', $site_id ], [ 'app_module', '=', $app_module ], [ 'config_key', '=', 'ALI_PAY_CONFIG' ] ]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取支付配置
|
||||
* @param int $site_id
|
||||
* @param string $app_module
|
||||
* @param bool $need_encrypt 是否需要加密数据,true:加密、false:不加密
|
||||
* @return array
|
||||
*/
|
||||
public function getPayConfig($site_id = 0, $app_module = 'shop', $need_encrypt = false)
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', $app_module ], [ 'config_key', '=', 'ALI_PAY_CONFIG' ] ]);
|
||||
if (!empty($res[ 'data' ][ 'value' ]) && $need_encrypt) {
|
||||
// 加密敏感信息
|
||||
if (!empty($res[ 'data' ][ 'value' ][ 'private_key' ])) {
|
||||
$res[ 'data' ][ 'value' ][ 'private_key' ] = $this->encrypt; // 应用私钥
|
||||
}
|
||||
if (!empty($res[ 'data' ][ 'value' ][ 'public_key' ])) {
|
||||
$res[ 'data' ][ 'value' ][ 'public_key' ] = $this->encrypt; // 应用公钥
|
||||
}
|
||||
if (!empty($res[ 'data' ][ 'value' ][ 'alipay_public_key' ])) {
|
||||
$res[ 'data' ][ 'value' ][ 'alipay_public_key' ] = $this->encrypt; // 支付宝公钥
|
||||
}
|
||||
if (!empty($res[ 'data' ][ 'value' ][ 'public_key_crt' ])) {
|
||||
$res[ 'data' ][ 'value' ][ 'public_key_crt' ] = $this->encrypt; // 应用公钥证书
|
||||
}
|
||||
if (!empty($res[ 'data' ][ 'value' ][ 'alipay_public_key_crt' ])) {
|
||||
$res[ 'data' ][ 'value' ][ 'alipay_public_key_crt' ] = $this->encrypt; // 支付宝公钥证书
|
||||
}
|
||||
if (!empty($res[ 'data' ][ 'value' ][ 'alipay_with_crt' ])) {
|
||||
$res[ 'data' ][ 'value' ][ 'alipay_with_crt' ] = $this->encrypt; // 支付宝根证书
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
508
addon/alipay/model/Pay.php
Executable file
508
addon/alipay/model/Pay.php
Executable file
@@ -0,0 +1,508 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\alipay\model;
|
||||
|
||||
use addon\alipay\data\sdk\AopClient;
|
||||
use addon\alipay\data\sdk\request\AlipayFundTransToaccountTransferRequest;
|
||||
use addon\alipay\data\sdk\request\AlipayTradeAppPayRequest;
|
||||
use addon\alipay\data\sdk\request\AlipayTradeCloseRequest;
|
||||
use addon\alipay\data\sdk\request\AlipayTradeCreateRequest;
|
||||
use addon\alipay\data\sdk\request\AlipayTradePagePayRequest;
|
||||
use addon\alipay\data\sdk\request\AlipayTradeRefundRequest;
|
||||
use addon\alipay\data\sdk\request\AlipayTradeWapPayRequest;
|
||||
use addon\alipay\data\sdk\request\AlipayTradePrecreateRequest;
|
||||
use addon\alipay\data\sdk\request\AlipayTradePayRequest;
|
||||
use addon\alipay\data\sdk\request\AlipayTradeQueryRequest;
|
||||
use app\model\BaseModel;
|
||||
use app\model\system\Cron;
|
||||
use app\model\system\Pay as PayCommon;
|
||||
use addon\alipay\data\sdk\request\AlipayFundTransUniTransferRequest;
|
||||
use addon\alipay\data\sdk\AopCertClient;
|
||||
use app\model\system\Pay as PayModel;
|
||||
use addon\aliapp\model\Config as AliappConfig;
|
||||
use think\facade\Log;
|
||||
|
||||
/**
|
||||
* 支付宝支付配置
|
||||
*/
|
||||
class Pay extends BaseModel
|
||||
{
|
||||
|
||||
public $aop;
|
||||
|
||||
private $is_aliapp = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param $site_id
|
||||
* @param int $is_aliapp 是否是小程序
|
||||
*/
|
||||
function __construct($site_id, $is_aliapp = 0)
|
||||
{
|
||||
$this->is_aliapp = $is_aliapp;
|
||||
|
||||
try {
|
||||
// 获取支付宝支付参数(统一支付到平台账户)
|
||||
if ($is_aliapp) {
|
||||
$config_info = ( new AliappConfig() )->getAliappConfig($site_id)[ 'data' ][ 'value' ];
|
||||
} else {
|
||||
$config_info = ( new Config() )->getPayConfig($site_id)[ 'data' ][ 'value' ];
|
||||
}
|
||||
|
||||
if (!empty($config_info)) {
|
||||
$countersign_type = $config_info[ 'countersign_type' ] ?? 0;
|
||||
|
||||
if ($countersign_type == 1) {
|
||||
$appCertPath = $config_info[ "public_key_crt" ] ?? "";
|
||||
$alipayCertPath = $config_info[ "alipay_public_key_crt" ] ?? "";
|
||||
$rootCertPath = $config_info[ "alipay_with_crt" ] ?? "";
|
||||
|
||||
$this->aop = new AopCertClient();
|
||||
//调用getPublicKey从支付宝公钥证书中提取公钥
|
||||
$this->aop->alipayrsaPublicKey = $this->aop->getPublicKey($alipayCertPath);
|
||||
//是否校验自动下载的支付宝公钥证书,如果开启校验要保证支付宝根证书在有效期内
|
||||
$this->aop->isCheckAlipayPublicCert = false;
|
||||
//调用getCertSN获取证书序列号
|
||||
$this->aop->appCertSN = $this->aop->getCertSN($appCertPath);
|
||||
//调用getRootCertSN获取支付宝根证书序列号
|
||||
$this->aop->alipayRootCertSN = $this->aop->getRootCertSN($rootCertPath);
|
||||
|
||||
} else {
|
||||
// 获取支付宝支付参数(统一支付到平台账户)
|
||||
$this->aop = new AopClient();
|
||||
$this->aop->alipayrsaPublicKey = $config_info[ 'public_key' ] ?? "";
|
||||
$this->aop->alipayPublicKey = $config_info[ 'alipay_public_key' ] ?? "";
|
||||
}
|
||||
$this->aop->appId = $config_info[ "app_id" ] ?? "";
|
||||
$this->aop->rsaPrivateKey = $config_info[ 'private_key' ] ?? "";
|
||||
$this->aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
|
||||
$this->aop->apiVersion = '1.0';
|
||||
$this->aop->signType = 'RSA2';
|
||||
$this->aop->postCharset = 'UTF-8';
|
||||
$this->aop->format = 'json';
|
||||
|
||||
}
|
||||
// else{
|
||||
// return $this->error('', '支付宝支付未配置');
|
||||
// }
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', '支付宝配置错误');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成支付
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
public function pay($param)
|
||||
{
|
||||
//构造要请求的参数数组,无需改动
|
||||
$parameter = array (
|
||||
"out_trade_no" => $param[ "out_trade_no" ],
|
||||
"subject" => str_sub($param[ "pay_body" ], 15),
|
||||
"total_amount" => (float) $param[ "pay_money" ],
|
||||
"body" => str_sub($param[ "pay_body" ], 60),
|
||||
"product_code" => 'FAST_INSTANT_TRADE_PAY',
|
||||
);
|
||||
|
||||
switch ( $param[ "app_type" ] ) {
|
||||
case "h5":
|
||||
$request = new AlipayTradeWapPayRequest();
|
||||
break;
|
||||
case "pc":
|
||||
$request = new AlipayTradePagePayRequest();
|
||||
break;
|
||||
case "app":
|
||||
$request = new AlipayTradeAppPayRequest();
|
||||
break;
|
||||
case 'wechat':
|
||||
$request = new AlipayTradeWapPayRequest();
|
||||
break;
|
||||
case 'cashier':
|
||||
$request = new AlipayTradePrecreateRequest();
|
||||
break;
|
||||
case 'aliapp':
|
||||
$parameter[ 'product_code' ] = 'FACE_TO_FACE_PAYMENT';
|
||||
|
||||
$member_info = model('member')->getInfo([ [ "member_id", "=", $param[ "member_id" ] ] ], 'ali_openid');
|
||||
if (empty($member_info)) return $this->error(-1, '未获取到会员信息');
|
||||
|
||||
$parameter[ 'buyer_id' ] = $member_info[ 'ali_openid' ];
|
||||
$request = new AlipayTradeCreateRequest();
|
||||
break;
|
||||
}
|
||||
|
||||
$parameter = json_encode($parameter);
|
||||
$request->setBizContent($parameter);
|
||||
$request->SetReturnUrl($param[ "return_url" ]);
|
||||
$request->SetNotifyUrl($param[ "notify_url" ]);
|
||||
|
||||
//清除绑定商户数据
|
||||
$pay_model = new PayModel();
|
||||
$clear_res = $pay_model->clearMchPay($param[ "out_trade_no" ], 'alipay');
|
||||
if($clear_res['code'] < 0) return $clear_res;
|
||||
|
||||
try {
|
||||
if ($param[ "app_type" ] == 'h5' || $param[ "app_type" ] == 'wechat' || $param[ "app_type" ] == 'pc') {
|
||||
$result = $this->aop->pageExecute($request, 'get');
|
||||
$pay_model->bindMchPay($param[ "out_trade_no" ], [
|
||||
"pay_type" => 'alipay',
|
||||
"is_aliapp" => $this->is_aliapp,
|
||||
]);
|
||||
return $this->success([
|
||||
'type' => 'url',
|
||||
'data' => $result
|
||||
]);
|
||||
} elseif ($param[ "app_type" ] == 'app') {
|
||||
$result = $this->aop->sdkExecute($request);
|
||||
if (strpos(get_class($this->aop), 'AopClient') !== false) {
|
||||
$pay_model->bindMchPay($param[ "out_trade_no" ], [
|
||||
"pay_type" => 'alipay',
|
||||
"is_aliapp" => $this->is_aliapp,
|
||||
]);
|
||||
return $this->success([
|
||||
'type' => 'url',
|
||||
'data' => $result
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
$result = $this->aop->execute($request);
|
||||
if($result !== false){
|
||||
$pay_model->bindMchPay($param[ "out_trade_no" ], [
|
||||
"pay_type" => 'alipay',
|
||||
"is_aliapp" => $this->is_aliapp,
|
||||
]);
|
||||
}
|
||||
}
|
||||
if ($result === false) return $this->error('', '支付宝发起支付失败');
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
|
||||
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
|
||||
$resultCode = $result->$responseNode->code;
|
||||
if (!empty($resultCode) && $resultCode == 10000) {
|
||||
switch ( $param[ "app_type" ] ) {
|
||||
case 'cashier':
|
||||
return $this->success([
|
||||
'type' => 'qrcode',
|
||||
'data' => [
|
||||
'qrcode' => $result->$responseNode->qr_code
|
||||
]
|
||||
]);
|
||||
break;
|
||||
case 'aliapp':
|
||||
return $this->success([
|
||||
'type' => 'data',
|
||||
'data' => [
|
||||
'orderInfo' => $result->$responseNode->trade_no
|
||||
]
|
||||
]);
|
||||
break;
|
||||
default:
|
||||
return $this->success();
|
||||
}
|
||||
} else {
|
||||
return $this->error("", $result->$responseNode->sub_msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付关闭
|
||||
* @param $param
|
||||
* @return array
|
||||
* @throws \think\Exception
|
||||
*/
|
||||
public function close($param)
|
||||
{
|
||||
$pay_order_result = $this->get($param[ "out_trade_no" ]);
|
||||
if($pay_order_result['code'] >= 0 && $pay_order_result['data']['trade_status'] != 'TRADE_CLOSED'){
|
||||
if(in_array($pay_order_result['data']['trade_status'], ['TRADE_SUCCESS','TRADE_FINISHED'])){
|
||||
return $this->error([ 'is_paid' => 1, 'pay_type' => 'alipay'], '支付宝已支付不可关闭');
|
||||
}
|
||||
//关闭请求
|
||||
$parameter = array (
|
||||
"out_trade_no" => $param[ "out_trade_no" ]
|
||||
);
|
||||
$request = new AlipayTradeCloseRequest();
|
||||
$request->setBizContent(json_encode($parameter));
|
||||
$result = $this->aop->execute($request);
|
||||
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
|
||||
$resultCode = $result->$responseNode->code;
|
||||
$sub_code = $result->$responseNode->sub_code;
|
||||
if($resultCode != 10000 && in_array($sub_code, ['ACQ.TRADE_STATUS_ERROR', 'ACQ.REASON_TRADE_STATUS_INVALID', 'ACQ.REASON_ILLEGAL_STATUS'])){
|
||||
return $this->error(null, $result->$responseNode->sub_msg);
|
||||
}
|
||||
}
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付宝支付原路返回
|
||||
* @param array $param 支付参数
|
||||
* @return array
|
||||
* @throws \think\Exception
|
||||
*/
|
||||
public function refund($param)
|
||||
{
|
||||
$pay_info = $param[ "pay_info" ];
|
||||
$refund_no = $param[ "refund_no" ];
|
||||
$out_trade_no = $pay_info[ "trade_no" ] ?? '';
|
||||
$refund_fee = $param[ "refund_fee" ];
|
||||
$parameter = array (
|
||||
'trade_no' => $out_trade_no,
|
||||
'refund_amount' => sprintf("%.2f", $refund_fee),
|
||||
'out_request_no' => $refund_no
|
||||
);
|
||||
// 建立请求
|
||||
$request = new AlipayTradeRefundRequest ();
|
||||
$request->setBizContent(json_encode($parameter));
|
||||
$result = $this->aop->execute($request);
|
||||
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
|
||||
$resultCode = $result->$responseNode->code;
|
||||
if (!empty($resultCode) && $resultCode == 10000) {
|
||||
return $this->success();
|
||||
} else {
|
||||
return $this->error("", $result->$responseNode->sub_msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付宝转账
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
public function payTransfer($param)
|
||||
{
|
||||
try {
|
||||
$config_model = new Config();
|
||||
$config_result = $config_model->getPayConfig($param[ 'site_id' ]);
|
||||
if ($config_result[ 'code' ] < 0) return $config_result;
|
||||
$config = $config_result[ 'data' ][ 'value' ];
|
||||
if (empty($config)) return $this->error([], '未配置支付宝支付');
|
||||
if (!$config[ 'transfer_status' ]) return $this->error([], '未启用支付宝转账');
|
||||
|
||||
$parameter = [
|
||||
'out_biz_no' => $param[ 'out_trade_no' ],
|
||||
'payee_type' => 'ALIPAY_LOGONID',
|
||||
'payee_account' => $param[ "account_number" ],
|
||||
'amount' => sprintf("%.2f", $param[ 'amount' ]),
|
||||
'payee_real_name' => $param[ "real_name" ],
|
||||
'remark' => $param[ "desc" ]
|
||||
];
|
||||
// 建立请求
|
||||
$request = new AlipayFundTransToaccountTransferRequest();
|
||||
$request->setBizContent(json_encode($parameter));
|
||||
$result = $this->aop->execute($request);
|
||||
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
|
||||
$resultCode = $result->$responseNode->code;
|
||||
if (!empty($resultCode) && $resultCode == 10000) {
|
||||
return $this->success([
|
||||
'out_trade_no' => $result->$responseNode->out_biz_no, // 商户交易号
|
||||
'payment_no' => $result->$responseNode->order_id, // 微信付款单号
|
||||
'payment_time' => date_to_time($result->$responseNode->pay_date) // 付款成功时间
|
||||
]);
|
||||
} else {
|
||||
return $this->error([], $result->$responseNode->sub_msg);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error([], $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 异步完成支付
|
||||
* @param $param
|
||||
*/
|
||||
public function payNotify()
|
||||
{
|
||||
|
||||
// Log::write('pay_notifiy_log:alipay:'.json_encode(input()), 'notice');
|
||||
try {
|
||||
$res = $this->aop->rsaCheckV1($_POST, $this->aop->alipayrsaPublicKey, $this->aop->signType);
|
||||
if ($res) { // 验证成功
|
||||
$out_trade_no = $_POST[ 'out_trade_no' ];
|
||||
// 支付宝交易号
|
||||
$trade_no = $_POST[ 'trade_no' ];
|
||||
// 交易状态
|
||||
$trade_status = $_POST[ 'trade_status' ];
|
||||
$pay_common = new PayCommon();
|
||||
if ($trade_status == "TRADE_SUCCESS") {
|
||||
$retval = $pay_common->onlinePay($out_trade_no, "alipay", $trade_no, "alipay");
|
||||
}
|
||||
echo "success";
|
||||
} else {
|
||||
// 验证失败
|
||||
echo "fail";
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
echo "fail";
|
||||
}
|
||||
}
|
||||
|
||||
public function payNewTransfer($param)
|
||||
{
|
||||
try {
|
||||
$config_model = new Config();
|
||||
$config_result = $config_model->getPayConfig($param[ 'site_id' ]);
|
||||
if ($config_result[ 'code' ] < 0) return $config_result;
|
||||
$config = $config_result[ 'data' ][ 'value' ];
|
||||
if (empty($config)) return $this->error([], '未配置支付宝支付');
|
||||
if (!$config[ 'transfer_status' ]) return $this->error([], '未启用支付宝转账');
|
||||
|
||||
$parameter = [
|
||||
'out_biz_no' => $param[ 'out_trade_no' ],
|
||||
'trans_amount' => sprintf("%.2f", $param[ 'amount' ]),
|
||||
'product_code' => 'TRANS_ACCOUNT_NO_PWD',
|
||||
'biz_scene' => 'DIRECT_TRANSFER',
|
||||
'order_title' => '支付宝转账',
|
||||
'remark' => $param[ "desc" ],
|
||||
'payee_info' => [
|
||||
'identity' => $param[ "account_number" ],
|
||||
'identity_type' => "ALIPAY_LOGON_ID",
|
||||
'name' => $param[ "real_name" ]
|
||||
]
|
||||
];
|
||||
|
||||
// 建立请求
|
||||
$request = new AlipayFundTransUniTransferRequest();
|
||||
$request->setBizContent(json_encode($parameter));
|
||||
$result = $this->aop->execute($request);
|
||||
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
|
||||
$resultCode = $result->$responseNode->code;
|
||||
if (!empty($resultCode) && $resultCode == 10000) {
|
||||
return $this->success([
|
||||
'out_trade_no' => $result->$responseNode->out_biz_no, // 商户交易号
|
||||
'payment_no' => $result->$responseNode->order_id, // 微信付款单号
|
||||
'payment_time' => date_to_time($result->$responseNode->trans_date) // 付款成功时间
|
||||
]);
|
||||
} else {
|
||||
return $this->error([], $result->$responseNode->sub_msg);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error([], $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 付款码支付
|
||||
* @param $param
|
||||
* @return array|mixed|void
|
||||
*/
|
||||
public function micropay($param)
|
||||
{
|
||||
try {
|
||||
$pay_model = new PayModel();
|
||||
|
||||
//清空绑定支付数据
|
||||
$clear_res = $pay_model->clearMchPay($param[ "out_trade_no" ], 'alipay');
|
||||
if($clear_res['code'] < 0) return $clear_res;
|
||||
//绑定支付数据
|
||||
$pay_model->bindMchPay($param[ "out_trade_no" ], [
|
||||
"pay_type" => 'alipay',
|
||||
"is_aliapp" => $this->is_aliapp,
|
||||
]);
|
||||
|
||||
//构造要请求的参数数组,无需改动
|
||||
$parameter = array (
|
||||
"out_trade_no" => $param[ "out_trade_no" ],
|
||||
"subject" => str_sub($param[ "pay_body" ], 15),
|
||||
"total_amount" => (float) $param[ "pay_money" ],
|
||||
"scene" => "bar_code",
|
||||
"auth_code" => $param[ 'auth_code' ],
|
||||
);
|
||||
$parameter = json_encode($parameter);
|
||||
$request = new AlipayTradePayRequest();
|
||||
$request->setBizContent($parameter);
|
||||
$result = $this->aop->execute($request);
|
||||
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
|
||||
$resultCode = $result->$responseNode->code;
|
||||
Log::write('支付宝—付款码支付,result:' . json_encode($result));
|
||||
Log::write('支付宝—付款码支付,resultCode:' . json_encode($resultCode));
|
||||
if (!empty($resultCode)) {
|
||||
if ($resultCode == 10000) {
|
||||
return $pay_model->onlinePay($param[ 'out_trade_no' ], 'alipay', $result->$responseNode->trade_no, 'alipay');
|
||||
} else if ($resultCode == 10003) {
|
||||
// 等待用户付款
|
||||
( new Cron() )->addCron(1, 0, "查询付款码支付结果", "PayOrderQuery", time() + 3, $param[ 'id' ]);
|
||||
return $this->error([], $result->$responseNode->sub_msg);
|
||||
} else {
|
||||
return $this->error([], $result->$responseNode->sub_msg);
|
||||
}
|
||||
} else {
|
||||
return $this->error([], $result->$responseNode->sub_msg);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error([], $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// todo 查询交易信息【AlipayTradeQueryRequest】 https://opendocs.alipay.com/open/194/106039?pathHash=5b8cf9e6
|
||||
public function orderQuery($param)
|
||||
{
|
||||
try {
|
||||
//构造要请求的参数数组,无需改动
|
||||
$parameter = array (
|
||||
"out_trade_no" => $param[ "out_trade_no" ],
|
||||
);
|
||||
$parameter = json_encode($parameter);
|
||||
$request = new AlipayTradeQueryRequest();
|
||||
$request->setBizContent($parameter);
|
||||
$result = $this->aop->execute($request);
|
||||
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
|
||||
$resultCode = $result->$responseNode->code;
|
||||
Log::write('alipay_orderQuery' . json_encode($result));
|
||||
Log::write('alipay_orderQuery_$resultCode' . json_encode($resultCode));
|
||||
if (!empty($resultCode) && $resultCode == 10000) {
|
||||
if ($result->$responseNode->trade_status == 'TRADE_SUCCESS') {
|
||||
$pay_common = new PayModel();
|
||||
return $res = $pay_common->onlinePay($param[ 'out_trade_no' ], 'alipay', $result->$responseNode->trade_no, 'alipay');
|
||||
} else {
|
||||
$cron_model = new Cron();
|
||||
$cron_model->deleteCron([ [ 'event', '=', 'PayOrderQuery' ], [ 'relate_id', '=', $param[ 'id' ] ] ]);
|
||||
$cron_model->addCron(1, 0, "查询付款码支付结果", "PayOrderQuery", time() + 3, $param[ 'id' ]);
|
||||
}
|
||||
|
||||
} else {
|
||||
return $this->error([], $result->$responseNode->sub_msg);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error([], $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询订单信息
|
||||
* @param $out_trade_no
|
||||
* @return array
|
||||
* @throws \think\Exception
|
||||
*/
|
||||
public function get($out_trade_no)
|
||||
{
|
||||
$parameter = array (
|
||||
"out_trade_no" => $out_trade_no
|
||||
);
|
||||
// 建立请求
|
||||
$request = new AlipayTradeQueryRequest();
|
||||
$request->setBizContent(json_encode($parameter));
|
||||
$result = $this->aop->execute($request);
|
||||
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
|
||||
$resultCode = $result->$responseNode->code;
|
||||
|
||||
if (!empty($resultCode) && $resultCode == 10000) {
|
||||
return $this->success(json_decode(json_encode($result->$responseNode), true));
|
||||
} else {
|
||||
return $this->error([], $result->$responseNode->sub_msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
94
addon/alipay/shop/controller/Pay.php
Executable file
94
addon/alipay/shop/controller/Pay.php
Executable file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\alipay\shop\controller;
|
||||
|
||||
use addon\alipay\model\Config as ConfigModel;
|
||||
use app\shop\controller\BaseShop;
|
||||
use think\facade\Config;
|
||||
use app\model\upload\Upload;
|
||||
|
||||
/**
|
||||
* 支付宝 控制器
|
||||
*/
|
||||
class Pay extends BaseShop
|
||||
{
|
||||
public function config()
|
||||
{
|
||||
$config_model = new ConfigModel();
|
||||
if (request()->isJson()) {
|
||||
$app_id = input("app_id", "");//支付宝应用ID (支付宝分配给开发者的应用ID)
|
||||
$private_key = input("private_key", "");//应用私钥
|
||||
$public_key = input("public_key", "");//应用公钥
|
||||
$alipay_public_key = input("alipay_public_key", "");//支付宝公钥
|
||||
$app_type = input("app_type", "");//支持端口 如web app
|
||||
$pay_status = input("pay_status", 0);//支付启用状态
|
||||
$refund_status = input("refund_status", 0);//退款启用状态
|
||||
$transfer_status = input("transfer_status", 0);//转账启用状态
|
||||
$public_key_crt = input("public_key_crt", "");
|
||||
$alipay_public_key_crt = input("alipay_public_key_crt", "");
|
||||
$alipay_with_crt = input("alipay_with_crt", "");
|
||||
$countersign_type = input("countersign_type", 0);//加签模式
|
||||
|
||||
$data = array (
|
||||
"app_id" => $app_id,
|
||||
"private_key" => $private_key,
|
||||
"public_key" => $public_key,
|
||||
"alipay_public_key" => $alipay_public_key,
|
||||
"refund_status" => $refund_status,
|
||||
"pay_status" => $pay_status,
|
||||
"transfer_status" => $transfer_status,
|
||||
"app_type" => $app_type,
|
||||
"public_key_crt" => $public_key_crt,
|
||||
"alipay_public_key_crt" => $alipay_public_key_crt,
|
||||
"alipay_with_crt" => $alipay_with_crt,
|
||||
"countersign_type" => $countersign_type
|
||||
);
|
||||
$result = $config_model->setPayConfig($data, $this->site_id, $this->app_module);
|
||||
return $result;
|
||||
} else {
|
||||
$info = $config_model->getPayConfig($this->site_id, $this->app_module, true)[ 'data' ][ 'value' ];
|
||||
|
||||
if (!empty($info)) {
|
||||
$app_type_arr = [];
|
||||
if (!empty($info[ 'app_type' ])) {
|
||||
$app_type_arr = explode(',', $info[ 'app_type' ]);
|
||||
}
|
||||
$info[ 'app_type_arr' ] = $app_type_arr;
|
||||
if (empty($info[ 'countersign_type' ])) {
|
||||
$info[ 'countersign_type' ] = 0;
|
||||
}
|
||||
}
|
||||
$this->assign("info", $info);
|
||||
$this->assign("app_type", Config::get("app_type"));
|
||||
|
||||
return $this->fetch("pay/config");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传微信支付证书
|
||||
*/
|
||||
public function uploadAlipayCrt()
|
||||
{
|
||||
$upload_model = new Upload();
|
||||
$site_id = request()->siteid();
|
||||
$name = input("name", "");
|
||||
$extend_type = [ 'crt' ];
|
||||
$param = array (
|
||||
"name" => "file",
|
||||
"extend_type" => $extend_type
|
||||
);
|
||||
|
||||
$site_id = max($site_id, 0);
|
||||
$result = $upload_model->setPath("common/alipay/crt/" . $site_id . "/")->file($param);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
294
addon/alipay/shop/view/pay/config.html
Executable file
294
addon/alipay/shop/view/pay/config.html
Executable file
@@ -0,0 +1,294 @@
|
||||
<style>
|
||||
.input-text span{margin-right: 15px;}
|
||||
</style>
|
||||
|
||||
<div class="layui-form form-wrap">
|
||||
<div class="layui-form-item balance-boday">
|
||||
<label class="layui-form-label">加签模式:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-inline">
|
||||
{if $info}
|
||||
<input type="radio" name="countersign_type" lay-filter="type" value="0" title="公钥" autocomplete="off" class="layui-input len-long" {if $info.countersign_type == 0} checked {/if} >
|
||||
<input type="radio" name="countersign_type" lay-filter="type" value="1" title="公钥证书" autocomplete="off" class="layui-input len-long" {if $info.countersign_type == 1} checked {/if} >
|
||||
{else/}
|
||||
<input type="radio" name="countersign_type" lay-filter="type" value="0" title="公钥" autocomplete="off" class="layui-input len-long" checked>
|
||||
<input type="radio" name="countersign_type" lay-filter="type" value="1" title="公钥证书" autocomplete="off" class="layui-input len-long">
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
<div class="word-aux">支付宝配置规则加签模式。</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">支付宝应用ID:</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="app_id" type="text" value="{$info.app_id ?? ''}" class="layui-input len-long">
|
||||
</div>
|
||||
<div class="word-aux"><span>[API_ID]</span>支付宝分配给开发者的应用ID</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">应用私钥:</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea name="private_key" class="layui-textarea len-long" placeholder="请输入应用私钥">{$info.private_key ?? ''}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{if empty($info) || $info.countersign_type == 0}
|
||||
<div class="countersign_type_zero" >
|
||||
<div class="layui-form-item " >
|
||||
<label class="layui-form-label">应用公钥:</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea name="public_key" class="layui-textarea len-long" placeholder="请输入应用公钥">{$info.public_key ?? ''}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">支付宝公钥:</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea name="alipay_public_key" class="layui-textarea len-long" placeholder="请输入支付宝公钥">{$info.alipay_public_key ?? ''}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="countersign_type_one" style="display: none">
|
||||
<div class="layui-form-item ">
|
||||
<label class="layui-form-label">应用公钥证书:</label>
|
||||
<div class="layui-input-block">
|
||||
{notempty name="$info.public_key_crt"}
|
||||
<p class="file-upload">已上传</p>
|
||||
{else/}
|
||||
<p class="file-upload">未上传</p>
|
||||
{/notempty}
|
||||
<button type="button" class="layui-btn" id="public_key_upload">
|
||||
<i class="layui-icon"></i>上传文件
|
||||
</button>
|
||||
<input type="hidden" name="public_key_crt" class="layui-input len-long" value="{$info.public_key_crt ?? ''}">
|
||||
</div>
|
||||
<div class="word-aux">上传appCertPublicKey文件</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">支付宝公钥证书:</label>
|
||||
<div class="layui-input-block">
|
||||
{notempty name="$info.alipay_public_key_crt"}
|
||||
<p class="file-upload">已上传</p>
|
||||
{else/}
|
||||
<p class="file-upload">未上传</p>
|
||||
{/notempty}
|
||||
<button type="button" class="layui-btn" id="alipay_public_key_upload">
|
||||
<i class="layui-icon"></i>上传文件
|
||||
</button>
|
||||
<input type="hidden" name="alipay_public_key_crt" class="layui-input len-long" value="{$info.alipay_public_key_crt ?? ''}">
|
||||
</div>
|
||||
<div class="word-aux">上传alipayCertPublicKey文件</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">支付宝根证书:</label>
|
||||
<div class="layui-input-block">
|
||||
{notempty name="$info.alipay_with_crt"}
|
||||
<p class="file-upload">已上传</p>
|
||||
{else/}
|
||||
<p class="file-upload">未上传</p>
|
||||
{/notempty}
|
||||
<button type="button" class="layui-btn" id="alipay_with_upload">
|
||||
<i class="layui-icon"></i>上传文件
|
||||
</button>
|
||||
<input type="hidden" name="alipay_with_crt" class="layui-input len-long" value="{$info.alipay_with_crt ?? ''}">
|
||||
</div>
|
||||
<div class="word-aux">上传alipayRootCert文件</div>
|
||||
</div>
|
||||
</div>
|
||||
{else/}
|
||||
<div class="countersign_type_zero" style="display: none">
|
||||
<div class="layui-form-item " >
|
||||
<label class="layui-form-label">应用公钥:</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea name="public_key" class="layui-textarea len-long" placeholder="请输入应用公钥">{$info.public_key ?? ''}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">支付宝公钥:</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea name="alipay_public_key" class="layui-textarea len-long" placeholder="请输入支付宝公钥">{$info.alipay_public_key ?? ''}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="countersign_type_one">
|
||||
<div class="layui-form-item ">
|
||||
<label class="layui-form-label">应用公钥证书:</label>
|
||||
<div class="layui-input-block">
|
||||
{notempty name="$info.public_key_crt"}
|
||||
<p class="file-upload">已上传</p>
|
||||
{else/}
|
||||
<p class="file-upload">未上传</p>
|
||||
{/notempty}
|
||||
<button type="button" class="layui-btn" id="public_key_upload">
|
||||
<i class="layui-icon"></i>上传文件
|
||||
</button>
|
||||
<input type="hidden" name="public_key_crt" class="layui-input len-long" value="{$info.public_key_crt ?? ''}">
|
||||
</div>
|
||||
<div class="word-aux">上传appCertPublicKey文件</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">支付宝公钥证书:</label>
|
||||
<div class="layui-input-block">
|
||||
{notempty name="$info.alipay_public_key_crt"}
|
||||
<p class="file-upload">已上传</p>
|
||||
{else/}
|
||||
<p class="file-upload">未上传</p>
|
||||
{/notempty}
|
||||
<button type="button" class="layui-btn" id="alipay_public_key_upload">
|
||||
<i class="layui-icon"></i>上传文件
|
||||
</button>
|
||||
<input type="hidden" name="alipay_public_key_crt" class="layui-input len-long" value="{$info.alipay_public_key_crt ?? ''}">
|
||||
</div>
|
||||
<div class="word-aux">上传alipayCertPublicKey文件</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">支付宝根证书:</label>
|
||||
<div class="layui-input-block">
|
||||
{notempty name="$info.alipay_with_crt"}
|
||||
<p class="file-upload">已上传</p>
|
||||
{else/}
|
||||
<p class="file-upload">未上传</p>
|
||||
{/notempty}
|
||||
<button type="button" class="layui-btn" id="alipay_with_upload">
|
||||
<i class="layui-icon"></i>上传文件
|
||||
</button>
|
||||
<input type="hidden" name="alipay_with_crt" class="layui-input len-long" value="{$info.alipay_with_crt ?? ''}">
|
||||
</div>
|
||||
<div class="word-aux">上传alipayRootCert文件</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">支持端口:</label>
|
||||
<div class="input-text">
|
||||
{foreach $app_type as $app_type_k => $app_type_v}
|
||||
{if condition="$app_type_v['name'] !='微信小程序' && $app_type_v['name'] !='微信公众号'"}
|
||||
<span>{$app_type_v['name']}</span>
|
||||
{/if}
|
||||
{/foreach}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否启用支付:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="pay_status" value="1" lay-skin="switch" {if condition="$info && $info.pay_status == 1"} checked {/if} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否启用退款:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="refund_status" value="1" lay-skin="switch" {if condition="$info && $info.refund_status == 1"} checked {/if} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否启用转账:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="transfer_status" value="1" lay-skin="switch" {if condition="$info && $info.transfer_status == 1"} checked {/if} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="back()">返回</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
layui.use('form', function() {
|
||||
var form = layui.form;
|
||||
var repeat_flag = false; //防重复标识
|
||||
form.render();
|
||||
|
||||
layui.form.on('radio(type)', function(data){
|
||||
if(data.value == 0){
|
||||
$(".countersign_type_zero").show();
|
||||
$(".countersign_type_one").hide();
|
||||
}else{
|
||||
$(".countersign_type_one").show();
|
||||
$(".countersign_type_zero").hide();
|
||||
}
|
||||
});
|
||||
|
||||
var public_key_upload = new Upload({
|
||||
elem: '#public_key_upload',
|
||||
url: ns.url("alipay://shop/pay/uploadalipaycrt"), //改成您自己的上传接口
|
||||
accept: 'file',
|
||||
callback:function (res) {
|
||||
if (res.code >= 0) {
|
||||
$("input[name='public_key_crt']").val(res.data.path);
|
||||
$("input[name='public_key_crt']").siblings(".file-upload").text("已上传");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var alipay_public_key_upload = new Upload({
|
||||
elem: '#alipay_public_key_upload',
|
||||
url: ns.url("alipay://shop/pay/uploadalipaycrt"), //改成您自己的上传接口
|
||||
accept: 'file',
|
||||
callback:function (res) {
|
||||
if (res.code >= 0) {
|
||||
$("input[name='alipay_public_key_crt']").val(res.data.path);
|
||||
$("input[name='alipay_public_key_crt']").siblings(".file-upload").text("已上传");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var alipay_with_upload = new Upload({
|
||||
elem: '#alipay_with_upload',
|
||||
url: ns.url("alipay://shop/pay/uploadalipaycrt"), //改成您自己的上传接口
|
||||
accept: 'file',
|
||||
callback:function (res) {
|
||||
if (res.code >= 0) {
|
||||
$("input[name='alipay_with_crt']").val(res.data.path);
|
||||
$("input[name='alipay_with_crt']").siblings(".file-upload").text("已上传");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听提交
|
||||
*/
|
||||
form.on('submit(save)', function(data) {
|
||||
if (repeat_flag) return false;
|
||||
repeat_flag = true;
|
||||
$.ajax({
|
||||
url: ns.url("alipay://shop/pay/config"),
|
||||
data: data.field,
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function(res){
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
layer.confirm('编辑成功', {
|
||||
title:'操作提示',
|
||||
btn: ['返回列表', '继续编辑'],
|
||||
yes: function(index, layero) {
|
||||
location.hash = ns.hash("shop/config/pay");
|
||||
layer.close(index);
|
||||
},
|
||||
btn2: function(index, layero) {
|
||||
layer.close(index);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function back(){
|
||||
location.hash = ns.hash("shop/config/pay");
|
||||
}
|
||||
|
||||
</script>
|
||||
38
addon/alisms/config/diy_view.php
Executable file
38
addon/alisms/config/diy_view.php
Executable file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
return [
|
||||
|
||||
// 自定义模板页面类型,格式:[ 'title' => '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
|
||||
'template' => [],
|
||||
|
||||
// 后台自定义组件——装修
|
||||
'util' => [],
|
||||
|
||||
// 自定义页面路径
|
||||
'link' => [],
|
||||
|
||||
// 自定义图标库
|
||||
'icon_library' => [],
|
||||
|
||||
// uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件
|
||||
'component' => [],
|
||||
|
||||
// uni-app 页面,多个逗号隔开
|
||||
'pages' => [],
|
||||
|
||||
// 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述'
|
||||
'info' => [],
|
||||
|
||||
// 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】
|
||||
'theme' => [],
|
||||
|
||||
// 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ]
|
||||
'data' => []
|
||||
];
|
||||
34
addon/alisms/config/event.php
Executable file
34
addon/alisms/config/event.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
// 事件定义文件
|
||||
return [
|
||||
'bind' => [
|
||||
|
||||
],
|
||||
|
||||
'listen' => [
|
||||
//短信方式
|
||||
'SmsType' => [
|
||||
'addon\alisms\event\SmsType'
|
||||
],
|
||||
'DoEditSmsMessage' => [
|
||||
'addon\alisms\event\DoEditSmsMessage'
|
||||
],
|
||||
'SendSms' => [
|
||||
'addon\alisms\event\SendSms'
|
||||
],
|
||||
//启用回调,使用这个短信,就要关闭其他短信插件
|
||||
'EnableCallBack' => [
|
||||
'addon\alisms\event\EnableCallBack'
|
||||
],
|
||||
//查询启用的短信插件
|
||||
'EnableSms' => [
|
||||
'addon\alisms\event\EnableSms'
|
||||
],
|
||||
'SmsTemplateInfo' => [
|
||||
'addon\alisms\event\SmsTemplateInfo'
|
||||
]
|
||||
],
|
||||
|
||||
'subscribe' => [
|
||||
],
|
||||
];
|
||||
21
addon/alisms/config/info.php
Executable file
21
addon/alisms/config/info.php
Executable file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
return [
|
||||
'name' => 'alisms',
|
||||
'title' => '阿里云短信',
|
||||
'description' => '阿里云短信功能',
|
||||
'type' => 'system', //插件类型 system :系统插件(自动安装), business:业务插件 promotion:营销插件 tool:工具插件
|
||||
'status' => 1,
|
||||
'author' => '',
|
||||
'version' => '5.5.3',
|
||||
'version_no' => '553250709001',
|
||||
'content' => '',
|
||||
];
|
||||
30
addon/alisms/config/menu_shop.php
Executable file
30
addon/alisms/config/menu_shop.php
Executable file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 平台端菜单设置
|
||||
// +----------------------------------------------------------------------
|
||||
return [
|
||||
[
|
||||
'name' => 'ALI_SMS_CONFIG',
|
||||
'title' => '阿里云短信配置',
|
||||
'url' => 'alisms://shop/sms/config',
|
||||
'parent' => 'SMS_MANAGE',
|
||||
'is_show' => 0,
|
||||
'is_control' => 1,
|
||||
'is_icon' => 0,
|
||||
'picture' => '',
|
||||
'picture_select' => '',
|
||||
'sort' => 1,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'ALI_MESSAGE_SMS_EDIT',
|
||||
'title' => '编辑阿里云短信模板',
|
||||
'url' => 'alisms://shop/message/edit',
|
||||
'parent' => 'MESSAGE_LISTS',
|
||||
'is_show' => 0,
|
||||
'picture' => '',
|
||||
'picture_select' => '',
|
||||
'sort' => 1,
|
||||
'type' => 'button',
|
||||
],
|
||||
];
|
||||
34
addon/alisms/event/DoEditSmsMessage.php
Executable file
34
addon/alisms/event/DoEditSmsMessage.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\alisms\event;
|
||||
|
||||
use addon\alisms\model\Config as ConfigModel;
|
||||
|
||||
/**
|
||||
* 短信模板 (后台调用)
|
||||
*/
|
||||
class DoEditSmsMessage
|
||||
{
|
||||
/**
|
||||
* 短信发送方式方式及配置
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$config_model = new ConfigModel();
|
||||
$config_result = $config_model->getSmsConfig();
|
||||
$config = $config_result["data"];
|
||||
if ($config["is_use"] == 1) {
|
||||
return ["edit_url" => "alisms://shop/message/edit", "shop_url" => "alisms://shop/message/edit"];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
37
addon/alisms/event/EnableCallBack.php
Executable file
37
addon/alisms/event/EnableCallBack.php
Executable file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\alisms\event;
|
||||
|
||||
use addon\alisms\model\Config;
|
||||
|
||||
/**
|
||||
* 使用这个短信,就要关闭其他短信插件
|
||||
*/
|
||||
class EnableCallBack
|
||||
{
|
||||
/**
|
||||
* 短信发送方式方式及配置
|
||||
*/
|
||||
public function handle($param)
|
||||
{
|
||||
if ($param[ 'sms_type' ] != 'alisms') {
|
||||
$config_model = new Config();
|
||||
$sms_config = $config_model->getSmsConfig($param[ 'site_id' ]);
|
||||
$is_use = $sms_config[ 'data' ][ 'is_use' ];
|
||||
if ($is_use) {
|
||||
$is_use = 0;
|
||||
$res = $config_model->enableCallBack($is_use, $param[ 'site_id' ]);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
40
addon/alisms/event/EnableSms.php
Executable file
40
addon/alisms/event/EnableSms.php
Executable file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\alisms\event;
|
||||
|
||||
use addon\alisms\model\Config;
|
||||
|
||||
/**
|
||||
* 查询启用的短信插件
|
||||
*/
|
||||
class EnableSms
|
||||
{
|
||||
/**
|
||||
* 短信发送方式方式及配置
|
||||
*/
|
||||
public function handle($param)
|
||||
{
|
||||
$info = array (
|
||||
"sms_type" => "alisms",
|
||||
"sms_type_name" => "阿里云短信",
|
||||
"edit_url" => "alisms://shop/sms/config",
|
||||
"shop_url" => "alisms://shop/sms/config",
|
||||
"desc" => "阿里云短信服务(Short Message Service)支持国内和国际快速发送验证码、短信通知和推广短信,服务范围覆盖全球200多个国家和地区。国内短信支持三网合一专属通道,与工信部携号转网平台实时互联。电信级运维保障,实时监控自动切换,到达率高达99%。"
|
||||
);
|
||||
|
||||
$config_model = new Config();
|
||||
$config = $config_model->getSmsConfig($param[ 'site_id' ]);
|
||||
if ($config[ 'data' ][ 'is_use' ] == 1) {
|
||||
return $info;
|
||||
}
|
||||
}
|
||||
}
|
||||
26
addon/alisms/event/Install.php
Executable file
26
addon/alisms/event/Install.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\alisms\event;
|
||||
|
||||
/**
|
||||
* 应用安装
|
||||
*/
|
||||
class Install
|
||||
{
|
||||
/**
|
||||
* 执行安装
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return success();
|
||||
}
|
||||
}
|
||||
34
addon/alisms/event/SendSms.php
Executable file
34
addon/alisms/event/SendSms.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\alisms\event;
|
||||
|
||||
use addon\alisms\model\Sms;
|
||||
|
||||
/**
|
||||
* 短信发送
|
||||
*/
|
||||
class SendSms
|
||||
{
|
||||
/**
|
||||
* 短信发送方式方式及配置
|
||||
* @param $param
|
||||
* @return array|mixed
|
||||
* @throws \Overtrue\EasySms\Exceptions\InvalidArgumentException
|
||||
*/
|
||||
public function handle($param)
|
||||
{
|
||||
$sms = new Sms();
|
||||
$res = $sms->send($param);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
35
addon/alisms/event/SmsTemplateInfo.php
Executable file
35
addon/alisms/event/SmsTemplateInfo.php
Executable file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\alisms\event;
|
||||
|
||||
use addon\alisms\model\Config;
|
||||
|
||||
/**
|
||||
* 获取短信模板数据
|
||||
*/
|
||||
class SmsTemplateInfo
|
||||
{
|
||||
/**
|
||||
* 获取短信模板数据
|
||||
*/
|
||||
public function handle($param)
|
||||
{
|
||||
$config_model = new Config();
|
||||
$sms_config = $config_model->getSmsConfig($param['site_id'], 'shop')[ 'data' ];
|
||||
if ($sms_config['is_use']) {
|
||||
$template_info = model('message_template')->getInfo([ ['keywords', '=', $param['keywords'] ]]);
|
||||
if (!empty($template_info['sms_json'])) {
|
||||
return json_decode($template_info['sms_json'], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
38
addon/alisms/event/SmsType.php
Executable file
38
addon/alisms/event/SmsType.php
Executable file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\alisms\event;
|
||||
|
||||
use addon\alisms\model\Config;
|
||||
|
||||
/**
|
||||
* 短信方式 (后台调用)
|
||||
*/
|
||||
class SmsType
|
||||
{
|
||||
/**
|
||||
* 短信发送方式方式及配置
|
||||
*/
|
||||
public function handle($param)
|
||||
{
|
||||
$info = array (
|
||||
"sms_type" => "alisms",
|
||||
"sms_type_name" => "阿里云短信",
|
||||
"edit_url" => "alisms://shop/sms/config",
|
||||
"shop_url" => "alisms://shop/sms/config",
|
||||
"desc" => "阿里云短信服务(Short Message Service)支持国内和国际快速发送验证码、短信通知和推广短信,服务范围覆盖全球200多个国家和地区。国内短信支持三网合一专属通道,与工信部携号转网平台实时互联。电信级运维保障,实时监控自动切换,到达率高达99%。"
|
||||
);
|
||||
|
||||
$config_model = new Config();
|
||||
$config = $config_model->getSmsConfig($param[ 'site_id' ]);
|
||||
$info[ 'status' ] = $config[ 'data' ][ 'is_use' ] ?? 0;
|
||||
return $info;
|
||||
}
|
||||
}
|
||||
27
addon/alisms/event/UnInstall.php
Executable file
27
addon/alisms/event/UnInstall.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\alisms\event;
|
||||
|
||||
/**
|
||||
* 应用卸载
|
||||
*/
|
||||
class UnInstall
|
||||
{
|
||||
/**
|
||||
* 执行卸载
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return success();
|
||||
}
|
||||
}
|
||||
BIN
addon/alisms/icon.png
Executable file
BIN
addon/alisms/icon.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
64
addon/alisms/model/Config.php
Executable file
64
addon/alisms/model/Config.php
Executable file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\alisms\model;
|
||||
|
||||
use app\model\system\Config as ConfigModel;
|
||||
use app\model\BaseModel;
|
||||
|
||||
/**
|
||||
* 支付宝支付配置
|
||||
*/
|
||||
class Config extends BaseModel
|
||||
{
|
||||
/**
|
||||
* 设置短信配置
|
||||
* array $data
|
||||
*/
|
||||
public function setSmsConfig($data, $is_use, $site_id = 1, $app_module = 'shop')
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->setConfig($data, '阿里云短信配置', $is_use, [ [ 'site_id', '=', $site_id ], [ 'app_module', '=', $app_module ], [ 'config_key', '=', 'ALI_SMS_CONFIG' ] ]);
|
||||
event('EnableCallBack', [ 'sms_type' => 'alisms', 'is_use' => $is_use, 'site_id' => $site_id ]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取短信配置
|
||||
*/
|
||||
public function getSmsConfig($site_id = 1, $app_module = 'shop')
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', $app_module ], [ 'config_key', '=', 'ALI_SMS_CONFIG' ] ]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置开关
|
||||
*/
|
||||
public function modifyConfigIsUse($is_use, $site_id = 1, $app_module = 'shop')
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->modifyConfigIsUse($is_use, [ [ 'site_id', '=', $site_id ], [ 'app_module', '=', $app_module ], [ 'config_key', '=', 'ALI_SMS_CONFIG' ] ]);
|
||||
event('EnableCallBack', [ 'sms_type' => 'alisms', 'is_use' => $is_use, 'site_id' => $site_id ]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 事件修改开关状态
|
||||
*/
|
||||
public function enableCallBack($is_use, $site_id = 1, $app_module = 'shop')
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->modifyConfigIsUse($is_use, [ [ 'site_id', '=', $site_id ], [ 'app_module', '=', $app_module ], [ 'config_key', '=', 'ALI_SMS_CONFIG' ] ]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
}
|
||||
76
addon/alisms/model/Sms.php
Executable file
76
addon/alisms/model/Sms.php
Executable file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\alisms\model;
|
||||
|
||||
use app\model\BaseModel;
|
||||
use Overtrue\EasySms\EasySms;
|
||||
use Overtrue\EasySms\Exceptions\InvalidArgumentException;
|
||||
use Overtrue\EasySms\Exceptions\NoGatewayAvailableException;
|
||||
use Overtrue\EasySms\Strategies\OrderStrategy;
|
||||
|
||||
/**
|
||||
* 阿里云短信
|
||||
*/
|
||||
class Sms extends BaseModel
|
||||
{
|
||||
/**
|
||||
* 短信发送
|
||||
* @param array $param
|
||||
* @return array|mixed
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function send($param = [])
|
||||
{
|
||||
|
||||
$config_model = new Config();
|
||||
$config_result = $config_model->getSmsConfig();
|
||||
if ($config_result[ "data" ][ "is_use" ]) {
|
||||
$config = $config_result[ "data" ][ "value" ];
|
||||
$sms_info = $param[ "message_info" ][ "sms_json_array" ];//消息类型模板 短信模板信息
|
||||
if (empty($sms_info[ "alisms" ])) return $this->error([], "消息模板尚未配置");
|
||||
$sms_info = $sms_info[ "alisms" ];
|
||||
$var_parse = $param[ "var_parse" ];//变量解析
|
||||
$account = $param[ "sms_account" ];//发送手机号
|
||||
//加入阿里云短信配置
|
||||
$sms_config = [
|
||||
// HTTP 请求的超时时间(秒)
|
||||
'timeout' => 5.0,
|
||||
// 默认发送配置
|
||||
'default' => [
|
||||
// 网关调用策略,默认:顺序调用
|
||||
'strategy' => OrderStrategy::class,
|
||||
// 默认可用的发送网关
|
||||
'gateways' => [ 'aliyun' ],
|
||||
],
|
||||
// 可用的网关配置
|
||||
'gateways' => [
|
||||
"aliyun" => [
|
||||
'access_key_id' => $config[ "access_key_id" ],
|
||||
'access_key_secret' => $config[ "access_key_secret" ],
|
||||
'sign_name' => $config[ "smssign" ],
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
try {
|
||||
$easySms = new EasySms($sms_config);
|
||||
$easySms->send($account, [
|
||||
'template' => $sms_info[ "template_id" ],
|
||||
'data' => $var_parse,
|
||||
]);
|
||||
return $this->success([ "addon" => "alisms", "addon_name" => "阿里云短信", "content" => $sms_info[ "content" ] ]);
|
||||
} catch (NoGatewayAvailableException $exception) {
|
||||
$message = $exception->getException('aliyun')->getMessage();
|
||||
return $this->error([ "content" => $sms_info[ "content" ] ], $message ? : '短信发送异常');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
86
addon/alisms/shop/controller/Message.php
Executable file
86
addon/alisms/shop/controller/Message.php
Executable file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\alisms\shop\controller;
|
||||
|
||||
use app\model\message\Message as MessageModel;
|
||||
use app\model\message\MessageTemplate as MessageTemplateModel;
|
||||
use app\shop\controller\BaseShop;
|
||||
|
||||
/**
|
||||
* 阿里云短信消息管理
|
||||
*/
|
||||
class Message extends BaseShop
|
||||
{
|
||||
/**
|
||||
* 编辑模板消息
|
||||
* @return array|mixed|string
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$message_model = new MessageModel();
|
||||
$keywords = input("keywords", "");
|
||||
$info_result = $message_model->getMessageInfo($this->site_id, $keywords);
|
||||
$info = $info_result[ "data" ];
|
||||
if (request()->isJson()) {
|
||||
if (empty($info))
|
||||
return error("", "不存在的模板信息!");
|
||||
|
||||
$sms_is_open = input('sms_is_open', 0);
|
||||
$sms_json_array = !empty($info[ "sms_json_array" ]) ? $info[ "sms_json_array" ] : [];//短信配置
|
||||
$template_id = input("template_id", '');//短信模板id
|
||||
$smssign = input("smssign", '');//短信签名
|
||||
$content = input("content", '');//短信签名
|
||||
|
||||
$ali_array = [];
|
||||
if (!empty($sms_json_array[ "alisms" ])) {
|
||||
$ali_array = $sms_json_array[ "alisms" ];
|
||||
}
|
||||
$ali_array[ 'template_id' ] = $template_id;//模板ID (备注:服务商提供的模板ID)
|
||||
$ali_array[ 'content' ] = $content;//模板内容 (备注:仅用于显示)
|
||||
$ali_array[ 'smssign' ] = $smssign;//短信签名 (备注:请填写短信签名(如果服务商是大于请填写审核成功的签名))
|
||||
$sms_json_array[ "alisms" ] = $ali_array;
|
||||
$data = array (
|
||||
'sms_json' => json_encode($sms_json_array),
|
||||
);
|
||||
$condition = array (
|
||||
[ "keywords", "=", $keywords ]
|
||||
);
|
||||
$template_model = new MessageTemplateModel();
|
||||
$res = $template_model->editMessageTemplate($data, $condition);
|
||||
if ($res[ 'code' ] == 0) {
|
||||
$res = $message_model->editMessage([ 'sms_is_open' => $sms_is_open, 'site_id' => $this->site_id, 'keywords' => $keywords ], [
|
||||
[ "keywords", "=", $keywords ],
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
]);
|
||||
}
|
||||
return $res;
|
||||
} else {
|
||||
if (empty($info))
|
||||
$this->error("不存在的模板信息!");
|
||||
|
||||
$sms_json_array = $info[ "sms_json_array" ];//短信配置
|
||||
$ali_array = [];
|
||||
if (!empty($sms_json_array[ "alisms" ])) {
|
||||
$ali_array = $sms_json_array[ "alisms" ];
|
||||
}
|
||||
$this->assign("info", $ali_array);
|
||||
$this->assign("keywords", $keywords);
|
||||
|
||||
//模板变量
|
||||
$message_variable_list = $info[ "message_json_array" ];
|
||||
$this->assign("message_variable_list", $message_variable_list);
|
||||
|
||||
$this->assign('sms_is_open', $info[ 'sms_is_open' ]);
|
||||
return $this->fetch('message/edit');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
44
addon/alisms/shop/controller/Sms.php
Executable file
44
addon/alisms/shop/controller/Sms.php
Executable file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\alisms\shop\controller;
|
||||
|
||||
use addon\alisms\model\Config as ConfigModel;
|
||||
use app\shop\controller\BaseShop;
|
||||
|
||||
/**
|
||||
* 阿里云短信 控制器
|
||||
*/
|
||||
class Sms extends BaseShop
|
||||
{
|
||||
public function config()
|
||||
{
|
||||
$config_model = new ConfigModel();
|
||||
if (request()->isJson()) {
|
||||
$access_key_id = input("access_key_id", "");
|
||||
$access_key_secret = input("access_key_secret", "");
|
||||
$smssign = input("smssign", '');//短信签名
|
||||
|
||||
$status = input("status", 0);//启用状态
|
||||
$data = array (
|
||||
"access_key_id" => $access_key_id,
|
||||
"access_key_secret" => $access_key_secret,
|
||||
"smssign" => $smssign
|
||||
);
|
||||
$result = $config_model->setSmsConfig($data, $status, $this->site_id, $this->app_module);
|
||||
return $result;
|
||||
} else {
|
||||
$info_result = $config_model->getSmsConfig($this->site_id, $this->app_module);
|
||||
$info = $info_result[ "data" ];
|
||||
$this->assign("info", $info);
|
||||
return $this->fetch("sms/config");
|
||||
}
|
||||
}
|
||||
}
|
||||
105
addon/alisms/shop/view/message/edit.html
Executable file
105
addon/alisms/shop/view/message/edit.html
Executable file
@@ -0,0 +1,105 @@
|
||||
<style>
|
||||
.layui-btn-primary:hover {border-color: #C9C9C9;}
|
||||
.number-con {margin-right: 10px;}
|
||||
</style>
|
||||
|
||||
<div class="layui-form form-wrap">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">短信类型:</label>
|
||||
<div class="layui-input-block">阿里云短信</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否开启:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="sms_is_open" value="1" {if $sms_is_open == 1}checked{/if} lay-skin="switch">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>模板CODE:</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="template_id" type="text" value="{if !empty($info)}{$info.template_id}{/if}" lay-verify="required" placeholder="短信模板ID" class="layui-input len-long">
|
||||
</div>
|
||||
<div class="word-aux">必须与阿里云短信模板中要使用的模版CODE一致,否则无效!</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">数据值:</label>
|
||||
<div class="layui-input-block">
|
||||
{foreach $message_variable_list as $message_variable_k => $message_variable_v}
|
||||
<button class="layui-btn layui-btn-primary number-con" onclick="clickBtn('{$message_variable_k}')">{$message_variable_v}</button>
|
||||
{/foreach}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">短信内容:</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea id="text_area" name="content" class="layui-textarea len-long">{if !empty($info)}{$info.content}{/if}</textarea>
|
||||
</div>
|
||||
<div class="word-aux">变量只能使用上方数据值中的变量,否则不会被解析</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="back()">返回</button>
|
||||
</div>
|
||||
<input type="hidden" name="keywords" value="{$keywords}">
|
||||
</div>
|
||||
|
||||
<script>
|
||||
layui.use('form', function() {
|
||||
var form = layui.form;
|
||||
var repeat_flag = false; //防重复标识
|
||||
form.render();
|
||||
|
||||
/**
|
||||
* 监听提交
|
||||
*/
|
||||
form.on('submit(save)', function(data) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
|
||||
$.ajax({
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
url: ns.url("alisms://shop/message/edit"),
|
||||
data: data.field,
|
||||
success: function(res){
|
||||
repeat_flag = false;
|
||||
|
||||
if (res.code == 0) {
|
||||
layer.confirm('编辑成功', {
|
||||
title:'操作提示',
|
||||
btn: ['返回列表', '继续编辑'],
|
||||
yes: function(index, layero) {
|
||||
location.hash = ns.hash("shop/message/lists")
|
||||
layer.close(index);
|
||||
},
|
||||
btn2: function(index, layero) {
|
||||
layer.close(index);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function back(){
|
||||
location.hash = ns.hash("shop/message/lists");
|
||||
}
|
||||
|
||||
function clickBtn(con) {
|
||||
var txtArea = $("#text_area")[0];
|
||||
var content = txtArea.value;//文本域内容
|
||||
var start = txtArea.selectionStart; //光标的初始位置,selectionStart:选区开始位置;selectionEnd:选区结束位置。
|
||||
|
||||
txtArea.value = content.substring(0, txtArea.selectionStart) + '{' + con + '}' + content.substring(txtArea.selectionEnd, content.length);
|
||||
var position = start + con.length;
|
||||
$("#text_area").focus();
|
||||
txtArea.setSelectionRange(position + 2, position + 2); //setSelectionRange()方法用来设置<input>元素当前选中的文本的开始和结束位置
|
||||
}
|
||||
</script>
|
||||
80
addon/alisms/shop/view/sms/config.html
Executable file
80
addon/alisms/shop/view/sms/config.html
Executable file
@@ -0,0 +1,80 @@
|
||||
<div class="layui-form form-wrap">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否开启:</label>
|
||||
<div class="layui-input-block" id="isOpen">
|
||||
<input type="checkbox" name="status" lay-filter="isOpen" value="1" lay-skin="switch" {if condition="$info.is_use == 1"} checked {/if} />
|
||||
</div>
|
||||
<div class="word-aux">当前使用阿里云短信配置</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">APP_KEY:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="access_key_id" placeholder="请输入内容APP_KEY" {if $info.value } value="{$info.value.access_key_id}" {/if} autocomplete="off" class="layui-input len-long">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">SECRET_KEY:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="access_key_secret" placeholder="请输入SECRET_KEY" {if $info.value } value="{$info.value.access_key_secret}" {/if} autocomplete="off" class="layui-input len-long">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">短信内容签名:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="smssign" placeholder="请输入短信内容签名" {if $info.value } value="{$info.value.smssign}" {/if} autocomplete="off" class="layui-input len-long">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 表单操作 -->
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="backSms()">返回</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
layui.use('form', function() {
|
||||
var form = layui.form,
|
||||
repeat_flag = false; //防重复标识
|
||||
form.render();
|
||||
|
||||
form.on('submit(save)', function(data) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("alisms://shop/sms/config"),
|
||||
data: data.field,
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function(res) {
|
||||
repeat_flag = false;
|
||||
|
||||
if (res.code == 0) {
|
||||
layer.confirm('编辑成功', {
|
||||
title:'操作提示',
|
||||
btn: ['返回列表', '继续编辑'],
|
||||
yes: function(index, layero) {
|
||||
location.hash = ns.hash("shop/message/sms")
|
||||
layer.close(index);
|
||||
},
|
||||
btn2: function(index, layero) {
|
||||
layer.close(index);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function backSms() {
|
||||
location.hash = ns.hash("shop/message/sms");
|
||||
}
|
||||
</script>
|
||||
37
addon/bale/api/controller/Bale.php
Executable file
37
addon/bale/api/controller/Bale.php
Executable file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\bale\api\controller;
|
||||
|
||||
use app\api\controller\BaseApi;
|
||||
use addon\bale\model\Bale as BaleModel;
|
||||
|
||||
/**
|
||||
* 打包一口价
|
||||
*/
|
||||
class Bale extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 详情信息
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$bale_id = $this->params['bale_id'] ?? 0;
|
||||
if (empty($bale_id)) {
|
||||
return $this->response($this->error('', 'REQUEST_BALE_ID'));
|
||||
}
|
||||
|
||||
$bale_model = new BaleModel();
|
||||
$info = $bale_model->getBaleDetail($bale_id, $this->site_id);
|
||||
return $this->response($info);
|
||||
}
|
||||
|
||||
}
|
||||
73
addon/bale/api/controller/Ordercreate.php
Executable file
73
addon/bale/api/controller/Ordercreate.php
Executable file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\bale\api\controller;
|
||||
|
||||
use addon\bale\model\BaleOrderCreate as OrderCreateModel;
|
||||
use app\api\controller\BaseOrderCreateApi;
|
||||
|
||||
/**
|
||||
* 订单创建
|
||||
*/
|
||||
class Ordercreate extends BaseOrderCreateApi
|
||||
{
|
||||
/**
|
||||
* 创建订单
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
$order_create = new OrderCreateModel();
|
||||
$data = [
|
||||
'order_key' => $this->params['order_key'] ?? '',
|
||||
'is_balance' => $this->params['is_balance'] ?? 0,//是否使用余额
|
||||
];
|
||||
$res = $order_create->setParam(array_merge($data, $this->getInputParam(), $this->getCommonParam(), $this->getDeliveryParam(), $this->getInvoiceParam()))->create();
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算
|
||||
*/
|
||||
public function calculate()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
$order_create = new OrderCreateModel();
|
||||
$data = [
|
||||
'order_key' => $this->params[ 'order_key' ] ?? '',//是否使用余额
|
||||
'is_balance' => $this->params[ 'is_balance' ] ?? 0,//是否使用余额
|
||||
];
|
||||
$res = $order_create->setParam(array_merge($data, $this->getCommonParam(), $this->getDeliveryParam(), $this->getInvoiceParam()))->confirm();
|
||||
return $this->response($this->success($res));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 待支付订单 数据初始化
|
||||
* @return string
|
||||
*/
|
||||
public function payment()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
$order_create = new OrderCreateModel();
|
||||
$data = [
|
||||
'bale_id' => $this->params[ 'bale_id' ] ?? '',
|
||||
'sku_list_json' => $this->params[ 'sku_list_json' ] ?? 1,//打包一口价商品信息
|
||||
];
|
||||
if (empty($data[ 'bale_id' ])) {
|
||||
return $this->response($this->error('', '缺少必填参数商品数据'));
|
||||
}
|
||||
$res = $order_create->setParam(array_merge($data, $this->getCommonParam(), $this->getDeliveryParam()))->orderPayment();
|
||||
return $this->response($this->success($res));
|
||||
}
|
||||
}
|
||||
38
addon/bale/config/diy_view.php
Executable file
38
addon/bale/config/diy_view.php
Executable file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
return [
|
||||
|
||||
// 自定义模板页面类型,格式:[ 'title' => '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
|
||||
'template' => [],
|
||||
|
||||
// 后台自定义组件——装修
|
||||
'util' => [],
|
||||
|
||||
// 自定义页面路径
|
||||
'link' => [],
|
||||
|
||||
// 自定义图标库
|
||||
'icon_library' => [],
|
||||
|
||||
// uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件
|
||||
'component' => [],
|
||||
|
||||
// uni-app 页面,多个逗号隔开
|
||||
'pages' => [],
|
||||
|
||||
// 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述'
|
||||
'info' => [],
|
||||
|
||||
// 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】
|
||||
'theme' => [],
|
||||
|
||||
// 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ]
|
||||
'data' => []
|
||||
];
|
||||
27
addon/bale/config/event.php
Executable file
27
addon/bale/config/event.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
// 事件定义文件
|
||||
return [
|
||||
'bind' => [
|
||||
|
||||
],
|
||||
|
||||
'listen' => [
|
||||
//展示活动
|
||||
'ShowPromotion' => [
|
||||
'addon\bale\event\ShowPromotion',
|
||||
],
|
||||
'OpenBale' => [
|
||||
'addon\bale\event\OpenBale',
|
||||
],
|
||||
'CloseBale' => [
|
||||
'addon\bale\event\CloseBale',
|
||||
],
|
||||
// 订单营销活动类型
|
||||
'OrderPromotionType' => [
|
||||
'addon\bale\event\OrderPromotionType',
|
||||
]
|
||||
],
|
||||
|
||||
'subscribe' => [
|
||||
],
|
||||
];
|
||||
20
addon/bale/config/info.php
Executable file
20
addon/bale/config/info.php
Executable file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
return [
|
||||
'name' => 'bale',
|
||||
'title' => '打包一口价',
|
||||
'description' => '促销利器,吸引客户更多消费',
|
||||
'type' => 'promotion', //插件类型 system :系统插件(自动安装), promotion:扩展营销插件 tool:工具插件
|
||||
'status' => 1,
|
||||
'author' => '',
|
||||
'version' => '5.5.3',
|
||||
'version_no' => '553250709001',
|
||||
'content' => '',
|
||||
];
|
||||
60
addon/bale/config/menu_shop.php
Executable file
60
addon/bale/config/menu_shop.php
Executable file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 平台端菜单设置
|
||||
// +----------------------------------------------------------------------
|
||||
return [
|
||||
[
|
||||
'name' => 'PROMOTION_BALE',
|
||||
'title' => '打包一口价',
|
||||
'url' => 'bale://shop/bale/lists',
|
||||
'parent' => 'PROMOTION_CENTER',
|
||||
'is_show' => 1,
|
||||
'is_control' => 1,
|
||||
'is_icon' => 0,
|
||||
'picture' => '',
|
||||
'picture_select' => '',
|
||||
'sort' => 100,
|
||||
'child_list' => [
|
||||
[
|
||||
'name' => 'PROMOTION_BALE_DETAIL',
|
||||
'title' => '活动详情',
|
||||
'url' => 'bale://shop/bale/detail',
|
||||
'sort' => 1,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_BALE_ADD',
|
||||
'title' => '添加活动',
|
||||
'url' => 'bale://shop/bale/add',
|
||||
'sort' => 1,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_BALE_EDIT',
|
||||
'title' => '编辑活动',
|
||||
'url' => 'bale://shop/bale/edit',
|
||||
'sort' => 1,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_BALE_CLOSE',
|
||||
'title' => '关闭活动',
|
||||
'url' => 'bale://shop/bale/close',
|
||||
'sort' => 1,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_BALE_DELETE',
|
||||
'title' => '删除活动',
|
||||
'url' => 'bale://shop/bale/delete',
|
||||
'sort' => 1,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
30
addon/bale/event/CloseBale.php
Executable file
30
addon/bale/event/CloseBale.php
Executable file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\bale\event;
|
||||
|
||||
use addon\bale\model\Bale;
|
||||
|
||||
/**
|
||||
* 关闭活动
|
||||
*/
|
||||
class CloseBale
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
$bale = new Bale();
|
||||
$res = $bale->cronCloseBale($params[ 'relate_id' ]);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
26
addon/bale/event/Install.php
Executable file
26
addon/bale/event/Install.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\bale\event;
|
||||
|
||||
/**
|
||||
* 应用安装
|
||||
*/
|
||||
class Install
|
||||
{
|
||||
/**
|
||||
* 执行安装
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return success();
|
||||
}
|
||||
}
|
||||
30
addon/bale/event/OpenBale.php
Executable file
30
addon/bale/event/OpenBale.php
Executable file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\bale\event;
|
||||
|
||||
use addon\bale\model\Bale;
|
||||
|
||||
/**
|
||||
* 开启活动
|
||||
*/
|
||||
class OpenBale
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
$bale = new Bale();
|
||||
$res = $bale->cronOpenBale($params[ 'relate_id' ]);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
28
addon/bale/event/OrderPromotionType.php
Executable file
28
addon/bale/event/OrderPromotionType.php
Executable file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\bale\event;
|
||||
|
||||
/**
|
||||
* 订单营销活动类型
|
||||
*/
|
||||
class OrderPromotionType
|
||||
{
|
||||
|
||||
/**
|
||||
* 活动类型
|
||||
* @return array
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return ["name" => "一口价", "type" => "bale"];
|
||||
}
|
||||
}
|
||||
97
addon/bale/event/ShowPromotion.php
Executable file
97
addon/bale/event/ShowPromotion.php
Executable file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\bale\event;
|
||||
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
*/
|
||||
class ShowPromotion
|
||||
{
|
||||
public $promotion_type = 'time_limit';
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
* @param array $params
|
||||
* @return array
|
||||
*/
|
||||
public function handle($params = [])
|
||||
{
|
||||
$data = [
|
||||
'admin' => [
|
||||
|
||||
],
|
||||
'shop' => [
|
||||
[
|
||||
//插件名称
|
||||
'name' => 'bale',
|
||||
//展示分类(根据平台端设置,admin(平台营销),shop:店铺营销,member:会员营销, tool:应用工具)
|
||||
'show_type' => 'shop',
|
||||
//展示主题
|
||||
'title' => '打包一口价',
|
||||
//展示介绍
|
||||
'description' => '帮助商家提升客单价',
|
||||
//展示图标
|
||||
'icon' => 'addon/bale/icon.png',
|
||||
//跳转链接
|
||||
'url' => 'bale://shop/bale/lists',
|
||||
'summary' => $this->summary($params)
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 营销活动概况
|
||||
* @param $params
|
||||
* @return array
|
||||
*/
|
||||
private function summary($params)
|
||||
{
|
||||
if (empty($params)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if(isset($params['promotion_type']) && $params['promotion_type'] != $this->promotion_type){
|
||||
return [];
|
||||
}
|
||||
|
||||
//获取活动数量
|
||||
if (isset($params[ 'count' ])) {
|
||||
$count = model("blindbox")->getCount([ 'site_id' => $params[ 'site_id' ] ]);
|
||||
return [
|
||||
'count' => $count
|
||||
];
|
||||
}
|
||||
//获取活动概况,需要获取开始时间与结束时间
|
||||
if (isset($params[ 'summary' ])) {
|
||||
$list = model("promotion_bale")->getList([
|
||||
[ '', 'exp', Db::raw('not ( (`start_time` >= ' . $params[ 'end_time' ] . ') or (`end_time` <= ' . $params[ 'start_time' ] . '))') ],
|
||||
[ 'site_id', '=', $params[ 'site_id' ] ],
|
||||
[ 'status', '<>', 2 ]
|
||||
], 'name as promotion_name,bale_id as promotion_id,start_time,end_time');
|
||||
return !empty($list) ? [
|
||||
'time_limit' => [
|
||||
'count' => count($list),
|
||||
'detail' => $list,
|
||||
'color' => '#FFA666'
|
||||
]
|
||||
] : [];
|
||||
}
|
||||
}
|
||||
}
|
||||
26
addon/bale/event/UnInstall.php
Executable file
26
addon/bale/event/UnInstall.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\bale\event;
|
||||
|
||||
/**
|
||||
* 应用卸载
|
||||
*/
|
||||
class UnInstall
|
||||
{
|
||||
/**
|
||||
* 执行卸载
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return error("系统插件不能删除");
|
||||
}
|
||||
}
|
||||
BIN
addon/bale/icon.png
Executable file
BIN
addon/bale/icon.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 661 B |
346
addon/bale/model/Bale.php
Executable file
346
addon/bale/model/Bale.php
Executable file
@@ -0,0 +1,346 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\bale\model;
|
||||
|
||||
use app\model\BaseModel;
|
||||
use app\model\system\Cron;
|
||||
|
||||
/**
|
||||
* 微信小程序配置
|
||||
*/
|
||||
class Bale extends BaseModel
|
||||
{
|
||||
/**
|
||||
* 添加一口价活动
|
||||
* @param $data
|
||||
* @param $sku_ids
|
||||
* @return array
|
||||
*/
|
||||
public function addBale($param)
|
||||
{
|
||||
if (empty($param[ 'sku_ids' ])) return $this->error([], '请选择参与活动的商品');
|
||||
|
||||
$sku_id_array = explode(',', $param[ 'sku_ids' ]);
|
||||
foreach ($sku_id_array as $k => $v) {
|
||||
|
||||
$sku_info = model('goods_sku')->getInfo([ [ 'sku_id', '=', $v ] ], 'is_virtual');
|
||||
if ($sku_info['is_virtual'] == 1) {
|
||||
return $this->error([], '不能包含虚拟商品');
|
||||
}
|
||||
}
|
||||
|
||||
$data = [
|
||||
'site_id' => $param[ 'site_id' ],
|
||||
'name' => $param[ 'name' ],
|
||||
'num' => $param[ 'num' ],
|
||||
'price' => $param[ 'price' ],
|
||||
'goods_ids' => ',' . $param[ 'goods_ids' ] . ',',
|
||||
'sku_ids' => ',' . $param[ 'sku_ids' ] . ',',
|
||||
'start_time' => $param[ 'start_time' ],
|
||||
'end_time' => $param[ 'end_time' ],
|
||||
'create_time' => time(),
|
||||
'status' => 0,
|
||||
'shipping_fee_type' => $param[ 'shipping_fee_type' ]
|
||||
];
|
||||
if ($param[ 'start_time' ] <= time()) {
|
||||
$data[ 'status' ] = 1;
|
||||
}
|
||||
$bale_id = model('promotion_bale')->add($data);
|
||||
|
||||
$cron = new Cron();
|
||||
if ($data[ 'status' ] == 1) {
|
||||
$cron->addCron(1, 0, '打包一口价活动关闭', 'CloseBale', $data[ 'end_time' ], $bale_id);
|
||||
} else {
|
||||
$cron->addCron(1, 0, '打包一口价活动开启', 'OpenBale', $data[ 'start_time' ], $bale_id);
|
||||
$cron->addCron(1, 0, '打包一口价活动关闭', 'CloseBale', $data[ 'end_time' ], $bale_id);
|
||||
}
|
||||
return $this->success($bale_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑一口价活动
|
||||
* @param $param
|
||||
*/
|
||||
public function editBale($param)
|
||||
{
|
||||
if (empty($param[ 'sku_ids' ])) return $this->error([], '请选择参与活动的商品');
|
||||
|
||||
$sku_id_array = explode(',', $param[ 'sku_ids' ]);
|
||||
foreach ($sku_id_array as $k => $v) {
|
||||
|
||||
$sku_info = model('goods_sku')->getInfo([ [ 'sku_id', '=', $v ] ], 'is_virtual');
|
||||
if ($sku_info['is_virtual'] == 1) {
|
||||
return $this->error([], '不能包含虚拟商品');
|
||||
}
|
||||
}
|
||||
|
||||
$data = [
|
||||
'site_id' => $param[ 'site_id' ],
|
||||
'name' => $param[ 'name' ],
|
||||
'num' => $param[ 'num' ],
|
||||
'price' => $param[ 'price' ],
|
||||
'goods_ids' => ',' . $param[ 'goods_ids' ] . ',',
|
||||
'sku_ids' => ',' . $param[ 'sku_ids' ] . ',',
|
||||
'start_time' => $param[ 'start_time' ],
|
||||
'end_time' => $param[ 'end_time' ],
|
||||
'shipping_fee_type' => $param[ 'shipping_fee_type' ]
|
||||
];
|
||||
if ($param[ 'start_time' ] < time()) {
|
||||
$data[ 'status' ] = 1;
|
||||
} else {
|
||||
$data[ 'status' ] = 0;
|
||||
}
|
||||
$res = model('promotion_bale')->update($data, [ [ 'bale_id', '=', $param[ 'bale_id' ] ], [ 'site_id', '=', $param[ 'site_id' ] ] ]);
|
||||
|
||||
$cron = new Cron();
|
||||
if ($data[ 'status' ] == 1) {
|
||||
$cron->deleteCron([ [ 'event', '=', 'OpenBale' ], [ 'relate_id', '=', $param[ 'bale_id' ] ] ]);
|
||||
$cron->deleteCron([ [ 'event', '=', 'CloseBale' ], [ 'relate_id', '=', $param[ 'bale_id' ] ] ]);
|
||||
|
||||
$cron->addCron(1, 0, '打包一口价活动关闭', 'CloseBale', $data[ 'end_time' ], $param[ 'bale_id' ]);
|
||||
} else {
|
||||
$cron->deleteCron([ [ 'event', '=', 'OpenBale' ], [ 'relate_id', '=', $param[ 'bale_id' ] ] ]);
|
||||
$cron->deleteCron([ [ 'event', '=', 'CloseBale' ], [ 'relate_id', '=', $param[ 'bale_id' ] ] ]);
|
||||
|
||||
$cron->addCron(1, 0, '打包一口价活动开启', 'OpenBale', $data[ 'start_time' ], $param[ 'bale_id' ]);
|
||||
$cron->addCron(1, 0, '打包一口价活动关闭', 'CloseBale', $data[ 'end_time' ], $param[ 'bale_id' ]);
|
||||
}
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除活动
|
||||
* @param $bale_id
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function deleteBale($bale_id, $site_id)
|
||||
{
|
||||
$info = model('promotion_bale')->getInfo([ [ 'bale_id', '=', $bale_id ], [ 'site_id', '=', $site_id ] ], 'status');
|
||||
if (empty($info)) {
|
||||
return $this->success();
|
||||
}
|
||||
if ($info[ 'status' ] != 2) {
|
||||
return $this->error('', '请先关闭活动后,在进行删除');
|
||||
}
|
||||
|
||||
$res = model('promotion_bale')->delete([ [ 'bale_id', '=', $bale_id ], [ 'site_id', '=', $site_id ] ]);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启活动
|
||||
* @param $bale_id
|
||||
* @return array
|
||||
*/
|
||||
public function cronOpenBale($bale_id)
|
||||
{
|
||||
$info = model('promotion_bale')->getInfo([ [ 'bale_id', '=', $bale_id ] ], 'status');
|
||||
if (empty($info)) {
|
||||
return $this->error('', '活动不存在');
|
||||
}
|
||||
if ($info[ 'status' ] == 1) {
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
$res = model('promotion_bale')->update([ 'status' => 1 ], [ [ 'bale_id', '=', $bale_id ] ]);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭活动
|
||||
* @param $bale_id
|
||||
* @return array
|
||||
*/
|
||||
public function cronCloseBale($bale_id)
|
||||
{
|
||||
$info = model('promotion_bale')->getInfo([ [ 'bale_id', '=', $bale_id ] ], 'status');
|
||||
if (empty($info)) {
|
||||
return $this->error('', '活动不存在');
|
||||
}
|
||||
if ($info[ 'status' ] == 2) {
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
$res = model('promotion_bale')->update([ 'status' => 2 ], [ [ 'bale_id', '=', $bale_id ] ]);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一口价活动信息
|
||||
* @param array $where
|
||||
* @param bool $field
|
||||
* @param string $alias
|
||||
* @param null $join
|
||||
* @return array
|
||||
*/
|
||||
public function getBaleInfo($where = [], $field = true, $alias = 'a', $join = null)
|
||||
{
|
||||
$info = model('promotion_bale')->getInfo($where, $field, $alias, $join);
|
||||
return $this->success($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一口价活动详情
|
||||
* @param $id
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function getBaleDetail($id, $site_id)
|
||||
{
|
||||
$info = model('promotion_bale')->getInfo([ [ 'bale_id', '=', $id ], [ 'site_id', '=', $site_id ] ], '*');
|
||||
if (!empty($info)) {
|
||||
|
||||
$alias = 'gs';
|
||||
$condition = [
|
||||
[ 'gs.sku_id', 'in', explode(',', substr($info[ 'sku_ids' ], 1, -1)) ],
|
||||
[ 'gs.site_id', '=', $site_id ],
|
||||
];
|
||||
|
||||
$join = [
|
||||
[ 'goods g', 'gs.goods_id = g.goods_id', 'inner' ]
|
||||
];
|
||||
|
||||
$field = 'gs.goods_id,gs.sku_id,gs.sku_name,gs.price,gs.discount_price,gs.stock
|
||||
,gs.sku_image,gs.goods_name,g.goods_spec_format,g.goods_state
|
||||
,gs.promotion_type,g.goods_image,gs.spec_name
|
||||
,gs.max_buy,gs.min_buy,gs.unit,gs.is_limit,gs.limit_type
|
||||
,gs.goods_spec_format as goods_sku_spec_format,gs.sku_spec_format';
|
||||
$goods_list = model('goods_sku')->getList($condition, $field, 'g.sort,g.create_time desc', $alias, $join);
|
||||
|
||||
foreach ($goods_list as $k => $v) {
|
||||
|
||||
$goods_list[ $k ][ 'stock' ] = numberFormat($goods_list[ $k ][ 'stock' ]);
|
||||
|
||||
$field = 'gs.goods_id,gs.sku_id,g.goods_image,gs.sku_name,gs.sku_spec_format,gs.price,gs.discount_price,gs.promotion_type,gs.stock,gs.sku_image,gs.sku_images,gs.goods_spec_format,gs.unit';
|
||||
$join = [
|
||||
[ 'goods g', 'g.goods_id = gs.goods_id', 'inner' ],
|
||||
];
|
||||
$goods_list[ $k ][ 'sku_list' ] = model('goods_sku')->getList([ [ 'gs.goods_id', '=', $v[ 'goods_id' ] ], [ 'gs.site_id', '=', $site_id ], [ 'gs.is_delete', '=', 0 ] ], $field, 'gs.sku_id asc', 'gs', $join);
|
||||
if (!empty($goods_list[ $k ][ 'sku_list' ])) {
|
||||
foreach ($goods_list[ $k ][ 'sku_list' ] as $ck => $cv) {
|
||||
$goods_list[ $k ][ 'sku_list' ][ $ck ][ 'stock' ] = numberFormat($goods_list[ $k ][ 'sku_list' ][ $ck ][ 'stock' ]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$info[ 'sku_list' ] = $goods_list;
|
||||
$info[ 'sku_list_count' ] = count($goods_list);
|
||||
}
|
||||
return $this->success($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一口价活动详情
|
||||
* @param $id
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function getEditBaleData($id, $site_id)
|
||||
{
|
||||
$info = model('promotion_bale')->getInfo([ [ 'bale_id', '=', $id ], [ 'site_id', '=', $site_id ] ], '*');
|
||||
if (!empty($info)) {
|
||||
|
||||
$alias = 'gs';
|
||||
$condition = [
|
||||
[ 'gs.sku_id', 'in', explode(',', substr($info[ 'sku_ids' ], 1, -1)) ],
|
||||
[ 'gs.site_id', '=', $site_id ],
|
||||
];
|
||||
|
||||
$join = [
|
||||
[ 'goods g', 'gs.goods_id = g.goods_id', 'inner' ]
|
||||
];
|
||||
|
||||
$field = 'gs.goods_id,gs.sku_id,gs.sku_name,gs.price,gs.discount_price,gs.stock
|
||||
,gs.sku_image,gs.goods_name,g.goods_spec_format,g.goods_state
|
||||
,gs.promotion_type,g.goods_image
|
||||
,gs.max_buy,gs.min_buy,gs.unit,gs.is_limit,gs.limit_type
|
||||
,gs.goods_spec_format as goods_sku_spec_format,gs.sku_spec_format';
|
||||
$sku_list = model('goods_sku')->getList($condition, $field, 'g.sort,g.create_time desc', $alias, $join);
|
||||
|
||||
foreach ($sku_list as $k => $v) {
|
||||
|
||||
$sku_list[ $k ][ 'stock' ] = numberFormat($sku_list[ $k ][ 'stock' ]);
|
||||
|
||||
$field = 'gs.goods_id,gs.sku_id,g.goods_image,gs.sku_name,gs.sku_spec_format,gs.price,gs.discount_price,gs.promotion_type,gs.stock,gs.sku_image,gs.sku_images,gs.goods_spec_format,gs.unit';
|
||||
$join = [
|
||||
[ 'goods g', 'g.goods_id = gs.goods_id', 'inner' ],
|
||||
];
|
||||
$sku_list[ $k ][ 'sku_list' ] = model('goods_sku')->getList([ [ 'gs.goods_id', '=', $v[ 'goods_id' ] ], [ 'gs.site_id', '=', $site_id ], [ 'gs.is_delete', '=', 0 ] ], $field, 'gs.sku_id asc', 'gs', $join);
|
||||
if (!empty($sku_list[ $k ][ 'sku_list' ])) {
|
||||
foreach ($sku_list[ $k ][ 'sku_list' ] as $ck => $cv) {
|
||||
$sku_list[ $k ][ 'sku_list' ][ $ck ][ 'stock' ] = numberFormat($sku_list[ $k ][ 'sku_list' ][ $ck ][ 'stock' ]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$info[ 'sku_list' ] = $sku_list;
|
||||
$info[ 'sku_list_count' ] = count($sku_list);
|
||||
}
|
||||
return $this->success($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分页列表
|
||||
* @param array $condition
|
||||
* @param int $page
|
||||
* @param int $page_size
|
||||
* @param string $order
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getBalePageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'create_time desc', $field = '*')
|
||||
{
|
||||
$list = model('promotion_bale')->pageList($condition, $field, $order, $page, $page_size);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭活动
|
||||
* @param $bale_id
|
||||
* @return array
|
||||
*/
|
||||
public function closeBale($bale_id)
|
||||
{
|
||||
$res = model('promotion_bale')->update([ 'status' => 2 ], [ [ 'bale_id', '=', $bale_id ] ]);
|
||||
$cron = new Cron();
|
||||
if ($res == 1) {
|
||||
$cron->deleteCron([ [ 'event', '=', 'CloseBale' ], [ 'relate_id', '=', $bale_id ] ]);
|
||||
}
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 活动推广链接
|
||||
* @param $page
|
||||
* @param $qrcode_param
|
||||
* @param string $promotion_type
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function urlQrcode($page, $qrcode_param, $promotion_type, $app_type, $site_id)
|
||||
{
|
||||
$params = [
|
||||
'site_id' => $site_id,
|
||||
'data' => $qrcode_param,
|
||||
'page' => $page,
|
||||
'promotion_type' => $promotion_type,
|
||||
'h5_path' => $page . '?id=' . $qrcode_param[ 'id' ],
|
||||
'app_type' => $app_type,
|
||||
'qrcode_path' => 'upload/qrcode/bale',
|
||||
'qrcode_name' => 'bale_qrcode_' . $promotion_type . '_' . $qrcode_param[ 'id' ] . '_' . $site_id
|
||||
];
|
||||
$solitaire = event('PromotionQrcode', $params, true);
|
||||
return $this->success($solitaire);
|
||||
}
|
||||
}
|
||||
278
addon/bale/model/BaleOrderCreate.php
Executable file
278
addon/bale/model/BaleOrderCreate.php
Executable file
@@ -0,0 +1,278 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\bale\model;
|
||||
|
||||
use app\model\BaseModel;
|
||||
use app\model\order\OrderCreateTool;
|
||||
use app\model\system\Pay;
|
||||
use Exception;
|
||||
use extend\exception\OrderException;
|
||||
|
||||
/**
|
||||
* 订单创建
|
||||
* Class BaleOrderCreate
|
||||
* @package addon\bale\model
|
||||
*/
|
||||
class BaleOrderCreate extends BaseModel
|
||||
{
|
||||
|
||||
use OrderCreateTool;
|
||||
|
||||
public $bale_info = [];
|
||||
//打包一口价总价
|
||||
public $bale_money = 0;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->promotion_type = 'bale';
|
||||
$this->promotion_type_name = '打包一口价';
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单创建
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//计算
|
||||
$this->confirm();
|
||||
if ($this->error > 0) {
|
||||
return $this->error([ 'error_code' => $this->error ], $this->error_msg);
|
||||
}
|
||||
//订单创建数据
|
||||
$order_insert_data = $this->getOrderInsertData([ 'discount' ], 'invert');
|
||||
$order_insert_data[ 'store_id' ] = $this->store_id;
|
||||
$order_insert_data[ 'create_time' ] = time();
|
||||
$order_insert_data[ 'is_enable_refund' ] = 0;
|
||||
//订单类型以及状态
|
||||
$this->orderType();
|
||||
$order_insert_data[ 'order_type' ] = $this->order_type[ 'order_type_id' ];
|
||||
$order_insert_data[ 'order_type_name' ] = $this->order_type[ 'order_type_name' ];
|
||||
$order_insert_data[ 'order_status_name' ] = $this->order_type[ 'order_status' ][ 'name' ];
|
||||
$order_insert_data[ 'order_status_action' ] = json_encode($this->order_type[ 'order_status' ], JSON_UNESCAPED_UNICODE);
|
||||
model('order')->startTrans();
|
||||
//循环生成多个订单
|
||||
try {
|
||||
$this->order_id = model('order')->add($order_insert_data);
|
||||
//订单项目表
|
||||
$order_goods_insert_data = [];
|
||||
foreach ($this->goods_list as $order_goods_v) {
|
||||
$order_goods_insert_data[] = $this->getOrderGoodsInsertData($order_goods_v);
|
||||
}
|
||||
model('order_goods')->addList($order_goods_insert_data);
|
||||
//扣除余额(统一扣除)
|
||||
$this->useBalance();
|
||||
//批量库存处理(卡密商品支付后在扣出库存)//todo 可以再商品中设置扣除库存步骤
|
||||
$this->batchDecOrderGoodsStock();
|
||||
model('order')->commit();
|
||||
//订单创建后事件
|
||||
$this->orderCreateAfter();
|
||||
//支付单据
|
||||
$pay = new Pay();
|
||||
$pay->addPay($this->site_id, $this->out_trade_no, $this->pay_type, $this->order_name, $this->order_name, $this->pay_money, '', 'OrderPayNotify', '', $this->order_id, $this->member_id);
|
||||
return $this->success($this->out_trade_no);
|
||||
} catch (Exception $e) {
|
||||
model('order')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算后的进一步计算(不存缓存,每次都是重新计算)
|
||||
* @return array
|
||||
*/
|
||||
public function confirm()
|
||||
{
|
||||
$order_key = $this->param[ 'order_key' ];
|
||||
$this->getOrderCache($order_key);
|
||||
//初始化地址
|
||||
$this->initMemberAddress();
|
||||
//初始化门店信息
|
||||
$this->initStore();
|
||||
//配送计算
|
||||
$this->calculateDelivery();
|
||||
//批量校验配送方式
|
||||
$this->batchCheckDeliveryType();
|
||||
//计算发票相关
|
||||
$this->calculateInvoice();
|
||||
//计算余额
|
||||
$this->calculateBalcnce();
|
||||
$this->pay_money = $this->order_money - $this->balance_money;
|
||||
//设置过的商品项信息
|
||||
return get_object_vars($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单计算
|
||||
*/
|
||||
public function calculate()
|
||||
{
|
||||
$this->initMemberAddress();
|
||||
$this->initMemberAccount();//初始化会员账户
|
||||
|
||||
//打包一口价id 查询订单商品数据
|
||||
$bale_model = new Bale();
|
||||
$this->bale_info = $bale_model->getBaleInfo([ [ 'bale_id', '=', $this->param[ 'bale_id' ] ], [ 'site_id', '=', $this->site_id ] ])[ 'data' ] ?? [];
|
||||
|
||||
//商品列表信息
|
||||
$this->getOrderGoodsCalculate();
|
||||
$this->shopOrderCalculate();
|
||||
|
||||
//获取发票相关
|
||||
$this->getInovice();
|
||||
$this->order_key = create_no();
|
||||
$this->setOrderCache(get_object_vars($this), $this->order_key);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品的计算信息
|
||||
*/
|
||||
public function getOrderGoodsCalculate()
|
||||
{
|
||||
//传输打包一口价id组合','隔开要进行拆单
|
||||
$this->getBaleGoodsList();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取打包一口价商品列表信息
|
||||
* @return array
|
||||
*/
|
||||
public function getBaleGoodsList()
|
||||
{
|
||||
//商品数据
|
||||
$sku_list_json = json_decode($this->param[ 'sku_list_json' ], true);
|
||||
$sku_ids = explode(',', substr($this->bale_info[ 'sku_ids' ], 1, -1));
|
||||
//判断商品是否在该活动中
|
||||
$goods_num = 0;
|
||||
$sku_list = [];
|
||||
foreach ($sku_list_json as $v) {
|
||||
if (in_array($v[ 'sku_id' ], $sku_ids)) {
|
||||
$goods_num += $v[ 'num' ];
|
||||
$sku_list[ $v[ 'sku_id' ] ] = $v[ 'num' ];
|
||||
} else {
|
||||
throw new OrderException('商品信息有误');
|
||||
}
|
||||
}
|
||||
//判断商品数量是否正确
|
||||
if ($goods_num % $this->bale_info[ 'num' ] != 0) throw new OrderException('商品数量有误');
|
||||
$this->goods_num = $goods_num;
|
||||
$this->bale_money = $this->bale_info[ 'price' ] * ( $this->goods_num / $this->bale_info[ 'num' ] );
|
||||
//组装商品列表
|
||||
$field = 'ngs.sku_id, ngs.sku_name, ngs.sku_no,ngs.price, ngs.discount_price, ngs.cost_price, ngs.stock, ngs.weight, ngs.volume,
|
||||
ngs.sku_image, ngs.site_id, ngs.goods_state, ngs.is_virtual, ngs.is_free_shipping, ngs.shipping_template, ngs.goods_class, ngs.form_id,
|
||||
ngs.goods_class_name, ngs.goods_id, ngs.sku_spec_format,ngs.goods_name,ngs.support_trade_type,ns.site_name,ngs.supplier_id';
|
||||
$alias = 'ngs';
|
||||
$join = [
|
||||
[
|
||||
'site ns',
|
||||
'ngs.site_id = ns.site_id',
|
||||
'inner'
|
||||
]
|
||||
];
|
||||
$goods_list = model('goods_sku')->getList([ [ 'ngs.sku_id', 'in', array_column($sku_list_json, 'sku_id') ] ], $field, '', $alias, $join);
|
||||
if (!$goods_list) throw new OrderException('商品不存在!');
|
||||
|
||||
foreach ($goods_list as $v) {
|
||||
$this->is_virtual = $v[ 'is_virtual' ];
|
||||
$v[ 'num' ] = $sku_list[ $v[ 'sku_id' ] ];
|
||||
$price = $v[ 'discount_price' ];
|
||||
$v[ 'price' ] = $price;
|
||||
$v[ 'goods_money' ] = $price * $v[ 'num' ];
|
||||
$v[ 'real_goods_money' ] = $v[ 'goods_money' ];
|
||||
$v[ 'coupon_money' ] = 0;//优惠券金额
|
||||
$v[ 'promotion_money' ] = 0;//优惠金额
|
||||
|
||||
$this->site_name = $v[ 'site_name' ];
|
||||
$this->goods_list[] = $v;
|
||||
$order_name = $this->order_name ?? '';
|
||||
if ($order_name) {
|
||||
$len = strlen_mb($order_name);
|
||||
if ($len > 200) {
|
||||
$this->order_name = str_sub($order_name, 200);
|
||||
} else {
|
||||
$this->order_name = string_split($order_name, ',', $v[ 'sku_name' ]);
|
||||
}
|
||||
} else {
|
||||
$this->order_name = string_split('', ',', $v[ 'sku_name' ]);
|
||||
}
|
||||
// $this->goods_num += $v['num'];
|
||||
$this->goods_money += $v[ 'goods_money' ];
|
||||
//以;隔开的商品项
|
||||
$goods_list_str = $this->goods_list_str ?? '';
|
||||
if ($goods_list_str) {
|
||||
$this->goods_list_str = $goods_list_str . ';' . $v[ 'sku_id' ] . ':' . $v[ 'num' ];
|
||||
} else {
|
||||
$this->goods_list_str = $v[ 'sku_id' ] . ':' . $v[ 'num' ];
|
||||
}
|
||||
}
|
||||
|
||||
//循环计算订单项商品价格(受打包一口价的影响)
|
||||
$rate = $this->bale_money / $this->goods_money;//计算打包一口价与原商品价格计算比率
|
||||
$rate = substr(sprintf('%.5f', $rate), 0, -1);
|
||||
$total_temp_money = $this->bale_money;
|
||||
$count = count($this->goods_list);
|
||||
foreach ($this->goods_list as $k => &$v) {
|
||||
if ($k == ( $count - 1 )) {
|
||||
$temp_money = $total_temp_money;
|
||||
$temp_price = round($temp_money / $v[ 'num' ], 3);
|
||||
$temp_price = substr(sprintf('%.3f', $temp_price), 0, -1);
|
||||
$temp_money = substr(sprintf('%.3f', $temp_money), 0, -1);
|
||||
} else {
|
||||
$temp_price = round($v[ 'discount_price' ] * $rate, 3);
|
||||
$temp_money = round($v[ 'discount_price' ] * $v[ 'num' ] * $rate, 3);
|
||||
$temp_price = substr(sprintf('%.3f', $temp_price), 0, -1);
|
||||
$temp_money = substr(sprintf('%.3f', $temp_money), 0, -1);
|
||||
$total_temp_money -= $temp_money;
|
||||
}
|
||||
$v[ 'price' ] = $temp_price;
|
||||
$v[ 'goods_money' ] = $temp_money;
|
||||
$v[ 'real_goods_money' ] = $temp_money;
|
||||
}
|
||||
$this->goods_money = $this->bale_money;//直接使用打包一口价价格
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取店铺订单计算
|
||||
*/
|
||||
public function shopOrderCalculate()
|
||||
{
|
||||
$this->is_free_delivery = $this->bale_info[ 'shipping_fee_type' ] == 1;
|
||||
//重新计算订单总额
|
||||
$this->getOrderMoney();
|
||||
//理论上是多余的操作
|
||||
if ($this->order_money < 0) {
|
||||
$this->order_money = 0;
|
||||
}
|
||||
//总结计算
|
||||
$this->pay_money = $this->order_money;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 待付款订单
|
||||
*/
|
||||
public function orderPayment()
|
||||
{
|
||||
//计算
|
||||
$this->calculate();
|
||||
//查询配送信息
|
||||
$this->getDeliveryData();
|
||||
|
||||
return get_object_vars($this);
|
||||
}
|
||||
|
||||
}
|
||||
75
addon/bale/model/share/WchatShare.php
Executable file
75
addon/bale/model/share/WchatShare.php
Executable file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\bale\model\share;
|
||||
|
||||
use app\model\share\WchatShareBase as BaseModel;
|
||||
use addon\bale\model\Bale as BaleModel;
|
||||
|
||||
/**
|
||||
* 分享
|
||||
*/
|
||||
class WchatShare extends BaseModel
|
||||
{
|
||||
protected $config = [
|
||||
[
|
||||
'title' => '打包一口价',
|
||||
'config_key' => 'WCHAT_SHARE_CONFIG_BALE_PROMOTE',
|
||||
'path' => [ '/pages_promotion/bale/detail' ],
|
||||
'method_prefix' => 'goodsDetail',
|
||||
],
|
||||
];
|
||||
|
||||
protected $sort = 9;
|
||||
|
||||
/**
|
||||
* 打包一口价分享数据
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
protected function goodsDetailShareData($param)
|
||||
{
|
||||
$site_id = $param[ 'site_id' ] ?? 0;
|
||||
$url = $param[ 'url' ];
|
||||
|
||||
$parse_res = parse_url($url);
|
||||
parse_str($parse_res[ 'query' ] ?? '', $query);
|
||||
|
||||
if (isset($query[ 'id' ]) || isset($query[ 'bale_id' ])) {
|
||||
$id = $query['id'] ?? $query['bale_id'];
|
||||
$bale_model = new BaleModel();
|
||||
$bale_detail = $bale_model->getBaleDetail($id, $site_id)[ 'data' ];
|
||||
if (!empty($bale_detail)) {
|
||||
$config_model = new \app\model\share\WchatShare();
|
||||
$config_data = $config_model->goodsDetailShareConfig($param);
|
||||
|
||||
$title = str_replace('{goods_name}', $bale_detail[ 'name' ], $config_data[ 'value' ][ 'title' ]);
|
||||
$desc = str_replace('{price}', sprintf("%.2f", $bale_detail[ 'price' ] / $bale_detail[ 'num' ]), $config_data[ 'value' ][ 'desc' ]);
|
||||
$link = $this->getShareLink($param);
|
||||
$image_url = $bale_detail[ 'sku_list' ][ 0 ][ 'sku_image' ] ?? '';
|
||||
|
||||
$data = [
|
||||
'title' => $title,
|
||||
'desc' => $desc,
|
||||
'link' => $link,
|
||||
'imgUrl' => $image_url,
|
||||
];
|
||||
return [
|
||||
'permission' => [
|
||||
'hideOptionMenu' => false,
|
||||
'hideMenuItems' => [],
|
||||
],
|
||||
'data' => $data,//分享内容
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
205
addon/bale/shop/controller/Bale.php
Executable file
205
addon/bale/shop/controller/Bale.php
Executable file
@@ -0,0 +1,205 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\bale\shop\controller;
|
||||
|
||||
use app\shop\controller\BaseShop;
|
||||
use addon\bale\model\Bale as BaleModel;
|
||||
|
||||
/**
|
||||
* 打包一口价
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
class Bale extends BaseShop
|
||||
{
|
||||
/**
|
||||
* 活动列表
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$status = input('status', '');
|
||||
$name = input('name', '');
|
||||
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ]
|
||||
];
|
||||
if ($status !== '') {
|
||||
$condition[] = [ 'status', '=', $status ];
|
||||
}
|
||||
if (!empty($name)) {
|
||||
$condition[] = [ 'name', 'like', '%' . $name . '%' ];
|
||||
}
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
|
||||
if ($start_time && !$end_time) {
|
||||
$condition[] = [ 'end_time', '>=', date_to_time($start_time) ];
|
||||
} elseif (!$start_time && $end_time) {
|
||||
$condition[] = [ 'start_time', '<=', date_to_time($end_time) ];
|
||||
} elseif ($start_time && $end_time) {
|
||||
$start_timestamp = date_to_time($start_time);
|
||||
$end_timestamp = date_to_time($end_time);
|
||||
$sql = "start_time between {$start_timestamp} and {$end_timestamp}";
|
||||
$sql .= " or end_time between {$start_timestamp} and {$end_timestamp}";
|
||||
$sql .= " or (start_time <= {$start_timestamp} and end_time >= {$end_timestamp})";
|
||||
$condition[] = [ '', 'exp', \think\facade\Db::raw($sql) ];
|
||||
}
|
||||
|
||||
$bale = new BaleModel();
|
||||
$list = $bale->getBalePageList($condition, $page, $page_size);
|
||||
return $list;
|
||||
} else {
|
||||
return $this->fetch('bale/lists');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加活动
|
||||
* @return mixed
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$bale = new BaleModel();
|
||||
$res = $bale->addBale([
|
||||
'site_id' => $this->site_id,
|
||||
'name' => input('name', ''),
|
||||
'num' => input('num', 0),
|
||||
'price' => input('price', 0.00),
|
||||
'goods_ids' => input('goods_ids', ''),
|
||||
'sku_ids' => input('sku_ids', ''),
|
||||
'start_time' => strtotime(input('start_time', 0)),
|
||||
'end_time' => strtotime(input('end_time', 0)),
|
||||
'shipping_fee_type' => input('shipping_fee_type', 0),
|
||||
]);
|
||||
return $res;
|
||||
}
|
||||
return $this->fetch('bale/add');
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑活动
|
||||
* @return mixed
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$bale = new BaleModel();
|
||||
if (request()->isJson()) {
|
||||
$res = $bale->editBale([
|
||||
'bale_id' => input('bale_id'),
|
||||
'site_id' => $this->site_id,
|
||||
'name' => input('name', ''),
|
||||
'num' => input('num', 0),
|
||||
'price' => input('price', 0.00),
|
||||
'goods_ids' => input('goods_ids', ''),
|
||||
'sku_ids' => input('sku_ids', ''),
|
||||
'start_time' => strtotime(input('start_time', 0)),
|
||||
'end_time' => strtotime(input('end_time', 0)),
|
||||
'shipping_fee_type' => input('shipping_fee_type', 0),
|
||||
]);
|
||||
return $res;
|
||||
}
|
||||
$bale_id = input('bale_id', '');
|
||||
$info = $bale->getEditBaleData($bale_id, $this->site_id);
|
||||
if (empty($info[ 'data' ])) $this->error('未获取到活动信息');
|
||||
|
||||
$this->assign('bale_info', $info[ 'data' ]);
|
||||
return $this->fetch('bale/edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$bale_id = input('bale_id', '');
|
||||
|
||||
$bale = new BaleModel();
|
||||
|
||||
$info = $bale->getEditBaleData($bale_id, $this->site_id)[ 'data' ] ?? [];
|
||||
if (empty($info)) $this->error('未获取到活动信息');
|
||||
$this->assign('info', $info);
|
||||
return $this->fetch('bale/detail');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除活动
|
||||
* @return array
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$id = input('id', 0);
|
||||
$bale = new BaleModel();
|
||||
$res = $bale->deleteBale($id, $this->site_id);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品推广
|
||||
* return
|
||||
*/
|
||||
public function baleUrl()
|
||||
{
|
||||
$bale_id = input('bale_id', '');
|
||||
$app_type = input('app_type', 'all');
|
||||
$bale = new BaleModel();
|
||||
$res = $bale->urlQrcode('/pages_promotion/bale/detail', [ 'id' => $bale_id ], 'bale', $app_type, $this->site_id);
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function closeBale()
|
||||
{
|
||||
$bale_id = input('id', '');
|
||||
$bale = new BaleModel();
|
||||
$res = $bale->closeBale($bale_id);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除活动(批量)
|
||||
* @return array
|
||||
*/
|
||||
public function deleteAll()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$bale_id = input('bale_id', '');
|
||||
$bale = new BaleModel();
|
||||
foreach ($bale_id as $k => $v){
|
||||
$res = $bale->deleteBale($v, $this->site_id);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭活动(批量)
|
||||
* @return array
|
||||
*/
|
||||
public function closeBaleAll()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$bale_id = input('bale_id', '');
|
||||
$bale = new BaleModel();
|
||||
foreach ($bale_id as $k => $v){
|
||||
$res = $bale->closeBale($v);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
}
|
||||
283
addon/bale/shop/view/bale/add.html
Executable file
283
addon/bale/shop/view/bale/add.html
Executable file
@@ -0,0 +1,283 @@
|
||||
<style type="text/css">
|
||||
.goods_num {padding-left: 20px;}
|
||||
</style>
|
||||
|
||||
<div class="layui-form form-wrap">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>活动名称:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="name" lay-verify="required|len" class="layui-input len-long" autocomplete="off" maxlength="40">
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>活动名称最多为25个字符</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>开始时间:</label>
|
||||
<div class="layui-input-block len-mid">
|
||||
<input type="text" class="layui-input" name="start_time" lay-verify="required" id="start_time" autocomplete="off" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>结束时间:</label>
|
||||
<div class="layui-input-block len-mid end_time">
|
||||
<input type="text" class="layui-input" name="end_time" lay-verify="required|time" id="end_time" autocomplete="off" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>结束时间不能小于开始时间,也不能小于当前时间</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>活动商品:</label>
|
||||
<div class="layui-input-block">
|
||||
<table id="selected_goods_list"></table>
|
||||
<button class="layui-btn" onclick="addGoods()">选择商品</button>
|
||||
<span class="goods_num">已选商品(<span id="goods_num" class="text-color">0</span>)</span>
|
||||
<input type="hidden" name="sku_ids" lay-verify="goods_ids">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>活动规则:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-inline len-short">
|
||||
<input type="number" name="price" value="" placeholder="" autocomplete="off" class="layui-input len-short" lay-verify="price">
|
||||
</div>
|
||||
<div class="layui-form-mid">元 任选</div>
|
||||
<div class="layui-input-inline len-short">
|
||||
<input type="number" name="num" value="" placeholder="" autocomplete="off" class="layui-input len-short" lay-verify="num">
|
||||
</div>
|
||||
<div class="layui-form-mid">件</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">运费承担:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="shipping_fee_type" value="0" title="卖家承担运费" checked>
|
||||
<input type="radio" name="shipping_fee_type" value="1" title="买家承担运费(快递)">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">提交</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="backBaleList()">返回</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var sku_list = [], selectedGoodsId = [], sku_id = [], form, laydate, currentDate = new Date(), minDate = "", repeat_flag = false;
|
||||
|
||||
layui.use(['form', 'laydate', 'laytpl'], function() {
|
||||
form = layui.form,
|
||||
laydate = layui.laydate;
|
||||
form.render();
|
||||
currentDate.setDate(currentDate.getDate() + 30); //当前时间+30之后的时间戳
|
||||
// 开始时间
|
||||
laydate.render({
|
||||
elem: '#start_time' ,//指定元素
|
||||
type: 'datetime',
|
||||
value: new Date(),
|
||||
done: function(value){
|
||||
minDate = value;
|
||||
reRender();
|
||||
}
|
||||
});
|
||||
|
||||
//结束时间
|
||||
laydate.render({
|
||||
elem: '#end_time' ,//指定元素
|
||||
type: 'datetime',
|
||||
value: new Date(currentDate)
|
||||
});
|
||||
|
||||
/**
|
||||
* 重新渲染结束时间
|
||||
* */
|
||||
function reRender(){
|
||||
$("#end_time").remove();
|
||||
$(".end_time").html('<input type="text" id="end_time" name="end_time" placeholder="请输入结束时间" lay-verify="required|time" class="layui-input len-mid" autocomplete="off">');
|
||||
laydate.render({
|
||||
elem: '#end_time',
|
||||
type: 'datetime',
|
||||
min: minDate
|
||||
});
|
||||
}
|
||||
|
||||
renderTable(sku_list); // 初始化表格
|
||||
|
||||
/**
|
||||
* 表单验证
|
||||
*/
|
||||
form.verify({
|
||||
len: function(value) {
|
||||
if (value.length > 25) {
|
||||
return "活动名称最多为25个字符!";
|
||||
}
|
||||
},
|
||||
time: function(value) {
|
||||
var now_time = (new Date()).getTime();
|
||||
var start_time = (new Date($("#start_time").val())).getTime();
|
||||
var end_time = (new Date(value)).getTime();
|
||||
if (now_time > end_time) {
|
||||
return '结束时间不能小于当前时间!'
|
||||
}
|
||||
if (start_time > end_time) {
|
||||
return '结束时间不能小于开始时间!';
|
||||
}
|
||||
},
|
||||
goods_ids: function(value){
|
||||
if (!/[\S]+/.test(value)) {
|
||||
return '请选择活动商品';
|
||||
}
|
||||
},
|
||||
num: function(value) {
|
||||
if (!/[\S]+/.test(value)) {
|
||||
return '请输入商品件数';
|
||||
}
|
||||
if (value <= 0) {
|
||||
return '商品件数不能小于等于0!';
|
||||
}
|
||||
},
|
||||
price: function(value) {
|
||||
if (!/[\S]+/.test(value)) {
|
||||
return '请输入活动金额';
|
||||
}
|
||||
if (value <= 0) {
|
||||
return '活动金额不能小于等于0!';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听提交
|
||||
*/
|
||||
form.on('submit(save)', function(data) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
|
||||
data.field.goods_ids = [];
|
||||
sku_list.forEach(function(item){
|
||||
if (jQuery.inArray(item.goods_id, data.field.goods_ids) == -1) {
|
||||
data.field.goods_ids.push(item.goods_id)
|
||||
}
|
||||
});
|
||||
data.field.goods_ids = data.field.goods_ids.toString();
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: ns.url("bale://shop/bale/add"),
|
||||
data: data.field,
|
||||
dataType: 'JSON',
|
||||
success: function (res) {
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
layer.confirm('添加成功', {
|
||||
title:'操作提示',
|
||||
btn: ['返回列表', '继续添加'],
|
||||
closeBtn: 0,
|
||||
yes: function(index, layero) {
|
||||
location.hash = ns.hash("bale://shop/bale/lists")
|
||||
layer.close(index);
|
||||
},
|
||||
btn2: function(index, layero) {
|
||||
listenerHash(); // 刷新页面
|
||||
layer.close(index);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 添加商品
|
||||
*/
|
||||
function addGoods() {
|
||||
goodsSelect(function (data) {
|
||||
|
||||
sku_id = [];
|
||||
sku_list = [];
|
||||
|
||||
for (var key in data) {
|
||||
for (var sku in data[key].selected_sku_list) {
|
||||
var item = data[key].selected_sku_list[sku];
|
||||
sku_id.push(item.sku_id);
|
||||
sku_list.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
renderTable(sku_list);
|
||||
$("input[name='sku_ids']").val(sku_id.toString());
|
||||
selectedGoodsId = sku_id;
|
||||
$("#goods_num").html(sku_list.length)
|
||||
}, selectedGoodsId, {mode: "sku", is_virtual: 0});
|
||||
}
|
||||
|
||||
function delRow(obj,id) {
|
||||
for (var i = 0; i < sku_list.length; i++){
|
||||
if (sku_list[i].sku_id == parseInt(id)){
|
||||
sku_list.splice(i,1);
|
||||
}
|
||||
}
|
||||
$("#goods_num").html(sku_list.length);
|
||||
//删除选中的id
|
||||
selectedGoodsId.splice(selectedGoodsId.indexOf(id),1);
|
||||
$("input[name='sku_ids']").val(selectedGoodsId.toString());
|
||||
$(obj).parents("tr").remove();
|
||||
}
|
||||
|
||||
function backBaleList() {
|
||||
location.hash = ns.hash("bale://shop/bale/lists");
|
||||
}
|
||||
|
||||
function renderTable(sku_list) {
|
||||
//展示已知数据
|
||||
table = new Table({
|
||||
elem: '#selected_goods_list',
|
||||
cols: [
|
||||
[{
|
||||
field: 'sku_name',
|
||||
title: '商品名称',
|
||||
unresize: 'false',
|
||||
width: '50%'
|
||||
}, {
|
||||
field: 'price',
|
||||
title: '商品价格(元)',
|
||||
unresize: 'false',
|
||||
align: 'right',
|
||||
width: '20%',
|
||||
templet: function(data) {
|
||||
return '¥' + data.price;
|
||||
}
|
||||
}, {
|
||||
field: 'stock',
|
||||
title: '库存',
|
||||
unresize: 'false',
|
||||
align: 'center',
|
||||
width: '20%'
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
unresize: 'false',
|
||||
align:'right'
|
||||
}],
|
||||
],
|
||||
data: sku_list,
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<script type="text/html" id="operation">
|
||||
<div class="table-btn">
|
||||
<a class="layui-btn" onclick="delRow(this,{{d.sku_id}})">删除</a>
|
||||
</div>
|
||||
</script>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user