瀏覽代碼

sunguidong

zhangguidong 2 年之前
當前提交
052e979a88
共有 100 個文件被更改,包括 6946 次插入0 次删除
  1. 6 0
      .buildpath
  2. 6 0
      .env
  3. 7 0
      .gitignore
  4. 13 0
      .htaccess
  5. 22 0
      .project
  6. 42 0
      .travis.yml
  7. 52 0
      README.md
  8. 53 0
      addon/alioss/admin/controller/Config.php
  9. 97 0
      addon/alioss/admin/view/config/config.html
  10. 23 0
      addon/alioss/config/diy_view.php
  11. 23 0
      addon/alioss/config/event.php
  12. 20 0
      addon/alioss/config/info.php
  13. 18 0
      addon/alioss/config/menu_admin.php
  14. 7 0
      addon/alioss/config/menu_shop.php
  15. 29 0
      addon/alioss/event/CloseOss.php
  16. 29 0
      addon/alioss/event/Install.php
  17. 34 0
      addon/alioss/event/OssType.php
  18. 32 0
      addon/alioss/event/Put.php
  19. 28 0
      addon/alioss/event/UnInstall.php
  20. 二進制
      addon/alioss/icon.png
  21. 110 0
      addon/alioss/model/Alioss.php
  22. 57 0
      addon/alioss/model/Config.php
  23. 65 0
      addon/alipay/admin/controller/Pay.php
  24. 121 0
      addon/alipay/admin/view/pay/config.html
  25. 23 0
      addon/alipay/config/diy_view.php
  26. 46 0
      addon/alipay/config/event.php
  27. 20 0
      addon/alipay/config/info.php
  28. 25 0
      addon/alipay/config/menu_admin.php
  29. 14 0
      addon/alipay/config/menu_shop.php
  30. 231 0
      addon/alipay/data/sdk/AlipayMobilePublicMultiMediaClient.php
  31. 108 0
      addon/alipay/data/sdk/AlipayMobilePublicMultiMediaExecute.php
  32. 1210 0
      addon/alipay/data/sdk/AopClient.php
  33. 71 0
      addon/alipay/data/sdk/AopEncrypt.php
  34. 19 0
      addon/alipay/data/sdk/EncryptParseItem.php
  35. 18 0
      addon/alipay/data/sdk/EncryptResponseData.php
  36. 17 0
      addon/alipay/data/sdk/SignData.php
  37. 120 0
      addon/alipay/data/sdk/request/AlipayFundTransToaccountTransferRequest.php
  38. 119 0
      addon/alipay/data/sdk/request/AlipayFundTransUniTransferRequest.php
  39. 119 0
      addon/alipay/data/sdk/request/AlipayTradeAppPayRequest.php
  40. 118 0
      addon/alipay/data/sdk/request/AlipayTradeCancelRequest.php
  41. 120 0
      addon/alipay/data/sdk/request/AlipayTradeCloseRequest.php
  42. 118 0
      addon/alipay/data/sdk/request/AlipayTradeCreateRequest.php
  43. 118 0
      addon/alipay/data/sdk/request/AlipayTradeCustomsDeclareRequest.php
  44. 118 0
      addon/alipay/data/sdk/request/AlipayTradeCustomsQueryRequest.php
  45. 118 0
      addon/alipay/data/sdk/request/AlipayTradeFastpayRefundQueryRequest.php
  46. 118 0
      addon/alipay/data/sdk/request/AlipayTradeOrderSettleRequest.php
  47. 118 0
      addon/alipay/data/sdk/request/AlipayTradeOrderinfoSyncRequest.php
  48. 120 0
      addon/alipay/data/sdk/request/AlipayTradePagePayRequest.php
  49. 119 0
      addon/alipay/data/sdk/request/AlipayTradePayRequest.php
  50. 119 0
      addon/alipay/data/sdk/request/AlipayTradePrecreateRequest.php
  51. 119 0
      addon/alipay/data/sdk/request/AlipayTradeQueryRequest.php
  52. 120 0
      addon/alipay/data/sdk/request/AlipayTradeRefundRequest.php
  53. 118 0
      addon/alipay/data/sdk/request/AlipayTradeVendorpayDevicedataUploadRequest.php
  54. 120 0
      addon/alipay/data/sdk/request/AlipayTradeWapPayRequest.php
  55. 29 0
      addon/alipay/event/Install.php
  56. 36 0
      addon/alipay/event/Pay.php
  57. 32 0
      addon/alipay/event/PayClose.php
  58. 30 0
      addon/alipay/event/PayNotify.php
  59. 32 0
      addon/alipay/event/PayRefund.php
  60. 27 0
      addon/alipay/event/PayTransfer.php
  61. 50 0
      addon/alipay/event/PayType.php
  62. 41 0
      addon/alipay/event/TransferType.php
  63. 28 0
      addon/alipay/event/UnInstall.php
  64. 二進制
      addon/alipay/icon.png
  65. 43 0
      addon/alipay/model/Config.php
  66. 224 0
      addon/alipay/model/Pay.php
  67. 82 0
      addon/alisms/admin/controller/Message.php
  68. 47 0
      addon/alisms/admin/controller/Sms.php
  69. 107 0
      addon/alisms/admin/view/message/edit.html
  70. 88 0
      addon/alisms/admin/view/sms/config.html
  71. 23 0
      addon/alisms/config/diy_view.php
  72. 23 0
      addon/alisms/config/event.php
  73. 20 0
      addon/alisms/config/info.php
  74. 31 0
      addon/alisms/config/menu_admin.php
  75. 7 0
      addon/alisms/config/menu_shop.php
  76. 35 0
      addon/alisms/event/DoEditSmsMessage.php
  77. 29 0
      addon/alisms/event/Install.php
  78. 34 0
      addon/alisms/event/SendSms.php
  79. 41 0
      addon/alisms/event/SmsType.php
  80. 28 0
      addon/alisms/event/UnInstall.php
  81. 二進制
      addon/alisms/icon.png
  82. 43 0
      addon/alisms/model/Config.php
  83. 79 0
      addon/alisms/model/Sms.php
  84. 84 0
      addon/bundling/admin/controller/Bundling.php
  85. 60 0
      addon/bundling/admin/view/bundling/detail.html
  86. 204 0
      addon/bundling/admin/view/bundling/lists.html
  87. 53 0
      addon/bundling/api/controller/Bundling.php
  88. 108 0
      addon/bundling/api/controller/Ordercreate.php
  89. 23 0
      addon/bundling/config/diy_view.php
  90. 20 0
      addon/bundling/config/event.php
  91. 20 0
      addon/bundling/config/info.php
  92. 35 0
      addon/bundling/config/menu_admin.php
  93. 49 0
      addon/bundling/config/menu_shop.php
  94. 1 0
      addon/bundling/data/install.sql
  95. 1 0
      addon/bundling/data/uninstall.sql
  96. 34 0
      addon/bundling/event/Install.php
  97. 30 0
      addon/bundling/event/PromotionType.php
  98. 66 0
      addon/bundling/event/ShowPromotion.php
  99. 34 0
      addon/bundling/event/UnInstall.php
  100. 二進制
      addon/bundling/icon.png

+ 6 - 0
.buildpath

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<buildpath>
+	<buildpathentry kind="src" path=""/>
+	<buildpathentry excluding="vendor/**/test*/**" kind="src" path=""/>
+	<buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>
+</buildpath>

+ 6 - 0
.env

@@ -0,0 +1,6 @@
+APP_DEBUG = false
+
+[APP]
+DEFAULT_TIMEZONE = Asia/Shanghai
+[LANG]
+default_lang = zh-cn

+ 7 - 0
.gitignore

@@ -0,0 +1,7 @@
+/.idea
+/.vscode
+/.setting
+*.log
+.idea
+.idea/niushop_b2b2c_tp6_git.iml
+*.txt

+ 13 - 0
.htaccess

@@ -0,0 +1,13 @@
+<IfModule mod_rewrite.c>
+  Options +FollowSymlinks -Multiviews
+  RewriteEngine On
+
+  RewriteCond %{REQUEST_FILENAME} !-d
+  RewriteCond %{REQUEST_FILENAME} !-f
+  RewriteRule ^(.*)$ index.php?s=/$1 [QSA,PT,L]
+  RewriteEngine on RewriteCond % !^$
+
+# 视频防盗,直接访问时,替换成图片
+#  RewriteCond %{HTTP_REFERER} !^$ [NC]
+#  RewriteRule .(mp4) https://img2.mukewang.com/szimg/5c7e6835087ef3d806000338.jpg [R,NC,L]
+</IfModule>

+ 22 - 0
.project

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>niushop_b2b2c_tp6_git</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.wst.validation.validationbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.dltk.core.scriptbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.php.core.PHPNature</nature>
+	</natures>
+</projectDescription>

+ 42 - 0
.travis.yml

@@ -0,0 +1,42 @@
+sudo: false
+
+language: php
+
+branches:
+  only:
+    - stable
+
+cache:
+  directories:
+    - $HOME/.composer/cache
+
+before_install:
+  - composer self-update
+
+install:
+  - composer install --no-dev --no-interaction --ignore-platform-reqs
+  - zip -r --exclude='*.git*' --exclude='*.zip' --exclude='*.travis.yml' ThinkPHP_Core.zip .
+  - composer require --update-no-dev --no-interaction "topthink/think-image:^1.0"
+  - composer require --update-no-dev --no-interaction "topthink/think-migration:^1.0"
+  - composer require --update-no-dev --no-interaction "topthink/think-captcha:^1.0"
+  - composer require --update-no-dev --no-interaction "topthink/think-mongo:^1.0"
+  - composer require --update-no-dev --no-interaction "topthink/think-worker:^1.0"
+  - composer require --update-no-dev --no-interaction "topthink/think-helper:^1.0"
+  - composer require --update-no-dev --no-interaction "topthink/think-queue:^1.0"
+  - composer require --update-no-dev --no-interaction "topthink/think-angular:^1.0"
+  - composer require --dev --update-no-dev --no-interaction "topthink/think-testing:^1.0"
+  - zip -r --exclude='*.git*' --exclude='*.zip' --exclude='*.travis.yml' ThinkPHP_Full.zip .
+
+script:
+  - php think unit
+
+deploy:
+  provider: releases
+  api_key:
+    secure: TSF6bnl2JYN72UQOORAJYL+CqIryP2gHVKt6grfveQ7d9rleAEoxlq6PWxbvTI4jZ5nrPpUcBUpWIJHNgVcs+bzLFtyh5THaLqm39uCgBbrW7M8rI26L8sBh/6nsdtGgdeQrO/cLu31QoTzbwuz1WfAVoCdCkOSZeXyT/CclH99qV6RYyQYqaD2wpRjrhA5O4fSsEkiPVuk0GaOogFlrQHx+C+lHnf6pa1KxEoN1A0UxxVfGX6K4y5g4WQDO5zT4bLeubkWOXK0G51XSvACDOZVIyLdjApaOFTwamPcD3S1tfvuxRWWvsCD5ljFvb2kSmx5BIBNwN80MzuBmrGIC27XLGOxyMerwKxB6DskNUO9PflKHDPI61DRq0FTy1fv70SFMSiAtUv9aJRT41NQh9iJJ0vC8dl+xcxrWIjU1GG6+l/ZcRqVx9V1VuGQsLKndGhja7SQ+X1slHl76fRq223sMOql7MFCd0vvvxVQ2V39CcFKao/LB1aPH3VhODDEyxwx6aXoTznvC/QPepgWsHOWQzKj9ftsgDbsNiyFlXL4cu8DWUty6rQy8zT2b4O8b1xjcwSUCsy+auEjBamzQkMJFNlZAIUrukL/NbUhQU37TAbwsFyz7X0E/u/VMle/nBCNAzgkMwAUjiHM6FqrKKBRWFbPrSIixjfjkCnrMEPw=
+  file:
+    - ThinkPHP_Core.zip
+    - ThinkPHP_Full.zip
+  skip_cleanup: true
+  on:
+    tags: true

+ 52 - 0
README.md

@@ -0,0 +1,52 @@
+ThinkPHP 6.0
+===============
+
+> 运行环境要求PHP7.1+。1
+
+## 主要新特性
+
+* 采用`PHP7`强类型(严格模式)
+* 支持更多的`PSR`规范
+* 原生多应用支持
+* 更强大和易用的查询
+* 全新的事件系统
+* 模型事件和数据库事件统一纳入事件系统
+* 模板引擎分离出核心
+* 内部功能中间件化
+* SESSION/Cookie机制改进
+* 对Swoole以及协程支持改进
+* 对IDE更加友好
+* 统一和精简大量用法
+
+## 安装
+
+~~~
+composer create-project topthink/think tp 6.0.*-dev
+~~~
+
+如果需要更新框架使用
+~~~
+composer update topthink/framework
+~~~
+
+## 文档
+
+[完全开发手册](https://www.kancloud.cn/manual/thinkphp6_0/content)
+
+## 参与开发
+
+请参阅 [ThinkPHP 核心框架包](https://github.com/top-think/framework)。
+
+## 版权信息
+
+ThinkPHP遵循Apache2开源协议发布,并提供免费使用。
+
+本项目包含的第三方源码和二进制文件之版权信息另行标注。
+
+版权所有Copyright © 2006-2019 by ThinkPHP (http://thinkphp.cn)
+
+All rights reserved。
+
+ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。
+
+更多细节参阅 [LICENSE.txt](LICENSE.txt)

+ 53 - 0
addon/alioss/admin/controller/Config.php

@@ -0,0 +1,53 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+
+namespace addon\alioss\admin\controller;
+
+use app\admin\controller\BaseAdmin;
+use addon\alioss\model\Config as ConfigModel;
+
+/**
+ * 七牛云上传管理
+ */
+class Config extends BaseAdmin
+{
+	
+	/**
+	 * 云上传配置
+	 * @return mixed
+	 */
+	public function config()
+	{
+		$config_model = new ConfigModel();
+		if (request()->isAjax()) {
+			$bucket = input("bucket", "");
+			$access_key_id = input("access_key_id", "");
+			$access_key_secret = input("access_key_secret", "");
+			$endpoint = input("endpoint", "");
+			$status = input("status", 0);
+			$data = array(
+				"bucket" => $bucket,
+				"access_key_id" => $access_key_id,
+				"access_key_secret" => $access_key_secret,
+				"endpoint" => $endpoint,
+			);
+			
+			$result = $config_model->setAliossConfig($data, $status);
+			return $result;
+		} else {
+			$info_result = $config_model->getAliossConfig();
+			$info = $info_result["data"];
+			$this->assign("info", $info);
+			return $this->fetch("config/config");
+		}
+	}
+}

+ 97 - 0
addon/alioss/admin/view/config/config.html

@@ -0,0 +1,97 @@
+{extend name="app/admin/view/base.html"/}
+{block name="resources"}
+<style>
+	.ns-form {margin-top: 0;}
+</style>
+{/block}
+{block name="main"}
+<div class="layui-form ns-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="ns-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 ns-len-long">
+		</div>
+        <div class="ns-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 ns-len-long">
+		</div>
+        <div class="ns-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 ns-len-long">
+		</div>
+        <div class="ns-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="请输入domain" value="{$info.value.endpoint ?? ''}" autocomplete="off" class="layui-input ns-len-long">
+        </div>
+        <div class="ns-word-aux">官方建议开启绑定域名,域名格式:http://xx.xxxx.com/(不可绑定当前网站域名,建议新开二级域名)</div>
+    </div>
+    <!-- 表单操作 -->
+    <div class="ns-form-row">
+        <button class="layui-btn ns-bg-color" lay-submit lay-filter="save">保存</button>
+        <button class="layui-btn layui-btn-primary" onclick="back()">返回</button>
+    </div>
+
+</div>
+{/block}
+{block name="script"}
+<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("alioss://admin/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(){
+								location.href = ns.url("admin/upload/oss")
+							},
+							btn2: function() {
+								location.reload();
+							}
+						});
+					}else{
+						layer.msg(res.message);
+					}
+                }
+            });
+        });
+    });
+
+    function back() {
+        location.href = ns.url("admin/upload/oss");
+    }
+</script>
+{/block}

+ 23 - 0
addon/alioss/config/diy_view.php

@@ -0,0 +1,23 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+return [
+    
+	'diy' => [
+		'view' => [
+		],
+		'util' => [
+		],
+		'link' => [
+		],
+	
+	],
+];

+ 23 - 0
addon/alioss/config/event.php

@@ -0,0 +1,23 @@
+<?php
+// 事件定义文件
+return [
+    'bind'      => [
+        
+    ],
+
+    'listen'    => [
+        //短信方式
+       'OssType' => [
+            'addon\alioss\event\OssType'
+        ],
+        'Put' => [
+            'addon\alioss\event\Put'
+        ],
+        'CloseOss' => [
+            'addon\alioss\event\CloseOss'
+        ],
+    ],
+
+    'subscribe' => [
+    ],
+];

+ 20 - 0
addon/alioss/config/info.php

@@ -0,0 +1,20 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+return [
+		'name' => 'alioss',
+		'title' => '阿里云OSS',
+		'description' => '阿里云OSS',
+		'status' => 1,
+		'author' => '',
+		'version' => '1.0',
+		'content' => '',
+];

+ 18 - 0
addon/alioss/config/menu_admin.php

@@ -0,0 +1,18 @@
+<?php
+// +----------------------------------------------------------------------
+// | 平台端菜单设置
+// +----------------------------------------------------------------------
+return [
+    [
+        'name' => 'ALIOSS_CONFIG',
+        'title' => '阿里云OSS上传配置',
+        'url' => 'alioss://admin/config/config',
+        'parent' => 'UPLOAD_OSS',
+        'is_show' => 0,
+        'is_control' => 1,
+        'is_icon' => 0,
+        'picture' => '',
+        'picture_select' => '',
+        'sort' => 1,
+    ],
+];

+ 7 - 0
addon/alioss/config/menu_shop.php

@@ -0,0 +1,7 @@
+<?php
+// +----------------------------------------------------------------------
+// | 平台端菜单设置
+// +----------------------------------------------------------------------
+return [
+
+];

+ 29 - 0
addon/alioss/event/CloseOss.php

@@ -0,0 +1,29 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+declare (strict_types = 1);
+
+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;
+        }
+}

+ 29 - 0
addon/alioss/event/Install.php

@@ -0,0 +1,29 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+declare (strict_types = 1);
+
+namespace addon\alioss\event;
+
+/**
+ * 应用安装
+ */
+class Install
+{
+	/**
+	 * 执行安装
+	 */
+	public function handle()
+	{
+
+        return success();
+	}
+}

+ 34 - 0
addon/alioss/event/OssType.php

@@ -0,0 +1,34 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+declare (strict_types = 1);
+
+namespace addon\alioss\event;
+
+/**
+ * 云上传方式
+ */
+class OssType
+{
+	/**
+	 * 短信发送方式方式及配置
+	 */
+	public function handle()
+	{
+	    $info = array(
+	        "sms_type" => "alioss",
+            "sms_type_name" => "阿里云上传",
+            "edit_url" => "alioss://admin/config/config",
+            "desc" => "阿里云上传"
+        );
+        return $info;
+	}
+}

+ 32 - 0
addon/alioss/event/Put.php

@@ -0,0 +1,32 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+declare (strict_types = 1);
+
+namespace addon\alioss\event;
+
+use addon\alioss\model\Alioss;
+
+/**
+ * 云上传方式
+ */
+class Put
+{
+	/**
+	 * 短信发送方式方式及配置
+	 */
+	public function handle($param)
+	{
+	    $qiniu_model = new Alioss();
+        $result = $qiniu_model->putFile($param);
+        return $result;
+	}
+}

+ 28 - 0
addon/alioss/event/UnInstall.php

@@ -0,0 +1,28 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+declare (strict_types = 1);
+
+namespace addon\alioss\event;
+
+/**
+ * 应用卸载
+ */
+class UnInstall
+{
+	/**
+	 * 执行卸载
+	 */
+	public function handle()
+	{
+        return success();
+	}
+}

