This commit is contained in:
2025-10-29 15:32:26 +08:00
parent d90614805b
commit b7462657cd
78921 changed files with 2753938 additions and 71 deletions

View File

@@ -0,0 +1,38 @@
<?php
/**
*/
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' => []
];

View 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' => [
],
];

View File

@@ -0,0 +1,21 @@
<?php
/**
*/
return [
'name' => 'alioss',
'title' => '阿里云OSS',
'description' => '阿里云OSS',
'type' => 'system', //插件类型 system :系统插件(自动安装), business:业务插件 promotion:营销插件 tool:工具插件
'status' => 1,
'author' => '',
'version' => '5.3.1',
'version_no' => '525231212001',
'content' => '',
];

View File

@@ -0,0 +1,18 @@
<?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,
],
];

View File

@@ -0,0 +1,39 @@
<?php
/**
*/
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;
}
}
}
}

View File

@@ -0,0 +1,27 @@
<?php
/**
*/
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;
}
}

View File

@@ -0,0 +1,26 @@
<?php
/**
*/
namespace addon\alioss\event;
/**
* 应用安装
*/
class Install
{
/**
* 执行安装
*/
public function handle()
{
return success();
}
}

View File

@@ -0,0 +1,33 @@
<?php
/**
*/
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;
}
}

View File

@@ -0,0 +1,31 @@
<?php
/**
*/
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;
}
}

View File

@@ -0,0 +1,57 @@
<?php
/**
*/
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;
}
}

View File

@@ -0,0 +1,27 @@
<?php
/**
*/
namespace addon\alioss\event;
/**
* 应用卸载
*/
class UnInstall
{
/**
* 执行卸载
*/
public function handle()
{
return success();
}
}

BIN
src/addon/alioss/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@@ -0,0 +1,146 @@
<?php
/**
*/
namespace addon\alioss\model;
use app\model\BaseModel;
use OSS\Core\OssException;
use OSS\OssClient;
use think\facade\Log;
/**
* 阿里云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());
}
}
}
}

View File

@@ -0,0 +1,56 @@
<?php
/**
*/
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;
}
}

View File

@@ -0,0 +1,56 @@
<?php
/**
*/
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');
}
}
}

View 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="back()">返回</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 back() {
location.hash = ns.hash("shop/upload/oss");
}
</script>

View File

@@ -0,0 +1,38 @@
<?php
/**
*/
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' => []
];

View File

@@ -0,0 +1,50 @@
<?php
/**
*/
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' => [
],
];

View File

@@ -0,0 +1,21 @@
<?php
/**
*/
return [
'name' => 'alipay',
'title' => '支付宝支付',
'description' => '支付宝支付功能',
'type' => 'system', //插件类型 system :系统插件(自动安装), promotion:营销插件 tool:工具插件
'status' => 1,
'author' => '',
'version' => '5.3.1',
'version_no' => '525231212001',
'content' => '',
];

View File

@@ -0,0 +1,23 @@
<?php
/**
*/
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,
],
];

View 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;
}
}

View 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 ;
}
}

File diff suppressed because it is too large Load Diff

View 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);
}

File diff suppressed because it is too large Load Diff

View 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;
}

View File

@@ -0,0 +1,19 @@
<?php
/**
* TODO 补充说明
*
* User: jiehua
* Date: 16/3/30
* Time: 下午8:55
*/
class EncryptParseItem {
public $startIndex;
public $endIndex;
public $encryptContent;
}

View File

@@ -0,0 +1,18 @@
<?php
/**
* TODO 补充说明
*
* User: jiehua
* Date: 16/3/30
* Time: 下午8:51
*/
class EncryptResponseData {
public $realContent;
public $returnContent;
}

View 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;
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View File

@@ -0,0 +1,37 @@
<?php
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;
}
}
}
}
}

View File

@@ -0,0 +1,27 @@
<?php
/**
*/
namespace addon\alipay\event;
/**
* 应用安装
*/
class Install
{
/**
* 执行安装
*/
public function handle()
{
return success();
}
}

View File

@@ -0,0 +1,33 @@
<?php
/**
*/
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;
}
}
}
}

View File

@@ -0,0 +1,39 @@
<?php
/**
*/
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)
{
// if ($params["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());
}
// }
}
}

View File

@@ -0,0 +1,41 @@
<?php
/**
*/
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();
}
}
}

View File

@@ -0,0 +1,34 @@
<?php
/**
*/
namespace addon\alipay\event;
use addon\alipay\model\Config as ConfigModel;
use addon\alipay\model\Pay as PayModel;
use app\model\system\Pay;
/**
* 查询支付结果
*/
class PayOrderQuery
{
public function handle(array $params)
{
$pay_info = ( new Pay() )->getInfo([ [ 'id', '=', $params[ 'relate_id' ] ] ])[ 'data' ];
if (!empty($pay_info)) {
$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' ]);
$pay_common->orderQuery($pay_info);
}
}
}
}

View File

@@ -0,0 +1,33 @@
<?php
/**
*/
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;
}
}
}

View File

@@ -0,0 +1,42 @@
<?php
/**
*/
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;
}
}
}
}

View File

@@ -0,0 +1,51 @@
<?php
/**
*/
namespace addon\alipay\event;
use addon\alipay\model\Config;
/**
* 支付方式 (后台调用)
*/
class PayType
{
/**
* 支付方式及配置
*/
public function handle($param)
{
$app_type = $param['app_type'] ?? '';
if (!empty($app_type)) {
if (!in_array($app_type, [ "h5", "app", "pc", "aliapp", 'wechat' ])) {
return '';
}
if ($app_type != 'aliapp') {
$config_model = new Config();
$config_result = $config_model->getPayConfig($param[ 'site_id' ]);
$config = $config_result[ "data" ][ "value" ] ?? [];
$pay_status = $config[ "pay_status" ] ?? 0;
if ($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) 是国内先进的网上支付平台。"
);
return $info;
}
}

View File

@@ -0,0 +1,39 @@
<?php
/**
*/
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;
}
}

View File

@@ -0,0 +1,26 @@
<?php
/**
*/
namespace addon\alipay\event;
/**
* 应用卸载
*/
class UnInstall
{
/**
* 执行卸载
*/
public function handle()
{
return error(-1, "系统插件不得删除");
}
}

BIN
src/addon/alipay/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -0,0 +1,96 @@
<?php
/**
*/
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 ($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;
}
}

View File