二進制
addon/alioss/icon.png


+ 110 - 0
addon/alioss/model/Alioss.php

@@ -0,0 +1,110 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+namespace addon\alioss\model;
+
+use app\model\BaseModel;
+// 引入Oss类
+use \OSS\OssClient;
+use \OSS\Core\OssException;
+/**
+ * 阿里云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);
+                $data = array(
+                    //                    "path" => $this->subEndpoint($endpoint, $bucket)."/". $key,
+                    "path" => $result["info"]["url"],
+                    "domain" => $endpoint,
+                    "bucket" => $bucket
+                );
+                return $this->success($data);
+            } catch(OssException $e) {
+                return $this->error($e->getMessage());
+            }
+
+
+        }
+    }
+
+    /**
+     * 设置阿里云OSS参数配置
+     * @param unknown $filePath  上传图片路径
+     * @param unknown $key 上传到阿里云后保存的文件名
+     */
+    public function putFile($param){
+        $file_path = $param["file_path"];
+        $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->uploadFile($bucket, $key, $file_path);
+
+                //返回图片的完整URL
+                $data = array(
+//                    "path" => $this->subEndpoint($endpoint, $bucket)."/". $key,
+                    "path" => $result["info"]["url"],
+                    "domain" => $endpoint,
+                    "bucket" => $bucket
+                );
+                return $this->success($data);
+            } catch(OssException $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];
+    }
+
+}

+ 57 - 0
addon/alioss/model/Config.php

@@ -0,0 +1,57 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+
+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)
+	{
+            if($status == 1){
+                event("CloseOss", []);//同步关闭所有云上传
+            }
+
+            $config = new ConfigModel();
+            $res = $config->setConfig($data, '阿里云OSS上传配置', $status, [ [ 'site_id', '=', 0 ], [ 'app_module', '=', 'admin' ], [ 'config_key', '=', 'ALIOSS_CONFIG' ] ]);
+            return $res;
+	}
+	
+	/**
+	 * 获取阿里云上传配置
+	 */
+	public function getAliossConfig()
+	{
+		$config = new ConfigModel();
+		$res = $config->getConfig([ [ 'site_id', '=', 0 ], [ 'app_module', '=', 'admin' ], [ 'config_key', '=', 'ALIOSS_CONFIG' ] ]);
+		return $res;
+	}
+
+    /**
+     * 配置阿里云开关状态
+     * @param $status
+     */
+	public function modifyConfigIsUse($status){
+          $config = new ConfigModel();
+          $res = $config->modifyConfigIsUse($status, [ [ 'site_id', '=', 0 ], [ 'app_module', '=', 'admin' ], [ 'config_key', '=', 'ALIOSS_CONFIG' ] ]);
+          return $res;
+      }
+}

+ 65 - 0
addon/alipay/admin/controller/Pay.php

@@ -0,0 +1,65 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+
+namespace addon\alipay\admin\controller;
+
+use addon\alipay\model\Config as ConfigModel;
+use app\admin\controller\BaseAdmin;
+use think\facade\Config;
+
+/**
+ * 支付宝 控制器
+ */
+class Pay extends BaseAdmin
+{
+	public function config()
+	{
+		$config_model = new ConfigModel();
+		if (request()->isAjax()) {
+			$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);//转账启用状态
+			$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
+			);
+			$result = $config_model->setPayConfig($data);
+			return $result;
+		} else {
+			$info_result = $config_model->getPayConfig();
+			$info = $info_result["data"];
+			
+			if (!empty($info['value'])) {
+				$app_type_arr = [];
+				if (!empty($info['value']['app_type'])) {
+					$app_type_arr = explode(',', $info['value']['app_type']);
+				}
+				$info['value']['app_type_arr'] = $app_type_arr;
+			}
+			$this->assign("info", $info);
+			$this->assign("app_type", Config::get("app_type"));
+			
+			return $this->fetch("pay/config");
+		}
+	}
+}

+ 121 - 0
addon/alipay/admin/view/pay/config.html

@@ -0,0 +1,121 @@
+{extend name="app/admin/view/base.html"/}
+{block name="resources"}
+<style>
+	.ns-input-text span{margin-left: 15px;}
+	.ns-form {margin-top: 0;}
+</style>
+{/block}
+{block name="main"}
+<div class="layui-form ns-form">
+	<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.value.app_id ?? ''}" class="layui-input ns-len-long">
+		</div>
+		<div class="ns-word-aux"><span class="ns-text-color-red">[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 ns-len-long" placeholder="请输入应用私钥">{$info.value.private_key ?? ''}</textarea>
+		</div>
+	</div>
+	
+	<div class="layui-form-item">
+		<label class="layui-form-label">应用公钥:</label>
+		<div class="layui-input-block">
+			<textarea name="public_key" class="layui-textarea ns-len-long" placeholder="请输入应用公钥">{$info.value.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 ns-len-long" placeholder="请输入支付宝公钥">{$info.value.alipay_public_key ?? ''}</textarea>
+		</div>
+	</div>
+	
+	<div class="layui-form-item">
+		<label class="layui-form-label">支持端口:</label>
+		<div class="ns-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.value && $info.value.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.value && $info.value.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.value && $info.value.transfer_status == 1"} checked {/if} />
+		</div>
+	</div>
+
+	<div class="ns-form-row">
+		<button class="layui-btn ns-bg-color" lay-submit lay-filter="save">保存</button>
+		<button class="layui-btn layui-btn-primary" onclick="back()">返回</button>
+	</div>
+</div>
+
+{/block}
+{block name="script"}
+<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 false;
+			repeat_flag = true;
+			
+			$.ajax({
+				url: ns.url("alipay://admin/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(){
+								location.href = ns.url("admin/config/pay")
+							},
+							btn2: function() {
+								location.reload();
+							}
+						});
+					}else{
+						layer.msg(res.message);
+					}
+				}
+			});
+		});
+	});
+	
+	function back(){
+		location.href = ns.url("admin/config/pay");
+	}
+</script>
+{/block}

+ 23 - 0
addon/alipay/config/diy_view.php

@@ -0,0 +1,23 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+return [
+    
+	'diy' => [
+		'view' => [
+		],
+		'util' => [
+		],
+		'link' => [
+		],
+	
+	],
+];

+ 46 - 0
addon/alipay/config/event.php

@@ -0,0 +1,46 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+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'
+        ]
+    ],
+
+    'subscribe' => [
+    ],
+];

+ 20 - 0
addon/alipay/config/info.php

@@ -0,0 +1,20 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+return [
+		'name' => 'alipay',
+		'title' => '支付宝支付',
+		'description' => '支付宝支付功能',
+		'status' => 1,
+		'author' => '',
+		'version' => '1.0',
+		'content' => '',
+];

+ 25 - 0
addon/alipay/config/menu_admin.php

@@ -0,0 +1,25 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+return [
+    [
+        'name' => 'ALI_PAY_CONFIG',
+        'title' => '支付宝支付编辑',
+        'url' => 'alipay://admin/pay/config',
+        'parent' => 'CONFIG_PAY',
+        'is_show' => 0,
+        'is_control' => 1,
+        'is_icon' => 0,
+        'picture' => '',
+        'picture_select' => '',
+        'sort' => 1,
+    ],
+];

+ 14 - 0
addon/alipay/config/menu_shop.php

@@ -0,0 +1,14 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+return [
+
+];

+ 231 - 0
addon/alipay/data/sdk/AlipayMobilePublicMultiMediaClient.php

@@ -0,0 +1,231 @@
+<?php
+
+/**
+ * 多媒体文件客户端
+ * @author yikai.hu
+ * @version $Id: AlipayMobilePublicMultiMediaClient.php, v 0.1 Aug 15, 2014 10:19:01 AM yikai.hu Exp $
+ */
+
+//namespace alipay\api ;
+
+include("AlipayMobilePublicMultiMediaExecute.php");
+
+
+class AlipayMobilePublicMultiMediaClient{
+
+    private				$DEFAULT_CHARSET = 'UTF-8';
+    private				$METHOD_POST     = "POST";
+    private				$METHOD_GET      = "GET";
+	private				$SIGN			= 'sign'; //get name
+
+	private				$timeout = 10 ;// 超时时间
+    private				$serverUrl;
+    private				$appId;
+    private				$privateKey;
+    private				$prodCode;
+    private				$format          = 'json'; //todo
+    private				$sign_type       = 'RSA'; //todo
+
+	private				$charset;
+	private				$apiVersion    = "1.0";
+	private				$apiMethodName = "alipay.mobile.public.multimedia.download";
+	private				$media_id = "L21pZnMvVDFQV3hYWGJKWFhYYUNucHJYP3Q9YW13ZiZ4c2lnPTU0MzRhYjg1ZTZjNWJmZTMxZGJiNjIzNDdjMzFkNzkw575";
+	//此处写死的,实际开发中,请传入
+
+    private				$connectTimeout  = 3000;
+    private				$readTimeout     = 15000;
+
+
+
+	function __construct($serverUrl = '', $appId = '', $partner_private_key = '', $format = '', $charset = 'GBK'){
+		$this -> serverUrl = $serverUrl;
+		$this -> appId = $appId;
+		$this -> privateKey = $partner_private_key;
+		$this -> format = $format;
+		$this -> charset = $charset;
+	}
+
+	/**
+	 * getContents 获取网址内容
+	 * @param $request
+	 * @return text | bin
+	 */
+	public function getContents(){
+		//自己的服务器如果没有 curl,可用:fsockopen() 等
+
+
+		//1:
+		//2: 私钥格式
+		$datas = array(
+			"app_id" 		=> $this -> appId,
+			"method" 		=> $this -> METHOD_POST,
+			"sign_type" 	=> $this -> sign_type,
+			"version" 		=> $this -> apiVersion,
+			"timestamp" 	=> date('Y-m-d H:i:s')  ,//yyyy-MM-dd HH:mm:ss
+			"biz_content" 	=> '{"mediaId":"'. $this -> media_id  .'"}',
+			"charset" 		=> $this -> charset
+		);
+
+
+
+		//要提交的数据
+		$data_sign = $this -> buildGetUrl( $datas );
+
+		$post_data = $data_sign;
+		//初始化 curl
+		$ch = curl_init();
+		//设置目标服务器
+		curl_setopt($ch, CURLOPT_URL, $this -> serverUrl );
+		curl_setopt($ch, CURLOPT_HEADER, TRUE);
+		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+		//超时时间
+		curl_setopt($ch, CURLOPT_TIMEOUT, $this-> timeout);
+
+		if( $this-> METHOD_POST == 'POST'){
+			// post数据
+			curl_setopt($ch, CURLOPT_POST, 1);
+			// post的变量
+			curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
+		}
+
+
+
+
+		$output = curl_exec($ch);
+		$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+		curl_close($ch);
+
+		echo $output;
+
+		//分离头部
+		//list($header, $body) = explode("\r\n\r\n", $output, 2);
+		$datas = explode("\r\n\r\n", $output, 2);
+		$header = $datas[0];
+
+		if( $httpCode == '200'){
+			$body = $datas[1];
+		}else{
+			$body = '';
+
+		}
+
+
+
+
+		return $this -> execute( $header, $body, $httpCode );
+	}
+
+	/**
+	 *
+	 * @param $request
+	 * @return text | bin
+	 */
+	public function execute( $header = '', $body = '', $httpCode = '' ){
+		$exe = new AlipayMobilePublicMultiMediaExecute( $header, $body, $httpCode );
+		return $exe;
+	}
+
+	public function buildGetUrl( $query = array() ){
+
+		if( ! is_array( $query ) ){
+			//exit;
+		}
+
+		//排序参数,
+		$data = $this -> buildQuery( $query );
+
+
+
+		// 私钥密码
+		$passphrase = '';
+		$key_width = 64;
+
+		//私钥
+		$privateKey = $this -> privateKey;
+		$p_key = array();
+		//如果私钥是 1行
+		if( ! stripos( $privateKey, "\n" )  ){
+			$i = 0;
+			while( $key_str = substr( $privateKey , $i * $key_width , $key_width) ){
+				$p_key[] = $key_str;
+				$i ++ ;
+			}
+		}else{
+			//echo '一行?';
+		}
+		$privateKey = "-----BEGIN RSA PRIVATE KEY-----\n" . implode("\n", $p_key) ;
+		$privateKey = $privateKey ."\n-----END RSA PRIVATE KEY-----";
+
+//		echo "\n\n私钥:\n";
+//		echo( $privateKey );
+//		echo "\n\n\n";
+
+		//私钥
+		$private_id = openssl_pkey_get_private( $privateKey , $passphrase);
+
+
+		// 签名
+		$signature = '';
+
+		if("RSA2"==$this->sign_type){
+
+			openssl_sign($data, $signature, $private_id, OPENSSL_ALGO_SHA256 );
+		}else{
+
+			openssl_sign($data, $signature, $private_id, OPENSSL_ALGO_SHA1 );
+		}
+
+		openssl_free_key( $private_id );
+
+		//加密后的内容通常含有特殊字符,需要编码转换下
+		$signature = base64_encode($signature);
+
+		$signature = urlencode( $signature );
+
+		//$signature = 'XjUN6YM1Mc9HXebKMv7GTLy7gmyhktyOgKk2/Jf+cz4DtP6udkzTdpkjW2j/Z4ZSD7xD6CNYI1Spz4yS93HPT0a5X9LgFWYY8SaADqe+ArXg+FBSiTwUz49SE//Xd9+LEiIRsSFkbpkuiGoO6mqJmB7vXjlD5lx6qCM3nb41wb8=';
+
+		$out = $data .'&'. $this -> SIGN .'='. $signature;
+
+//		echo "\n\n 加密后:\n";
+//		echo( $out );
+//		echo "\n\n\n";
+
+		return $out ;
+	}
+
+	/*
+	 * 查询参数排序 a-z
+	 * */
+	public function buildQuery( $query ){
+		if ( !$query ) {
+			return null;
+		}
+
+//将要 参数 排序
+		ksort( $query );
+
+		//重新组装参数
+		$params = array();
+		foreach($query as $key => $value){
+			$params[] = $key .'='. $value ;
+		}
+		$data = implode('&', $params);
+
+		return $data;
+
+	}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}

+ 108 - 0
addon/alipay/data/sdk/AlipayMobilePublicMultiMediaExecute.php

@@ -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 ;
+	}
+
+
+}

+ 1210 - 0
addon/alipay/data/sdk/AopClient.php

@@ -0,0 +1,1210 @@
+<?php
+namespace addon\alipay\data\sdk;
+use think\Exception;
+use addon\alipay\data\sdk\SignData;
+require_once 'AopEncrypt.php';
+
+class AopClient {
+	//应用ID
+	public $appId;
+	
+	//私钥文件路径
+	public $rsaPrivateKeyFilePath;
+
+	//私钥值
+	public $rsaPrivateKey;
+
+	//网关
+	public $gatewayUrl = "https://openapi.alipay.com/gateway.do";
+	//返回数据格式
+	public $format = "json";
+	//api版本
+	public $apiVersion = "1.0";
+
+	// 表单提交字符集编码
+	public $postCharset = "UTF-8";
+
+	//使用文件读取文件格式,请只传递该值
+	public $alipayPublicKey = null;
+
+	//使用读取字符串格式,请只传递该值
+	public $alipayrsaPublicKey;
+
+
+	public $debugInfo = false;
+
+	private $fileCharset = "UTF-8";
+
+	private $RESPONSE_SUFFIX = "_response";
+
+	private $ERROR_RESPONSE = "error_response";
+
+	private $SIGN_NODE_NAME = "sign";
+
+
+	//加密XML节点名称
+	private $ENCRYPT_XML_NODE_NAME = "response_encrypted";
+
+	private $needEncrypt = false;
+
+
+	//签名类型
+	public $signType = "RSA";
+
+
+	//加密密钥和类型
+
+	public $encryptKey;
+
+	public $encryptType = "AES";
+
+	protected $alipaySdkVersion = "alipay-sdk-php-20180705";
+
+	public function generateSign($params, $signType = "RSA") {
+		return $this->sign($this->getSignContent($params), $signType);
+	}
+
+	public function rsaSign($params, $signType = "RSA") {
+		return $this->sign($this->getSignContent($params), $signType);
+	}
+
+	public function getSignContent($params) {
+		ksort($params);
+
+		$stringToBeSigned = "";
+		$i = 0;
+		foreach ($params as $k => $v) {
+			if (false === $this->checkEmpty($v) && "@" != substr($v, 0, 1)) {
+
+				// 转换成目标字符集
+				$v = $this->characet($v, $this->postCharset);
+
+				if ($i == 0) {
+					$stringToBeSigned .= "$k" . "=" . "$v";
+				} else {
+					$stringToBeSigned .= "&" . "$k" . "=" . "$v";
+				}
+				$i++;
+			}
+		}
+
+		unset ($k, $v);
+		return $stringToBeSigned;
+	}
+
+
+	//此方法对value做urlencode
+	public function getSignContentUrlencode($params) {
+		ksort($params);
+
+		$stringToBeSigned = "";
+		$i = 0;
+		foreach ($params as $k => $v) {
+			if (false === $this->checkEmpty($v) && "@" != substr($v, 0, 1)) {
+
+				// 转换成目标字符集
+				$v = $this->characet($v, $this->postCharset);
+
+				if ($i == 0) {
+					$stringToBeSigned .= "$k" . "=" . urlencode($v);
+				} else {
+					$stringToBeSigned .= "&" . "$k" . "=" . urlencode($v);
+				}
+				$i++;
+			}
+		}
+
+		unset ($k, $v);
+		return $stringToBeSigned;
+	}
+
+	protected function sign($data, $signType = "RSA") {
+		if($this->checkEmpty($this->rsaPrivateKeyFilePath)){
+			$priKey=$this->rsaPrivateKey;
+			$res = "-----BEGIN RSA PRIVATE KEY-----\n" .
+				wordwrap($priKey, 64, "\n", true) .
+				"\n-----END RSA PRIVATE KEY-----";
+		}else {
+			$priKey = file_get_contents($this->rsaPrivateKeyFilePath);
+			$res = openssl_get_privatekey($priKey);
+		}
+
+		($res) or die('您使用的私钥格式错误,请检查RSA私钥配置'); 
+
+		if ("RSA2" == $signType) {
+			openssl_sign($data, $sign, $res, OPENSSL_ALGO_SHA256);
+		} else {
+			openssl_sign($data, $sign, $res);
+		}
+
+		if(!$this->checkEmpty($this->rsaPrivateKeyFilePath)){
+			openssl_free_key($res);
+		}
+		$sign = base64_encode($sign);
+		return $sign;
+	}
+
+    /**
+     * RSA单独签名方法,未做字符串处理,字符串处理见getSignContent()
+     * @param $data 待签名字符串
+     * @param $privatekey 商户私钥,根据keyfromfile来判断是读取字符串还是读取文件,false:填写私钥字符串去回车和空格 true:填写私钥文件路径 
+     * @param $signType 签名方式,RSA:SHA1     RSA2:SHA256 
+     * @param $keyfromfile 私钥获取方式,读取字符串还是读文件
+     * @return string 
+     * @author mengyu.wh
+     */
+	public function alonersaSign($data,$privatekey,$signType = "RSA",$keyfromfile=false) {
+
+		if(!$keyfromfile){
+			$priKey=$privatekey;
+			$res = "-----BEGIN RSA PRIVATE KEY-----\n" .
+				wordwrap($priKey, 64, "\n", true) .
+				"\n-----END RSA PRIVATE KEY-----";
+		}
+		else{
+			$priKey = file_get_contents($privatekey);
+			$res = openssl_get_privatekey($priKey);
+		}
+
+		($res) or die('您使用的私钥格式错误,请检查RSA私钥配置'); 
+
+		if ("RSA2" == $signType) {
+			openssl_sign($data, $sign, $res, OPENSSL_ALGO_SHA256);
+		} else {
+			openssl_sign($data, $sign, $res);
+		}
+
+		if($keyfromfile){
+			openssl_free_key($res);
+		}
+		$sign = base64_encode($sign);
+		return $sign;
+	}
+
+
+	protected function curl($url, $postFields = null) {
+		$ch = curl_init();
+		curl_setopt($ch, CURLOPT_URL, $url);
+		curl_setopt($ch, CURLOPT_FAILONERROR, false);
+		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+
+		$postBodyString = "";
+		$encodeArray = Array();
+		$postMultipart = false;
+
+
+		if (is_array($postFields) && 0 < count($postFields)) {
+
+			foreach ($postFields as $k => $v) {
+				if ("@" != substr($v, 0, 1)) //判断是不是文件上传
+				{
+
+					$postBodyString .= "$k=" . urlencode($this->characet($v, $this->postCharset)) . "&";
+					$encodeArray[$k] = $this->characet($v, $this->postCharset);
+				} else //文件上传用multipart/form-data,否则用www-form-urlencoded
+				{
+					$postMultipart = true;
+					$encodeArray[$k] = new \CURLFile(substr($v, 1));
+				}
+
+			}
+			unset ($k, $v);
+			curl_setopt($ch, CURLOPT_POST, true);
+			if ($postMultipart) {
+				curl_setopt($ch, CURLOPT_POSTFIELDS, $encodeArray);
+			} else {
+				curl_setopt($ch, CURLOPT_POSTFIELDS, substr($postBodyString, 0, -1));
+			}
+		}
+
+		if ($postMultipart) {
+
+			$headers = array('content-type: multipart/form-data;charset=' . $this->postCharset . ';boundary=' . $this->getMillisecond());
+		} else {
+
+			$headers = array('content-type: application/x-www-form-urlencoded;charset=' . $this->postCharset);
+		}
+		curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+
+
+
+
+		$reponse = curl_exec($ch);
+
+		if (curl_errno($ch)) {
+
+			throw new Exception(curl_error($ch), 0);
+		} else {
+			$httpStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+			if (200 !== $httpStatusCode) {
+				throw new Exception($reponse, $httpStatusCode);
+			}
+		}
+
+		curl_close($ch);
+		return $reponse;
+	}
+
+	protected function getMillisecond() {
+		list($s1, $s2) = explode(' ', microtime());
+		return (float)sprintf('%.0f', (floatval($s1) + floatval($s2)) * 1000);
+	}
+
+
+	protected function logCommunicationError($apiName, $requestUrl, $errorCode, $responseTxt) {
+		$localIp = isset ($_SERVER["SERVER_ADDR"]) ? $_SERVER["SERVER_ADDR"] : "CLI";
+		$logger = new LtLogger;
+		$logger->conf["log_file"] = rtrim(AOP_SDK_WORK_DIR, '\\/') . '/' . "logs/aop_comm_err_" . $this->appId . "_" . date("Y-m-d") . ".log";
+		$logger->conf["separator"] = "^_^";
+		$logData = array(
+			date("Y-m-d H:i:s"),
+			$apiName,
+			$this->appId,
+			$localIp,
+			PHP_OS,
+			$this->alipaySdkVersion,
+			$requestUrl,
+			$errorCode,
+			str_replace("\n", "", $responseTxt)
+		);
+		$logger->log($logData);
+	}
+
+    /**
+     * 生成用于调用收银台SDK的字符串
+     * @param $request SDK接口的请求参数对象
+     * @return string 
+     * @author guofa.tgf
+     */
+	public function sdkExecute($request) {
+		
+		$this->setupCharsets($request);
+
+		$params['app_id'] = $this->appId;
+		$params['method'] = $request->getApiMethodName();
+		$params['format'] = $this->format; 
+		$params['sign_type'] = $this->signType;
+		$params['timestamp'] = date("Y-m-d H:i:s");
+		$params['alipay_sdk'] = $this->alipaySdkVersion;
+		$params['charset'] = $this->postCharset;
+
+		$version = $request->getApiVersion();
+		$params['version'] = $this->checkEmpty($version) ? $this->apiVersion : $version;
+
+		if ($notify_url = $request->getNotifyUrl()) {
+			$params['notify_url'] = $notify_url;
+		}
+
+		$dict = $request->getApiParas();
+		$params['biz_content'] = $dict['biz_content'];
+
+		ksort($params);
+
+		$params['sign'] = $this->generateSign($params, $this->signType);
+
+		foreach ($params as &$value) {
+			$value = $this->characet($value, $params['charset']);
+		}
+		
+		return http_build_query($params);
+	}
+
+	/*
+		页面提交执行方法
+		@param:跳转类接口的request; $httpmethod 提交方式。两个值可选:post、get
+		@return:构建好的、签名后的最终跳转URL(GET)或String形式的form(POST)
+		auther:笙默
+	*/
+	public function pageExecute($request,$httpmethod = "POST") {
+
+		$this->setupCharsets($request);
+
+		if (strcasecmp($this->fileCharset, $this->postCharset)) {
+
+			// writeLog("本地文件字符集编码与表单提交编码不一致,请务必设置成一样,属性名分别为postCharset!");
+			throw new Exception("文件编码:[" . $this->fileCharset . "] 与表单提交编码:[" . $this->postCharset . "]两者不一致!");
+		}
+
+		$iv=null;
+
+		if(!$this->checkEmpty($request->getApiVersion())){
+			$iv=$request->getApiVersion();
+		}else{
+			$iv=$this->apiVersion;
+		}
+
+		//组装系统参数
+		$sysParams["app_id"] = $this->appId;
+		$sysParams["version"] = $iv;
+		$sysParams["format"] = $this->format;
+		$sysParams["sign_type"] = $this->signType;
+		$sysParams["method"] = $request->getApiMethodName();
+		$sysParams["timestamp"] = date("Y-m-d H:i:s");
+		$sysParams["alipay_sdk"] = $this->alipaySdkVersion;
+		$sysParams["terminal_type"] = $request->getTerminalType();
+		$sysParams["terminal_info"] = $request->getTerminalInfo();
+		$sysParams["prod_code"] = $request->getProdCode();
+		$sysParams["notify_url"] = $request->getNotifyUrl();
+		$sysParams["return_url"] = $request->getReturnUrl();
+		$sysParams["charset"] = $this->postCharset;
+
+		//获取业务参数
+		$apiParams = $request->getApiParas();
+
+		if (method_exists($request,"getNeedEncrypt") &&$request->getNeedEncrypt()){
+
+			$sysParams["encrypt_type"] = $this->encryptType;
+
+			if ($this->checkEmpty($apiParams['biz_content'])) {
+
+				throw new Exception(" api request Fail! The reason : encrypt request is not supperted!");
+			}
+
+			if ($this->checkEmpty($this->encryptKey) || $this->checkEmpty($this->encryptType)) {
+
+				throw new Exception(" encryptType and encryptKey must not null! ");
+			}
+
+			if ("AES" != $this->encryptType) {
+
+				throw new Exception("加密类型只支持AES");
+			}
+
+			// 执行加密
+			$enCryptContent = new_encrypt($apiParams['biz_content'], $this->encryptKey);
+			$apiParams['biz_content'] = $enCryptContent;
+
+		}
+
+		//print_r($apiParams);
+		$totalParams = array_merge($apiParams, $sysParams);
+		
+		//待签名字符串
+		$preSignStr = $this->getSignContent($totalParams);
+
+		//签名
+		$totalParams["sign"] = $this->generateSign($totalParams, $this->signType);
+
+		if ("GET" == strtoupper($httpmethod)) {
+			
+			//value做urlencode
+			$preString=$this->getSignContentUrlencode($totalParams);
+			//拼接GET请求串
+			$requestUrl = $this->gatewayUrl."?".$preString;
+			
+			return $requestUrl;
+		} else {
+			//拼接表单字符串
+			return $this->buildRequestForm($totalParams);
+		}
+
+
+	}
+
+
+
+	/**
+     * 建立请求,以表单HTML形式构造(默认)
+     * @param $para_temp 请求参数数组
+     * @return 提交表单HTML文本
+     */
+	protected function buildRequestForm($para_temp) {
+		
+		$sHtml = "<form id='alipaysubmit' name='alipaysubmit' action='".$this->gatewayUrl."?charset=".trim($this->postCharset)."' method='POST'>";
+		while (list ($key, $val) = each ($para_temp)) {
+			if (false === $this->checkEmpty($val)) {
+				//$val = $this->characet($val, $this->postCharset);
+				$val = str_replace("'","&apos;",$val);
+				//$val = str_replace("\"","&quot;",$val);
+				$sHtml.= "<input type='hidden' name='".$key."' value='".$val."'/>";
+			}
+        }
+
+		//submit按钮控件请不要含有name属性
+        $sHtml = $sHtml."<input type='submit' value='ok' style='display:none;''></form>";
+		
+		$sHtml = $sHtml."<script>document.forms['alipaysubmit'].submit();</script>";
+		
+		return $sHtml;
+	}
+
+
+	public function execute($request, $authToken = null, $appInfoAuthtoken = null) {
+
+		$this->setupCharsets($request);
+
+		//		//  如果两者编码不一致,会出现签名验签或者乱码
+		if (strcasecmp($this->fileCharset, $this->postCharset)) {
+
+			// writeLog("本地文件字符集编码与表单提交编码不一致,请务必设置成一样,属性名分别为postCharset!");
+			throw new Exception("文件编码:[" . $this->fileCharset . "] 与表单提交编码:[" . $this->postCharset . "]两者不一致!");
+		}
+
+		$iv = null;
+
+		if (!$this->checkEmpty($request->getApiVersion())) {
+			$iv = $request->getApiVersion();
+		} else {
+			$iv = $this->apiVersion;
+		}
+
+
+		//组装系统参数
+		$sysParams["app_id"] = $this->appId;
+		$sysParams["version"] = $iv;
+		$sysParams["format"] = $this->format;
+		$sysParams["sign_type"] = $this->signType;
+		$sysParams["method"] = $request->getApiMethodName();
+		$sysParams["timestamp"] = date("Y-m-d H:i:s");
+		$sysParams["auth_token"] = $authToken;
+		$sysParams["alipay_sdk"] = $this->alipaySdkVersion;
+		$sysParams["terminal_type"] = $request->getTerminalType();
+		$sysParams["terminal_info"] = $request->getTerminalInfo();
+		$sysParams["prod_code"] = $request->getProdCode();
+		$sysParams["notify_url"] = $request->getNotifyUrl();
+		$sysParams["charset"] = $this->postCharset;
+		$sysParams["app_auth_token"] = $appInfoAuthtoken;
+
+
+		//获取业务参数
+		$apiParams = $request->getApiParas();
+
+			if (method_exists($request,"getNeedEncrypt") &&$request->getNeedEncrypt()){
+
+			$sysParams["encrypt_type"] = $this->encryptType;
+
+			if ($this->checkEmpty($apiParams['biz_content'])) {
+
+				throw new Exception(" api request Fail! The reason : encrypt request is not supperted!");
+			}
+
+			if ($this->checkEmpty($this->encryptKey) || $this->checkEmpty($this->encryptType)) {
+
+				throw new Exception(" encryptType and encryptKey must not null! ");
+			}
+
+			if ("AES" != $this->encryptType) {
+
+				throw new Exception("加密类型只支持AES");
+			}
+
+			// 执行加密
+			$enCryptContent = new_encrypt($apiParams['biz_content'], $this->encryptKey);
+			$apiParams['biz_content'] = $enCryptContent;
+
+		}
+
+
+		//签名
+		$sysParams["sign"] = $this->generateSign(array_merge($apiParams, $sysParams), $this->signType);
+
+
+		//系统参数放入GET请求串
+		$requestUrl = $this->gatewayUrl . "?";
+		foreach ($sysParams as $sysParamKey => $sysParamValue) {
+			$requestUrl .= "$sysParamKey=" . urlencode($this->characet($sysParamValue, $this->postCharset)) . "&";
+		}
+		$requestUrl = substr($requestUrl, 0, -1);
+
+
+		//发起HTTP请求
+		try {
+			$resp = $this->curl($requestUrl, $apiParams);
+		} catch (Exception $e) {
+
+			$this->logCommunicationError($sysParams["method"], $requestUrl, "HTTP_ERROR_" . $e->getCode(), $e->getMessage());
+			return false;
+		}
+
+		//解析AOP返回结果
+		$respWellFormed = false;
+
+
+		// 将返回结果转换本地文件编码
+		$r = iconv($this->postCharset, $this->fileCharset . "//IGNORE", $resp);
+
+
+
+		$signData = null;
+
+		if ("json" == $this->format) {
+
+			$respObject = json_decode($r);
+			if (null !== $respObject) {
+				$respWellFormed = true;
+				$signData = $this->parserJSONSignData($request, $resp, $respObject);
+			}
+		} else if ("xml" == $this->format) {
+			$disableLibxmlEntityLoader = libxml_disable_entity_loader(true);
+			$respObject = @ simplexml_load_string($resp);
+			if (false !== $respObject) {
+				$respWellFormed = true;
+
+				$signData = $this->parserXMLSignData($request, $resp);
+			}
+			libxml_disable_entity_loader($disableLibxmlEntityLoader);
+		}
+
+
+		//返回的HTTP文本不是标准JSON或者XML,记下错误日志
+		if (false === $respWellFormed) {
+			$this->logCommunicationError($sysParams["method"], $requestUrl, "HTTP_RESPONSE_NOT_WELL_FORMED", $resp);
+			return false;
+		}
+
+		// 验签
+		//$this->checkResponseSign($request, $signData, $resp, $respObject);
+
+		// 解密
+		if (method_exists($request,"getNeedEncrypt") &&$request->getNeedEncrypt()){
+
+			if ("json" == $this->format) {
+
+
+				$resp = $this->encryptJSONSignSource($request, $resp);
+
+				// 将返回结果转换本地文件编码
+				$r = iconv($this->postCharset, $this->fileCharset . "//IGNORE", $resp);
+				$respObject = json_decode($r);
+			}else{
+
+				$resp = $this->encryptXMLSignSource($request, $resp);
+
+				$r = iconv($this->postCharset, $this->fileCharset . "//IGNORE", $resp);
+				$disableLibxmlEntityLoader = libxml_disable_entity_loader(true);
+				$respObject = @ simplexml_load_string($r);
+				libxml_disable_entity_loader($disableLibxmlEntityLoader);
+
+			}
+		}
+
+		return $respObject;
+	}
+
+	/**
+	 * 转换字符集编码
+	 * @param $data
+	 * @param $targetCharset
+	 * @return string
+	 */
+	function characet($data, $targetCharset) {
+		
+		if (!empty($data)) {
+			$fileType = $this->fileCharset;
+			if (strcasecmp($fileType, $targetCharset) != 0) {
+				$data = mb_convert_encoding($data, $targetCharset, $fileType);
+				//				$data = iconv($fileType, $targetCharset.'//IGNORE', $data);
+			}
+		}
+
+
+		return $data;
+	}
+
+	public function exec($paramsArray) {
+		if (!isset ($paramsArray["method"])) {
+			trigger_error("No api name passed");
+		}
+		$inflector = new LtInflector;
+		$inflector->conf["separator"] = ".";
+		$requestClassName = ucfirst($inflector->camelize(substr($paramsArray["method"], 7))) . "Request";
+		if (!class_exists($requestClassName)) {
+			trigger_error("No such api: " . $paramsArray["method"]);
+		}
+
+		$session = isset ($paramsArray["session"]) ? $paramsArray["session"] : null;
+
+		$req = new $requestClassName;
+		foreach ($paramsArray as $paraKey => $paraValue) {
+			$inflector->conf["separator"] = "_";
+			$setterMethodName = $inflector->camelize($paraKey);
+			$inflector->conf["separator"] = ".";
+			$setterMethodName = "set" . $inflector->camelize($setterMethodName);
+			if (method_exists($req, $setterMethodName)) {
+				$req->$setterMethodName ($paraValue);
+			}
+		}
+		return $this->execute($req, $session);
+	}
+
+	/**
+	 * 校验$value是否非空
+	 *  if not set ,return true;
+	 *    if is null , return true;
+	 **/
+	protected function checkEmpty($value) {
+		if (!isset($value))
+			return true;
+		if ($value === null)
+			return true;
+		if (trim($value) === "")
+			return true;
+
+		return false;
+	}
+
+	/** rsaCheckV1 & rsaCheckV2
+	 *  验证签名
+	 *  在使用本方法前,必须初始化AopClient且传入公钥参数。
+	 *  公钥是否是读取字符串还是读取文件,是根据初始化传入的值判断的。
+	 **/
+	public function rsaCheckV1($params, $rsaPublicKeyFilePath,$signType='RSA') {
+		$sign = $params['sign'];
+		$params['sign_type'] = null;
+		$params['sign'] = null;
+		return $this->verify($this->getSignContent($params), $sign, $rsaPublicKeyFilePath,$signType);
+	}
+	public function rsaCheckV2($params, $rsaPublicKeyFilePath, $signType='RSA') {
+		$sign = $params['sign'];
+		$params['sign'] = null;
+		return $this->verify($this->getSignContent($params), $sign, $rsaPublicKeyFilePath, $signType);
+	}
+
+	function verify($data, $sign, $rsaPublicKeyFilePath, $signType = 'RSA') {
+
+	    $pubKey= $this->alipayPublicKey;
+		$res = "-----BEGIN PUBLIC KEY-----\n" .
+			wordwrap($pubKey, 64, "\n", true) .
+			"\n-----END PUBLIC KEY-----";
+
+		($res) or die('支付宝RSA公钥错误。请检查公钥文件格式是否正确');  
+
+		//调用openssl内置方法验签,返回bool值
+
+		$result = FALSE;
+		if ("RSA2" == $signType) {
+			$result = (openssl_verify($data, base64_decode($sign), $res, OPENSSL_ALGO_SHA256)===1);
+		} else {
+			$result = (openssl_verify($data, base64_decode($sign), $res)===1);
+		}
+
+	    //openssl_free_key($res);
+
+		return $result;
+	}
+
+/** 
+	 *  在使用本方法前,必须初始化AopClient且传入公私钥参数。
+	 *  公钥是否是读取字符串还是读取文件,是根据初始化传入的值判断的。
+	 **/
+	public function checkSignAndDecrypt($params, $rsaPublicKeyPem, $rsaPrivateKeyPem, $isCheckSign, $isDecrypt, $signType='RSA') {
+		$charset = $params['charset'];
+		$bizContent = $params['biz_content'];
+		if ($isCheckSign) {
+			if (!$this->rsaCheckV2($params, $rsaPublicKeyPem, $signType)) {
+				echo "<br/>checkSign failure<br/>";
+				exit;
+			}
+		}
+		if ($isDecrypt) {
+			return $this->rsaDecrypt($bizContent, $rsaPrivateKeyPem, $charset);
+		}
+
+		return $bizContent;
+	}
+
+	/** 
+	 *  在使用本方法前,必须初始化AopClient且传入公私钥参数。
+	 *  公钥是否是读取字符串还是读取文件,是根据初始化传入的值判断的。
+	 **/
+	public function encryptAndSign($bizContent, $rsaPublicKeyPem, $rsaPrivateKeyPem, $charset, $isEncrypt, $isSign, $signType='RSA') {
+		// 加密,并签名
+		if ($isEncrypt && $isSign) {
+			$encrypted = $this->rsaEncrypt($bizContent, $rsaPublicKeyPem, $charset);
+			$sign = $this->sign($encrypted, $signType);
+			$response = "<?xml version=\"1.0\" encoding=\"$charset\"?><alipay><response>$encrypted</response><encryption_type>RSA</encryption_type><sign>$sign</sign><sign_type>$signType</sign_type></alipay>";
+			return $response;
+		}
+		// 加密,不签名
+		if ($isEncrypt && (!$isSign)) {
+			$encrypted = $this->rsaEncrypt($bizContent, $rsaPublicKeyPem, $charset);
+			$response = "<?xml version=\"1.0\" encoding=\"$charset\"?><alipay><response>$encrypted</response><encryption_type>$signType</encryption_type></alipay>";
+			return $response;
+		}
+		// 不加密,但签名
+		if ((!$isEncrypt) && $isSign) {
+			$sign = $this->sign($bizContent, $signType);
+			$response = "<?xml version=\"1.0\" encoding=\"$charset\"?><alipay><response>$bizContent</response><sign>$sign</sign><sign_type>$signType</sign_type></alipay>";
+			return $response;
+		}
+		// 不加密,不签名
+		$response = "<?xml version=\"1.0\" encoding=\"$charset\"?>$bizContent";
+		return $response;
+	}
+
+	/** 
+	 *  在使用本方法前,必须初始化AopClient且传入公私钥参数。
+	 *  公钥是否是读取字符串还是读取文件,是根据初始化传入的值判断的。
+	 **/
+	public function rsaEncrypt($data, $rsaPublicKeyPem, $charset) {
+		if($this->checkEmpty($this->alipayPublicKey)){
+			//读取字符串
+			$pubKey= $this->alipayrsaPublicKey;
+			$res = "-----BEGIN PUBLIC KEY-----\n" .
+				wordwrap($pubKey, 64, "\n", true) .
+				"\n-----END PUBLIC KEY-----";
+		}else {
+			//读取公钥文件
+			$pubKey = file_get_contents($rsaPublicKeyFilePath);
+			//转换为openssl格式密钥
+			$res = openssl_get_publickey($pubKey);
+		}
+
+		($res) or die('支付宝RSA公钥错误。请检查公钥文件格式是否正确'); 
+		$blocks = $this->splitCN($data, 0, 30, $charset);
+		$chrtext  = null;
+		$encodes  = array();
+		foreach ($blocks as $n => $block) {
+			if (!openssl_public_encrypt($block, $chrtext , $res)) {
+				echo "<br/>" . openssl_error_string() . "<br/>";
+			}
+			$encodes[] = $chrtext ;
+		}
+		$chrtext = implode(",", $encodes);
+
+		return base64_encode($chrtext);
+	}
+
+	/** 
+	 *  在使用本方法前,必须初始化AopClient且传入公私钥参数。
+	 *  公钥是否是读取字符串还是读取文件,是根据初始化传入的值判断的。
+	 **/
+	public function rsaDecrypt($data, $rsaPrivateKeyPem, $charset) {
+		
+		if($this->checkEmpty($this->rsaPrivateKeyFilePath)){
+			//读字符串
+			$priKey=$this->rsaPrivateKey;
+			$res = "-----BEGIN RSA PRIVATE KEY-----\n" .
+				wordwrap($priKey, 64, "\n", true) .
+				"\n-----END RSA PRIVATE KEY-----";
+		}else {
+			$priKey = file_get_contents($this->rsaPrivateKeyFilePath);
+			$res = openssl_get_privatekey($priKey);
+		}
+		($res) or die('您使用的私钥格式错误,请检查RSA私钥配置'); 
+		//转换为openssl格式密钥
+		$decodes = explode(',', $data);
+		$strnull = "";
+		$dcyCont = "";
+		foreach ($decodes as $n => $decode) {
+			if (!openssl_private_decrypt($decode, $dcyCont, $res)) {
+				echo "<br/>" . openssl_error_string() . "<br/>";
+			}
+			$strnull .= $dcyCont;
+		}
+		return $strnull;
+	}
+
+	function splitCN($cont, $n = 0, $subnum, $charset) {
+		//$len = strlen($cont) / 3;
+		$arrr = array();
+		for ($i = $n; $i < strlen($cont); $i += $subnum) {
+			$res = $this->subCNchar($cont, $i, $subnum, $charset);
+			if (!empty ($res)) {
+				$arrr[] = $res;
+			}
+		}
+
+		return $arrr;
+	}
+
+	function subCNchar($str, $start = 0, $length, $charset = "gbk") {
+		if (strlen($str) <= $length) {
+			return $str;
+		}
+		$re['utf-8'] = "/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xff][\x80-\xbf]{3}/";
+		$re['gb2312'] = "/[\x01-\x7f]|[\xb0-\xf7][\xa0-\xfe]/";
+		$re['gbk'] = "/[\x01-\x7f]|[\x81-\xfe][\x40-\xfe]/";
+		$re['big5'] = "/[\x01-\x7f]|[\x81-\xfe]([\x40-\x7e]|\xa1-\xfe])/";
+		preg_match_all($re[$charset], $str, $match);
+		$slice = join("", array_slice($match[0], $start, $length));
+		return $slice;
+	}
+
+	function parserResponseSubCode($request, $responseContent, $respObject, $format) {
+
+		if ("json" == $format) {
+
+			$apiName = $request->getApiMethodName();
+			$rootNodeName = str_replace(".", "_", $apiName) . $this->RESPONSE_SUFFIX;
+			$errorNodeName = $this->ERROR_RESPONSE;
+
+			$rootIndex = strpos($responseContent, $rootNodeName);
+			$errorIndex = strpos($responseContent, $errorNodeName);
+
+			if ($rootIndex > 0) {
+				// 内部节点对象
+				$rInnerObject = $respObject->$rootNodeName;
+			} elseif ($errorIndex > 0) {
+
+				$rInnerObject = $respObject->$errorNodeName;
+			} else {
+				return null;
+			}
+
+			// 存在属性则返回对应值
+			if (isset($rInnerObject->sub_code)) {
+
+				return $rInnerObject->sub_code;
+			} else {
+
+				return null;
+			}
+
+
+		} elseif ("xml" == $format) {
+
+			// xml格式sub_code在同一层级
+			return $respObject->sub_code;
+
+		}
+
+
+	}
+
+	function parserJSONSignData($request, $responseContent, $responseJSON) {
+
+		$signData = new SignData();
+
+		$signData->sign = $this->parserJSONSign($responseJSON);
+		$signData->signSourceData = $this->parserJSONSignSource($request, $responseContent);
+
+
+		return $signData;
+
+	}
+
+	function parserJSONSignSource($request, $responseContent) {
+
+		$apiName = $request->getApiMethodName();
+		$rootNodeName = str_replace(".", "_", $apiName) . $this->RESPONSE_SUFFIX;
+
+		$rootIndex = strpos($responseContent, $rootNodeName);
+		$errorIndex = strpos($responseContent, $this->ERROR_RESPONSE);
+
+
+		if ($rootIndex > 0) {
+
+			return $this->parserJSONSource($responseContent, $rootNodeName, $rootIndex);
+		} else if ($errorIndex > 0) {
+
+			return $this->parserJSONSource($responseContent, $this->ERROR_RESPONSE, $errorIndex);
+		} else {
+
+			return null;
+		}
+
+
+	}
+
+	function parserJSONSource($responseContent, $nodeName, $nodeIndex) {
+		$signDataStartIndex = $nodeIndex + strlen($nodeName) + 2;
+		$signIndex = strrpos($responseContent, "\"" . $this->SIGN_NODE_NAME . "\"");
+		// 签名前-逗号
+		$signDataEndIndex = $signIndex - 1;
+		$indexLen = $signDataEndIndex - $signDataStartIndex;
+		if ($indexLen < 0) {
+
+			return null;
+		}
+
+		return substr($responseContent, $signDataStartIndex, $indexLen);
+
+	}
+
+	function parserJSONSign($responseJSon) {
+
+		return $responseJSon->sign;
+	}
+
+	function parserXMLSignData($request, $responseContent) {
+
+
+		$signData = new SignData();
+
+		$signData->sign = $this->parserXMLSign($responseContent);
+		$signData->signSourceData = $this->parserXMLSignSource($request, $responseContent);
+
+
+		return $signData;
+
+
+	}
+
+	function parserXMLSignSource($request, $responseContent) {
+
+
+		$apiName = $request->getApiMethodName();
+		$rootNodeName = str_replace(".", "_", $apiName) . $this->RESPONSE_SUFFIX;
+
+
+		$rootIndex = strpos($responseContent, $rootNodeName);
+		$errorIndex = strpos($responseContent, $this->ERROR_RESPONSE);
+		//		$this->echoDebug("<br/>rootNodeName:" . $rootNodeName);
+		//		$this->echoDebug("<br/> responseContent:<xmp>" . $responseContent . "</xmp>");
+
+
+		if ($rootIndex > 0) {
+
+			return $this->parserXMLSource($responseContent, $rootNodeName, $rootIndex);
+		} else if ($errorIndex > 0) {
+
+			return $this->parserXMLSource($responseContent, $this->ERROR_RESPONSE, $errorIndex);
+		} else {
+
+			return null;
+		}
+
+
+	}
+
+	function parserXMLSource($responseContent, $nodeName, $nodeIndex) {
+		$signDataStartIndex = $nodeIndex + strlen($nodeName) + 1;
+		$signIndex = strrpos($responseContent, "<" . $this->SIGN_NODE_NAME . ">");
+		// 签名前-逗号
+		$signDataEndIndex = $signIndex - 1;
+		$indexLen = $signDataEndIndex - $signDataStartIndex + 1;
+
+		if ($indexLen < 0) {
+			return null;
+		}
+
+
+		return substr($responseContent, $signDataStartIndex, $indexLen);
+
+
+	}
+
+	function parserXMLSign($responseContent) {
+		$signNodeName = "<" . $this->SIGN_NODE_NAME . ">";
+		$signEndNodeName = "</" . $this->SIGN_NODE_NAME . ">";
+
+		$indexOfSignNode = strpos($responseContent, $signNodeName);
+		$indexOfSignEndNode = strpos($responseContent, $signEndNodeName);
+
+
+		if ($indexOfSignNode < 0 || $indexOfSignEndNode < 0) {
+			return null;
+		}
+
+		$nodeIndex = ($indexOfSignNode + strlen($signNodeName));
+
+		$indexLen = $indexOfSignEndNode - $nodeIndex;
+
+		if ($indexLen < 0) {
+			return null;
+		}
+
+		// 签名
+		return substr($responseContent, $nodeIndex, $indexLen);
+
+	}
+
+	/**
+	 * 验签
+	 * @param $request
+	 * @param $signData
+	 * @param $resp
+	 * @param $respObject
+	 * @throws Exception
+	 */
+	public function checkResponseSign($request, $signData, $resp, $respObject) {
+
+		if (!$this->checkEmpty($this->alipayPublicKey) || !$this->checkEmpty($this->alipayrsaPublicKey)) {
+
+
+			if ($signData == null || $this->checkEmpty($signData->sign) || $this->checkEmpty($signData->signSourceData)) {
+
+				throw new Exception(" check sign Fail! The reason : signData is Empty");
+			}
+
+
+			// 获取结果sub_code
+			$responseSubCode = $this->parserResponseSubCode($request, $resp, $respObject, $this->format);
+
+
+			if (!$this->checkEmpty($responseSubCode) || ($this->checkEmpty($responseSubCode) && !$this->checkEmpty($signData->sign))) {
+
+				$checkResult = $this->verify($signData->signSourceData, $signData->sign, $this->alipayPublicKey, $this->signType);
+
+
+				if (!$checkResult) {
+
+					if (strpos($signData->signSourceData, "\\/") > 0) {
+
+						$signData->signSourceData = str_replace("\\/", "/", $signData->signSourceData);
+
+						$checkResult = $this->verify($signData->signSourceData, $signData->sign, $this->alipayPublicKey, $this->signType);
+
+						if (!$checkResult) {
+							throw new Exception("check sign Fail! [sign=" . $signData->sign . ", signSourceData=" . $signData->signSourceData . "]");
+						}
+
+					} else {
+
+						throw new Exception("check sign Fail! [sign=" . $signData->sign . ", signSourceData=" . $signData->signSourceData . "]");
+					}
+
+				}
+			}
+
+
+		}
+	}
+
+	private function setupCharsets($request) {
+		if ($this->checkEmpty($this->postCharset)) {
+			$this->postCharset = 'UTF-8';
+		}
+		$str = preg_match('/[\x80-\xff]/', $this->appId) ? $this->appId : print_r($request, true);
+		$this->fileCharset = mb_detect_encoding($str, "UTF-8, GBK") == 'UTF-8' ? 'UTF-8' : 'GBK';
+	}
+
+	// 获取加密内容
+
+	private function encryptJSONSignSource($request, $responseContent) {
+
+		$parsetItem = $this->parserEncryptJSONSignSource($request, $responseContent);
+
+		$bodyIndexContent = substr($responseContent, 0, $parsetItem->startIndex);
+		$bodyEndContent = substr($responseContent, $parsetItem->endIndex, strlen($responseContent) + 1 - $parsetItem->endIndex);
+
+		$bizContent = new_decrypt($parsetItem->encryptContent, $this->encryptKey);
+		return $bodyIndexContent . $bizContent . $bodyEndContent;
+
+	}
+
+
+	private function parserEncryptJSONSignSource($request, $responseContent) {
+
+		$apiName = $request->getApiMethodName();
+		$rootNodeName = str_replace(".", "_", $apiName) . $this->RESPONSE_SUFFIX;
+
+		$rootIndex = strpos($responseContent, $rootNodeName);
+		$errorIndex = strpos($responseContent, $this->ERROR_RESPONSE);
+
+
+		if ($rootIndex > 0) {
+
+			return $this->parserEncryptJSONItem($responseContent, $rootNodeName, $rootIndex);
+		} else if ($errorIndex > 0) {
+
+			return $this->parserEncryptJSONItem($responseContent, $this->ERROR_RESPONSE, $errorIndex);
+		} else {
+
+			return null;
+		}
+
+
+	}
+
+
+	private function parserEncryptJSONItem($responseContent, $nodeName, $nodeIndex) {
+		$signDataStartIndex = $nodeIndex + strlen($nodeName) + 2;
+		$signIndex = strpos($responseContent, "\"" . $this->SIGN_NODE_NAME . "\"");
+		// 签名前-逗号
+		$signDataEndIndex = $signIndex - 1;
+
+		if ($signDataEndIndex < 0) {
+
+			$signDataEndIndex = strlen($responseContent)-1 ;
+		}
+
+		$indexLen = $signDataEndIndex - $signDataStartIndex;
+
+		$encContent = substr($responseContent, $signDataStartIndex+1, $indexLen-2);
+
+
+		$encryptParseItem = new EncryptParseItem();
+
+		$encryptParseItem->encryptContent = $encContent;
+		$encryptParseItem->startIndex = $signDataStartIndex;
+		$encryptParseItem->endIndex = $signDataEndIndex;
+
+		return $encryptParseItem;
+
+	}
+
+	// 获取加密内容
+
+	private function encryptXMLSignSource($request, $responseContent) {
+
+		$parsetItem = $this->parserEncryptXMLSignSource($request, $responseContent);
+
+		$bodyIndexContent = substr($responseContent, 0, $parsetItem->startIndex);
+		$bodyEndContent = substr($responseContent, $parsetItem->endIndex, strlen($responseContent) + 1 - $parsetItem->endIndex);
+		$bizContent = new_decrypt($parsetItem->encryptContent, $this->encryptKey);
+
+		return $bodyIndexContent . $bizContent . $bodyEndContent;
+
+	}
+
+	private function parserEncryptXMLSignSource($request, $responseContent) {
+
+
+		$apiName = $request->getApiMethodName();
+		$rootNodeName = str_replace(".", "_", $apiName) . $this->RESPONSE_SUFFIX;
+
+
+		$rootIndex = strpos($responseContent, $rootNodeName);
+		$errorIndex = strpos($responseContent, $this->ERROR_RESPONSE);
+		//		$this->echoDebug("<br/>rootNodeName:" . $rootNodeName);
+		//		$this->echoDebug("<br/> responseContent:<xmp>" . $responseContent . "</xmp>");
+
+
+		if ($rootIndex > 0) {
+
+			return $this->parserEncryptXMLItem($responseContent, $rootNodeName, $rootIndex);
+		} else if ($errorIndex > 0) {
+
+			return $this->parserEncryptXMLItem($responseContent, $this->ERROR_RESPONSE, $errorIndex);
+		} else {
+
+			return null;
+		}
+
+
+	}
+
+	private function parserEncryptXMLItem($responseContent, $nodeName, $nodeIndex) {
+
+		$signDataStartIndex = $nodeIndex + strlen($nodeName) + 1;
+
+		$xmlStartNode="<".$this->ENCRYPT_XML_NODE_NAME.">";
+		$xmlEndNode="</".$this->ENCRYPT_XML_NODE_NAME.">";
+
+		$indexOfXmlNode=strpos($responseContent,$xmlEndNode);
+		if($indexOfXmlNode<0){
+
+			$item = new EncryptParseItem();
+			$item->encryptContent = null;
+			$item->startIndex = 0;
+			$item->endIndex = 0;
+			return $item;
+		}
+
+		$startIndex=$signDataStartIndex+strlen($xmlStartNode);
+		$bizContentLen=$indexOfXmlNode-$startIndex;
+		$bizContent=substr($responseContent,$startIndex,$bizContentLen);
+
+		$encryptParseItem = new EncryptParseItem();
+		$encryptParseItem->encryptContent = $bizContent;
+		$encryptParseItem->startIndex = $signDataStartIndex;
+		$encryptParseItem->endIndex = $indexOfXmlNode+strlen($xmlEndNode);
+
+		return $encryptParseItem;
+
+	}
+
+
+	function echoDebug($content) {
+
+		if ($this->debugInfo) {
+			echo "<br/>" . $content;
+		}
+
+	}
+
+
+}