@@ -0,0 +1,486 @@
<?php
/**
*/
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();
$pay_model->bindMchPay($param[ "out_trade_no" ], [ "is_aliapp" => $this->is_aliapp ]);
try {
if ($param[ "app_type" ] == 'h5' || $param[ "app_type" ] == 'wechat' || $param[ "app_type" ] == 'pc') {
$result = $this->aop->pageExecute($request, 'get');
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) {
return $this->success([
'type' => 'url',
'data' => $result
]);
}
} else {
$result = $this->aop->execute($request);
}
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)
{
$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;
if (!empty($resultCode) && $resultCode == 10000) {
return $this->success();
} else {
$sub_code = $result->$responseNode->sub_code;
$data = [];
if(in_array($sub_code, ['ACQ.TRADE_STATUS_ERROR', 'ACQ.REASON_TRADE_STATUS_INVALID', 'ACQ.REASON_ILLEGAL_STATUS'])){
$pay_order_result = $this->get($param[ "out_trade_no" ]);
if(!empty($pay_order_result) && $pay_order_result['code'] >= 0){
if($pay_order_result['data']['trade_status'] == 'TRADE_SUCCESS' || $pay_order_result['data']['trade_status'] == 'TRADE_FINISHED'){
$data['is_paid'] = 1;
}
}
}
return $this->error($data, $result->$responseNode->sub_msg);
}
}
/**
* 支付宝支付原路返回
* @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 {
//构造要请求的参数数组,无需改动
$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) {
$pay_common = new PayModel();
return $res = $pay_common->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' ]);
}
} 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 {
( new Cron() )->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);
}
}
}

View File

@@ -0,0 +1,94 @@
<?php
/**
*/
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;
}
}

View 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">&#xe67c;</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">&#xe67c;</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">&#xe67c;</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">&#xe67c;</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">&#xe67c;</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">&#xe67c;</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>

View File

@@ -0,0 +1,6 @@
<?php
return [
'template' => [],
'util' => [],
'link' => [],
];

View 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' => [
],
];

View File

@@ -0,0 +1,12 @@
<?php
return [
'name' => 'alisms',
'title' => '阿里云短信',
'description' => '阿里云短信功能',
'type' => 'tool', //插件类型 system :系统插件(自动安装), business:业务插件 promotion:营销插件 tool:工具插件
'status' => 1,
'author' => '',
'version' => '1',
'version_no' => '100',
'content' => '',
];

View File

@@ -0,0 +1,30 @@
<?php
// +----------------------------------------------------------------------
// | 平台端菜单设置
// +----------------------------------------------------------------------
return [
[
'name' => 'ALI_SMS_CONFIG',
'title' => '短信配置',
'url' => 'alisms://shop/sms/config',
'parent' => 'CONFIG_BASE',
'is_show' => 1,
'is_control' => 1,
'is_icon' => 0,
'picture' => '',
'picture_select' => '',
'sort' => 98,
],
[
'name' => 'MESSAGE_SMS_EDIT',
'title' => '编辑短信模板',
'url' => 'alisms://shop/message/edit',
'parent' => 'MESSAGE_LISTS',
'is_show' => 0,
'picture' => '',
'picture_select' => '',
'sort' => 1,
'child_list' => [
],
],
];

View File

@@ -0,0 +1,26 @@
<?php
namespace addon\alisms\event;
use addon\alisms\model\Config as ConfigModel;
/**
* 短信模板 (后台调用)
*/
class DoEditSmsMessage
{
/**
* 短信发送方式方式及配置
*/
public function handle($data)
{
$config_model = new ConfigModel();
$config_result = $config_model->getSmsConfig($data['site_id']);
$config = $config_result["data"];
if ($config["is_use"] == 1) {
return ["edit_url" => "alisms://shop/message/edit", "shop_url" => "alisms://shop/message/edit"];
}
}
}

View File

@@ -0,0 +1,28 @@
<?php
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;
}
}
}
}

View File

@@ -0,0 +1,31 @@
<?php
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;
}
}
}

View File

@@ -0,0 +1,17 @@
<?php
namespace addon\alisms\event;
/**
* 应用安装
*/
class Install
{
/**
* 执行安装
*/
public function handle()
{
return success();
}
}

View File

@@ -0,0 +1,24 @@
<?php
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;
}
}

View File

@@ -0,0 +1,26 @@
<?php
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');
$sms_config = $sms_config[ '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);
}
}
}
}

View File

@@ -0,0 +1,30 @@
<?php
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;
}
}

View File

@@ -0,0 +1,17 @@
<?php
namespace addon\alisms\event;
/**
* 应用卸载
*/
class UnInstall
{
/**
* 执行卸载
*/
public function handle()
{
return success();
}
}

BIN
src/addon/alisms/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,58 @@
<?php
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;
}
}

View File

@@ -0,0 +1,71 @@
<?php
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($param['site_id']);
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 = ['name'=>$param[ "var_parse" ]['code']];//$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" ],
]
],
];
// $sms_info['content'] = '【聚上科技】尊敬的用户:您的校验码: ${name},工作人员不会索取,请勿泄漏。';
// $sms_info['template_id'] = 'SMS_241077505';
$sms_info['smssign'] = $config[ "smssign" ];
try {
$easySms = new EasySms($sms_config);
$res = $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 ? : '短信发送异常');
}
}
}
}

View File

@@ -0,0 +1,76 @@
<?php
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 = 'REGISTER_CODE';//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');
}
}
}

View File

@@ -0,0 +1,36 @@
<?php
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_id
$access_key_secret = input("access_key_secret", "");//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");
}
}
}

View File

@@ -0,0 +1,102 @@
<style>
.layui-btn-primary:hover {border-color: #C9C9C9;}
.number-con {margin-right: 10px;}
.form {margin-top: 0;}
</style>
<div class="layui-form form">
<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}
{if $message_variable_v !='站点名称'}
<button class="layui-btn layui-btn-primary number-con" onclick="clickBtn('{$message_variable_k}')">{$message_variable_v}</button>
{/if}
{/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 bg-color" 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(){
location.href = ns.url("shop/message/lists")
},
btn2: function() {
location.reload();
}
});
}else{
layer.msg(res.message);
}
}
});
});
});
function back(){
location.href = ns.url("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+1, position+1); //setSelectionRange()方法用来设置<input>元素当前选中的文本的开始和结束位置
}
</script>

View File

@@ -0,0 +1,82 @@
<style>
.form {margin-top: 0;}
</style>
<div class="layui-form form">
<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 bg-color" 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,
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(){
location.href = ns.url("shop/message/sms")
},
btn2: function() {
location.reload();
}
});
}else{
layer.msg(res.message);
}
}
});
});
});
function back() {
location.href = ns.url("shop/message/sms");
}
</script>