+ 71 - 0
addon/alipay/data/sdk/AopEncrypt.php

@@ -0,0 +1,71 @@
+<?php
+/**
+ *   加密工具类
+ *
+ * User: jiehua
+ * Date: 16/3/30
+ * Time: 下午3:25
+ */
+
+/**
+ * 加密方法
+ * @param string $str
+ * @return string
+ */
+function new_encrypt($str,$screct_key){
+	//AES, 128 模式加密数据 CBC
+	$screct_key = base64_decode($screct_key);
+	$str = trim($str);
+	$str = addPKCS7Padding($str);
+	$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128,MCRYPT_MODE_CBC),1);
+	$encrypt_str =  mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $screct_key, $str, MCRYPT_MODE_CBC);
+	return base64_encode($encrypt_str);
+}
+
+/**
+ * 解密方法
+ * @param string $str
+ * @return string
+ */
+ function new_decrypt($str,$screct_key){
+	//AES, 128 模式加密数据 CBC
+	$str = base64_decode($str);
+	$screct_key = base64_decode($screct_key);
+	$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128,MCRYPT_MODE_CBC),1);
+	$encrypt_str =  mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $screct_key, $str, MCRYPT_MODE_CBC);
+	$encrypt_str = trim($encrypt_str);
+
+	$encrypt_str = stripPKSC7Padding($encrypt_str);
+	return $encrypt_str;
+
+}
+
+/**
+ * 填充算法
+ * @param string $source
+ * @return string
+ */
+function addPKCS7Padding($source){
+	$source = trim($source);
+	$block = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
+
+	$pad = $block - (strlen($source) % $block);
+	if ($pad <= $block) {
+		$char = chr($pad);
+		$source .= str_repeat($char, $pad);
+	}
+	return $source;
+}
+/**
+ * 移去填充算法
+ * @param string $source
+ * @return string
+ */
+function stripPKSC7Padding($source){
+	$source = trim($source);
+	$char = substr($source, -1);
+	$num = ord($char);
+	if($num==62)return $source;
+	$source = substr($source,0,-$num);
+	return $source;
+}

+ 19 - 0
addon/alipay/data/sdk/EncryptParseItem.php

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

+ 18 - 0
addon/alipay/data/sdk/EncryptResponseData.php

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

+ 17 - 0
addon/alipay/data/sdk/SignData.php

@@ -0,0 +1,17 @@
+<?php
+namespace addon\alipay\data\sdk;
+/**
+ * Created by PhpStorm.
+ * User: jiehua
+ * Date: 15/5/2
+ * Time: 下午6:21
+ */
+
+class SignData {
+
+    public $signSourceData=null;
+
+
+    public $sign=null;
+
+} 