View File

@@ -0,0 +1,61 @@
<?php
namespace addon\cases\api\controller;
use app\api\controller\BaseApi;
use addon\cases\model\Cases as CasesModel;
use app\model\shop\Shop as ShopModel;
/**
* 电子名片
*/
class Cases extends BaseApi
{
/**
* 名片数据
*/
public function cases()
{
$shop_model = new ShopModel();
$list = model('cases')->getList(['site_id'=>$this->site_id],'*','displayorder desc');
$shop_info_result = $shop_model->getShopInfo(['site_id'=>$this->site_id])['data'];//$this->site_id
$Casesmodel = new CasesModel();
$set = $Casesmodel->getCasesSet($this->site_id, $this->app_module)[ 'data' ][ 'value' ];
//视频文件
$video_list = model('cases_video')->getList(['site_id'=>$this->site_id],'*','createtime desc');
//企业文件
$file_list = model('cases_files')->getList(['site_id'=>$this->site_id],'*','createtime desc');
//电子名片diy
// $config = $Casesmodel->getCasesSet($this->site_id, $this->app_module)[ 'data' ][ 'value' ];
// $config['value'] = json_decode($config['value'],true);
return $this->response(['code'=>'0','data'=>$list,'message'=>'操作成功','shop'=>$shop_info_result,'set'=>$set,'video_list'=>$video_list,'file_list'=>$file_list]);
}
public function getPersonnelset(){
$Casesmodel = new CasesModel();
$config = $Casesmodel->getCasesSet($this->site_id, $this->app_module)[ 'data' ][ 'value' ];
$this->response($config);
}
}

View File

@@ -0,0 +1,48 @@
<?php
/**
*/
return [
// 自定义模板页面类型,格式:[ 'title' => '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据json格式' ]
'template' => [],
// 后台自定义组件——装修
'util' => [],
// 自定义页面路径
'link' => [
[
'name' => 'CASES_INFO',
'title' => '案例展示',
'parent' => 'BASICS_LINK',
'wap_url' => '/pages_tool/cases/index',
'web_url' => '',
'sort' => 0
]
],
// 自定义图标库
'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' => []
];

View File

@@ -0,0 +1,18 @@
<?php
// 事件定义文件
return [
'bind' => [
],
'listen' => [
//展示活动
'ShowPromotion' => [
'addon\cases\event\ShowPromotion',
],
],
'subscribe' => [
],
];

View File

@@ -0,0 +1,21 @@
<?php
/**
*/
return [
'name' => 'cases',
'title' => '案例展示',
'description' => '展示案例信息',
'type' => 'tool', //插件类型 system :系统插件(自动安装), promotion:扩展营销插件 tool:工具插件
'status' => 1,
'author' => '',
'version' => '1.0.0',
'version_no' => '2025051923121',
'content' => '',
];

View File

@@ -0,0 +1,201 @@
<?php
// +----------------------------------------------------------------------
// | 店铺端菜单设置
// +----------------------------------------------------------------------
return [
[
'name' => 'CASES_ROOT',
'title' => '案例展示',
'url' => 'cases://shop/cases/lists',
'parent' => 'PROMOTION_TOOL',
'picture' => 'addon/cases/shop/view/public/img/live_new.png',
'picture_selected' => 'addon/cases/shop/view/public/img/live_select.png',
'is_show' => 1,
'sort' => 100,
'child_list' => [
[
'name' => 'CASES_LIST',
'title' => '人员列表',
'url' => 'cases://shop/cases/lists',
'is_show' => 1,
'sort' => 1,
'child_list' => [
[
'name' => 'CASES_ADD',
'title' => '添加人员',
'url' => 'cases://shop/cases/add',
'sort' => 1,
'is_show' => 0,
'is_control' => 1,
],
[
'name' => 'CASES_EDIT',
'title' => '编辑人员',
'url' => 'cases://shop/cases/edit',
'sort' => 1,
'is_show' => 0,
'is_control' => 1,
],
[
'name' => 'CASES_DELETE',
'title' => '删除人员',
'url' => 'cases://shop/cases/delete',
'sort' => 1,
'is_show' => 0,
'is_control' => 1,
],
]
],
[
'name' => 'CASES_ENTERPRISE_LIST',
'title' => '企业文件',
'url' => 'cases://shop/enterprise/lists',
'is_show' => 1,
'sort' => 2,
'child_list' => [
[
'name' => 'CASES_ENTERPRISE_ADD',
'title' => '添加企业文件',
'url' => 'cases://shop/enterprise/add',
'sort' => 1,
'is_show' => 0,
'is_control' => 1,
],
[
'name' => 'CASES_ENTERPRISE_EDIT',
'title' => '编辑企业文件',
'url' => 'cases://shop/enterprise/edit',
'sort' => 1,
'is_show' => 0,
'is_control' => 1,
],
[
'name' => 'CASES_ENTERPRISE_DELETE',
'title' => '删除企业文件',
'url' => 'cases://shop/enterprise/delete',
'sort' => 2,
'is_show' => 0,
'is_control' => 1,
],
]
],
[
'name' => 'CASES_VIDEO_LIST',
'title' => '视频文件',
'url' => 'cases://shop/enterprise/videolists',
'is_show' => 1,
'sort' => 3,
'child_list' => [
[
'name' => 'CASES_VIDEO_ADD',
'title' => '添加视频文件',
'url' => 'cases://shop/enterprise/videoadd',
'sort' => 1,
'is_show' => 0,
'is_control' => 1,
],
[
'name' => 'CASES_VIDEO_EDIT',
'title' => '编辑视频文件',
'url' => 'cases://shop/enterprise/videoedit',
'sort' => 1,
'is_show' => 0,
'is_control' => 1,
],
[
'name' => 'CASES_VIDEO_DELETE',
'title' => '删除视频文件',
'url' => 'cases://shop/enterprise/videodelete',
'sort' => 2,
'is_show' => 0,
'is_control' => 1,
],
]
],
// [
// 'name' => 'MESSAGE_ROOT',
// 'title' => '留言列表',
// 'url' => 'cases://shop/cases/message',
// 'is_show' => 1,
// 'sort' => 4,
// 'child_list' => [
// ],
// ],
// [
// 'name' => 'CONTACT_SHOW',
// 'title' => '电子名片',
// 'url' => 'cases://shop/cases/diy',
// 'is_show' => 1,
// 'sort' => 5,
// 'child_list' => [
// ],
// ],
[
'name' => 'CASES_SET',
'title' => '设置',
'url' => 'cases://shop/cases/set',
'is_show' => 1,
'sort' => 6,
'child_list' => [
],
],
// [
// 'name' => 'CASES_SET',
// 'title' => '基础设置',
// 'url' => 'cases://shop/cases/set',
// 'is_show' => 1,
// 'sort' => 3,
// 'child_list' => [
// ],
// ]
]
],
];
// +----------------------------------------------------------------------
// | 平台端菜单设置
// +----------------------------------------------------------------------
/*
return [
[
'name' => 'CASES_ROOT',
'title' => '电子名片',
'url' => 'cases://shop/cases/lists',
'picture' => 'addon/cases/shop/view/public/img/live_new.png',
'picture_selected' => 'addon/cases/shop/view/public/img/live_select.png',
'parent' => 'CASES_TOOL',
'is_show' => 1,
'sort' => 1,
'child_list' => [
[
'child_list' => [
]
],
]
],[
'name' => 'MESSAGE_ROOT',
'title' => '留言列表',
'url' => 'cases://shop/cases/message',
'parent' => 'CASES_TOOL',
'is_show' => 1,
'picture' => '',
'picture_select' => '',
'sort' => 1,
'child_list' => [],
],
];
*/