+ 120 - 0
addon/alipay/data/sdk/request/AlipayFundTransToaccountTransferRequest.php

@@ -0,0 +1,120 @@
+<?php
+namespace addon\alipay\data\sdk\request;
+
+/**
+ * ALIPAY API: alipay.fund.trans.toaccount.transfer request
+ *
+ * @author auto create
+ * @since 1.0, 2018-08-14 14:05:00
+ */
+class AlipayFundTransToaccountTransferRequest
+{
+	/** 
+	 * 单笔转账到支付宝账户接口
+	 **/
+	private $bizContent;
+
+	private $apiParas = array();
+	private $terminalType;
+	private $terminalInfo;
+	private $prodCode;
+	private $apiVersion="1.0";
+	private $notifyUrl;
+	private $returnUrl;
+    private $needEncrypt=false;
+
+	
+	public function setBizContent($bizContent)
+	{
+		$this->bizContent = $bizContent;
+		$this->apiParas["biz_content"] = $bizContent;
+	}
+
+	public function getBizContent()
+	{
+		return $this->bizContent;
+	}
+
+	public function getApiMethodName()
+	{
+		return "alipay.fund.trans.toaccount.transfer";
+	}
+
+	public function setNotifyUrl($notifyUrl)
+	{
+		$this->notifyUrl=$notifyUrl;
+	}
+
+	public function getNotifyUrl()
+	{
+		return $this->notifyUrl;
+	}
+
+	public function setReturnUrl($returnUrl)
+	{
+		$this->returnUrl=$returnUrl;
+	}
+
+	public function getReturnUrl()
+	{
+		return $this->returnUrl;
+	}
+
+	public function getApiParas()
+	{
+		return $this->apiParas;
+	}
+
+	public function getTerminalType()
+	{
+		return $this->terminalType;
+	}
+
+	public function setTerminalType($terminalType)
+	{
+		$this->terminalType = $terminalType;
+	}
+
+	public function getTerminalInfo()
+	{
+		return $this->terminalInfo;
+	}
+
+	public function setTerminalInfo($terminalInfo)
+	{
+		$this->terminalInfo = $terminalInfo;
+	}
+
+	public function getProdCode()
+	{
+		return $this->prodCode;
+	}
+
+	public function setProdCode($prodCode)
+	{
+		$this->prodCode = $prodCode;
+	}
+
+	public function setApiVersion($apiVersion)
+	{
+		$this->apiVersion=$apiVersion;
+	}
+
+	public function getApiVersion()
+	{
+		return $this->apiVersion;
+	}
+
+  public function setNeedEncrypt($needEncrypt)
+  {
+
+     $this->needEncrypt=$needEncrypt;
+
+  }
+
+  public function getNeedEncrypt()
+  {
+    return $this->needEncrypt;
+  }
+
+}

+ 119 - 0
addon/alipay/data/sdk/request/AlipayFundTransUniTransferRequest.php

@@ -0,0 +1,119 @@
+<?php
+namespace addon\alipay\data\sdk\request;
+/**
+ * ALIPAY API: alipay.fund.trans.uni.transfer request
+ *
+ * @author auto create
+ * @since 1.0, 2020-04-02 22:40:08
+ */
+class AlipayFundTransUniTransferRequest
+{
+	/** 
+	 * 支付宝转账支付接口
+	 **/
+	private $bizContent;
+
+	private $apiParas = array();
+	private $terminalType;
+	private $terminalInfo;
+	private $prodCode;
+	private $apiVersion="1.0";
+	private $notifyUrl;
+	private $returnUrl;
+    private $needEncrypt=false;
+
+	
+	public function setBizContent($bizContent)
+	{
+		$this->bizContent = $bizContent;
+		$this->apiParas["biz_content"] = $bizContent;
+	}
+
+	public function getBizContent()
+	{
+		return $this->bizContent;
+	}
+
+	public function getApiMethodName()
+	{
+		return "alipay.fund.trans.uni.transfer";
+	}
+
+	public function setNotifyUrl($notifyUrl)
+	{
+		$this->notifyUrl=$notifyUrl;
+	}
+
+	public function getNotifyUrl()
+	{
+		return $this->notifyUrl;
+	}
+
+	public function setReturnUrl($returnUrl)
+	{
+		$this->returnUrl=$returnUrl;
+	}
+
+	public function getReturnUrl()
+	{
+		return $this->returnUrl;
+	}
+
+	public function getApiParas()
+	{
+		return $this->apiParas;
+	}
+
+	public function getTerminalType()
+	{
+		return $this->terminalType;
+	}
+
+	public function setTerminalType($terminalType)
+	{
+		$this->terminalType = $terminalType;
+	}
+
+	public function getTerminalInfo()
+	{
+		return $this->terminalInfo;
+	}
+
+	public function setTerminalInfo($terminalInfo)
+	{
+		$this->terminalInfo = $terminalInfo;
+	}
+
+	public function getProdCode()
+	{
+		return $this->prodCode;
+	}
+
+	public function setProdCode($prodCode)
+	{
+		$this->prodCode = $prodCode;
+	}
+
+	public function setApiVersion($apiVersion)
+	{
+		$this->apiVersion=$apiVersion;
+	}
+
+	public function getApiVersion()
+	{
+		return $this->apiVersion;
+	}
+
+  public function setNeedEncrypt($needEncrypt)
+  {
+
+     $this->needEncrypt=$needEncrypt;
+
+  }
+
+  public function getNeedEncrypt()
+  {
+    return $this->needEncrypt;
+  }
+
+}

+ 119 - 0
addon/alipay/data/sdk/request/AlipayTradeAppPayRequest.php

@@ -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;
+  }
+
+}

+ 118 - 0
addon/alipay/data/sdk/request/AlipayTradeCancelRequest.php

@@ -0,0 +1,118 @@
+<?php
+/**
+ * ALIPAY API: alipay.trade.cancel request
+ *
+ * @author auto create
+ * @since 1.0, 2018-07-13 17:18:06
+ */
+class AlipayTradeCancelRequest
+{
+	/** 
+	 * 统一收单交易撤销接口
+	 **/
+	private $bizContent;
+
+	private $apiParas = array();
+	private $terminalType;
+	private $terminalInfo;
+	private $prodCode;
+	private $apiVersion="1.0";
+	private $notifyUrl;
+	private $returnUrl;
+    private $needEncrypt=false;
+
+	
+	public function setBizContent($bizContent)
+	{
+		$this->bizContent = $bizContent;
+		$this->apiParas["biz_content"] = $bizContent;
+	}
+
+	public function getBizContent()
+	{
+		return $this->bizContent;
+	}
+
+	public function getApiMethodName()
+	{
+		return "alipay.trade.cancel";
+	}
+
+	public function setNotifyUrl($notifyUrl)
+	{
+		$this->notifyUrl=$notifyUrl;
+	}
+
+	public function getNotifyUrl()
+	{
+		return $this->notifyUrl;
+	}
+
+	public function setReturnUrl($returnUrl)
+	{
+		$this->returnUrl=$returnUrl;
+	}
+
+	public function getReturnUrl()
+	{
+		return $this->returnUrl;
+	}
+
+	public function getApiParas()
+	{
+		return $this->apiParas;
+	}
+
+	public function getTerminalType()
+	{
+		return $this->terminalType;
+	}
+
+	public function setTerminalType($terminalType)
+	{
+		$this->terminalType = $terminalType;
+	}
+
+	public function getTerminalInfo()
+	{
+		return $this->terminalInfo;
+	}
+
+	public function setTerminalInfo($terminalInfo)
+	{
+		$this->terminalInfo = $terminalInfo;
+	}
+
+	public function getProdCode()
+	{
+		return $this->prodCode;
+	}
+
+	public function setProdCode($prodCode)
+	{
+		$this->prodCode = $prodCode;
+	}
+
+	public function setApiVersion($apiVersion)
+	{
+		$this->apiVersion=$apiVersion;
+	}
+
+	public function getApiVersion()
+	{
+		return $this->apiVersion;
+	}
+
+  public function setNeedEncrypt($needEncrypt)
+  {
+
+     $this->needEncrypt=$needEncrypt;
+
+  }
+
+  public function getNeedEncrypt()
+  {
+    return $this->needEncrypt;
+  }
+
+}

+ 120 - 0
addon/alipay/data/sdk/request/AlipayTradeCloseRequest.php

@@ -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;
+  }
+
+}

+ 118 - 0
addon/alipay/data/sdk/request/AlipayTradeCreateRequest.php

@@ -0,0 +1,118 @@
+<?php
+/**
+ * ALIPAY API: alipay.trade.create request
+ *
+ * @author auto create
+ * @since 1.0, 2018-09-01 17:05:01
+ */
+class AlipayTradeCreateRequest
+{
+	/** 
+	 * 商户通过该接口进行交易的创建下单
+	 **/
+	private $bizContent;
+
+	private $apiParas = array();
+	private $terminalType;
+	private $terminalInfo;
+	private $prodCode;
+	private $apiVersion="1.0";
+	private $notifyUrl;
+	private $returnUrl;
+    private $needEncrypt=false;
+
+	
+	public function setBizContent($bizContent)
+	{
+		$this->bizContent = $bizContent;
+		$this->apiParas["biz_content"] = $bizContent;
+	}
+
+	public function getBizContent()
+	{
+		return $this->bizContent;
+	}
+
+	public function getApiMethodName()
+	{
+		return "alipay.trade.create";
+	}
+
+	public function setNotifyUrl($notifyUrl)
+	{
+		$this->notifyUrl=$notifyUrl;
+	}
+
+	public function getNotifyUrl()
+	{
+		return $this->notifyUrl;
+	}
+
+	public function setReturnUrl($returnUrl)
+	{
+		$this->returnUrl=$returnUrl;
+	}
+
+	public function getReturnUrl()
+	{
+		return $this->returnUrl;
+	}
+
+	public function getApiParas()
+	{
+		return $this->apiParas;
+	}
+
+	public function getTerminalType()
+	{
+		return $this->terminalType;
+	}
+
+	public function setTerminalType($terminalType)
+	{
+		$this->terminalType = $terminalType;
+	}
+
+	public function getTerminalInfo()
+	{
+		return $this->terminalInfo;
+	}
+
+	public function setTerminalInfo($terminalInfo)
+	{
+		$this->terminalInfo = $terminalInfo;
+	}
+
+	public function getProdCode()
+	{
+		return $this->prodCode;
+	}
+
+	public function setProdCode($prodCode)
+	{
+		$this->prodCode = $prodCode;
+	}
+
+	public function setApiVersion($apiVersion)
+	{
+		$this->apiVersion=$apiVersion;
+	}
+
+	public function getApiVersion()
+	{
+		return $this->apiVersion;
+	}
+
+  public function setNeedEncrypt($needEncrypt)
+  {
+
+     $this->needEncrypt=$needEncrypt;
+
+  }
+
+  public function getNeedEncrypt()
+  {
+    return $this->needEncrypt;
+  }
+
+}

+ 118 - 0
addon/alipay/data/sdk/request/AlipayTradeCustomsDeclareRequest.php

@@ -0,0 +1,118 @@
+<?php
+/**
+ * ALIPAY API: alipay.trade.customs.declare request
+ *
+ * @author auto create
+ * @since 1.0, 2016-12-08 00:48:24
+ */
+class AlipayTradeCustomsDeclareRequest
+{
+	/** 
+	 * 统一收单报关接口
+	 **/
+	private $bizContent;
+
+	private $apiParas = array();
+	private $terminalType;
+	private $terminalInfo;
+	private $prodCode;
+	private $apiVersion="1.0";
+	private $notifyUrl;
+	private $returnUrl;
+    private $needEncrypt=false;
+
+	
+	public function setBizContent($bizContent)
+	{
+		$this->bizContent = $bizContent;
+		$this->apiParas["biz_content"] = $bizContent;
+	}
+
+	public function getBizContent()
+	{
+		return $this->bizContent;
+	}
+
+	public function getApiMethodName()
+	{
+		return "alipay.trade.customs.declare";
+	}
+
+	public function setNotifyUrl($notifyUrl)
+	{
+		$this->notifyUrl=$notifyUrl;
+	}
+
+	public function getNotifyUrl()
+	{
+		return $this->notifyUrl;
+	}
+
+	public function setReturnUrl($returnUrl)
+	{
+		$this->returnUrl=$returnUrl;
+	}
+
+	public function getReturnUrl()
+	{
+		return $this->returnUrl;
+	}
+
+	public function getApiParas()
+	{
+		return $this->apiParas;
+	}
+
+	public function getTerminalType()
+	{
+		return $this->terminalType;
+	}
+
+	public function setTerminalType($terminalType)
+	{
+		$this->terminalType = $terminalType;
+	}
+
+	public function getTerminalInfo()
+	{
+		return $this->terminalInfo;
+	}
+
+	public function setTerminalInfo($terminalInfo)
+	{
+		$this->terminalInfo = $terminalInfo;
+	}
+
+	public function getProdCode()
+	{
+		return $this->prodCode;
+	}
+
+	public function setProdCode($prodCode)
+	{
+		$this->prodCode = $prodCode;
+	}
+
+	public function setApiVersion($apiVersion)
+	{
+		$this->apiVersion=$apiVersion;
+	}
+
+	public function getApiVersion()
+	{
+		return $this->apiVersion;
+	}
+
+  public function setNeedEncrypt($needEncrypt)
+  {
+
+     $this->needEncrypt=$needEncrypt;
+
+  }
+
+  public function getNeedEncrypt()
+  {
+    return $this->needEncrypt;
+  }
+
+}

+ 118 - 0
addon/alipay/data/sdk/request/AlipayTradeCustomsQueryRequest.php

@@ -0,0 +1,118 @@
+<?php
+/**
+ * ALIPAY API: alipay.trade.customs.query request
+ *
+ * @author auto create
+ * @since 1.0, 2018-03-02 14:37:16
+ */
+class AlipayTradeCustomsQueryRequest
+{
+	/** 
+	 * 查询报关详细信息
+	 **/
+	private $bizContent;
+
+	private $apiParas = array();
+	private $terminalType;
+	private $terminalInfo;
+	private $prodCode;
+	private $apiVersion="1.0";
+	private $notifyUrl;
+	private $returnUrl;
+    private $needEncrypt=false;
+
+	
+	public function setBizContent($bizContent)
+	{
+		$this->bizContent = $bizContent;
+		$this->apiParas["biz_content"] = $bizContent;
+	}
+
+	public function getBizContent()
+	{
+		return $this->bizContent;
+	}
+
+	public function getApiMethodName()
+	{
+		return "alipay.trade.customs.query";
+	}
+
+	public function setNotifyUrl($notifyUrl)
+	{
+		$this->notifyUrl=$notifyUrl;
+	}
+
+	public function getNotifyUrl()
+	{
+		return $this->notifyUrl;
+	}
+
+	public function setReturnUrl($returnUrl)
+	{
+		$this->returnUrl=$returnUrl;
+	}
+
+	public function getReturnUrl()
+	{
+		return $this->returnUrl;
+	}
+
+	public function getApiParas()
+	{
+		return $this->apiParas;
+	}
+
+	public function getTerminalType()
+	{
+		return $this->terminalType;
+	}
+
+	public function setTerminalType($terminalType)
+	{
+		$this->terminalType = $terminalType;
+	}
+
+	public function getTerminalInfo()
+	{
+		return $this->terminalInfo;
+	}
+
+	public function setTerminalInfo($terminalInfo)
+	{
+		$this->terminalInfo = $terminalInfo;
+	}
+
+	public function getProdCode()
+	{
+		return $this->prodCode;
+	}
+
+	public function setProdCode($prodCode)
+	{
+		$this->prodCode = $prodCode;
+	}
+
+	public function setApiVersion($apiVersion)
+	{
+		$this->apiVersion=$apiVersion;
+	}
+
+	public function getApiVersion()
+	{
+		return $this->apiVersion;
+	}
+
+  public function setNeedEncrypt($needEncrypt)
+  {
+
+     $this->needEncrypt=$needEncrypt;
+
+  }
+
+  public function getNeedEncrypt()
+  {
+    return $this->needEncrypt;
+  }
+
+}

+ 118 - 0
addon/alipay/data/sdk/request/AlipayTradeFastpayRefundQueryRequest.php

@@ -0,0 +1,118 @@
+<?php
+/**
+ * ALIPAY API: alipay.trade.fastpay.refund.query request
+ *
+ * @author auto create
+ * @since 1.0, 2018-07-25 17:25:00
+ */
+class AlipayTradeFastpayRefundQueryRequest
+{
+	/** 
+	 * 商户可使用该接口查询自已通过alipay.trade.refund提交的退款请求是否执行成功。
+	 **/
+	private $bizContent;
+
+	private $apiParas = array();
+	private $terminalType;
+	private $terminalInfo;
+	private $prodCode;
+	private $apiVersion="1.0";
+	private $notifyUrl;
+	private $returnUrl;
+    private $needEncrypt=false;
+
+	
+	public function setBizContent($bizContent)
+	{
+		$this->bizContent = $bizContent;
+		$this->apiParas["biz_content"] = $bizContent;
+	}
+
+	public function getBizContent()
+	{
+		return $this->bizContent;
+	}
+
+	public function getApiMethodName()
+	{
+		return "alipay.trade.fastpay.refund.query";
+	}
+
+	public function setNotifyUrl($notifyUrl)
+	{
+		$this->notifyUrl=$notifyUrl;
+	}
+
+	public function getNotifyUrl()
+	{
+		return $this->notifyUrl;
+	}
+
+	public function setReturnUrl($returnUrl)
+	{
+		$this->returnUrl=$returnUrl;
+	}
+
+	public function getReturnUrl()
+	{
+		return $this->returnUrl;
+	}
+
+	public function getApiParas()
+	{
+		return $this->apiParas;
+	}
+
+	public function getTerminalType()
+	{
+		return $this->terminalType;
+	}
+
+	public function setTerminalType($terminalType)
+	{
+		$this->terminalType = $terminalType;
+	}
+
+	public function getTerminalInfo()
+	{
+		return $this->terminalInfo;
+	}
+
+	public function setTerminalInfo($terminalInfo)
+	{
+		$this->terminalInfo = $terminalInfo;
+	}
+
+	public function getProdCode()
+	{
+		return $this->prodCode;
+	}
+
+	public function setProdCode($prodCode)
+	{
+		$this->prodCode = $prodCode;
+	}
+
+	public function setApiVersion($apiVersion)
+	{
+		$this->apiVersion=$apiVersion;
+	}
+
+	public function getApiVersion()
+	{
+		return $this->apiVersion;
+	}
+
+  public function setNeedEncrypt($needEncrypt)
+  {
+
+     $this->needEncrypt=$needEncrypt;
+
+  }
+
+  public function getNeedEncrypt()
+  {
+    return $this->needEncrypt;
+  }
+
+}

+ 118 - 0
addon/alipay/data/sdk/request/AlipayTradeOrderSettleRequest.php

@@ -0,0 +1,118 @@
+<?php
+/**
+ * ALIPAY API: alipay.trade.order.settle request
+ *
+ * @author auto create
+ * @since 1.0, 2018-07-13 17:18:06
+ */
+class AlipayTradeOrderSettleRequest
+{
+	/** 
+	 * 统一收单交易结算接口
+	 **/
+	private $bizContent;
+
+	private $apiParas = array();
+	private $terminalType;
+	private $terminalInfo;
+	private $prodCode;
+	private $apiVersion="1.0";
+	private $notifyUrl;
+	private $returnUrl;
+    private $needEncrypt=false;
+
+	
+	public function setBizContent($bizContent)
+	{
+		$this->bizContent = $bizContent;
+		$this->apiParas["biz_content"] = $bizContent;
+	}
+
+	public function getBizContent()
+	{
+		return $this->bizContent;
+	}
+
+	public function getApiMethodName()
+	{
+		return "alipay.trade.order.settle";
+	}
+
+	public function setNotifyUrl($notifyUrl)
+	{
+		$this->notifyUrl=$notifyUrl;
+	}
+
+	public function getNotifyUrl()
+	{
+		return $this->notifyUrl;
+	}
+
+	public function setReturnUrl($returnUrl)
+	{
+		$this->returnUrl=$returnUrl;
+	}
+
+	public function getReturnUrl()
+	{
+		return $this->returnUrl;
+	}
+
+	public function getApiParas()
+	{
+		return $this->apiParas;
+	}
+
+	public function getTerminalType()
+	{
+		return $this->terminalType;
+	}
+
+	public function setTerminalType($terminalType)
+	{
+		$this->terminalType = $terminalType;
+	}
+
+	public function getTerminalInfo()
+	{
+		return $this->terminalInfo;
+	}
+
+	public function setTerminalInfo($terminalInfo)
+	{
+		$this->terminalInfo = $terminalInfo;
+	}
+
+	public function getProdCode()
+	{
+		return $this->prodCode;
+	}
+
+	public function setProdCode($prodCode)
+	{
+		$this->prodCode = $prodCode;
+	}
+
+	public function setApiVersion($apiVersion)
+	{
+		$this->apiVersion=$apiVersion;
+	}
+
+	public function getApiVersion()
+	{
+		return $this->apiVersion;
+	}
+
+  public function setNeedEncrypt($needEncrypt)
+  {
+
+     $this->needEncrypt=$needEncrypt;
+
+  }
+
+  public function getNeedEncrypt()
+  {
+    return $this->needEncrypt;
+  }
+
+}

+ 118 - 0
addon/alipay/data/sdk/request/AlipayTradeOrderinfoSyncRequest.php

@@ -0,0 +1,118 @@
+<?php
+/**
+ * ALIPAY API: alipay.trade.orderinfo.sync request
+ *
+ * @author auto create
+ * @since 1.0, 2018-07-23 11:40:00
+ */
+class AlipayTradeOrderinfoSyncRequest
+{
+	/** 
+	 * 支付宝订单信息同步接口
+	 **/
+	private $bizContent;
+
+	private $apiParas = array();
+	private $terminalType;
+	private $terminalInfo;
+	private $prodCode;
+	private $apiVersion="1.0";
+	private $notifyUrl;
+	private $returnUrl;
+    private $needEncrypt=false;
+
+	
+	public function setBizContent($bizContent)
+	{
+		$this->bizContent = $bizContent;
+		$this->apiParas["biz_content"] = $bizContent;
+	}
+
+	public function getBizContent()
+	{
+		return $this->bizContent;
+	}
+
+	public function getApiMethodName()
+	{
+		return "alipay.trade.orderinfo.sync";
+	}
+
+	public function setNotifyUrl($notifyUrl)
+	{
+		$this->notifyUrl=$notifyUrl;
+	}
+
+	public function getNotifyUrl()
+	{
+		return $this->notifyUrl;
+	}
+
+	public function setReturnUrl($returnUrl)
+	{
+		$this->returnUrl=$returnUrl;
+	}
+
+	public function getReturnUrl()
+	{
+		return $this->returnUrl;
+	}
+
+	public function getApiParas()
+	{
+		return $this->apiParas;
+	}
+
+	public function getTerminalType()
+	{
+		return $this->terminalType;
+	}
+
+	public function setTerminalType($terminalType)
+	{
+		$this->terminalType = $terminalType;
+	}
+
+	public function getTerminalInfo()
+	{
+		return $this->terminalInfo;
+	}
+
+	public function setTerminalInfo($terminalInfo)
+	{
+		$this->terminalInfo = $terminalInfo;
+	}
+
+	public function getProdCode()
+	{
+		return $this->prodCode;
+	}
+
+	public function setProdCode($prodCode)
+	{
+		$this->prodCode = $prodCode;
+	}
+
+	public function setApiVersion($apiVersion)
+	{
+		$this->apiVersion=$apiVersion;
+	}
+
+	public function getApiVersion()
+	{
+		return $this->apiVersion;
+	}
+
+  public function setNeedEncrypt($needEncrypt)
+  {
+
+     $this->needEncrypt=$needEncrypt;
+
+  }
+
+  public function getNeedEncrypt()
+  {
+    return $this->needEncrypt;
+  }
+
+}

+ 120 - 0
addon/alipay/data/sdk/request/AlipayTradePagePayRequest.php

@@ -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;
+  }
+
+}

+ 119 - 0
addon/alipay/data/sdk/request/AlipayTradePayRequest.php

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

+ 119 - 0
addon/alipay/data/sdk/request/AlipayTradePrecreateRequest.php

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

+ 119 - 0
addon/alipay/data/sdk/request/AlipayTradeQueryRequest.php

@@ -0,0 +1,119 @@
+<?php
+/**
+ * ALIPAY API: alipay.trade.query request
+ *
+ * @author auto create
+ * @since 1.0, 2018-05-11 18:28:47
+ */
+class AlipayTradeQueryRequest
+{
+	/** 
+	 * 统一收单线下交易查询
+修改路由策略到R
+	 **/
+	private $bizContent;
+
+	private $apiParas = array();
+	private $terminalType;
+	private $terminalInfo;
+	private $prodCode;
+	private $apiVersion="1.0";
+	private $notifyUrl;
+	private $returnUrl;
+    private $needEncrypt=false;
+
+	
+	public function setBizContent($bizContent)
+	{
+		$this->bizContent = $bizContent;
+		$this->apiParas["biz_content"] = $bizContent;
+	}
+
+	public function getBizContent()
+	{
+		return $this->bizContent;
+	}
+
+	public function getApiMethodName()
+	{
+		return "alipay.trade.query";
+	}
+
+	public function setNotifyUrl($notifyUrl)
+	{
+		$this->notifyUrl=$notifyUrl;
+	}
+
+	public function getNotifyUrl()
+	{
+		return $this->notifyUrl;
+	}
+
+	public function setReturnUrl($returnUrl)
+	{
+		$this->returnUrl=$returnUrl;
+	}
+
+	public function getReturnUrl()
+	{
+		return $this->returnUrl;
+	}
+
+	public function getApiParas()
+	{
+		return $this->apiParas;
+	}
+
+	public function getTerminalType()
+	{
+		return $this->terminalType;
+	}
+
+	public function setTerminalType($terminalType)
+	{
+		$this->terminalType = $terminalType;
+	}
+
+	public function getTerminalInfo()
+	{
+		return $this->terminalInfo;
+	}
+
+	public function setTerminalInfo($terminalInfo)
+	{
+		$this->terminalInfo = $terminalInfo;
+	}
+
+	public function getProdCode()
+	{
+		return $this->prodCode;
+	}
+
+	public function setProdCode($prodCode)
+	{
+		$this->prodCode = $prodCode;
+	}
+
+	public function setApiVersion($apiVersion)
+	{
+		$this->apiVersion=$apiVersion;
+	}
+
+	public function getApiVersion()
+	{
+		return $this->apiVersion;
+	}
+
+  public function setNeedEncrypt($needEncrypt)
+  {
+
+     $this->needEncrypt=$needEncrypt;
+
+  }
+
+  public function getNeedEncrypt()
+  {
+    return $this->needEncrypt;
+  }
+
+}

+ 120 - 0
addon/alipay/data/sdk/request/AlipayTradeRefundRequest.php

@@ -0,0 +1,120 @@
+<?php
+
+namespace addon\alipay\data\sdk\request;
+/**
+ * ALIPAY API: alipay.trade.refund request
+ *
+ * @author auto create
+ * @since 1.0, 2018-09-01 17:20:00
+ */
+class AlipayTradeRefundRequest
+{
+	/** 
+	 * 统一收单交易退款接口
+	 **/
+	private $bizContent;
+
+	private $apiParas = array();
+	private $terminalType;
+	private $terminalInfo;
+	private $prodCode;
+	private $apiVersion="1.0";
+	private $notifyUrl;
+	private $returnUrl;
+    private $needEncrypt=false;
+
+	
+	public function setBizContent($bizContent)
+	{
+		$this->bizContent = $bizContent;
+		$this->apiParas["biz_content"] = $bizContent;
+	}
+
+	public function getBizContent()
+	{
+		return $this->bizContent;
+	}
+
+	public function getApiMethodName()
+	{
+		return "alipay.trade.refund";
+	}
+
+	public function setNotifyUrl($notifyUrl)
+	{
+		$this->notifyUrl=$notifyUrl;
+	}
+
+	public function getNotifyUrl()
+	{
+		return $this->notifyUrl;
+	}
+
+	public function setReturnUrl($returnUrl)
+	{
+		$this->returnUrl=$returnUrl;
+	}
+
+	public function getReturnUrl()
+	{
+		return $this->returnUrl;
+	}
+
+	public function getApiParas()
+	{
+		return $this->apiParas;
+	}
+
+	public function getTerminalType()
+	{
+		return $this->terminalType;
+	}
+
+	public function setTerminalType($terminalType)
+	{
+		$this->terminalType = $terminalType;
+	}
+
+	public function getTerminalInfo()
+	{
+		return $this->terminalInfo;
+	}
+
+	public function setTerminalInfo($terminalInfo)
+	{
+		$this->terminalInfo = $terminalInfo;
+	}
+
+	public function getProdCode()
+	{
+		return $this->prodCode;
+	}
+
+	public function setProdCode($prodCode)
+	{
+		$this->prodCode = $prodCode;
+	}
+
+	public function setApiVersion($apiVersion)
+	{
+		$this->apiVersion=$apiVersion;
+	}
+
+	public function getApiVersion()
+	{
+		return $this->apiVersion;
+	}
+
+  public function setNeedEncrypt($needEncrypt)
+  {
+
+     $this->needEncrypt=$needEncrypt;
+
+  }
+
+  public function getNeedEncrypt()
+  {
+    return $this->needEncrypt;
+  }
+
+}

+ 118 - 0
addon/alipay/data/sdk/request/AlipayTradeVendorpayDevicedataUploadRequest.php

@@ -0,0 +1,118 @@
+<?php
+/**
+ * ALIPAY API: alipay.trade.vendorpay.devicedata.upload request
+ *
+ * @author auto create
+ * @since 1.0, 2016-12-08 00:51:39
+ */
+class AlipayTradeVendorpayDevicedataUploadRequest
+{
+	/** 
+	 * 厂商支付授权时上传设备数据接口,目前主要包含三星支付。com
+	 **/
+	private $bizContent;
+
+	private $apiParas = array();
+	private $terminalType;
+	private $terminalInfo;
+	private $prodCode;
+	private $apiVersion="1.0";
+	private $notifyUrl;
+	private $returnUrl;
+    private $needEncrypt=false;
+
+	
+	public function setBizContent($bizContent)
+	{
+		$this->bizContent = $bizContent;
+		$this->apiParas["biz_content"] = $bizContent;
+	}
+
+	public function getBizContent()
+	{
+		return $this->bizContent;
+	}
+
+	public function getApiMethodName()
+	{
+		return "alipay.trade.vendorpay.devicedata.upload";
+	}
+
+	public function setNotifyUrl($notifyUrl)
+	{
+		$this->notifyUrl=$notifyUrl;
+	}
+
+	public function getNotifyUrl()
+	{
+		return $this->notifyUrl;
+	}
+
+	public function setReturnUrl($returnUrl)
+	{
+		$this->returnUrl=$returnUrl;
+	}
+
+	public function getReturnUrl()
+	{
+		return $this->returnUrl;
+	}
+
+	public function getApiParas()
+	{
+		return $this->apiParas;
+	}
+
+	public function getTerminalType()
+	{
+		return $this->terminalType;
+	}
+
+	public function setTerminalType($terminalType)
+	{
+		$this->terminalType = $terminalType;
+	}
+
+	public function getTerminalInfo()
+	{
+		return $this->terminalInfo;
+	}
+
+	public function setTerminalInfo($terminalInfo)
+	{
+		$this->terminalInfo = $terminalInfo;
+	}
+
+	public function getProdCode()
+	{
+		return $this->prodCode;
+	}
+
+	public function setProdCode($prodCode)
+	{
+		$this->prodCode = $prodCode;
+	}
+
+	public function setApiVersion($apiVersion)
+	{
+		$this->apiVersion=$apiVersion;
+	}
+
+	public function getApiVersion()
+	{
+		return $this->apiVersion;
+	}
+
+  public function setNeedEncrypt($needEncrypt)
+  {
+
+     $this->needEncrypt=$needEncrypt;
+
+  }
+
+  public function getNeedEncrypt()
+  {
+    return $this->needEncrypt;
+  }
+
+}

+ 120 - 0
addon/alipay/data/sdk/request/AlipayTradeWapPayRequest.php

@@ -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;
+  }
+
+}

+ 29 - 0
addon/alipay/event/Install.php

@@ -0,0 +1,29 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+declare (strict_types = 1);
+
+namespace addon\alipay\event;
+
+/**
+ * 应用安装
+ */
+class Install
+{
+	/**
+	 * 执行安装
+	 */
+	public function handle()
+	{
+
+        return success();
+	}
+}

+ 36 - 0
addon/alipay/event/Pay.php

@@ -0,0 +1,36 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+declare (strict_types = 1);
+
+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" ])) {
+                $pay_model = new PayModel();
+                $res = $pay_model->pay($param);
+                return $res;
+            }
+        }
+	}
+}

+ 32 - 0
addon/alipay/event/PayClose.php

@@ -0,0 +1,32 @@
+<?php
+// +---------------------------------------------------------------------+
+// | NiuCloud | [ WE CAN DO IT JUST NiuCloud ]                |
+// +---------------------------------------------------------------------+
+// | Copy right 2019-2029 www.niucloud.com                          |
+// +---------------------------------------------------------------------+
+// | Author | NiuCloud <niucloud@outlook.com>                       |
+// +---------------------------------------------------------------------+
+// | Repository | https://github.com/niucloud/framework.git          |
+// +---------------------------------------------------------------------+
+declare (strict_types = 1);
+
+namespace addon\alipay\event;
+
+use addon\alipay\model\Pay as PayModel;
+/**
+ * 关闭支付
+ */
+class PayClose
+{
+    /**
+     * 关闭支付
+     */
+    public function handle($params)
+    {
+        if($params["pay_type"] == "alipay"){
+            $pay_model = new PayModel();
+            $result = $pay_model->close($params);
+            return $result;
+        }
+    }
+}

+ 30 - 0
addon/alipay/event/PayNotify.php

@@ -0,0 +1,30 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+declare (strict_types = 1);
+
+namespace addon\alipay\event;
+
+use addon\alipay\model\Pay as PayModel;
+/**
+ * 支付回调
+ */
+class PayNotify
+{
+	/**
+	 * 支付方式及配置
+	 */
+	public function handle($param)
+	{
+        $pay_model = new PayModel();
+        $pay_model->payNotify();
+	}
+}

+ 32 - 0
addon/alipay/event/PayRefund.php

@@ -0,0 +1,32 @@
+<?php
+// +---------------------------------------------------------------------+
+// | NiuCloud | [ WE CAN DO IT JUST NiuCloud ]                |
+// +---------------------------------------------------------------------+
+// | Copy right 2019-2029 www.niucloud.com                          |
+// +---------------------------------------------------------------------+
+// | Author | NiuCloud <niucloud@outlook.com>                       |
+// +---------------------------------------------------------------------+
+// | Repository | https://github.com/niucloud/framework.git          |
+// +---------------------------------------------------------------------+
+declare (strict_types = 1);
+
+namespace addon\alipay\event;
+
+use addon\alipay\model\Pay as PayModel;
+/**
+ * 原路退款
+ */
+class PayRefund
+{
+    /**
+     * 关闭支付
+     */
+    public function handle($params)
+    {
+        if($params["pay_info"]["pay_type"] == "alipay"){
+            $pay_model = new PayModel();
+            $result = $pay_model->refund($params);
+            return $result;
+        }
+    }
+}

+ 27 - 0
addon/alipay/event/PayTransfer.php

@@ -0,0 +1,27 @@
+<?php
+// +---------------------------------------------------------------------+
+// | NiuCloud | [ WE CAN DO IT JUST NiuCloud ]                |
+// +---------------------------------------------------------------------+
+// | Copy right 2019-2029 www.niucloud.com                          |
+// +---------------------------------------------------------------------+
+// | Author | NiuCloud <niucloud@outlook.com>                       |
+// +---------------------------------------------------------------------+
+// | Repository | https://github.com/niucloud/framework.git          |
+// +---------------------------------------------------------------------+
+declare (strict_types = 1);
+
+namespace addon\alipay\event;
+
+use addon\alipay\model\Pay;
+
+class PayTransfer
+{
+    public function handle(array $params)
+    {
+        if ($params['transfer_type'] == 'alipay') {
+            $pay = new Pay();
+            $res = $pay->payTransfer($params);
+            return $res;
+        }
+    }
+}

+ 50 - 0
addon/alipay/event/PayType.php

@@ -0,0 +1,50 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+declare (strict_types = 1);
+
+namespace addon\alipay\event;
+
+use addon\alipay\model\Config;
+
+/**
+ * 支付方式  (后台调用)
+ */
+class PayType
+{
+	/**
+	 * 支付方式及配置
+	 */
+	public function handle($param)
+	{
+          $app_type = isset($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();
+              $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://admin/pay/config",
+			"logo" => "addon/alipay/icon.png",
+            "desc" => "支付宝网站(www.alipay.com) 是国内先进的网上支付平台。"
+        );
+        return $info;
+	}
+}

+ 41 - 0
addon/alipay/event/TransferType.php

@@ -0,0 +1,41 @@
+<?php
+// +---------------------------------------------------------------------+
+// | NiuCloud | [ WE CAN DO IT JUST NiuCloud ]                |
+// +---------------------------------------------------------------------+
+// | Copy right 2019-2029 www.niucloud.com                          |
+// +---------------------------------------------------------------------+
+// | Author | NiuCloud <niucloud@outlook.com>                       |
+// +---------------------------------------------------------------------+
+// | Repository | https://github.com/niucloud/framework.git          |
+// +---------------------------------------------------------------------+
+declare (strict_types = 1);
+
+namespace addon\alipay\event;
+
+use addon\alipay\model\Config;
+
+class TransferType
+{
+    public function handle(array $param)
+    {
+
+        $app_type = isset($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();
+            $config = $config_result["data"]["value"] ?? [];
+            $transfer_status = $config["transfer_status"] ?? 0;
+            if($transfer_status == 0){
+                return '';
+            }
+        }
+        $info = array(
+            "type" => "alipay",
+            "type_name" => "支付宝",
+        );
+        return $info;
+    }
+}

+ 28 - 0
addon/alipay/event/UnInstall.php

@@ -0,0 +1,28 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+declare (strict_types = 1);
+
+namespace addon\alipay\event;
+
+/**
+ * 应用卸载
+ */
+class UnInstall
+{
+	/**
+	 * 执行卸载
+	 */
+	public function handle()
+	{
+        return error(-1,"系统插件不得删除");
+	}
+}

二進制
addon/alipay/icon.png


+ 43 - 0
addon/alipay/model/Config.php

@@ -0,0 +1,43 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+
+namespace addon\alipay\model;
+
+
+use app\model\system\Config as ConfigModel;
+use app\model\BaseModel;
+/**
+ * 支付宝支付配置
+ */
+class Config extends BaseModel
+{
+    /**
+     * 设置支付配置
+     * array $data
+     */
+    public function setPayConfig($data)
+    {
+        $config = new ConfigModel();
+        $res = $config->setConfig($data, '支付宝支付配置', 1, [['site_id', '=', 0], ['app_module', '=', 'admin'], ['config_key', '=', 'ALI_PAY_CONFIG']]);
+        return $res;
+    }
+    
+    /**
+     * 获取支付配置
+     */
+    public function getPayConfig()
+    {
+        $config = new ConfigModel();
+        $res = $config->getConfig([['site_id', '=', 0], ['app_module', '=', 'admin'], ['config_key', '=', 'ALI_PAY_CONFIG']]);
+        return $res;
+    }
+}