View File

@@ -0,0 +1 @@
SET NAMES 'utf8';

View File

@@ -0,0 +1 @@
SET NAMES 'utf8';

View File

@@ -0,0 +1,25 @@
<?php
/**
*/
namespace addon\cases\event;
/**
* 应用安装
*/
class Install
{
/**
* 执行安装
*/
public function handle()
{
return success();
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace addon\cases\event;
/**
* 活动展示
*/
class ShowPromotion
{
/**
* 活动展示
* @return array
*/
public function handle()
{
$data = [
'shop' => [
[
//插件名称
'name' => 'cases',
//店铺端展示分类 shop:营销活动 member:互动营销
'show_type' => 'tool',
//展示主题
'title' => '案例展示',
//展示介绍
'description' => '展示案例信息',
//展示图标
'icon' => 'addon/cases/icon.png',
//跳转链接
'url' => 'cases://shop/cases/lists',
]
]
];
return $data;
}
}

View File

@@ -0,0 +1,30 @@
<?php
/**
*/
namespace addon\cases\event;
/**
* 应用卸载
*/
class UnInstall
{
/**
* 执行卸载
*/
public function handle()
{
try {
return error('', "系统插件不允许删除");
} catch (\Exception $e) {
return error('', $e->getMessage());
}
}
}

BIN
src/addon/cases/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@@ -0,0 +1,136 @@
<?php
namespace addon\cases\model;
use app\model\BaseModel;
use app\model\system\Cron;
use app\model\upload\Upload;
use app\model\system\Config as ConfigModel;
class Cases extends BaseModel
{
/**
* 获取名片设置
* @param $site_id
* @param $app_module
* @return array
*/
public function getCasesSet($site_id, $app_module)
{
$config = new ConfigModel();
$res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', $app_module ], [ 'config_key', '=', 'DIY_CASES' ] ]);
if (empty($res[ 'data' ][ 'value' ])){
$res[ 'data' ][ 'value' ] = [
'cases_bg' => '',
'cases_tip'=>''
];
}
//public/static/img/diy_view/member_info_bg.png
return $res;
}
/**
* 设置名片设置
* @param $data
* @param $site_id
* @param $app_module
* @return array
*/
public function setCasesSet($data, $site_id, $app_module)
{
$config = new ConfigModel();
$res = $config->setConfig($data, '案例设置', 1, [ [ 'site_id', '=', $site_id ], [ 'app_module', '=', $app_module ], [ 'config_key', '=', 'DIY_CASES' ] ]);
return $res;
}
/**
* 获取留言列表
* @param array $condition
* @param bool $field
* @param string $order
* @param int $page
* @param int $list_rows
* @param string $alias
* @param array $join
* @return array
*/
public function getMessagePageList($condition = [], $field = true, $order = '', $page = 1, $list_rows = PAGE_LIST_ROWS, $alias = 'a', $join = [])
{
$data = model('cases_message')->pageList($condition, $field, $order, $page, $list_rows, $alias, $join);
if (!empty($data[ 'list' ])) {
foreach ($data[ 'list' ] as $k => $item) {
$data[ 'list' ][ $k ][ 'createtime' ] = date('Y-m-d H:i:s',$item['createtime']);
}
}
return $this->success($data);
}
/**
* 添加人员
* @param $param
*/
public function addCases($data)
{
$result = model('cases')->add($data);
return $this->success($result);
}
/**
* 编辑人员
* @param $param
*/
public function editCases($condition,$data)
{
$result = model('cases')->update($condition,$data);
return $this->success($result);
}
/**
* 删除人员
* @param $id
* @param $site_id
*/
public function deleteCases($id, $site_id)
{
$info = model('cases')->getInfo([ [ 'site_id', '=', $site_id ], [ 'id', '=', $id ] ], 'id');
if (empty($info)) return $this->error('', '未获取到人员信息');
$res = model('cases')->delete([ [ 'site_id', '=', $site_id ], [ 'id', '=', $id ] ]);
return $this->success($res);
}
/**
* 获取电子名片人员列表
* @param array $condition
* @param bool $field
* @param string $order
* @param int $page
* @param int $list_rows
* @param string $alias
* @param array $join
* @return array
*/
public function getCasesPageList($condition = [], $field = true, $order = '', $page = 1, $list_rows = PAGE_LIST_ROWS, $alias = 'a', $join = [])
{
$data = model('cases')->pageList($condition, $field, $order, $page, $list_rows, $alias, $join);
return $this->success($data);
}
/**
* 删除留言
* @param $id
* @param $site_id
*/
public function deleteMessage($id, $site_id)
{
$info = model('cases_message')->getInfo([ [ 'site_id', '=', $site_id ], [ 'id', '=', $id ] ], 'id');
if (empty($info)) return $this->error('', '未获取到留言信息');
$res = model('cases_message')->delete([ [ 'site_id', '=', $site_id ], [ 'id', '=', $id ] ]);
return $this->success($res);
}
}

View File

@@ -0,0 +1,267 @@
<?php
namespace addon\cases\model;
use app\model\BaseModel;
/**
* 文件
*/
class Enterprise extends BaseModel
{
/**
* 添加文件
* @param $data
* @return array
*/
public function addFiles($data)
{
$data[ 'createtime' ] = time();
model('cases_files')->startTrans();
try {
//添加文件
model('cases_files')->add($data);
model('cases_files')->commit();
return $this->success();
} catch (\Exception $e) {
model('cases_files')->rollback();
return $this->error('', $e->getMessage());
}
}
/**
* 编辑文件
* @param $condition
* @param $data
* @return array
*/
public function editFiles($data)
{
// $data[ 'update_time' ] = time();
model('cases_files')->startTrans();
try {
//添加文件
model('cases_files')->update($data, [ [ 'site_id', '=', $data[ 'site_id' ] ], [ 'files_id', '=', $data[ 'files_id' ] ] ]);
model('cases_files')->commit();
return $this->success();
} catch (\Exception $e) {
model('cases_files')->rollback();
return $this->error('', $e->getMessage());
}
}
/**
* 删除文件
* @param $files_id
* @param $site_id
* @return array|\multitype
*/
public function deleteFiles($condition)
{
//文件数
$files_info = model('cases_files')->getInfo($condition, '*');
if (empty($files_info)) {
return $this->success('', '数据不合法');
} else {
model('cases_files')->startTrans();
try {
//删除文件
model('cases_files')->delete($condition);
model('cases_files')->commit();
return $this->success();
} catch (\Exception $e) {
model('cases_files')->rollback();
return $this->error('', $e->getMessage());
}
}
}
/**
* 获取文件信息
* @param array $condition
* @param string $field
* @return array
*/
public function getFilesInfo($condition = [], $field = '*')
{
$info = model("cases_files")->getInfo($condition, $field);
return $this->success($info);
}
/**
* 获取文件信息
* @param array $condition
* @param string $field
* @param int $type
* @return array
*/
public function getFilesDetailInfo($condition = [], $field = '*', $type = 1)
{
$info = model('cases_files')->getInfo($condition, $field);
//添加浏览记录
if ($type == 2) {
model('cases_files')->setInc($condition, 'read_num', 1);
}
return $this->success($info);
}
/**
* 获取文件列表
* @param array $condition
* @param string $field
* @param string $order
* @param string $limit
*/
public function getFilesList($condition = [], $field = '*', $order = '', $limit = null, $alias = '', $join = [])
{
$list = model('cases_files')->getList($condition, $field, $order, $alias, $join, '', $limit);
return $this->success($list);
}
/**
* 获取文件分页列表
* @param array $condition
* @param int $page
* @param int $page_size
* @param string $order
* @param string $field
* @return array
*/
public function getFilesPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'pn.createtime asc', $field = 'pn.*')
{
$alias = 'pn';
$join = [];
$list = model('cases_files')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
return $this->success($list);
}
/**
* 生成推广二维码链接
* @param $qrcode_param
* @param $site_id
* @return array
*/
public function urlQrcode($qrcode_param, $app_type, $site_id)
{
$h5_page = '/pages_tool/files/detail';
$pc_page = '/cms/files/detail';
$params = [
'site_id' => $site_id,
'data' => $qrcode_param,
'pc_data' => [ 'id' => $qrcode_param[ 'files_id' ] ],
'page' => $h5_page,
'h5_path' => $h5_page . '?files_id=' . $qrcode_param[ 'files_id' ],
'pc_page' => $pc_page,
'pc_path' => $pc_page . '?id=' . $qrcode_param[ 'files_id' ],
'qrcode_path' => 'upload/qrcode/files',
'qrcode_name' => 'files_qrcode' . $qrcode_param[ 'files_id' ] . '_' . $site_id,
'app_type' => $app_type,
];
$solitaire = event('PromotionQrcode', $params);
return $this->success($solitaire[ 0 ]);
}
//视频
/**
* 获取分页列表
* @param array $condition
* @param number $page
* @param string $page_size
* @param string $order
* @param string $field
*/
public function getVideoPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'sort asc', $field = '*')
{
$check_condition = array_column($condition, 2, 0);
$site_id = $check_condition['site_id'] ?? '';
if ($site_id === '') {
return $this->error('', 'REQUEST_SITE_ID');
}
$list = model('cases_video')->pageList($condition, $field, $order, $page, $page_size);
return $this->success($list);
}
/**
* 获取视频列表
* @param array $condition
* @param string $field
* @param string $order
* @param string $limit
*/
public function getVideoList($condition = [], $field = '*', $order = '', $limit = null)
{
$list = model('cases_video')->getList($condition, $field, $order, '', '', '', $limit);
return $this->success($list);
}
/**
* 添加商户分类
* @param array $data
*/
public function addVideo($data)
{
$site_id = $data['site_id'] ?? '';
if ($site_id === '') {
return $this->error('', 'REQUEST_SITE_ID');
}
$data[ 'create_time' ] = time();
$category_id = model('cases_video')->add($data);
return $this->success($category_id);
}
public function getVideoInfo($condition = [], $field = '*')
{
$list = model('cases_video')->getInfo($condition, $field);
return $this->success($list);
}
/**
* 修改商户分类
* @param array $data
*/
public function editVideo($data)
{
$site_id = $data['site_id'] ?? '';
if ($site_id === '') {
return $this->error('', 'REQUEST_SITE_ID');
}
model('cases_video')->startTrans();
try {
//添加文件
model('cases_video')->update($data, [ [ 'site_id', '=', $data[ 'site_id' ] ], [ 'video_id', '=', $data[ 'video_id' ] ] ]);
model('cases_video')->commit();
return $this->success();
} catch (\Exception $e) {
model('cases_video')->rollback();
return $this->error('', $e->getMessage());
}
}
/**
* 删除商户分类
* @param array $condition
*/
public function deleteVideo($condition)
{
file_put_contents(__DIR__ . '/debug.txt', var_export($condition,true));
$check_condition = array_column($condition, 2, 0);
$site_id = $check_condition['site_id'] ?? '';
if ($site_id === '') {
return $this->error('', 'REQUEST_SITE_ID');
}
$res = model('cases_video')->delete($condition);
return $this->success($res);
}
}