+ 224 - 0
addon/alipay/model/Pay.php

@@ -0,0 +1,224 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+namespace addon\alipay\model;
+
+use addon\alipay\data\sdk\AopClient;
+use addon\alipay\data\sdk\request\AlipayTradeWapPayRequest;
+use addon\alipay\data\sdk\request\AlipayTradePagePayRequest;
+use addon\alipay\data\sdk\request\AlipayTradeAppPayRequest;
+use addon\alipay\data\sdk\request\AlipayTradeCloseRequest;
+use addon\alipay\data\sdk\request\AlipayTradeRefundRequest;
+use app\model\system\Pay as PayCommon;
+use app\model\BaseModel;
+use think\facade\Log;
+use addon\alipay\data\sdk\request\AlipayFundTransToaccountTransferRequest;
+
+/**
+ * 支付宝支付配置
+ */
+class Pay extends BaseModel
+{
+
+    public $aop;
+
+    function __construct()
+    {
+        // 获取支付宝支付参数(统一支付到平台账户)
+        $config_model = new Config();
+        $config_result = $config_model->getPayConfig();
+        $config = $config_result["data"];
+        if(!empty($config)){
+            $config_info = $config["value"];
+        }
+
+        // 获取支付宝支付参数(统一支付到平台账户)
+        $this->aop = new AopClient();
+        $this->aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
+        $this->aop->appId = $config_info["app_id"] ?? "";
+        $this->aop->rsaPrivateKey = $config_info['private_key'] ?? "";
+        $this->aop->alipayrsaPublicKey =$config_info['public_key'] ?? "";
+        $this->aop->alipayPublicKey = $config_info['alipay_public_key'] ?? "";
+        $this->aop->apiVersion = '1.0';
+        $this->aop->signType = 'RSA2';
+        $this->aop->postCharset = 'UTF-8';
+        $this->aop->format = 'json';
+    }
+
+    /**
+     * 生成支付
+     * @param $param
+     */
+    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',
+        );
+        $parameter = json_encode($parameter);
+        switch ($param["app_type"])
+        {
+            case "h5":
+                $request = new AlipayTradeWapPayRequest();
+                break;
+            case "pc":
+                $request = new AlipayTradePagePayRequest();
+                break;
+            case "app":
+                $request = new AlipayTradeAppPayRequest();
+                break;
+        }
+
+        $request->setBizContent($parameter);
+        $request->SetReturnUrl($param["return_url"]);
+        $request->SetNotifyUrl($param["notify_url"]);
+        $result = $this->aop->pageExecute($request, 'get');
+        return $this->success([
+            'type' => 'url',
+            'data' => $result
+        ]);
+        $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
+        $resultCode = $result->$responseNode->code;
+        if (!empty($resultCode) && $resultCode == 10000) {
+            return $this->success();
+        } else {
+            return $this->error("", $resultCode);
+        }
+    }
+
+    /**
+     * 支付关闭
+     * @param unknown $orderNumber
+     * @return multitype:number string |multitype:number mixed
+     */
+    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 {
+            return $this->error("", $resultCode->sub_msg);
+        }
+    }
+
+    /**
+     * 支付宝支付原路返回
+     * @param unknown $param  支付参数
+     */
+    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("", $resultCode->sub_msg);
+        }
+    }
+
+    /**
+     * 支付宝转账
+     * @param $param
+     * @return array
+     * @throws \think\Exception
+     */
+    public function payTransfer($param)
+    {
+        try {
+            $config_model = new Config();
+            $config_result = $config_model->getPayConfig();
+            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";
+        }
+    }
+
+}

+ 82 - 0
addon/alisms/admin/controller/Message.php

@@ -0,0 +1,82 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+
+namespace addon\alisms\admin\controller;
+
+use app\admin\controller\BaseAdmin;
+use app\model\message\Message as MessageModel;
+
+/**
+ * 阿里云短信消息管理
+ */
+class Message extends BaseAdmin
+{
+	
+	/**
+	 * 编辑模板消息
+	 * @return array|mixed|string
+	 */
+	public function edit()
+	{
+		$message_model = new MessageModel();
+		$keywords = input("keywords", "");
+		$info_result = $message_model->getMessageInfo([ [ "keywords", "=", $keywords ] ]);
+		$info = $info_result["data"];
+		if (request()->isAjax()) {
+			if (empty($info))
+				return error("", "不存在的模板信息!");
+			
+			$sms_json_array = $info["sms_json_array"];//短信配置
+			$template_id = input("template_id", '');//短信模板id
+			$smssign = input("smssign", '');//短信签名
+			$content = input("content", '');//短信签名
+			
+			$sms_is_open = input("sms_is_open", 0);
+			
+			$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),
+				"sms_is_open" => $sms_is_open,
+			);
+			$condition = array(
+				[ "keywords", "=", $keywords ]
+			);
+			$res = $message_model->editMessage($data, $condition);
+			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("sms_is_open", $info["sms_is_open"]);
+			$this->assign("keywords", $keywords);
+			
+			//模板变量
+			$message_variable_list = $info["message_json_array"];
+			$this->assign("message_variable_list", $message_variable_list);
+			return $this->fetch('message/edit');
+		}
+	}
+	
+}

+ 47 - 0
addon/alisms/admin/controller/Sms.php

@@ -0,0 +1,47 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+
+namespace addon\alisms\admin\controller;
+
+use addon\alisms\model\Config as ConfigModel;
+use app\admin\controller\BaseAdmin;
+
+/**
+ * 阿里云短信 控制器
+ */
+class Sms extends BaseAdmin
+{
+	public function config()
+	{
+		$config_model = new ConfigModel();
+		if (request()->isAjax()) {
+			$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(
+				"status" => $status,
+				"access_key_id" => $access_key_id,
+				"access_key_secret" => $access_key_secret,
+				"smssign" => $smssign
+			);
+			$result = $config_model->setSmsConfig($data);
+			return $result;
+		} else {
+			$info_result = $config_model->getSmsConfig();
+			$info = $info_result["data"];
+			$this->assign("info", $info);
+			return $this->fetch("sms/config");
+		}
+	}
+}

+ 107 - 0
addon/alisms/admin/view/message/edit.html

@@ -0,0 +1,107 @@
+{extend name="app/admin/view/base.html"/}
+{block name="resources"}
+<style>
+	.layui-btn-primary:hover {border-color: #C9C9C9;}
+	.number-con {margin-right: 10px;}
+	.ns-form {margin-top: 0;}
+</style>
+{/block}
+{block name="main"}
+<div class="layui-form ns-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>模板ID:</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 ns-len-long">
+		</div>
+		<div class="ns-word-aux">必须与短信接口的模板ID一致,否则无效!</div>
+	</div>
+	
+	<div class="layui-form-item">
+		<label class="layui-form-label">数据值:</label>
+		<div class="layui-input-block">
+			{foreach $message_variable_list as $message_variable_k => $message_variable_v}
+			<button class="layui-btn layui-btn-primary number-con" onclick="clickBtn('{$message_variable_k}')">{$message_variable_v}</button>
+			{/foreach}
+		</div>
+	</div>
+	
+	<div class="layui-form-item">
+		<label class="layui-form-label">短信内容:</label>
+		<div class="layui-input-block">
+			<textarea id="text_area" name="content" class="layui-textarea ns-len-long">{if !empty($info)}{$info.content}{/if}</textarea>
+		</div>
+		<div class="ns-word-aux">变量只能使用上方的可用变量中的变量,否则不会被解析;如果要使用凌凯短信时,短信内容必须进行设置。</div>
+	</div>
+	
+	<div class="ns-form-row">
+		<button class="layui-btn ns-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>
+{/block}
+{block name="script"}
+<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({
+				dataType: 'JSON',
+				type: 'POST',
+				url: ns.url("alisms://admin/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("admin/message/lists")
+							},
+							btn2: function() {
+								location.reload();
+							}
+						});
+					}else{
+						layer.msg(res.message);
+					}
+				}
+			});
+		});
+	});
+	
+	function back(){
+		location.href = ns.url("admin/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>
+{/block}

+ 88 - 0
addon/alisms/admin/view/sms/config.html

@@ -0,0 +1,88 @@
+{extend name="app/admin/view/base.html"/}
+{block name="resources"}
+<style>
+	.ns-form {margin-top: 0;}
+</style>
+{/block}
+{block name="main"}
+<div class="layui-form ns-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.value && $info.value.status == 1"} checked {/if} />
+        </div>
+		<div class="ns-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 ns-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 ns-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 ns-len-long">
+		</div>
+	</div>
+
+    <!-- 表单操作 -->
+    <div class="ns-form-row">
+        <button class="layui-btn ns-bg-color" lay-submit lay-filter="save">保存</button>
+        <button class="layui-btn layui-btn-primary" onclick="back()">返回</button>
+    </div>
+
+</div>
+{/block}
+{block name="script"}
+<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://admin/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("admin/message/sms")
+							},
+							btn2: function() {
+								location.reload();
+							}
+						});
+					}else{
+						layer.msg(res.message);
+					}
+                }
+            });
+        });
+    });
+
+    function back() {
+        location.href = ns.url("admin/message/sms");
+    }
+</script>
+{/block}

+ 23 - 0
addon/alisms/config/diy_view.php

@@ -0,0 +1,23 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+return [
+    
+	'diy' => [
+		'view' => [
+		],
+		'util' => [
+		],
+		'link' => [
+		],
+	
+	],
+];

+ 23 - 0
addon/alisms/config/event.php

@@ -0,0 +1,23 @@
+<?php
+// 事件定义文件
+return [
+    'bind'      => [
+        
+    ],
+
+    'listen'    => [
+        //短信方式
+        'SmsType' => [
+            'addon\alisms\event\SmsType'
+        ],
+        'DoEditSmsMessage' => [
+            'addon\alisms\event\DoEditSmsMessage'
+        ],
+        'SendSms' => [
+            'addon\alisms\event\SendSms'
+        ]
+    ],
+
+    'subscribe' => [
+    ],
+];

+ 20 - 0
addon/alisms/config/info.php

@@ -0,0 +1,20 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+return [
+		'name' => 'alisms',
+		'title' => '阿里云短信',
+		'description' => '阿里云短信功能',
+		'status' => 1,
+		'author' => '',
+		'version' => '1.0',
+		'content' => '',
+];

+ 31 - 0
addon/alisms/config/menu_admin.php

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

+ 7 - 0
addon/alisms/config/menu_shop.php

@@ -0,0 +1,7 @@
+<?php
+// +----------------------------------------------------------------------
+// | 平台端菜单设置
+// +----------------------------------------------------------------------
+return [
+
+];

+ 35 - 0
addon/alisms/event/DoEditSmsMessage.php

@@ -0,0 +1,35 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+declare (strict_types = 1);
+
+namespace addon\alisms\event;
+use addon\alisms\model\Config as ConfigModel;
+
+/**
+ * 短信模板  (后台调用)
+ */
+class DoEditSmsMessage
+{
+	/**
+	 * 短信发送方式方式及配置
+	 */
+	public function handle()
+	{
+	    $config_model = new ConfigModel();
+        $config_result = $config_model->getSmsConfig();
+        $config = $config_result["data"];
+        if($config["is_use"] == 1){
+            return ["edit_url" => "alisms://admin/message/edit"];
+        }
+
+	}
+}

+ 29 - 0
addon/alisms/event/Install.php

@@ -0,0 +1,29 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+declare (strict_types = 1);
+
+namespace addon\alisms\event;
+
+/**
+ * 应用安装
+ */
+class Install
+{
+	/**
+	 * 执行安装
+	 */
+	public function handle()
+	{
+
+        return success();
+	}
+}

+ 34 - 0
addon/alisms/event/SendSms.php

@@ -0,0 +1,34 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+declare (strict_types = 1);
+
+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;
+	}
+}

+ 41 - 0
addon/alisms/event/SmsType.php

@@ -0,0 +1,41 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+declare (strict_types = 1);
+
+namespace addon\alisms\event;
+
+use addon\alisms\model\Config;
+
+/**
+ * 短信方式  (后台调用)
+ */
+class SmsType
+{
+	/**
+	 * 短信发送方式方式及配置
+	 */
+	public function handle()
+	{
+	    $info = array(
+	        "sms_type" => "alisms",
+            "sms_type_name" => "阿里云短信",
+            "edit_url" => "alisms://admin/sms/config",
+            "desc" => "阿里云短信服务(Short Message Service)支持国内和国际快速发送验证码、短信通知和推广短信,服务范围覆盖全球200多个国家和地区。国内短信支持三网合一专属通道,与工信部携号转网平台实时互联。电信级运维保障,实时监控自动切换,到达率高达99%。"
+        );
+
+	    $config_model = new Config();
+	    $config = $config_model->getSmsConfig();
+        $info['status'] = $config['data']['value']['status'] ?? 0;
+
+        return $info;
+	}
+}

+ 28 - 0
addon/alisms/event/UnInstall.php

@@ -0,0 +1,28 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+declare (strict_types = 1);
+
+namespace addon\alisms\event;
+
+/**
+ * 应用卸载
+ */
+class UnInstall
+{
+	/**
+	 * 执行卸载
+	 */
+	public function handle()
+	{
+        return success();
+	}
+}

二進制
addon/alisms/icon.png


+ 43 - 0
addon/alisms/model/Config.php

@@ -0,0 +1,43 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+
+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)
+	{
+		$config = new ConfigModel();
+		$res = $config->setConfig($data, '阿里云短信配置', $data['status'], [ [ 'site_id', '=', 0 ], [ 'app_module', '=', 'admin' ], [ 'config_key', '=', 'ALI_SMS_CONFIG' ] ]);
+		return $res;
+	}
+	
+	/**
+	 * 获取短信配置
+	 */
+	public function getSmsConfig()
+	{
+		$config = new ConfigModel();
+		$res = $config->getConfig([ [ 'site_id', '=', 0 ], [ 'app_module', '=', 'admin' ], [ 'config_key', '=', 'ALI_SMS_CONFIG' ] ]);
+		return $res;
+	}
+}

+ 79 - 0
addon/alisms/model/Sms.php

@@ -0,0 +1,79 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+
+namespace addon\alisms\model;
+
+use app\model\BaseModel;
+use Overtrue\EasySms\EasySms;
+use Overtrue\EasySms\Exceptions\InvalidArgumentException;
+use Overtrue\EasySms\Exceptions\NoGatewayAvailableException;
+use Overtrue\EasySms\Strategies\OrderStrategy;
+
+/**
+ * 阿里云短信
+ */
+class Sms extends BaseModel
+{
+	/**
+	 * 短信发送
+	 * @param array $param
+	 * @return array|mixed
+	 * @throws InvalidArgumentException
+	 */
+	public function send($param = [])
+	{
+		$config_model = new Config();
+		$config_result = $config_model->getSmsConfig();
+		if ($config_result["data"]["is_use"]) {
+			$config = $config_result["data"]["value"];
+			$sms_info = $param["message_info"]["sms_json_array"];//消息类型模板 短信模板信息
+			if (empty($sms_info["alisms"])) return $this->error([], "消息模板尚未配置");
+			
+			$sms_info = $sms_info["alisms"];
+			$var_parse = $param["var_parse"];//变量解析
+			$account = $param["sms_account"];//发送手机号
+			//加入阿里云短信配置
+			
+			$sms_config = [
+				// HTTP 请求的超时时间(秒)
+				'timeout' => 5.0,
+				// 默认发送配置
+				'default' => [
+					// 网关调用策略,默认:顺序调用
+					'strategy' => OrderStrategy::class,
+					// 默认可用的发送网关
+					'gateways' => [ 'aliyun' ],
+				],
+				// 可用的网关配置
+				'gateways' => [
+					"aliyun" => [
+						'access_key_id' => $config["access_key_id"],
+						'access_key_secret' => $config["access_key_secret"],
+						'sign_name' => $config["smssign"],
+					]
+				],
+			];
+			try {
+				unset($var_parse['site_name']);
+				$easySms = new EasySms($sms_config);
+				$easySms->send($account, [
+					'template' => $sms_info["template_id"],
+					'data' => $var_parse,
+				]);
+				return $this->success([ "addon" => "alisms", "addon_name" => "阿里云短信", "content" => $sms_info["content"] ]);
+			} catch (NoGatewayAvailableException $exception) {
+				$message = $exception->getException('aliyun')->getMessage();
+				return $this->error([ "content" => $sms_info["content"] ], $message ? : '短信发送异常');
+			}
+		}
+	}
+}

+ 84 - 0
addon/bundling/admin/controller/Bundling.php

@@ -0,0 +1,84 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+
+namespace addon\bundling\admin\controller;
+
+use app\admin\controller\BaseAdmin;
+use addon\bundling\model\Bundling as BundlingModel;
+
+/**
+ * 优惠套餐
+ */
+class Bundling extends BaseAdmin
+{
+	/**
+	 * 活动列表
+	 */
+	public function lists()
+	{
+		if (request()->isAjax()) {
+			$page = input('page', 1);
+			$page_size = input('page_size', PAGE_LIST_ROWS);
+			$bl_name = input('bl_name', '');
+			$search_text = input('search_text', '');
+			$status = input('status', '');
+			$site_id = input("site_id", "");
+			$condition = [];
+			$condition[] = [ 'bl_name', 'like', '%' . $bl_name . '%' ];
+			$condition[] = [ 'site_name', 'like', '%' . $search_text . '%' ];
+			if ($site_id != "") {
+				$condition[] = [ 'site_id', '=', $site_id ];
+			}
+			if ($status != '') {
+				$condition[] = [ 'status', '=', $status ];
+			}
+			$order = 'update_time desc';
+			$field = '*';
+			
+			$bundling_model = new BundlingModel();
+			$res = $bundling_model->getBundlingPageList($condition, $page, $page_size, $order, $field);
+			return $res;
+		} else {
+			return $this->fetch("bundling/lists");
+		}
+	}
+	
+	/**
+	 * 活动详情
+	 */
+	public function detail()
+	{
+		$bl_id = input("bl_id", 0);
+		$site_id = input("site_id", 0);
+		$bundling_model = new BundlingModel();
+		$condition = [ [ 'bl_id', '=', $bl_id ], [ 'site_id', '=', $site_id ] ];
+		$info_result = $bundling_model->getBundlingDetail($condition);
+		$this->assign("info", $info_result["data"]);
+		return $this->fetch("bundling/detail");
+	}
+	
+	/**
+	 * 删除优惠套餐
+	 */
+	public function delete()
+	{
+		if (request()->isAjax()) {
+			$bl_id = input('bl_id', 0);
+			$site_id = input("site_id", 0);
+			$this->addLog("删除优惠套餐id:" . $bl_id);
+			$bundling_model = new BundlingModel();
+			$res = $bundling_model->deleteBundling($bl_id, $site_id);
+			return $res;
+		}
+	}
+	
+}

+ 60 - 0
addon/bundling/admin/view/bundling/detail.html

@@ -0,0 +1,60 @@
+{extend name="app/admin/view/base.html"/}
+{block name="resources"}
+<style>
+	.layui-table[lay-skin=line] {
+		border-width: 0;
+	}
+</style>
+{/block}
+{block name="main"}
+<div class="ns-detail-card ns-tips">
+	<div class="ns-detail-con">
+		<p class="ns-detail-line">
+			<span class="ns-goods-name">{$info.bl_name}</span>
+			<span class="ns-text-color">({$info.status == 1 ? '开启' : '关闭'})</span>
+		</p>
+		<p class="ns-detail-line">
+			<span>套餐价格:¥{$info.bl_price}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+			<span>原价:¥{$info.goods_money}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+			<span>节省价:¥{$info.goods_money - $info.bl_price}</span>
+		</p>
+		<p class="ns-detail-line">运费承担:{$info.shipping_fee_type == 1 ? '卖家承担运费' : '买家承担运费(快递)'}</p>
+	</div>
+</div>
+
+<table class="layui-table ns-pithy-table" id="goods" lay-skin="line" lay-size="lg">
+	<colgroup>
+		<col width="60%">
+		<col width="20%">
+		<col width="20%">
+	</colgroup>
+	<thead>
+		<tr>
+			<th>商品</th>
+			<th style="text-align: right;">价格</th>
+			<th style="text-align: right;">优惠价</th>
+		</tr>
+	</thead>
+	<tbody>
+		{foreach name= $info.bundling_goods as $k => $v}
+			<tr data-sku_id="{$v.sku_id}">
+				<td>
+					<div class="ns-table-tuwen-box">
+					    <div class="ns-img-box">
+					        <img layer-src src="{:img($v.sku_image)}">
+					    </div>
+					    <div class="ns-font-box">
+					        <p class="ns-multi-line-hiding">{$v.sku_name}</p>
+					    </div>
+					</div>
+					
+				</td>
+				<td class="price-one" align="right">¥{$v.price}</td>
+				<td align="right">¥{$v.promotion_price}</td>
+			</tr>
+		{/foreach}
+	</tbody>
+</table>
+{/block}
+{block name="script"}
+{/block}

+ 204 - 0
addon/bundling/admin/view/bundling/lists.html

@@ -0,0 +1,204 @@
+{extend name="app/admin/view/base.html"/}
+{block name="resources"}
+{/block}
+{block name="main"}
+<div class="layui-collapse ns-tips">
+	<div class="layui-colla-item">
+		<h2 class="layui-colla-title">操作提示</h2>
+		<ul class="layui-colla-content layui-show">
+			<li>优惠套餐显示在商品详情,是一种捆绑购买的优惠活动</li>
+			<li>商家可以选择发布组合套餐,同时可以设置套餐价格</li>
+		</ul>
+	</div>
+</div>
+<div class="ns-screen layui-collapse">
+	<div class="layui-colla-item">
+		<h2 class="layui-colla-title">筛选</h2>
+		<form class="layui-colla-content layui-form layui-show">
+			<div class="layui-form-item">
+				<div class="layui-inline">
+					<label class="layui-form-label">活动名称:</label>
+					<div class="layui-input-inline">
+						<input type="text" id="bl_name" name="bl_name" placeholder="请输入活动名称" class="layui-input" autocomplete="off">
+					</div>
+				</div>
+				
+				<div class="layui-inline">
+					<label class="layui-form-label">店铺名称:</label>
+					<div class="layui-input-inline">
+						<input type="text" id="search_text" name="search_text" placeholder="请输入店铺名称" class="layui-input" autocomplete="off">
+					</div>
+				</div>
+				
+				<!--<div class="layui-inline">-->
+					<!--<label class="layui-form-label">状态:</label>-->
+					<!--<div class="layui-input-inline">-->
+						<!--<select name="status" lay-filter="status">-->
+							<!--<option value=""></option>-->
+							<!--<option value="1">开启</option>-->
+							<!--<option value="0">关闭</option>-->
+						<!--</select>-->
+					<!--</div>-->
+				<!--</div>-->
+			</div>
+			
+			<div class="ns-form-row">
+				<button class="layui-btn ns-bg-color" lay-submit lay-filter="search">筛选</button>
+				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
+			</div>
+		</form>
+	</div>
+</div>
+
+<div class="layui-tab ns-table-tab" lay-filter="bundling_tab">
+	<ul class="layui-tab-title">
+		<li class="layui-this" lay-id="_all">全部</li>
+		<li lay-id="1_open">已开启</li>
+		<li lay-id="0_close">已关闭</li>
+	</ul>
+	<div class="layui-tab-content">
+		
+		<div class="layui-tab-item layui-show">
+			<!-- 列表 -->
+			<table id="activity_list" lay-filter="activity_list"></table>
+		</div>
+		
+	</div>
+</div>
+
+<!-- 状态 -->
+<script type="text/html" id="status">
+	{{ d.status == 0 ? '<span style="color: red">关闭</span>' : '<span style="color: green">开启</span>' }}
+</script>
+
+<!-- 操作 -->
+<script type="text/html" id="operation">
+	<div class="ns-table-btn">
+		<a class="layui-btn" lay-event="detail">详情</a>
+		<a class="layui-btn" lay-event="delete">删除</a>
+	</div>
+</script>
+{/block}
+{block name="script"}
+<script>
+    layui.use(['form','element'], function() {
+        var table,
+			element = layui.element,
+            form = layui.form;
+
+		form.render();
+	
+		//监听Tab切换,以改变地址hash值
+		element.on('tab(bundling_tab)', function(){
+			var id = this.getAttribute('lay-id');
+			location.hash = 'bundling_tab='+ id;
+			var status = id.split("_")[0];
+			table.reload({
+				page: {
+					curr: 1
+				},
+				where: { status : status }
+			});
+		});
+		
+        table = new Table({
+			elem: '#activity_list',
+			url: ns.url("bundling://admin/bundling/lists"),
+            cols: [
+                [{
+                	field: 'bl_name',
+                	title: '名称',
+                	unresize: 'false',
+                	width: '20%'
+                },{
+					field: 'site_name',
+					title: '店铺名称',
+					unresize: 'false',
+					width: '10%'
+				}, {
+                	field: 'bl_price',
+                	title: '商品优惠价格',
+                	unresize: 'false',
+                	width: '15%',
+					align: 'right',
+					templet: function(data) {
+						return '<span>¥'+ data.bl_price +'</span>';
+					}
+                }, {
+                	field: 'goods_money',
+                	title: '<span style="padding-right: 15px;">商品总价</span>',
+                	unresize: 'false',
+                	width: '15%',
+					align: 'right',
+					templet: function(data) {
+						return '<span style="padding-right: 15px;">¥'+ data.goods_money +'</span>';
+					}
+                }, {
+                	title: '状态',
+                	unresize: 'false',
+                	width: '10%',
+                	templet: '#status'
+                }, {
+                	field: 'update_time',
+                	title: '创建时间',
+                	unresize: 'false',
+                	width: '15%',
+                	templet: function(data) {
+                		return ns.time_to_date(data.update_time);
+                	}
+                }, {
+                	title: '操作',
+                	toolbar: '#operation',
+                	unresize: 'false',
+                	width: '15%'
+                }]
+            ]
+        });
+
+        /**
+         * 监听工具栏操作
+         */
+        table.tool(function(obj) {
+            var data = obj.data;
+            switch (obj.event) {
+                case 'detail': //详情
+                    location.href = ns.url("bundling://admin/bundling/detail?bl_id=" + data.bl_id + "&site_id=" +data.site_id);
+                    break;
+
+				case 'delete': //删除
+					deleteBunding(data.bl_id, data.site_id);
+            }
+        });
+
+        //删除组合套餐
+        function deleteBunding(bl_id, site_id){
+			$.ajax({
+				url: ns.url("bundling://admin/bundling/delete"),
+				data: {bl_id, site_id},
+				dataType: 'JSON',
+				type: 'POST',
+				async: false,
+				success: function(res) {
+					layer.msg(res.message);
+					if(res.code == 0){
+						table.reload();
+					}
+				}
+			});
+		}
+
+        /**
+         * 搜索功能
+         */
+        form.on('submit(search)', function(data) {
+            table.reload({
+                page: {
+                    curr: 1
+                },
+                where: data.field
+            });
+			return false;
+        });
+    });
+</script>
+{/block}

+ 53 - 0
addon/bundling/api/controller/Bundling.php

@@ -0,0 +1,53 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+
+namespace addon\bundling\api\controller;
+
+use app\api\controller\BaseApi;
+use addon\bundling\model\Bundling as BundlingModel;
+
+/**
+ * 组合套餐
+ */
+class Bundling extends BaseApi
+{
+	/**
+	 * sku所关联有关组合套餐
+	 * @return string
+	 */
+	public function lists()
+	{
+		$sku_id = isset($this->params['sku_id']) ? $this->params['sku_id'] : 0;
+		if (empty($sku_id)) {
+			return $this->response($this->error('', 'REQUEST_SKU_ID'));
+		}
+		$bundling_model = new BundlingModel();
+		$info = $bundling_model->getBundlingGoods($sku_id);
+		return $this->response($info);
+	}
+	
+	/**
+	 * 详情信息
+	 */
+	public function detail()
+	{
+		$bl_id = isset($this->params['bl_id']) ? $this->params['bl_id'] : 0;
+		if (empty($bl_id)) {
+			return $this->response($this->error('', 'REQUEST_BL_ID'));
+		}
+		$bundling_model = new BundlingModel();
+		$info = $bundling_model->getBundlingDetail([ [ 'bl_id', '=', $bl_id ] ]);
+		return $this->response($info);
+		
+	}
+	
+}

+ 108 - 0
addon/bundling/api/controller/Ordercreate.php

@@ -0,0 +1,108 @@
+<?php
+/**
+ * Index.php
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2015-2025 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: http://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ * @author : niuteam
+ * @date : 2015.1.17
+ * @version : v1.0.0.0
+ */
+
+namespace addon\bundling\api\controller;
+
+use app\api\controller\BaseApi;
+use addon\bundling\model\BundlingOrderCreate as OrderCreateModel;
+
+/**
+ * 订单创建
+ * @author Administrator
+ *
+ */
+class Ordercreate extends BaseApi
+{
+	/**
+	 * 创建订单
+	 */
+	public function create()
+	{
+		$token = $this->checkToken();
+		if ($token['code'] < 0) return $this->response($token);
+		$order_create = new OrderCreateModel();
+		$data = [
+			'bl_id' => isset($this->params['bl_id']) ? $this->params['bl_id'] : '',//组合套餐id
+			'num' => isset($this->params['num']) ? $this->params['num'] : 1,//组合套餐数量(买几套)
+			'member_id' => $this->member_id,
+			'order_from' => $this->params['app_type'],
+			'order_from_name' => $this->params['app_type_name'],
+            'is_balance' => isset($this->params['is_balance']) ? $this->params['is_balance'] : 0,//是否使用余额
+            'pay_password' => isset($this->params['pay_password']) ? $this->params['pay_password'] : '',//支付密码
+            'buyer_message' => $this->params['buyer_message'],
+			'delivery' => isset($this->params["delivery"]) && !empty($this->params["delivery"]) ? json_decode($this->params["delivery"], true) : [],
+			'coupon' => isset($this->params["coupon"]) && !empty($this->params["coupon"]) ? json_decode($this->params["coupon"], true) : [],
+			'member_address' => isset($this->params["member_address"]) && !empty($this->params["member_address"]) ? json_decode($this->params["member_address"], true) : []
+		];
+		if (empty($data['bl_id'])) {
+			return $this->response($this->error('', '缺少必填参数商品数据'));
+		}
+		$res = $order_create->create($data);
+		return $this->response($res);
+	}
+	
+	/**
+	 * 计算信息
+	 */
+	public function calculate()
+	{
+		$token = $this->checkToken();
+		if ($token['code'] < 0) return $this->response($token);
+		$order_create = new OrderCreateModel();
+		$data = [
+			'bl_id' => isset($this->params['bl_id']) ? $this->params['bl_id'] : '',//组合套餐id
+			'num' => isset($this->params['num']) ? $this->params['num'] : 1,//组合套餐数量(买几套)
+			'member_id' => $this->member_id,
+			'order_from' => $this->params['app_type'],
+			'order_from_name' => $this->params['app_type_name'],
+            'is_balance' => isset($this->params['is_balance']) ? $this->params['is_balance'] : 0,//是否使用余额
+			'delivery' => isset($this->params["delivery"]) && !empty($this->params["delivery"]) ? json_decode($this->params["delivery"], true) : [],
+			'coupon' => isset($this->params["coupon"]) && !empty($this->params["coupon"]) ? json_decode($this->params["coupon"], true) : [],
+			'member_address' => isset($this->params["member_address"]) && !empty($this->params["member_address"]) ? json_decode($this->params["member_address"], true) : []
+		];
+		if (empty($data['bl_id'])) {
+			return $this->response($this->error('', '缺少必填参数商品数据'));
+		}
+		$res = $order_create->calculate($data);
+		return $this->response($this->success($res));
+		
+	}
+	
+	/**
+	 * 待支付订单 数据初始化
+	 * @return string
+	 */
+	public function payment()
+	{
+		$token = $this->checkToken();
+		if ($token['code'] < 0) return $this->response($token);
+		$order_create = new OrderCreateModel();
+		$data = [
+			'bl_id' => isset($this->params['bl_id']) ? $this->params['bl_id'] : '',
+			'num' => isset($this->params['num']) ? $this->params['num'] : '',
+			'member_id' => $this->member_id,
+			'order_from' => $this->params['app_type'],
+            'is_balance' => isset($this->params['is_balance']) ? $this->params['is_balance'] : 0,//是否使用余额
+			'order_from_name' => $this->params['app_type_name']
+		];
+		if (empty($data['bl_id'])) {
+			return $this->response($this->error('', '缺少必填参数商品数据'));
+		}
+		$res = $order_create->orderPayment($data);
+		return $this->response($this->success($res));
+	}
+	
+}

+ 23 - 0
addon/bundling/config/diy_view.php

@@ -0,0 +1,23 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+return [
+    
+	'diy' => [
+		'view' => [
+		],
+		'util' => [
+		],
+		'link' => [
+		],
+	
+	],
+];

+ 20 - 0
addon/bundling/config/event.php

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

+ 20 - 0
addon/bundling/config/info.php

@@ -0,0 +1,20 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+return [
+		'name' => 'bundling',
+		'title' => '组合套餐',
+		'description' => '组合套餐活动功能',
+		'status' => 1,
+		'author' => '',
+		'version' => '1.0',
+		'content' => '',
+];

+ 35 - 0
addon/bundling/config/menu_admin.php

@@ -0,0 +1,35 @@
+<?php
+// +----------------------------------------------------------------------
+// | 平台端菜单设置
+// +----------------------------------------------------------------------
+return [
+    [
+        'name' => 'PROMOTION_BUNDLING',
+        'title' => '优惠套餐',
+        'url' => 'bundling://admin/bundling/lists',
+        'parent' => 'PROMOTION_SHOP',
+        'is_show' =>0,
+        'is_control' => 0,
+        'is_icon' => 0,
+        'picture' => '',
+        'picture_select' => '',
+        'sort' => 100,
+        'child_list' => [
+            [
+                'name' => 'PROMOTION_BUNDLING_DELETE',
+                'title' => '删除套餐',
+                'url' => 'bundling://admin/bundling/delete',
+                'sort'    => 1,
+                'is_show' => 0
+            ],
+            [
+                'name' => 'PROMOTION_BUNDLING_DETAIL',
+                'title' => '套餐详情',
+                'url' => 'bundling://admin/bundling/detail',
+                'sort'    => 1,
+                'is_show' => 0
+            ],
+        
+        ]
+    ],
+];

+ 49 - 0
addon/bundling/config/menu_shop.php

@@ -0,0 +1,49 @@
+<?php
+// +----------------------------------------------------------------------
+// | 平台端菜单设置
+// +----------------------------------------------------------------------
+return [
+    [
+        'name' => 'PROMOTION_BUNDLING',
+        'title' => '优惠套餐',
+        'url' => 'bundling://shop/bundling/lists',
+        'parent' => 'PROMOTION_CENTER',
+        'is_show' => 0,
+        'is_control' => 1,
+        'is_icon' => 0,
+        'picture' => '',
+        'picture_select' => '',
+        'sort' => 100,
+        'child_list' => [
+            [
+                'name' => 'PROMOTION_BUNDLING_DETAIL',
+                'title' => '套餐详情',
+                'url' => 'bundling://shop/bundling/detail',
+                'sort'    => 1,
+                'is_show' => 0
+            ],
+            [
+                'name' => 'PROMOTION_BUNDLING_ADD',
+                'title' => '添加套餐',
+                'url' => 'bundling://shop/bundling/add',
+                'sort'    => 1,
+                'is_show' => 0
+            ],
+            [
+                'name' => 'PROMOTION_BUNDLING_EDIT',
+                'title' => '编辑套餐',
+                'url' => 'bundling://shop/bundling/edit',
+                'sort'    => 1,
+                'is_show' => 0
+            ],
+            [
+                'name' => 'PROMOTION_BUNDLING_DELETE',
+                'title' => '删除套餐',
+                'url' => 'bundling://shop/bundling/delete',
+                'sort'    => 1,
+                'is_show' => 0
+            ],
+        
+        ]
+    ],
+];

+ 1 - 0
addon/bundling/data/install.sql

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

+ 1 - 0
addon/bundling/data/uninstall.sql

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

+ 34 - 0
addon/bundling/event/Install.php

@@ -0,0 +1,34 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+declare (strict_types = 1);
+
+namespace addon\bundling\event;
+
+/**
+ * 应用安装
+ */
+class Install
+{
+	/**
+	 * 执行安装
+	 */
+	public function handle()
+	{
+	    try{
+	        execute_sql('addon/bundling/data/install.sql');
+	        return success();
+	    }catch (\Exception $e)
+	    {
+	        return error('', $e->getMessage());
+	    }
+	}
+}

+ 30 - 0
addon/bundling/event/PromotionType.php

@@ -0,0 +1,30 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+declare (strict_types = 1);
+
+namespace addon\bundling\event;
+
+/**
+ * 活动
+ */
+class PromotionType
+{
+
+	/**
+	 * 活动类型
+	 * @return multitype:number unknown
+	 */
+	public function handle()
+	{
+	    return ["name" => "组合套餐", "type" => "bunding"];
+	}
+}

+ 66 - 0
addon/bundling/event/ShowPromotion.php

@@ -0,0 +1,66 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+declare (strict_types = 1);
+
+namespace addon\bundling\event;
+
+/**
+ * 店铺活动
+ */
+class ShowPromotion
+{
+
+	/**
+	 * 活动展示
+	 *
+	 * @return multitype:number unknown
+	 */
+	public function handle()
+	{
+	    $data = [
+	        'admin' => [
+	            [
+	                //插件名称
+	                'name' => 'bundling',
+	                //展示分类(根据平台端设置,admin(平台营销),shop:店铺营销,member:会员营销, tool:应用工具)
+	                'show_type' => 'shop',
+	                //展示主题
+	                'title' => '组合套餐',
+	                //展示介绍
+	                'description' => '组合套餐活动功能',
+	                //展示图标
+	                'icon' => 'addon/bundling/icon.png',
+	                //跳转链接
+	                'url' => 'bundling://admin/bundling/lists',
+	            ]
+	        ],
+	        'shop' => [
+	            [
+	                //插件名称
+	                'name' => 'bundling',
+	                //展示分类(根据平台端设置,admin(平台营销),shop:店铺营销,member:会员营销, tool:应用工具)
+	                'show_type' => 'shop',
+	                //展示主题
+	                'title' => '组合套餐',
+	                //展示介绍
+	                'description' => '组合套餐活动功能',
+	                //展示图标
+	                'icon' => 'addon/bundling/icon.png',
+	                //跳转链接
+	                'url' => 'bundling://shop/bundling/lists',
+	            ]
+	        ]
+	
+	    ];
+	    return $data;
+	}
+}

+ 34 - 0
addon/bundling/event/UnInstall.php

@@ -0,0 +1,34 @@
+<?php
+/**
+ * Niushop商城系统 - 团队十年电商经验汇集巨献!
+ * =========================================================
+ * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
+ * ----------------------------------------------
+ * 官方网址: https://www.niushop.com.cn
+ * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
+ * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
+ * =========================================================
+ */
+declare (strict_types = 1);
+
+namespace addon\bundling\event;
+
+/**
+ * 应用卸载
+ */
+class UnInstall
+{
+	/**
+	 * 执行卸载
+	 */
+	public function handle()
+	{
+	    try{
+	        execute_sql('addon/bundling/data/uninstall.sql');
+	        return success();
+	    }catch (\Exception $e)
+	    {
+	        return error('', $e->getMessage());
+	    }
+	}
+}

二進制
addon/bundling/icon.png


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