View File

@@ -0,0 +1,155 @@
<?php
namespace addon\cases\shop\controller;
use app\shop\controller\BaseShop;
use addon\cases\model\Cases as CasesModel;
//去除判断为空 add lucky
error_reporting(E_ALL ^ E_NOTICE );
/**
* 直播间
*/
class Cases extends BaseShop
{
public function lists()
{
if (request()->isJson()) {
$Cases = new CasesModel();
$page = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$condition = [
[ 'site_id', '=', $this->site_id ],
];
$search_text = input('search_text', '');
if (!empty($search_text)) {
$condition[] = [ 'realname', 'like', '%' . $search_text . '%' ];
}
$data = $Cases->getCasesPageList($condition, '*', 'displayorder desc', $page, $page_size);
return $data;
} else {
return $this->fetch('cases/lists');
}
}
/**
* 添加编辑人员
* @return mixed
*/
public function add()
{
$id = input('id',0);
if (request()->isJson()) {
$Cases = new CasesModel();
$data = [
'site_id' => $this->site_id,
'realname' => trim(input('realname')),
'displayorder' => intval(input('displayorder')),
'mobile' => trim(input('mobile')),
'address' => trim(input('address')),
'landline' => trim(input('landline')),
'position' => trim(input('position')),
'title_text' => trim(input('title_text')),
'position_text' => trim(input('position_text')),
'mobile_text' => trim(input('mobile_text')),
'address_text' => trim(input('address_text')),
'email' => trim(input('email')),
];
if($id > 0){
$res = $Cases->editCases($data,['id'=>$id]);
}else{
$res = $Cases->addCases($data);
}
return $res;
}
$item = $id>0?model('cases')->getInfo(['id'=>$id,'site_id' => $this->site_id]):[];
$this->assign('item',$item);
$this->assign('id',$id);
return $this->fetch('cases/add');
}
/**
* 删除人员
*/
public function delete()
{
if (request()->isJson()) {
$id = input('id', '');
$Cases = new CasesModel();
$res = $Cases->deleteCases($id, $this->site_id);
return $res;
}
}
//留言列表
public function message(){
if (request()->isJson()) {
$Cases = new CasesModel();
$page = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$condition = [
[ 'a.site_id', '=', $this->site_id ],
];
$search_text = input('search_text', '');
if (!empty($search_text)) {
$condition[] = [ 'a.username', 'like', '%' . $search_text . '%' ];
}
$join = [
[ 'member m', 'a.member_id = m.member_id', 'inner' ]
];
$data = $Cases->getMessagePageList($condition, 'a.*,m.headimg,m.nickname', 'a.createtime desc', $page, $page_size,'a',$join);
return $data;
} else {
return $this->fetch('cases/message');
}
}
/**
* 删除留言
*/
public function delmessage()
{
if (request()->isJson()) {
$id = input('id', '');
$Cases = new CasesModel();
$res = $Cases->deleteMessage($id, $this->site_id);
return $res;
}
}
/**
* 名片基础设置
*/
public function set(){
$Cases = new CasesModel();
if (request()->isJson()) {
// $Cases = new CasesModel();
$cases_bg = input('cases_bg', '');
$cases_tip = input('cases_tip', '');
$value = ['cases_bg'=>$cases_bg,'cases_tip'=>$cases_tip];
return $Cases->setCasesSet($value,$this->site_id, $this->app_module);
} else {
$config = $Cases->getCasesSet($this->site_id, $this->app_module)[ 'data' ][ 'value' ];
$this->assign('config', $config);
return $this->fetch('cases/set');
}
}
// public function diy(){
// $Cases = new CasesModel();
// $config = $Cases->getCasesSet($this->site_id, $this->app_module)[ 'data' ][ 'value' ];
// if (request()->isJson()) {
// $personnel_bg = $config['personnel_bg'];
// $value = input('value', '');
// $data = ['personnel_bg'=>$personnel_bg,'value'=>$value];
// return $Cases->setCasesSet($data,$this->site_id, $this->app_module);
// } else {
// $config['value'] = json_decode($config['value'],true);
// $this->assign('config', $config);
// return $this->fetch('cases/diy');
// }
// }
}

View File

@@ -0,0 +1,174 @@
<?php
namespace addon\cases\shop\controller;
use app\shop\controller\BaseShop;
use addon\cases\model\Enterprise as EnterpriseModel;
use app\model\upload\Upload;
//去除判断为空 add lucky
error_reporting(E_ALL ^ E_NOTICE );
/**
* 直播间
*/
class Enterprise extends BaseShop
{
public function lists()
{
if (request()->isJson()) {
$page = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$search_text = input('search_text', '');
$condition = [ [ 'pn.site_id', '=', $this->site_id ]];
$condition[] = [ 'pn.files_title', 'like', '%' . $search_text . '%' ];
$order_by = 'pn.createtime desc';
$model = new EnterpriseModel();
$list = $model->getFilesPageList($condition, $page, $page_size, $order_by);
return $list;
} else {
return $this->fetch('enterprise/lists');
}
}
/**
* 文件添加
*/
public function add()
{
$model = new EnterpriseModel();
if (request()->isJson()) {
$files_data = [
'site_id' => $this->site_id,
'files_title' => input('files_title', ''),
'files_url' => input('files_url', ''),
'size' => input('size', ''),
'category_id'=>input('category_id', 0)
];
return $model->addFiles($files_data);
} else {
return $this->fetch('enterprise/add');
}
}
/**
* 编辑
*/
public function edit()
{
$files_id = input('files_id', 0);
$model = new EnterpriseModel();
if (request()->isJson()) {
$files_data = [
'files_id' => $files_id,
'site_id' => $this->site_id,
'files_title' => input('files_title', ''),
'files_url' => input('files_url', ''),
'size' => input('size', ''),
];
return $model->editFiles($files_data);
} else {
$this->assign('files_id', $files_id);
$article_info = $model->getFilesInfo([ [ 'files_id', '=', $files_id ] ]);
$this->assign('info', $article_info[ 'data' ]);
return $this->fetch('enterprise/edit');
}
}
/**
* 文件删除
*/
public function delete()
{
if (request()->isJson()) {
$files_id = input('files_id', 0);
$model = new EnterpriseModel();
return $model->deleteFiles([ [ 'files_id', '=', $files_id ] ]);
}
}
/**
* 上传文件
*/
public function uploadfile()
{
$upload_model = new Upload();
$site_id = request()->siteid();
$name = input("name", "");
$extend_type = [ 'pdf' ];
$param = array (
"name" => "file",
"extend_type" => $extend_type
);
$file = request()->file($param[ "name" ]);
$site_id = max($site_id, 0);
$result = $upload_model->setPath("common/filepdf/" . $site_id . "/")->file($param);
if($result['code'] == 10067){
$result['data']['size'] = round($_FILES['file']['size']/(1024*1024),2);
}
return $result;
}
/***************************************视频部分****************************************/
public function videolists(){
if (request()->isJson()) {
$page = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$search_text = input('search_text', '');
$condition = [ [ 'site_id', '=', $this->site_id ]];
$condition[] = [ 'video_title', 'like', '%' . $search_text . '%' ];
$order_by = 'createtime desc';
$model = new EnterpriseModel();
$list = $model->getVideoPageList($condition, $page, $page_size, $order_by);
return $list;
} else {
return $this->fetch('enterprise/video/lists');
}
}
public function videoadd()
{
$model = new EnterpriseModel();
if (request()->isJson()) {
$data = [
'site_id' => $this->site_id,
'video_title' => input('video_title', ''),
'video_url' => input('video_url', ''),
'images' => input('cover_img', '')
];
return $model->addVideo($data);
} else {
return $this->fetch('enterprise/video/add');
}
}
public function videoedit()
{
$video_id = input('video_id', 0);
$model = new EnterpriseModel();
if (request()->isJson()) {
$files_data = [
'video_id' => $video_id,
'site_id' => $this->site_id,
'video_title' => input('video_title', ''),
'video_url' => input('video_url', ''),
'images' => input('cover_img', '')
];
return $model->editVideo($files_data);
} else {
$this->assign('video_id', $video_id);
$article_info = $model->getVideoInfo([ [ 'video_id', '=', $video_id ] ]);
$this->assign('info', $article_info[ 'data' ]);
return $this->fetch('enterprise/video/add');
}
}
public function videodelete()
{
if (request()->isJson()) {
$video_id = input('video_id', 0);
$model = new EnterpriseModel();
return $model->deleteVideo([ [ 'video_id', '=', $video_id],['site_id','=',$this->site_id] ]);
}
}
}

View File

@@ -0,0 +1,138 @@
<style type="text/css">
.price-wrap{display: flex;top: 4px;position: relative;}
.price-wrap > span {display: inline-block;margin: 0 5px;}
.price-wrap > span.sepa{margin: 0 20px;}
</style>
<div class="layui-form form-wrap">
<input type="hidden" name="id" value="{$id}" disabled style="background: #eee" class="layui-input ns-len-mid" autocomplete="off">
<div class="layui-form-item">
<label class="layui-form-label" style="width: 100px;margin-left: 120px;">
<input type="text" value="序号" disabled style="background: #eee" class="layui-input ns-len-mid" autocomplete="off">
</label>
<div class="layui-input-block" style="width:300px;display: flex;">
<input type="number" name="displayorder" value="{$item.displayorder??0}" class="layui-input ns-len-mid" autocomplete="off">
</div>
<div class="word-aux" style="margin-left: 250px">
<p>数字越大,排名越靠前</p>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label" style="width: 100px;margin-left: 120px;">
<input type="text" name="title_text" readonly value="{$item.title_text?$item.title_text:'姓名'}" class="layui-input ns-len-mid" autocomplete="off">
</label>
<div class="layui-input-block" style="width:300px;display: flex;">
<input type="text" name="realname" value="{$item.realname}" class="layui-input ns-len-mid" autocomplete="off">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label" style="width: 100px;margin-left: 120px;">
<input type="text" name="position_text" readonly value="{$item.position_text?$item.position_text:'公司'}" class="layui-input ns-len-mid" autocomplete="off">
</label>
<div class="layui-input-block" style="width:300px;display: flex;">
<input type="text" name="position" value="{$item.position}" class="layui-input ns-len-mid" autocomplete="off">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label" style="width: 100px;margin-left: 120px;">
<input type="text" name="mobile_text" readonly value="{$item.mobile_text?$item.mobile_text:'电话'}" class="layui-input ns-len-mid" autocomplete="off">
</label>
<div class="layui-input-block" style="width:300px;display: flex;">
<input type="text" name="mobile" value="{$item.mobile}" class="layui-input ns-len-mid" autocomplete="off">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label" style="width: 100px;margin-left: 120px;">
<input type="text" name="address_text" readonly value="{$item.address_text?$item.address_text:'职位'}" class="layui-input ns-len-mid" autocomplete="off">
</label>
<div class="layui-input-block" style="width:300px;display: flex;">
<input type="text" name="address" value="{$item.address}" class="layui-input ns-len-mid" autocomplete="off">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label" style="width: 100px;margin-left: 120px;">
<input type="text" value="邮箱" readonly class="layui-input ns-len-mid" autocomplete="off">
</label>
<div class="layui-input-block" style="width:300px;display: flex;">
<input type="text" name="email" value="{$item.email}" class="layui-input ns-len-mid" autocomplete="off">
</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 type="text/javascript">
var form,repeat_flag=false;
layui.use(['form'], function() {
form = layui.form;
form.render();
var upload = new Upload({
elem: '#ImgUpload',
multiple: true,
});
/**
* 表单验证
*/
// form.verify({
// name: function(value){
// if (value.length < 3 || value.length > 14) {
// return '商品名称必须为3-14个字符';
// }
// },
// goodsPic: function(value){
// var patt = /[\S]+/;
// if (!patt.test(value)) {
// return '请上传商品封面!';
// }
// },
// });
form.on('submit(save)', function(data){
if (repeat_flag) return;
repeat_flag = true;
$.ajax({
type: 'POST',
url: ns.url("cases://shop/cases/add"),
data: data.field,
dataType: 'JSON',
success: function(res) {
layer.msg(res.message);
repeat_flag = false;
if (res.code == 0) {
location.hash = ns.hash("cases://shop/cases/lists");
}
}
});
});
});
function back() {
location.hash = ns.hash("cases://shop/cases/lists");
}
</script>

View File

@@ -0,0 +1,166 @@
<style>
.goods-type{display: flex;justify-content: space-between;}
.goods-type .item-type{display: flex;flex-direction: column;align-items: center;padding: 15px;border: 1px solid #e5e5e5;border-radius: 5px;cursor: pointer;}
.goods-type .item-type ~ .item-type{margin-left: 20px;}
.goods-type .item-img{display: flex;justify-content: center;align-content: center;width: 200px;height: 270px;}
.goods-type .item-img img{max-width: 100%;max-height: 100%;}
.goods-type .item-content{margin-top: 15px;text-align: center;}
.goods-type .item-content .description{margin-top: 10px;font-size: 12px;color: #999;line-height: 1.6;}
.layui-layer-page .layui-layer-content{padding: 30px;}
.layui-table-header{overflow: inherit;}
.layui-table-header .layui-table-cell{overflow: inherit;}
.layui-form-item .layui-form-checkbox[lay-skin=primary] {margin-top: 0;}
.layui-layout-admin.admin-style-2 .layui-form-item .layui-input-inline{background-color: #fff;}
.layui-layout-admin.admin-style-2 .layui-body .layui-tab + .body-content {padding-top: 65px !important;}
</style>
<div class="single-filter-box">
<button class="layui-btn" onclick="add()">添加人员</button>
<div class="layui-form">
<div class="layui-input-inline len-mid">
<input type="text" name="search_text" placeholder="请输入姓名" class="layui-input">
<button type="button" class="layui-btn layui-btn-primary" lay-filter="search" lay-submit>
<i class="layui-icon">&#xe615;</i>
</button>
</div>
</div>
<input type="hidden" name="ap_id" value="{$ap_id}" />
</div>
<table id="goods_list" lay-filter="goods_list"></table>
<!-- 直播间信息 -->
<script type="text/html" id="goodsinfo">
<div class="layui-table-cell goods-info">
<img src="{{ ns.img(d.cover_img) }}">
<span class="room-name" title="{{ d.name }}">{{ d.name }}</span>
</div>
</script>
<!-- 操作 -->
<script type="text/html" id="operation">
<div class="table-btn">
<a class="layui-btn" lay-event="edit">编辑</a>
<a class="layui-btn" lay-event="del">删除</a>
</div>
</script>
<!-- <div class="progress-layer">
<h3>正在同步中...</h3>
<div class="layui-progress layui-progress-big" lay-showPercent="true" lay-filter="progress">
<div class="layui-progress-bar layui-bg-blue" lay-percent="0%"></div>
</div>
</div> -->
<script>
var form,table,element,syncClick = false,delete_flag = false;
layui.use(['form', 'element'], function() {
form = layui.form;
element = layui.element;
table = new Table({
elem: '#goods_list',
url: ns.url("cases://shop/cases/lists"),
cols: [
[{
title: '序号',
unresize: 'false',
field: 'displayorder'
}, {
title: '姓名',
unresize: 'false',
field: 'realname'
}, {
field: 'position',
title: '公司',
unresize: 'false',
}, {
field: 'mobile',
title: '电话',
unresize: 'false',
},{
field: 'address',
title: '职位',
unresize: 'false',
},
{
field: 'email',
title: '邮箱',
unresize: 'false',
},
/* {
field: 'status_name',
title: '状态',
unresize: 'false',
width: '15%',
}, */
{
title: '操作',
toolbar: '#operation',
unresize: 'false',
align:'right'
}]
]
});
/**
* 监听搜索
*/
form.on('submit(search)', function(data){
table.reload({
page: {
curr: 1
},
where: data.field
});
});
table.tool(function(obj) {
var data = obj.data;
switch (obj.event) {
case 'edit': //编辑
location.hash = ns.hash("cases://shop/cases/add?id="+data.id);
break;
case 'del': //删除
layer.confirm('确定要删除该人员吗?', function(index) {
if (delete_flag) return false;
delete_flag = true;
layer.close(index);
$.ajax({
url: ns.url("cases://shop/cases/delete"),
data: {
id: data.id
},
dataType: 'JSON',
type: 'POST',
success: function(res) {
layer.msg(res.message);
delete_flag = false;
if (res.code == 0) {
table.reload({
page: {
curr: 1
},
});
}
}
});
}, function() {
layer.close();
delete_flag = false;
});
break;
}
})
});
function add() {
location.hash = ns.hash("cases://shop/cases/add");
}
</script>

View File

@@ -0,0 +1,131 @@
<style type="text/css">
.examples {cursor: pointer;}
.label-width {width: 80px; }
.layui-layout-admin.admin-style-2 .layui-body .layui-tab + .body-content {padding-top: 63px !important;}
</style>
<div class="layui-form">
<div class="layui-form-item">
<label class="layui-form-label">提示语:</label>
<div class="layui-input-block">
<input type="text" name="cases_tip" value="{$config.cases_tip?? ''}" placeholder="请输入标题" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">封面:</label>
<div class="layui-input-block img-upload">
<div class="upload-img-block">
<div class="upload-img-box {if condition="!empty($config.cases_bg)"}hover{/if} ">
<div class="upload-default" id="personnelUpload">
{if condition="!empty($config.cases_bg)"}
<div id="preview_logoUpload" class="preview_img">
<img layer-src src="{:img($config.cases_bg)}" class="img_prev"/>
</div>
{else/}
<div class="upload">
<i class="iconfont iconshangchuan"></i>
<p>点击上传</p>
</div>
{/if}
</div>
<div class="operation">
<div>
<i title="图片预览" class="iconfont iconreview js-preview" style="margin-right: 20px;"></i>
<i title="删除图片" class="layui-icon layui-icon-delete js-delete"></i>
</div>
<div class="replace_img js-replace">点击替换</div>
</div>
<input type="hidden" name="cases_bg" value="{$config.cases_bg ?? ''}"/>
</div>
</div>
</div>
<div class="word-aux">
<p></p>
</div>
</div>
<div class="form-row">
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
</div>
<a id="btom_two"></a>
<a id="btom_three"></a>
</div>
<script>
var saveData = null;
var totalUploadNum = 0;
var completeUploadNum = 0;
var logo_upload;
layui.use(['form', 'laydate'], function(){
var form = layui.form,
laydate = layui.laydate,
repeat_flag = false; //防重复标识
form.render();
form.on('submit(save)', function(data){
saveData = data;
var obj = $("img.img_prev[data-prev='1']");
totalUploadNum = obj.length;
if(totalUploadNum > 0){
obj.each(function(){
var actionId = $(this).attr('data-action-id');
$(actionId).click();
})
}else{
saveFunc();
}
});
// 店铺LOGO
logo_upload = new Upload({
elem: '#personnelUpload'
,auto: false //选择文件后不自动上传
,bindAction: '#btom_two' //指向一个按钮触发上传
,callback: function (res) {
if(res.code >= 0){
//验证,增加是否上传完成
completeUploadNum += 1;
saveData.field.cases_bg = res.data.pic_path;
if(completeUploadNum == totalUploadNum){
saveFunc();
}
}
}
});
function saveFunc(){
var data = saveData;
// 删除图片
if(!data.field.cases_bg) logo_upload.delete();
if (repeat_flag) return;
repeat_flag = true;
$.ajax({
type: 'POST',
url: ns.url("cases://shop/cases/set"),
data: data.field,
dataType: 'JSON',
sync: false,
success: function(res) {
layer.msg(res.message);
repeat_flag = false;
}
});
}
});
</script>

Some files were not shown because too many files have changed in this diff Show More