diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d465120
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+/.idea
+/.vscode
+/vendor
+*.log
+.env
\ No newline at end of file
diff --git a/.htaccess b/.htaccess
new file mode 100644
index 0000000..0519ecb
--- /dev/null
+++ b/.htaccess
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..36f7b6f
--- /dev/null
+++ b/.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
diff --git a/.user.ini b/.user.ini
new file mode 100644
index 0000000..2df6812
--- /dev/null
+++ b/.user.ini
@@ -0,0 +1 @@
+open_basedir=/www/wwwroot/qianjiang.test/:/tmp/
\ No newline at end of file
diff --git a/404.html b/404.html
new file mode 100644
index 0000000..6096254
--- /dev/null
+++ b/404.html
@@ -0,0 +1,16 @@
+
+
+
+
+
404 Not Found
+
+404 Not Found
+
+
+
+
\ No newline at end of file
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..574a39c
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,32 @@
+
+ThinkPHP遵循Apache2开源协议发布,并提供免费使用。
+版权所有Copyright © 2006-2016 by ThinkPHP (http://thinkphp.cn)
+All rights reserved。
+ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。
+
+Apache Licence是著名的非盈利开源组织Apache采用的协议。
+该协议和BSD类似,鼓励代码共享和尊重原作者的著作权,
+允许代码修改,再作为开源或商业软件发布。需要满足
+的条件:
+1. 需要给代码的用户一份Apache Licence ;
+2. 如果你修改了代码,需要在被修改的文件中说明;
+3. 在延伸的代码中(修改和有源代码衍生的代码中)需要
+带有原来代码中的协议,商标,专利声明和其他原来作者规
+定需要包含的说明;
+4. 如果再发布的产品中包含一个Notice文件,则在Notice文
+件中需要带有本协议内容。你可以在Notice中增加自己的
+许可,但不可以表现为对Apache Licence构成更改。
+具体的协议参考:http://www.apache.org/licenses/LICENSE-2.0
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
diff --git a/Secret/apiclient_cert.pem b/Secret/apiclient_cert.pem
new file mode 100644
index 0000000..731654f
--- /dev/null
+++ b/Secret/apiclient_cert.pem
@@ -0,0 +1,24 @@
+-----BEGIN CERTIFICATE-----
+MIIEFDCCAvygAwIBAgIUcs0exYuNylTgN1OxWDReflL7vjkwDQYJKoZIhvcNAQEL
+BQAwXjELMAkGA1UEBhMCQ04xEzARBgNVBAoTClRlbnBheS5jb20xHTAbBgNVBAsT
+FFRlbnBheS5jb20gQ0EgQ2VudGVyMRswGQYDVQQDExJUZW5wYXkuY29tIFJvb3Qg
+Q0EwHhcNMjUwODA0MDY0MjI0WhcNMzAwODAzMDY0MjI0WjBuMRgwFgYDVQQDDA9U
+ZW5wYXkuY29tIHNpZ24xEzARBgNVBAoMClRlbnBheS5jb20xHTAbBgNVBAsMFFRl
+bnBheS5jb20gQ0EgQ2VudGVyMQswCQYDVQQGEwJDTjERMA8GA1UEBwwIU2hlblpo
+ZW4wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDl9u/PGIJKGPbF17xI
+MnjUCnEn4IflbIXLSxdLlGAi4XBrjyllAOxIY7sIGMxfpnULmU6VJV0oI+7/SnWQ
+fBX9jdQrucvgRAH80ZpItwwTh76+dSsJZo7TFuHG5vYWc0eo518Zrhf1zh5T0G1e
+NUPdV8hTBuu+JKcuWVXmpPEVmBzL5iVx8RnziCBSvC/Fpt1VZd+izwkNGZredsTM
+IJdQeU+v4fpgWyVOCISob9B0nvku3d33zckdoDwPqFnVoh1oPzTS2lKYx6NMGW6i
+HwV1PJ7DSBSTzE80vwkdavMl17WnJaMzAzcTL99xBCqKjE8EG1dzTqYHaJRwvWhP
+TGq7AgMBAAGjgbkwgbYwCQYDVR0TBAIwADALBgNVHQ8EBAMCA/gwgZsGA1UdHwSB
+kzCBkDCBjaCBiqCBh4aBhGh0dHA6Ly9ldmNhLml0cnVzLmNvbS5jbi9wdWJsaWMv
+aXRydXNjcmw/Q0E9MUJENDIyMEU1MERCQzA0QjA2QUQzOTc1NDk4NDZDMDFDM0U4
+RUJEMiZzZz1IQUNDNDcxQjY1NDIyRTEyQjI3QTlEMzNBODdBRDFDREY1OTI2RTE0
+MDM3MTANBgkqhkiG9w0BAQsFAAOCAQEAbVCzA5IewRfqGr3jOBdkFf3bssokI7im
+XuXEhXYO3s6xZfma9kIoRTZjVyWXTJnVDMX/w+RM+S799b1jhzvBIzsfU+uwSOH5
+uSNyew3FVK15y408bSQDNbjc5X8G48ofRIELKy6vQQkXw+M/lXUmjktriTZazUdt
+ukzaCIErQjHR9dCE5GFVa5okLMUU77ct3ArFhC4Dxr7VOZLYLGI4ioJb8wFFcDXU
++J7RPIkE3Ze+/Yx20PEbfO89BHSBXYNe94n9Ug69dm/hu+qZtrVM2EVasDIw6H1F
+mrHBYjKmrh2UAl5uLUTbD9poJ2qYEVAIe1FA7fug3ycDV7y8UYKYSQ==
+-----END CERTIFICATE-----
\ No newline at end of file
diff --git a/Secret/apiclient_cert_refund.pem b/Secret/apiclient_cert_refund.pem
new file mode 100644
index 0000000..4eb43f2
--- /dev/null
+++ b/Secret/apiclient_cert_refund.pem
@@ -0,0 +1,24 @@
+-----BEGIN CERTIFICATE-----
+MIID8DCCAtigAwIBAgIUH7Y1TUd7+JzGrQR0TYDd7/ajm6cwDQYJKoZIhvcNAQEL
+BQAwXjELMAkGA1UEBhMCQ04xEzARBgNVBAoTClRlbnBheS5jb20xHTAbBgNVBAsT
+FFRlbnBheS5jb20gQ0EgQ2VudGVyMRswGQYDVQQDExJUZW5wYXkuY29tIFJvb3Qg
+Q0EwHhcNMjIxMjExMDgyNzM3WhcNMjcxMjEwMDgyNzM3WjCBgTETMBEGA1UEAwwK
+MTYzNTcxOTA4MzEbMBkGA1UECgwS5b6u5L+h5ZWG5oi357O757ufMS0wKwYDVQQL
+DCTph43luobotrPlhbTnva7kuJrogqHku73mnInpmZDlhazlj7gxCzAJBgNVBAYM
+AkNOMREwDwYDVQQHDAhTaGVuWmhlbjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
+AQoCggEBAKUtam4ZW8SsGCbx3aCRKN0L7BRozJ1TnHdIECrppMcQSbxqIhObOQ2o
+5UiGW57J1TH8l74F9yQgCAI0ux99Gyp27LCeG7R08HAnthzDtRV5IAQJunG9Fv4Q
+7nro/Woy906i9qKvfT5att2XkhoXnIzb8BzzvXcG5U7Bsuw5qRX2DD7HGvr8Yg42
+0+wAxWHuqFnZdejEFzFRtvT0mQlmnHfMDo3gs82QIqVKY5EaPffoj8FvnluvH37d
+/A/rkPWBRfqBpJKIijXEGdbvYIKIBGXchjrIDl0sen0aS1bAWU7NN54FV328U/D+
+4gal8R5UUoiqNgxMtCR9kyqVBzYkjoMCAwEAAaOBgTB/MAkGA1UdEwQCMAAwCwYD
+VR0PBAQDAgP4MGUGA1UdHwReMFwwWqBYoFaGVGh0dHA6Ly9ldmNhLml0cnVzLmNv
+bS5jbi9wdWJsaWMvaXRydXNjcmw/Q0E9MUJENDIyMEU1MERCQzA0QjA2QUQzOTc1
+NDk4NDZDMDFDM0U4RUJEMjANBgkqhkiG9w0BAQsFAAOCAQEAhPzKzTKIhxRDRJdQ
+CQu1AX982goLsHe5jcakCuHThzA0c3hs25iCXE4gIpLPwRr6lwaj9tYYs518xjfk
+/HbtvnCHlCu0ZEPau2Y4ffpbq0M0vcU3y7YMnEqZ4qbDiBXCqcgBAz2PoRpJCd5a
+580wetHYn3zF4YnbpZR26K8H5JGlEcuWHSyeuZmidtd0WanZwtXUX27f8WYPfhIq
+JhsVpIyJCoFS1vvc6XAnJ4tdfgJTUeb0WGRfmqHp9LBB6CZkah/jQ9tcp4RRVntU
+oO01aWOof9LTUVRKDpKelvgEsEIDaU5vr8kzpmnFrFA0F2UBX+rPas7zhxzgIl3k
+sf4LFQ==
+-----END CERTIFICATE-----
diff --git a/Secret/apiclient_key.pem b/Secret/apiclient_key.pem
new file mode 100644
index 0000000..7ee7079
--- /dev/null
+++ b/Secret/apiclient_key.pem
@@ -0,0 +1,28 @@
+-----BEGIN PRIVATE KEY-----
+MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC6OSmgvo266Fe6
+M/PJQdsMUTuyxmdpoDQRS9iQShue7liQVy8MJBljM3Xxw63455fDopHPXWpQRk6O
+WJoQU9avtUXFlhlS8i52sGiYJKzoUrSWupdOVkxAuuRYgPo72TTUcZfeZA17kSkd
+yHhkot4TnlZVhu5ubBhNMPlp0pMgUojxLeTT00hQXBD86zhu0WKyYQ93jifyk13I
+LeBjTNMOJrvcr9LJR8f3Fk5bzBbBSwcTS/JViXR1N5hZjTHGDaecYhYcpLQPn/hp
+WLb775mbwS9cdx/BvVphdaWb9U8QRz+00fhFvOBGppxZdZ7YQpNfBXjLOcdN4T9j
+tHXWc+KbAgMBAAECggEAUvF+7w+whN1TpaXaIXvpmrTbyCbCjLNEPafwj2PSpZk3
+bSLH27qAbETRdZtYc5KDcCmKlDfhUFvgRVqFVFxjNOOibf0Kznz74PV1wL4lHV0o
+/jGhjsy1LeeQKTNZQSrfcvgdUnpx3uWq0I8nwHsiOs69WV69+ATBVjBIBrA5w5z8
+jxNmpk6rCr7ey3dwC4XUi8fs16WtZLZGROkrRh+ze1Wgo1/yYU44+DeGkmQOxhDJ
+Vfvx6ki0ieq83nNFve6ZgRyDM9RWjToBSrtY2ARZSDAd6DqrGYXCM5h3zLqgJ/4z
+FmyEtHMPc8rS+piEnIMlt86tq6+GNRZnzEH1ECd58QKBgQDljB8ftuAHE9MKmTuq
+QtShCdbDuHwE2UGmE5ZC80ursZg6kDznOayZfrrhC++P8JO09lVJKDzGjZVKUBW7
+Ic/BuG+vPuFfsJ4E9j2zGeHJMezjRphjzLKT+eOCyQ9bv7G8DTk4SS9lllPa6sUH
+JP8+TovRTk5nFcofdkLcrxfHNwKBgQDPrvAGOZ3x2rtIJRUin8WKBip8TTHpMfLZ
+7wGXcehobUNGcTnGsqnysGlUWlhQxc9WrzPyhz2R57Xj8W9tpoBhaVKkdvIxnDNf
+9vexXJjlnWcktFvWUYq3Tt5ImFPeEW+eK4m1Qs2tbNxsGqir3Mzqf7rEq/guYcK2
+l6yOl/IpvQKBgHFZkfztJw8XoPz40devjKPA4gZf0Q3r4lkKDwcccN9loRA6LXjY
+p/xb8hgy9qcTWzze7xpi/i/ltjSt+y0e8yJr2uqkmFHSOxWkKq+INlBNkPZh49pU
+OFKN8OSiOC1MKY380aaTrQ3y/5F4oLZ4dHnl+3DtxBVvUxHaKgYjiBBdAoGAH6X1
+98zh79A4R/c2sE8OqEjmQoj0+Sdeba2JXY3DL96uqNZqSohBc7VEZ9FYsf5i6T/L
+t8K6NDjONA0/wMLlv3JwYJWrtLmr7ozRFBsbRapl5GcDs7Y7YFHJd+CWrzmS+9SA
+qLmkZDA5qtOpLn94TqfmS0A1ksPdCzwz1Ir9ITUCgYEAsRSlbFVAESL3ztFvFXqi
+acvuYKpiIcBrKN2YrxvhEoT9splS98hDqIibfBCCFmModdX++kIOOfjfc7mZLNt6
+uF9gHexgIa1KNI9bykFVT1XlCzBpm+C6hdMjp0Ya5pR88KYAsjOGBrlNUfpSvUn+
+QTrLtSXCSC0mYsspfrQjNLA=
+-----END PRIVATE KEY-----
diff --git a/Secret/apiclient_key_refund.pem b/Secret/apiclient_key_refund.pem
new file mode 100644
index 0000000..495895e
--- /dev/null
+++ b/Secret/apiclient_key_refund.pem
@@ -0,0 +1,28 @@
+-----BEGIN PRIVATE KEY-----
+MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQClLWpuGVvErBgm
+8d2gkSjdC+wUaMydU5x3SBAq6aTHEEm8aiITmzkNqOVIhlueydUx/Je+BfckIAgC
+NLsffRsqduywnhu0dPBwJ7Ycw7UVeSAECbpxvRb+EO566P1qMvdOovair30+Wrbd
+l5IaF5yM2/Ac8713BuVOwbLsOakV9gw+xxr6/GIONtPsAMVh7qhZ2XXoxBcxUbb0
+9JkJZpx3zA6N4LPNkCKlSmORGj336I/Bb55brx9+3fwP65D1gUX6gaSSiIo1xBnW
+72CCiARl3IY6yA5dLHp9GktWwFlOzTeeBVd9vFPw/uIGpfEeVFKIqjYMTLQkfZMq
+lQc2JI6DAgMBAAECggEAd8h1lB4jpH5AjY18cUKTZamNrEdLixPlNcM2pkgFTK6N
+Kmu1Bo7cUwGWNH/q1T38s2FAEXd1/+aSqDbhNDafiq3vey1NXhIngs3pjPaHzWin
+RQZhBLZhhCF3L/7iNy96lLYtMVEd/CgA0LVoKC/TQXsFp5lCXpzLkc96F0DBU8CN
+9ZKvVQLakgi6tKeZMKazSSIojJQypRCeayfbXGh8CEpkrYk0qm0wz/VYy8wLmdIP
+2IzYU8gCrl+U55OzXzjSh0xJ+TQyEwOnq0xpui//siYUJ7aIppiUo5EqOMljSoEy
+EZ3TwVjbIhMKP/2ejG9GHQrfCo288JxPtFm43wUooQKBgQDZEfie3482p7k6RDHi
+BunvyDIBFSy9nwzg8z9khg9cTXNb0LWhDnTx2nswlBTfAGtJsW/QoWIU0bFb2m9x
+4LbhXmq7JxR7mUxQRSJl8a4N2ujOjIyEXnvOQ4cIb2DMRHPORAZmL2EeoDB3Z1Vx
+uH5TdNtE/YgiSPcKFN5wIS5xewKBgQDCzPdPTbxPhIIT7BNJe5M/r3oXvk93Kz1J
+bitfN0tw5gWA5HVMZ+YuNhYoPdD8H+7mGogT9vOO6eEJA4FiYuImIBkaRzvC0Pdp
+esR5KuAM6uim5bXHZSri6HoNtOzWzdhebF1OoG7QCH8lijt3O0XGTTv0JFIOEaSB
+IXhALrV0mQKBgQCU+Mlot0LBHrB3NXAKj/YisoDmz1JqPGqJQ0dBROPr09eUrpLI
+GnTVuryKpUYBmXcIFzcGtorqgNK4mBudyruXxcV39aUQAjAmcpvd3NQ3/AGEJ18U
+RQewkhVtC4siBOR5LaQ6os+DRiqc95TjO9uuiOcm3Nx9sxefmpzh1VPbWwKBgE88
+EagHJX5uln5F+v5brmQsGwxHU4lUZCRXFHsxQZVVao2n33JJnJ3VUCPkKPo0fvbH
+eews+Zp61RbWfy0mrXf2fF9s9Ajk+I3F6t6iKun2LtWb/9lv9AbBqsuieOdSaRzX
+FQjjRs+FdTouxMtVp6bmSWmf0GR6lqATnhb1KMeZAoGBALDJs/BAbATJw+0VywNr
+VAVaxOwo56RHQhhsunlB38zOmyIfqORRFf763I4XJO6vqPwyB4gAPeZnhK00MNZM
+Gj3S2e/6Rk15IHBIwHtohVThohVkfHxi+Ur6g2uPcLmmqDDs0JYa5rb2F1jmZyqB
+day2luUTLrEgyN9C7l3485xS
+-----END PRIVATE KEY-----
diff --git a/Secret/serial_no.txt b/Secret/serial_no.txt
new file mode 100644
index 0000000..9d35707
--- /dev/null
+++ b/Secret/serial_no.txt
@@ -0,0 +1 @@
+72CD1EC58B8DCA54E03753B158345E7E52FBBE39
\ No newline at end of file
diff --git a/Secret/tuikuan/apiclient_cert.pem b/Secret/tuikuan/apiclient_cert.pem
new file mode 100644
index 0000000..7f1adc8
--- /dev/null
+++ b/Secret/tuikuan/apiclient_cert.pem
@@ -0,0 +1,23 @@
+-----BEGIN CERTIFICATE-----
+MIID3DCCAsSgAwIBAgIUVAQmj1R5uFWRh/1boS5cYUiOe7wwDQYJKoZIhvcNAQEL
+BQAwXjELMAkGA1UEBhMCQ04xEzARBgNVBAoTClRlbnBheS5jb20xHTAbBgNVBAsT
+FFRlbnBheS5jb20gQ0EgQ2VudGVyMRswGQYDVQQDExJUZW5wYXkuY29tIFJvb3Qg
+Q0EwHhcNMjIxMjExMDgyNzM2WhcNMjcxMjEwMDgyNzM2WjBuMRgwFgYDVQQDDA9U
+ZW5wYXkuY29tIHNpZ24xEzARBgNVBAoMClRlbnBheS5jb20xHTAbBgNVBAsMFFRl
+bnBheS5jb20gQ0EgQ2VudGVyMQswCQYDVQQGDAJDTjERMA8GA1UEBwwIU2hlblpo
+ZW4wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDbalMD21zc8eQ9wDs6
+r1IVx8ZazD+qX2JWpW/dq4f4vOlyf+sUuvge1t30yA9zjzb93RORdsgBc2kxyS7v
+6oXGU69xWstg5WNUKzokpWTYIZm+g5hZsV4KaoFuFfCQ6NrvwgwVbGZNhmuHodeo
+ZoWdyo0lEynnHMVEFl5AzCWAehovLDCIsQjYH/z5CzFjBDlmAKDXE+cqanGmKD80
+ux7B2jKhaFVXa3VBW3vVjLkpyGWLmvvqpW9cMWI/YAH+W7kCNsG9Ukz6ZppF7CIn
+//RmTyIXIdzrsO6hsfzWgsp17Bz/367DjJoxc61iksq4EThF4cMLOXwQ/9dsFbQ+
+feyXAgMBAAGjgYEwfzAJBgNVHRMEAjAAMAsGA1UdDwQEAwID+DBlBgNVHR8EXjBc
+MFqgWKBWhlRodHRwOi8vZXZjYS5pdHJ1cy5jb20uY24vcHVibGljL2l0cnVzY3Js
+P0NBPTFCRDQyMjBFNTBEQkMwNEIwNkFEMzk3NTQ5ODQ2QzAxQzNFOEVCRDIwDQYJ
+KoZIhvcNAQELBQADggEBADd25dsExQ5bZpHOBHFu+lariGlYZIMpOjPIG4nHEfVO
+J4fbBwtDocO413qM++ZsiZnSR6JxUhbsupDRM6sWazksYzt2eBrcFJ4PhGvOlObM
+pj6PLlPpUKfMfnTFeaM2NNnwLcw63mWVOf63l7NSIGHsdrsjiBk1xrCr8HQQWkJN
+jTvwBbhumkkS1kRa6B4lVv8MXQzZ/p5CVUAsJ7sneWynsZYKpJnihSxjDZx7e88X
+THv3AeWH6JJTE+x5K06hUjb0v2UeTY6c7kM8Akzx1scvG78GXMcXtl93sqI6T142
+pK9rNs3NbvQ9XyckXSeOLahDJlzzNMBLjxeWVbqET9g=
+-----END CERTIFICATE-----
\ No newline at end of file
diff --git a/Secret/tuikuan/apiclient_key.pem b/Secret/tuikuan/apiclient_key.pem
new file mode 100644
index 0000000..495895e
--- /dev/null
+++ b/Secret/tuikuan/apiclient_key.pem
@@ -0,0 +1,28 @@
+-----BEGIN PRIVATE KEY-----
+MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQClLWpuGVvErBgm
+8d2gkSjdC+wUaMydU5x3SBAq6aTHEEm8aiITmzkNqOVIhlueydUx/Je+BfckIAgC
+NLsffRsqduywnhu0dPBwJ7Ycw7UVeSAECbpxvRb+EO566P1qMvdOovair30+Wrbd
+l5IaF5yM2/Ac8713BuVOwbLsOakV9gw+xxr6/GIONtPsAMVh7qhZ2XXoxBcxUbb0
+9JkJZpx3zA6N4LPNkCKlSmORGj336I/Bb55brx9+3fwP65D1gUX6gaSSiIo1xBnW
+72CCiARl3IY6yA5dLHp9GktWwFlOzTeeBVd9vFPw/uIGpfEeVFKIqjYMTLQkfZMq
+lQc2JI6DAgMBAAECggEAd8h1lB4jpH5AjY18cUKTZamNrEdLixPlNcM2pkgFTK6N
+Kmu1Bo7cUwGWNH/q1T38s2FAEXd1/+aSqDbhNDafiq3vey1NXhIngs3pjPaHzWin
+RQZhBLZhhCF3L/7iNy96lLYtMVEd/CgA0LVoKC/TQXsFp5lCXpzLkc96F0DBU8CN
+9ZKvVQLakgi6tKeZMKazSSIojJQypRCeayfbXGh8CEpkrYk0qm0wz/VYy8wLmdIP
+2IzYU8gCrl+U55OzXzjSh0xJ+TQyEwOnq0xpui//siYUJ7aIppiUo5EqOMljSoEy
+EZ3TwVjbIhMKP/2ejG9GHQrfCo288JxPtFm43wUooQKBgQDZEfie3482p7k6RDHi
+BunvyDIBFSy9nwzg8z9khg9cTXNb0LWhDnTx2nswlBTfAGtJsW/QoWIU0bFb2m9x
+4LbhXmq7JxR7mUxQRSJl8a4N2ujOjIyEXnvOQ4cIb2DMRHPORAZmL2EeoDB3Z1Vx
+uH5TdNtE/YgiSPcKFN5wIS5xewKBgQDCzPdPTbxPhIIT7BNJe5M/r3oXvk93Kz1J
+bitfN0tw5gWA5HVMZ+YuNhYoPdD8H+7mGogT9vOO6eEJA4FiYuImIBkaRzvC0Pdp
+esR5KuAM6uim5bXHZSri6HoNtOzWzdhebF1OoG7QCH8lijt3O0XGTTv0JFIOEaSB
+IXhALrV0mQKBgQCU+Mlot0LBHrB3NXAKj/YisoDmz1JqPGqJQ0dBROPr09eUrpLI
+GnTVuryKpUYBmXcIFzcGtorqgNK4mBudyruXxcV39aUQAjAmcpvd3NQ3/AGEJ18U
+RQewkhVtC4siBOR5LaQ6os+DRiqc95TjO9uuiOcm3Nx9sxefmpzh1VPbWwKBgE88
+EagHJX5uln5F+v5brmQsGwxHU4lUZCRXFHsxQZVVao2n33JJnJ3VUCPkKPo0fvbH
+eews+Zp61RbWfy0mrXf2fF9s9Ajk+I3F6t6iKun2LtWb/9lv9AbBqsuieOdSaRzX
+FQjjRs+FdTouxMtVp6bmSWmf0GR6lqATnhb1KMeZAoGBALDJs/BAbATJw+0VywNr
+VAVaxOwo56RHQhhsunlB38zOmyIfqORRFf763I4XJO6vqPwyB4gAPeZnhK00MNZM
+Gj3S2e/6Rk15IHBIwHtohVThohVkfHxi+Ur6g2uPcLmmqDDs0JYa5rb2F1jmZyqB
+day2luUTLrEgyN9C7l3485xS
+-----END PRIVATE KEY-----
diff --git a/Secret/tuikuan/serial_no.txt b/Secret/tuikuan/serial_no.txt
new file mode 100644
index 0000000..9d35707
--- /dev/null
+++ b/Secret/tuikuan/serial_no.txt
@@ -0,0 +1 @@
+72CD1EC58B8DCA54E03753B158345E7E52FBBE39
\ No newline at end of file
diff --git a/app/.htaccess b/app/.htaccess
new file mode 100644
index 0000000..3418e55
--- /dev/null
+++ b/app/.htaccess
@@ -0,0 +1 @@
+deny from all
\ No newline at end of file
diff --git a/app/AppService.php b/app/AppService.php
new file mode 100644
index 0000000..96556e8
--- /dev/null
+++ b/app/AppService.php
@@ -0,0 +1,22 @@
+app = $app;
+ $this->request = $this->app->request;
+
+ // 控制器初始化
+ $this->initialize();
+ }
+
+ // 初始化
+ protected function initialize()
+ {}
+
+ /**
+ * 验证数据
+ * @access protected
+ * @param array $data 数据
+ * @param string|array $validate 验证器名或者验证规则数组
+ * @param array $message 提示信息
+ * @param bool $batch 是否批量验证
+ * @return array|string|true
+ * @throws ValidateException
+ */
+ protected function validate(array $data, $validate, array $message = [], bool $batch = false)
+ {
+ if (is_array($validate)) {
+ $v = new Validate();
+ $v->rule($validate);
+ } else {
+ if (strpos($validate, '.')) {
+ // 支持场景
+ [$validate, $scene] = explode('.', $validate);
+ }
+ $class = false !== strpos($validate, '\\') ? $validate : $this->app->parseClass('validate', $validate);
+ $v = new $class();
+ if (!empty($scene)) {
+ $v->scene($scene);
+ }
+ }
+
+ $v->message($message);
+
+ // 是否批量验证
+ if ($batch || $this->batchValidate) {
+ $v->batch(true);
+ }
+
+ return $v->failException(true)->check($data);
+ }
+
+}
diff --git a/app/ExceptionHandle.php b/app/ExceptionHandle.php
new file mode 100644
index 0000000..453d126
--- /dev/null
+++ b/app/ExceptionHandle.php
@@ -0,0 +1,58 @@
+setName('reservation:task')->setDescription('Execute the reservation charging task');
+ }
+
+ protected function execute(Input $input, Output $output)
+ {
+ // 在这里可以使用 $this->param1 和 $this->param2 作为传递的参数
+// $EquipAuthSeq = $this->param1;
+// $ConnectorID = $this->param2;
+ // ... 其他代码
+
+// $hard = new HardMessage();
+ $currentDate = new DateTime();
+ $todayDate = $currentDate->format('Y-m-d H:i:s');
+ $nowDay = $currentDate->format('Y-m-d');
+ $PlugOrder = Db::table('appointment')->whereDay('plug_time', $nowDay)->where('plug_time', '<=', $todayDate)->where('IsExec', 1)->select();
+ if (!$PlugOrder->isEmpty()) {
+ foreach ($PlugOrder as $order) {
+ $plug = new PlugCharge();
+ $orderZu = Db::table('charge_order_gongjiao')->whereDay('charge_date', $nowDay)->where('ConnectorID', $order['ConnectorID'])->where('EvcInfoNo', $order['Vin'])->where('Status', 'in', [2, 3])->find();
+ $status = Db::table('charge_pile')->where('ConnectorID', $order['ConnectorID'])->value('status');
+ if (!empty($orderZu)) {
+ Db::table('appointment')->where('id', $order['id'])->save(['IsExec' => 2]);
+ Log::write('Reservation tasks executed successfully. But The ConnectorID status has charged', 'info');
+ } elseif ($status == 3) {
+ Db::table('appointment')->where('id', $order['id'])->save(['IsExec' => 2]);
+ Log::write('Reservation tasks executed successfully. But The ConnectorID status has charged', 'info');
+ } else {
+ $message = $plug->PlugGennerateOrder($order['ConnectorID'], $order['Vin']);
+ if ($message['code'] == 200) {
+ Db::table('appointment')->where('id', $order['id'])->save(['IsExec' => 2]);
+ Log::write('Reservation tasks executed successfully.', 'info');
+ $output->writeln('Reservation tasks executed successfully.');
+ } elseif ($message['code'] == 2) {
+ Db::table('appointment')->where('id', $order['id'])->save(['IsExec' => 2]);
+ Log::write('Reservation tasks executed successfully. But The ConnectorID has charged', 'info');
+ } else {
+ $output->writeln('Reservation tasks executed successfully But StartChargeFailed. The Reason:' . $message['message']);
+ Log::write('Reservation tasks executed successfully But StartChargeFailed. The Reason:' . $message['message']);
+ }
+ }
+ }
+ } else {
+ $output->writeln('Reservation tasks executed successfully But PlugOrderIsEmpty.');
+ Log::write('Reservation tasks executed successfully But PlugOrderIsEmpty.');
+ }
+ }
+}
diff --git a/app/command/TestTask.php b/app/command/TestTask.php
new file mode 100644
index 0000000..47b3b32
--- /dev/null
+++ b/app/command/TestTask.php
@@ -0,0 +1,23 @@
+setName('test:task')->setDescription('Execute the reservation charging task');
+ }
+
+ protected function execute(Input $input, Output $output)
+ {
+ Db::table('test')->save(['number' => 1, 'message' => time()]);
+ }
+}
\ No newline at end of file
diff --git a/app/common.php b/app/common.php
new file mode 100644
index 0000000..174646e
--- /dev/null
+++ b/app/common.php
@@ -0,0 +1,341 @@
+ $time) {
+ $dian_arr[$index]['dian_1'] = explode(':', $Elect[$index])[3];
+ $dian_1 = explode(':', $Elect[$index])[3];
+ }
+
+ }
+
+ // 计算服务费
+ $fu_1 = '0.00';
+ $ServiceFee = str_replace('服务费:', '', $fu);
+
+ $Elect = explode(',', $ServiceFee);
+ $fu_arr = [];
+ for ($index = 0; $index < count($Elect); $index++) {
+ $fu_arr[$index]['time_interval'] = substr($Elect[$index], 0, 11);
+
+ $start_time = substr($Elect[$index], 0, 5);
+ $end_time = substr($Elect[$index], 6, 5);
+
+
+ $fu_arr[$index]['price'] = substr($Elect[$index], 12, 4);
+
+ $fu_arr[$index]['fu_1'] = '';
+ if ($start_time < $time && $end_time > $time) {
+ $fu_arr[$index]['dian_1'] = explode(':', $Elect[$index])[3];
+ $fu_1 = explode(':', $Elect[$index])[3];
+ }
+ }
+
+ foreach ($dian_arr as $key => &$value) {
+ $value['dian_1'] = false;
+ $start_time = substr($value['time_interval'], 0, 5);
+ $end_time = substr($value['time_interval'], 6, 5);
+
+ if ($start_time < $time && $end_time > $time) {
+ $value['dian_1'] = true;
+ }
+
+ foreach ($fu_arr as $kk => $vv) {
+
+ if ($value['time_interval'] == $vv['time_interval']) {
+
+ $value['price'] = number_format((double)$value['price'], 4);
+ $value['fu_price'] = number_format((double)$vv['price'], 4);
+ $value['total_price'] = number_format($vv['price'] + $value['price'], 4);
+
+ } else {
+ continue;
+ }
+ }
+
+ }
+
+
+ return ['time_price' => number_format($dian_1 + $fu_1, 4), 'price_list' => $dian_arr];
+
+ }
+
+ function getMonthDate($date)
+ {
+ $date_t = array();
+ $date_t[] = $date;
+ for ($i = 0; $i < 4; $i++) {
+ $this_date = strtotime($date);
+ $next_date = date("Y-m-d", strtotime('next monday', $this_date));
+ $date_t[] = $next_date;
+ $date = $next_date;
+ }
+ return $date_t;
+
+ }
+
+ function getSeasonDate($date)
+ {
+ $date_t = array();
+ $date_t[] = $date;
+ for ($i = 0; $i < 2; $i++) {
+ $this_date = strtotime($date);
+ $next_date = date("Y-m-d", strtotime('next month', $this_date));
+ $date_t[] = $next_date;
+ $date = $next_date;
+ }
+ return $date_t;
+
+ }
+
+ function getYearDate($date)
+ {
+ $date_t = array();
+ $date_t[] = $date;
+ for ($i = 0; $i < 11; $i++) {
+ $this_date = strtotime($date);
+ $next_date = date("Y-m-d", strtotime('next month', $this_date));
+ $date_t[] = $next_date;
+ $date = $next_date;
+ }
+ return $date_t;
+
+ }
+
+ function getDayDate($date)
+ {
+ $date_t = array();
+ $date_t[] = $date;
+ $this_date = strtotime($date);
+ $end_date = date("Y-m-d H:i:s", strtotime('+4 hour -1 second', $this_date));
+ $date_end[] = $end_date;
+ for ($i = 0; $i < 5; $i++) {
+ $this_date = strtotime($date);
+ $next_date = date("Y-m-d H:i:s", strtotime('+4 hour', $this_date));
+ $this_date_end = strtotime($end_date);
+ $next_date_end = date("Y-m-d H:i:s", strtotime('+4 hour', $this_date_end));
+ $date_end[] = $next_date_end;
+ $date_t[] = $next_date;
+ $date = $next_date;
+ $next_date_end = date("Y-m-d H:59:59", strtotime($next_date_end));
+ $end_date = $next_date_end;
+ }
+ $kk['start_time'] = $date_t;
+ $kk['end_time'] = $date_end;
+ return $kk;
+
+ }
+
+ function getDistance($lat1, $lng1, $lat2, $lng2)
+ {
+ $earthRadius = 6367000;
+ $lat1 = ($lat1 * pi()) / 180;
+ $lng1 = ($lng1 * pi()) / 180;
+ $lat2 = ($lat2 * pi()) / 180;
+ $lng2 = ($lng2 * pi()) / 180;
+ $calcLongitude = $lng2 - $lng1;
+ $calcLatitude = $lat2 - $lat1;
+ $stepOne = pow(sin($calcLatitude / 2), 2) + cos($lat1) * cos($lat2) * pow(sin($calcLongitude / 2), 2);
+ $stepTwo = 2 * asin(min(1, sqrt($stepOne)));
+ $calculatedDistance = $earthRadius * $stepTwo;
+ return round($calculatedDistance / 1000, 2);
+ }
+
+
+ function Encrypt($data)
+ {
+ $aes = new Aes();
+ return $aes->encrypt($data);
+ }
+
+ function Decrypt($data)
+ {
+ $aes = new Aes();
+ return $aes->decrypt($data);
+ }
+
+ function HmacMD5($data)
+ {
+ $md5 = new HMACMD5();
+ return $md5->HMAC($data);
+ }
+
+ function CurlSend($url, $data = '', $token = '')
+ {
+ $data = json_encode($data);
+// echo $data;
+
+ $ch = curl_init();
+ $headers = array();
+ if ($token) {
+ $headers[] = 'Authorization: Bearer ' . $token;
+ }
+ $headers[] = 'Content-Type: application/json;charset=utf-8';
+ $headers[] = 'Content-Length: ' . strlen($data);
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 对认证证书来源的检查
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在
+ curl_setopt($ch, CURLOPT_HEADER, 0);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+ curl_setopt($ch, CURLOPT_POST, 1);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+ $curl_return = curl_exec($ch);
+ curl_close($ch);
+ return json_decode(trim($curl_return), true);
+ }
+
+ function checkParams($params)
+ {
+ $arr = ['OperatorID', 'Data', 'TimeStamp', 'Seq', 'Sig'];
+ // 参数检查
+ foreach ($arr as $v) {
+ if (empty($params[$v])) {
+ return $v;
+ }
+ }
+ return 2;
+ }
+
+ function checkSig($OperatorID, $params)
+ {
+ $sig = $OperatorID . $params['Data'] . $params['TimeStamp'] . $params['Seq'];
+ $ecry_sig = $this->HmacMD5($sig);
+ if ($params['Sig'] != $ecry_sig) {
+ return 1;
+ }
+ return 2;
+ }
+
+
+ function signToken()
+ {
+ $key = config('hard.DataSecretIV'); //这里是自定义的一个随机字串,应该写在config文件中的,解密时也会用,相当 于加密中常用的 盐 salt
+ $token = array(
+ "iss" => $key, //签发者 可以为空
+ "aud" => '', //面象的用户,可以为空
+ "iat" => time(), //签发时间
+ "nbf" => time() + 1, //在什么时候jwt开始生效 (这里表示生成100秒后才生效)
+ "exp" => time() + 7200, //token 过期时间
+ "data" => [ //记录的userid的信息,这里是自已添加上去的,如果有其它信息,可以再添加数组的键值对
+ 'name' => 'zuxing'
+ ]
+ );
+ // print_r($token);
+ $jwt = JWT::encode($token, $key, "HS256"); //根据参数生成了 token
+ return $jwt;
+ }
+
+
+//验证token
+ function checkToken_assess($token)
+ {
+ $key = config('hard.DataSecretIV');
+ $key = new Key($key, 'HS256');
+ $status = array("code" => 2);
+ try {
+ JWT::$leeway = 60;//当前时间减去60,把时间留点余地
+ $decoded = JWT::decode($token, $key, array('HS256')); //HS256方式,这里要和签发的时候对应
+ $arr = (array)$decoded;
+ $res['code'] = 1;
+ $res['data'] = $arr['data'];
+ return 2;
+
+ } catch (\Firebase\JWT\SignatureInvalidException $e) { //签名不正确
+ $status['msg'] = "签名不正确";
+ return 1;
+ } catch (\Firebase\JWT\BeforeValidException $e) { // 签名在某个时间点之后才能用
+ $status['msg'] = "token失效";
+ return 1;
+ } catch (\Firebase\JWT\ExpiredException $e) { // token过期
+ $status['msg'] = "token失效";
+ return 1;
+ } catch (\Exception $e) { //其他错误
+ $status['msg'] = "未知错误";
+ return 1;
+ }
+ }
+
+ function encodeData($data, $params, $ret, $msg = '')
+ {
+ $data = json_encode($data);
+ $data = $this->Encrypt($data);
+ $seq = empty($Seq) ? '0001' : $params['Seq'];
+ $datetime = empty($TimeStamp) ? date('YmdHis') : $params['TimeStamp'];
+ $sig = $params['OperatorID'] . $data . $datetime . $seq;
+ $s = $this->HmacMD5($sig);
+ return json(['Msg' => $msg, 'Ret' => $ret, 'Data' => $data, 'Sig' => $s]);
+ }
+
+ function generate_password($length)
+ {
+ $chars = '0123456789';
+ $time = time();
+ $password = config('hard.OperatorID') . $time;
+ for ($i = 0; $i < $length; $i++) {
+ $password .= $chars[mt_rand(0, strlen($chars) - 1)];
+ }
+ return $password;
+ }
+
+
+}
\ No newline at end of file
diff --git a/app/controller/Admin.php b/app/controller/Admin.php
new file mode 100644
index 0000000..a4b4c27
--- /dev/null
+++ b/app/controller/Admin.php
@@ -0,0 +1,249 @@
+ 5,
+ 'query' => request()->param()
+ ]);
+ return json($list);
+ }
+
+ public function admin_all()
+ {
+
+ $list = AdminModel::select();
+ return json($list);
+ }
+
+ /**
+ * 显示创建资源表单页.
+ *
+ * @return \think\Response
+ */
+ public function create()
+ {
+ //
+ }
+
+ /**
+ * 保存新建的资源
+ *
+ * @param \think\Request $request
+ * @return string|\think\Response
+ */
+ private function PasswordStrongEnough($password)
+ {
+ $error = "";
+ if (strlen($password) < 10) {
+ $error .= "密码至少为10位";
+ return $error;
+ }
+ if (!preg_match("/[a-z]/", $password)) {
+ $error .= "密码至少包含一个小写字母";
+ return $error;
+ }
+ if (!preg_match("/[A-Z]/", $password)) {
+ $error .= "密码至少包含一个大写字母";
+ return $error;
+ }
+ if (!preg_match("/[0-9]/", $password)) {
+ $error .= "密码至少包含一个数字";
+ return $error;
+ }
+ if (!preg_match("/[.!@#$%]/", $password)) {
+ $error .= "密码至少包含:(.!@#$%)其中一个符号";
+ return $error;
+ }
+ }
+
+ public function save(Request $request)
+ {
+ $data = $request->param();
+ $username = $data['username'];
+ $nickname = $data['nickname'];
+ $password = $data['password'];
+ $email = $data['email'];
+ $phone = $data['phone'];
+ $passwordStrengthErrors = $this->PasswordStrongEnough($password);
+ if (!empty($passwordStrengthErrors)) {
+ return json(['code' => 1, 'message' => '密码强度不足,' . $passwordStrengthErrors]);
+ }
+ $id = AdminModel::where('username', $username)->value('id');
+ if (empty($id)) {
+ AdminModel::create([
+ 'username' => $username,
+ 'password' => $password,
+ 'nickname' => $nickname,
+ 'email' => $email,
+ 'phone' => $phone
+ ]);
+ return json(['code' => 200, 'message' => '注册成功']);
+ } else {
+ return json(['code' => 1, 'message' => '用户名已存在']);
+ }
+
+ }
+
+ /**
+ * 显示指定的资源
+ *
+ * @return \think\Response
+ */
+ public function read(Request $request)
+ {
+ $data = $request->param();
+ $message = "'%" . $data['message'] . "%'";
+ $list = Db::table('admin')->whereRaw('(username like' . $message . ' or nickname like' . $message . ' or email like' . $message . ' or phone like' . $message . ' or roles like ' . $message . ')')->paginate(20);
+ return json($list);
+ }
+
+ /**
+ * 显示编辑资源表单页.
+ *
+ * @param int $id
+ * @return \think\Response
+ */
+ public function edit($id)
+ {
+
+ }
+
+ /**
+ * 保存更新的资源
+ *
+ * @param \think\Request $request
+ *
+ * @return \think\Response
+ */
+ public function update(Request $request): \think\Response
+ {
+ $data = $request->param();
+
+ $validate = Validate::rule([
+ 'username' => 'require|min:2|max:10|chsDash|unique:admin',
+ //'__token__' => 'require|token',
+ 'nickname' => 'require|min:2|max:10|chsDas',
+ 'password' => 'require|min:6',
+ 'email' => 'require|email|unique:admin',
+ 'phone' => 'require|number|length:11|unique:admin'
+ ]);
+ try {
+ $validate->batch(true)->check($request->param());
+ } catch (ValidateException $exception) {
+ return json(['code' => 1, 'massage' => $exception->getError()]);
+ }
+ $id = AdminModel::where('username', $data['username'])->value('id');
+ if (!empty($id)) {
+ AdminModel::update([
+ 'nickname' => $data['nickname'],
+ 'password' => $data['password'],
+ 'email' => $data['email'],
+ 'phone' => $data['phone'],
+ 'roles' => $data['roles']
+ ], ['id' => $id]);
+ return json(['code' => 200, 'massage' => '修改成功']);
+ } else {
+ return json(['code' => 1, 'massage' => '用户不存在']);
+ }
+ }
+
+ /**
+ * 删除指定资源
+ *
+ * @param int $id
+ * @return \think\Response
+ */
+ public function delete(Request $request)
+ {
+ $data = $request->param();
+ $username = $data['username'];
+ $id = AdminModel::where('username', $username)->value('id');
+ if ($id != null) {
+ $result = AdminModel::destroy($id);
+ if ($result) {
+ return json(['code' => 200, 'massage' => '删除成功']);
+ } else {
+ return json(['code' => 1, 'massage' => '删除失败']);
+ }
+ } else {
+ return json(['code' => 1, 'massage' => '该管理员不存在']);
+ }
+
+ }
+
+ public function update_password(Request $request)
+ {
+ $data = $request->param();
+ $phone = $data['phone'];
+ $id = AdminModel::where(['username' => $data['username'], 'phone' => $phone])->find()->getData('id');
+ if (!empty($id)) {
+ $password = $data['password'];
+ $result = AdminModel::where('id', $id)->update(['password' => $password]);
+ if ($result == 0) {
+ return json(['code' => 1, 'message' => '手机号或用户名错误!']);
+ } else {
+ return json(['code' => 200, 'message' => '已成功修改密码']);
+ }
+ }
+ }
+
+ public function change_password(Request $request)
+ {
+ $data = $request->param();
+ $username = $data['username'];
+ $old_password = $data['old_password'];
+ $id = AdminModel::where(['username' => $username, 'password' => $old_password])->value('id');
+ if (!empty($id)) {
+ $new_password = $data['new_password'];
+ $result = AdminModel::where('id', $id)->update(['password' => $new_password]);
+ if ($result == 1) {
+ return json(['code' => 200, 'message' => '已成功修改密码']);
+ }
+ } else {
+ return json(['code' => 1, 'message' => '原始密码不正确']);
+ }
+ }
+
+ public function UpdatePermission($admin_id, $permission = array())
+ {
+ if (empty($permission)) {
+ $pp = Db::table('admin')->where('id', $admin_id)->value('permission');
+ if (!empty($pp)) {
+ $pp = explode(',', substr($pp, 0, -1));
+ } else {
+ $pp = array();
+ }
+ $username = Db::table('admin')->where('id', $admin_id)->value('username');
+ return json(['code' => 200, 'msg' => 'Query OK', 'data' => ['admin_id' => $admin_id, 'adminName' => $username, 'permission' => $pp]]);
+ } else {
+ $pstr = '';
+ foreach ($permission as $pp) {
+ $pstr .= $pp . ',';
+ }
+ Db::table('admin')->where('id', $admin_id)->save(['permission' => $pstr]);
+ $pp = explode(',', substr($pstr, 0, -1));
+ return json(['code' => 200, 'msg' => 'Update OK', 'data' => ['permission' => $pp]]);
+ }
+ }
+
+}
diff --git a/app/controller/Aes.php b/app/controller/Aes.php
new file mode 100644
index 0000000..1fd9734
--- /dev/null
+++ b/app/controller/Aes.php
@@ -0,0 +1,18 @@
+paginate([
+ 'list_rows' => 20,
+ 'query' => request()->param()
+ ]);
+ return json($list);
+ }
+ // 菜单
+ public function getMenuList(){
+ $list = Db::table('zxc_menu')->where('pid',0)->select()->toArray();
+ foreach ($list as $key=>&$value){
+ $value['title'] = $value['name'];
+ $value['children'] = Db::table('zxc_menu')->where('pid',$value['id'])->select()->toArray();
+
+ if(!empty($value['children'])){
+ foreach ($value['children'] as $kk =>&$vv){
+ $vv['title'] = $vv['name'];
+ }
+ }
+ }
+
+ return json($list);
+ }
+
+ // 优惠券相关
+ public function getCouponList(){
+ $where = [];
+ $list = Db::table('zxc_coupon')
+ ->paginate([
+ 'list_rows' => 20,
+ 'query' => request()->param()
+ ]);
+ return json($list);
+ }
+ // 获取日志
+ public function getLogList(){
+ $where = [];
+ $list = Db::table('system_request_logs')
+ ->order('id desc')
+ ->paginate([
+ 'list_rows' => 20,
+ 'query' => request()->param()
+ ]);
+ return json($list);
+ }
+ //运营数据
+ public function getYunYingData(){
+ return json([]);
+ }
+ //财务数据
+ public function getCaiWuData(){
+ $where = [];
+ $list = Db::table('zxc_user_money_log')
+ ->order('id desc')
+ ->paginate([
+ 'list_rows' => 20,
+ 'query' => request()->param()
+ ]);
+ $typeMap = [
+ '1'=>'充电订单',
+ '2'=>'充值',
+ '3'=>'提现'
+ ];
+ $list->each(function($item, $key) use ($typeMap) {
+ $item['type_text'] = $typeMap[$item['type']];
+ return $item;
+ });
+ return json($list);
+ }
+
+}
\ No newline at end of file
diff --git a/app/controller/Bus/AlterBalance.php b/app/controller/Bus/AlterBalance.php
new file mode 100644
index 0000000..d4d8535
--- /dev/null
+++ b/app/controller/Bus/AlterBalance.php
@@ -0,0 +1,18 @@
+where("openid", "o-wLg5DGWU_rYwfmp1-1Wck1lKGw")->save(["account" => 99999.00]);
+ if ((int)$save == 1) {
+ return json(["code" => 200, "msg" => "修改成功"]);
+ } else {
+ return json(["code" => 404, "msg" => "修改失败"]);
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/controller/Bus/BusBill.php b/app/controller/Bus/BusBill.php
new file mode 100644
index 0000000..2f92afa
--- /dev/null
+++ b/app/controller/Bus/BusBill.php
@@ -0,0 +1,47 @@
+getDateFromRange($start_time, $end_time);
+ $i = 0;
+ foreach (array_unique($message) as $a) {
+ $DateWithMess[$i]['序号'] = $i + 1;
+// $DateWithMess[$i]['EvcInfoNo'] = $a;
+ $DateWithMess[$i]['车牌号'] = Vinlicense::where("EvcInfoNo", $a)->value("ParkNo");
+ $DateWithMess[$i]['车号'] = Vinlicense::where("EvcInfoNo", $a)->value("SelfCode");
+ $TotalCharge = 0;
+ foreach ($date as $d) {
+ $TotalPower = Db::table("charge_order_gongjiao")->where('EvcInfoNo', $a)->whereDay('charge_date', $d)->sum('TotalPower');
+ $TotalCharge += $TotalPower;
+ $DateWithMess[$i][$d] = round($TotalPower, 3);
+ }
+
+ $DateWithMess[$i]['充电电量(度)'] = round($TotalCharge, 3);
+ $DateWithMess[$i]['充电电费(元)'] = round(Db::table("charge_order_gongjiao")->where('EvcInfoNo', $a)->whereBetweenTime('charge_date', $start_time, $end_time)->sum('ElecMoney'), 2);
+ if ($DateWithMess[$i]['充电电量(度)'] != 0) {
+ $DateWithMess[$i]['平均电费'] = round($DateWithMess[$i]['充电电费(元)'] / $DateWithMess[$i]['充电电量(度)'], 3);
+ }
+ $charge_pile_number = Db::table("charge_order_gongjiao")->where('EvcInfoNo', $a)->value("Equipment_number");
+ $ddd = Db::table("charge_pile,charge_station")->where('charge_pile_number', $charge_pile_number)->where("charge_pile.charge_station_id=charge_station.charge_station_id")->value("charge_station_number");
+ $DateWithMess[$i]['充电服务费单价(元)'] = $this->Fee($ddd, "o-wLg5DGWU_rYwfmp1-1Wck1lKGw")['ServiceFee'][0]['univalence'];
+ $DateWithMess[$i]['充电服务费(元)'] = round(Db::table("charge_order_gongjiao")->where('EvcInfoNo', $a)->whereBetweenTime('charge_date', $start_time, $end_time)->sum('SeviceMoney'), 2);
+ $DateWithMess[$i]['充电费用(元)'] = round(Db::table("charge_order_gongjiao")->where('EvcInfoNo', $a)->whereBetweenTime('charge_date', $start_time, $end_time)->sum('TotalMoney'), 2);
+ $i += 1;
+ }
+ return $this->ResponseJson($DateWithMess, 200, "Request Success");
+ }
+}
\ No newline at end of file
diff --git a/app/controller/Bus/PlugCharge.php b/app/controller/Bus/PlugCharge.php
new file mode 100644
index 0000000..d59d0a3
--- /dev/null
+++ b/app/controller/Bus/PlugCharge.php
@@ -0,0 +1,350 @@
+header()['authorization'];//传递过来的token
+ $auths = explode(' ', trim($authorization));
+ $auth = $auths[count($auths) - 1];
+ $checkParams = $this->checkParams($params);
+ if ($checkParams != 2)
+ return json(['Msg' => $checkParams . '为空', 'Ret' => 4003, 'Data' => ['Status' => 1]]);
+ if ($auth) {
+ if ($this->checkToken_assess($auth) == 1) {
+ $data = json_encode(['Status' => 1]);
+ $data = $this->Encrypt($data);
+ $seq = empty($Seq) ? '0001' : $params['Seq'];
+ $datetime = empty($TimeStamp) ? date('YmdHis') : $params['TimeStamp'];
+ $sig = $OperatorID . $data . $datetime . $seq;
+ $s = $this->HmacMD5($sig);
+ return json(['Msg' => 'Token过期或者无效', 'Ret' => 4002, 'Data' => $data, 'Sig' => $s]);
+ }
+ $checkSig = $this->checkSig($params['OperatorID'], $params);
+ if ($checkSig == 1) {
+ $data = json_encode(['Status' => 1]);
+ $data = $this->Encrypt($data);
+ $seq = empty($Seq) ? '0001' : $params['Seq'];
+ $datetime = empty($TimeStamp) ? date('YmdHis') : $params['TimeStamp'];
+ $sig = $OperatorID . $data . $datetime . $seq;
+ $s = $this->HmacMD5($sig);
+ return json(['Msg' => '签名错误', 'Ret' => 4001, 'Data' => $data, 'Sig' => $s]);
+ }
+ $data = $this->Decrypt($params['Data']);
+ $data = json_decode($data, true);
+ if (isset($data['vin']) && isset($data['connectorID'])) {
+ Log::write("The Plug Message come on :" . $data['vin'] . $data['connectorID']);
+ $CheckVinIsExist = Db::table('vinlicense')->where('EvcInfoNo', $data['vin'])->find();
+ if (!empty($CheckVinIsExist)) {
+ $AppointmentTime = Db::table('appointment_time')->where('id', 1)->value('AppointmentTime');
+ $currentDate = new DateTime();
+ $combinedDateTime = new DateTime($currentDate->format('Y-m-d') . ' ' . $AppointmentTime);
+ $AppointmentTime = $combinedDateTime->format('Y-m-d H:i:s');
+ $nowTime = $currentDate->format('Y-m-d H:i:s');
+ $nowDay = $currentDate->format('Y-m-d');
+ $check = Db::table('appointment')->whereDay('action_time', $nowDay)->where('Vin', $data['vin'])->where('ConnectorID', $data['connectorID'])->find();
+ if (empty($check)) {
+ Db::table('appointment')->save(['action_time' => $nowTime, 'ConnectorID' => $data['connectorID'], 'Vin' => $data['vin'], 'plug_time' => $AppointmentTime]);
+ }
+// $check = Db::table('appointment')->whereDay('action_time', $nowDay)->where('Vin', $data['vin'])->find();
+// if (empty($check)) {
+// Db::table('appointment')->save(['action_time' => $nowTime, 'ConnectorID' => $data['connectorID'], 'Vin' => $data['vin'], 'plug_time' => $AppointmentTime]);
+// } else {
+// $checkVin = Db::table('appointment')->whereDay('action_time', $nowDay)->where('Vin', $data['vin'])->value('ConnectorID');
+// if ($checkVin != $data['connectorID']) {
+// Db::table('appointment')->whereDay('action_time', $nowDay)->where('Vin', $data['vin'])->save(['action_time' => $nowTime, 'ConnectorID' => $data['connectorID']]);
+// }
+// }
+ }
+ $kk['SuccStat'] = 0;
+ $kk['FailReason'] = 0;
+ return $this->encodeData($kk, $params, 0);
+ } else {
+ $kk['SuccStat'] = 1;
+ $kk['FailReason'] = 1;
+ return $this->encodeData($kk, $params, 0);
+ }
+ }
+ return $this->encodeData(['Status' => 1], $params, 4002, 'Bearer 未添加');
+// $OperatorID = Config::get('hard.OperatorID');
+// $OperatorSecret = Config::get('hard.OperatorSecret');
+ }
+
+ public function PlugGennerateOrder($ConnectorID, $vin): array
+ {
+ $station_id = Db::table('charge_pile')->where('ConnectorID', $ConnectorID)->value('charge_station_id');
+ $EquipAuthSeq = Db::table('charge_pile')->where('ConnectorID', $ConnectorID)->value('EquipAuthSeq');
+ $no = Db::table('charge_pile')->where('ConnectorID', $ConnectorID)->value('no');
+ if (empty($EquipAuthSeq)) {
+ $EquipAuthSeq = $this->generate_EquipmentAuth(7);
+ Db::table('charge_pile')->where('ConnectorID', $ConnectorID)->update(['EquipAuthSeq' => $EquipAuthSeq]);
+ }
+ $Hard = new HardMessage();
+ $openid = 'o-wLg5DGWU_rYwfmp1-1Wck1lKGw';
+ $area = Db::table('user')->where('openid', $openid)->value('area');
+ $pinyin = new Pinyin();
+ $s = $pinyin->sentence($area);
+ $s = strtr($s, array(' ' => ''));
+ $table = 'charge_order_' . $s;
+ $table_user = 'user_' . $s;
+ $AuthMessage = $Hard->Get_query_equip_auth($EquipAuthSeq, $ConnectorID);
+ if (isset($AuthMessage['FailReason']) && isset($AuthMessage['SuccStat'])) {//认证成功 请求启动充电
+ if ($AuthMessage['FailReason'] == 0 && $AuthMessage['SuccStat'] == 0) {
+ $StartChargeSeq = $this->generate_StartChargeSeq(7);
+ ChargeOrderModel::insert(['openid' => $openid, 'area' => $area, 'StartChargeSeq' => $StartChargeSeq]);
+ $ChargeModel = 1;
+ $StartCharge = $Hard->Get_query_start_charge_test($StartChargeSeq, $ConnectorID, 'QRCode', $ChargeModel, $vin); //ChargeModel vin
+ if ($StartCharge['StartChargeSeqStat'] == 1 && $StartCharge['SuccStat'] == 0 && $StartCharge['FailReason'] == 0) {
+ $order_number = $this->generate_order(6);
+ $charge_date = date('Y-m-d', time());
+ $account = 200;
+ $Equipment_number = Db::table('charge_pile')->where('ConnectorID', $ConnectorID)->value('charge_pile_number');
+ $mess = [
+ 'order_number' => $order_number,
+ 'charge_station_id' => $station_id,
+ 'openid' => $openid,
+ 'charge_date' => $charge_date,
+ 'Equipment_number' => $Equipment_number,
+ 'StartChargeSeq' => $StartChargeSeq,
+ 'status' => $StartCharge['StartChargeSeqStat'],
+ 'StartChargeSeqStat' => $StartCharge['StartChargeSeqStat'],
+ 'ConnectorID' => $ConnectorID,
+ 'WithholdingMoney' => $account,
+ 'EvcInfoNo' => $vin
+ ];
+ Db::table($table_user)->where('openid', $openid)->update(['account' => Db::raw('account-' . $account)]);
+ Db::table($table)->save($mess);
+ $time = date('Y-m-d H:i:s');
+ Log::write('Reservation order has been generated. The Message is ' . $time . json($mess)->getContent());
+ return ['code' => 200, 'message' => '订单创建成功', 'order_number' => $order_number];
+ } elseif ($StartCharge['SuccStat'] == 1) {
+ if ($StartCharge['FailReason'] == 0) {
+ return ['code' => 1, 'message' => '设备认证操作结果失败'];
+ } elseif ($StartCharge['FailReason'] == 1) {
+ return ['code' => 1, 'message' => '设备认证操作结果失败 此设备不存在'];
+ } elseif ($StartCharge['FailReason'] == 2) {
+ return ['code' => 1, 'message' => '设备认证操作结果失败 此设备离线'];
+ } elseif ($StartCharge['FailReason'] == 90) {
+ return ['code' => 1, 'message' => '设备认证操作结果失败 车辆未备案'];
+ } elseif ($StartCharge['FailReason'] == 91) {
+ return ['code' => 2, 'message' => '设备认证操作结果失败 该车辆充电中'];
+ } else {
+ return ['code' => 1, 'message' => '未知错误 设备认证成功 请求充电失败'];
+ }
+ } else {
+ return ['code' => 1, 'message' => '未知错误 设备认证成功 请求充电失败'];
+ }
+ } elseif ($AuthMessage['SuccStat'] == 1) {
+ if ($AuthMessage['FailReason'] == 0) {
+ return ['code' => 1, 'message' => '设备认证操作结果失败'];
+ } elseif ($AuthMessage['FailReason'] == 1) {
+ return ['code' => 1, 'message' => '设备认证操作结果失败 此设备尚未插枪'];
+ } elseif ($AuthMessage['FailReason'] == 2) {
+ return ['code' => 1, 'message' => '设备认证操作结果失败 设备检测失败'];
+ } else {
+ return ['code' => 1, 'message' => '未知错误 设备认证失败'];
+ }
+ } else {
+ return ['code' => 1, ' message' => '未知错误 设备认证失败'];
+ }
+ } else {
+ return ['code' => 1, 'message' => '未知错误 设备认证失败'];
+ }
+ }
+
+ public function ModifyAppointmentTime($time): \think\response\Json
+ {
+ $dateTime = new DateTime($time);
+ $formattedTime = $dateTime->format('H:i:s');
+ $modify = Db::table('appointment_time')->where('id', 1)->save(['AppointmentTime' => $formattedTime]);
+ if ((int)$modify == 1) {
+ return json(['code' => 200, 'msg' => '修改成功']);
+ } else {
+ return json(['code' => 1, 'msg' => '修改失败']);
+ }
+ }
+
+ public function ShowAppointmentTime(): \think\response\Json
+ {
+ $AppointmentTime = Db::table('appointment_time')->where('id', 1)->value('AppointmentTime');
+ return json(['code' => 200, 'msg' => '显示成功', 'data' => $AppointmentTime]);
+ }
+
+ private function generate_StartChargeSeq($length): string
+ {
+ $chars = '0123456789';
+ $time = time();
+ $password = config('hard.OperatorID') . $time . '2';//2代表是生成的充电订单号
+ for ($i = 0; $i < $length; $i++) {
+ $password .= $chars[mt_rand(0, strlen($chars) - 1)];
+ }
+ return $password;
+ }
+
+ private function generate_order($length): string
+ {
+ $chars = '0123456789';
+ $time = time();
+ $password = 'DZZS' . $time;
+ for ($i = 0; $i < $length; $i++) {
+ $password .= $chars[mt_rand(0, strlen($chars) - 1)];
+ }
+ return $password;
+ }
+
+ private function generate_EquipmentAuth($length): string
+ {
+ $chars = '0123456789';
+ $time = time();
+ $password = config('hard.OperatorID') . $time . '1';//1代表是生成的设备认证流水号
+ for ($i = 0; $i < $length; $i++) {
+ $password .= $chars[mt_rand(0, strlen($chars) - 1)];
+ }
+ return $password;
+ }
+
+ public function Encrypt($data): string
+ {
+ $aes = new Aes();
+ return $aes->encrypt($data);
+ }
+
+ private function Decrypt($data)
+ {
+ $aes = new Aes();
+ return $aes->decrypt($data);
+ }
+
+ private function HmacMD5($data): string
+ {
+ $md5 = new HMACMD5();
+ return $md5->HMAC($data);
+ }
+
+ private function CurlSend($url, $data = '', $token = '')
+ {
+ $data = json_encode($data);
+// echo $data;
+ $ch = curl_init();
+ $headers = array();
+ if ($token) {
+ $headers[] = 'Authorization: Bearer ' . $token;
+ }
+ $headers[] = 'Content-Type: application/json;charset=utf-8';
+ $headers[] = 'Content-Length: ' . strlen($data);
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 对认证证书来源的检查
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在
+ curl_setopt($ch, CURLOPT_HEADER, 0);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+ curl_setopt($ch, CURLOPT_POST, 1);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+ $curl_return = curl_exec($ch);
+ curl_close($ch);
+ return json_decode(trim($curl_return), true);
+ }
+
+ private function checkParams($params)
+ {
+ $arr = ['OperatorID', 'Data', 'TimeStamp', 'Seq', 'Sig'];
+ // 参数检查
+ foreach ($arr as $v) {
+ if (empty($params[$v])) {
+ return $v;
+ }
+ }
+ return 2;
+ }
+
+ private function checkSig($OperatorID, $params): int
+ {
+ $sig = $OperatorID . $params['Data'] . $params['TimeStamp'] . $params['Seq'];
+ $ecry_sig = $this->HmacMD5($sig);
+ if ($params['Sig'] != $ecry_sig) {
+ return 1;
+ }
+ return 2;
+ }
+
+
+ public function signToken(): string
+ {
+ $key = config('hard.DataSecretIV'); //这里是自定义的一个随机字串,应该写在config文件中的,解密时也会用,相当 于加密中常用的 盐 salt
+ $token = array(
+ "iss" => $key, //签发者 可以为空
+ "aud" => '', //面象的用户,可以为空
+ "iat" => time(), //签发时间
+ "nbf" => time() + 1, //在什么时候jwt开始生效 (这里表示生成100秒后才生效)
+ "exp" => time() + 7200, //token 过期时间
+ "data" => [ //记录的userid的信息,这里是自已添加上去的,如果有其它信息,可以再添加数组的键值对
+ 'name' => 'zuxing'
+ ]
+ );
+ // print_r($token);
+ $jwt = JWT::encode($token, $key, "HS256"); //根据参数生成了 token
+ return $jwt;
+ }
+
+
+//验证token
+ private function checkToken_assess($token): int
+ {
+ $key = config('hard.DataSecretIV');
+ $key = new Key($key, 'HS256');
+ $status = array("code" => 2);
+ try {
+ JWT::$leeway = 60;//当前时间减去60,把时间留点余地
+ $decoded = JWT::decode($token, $key, array('HS256')); //HS256方式,这里要和签发的时候对应
+ $arr = (array)$decoded;
+ $res['code'] = 1;
+ $res['data'] = $arr['data'];
+ return 2;
+
+ } catch (\Firebase\JWT\SignatureInvalidException $e) { //签名不正确
+ $status['msg'] = "签名不正确";
+ return 1;
+ } catch (\Firebase\JWT\BeforeValidException $e) { // 签名在某个时间点之后才能用
+ $status['msg'] = "token失效";
+ return 1;
+ } catch (\Firebase\JWT\ExpiredException $e) { // token过期
+ $status['msg'] = "token失效";
+ return 1;
+ } catch (\Exception $e) { //其他错误
+ $status['msg'] = "未知错误";
+ return 1;
+ }
+ }
+
+ private function encodeData($data, $params, $ret, $msg = ''): \think\response\Json
+ {
+ $data = json_encode($data);
+ $data = $this->Encrypt($data);
+ $seq = empty($Seq) ? '0001' : $params['Seq'];
+ $datetime = empty($TimeStamp) ? date('YmdHis') : $params['TimeStamp'];
+ $sig = $params['OperatorID'] . $data . $datetime . $seq;
+ $s = $this->HmacMD5($sig);
+ return json(['Msg' => $msg, 'Ret' => $ret, 'Data' => $data, 'Sig' => $s]);
+ }
+
+}
\ No newline at end of file
diff --git a/app/controller/Bus/SearchMessage.php b/app/controller/Bus/SearchMessage.php
new file mode 100644
index 0000000..13eec0c
--- /dev/null
+++ b/app/controller/Bus/SearchMessage.php
@@ -0,0 +1,207 @@
+OrderList("o-wLg5DGWU_rYwfmp1-1Wck1lKGw");
+ if (!empty($end_time)) {
+ $end_time = date("Y-m-d", strtotime("+1day", strtotime($end_time)));
+ }
+ $busOrder = ["code" => 9001, "Msg" => "请输入正确的参数"];
+ if (empty($message) && empty($start_time) && empty($end_time)) {
+ $busOrder = Db::table("charge_order_gongjiao")->select();
+ } elseif (!empty($message) && empty($start_time) && empty($end_time)) {
+ $busOrder = Db::table("charge_order_gongjiao")->where('order_number', 'like', '%' . $message . '%')->select();
+ } elseif (empty($message) && !empty($start_time) && !empty($end_time)) {
+ $busOrder = Db::table("charge_order_gongjiao")->whereBetweenTime('start_time', $start_time, $end_time)->select();
+ } elseif (!empty($message) && !empty($start_time) && !empty($end_time)) {
+ $busOrder = Db::table("charge_order_gongjiao")->where('order_number', 'like', '%' . $message . '%')->whereBetweenTime('start_time', $start_time, $end_time)->select();
+ }
+
+ $busOrder = $busOrder->toArray();
+ for ($i = 0; $i < count($busOrder); $i++) {
+ if (!isset($busOrder['code'])) {
+ $busOrder[$i]["order_id"] = $i + 1;
+ $busOrder[$i]["charge_station_name"] = Db::table("charge_station")->where("charge_station_id", $busOrder[$i]["charge_station_id"])->value("charge_station_name");
+ $busOrder[$i]["charge_station_number"] = Db::table("charge_station")->where("charge_station_id", $busOrder[$i]["charge_station_id"])->value("charge_station_number");
+ $busOrder[$i]["no"] = Db::table("charge_pile")->where("charge_pile_number", $busOrder[$i]["Equipment_number"])->value("no");
+ $busOrder[$i]["parkNo"] = Vinlicense::where("EvcInfoNo", $busOrder[$i]["EvcInfoNo"])->value("ParkNo");
+ $busOrder[$i]["SelfCode"] = Vinlicense::where("EvcInfoNo", $busOrder[$i]["EvcInfoNo"])->value("SelfCode");
+
+ if ($busOrder[$i]["IdentCode"] == 7) {
+ $busOrder[$i]["IdentCode"] = '设备异常';
+ } elseif ($busOrder[$i]["IdentCode"] == 15) {
+ $busOrder[$i]["IdentCode"] = '系统异常';
+ }
+
+ if (strlen((string)$busOrder[$i]['stop_type']) != 0 && $busOrder[$i]['stop_type'] == 0) {
+ $busOrder[$i]['stop_type'] = '正常停止';
+ } elseif ($busOrder[$i]['stop_type'] == 4) {
+ $busOrder[$i]['stop_type'] = '连接器断开';
+ } elseif ($busOrder[$i]['stop_type'] == 5) {
+ $busOrder[$i]['stop_type'] = '电池已充满';
+ } elseif ($busOrder[$i]['stop_type'] == 7) {
+ $busOrder[$i]['stop_type'] = '设备异常';
+ } elseif ($busOrder[$i]['stop_type'] == 8) {
+ $busOrder[$i]['stop_type'] = '枪头被拔下';
+ } elseif ($busOrder[$i]['stop_type'] == 10) {
+ $busOrder[$i]['stop_type'] = '设备故障';
+ } elseif ($busOrder[$i]['stop_type'] == 11) {
+ $busOrder[$i]['stop_type'] = '车辆故障';
+ } elseif ($busOrder[$i]['stop_type'] == 14) {
+ $busOrder[$i]['stop_type'] = '未知';
+ } elseif ($busOrder[$i]['stop_type'] == 15) {
+ $busOrder[$i]['stop_type'] = '系统异常';
+ } elseif ($busOrder[$i]['stop_type'] == 22) {
+ $busOrder[$i]['stop_type'] = '车辆识别失败';
+ } elseif ($busOrder[$i]['stop_type'] == 24) {
+ $busOrder[$i]['stop_type'] = '设备终止';
+ } elseif ($busOrder[$i]['stop_type'] == 25) {
+ $busOrder[$i]['stop_type'] = '互联互通终止';
+ } elseif ($busOrder[$i]['stop_type'] == 26) {
+ $busOrder[$i]['stop_type'] = '平台终止';
+ } elseif ($busOrder[$i]['stop_type'] == 27) {
+ $busOrder[$i]['stop_type'] = 'SOC限制终止';
+ } elseif ($busOrder[$i]['stop_type'] == 13) {
+ $busOrder[$i]['stop_type'] = '急停按钮被按下';
+ } elseif ($busOrder[$i]['stop_type'] == 16) {
+ $busOrder[$i]['stop_type'] = '主动防护';
+ } elseif ($busOrder[$i]['stop_type'] == 6) {
+ $busOrder[$i]['stop_type'] = 'BMS异常';
+ } elseif ($busOrder[$i]['stop_type'] == 12) {
+ $busOrder[$i]['stop_type'] = '账户余额不足';
+ } elseif ($busOrder[$i]['stop_type'] == 31) {
+ $busOrder[$i]['stop_type'] = '操作频繁,请稍后再试';
+ } elseif ($busOrder[$i]['stop_type'] == 32) {
+ $busOrder[$i]['stop_type'] = '请重新插枪启动充电';
+ } elseif ($busOrder[$i]['stop_type'] == 33) {
+ $busOrder[$i]['stop_type'] = '账户超出限额';
+ } elseif (strlen((string)$busOrder[$i]['stop_type']) == 0) {
+ $busOrder[$i]['stop_type'] = null;
+ } else {
+ $busOrder[$i]['stop_type'] = '未知错误';
+ }
+ }
+
+ }
+ return json($busOrder);
+ }
+
+ public function BusOrderPark($start_time = "", $end_time = "", $parkNo = ""): \think\response\Json
+ {
+// $order = new ChargeOrder();
+// $order->OrderList("o-wLg5DGWU_rYwfmp1-1Wck1lKGw");
+ if (!empty($end_time)) {
+ $end_time = date("Y-m-d", strtotime("+1day", strtotime($end_time)));
+ }
+ $busOrder = ["code" => 9001, "Msg" => "请输入正确的参数"];
+ if (empty($parkNo) && empty($start_time) && empty($end_time)) {
+ $busOrder = Db::table("charge_order_gongjiao")->select();
+ } elseif (!empty($parkNo) && empty($start_time) && empty($end_time)) {
+ $vin = Vinlicense::where("ParkNo", $parkNo)->value("EvcInfoNo");
+ if (empty($vin)) {
+ $vin = "NotFound";
+ }
+ $busOrder = Db::table("charge_order_gongjiao")->where('EvcInfoNo', $vin)->select();
+ } elseif (empty($parkNo) && !empty($start_time) && !empty($end_time)) {
+ $busOrder = Db::table("charge_order_gongjiao")->whereBetweenTime('start_time', $start_time, $end_time)->select();
+ } elseif (!empty($parkNo) && !empty($start_time) && !empty($end_time)) {
+ $vin = Vinlicense::where("ParkNo", $parkNo)->value("EvcInfoNo");
+ if (empty($vin)) {
+ $vin = "NotFound";
+ }
+ $busOrder = Db::table("charge_order_gongjiao")->where('EvcInfoNo', $vin)->whereBetweenTime('start_time', $start_time, $end_time)->select();
+ }
+ $busOrder = $busOrder->toArray();
+ for ($i = 0; $i < count($busOrder); $i++) {
+ if (!isset($busOrder['code'])) {
+ $busOrder[$i]["order_id"] = $i + 1;
+ $busOrder[$i]["charge_station_name"] = Db::table("charge_station")->where("charge_station_id", $busOrder[$i]["charge_station_id"])->value("charge_station_name");
+ $busOrder[$i]["charge_station_number"] = Db::table("charge_station")->where("charge_station_id", $busOrder[$i]["charge_station_id"])->value("charge_station_number");
+ $busOrder[$i]["no"] = Db::table("charge_pile")->where("charge_pile_number", $busOrder[$i]["Equipment_number"])->value("no");
+ $busOrder[$i]["parkNo"] = Vinlicense::where("EvcInfoNo", $busOrder[$i]["EvcInfoNo"])->value("ParkNo");
+ $busOrder[$i]["SelfCode"] = Vinlicense::where("EvcInfoNo", $busOrder[$i]["EvcInfoNo"])->value("SelfCode");
+ if ($busOrder[$i]["IdentCode"] == 7) {
+ $busOrder[$i]["IdentCode"] = '设备异常';
+ } elseif ($busOrder[$i]["IdentCode"] == 15) {
+ $busOrder[$i]["IdentCode"] = '系统异常';
+ }
+
+ if (strlen((string)$busOrder[$i]['stop_type']) != 0 && $busOrder[$i]['stop_type'] == 0) {
+ $busOrder[$i]['stop_type'] = '正常停止';
+ } elseif ($busOrder[$i]['stop_type'] == 4) {
+ $busOrder[$i]['stop_type'] = '连接器断开';
+ } elseif ($busOrder[$i]['stop_type'] == 5) {
+ $busOrder[$i]['stop_type'] = '电池已充满';
+ } elseif ($busOrder[$i]['stop_type'] == 7) {
+ $busOrder[$i]['stop_type'] = '设备异常';
+ } elseif ($busOrder[$i]['stop_type'] == 8) {
+ $busOrder[$i]['stop_type'] = '枪头被拔下';
+ } elseif ($busOrder[$i]['stop_type'] == 10) {
+ $busOrder[$i]['stop_type'] = '设备故障';
+ } elseif ($busOrder[$i]['stop_type'] == 11) {
+ $busOrder[$i]['stop_type'] = '车辆故障';
+ } elseif ($busOrder[$i]['stop_type'] == 14) {
+ $busOrder[$i]['stop_type'] = '未知';
+ } elseif ($busOrder[$i]['stop_type'] == 15) {
+ $busOrder[$i]['stop_type'] = '系统异常';
+ } elseif ($busOrder[$i]['stop_type'] == 22) {
+ $busOrder[$i]['stop_type'] = '车辆识别失败';
+ } elseif ($busOrder[$i]['stop_type'] == 24) {
+ $busOrder[$i]['stop_type'] = '设备终止';
+ } elseif ($busOrder[$i]['stop_type'] == 25) {
+ $busOrder[$i]['stop_type'] = '互联互通终止';
+ } elseif ($busOrder[$i]['stop_type'] == 26) {
+ $busOrder[$i]['stop_type'] = '平台终止';
+ } elseif ($busOrder[$i]['stop_type'] == 27) {
+ $busOrder[$i]['stop_type'] = 'SOC限制终止';
+ } elseif ($busOrder[$i]['stop_type'] == 13) {
+ $busOrder[$i]['stop_type'] = '急停按钮被按下';
+ } elseif ($busOrder[$i]['stop_type'] == 16) {
+ $busOrder[$i]['stop_type'] = '主动防护';
+ } elseif ($busOrder[$i]['stop_type'] == 6) {
+ $busOrder[$i]['stop_type'] = 'BMS异常';
+ } elseif ($busOrder[$i]['stop_type'] == 12) {
+ $busOrder[$i]['stop_type'] = '账户余额不足';
+ } elseif ($busOrder[$i]['stop_type'] == 31) {
+ $busOrder[$i]['stop_type'] = '操作频繁,请稍后再试';
+ } elseif ($busOrder[$i]['stop_type'] == 32) {
+ $busOrder[$i]['stop_type'] = '请重新插枪启动充电';
+ } elseif ($busOrder[$i]['stop_type'] == 33) {
+ $busOrder[$i]['stop_type'] = '账户超出限额';
+ } elseif (strlen((string)$busOrder[$i]['stop_type']) == 0) {
+ $busOrder[$i]['stop_type'] = null;
+ } else {
+ $busOrder[$i]['stop_type'] = '未知错误';
+ }
+ }
+ }
+ return json($busOrder);
+ }
+
+ public function ParkNo(): \think\response\Json
+ {
+ $Park = (new \app\model\Vinlicense)->column("ParkNo");
+ $data = [];
+ foreach ($Park as $p) {
+ $data["children"][]["LicenseNumber"] = $p;
+ }
+ return json($data);
+ }
+}
\ No newline at end of file
diff --git a/app/controller/Bus/VinBindLicense.php b/app/controller/Bus/VinBindLicense.php
new file mode 100644
index 0000000..51eee0d
--- /dev/null
+++ b/app/controller/Bus/VinBindLicense.php
@@ -0,0 +1,110 @@
+value("EvcInfoNo");
+ $VinLicense = Vinlicense::where("EvcInfoNo", $vin)->select();
+ return $this->ResponseJson($VinLicense, 200, "Request Success");
+ }
+ $VinLicense = Vinlicense::select();
+ return $this->ResponseJson($VinLicense, 200, "Request Success");
+ }
+
+ /**
+ * @throws ModelNotFoundException
+ * @throws DataNotFoundException
+ * @throws DbException
+ */
+ public function AddVinLicense($vin, $parkNo, $selfCode): \think\response\Json
+ {
+ $checkVin = Vinlicense::where("EvcInfoNo", $vin)->find();
+ $checkLicense = Vinlicense::where("ParkNo", $parkNo)->find();
+ $checkSelfCode = Vinlicense::where("SelfCode", $selfCode)->find();
+ if (empty($checkVin) && empty($checkLicense) && empty($checkSelfCode)) {
+ $AddVinLicense = (new \app\model\Vinlicense)->save([
+ "EvcInfoNo" => $vin,
+ 'ParkNo' => $parkNo,
+ "SelfCode" => $selfCode
+ ]);
+ if ($AddVinLicense == 1) {
+ $NewVinLicense = Vinlicense::where("EvcInfoNo", $vin)->select();
+ return $this->ResponseJson($NewVinLicense, 200, "新增成功");
+ } else {
+ return $this->ResponseJson([], 415, "新增失败");
+ }
+ } else {
+ return $this->ResponseJson([], 416, "Vin或车牌号已存在");
+ }
+ }
+
+ /**
+ * @throws ModelNotFoundException
+ * @throws DataNotFoundException
+ * @throws DbException
+ */
+ public function UpdateVinLicense($id, $vin, $parkNo, $selfCode): \think\response\Json
+ {
+ $oldVin = Vinlicense::where("id", $id)->value('EvcInfoNo');
+ $oldParkNo = Vinlicense::where("id", $id)->value('ParkNo');
+ $oldSelfCode = Vinlicense::where("id", $id)->value('ParkNo');
+ if ($oldVin != $vin) {
+ $checkVin = Vinlicense::where("EvcInfoNo", $vin)->find();
+ if (!empty($checkVin)) {
+ return $this->ResponseJson([], 421, "所输入的vin已存在");
+ }
+ }
+ if ($oldParkNo != $parkNo) {
+ $checkLicense = Vinlicense::where("ParkNo", $parkNo)->find();
+ if (!empty($checkLicense)) {
+ return $this->ResponseJson([], 422, "所输入的车牌号已存在");
+ }
+ }
+
+ if ($oldSelfCode != $selfCode) {
+ $checkLicense = Vinlicense::where("SelfCode", $selfCode)->find();
+ if (!empty($checkLicense)) {
+ return $this->ResponseJson([], 423, "所输入的自编码已存在");
+ }
+ }
+
+ $checkId = Vinlicense::where("id", $id)->find();
+ if (empty($checkId)) {
+ return $this->ResponseJson([], 420, "没有找到该ID");
+ }
+
+ $UpdateVinLicense = Vinlicense::where("id", $id)->save([
+ 'EvcInfoNo' => $vin,
+ 'ParkNo' => $parkNo,
+ 'SelfCode' => $selfCode
+ ]);
+ if ($UpdateVinLicense == 1) {
+ $NewVinLicense = Vinlicense::where("id", $id)->select();
+ return $this->ResponseJson($NewVinLicense, 200, "修改成功");
+ } else {
+ return $this->ResponseJson([], 417, "修改失败");
+ }
+
+ }
+
+ public function DeleteVinLicense($id): \think\response\Json
+ {
+ $DeleteVinLicense = Vinlicense::where("id", $id)->delete();
+ if ($DeleteVinLicense != 0) {
+ return $this->ResponseJson([], 200, "删除成功");
+ } else {
+ return $this->ResponseJson([], 418, "删除失败");
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/app/controller/ChargeOrder.php b/app/controller/ChargeOrder.php
new file mode 100644
index 0000000..1f3873a
--- /dev/null
+++ b/app/controller/ChargeOrder.php
@@ -0,0 +1,1370 @@
+ request()->param('order_number'),
+ 'charge_station_id' => request()->param('charge_station_id'),
+ 'openid' => request()->param('openid'),
+ 'charge_date' => request()->param('charge_date'),
+ 'status' => request()->param('status'),
+ ])->paginate([
+ 'list_rows' => 20,
+ 'query' => request()->param()
+ ]);
+
+ return json($list);
+ }
+
+
+ /**
+ * @throws \think\db\exception\ModelNotFoundException
+ * @throws \think\db\exception\DbException
+ * @throws \think\db\exception\DataNotFoundException
+ */
+ public function FuzzyOrder($charge_station_name = '', $message = '', $start_time = '', $end_time = '', $order = ''): \think\response\Json
+ {
+
+ $where = [];
+
+ if ($message) {
+ $where[] = ['message', 'like', '%' . $message . '%'];
+ }
+
+ if ($charge_station_name) {
+ $charge_station_id = Db::table('charge_station')->where('charge_station_name', $charge_station_name)->value('charge_station_id');
+ if ($charge_station_id) {
+ $where[] = ['charge_station_id', '=', $charge_station_id];
+ }
+ }
+
+ if ($start_time) {
+ $where[] = ['start_time', '>=', $start_time];
+ }
+ if ($end_time) {
+ $where[] = ['start_time', '<=', $end_time];
+ }
+
+
+ $list = Db::table('zxc_charge')
+ ->where($where)
+ ->order('start_time desc')
+ ->field('charge_station_id,order_number,order_id,TotalPower,TotalMoney,ElecMoney,SeviceMoney,end_time,EndTime,DetailMessage,status,start_time,openid')
+ ->select(); // 获取全部数据
+
+
+ foreach ($list as $key => &$value) {
+ $value['charge_station_name'] = Db::table('charge_station')->where('charge_station_id', $value['charge_station_id'])->value('charge_station_name');
+ $phone = Db::table('zxc_user')->where('openid', $value['openid'])->value('phone');
+ $value['phone'] = $phone;
+ }
+
+ return json($list);
+ }
+
+
+ public function GennerateOrder($openid, $station_number, $no, $account)
+ {
+
+ $table = 'zxc_charge_order';
+ $table_user = 'zxc_user';
+
+ $balance = Db::table($table_user)->where('openid', $openid)->value('account');
+
+ $exit = Db::table($table)->where('openid', $openid)->find();
+ $exit2 = Db::table($table)->where('openid', $openid)->order('order_id desc')->value('end_time');
+
+ if (($balance - $account) >= 0 && ($openid == "o-wLg5DGWU_rYwfmp1-1Wck1lKGw" || (empty($exit) || !empty($exit2)))) {
+ return $this->Charge($station_number, $no, $openid, $table, $table_user, $account);
+ } elseif (($balance - $account) < 0) {
+ return json(['code' => 3, 'message' => '余额不足 请充值']);
+ } else {
+ return json(['code' => 1, 'message' => '请先完成当前订单']);
+ }
+ }
+
+
+ protected function Charge($station_number, $no, $openid, $table, $table_user, $account): \think\response\Json
+ {
+
+ $station_id = Db::table('charge_station')->where('charge_station_number', $station_number)->value('charge_station_id');
+ $ConnectorID = Db::table('charge_pile')->where(['charge_station_id' => $station_id, 'no' => $no])->value('ConnectorID');
+ $EquipAuthSeq = Db::table('charge_pile')->where(['charge_station_id' => $station_id, 'no' => $no])->value('EquipAuthSeq');
+ if (empty($EquipAuthSeq)) {
+ $EquipAuthSeq = $this->generate_EquipmentAuth(7);
+ Db::table('charge_pile')->where(['charge_station_id' => $station_id, 'no' => $no])->update(['EquipAuthSeq' => $EquipAuthSeq]);
+ }
+
+ $Hard = new HardMessage();
+ $AuthMessage = $Hard->Get_query_equip_auth($EquipAuthSeq, $ConnectorID);
+
+ if (isset($AuthMessage['FailReason']) && isset($AuthMessage['SuccStat'])) {//认证成功 请求启动充电
+
+ if ($AuthMessage['FailReason'] == 0 && $AuthMessage['SuccStat'] == 0) {
+ $StartChargeSeq = $this->generate_StartChargeSeq(7);
+ ChargeOrderModel::insert(['openid' => $openid, 'StartChargeSeq' => $StartChargeSeq]);
+ $ChargeModel = 2;
+
+ $StartCharge = $Hard->Get_query_start_charge_test($StartChargeSeq, $ConnectorID, 'QRCode', $ChargeModel);
+
+
+ if ($StartCharge['StartChargeSeqStat'] == 1 && $StartCharge['SuccStat'] == 0 && $StartCharge['FailReason'] == 0) {
+ $check = Db::table($table)->where('openid', $openid)->order('order_id desc')->value('end_time');
+ $check2 = Db::table($table)->where('openid', $openid)->find();
+ if ((!empty($check) || empty($check2))) {
+ $order_number = $this->generate_order(6);
+
+ $charge_date = date('Y-m-d', time());
+ $Equipment_number = Db::table('charge_pile')->where([
+ ['charge_station_id', '=', $station_id],
+ ['no', '=', $no]
+ ])->value('charge_pile_number');
+ $mess = [
+ 'order_number' => $order_number,
+ 'charge_station_id' => $station_id,
+ 'openid' => $openid,
+ 'charge_date' => $charge_date,
+ 'Equipment_number' => $Equipment_number,
+ 'StartChargeSeq' => $StartChargeSeq,
+ 'status' => $StartCharge['StartChargeSeqStat'],
+ 'StartChargeSeqStat' => $StartCharge['StartChargeSeqStat'],
+ 'ConnectorID' => $ConnectorID,
+ 'WithholdingMoney' => $account
+ ];
+ Db::table($table_user)->where('openid', $openid)->update(['account' => Db::raw('account-' . $account)]);
+ Db::table($table)->save($mess);
+
+ return json(['code' => 200, 'message' => '订单创建成功', 'order_number' => $order_number, 'info' => Db::table($table)->where(['order_number' => $order_number])->find()]);
+ } else {
+ return json(['code' => 1, 'message' => '请不要点击过快']);
+ }
+ } elseif ($StartCharge['SuccStat'] == 1) {
+ if ($StartCharge['FailReason'] == 0) {
+ return json(['code' => 1, 'message' => '设备认证操作结果失败5']);
+ } elseif ($StartCharge['FailReason'] == 1) {
+ return json(['code' => 1, 'message' => '设备认证操作结果失败 此设备不存在']);
+ } elseif ($StartCharge['FailReason'] == 2) {
+ return json(['code' => 1, 'message' => '设备认证操作结果失败 此设备离线']);
+ } elseif ($StartCharge['FailReason'] == 90) {
+ return json(['code' => 1, 'message' => '设备认证操作结果失败 车辆未备案']);
+ } elseif ($StartCharge['FailReason'] == 91) {
+ return json(['code' => 1, 'message' => '设备认证操作结果失败 该车辆充电中']);
+ } else {
+ return json(['code' => 1, 'message' => '未知错误 设备认证成功 请求充电失败']);
+ }
+ } else {
+ return json(['code' => 1, 'message' => '未知错误 设备认证成功 请求充电失败']);
+ }
+ } elseif ($AuthMessage['SuccStat'] == 1) {
+ if ($AuthMessage['FailReason'] == 0) {
+ return json(['code' => 1, 'message' => '设备认证操作结果失败3']);
+ } elseif ($AuthMessage['FailReason'] == 1) {
+ return json(['code' => 1, 'message' => '设备认证操作结果失败 此设备尚未插枪']);
+ } elseif ($AuthMessage['FailReason'] == 2) {
+ return json(['code' => 1, 'message' => '设备认证操作结果失败 设备检测失败']);
+ } else {
+ return json(['code' => 1, 'message' => '未知错误 设备认证失败4']);
+ }
+ } else {
+ return json(['code' => 1, 'message' => '未知错误 设备认证失败2']);
+ }
+ } else {
+ return json(['code' => 1, 'message' => '未知错误 设备认证失败1']);
+ }
+ }
+
+
+ // 潜江充电模式
+ public function GennerateOrder2()
+ {
+
+ $params = input();
+
+ //启动前验证
+
+ $check = $this->startChargeCheck($params);
+
+ if ($check && $check['code'] == 1) {
+ return json(['code' => 1, 'message' => $check['message']]);
+ }
+
+
+ $openid = $params['openid'];
+ $account = $params['account'];
+ $type = $params['type'];
+
+ //认证成功 生成系统充电订单号
+ $StartChargeSeq = $this->generate_StartChargeSeq(7);
+
+
+ if ($type == 1) {// 即充即退
+//
+// $time = time();
+// Db::table('zxc_charge_order')->save([
+// 'type' => 1,
+// 'openid' => 'obUtOvjCdTSrZTqbjTByESPo6kLE',
+// 'directly_pay_no' => '1217752501201407033233368026',
+// 'directly_pay_status' => 1,
+// 'directly_pay_time' => $time,
+// 'directly_prepaid_amount' => $account,
+// 'WithholdingMoney' => $account,
+// 'start_time' => date('Y-m-d H:i:s', $time),
+// ]);
+//
+// Db::table('zxc_charge')->save([
+// 'type' => 2,
+// 'openid' => 'obUtOvjCdTSrZTqbjTByESPo6kLE',
+// 'out_trade_no' => $StartChargeSeq,
+// 'transaction_id' => '1217752501201407033233368026',
+// 'trade_state' => 1,
+// 'total' => $account,
+// 'payer_total' => $account,
+// 'success_time' => date('Y-m-d H:i:s', $time),
+// ]);
+//
+// \app\model\User::addMoneyLog('obUtOvjCdTSrZTqbjTByESPo6kLE', $account, 2, '用户使用即充即退');
+
+
+ //返回支付信息 生成充电订单
+ $out_trade_no = $this->generate_order(6);
+ $pay_info = (new WechatPay())->directlyConfig($out_trade_no, $params['openid'], $account);
+ $pay_info['StartChargeSeq'] = $StartChargeSeq;
+ return json(['code' => 2, 'message' => '获取支付参数', 'data' => $pay_info]);
+
+// return json(['code' => 200, 'message' => '可以充值', 'data' => ['StartChargeSeq' => $StartChargeSeq]]);
+ } elseif ($type == 2) { // 个人钱包充电
+ // 判断余额
+ // 账户余额
+ $balance = Db::table('zxc_user')->where('openid', $openid)->value('account');
+
+ if ($balance < 20) {
+ return json(['code' => 1, 'message' => '余额不足 请充值']);
+ }
+ return json(['code' => 200, 'message' => '可以充值', 'data' => ['StartChargeSeq' => $StartChargeSeq]]);
+
+ } elseif ($type == 3) { // 企业充电
+ // 判断余额
+
+ } else {
+ return json(['code' => 1, 'message' => '参数错误']);
+ }
+
+ }
+
+ //潜江充电----启动充电
+ public function startCharging()
+ {
+
+
+ $params = input();
+
+ //是否存在订单号
+ $StartChargeSeq = $params['StartChargeSeq'];
+ if (!$StartChargeSeq) {
+ return json(['code' => 1, 'message' => '请求失败']);
+ }
+
+ //启动前验证
+ $check = $this->startChargeCheck($params, true);
+
+ if ($check && $check['code'] == 1) {
+ return json(['code' => 1, 'message' => $check['message']]);
+ }
+
+
+ //生成充电桩唯一标识
+ $charge_pile_info = Db::table('charge_pile')->where('ConnectorID', $params['ConnectorId'])->find();
+ if (empty($charge_pile_info['EquipAuthSeq'])) {
+ $EquipAuthSeq = $this->generate_EquipmentAuth(7);
+ Db::table('charge_pile')->where(['ConnectorID' => $params['ConnectorId']])->update(['EquipAuthSeq' => $EquipAuthSeq]);
+ }
+
+ $result = false;
+ //创建系统订单
+ $order_number = $this->generate_order(6);
+ $charge_date = date('Y-m-d', time());
+ $save_data = [
+ 'StartChargeSeq' => $StartChargeSeq,
+ 'order_number' => $order_number,
+ 'charge_station_id' => $charge_pile_info['charge_station_id'],
+ 'openid' => $params['openid'],
+ 'charge_date' => $charge_date,
+ 'Equipment_number' => $charge_pile_info['charge_pile_number'],
+ 'status' => $StartCharge['StartChargeSeqStat'] ?? '',
+ 'StartChargeSeqStat' => $StartCharge['StartChargeSeqStat'] ?? '',
+ 'ConnectorID' => $params['ConnectorId'],
+ 'WithholdingMoney' => $params['account'],
+ 'type' => $params['type']
+ ];
+
+ if ($params['type'] == 1) {//通过支付后回调产生订单更新订单号
+ $result = Db::table('zxc_charge_order')->where('directly_pay_no', $params['out_trade_no'])->update($save_data);
+ } else if ($params['type'] == 2) {
+ $result = Db::table('zxc_charge_order')->save($save_data);
+ }
+
+ if ($result) {
+ //请求充电
+ $Hard = new HardMessage();
+ $StartCharge = $Hard->Get_query_start_charge_test($StartChargeSeq, $params['ConnectorId'], 'QRCode', 2);
+ if ($StartCharge['StartChargeSeqStat'] != 1) {
+ Db::table('zxc_charge_order')->where(['order_number' => $order_number])->delete();
+
+ return json(['code' => 1, 'message' => '充电启动失败' . $StartCharge['FailReason']]);
+ }
+
+ $info = Db::table('zxc_charge_order')->where(['order_number' => $order_number])->find();
+ return json(['code' => 200, 'message' => '订单创建成功', 'order_number' => $order_number, 'info' => $info]);
+ }
+
+ return json(['code' => 1, 'message' => '系统出错啦~']);
+
+ }
+
+
+ //潜江充电前验证
+ public function startChargeCheck($params, $status = false)
+ {
+
+ //1.订单验证
+ $exit2 = Db::table('zxc_charge_order')
+ ->where('openid', $params['openid'])
+ ->where('end_time', '=', null)
+ ->find();
+ if ($exit2 && !$status) {
+ return ['code' => 1, 'message' => '存在未结束订单'];
+ }
+
+ //2.设备信息验证和更新
+ $charge_pile_info = Db::table('charge_pile')
+ ->where('ConnectorID', $params['ConnectorId'])
+ ->find();
+ $EquipAuthSeq = $charge_pile_info['EquipAuthSeq'];
+ if (empty($EquipAuthSeq)) {
+ $EquipAuthSeq = $this->generate_EquipmentAuth(7);
+ Db::table('charge_pile')
+ ->where(['ConnectorID' => $params['ConnectorId']])
+ ->update(['EquipAuthSeq' => $EquipAuthSeq]);
+ }
+
+ //3设备认证
+ $Hard = new HardMessage();
+ $AuthMessage = $Hard->Get_query_equip_auth($EquipAuthSeq, $params['ConnectorId']);
+ if ($AuthMessage['SuccStat'] != 0) {
+ $arr = [
+ '0' => '无',
+ '1' => '此设备尚未插枪',
+ '2' => '设备检测失败',
+ ];
+ return ['code' => 1, 'message' => $arr[$AuthMessage['FailReason']] ?? '设备认证1-自定义错误信息' . $AuthMessage['FailReason']];
+ }
+ return ['code' => 2];
+ }
+
+ public function QRCode($address, $openid)
+ {
+ $exit = Db::table('user')->where('openid', $openid)->value('area');
+ if (!empty($exit)) {
+ $ConnectorID = substr($address, 7, 13);
+ $OperatorID = substr($address, 21, 9);
+ if ($OperatorID != '395815801') {
+ return json(['code' => 1, 'message' => '运营商出现问题']);
+ }
+ $Equipment = Db::table('charge_pile')->where('ConnectorID', $ConnectorID)->find();
+ $Station_id = $Equipment['charge_station_id'];
+ $Station_number = Db::table('charge_station')->where('charge_station_id', $Station_id)->value('charge_station_number');
+ $Station_name = Db::table('charge_station')->where('charge_station_id', $Station_id)->value('charge_station_name');
+ $no = $Equipment['no'];
+ $status = $Equipment['status'];
+ if ($status == 3 || $status == 4) {
+ return json(['code' => 1, 'message' => '该充电桩已被占用']);
+ } elseif ($status == 255) {
+ return json(['code' => 1, 'message' => '该充电桩故障']);
+ } elseif ($status == 1 || $status == 2) {
+ $kk['station_name'] = $Station_name;
+ $kk['station_number'] = $Station_number;
+ $kk['no'] = $no;
+ return json(['code' => 200, 'message' => '成功', 'data' => $kk]);
+ } elseif ($status == 0) {
+ return json(['code' => 1, 'message' => '该充电桩离网']);
+ }
+
+ } else {
+ return json(['code' => 1, 'message' => '没有获取到地址信息 请先登录']);
+ }
+
+ }
+
+ public function OrderDetail($openid, $order_number)
+ {
+
+ $table = 'zxc_charge_order';
+
+ $StartChargeSeq = Db::table($table)->where('order_number', $order_number)->value('StartChargeSeq');
+ $Equipment_number = Db::table($table)->where('order_number', $order_number)->value('Equipment_number');
+ $message['charge_length'] = null;
+ $status = Db::table($table)->where('order_number', $order_number)->value('status');
+ $end_time = Db::table($table)->where('order_number', $order_number)->value('end_time');
+
+ if (empty($end_time) && ($status == 2)) {
+ $Hard = new HardMessage();
+ $Hard->Get_query_equip_charge_status($StartChargeSeq);
+ }
+
+ $message = Db::table($table)->where('order_number', $order_number)->find();
+ $start_time = Db::table($table)->where('StartChargeSeq', $StartChargeSeq)->value('start_time');
+ $end_time = Db::table($table)->where('StartChargeSeq', $StartChargeSeq)->value('end_time');
+
+ if (isset($message['start_time']) && strtotime($message['start_time']) < strtotime('2099-02-03 00:00:00') && $message['status'] == 4) {
+ $station_type = \app\model\ChargeStation::where('charge_station_id', $message['charge_station_id'])->value('station_type');
+ if ($station_type == 0) {
+ $message['SeviceMoney'] = round($message['TotalPower'] * 0.2, 2);
+ } else {
+ $message['SeviceMoney'] = round($message['TotalPower'] * 0.4, 2);
+ }
+ $message['ElecMoney'] = round($message['TotalMoney'] - $message['SeviceMoney'], 2);
+ } else {
+ $message['ElecMoney'] = Db::table($table)->where('StartChargeSeq', $StartChargeSeq)->value('ElecMoney');
+ $message['SeviceMoney'] = Db::table($table)->where('StartChargeSeq', $StartChargeSeq)->value('SeviceMoney');
+ }
+
+ if (!empty($end_time)) {
+ $charge_length = (strtotime($end_time) - strtotime($start_time)) % 86400 / 3600;
+ Db::table($table)->where('order_number', $order_number)->update(['charge_length' => $charge_length]);
+ $message['charge_length'] = $charge_length;
+ }
+ $charge_station_id = Db::table($table)->where('order_number', $order_number)->value('charge_station_id');
+ $charge_station_number = Db::table('charge_station')->where('charge_station_id', $charge_station_id)->value('charge_station_number');
+ $charge_station_name = Db::table('charge_station')->where('charge_station_id', $charge_station_id)->value('charge_station_name');
+ $no = Db::table('charge_pile')->where('charge_pile_number', $Equipment_number)->value('no');
+ if ($message['TotalPower'] == null) {
+ $message['TotalPower'] = 0;
+ }
+ $message['TotalPower'] = number_format($message['TotalPower'], 3);
+ $message['charge_station_number'] = $charge_station_number;
+ $message['charge_station_name'] = $charge_station_name;
+ $message['no'] = $no;
+ if ($message['status'] == 1) {
+ $message['message'] = '启动中';
+ } elseif ($message['status'] == 2) {
+ $message['message'] = '充电中';
+ } elseif ($message['status'] == 3) {
+ $message['message'] = '停止中';
+ } elseif ($message['status'] == 4) {
+ $message['message'] = '已结束';
+ } elseif ($message['status'] == 5) {
+ $message['message'] = '未知错误';
+ }
+
+
+ if (strlen((string)$message['stop_type']) != 0 && $message['stop_type'] == 0) {
+ $message['stop_type'] = '正常停止';
+ } elseif ($message['stop_type'] == 4) {
+ $message['stop_type'] = '连接器断开';
+ } elseif ($message['stop_type'] == 5) {
+ $message['stop_type'] = '电池已充满';
+ } elseif ($message['stop_type'] == 7) {
+ $message['stop_type'] = '设备异常';
+ } elseif ($message['stop_type'] == 8) {
+ $message['stop_type'] = '枪头被拔下';
+ } elseif ($message['stop_type'] == 10) {
+ $message['stop_type'] = '设备故障';
+ } elseif ($message['stop_type'] == 11) {
+ $message['stop_type'] = '车辆故障';
+ } elseif ($message['stop_type'] == 14) {
+ $message['stop_type'] = '未知';
+ } elseif ($message['stop_type'] == 15) {
+ $message['stop_type'] = '系统异常';
+ } elseif ($message['stop_type'] == 22) {
+ $message['stop_type'] = '车辆识别失败';
+ } elseif ($message['stop_type'] == 24) {
+ $message['stop_type'] = '设备终止';
+ } elseif ($message['stop_type'] == 25) {
+ $message['stop_type'] = '互联互通终止';
+ } elseif ($message['stop_type'] == 26) {
+ $message['stop_type'] = '平台终止';
+ } elseif ($message['stop_type'] == 27) {
+ $message['stop_type'] = 'SOC限制终止';
+ } elseif ($message['stop_type'] == 13) {
+ $message['stop_type'] = '急停按钮被按下';
+ } elseif ($message['stop_type'] == 16) {
+ $message['stop_type'] = '主动防护';
+ } elseif ($message['stop_type'] == 6) {
+ $message['stop_type'] = 'BMS异常';
+ } elseif ($message['stop_type'] == 12) {
+ $message['stop_type'] = '账户余额不足';
+ } elseif ($message['stop_type'] == 31) {
+ $message['stop_type'] = '操作频繁,请稍后再试';
+ } elseif ($message['stop_type'] == 32) {
+ $message['stop_type'] = '请重新插枪启动充电';
+ } elseif ($message['stop_type'] == 33) {
+ $message['stop_type'] = '账户超出限额';
+ } elseif (strlen((string)$message['stop_type']) == 0) {
+ $message['stop_type'] = null;
+ } else {
+ $message['stop_type'] = '未知错误';
+ }
+
+ return json(['code' => 200, 'data' => $message]);
+ }
+
+ public function OrderDetail2($openid, $order_number)
+ {
+
+ $table = 'zxc_charge_order';
+
+
+ $message = Db::table($table)->where('order_number', $order_number)->find();
+
+ $message['charge_length'] = null;
+
+ if (empty($message['end_time']) && ($message['status'] == 2)) {
+ $Hard = new HardMessage();
+ $Hard->Get_query_equip_charge_status($message['StartChargeSeq']);
+ $message = Db::table($table)->where('order_number', $order_number)->find();
+ }
+
+
+ if (isset($message['start_time']) && strtotime($message['start_time']) < strtotime('2099-02-03 00:00:00') && $message['status'] == 4) {
+ $station_type = \app\model\ChargeStation::where('charge_station_id', $message['charge_station_id'])->value('station_type');
+ if ($station_type == 0) {
+ $message['SeviceMoney'] = round($message['TotalPower'] * 0.2, 2);
+ } else {
+ $message['SeviceMoney'] = round($message['TotalPower'] * 0.4, 2);
+ }
+ $message['ElecMoney'] = round($message['TotalMoney'] - $message['SeviceMoney'], 2);
+ }
+
+ if (!empty($message['end_time'])) {
+ $charge_length = (strtotime($message['end_time']) - strtotime($message['start_time'])) % 86400 / 3600;
+ Db::table($table)->where('order_number', $order_number)->update(['charge_length' => $charge_length]);
+ $message['charge_length'] = $charge_length;
+ }
+
+
+ $charge_station_info = Db::table('charge_station')
+ ->where('charge_station_id', $message['charge_station_id'])
+ ->field('charge_station_number,charge_station_name')
+ ->find();
+
+ $no = Db::table('charge_pile')->where('ConnectorID', $message['ConnectorID'])->value('no');
+
+
+ if ($message['TotalPower'] == null) {
+ $message['TotalPower'] = 0;
+ }
+
+ $message['TotalPower'] = number_format($message['TotalPower'], 3);
+ $message['charge_station_number'] = $message['ConnectorID'];
+ $message['charge_station_name'] = $charge_station_info['charge_station_name'];
+ $message['no'] = $no;
+
+ $message_arr = [
+ '1' => '启动中',
+ '2' => '充电中',
+ '3' => '停止中',
+ '4' => '已结束',
+ '5' => '未知错误',
+ ];
+
+ $message['message'] = $message_arr[$message['status']] ?? '未知错误';
+
+
+ if (strlen((string)$message['stop_type']) != 0 && $message['stop_type'] == 0) {
+ $message['stop_type'] = '正常停止';
+ } elseif ($message['stop_type'] == 4) {
+ $message['stop_type'] = '连接器断开';
+ } elseif ($message['stop_type'] == 5) {
+ $message['stop_type'] = '电池已充满';
+ } elseif ($message['stop_type'] == 7) {
+ $message['stop_type'] = '设备异常';
+ } elseif ($message['stop_type'] == 8) {
+ $message['stop_type'] = '枪头被拔下';
+ } elseif ($message['stop_type'] == 10) {
+ $message['stop_type'] = '设备故障';
+ } elseif ($message['stop_type'] == 11) {
+ $message['stop_type'] = '车辆故障';
+ } elseif ($message['stop_type'] == 14) {
+ $message['stop_type'] = '未知';
+ } elseif ($message['stop_type'] == 15) {
+ $message['stop_type'] = '系统异常';
+ } elseif ($message['stop_type'] == 22) {
+ $message['stop_type'] = '车辆识别失败';
+ } elseif ($message['stop_type'] == 24) {
+ $message['stop_type'] = '设备终止';
+ } elseif ($message['stop_type'] == 25) {
+ $message['stop_type'] = '互联互通终止';
+ } elseif ($message['stop_type'] == 26) {
+ $message['stop_type'] = '平台终止';
+ } elseif ($message['stop_type'] == 27) {
+ $message['stop_type'] = 'SOC限制终止';
+ } elseif ($message['stop_type'] == 13) {
+ $message['stop_type'] = '急停按钮被按下';
+ } elseif ($message['stop_type'] == 16) {
+ $message['stop_type'] = '主动防护';
+ } elseif ($message['stop_type'] == 6) {
+ $message['stop_type'] = 'BMS异常';
+ } elseif ($message['stop_type'] == 12) {
+ $message['stop_type'] = '账户余额不足';
+ } elseif ($message['stop_type'] == 31) {
+ $message['stop_type'] = '操作频繁,请稍后再试';
+ } elseif ($message['stop_type'] == 32) {
+ $message['stop_type'] = '请重新插枪启动充电';
+ } elseif ($message['stop_type'] == 33) {
+ $message['stop_type'] = '账户超出限额';
+ } elseif (strlen((string)$message['stop_type']) == 0) {
+ $message['stop_type'] = null;
+ } else {
+ $message['stop_type'] = '未知错误';
+ }
+
+ return json(['code' => 200, 'data' => $message]);
+ }
+
+ public function StationFee()
+ {
+
+ $params = input();
+ $station_number = $params['station_number'] ?? '';
+ $openid = $params['openid'] ?? '';
+ $charge_station_info = Db::table('charge_station')
+ ->where('charge_station_number', $station_number)->find();
+
+ $user_info = Db::table('zxc_user')->where('openid', $openid)->field('type,account,group_id')->find();
+
+ // if ($user_info['type'] == 3) {
+ // $ServiceFee = ServiceFee::where('type', $user_info['type'])->where('group_id', $user_info['group_id'])->where('station_type', $charge_station_info['station_type'])->value('service_fee');
+ // } else {
+ // $ServiceFee = ServiceFee::where('type', $user_info['type'])->where('station_type', $charge_station_info['station_type'])->value('service_fee');
+ // }
+ $ServiceFee = ServiceFee::where('id', 1)->value('service_fee');
+
+ $time_price = $this->returnFree($charge_station_info['ElectricityFee'], $ServiceFee);
+
+
+ $ElectricityFee = str_replace('电费:', '', $charge_station_info['ElectricityFee']);
+ $Elect = explode(',', $ElectricityFee);
+ for ($index = 0; $index < count($Elect); $index++) {
+ $kk['time_interval'] = substr($Elect[$index], 0, 11);
+ $kk['univalence'] = explode(':', $Elect[$index])[3];
+ $ss[] = $kk;
+ }
+
+
+ $ServiceFee = str_replace('服务费:', '', $ServiceFee);
+ $Server = explode(',', $ServiceFee);
+ for ($index = 0; $index < count($Server); $index++) {
+ $ll['time_interval'] = substr($Server[$index], 0, -5);
+ $ll['univalence'] = substr($Server[$index], Strlen($Server[$index]) - 4);
+ $mm[] = $ll;
+ }
+
+ return json(['code' => 200, 'ElectricityFee' => $ss, 'ServiceFee' => $mm, 'data' => $time_price, 'balance' => $user_info ? $user_info['account'] : '0.00']);
+ }
+
+ //改后暂未使用
+ public function QueryPayStatus($openid)
+ {
+ $table = 'zxc_charge_order';
+ $paystatus = Db::table($table)->where('openid', $openid)->order('start_time desc')->value('PayStatus');
+
+ if ($paystatus == 1) {
+ $message['paystatus'] = 1;
+ $message['paymessage'] = '存在订单未支付 无法生成';
+ return json(['code' => 1, 'data' => $message]);
+ } elseif ($paystatus == 2 || empty($paystatus)) {
+ $message['paystatus'] = 2;
+ $message['paymessage'] = '订单已全部支付 可以正常生成订单';
+ return json(['code' => 200, 'data' => $message]);
+ } elseif ($paystatus == 0) {
+ $message['paystatus'] = 0;
+ $message['paymessage'] = '订单未完成 请先完成当前订单';
+ return json(['code' => 1, 'data' => $message]);
+ }
+ }
+
+
+ /**
+ * 显示指定的资源
+ *
+ * @param int $id
+ * @return \think\Response
+ */
+ public function read_order(Request $request)
+ {
+ $data = $request->param();
+ $table = 'zxc_charge_order';
+ $count = Db::table($table)->select()->count();
+ $query = Db::table($table)->paginate(20, $count)->toArray();
+ $i = 0;
+ foreach ($query['data'] as $d) {
+ $query['data'][$i]['order_id'] = $i + 1;
+ if (strtotime($query['data'][$i]['start_time']) < strtotime('2023-02-03 00:00:00') && ($query['data'][$i]['ElecMoney'] + $query['data'][$i]['SeviceMoney']) != $query['data'][$i]['TotalMoney']) {
+ $station_type = \app\model\ChargeStation::where('charge_station_id', $query['data'][$i]['charge_station_id'])->value('station_type');
+ if ($station_type == 0) {
+ $query['data'][$i]['SeviceMoney'] = round(($query['data'][$i]['TotalPower'] * 0.2), 2);
+ } else {
+ $query['data'][$i]['SeviceMoney'] = round(($query['data'][$i]['TotalPower'] * 0.4), 2);
+ }
+ $query['data'][$i]['ElecMoney'] = round($query['data'][$i]['TotalMoney'] - $query['data'][$i]['SeviceMoney'], 2);
+ }
+ $station_name = \app\model\ChargeStation::where('charge_station_id', $query['data'][$i]['charge_station_id'])->value('charge_station_name');
+ $query['data'][$i]['charge_station_name'] = $station_name;
+ $i += 1;
+ }
+ return json($query);
+ }
+
+
+ public function order_all(Request $request)
+ {
+ $data = $request->param();
+ $table = 'zxc_charge_order';
+ $charge_station_name = $data['charge_station_name'];
+ $charge_station_id = Db::table('charge_station')->where('charge_station_name', $charge_station_name)->value('charge_station_id');
+ $list = Db::table($table)->where('charge_station_id', $charge_station_id)->select();
+ return json($list);
+ }
+
+ public function read_equipment(Request $request)
+ {
+ $data = $request->param();
+ $where = [];
+ if (isset($data['area'])) {
+ $where[] = ['street', '=', $data['area']];
+ }
+ if (isset($data['charge_station_name'])) {
+ $where[] = ['charge_station_name', '=', $data['charge_station_name']];
+ }
+
+ if (isset($data['status'])) {
+ $where[] = ['status', '>', 3];
+ }
+
+ $mess = Db::table('charge_pile')->where($where)->orderRaw('charge_station_id asc,CAST(no AS SIGNED) ASC')->paginate([
+ 'list_rows' => 20,
+ 'query' => request()->param()
+ ]);
+ $statusMap = [
+ '1' => '空闲中',
+ '2' => '联通中',
+ '3' => '充电中',
+ '0' => '离网中',
+ '255' => '故障中'
+ ];
+
+ $mess->each(function($item, $key) use ($statusMap) {
+ $item['status_text'] = $statusMap[(int)$item['status']] ?? '未知';
+ $item['charge_station_name'] = Db::table('charge_station')->where('charge_station_id', $item['charge_station_id'])->value('charge_station_name');
+ return $item;
+ });
+
+ return json($mess);
+ }
+
+ public function read_total(Request $request)
+ {
+ $data = $request->param();
+ $charge_station_name = $data['charge_station_name'];
+ $charge_station_id = Db::table('charge_station')->where('charge_station_name', $charge_station_name)->value('charge_station_id');
+
+ $table = 'zxc_charge_order';
+
+ $revenue = Db::table($table)->where('charge_station_id', $charge_station_id)->sum('TotalMoney');
+ $degree = Db::table($table)->where('charge_station_id', $charge_station_id)->sum('TotalPower');
+ $order_num = Db::table($table)->where('charge_station_id', $charge_station_id)->count();
+
+ $message = [
+ 'charge_station_id' => $charge_station_id,
+ 'degree' => round($degree, 2),
+ 'revenue' => round($revenue, 2),
+ 'order_num' => $order_num
+ ];
+ return json($message);
+ }
+
+
+ public function EndOrder($openid, $order_number)
+ {
+ $table = 'zxc_charge_order';
+ $StartChargeSeq = Db::table($table)->where('order_number', $order_number)->value('StartChargeSeq');
+ $ConnectorID = Db::table($table)->where('order_number', $order_number)->value('ConnectorID');
+ $Hard = new HardMessage();
+ $Stop = $Hard->Get_query_stop_charge($StartChargeSeq, $ConnectorID);
+ $StopFailReson = Db::table($table)->where('order_number', $order_number)->value('StopFailreason');
+ if (!empty($StopFailReson) && (int)$StopFailReson == 2) {
+ return json(['code' => 1, 'message' => '设备离线,请耐心等待,请直接拔枪,后续信息会回传']);
+ } elseif (!empty($StopFailReson) && (int)$StopFailReson == 15) {
+ return json(['code' => 1, 'message' => '系统异常,请多次尝试,或直接拔枪,后续信息会回传']);
+ }
+
+ if ($Stop['StartChargeSeqStat'] == 3 && $Stop['SuccStat'] == 0 && $Stop['FailReason'] == 0) {
+ return json(['code' => 200, 'message' => '正在结束充电']);
+ } elseif ($Stop['SuccStat'] == 1) {
+ if ($Stop['FailReason'] == 1) {
+ return json(['code' => 1, 'message' => '请求停止充电失败 此设备不存在']);
+ } elseif ($Stop['FailReason'] == 2) {
+ return json(['code' => 1, 'message' => '请求停止充电失败 此设备离线']);
+ } elseif ($Stop['FailReason'] == 3) {
+ return json(['code' => 1, 'message' => '请求停止充电失败 设备已停止充电']);
+ } elseif ($Stop['FailReason'] == 4) {
+ return json(['code' => 1, 'message' => '请求停止充电失败 订单编号不符合规范']);
+ } else {
+ return json(['code' => 1, 'message' => '请求停止充电失败 系统异常']);
+ }
+ } elseif ($Stop['SuccStat'] == 0 && $Stop['FailReason'] == 0) {
+ return json(['code' => 200, 'message' => '正在结束充电']);
+ } else {
+ return json(['code' => 1, 'message' => '未知原因']);
+ }
+
+ }
+
+// 请求停止充电
+ public function EndOrder2($order_number)
+ {
+
+ $charge_info = Db::table('zxc_charge_order')->where('order_number', $order_number)->find();
+
+
+ $StopFailReson = $charge_info['StopFailreason'];
+ if (!empty($StopFailReson) && (int)$StopFailReson == 2) {
+ return json(['code' => 1, 'message' => '设备离线,请耐心等待,请直接拔枪,后续信息会回传']);
+ } elseif (!empty($StopFailReson) && (int)$StopFailReson == 15) {
+ return json(['code' => 1, 'message' => '系统异常,请多次尝试,或直接拔枪,后续信息会回传']);
+ }
+
+
+ //请求停止充电
+ $Hard = new HardMessage();
+ $Stop = $Hard->Get_query_stop_charge($charge_info['StartChargeSeq'], $charge_info['ConnectorID']);
+
+
+ if ($Stop['StartChargeSeqStat'] == 3 && $Stop['SuccStat'] == 0 && $Stop['FailReason'] == 0) {
+ return json(['code' => 200, 'message' => '正在结束充电']);
+ } elseif ($Stop['SuccStat'] == 1) {
+
+ $arr = [
+ '1' => '请求停止充电失败 此设备不存在',
+ '2' => '请求停止充电失败 此设备离线',
+ '3' => '请求停止充电失败 设备已停止充电',
+ '4' => '请求停止充电失败 订单编号不符合规范'
+
+ ];
+
+ return json(['code' => 1, 'message' => $arr[$Stop['FailReason']] ?? '请求停止充电失败 系统异常']);
+
+ } elseif ($Stop['SuccStat'] == 0 && $Stop['FailReason'] == 0) {
+ return json(['code' => 200, 'message' => '正在结束充电']);
+ } else {
+ return json(['code' => 1, 'message' => '未知原因']);
+ }
+
+ }
+
+
+ public function total()
+ {
+ $already_revenue = ChargeOrderModel::where('status', 1)->sum('revenue');
+ $total_revenue = ChargeOrderModel::sum('revenue');
+ $total_degree = ChargeOrderModel::sum('charge_degree');
+ $message = [
+ '已收益' => $already_revenue,
+ '总收益' => $total_revenue,
+ '总耗电量' => $total_degree
+ ];
+ return json([
+ 'code' => 200,
+ 'message' => $message
+ ]);
+ }
+
+ public function List_ToWechat()
+ {
+ $list = Db::table('charge_order,charge_pile')
+ ->where('charge_order.Equipment_number=charge_pile.charge_pile_number')
+ ->field('order_number,start_time,end_time,charge_length,revenue,stop_type,charge_order.Equipment_number,charge_pile.charge_pile_name,charge_pile.power')
+ ->select()->toArray();
+
+ for ($i = 0; $i < count($list); $i++) {
+ $list[$i]['charge_length'] *= 60;
+ if ($list[$i]['stop_type'] == 1) {
+ $list[$i]['stop_type'] = '正常停止';
+ } elseif ($list[$i]['stop_type'] == 2) {
+ $list[$i]['stop_type'] = '强制停止';
+ } elseif ($list[$i]['stop_type'] == 3) {
+ $list[$i]['stop_type'] = '故障停止';
+ }
+ }
+ return json($list);
+ }
+
+ public function StreetWithName()
+ {
+ $area = Db::table('area_three')->column('area');
+ foreach ($area as $a) {
+ $station = Db::table('charge_station')->where('street', $a)->column('charge_station_name');
+ $i = 0;
+ foreach ($station as $st) {
+ $name = $a . $i . '号充电站';
+ $station_id = Db::table('charge_station')->where(['street' => $a, 'charge_station_name' => $st])->value('charge_station_id');
+ $flag = Db::table('charge_station')->where('charge_station_id', $station_id)->value('charge_station_name');
+ if (empty($flag)) {
+ Db::table('charge_station')->where('charge_station_id', $station_id)->update(['charge_station_name' => $name]);
+ } else {
+ $i += 1;
+ }
+
+ $i += 1;
+ }
+ }
+ $data = [];
+ foreach ($area as $a) {
+ $station_data = [];
+ $station = Db::table('charge_station')->where('street', $a)->column('charge_station_name');
+ $i = 1;
+ foreach ($station as $s) {
+ array_push($station_data, ['station' => $s]);
+ $i += 1;
+ }
+ array_push($data, ['station' => $a, 'children' => $station_data]);
+ }
+ return json($data);
+
+ }
+
+ public function OrderList($openid)
+ {
+
+ $table = 'zxc_charge_order';
+ $list = Db::table($table)->where('openid', $openid)->order('order_id desc')->select()->toArray();
+ $i = 0;
+ foreach ($list as $l) {
+ if (!empty($l['end_time']) && ($l['start_time'] != $l['end_time']) && ($l['status'] == 2 || $l['status'] == 5)) {
+ Db::table($table)->where('order_number', $l['order_number'])->save(['status' => 4, 'StartChargeSeqStat' => 4, 'TotalMoney' => round($l['WithholdingMoney'] - $l['FeedbackMoney'], 2)]);
+ } elseif (!empty($l['end_time']) && ($l['start_time'] == $l['end_time'])) {
+ Db::table($table)->where('order_number', $l['order_number'])->save(['status' => 5, 'StartChargeSeqStat' => 5]);
+ } elseif (empty($l['end_time']) && $l['status'] == 4 && empty($l['FeedbackMoney'])) {
+ $this->AmendmentOrders($openid, $table, $l['StartChargeSeq'], $l['WithholdingMoney']);
+ }
+ }
+ $list = Db::table($table)->where('openid', $openid)->order('order_id desc')->select()->toArray();
+ foreach ($list as $l) {
+ if ($l['status'] == 1 || $l['status'] == 2 || $l['status'] == 3) {
+ $list[$i]['status'] = '正在充电中';
+ } elseif ($l['status'] == 4) {
+ $list[$i]['status'] = '充电完成';
+ } else {
+ $list[$i]['status'] = '系统异常';
+ }
+ $list[$i]['TotalMoney'] = sprintf("%01.2f", $list[$i]['TotalMoney']);
+ $i += 1;
+ }
+ return json($list);
+ }
+
+ public function OrderList2($openid)
+ {
+
+ $table = 'zxc_charge_order';
+ $list = Db::table($table)->where('openid', $openid)->order('order_id desc')->select()->toArray();
+ $i = 0;
+ foreach ($list as $l) {
+ if (!empty($l['end_time']) && ($l['start_time'] != $l['end_time']) && ($l['status'] == 2 || $l['status'] == 5)) {
+ Db::table('zxc_charge_order')->where('order_number', $l['order_number'])->save(['status' => 4, 'StartChargeSeqStat' => 4, 'TotalMoney' => round($l['WithholdingMoney'] - $l['FeedbackMoney'], 2)]);
+ } elseif (!empty($l['end_time']) && ($l['start_time'] == $l['end_time'])) {
+ Db::table('zxc_charge_order')->where('order_number', $l['order_number'])->save(['status' => 5, 'StartChargeSeqStat' => 5]);
+ } elseif (empty($l['end_time']) && $l['status'] == 4 && empty($l['FeedbackMoney'])) {
+ $this->AmendmentOrders($openid, 'zxc_charge_order', $l['StartChargeSeq'], $l['WithholdingMoney']);
+ }
+
+ }
+ $list = Db::table($table)->where('openid', $openid)->field('order_number,start_time,end_time,TotalMoney,status,PayStatus,WithholdingMoney,FeedbackMoney,StartChargeSeqStat,StartChargeSeq')->order('order_id desc')->select()->toArray();
+ foreach ($list as $l) {
+ if ($l['status'] == 1 || $l['status'] == 2 || $l['status'] == 3) {
+ $list[$i]['status'] = '正在充电中';
+ } elseif ($l['status'] == 4) {
+ $list[$i]['status'] = '充电完成';
+ } else {
+ $list[$i]['status'] = '系统异常';
+ }
+ $list[$i]['TotalMoney'] = sprintf("%01.2f", $list[$i]['TotalMoney']);
+ $i += 1;
+ }
+ return json($list);
+ }
+
+ public function AmendmentAccount($table, $StartChargeSeq)
+ {
+ $hard = new HardMessage();
+ $data = $hard->Get_query_equip_charge_status_test($StartChargeSeq);
+ $TotalMoney = Db::table($table)->where('StartChargeSeq', $StartChargeSeq)->value('TotalMoney');
+ $TotalMoney = round($TotalMoney, 2);
+ if ($data['code'] == 200 && $TotalMoney == $data['data']['TotalMoney']) {
+ Db::table($table)->where('StartChargeSeq', $StartChargeSeq)->save([
+ 'TotalPower' => $data['data']['TotalPower'],
+ 'ElecMoney' => $data['data']['ElecMoney'],
+ 'SeviceMoney' => $data['data']['SeviceMoney'],
+ ]);
+ }
+ }
+
+
+ protected function AmendmentOrders($openid, $table, $StartChargeSeq, $WithholdingMoney)
+ {
+ $hard = new HardMessage();
+ $data = $hard->Get_query_equip_charge_status_test($StartChargeSeq);
+ if ($data['code'] == 200) {
+ $FeedbackMoney = $WithholdingMoney - $data['data']['TotalMoney'];
+ $table_user = 'zxc_user';
+ $check = Db::table($table)->where('StartChargeSeq', $StartChargeSeq)->value('FeedbackMoney');
+ if (empty($check)) {
+ Db::table($table_user)->where('openid', $openid)->update(['account' => Db::raw('account+' . round($FeedbackMoney, 2))]);
+ Db::table($table)->where('StartChargeSeq', $StartChargeSeq)->save([
+ 'end_time' => $data['data']['EndTime'],
+ 'charge_degree' => $data['data']['TotalPower'],
+ 'stop_type' => 25,
+ 'TotalPower' => $data['data']['TotalPower'],
+ 'ElecMoney' => $data['data']['ElecMoney'],
+ 'SeviceMoney' => $data['data']['SeviceMoney'],
+ 'TotalMoney' => $data['data']['TotalMoney'],
+ 'Soc' => $data['data']['Soc'],
+ 'DetailMessage' => $data['data']['DetailMessage'],
+ 'FeedbackMoney' => $FeedbackMoney,
+ 'status' => $data['data']['StartChargeSeqStat']
+ ]);
+ }
+ }
+ }
+
+ public function OrderNum($openid)
+ {
+ $table = 'zxc_charge_order';
+ $count = Db::table($table)->where('openid', $openid)->field('order_number,start_time,end_time,revenue,status')->count();
+
+ return json(['code' => 200, 'message' => '请求成功', 'count' => $count]);
+ }
+
+ public function RechargeRecord($openid)
+ {
+ $table = 'zxc_recharge';
+ $list = Db::table($table)->where('openid', $openid)->order('id desc')->select()->toArray();
+ $i = 0;
+ foreach ($list as $l) {
+ $list[$i]['total'] /= 100;
+ $list[$i]['payer_total'] /= 100;
+ if ($list[$i]['trade_state'] == 'SUCCESS') {
+ $list[$i]['trade_state'] = '支付成功';
+ } else {
+ $list[$i]['trade_state'] = '支付失败';
+ }
+ $i += 1;
+ }
+ return json($list);
+ }
+
+ public function RechargeAll($start_time = '', $end_time = '')
+ {
+ if (!empty($end_time)) {
+ $end_time = date("Y-m-d", strtotime("+1day", strtotime($end_time)));
+ }
+ $query = Db::table('zxc_recharge')->select()->toArray();
+ $i = 0;
+ foreach ($query as $d) {
+ $query[$i]['id'] = $i + 1;
+ $query[$i]['total'] = round($query[$i]['total'] / 100, 2);
+ $query[$i]['payer_total'] = round($query[$i]['payer_total'] / 100, 2);
+ $i += 1;
+ }
+ return json($query);
+ }
+
+ public function RechargeAllExport($start_time = '', $end_time = '')
+ {
+
+
+ $where = [];
+ if ($start_time) {
+ $where[] = ['success_time', '>=', $start_time];
+ }
+ if ($end_time) {
+ $where[] = ['success_time', '<=', $end_time];
+ }
+
+
+ $list = Db::table('zxc_recharge')->where($where)->order('id desc')->select()->toArray();
+ foreach ($list as $key => &$value) {
+
+ $value['total'] = round($value['total'] / 100, 2);
+ $value['payer_total'] = round($value['payer_total'] / 100, 2);
+
+ $table = 'zxc_user';
+ $phone = Db::table($table)->where('openid', $value['openid'])->value('phone');
+ $value['phone'] = $phone;
+
+ }
+
+ return json($list);
+
+ }
+
+ public function OrderExport($charge_station_name = '', $start_time = '', $end_time = '')
+ {
+
+
+ $where = [];
+
+ if ($charge_station_name) {
+ $charge_station_id = Db::table('charge_station')->where('charge_station_name', $charge_station_name)->value('charge_station_id');
+ if ($charge_station_id) {
+ $where[] = ['charge_station_id', '=', $charge_station_id];
+ }
+ }
+
+ if ($start_time) {
+ $where[] = ['start_time', '>=', $start_time];
+ }
+ if ($end_time) {
+ $where[] = ['start_time', '<=', $end_time];
+ }
+
+ $list = Db::table('zxc_charge_order')
+ ->where($where)
+ ->field('charge_station_id,order_number,order_id,TotalPower,TotalMoney,ElecMoney,SeviceMoney,end_time,EndTime,DetailMessage,status,start_time,openid')
+ ->order('start_time DESC')
+ ->select(); // 获取全部数据
+
+
+ foreach ($list as $key => &$value) {
+ $value['charge_station_name'] = Db::table('charge_station')->where('charge_station_id', $value['charge_station_id'])->value('charge_station_name');
+
+ $table = 'zxc_user';
+ $phone = Db::table($table)->where('openid', $value['openid'])->value('phone');
+ $value['phone'] = $phone;
+ }
+ return json($list);
+ }
+
+ /**
+ * @throws DataNotFoundException
+ * @throws ModelNotFoundException
+ * @throws DbException
+ */
+ public function OrderQuery($message)
+ {
+
+ $table = 'zxc_charge_order';
+ $query = Db::table($table)->where('openid', 'like', '%' . $message . '%')->select()->toArray();
+ $i = 0;
+ foreach ($query as $d) {
+ if (strtotime($query[$i]['start_time']) < strtotime('2023-02-03 00:00:00') && ($query[$i]['ElecMoney'] + $query[$i]['SeviceMoney']) != $query[$i]['TotalMoney']) {
+ $station_type = \app\model\ChargeStation::where('charge_station_id', $d['charge_station_id'])->value('station_type');
+ if ($station_type == 0) {
+ $query[$i]['SeviceMoney'] = round(($query[$i]['TotalPower'] * 0.2), 2);
+ } else {
+ $query[$i]['SeviceMoney'] = round(($query[$i]['TotalPower'] * 0.4), 2);
+ }
+ $query[$i]['ElecMoney'] = round($query[$i]['TotalMoney'] - $query[$i]['SeviceMoney'], 2);
+ }
+ $query[$i]['order_id'] = $i + 1;
+ $query[$i]["charge_station_name"] = Db::table('charge_station')->where('charge_station_id', $query[$i]['charge_station_id'])->value('charge_station_name');
+ $i += 1;
+ }
+ return json(['data' => $query]);
+ }
+
+ /**
+ * @param $order
+ * @param string $union
+ * @return string
+ */
+ protected function getStr($order, string $union): string
+ {
+ if (!empty($order) && (int)$order == 1) {
+ $union .= ' AND ' . ' (status = 1 or status = 2 or status = 3)';
+ } elseif (!empty($order) && (int)$order == 2) {
+ $union .= ' AND ' . ' status = 4';
+ } elseif (!empty($order) && (int)$order == 3) {
+ $union .= ' AND ' . ' status = 5';
+ }
+ return $union;
+ }
+
+
+ protected function getSelect1($order, $query)
+ {
+ if (!empty($order) && (int)$order == 1) {
+ $query = $query->whereOr('status', 1)->whereOr('status', 2)->whereOr('status', 3)->select();
+ } elseif (!empty($order) && (int)$order == 2) {
+ $query = $query->whereOr('status', 4)->select();
+ } elseif (!empty($order) && (int)$order == 3) {
+ $query = $query->whereOr('status', 5)->select();
+ } else {
+ $query = $query->select();
+ }
+ return $query;
+ }
+
+
+ // 查询充电桩信息
+ public function getChargePileNew($start_time = "", $end_time = "", $station_name = [], $selectt = "", $listQuery = "")
+ {
+ $station_name = array_merge(...array_map(fn($item) => json_decode($item, true), $station_name));
+
+ $statusMap = [
+ '1' => '空闲中',
+ '2' => '联通中',
+ '3' => '充电中',
+ '0' => '离网中',
+ '255' => '故障中'
+ ];
+
+ $where = [];
+
+ if (!empty($station_name)) {
+ $charge_station_ids = Db::table('charge_station')->where('charge_station_name', 'in', implode(',', $station_name))->column('charge_station_id');
+
+ $where[] = ['charge_station_id', 'in', $charge_station_ids];
+
+ }
+ $pileList = Db::table('charge_pile')->where($where)->order('charge_station_id,ConnectorID')->select()->toArray();
+
+// 获取所有充电站ID
+ $stationIds = array_unique(array_column($pileList, 'charge_station_id'));
+// 批量查询充电站名称
+ $stations = Db::table('charge_station')
+ ->whereIn('charge_station_id', $stationIds)
+ ->column('charge_station_name', 'charge_station_id');
+
+
+ $where = [];
+ if (!empty($station_name)) {
+ $charge_station_ids = Db::table('charge_station')->where('charge_station_name', 'in', $station_name)->column('charge_station_id');
+
+ $ids = array_map('intval', $charge_station_ids); // 强制转为整数
+ $where[] = ['charge_station_id', 'in', implode(',', $ids)];
+
+ }
+
+
+ if (!empty($selectt) && !empty($listQuery)) {
+
+ if ($selectt == 1) {
+ // 当天查询 (格式: YYYY-MM-DD 00:00:00)
+ $listQuery = $listQuery . ' 00:00:00';
+
+ $where[] = ['charge_date', '=', $listQuery];
+
+
+ } elseif ($selectt == 3) {
+ // 当月查询 (格式: YYYY-MM)
+ $monthStart = date('Y-m-01 00:00:00', strtotime($listQuery));
+ $monthEnd = date('Y-m-t 23:59:59', strtotime($listQuery));
+
+ $where[] = ['charge_date', '>=', $monthStart];
+ $where[] = ['charge_date', '<=', $monthEnd];
+
+ } elseif ($selectt == 5) {
+ // 当年查询 (格式: YYYY)
+ $yearStart = date('Y-01-01 00:00:00', strtotime($listQuery));
+ $yearEnd = date('Y-12-31 23:59:59', strtotime($listQuery));
+
+ $where[] = ['charge_date', '>=', $yearStart];
+ $where[] = ['charge_date', '<=', $yearEnd];
+ }
+
+ } else {
+ if (!empty($start_time)) {
+
+ $where[] = ['start_time', '>=', $start_time];
+ }
+ if (!empty($end_time)) {
+
+ $where[] = ['start_time', '<=', $end_time];
+ }
+ }
+
+
+ $allOrders = Db::table('zxc_charge_order')
+ ->where($where)
+ ->order('charge_station_id ASC,ConnectorID')
+ ->select()->toArray();
+
+
+ $ordersByConnector = [];
+ foreach ($allOrders as $order) {
+ $connectorId = $order['ConnectorID'];
+ if (!isset($ordersByConnector[$connectorId])) {
+ $ordersByConnector[$connectorId] = [];
+ }
+ $ordersByConnector[$connectorId][] = $order;
+ }
+ foreach ($pileList as &$pile) {
+ // 设置状态文本
+ $pile['status_text'] = $statusMap[$pile['status']] ?? '未知状态';
+
+ // 设置充电站名称
+ $pile['charge_station_name'] = $stations[$pile['charge_station_id']] ?? '未知电站';
+
+ // 初始化统计数据
+ $pile['totalPower'] = 0; // 总电量(kWh)
+ $pile['totalTime'] = 0; // 总时长(秒)
+ $pile['totalPrice'] = 0; // 总费用(元)
+
+ // 获取该充电桩的所有订单
+ $connectorId = $pile['ConnectorID'];
+ if (isset($ordersByConnector[$connectorId])) {
+ foreach ($ordersByConnector[$connectorId] as $order) {
+ // 计算充电时长(秒)
+ if (!empty($order['end_time']) && !empty($order['start_time'])) {
+ $startTime = strtotime($order['start_time']);
+ $endTime = strtotime($order['end_time']);
+ if ($startTime && $endTime && $endTime > $startTime) {
+ $pile['totalTime'] += ($endTime - $startTime);
+ }
+ }
+
+ // 累加电量和费用
+ $pile['totalPower'] += floatval($order['TotalPower'] ?? 0);
+ $pile['totalPrice'] += floatval($order['TotalMoney'] ?? 0);
+ }
+ }
+
+ // 将秒转换为小时:分钟:秒格式
+ $pile['totalTimeFormatted'] = number_format(($pile['totalTime'] / 3600), 4);
+
+
+ // 格式化金额和电量
+ $pile['totalPrice'] = number_format($pile['totalPrice'], 2);
+ $pile['totalPower'] = number_format($pile['totalPower'], 2);
+ }
+
+
+ return $pileList;
+ }
+}
+
+
diff --git a/app/controller/ChargeStation.php b/app/controller/ChargeStation.php
new file mode 100644
index 0000000..029b07f
--- /dev/null
+++ b/app/controller/ChargeStation.php
@@ -0,0 +1,1120 @@
+1 ORDER BY charge_station_id";
+ $message = Db::query($sql);
+ foreach ($message as $m) {
+ $charge_station_id = $m['charge_station_id'];
+ $pile_number = $m['pile_number'];
+ ChargeStationModel::where('charge_station_id', $charge_station_id)->update(['charge_pile_num' => $pile_number]);
+ }
+ $list = ChargeStationModel::withSearch(['charge_station_name', 'station_type', 'city', 'area', 'street', 'address', 'price'], [
+ 'charge_station_name' => request()->param('charge_station_name'),
+ 'station_type' => request()->param('station_type'),
+ 'city' => request()->param('city'),
+ 'area' => request()->param('area'),
+ 'street' => request()->param('street'),
+ 'address' => request()->param('address'),
+ 'price' => request()->param('price')
+ ])->paginate([
+ 'list_rows' => 20,
+ 'query' => request()->param()
+ ]);
+// return Db::getLastSql();
+ return json($list);
+ }
+
+ public function station_all()
+ {
+ $sql = "SELECT charge_station_id,count(charge_station_id) pile_number FROM charge_pile GROUP BY charge_station_id HAVING count(charge_station_id)>1 ORDER BY charge_station_id";
+ $message = Db::query($sql);
+ foreach ($message as $m) {
+ $charge_station_id = $m['charge_station_id'];
+ $pile_number = $m['pile_number'];
+ ChargeStationModel::where('charge_station_id', $charge_station_id)->update(['charge_pile_num' => $pile_number]);
+ }
+ $list = ChargeStationModel::select();
+// return Db::getLastSql();
+ return json($list);
+ }
+
+ /**
+ * 显示创建资源表单页.
+ *
+ * @return \think\Response
+ */
+ public function create()
+ {
+ //
+ }
+
+ /**
+ * 保存新建的资源
+ *
+ * @param \think\Request $request
+ * @return \think\Response
+ */
+ public function save(Request $request)
+ {
+ $data = $request->param();
+ $charge_station_name = $data['charge_station_name'];
+ $id = ChargeStationModel::where('charge_station_name', $charge_station_name)->value('charge_station_id');
+ if (empty($id)) {
+ $message = [
+ 'charge_station_name' => $data['charge_station_name'],
+ 'station_type' => $data['station_type'],
+ 'city' => $data['city'],
+ 'area' => $data['area'],
+ 'street' => $data['street'],
+ 'address' => $data['address'],
+ 'charge_pile_num' => $data['charge_pile_num'],
+ 'charge_station_phone' => $data['charge_station_phone'],
+ 'longitude' => $data['longitude'],
+ 'latitude' => $data['latitude'],
+ 'price' => $data['price']
+ ];
+ $result = ChargeStationModel::create($message);
+ if ($result != false) {
+ return json(['code' => 200, 'massage' => '增加成功']);
+ } else {
+ return json(['code' => 1, 'massage' => '增加失败']);
+ }
+ }
+ }
+
+ /**
+ * 显示指定的资源
+ *
+ * @param int $id
+ * @return \think\Response
+ */
+ public function read($id)
+ {
+ //
+ }
+
+ /**
+ * 显示编辑资源表单页.
+ *
+ * @param int $id
+ * @return \think\Response
+ */
+ public function edit($id)
+ {
+ //
+ }
+
+ /**
+ * 保存更新的资源
+ *
+ * @param \think\Request $request
+ * @param int $id
+ * @return \think\Response
+ */
+ public function update(Request $request, $id)
+ {
+ //
+ }
+
+ /**
+ * 删除指定资源
+ *
+ * @param int $id
+ * @return \think\Response
+ */
+ public function delete($id)
+ {
+ //
+ }
+
+ public function price_update(Request $request)
+ {
+ $data = $request->param();
+ $price = $data['price'];
+ $id = $data['charge_station_id'];
+ $id_message = ChargeStationModel::where('charge_station_id', $id)->find();
+ $time = date('Y-m-d H:i:s');
+ if (!empty($id_message)) {
+ $result = ChargeStationModel::update([
+ 'ElectricityFee' => $price
+ ], ['charge_station_id' => $id]);
+ if ($result != null) {
+ Db::table('charge_station')->where('charge_station_id', $id)->update(
+ ['last_update_time' => $time]
+ );
+ return json(['code' => 200, 'massage' => '更新成功', 'update_time' => $time]);
+ }
+ } else {
+ return json(['code' => 1, 'massage' => '更新价格失败']);
+ }
+ }
+
+
+ public function InnerChargeStation($station_number, $openid, $lat, $lng)
+ {
+ $sql = "SELECT charge_station_id,count(charge_station_id) pile_number FROM charge_pile GROUP BY charge_station_id HAVING count(charge_station_id)>1 ORDER BY charge_station_id";
+ $message = Db::query($sql);
+ foreach ($message as $m) {
+ $charge_station_id = $m['charge_station_id'];
+ $pile_number = $m['pile_number'];
+ ChargeStationModel::where('charge_station_id', $charge_station_id)->update(['charge_pile_num' => $pile_number]);
+ }
+
+ $charge_station_number = $station_number;
+ $station_id = Db::table('charge_station')->where('charge_station_number', $charge_station_number)->value('charge_station_id');
+ $station_name = Db::table('charge_station')->where('charge_station_number', $charge_station_number)->value('charge_station_name');
+ $free = 0;
+ $occupy = 0;
+ $fault = 0;
+ $i = 1;
+ $mess = Db::table('charge_pile')->where('charge_station_id', $station_id)->select();
+ foreach ($mess as $m) {
+ if ($m['status'] == 1) {
+ $free += 1;
+ } elseif ($m['status'] == 2) {
+ $occupy += 1;
+ } elseif ($m['status'] == 3) {
+ $occupy += 1;
+ } elseif ($m['status'] == 255) {
+ $fault += 1;
+ }
+ $no = Db::table('charge_pile')->where('charge_pile_id', $m['charge_pile_id'])->value('no');
+ if ($no == null) {
+ Db::table('charge_pile')->where('charge_pile_id', $m['charge_pile_id'])->update(['no' => $i]);
+ }
+ $i += 1;
+ }
+ $data_station = [
+ 'pile_free' => $free,
+ 'pile_occupy' => $occupy,
+ 'pile_fault' => $fault
+ ];
+ Db::table('charge_station')->where('charge_station_id', $station_id)->update($data_station);
+ $lat1 = $lat;
+ $lng1 = $lng;
+ $lat2 = Db::table('charge_station')->where('charge_station_id', $station_id)->value('latitude');
+ $lng2 = Db::table('charge_station')->where('charge_station_id', $station_id)->value('longitude');
+ $distance = $this->getDistance($lat1, $lng1, $lat2, $lng2);
+ $s = 0;
+ $no_mess = Db::table('charge_pile')->where('charge_station_id', $station_id)->field('no,status,ConnectorId,VoltageUpperLimits')->orderRaw('CAST(no AS SIGNED) ASC')->select()->toArray();
+ $xian = 0;
+ foreach ($no_mess as $m) {
+ if ($m['status'] == 1) {
+ $xian++;
+ $no_mess[$s]['code'] = '1';
+ $no_mess[$s]['status'] = '空闲中';
+ } elseif ($m['status'] == 2) {
+ $no_mess[$s]['code'] = '2';
+ $no_mess[$s]['status'] = '占用(未充电)';
+ } elseif ($m['status'] == 3) {
+ $no_mess[$s]['code'] = '3';
+ $no_mess[$s]['status'] = '占用(充电中)';
+ } elseif ($m['status'] == 255) {
+ $no_mess[$s]['code'] = '255';
+ $no_mess[$s]['status'] = '故障中';
+ } elseif ($m['status'] == 0) {
+ $no_mess[$s]['code'] = '0';
+ $no_mess[$s]['status'] = '离网中';
+ }
+ $s += 1;
+ }
+ $Type = Db::table('charge_station')->where('charge_station_id', $station_id)->value('station_type');
+ if ((int)$Type == 0) {
+ $Type = '快充';
+ } elseif ((int)$Type == 1) {
+ $Type = '慢充';
+ }
+
+ $table = 'zxc_user_collect';
+ $collect = Db::table($table)->where('openid', $openid)->where('charge_station_id', $station_id)->find();
+ if (empty($collect)) {
+ $is_collect = 0;
+ $collect_message = '收藏';
+ } else {
+ $is_collect = 1;
+ $collect_message = '取消收藏';
+ }
+ $info = Db::table('charge_station')->where('charge_station_id', $station_id)->field('longitude,latitude,address,ElectricityFee,ServiceFee')->find();
+ $longitude = $info['longitude'];
+ $latitude = $info['latitude'];
+ $address = $info['address'];
+ $electrovalence = $this->returnFree($info['ElectricityFee'], $info['ServiceFee']);
+
+ $info2 = [
+ 'electrovalence' => $electrovalence,
+ 'station_name' => $station_name,
+ 'distance' => $distance,
+ 'is_collect' => $is_collect,
+ 'collect_message' => $collect_message,
+ 'pile' => $no_mess,
+ 'type' => $Type,
+ 'xian' => $xian,
+ ];
+ return json(array_merge($info, $info2));
+ }
+
+ public function charge_station_withpile(Request $request)
+ {
+ $sql = "SELECT charge_station_id,count(charge_station_id) pile_number FROM charge_pile GROUP BY charge_station_id HAVING count(charge_station_id)>1 ORDER BY charge_station_id";
+ $message = Db::query($sql);
+ foreach ($message as $m) {
+ $charge_station_id = $m['charge_station_id'];
+ $pile_number = $m['pile_number'];
+ ChargeStationModel::where('charge_station_id', $charge_station_id)->update(['charge_pile_num' => $pile_number]);
+ }
+ $data = $request->param();
+ $charge_station_number = $data['charge_station_number'];
+ $station_id = Db::table('charge_station')->where('charge_station_number', $charge_station_number)->value('charge_station_id');
+ $station_name = Db::table('charge_station')->where('charge_station_number', $charge_station_number)->value('charge_station_name');
+ $free = 0;
+ $occupy = 0;
+ $fault = 0;
+ $i = 1;
+ $mess = Db::table('charge_pile')->where('charge_station_id', $station_id)->select();
+ foreach ($mess as $m) {
+ if ($m['status'] == 1) {
+ $free += 1;
+ } elseif ($m['status'] == 2) {
+ $occupy += 1;
+ } elseif ($m['status'] == 3) {
+ $occupy += 1;
+ } elseif ($m['status'] == 255) {
+ $fault += 1;
+ }
+ $no = Db::table('charge_pile')->where('charge_pile_id', $m['charge_pile_id'])->value('no');
+ if ($no == null) {
+ Db::table('charge_pile')->where('charge_pile_id', $m['charge_pile_id'])->update(['no' => $i]);
+ }
+ $i += 1;
+ }
+ $data_station = [
+ 'pile_free' => $free,
+ 'pile_occupy' => $occupy,
+ 'pile_fault' => $fault
+ ];
+ Db::table('charge_station')->where('charge_station_id', $station_id)->update($data_station);
+ $s = 0;
+ $no_mess = Db::table('charge_pile')->where('charge_station_id', $station_id)->field('no,status')->select()->toArray();
+ foreach ($no_mess as $m) {
+ if ($m['status'] == 1) {
+ $no_mess[$s]['status'] = '空闲中';
+ } elseif ($m['status'] == 2) {
+ $no_mess[$s]['status'] = '联通中';
+ } elseif ($m['status'] == 3) {
+ $no_mess[$s]['status'] = '充电中';
+ } elseif ($m['status'] == 0) {
+ $no_mess[$s]['status'] = '离网中';
+ } elseif ($m['status'] == 255) {
+ $no_mess[$s]['status'] = '故障中';
+ } else {
+ $no_mess[$s]['status'] = '未知状态';
+ }
+ $s += 1;
+ }
+ $info = [
+ 'charge_station_number' => $charge_station_number,
+ 'station_name' => $station_name,
+ 'pile' => $no_mess
+ ];
+ return json($info);
+ }
+
+ public function getDateFromRange($startdate, $enddate)
+ {
+
+ $stimestamp = strtotime($startdate);
+ $etimestamp = strtotime($enddate);
+ // 计算日期段内有多少天
+ $days = ($etimestamp - $stimestamp) / 86400;
+ // 保存每天日期
+ $date = array();
+ for ($i = 0; $i < $days; $i++) {
+
+ $date[] = date('Y-m-d', $stimestamp + (86400 * $i));
+ }
+
+ return $date;
+ }
+
+ public function Order_Total(Request $request)
+ {
+ $data = $request->param();
+
+// 基础UNION查询
+// $unionSql = "(SELECT charge_station_id, order_number, order_id, TotalPower, TotalMoney,
+// ElecMoney, SeviceMoney, end_time, EndTime, DetailMessage, status,
+// start_time, openid, ConnectorID, charge_date
+// FROM charge_order_qianlongzhiyaozhan)
+// UNION ALL
+// (SELECT charge_station_id, order_number, order_id, TotalPower, TotalMoney,
+// ElecMoney, SeviceMoney, end_time, EndTime, DetailMessage, status,
+// start_time, openid, ConnectorID, charge_date
+// FROM charge_order_kechuangzhongxin)
+// UNION ALL
+// (SELECT charge_station_id, order_number, order_id, TotalPower, TotalMoney,
+// ElecMoney, SeviceMoney, end_time, EndTime, DetailMessage, status,
+// start_time, openid, ConnectorID, charge_date
+// FROM charge)";
+
+ $where = [];
+
+ switch ($data['mouth']) {
+ case '月':
+ $startDate = date('Y-m-01 00:00:00', strtotime($data['value']));
+ $endDate = date('Y-m-t 23:59:59', strtotime($data['value']));
+ break;
+
+ case '季度':
+ $year = (int)date('Y');
+ $quarter = (int)$data['value'] ?? 1;
+
+
+ $startMonth = ($quarter - 1) * 3 + 1;
+ $endMonth = $quarter * 3;
+
+ $startDate = date("Y-m-01 00:00:00", mktime(0, 0, 0, $startMonth, 1, $year));
+ $endDate = date("Y-m-t 23:59:59", mktime(0, 0, 0, $endMonth, 1, $year));
+ break;
+
+ case '年':
+ $year = isset($data['value']) && !empty($data['value']) ? $data['value'] : date('Y');
+ $startDate = "$year-01-01 00:00:00";
+ $endDate = "$year-12-31 23:59:59";
+ break;
+
+ default:
+ $startDate = $data['start_time'] . ' 00:00:00';
+ $endDate = $data['end_time'] . ' 23:59:59';
+ break;
+ }
+
+// 获取所有充电站信息(先查询所有充电站,确保没有数据的也返回)
+ $allStations = Db::table('charge_station')
+ ->column('charge_station_name', 'charge_station_id');
+
+// 初始化所有充电站统计数据
+ $stationStats = [];
+ foreach ($allStations as $id => $name) {
+ $stationStats[$id] = [
+ 'charge_station_id' => $id,
+ 'charge_station_name' => $name,
+ 'TotalMoney' => 0,
+ 'TotalPower' => 0,
+ 'order_num' => 0
+ ];
+ }
+
+// 查询并处理订单数据
+// $finalSql = "SELECT * FROM ($unionSql) AS temp_table WHERE charge_date BETWEEN ? AND ?";
+// $allOrders = Db::query($finalSql, [$startDate, $endDate]);
+ $where[] = ['charge_date', '>=', $startDate];
+ $where[] = ['charge_date', '<=', $endDate];
+ $allOrders = Db::table('zxc_charge_order')->where($where)->select();
+
+// 更新有数据的充电站统计
+ foreach ($allOrders as $order) {
+ $stationId = $order['charge_station_id'];
+ if (isset($stationStats[$stationId])) {
+ $stationStats[$stationId]['TotalMoney'] += $order['TotalMoney'];
+ $stationStats[$stationId]['TotalPower'] += $order['TotalPower'];
+ $stationStats[$stationId]['order_num']++;
+ }
+ }
+
+// 格式化返回结果
+ $result = array_values(array_map(function ($item) {
+ return [
+ 'charge_station_id' => $item['charge_station_id'],
+ 'charge_station_name' => $item['charge_station_name'],
+ 'TotalMoney' => round($item['TotalMoney'], 2),
+ 'TotalPower' => round($item['TotalPower'], 2),
+ 'order_num' => $item['order_num']
+ ];
+ }, $stationStats));
+
+ return $result;
+
+ }
+
+ public function FaultInfo()
+ {
+ $hasfault = Db::table('charge_pile')->whereRaw('status = 255 OR status = 0')->order('charge_pile_id desc')->count('charge_pile_id');
+ $faultInfo = Db::table('charge_pile,charge_station')
+ ->whereRaw('status = 255 OR status = 0')
+ ->where('charge_pile.charge_station_id = charge_station.charge_station_id')
+ ->order('charge_station.charge_station_id desc')
+ ->field('charge_station.charge_station_id,charge_station_name,address,charge_pile.no,charge_pile.charge_pile_number,charge_station.area,charge_station.street,charge_pile.status')
+ ->select();
+ return json(['code' => 200, 'message' => '请求成功', 'count' => $hasfault, 'data' => $faultInfo]);
+ }
+
+ public function Time_Data(Request $request)
+ {
+
+ // 获取请求参数
+ $data = $request->param();
+ $timeType = $data['time_type'] ?: '日';
+ $strDay = $data['str_time'] ?? '';
+ $chargeStationName = $data['area'] ?? '';
+
+
+ // 设置当前日期
+ $currentDate = $strDay ?: date('Y-m-d');
+
+ // 获取充电站ID
+
+ $stationId = Db::table('charge_station')
+ ->where('charge_station_name', $chargeStationName)
+ ->value('charge_station_id');
+
+
+ // 基础UNION查询
+// $unionSql = "(SELECT charge_station_id, order_number, order_id, TotalPower, TotalMoney,
+// ElecMoney, SeviceMoney, end_time, EndTime, DetailMessage, status,
+// start_time, openid, ConnectorID, charge_date
+// FROM charge_order_qianlongzhiyaozhan)
+// UNION ALL
+// (SELECT charge_station_id, order_number, order_id, TotalPower, TotalMoney,
+// ElecMoney, SeviceMoney, end_time, EndTime, DetailMessage, status,
+// start_time, openid, ConnectorID, charge_date
+// FROM charge_order_kechuangzhongxin)
+// UNION ALL
+// (SELECT charge_station_id, order_number, order_id, TotalPower, TotalMoney,
+// ElecMoney, SeviceMoney, end_time, EndTime, DetailMessage, status,
+// start_time, openid, ConnectorID, charge_date
+// FROM charge)";
+
+ // 根据时间类型设置查询范围
+ switch ($timeType) {
+ case '日':
+ $startDate = $currentDate . ' 00:00:00';
+ $endDate = $currentDate . ' 23:59:59';
+ $where = '';
+ if ($stationId) {
+ $where .= "charge_station_id = {$stationId} AND ";
+ }
+ $where .= "start_time BETWEEN '{$startDate}' AND '{$endDate}'";
+ $groupBy = "DATE_FORMAT(start_time, '%H:00')";
+ $timeFormat = "DATE_FORMAT(start_time, '%H:00') AS time";
+ break;
+
+ case '周':
+ $monday = date('Y-m-d', strtotime('monday this week', strtotime($currentDate)));
+ $sunday = date('Y-m-d', strtotime('sunday this week', strtotime($currentDate)));
+ $startDate = $monday . ' 00:00:00';
+ $endDate = $sunday . ' 23:59:59';
+ $where = '';
+ if ($stationId) {
+ $where .= "charge_station_id = {$stationId} AND ";
+ }
+ $where .= "charge_date BETWEEN '{$startDate}' AND '{$endDate}'";
+ $groupBy = "DATE(charge_date)";
+ $timeFormat = "DATE(charge_date) AS time";
+ break;
+
+ case '月':
+ $firstDay = date('Y-m-01', strtotime($currentDate));
+ $lastDay = date('Y-m-t', strtotime($currentDate));
+ $startDate = $firstDay . ' 00:00:00';
+ $endDate = $lastDay . ' 23:59:59';
+ $where = '';
+ if ($stationId) {
+ $where .= "charge_station_id = {$stationId} AND ";
+ }
+ $where .= "charge_date BETWEEN '{$startDate}' AND '{$endDate}'";
+ $groupBy = "WEEK(charge_date, 1)";
+ $timeFormat = "CONCAT('第', WEEK(charge_date, 1) - WEEK('{$firstDay}', 1) + 1, '周') AS time";
+ break;
+
+ case '年':
+ $firstDay = date('Y-01-01', strtotime($currentDate));
+ $lastDay = date('Y-12-31', strtotime($currentDate));
+ $startDate = $firstDay . ' 00:00:00';
+ $endDate = $lastDay . ' 23:59:59';
+ $where = '';
+ if ($stationId) {
+ $where .= "charge_station_id = {$stationId} AND ";
+ }
+ $where .= "charge_date BETWEEN '{$startDate}' AND '{$endDate}'";
+ $groupBy = "MONTH(charge_date)";
+ $timeFormat = "CONCAT(MONTH(charge_date), '月') AS time";
+ break;
+
+ default:
+ return json(['error' => '不支持的查询类型'], 400);
+ }
+
+ // 构建完整SQL查询
+// $sql = "SELECT
+// {$timeFormat},
+// SUM(TotalMoney) AS revenue,
+// SUM(TotalPower) AS degree,
+// COUNT(*) AS order_num,
+// SUM(SeviceMoney) AS service_money
+// FROM ({$unionSql}) AS combined_tables
+// WHERE {$where}
+// GROUP BY {$groupBy}
+// ORDER BY time";
+
+ // 执行查询
+// $result = Db::query($sql);
+
+ $result = Db::table('zxc_charge_order')->where($where)
+ ->field("{$timeFormat},SUM(TotalMoney) AS revenue,SUM(TotalPower) AS degree,
+ COUNT(*) AS order_num,
+ SUM(SeviceMoney) AS service_money")
+ ->order($groupBy)->select();
+
+ // 计算总量
+ $total = [
+ 'revenue' => 0,
+ 'degree' => 0,
+ 'order_num' => 0,
+ 'service_money' => 0
+ ];
+
+ $perData = [];
+ foreach ($result as $item) {
+ $perData[] = [
+ 'time' => $item['time'],
+ 'data' => [
+ 'revenue' => round($item['revenue'], 2),
+ 'degree' => round($item['degree'], 2),
+ 'order_num' => $item['order_num'],
+ 'service_money' => round($item['service_money'], 2)
+ ]
+ ];
+
+ $total['revenue'] += $item['revenue'];
+ $total['degree'] += $item['degree'];
+ $total['order_num'] += $item['order_num'];
+ $total['service_money'] += $item['service_money'];
+ }
+
+ // 格式化总量数据
+ $total = [
+ 'revenue' => round($total['revenue'], 2),
+ 'degree' => round($total['degree'], 2),
+ 'order_num' => $total['order_num'],
+ 'sevice_money' => round($total['service_money'], 2)
+ ];
+
+ return json([
+ 'per' => $perData,
+ 'total' => $total
+ ]);
+
+ }
+
+
+ //待整改
+ public function Time_Data_Total(Request $request)
+ {
+ $data = $request->param();
+ $time_type = $data['time_type'] ?? '周';
+ $str_day = $data['str_time'] ?? date('Y-m-d', time());
+ $time = strtotime($str_day);
+ $date_time = date('Y-m-d', $time);
+
+ // 基础UNION查询
+ $unionSql = "(SELECT charge_station_id, order_number, order_id, TotalPower, TotalMoney,
+ ElecMoney, SeviceMoney, end_time, EndTime, DetailMessage, status,
+ start_time, openid, ConnectorID, charge_date
+ FROM charge_order_qianlongzhiyaozhan)
+ UNION ALL
+ (SELECT charge_station_id, order_number, order_id, TotalPower, TotalMoney,
+ ElecMoney, SeviceMoney, end_time, EndTime, DetailMessage, status,
+ start_time, openid, ConnectorID, charge_date
+ FROM charge_order_kechuangzhongxin)
+ UNION ALL
+ (SELECT charge_station_id, order_number, order_id, TotalPower, TotalMoney,
+ ElecMoney, SeviceMoney, end_time, EndTime, DetailMessage, status,
+ start_time, openid, ConnectorID, charge_date
+ FROM charge)";
+
+ // 初始化结果数组
+ $mess = [
+ 'per' => [],
+ 'total' => [
+ 'revenue' => 0,
+ 'degree' => 0,
+ 'order_num' => 0,
+ 'service_money' => 0
+ ]
+ ];
+
+ // 根据时间类型处理数据
+ switch ($time_type) {
+ case '日':
+ $start_time = date('Y-m-d 00:00:00', $time);
+ $date_ranges = $this->getDayDate($start_time);
+ $date_start = $date_ranges['start_time'];
+ $date_end = $date_ranges['end_time'];
+
+ foreach ($date_start as $i => $d_start) {
+ $interval = substr($date_start[$i], 11) . '~' . substr($date_end[$i], 11);
+ $this->processTimeRange($mess, $unionSql, $date_start[$i], $date_end[$i], $interval);
+ }
+ break;
+
+ case '周':
+ $end_time = date("Y-m-d 23:59:59", strtotime("$date_time Saturday"));
+ $start_time = date("Y-m-d 00:00:00", strtotime("$end_time - 6 days"));
+ $dates = $this->getDateFromRange($start_time, $end_time);
+
+ foreach ($dates as $d) {
+ $this->processTimeRange($mess, $unionSql, "$d 00:00:00", "$d 23:59:59", $d);
+ }
+ break;
+
+ case '月':
+ $start_time = date("Y-m-d", strtotime(date('Y-m-01', $time)));
+ $dates = $this->getMonthDate($start_time);
+ $i = 1;
+
+ foreach ($dates as $d) {
+ $week_label = '第' . $i . '周';
+ $this->processTimeRange($mess, $unionSql, "$d 00:00:00", date('Y-m-d 23:59:59', strtotime("$d +6 days")), $week_label);
+ $i++;
+ }
+ break;
+
+ case '季':
+ $season = ceil(date('m', $time) / 3);
+ $start_month = $season * 3 - 2;
+ $start_time = date("Y-m-d H:i:s", strtotime(date("Y-{$start_month}-01", $time)));
+ $end_time = date("Y-m-d 23:59:59", strtotime("$start_time +3 month -1 day"));
+ $dates = $this->getSeasonDate($start_time);
+ $i = date("m", strtotime($start_time));
+
+ foreach ($dates as $d) {
+ $month_label = $i . '月';
+ $this->processTimeRange($mess, $unionSql, "$d 00:00:00", date('Y-m-d 23:59:59', strtotime("$d +1 month -1 day")), $month_label);
+ $i++;
+ }
+ break;
+
+ case '年':
+ $start_time = date('Y-01-01 00:00:00', $time);
+ $dates = $this->getYearDate($start_time);
+ $i = 1;
+
+ foreach ($dates as $d) {
+ $month_label = $i . '月';
+ $this->processTimeRange($mess, $unionSql, "$d-01 00:00:00", "$d-" . date('t', strtotime($d)) . " 23:59:59", $month_label);
+ $i++;
+ }
+ break;
+ }
+
+ // 格式化金额数据
+ $mess['total']['revenue'] = round($mess['total']['revenue'], 2);
+ $mess['total']['degree'] = round($mess['total']['degree'], 2);
+ $mess['total']['service_money'] = round($mess['total']['service_money'], 2);
+
+ return json($mess);
+ }
+
+ /**
+ * 处理时间范围数据
+ */
+ private function processTimeRange(&$mess, $unionSql, $start_time, $end_time, $label)
+ {
+
+ // 查询该时间范围内的数据
+ $sql = "SELECT * FROM ($unionSql) AS temp_table
+ WHERE charge_date BETWEEN ? AND ?";
+ $orders = Db::query($sql, [$start_time, $end_time]);
+
+ // 计算统计数据
+ $revenue = 0;
+ $degree = 0;
+ $order_num = count($orders);
+ $service = 0;
+
+ foreach ($orders as $order) {
+ $revenue += $order['TotalMoney'];
+ $degree += $order['TotalPower'];
+
+ // 服务费计算逻辑
+ if (strtotime($start_time) < strtotime('2023-02-03 00:00:00')) {
+ $service += round($order['TotalPower'] * 0.2, 2);
+ } else {
+ $service += $order['SeviceMoney'];
+ }
+ }
+
+ // 更新结果数组
+ $mess['per'][] = [
+ 'time' => $label,
+ 'data' => [
+ 'revenue' => round($revenue, 2),
+ 'degree' => round($degree, 2),
+ 'order_num' => $order_num,
+ 'service_money' => round($service, 2)
+ ]
+ ];
+
+ $mess['total']['revenue'] += $revenue;
+ $mess['total']['degree'] += $degree;
+ $mess['total']['order_num'] += $order_num;
+ $mess['total']['service_money'] += $service;
+ }
+
+
+ public function Recharge_Total(Request $request)
+ {
+ $data = $request->param();
+ $time_type = $data['time_type'];
+ $str_day = $data['str_time'];
+ $time = strtotime($str_day);
+ $date_time = date('Y-m-d', $time);
+ $area = Db::table('area')->column('area');
+
+ if ($time_type == '周') {
+ $mess = [];
+ $end_time = date("Y-m-d 23:59:59", strtotime("$date_time Saturday"));//结束时间(2020-04-19 23:59:59)
+ $start_time = date("Y-m-d 00:00:00", strtotime("$end_time - 6 days"));//开始时间(2020-04-13 00:00:00
+ $revenue_total = 0;
+ $order_num_total = 0;
+ $date = $this->getDateFromRange($start_time, $end_time);
+
+ foreach ($date as $d) {
+
+ $table = 'zxc_charge_order';
+ $table_recharge = 'zxc_recharge';
+ $result = Db::table($table)->select();
+ if (empty($result)) {
+ continue;
+ } else {
+ $revenue = Db::table($table_recharge)->whereDay('success_time', $d)->sum('total');
+ $order_num = Db::table($table_recharge)->whereDay('success_time', $d)->count();
+ }
+
+ $mess['per'][] = ['time' => $d, 'data' => ['revenue' => round($revenue / 100, 2), 'order_num' => $order_num]];
+ $revenue_total += $revenue;
+ $order_num_total += $order_num;
+
+ }
+ $mess['total'] = ['revenue' => round($revenue_total / 100, 2), 'order_num' => $order_num_total];
+ return json($mess);
+ } elseif ($time_type == '月') {
+ $mess = [];
+ $start_time = date("Y-m-d", strtotime(date('Y-m-01', $time)));//开始时间(2020-04-01 00:00:00)
+ $date = $this->getMonthDate($start_time);
+ $i = 1;
+ $revenue_total = 0;
+ $order_num_total = 0;
+ foreach ($date as $d) {
+ $z = '第' . $i . '周';
+ $d = date('Y-m-d', strtotime($d));
+ $revenue = 0;
+ $order_num = 0;
+ foreach ($area as $a) {
+ $table = 'zxc_charge_order';
+ $table_recharge = 'zxc_recharge';
+ $result = Db::table($table)->select();
+ if (empty($result)) {
+ continue;
+ } else {
+ $order = Db::table($table);
+ $recharge = Db::table($table_recharge);
+ $revenue = $recharge->whereWeek('success_time', $d)->sum('total');
+ $order_num = $recharge->whereWeek('success_time', $d)->count();
+
+ }
+ }
+ $mess['per'][] = ['time' => $z, 'data' => ['revenue' => round($revenue / 100, 2), 'order_num' => $order_num]];
+ $revenue_total += $revenue;
+ $order_num_total += $order_num;
+ $i += 1;
+ }
+ $mess['total'] = ['revenue' => round($revenue_total / 100, 2), 'order_num' => $order_num_total];
+ return json($mess);
+ } elseif ($time_type == '季') {
+ $season = intval(ceil(date('m', $time) / 3));
+ if ($season == 4) {
+ $start_time = date("Y-m-d H:i:s", strtotime(date('Y-' . ($season * 3 - 2) . '-01', $time)));//开始时间(2020-04-01 00:00:00)
+ $end_time = date("Y-m-d 23:59:59", strtotime(date('Y-m-d', strtotime("$start_time +3 month -1 day"))));//开始时间(2020-04-01 00:00:00)
+ } else {
+ $start_time = date("Y-m-d H:i:s", strtotime(date('Y-0' . ($season * 3 - 2) . '-01', $time)));//开始时间(2020-04-01 00:00:00)
+ $end_time = date("Y-m-d 23:59:59", strtotime(date('Y-m-d', strtotime("$start_time +3 month -1 day"))));//开始时间(2020-04-01 00:00:00)
+ }
+ $i = date("m", strtotime(date('Y-' . ($season * 3 - 2) . '-01', $time)));
+ if ((int)substr($i, 0, 1) == 0) {
+ $i = substr($i, -1);
+ }
+ $date = $this->getSeasonDate($start_time);
+ $mess = [];
+ $revenue_total = 0;
+ $order_num_total = 0;
+ foreach ($date as $d) {
+ $z = $i . '月';
+ $d = date('Y-m-d', strtotime($d));
+ $revenue = 0;
+ $order_num = 0;
+ foreach ($area as $a) {
+ $table = 'zxc_charge_order';
+ $table_recharge = 'zxc_recharge';
+ $result = Db::table($table)->select();
+ if (empty($result)) {
+ continue;
+ } else {
+ $recharge = Db::table($table_recharge);
+ $revenue = $recharge->whereMonth('success_time', $d)->sum('total');
+ $order_num = $recharge->whereMonth('success_time', $d)->count();
+
+ }
+ }
+ $mess['per'][] = ['time' => $z, 'data' => ['revenue' => round($revenue / 100, 2), 'order_num' => $order_num]];
+ $revenue_total += $revenue;
+ $order_num_total += $order_num;
+ $i += 1;
+ }
+ $mess['total'] = ['revenue' => round($revenue_total / 100, 2), 'order_num' => $order_num_total];
+ return json($mess);
+ } elseif ($time_type == '年') {
+ $start_time = date('Y-01-01 00:00:00', $time);//开始时间
+ $date = $this->getYearDate($start_time);
+
+ $mess = [];
+ $revenue_total = 0;
+ $order_num_total = 0;
+ $i = 1;
+
+ foreach ($date as $d) {
+ $z = $i . '月';
+ $d = date('Y-m', strtotime($d));
+ $revenue = 0;
+ $order_num = 0;
+
+ foreach ($area as $a) {
+ $table = 'zxc_charge_order';
+ $table_recharge = 'zxc_recharge';
+ $result = Db::table($table)->select();
+ if (empty($result)) {
+ continue;
+ } else {
+ $recharge = Db::table($table_recharge);
+ $revenue = $recharge->whereMonth('success_time', $d)->sum('total');
+ $order_num = $recharge->whereMonth('success_time', $d)->count();
+
+ }
+ }
+ $mess['per'][] = ['time' => $z, 'data' => ['revenue' => round($revenue / 100, 2), 'order_num' => $order_num]];
+ $revenue_total += $revenue;
+ $order_num_total += $order_num;
+ $i += 1;
+ }
+ $mess['total'] = ['revenue' => round($revenue_total / 100, 2), 'order_num' => $order_num_total];
+ return json($mess);
+ }
+ }
+
+ public function The_Last_Five($lat, $lng, $openid)
+ {
+
+
+ //更新所有站的充电桩数量统计
+ $sql = "SELECT charge_station_id,count(charge_station_id) pile_number FROM charge_pile GROUP BY charge_station_id HAVING count(charge_station_id)>1 ORDER BY charge_station_id";
+ $message = Db::query($sql);
+ foreach ($message as $m) {
+ $charge_station_id = $m['charge_station_id'];
+ $pile_number = $m['pile_number'];
+ ChargeStationModel::where('charge_station_id', $charge_station_id)->update(['charge_pile_num' => $pile_number]);
+ }
+
+
+ //获取附近充电站并按距离排序
+ $lat1 = $lat;
+ $lng1 = $lng;
+ $list = Db::table('charge_station')->select();
+ $mess = array();
+ foreach ($list as $l) {
+ $distance = $this->getDistance($lat1, $lng1, $l['latitude'], $l['longitude']);
+ $mess[$l['charge_station_id']] = $distance;
+ }
+ asort($mess);
+
+ //站点信息
+ $ss = array();
+ $a = 0;
+ foreach ($mess as $key => $value) {
+
+ $info = Db::table('charge_station')->where('charge_station_id', $key)->find();
+
+
+ $mess = Db::table('charge_pile')->where('charge_station_id', $key)->select();
+ $free = 0;
+ $occupy = 0;
+ $fault = 0;
+ foreach ($mess as $m) {
+ if ($m['status'] == 1) {
+ $free += 1;
+ } elseif ($m['status'] == 2) {
+ $occupy += 1;
+ } elseif ($m['status'] == 3) {
+ $occupy += 1;
+ } elseif ($m['status'] == 255) {
+ $fault += 1;
+ }
+ }
+ Db::table('charge_station')->where('charge_station_id', $key)->update([
+ 'pile_free' => $free,
+ 'pile_occupy' => $occupy,
+ 'pile_fault' => $fault
+ ]);
+
+
+ $kk['electrovalence'] = $this->returnFree($info['ElectricityFee'], $info['ServiceFee']);
+ $kk['ChargeStationNumber'] = $info['charge_station_number'];
+ $kk['ChargeStationName'] = $info['charge_station_name'];
+ $kk['Free'] = $free;
+ $kk['Occupy'] = $occupy;
+ $kk['Fault'] = $fault;
+ $kk['Distance'] = $value;
+ $kk['is_show'] = ($a == 0 && $value * 1000 < 100) ? '当前站点' : '';
+ $kk['type'] = $info['station_type'] == 0 ? '快充' : '慢充';
+ $kk['longitude'] = $info['longitude'];
+ $kk['latitude'] = $info['latitude'];
+ $kk['address'] = $info['address'];
+
+ $ss[] = $kk;
+ $a++;
+ }
+ return json($ss);
+ }
+
+
+ public function SearchStation($message, $lat, $lng, $openid)
+ {
+
+ $table = 'zxc_user_collect';
+ $lat1 = $lat;
+ $lng1 = $lng;
+ $list = Db::table('charge_station')->where('charge_station_number|charge_station_name', 'like', '%' . $message . '%')->select();
+ $mess = array();
+ foreach ($list as $l) {
+ $charge_station_id = $l['charge_station_id'];
+ $lat2 = $l['latitude'];
+ $lng2 = $l['longitude'];
+ $distance = $this->getDistance($lat1, $lng1, $lat2, $lng2);
+ $mess[$charge_station_id] = $distance;
+ }
+ asort($mess);
+ $l = 1;
+ $ss = array();
+ foreach ($mess as $key => $value) {
+ $distance = $value;
+ $sql = "SELECT charge_station_id,count(charge_station_id) pile_number FROM charge_pile GROUP BY charge_station_id HAVING count(charge_station_id)>1 ORDER BY charge_station_id";
+ $message = Db::query($sql);
+ foreach ($message as $m) {
+ $charge_station_id = $m['charge_station_id'];
+ $pile_number = $m['pile_number'];
+ ChargeStationModel::where('charge_station_id', $charge_station_id)->update(['charge_pile_num' => $pile_number]);
+ }
+ $station_id = $key;
+ $station_name = Db::table('charge_station')->where('charge_station_id', $station_id)->value('charge_station_name');
+ $station_number = Db::table('charge_station')->where('charge_station_id', $station_id)->value('charge_station_number');
+ $Type = Db::table('charge_station')->where('charge_station_id', $station_id)->value('station_type');
+ if ((int)$Type == 0) {
+ $Type = '快充';
+ } elseif ((int)$Type == 1) {
+ $Type = '慢充';
+ }
+ $free = 0;
+ $occupy = 0;
+ $fault = 0;
+ $i = 1;
+ $mess = Db::table('charge_pile')->where('charge_station_id', $station_id)->select();
+ foreach ($mess as $m) {
+ if ($m['status'] == 1) {
+ $free += 1;
+ } elseif ($m['status'] == 2) {
+ $occupy += 1;
+ } elseif ($m['status'] == 3) {
+ $occupy += 1;
+ } elseif ($m['status'] == 255) {
+ $fault += 1;
+ }
+ $no = Db::table('charge_pile')->where('charge_pile_id', $m['charge_pile_id'])->value('no');
+ if ($no == null) {
+ Db::table('charge_pile')->where('charge_pile_id', $m['charge_pile_id'])->update(['no' => $i]);
+ }
+ $i += 1;
+ }
+ $data_station = [
+ 'pile_free' => $free,
+ 'pile_occupy' => $occupy,
+ 'pile_fault' => $fault
+ ];
+ Db::table('charge_station')->where('charge_station_id', $station_id)->update($data_station);
+
+ $collect = Db::table($table)->where('openid', $openid)->where('charge_station_id', $station_id)->find();
+ if (empty($collect)) {
+ $is_collect = 0;
+ $collect_message = '收藏';
+ } else {
+ $is_collect = 1;
+ $collect_message = '取消收藏';
+ }
+ $info = Db::table('charge_station')->where('charge_station_id', $station_id)->field('longitude,latitude,address,ElectricityFee,ServiceFee')->find();
+ $longitude = $info['longitude'];
+ $latitude = $info['latitude'];
+ $address = $info['address'];
+ $kk['ChargeStationNumber'] = $station_number;
+ $kk['ChargeStationName'] = $station_name;
+ $kk['Free'] = $free;
+ $kk['Occupy'] = $occupy;
+ $kk['Fault'] = $fault;
+ $kk['Distance'] = $distance;
+ $kk['is_collect'] = $is_collect;
+ $kk['type'] = $Type;
+ $kk['message'] = $collect_message;
+ $kk['longitude'] = $longitude;
+ $kk['latitude'] = $latitude;
+ $kk['address'] = $address;
+
+ $ss[] = $kk;
+ }
+ return json($ss);
+ }
+
+ public function GetDiscounts($openid)
+ {
+ $discounts = Db::table('discount')->where('id', 1)->value('message');
+ return json(['code' => 200, 'message' => $discounts]);
+ }
+
+
+ public function getConnectorIDCharge(){
+ $params = input();
+ if($params['ConnectorID']){
+ $info = Db::table('charge_pile')->where('ConnectorID',$params['ConnectorID'])->find();
+ $info['parent'] = Db::table('charge_station')->where('charge_station_id',$info['charge_station_id'])->value('charge_station_name');
+ return json($info);
+ }
+ return json([]);
+ }
+}
+
+
+
diff --git a/app/controller/Enterprise.php b/app/controller/Enterprise.php
new file mode 100644
index 0000000..a513504
--- /dev/null
+++ b/app/controller/Enterprise.php
@@ -0,0 +1,104 @@
+param();
+ $page = $params['page'] ?? 1;
+ $pageSize = $params['pageSize'] ?? 10;
+
+ $where = [];
+ if(!empty($params['credit_code']) && isset($params['credit_code'])){
+ $where[] = ['credit_code','like','%'.$params['credit_code'].'%'];
+ }
+ if(!empty($params['name']) && isset($params['name'])){
+ $where[] = ['name','like','%'.$params['name'].'%'];
+ }
+
+ $query = EnterpriseModel::where($where)->order('id desc');
+
+
+ $list = $query->paginate([
+ 'list_rows' => $pageSize,
+ 'page' => $page,
+ 'query' =>$params
+ ]);
+
+ return json($list);
+ }
+
+
+ public function read($id)
+ {
+ $result = EnterpriseModel::find($id);
+ if(!$result){
+ return json(['code' => 1, 'msg' => '数据不存在']);
+ }
+
+ return json(['msg'=>'','code'=>0,'data'=>$result]);
+ }
+
+ public function update(Request $request)
+ {
+ $params = $request->param();
+
+ $info = EnterpriseModel::find($params['id']);
+ if(!$info){
+ return json(['code' => 1, 'msg' => '数据不存在']);
+ }
+ unset($params['create_time']);
+ $result = $info->save($params);
+
+ if($result){
+ return json(['msg'=>'更新成功','code'=>0,'data'=>[]]);
+ }else{
+ return json(['msg'=>'更新失败,请检查~','code'=>1,'data'=>[]]);
+ }
+ }
+
+ public function save(Request $request)
+ {
+ $params = $request->param();
+
+ $result = EnterpriseModel::create([
+ 'name'=>$params['name'],
+ 'credit_code'=>$params['credit_code'],
+ 'username'=>$params['username'],
+ 'phone'=>$params['phone'],
+ 'discount'=>$params['discount'],
+ 'range'=>$params['range'],
+ 'account'=>$params['account'],
+ 'marks'=>$params['marks'],
+ ]);
+
+ if($result){
+ return json(['msg'=>'新增成功','code'=>0,'data'=>[]]);
+ }else{
+ return json(['msg'=>'新增失败,请检查~','code'=>1,'data'=>[]]);
+ }
+
+ }
+ public function delete(Request $request)
+ {
+ $data = $request->param();
+
+
+ if(!EnterpriseModel::find($data['id'])){
+ return json(['code' => 1, 'msg' => '数据不存在']);
+ }
+ $result = EnterpriseModel::destroy($data['id']);
+ if ($result) {
+ return json(['code' => 0, 'msg' => '删除成功']);
+ } else {
+ return json(['code' => 1, 'msg' => '删除失败']);
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/app/controller/EnterpriseCar.php b/app/controller/EnterpriseCar.php
new file mode 100644
index 0000000..2cd09b6
--- /dev/null
+++ b/app/controller/EnterpriseCar.php
@@ -0,0 +1,96 @@
+param();
+ $page = $params['page'] ?? 1;
+ $pageSize = $params['pageSize'] ?? 10;
+
+ $keyword = $params['keyword'] ?? '';
+ $where = [];
+ $where['enterprise_id'] = ['=',$params['enterprise_id']];
+ $query = EnterpriseCarModel::where($where);
+
+ $list = $query->paginate([
+ 'list_rows' => $pageSize,
+ 'page' => $page,
+ 'query' =>$params
+ ]);
+
+ return json($list);
+ }
+
+
+ public function read($id)
+ {
+ $result = EnterpriseCarModel::find($id);
+ if(!$result){
+ return json(['code' => 1, 'msg' => '数据不存在']);
+ }
+
+ return json(['msg'=>'','code'=>0,'data'=>$result]);
+ }
+
+ public function update(Request $request)
+ {
+ $params = $request->param();
+
+ $info = EnterpriseCarModel::find($params['id']);
+ if(!$info){
+ return json(['code' => 1, 'msg' => '数据不存在']);
+ }
+ unset($params['create_time']);
+ $result = $info->allowField(['car_number', 'car_vin', 'enterprise_id', 'car_no', 'car_user', 'vin_type'])->save($params);
+
+ if($result){
+ return json(['msg'=>'更新成功','code'=>0,'data'=>[]]);
+ }else{
+ return json(['msg'=>'更新失败,请检查~','code'=>1,'data'=>[]]);
+ }
+ }
+
+ public function save(Request $request)
+ {
+ $params = $request->param();
+
+ $result = EnterpriseCarModel::create([
+ 'car_number'=>$params['car_number'],
+ 'car_vin'=>$params['car_vin'],
+ 'enterprise_id'=>$params['enterprise_id'],
+ 'car_no'=>$params['car_no'],
+ 'car_user'=>$params['car_user'],
+ 'vin_type'=>$params['vin_type']
+ ]);
+
+ if($result){
+ return json(['msg'=>'新增成功','code'=>0,'data'=>[]]);
+ }else{
+ return json(['msg'=>'新增失败,请检查~','code'=>1,'data'=>[]]);
+ }
+
+ }
+ public function delete(Request $request)
+ {
+ $data = $request->param();
+
+
+ if(!EnterpriseCarModel::find($data['id'])){
+ return json(['code' => 1, 'msg' => '数据不存在']);
+ }
+ $result = EnterpriseCarModel::destroy($data['id']);
+ if ($result) {
+ return json(['code' => 0, 'msg' => '删除成功']);
+ } else {
+ return json(['code' => 1, 'msg' => '删除失败']);
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/app/controller/EnterpriseUser.php b/app/controller/EnterpriseUser.php
new file mode 100644
index 0000000..9aefb72
--- /dev/null
+++ b/app/controller/EnterpriseUser.php
@@ -0,0 +1,94 @@
+param();
+ $page = $params['page'] ?? 1;
+ $pageSize = $params['pageSize'] ?? 10;
+
+ $keyword = $params['keyword'] ?? '';
+
+ $where = [];
+ $where['enterprise_id'] = ['=',$params['enterprise_id']];
+ $query = EnterpriseUserModel::where($where);
+
+ $list = $query->paginate([
+ 'list_rows' => $pageSize,
+ 'page' => $page,
+ 'query' =>$params
+ ]);
+
+ return json($list);
+ }
+
+
+ public function read($id)
+ {
+ $result = EnterpriseUserModel::find($id);
+ if(!$result){
+ return json(['code' => 1, 'msg' => '数据不存在']);
+ }
+
+ return json(['msg'=>'','code'=>0,'data'=>$result]);
+ }
+
+ public function update(Request $request)
+ {
+ $params = $request->param();
+
+ $info = EnterpriseUserModel::find($params['id']);
+ if(!$info){
+ return json(['code' => 1, 'msg' => '数据不存在']);
+ }
+ unset($params['create_time']);
+ $result = $info->save($params);
+
+ if($result){
+ return json(['msg'=>'更新成功','code'=>0,'data'=>[]]);
+ }else{
+ return json(['msg'=>'更新失败,请检查~','code'=>1,'data'=>[]]);
+ }
+ }
+
+ public function save(Request $request)
+ {
+ $params = $request->param();
+
+ $result = EnterpriseUserModel::create([
+ 'enterprise_id'=>$params['enterprise_id'],
+ 'phone'=>$params['phone'],
+ 'group_id'=>$params['group_id']
+ ]);
+
+ if($result){
+ return json(['msg'=>'新增成功','code'=>0,'data'=>[]]);
+ }else{
+ return json(['msg'=>'新增失败,请检查~','code'=>1,'data'=>[]]);
+ }
+
+ }
+ public function delete(Request $request)
+ {
+ $data = $request->param();
+
+
+ if(!EnterpriseUserModel::find($data['id'])){
+ return json(['code' => 1, 'msg' => '数据不存在']);
+ }
+ $result = EnterpriseUserModel::destroy($data['id']);
+ if ($result) {
+ return json(['code' => 0, 'msg' => '删除成功']);
+ } else {
+ return json(['code' => 1, 'msg' => '删除失败']);
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/app/controller/Event.php b/app/controller/Event.php
new file mode 100644
index 0000000..6a76f0d
--- /dev/null
+++ b/app/controller/Event.php
@@ -0,0 +1,271 @@
+toArray();
+ $i = 0;
+ foreach ($list['data'] as $ll) {
+ if (strpos($ll['pic'], ',') !== false) {
+ $arr = explode(',', $ll['pic']);
+ $s = 0;
+ foreach ($arr as $a) {
+ $arr[$s] = $a;
+ $s += 1;
+ }
+ $list['data'][$i]['pic'] = $arr;
+ } else {
+ $list['data'][$i]['pic'] = (array)$list['data'][$i]['pic'];
+ }
+ $i += 1;
+ }
+ return json($list);
+ }
+
+ public function AddEvent(Request $request, $str_file = [], $str_list_file = '')
+ {
+ $data = $request->param();
+ $title = $data['title'];
+ $content = $data['content'];
+ $file = $request->file();
+ // 设定文件上传的大小
+ $fileSize = 1024 * 1024 * 10;
+ $allowedTypes = ['image/jpeg', 'image/png', 'image/gif'];
+ $savename = [];
+ $listname = [];
+ if (!empty($file)) {
+ foreach ($file as $f) {
+ if (is_array($f)) {
+ foreach ($f as $singleFile) {
+ if (!in_array($singleFile->getMime(), $allowedTypes)) {
+ return json(['code' => 1, 'Msg' => '不支持的文件类型', 'data' => '']);
+ }
+ }
+ } else {
+ if (!in_array($f->getMime(), $allowedTypes)) {
+ return json(['code' => 1, 'Msg' => '不支持的文件类型', 'data' => '']);
+ }
+ }
+ }
+ }
+
+ $pico = $this->SavePic($str_file, $fileSize, $file, $request, $savename, $listname, $str_list_file);
+ $save = (new \app\model\Event)->save(['title' => $title, 'content' => $content, 'pic' => $pico['pic'], 'listpic' => $pico['listpic']]);
+ if ((int)$save == 1) {
+ return json(['code' => 200, 'Msg' => '新增成功', 'data' => ['title' => $title, 'content' => $content, 'pic' => $pico['pic'], 'listpic' => $pico['listpic']]]);
+ } else {
+ return json(['code' => 1, 'Msg' => '新增失败', 'data' => '']);
+ }
+
+ }
+
+ public function EditEvent(Request $request, $str_file = [], $str_list_file = '')
+ {
+ $data = $request->param();
+ $id = $data['id'];
+ $title = $data['title'];
+ $content = $data['content'];
+ $status = (int)$data['status'];
+ $edit = EventModel::find($id);
+ $file = $request->file();
+ // 设定文件上传的大小
+ $fileSize = 1024 * 1024 * 10;
+ $savename = [];
+ $listname = '';
+ $allowedTypes = ['image/jpeg', 'image/png', 'image/gif'];
+ try {
+ if (!empty($file)) {
+ foreach ($file as $f) {
+ if (is_array($f)) {
+ foreach ($f as $singleFile) {
+ if (!in_array($singleFile->getMime(), $allowedTypes)) {
+ return json(['code' => 1, 'Msg' => '不支持的文件类型', 'data' => '']);
+ }
+ }
+ } else {
+ if (!in_array($f->getMime(), $allowedTypes)) {
+ return json(['code' => 1, 'Msg' => '不支持的文件类型', 'data' => '']);
+ }
+ }
+ }
+ }
+
+ $pico = $this->SavePic($str_file, $fileSize, $file, $request, $savename, $listname, $str_list_file);
+ $edit = $edit->save(['title' => $title, 'content' => $content, 'pic' => $pico['pic'], 'listpic' => $pico['listpic'], 'status' => $status]);
+ if ((int)$edit == 1) {
+ return json(['code' => 200, 'Msg' => '修改成功', 'data' => ['title' => $title, 'content' => $content, 'pic' => $pico['pic'], 'status' => $status, 'listpic' => $pico['listpic']]]);
+ } else {
+ return json(['code' => 1, 'Msg' => '修改失败', 'data' => '']);
+ }
+ } catch (\think\exception\ValidateException $e) {
+ return json(['code' => 1, 'Msg' => $e->getMessage(), 'data' => '']);
+ }
+
+ }
+
+ public function DeleteEvent($id)
+ {
+ $ee = EventModel::find($id);
+ if ($ee != null) {
+ $result = EventModel::destroy($id);
+ if ($result) {
+ return json(['code' => 200, 'Msg' => '删除成功']);
+ } else {
+ return json(['code' => 1, 'Msg' => '删除失败']);
+ }
+ } else {
+ return json(['code' => 1, 'Msg' => '活动编号不存在']);
+ }
+ }
+
+
+ /**
+ * [将Base64图片转换为本地图片并保存]
+ * @E-mial wuliqiang_aa@163.com
+ * @TIME 2017-04-07
+ * @WEB http://blog.iinu.com.cn
+ * @param [Base64] $base64_image_content [要保存的Base64]
+ * @param [目录] $path [要保存的路径]
+ */
+ function base64_image_content($base64_image_content, $path = '../public/static/img', $name = '')
+ {
+ //匹配出图片的格式
+ if (preg_match('/^(data:\s*image\/(\w+);base64,)/', $base64_image_content, $result)) {
+ $type = $result[2];
+ $new_file = $path;
+ if (!file_exists($new_file)) {
+ //检查是否有该文件夹,如果没有就创建,并给予最高权限
+ mkdir($new_file, 0700);
+ }
+ $new_file = $new_file . ($name ?? date('YmdHis', time()) ). ".{$type}";
+ if (file_put_contents($new_file, base64_decode(str_replace($result[1], '', $base64_image_content)))) {
+ return 'https://' . $_SERVER['HTTP_HOST'] . '/' . substr($new_file, 10);
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+
+ /**
+ * @param $fileSize
+ * @param $file
+ * @param Request $request
+ * @param array $savename
+ * @return array
+ */
+ protected function SavePic($str_file, $fileSize, $file, Request $request, array $savename, $listname, $str_list_file): array
+ {
+ if (!empty($str_file)) {
+ foreach ($str_file as $sfile) {
+ $savename[] = $sfile;
+ }
+ }
+ if (!empty($file)) {
+ validate(['logo' => 'fileSize:' . $fileSize . '|fileExt:jpg,png'])
+ ->check($file);
+ $small_file = $request->file("small_file");
+ if (!empty($small_file) && empty($str_list_file)) {
+ $listname = 'https://' . $_SERVER['HTTP_HOST'] . '/static/' . str_replace('\\', '/', \think\facade\Filesystem::disk('public')->putFile('img', $small_file));
+ } elseif (!empty($str_list_file) && empty($small_file)) {
+ $listname = $str_list_file;
+ } else {
+ $listname = '';
+ }
+ $files = $request->file("file");
+ // 将图片保存至本地
+ if (!empty($files)) {
+ foreach ($files as $file) {
+ $savename[] = 'https://' . $_SERVER['HTTP_HOST'] . '/static/' . str_replace('\\', '/', \think\facade\Filesystem::disk('public')->putFile('img', $file));
+ }
+ }
+ } else {
+ if (!empty($str_list_file)) {
+ $listname = $str_list_file;
+ }
+ }
+
+ $pico = '';
+ $i = 1;
+ foreach ($savename as $p) {
+ if ($i == count($savename)) {
+ $pico .= $p;
+ } else {
+ $pico .= $p . ',';
+ }
+ $i += 1;
+ }
+ return ['pic' => $pico, 'listpic' => $listname];
+ }
+
+ public function EventList()
+ {
+ $list = EventModel::order('id desc')->paginate([
+ 'list_rows' => 20,
+ 'query' => request()->param()
+ ]);
+
+ foreach ($list as $ll=>$value) {
+ if ($value['status'] == 1) {
+ $list[$ll]['statusMsg'] = '上线中';
+ } elseif ($value['status'] == 2) {
+ $list[$ll]['statusMsg'] = '已下架';
+ }
+ }
+ return json($list);
+ }
+
+ /**
+ * @throws \think\db\exception\ModelNotFoundException
+ * @throws \think\db\exception\DataNotFoundException
+ * @throws \think\db\exception\DbException
+ */
+ public function EventDetail($id)
+ {
+ $DMessage = EventModel::where('id', $id)->find()->toArray();
+ $Dpic = [];
+ if (strpos($DMessage['pic'], ',') !== false) {
+ $PicArray = explode(',', $DMessage['pic']);
+ $i = 0;
+ foreach ($PicArray as $pic) {
+ if ($i != 0) {
+ $Dpic[] = $pic;
+ }
+ $i += 1;
+ }
+ } else {
+ $Dpic[] = $DMessage['pic'];
+ }
+ $DMessage['pic'] = $Dpic;
+ if ((int)$DMessage['status'] == 1) {
+ $DMessage['statusMsg'] = '上线中';
+ } elseif ((int)$DMessage['status'] == 2) {
+ $DMessage['statusMsg'] = '已下架';
+ }
+ return json($DMessage);
+ }
+
+ public function FindEvent($name)
+ {
+ $list = EventModel::whereLike('title', '%' . $name . '%')->paginate(20)->toArray();
+ $i = 0;
+ foreach ($list['data'] as $ll) {
+ if (strpos($ll['pic'], ',') !== false) {
+ $list['data'][$i]['pic'] = explode(',', $ll['pic']);
+ } else {
+ $list['data'][$i]['pic'] = (array)$ll['pic'];
+ }
+ $i += 1;
+ }
+ return json($list);
+ }
+}
\ No newline at end of file
diff --git a/app/controller/HMACMD5.php b/app/controller/HMACMD5.php
new file mode 100644
index 0000000..6e324f5
--- /dev/null
+++ b/app/controller/HMACMD5.php
@@ -0,0 +1,36 @@
+ $b) {
+ $key = pack("H32", md5($key));
+ }
+ $key = str_pad($key, $b, chr(0x00));
+ $ipad = str_pad('', $b, chr(0x36));
+ $opad = str_pad('', $b, chr(0x5c));
+ $k_ipad = $key ^ $ipad;
+ $k_opad = $key ^ $opad;
+
+ return strtoupper(md5($k_opad . pack("H32", md5($k_ipad . $data))));
+ }
+}
+
+function strToUtf8($str)
+{
+ $encode = mb_detect_encoding($str, array("ASCII", 'UTF-8', "GB2312", "GBK", 'BIG5'));
+ if ($encode == 'UTF-8') {
+ return $str;
+ } else {
+ return mb_convert_encoding($str, 'UTF-8', $encode);
+ }
+}
diff --git a/app/controller/HardMessage.php b/app/controller/HardMessage.php
new file mode 100644
index 0000000..1aa4e82
--- /dev/null
+++ b/app/controller/HardMessage.php
@@ -0,0 +1,1222 @@
+getToken();
+ }
+
+ $kk = [
+ 'LastQueryTime' => '',
+ 'PageNo' => $PageNo,
+ 'PageSize' => 10,
+ ];
+ $en = $this->Encrypt(json_encode($kk));
+
+
+ $datetime = date('YmdHis');
+ $sig = config('hard.OperatorID') . $en . $datetime . config('hard.Seq');
+ $s = $this->HmacMD5($sig);
+
+ $data = [
+ 'OperatorID' => config('hard.OperatorID'),
+ 'Data' => $en,
+ 'TimeStamp' => $datetime,
+ 'Seq' => config('hard.Seq'),
+ 'Sig' => $s,
+ ];
+
+ $message = $this->CurlSend(config('hard.url') . '/query_stations_info', $data, $token);
+ $de_data = $this->Decrypt($message['Data']);
+ $array = json_decode($de_data, true);
+// dd($array);
+
+
+ foreach ($array['StationInfos'] as $station_arr) {
+ $station_arr1 = (array)$station_arr;
+
+ $station_arr1 = array_diff_key($station_arr1, ["EquipmentInfos" => 'xy', "CtrlsInfos" => 'xy']);
+ $check = Db::table('stationinfo_slow')->where('StationID', $station_arr1['StationID'])->find();
+ if (!$check) {
+ Db::table('stationinfo_slow')->save($station_arr1);
+ }
+
+ foreach ($station_arr['EquipmentInfos'] as $equipment_arr) {
+ $equipment_arr1 = (array)$equipment_arr;
+ $equipment_arr1 = array_diff_key($equipment_arr1, ["ConnectorInfos" => 'xy']);
+ $equipment_arr1['StationID'] = $station_arr['StationID'];
+ $check = Db::table('equipmentinfo_slow')->where('EquipmentID', $equipment_arr1['EquipmentID'])->find();
+ if (!$check) {
+ Db::table('equipmentinfo_slow')->save($equipment_arr1);
+ }
+ foreach ($equipment_arr['ConnectorInfos'] as $connector_arr) {
+ $connector_arr = (array)$connector_arr;
+ $connector_arr['EquipmentID'] = $equipment_arr['EquipmentID'];
+ $check = Db::table('connectorinfo_slow')->where('ConnectorID', $connector_arr['ConnectorID'])->find();
+ if (!$check) {
+ Db::table('connectorinfo_slow')->save($connector_arr);
+ }
+ }
+ }
+ }
+ return 'OK';
+ }
+
+
+ public function query_token()
+ {
+ $TimeStamp = '';
+ $Seq = '';
+ $OperatorSecret = config('hard.OperatorSecret');
+ $params = file_get_contents('php://input');
+
+ Db::table('charge_logo')->save(['name' => 'query_token', 'mark' => $params]);
+
+ $params = json_decode($params, true);
+ $OperatorID = empty($params['OperatorID']) ? '' : $params['OperatorID'];
+ $checkParams = $this->checkParams($params);
+ if ($checkParams != 2) {
+ return json(['Msg' => $checkParams . '为空', 'Ret' => 4003, 'Data' => ['Status' => 1]]);
+ }
+ $checkSig = $this->checkSig($OperatorID, $params);
+ if ($checkSig == 1) {
+ $data = json_encode(['OperatorID' => $OperatorID, 'SuccStat' => 1, 'FailReason' => 4]);
+ $data = $this->Encrypt($data);
+ $seq = empty($Seq) ? '0001' : $params['Seq'];
+ $datetime = empty($TimeStamp) ? date('YmdHis') : $params['TimeStamp'];
+ $sig = $OperatorID . $data . $datetime . $seq;
+ $s = $this->HmacMD5($sig);
+ return json(['Msg' => '签名错误', 'Ret' => 4001, 'Data' => $data, 'Sig' => $s]);
+ }
+ $data = $this->Decrypt($params['Data']);
+ $datas = json_decode($data, true);
+ if (isset($datas['OperatorID']) && isset($datas['OperatorSecret'])) {
+ if (($datas['OperatorID'] == $OperatorID) && ($datas['OperatorSecret'] == $OperatorSecret)) {
+ $AccessToken = $this->signToken();
+ Cache::set('accesstoken', $AccessToken, 7200);
+ $strr = ['OperatorID' => $OperatorID, 'SuccStat' => 0, 'AccessToken' => $AccessToken,
+ 'TokenAvailableTime' => 7200, 'FailReason' => 0];
+ $data = json_encode($strr);
+ $data = $this->Encrypt($data);
+ $seq = empty($Seq) ? '0001' : $params['Seq'];
+ $datetime = empty($TimeStamp) ? date('YmdHis') : $params['TimeStamp'];
+ $sig = $OperatorID . $data . $datetime . $seq;
+ $s = $this->HmacMD5($sig);
+ return json(['Msg' => '', 'Ret' => 0, 'Data' => $data, 'Sig' => $s]);
+ }
+ $re = ['OperatorID' => $OperatorID, 'SuccStat' => 1, 'FailReason' => 5];
+ $data = json_encode($re);
+ $data = $this->Encrypt($data);
+ $seq = empty($Seq) ? '0001' : $params['Seq'];
+ $datetime = empty($TimeStamp) ? date('YmdHis') : $params['TimeStamp'];
+ $sig = $OperatorID . $data . $datetime . $seq;
+ $s = $this->HmacMD5($sig);
+ return json(['Msg' => 'OperatorID,Data错误', 'Ret' => 4003, 'Data' => $data, 'Sig' => $s]);
+ }
+ }
+
+ /**
+ * 设备接口状态查询query_station_status
+ * 数组长度不超过50
+ * @param $stationid
+ * @return void
+ */
+ public function Get_station_status($stationid = [])
+ {
+ $token = Cache::get('token');
+ if (!$token) {
+ $hardtoken = new HardToken();
+ $token = $hardtoken->getToken();
+ }
+
+
+ $kk['StationIDs'] = $stationid;
+ $en = $this->Encrypt(json_encode($kk));
+
+ $datetime = date('YmdHis');
+ $sig = config('hard.OperatorID') . $en . $datetime . config('hard.Seq');
+ $s = $this->HmacMD5($sig);
+
+ $data = [
+ 'OperatorID' => config('hard.OperatorID'),
+ 'Data' => $en,
+ 'TimeStamp' => $datetime,
+ 'Seq' => config('hard.Seq'),
+ 'Sig' => $s,
+ ];
+ $message = $this->CurlSend(config('hard.url') . '/query_station_status', $data, $token);
+ $en_mess = $message['Data'];
+ $de_data = $this->Decrypt($en_mess);
+ $array = json_decode($de_data, true);
+
+
+ foreach ($array['StationStatusInfos'] as $stationStatusInfo_arr) {
+ foreach ($stationStatusInfo_arr['ConnectorStatusInfos'] as $connectorStatusInfo_arr) {
+ $connectorStatusInfo_arr['StationID'] = $stationStatusInfo_arr['StationID'];
+ Db::table('charge_pile')
+ ->where('ConnectorID', $connectorStatusInfo_arr['ConnectorID'])
+ ->update(['status' => $connectorStatusInfo_arr['Status']]);
+
+ $check = Db::table('connectorstatusinfo_slow')
+ ->where('ConnectorID', $connectorStatusInfo_arr['ConnectorID'])
+ ->find();
+ if (!$check) {
+ Db::table('connectorstatusinfo_slow')->save($connectorStatusInfo_arr);
+ } else {
+ Db::table('connectorstatusinfo_slow')->where('ConnectorID', $connectorStatusInfo_arr['ConnectorID'])->update($connectorStatusInfo_arr);
+
+ }
+ }
+ }
+ }
+
+
+ /**
+ * 设备状态变化推送 notification_stationStatus
+ * @param Request $request
+ * @return void
+ * 充电设备接口编码 ConnectorID 充电设备接口编码,同一运营商内唯一 是 字符串 <=26字符
+ *
+ * 充电设备接口状态 Status 0:离网 1:空闲 2:占用(未充电) 3:占用(充电中) 4:占用(预约锁定) 255:故障 是 整型
+ *
+ * 车位状态 ParkStatus 0:未知 10:空闲 50:占用 否 整型
+ *
+ * 地锁状态 LockStatus 0:未知 10:已解锁 50:已上锁
+ */
+ public function notification_station(Request $request)
+ {
+ Db::table('charge_logo')->save(['name' => '设备状态变化推送notification_station', 'mark' => '']);
+ $params = file_get_contents('php://input');
+ $params = json_decode($params, true);
+
+ $OperatorID = empty($params['OperatorID']) ? '' : $params['OperatorID'];
+ $authorization = $request->header()['authorization'];//传递过来的token
+ $auths = explode(' ', trim($authorization));
+ $auth = $auths[count($auths) - 1];
+ $checkParams = $this->checkParams($params);
+
+
+ if ($checkParams != 2) {
+ return ['Msg' => $checkParams . '为空', 'Ret' => 4003, 'Data' => ['Status' => 1]];
+ }
+
+ if (!$auth) {
+ return $this->encodeData(['Status' => 1], $params, 4002, 'Bearer 未添加');
+ }
+
+ if ($this->checkToken_assess($auth) == 1 || $this->checkSig($params['OperatorID'], $params) == 1) {
+ $data = json_encode(['Status' => 1]);
+ $data = $this->Encrypt($data);
+ $seq = empty($Seq) ? '0001' : $params['Seq'];
+ $datetime = empty($TimeStamp) ? date('YmdHis') : $params['TimeStamp'];
+ $sig = $OperatorID . $data . $datetime . $seq;
+ $s = $this->HmacMD5($sig);
+ return json(['Msg' => '请检查签名或Token过期或者无效', 'Ret' => 4002, 'Data' => $data, 'Sig' => $s]);
+ }
+
+
+ $data = $this->Decrypt($params['Data']);
+ Db::table('charge_logo')->save(['name' => '设备状态变化推送notification_station', 'mark' => $data]);
+
+
+ $data = json_decode($data, true);
+ $da = $data['ConnectorStatusInfo'];
+ if (isset($da['ConnectorID']) && isset($da['Status'])) {
+ $ConnectorID = $da['ConnectorID'];
+ Db::table('charge_pile')->where('ConnectorID', $ConnectorID)
+ ->save(['status' => $da['Status'], 'is_pushed' => 1]);
+ return $this->encodeData(['Status' => 0], $params, 0);
+ }
+
+ }
+
+
+ /**
+ * 请求设备认证
+ * @param $EquipAuthSeq string
+ * @param $ConnectorID string
+ * @return mixed
+ *
+ * 设备认证流水号 EquipAuthSeq 字符串 格式“运营商ID+唯一编号”,27字符
+ *
+ * 充电设备接口编码 ConnectorID 字符串 电设备接口编码:格式“6位行政区编码,4位电站编码,3位终端编码”,13位字符
+ *
+ * 操作结果 SuccStat 整型 0:成功; 1:失败 失败原因 FailReason 整型 0:无; 1:此设备尚未插枪; 2:设备检测失败: 3~99:自定义
+ */
+ public function Get_query_equip_auth($EquipAuthSeq, $ConnectorID)
+ {
+ $token = Cache::get('token');
+ if (!$token) {
+ $hardtoken = new HardToken();
+ $token = $hardtoken->getToken();
+ }
+
+ $kk = [
+ 'EquipAuthSeq' => $EquipAuthSeq,
+ 'ConnectorID' => $ConnectorID,
+ ];
+ $en = $this->Encrypt(json_encode($kk));
+
+
+ $datetime = date('YmdHis');
+ $sig = config('hard.OperatorID') . $en . $datetime . config('hard.Seq');
+ $s = $this->HmacMD5($sig);
+
+
+ $data = [
+ 'OperatorID' => config('hard.OperatorID'),
+ 'Data' => $en,
+ 'TimeStamp' => $datetime,
+ 'Seq' => config('hard.Seq'),
+ 'Sig' => $s,
+
+ ];
+ $message = $this->CurlSend(config('hard.url') . '/query_equip_auth', $data, $token);
+
+
+ $en_mess = $message['Data'];
+ $de_data = $this->Decrypt($en_mess);
+
+ return json_decode($de_data, true);
+
+ }
+
+
+ /**
+ * 请求启动充电
+ * @param $StartChargeSeq string 充电订单号:格式“运营商ID+唯一编号”,27字符
+ * @param $ConnectorID string 充电设备接口编码:格式“6位行政区编码,4位电站编码,3位终端编码”,13位字符
+ * @param $QRCode string 二维码其他信息
+ * @param $PhoneNum string 手机号 false 个人支付必传,格式确保正确
+ * @param $PlateNum string 车牌号 false 停车减免必传,格式确保正确
+ * @return array
+ * 设备认证流水号 EquipAuthSeq 字符串 式“运营商ID+唯一编号”,27字符
+ *
+ * 充电设备接口编码 ConnectorID 字符串 参见《电动汽车充换电服务信息交换 第2部分:公共信息交换规范》
+ *
+ * 操作结果 SuccStat 整型 0:成功; 1:失败 失败原因 FailReason 整型 0:无; 1:此设备尚未插枪; 2:设备检测失败: 3~99:自定义
+ *
+ */
+ public function Get_query_start_charge($StartChargeSeq, $ConnectorID, $QRCode, $PhoneNum = '', $PlateNum = '')
+ {
+ $token = Cache::get('token');
+ if (!$token) {
+ $hardtoken = new HardToken();
+ $token = $hardtoken->getToken();
+ }
+
+ $kk = [
+ 'StartChargeSeq' => $StartChargeSeq,
+ 'ConnectorID' => $ConnectorID,
+ 'QRCode' => $QRCode,
+ 'PhoneNum' => $PhoneNum,
+ 'PlateNum' => $PlateNum,
+ ];
+ $en = $this->Encrypt(json_encode($kk));
+
+ $datetime = date('YmdHis');
+ $sig = config('hard.OperatorID') . $en . $datetime . config('hard.Seq');
+ $s = $this->HmacMD5($sig);
+
+ $data = [
+ 'OperatorID' => config('hard.OperatorID'),
+ 'Data' => $en,
+ 'TimeStamp' => $datetime,
+ 'Seq' => config('hard.Seq'),
+ 'Sig' => $s,
+ ];
+ $message = $this->CurlSend(config('hard.url') . '/query_start_charge', $data, $token);
+ $en_mess = $message['Data'];
+ $de_data = $this->Decrypt($en_mess);
+
+ return json_decode($de_data, true);
+ }
+
+
+ /**
+ * 请求启动充电
+ * @param $StartChargeSeq string 充电订单号
+ * @param $ConnectorID string 充电设备接口编码
+ * @param $QRCode string 二维码其他信息
+ * @param $ChargeModel string 未知作用
+ * @param $vin string 车辆VIN码
+ * @param $PhoneNum string 手机号
+ * @return array
+ */
+ public function Get_query_start_charge_test($StartChargeSeq, $ConnectorID, $QRCode, $ChargeModel, $vin = '', $PhoneNum = ''): array
+ {
+ $token = Cache::get('token');
+ if (!$token) {
+ $hardtoken = new HardToken();
+ $token = $hardtoken->getToken();
+ }
+
+
+ $kk = [
+ 'StartChargeSeq' => $StartChargeSeq,
+ 'ConnectorID' => $ConnectorID,
+ 'QRCode' => $QRCode,
+ 'PhoneNum' => $PhoneNum,
+ 'ChargeModel' => $ChargeModel,
+ 'Vin' => $vin,
+ ];
+ $en = $this->Encrypt(json_encode($kk));
+
+
+ $datetime = date('YmdHis');
+ $sig = config('hard.OperatorID') . $en . $datetime . config('hard.Seq');
+ $s = $this->HmacMD5($sig);
+
+
+ $data = [
+ 'OperatorID' => config('hard.OperatorID'),
+ 'Data' => $en,
+ 'TimeStamp' => $datetime,
+ 'Seq' => config('hard.Seq'),
+ 'Sig' => $s,
+ ];
+ $message = $this->CurlSend(config('hard.url') . '/query_start_charge', $data, $token);
+ $en_mess = $message['Data'];
+ $de_data = $this->Decrypt($en_mess);
+
+
+ return json_decode($de_data, true);
+ }
+
+ /**
+ * @@@@@@@---------推送充电结果----------@@@@@@@@@@@@
+ * 发起充电后,由特来电方推送启动充电结果,包括充电订单号、订单状态、充电设备接口编码、充电启动时间。
+ * @param Request $request
+ *充电订单号 StartChargeSeq 是 字符串 格式“运营商ID+唯一编号”,27字符
+ *
+ * 充电订单状态 StartChargeSeqStat 是 整型 1:启动中 2:充电中 3:停止中 :已结束 5:未知
+ *
+ * 充电设备接口编码 ConnectorID 是 字符串 格式“6位行政区编码,4位电站编码,3位终端编码”,13位字符
+ *
+ * 充电启动时间 StartTime 是 字符串 格式“yyyy-MM-dd HH:mm:ss”
+ *
+ * 验证码 IdentCode 否 字符串 特来电将该字段作为启动充电失败原因错误码
+ *
+ * @return Json
+ * 充电订单号 StartChargeSeq 是 字符串 格式“运营商ID+唯一编号”,27字符
+ *
+ * 操作结果 SuccStat 是 整型 0:成功; 1:失败
+ *
+ * 失败原因 FailReason 是 整型 0:无; 1:接收失败;
+ */
+ public function notification_start_charge_result(Request $request)
+ {
+ $params = file_get_contents('php://input');
+ $params = json_decode($params, true);
+ $OperatorID = empty($params['OperatorID']) ? '' : $params['OperatorID'];
+ $authorization = $request->header()['authorization'];//传递过来的token
+ $auths = explode(' ', trim($authorization));
+ $auth = $auths[count($auths) - 1];
+
+
+ $checkParams = $this->checkParams($params);
+ if ($checkParams != 2) {
+ return json(['Msg' => $checkParams . '为空', 'Ret' => 4003, 'Data' => ['Status' => 1]]);
+ }
+
+ if (!$auth) {
+ return $this->encodeData(['Status' => 1], $params, 4002, 'Bearer 未添加');
+ }
+
+
+ if ($this->checkToken_assess($auth) == 1 || $this->checkSig($params['OperatorID'], $params) == 1) {
+ $data = json_encode(['Status' => 1]);
+ $data = $this->Encrypt($data);
+ $seq = empty($Seq) ? '0001' : $params['Seq'];
+ $datetime = empty($TimeStamp) ? date('YmdHis') : $params['TimeStamp'];
+ $sig = $OperatorID . $data . $datetime . $seq;
+ $s = $this->HmacMD5($sig);
+ return json(['Msg' => '签名错误/Token过期或者无效', 'Ret' => 4002, 'Data' => $data, 'Sig' => $s]);
+ }
+
+
+ $data = $this->Decrypt($params['Data']);
+ Db::table('charge_logo')->save(['name' => $params['OperatorID'] . ':推送充电结果notification_start_charge_result', 'mark' => $data]);
+ $data = json_decode($data, true);
+
+
+ if ($data['StartChargeSeqStat'] == 2) {
+ //充电中
+ $ss = [
+ 'status' => $data['StartChargeSeqStat'],
+ 'StartChargeSeqStat' => $data['StartChargeSeqStat'],
+ 'start_time' => date('Y-m-d H:i:s', strtotime($data['StartTime'])),
+ 'vin' => $data['VIN'],
+ ];
+ } else {
+ $time = date('Y-m-d H:i:s', time());
+ $ss = [
+ 'status' => $data['StartChargeSeqStat'],//充电状态
+ 'StartChargeSeqStat' => $data['StartChargeSeqStat'],//充电状态
+ 'start_time' => $time,
+ 'end_time' => $time,
+ 'stop_type' => 15,
+ 'TotalMoney' => 0,
+ 'TotalPower' => 0,
+ 'IdentCode' => $data['IdentCode'] ?? '',
+ 'vin' => $data['VIN'] ?? '',
+ ];
+ }
+ Db::table('zxc_charge_order')->where('StartChargeSeq', $data['StartChargeSeq'])
+ ->update($ss);
+ exit();
+ }
+
+
+ /**
+ * 查询充电状态
+ * 通过充电订单号查询充电状态。
+ * @param $StartChargeSeq string 充电订单号
+ * @return int[]
+ *
+ * 充电订单号 StartChargeSeq 是 字符串 格式“运营商ID+唯一编号”,27字符
+ *
+ * 充电订单状态 StartChargeSeqStat 是 整型 1:启动中 2:充电中 3:停止中 4:已结束 5:未知
+ *
+ * 充电设备接口编码 ConnectorID 是 字符串 参见《电动汽车充换电服务信息交换 第2部分:公共信息交换规范》
+ *
+ * 充电设备接口状态 ConnectorStatus 是 整型 1:空闲 2:占用(未充电) 3:占用(充电中) 4:占用(预约锁定) 255:故障
+ *
+ * A相电流 CurrentA 是 浮点型 单位:A,默认:0 含直流(输出)
+ *
+ * B相电流 CurrentB 否 浮点型 单位:A,默认:0
+ *
+ * C相电流 CurrentC 否 浮点型 单位:A,默认:0
+ *
+ * A相电压 VoltageA 是 浮点型 单位:V,默认:0含直流(输出)
+ *
+ * B相电压 VoltageB 否 浮点型 单位:V,默认:0
+ *
+ * C相电压 VoltageC 否 浮点型 单位:V,默认:0
+ *
+ * 电池剩余电量 Soc 是 浮点型 默认:0
+ *
+ * 开始充电时间 StartTime 是 字符型 格式“yyyy-MM-dd HH:mm:ss”
+ *
+ * 本次采样时间 EndTime 是 字符型 格式“yyyy-MM-dd HH:mm:ss”
+ *
+ * 累计充电量 TotalPower 是 浮点型 单位:度,小数点后3位
+ *
+ * 累计电费 ElecMoney 否 浮点型 单位:元,小数点后2位
+ *
+ * 累计服务费 SeviceMoney 否 浮点型 单位:元,小数点后2位
+ *
+ * 累计总金额 TotalMoney 否 浮点型 单位:元,小数点后2位
+ *
+ * 时段数N SumPeriod 否 整型 范围:0~32
+ *
+ * 充电明细信息 ChargeDetails 否
+ *
+ * ChargeDetails数组 单时段充电明细信息
+ *充电明细信息体(ChargeDetails)
+ * 参数名称 定义 必填 参数类型 描述
+ * 始时间 DetailStartTime 是 字符串 格式“yyyy-MM-dd HH:mm:ss”
+ * 结束时间 DetailEndTime 是 字符串 格式“yyyy-MM-dd HH:mm:ss”
+ * 时段电价 ElecPrice 否 浮点型 小数点后4位
+ * 时段服务费价格 SevicePrice 否 浮点型 小数点后4位
+ * 时段充电量 DetailPower 是 浮点型 单位:度,小数点后3位
+ * 时段电费 DetailElecMoney 否 浮点型 小数点后2位
+ * 时段服务费 DetailSeviceMoney 否 浮点型 小数点后2位
+ */
+ public function Get_query_equip_charge_status($StartChargeSeq)
+ {
+ $token = Cache::get('token');
+ if (!$token) {
+ $hardtoken = new HardToken();
+ $token = $hardtoken->getToken();
+ }
+
+
+ $kk['StartChargeSeq'] = $StartChargeSeq;
+ $en = $this->Encrypt(json_encode($kk));
+
+ $datetime = date('YmdHis');
+ $sig = config('hard.OperatorID') . $en . $datetime . config('hard.Seq');
+ $s = $this->HmacMD5($sig);
+
+ $data = [
+ 'OperatorID' => config('hard.OperatorID'),
+ 'Data' => $en,
+ 'TimeStamp' => $datetime,
+ 'Seq' => config('hard.Seq'),
+ 'Sig' => $s,
+ ];
+ $message = $this->CurlSend(config('hard.url') . '/query_equip_charge_status ', $data, $token);
+ $en_mess = $message['Data'];
+ $de_data = $this->Decrypt($en_mess);
+ Db::table('charge_logo')->insert(['mark' => $de_data, 'name' => $StartChargeSeq . ':充电状态Get_query_equip_charge_status']);
+
+
+ $array = json_decode($de_data, true);
+
+ if (isset($data['TotalMoney']) && $data['TotalMoney'] > 0) {
+ //累计金额??????
+
+ $ll = array_diff_key($array, ["ChargeDetails" => 'xy', 'StartTime' => 'xy', "StartChargeSeq" => 'xy', 'ConnectorID' => 'xy', 'TotalMoney' => 'xy']);
+
+
+ $charge_order_info = Db::table('zxc_charge_order')
+ ->where('StartChargeSeq', $StartChargeSeq)
+ ->field('openid,charge_station_id,order_number,WithholdingMoney,status, end_time')
+ ->find();
+
+ $station_type = \app\model\ChargeStation::where('charge_station_id', $charge_order_info['charge_station_id'])->value('station_type');
+
+ $detail_message = '';
+ if ((int)$station_type == 0) {
+ $ii = 1;
+ $total = 0;
+ $ElectMoney = 0;
+ $SeviceMoney = 0;
+ foreach ($array['ChargeDetails'] as $Details) {
+ $Details = (array)$Details;
+ $per_price = $this->Rank($charge_order_info['charge_station_id'], $Details['DetailStartTime'], $Details['DetailEndTime'], $charge_order_info['openid'])['Elect'];
+ $S_price = $this->Rank($charge_order_info['charge_station_id'], $Details['DetailStartTime'], $Details['DetailEndTime'], $charge_order_info['openid'])['Serve'];
+ $period_price = round($Details['DetailPower'] * $per_price, 2);
+ $service_price = round($Details['DetailPower'] * $S_price, 2);
+ $total_money = $period_price + $service_price;
+ $detail_message .= '时段' . $ii .
+ ':开始时间:' . $Details['DetailStartTime'] . ',' .
+ '结束时间:' . $Details['DetailEndTime'] . ',' .
+ '所用度数:' . $Details['DetailPower'] . ',' .
+ '时段电费单价:' . $per_price . ',' .
+ '时段电费金额:' . $period_price . ',' .
+ '时段服务费单价:' . $S_price . ',' .
+ '时段服务费金额:' . $service_price . ',' .
+ '时段总价:' . $total_money . ';';
+ $ii += 1;
+ $total += $total_money;
+ $ElectMoney += $period_price;
+ $SeviceMoney += $service_price;
+ }
+ } else {
+ $price = $this->GetPrice($charge_order_info['charge_station_id'], $charge_order_info['openid']);
+ $total = $ll['TotalPower'] * $price['EPrice'] + ($ll['TotalPower'] * $price['SPrice']);
+ $ElectMoney = $array['TotalPower'] * $price['EPrice'];
+ $SeviceMoney = $array['TotalPower'] * $price['SPrice'];
+ }
+
+
+ if ((float)$charge_order_info['WithholdingMoney'] - (float)$total <= 3) {
+ Db::table('charge_logo')->save([
+ 'name' => '检测到费用不足执行结束--查询充电状态',
+ 'mark' => json_encode([
+ 'WithholdingMoney' => $charge_order_info['WithholdingMoney'],
+ 'TotalMoney' => $array['TotalMoney'],
+ ])
+ ]);
+ $order = new ChargeOrder();
+ $order->EndOrder2($charge_order_info['openid'], $charge_order_info['order_number']);
+ }
+
+ $ll['status'] = $ll['StartChargeSeqStat'];
+ $ll['TotalMoney'] = round($total, 2);
+ $ll['ElecMoney'] = round($ElectMoney, 2);
+ $ll['SeviceMoney'] = round($SeviceMoney, 2);
+
+ if (empty($charge_order_info['end_time']) && $charge_order_info['status'] != 4) {
+ Db::table('zxc_charge_order')
+ ->where('StartChargeSeq', $StartChargeSeq)
+ ->save($ll);
+ }
+ return ['code' => 200];
+ } else {
+ return ['code' => 1];
+ }
+ }
+
+
+ //查询充电状态 同上但是只返回了数据信息
+ public function Get_query_equip_charge_status_test($StartChargeSeq)
+ {
+ $token = Cache::get('token');
+ if (!$token) {
+ $hardtoken = new HardToken();
+ $token = $hardtoken->getToken();
+ }
+ $datetime = date('YmdHis');
+ $kk['StartChargeSeq'] = $StartChargeSeq;
+ $en = $this->Encrypt(json_encode($kk));
+ $sig = config('hard.OperatorID') . $en . $datetime . config('hard.Seq');
+ $s = $this->HmacMD5($sig);
+ $rr['OperatorID'] = config('hard.OperatorID');
+ $rr['Data'] = $en;
+ $rr['TimeStamp'] = $datetime;
+ $rr['Seq'] = config('hard.Seq');
+ $rr['Sig'] = $s;
+ $data = $rr;
+ $message = $this->CurlSend(config('hard.url') . '/query_equip_charge_status ', $data, $token);
+ $en_mess = $message['Data'];
+ $de_data = $this->Decrypt($en_mess);
+ $arr = json_decode($de_data);
+ $array = (array)$arr;
+// dd($array);
+ if (isset($array['TotalMoney'])) {
+ $ll = array_diff_key($array, ["ChargeDetails" => 'xy', 'StartTime' => 'xy', "StartChargeSeq" => 'xy', 'ConnectorID' => 'xy', 'TotalMoney' => 'xy']);
+ $station_id = Db::table('zxc_charge_order')->where('StartChargeSeq', $StartChargeSeq)->value('charge_station_id');
+ $station_type = \app\model\ChargeStation::where('charge_station_id', $station_id)->value('station_type');
+ $openid = Db::table('zxc_charge_order')->where('StartChargeSeq', $StartChargeSeq)->value('openid');
+ $detail_message = '';
+// dd($array);
+ if ((int)$station_type == 0) {
+ $ii = 1;
+ $total = 0;
+ $total_elet = 0;
+ $total_ser = 0;
+
+ foreach ($array['ChargeDetails'] as $Details) {
+ $Details = (array)$Details;
+ $price = $this->Rank($station_id, $Details['DetailStartTime'], $Details['DetailEndTime'], $openid);
+ $per_price = $price['Elect'];
+ $S_price = $price['Serve'];
+ $period_price = round($Details['DetailPower'] * $per_price, 2);
+ $service_price = round($Details['DetailPower'] * $S_price, 2);
+ $total_money = $period_price + $service_price;
+ $detail_message .= '时段' . $ii .
+ ':开始时间:' . $Details['DetailStartTime'] . ',' .
+ '结束时间:' . $Details['DetailEndTime'] . ',' .
+ '所用度数:' . $Details['DetailPower'] . ',' .
+ '时段电费单价:' . $per_price . ',' .
+ '时段电费金额:' . $period_price . ',' .
+ '时段服务费单价:' . $S_price . ',' .
+ '时段服务费金额:' . $service_price . ',' .
+ '时段总价:' . $total_money . ';';
+ $ii += 1;
+ $total += $total_money;
+ $total_elet += $period_price;
+ $total_ser += $service_price;
+ }
+ } else {
+ $price = $this->GetPrice($station_id, $openid);
+ $total = $ll['TotalPower'] * $price['EPrice'] + ($ll['TotalPower'] * $price['SPrice']);
+ $total_elet = $ll['TotalPower'] * $price['EPrice'];
+ $total_ser = $ll['TotalPower'] * $price['SPrice'];
+ }
+ $ll['TotalMoney'] = round($total, 2);
+ $ll['ElecMoney'] = round($total_elet, 2);
+ $ll['SeviceMoney'] = round($total_ser, 2);
+// $WithholdingMoney = Db::table($table)->where('StartChargeSeq',$StartChargeSeq)->value('WithholdingMoney');
+// $openid = Db::table($table)->where('StartChargeSeq',$StartChargeSeq)->value('openid');
+// $order_num = Db::table($table)->where('StartChargeSeq',$StartChargeSeq)->value('order_number');
+// if ((float)$WithholdingMoney - (float)$ll['TotalMoney']<=3){
+// $order = new ChargeOrder();
+// $order->EndOrder($openid,$order_num);
+// }
+ $ll['status'] = $ll['StartChargeSeqStat'];
+ $ll['DetailMessage'] = $detail_message;
+ return ['code' => 200, 'data' => $ll];
+// $end_time = Db::table($table)->where('order_number',$order_num)->value('end_time');
+// if (empty($end_time)){
+// Db::table($table)->where('StartChargeSeq',$StartChargeSeq)->update($ll);
+// }
+ } else {
+ return ['code' => 1];
+ }
+ }
+
+
+// 计算单个价格
+ public function Rank($station_id, $start, $end, $openid)
+ {
+
+ $start_time = date('H:i:s', strtotime($start));
+ $end_time = date('H:i:s', strtotime($end));
+// echo $start_time;
+// echo $end_time;
+ $interval = $this->GetPrice($station_id, $openid);
+ $SPrice = $interval['SPrice'];
+ $interval = $interval['message'];
+ $station_type = \app\model\ChargeStation::where('charge_station_id', $station_id)->value('station_type');
+ if ((int)$station_type == 0) {
+ $i = 0;
+ foreach ($interval as $in) {
+ $st = date('H:i:s', strtotime($in['start']));
+// $en = date('H:i:s',strtotime('-1 seconds',strtotime($in['end'])));
+ $en = date('H:i:s', strtotime($in['end']));
+ $check = date('H:i:s', strtotime('23:59:59'));
+ $check1 = date('H:i:s', strtotime('00:00:00'));
+ if ($i <= 7 && $start_time >= $st && $end_time <= $en && $end_time != $check1) {
+ return ['Elect' => $in['univalence'], 'Serve' => $SPrice];
+ } elseif ($i == 7 && $start_time >= $st && ($end_time <= $check || $end_time = $check1)) {
+ return ['Elect' => $in['univalence'], 'Serve' => $SPrice];
+ }
+ $i += 1;
+ }
+ }
+ }
+
+ //计算电费
+ public function GetPrice($station_id, $openid)
+ {
+ $station_type = \app\model\ChargeStation::where('charge_station_id', $station_id)->value('station_type');
+ $ElectricityFee = Db::table('charge_station')->where('charge_station_id', $station_id)->value('ElectricityFee');
+ $type = Db::table('zxc_user')->where('openid', $openid)->value('type');
+ if ($type != 3) {
+ $ServiceFee = ServiceFee::where('type', $type)->where('station_type', $station_type)->value('service_fee');
+ } else {
+ $group_id = EnterpriseUser::where('openid', $openid)->value('group_id');
+ $ServiceFee = ServiceFee::where('type', $type)->where('station_type', $station_type)->where('group_id', $group_id)->value('service_fee');
+ }
+// $ServiceFee= Db::table('charge_station')->where('charge_station_id',$station_id)->value('ServiceFee');
+ $ElectricityFee = str_replace('电费:', '', $ElectricityFee);
+ $Elect = explode(',', $ElectricityFee);
+
+ for ($index = 0; $index < count($Elect); $index++) {
+ $kk['time_interval'] = substr($Elect[$index], 0, 11);
+ $tt = explode('~', $kk['time_interval']);
+ $start = $tt[0] . ':00';
+ $end = $tt[1] ?? $tt[1] . ':00';
+
+ $kk['univalence'] = explode(':', $Elect[$index])[3];
+ $kk['start'] = $start;
+ $kk['end'] = $end;
+ $ss[] = $kk;
+ }
+ $ServiceFee = str_replace('服务费:', '', $ServiceFee);
+ $Server = explode(',', $ServiceFee);
+ for ($index = 0; $index < count($Server); $index++) {
+ $ll['time_interval'] = substr($Server[$index], 0, -5);
+ $ll['univalence'] = substr($Server[$index], Strlen($Server[$index]) - 4);
+ $mm[] = $ll;
+ }
+ if ($station_type == 1) {
+ return ['EPrice' => number_format((float)($ss[0]['univalence']), 6), 'SPrice' => number_format((float)($mm[0]['univalence']), 2)];
+ } elseif ($station_type == 0) {
+ return ['message' => $ss, 'SPrice' => number_format((float)($mm[0]['univalence']), 2)];
+
+ }
+ }
+
+
+ /**
+ * 推送充电状态
+ * 启动充电后,由特来电每@@@@@@五分钟@@@@@@@@推一次充电状态
+ * @param Request $request
+ * @return array|Json
+ */
+ public function notification_equip_charge_status(Request $request)
+ {
+ $params = file_get_contents('php://input');
+
+
+ $params = json_decode($params, true);
+ $OperatorID = empty($params['OperatorID']) ? '' : $params['OperatorID'];
+ $authorization = $request->header()['authorization'];//传递过来的token
+ $auths = explode(' ', trim($authorization));
+ $auth = $auths[count($auths) - 1];
+ $checkParams = $this->checkParams($params);
+
+ if ($checkParams != 2) {
+ return ['Msg' => $checkParams . '为空', 'Ret' => 4003, 'Data' => ['Status' => 1]];
+ }
+
+ if (!$auth) {
+ return $this->encodeData(['Status' => 1], $params, 4002, 'Bearer 未添加');
+ }
+
+ if ($this->checkToken_assess($auth) == 1 || $this->checkSig($params['OperatorID'], $params) == 1) {
+ $data = json_encode(['Status' => 1]);
+ $data = $this->Encrypt($data);
+ $seq = empty($Seq) ? '0001' : $params['Seq'];
+ $datetime = empty($TimeStamp) ? date('YmdHis') : $params['TimeStamp'];
+ $sig = $OperatorID . $data . $datetime . $seq;
+ $s = $this->HmacMD5($sig);
+ return json(['Msg' => '签名错误、Token过期或者无效', 'Ret' => 4002, 'Data' => $data, 'Sig' => $s]);
+ }
+
+
+ $data = $this->Decrypt($params['Data']);
+ Db::table('charge_logo')->save(['name' => '推送充电状态notification_equip_charge_status', 'mark' => $data]);
+
+
+ $data = json_decode($data, true);
+ if (isset($data['TotalMoney']) && $data['TotalMoney'] > 0) {
+ $array = array_diff_key($data, ["ChargeDetails" => 'xy', 'StartTime' => 'xy', 'StartChargeSeq' => 'xy', 'ConnectorID' => 'xy', 'TotalMoney' => 'xy']);
+ $array['start_time'] = $data['StartTime'];
+
+
+ $charge_order_info = Db::table('zxc_charge_order')->where('StartChargeSeq', $data['StartChargeSeq'])->find();
+ Db::table('charge_logo')->save(['name' => '调试数据', 'mark' => json_encode($charge_order_info)]);
+
+ $station_type = \app\model\ChargeStation::where('charge_station_id', $charge_order_info['charge_station_id'])->value('station_type');
+
+ $detail_message = '';
+ if ((int)$station_type == 0) {
+ $ii = 1;
+ $total = 0;
+ $ElectMoney = 0;
+ $SeviceMoney = 0;
+ foreach ($data['ChargeDetails'] as $Details) {
+ $Details = (array)$Details;
+ $per_price = $this->Rank($charge_order_info['charge_station_id'], $Details['DetailStartTime'], $Details['DetailEndTime'], $charge_order_info['openid'])['Elect'];
+ $S_price = $this->Rank($charge_order_info['charge_station_id'], $Details['DetailStartTime'], $Details['DetailEndTime'], $charge_order_info['openid'])['Serve'];
+ $period_price = round($Details['DetailPower'] * $per_price, 2);
+ $service_price = round($Details['DetailPower'] * $S_price, 2);
+ $total_money = $period_price + $service_price;
+ $detail_message .= '时段' . $ii .
+ ':开始时间:' . $Details['DetailStartTime'] . ',' .
+ '结束时间:' . $Details['DetailEndTime'] . ',' .
+ '所用度数:' . $Details['DetailPower'] . ',' .
+ '时段电费单价:' . $per_price . ',' .
+ '时段电费金额:' . $period_price . ',' .
+ '时段服务费单价:' . $S_price . ',' .
+ '时段服务费金额:' . $service_price . ',' .
+ '时段总价:' . $total_money . ';';
+ $ii += 1;
+ $total += $total_money;
+ $ElectMoney += $period_price;
+ $SeviceMoney += $service_price;
+ }
+ } else {
+ $price = $this->GetPrice($charge_order_info['charge_station_id'], $charge_order_info['openid']);
+ $total = $array['TotalPower'] * $price['EPrice'] + ($array['TotalPower'] * $price['SPrice']);
+ $ElectMoney = $data['TotalPower'] * $price['EPrice'];
+ $SeviceMoney = $data['TotalPower'] * $price['SPrice'];
+ }
+
+ $array['TotalMoney'] = round($total, 2);
+ $order_num = Db::table('zxc_charge_order')->where('StartChargeSeq', $data['StartChargeSeq'])->value('order_number');
+ if ((float)$charge_order_info['WithholdingMoney'] - (float)$array['TotalMoney'] <= 3) {
+ Db::table('charge_logo')->save([
+ 'name' => '检测到费用不足执行结束--推送',
+ 'mark' => json_encode([
+ 'WithholdingMoney' => $charge_order_info['WithholdingMoney'],
+ 'TotalMoney' => $array['TotalMoney'],
+ ])
+ ]);
+ $order = new ChargeOrder();
+ $order->EndOrder2($charge_order_info['openid'], $order_num);
+ }
+
+
+ $array['ElecMoney'] = round($ElectMoney, 2);
+ $array['SeviceMoney'] = round($SeviceMoney, 2);
+ $array['status'] = $array['StartChargeSeqStat'];
+
+ if (empty($charge_order_info['end_time']) && $charge_order_info['status'] != 4) {
+ Db::table('zxc_charge_order')->where('StartChargeSeq', $data['StartChargeSeq'])->save($array);
+ }
+
+ $kk['StartChargeSeq'] = $data['StartChargeSeq'];
+ $kk['SuccStat'] = 0;
+ return $this->encodeData($kk, $params, 0);
+ }
+
+
+ }
+
+
+ /**
+ * 接口名称:请求停止充电query_stop_charge
+ * 接口说明:通过充电订单号、设备接口编码,请求停止充电。
+ * 请求格式:json
+ * 请求方式:post
+ * @param $StartChargeSeq string 充电订单号
+ * @param $ConnectorID string 充电设备接口编码
+ * @return array
+ */
+ public function Get_query_stop_charge($StartChargeSeq, $ConnectorID)
+ {
+
+ $token = Cache::get('token');
+ if (!$token) {
+ $hardtoken = new HardToken();
+ $token = $hardtoken->getToken();
+ }
+
+
+ $kk = [
+ 'StartChargeSeq' => $StartChargeSeq,
+ 'ConnectorID' => $ConnectorID,
+ ];
+ $en = $this->Encrypt(json_encode($kk));
+
+
+ $datetime = date('YmdHis');
+ $sig = config('hard.OperatorID') . $en . $datetime . config('hard.Seq');
+ $s = $this->HmacMD5($sig);
+
+ $data = [
+ 'OperatorID' => config('hard.OperatorID'),
+ 'Data' => $en,
+ 'TimeStamp' => $datetime,
+ 'Seq' => config('hard.Seq'),
+ 'Sig' => $s,
+ ];
+ $message = $this->CurlSend(config('hard.url') . '/query_stop_charge', $data, $token);
+ $en_mess = $message['Data'];
+ $de_data = $this->Decrypt($en_mess);
+
+
+ return json_decode($de_data, true);
+ }
+
+
+ /**
+ * 接口名称:推送停止充电结果notification_stop_charge_result
+ * 接口说明:发起停止充电请求后,由特来电方推送停止充电结果,包括充电订单号、订单状态、充电设备接口编码、充电启动时间。
+ * 请求格式:json
+ * 请求方式:post
+ * @param Request $request
+ * 充电订单号 StartChargeSeq 是 字符串 格式“运营商ID+唯一编号”,27字符
+ *
+ * 充电订单状态 StartChargeSeqStat 是 整型 1:启动中 2:充电中 3:停止中 4:已结束 5:未知
+ *
+ * 充电设备接口编码 ConnectorID 是 字符串 格式“6位行政区编码,4位电站编码,3位终端编码”,13位字符
+ *
+ * 成功标识 SuccStat 是 整型 0:成功; 1:失败
+ *
+ * 停止失败原因 FailReason 是 整型 0:无; 1:此设备不存在; 2:此设备离线: 3:设备已停止充电; 4~99:自定义
+ *
+ * @return array|Json
+ * 充电订单号 StartChargeSeq 是 字符串 格式“运营商ID+唯一编号”,27字符,与6.5.3章节相同
+ *
+ * 操作结果 SuccStat 是 整型 0:成功; 1:失败
+ * 失败原因 FailReason 是 整型 0:无; 1:接收失败;
+ *
+ */
+ public function notification_stop_charge_result(Request $request)
+ {
+ $params = file_get_contents('php://input');
+
+ Db::table('charge_logo')->save(['name' => '推送停止充电结果notification_stop_charge_result', 'mark' => $params]);
+ $params = json_decode($params, true);
+ $OperatorID = empty($params['OperatorID']) ? '' : $params['OperatorID'];
+ $authorization = $request->header()['authorization'];//传递过来的token
+ $auths = explode(' ', trim($authorization));
+ $auth = $auths[count($auths) - 1];
+ $checkParams = $this->checkParams($params);
+ if ($checkParams != 2) {
+ return ['Msg' => $checkParams . '为空', 'Ret' => 4003, 'Data' => ['Status' => 1]];
+ }
+
+ if (!$auth) {
+ return $this->encodeData(['Status' => 1], $params, 4002, 'Bearer 未添加');
+ }
+
+
+ if ($this->checkToken_assess($auth) == 1 || $this->checkSig($params['OperatorID'], $params) == 1) {
+ $data = json_encode(['Status' => 1]);
+ $data = $this->Encrypt($data);
+ $seq = empty($Seq) ? '0001' : $params['Seq'];
+ $datetime = empty($TimeStamp) ? date('YmdHis') : $params['TimeStamp'];
+ $sig = $OperatorID . $data . $datetime . $seq;
+ $s = $this->HmacMD5($sig);
+ return json(['Msg' => '签名错误/Token过期或者无效', 'Ret' => 4002, 'Data' => $data, 'Sig' => $s]);
+ }
+
+
+ $data = $this->Decrypt($params['Data']);
+ Db::table('charge_logo')->save(['name' => $params['OperatorID'] . ':停止充电推送结果notification_stop_charge_result', 'mark' => $data]);
+ $data = json_decode($data, true);
+
+
+ if ($data['StartChargeSeqStat'] == 4 && $data['SuccStat'] == 0 && $data['FailReason'] == 0) {
+
+ $ss['StartChargeSeqStat'] = $data['StartChargeSeqStat'];
+ $ss['status'] = $data['StartChargeSeqStat'];
+
+ Db::table('zxc_charge_order')->where('StartChargeSeq', $data['StartChargeSeq'])->update($ss);
+
+ exit();
+ } else {
+ Db::table('zxc_charge_order')
+ ->where('StartChargeSeq', $data['StartChargeSeq'])
+ ->update(['StopFailreason' => $data['FailReason']]);
+ exit();
+ }
+
+ }
+
+
+ /**
+ * 接口名称:推送充电订单信息notification_charge_order_info
+ * 接口说明:结束充电后,由特来电推送充电订单信息。
+ * 请求格式:json
+ * 请求方式:post
+ * @param Request $request
+ *充电订单号 StartChargeSeq 是 字符串 格式“运营商ID+唯一编号”,27字符
+ *
+ * 充电设备接口编码 ConnectorID 是 字符串 格式“6位行政区编码,4位电站编码,3位终端编码”,13位字符
+ *
+ * 开始充电时间 StartTime 是 字符串 格式“yyyy-MM-dd HH:mm:ss”
+ *
+ * 结束充电时间 EndTime 是 字符串 格式“yyyy-MM-dd HH:mm:ss”
+ *
+ * 累计充电量 TotalPower 是 浮点型 单位:度,小数点后3位
+ *
+ * 总电费 TotalElecMoney 是 浮点型 单位:元,小数点后2位
+ *
+ * 总服务费 TotalSeviceMoney 是 浮点型 单位:元,小数点后2位
+ *
+ * 累计总金额 TotalMoney 是 浮点型 单位:元,小数点后2位
+ *
+ * 充电结束原因 StopReason 是 整型 0:用户手动停止充电 1:客户归属地运营商平台停止充电 2:BMS停止充电; 3:充电机设备故障; 4:连接器断开 5-99自定义
+ *
+ * 时段数N SumPeriod 否 整型 范围:0~32
+ *
+ * 充电明细信息 ChargeDetails 否 ChargeDetails数组 单时段充电明细信息
+ * @return array|Json
+ *充电订单号 StartChargeSeq 是 字符串 格式“运营商ID+唯一编号”,27字符
+ *
+ * 充电设备接口编码 ConnectorID 是 字符串 格式“6位行政区编码,4位电站编码,3位终端编码”,13位字符
+ *
+ * 确认结果 ConfirmResult 是 整型 0:成功 1:争议交易 2~99:自定义
+ */
+ public function notification_charge_order_info(Request $request)
+ {
+
+ $params = file_get_contents('php://input');
+ $params = json_decode($params, true);
+ $OperatorID = empty($params['OperatorID']) ? '' : $params['OperatorID'];
+ $authorization = $request->header()['authorization'];//传递过来的token
+ $auths = explode(' ', trim($authorization));
+ $auth = $auths[count($auths) - 1];
+
+ $checkParams = $this->checkParams($params);
+ if ($checkParams != 2) {
+ return ['Msg' => $checkParams . '为空', 'Ret' => 4003, 'Data' => ['Status' => 1]];
+ }
+
+
+ if (!$auth) {
+ return $this->encodeData(['Status' => 1], $params, 4002, 'Bearer 未添加');
+ }
+ if ($this->checkToken_assess($auth) == 1 || $this->checkSig($params['OperatorID'], $params) == 1) {
+ $data = json_encode(['Status' => 1]);
+ $data = $this->Encrypt($data);
+ $seq = empty($Seq) ? '0001' : $params['Seq'];
+ $datetime = empty($TimeStamp) ? date('YmdHis') : $params['TimeStamp'];
+ $sig = $OperatorID . $data . $datetime . $seq;
+ $s = $this->HmacMD5($sig);
+ return json(['Msg' => '签名错误、Token过期或者无效', 'Ret' => 4002, 'Data' => $data, 'Sig' => $s]);
+ }
+
+ $data = $this->Decrypt($params['Data']);
+ Db::table('charge_logo')->save(['name' => $params['OperatorID'] . ':推送充电订单信息notification_charge_order_info', 'mark' => $data]);
+ $data = json_decode($data, true);
+
+
+ if (isset($data['StopReason'])) {
+
+ $StartChargeSeq = $data['StartChargeSeq'];
+
+ $charge_info = Db::table('zxc_charge_order')->where('StartChargeSeq', $StartChargeSeq)->find();
+
+ $WithholdingMoney = $charge_info['WithholdingMoney'];
+ $station_id = $charge_info['charge_station_id'];
+ $station_type = \app\model\ChargeStation::where('charge_station_id', $station_id)->value('station_type');
+
+ $detail_message = '';
+ if ((int)$station_type == 0) {
+ $ii = 1;
+ $total = 0;
+ $ElectMoney = 0;
+ $SeviceMoney = 0;
+ foreach ($data['ChargeDetails'] as $Details) {
+ $Details = (array)$Details;
+ $per_price = $this->Rank($station_id, $Details['DetailStartTime'], $Details['DetailEndTime'], $charge_info['openid'])['Elect'];
+ $S_price = $this->Rank($station_id, $Details['DetailStartTime'], $Details['DetailEndTime'], $charge_info['openid'])['Serve'];
+ $period_price = round($Details['DetailPower'] * $per_price, 2);
+ $service_price = round($Details['DetailPower'] * $S_price, 2);
+ $total_money = $period_price + $service_price;
+ $detail_message .= '时段' . $ii .
+ ':开始时间:' . $Details['DetailStartTime'] . ',' .
+ '结束时间:' . $Details['DetailEndTime'] . ',' .
+ '所用度数:' . $Details['DetailPower'] . ',' .
+ '时段电费单价:' . $per_price . ',' .
+ '时段电费金额:' . $period_price . ',' .
+ '时段服务费单价:' . $S_price . ',' .
+ '时段服务费金额:' . $service_price . ',' .
+ '时段总价:' . $total_money . ';';
+ $ii += 1;
+ $total += $total_money;
+ $ElectMoney += $period_price;
+ $SeviceMoney += $service_price;
+ }
+ } else {
+ $price = $this->GetPrice($station_id, $charge_info['openid']);
+ $total = $data['TotalPower'] * $price['EPrice'] + ($data['TotalPower'] * $price['SPrice']);
+ $ElectMoney = $data['TotalPower'] * $price['EPrice'];
+ $SeviceMoney = $data['TotalPower'] * $price['SPrice'];
+ }
+ $ss['end_time'] = $data['EndTime'];
+ $ss['TotalPower'] = $data['TotalPower'];
+ $TotalMoney = round($total, 2);
+ $ss['ElecMoney'] = round($ElectMoney, 2);
+ $ss['SeviceMoney'] = round($SeviceMoney, 2);
+ $ss['TotalMoney'] = $TotalMoney;
+ $ss['stop_type'] = $data['StopReason'];
+ $ss['SumPeriod'] = $data['SumPeriod'];
+ $ss['status'] = 4;
+ $ss['StartChargeSeqStat'] = 4;
+ $ss['FeedbackMoney'] = round($WithholdingMoney - $TotalMoney, 2);
+ $ss['DetailMessage'] = $detail_message;
+
+ $check = $charge_info['FeedbackMoney'];
+ if (empty($check)) {
+
+ Db::table('zxc_charge_order')->where('StartChargeSeq', $StartChargeSeq)->save($ss);
+ $charge_info = Db::table('zxc_charge_order')->where('StartChargeSeq', $StartChargeSeq)->find();
+
+
+ // 即充即退
+ if ($charge_info['type'] == 1 && $charge_info['directly_refund_status'] == 0 && $charge_info['is_wind'] == 0) {
+ $td = new WechatReimburse();
+ $td->Refund2($charge_info['order_id'], $charge_info['openid'], $charge_info['FeedbackMoney'], $charge_info['WithholdingMoney'], $charge_info['directly_pay_no']);
+ Db::table('charge_logo')->save(['name' => '充电结束即充即退执行退款', 'mark' => json_encode($charge_info)]);
+ }
+
+ //个人余额
+ if ($charge_info['type'] == 2 && $charge_info['is_wind'] == 0) {
+ Db::table('zxc_charge_order')->where('StartChargeSeq', $StartChargeSeq)->save(['is_wind'=>1]);
+ \app\model\User::addMoneyLog($charge_info['openid'], $TotalMoney, 1, '充电结束执行用户使用个人钱包充电' . $ss['FeedbackMoney']);
+ Db::table('zxc_user')->where('openid', $charge_info['openid'])->update(['account' => Db::raw('account-' . $TotalMoney)]);
+ }
+
+ }
+
+
+ Log::error('充电结束' . json_encode($data), 'error');
+
+ exit();
+ }
+
+ }
+}
+
+
+
+
+
diff --git a/app/controller/HardToken.php b/app/controller/HardToken.php
new file mode 100644
index 0000000..4e18096
--- /dev/null
+++ b/app/controller/HardToken.php
@@ -0,0 +1,55 @@
+ $OperatorID, 'OperatorSecret' => $OperatorSecret);
+
+ $data = json_encode($mess);
+ $aes = new Aes();
+ $en_data = $aes->encrypt($data);
+
+
+ $de_Sig = $OperatorID . $en_data . $time . $Seq;
+ $hmacmd5 = new HMACMD5();
+ $Sig = $hmacmd5->HMAC($de_Sig);
+
+
+ $kk['OperatorID'] = $OperatorID;
+ $kk['Data'] = $en_data;
+ $kk['TimeStamp'] = $time;
+ $kk['Seq'] = $Seq;
+ $kk['Sig'] = $Sig;
+ $datas = $this->CurlSend(config('hard.url') . '/query_token', $kk);
+
+
+ $array_data = (array)$datas;
+ if ($array_data['Ret'] == 0) {
+ $token = $array_data['Data'];
+ $de_data = $aes->decrypt($token);
+
+ $array_token = json_decode($de_data, true);
+ $token = $array_token['AccessToken'];
+ Cache::set('token', $token, 7200);
+
+ return $token;
+ } else {
+ return 1;
+ }
+ }
+
+
+}
diff --git a/app/controller/Index.php b/app/controller/Index.php
new file mode 100644
index 0000000..0ea9068
--- /dev/null
+++ b/app/controller/Index.php
@@ -0,0 +1,278 @@
+sentence($area);
+ $s = strtr($s, array(' ' => ''));
+
+ $account = Db::table('user_' . $s)->where('openid', $openid)->value('account');
+
+ if ($account > 0) {
+
+ $chongzhi = Db::table('recharge_' . $s)->where('openid', $openid)->sum('total');
+ $chongzhi_usd = Db::table('recharge_' . $s)->where('openid', $openid)->sum('total_used');
+
+ $refund = Db::table('refund_' . $s)->where('openid', $openid)->sum('refund_total');
+
+
+ $order = Db::table('charge')->where('openid', $openid)->where('type', 1)->sum('TotalMoney');
+ $order_1 = Db::table('charge')->where('openid', $openid)->where('type', 1)->sum('WithholdingMoney');
+ $order_2 = Db::table('charge')->where('openid', $openid)->where('type', 1)->sum('FeedbackMoney');
+ $order2 = Db::table('charge_order_' . $s)->where('openid', $openid)->sum('TotalMoney');
+ echo '用户账户余额:' . $account;
+ echo '
';
+ echo '用户充值金额:' . number_format($chongzhi, 2);
+ echo '
';
+ echo '用户充值中提现金额:' . number_format($chongzhi_usd, 2);
+ echo '
';
+ echo '用户提现金额:' . number_format($refund, 2);
+ echo '
';
+ echo '用户老订单使用金额' . number_format($order2, 2);
+ echo '
';
+ echo '用户新订单充值金额' . number_format($order_1, 2);
+ echo '
';
+ echo '用户新订单退款金额' . number_format($order_2, 2);
+ echo '
';
+ echo '用户新订单消费金额' . number_format($order, 2);
+ echo '
';
+ echo '
';
+ echo '
';
+ }
+
+
+ }
+
+ public function index()
+ {
+
+
+ //充值记录
+// // $new_user = Db::table('user')->select();
+// $data = [];
+// // foreach ($new_user as $key => $value) {
+// // $openid = $value['openid'];
+// // $pinyin = new Pinyin();
+//
+// // $s = $pinyin->sentence($value['area']);
+// // $s = strtr($s, array(' ' => ''));
+// $list = Db::table('charge')->select();
+// foreach ($list as $key => $value) {
+// unset($value['order_id']);
+// $data[] = $value;
+// }
+// // }
+// // $id = Db::table('zxc_charge_order')->insertAll($data);
+// // halt($id);
+// halt($data);
+// exit();
+ // // 查询用户余额
+ // $new_user = Db::table('user')->select();
+
+ // $data = [];
+ // $i = 0;
+ // foreach ($new_user as $key => $value) {
+
+ // // $this->totalPrice($value['openid'], $value['area']);
+ // $openid = $value['openid'];
+ // $pinyin = new Pinyin();
+
+ // $s = $pinyin->sentence($value['area']);
+ // $s = strtr($s, array(' ' => ''));
+
+ // $account = Db::table('user_' . $s)->where('openid', $openid)->value('account');
+
+ // if ($account > 0) {
+ // $i++;
+ // $chongzhi = Db::table('recharge_' . $s)->where('openid', $openid)->sum('total');
+ // $chongzhi_usd = Db::table('recharge_' . $s)->where('openid', $openid)->sum('total_used');
+
+ // $refund = Db::table('refund_' . $s)->where('openid', $openid)->sum('refund_total');
+
+
+ // $order = Db::table('charge')->where('openid', $openid)->where('type', 1)->sum('TotalMoney');
+ // $order_1 = Db::table('charge')->where('openid', $openid)->where('type', 1)->sum('WithholdingMoney');
+ // $order_2 = Db::table('charge')->where('openid', $openid)->where('type', 1)->sum('FeedbackMoney');
+ // $order2 = Db::table('charge_order_' . $s)->where('openid', $openid)->sum('TotalMoney');
+ // $order2_1 = Db::table('charge_order_' . $s)->where('openid', $openid)->sum('WithholdingMoney');
+ // $order2_2 = Db::table('charge_order_' . $s)->where('openid', $openid)->sum('FeedbackMoney');
+ // echo '用户信息:'.$openid.' ' . $account;
+ // echo '
';
+ // echo '用户充值金额:' . number_format($chongzhi/100, 2);
+ // echo '
';
+ // echo '用户充值中提现金额:' . number_format($chongzhi_usd/100, 2);
+ // echo '
';
+ // echo '用户提现金额:' . number_format($refund/100, 2);
+ // echo '
';
+ // echo '用户老订单使用金额' . number_format($order2, 2);
+ // echo '
';
+ // echo '用户老订单充值金额' . number_format($order2_1, 2);
+ // echo '
';
+ // echo '用户老订单退款金额' . number_format($order2_2, 2);
+ // echo '
';
+ // echo '用户新订单充值金额' . number_format($order_1, 2);
+ // echo '
';
+ // echo '用户新订单退款金额' . number_format($order_2, 2);
+ // echo '
';
+ // echo '用户新订单消费金额' . number_format($order, 2);
+ // echo '
';
+ // echo '
';
+ // echo '
';
+ // }
+ // }
+ // echo '共'.$i.'个用户';
+ // halt($data);
+
+
+// 退款
+ // $charge_info = Db::table('zxc_charge_order')->where('StartChargeSeq', 'MACFHBM3X176243163424257415')->find();
+
+ // if ($charge_info['type'] == 1 && $charge_info['directly_refund_status'] == 0 && $charge_info['is_wind'] == 0) {
+ // $td = new WechatReimburse();
+ // $res = $td->Refund2($charge_info['order_id'], $charge_info['openid'], $charge_info['FeedbackMoney'], $charge_info['WithholdingMoney'], $charge_info['directly_pay_no']);
+ // var_dump($res);
+ // Db::table('charge_logo')->save(['name' => '充电结束即充即退执行退款', 'mark' => json_encode($charge_info)]);
+ // }else{
+ // echo '已退款';
+ // }
+
+ // exit();
+
+
+ //生成二维码
+ // $pile = Db::table('charge_pile')->where('charge_station_id','>',20)->select();
+ // foreach ($pile as $key=>$value){
+ // $this->getwxacode($value['ConnectorID']);
+ // echo $value['ConnectorID'].'
';
+ // }
+ // halt([]);
+ // $res = $this->getwxacode('9920000040835A');
+ // halt($res);
+
+
+ // 检查费用
+// $charge_order_info = Db::table('zxc_charge_order')->where('StartChargeSeq', 'MACFHBM3X176069545021698018')->find();
+// halt($charge_order_info);
+// $per_price = (new HardMessage())->Rank($charge_order_info['charge_station_id'], '2025-10-17 18:05:48', '2025-10-17 18:06:26', $charge_order_info['openid'])['Elect'];
+// halt($per_price);
+
+
+ // // 测试加金额
+ // $StartChargeSeq = 'MACFHBM3X176075347725868066';
+ // $charge_info = Db::table('charge')->where('StartChargeSeq', $StartChargeSeq)
+ // ->field('WithholdingMoney,charge_station_id,openid,FeedbackMoney,type,directly_refund_status')->find();
+ // $check = $charge_info['FeedbackMoney'];
+ // $ff = 0.01;
+ // $area = \app\model\ChargeOrder::where('StartChargeSeq', $StartChargeSeq)->value('area');
+ // $pinyin = new Pinyin();
+ // $s = $pinyin->sentence($area);
+ // $s = strtr($s, array(' ' => ''));
+ // $table = 'charge_order_' . $s;
+ // $table = 'charge';
+ // $table_user = 'user_' . $s;
+ // if (empty($check)) {
+ // Db::table($table_user)->where('openid', $charge_info['openid'])->update(['account' => Db::raw('account+' . $ff)]);
+ // Db::table('charge_logo')->save(['name'=>'充电结束执行用余额增加退款','mark'=>$ff]);
+ // // Db::table('charge')->where('StartChargeSeq', $StartChargeSeq)->save($ss);
+ // }
+ // exit();
+
+
+ // 计算费用
+ // $price = (new HardMessage)->GetPrice(19, 'obUtOvjCdTSrZTqbjTByESPo6kLE', 'user_qianlongzhiyaozhan');
+ // $total = $array['TotalPower'] * $price['EPrice'] + ($array['TotalPower'] * $price['SPrice']);
+ // $ElectMoney = $data['TotalPower'] * $price['EPrice'];
+ // $SeviceMoney = $data['TotalPower'] * $price['SPrice'];
+
+ // halt($price);
+
+
+ return ' :)
ThinkPHP V' . \think\facade\App::version() . '
16载初心不改 - 你值得信赖的PHP框架
[ V6.0 版本由 亿速云 独家赞助发布 ] ';
+ }
+
+ public function hello($name = 'ThinkPHP6')
+ {
+
+ return 'hello,' . $name;
+ }
+
+ public function config()
+ {
+ echo Config::has('database.connections.mysql.hostname');
+ }
+
+ function postRequest($url, $data, $headers = [])
+ {
+ $ch = curl_init();
+
+ // 如果是数组,自动转换为 JSON
+ if (is_array($data)) {
+ $data = json_encode($data, JSON_UNESCAPED_UNICODE);
+ $headers[] = 'Content-Type: application/json';
+ }
+
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_POST, true);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+
+ // 跳过 HTTPS 证书验证(仅测试环境使用,生产环境需配置证书)
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
+
+ $response = curl_exec($ch);
+ if (curl_errno($ch)) {
+ throw new Exception('cURL 请求失败: ' . curl_error($ch));
+ }
+ curl_close($ch);
+
+ return $response;
+ }
+
+ function base64_save($base64_img, $path)
+ {
+ $img_base = str_replace('data:image/jpeg;base64,', '', $base64_img);
+ $img_name = time() . rand(1000, 9999) . '.jpg'; //图片新名称
+ $img_path = $path . $img_name;
+ file_put_contents($img_path, base64_decode($img_base));
+
+ return $img_name; //返回新名称
+ }
+
+ public function getwxacode($ConnectorID)
+ {
+
+ $url_get = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' . config("wx.AppID") . '&secret=' . config("wx.AppSecret");
+ $tmptoken = file_get_contents($url_get);
+ $tmptoken = json_decode($tmptoken, true);
+ $token = $tmptoken['access_token'];
+ $url = 'https://api.weixin.qq.com/wxa/getwxacode?access_token=' . $token;
+ $data = [
+ 'path' => '/pages/charging/charging?ConnectorID=' . $ConnectorID,
+ 'env_version' => 'release',// 试用版(develop/trial/release)
+ ];
+ $res = $this->postRequest($url, $data);
+ $base64_image = "data:image/jpeg;base64," . base64_encode($res);
+
+ $res = (new Event())->base64_image_content($base64_image, '../public/qrcode/', $ConnectorID);
+ return $res;
+
+ }
+
+
+}
diff --git a/app/controller/Login.php b/app/controller/Login.php
new file mode 100644
index 0000000..4f35ac5
--- /dev/null
+++ b/app/controller/Login.php
@@ -0,0 +1,98 @@
+param();
+// var_dump($data);
+ //错误集合
+ $errors = [];
+ //验证
+ $validate = Validate::rule([
+ 'username' => 'unique:admin,username^password'
+ ]);
+
+ $result = $validate->check([
+ 'username' => $data['username'],
+ 'password' => $data['password']
+ ]);
+
+ //错误提示,反向操作
+ //如果用户名和密码同时比对存在,那其实就是正确的
+ if ($result) {
+ $errors[] = '用户名或密码错误~';
+ }
+
+ //判断跳转
+ if (!empty($errors)) {
+ return json([
+ 'code' => 1,
+ 'message' => $errors,
+ ]);
+ } else {
+
+ session('admin', $data['username']);
+ $admin_id = AdminModel::where('username', $data['username'])->value('id');
+ $roles = AdminModel::where('id', $admin_id)->value('roles');
+ $permission = AdminModel::where('id', $admin_id)->value('permission');
+ $token = $this->GennerteToken($admin_id);
+
+
+ if (!empty($permission)) {
+ $pp = explode(',', substr($permission, 0, -1));
+ } else {
+ $pp = array();
+ }
+ return json([
+ 'code' => 200,
+ 'message' => '登陆成功',
+ 'permissions' => $roles,
+ 'authority' => $pp,
+ 'adminId' => $admin_id,
+ 'token' => $token
+ ]);
+ }
+
+ }
+
+ private function GennerteToken($admin_id)
+ {
+ $key = 'zuxingzdz';
+ $token = array(
+ "iss" => $key, //签发者 可以为空
+ "aud" => '', //面象的用户,可以为空
+ "iat" => time(), //签发时间
+ "nbf" => time() + 3, //在什么时候jwt开始生效 (这里表示生成100秒后才生效)
+ "exp" => time() + 1296000, //token 过期时间
+ "data" => [ //记录的userid的信息,这里是自已添加上去的,如果有其它信息,可以再添加数组的键值对
+ 'admin_id' => $admin_id,
+ ]
+ );
+
+ $jwt = JWT::encode($token, $key, "HS256"); //根据参数生成了 token
+ return $jwt;
+ }
+
+ public function out()
+ {
+ session('admin', null);
+ return json(['code' => 200, 'massage' => '退出成功']);
+ }
+}
\ No newline at end of file
diff --git a/app/controller/Monitor.php b/app/controller/Monitor.php
new file mode 100644
index 0000000..cd9df9f
--- /dev/null
+++ b/app/controller/Monitor.php
@@ -0,0 +1,30 @@
+column('charge_station_name');
+ foreach ($list as $ll){
+ $message = Db::table('rtspaddr')->field('name')->where('charge_station_name',$ll)->select()->toArray();
+ $i = 0;
+ foreach ($message as $mess){
+ $message[$i]['station'] = $message[$i]['name'];
+ array_diff_key($message[$i],['name' => 'xy']);
+ $i+=1;
+ }
+ $kk['station'] = $ll;
+ $kk['children'] = $message;
+ $ss[] = $kk;
+ }
+ return json($ss);
+ }
+
+ public function MonitorId($MonitorName){
+ $id = Db::table('rtspaddr')->where('name',$MonitorName)->value('id');
+ return json(['id' => $id]);
+ }
+}
\ No newline at end of file
diff --git a/app/controller/Navigation.php b/app/controller/Navigation.php
new file mode 100644
index 0000000..b5ff45d
--- /dev/null
+++ b/app/controller/Navigation.php
@@ -0,0 +1,140 @@
+where("charge_station_number",$station_number)->value("charge_station_id");
+
+ $table_user = 'zxc_user';
+ $hd = new HardMessage();
+ $interval = $hd->GetPrice($station_id,$openid,$table_user);
+ $station_type = \app\model\ChargeStation::where('charge_station_id',$station_id)->value('station_type');
+
+ $free = 0;
+ $occupy = 0;
+ $fault = 0;
+ $i = 1;
+ $mess = Db::table('charge_pile')->where('charge_station_id',$station_id)->select();
+ foreach ($mess as $m){
+ if ($m['status']==1){
+ $free+=1;
+ }elseif ($m['status']==2){
+ $occupy+=1;
+ }elseif ($m['status']==3){
+ $occupy+=1;
+ }elseif ($m['status']==255){
+ $fault+=1;
+ }elseif ($m['status']==0){
+ $fault+=1;
+ }
+ $no = Db::table('charge_pile')->where('charge_pile_id',$m['charge_pile_id'])->value('no');
+ if($no==null){
+ Db::table('charge_pile')->where('charge_pile_id',$m['charge_pile_id'])->update(['no' => $i]);
+ }
+ $i+=1;
+ }
+ $kk['free'] = $free;
+ $kk['occupy'] = $occupy;
+ $kk['fault'] = $fault;
+ $kk['all'] = $free+$occupy+$fault;
+
+// $time = strtotime(date('H:i:s','00:00:00'));
+// $time = date('H:i:s',strtotime("2023-03-24 21:59:59"));
+ $time = date('H:i:s',time());
+ if ((int)$station_type==0){
+ $SPrice = $interval['SPrice'];
+ $interval = $interval['message'];
+ $i = 0;
+ foreach ($interval as $in){
+ $st = date('H:i:s',strtotime($in['start']));
+// $en = date('H:i:s',strtotime('-1 seconds',strtotime($in['end'])));
+ $en = date('H:i:s',strtotime($in['end']));
+ $check = date('H:i:s',strtotime('23:59:59'));
+ $check1 = date('H:i:s',strtotime('00:00:00'));
+ if ($i<=7 && $time>=$st && $time<$en && $time!=$check1){
+ $kk['Elect'] = $in['univalence'];
+ $kk['Serve'] = $SPrice;
+ break;
+ }elseif($i==7 && ($time>=$st || $time<=$check )|| $time==$check1){
+ $kk['Elect'] = $in['univalence'];
+ $kk['Serve'] = $SPrice;
+ break;
+ }
+ $i+=1;
+ }
+ }else{
+ $SPrice = $interval['SPrice'];
+ $EPrice = $interval['EPrice'];
+ $kk['Elect'] = $EPrice;
+ $kk['Serve'] = $SPrice;
+
+ }
+ $kk['total'] = number_format($kk['Elect'] + $kk['Serve'],6);
+ $address = Db::table('charge_station')->where("charge_station_number",$station_number)->value("address");
+ $station_name = Db::table('charge_station')->where("charge_station_number",$station_number)->value("charge_station_name");
+ $kk['address'] = $address;
+ $kk['station_name'] = $station_name;
+ $Type = Db::table('charge_station')->where('charge_station_id',$station_id)->value('station_type');
+ if ((int)$Type == 0){
+ $kk['type'] = '快充';
+ }elseif((int)$Type == 1){
+ $kk['type'] = '慢充';
+ }
+ $lat1 = $lat;
+ $lng1 = $lng;
+ $lat2 = Db::table('charge_station')->where('charge_station_id',$station_id)->value('latitude');
+ $lng2 = Db::table('charge_station')->where('charge_station_id',$station_id)->value('longitude');
+ $distance = $this->getDistance($lat1, $lng1, $lat2, $lng2);
+ $kk['distance'] = $distance;
+ return json($kk);
+ }
+
+ public function GetLastStation($lat,$lng){
+ $lat1 = $lat;
+ $lng1 = $lng;
+ $list = Db::table('charge_station')->select();
+ $mess = array();
+ foreach ($list as $l){
+ $charge_station_id = $l['charge_station_id'];
+ $lat2 = $l['latitude'];
+ $lng2 = $l['longitude'];
+ $distance = $this->getDistance($lat1, $lng1, $lat2, $lng2);
+ $mess[$charge_station_id] = $distance;
+ }
+ asort($mess);
+ $kk = array();
+ foreach ($mess as $key=>$value){
+ $station_id = $key;
+ $distance =$value;
+ $station_number = Db::table('charge_station')->where('charge_station_id',$station_id)->value('charge_station_number');
+ $s_latitude = Db::table('charge_station')->where('charge_station_id',$station_id)->value('latitude');
+ $s_longitude = Db::table('charge_station')->where('charge_station_id',$station_id)->value('longitude');
+ $kk['station_number'] = $station_number;
+ $kk['distance'] = $distance;
+ $kk['s_latitude'] = $s_latitude;
+ $kk['s_longitude'] = $s_longitude;
+ break;
+ }
+ return json($kk);
+ }
+
+ private function getDistance($lat1, $lng1, $lat2, $lng2): float
+ {
+ $earthRadius = 6367000;
+ $lat1 = ($lat1 * pi() ) / 180;
+ $lng1 = ($lng1 * pi() ) / 180;
+ $lat2 = ($lat2 * pi() ) / 180;
+ $lng2 = ($lng2 * pi() ) / 180;
+ $calcLongitude = $lng2 - $lng1;
+ $calcLatitude = $lat2 - $lat1;
+ $stepOne = pow(sin($calcLatitude / 2), 2) + cos($lat1) * cos($lat2) * pow(sin($calcLongitude / 2), 2);
+ $stepTwo = 2 * asin(min(1, sqrt($stepOne)));
+ $calculatedDistance = $earthRadius * $stepTwo;
+ return round($calculatedDistance/1000,2);
+ }
+}
\ No newline at end of file
diff --git a/app/controller/Order/ChargeOrder.php b/app/controller/Order/ChargeOrder.php
new file mode 100644
index 0000000..4c5f2a8
--- /dev/null
+++ b/app/controller/Order/ChargeOrder.php
@@ -0,0 +1,81 @@
+param();
+ $page = $params['page'] ?? 1;
+ $pageSize = $params['pageSize'] ?? 10;
+ $where = [];
+ if(isset($params['phone']) && !empty($params['phone'])){
+ $where[] = ['u.phone','=',$params['phone']];
+ }
+ $list = Db::table('zxc_charge_order o')
+ ->leftJoin('zxc_user u', 'o.openid = u.openid')
+ ->leftJoin('charge_station s', 's.charge_station_id = o.charge_station_id')
+ ->field('o.*, u.phone,s.charge_station_name')
+ ->where($where)
+ ->order('o.order_id desc')
+ ->paginate([
+ 'list_rows' => $pageSize,
+ 'page' => $page,
+ 'query' =>$params
+ ]);
+ $list->each(function($item, $key) {
+ $item['type_text'] = $item['type'] == 1 ? '即充即退' : '个人钱包';
+ return $item;
+ });
+ return json($list);
+ }
+
+ public function recharge_order(Request $request){
+ $params = $request->param();
+ $page = $params['page'] ?? 1;
+ $pageSize = $params['pageSize'] ?? 10;
+ $where = [];
+ $list = Db::table('zxc_recharge o')
+ ->leftJoin('zxc_user u', 'o.openid = u.openid')
+ ->field('o.*, u.phone')
+ ->order('o.id desc')
+ ->paginate([
+ 'list_rows' => $pageSize,
+ 'page' => $page,
+ 'query' =>$params
+ ]);
+ $list->each(function($item, $key) {
+ $item['trade_state'] = '成功';
+ return $item;
+ });
+ return json($list);
+ }
+
+ public function refund_order(Request $request){
+ $params = $request->param();
+ $page = $params['page'] ?? 1;
+ $pageSize = $params['pageSize'] ?? 10;
+ $where = [];
+ $list = Db::table('zxc_refund o')
+ ->leftJoin('zxc_user u', 'o.openid = u.openid')
+ ->field('o.*, u.phone')
+ ->order('o.id desc')
+ ->paginate([
+ 'list_rows' => $pageSize,
+ 'page' => $page,
+ 'query' =>$params
+ ]);
+ $list->each(function($item, $key) {
+ $item['status'] = '成功';
+ $item['refund_total'] = $item['refund_total']/100;
+ return $item;
+ });
+ return json($list);
+ }
+
+}
\ No newline at end of file
diff --git a/app/controller/Order/CountExcel.php b/app/controller/Order/CountExcel.php
new file mode 100644
index 0000000..b0fd45a
--- /dev/null
+++ b/app/controller/Order/CountExcel.php
@@ -0,0 +1,104 @@
+getDateFromRange($start_time,$end_time);
+ $RechargeAmountTotal = 0;
+ $RefundAmountTotal = 0;
+ $RechargeNumTotal = 0;
+ $RefundNumTotal = 0;
+ $OrderAmountTotal = 0;
+ $OrderNumTotal = 0;
+ $ServiceAmountTotal = 0;
+ $mess =array();
+ foreach ($date as $d){
+ $area = Db::table('area_three')->column('area');
+ $RechargeAmount = 0;
+ $RefundAmount = 0;
+ $RechargeNum = 0;
+ $RefundNum = 0;
+ $OrderAmount = 0;
+ $OrderNum = 0;
+ $ServiceAmount = 0;
+ $degree_pri = 0;
+ foreach ($area as $a){
+ $s = $this->GetArea($a);
+ $table_refund = 'refund_'.$s;
+ $table_order = 'charge_order_'.$s;
+ $table_recharge = 'recharge_'.$s;
+ $recharge = Db::table($table_recharge);
+ $RechargeAmount += $recharge->whereDay('success_time',$d)->sum('total');
+ $RechargeNum += $recharge->whereDay('success_time',$d)->count();
+ $order = Db::table($table_order);
+ $OrderAmount += $order->whereDay('charge_date',$d)->sum('TotalMoney');
+ $OrderNum += $order->whereDay('charge_date',$d)->count();
+ $refund = Db::table($table_refund);
+ $RefundAmount += $refund->whereDay('create_time',$d)->sum('refund_total');
+ $RefundNum += $refund->whereDay('create_time',$d)->count();
+ if (strtotime($d)whereDay('charge_date',$d)->sum('TotalPower');
+ $ServiceAmount += round($degree_pri*0.2,2);
+ }else{
+ $ServiceAmount += $order->whereDay('charge_date',$d)->sum('SeviceMoney');
+ }
+ }
+ $kk['RechargeAmount'] = round($RechargeAmount/100,2);
+ $kk['RechargeNum'] = $RechargeNum;
+ $kk['OrderAmount'] = round($OrderAmount,2);
+ $kk['OrderNum'] = $OrderNum;
+ $kk['RefundAmount'] = round($RefundAmount/100,2);
+ $kk['RefundNum'] = $RefundNum;
+ $kk['ServiceAmount'] = round($ServiceAmount,2);
+ $kk['Time'] = $d;
+ $mess['per'][] = $kk;
+ //['time'=>$d,'data' => $kk];
+ $RechargeAmountTotal += $RechargeAmount;
+ $RefundAmountTotal += $RefundAmount;
+ $RechargeNumTotal += $RechargeNum;
+ $RefundNumTotal += $RefundNum;
+ $OrderAmountTotal += $OrderAmount;
+ $OrderNumTotal += $OrderNum;
+ $ServiceAmountTotal += $ServiceAmount;
+ }
+ $ss['RechargeAmountTotal']=round($RechargeAmountTotal/100,2);
+ $ss['RefundAmountTotal']=round($RefundAmountTotal/100,2);
+ $ss['RechargeNumTotal']=$RechargeNumTotal;
+ $ss['RefundNumTotal']=$RefundNumTotal;
+ $ss['OrderAmountTotal']=round($OrderAmountTotal,2);
+ $ss['OrderNumTotal']=$OrderNumTotal;
+ $ss['ServiceAmountTotal'] = round($ServiceAmountTotal,2);
+ $mess['total'] = [$ss];
+ return json($mess);
+ }
+
+ private function GetArea($area){
+ $pinyin = new Pinyin();
+ $s = $pinyin->sentence($area);
+ $s = strtr($s,array(' '=>''));
+ return $s;
+ }
+
+ private function getDateFromRange($startdate, $enddate): array
+ {
+
+ $stimestamp = strtotime($startdate);
+ $etimestamp = strtotime($enddate);
+ // 计算日期段内有多少天
+ $days = ($etimestamp-$stimestamp)/86400;
+ // 保存每天日期
+ $date = array();
+ for($i=0; $i<$days; $i++){
+
+ $date[] = date('Y-m-d', $stimestamp+(86400*$i));
+ }
+
+ return $date;
+ }
+}
\ No newline at end of file
diff --git a/app/controller/Order/RechargeRecord.php b/app/controller/Order/RechargeRecord.php
new file mode 100644
index 0000000..8caf928
--- /dev/null
+++ b/app/controller/Order/RechargeRecord.php
@@ -0,0 +1,27 @@
+where('openid',$openid)->value('area');
+ $pinyin = new Pinyin();
+ $s = $pinyin->sentence($area);
+ $s = strtr($s,array(' '=>''));
+ $table = 'recharge_'.$s;
+ $list = Db::table($table)->where('openid',$openid)->order('id desc')->select()->toArray();
+ $i = 0;
+ foreach ($list as $l){
+ $list[$i]['total'] /= 100;
+ $list[$i]['payer_total']/= 100;
+ $i+=1;
+ }
+ return json($list);
+ }
+
+
+}
\ No newline at end of file
diff --git a/app/controller/Order/RefundRecord.php b/app/controller/Order/RefundRecord.php
new file mode 100644
index 0000000..ad464bb
--- /dev/null
+++ b/app/controller/Order/RefundRecord.php
@@ -0,0 +1,31 @@
+where('openid',$openid)->value('area');
+ $pinyin = new Pinyin();
+ $s = $pinyin->sentence($area);
+ $s = strtr($s,array(' '=>''));
+ $table_refund = 'refund_'.$s;
+ $message = Db::table($table_refund)->where('openid',$openid)->order('create_time desc')->select()->toArray();
+ for($i=0;$iconnect('127.0.0.1', 6379);
+ }
+
+ public function AdmenAmont(): \think\response\Json
+ {
+ $list = Db::table("charge_order_longshuizhen")->whereBetweenTime("start_time", "2023-06-01", "2023-07-01")->select()->toArray();
+// return json($list);
+ $jj = [];
+ foreach ($list as $l) {
+ if (round($l['SeviceMoney'] + $l['ElecMoney'], 2) != round($l["TotalMoney"], 2)) {
+ $jj[] = $l['StartChargeSeq'];
+ }
+ }
+// foreach ($jj as $j) {
+// $order = new ChargeOrder();
+// $order->AmendmentAccount('charge_order_longshuizhen', $j);
+// }
+ $list = Db::table("charge_order_longshuizhen")->whereBetweenTime("start_time", "2023-06-01", "2023-07-01")->select()->toArray();
+ return json($jj);
+ }
+
+}
\ No newline at end of file
diff --git a/app/controller/Push.php b/app/controller/Push.php
new file mode 100644
index 0000000..56d55a3
--- /dev/null
+++ b/app/controller/Push.php
@@ -0,0 +1,73 @@
+whereOr([$map1, $map2])->order('charge_pile_id desc')->count('charge_pile_id');
+
+ if ($hasfault) {
+ $case1 = [
+ ['charge_pile.status', '=',255],
+ ['is_pushed','=',1],
+ ];
+ $case2 = [
+ ['charge_pile.status', '=',0],
+ ['is_pushed','=',1],
+ ];
+ $faultInfo = Db::table('charge_pile,charge_station')
+ ->whereOr([$case1, $case2])
+ ->where('charge_pile.charge_station_id = charge_station.charge_station_id')
+ ->order('charge_pile_id desc')
+ ->field('charge_station.charge_station_id,charge_station_name,charge_pile.charge_pile_number,charge_station.area,charge_station.street,charge_pile.status,charge_pile.no')
+ ->find();
+ $faultInfo['code'] = 1;
+ foreach ($worker->connections as $connection) {
+ if (empty($connection->lastMessageTime)) {
+ $connection->lastMessageTime = $time_now;
+ }
+
+ if ($time_now - $connection->lastMessageTime > self::$heartbeat_time) {
+ $connection->close();
+ }
+
+ $connection->send(json_encode($faultInfo));
+ }
+ Db::table('charge_pile')->where('charge_pile_number',$faultInfo['charge_pile_number'])->save(['is_pushed'=>2]);
+ } else {
+ foreach ($worker->connections as $connection) {
+ if (empty($connection->lastMessageTime)) {
+ $connection->lastMessageTime = $time_now;
+ continue;
+ }
+ if ($time_now - $connection->lastMessageTime > self::$heartbeat_time) { //连接超时
+ $connection->close();
+ }
+ $connection->send(json_encode(['code'=>0,'msg'=>'暂时没有信息']));
+ }
+
+ }
+ });
+ }
+}
diff --git a/app/controller/Refund.php b/app/controller/Refund.php
new file mode 100644
index 0000000..6b4e288
--- /dev/null
+++ b/app/controller/Refund.php
@@ -0,0 +1,55 @@
+=',$start_time];
+ }
+ if ($end_time) {
+ $where[] = ['success_time','<=',$end_time];
+ }
+
+ if ($out_trade_no) {
+ $where[] = ['out_trade_no','like','%'.$end_time.'%'];
+ }
+
+
+ $list = Db::table('zxc_recharge')->where($where)->order('id desc')->select(); // 获取全部数据
+
+
+
+
+ foreach ($list as $key => &$value) {
+
+ $value['total'] = round($value['total'] / 100, 2);
+ $value['payer_total'] = round($value['payer_total'] / 100, 2);
+
+
+ $table = 'zxc_user';
+ $phone = Db::table($table)->where('openid', $value['openid'])->value('phone');
+ $value['phone'] = $phone;
+
+ }
+
+ return json($list);
+
+ }
+}
\ No newline at end of file
diff --git a/app/controller/TeldTest.php b/app/controller/TeldTest.php
new file mode 100644
index 0000000..400f1bd
--- /dev/null
+++ b/app/controller/TeldTest.php
@@ -0,0 +1,372 @@
+OperatorID;
+ $OperatorSecret = $this->OperatorSecret;
+ $time = date('YmdHis');
+ $Seq = $this->Seq;
+ $mess = array('OperatorID' => $OperatorID, 'OperatorSecret' => $OperatorSecret);
+ $data = json_encode($mess);
+
+
+ $en_data = $this->encrypt($data);
+
+ $de_Sig = $OperatorID . $en_data . $time . $Seq;
+
+ $Sig = $this->HMAC($de_Sig, $this->DataSecret);
+ $kk['OperatorID'] = $OperatorID;
+ $kk['Data'] = $en_data;
+ $kk['TimeStamp'] = $time;
+ $kk['Seq'] = $Seq;
+ $kk['Sig'] = $Sig;
+
+
+ $datas = $this->CurlSend_Token($this->url . '/query_token', $kk);
+
+ $array_data = (array)$datas;
+ if ($array_data['Ret'] == 0) {
+ $token = $array_data['Data'];
+ $de_data = $this->decrypt($token);
+ $arr_token = json_decode($de_data);
+ $array_token = (array)$arr_token;
+ $token = $array_token['AccessToken'];
+ Cache::set('token', $token, 7200);
+ return $token;
+ } else {
+ return 1;
+ }
+ }
+
+
+ //设备认证
+ public function queryEquipAuth()
+ {
+ Cache::delete('token');
+ $token = Cache::get('token');
+ if (!$token) {
+ $token = $this->getToken();
+ }
+ $datetime = date('YmdHis');
+ $kk['EquipAuthSeq'] = $this->EquipAuthSeq;
+ $kk['ConnectorID'] = $this->connectorID;
+ $en = $this->encrypt(json_encode($kk));
+ $sig = $this->OperatorID . $en . $datetime . $this->Seq;
+ $s = $this->HMAC($sig, $this->DataSecret);
+ $rr['OperatorID'] = $this->OperatorID;
+ $rr['Data'] = $en;
+ $rr['TimeStamp'] = $datetime;
+ $rr['Seq'] = $this->Seq;
+ $rr['Sig'] = $s;
+ $data = $rr;
+ $message = $this->CurlSend_Token($this->url . '/query_equip_auth', $data, $token);
+
+ $en_mess = $message['Data'];
+ $de_data = $this->decrypt($en_mess);
+
+ $arr = json_decode($de_data, true);
+
+// Array
+// (
+// [FailReason] => 0
+// [SuccStat] => 0
+// [EquipAuthSeq] => 3702121094205
+// [ConnectorID] => 3702121094105
+// )
+ return $arr;
+ }
+
+
+ //开始充电
+ public function queryStartCharge()
+ {
+ $token = Cache::get('token');
+ if (!$token) {
+ $token = $this->getToken();
+ }
+ $datetime = date('YmdHis');
+ $kk['StartChargeSeq'] = 'MACFHBM3X175705873925064035';
+ $kk['ConnectorID'] = $this->connectorID;
+ $kk['QRCode'] = 'QRCode';
+ $kk['PhoneNum'] = ''; //13698689669 个人支付必传,格式确保正确
+ $kk['PlateNum'] = '';// 车牌号
+ $en = $this->encrypt(json_encode($kk));
+
+
+ $sig = $this->OperatorID . $en . $datetime . $this->Seq;
+ $s = $this->HMAC($sig, $this->DataSecret);
+ $rr['OperatorID'] = $this->OperatorID;
+ $rr['Data'] = $en;
+ $rr['TimeStamp'] = $datetime;
+ $rr['Seq'] = $this->Seq;
+ $rr['Sig'] = $s;
+
+
+ $message = $this->CurlSend_Token($this->url . '/query_start_charge', $rr, $token);
+
+ $en_mess = $message['Data'];
+ $de_data = $this->decrypt($en_mess);
+ $arr = json_decode($de_data);
+ $array = (array)$arr;
+
+ return $array;
+
+ // Array (
+ // [StartChargeSeq] => MACFHBM3X175705873925064035
+ // [SuccStat] => 1
+ // [FailReason] => 18
+ // [StartChargeSeqStat] => 5
+ // [ConnectorID] => 3702121094105
+ // )
+ }
+
+//充电状态
+ public function queryEquipChargeStatus()
+ {
+ $token = Cache::get('token');
+ if (!$token) {
+ $token = $this->getToken();
+ }
+ $datetime = date('YmdHis');
+ $kk['StartChargeSeq'] = 'MACFHBM3X175705873925064035';
+
+ $en = $this->encrypt(json_encode($kk));
+ $sig = $this->OperatorID . $en . $datetime . $this->Seq;
+
+ $s = $this->HMAC($sig, $this->DataSecret);
+
+ $rr['OperatorID'] = $this->OperatorID;
+ $rr['Data'] = $en;
+ $rr['TimeStamp'] = $datetime;
+ $rr['Seq'] = $this->Seq;
+ $rr['Sig'] = $s;
+ $data = $rr;
+ $message = $this->CurlSend_Token($this->url . '/query_equip_charge_status ', $data, $token);
+
+ $en_mess = $message['Data'];
+ $de_data = $this->decrypt($en_mess);
+ $arr = json_decode($de_data);
+ $array = (array)$arr;
+ halt($array);
+ if (isset($array['TotalMoney'])) {
+ $area = \app\model\ChargeOrder::where('StartChargeSeq', $StartChargeSeq)->value('area');
+ $pinyin = new Pinyin();
+ $s = $pinyin->sentence($area);
+ $s = strtr($s, array(' ' => ''));
+ $table = 'charge_order_' . $s;
+ $table_user = 'user_' . $s;
+ $ll = array_diff_key($array, ["ChargeDetails" => 'xy', 'StartTime' => 'xy', "StartChargeSeq" => 'xy', 'ConnectorID' => 'xy', 'TotalMoney' => 'xy']);
+ $station_id = Db::table($table)->where('StartChargeSeq', $StartChargeSeq)->value('charge_station_id');
+ $station_type = \app\model\ChargeStation::where('charge_station_id', $station_id)->value('station_type');
+ $openid = Db::table($table)->where('StartChargeSeq', $StartChargeSeq)->value('openid');
+ $detail_message = '';
+ if ((int)$station_type == 0) {
+ $ii = 1;
+ $total = 0;
+ $ElectMoney = 0;
+ $SeviceMoney = 0;
+ foreach ($array['ChargeDetails'] as $Details) {
+ $Details = (array)$Details;
+ $per_price = $this->Rank($station_id, $Details['DetailStartTime'], $Details['DetailEndTime'], $openid, $table_user)['Elect'];
+ $S_price = $this->Rank($station_id, $Details['DetailStartTime'], $Details['DetailEndTime'], $openid, $table_user)['Serve'];
+ $period_price = round($Details['DetailPower'] * $per_price, 2);
+ $service_price = round($Details['DetailPower'] * $S_price, 2);
+ $total_money = $period_price + $service_price;
+ $detail_message .= '时段' . $ii .
+ ':开始时间:' . $Details['DetailStartTime'] . ',' .
+ '结束时间:' . $Details['DetailEndTime'] . ',' .
+ '所用度数:' . $Details['DetailPower'] . ',' .
+ '时段电费单价:' . $per_price . ',' .
+ '时段电费金额:' . $period_price . ',' .
+ '时段服务费单价:' . $S_price . ',' .
+ '时段服务费金额:' . $service_price . ',' .
+ '时段总价:' . $total_money . ';';
+ $ii += 1;
+ $total += $total_money;
+ $ElectMoney += $period_price;
+ $SeviceMoney += $service_price;
+ }
+ } else {
+ $price = $this->GetPrice($station_id, $openid, $table_user);
+ $total = $ll['TotalPower'] * $price['EPrice'] + ($ll['TotalPower'] * $price['SPrice']);
+ $ElectMoney = $array['TotalPower'] * $price['EPrice'];
+ $SeviceMoney = $array['TotalPower'] * $price['SPrice'];
+ }
+ $ll['TotalMoney'] = round($total, 2);
+ $ll['ElecMoney'] = round($ElectMoney, 2);
+ $ll['SeviceMoney'] = round($SeviceMoney, 2);
+ $WithholdingMoney = Db::table($table)->where('StartChargeSeq', $StartChargeSeq)->value('WithholdingMoney');
+ $order_num = Db::table($table)->where('StartChargeSeq', $StartChargeSeq)->value('order_number');
+ if ((float)$WithholdingMoney - (float)$ll['TotalMoney'] <= 3) {
+ $order = new ChargeOrder();
+ $order->EndOrder($openid, $order_num);
+ }
+ $ll['status'] = $ll['StartChargeSeqStat'];
+ $end_time = Db::table($table)->where('order_number', $order_num)->value('end_time');
+ $status = Db::table($table)->where('order_number', $order_num)->value('status');
+ if (empty($end_time) && $status != 4) {
+ Db::table($table)->where('StartChargeSeq', $StartChargeSeq)->save($ll);
+ }
+ return ['code' => 200];
+ } else {
+ return ['code' => 1];
+ }
+ }
+
+
+//停止充电
+ public function queryStopCharge()
+ {
+
+ $token = Cache::get('token');
+ if (!$token) {
+ $token = $this->getToken();
+ }
+ $datetime = date('YmdHis');
+ $kk['StartChargeSeq'] = 'MACFHBM3X175705873925064035';
+ $kk['ConnectorID'] = $this->connectorID;
+
+
+ $en = $this->encrypt(json_encode($kk));
+ $sig = $this->connectorID . $en . $datetime . $this->Seq;
+
+
+ $s = $this->HMAC($sig, $this->DataSecret);
+
+ $rr['OperatorID'] = $this->connectorID;
+ $rr['Data'] = $en;
+ $rr['TimeStamp'] = $datetime;
+ $rr['Seq'] = $this->Seq;
+ $rr['Sig'] = $s;
+
+ $data = $rr;
+ $message = $this->CurlSend_Token($this->url . '/query_stop_charge', $data, $token);
+
+ halt($message);
+ $en_mess = $message['Data'];
+ $de_data = $this->decrypt($en_mess);
+ $arr = json_decode($de_data);
+ $array = (array)$arr;
+ return $array;
+ }
+
+
+ public function index()
+ {
+
+ return print_r($this->queryStopCharge());
+
+ }
+
+
+ function CurlSend_Token($url, $data = '', $token = '')
+ {
+ $data = json_encode($data);
+ $ch = curl_init();
+ $headers = array();
+ if ($token) {
+ $headers[] = 'Authorization: Bearer ' . $token;
+ }
+ $headers[] = 'Content-Type: application/json;charset=utf-8';
+ $headers[] = 'Content-Length: ' . strlen($data);
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 对认证证书来源的检查
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在
+ curl_setopt($ch, CURLOPT_HEADER, 0);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+ curl_setopt($ch, CURLOPT_POST, 1);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+ $curl_return = curl_exec($ch);
+ curl_close($ch);
+ return json_decode(trim($curl_return), true);
+ }
+
+ public function HMAC($data, $key)
+ {
+ $key = $this->strToUtf8($key);
+ $data = $this->strToUtf8($data);
+
+ $b = 64; // byte length for md5
+ if (strlen($key) > $b) {
+ $key = pack("H32", md5($key));
+ }
+ $key = str_pad($key, $b, chr(0x00));
+ $ipad = str_pad('', $b, chr(0x36));
+ $opad = str_pad('', $b, chr(0x5c));
+ $k_ipad = $key ^ $ipad;
+ $k_opad = $key ^ $opad;
+
+ return strtoupper(md5($k_opad . pack("H32", md5($k_ipad . $data))));
+ }
+
+ function strToUtf8($str)
+ {
+ $encode = mb_detect_encoding($str, array("ASCII", 'UTF-8', "GB2312", "GBK", 'BIG5'));
+ if ($encode == 'UTF-8') {
+ return $str;
+ } else {
+ return mb_convert_encoding($str, 'UTF-8', $encode);
+ }
+ }
+
+ public function encrypt($input)
+ {
+ return base64_encode(openssl_encrypt($input, 'AES-128-CBC', $this->key, OPENSSL_RAW_DATA, $this->iv));
+ }
+
+ public function decrypt($input)
+ {
+ return openssl_decrypt(base64_decode($input), 'AES-128-CBC', $this->key, OPENSSL_RAW_DATA, $this->iv);
+ }
+}
\ No newline at end of file
diff --git a/app/controller/Test.php b/app/controller/Test.php
new file mode 100644
index 0000000..5822c01
--- /dev/null
+++ b/app/controller/Test.php
@@ -0,0 +1,390 @@
+ "LA9LC30F0NCLA6198", "connectorID" => "5001110048204", "StartSc" => 44];
+ if (isset($data['vin']) && isset($data['connectorID'])) {
+// $this->PlugGennerateOrder($data['ConnectorID'], $data['Vin']);
+ $AppointmentTime = Db::table('appointment_time')->where('id', 1)->value('AppointmentTime');
+ $currentDate = new DateTime();
+ $combinedDateTime = new DateTime($currentDate->format('Y-m-d') . ' ' . $AppointmentTime);
+ $AppointmentTime = $combinedDateTime->format('Y-m-d H:i:s');
+ $nowTime = $currentDate->format('Y-m-d H:i:s');
+ $nowDay = $currentDate->format('Y-m-d');
+ $check = Db::table('appointment')->whereDay('action_time', $nowDay)->where('Vin', $data['vin'])->find();
+ if (empty($check)) {
+ Db::table('appointment')->save(['action_time' => $nowTime, 'ConnectorID' => $data['connectorID'], 'Vin' => $data['vin'], 'plug_time' => $AppointmentTime]);
+ } else {
+ $checkVin = Db::table('appointment')->where('Vin', $data['vin'])->value('ConnectorID');
+ if ($checkVin != $data['connectorID']) {
+ Db::table('appointment')->where('Vin', $data['vin'])->save(['action_time' => $nowTime, 'ConnectorID' => $data['connectorID']]);
+ }
+ }
+ $kk['SuccStat'] = 0;
+ $kk['FailReason'] = 0;
+ }
+ $data = json_encode($data);
+ $h = new PlugCharge();
+ $st = $h->signToken();
+ $data = $h->Encrypt($data);
+ return json($st);
+
+ }
+
+ public function GetPriceTest($station_id, $openid, $table)
+ {
+ $station_type = \app\model\ChargeStation::where('charge_station_id', $station_id)->value('station_type');
+ $ElectricityFee = Db::table('charge_station')->where('charge_station_id', $station_id)->value('ElectricityFee');
+ $type = Db::table($table)->where('openid', $openid)->value('type');
+ if ($type != 3) {
+ $ServiceFee = ServiceFee::where('type', $type)->where('station_type', $station_type)->value('service_fee');
+ } else {
+ $group_id = EnterpriseUser::where('openid', $openid)->value('group_id');
+ $ServiceFee = ServiceFee::where('type', $type)->where('station_type', $station_type)->where('group_id', $group_id)->value('service_fee');
+ }
+// $ServiceFee= Db::table('charge_station')->where('charge_station_id',$station_id)->value('ServiceFee');
+ $ElectricityFee = str_replace('电费:', '', $ElectricityFee);
+ $Elect = explode(',', $ElectricityFee);
+
+ for ($index = 0; $index < count($Elect); $index++) {
+ $kk['time_interval'] = substr($Elect[$index], 0, 11);
+ $tt = explode('~', $kk['time_interval']);
+ $start = $tt[0] . ':00';
+ $end = $tt[1] . ':00';
+
+ $kk['univalence'] = explode(':', $Elect[$index])[3];
+ $kk['start'] = $start;
+ $kk['end'] = $end;
+ $ss[] = $kk;
+ }
+ $ServiceFee = str_replace('服务费:', '', $ServiceFee);
+ $Server = explode(',', $ServiceFee);
+ $wk_day = date('w');
+ $now_time = time();
+ $start_time = '2023-03-18 00:00:00';
+ $start_time = strtotime($start_time);
+ $wkday_ar = array('日', '一', '二', '三', '四', '五', '六');
+ for ($index = 0; $index < count($Server); $index++) {
+ $ll['time_interval'] = substr($Server[$index], 0, -5);
+ // if ($wkday_ar[$wk_day] == '三' && $now_time > $start_time && $type == 1) {
+ // $ll['univalence'] = number_format((float)(substr($Server[$index], Strlen($Server[$index]) - 4) - 0.20), 2);
+ // } else {
+ $ll['univalence'] = substr($Server[$index], Strlen($Server[$index]) - 4);
+ // }
+ $mm[] = $ll;
+ }
+ if ($station_type == 1) {
+ return json(['EPrice' => number_format((float)($ss[0]['univalence']), 6), 'SPrice' => number_format((float)($mm[0]['univalence']), 2)]);
+ } elseif ($station_type == 0) {
+ return json(['message' => $ss, 'SPrice' => number_format((float)($mm[0]['univalence']), 2)]);
+
+ }
+ }
+
+ public function tsesg1()
+ {
+ $currentDate = new DateTime();
+ $todayDate = $currentDate->format('Y-m-d H:i:s');
+ $nowDay = $currentDate->format('Y-m-d');
+ $PlugOrder = Db::table('appointment')->select();
+ foreach ($PlugOrder as $order) {
+ $status = Db::table('charge_pile')->where('ConnectorID', $order['ConnectorID'])->value('status');
+ echo $status;
+ }
+
+ }
+
+ public function index()
+ {
+ $map1 = [
+ ['status', '=', 255],
+ ['is_pushed', '=', 1],
+ ];
+
+ $map2 = [
+ ['status', '=', 0],
+ ['is_pushed', '=', 1],
+ ];
+ $hasfault = Db::table('charge_pile')->whereOr([$map1, $map2])->order('charge_pile_id desc')->select();
+
+ $case1 = [
+ ['charge_pile.status', '=', 255],
+ ['is_pushed', '=', 1],
+ ];
+ $case2 = [
+ ['charge_pile.status', '=', 0],
+ ['is_pushed', '=', 1],
+ ];
+ $faultInfo = Db::table('charge_pile,charge_station')
+ ->whereOr([$case1, $case2])
+ ->where('charge_pile.charge_station_id = charge_station.charge_station_id')
+ ->order('charge_pile_id desc')
+ ->field('charge_station.charge_station_id,charge_station_name,charge_pile.charge_pile_number,charge_station.area,charge_station.street,charge_pile.status,charge_pile.no')
+ ->find();
+ return json($faultInfo);
+
+ }
+
+ /**
+ * 显示创建资源表单页.
+ *
+ * @return \think\Response
+ */
+ public function create()
+ {
+ $faultInfo = Db::table('charge_pile,charge_station')
+ ->where('charge_pile.status', 3)
+ ->where('charge_pile.is_pushed', 1)
+ ->where('charge_pile.charge_station_id = charge_station.charge_station_id')
+ ->order('charge_pile_id desc')
+ ->field('charge_station.charge_station_id,charge_station_name,charge_pile.charge_pile_number,charge_station.area,charge_station.street,charge_pile.status,charge_pile.is_pushed')
+ ->find();
+ return json($faultInfo);
+ }
+
+ /**
+ * 保存新建的资源
+ *
+ * @param \think\Request $request
+ * @return \think\Response
+ */
+ public function save()
+ {
+ $openid_array = Db::table('zxc_user')->column('openid');
+ foreach ($openid_array as $openid) {
+ $table_user = 'zxc_user';
+ $table_order = 'zxc_charge_order';
+ $table_recharge = 'zxc_recharge';
+ $account = Db::table($table_user)->where('openid', $openid)->value('account');
+ $recharge_all = Db::table($table_recharge)->where('openid', $openid)->sum('total');
+ $recharge_all /= 100;
+ $check = Db::table($table_order)->where('openid', $openid)->where('status', 2)->order('start_time desc')->value('end_time');
+ if (empty($check)) {
+ $order_all = Db::table($table_order)->where('openid', $openid)->where('status', 4)->sum('TotalMoney');
+ $inorder = Db::table($table_order)->where('openid', $openid)->where('status', '<>', 4)->where('status', '<>', 5)->order('start_time desc')->value('WithholdingMoney');
+ $order_total = $order_all + $inorder;
+ } else {
+ $order_total = Db::table($table_order)->where('openid', $openid)->where('status', 4)->sum('TotalMoney');
+ }
+ $order_total = round($order_total, 2);
+ $mask = round($recharge_all - $order_total, 2); //这里还要减已经提现的
+ if (round($mask, 2) == round($account, 2)) {
+ continue;
+ } else {
+ $ss['order_total'] = $order_total;
+ $ss['openid'] = $openid;
+ $ss['recharge_all'] = $recharge_all;
+ $ss['mask'] = $mask;
+ $ss['account'] = $account;
+ }
+ $ll[] = $ss;
+ }
+ return json($ll);
+ }
+
+
+ public function FindOneUser($openid)
+ {
+
+ $table_user = 'zxc_user';
+ $table_order = 'zxc_charge_order';
+ $table_recharge = 'zxc_recharge';
+ $table_refund = 'zxc_refund';
+ $account = Db::table($table_user)->where('openid', $openid)->value('account');
+ $recharge_all = Db::table($table_recharge)->where('openid', $openid)->sum('total');
+ $recharge_all /= 100;
+ $check = Db::table($table_order)->where('openid', $openid)->where('status', 2)->order('start_time desc')->value('end_time');
+ if (empty($check)) {
+ $order_all = Db::table($table_order)->where('openid', $openid)->where('status', 4)->sum('TotalMoney');
+ $inorder = Db::table($table_order)->where('openid', $openid)->where('status', '<>', 4)->where('status', '<>', 5)->order('start_time desc')->value('WithholdingMoney');
+ $order_total = $order_all + $inorder;
+ } else {
+ $order_total = Db::table($table_order)->where('openid', $openid)->where('status', 4)->sum('TotalMoney');
+ }
+ $refund_total = Db::table($table_refund)->where('openid', $openid)->sum('refund_total');
+ $refund_total /= 100;
+ $order_total = round($order_total, 2);
+ $mask = round($recharge_all - $order_total - $refund_total, 2); //这里还要减已经提现的
+ if (round($mask, 2) == round($account, 2)) {
+ $ss['status'] = 'ok';
+ } else {
+ $ss['order_total'] = $order_total;
+ $ss['openid'] = $openid;
+ $ss['recharge_all'] = $recharge_all;
+ $ss['mask'] = $mask;
+ $ss['account'] = $account;
+ $ss['refund_total'] = $refund_total;
+ }
+ return json($ss);
+ }
+
+ public function FindAllExUser($area, $time = '2023-05-11')
+ {
+
+ $table_user = 'zxc_user';
+ $table_order = 'zxc_charge_order';
+ $table_recharge = 'zxc_recharge';
+ $table_refund = 'zxc_refund';
+ $openid = Db::table($table_user)->column('openid');
+ $kk = array();
+ foreach ($openid as $o) {
+ $checkdate = Db::table($table_order)->where('start_time', '<', $time)->find();
+ if (empty($checkdate)) {
+ continue;
+ } else {
+
+ $account = Db::table($table_user)->where('openid', $o)->value('account');
+ $recharge_all = Db::table($table_recharge)->where('openid', $o)->sum('total');
+ $recharge_all /= 100;
+ $check = Db::table($table_order)->where('openid', $o)->where('status', 2)->order('start_time desc')->value('end_time');
+ if (empty($check)) {
+ $order_all = Db::table($table_order)->where('openid', $o)->where('status', 4)->sum('TotalMoney');
+ $inorder = Db::table($table_order)->where('openid', $o)->where('status', '<>', 4)->where('status', '<>', 5)->order('start_time desc')->value('WithholdingMoney');
+ $order_total = $order_all + $inorder;
+ } else {
+ $order_total = Db::table($table_order)->where('openid', $o)->where('status', 4)->sum('TotalMoney');
+ }
+ $order_total = round($order_total, 2);
+ $refund_total = Db::table($table_refund)->where('openid', $o)->sum('refund_total');
+ $refund_total /= 100;
+ $refund_total = round($refund_total, 2);
+ $mask = round($recharge_all - $order_total - $refund_total, 2); //这里还要减已经提现的
+ if (round($mask, 2) == round($account, 2)) {
+ $ss['status'] = 'ok';
+ } else {
+ $ss['order_total'] = $order_total;
+ $ss['openid'] = $o;
+ $ss['recharge_all'] = $recharge_all;
+ $ss['refund_total'] = $refund_total;
+ $ss['mask'] = $mask;
+ $ss['account'] = $account;
+ $kk[] = $ss;
+ }
+
+ }
+ }
+ return json($kk);
+ }
+
+
+ public function correction($openid)
+ {
+ $OrderList = new ChargeOrder();
+ $OrderList->OrderList($openid);
+
+ $table_order = 'zxc_charge_order';
+ $order = Db::table($table_order)->where('openid', $openid)->select()->toArray();
+ $i = 0;
+ foreach ($order as $oo) {
+ if (($oo['TotalMoney'] + $oo['FeedbackMoney']) != $oo['WithholdingMoney'] && $oo['status'] == 4) {
+ Db::table($table_order)->where('order_number', $oo['order_number'])->save(['TotalMoney' => round($oo['WithholdingMoney'] - $oo['FeedbackMoney'], 2)]);
+ $ss['order_number'] = $oo['order_number'];
+ $ss['TotalMoney'] = $oo['TotalMoney'];
+ $ss['WithholdingMoney'] = $oo['WithholdingMoney'];
+ $ss['FeedbackMoney'] = $oo['FeedbackMoney'];
+ $new_TotalMoney = Db::table($table_order)->where('order_number', $oo['order_number'])->value('TotalMoney');
+ $ss['NewMoney'] = $new_TotalMoney;
+ $i += 1;
+ } else {
+ continue;
+ }
+
+ $ll[] = $ss;
+ }
+ $ll['update_num'] = $i;
+ return json($ll);
+ }
+
+ /**
+ * 显示指定的资源
+ *
+ * @param int $id
+ * @return \think\Response
+ */
+ public function read($id)
+ {
+ //
+ }
+
+ /**
+ * 显示编辑资源表单页.
+ *
+ * @param int $id
+ * @return \think\Response
+ */
+ public function edit($order_number = 'DZZS1673603040121831')
+ {
+ $message = Db::table('charge_order_longgangjiedao')->where('order_number', $order_number)->find();
+ echo strtotime($message['start_time']);
+ echo strtotime("2023-03-03 15:09:47");
+ }
+
+ /**
+ * 保存更新的资源
+ *
+ * @param \think\Request $request
+ * @param int $id
+ * @return \think\Response
+ */
+ public function update(Request $request, $id)
+ {
+ //
+ }
+
+ /**
+ * 删除指定资源
+ *
+ * @param int $id
+ * @return \think\Response
+ */
+ public function delete($id)
+ {
+ //
+ }
+}
+
+function getDistance($lat1, $lng1, $lat2, $lng2)
+{
+ $earthRadius = 6367000;
+ $lat1 = ($lat1 * pi()) / 180;
+ $lng1 = ($lng1 * pi()) / 180;
+ $lat2 = ($lat2 * pi()) / 180;
+ $lng2 = ($lng2 * pi()) / 180;
+ $calcLongitude = $lng2 - $lng1;
+ $calcLatitude = $lat2 - $lat1;
+ $stepOne = pow(sin($calcLatitude / 2), 2) + cos($lat1) * cos($lat2) * pow(sin($calcLongitude / 2), 2);
+ $stepTwo = 2 * asin(min(1, sqrt($stepOne)));
+ $calculatedDistance = $earthRadius * $stepTwo;
+ return round($calculatedDistance / 1000, 2);
+}
+
+function Encrypt($data)
+{
+ $aes = new Aes();
+ return $aes->encrypt($data);
+}
+
+function HmacMD5($data)
+{
+ $md5 = new HMACMD5();
+ return $md5->HMAC($data);
+}
\ No newline at end of file
diff --git a/app/controller/User.php b/app/controller/User.php
new file mode 100644
index 0000000..d21ab9d
--- /dev/null
+++ b/app/controller/User.php
@@ -0,0 +1,388 @@
+select()->count();
+ $list = Db::table($table)->paginate(20, $count)->toArray();
+ $i = 0;
+ foreach ($list['data'] as $ll) {
+ $list['data'][$i]['account'] = round($list['data'][$i]['account'], 2);
+ $i += 1;
+ }
+ return json($list);
+ }
+
+
+ public function user_all()
+ {
+
+
+ $count = Db::table('zxc_user')->select();
+ return json($count);
+ }
+
+
+ public function read($message = '')
+ {
+ $count = Db::table('zxc_user')->select()->count();
+ $list = Db::table('zxc_user')->where('phone|openid', 'like', '%' . $message . '%')->paginate(20, $count);
+
+ return json($list);
+ }
+
+ public function UpdateDiscount($message)
+ {
+ $time = date("Y-m-d H:i:s");
+ Db::table('discount')->where('id', 1)->update(['message' => $message, 'update_time' => $time]);
+ return json(['code' => '更新成功']);
+ }
+
+ public function DiscountInfo()
+ {
+ $message = Db::table('discount')->where('id', 1)->value('message');
+ return json(['code' => '200', 'message' => $message]);
+ }
+
+
+ public function UserEdit($openid, $username, $phone, $sex, $location_area, $address)
+ {
+ $table = 'zxc_user';
+ $data = ['username' => $username,
+ 'phone' => $phone,
+ 'sex' => $sex,
+ 'address' => $address];
+
+ $update = Db::table($table)->where('openid', $openid)->update($data);
+ if ($update != 0) {
+ return json(['code' => 200, 'message' => '更新成功']);
+ } else {
+ return json(['code' => 1, 'message' => '没有更新']);
+ }
+
+ }
+
+ public function UserInfo($openid)
+ {
+
+ $table = 'zxc_user';
+ $info = Db::table($table)->where('openid', $openid)->field('username,sex,phone,address')->find();
+ $location_area = Db::table($table)->where('openid', $openid)->value('location_area');
+ if (!empty($location_area)) {
+ $location_area = explode('-', $location_area);
+ }
+ $info['location_area'] = $location_area;
+ return json(['code' => 200, 'message' => '请求成功', 'data' => $info]);
+ }
+
+
+ public function area()
+ {
+ $area = Db::table('area')->select();
+ return json($area);
+ }
+
+ public function StationPrice(Request $request)
+ {
+ $data = $request->param();
+ $where = [];
+ if (isset($data['station_number']) && !empty($data['station_number'])) {
+ $where['charge_station_number'] = ['=', $data['station_number']];
+ }
+
+
+ $info = Db::table('charge_station')->where($where)->where('charge_station_id', 19)->field('*')->find();
+
+ // if ($info['station_type'] == 0) {
+ $station_type = '快充';
+ // } else {
+ $station_type = '慢充';
+ // }
+ $ElectricityFee = str_replace('电费:', '', $info['ElectricityFee']);
+ $Elect = explode(',', $ElectricityFee);
+ for ($index = 0; $index < count($Elect); $index++) {
+ $kk['time_interval'] = substr($Elect[$index], 0, 11);
+ $kk['univalence'] = explode(':', $Elect[$index])[3];
+ $ss[] = $kk;
+ }
+ $ServiceFee = str_replace('服务费:', '', $info['ServiceFee']);
+ $Server = explode(',', $ServiceFee);
+ for ($index = 0; $index < count($Server); $index++) {
+ $ll['time_interval'] = substr($Server[$index], 0, -5);
+ $ll['univalence'] = substr($Server[$index], Strlen($Server[$index]) - 4);
+ $mm[] = $ll;
+
+ }
+ $info2 = Db::table('charge_station')->select();
+ return json(['code' => 2000, 'Station_Type' => $station_type, 'ElectricityFee' => $ss, 'ServiceFee' => $mm, 'yuan' => $info2]);
+ }
+
+ public function StationPriceUpdate($station_number, $time_interval, $univalence)
+ {
+ $time_interval = preg_replace("/\s| /", "", $time_interval);;
+ $univalence = preg_replace("/\s| /", "", $univalence);;
+ $time_interval = str_replace('[', '', $time_interval);
+ $time_interval = str_replace("'", "", $time_interval);
+ $time_interval = str_replace('"', '', $time_interval);
+ $time_interval = str_replace(']', '', $time_interval);
+ $univalence = str_replace('[', '', $univalence);
+ $univalence = str_replace(']', '', $univalence);
+ $univalence = str_replace("'", "", $univalence);
+ $univalence = str_replace('"', '', $univalence);
+ $time_interval = explode(",", $time_interval);
+ $univalence = explode(",", $univalence);
+ $z = array();
+ $ss = '';
+ $station_type = \app\model\ChargeStation::where('charge_station_number', $station_number)->value('station_type');
+ for ($i = 0; $i < count($time_interval); $i++) {
+ if ($station_type != 1) {
+ $z[$i] = $time_interval[$i] . ':' . number_format((float)($univalence[$i]), 6);
+ if ($i != 7) {
+ $ss .= $z[$i] . ',';
+ } else {
+ $ss .= $z[$i];
+ }
+ } else {
+ $z[$i] = $time_interval[$i] . ':' . number_format((float)$univalence[$i], 6);
+ $ss .= $z[$i];
+ }
+ }
+ $last = '电费:' . $ss;
+ \app\model\ChargeStation::where('charge_station_number', $station_number)->update(['ElectricityFee' => $last]);
+ return json(['code' => 200, 'message' => '修改成功']);
+
+ }
+
+ protected function getLen($num)
+ {
+
+ $pos = strrpos($num, '.');
+ $ext = substr($num, $pos + 1);
+ $len = strlen($ext);
+ return $len;
+ }
+
+ public function WxLogin()
+ {
+ $code = input('code');
+ $res = getWxMessage($code);
+
+ $userInfo = Db::table('zxc_user')->where('openid', $res['openid'])->find();
+
+ $time = date('Y-m-d H:i:s', time());
+ if (!$userInfo) {
+
+ $data = ['openid' => $res['openid'], 'createtime' => $time];
+ $id = Db::table('zxc_user')->insertGetId($data);
+
+ } else {
+ $id = $userInfo['user_id'];
+ }
+ Db::table('zxc_user')->where('user_id', $id)->update(['logintime' => $time]);
+ $token = signToken($id);
+ return json(['code' => 200, 'message' => '登录成功', 'token' => $token, 'openid' => $res['openid']]);
+ }
+
+ public function WxGetArea($openid)
+ {
+ $area_three = Db::table('area_three')->column('area');
+ $new = array_rand($area_three);
+ $area = $area_three[$new];
+ $userinfo = \app\model\User::where('openid', $openid)->value('area');
+ if (empty($userinfo)) {
+ $message = \app\model\User::where('openid', $openid)->value('area');
+ if (empty($message)) {
+ return json(['code' => 1, 'message' => '地区信息无效']);
+ }
+ $table_user = 'zxc_user';
+ $createtime = date('Y-m-d H:i:s', time());
+ $user = Db::table($table_user)->where('openid', $openid)->find();
+ if (empty($user)) {
+ $data = ['openid' => $openid, 'createtime' => $createtime, 'area' => $area];
+ Db::table($table_user)->save($data);
+ return json(['code' => 200, 'message' => '用户地区保存成功']);
+ }
+ return json(['code' => 200, 'message' => '用户地区保存成功']);
+ } else {
+ return json(['code' => 200, 'message' => '用户地区信息已存过']);
+ }
+
+ }
+
+
+ public function checkToken($token)
+ {
+ $key = 'zbcazbc';
+ $key = new Key($key, 'HS256');
+ $status = array("code" => 1);
+// echo $token;
+ try {
+ JWT::$leeway = 60;//当前时间减去60,把时间留点余地
+ $decoded = JWT::decode($token, $key, array('HS256')); //HS256方式,这里要和签发的时候对应
+ $arr = (array)$decoded;
+ $res['code'] = 200;
+ $res['msg'] = 'OK';
+ $res['data'] = $arr['data'];
+ return json($res);
+ } catch (\Firebase\JWT\SignatureInvalidException $e) { //签名不正确
+ $status['msg'] = "签名不正确";
+ return json($status);
+ } catch (\Firebase\JWT\BeforeValidException $e) { // 签名在某个时间点之后才能用
+ $status['msg'] = "token失效";
+ return json($status);
+ } catch (\Firebase\JWT\ExpiredException $e) { // token过期
+ $status['msg'] = "token失效";
+ return json($status);
+ } catch (Exception $e) { //其他错误
+ $status['msg'] = "未知错误";
+ return json($status);
+ }
+ }
+
+ public function UserBalance($openid)
+ {
+
+ $table_user = 'zxc_user';
+
+ $info = Db::table($table_user)->where('openid', $openid)->field('account,phone')->find();
+ $balance = $info['account'];
+ $balance = sprintf("%01.2f", $balance);
+ $FrozenAccount = Db::table($table_user)->where('openid', $openid)->value('FrozenAccount');
+ $FrozenAccount = sprintf("%01.2f", $FrozenAccount);
+ $table = 'zxc_charge_order';
+ $count = Db::table($table)->where('openid', $openid)->field('order_number,start_time,end_time,revenue,status')->count();
+ $enterprise_accout = Db::table('enterprise_user')->where('phone', $info['phone'])->count();
+ return json([
+ 'openid' => $openid,
+ 'balance' => $balance,
+ 'count' => $count,
+ 'FrozenAccount' => $FrozenAccount,
+ 'phone' => $info['phone'],
+ 'enterprise' => $enterprise_accout
+ ]);
+ }
+
+ public function getMoneyLog(){
+ $result = Db::table('zxc_user_money_log')->where('openid',input('openid'))->order('id desc')->select();
+ return json($result);
+
+ }
+
+// 企业相关
+
+ /**
+ * 获取企业信息
+ *
+ */
+ public function getEnterpriseInfo($phone)
+ {
+
+ $enterprise_user = Db::table('enterprise_user')->where('phone', $phone)->find();
+ if ($enterprise_user) {
+ $enterprise = Db::table('enterprise')->where('id', $enterprise_user['enterprise_id'])->find();
+ $enterprise['is_account'] = $enterprise_user['group_id'] == 1 ? false : true;
+ $enterprise['enterprise_user_id'] = $enterprise_user['id'];
+ return json($enterprise);
+ }
+ return json([]);
+
+ }
+
+ // 充值记录
+ public function getEnterpriseReangeLog()
+ {
+ }
+
+ protected function generate_tuikuan($length)
+ {
+ $chars = '0123456789';
+ $time = time();
+ $password = 'DZZS' . $time . 'TK';
+ for ($i = 0; $i < $length; $i++) {
+ $password .= $chars[mt_rand(0, strlen($chars) - 1)];
+ }
+ return $password;
+ }
+
+
+}
+
+function signToken($uid)
+{
+ $key = 'zbcazbc';
+ $token = array(
+ "iss" => $key, //签发者 可以为空
+ "aud" => '', //面象的用户,可以为空
+ "iat" => time(), //签发时间
+ "nbf" => time() + 3, //在什么时候jwt开始生效 (这里表示生成100秒后才生效)
+ "exp" => time() + 1296000, //token 过期时间
+ "data" => [ //记录的userid的信息,这里是自已添加上去的,如果有其它信息,可以再添加数组的键值对
+ 'uid' => $uid,
+ ]
+ );
+// print_r($token);
+// $keyId = "keyId";
+ $jwt = JWT::encode($token, $key, "HS256"); //根据参数生成了 token
+ return $jwt;
+}
+
+function getCurl($url)
+{
+ $headerArray = array("Content-type:application/json;", "Accept:application/json");
+ $ch = curl_init();//初始化CURL
+ curl_setopt($ch, CURLOPT_URL, $url);//设置访问地址
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);//HTTPS访问设置 关闭监视
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);//HTTPS访问设置 关闭监视访问地址
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArray);//设置访问头部信息
+ $output = curl_exec($ch);//获取结果
+ curl_close($ch);//关闭连接
+ $output = json_decode($output, true);//json数据转换
+ return $output;
+}
+
+function getWxMessage($code)
+{
+ //网址,appid,appsecret都封装至配置文件中,方便后期管理
+
+ $url = sprintf(config('wx.url'), config('wx.AppID'), config('wx.AppSecret'), $code);
+ //使用封装的CURL方法
+ $res = getCurl($url);
+ //返回结果
+ return $res;
+}
+
+function getDistance($lat1, $lng1, $lat2, $lng2)
+{
+ $earthRadius = 6367000;
+ $lat1 = ($lat1 * pi()) / 180;
+ $lng1 = ($lng1 * pi()) / 180;
+ $lat2 = ($lat2 * pi()) / 180;
+ $lng2 = ($lng2 * pi()) / 180;
+ $calcLongitude = $lng2 - $lng1;
+ $calcLatitude = $lat2 - $lat1;
+ $stepOne = pow(sin($calcLatitude / 2), 2) + cos($lat1) * cos($lat2) * pow(sin($calcLongitude / 2), 2);
+ $stepTwo = 2 * asin(min(1, sqrt($stepOne)));
+ $calculatedDistance = $earthRadius * $stepTwo;
+ return round($calculatedDistance / 1000, 2);
+}
+
+
+
+
+
+
diff --git a/app/controller/UserCollect.php b/app/controller/UserCollect.php
new file mode 100644
index 0000000..bdfee1d
--- /dev/null
+++ b/app/controller/UserCollect.php
@@ -0,0 +1,299 @@
+where('charge_station_number', $station_number)->value('charge_station_id');
+ $query = Db::table($table)->where('openid', $openid)->where('charge_station_id', $station_id)->find();
+ if (empty($query)) {
+ $data = ['openid' => $openid, 'charge_station_id' => $station_id];
+ Db::table($table)->save($data);
+ return json(['code' => 200, 'message' => '新增收藏成功', 'is_collect' => 1, 'collect_message' => '取消收藏']);
+ } else {
+ return json(['code' => 1, 'message' => '收藏过了,代码可能有问题']);
+ }
+ } elseif (intval($is_collect) == 1) {
+ $station_id = Db::table('charge_station')->where('charge_station_number', $station_number)->value('charge_station_id');
+ $query = Db::table($table)->where('openid', $openid)->where('charge_station_id', $station_id)->find();
+ if (!empty($query)) {
+ Db::table($table)->where('openid', $openid)->where('charge_station_id', $station_id)->delete();
+ return json(['code' => 200, 'message' => '取消收藏成功', 'is_collect' => 0, 'collect_message' => '收藏']);
+ } else {
+ return json(['code' => 1, 'message' => '没有收藏呀,代码可能有问题']);
+ }
+ }
+ }
+
+
+ public function MyCollect($openid, $lat, $lng)
+ {
+ $ss = array();
+
+ $table = 'zxc_user_collect';
+ $station = Db::table($table)->where('openid', $openid)->select();
+ $sql = "SELECT charge_station_id,count(charge_station_id) pile_number FROM charge_pile GROUP BY charge_station_id HAVING count(charge_station_id)>1 ORDER BY charge_station_id";
+ $message = Db::query($sql);
+ foreach ($message as $m) {
+ $charge_station_id = $m['charge_station_id'];
+ $pile_number = $m['pile_number'];
+ ChargeStationModel::where('charge_station_id', $charge_station_id)->update(['charge_pile_num' => $pile_number]);
+ }
+ foreach ($station as $st) {
+ $station_id = $st['charge_station_id'];
+ $lat1 = $lat;
+ $lng1 = $lng;
+ $lat2 = Db::table('charge_station')->where('charge_station_id', $station_id)->value('latitude');
+ $lng2 = Db::table('charge_station')->where('charge_station_id', $station_id)->value('longitude');
+ $distance = $this->getDistance($lat1, $lng1, $lat2, $lng2);
+ $station_name = Db::table('charge_station')->where('charge_station_id', $station_id)->value('charge_station_name');
+ $station_number = Db::table('charge_station')->where('charge_station_id', $station_id)->value('charge_station_number');
+ $free = 0;
+ $occupy = 0;
+ $fault = 0;
+ $i = 1;
+ $mess = Db::table('charge_pile')->where('charge_station_id', $station_id)->select();
+ foreach ($mess as $m) {
+ if ($m['status'] == 1) {
+ $free += 1;
+ } elseif ($m['status'] == 2) {
+ $occupy += 1;
+ } elseif ($m['status'] == 3) {
+ $fault += 1;
+ }
+ $no = Db::table('charge_pile')->where('charge_pile_id', $m['charge_pile_id'])->value('no');
+ if ($no == null) {
+ Db::table('charge_pile')->where('charge_pile_id', $m['charge_pile_id'])->update(['no' => $i]);
+ }
+ $i += 1;
+ }
+ $data_station = [
+ 'pile_free' => $free,
+ 'pile_occupy' => $occupy,
+ 'pile_fault' => $fault
+ ];
+ Db::table('charge_station')->where('charge_station_id', $station_id)->update($data_station);
+
+ $collect = Db::table($table)->where('openid', $openid)->where('charge_station_id', $station_id)->find();
+ if (empty($collect)) {
+ $is_collect = 0;
+ $collect_message = '收藏';
+ } else {
+ $is_collect = 1;
+ $collect_message = '取消收藏';
+ }
+
+ $kk['ChargeStationNumber'] = $station_number;
+ $kk['ChargeStationName'] = $station_name;
+ $kk['Free'] = $free;
+ $kk['Occupy'] = $occupy;
+ $kk['Fault'] = $fault;
+ $kk['Distance'] = $distance;
+ $kk['is_collect'] = $is_collect;
+ $kk['message'] = $collect_message;
+
+ $ss[] = $kk;
+ }
+ return json($ss);
+ }
+
+ /**
+ * 显示资源列表
+ *
+ * @return \think\Response
+ */
+ public function index_ToWechat(Request $request)
+ {
+ $data = $request->param();
+ $openid = $data['openid'];
+
+ $table = 'zxc_user_collect';
+ $charge_station_id = Db::table($table)->where('openid', $openid)->column('charge_station_id');
+ $infomation = [];
+ foreach ($charge_station_id as $id) {
+ $charge_station_number = Db::table('charge_station')->where('charge_station_id', $id)->value('charge_station_number');
+ $charge_station_name = Db::table('charge_station')->where('charge_station_id', $id)->value('charge_station_name');
+ $sql = "SELECT charge_station_id,count(charge_station_id) pile_number FROM charge_pile GROUP BY charge_station_id HAVING count(charge_station_id)>1 ORDER BY charge_station_id";
+ $message = Db::query($sql);
+ foreach ($message as $m) {
+ $charge_station_id = $m['charge_station_id'];
+ $pile_number = $m['pile_number'];
+ ChargeStationModel::where('charge_station_id', $charge_station_id)->update(['charge_pile_num' => $pile_number]);
+ }
+ $free = 0;
+ $occupy = 0;
+ $fault = 0;
+ $i = 1;
+ $mess = Db::table('charge_pile')->where('charge_station_id', $id)->select();
+ foreach ($mess as $m) {
+ if ($m['status'] == 1) {
+ $free += 1;
+ } elseif ($m['status'] == 2) {
+ $occupy += 1;
+ } elseif ($m['status'] == 3) {
+ $fault += 1;
+ }
+ $no = Db::table('charge_pile')->where('charge_pile_id', $m['charge_pile_id'])->value('no');
+ if ($no == null) {
+ Db::table('charge_pile')->where('charge_pile_id', $m['charge_pile_id'])->update(['no' => $i]);
+ }
+ $i += 1;
+ }
+ $data_station = [
+ 'pile_free' => $free,
+ 'pile_occupy' => $occupy,
+ 'pile_fault' => $fault
+ ];
+ Db::table('charge_station')->where('charge_station_id', $id)->update($data_station);
+ $lat1 = $data['lat'];
+ $lng1 = $data['lng'];
+ $lat2 = Db::table('charge_station')->where('charge_station_id', $id)->value('latitude');
+ $lng2 = Db::table('charge_station')->where('charge_station_id', $id)->value('longitude');
+
+ $distance = $this->getDistance($lat1, $lng1, $lat2, $lng2);
+ $info = [
+ 'charge_station_id' => $id,
+ 'charge_station_number' => $charge_station_number,
+ 'station_name' => $charge_station_name,
+ 'distance' => $distance,
+ 'free' => $free,
+ 'occupy' => $occupy,
+ 'fault' => $fault
+ ];
+ array_push($infomation, $info);
+ }
+ return json($infomation);
+ }
+
+
+ /**
+ * 显示创建资源表单页.
+ *
+ * @return \think\Response
+ */
+ public function create()
+ {
+ //
+ }
+
+ /**
+ * 保存新建的资源
+ *
+ * @param \think\Request $request
+ * @return \think\Response
+ */
+ public function save(Request $request)
+ {
+ $data = $request->param();
+
+ $table = 'zxc_user_collect';
+
+// $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
+// `usercollect_id` int unsigned NOT NULL AUTO_INCREMENT,
+// `openid` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
+// `charge_station_id` int DEFAULT NULL,
+// `charge_pile_number` varchar(50) DEFAULT NULL,
+// `area` varchar(50) DEFAULT NULL,
+// PRIMARY KEY (`usercollect_id`) USING BTREE,
+// KEY `user_id` (`openid`)
+// ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb3";
+// Db::execute($sql);
+//
+
+ $openid = $data['openid'];
+ $charge_pile_number = $data['charge_pile_number'];
+ $charge_station_id = Db::table('charge_pile')->where('charge_pile_number', $charge_pile_number)->value('charge_station_id');
+ $pile_data = [
+ 'openid' => $openid,
+ 'charge_station_id' => $charge_station_id,
+ 'charge_pile_number' => $charge_pile_number,
+ 'area' => ''
+ ];
+ $mess = Db::table($table)->where([['openid', '=', $openid], ['charge_pile_number', '=', $charge_pile_number]])->find();
+ if ($mess == null) {
+ $result = Db::table($table)->insert($pile_data);
+ if ($result == 1) {
+ return json(['code' => 200, 'massage' => '收藏成功']);
+ } else {
+ return json(['code' => 1, 'massage' => '收藏失败']);
+ }
+ } else {
+ return json(['code' => 1, 'massage' => '已收藏过']);
+ }
+
+ }
+
+ /**
+ * 显示指定的资源
+ *
+ * @param int $id
+ * @return \think\Response
+ */
+ public function read($id)
+ {
+ //
+ }
+
+ /**
+ * 显示编辑资源表单页.
+ *
+ * @param int $id
+ * @return \think\Response
+ */
+ public function edit($id)
+ {
+ //
+ }
+
+ /**
+ * 保存更新的资源
+ *
+ * @param \think\Request $request
+ * @param int $id
+ * @return \think\Response
+ */
+ public function update(Request $request, $id)
+ {
+ //
+ }
+
+ /**
+ * 删除指定资源
+ *
+ * @return \think\Response
+ */
+ public function delete(Request $request)
+ {
+ $data = $request->param();
+ $table = 'zxc_user_collect';
+ $openid = $data['openid'];
+ $charge_pile_number = $data['charge_pile_number'];
+ $massage = [
+ ['openid', '=', $openid],
+ ['charge_pile_number', '=', $charge_pile_number]
+ ];
+ $result = Db::table($table)->where($massage)->delete();
+ if ($result != 0) {
+ return json(['code' => 200, 'massage' => '取消收藏成功']);
+ } else {
+ return json(['code' => 1, 'massage' => '取消收藏失败']);
+ }
+ }
+
+
+}
+
+
diff --git a/app/controller/UserGroup.php b/app/controller/UserGroup.php
new file mode 100644
index 0000000..72ab462
--- /dev/null
+++ b/app/controller/UserGroup.php
@@ -0,0 +1,528 @@
+paginate([
+ 'list_rows' => 20,
+ 'query' => request()->param()
+ ]); // 获取全部数据
+
+ return json($list);
+
+
+ }
+
+
+ public function EnterpriseGroupAdd($group_name, $group_msg)
+ {
+ $add = (new \app\model\EnterpriseGroup)->save(['group_name' => $group_name, 'group_msg' => $group_msg]);
+ if ($add == 1) {
+ $m = (new \app\model\EnterpriseGroup)->where('group_name', $group_name)->find();
+ Db::table('service_fee')->save(
+ ['type' => 3, 'group_id' => $m['id'], 'service_fee' => '服务费:00:00~24:00:0.40', 'station_type' => 0]
+ );
+ Db::table('service_fee')->save(
+ ['type' => 3, 'group_id' => $m['id'], 'service_fee' => '服务费:00:00~24:00:0.40', 'station_type' => 1]
+ );
+ return json(['code' => 200, 'msg' => '新增成功', 'data' => $m]);
+ } else {
+ return json(['code' => 404, 'msg' => '新增失败']);
+ }
+ }
+
+ public function EnterpriseAdd($phone, $group_id)
+ {
+
+ }
+
+ public function NormalSearch($phone)
+ {
+ if (!empty($phone)) {
+
+ $list = Db::table('zxc_user')->where('phone', $phone)->where('type', 1)->find();
+
+ $array[] = $list;
+ return json(['code' => 200, 'msg' => '请求成功', 'data' => $array]);
+ } else {
+ return json(['code' => 404, 'msg' => '没有数据']);
+ }
+ return json(['code' => 404, 'msg' => '没有数据']);
+
+ }
+
+ public function NormalToEnterprise($phone, $group_id)
+ {
+
+ $ll = Db::table('zxc_user')->where('phone', $phone)->find();
+
+ $list = Db::table('zxc_user')->where('phone', $phone)->save(['type' => 3, 'group_id' => $group_id]);
+ if ($list == 1) {
+ $data = Db::table('zxc_user')->where('phone', $phone)->find();
+ $check = EnterpriseUser::where('phone', $phone)->find();
+ if (empty($check)) {
+ (new \app\model\EnterpriseUser)->save(['phone' => $phone, 'group_id' => $group_id, 'openid' => $ll['openid']]);
+ } else {
+ (new \app\model\EnterpriseUser)->where('phone', $phone)->save(['phone' => $phone, 'group_id' => $group_id, 'openid' => $ll['openid']]);
+ }
+ return json(['code' => 200, 'msg' => '添加成功', 'data' => $data]);
+ }
+ return json(['code' => 404, 'msg' => '添加失败']);
+ }
+
+ public function GetGroup()
+ {
+ $group = EnterpriseGroup::select();
+ return json($group);
+ }
+
+ public function DeleteEnterpriseUser($openid)
+ {
+ $table = 'zxc_user';
+ $msg = Db::table($table)->where('openid', $openid)->find();
+ if (!empty($msg)) {
+ $phone = Db::table($table)->where('openid', $openid)->value('phone');
+ $destroy = Db::table($table)->where('openid', $openid)->save(['type' => 1, 'group_id' => '']);
+ $EnterptiseUserDelete = EnterpriseUser::where('phone', $phone)->delete();
+ if ($destroy == 1 && $EnterptiseUserDelete == 1) {
+ return json(['code' => 200, 'msg' => '移除成功']);
+ } else {
+ return json(['code' => 404, 'msg' => '移除失败']);
+ }
+ } else {
+ return json(['code' => 404, 'msg' => '不存在该用户']);
+ }
+ }
+
+
+ public function DeleteEnterpriseGroup($group_id)
+ {
+ $user = EnterpriseUser::where('group_id', $group_id)->select();
+ foreach ($user as $u) {
+ $this->DeleteEnterpriseUser($u['openid']);
+ }
+ $EnterptiseGroupDelete = EnterpriseGroup::where('id', $group_id)->delete();
+ $ServerFeeDelete = ServiceFee::where('group_id', $group_id)->delete();
+ if ($EnterptiseGroupDelete > 0 && $ServerFeeDelete > 0) {
+ return json(['code' => 200, 'msg' => '删除成功']);
+ } else {
+ return json(['code' => 404, 'msg' => '删除失败']);
+ }
+ }
+
+ public function PhoneSearch($phone)
+ {
+ $message = EnterpriseUser::where('phone', 'like', '%' . $phone . '%')->select();
+ $i = 0;
+ foreach ($message as $m) {
+ $message[$i]['group_name'] = EnterpriseGroup::where('id', $m['group_id'])->value('group_name');
+ $table = 'zxc_user';
+ $account = Db::table($table)->where('openid', $m['openid'])->value('account');
+ $message[$i]['account'] = $account;
+ $i += 1;
+ }
+ return json(['data' => $message]);
+ }
+
+ public function EnterpriserUserEdit($phone, $group_id)
+ {
+ $o_data = EnterpriseUser::where('phone', $phone)->find();
+ $o_data['group_name'] = EnterpriseGroup::where('id', $o_data['group_id'])->value('group_name');
+ $edit = EnterpriseUser::where('phone', $phone)->save(['group_id' => $group_id]);
+ if ($edit != 0) {
+ $n_data = EnterpriseUser::where('phone', $phone)->find();
+ $n_data['group_name'] = EnterpriseGroup::where('id', $n_data['group_id'])->value('group_name');
+ return json(['code' => 200, 'mag' => '修改成功', 'before_data' => $o_data, 'now_data' => $n_data]);
+ } else {
+ return json(['code' => 404, 'msg' => '修改失败']);
+ }
+
+ }
+
+ public function Electricity($time_type = "", $str_day = "", $charge_station_name = '')
+ {
+
+ $where = [];
+
+ if (!empty($charge_station_name)) {
+ $charge_station_ids = Db::table('charge_station')->where('charge_station_name', 'in', $charge_station_name)->column('charge_station_id');
+
+ $ids = array_map('intval', $charge_station_ids); // 强制转为整数
+
+ $where[] = ['charge_station_id', 'in', $ids];
+ }
+ // 设置日期范围
+ $currentDate = $str_day ?: date('Y-m-d');
+ $time_type = $time_type ?: '天';
+ switch ($time_type) {
+ case '天':
+
+ $startDate = $currentDate . ' 00:00:00';
+ $endDate = $currentDate . ' 23:59:59';
+ break;
+ case '周':
+ $monday = date('Y-m-d', strtotime('monday this week', strtotime($currentDate)));
+ $sunday = date('Y-m-d', strtotime('sunday this week', strtotime($currentDate)));
+ $startDate = $monday . ' 00:00:00';
+ $endDate = $sunday . ' 23:59:59';
+ break;
+ case '月':
+ $firstDay = date('Y-m-01', strtotime($currentDate));
+ $lastDay = date('Y-m-t', strtotime($currentDate));
+ $startDate = $firstDay . ' 00:00:00';
+ $endDate = $lastDay . ' 23:59:59';
+ break;
+ default:
+ throw new Exception('不支持的统计类型');
+ }
+
+
+ $where[] = ['start_time', '>=', $startDate];
+ $where[] = ['start_time', '<=', $endDate];
+ $allData = Db::table('zxc_charge_order')
+ ->where($where)
+ ->field('charge_station_id, start_time, TotalPower')
+ ->select();
+
+ // 2. 初始化12个时段统计数据
+ $hourlyStats = [];
+ for ($hour = 0; $hour < 24; $hour += 2) {
+ $startHour = str_pad($hour, 2, '0', STR_PAD_LEFT);
+ $endHour = str_pad($hour + 2, 2, '0', STR_PAD_LEFT);
+ $timeKey = $startHour . ':00~' . ($hour == 22 ? '23:59' : $endHour . ':00');
+
+ $hourlyStats[$timeKey] = [
+ 'time_range' => $timeKey,
+ 'power' => '0',
+ 'order_count' => 0
+ ];
+ }
+
+ // 3. 遍历数据按时段统计
+ $totalPower = 0;
+ foreach ($allData as $row) {
+ $hour = date('H', strtotime($row['start_time']));
+ $timeKey = $this->getTimeKeyForHour($hour);
+
+ if (isset($hourlyStats[$timeKey])) {
+ $hourlyStats[$timeKey]['power'] = bcadd($hourlyStats[$timeKey]['power'], $row['TotalPower'], 4);
+ $hourlyStats[$timeKey]['order_count']++;
+ $totalPower = bcadd($totalPower, $row['TotalPower'], 4);
+ }
+ }
+
+ return [
+ 'date_range' => ['start' => $startDate, 'end' => $endDate],
+ 'total_power' => number_format((double)$totalPower, 4),
+ 'total_orders' => count($allData),
+ 'hourly_stats' => array_values($hourlyStats),
+ 'time_interval' => '2小时',
+ 'station' => $charge_station_name ?: '全部充电站'
+ ];
+ }
+
+ /**
+ * 根据小时数获取对应的时间段key
+ */
+ public function getTimeKeyForHour($hour)
+ {
+ $hour = (int)$hour;
+ $start = str_pad(floor($hour / 2) * 2, 2, '0', STR_PAD_LEFT);
+ $end = ($start == 22) ? '23:59' : str_pad($start + 2, 2, '0', STR_PAD_LEFT) . ':00';
+ return $start . ':00~' . $end;
+ }
+
+
+ protected function WeedDay($startdate, $enddate)
+ {
+
+ $stimestamp = strtotime($startdate);
+ $etimestamp = strtotime($enddate);
+ // 计算日期段内有多少天
+ $days = ($etimestamp - $stimestamp) / 86400;
+ // 保存每天日期
+ $date = array();
+ for ($i = 0; $i < $days; $i++) {
+
+ $date[] = date('Y-m-d 00:00:00', $stimestamp + (86400 * $i));
+ }
+
+ return $date;
+ }
+
+ public function PeriodElectricityConsumption($str_day, $charge_station_name = '')
+ {
+ $time = strtotime($str_day);
+ $start_time = date('Y-m-d 00:00:00', $time);
+ $date_start = $this->getDayDate($start_time)['start_time'];
+ $date_end = $this->getDayDate($start_time)['end_time'];
+ $i = 0;
+ $ss = 0;
+ $data = array();
+ foreach ($date_start as $d) {
+ $interval = substr($date_start[$ss], 11) . '~' . substr($date_end[$ss], 11);
+ $data[$ss]['interval'] = $interval;
+ $data[$ss]['Total'] = 0;
+ $ss += 1;
+ }
+ foreach ($date_start as $d) {
+ $table = 'zxc_charge_order';
+ $d_start = date('Y-m-d H:i:s', strtotime($date_start[$i]));
+ $d_end = date('Y-m-d H:i:s', strtotime($date_end[$i]));
+ if (!empty($charge_station_name)) {
+ $station_id = Db::table('charge_station')->where('charge_station_name', $charge_station_name)->value('charge_station_id');
+ $order = Db::table($table)->where('charge_station_id', $station_id)->whereBetweenTime('start_time', $d_start, $d_end)->select();
+ } else {
+ $order = Db::table($table)->whereBetweenTime('start_time', $d_start, $d_end)->select();
+ }
+ foreach ($order as $o) {
+ if (!empty($o['DetailMessage'])) {
+ if ($o['SumPeriod'] == 1) {
+ $data[$i]['Total'] += $o['TotalPower'];
+ } elseif ($o['SumPeriod'] == 2) {
+ $data[$i]['Total'] += $this->GetDetailMessage($o['DetailMessage'], $o['SumPeriod'])[0];
+ if ($i == 7) {
+ $data[$i - 7]['Total'] += $this->GetDetailMessage($o['DetailMessage'], $o['SumPeriod'])[1]; //再思考一下
+ } else {
+ $data[$i + 1]['Total'] += $this->GetDetailMessage($o['DetailMessage'], $o['SumPeriod'])[1];
+ }
+ } elseif ($o['SumPeriod'] == 3) {
+ $data[$i]['Total'] += $this->GetDetailMessage($o['DetailMessage'], $o['SumPeriod'])[0];
+ if ($i == 6) {
+ $data[$i + 1]['Total'] += $this->GetDetailMessage($o['DetailMessage'], $o['SumPeriod'])[1];
+ $data[$i + 1 - 7]['Total'] += $this->GetDetailMessage($o['DetailMessage'], $o['SumPeriod'])[2];
+ } elseif ($i == 7) {
+ $data[$i - 7]['Total'] += $this->GetDetailMessage($o['DetailMessage'], $o['SumPeriod'])[1];
+ $data[$i - 7 + 1]['Total'] += $this->GetDetailMessage($o['DetailMessage'], $o['SumPeriod'])[2];
+ }
+ }
+ } else {
+ for ($a = 0; $a < count($this->GetTimeInterVal($o['start_time'], $o['end_time'])); $a++) {
+ if ($i + $a >= 7) {
+ $data[$i + $a - 7]['Total'] += round($o['TotalPower'] * $this->GetTimeInterVal($o['start_time'], $o['end_time'])[$a], 3);
+ } else {
+ $data[$i + $a]['Total'] += round($o['TotalPower'] * $this->GetTimeInterVal($o['start_time'], $o['end_time'])[$a], 3);
+ }
+ }
+ }
+ }
+ $i += 1;
+ }
+ for ($k = 0; $k < count($data); $k++) {
+ $data[$k]['Total'] = round($data[$k]['Total'], 2);
+ }
+ return $data;
+
+ }
+
+ public function GetTimeInterVal($start_time, $end_time)
+ {
+ $date = floor((strtotime($end_time) - strtotime($start_time)) / 86400);
+ $minute1 = floor((strtotime($end_time) - strtotime($start_time)) % 86400 / 60) + $date * 24 * 60;
+ $timeArray = $this->TimeProportion($start_time, $end_time);
+ $data = array();
+ for ($i = 0; $i < count($timeArray['start_time']); $i++) {
+ if ($i >= 8) {
+ $data['period'][$i - 8] += floor((strtotime($timeArray['end_time'][$i]) - strtotime($timeArray['start_time'][$i])) % 86400 / 60);
+ } else {
+ $data['period'][$i] = floor((strtotime($timeArray['end_time'][$i]) - strtotime($timeArray['start_time'][$i])) % 86400 / 60);
+ }
+ }
+ foreach ($data['period'] as $p) {
+ if ($minute1 != 0) {
+ $Proportion[] = round($p / $minute1, 3);
+ } else {
+ $Proportion[] = 0;
+ }
+ }
+ return $Proportion;
+ }
+
+ public function TimeProportion($order_start_time, $order_end_time)
+ {
+ $time = strtotime($order_start_time);
+ $start_time = date('Y-m-d 00:00:00', $time);
+ $end_time = date('Y-m-d 00:00:00', strtotime($order_end_time));
+ $start_d = date('d', $time);
+ $end_d = date('d', strtotime($order_end_time));
+ $timeArray = $this->getDayDate($start_time);
+ $arry2 = $this->getDayDate($end_time);
+ if ($start_d != $end_d) {
+ $timeArray = array_merge_recursive($timeArray, $arry2);
+ }
+ $data = array();
+ for ($i = 0; $i < count($timeArray['start_time']); $i++) {
+ if (date('Y-m-d H:i:s', strtotime($order_start_time)) >= date('Y-m-d H:i:s', strtotime($timeArray['start_time'][$i])) && date('Y-m-d H:i:s', strtotime($order_end_time)) <= date('Y-m-d H:i:s', strtotime($timeArray['end_time'][$i]))) {
+ $data['start_time'][] = $order_start_time;
+ $data['end_time'][] = $order_end_time;
+ } elseif (date('Y-m-d H:i:s', strtotime($order_start_time)) >= date('Y-m-d H:i:s', strtotime($timeArray['start_time'][$i])) && date('Y-m-d H:i:s', strtotime($order_end_time)) >= date('Y-m-d H:i:s', strtotime($timeArray['end_time'][$i]))) {
+ if (date('Y-m-d H:i:s', strtotime($order_start_time)) < date('Y-m-d H:i:s', strtotime($timeArray['end_time'][$i]))) {
+ $data['start_time'][] = $order_start_time;
+ $data['end_time'][] = date('Y-m-d H:i:s', strtotime($timeArray['end_time'][$i]));
+ }
+
+ } elseif (date('Y-m-d H:i:s', strtotime($order_start_time)) <= date('Y-m-d H:i:s', strtotime($timeArray['start_time'][$i])) && date('Y-m-d H:i:s', strtotime($order_end_time)) <= date('Y-m-d H:i:s', strtotime($timeArray['end_time'][$i]))) {
+ if (date('Y-m-d H:i:s', strtotime($order_end_time)) >= date('Y-m-d H:i:s', strtotime($timeArray['start_time'][$i])) && date('Y-m-d H:i:s', strtotime($order_end_time)) <= date('Y-m-d H:i:s', strtotime($timeArray['end_time'][$i]))) {
+ $data['start_time'][] = $timeArray['start_time'][$i];
+ $data['end_time'][] = $order_end_time;
+ }
+ } elseif (date('Y-m-d H:i:s', strtotime($order_start_time)) <= date('Y-m-d H:i:s', strtotime($timeArray['start_time'][$i])) && date('Y-m-d H:i:s', strtotime($order_end_time)) >= date('Y-m-d H:i:s', strtotime($timeArray['end_time'][$i]))) {
+ if (date('Y-m-d H:i:s', strtotime($order_end_time)) >= date('Y-m-d H:i:s', strtotime($timeArray['end_time'][$i]))) {
+ $data['start_time'][] = $timeArray['start_time'][$i];
+ $data['end_time'][] = $timeArray['end_time'][$i];
+ }
+ }
+ }
+ return $data;
+ }
+
+ protected function getDayDate($date)
+ {
+ $date_t = array();
+ $date_t[] = $date;
+ $this_date = strtotime($date);
+ $end_date = date("Y-m-d H:i:s", strtotime('+8 hour -1 second', $this_date));
+ $date_end[] = $end_date;
+ $t = $this->GetPeriod($date, $end_date, $date_t, $date_end);
+ $kk['start_time'] = $t[1];
+ $kk['end_time'] = $t[0];
+ return $kk;
+
+ }
+
+ protected function GetDetailMessage($message, $period)
+ {
+ $array = explode(';', $message, $period);
+ foreach ($array as $a) {
+ $arr1 = explode(',', $a);
+ $degree = explode(':', $arr1[2])[1];
+ $data[] = $degree;
+ }
+ return $data;
+ }
+
+
+ protected function GetPeriod($date, $end_date, $date_t, $date_end, $array1 = [8, 3, 1, 2, 3, 3, 2, 2])
+ {
+ for ($i = 0; $i < count($array1) - 1; $i++) {
+ $this_date = strtotime($date);
+ $next_date = date("Y-m-d H:i:s", strtotime('+' . $array1[$i] . ' hour', $this_date));
+ $this_date_end = strtotime($end_date);
+ $next_date_end = date("Y-m-d H:i:s", strtotime('+' . $array1[$i + 1] . ' hour', $this_date_end));
+ $date_end[] = $next_date_end;
+ $date_t[] = $next_date;
+ $date = $next_date;
+ $next_date_end = date("Y-m-d H:59:59", strtotime($next_date_end));
+ $end_date = $next_date_end;
+ }
+ return [$date_end, $date_t];
+ }
+
+ public function ShowServiceFee($type, $station_type, $group_id = '')
+ {
+ if ($type != 3) {
+ $ServiceFee = (new \app\model\ServiceFee)->where('type', $type)->where('station_type', $station_type)->value('service_fee');
+ } else {
+ $ServiceFee = (new \app\model\ServiceFee)->where('type', $type)->where('group_id', $group_id)->where('station_type', $station_type)->value('service_fee');
+ }
+ if ($station_type == 0) {
+ $station_type = '快充';
+ } else {
+ $station_type = '慢充';
+ }
+ $ServiceFee = str_replace('服务费:', '', $ServiceFee);
+ $Server = explode(',', $ServiceFee);
+ for ($index = 0; $index < count($Server); $index++) {
+ $ll['time_interval'] = substr($Server[$index], 0, -5);
+ $ll['univalence'] = substr($Server[$index], Strlen($Server[$index]) - 4);
+ $mm[] = $ll;
+ }
+ return json(['code' => 200, 'Station_Type' => $station_type, 'ServiceFee' => $mm]);
+ }
+
+ public function UpdateServiceFee($type, $station_type, $fee, $group_id = '')
+ {
+ $service = '服务费:00:00~24:00:' . number_format((float)$fee, 2);
+ if ($type == 1) {
+ $update = (new \app\model\ChargeStation)->where('station_type', $station_type)->save(['ServiceFee' => $service]);
+ $feeUpdate = (new \app\model\ServiceFee)->where('type', $type)->where('station_type', $station_type)->save(['service_fee' => $service]);
+ if ($update >= 1 && $feeUpdate == 1) {
+ return json(['code' => 200, 'message' => '修改成功', 'NowFee' => $service]);
+ } else {
+ return json(['code' => 1, 'message' => '金额未发生变化,修改失败']);
+ }
+ } elseif ($type == 2) {
+ $feeUpdate = (new \app\model\ServiceFee)->where('type', $type)->where('station_type', $station_type)->save(['service_fee' => $service]);
+ if ($feeUpdate == 1) {
+ return json(['code' => 200, 'message' => '修改成功', 'NowFee' => $service]);
+ } else {
+ return json(['code' => 1, 'message' => '金额未发生变化,修改失败']);
+ }
+ } else {
+ $feeUpdate = (new \app\model\ServiceFee)->where('type', $type)->where('station_type', $station_type)->where('group_id', $group_id)->save(['service_fee' => $service]);
+ if ($feeUpdate == 1) {
+ return json(['code' => 200, 'message' => '修改成功', 'NowFee' => $service]);
+ } else {
+ return json(['code' => 1, 'message' => '金额未发生变化,修改失败']);
+ }
+ }
+
+ }
+
+ public function UserVip($openid)
+ {
+
+ $type = Db::table('zxc_user')->where('openid', $openid)->value('type');
+ if ($type == 1) {
+ $vip = 'normal';
+ return json(['code' => 200, 'vip' => $vip]);
+ } elseif ($type == 2) {
+ $vip = 'vip';
+ return json(['code' => 200, 'vip' => $vip]);
+ } elseif ($type == 3) {
+ $vip = 'company';
+ $group_id = EnterpriseUser::where('openid', $openid)->value('group_id');
+ $group_name = EnterpriseGroup::where('id', $group_id)->value('group_name');
+ return json(['code' => 200, 'vip' => $vip, 'group_name' => $group_name]);
+ } else {
+ return json(['code' => 1]);
+ }
+ }
+
+ /**
+ * @param $start_time
+ * @param $end_time
+ * @param string $charge_station_name
+ * @param array $DataAll
+ * @return \think\response\Json
+ */
+ protected function GetData($start_time, $end_time, string $charge_station_name, array $DataAll): \think\response\Json
+ {
+ $date = $this->WeedDay($start_time, $end_time);
+ foreach ($date as $d) {
+ $data = $this->PeriodElectricityConsumption($d, $charge_station_name);
+ for ($i = 0; $i < count($data); $i++) {
+ $DataAll[$i]['Total'] += $data[$i]['Total'];
+ }
+ }
+ $all = 0;
+ for ($k = 0; $k < count($DataAll); $k++) {
+ $DataAll[$k]['Total'] = round($DataAll[$k]['Total'], 2);
+ $all += $DataAll[$k]['Total'];
+ }
+ return json(['data' => $DataAll, 'all' => round($all, 2)]);
+ }
+}
\ No newline at end of file
diff --git a/app/controller/UserRefund.php b/app/controller/UserRefund.php
new file mode 100644
index 0000000..4ca3125
--- /dev/null
+++ b/app/controller/UserRefund.php
@@ -0,0 +1,462 @@
+where('openid', $openid)->find();
+ //判断金额 余额>=提现金额
+ if ($user_info['account'] < $money) {
+ return json(['code' => 1, 'message' => '余额不足']);
+ }
+ //正在进行余额充电的订单不可提现
+ $count = Db::table('zxc_charge_order')
+ ->where('openid', $openid)
+ ->where('type', 2)
+ ->where('end_time', null)
+ ->find();
+ if ($count > 0) {
+ return json(['code' => 1, 'message' => '存在未结算订单']);
+ }
+
+ $table_recharge = 'zxc_recharge';
+ $reOrder = $this->SelectReOrder($openid, $money, $table_recharge);
+
+ if (empty($reOrder)) {
+ return json(['code' => 1, 'message' => '提现数据为空']);
+ }
+ $i = 0;
+ $suceess = 0;
+ $fail = 0;
+ foreach ($reOrder as $key => $value) {
+ $transaction_id = $key;
+ $OriginalOrderAmount = Db::table($table_recharge)->where('transaction_id', $transaction_id)->value('total');
+ $OriginalOrderAmount /= 100;
+ $refundAmount = $value / 100;
+ $td = new WechatReimburse();
+ $kk[] = $td->Refund($transaction_id, $openid, $refundAmount, $OriginalOrderAmount);
+ if ($kk[$i]['code'] == 200) {
+ $suceess += 1;
+ } elseif ($kk[$i]['code'] == 1) {
+ $fail += 1;
+ }
+ $i += 1;
+ }
+ return json(['code' => 200, 'total' => $i, 'success' => $suceess, 'fail' => $fail, 'message' => $kk, 'reOrder' => $reOrder]);
+
+ exit();
+
+
+ $account = Db::table($table_user)->where('openid', $openid)->value('account');
+ $account = round($account, 2);
+ $frozenAmount = Db::table($table_user)->where('openid', $openid)->value('FrozenAccount');
+ if ($money <= $account) {
+ $OrderList = new ChargeOrder();
+ $OrderList->OrderList($openid);//更新一下状态
+ //二次确认
+ $recharge_all = Db::table($table_recharge)->where('openid', $openid)->sum('total');
+ $recharge_all /= 100;
+ $refund_all = Db::table($table_refund)->where('openid', $openid)
+ ->where('status', 'SUCCESS')
+ ->sum('refund_total');
+ $refund_all /= 100;
+ $check = Db::table($table_order)->where('openid', $openid)
+ ->where('status', '<>', 4)
+ ->where('status', '<>', 5)
+ ->order('start_time desc')
+ ->value('end_time');
+ if (empty($check)) {
+ $order_all = Db::table($table_order)->where('openid', $openid)
+ ->where('status', 4)
+ ->sum('TotalMoney');
+ $inorder = Db::table($table_order)->where('openid', $openid)
+ ->where('status', '<>', 4)
+ ->where('status', '<>', 5)
+ ->order('start_time desc')
+ ->value('WithholdingMoney');
+ $order_total = $order_all + $inorder;
+ } else {
+ $order_total = Db::table($table_order)->where('openid', $openid)
+ ->where('status', 4)
+ ->sum('TotalMoney');
+ }
+ $order_total = round($order_total, 2);
+ $mask = round($recharge_all - $order_total - $refund_all, 2); //这里还要减已经提现的
+ if (round($mask, 2) == round($account, 2)) {
+ $reOrder = $this->SelectReOrder($openid, $money, $table_recharge);
+ if (empty($reOrder)) {
+ return json(['code' => 1, 'message' => '提现数据为空']);
+ }
+ $i = 0;
+ $suceess = 0;
+ $fail = 0;
+ foreach ($reOrder as $key => $value) {
+ $transaction_id = $key;
+ $OriginalOrderAmount = Db::table($table_recharge)->where('transaction_id', $transaction_id)->value('total');
+ $OriginalOrderAmount /= 100;
+ $refundAmount = $value / 100;
+ $td = new WechatReimburse();
+ $kk[] = $td->Refund($transaction_id, $openid, $refundAmount, $OriginalOrderAmount);
+ if ($kk[$i]['code'] == 200) {
+ $suceess += 1;
+ } elseif ($kk[$i]['code'] == 1) {
+ $fail += 1;
+ }
+ $i += 1;
+ }
+ return json(['code' => 200, 'total' => $i, 'success' => $suceess, 'fail' => $fail, 'message' => $kk, 'reOrder' => $reOrder]);
+ } else {
+ Db::table('refundexception')->save([
+ 'openid' => $openid,
+ 'order_total' => $order_total,
+ 'recharge_total' => $recharge_all,
+ 'refund_total' => $refund_all,
+ 'mask' => $mask,
+ 'account' => $account
+ ]);
+ return json(['code' => 1, 'message' => '账户异常', 'order_total' => $order_total, 'recharge_all' => $recharge_all, 'mask' => $mask]);
+ }
+ } else {
+ return json(['code' => 1, 'message' => '提现金额不能大于余额']);
+ }
+ }
+
+ public function SelectReOrder($openid, $money, $table_recharge)
+ {
+ $oneYearAgo = strtotime('-1 year');
+ $oneYearAgoDate = date('Y-m-d H:i:s', $oneYearAgo);
+ $reOrder = Db::table($table_recharge)->where('openid', $openid)->where('type', 1)->where('success_time', '>=', $oneYearAgoDate)->order('total')->select();
+ $money *= 100;
+ $money = floor($money);
+ $kk = array();
+ foreach ($reOrder as $re) {
+ if ($re['total'] - $re['total_used'] == 0) {
+ continue;
+ } else {
+ $backMoney = $re['total'] - $re['total_used'];
+ if ($money > $backMoney) {
+ $kk[$re['transaction_id']] = $backMoney;
+ $money = $money - $backMoney;
+ } elseif ($money == $backMoney) {
+ $kk[$re['transaction_id']] = $money;
+ break;
+ } else {
+ $kk[$re['transaction_id']] = $money;
+ break;
+ }
+ }
+ }
+ return $kk;
+ }
+
+
+ public function TKRecord($openid)
+ {
+
+ $table_refund = 'zxc_refund';
+
+ $message = Db::table($table_refund)->where('openid', $openid)->order('create_time desc')->select()->toArray();
+
+ $statusMap = [
+ 'SUCCESS' => '退款成功',
+ 'PROCESSING' => '退款处理中',
+ 'ABNORMAL' => '退款异常',
+ 'CLOSED' => '退款关闭',
+ ];
+
+ foreach ($message as &$record) {
+ $record['refund_total'] = round($record['refund_total'] / 100, 2);
+ $record['status'] = $statusMap[$record['status']] ?? $record['status'];
+ }
+
+ return json($message);
+ }
+
+
+ public function RefundQuery($start_time = '', $end_time = '', $message = '')
+ {
+ // 处理结束时间
+ if (!empty($end_time)) {
+ $end_time = date("Y-m-d", strtotime("+1 day", strtotime($end_time)));
+ }
+
+
+ // 生成表名
+ $refundTable = 'zxc_refund';
+ $userTable = 'zxc_user';
+
+
+ // 构建查询条件
+ $query = Db::table($refundTable);
+
+ // 时间范围条件
+ if (!empty($start_time) && !empty($end_time)) {
+ $query->whereBetween('create_time', [$start_time, $end_time]);
+ }
+
+ // 消息条件
+ if (!empty($message)) {
+ if (strlen($message) == 11) {
+ $openid = Db::table($userTable)->where('phone', $message)->value('openid');
+ if ($openid) {
+ $query->where('openid', $openid);
+ } else {
+ $query->where('out_refund_no', 'like', "%{$message}%");
+ }
+ } else {
+ $query->where('out_refund_no', 'like', "%{$message}%");
+ }
+ }
+
+ // 获取数据并合并
+ $resultData = $query->order('create_time desc')->select()->toArray();
+
+ // 处理结果数据
+
+ foreach ($resultData as $index => &$item) {
+ $item['id'] = $index + 1;
+ $item['refund_total'] = round($item['refund_total'] / 100, 2);
+
+ $table = 'zxc_user';
+ $phone = Db::table($table)->where('openid', $item['openid'])->value('phone');
+ $item['phone'] = $phone;
+ }
+
+ return json($resultData);
+ }
+
+
+ public function Refund_Total(Request $request)
+ {
+ $data = $request->param();
+ $time_type = $data['time_type'];
+ $str_day = $data['str_time'];
+ $time = strtotime($str_day);
+ $date_time = date('Y-m-d', $time);
+ $area = Db::table('area_three')->column('area');
+ if ($time_type == '周') {
+ $mess = [];
+ $end_time = date("Y-m-d 23:59:59", strtotime("$date_time Saturday"));//结束时间(2020-04-19 23:59:59)
+ $start_time = date("Y-m-d 00:00:00", strtotime("$end_time - 6 days"));//开始时间(2020-04-13 00:00:00
+ $revenue_total = 0;
+ $order_num_total = 0;
+ $date = $this->getDateFromRange($start_time, $end_time);
+ foreach ($date as $d) {
+ $revenue = 0;
+ $order_num = 0;
+ $table_refund = 'zxc_refund';
+
+ $result = Db::table($table_refund)->select();
+ if (empty($result)) {
+ continue;
+ } else {
+ $recharge = Db::table($table_refund);
+ $revenue = $recharge->whereDay('create_time', $d)->sum('refund_total');
+ $order_num = $recharge->whereDay('create_time', $d)->count();
+ }
+
+ $mess['per'][] = ['time' => $d, 'data' => ['EnterAccount' => round($revenue / 100, 2), 'AccountNum' => $order_num]];
+ $revenue_total += $revenue;
+ $order_num_total += $order_num;
+
+ }
+ $mess['total'] = ['EnterAccount' => round($revenue_total / 100, 2), 'AccountNum' => $order_num_total];
+ return json($mess);
+ } elseif ($time_type == '月') {
+ $mess = [];
+ $start_time = date("Y-m-d", strtotime(date('Y-m-01', $time)));//开始时间(2020-04-01 00:00:00)
+ $date = $this->getMonthDate($start_time);
+ $i = 1;
+ $revenue_total = 0;
+ $order_num_total = 0;
+ foreach ($date as $d) {
+ $z = '第' . $i . '周';
+ $d = date('Y-m-d', strtotime($d));
+ $revenue = 0;
+ $order_num = 0;
+ $table_refund = 'zxc_refund';
+
+ $result = Db::table($table_refund)->select();
+ if (empty($result)) {
+ continue;
+ } else {
+ $recharge = Db::table($table_refund);
+ $revenue = $recharge->whereWeek('create_time', $d)->sum('refund_total');
+ $order_num = $recharge->whereWeek('create_time', $d)->count();
+
+ }
+
+ $mess['per'][] = ['time' => $z, 'data' => ['EnterAccount' => round($revenue / 100, 2), 'AccountNum' => $order_num]];
+ $revenue_total += $revenue;
+ $order_num_total += $order_num;
+ $i += 1;
+ }
+ $mess['total'] = ['EnterAccount' => round($revenue_total / 100, 2), 'AccountNum' => $order_num_total];
+ return json($mess);
+ } elseif ($time_type == '季') {
+ $season = intval(ceil(date('m', $time) / 3));
+ if ($season == 4) {
+ $start_time = date("Y-m-d H:i:s", strtotime(date('Y-' . ($season * 3 - 2) . '-01', $time)));//开始时间(2020-04-01 00:00:00)
+ $end_time = date("Y-m-d 23:59:59", strtotime(date('Y-m-d', strtotime("$start_time +3 month -1 day"))));//开始时间(2020-04-01 00:00:00)
+ } else {
+ $start_time = date("Y-m-d H:i:s", strtotime(date('Y-0' . ($season * 3 - 2) . '-01', $time)));//开始时间(2020-04-01 00:00:00)
+ $end_time = date("Y-m-d 23:59:59", strtotime(date('Y-m-d', strtotime("$start_time +3 month -1 day"))));//开始时间(2020-04-01 00:00:00)
+ }
+ $i = date("m", strtotime(date('Y-' . ($season * 3 - 2) . '-01', $time)));
+ if ((int)substr($i, 0, 1) == 0) {
+ $i = substr($i, -1);
+ }
+ $date = $this->getSeasonDate($start_time);
+ $mess = [];
+ $revenue_total = 0;
+ $order_num_total = 0;
+ foreach ($date as $d) {
+ $z = $i . '月';
+ $d = date('Y-m-d', strtotime($d));
+ $revenue = 0;
+ $order_num = 0;
+
+ $table_refund = 'zxc_refund';
+
+ $result = Db::table($table_refund)->select();
+ if (empty($result)) {
+ continue;
+ } else {
+ $recharge = Db::table($table_refund);
+ $revenue = $recharge->whereMonth('create_time', $d)->sum('refund_total');
+ $order_num = $recharge->whereMonth('create_time', $d)->count();
+
+ }
+ $mess['per'][] = ['time' => $z, 'data' => ['EnterAccount' => round($revenue / 100, 2), 'AccountNum' => $order_num]];
+ $revenue_total += $revenue;
+ $order_num_total += $order_num;
+ $i += 1;
+ }
+ $mess['total'] = ['EnterAccount' => round($revenue_total / 100, 2), 'AccountNum' => $order_num_total];
+ return json($mess);
+ } elseif ($time_type == '年') {
+ $start_time = date('Y-01-01 00:00:00', $time);//开始时间
+ $date = $this->getYearDate($start_time);
+ $mess = [];
+ $revenue_total = 0;
+ $order_num_total = 0;
+ $i = 1;
+ foreach ($date as $d) {
+ $z = $i . '月';
+ $d = date('Y-m', strtotime($d));
+ $revenue = 0;
+ $order_num = 0;
+
+ $table_refund = 'zxc_refund';
+
+ $result = Db::table($table_refund)->select();
+ if (empty($result)) {
+ continue;
+ } else {
+ $recharge = Db::table($table_refund);
+ $revenue = $recharge->whereMonth('create_time', $d)->sum('refund_total');
+ $order_num = $recharge->whereMonth('create_time', $d)->count();
+
+ }
+
+ $mess['per'][] = ['time' => $z, 'data' => ['EnterAccount' => round($revenue / 100, 2), 'AccountNum' => $order_num]];
+ $revenue_total += $revenue;
+ $order_num_total += $order_num;
+ $i += 1;
+ }
+ $mess['total'] = ['EnterAccount' => round($revenue_total / 100, 2), 'AccountNum' => $order_num_total];
+ return json($mess);
+ }
+ }
+
+ private function getDateFromRange($startdate, $enddate): array
+ {
+
+ $stimestamp = strtotime($startdate);
+ $etimestamp = strtotime($enddate);
+ // 计算日期段内有多少天
+ $days = ($etimestamp - $stimestamp) / 86400;
+ // 保存每天日期
+ $date = array();
+ for ($i = 0; $i < $days; $i++) {
+
+ $date[] = date('Y-m-d', $stimestamp + (86400 * $i));
+ }
+
+ return $date;
+ }
+
+ private function getMonthDate($date)
+ {
+ $date_t = array();
+ $date_t[] = $date;
+ for ($i = 0; $i < 4; $i++) {
+ $this_date = strtotime($date);
+ $next_date = date("Y-m-d", strtotime('next monday', $this_date));
+ $date_t[] = $next_date;
+ $date = $next_date;
+ }
+ return $date_t;
+
+ }
+
+ private function getSeasonDate($date)
+ {
+ $date_t = array();
+ $date_t[] = $date;
+ for ($i = 0; $i < 2; $i++) {
+ $this_date = strtotime($date);
+ $next_date = date("Y-m-d", strtotime('next month', $this_date));
+ $date_t[] = $next_date;
+ $date = $next_date;
+ }
+ return $date_t;
+
+ }
+
+ private function getYearDate($date)
+ {
+ $date_t = array();
+ $date_t[] = $date;
+ for ($i = 0; $i < 11; $i++) {
+ $this_date = strtotime($date);
+ $next_date = date("Y-m-d", strtotime('next month', $this_date));
+ $date_t[] = $next_date;
+ $date = $next_date;
+ }
+ return $date_t;
+
+ }
+
+ private function getDayDate($date)
+ {
+ $date_t = array();
+ $date_t[] = $date;
+ $this_date = strtotime($date);
+ $end_date = date("Y-m-d H:i:s", strtotime('+4 hour -1 second', $this_date));
+ $date_end[] = $end_date;
+ for ($i = 0; $i < 5; $i++) {
+ $this_date = strtotime($date);
+ $next_date = date("Y-m-d H:i:s", strtotime('+4 hour', $this_date));
+ $this_date_end = strtotime($end_date);
+ $next_date_end = date("Y-m-d H:i:s", strtotime('+4 hour', $this_date_end));
+ $date_end[] = $next_date_end;
+ $date_t[] = $next_date;
+ $date = $next_date;
+ $next_date_end = date("Y-m-d H:59:59", strtotime($next_date_end));
+ $end_date = $next_date_end;
+ }
+ $kk['start_time'] = $date_t;
+ $kk['end_time'] = $date_end;
+ return $kk;
+
+ }
+}
\ No newline at end of file
diff --git a/app/controller/WechatPay.php b/app/controller/WechatPay.php
new file mode 100644
index 0000000..48861e4
--- /dev/null
+++ b/app/controller/WechatPay.php
@@ -0,0 +1,775 @@
+generate_recharge(6);
+
+ $data = [
+ "appid" => $appid,
+ "mchid" => $merchantId,
+ "description" => '个人钱包充值',
+ 'out_trade_no' => $out_trade_no,
+ 'notify_url' => 'https://' . $_SERVER['HTTP_HOST'] . '/sharenotify', //回调地址
+ "amount" => [
+ "total" => $money * 100,
+ "currency" => "CNY"
+ ],
+ "payer" => [
+ "openid" => $openid //用户openid
+ ]
+ ];
+
+ $timestamp = time();
+ $nonce = date('YmdHis', time()) . rand(1000, 9999);
+ $url = 'https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi';
+ $url_parts = parse_url($url);
+ $canonical_url = ($url_parts['path'] . (!empty($url_parts['query']) ? "?${url_parts['query']}" : ""));
+
+ $data = json_encode($data);
+ $message = 'POST' . "\n" .
+ $canonical_url . "\n" .
+ $timestamp . "\n" .
+ $nonce . "\n" .
+ $data . "\n";
+
+ openssl_sign($message, $signature, $mch_private_key, "sha256WithRSAEncryption");
+ $sign = base64_encode($signature);
+ $schema = 'WECHATPAY2-SHA256-RSA2048';
+ $token = sprintf('mchid="%s",nonce_str="%s",timestamp="%d",serial_no="%s",signature="%s"', $merchantId, $nonce, $timestamp, $merchantSerialNumber, $sign);
+
+ $header = "Authorization: " . $schema . " " . $token;
+
+ $res = $this->http_post($url, $header, $data);
+ $arr = json_decode($res, true);
+
+ $time = time();
+ $str = time() . round('1000', '9999');
+ $prepay = 'prepay_id=' . $arr['prepay_id'];
+
+ $message1 = $appid . "\n" .
+ $time . "\n" .
+ $str . "\n" .
+ $prepay . "\n";
+ $prepay_id = $arr['prepay_id'];
+
+ openssl_sign($message1, $signature, $mch_private_key, "sha256WithRSAEncryption");
+ $sign1 = base64_encode($signature);
+
+ $data = array();
+ $data['appId'] = $appid;
+ $data['timeStamp'] = (string)$time;
+ $data['nonceStr'] = $str;
+ $data['package'] = 'prepay_id=' . $arr['prepay_id'];
+ $data['signType'] = 'RSA';
+
+ $data['paySign'] = $sign1;
+
+ return json($data);
+
+ }
+
+
+ function http_post($url, $header, $data)
+ {
+ $headers[] = "Accept:application/json";
+ $headers[] = "Content-Type:application/json";
+ $headers[] = "User-Agent:application/json";
+ $headers[] = $header;
+
+ $curl = curl_init(); // 启动一个CURL会话
+ curl_setopt($curl, CURLOPT_URL, $url);
+ curl_setopt($curl, CURLOPT_HEADER, 0);
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($curl, CURLOPT_POST, 1);
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
+ curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在
+ curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
+ $tmpInfo = curl_exec($curl);
+ //关闭URL请求
+ curl_close($curl);
+ return $tmpInfo;
+ }
+
+ //支付回调
+ public function sharenotify()
+ {
+
+ try {
+ //code...
+
+ $header = $this->getHeaders(); //读取http头信息 见下文
+ $body = file_get_contents('php://input'); //读取微信传过来的信息,是一个json字符串
+
+ if (empty($header) || empty($body)) {
+ throw new \Exception('通知参数为空', 2001);
+ }
+
+ $timestamp = $header['WECHATPAY-TIMESTAMP'];
+ $nonce = $header['WECHATPAY-NONCE'];
+ $signature = $header['WECHATPAY-SIGNATURE'];
+ $serialNo = $header['WECHATPAY-SERIAL'];
+ if (empty($timestamp) || empty($nonce) || empty($signature) || empty($serialNo)) {
+ throw new \Exception('通知头参数为空', 2002);
+ }
+ $cert = $this->getzhengshuDb(1);
+
+ if ($cert != $serialNo) {
+ throw new \Exception('验签失败', 2005);
+ }
+ $message = "$timestamp\n$nonce\n$body\n";
+
+ //校验签名
+ if (!$this->verify($message, $signature, __DIR__ . config('wx.pingtai_public_key_path'))) {
+ throw new \Exception('验签失败', 2005);
+ }
+
+ $decodeBody = json_decode($body, true);
+ if (empty($decodeBody) || !isset($decodeBody['resource'])) {
+ throw new \Exception('通知参数内容为空', 2003);
+ }
+ $decodeBodyResource = $decodeBody['resource'];
+ $decodeData_res = $this->decryptToString($decodeBodyResource['associated_data'], $decodeBodyResource['nonce'], $decodeBodyResource['ciphertext'], ''); //解密resource
+ $decodeData = json_decode($decodeData_res, true);
+ Log::error('用户充值: ' . $decodeData_res);
+
+ //返回结果格式
+ //array (
+ // 'mchid' => 'xxx',
+ // 'appid' => 'xxxxxxx',
+ // 'out_trade_no' => '1217752501201407033233368026',
+ // 'transaction_id' => '4200001336202201037507057791',
+ // 'trade_type' => 'NATIVE',
+ // 'trade_state' => 'SUCCESS',
+ // 'trade_state_desc' => '支付成功',
+ // 'bank_type' => 'OTHERS',
+ // 'attach' => '',
+ // 'success_time' => '2022-01-03T19:43:05+08:00',
+ // 'payer' =>
+ // array (
+ // 'openid' => 'ovs326bgwfA4o8jlFQXMEma2JZek',
+ // ),
+ // 'amount' =>
+ // array (
+ // 'total' => 1,
+ // 'payer_total' => 1,
+ // 'currency' => 'CNY',
+ // 'payer_currency' => 'CNY',
+ // ),
+ // )
+ //执行自己的代码start
+ $openid = $decodeData['payer']['openid'];
+
+ $data = [
+ 'out_trade_no' => $decodeData['out_trade_no'],
+ 'transaction_id' => $decodeData['transaction_id'],
+ 'trade_state' => $decodeData['trade_state'],
+ 'success_time' => date('Y-m-d H:i:s', time()),
+ 'total' => $decodeData['amount']['total'] / 100,
+ 'payer_total' => $decodeData['amount']['payer_total'] / 100,
+ 'openid' => $openid
+ ];
+
+
+ Db::table('zxc_recharge')->save($data);
+ Db::table('zxc_user')
+ ->where('openid', $openid)
+ ->update([
+ 'account' => Db::raw('account+' . ($decodeData['amount']['total'] / 100))
+ ]);
+ \app\model\User::addMoneyLog($openid, $decodeData['amount']['total'] / 100, 2, '用户充值');
+
+
+ //执行自己的代码end
+
+ exit();
+
+ } catch (\Exception $e) {
+ Log::error($e->getMessage());
+ $arr = array("code" => "ERROR", "message" => $e->getMessage());
+ echo json_encode($arr);
+ }
+ }
+
+ public function getHeaders()
+ {
+ $header = array();
+
+ foreach ($_SERVER as $key => $value) {
+ if ('HTTP_' == substr($key, 0, 5)) {
+ $header[str_replace('_', '-', substr($key, 5))] = $value;
+ }
+ if (isset($_SERVER['PHP_AUTH_DIGEST'])) {
+ $header['AUTHORIZATION'] = $_SERVER['PHP_AUTH_DIGEST'];
+ } elseif (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
+ $header['AUTHORIZATION'] = base64_encode($_SERVER['PHP_AUTH_USER'] . ':' . $_SERVER['PHP_AUTH_PW']);
+ }
+ if (isset($_SERVER['CONTENT_LENGTH'])) {
+ $header['CONTENT-LENGTH'] = $_SERVER['CONTENT_LENGTH'];
+ }
+ if (isset($_SERVER['CONTENT_TYPE'])) {
+ $header['CONTENT-TYPE'] = $_SERVER['CONTENT_TYPE'];
+ }
+ }
+
+ return $header;
+ }
+
+ //获取平台证书序列号
+ public function getzhengshuDb($getNew = 0)
+ {
+ if ($getNew !== 1) {
+ dump(file_get_contents(__DIR__ . config('wx.pingtai_public_key_path')));
+ }
+ $url = "https://api.mch.weixin.qq.com/v3/certificates";
+ $timestamp = time(); //时间戳
+ $nonce = $this->nonce_str(); //获取一个随机数
+ $body = "";
+ $mch_private_key = $this->getPrivateKey(); //读取商户api证书私钥
+ $merchant_id = config('wx.merchantId'); //服务商商户号
+ $serial_no = config('wx.merchantSerialNumber'); //在API安全中获取
+ $sign = $this->sign($url, 'GET', $timestamp, $nonce, $body, $mch_private_key, $merchant_id, $serial_no); //签名
+
+ $header = [
+ 'Authorization:WECHATPAY2-SHA256-RSA2048 ' . $sign,
+ 'Accept:application/json',
+ 'User-Agent:' . $merchant_id
+ ];
+ $result = $this->curl($url, '', $header, 'GET');
+ $result = json_decode($result, true);
+ $serial_no = $result['data'][0]['serial_no'];
+ file_put_contents(__DIR__ . '/../../Secret/serial_no.txt', $serial_no);
+
+ $encrypt_certificate = $result['data'][0]['encrypt_certificate'];
+ $sign_key = config('wx.apiV3key'); //在API安全中设置
+ $result = $this->decryptToString($encrypt_certificate['associated_data'], $encrypt_certificate['nonce'], $encrypt_certificate['ciphertext'], $sign_key); //解密
+
+ file_put_contents(__DIR__ . config('wx.pingtai_public_key_path'), $result);
+
+ return $serial_no;
+ }
+
+ //生成随机字符串
+ public function nonce_str($length = 32)
+ {
+ $chars = "abcdefghijklmnopqrstuvwxyz0123456789";
+ $str = "";
+ for ($i = 0; $i < $length; $i++) {
+ $str .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
+ }
+ return $str;
+ }
+
+ //读取商户api证书私钥
+ public function getPrivateKey()
+ {
+ return openssl_get_privatekey(file_get_contents(__DIR__ . config('wx.apiclientKey'))); //微信商户平台中下载下来,保存到服务器直接读取
+
+ }
+
+ //签名
+ public function sign($url, $http_method, $timestamp, $nonce, $body, $mch_private_key, $merchant_id, $serial_no)
+ {
+ $url_parts = parse_url($url);
+ $canonical_url = ($url_parts['path'] . (!empty($url_parts['query']) ? "?${url_parts['query']}" : ""));
+ $message =
+ $http_method . "\n" .
+ $canonical_url . "\n" .
+ $timestamp . "\n" .
+ $nonce . "\n" .
+ $body . "\n";
+ openssl_sign($message, $raw_sign, $mch_private_key, 'sha256WithRSAEncryption');
+ $sign = base64_encode($raw_sign);
+ $schema = 'WECHATPAY2-SHA256-RSA2048';
+ $token = sprintf(
+ 'mchid="%s",nonce_str="%s",signature="%s",timestamp="%d",serial_no="%s"',
+ $merchant_id,
+ $nonce,
+ $sign,
+ $timestamp,
+ $serial_no
+ );
+ return $token;
+ }
+
+ //curl提交
+ public function curl($url, $data = [], $header, $method = 'POST')
+ {
+ $curl = curl_init();
+ curl_setopt($curl, CURLOPT_URL, $url);
+ curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
+ curl_setopt($curl, CURLOPT_HEADER, false);
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
+ if ($method == "POST") {
+ curl_setopt($curl, CURLOPT_POST, TRUE);
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
+ }
+ $result = curl_exec($curl);
+ curl_close($curl);
+ return $result;
+ }
+
+ private function decryptToString($associatedData, $nonceStr, $ciphertext, $aesKey = '')
+ {
+ if (empty($aesKey)) {
+ $aesKey = config('wx.apiV3key'); //微信商户平台 api安全中设置获取
+ }
+ $ciphertext = \base64_decode($ciphertext);
+ if (strlen($ciphertext) <= self::AUTH_TAG_LENGTH_BYTE) {
+ return false;
+ }
+ // ext-sodium (default installed on >= PHP 7.2)
+ if (
+ function_exists('\sodium_crypto_aead_aes256gcm_is_available') && \sodium_crypto_aead_aes256gcm_is_available()
+ ) {
+ return \sodium_crypto_aead_aes256gcm_decrypt($ciphertext, $associatedData, $nonceStr, $aesKey);
+ }
+
+ // ext-libsodium (need install libsodium-php 1.x via pecl)
+ if (
+ function_exists('\Sodium\crypto_aead_aes256gcm_is_available') && \Sodium\crypto_aead_aes256gcm_is_available()
+ ) {
+ return \Sodium\crypto_aead_aes256gcm_decrypt($ciphertext, $associatedData, $nonceStr, $aesKey);
+ }
+
+ // openssl (PHP >= 7.1 support AEAD)
+ if (PHP_VERSION_ID >= 70100 && in_array('aes-256-gcm', \openssl_get_cipher_methods())) {
+ $ctext = substr($ciphertext, 0, -self::AUTH_TAG_LENGTH_BYTE);
+ $authTag = substr($ciphertext, -self::AUTH_TAG_LENGTH_BYTE);
+
+ return \openssl_decrypt(
+ $ctext,
+ 'aes-256-gcm',
+ $aesKey,
+ \OPENSSL_RAW_DATA,
+ $nonceStr,
+ $authTag,
+ $associatedData
+ );
+ }
+
+ throw new \RuntimeException('AEAD_AES_256_GCM需要PHP 7.1以上或者安装libsodium-php');
+ }
+
+ //签名验证操作
+ private function verify($message, $signature, $merchantPublicKey)
+ {
+ if (!in_array('sha256WithRSAEncryption', \openssl_get_md_methods(true))) {
+ throw new \RuntimeException("当前PHP环境不支持SHA256withRSA");
+ }
+ $signature = base64_decode($signature);
+ $a = openssl_verify($message, $signature, $this->getWxPublicKey($merchantPublicKey), 'sha256WithRSAEncryption');
+ return $a;
+ }
+
+ //获取平台公钥 获取平台证书序列号时存起来的cert.pem文件
+ protected function getWxPublicKey($key)
+ {
+ $public_content = file_get_contents($key);
+ $a = openssl_get_publickey($public_content);
+ return $a;
+ }
+
+ protected function generate_recharge($length)
+ {
+ $chars = '0123456789';
+ $time = time();
+ $password = 'DZZS' . $time . 'RE';
+ for ($i = 0; $i < $length; $i++) {
+ $password .= $chars[mt_rand(0, strlen($chars) - 1)];
+ }
+ return $password;
+ }
+
+// 企业充值
+ public function EnterpriseConfig()
+ {
+ $params = input();
+ // 商户相关配置
+ $merchantId = config('wx.merchantId'); // 商户号
+ $merchantSerialNumber = config('wx.merchantSerialNumber');
+ $filepath = __DIR__ . config('wx.apiclientKey'); //私钥在本地的位置
+ $file = file_get_contents($filepath);
+ $mch_private_key = openssl_get_privatekey($file);
+
+ $appid = config('wx.AppID'); //小程序appid
+ $out_trade_no = $this->generate_recharge(6);
+
+
+ // 创建企业充值订单
+ Db::table('enterprise_recharge')->save([
+ 'user_id' => $params['enterprise_user_id'],
+ 'enterprise_id' => $params['enterprise_id'],
+ 'recharge_no' => $out_trade_no,
+ 'money' => $params['money'],
+ 'create_time' => time()
+ ]);
+
+
+ $data = [
+ "appid" => $appid,
+ "mchid" => $merchantId,
+ "description" => '充值企业余额',
+ 'out_trade_no' => $out_trade_no,
+ 'notify_url' => 'https://' . $_SERVER['HTTP_HOST'] . '/enterpriseChargeNotify', //回调地址
+ "amount" => [
+ "total" => $params['money'] * 100,
+ "currency" => "CNY"
+ ],
+ "payer" => [
+ "openid" => $params['openid'] //用户openid
+ ]
+ ];
+
+ $timestamp = time();
+ $nonce = date('YmdHis', time()) . rand(1000, 9999);
+ $url = 'https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi';
+ $url_parts = parse_url($url);
+ $canonical_url = ($url_parts['path'] . (!empty($url_parts['query']) ? "?${url_parts['query']}" : ""));
+
+ $data = json_encode($data);
+ $message = 'POST' . "\n" .
+ $canonical_url . "\n" .
+ $timestamp . "\n" .
+ $nonce . "\n" .
+ $data . "\n";
+
+ openssl_sign($message, $signature, $mch_private_key, "sha256WithRSAEncryption");
+ $sign = base64_encode($signature);
+ $schema = 'WECHATPAY2-SHA256-RSA2048';
+ $token = sprintf('mchid="%s",nonce_str="%s",timestamp="%d",serial_no="%s",signature="%s"', $merchantId, $nonce, $timestamp, $merchantSerialNumber, $sign);
+
+ $header = "Authorization: " . $schema . " " . $token;
+
+ $res = $this->http_post($url, $header, $data);
+ $arr = json_decode($res, true);
+
+ $time = time();
+ $str = time() . round('1000', '9999');
+ $prepay = 'prepay_id=' . $arr['prepay_id'];
+
+ $message1 = $appid . "\n" .
+ $time . "\n" .
+ $str . "\n" .
+ $prepay . "\n";
+ $prepay_id = $arr['prepay_id'];
+ $key = 'ZuXingZhiYeYouXianGongSi15182231';
+// $paySign = strtoupper(MD5("appId=$appid&nonceStr=$str&package=prepay_id=$prepay_id&signType=MD5&timeStamp=$time&key=$key"));
+ openssl_sign($message1, $signature, $mch_private_key, "sha256WithRSAEncryption");
+ $sign1 = base64_encode($signature);
+
+ $data = array();
+ $data['appId'] = $appid;
+ $data['timeStamp'] = (string)$time;
+ $data['nonceStr'] = $str;
+ $data['package'] = 'prepay_id=' . $arr['prepay_id'];
+ $data['signType'] = 'RSA';
+// $data['signType'] = $arr['prepay_id'];
+ $data['paySign'] = $sign1;
+
+ return json($data);
+
+ }
+// 企业充值回调
+ //支付回调
+ public function enterpriseChargeNotify()
+ {
+
+
+ try {
+ //code...
+
+ $header = $this->getHeaders(); //读取http头信息 见下文
+ $body = file_get_contents('php://input'); //读取微信传过来的信息,是一个json字符串
+
+ if (empty($header) || empty($body)) {
+ throw new \Exception('通知参数为空', 2001);
+ }
+
+ $timestamp = $header['WECHATPAY-TIMESTAMP'];
+ $nonce = $header['WECHATPAY-NONCE'];
+ $signature = $header['WECHATPAY-SIGNATURE'];
+ $serialNo = $header['WECHATPAY-SERIAL'];
+ if (empty($timestamp) || empty($nonce) || empty($signature) || empty($serialNo)) {
+ throw new \Exception('通知头参数为空', 2002);
+ }
+ $cert = $this->getzhengshuDb(1);
+
+ if ($cert != $serialNo) {
+ throw new \Exception('验签失败', 2005);
+ }
+ $message = "$timestamp\n$nonce\n$body\n";
+
+ //校验签名
+ if (!$this->verify($message, $signature, __DIR__ . config('wx.pingtai_public_key_path'))) {
+ throw new \Exception('验签失败', 2005);
+ }
+
+ $decodeBody = json_decode($body, true);
+ if (empty($decodeBody) || !isset($decodeBody['resource'])) {
+ throw new \Exception('通知参数内容为空', 2003);
+ }
+ $decodeBodyResource = $decodeBody['resource'];
+ $decodeData_res = $this->decryptToString($decodeBodyResource['associated_data'], $decodeBodyResource['nonce'], $decodeBodyResource['ciphertext'], ''); //解密resource
+ $decodeData = json_decode($decodeData_res, true);
+ Log::error('企业充值返回数据: ' . $decodeData_res);
+ Db::table('charge_logo')->save(['name' => '企业充值返回数据', 'mark' => $decodeData_res]);
+
+ //返回结果格式
+ //array (
+ // 'mchid' => 'xxx',
+ // 'appid' => 'xxxxxxx',
+ // 'out_trade_no' => '1217752501201407033233368026',
+ // 'transaction_id' => '4200001336202201037507057791',
+ // 'trade_type' => 'NATIVE',
+ // 'trade_state' => 'SUCCESS',
+ // 'trade_state_desc' => '支付成功',
+ // 'bank_type' => 'OTHERS',
+ // 'attach' => '',
+ // 'success_time' => '2022-01-03T19:43:05+08:00',
+ // 'payer' =>
+ // array (
+ // 'openid' => 'ovs326bgwfA4o8jlFQXMEma2JZek',
+ // ),
+ // 'amount' =>
+ // array (
+ // 'total' => 1,
+ // 'payer_total' => 1,
+ // 'currency' => 'CNY',
+ // 'payer_currency' => 'CNY',
+ // ),
+ // )
+ //执行自己的代码start
+ $info = Db::table('enterprise_recharge')->where('recharge_no', $decodeData['out_trade_no'])->where('status', 0)->find();
+ if ($info && $decodeData['trade_state'] == 'SUCCESS') {
+ // 充值成功,修改状态 增加余额
+ Db::table('enterprise_recharge')->where('id', $info['id'])->update(['status' => 1]);
+
+ Db::table('enterprise')->where('id', $info['enterprise_id'])->inc('money', $info['money'])->update();
+
+ \app\model\User::addMoneyLog($decodeData['payer']['openid'], $decodeData['amount']['total']/100, 2, '用户进行企业充值');
+ }
+ echo 'OK';
+ } catch (\Exception $e) {
+ Log::error($e->getMessage());
+ $arr = array("code" => "ERROR", "message" => $e->getMessage());
+ echo json_encode($arr);
+ }
+ }
+
+// 即充即退支付信息
+ public function directlyConfig($out_trade_no, $openid, $money)
+ {
+
+ // 商户相关配置
+ $merchantId = config('wx.merchantId'); // 商户号
+ $merchantSerialNumber = config('wx.merchantSerialNumber');
+ $filepath = __DIR__ . config('wx.apiclientKey'); //私钥在本地的位置
+ $file = file_get_contents($filepath);
+ $mch_private_key = openssl_get_privatekey($file);
+
+ $appid = config('wx.AppID'); //小程序appid
+
+ $data = [
+ "appid" => $appid,
+ "mchid" => $merchantId,
+ "description" => '即充即退',
+ 'out_trade_no' => $out_trade_no,
+ 'notify_url' => 'https://' . $_SERVER['HTTP_HOST'] . '/directlychargenotify', //回调地址
+ "amount" => [
+ "total" => $money * 100,
+ "currency" => "CNY"
+ ],
+ "payer" => [
+ "openid" => $openid //用户openid
+ ]
+ ];
+
+ $timestamp = time();
+ $nonce = date('YmdHis', time()) . rand(1000, 9999);
+ $url = 'https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi';
+ $url_parts = parse_url($url);
+ $canonical_url = ($url_parts['path'] . (!empty($url_parts['query']) ? "?${url_parts['query']}" : ""));
+
+ $data = json_encode($data);
+ $message = 'POST' . "\n" .
+ $canonical_url . "\n" .
+ $timestamp . "\n" .
+ $nonce . "\n" .
+ $data . "\n";
+
+ openssl_sign($message, $signature, $mch_private_key, "sha256WithRSAEncryption");
+ $sign = base64_encode($signature);
+ $schema = 'WECHATPAY2-SHA256-RSA2048';
+ $token = sprintf('mchid="%s",nonce_str="%s",timestamp="%d",serial_no="%s",signature="%s"', $merchantId, $nonce, $timestamp, $merchantSerialNumber, $sign);
+
+ $header = "Authorization: " . $schema . " " . $token;
+
+ $res = $this->http_post($url, $header, $data);
+ $arr = json_decode($res, true);
+
+ $time = time();
+ $str = time() . round('1000', '9999');
+ $prepay = 'prepay_id=' . $arr['prepay_id'];
+
+ $message1 = $appid . "\n" .
+ $time . "\n" .
+ $str . "\n" .
+ $prepay . "\n";
+ $prepay_id = $arr['prepay_id'];
+
+ openssl_sign($message1, $signature, $mch_private_key, "sha256WithRSAEncryption");
+ $sign1 = base64_encode($signature);
+
+ $data = array();
+ $data['appId'] = $appid;
+ $data['timeStamp'] = (string)$time;
+ $data['nonceStr'] = $str;
+ $data['package'] = 'prepay_id=' . $arr['prepay_id'];
+ $data['signType'] = 'RSA';
+
+ $data['paySign'] = $sign1;
+ $data['out_trade_no'] = $out_trade_no;
+ $data['openid'] = $openid;
+ return $data;
+ return json($data);
+ }
+
+ public function directlychargenotify()
+ {
+
+
+ try {
+ //code...
+
+ $header = $this->getHeaders(); //读取http头信息 见下文
+ $body = file_get_contents('php://input'); //读取微信传过来的信息,是一个json字符串
+
+
+ if (empty($header) || empty($body)) {
+ throw new \Exception('通知参数为空', 2001);
+ }
+
+ $timestamp = $header['WECHATPAY-TIMESTAMP'];
+ $nonce = $header['WECHATPAY-NONCE'];
+ $signature = $header['WECHATPAY-SIGNATURE'];
+ $serialNo = $header['WECHATPAY-SERIAL'];
+
+ if (empty($timestamp) || empty($nonce) || empty($signature) || empty($serialNo)) {
+ throw new \Exception('通知头参数为空', 2002);
+ }
+ $cert = $this->getzhengshuDb(1);
+
+ if ($cert != $serialNo) {
+ throw new \Exception('验签失败', 2005);
+ }
+ $message = "$timestamp\n$nonce\n$body\n";
+
+ //校验签名
+ if (!$this->verify($message, $signature, __DIR__ . config('wx.pingtai_public_key_path'))) {
+ throw new \Exception('验签失败', 2005);
+ }
+
+ $decodeBody = json_decode($body, true);
+ if (empty($decodeBody) || !isset($decodeBody['resource'])) {
+ throw new \Exception('通知参数内容为空', 2003);
+ }
+
+
+ $decodeBodyResource = $decodeBody['resource'];
+
+
+ $decodeData_res = $this->decryptToString($decodeBodyResource['associated_data'], $decodeBodyResource['nonce'], $decodeBodyResource['ciphertext'], ''); //解密resource
+
+
+ $decodeData = json_decode($decodeData_res, true);
+ Log::error('即充即退充值返回数据: ' . $decodeData_res);
+ Db::table('charge_logo')->save(['name' => '即充即退返回数据', 'mark' => $decodeData_res]);
+
+ //返回结果格式
+ //array (
+ // 'mchid' => 'xxx',
+ // 'appid' => 'xxxxxxx',
+ // 'out_trade_no' => '1217752501201407033233368026',
+ // 'transaction_id' => '4200001336202201037507057791',
+ // 'trade_type' => 'NATIVE',
+ // 'trade_state' => 'SUCCESS',
+ // 'trade_state_desc' => '支付成功',
+ // 'bank_type' => 'OTHERS',
+ // 'attach' => '',
+ // 'success_time' => '2022-01-03T19:43:05+08:00',
+ // 'payer' =>
+ // array (
+ // 'openid' => 'ovs326bgwfA4o8jlFQXMEma2JZek',
+ // ),
+ // 'amount' =>
+ // array (
+ // 'total' => 1,
+ // 'payer_total' => 1,
+ // 'currency' => 'CNY',
+ // 'payer_currency' => 'CNY',
+ // ),
+ // )
+ //执行自己的代码start
+
+
+ if ($decodeData['trade_state'] == 'SUCCESS') {
+ $account = $decodeData['amount']['total'] / 100;
+ $time = time();
+ Db::table('zxc_charge_order')->save([
+ 'type' => 1,
+ 'openid' => $decodeData['payer']['openid'],
+ 'directly_pay_no' => $decodeData['out_trade_no'],
+ 'directly_pay_status' => 1,
+ 'directly_pay_time' => $time,
+ 'directly_prepaid_amount' => $account,
+ 'WithholdingMoney' => $account,
+ 'start_time' => date('Y-m-d H:i:s', $time),
+ ]);
+ Db::table('zxc_recharge')->save([
+ 'type' => 2,
+ 'openid' => $decodeData['payer']['openid'],
+ 'out_trade_no' => $decodeData['out_trade_no'],
+ 'transaction_id' => $decodeData['transaction_id'],
+ 'trade_state' => $decodeData['trade_state'],
+ 'total' => $account,
+ 'payer_total' => $account,
+ 'success_time' => date('Y-m-d H:i:s', $time),
+ ]);
+
+ \app\model\User::addMoneyLog($decodeData['payer']['openid'], $decodeData['amount']['total'] / 100, 2, '用户使用即充即退-充值');
+
+ }
+
+
+ echo 'OK';
+ } catch (\Exception $e) {
+ Log::error($e->getMessage());
+ $arr = array("code" => "ERROR", "message" => $e->getMessage());
+ echo json_encode($arr);
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/app/controller/WechatRefund.php b/app/controller/WechatRefund.php
new file mode 100644
index 0000000..2477d90
--- /dev/null
+++ b/app/controller/WechatRefund.php
@@ -0,0 +1,104 @@
+ $out_trade_no,
+ 'transfer_amount'=>$pars['total_amount'],
+ 'transfer_remark'=>$batch_name,
+ 'openid'=>$openid
+ ];//转账明细列表
+ $token = $this->getToken($pars);//获取token
+ $res = $this->https_request($url,json_encode($pars),$token);//发送请求
+ $resArr = json_decode($res,true);
+ return $resArr;
+ //成功返回
+ // array(3) {
+ // ["batch_id"] => string(40) "1030001016101247194272022062900873000000"
+ // ["create_time"] => string(25) "2022-06-29T10:21:30+08:00"
+ // ["out_batch_no"] => string(16) "sjzz202206291647001"
+ // }
+ }
+ function https_request($url,$data = null,$token){
+ $curl = curl_init();
+ curl_setopt($curl, CURLOPT_URL, (string)$url);
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
+ curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
+ if (!empty($data)){
+ curl_setopt($curl, CURLOPT_POST, 1);
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
+ }
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
+ //添加请求头
+ $headers = [
+ 'Authorization:WECHATPAY2-SHA256-RSA2048 '.$token,
+ 'Accept: application/json',
+ 'Content-Type: application/json; charset=utf-8',
+ 'User-Agent:Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36',
+ ];
+ if(!empty($headers)){
+ curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
+ }
+ $output = curl_exec($curl);
+ curl_close($curl);
+ return $output;
+ }
+ public function getToken($pars)
+ {
+ // $url = 'https://api.mch.weixin.qq.com/v3/certificates';
+ $url = 'https://api.mch.weixin.qq.com/v3/transfer/batches';
+ $http_method = 'POST';//请求方法(GET,POST,PUT)
+ $timestamp = time();//请求时间戳
+ $url_parts = parse_url($url);//获取请求的绝对URL
+ $nonce = $timestamp.rand('10000','99999');//请求随机串
+ $body = json_encode((object)$pars);//请求报文主体
+ $stream_opts = [
+ "ssl" => [
+ "verify_peer"=>false,
+ "verify_peer_name"=>false,
+ ]
+ ];
+
+ $apiclient_cert_path = 'D:\wamp64\www\ChargePile\Secret\apiclient_cert_refund.pem';
+ $apiclient_key_path = 'D:\wamp64\www\ChargePile\Secret\apiclient_key_refund.pem';
+
+ $apiclient_cert_arr = openssl_x509_parse(file_get_contents($apiclient_cert_path,false, stream_context_create($stream_opts)));
+ $serial_no = $apiclient_cert_arr['serialNumberHex'];//证书序列号
+ $mch_private_key = file_get_contents($apiclient_key_path,false, stream_context_create($stream_opts));//密钥
+ $merchant_id = '1635719083';//商户id
+ $canonical_url = ($url_parts['path'] . (!empty($url_parts['query']) ? "?${url_parts['query']}" : ""));
+ $message = $http_method."\n".
+ $canonical_url."\n".
+ $timestamp."\n".
+ $nonce."\n".
+ $body."\n";
+ openssl_sign($message, $raw_sign, $mch_private_key, 'sha256WithRSAEncryption');
+ $sign = base64_encode($raw_sign);//签名
+ $schema = 'WECHATPAY2-SHA256-RSA2048';
+ $token = sprintf('mchid="%s",nonce_str="%s",timestamp="%d",serial_no="%s",signature="%s"',
+ $merchant_id, $nonce, $timestamp, $serial_no, $sign);//微信返回token
+ return $token;
+ }
+
+
+}
\ No newline at end of file
diff --git a/app/controller/WechatReimburse.php b/app/controller/WechatReimburse.php
new file mode 100644
index 0000000..7f61789
--- /dev/null
+++ b/app/controller/WechatReimburse.php
@@ -0,0 +1,615 @@
+generate_tuikuan(6);
+ $refundData = [
+ 'transaction_id' => $transaction_id,
+ 'out_refund_no' => $out_refund_no,
+ 'reason' => '余额退款',
+ 'notify_url' => 'https://' . $_SERVER['HTTP_HOST'] . '/refund_notify',
+ 'funds_account' => 'AVAILABLE',
+ 'amount' => [
+ 'refund' => floor($refundAmount * 100), //退款标价金额,单位为分,可以做部分退款
+ 'total' => $OriginalOrderAmount * 100, //订单总金额,单位为分
+ 'currency' => 'CNY'
+ ]
+ ];
+// if(!$transaction_id){ //商户订单号,微信生成的退款订单号 二选一即可
+// if(!$out_trade_no){
+// return ['code'=>0,'msg'=>'退款订单号不能为空'];
+// }else{
+// $refundData['out_trade_no']=$out_trade_no;
+// }
+// }else{
+// $refundData['transaction_id']=$transaction_id;
+// }
+ $url = 'https://api.mch.weixin.qq.com/v3/refund/domestic/refunds';
+ $url_parts = parse_url($url); //拆解为:[scheme=>https,host=>api.mch.weixin.qq.com,path=>/v3/pay/transactions/native]
+ $mchid = config('wx.merchantId');//商户ID
+ $xlid = config('wx.merchantSerialNumber');//证书序列号
+ $refundData = json_encode($refundData);
+ $nonce = date('YmdHis', time()) . rand(1000, 9999);
+ $canonical_url = ($url_parts['path'] . (!empty($url_parts['query']) ? "?${url_parts['query']}" : ""));
+// $key = $this->getSign($refundData,$urlarr['path'],$nonce,$time);
+ $message = 'POST' . "\n" .
+ $canonical_url . "\n" .
+ $time . "\n" .
+ $nonce . "\n" .
+ $refundData . "\n";
+ openssl_sign($message, $signature, $mch_private_key, "sha256WithRSAEncryption");
+ $sign = base64_encode($signature);
+ $schema = 'WECHATPAY2-SHA256-RSA2048';
+ $token = sprintf('mchid="%s",serial_no="%s",nonce_str="%s",timestamp="%d",signature="%s"', $mchid, $xlid, $nonce, $time, $sign);
+ $header = "Authorization: " . $schema . " " . $token;
+// $header = array(
+// 'Accept: application/json',
+// 'Content-Type: application/json',
+// 'User-Agent:*/*',
+// 'Authorization: WECHATPAY2-SHA256-RSA2048 '.$token
+// );
+ $res = $this->http_post($url, $header, $refundData);
+ Db::table('charge_logo')->save(['name' => '余额提现', 'mark' => $res]);
+ $res_array = json_decode($res, true);
+// dd($res_array);
+ if (isset($res_array['status']) && ($res_array['status'] == 'PROCESSING' || $res_array['status'] == 'SUCCESS')) {
+
+ $kk['openid'] = $openid;
+ $create_time = $res_array['create_time'];
+ $create_time = str_replace('T', ' ', $create_time);
+ $create_time = substr($create_time, 0, -6);
+
+ $kk = [
+ 'openid' => $openid,
+ 'create_time' => $create_time,
+ 'out_trade_no' => $res_array['out_trade_no'],
+ 'out_refund_no' => $res_array['out_refund_no'],
+ 'refund_id' => $res_array['refund_id'],
+ 'status' => $res_array['status'],
+ 'transaction_id' => $res_array['transaction_id'],
+ 'user_received_account' => $res_array['user_received_account'],
+ 'refund_total' => $res_array['amount']['refund'],
+ ];
+ $table = 'zxc_refund';
+ $table_recharge = 'zxc_recharge';
+
+
+ $table_user = 'zxc_user';
+ Db::transaction(function () use ($table_recharge, $res_array, $openid, $table_user, $kk, $table) {
+ Db::table($table)->save($kk);
+ Db::table($table_user)->where('openid', $openid)
+ ->update([
+ 'account' => Db::raw('account-' . ($res_array['amount']['refund'] / 100)),
+ ]);
+
+
+ Db::table($table_recharge)->where('out_trade_no', $res_array['out_trade_no'])->update(['total_used' => Db::raw('total_used+' . ($res_array['amount']['refund']))]);
+ });
+
+ return ['code' => 200, 'msg' => '退款受理成功'];
+ } else {
+ return ['code' => 1, 'msg' => $res_array['message']];
+ }
+ }
+
+ //退款回调地址
+ public function refund_notify()
+ {
+ try {
+ //code...
+
+ $header = $this->getHeaders(); //读取http头信息 见下文
+ $body = file_get_contents('php://input'); //读取微信传过来的信息,是一个json字符串
+
+ if (empty($header) || empty($body)) {
+ throw new \Exception('通知参数为空', 2001);
+ }
+
+ $timestamp = $header['WECHATPAY-TIMESTAMP'];
+ $nonce = $header['WECHATPAY-NONCE'];
+ $signature = $header['WECHATPAY-SIGNATURE'];
+ $serialNo = $header['WECHATPAY-SERIAL'];
+ if (empty($timestamp) || empty($nonce) || empty($signature) || empty($serialNo)) {
+ throw new \Exception('通知头参数为空', 2002);
+ }
+ $cert = $this->getzhengshuDb(1);
+
+ if ($cert != $serialNo) {
+ throw new \Exception('验签失败', 2005);
+ }
+ $message = "$timestamp\n$nonce\n$body\n";
+
+ //校验签名
+ if (!$this->verify($message, $signature, __DIR__ . config('wx.pingtai_public_key_path'))) {
+ throw new \Exception('验签失败', 2005);
+ }
+
+ $decodeBody = json_decode($body, true);
+ if (empty($decodeBody) || !isset($decodeBody['resource'])) {
+ throw new \Exception('通知参数内容为空', 2003);
+ }
+ $decodeBodyResource = $decodeBody['resource'];
+ $decodeData_res = $this->decryptToString($decodeBodyResource['associated_data'], $decodeBodyResource['nonce'], $decodeBodyResource['ciphertext'], ''); //解密resource
+ $decodeData = json_decode($decodeData_res, true);
+ Db::table('charge_logo')->save(['name' => '余额提现回调', 'mark' => $decodeData]);
+ Log::error('余额提现: ' . $decodeData);
+ //返回结果格式
+ //array (
+ // 'mchid' => 'xxx',
+ // 'appid' => 'xxxxxxx',
+ // 'out_trade_no' => '1217752501201407033233368026',
+ // 'transaction_id' => '4200001336202201037507057791',
+ // 'trade_type' => 'NATIVE',
+ // 'trade_state' => 'SUCCESS',
+ // 'trade_state_desc' => '支付成功',
+ // 'bank_type' => 'OTHERS',
+ // 'attach' => '',
+ // 'success_time' => '2022-01-03T19:43:05+08:00',
+ // 'payer' =>
+ // array (
+ // 'openid' => 'ovs326bgwfA4o8jlFQXMEma2JZek',
+ // ),
+ // 'amount' =>
+ // array (
+ // 'total' => 1,
+ // 'payer_total' => 1,
+ // 'currency' => 'CNY',
+ // 'payer_currency' => 'CNY',
+ // ),
+ // )
+ //执行自己的代码start
+ $out_refund_no = $decodeData['out_refund_no'];
+ $openid = Db::table('zxc_refund')->where('out_refund_no', $out_refund_no)->value('openid');
+
+ $table = 'zxc_refund';
+ $table_user = 'zxc_user';
+ $kk['status'] = $decodeData['refund_status'];
+ if ($decodeData['refund_status'] == 'SUCCESS') {
+ $success_time = $decodeData['success_time'];
+ $success_time = str_replace('T', ' ', $success_time);
+ $success_time = substr($success_time, 0, -6);
+ $kk['success_time'] = $success_time;
+ Db::table($table_user)->where('openid', $openid)->update(['FrozenAccount' => Db::raw('FrozenAccount-' . ($decodeData['amount']['refund'] / 100))]);
+ }
+ Db::table($table)->where('out_refund_no', $out_refund_no)->save($kk);
+
+
+ \app\model\User::addMoneyLog($openid, $decodeData['amount']['refund'], 3, '用户提现');
+
+// $order_info = Db::table($table)->save($data);
+// Db::table($table_user)->where('openid',$openid)->update(['account' => Db::raw('account+'.($total/100))]);
+ //执行自己的代码end
+
+ $arr = array("code" => "SUCCESS", "message" => "");
+ echo json_encode($arr);
+
+ } catch (\Exception $e) {
+ Log::error($e->getMessage());
+ $arr = array("code" => "ERROR", "message" => $e->getMessage());
+ echo json_encode($arr);
+ }
+
+
+// $notifiedData = file_get_contents('php://input');
+// $data = json_decode($notifiedData, true);
+// $nonceStr = $data['resource']['nonce'];
+// $associatedData = $data['resource']['associated_data'];
+// $ciphertext = $data['resource']['ciphertext'];
+// $ciphertext = base64_decode($ciphertext);
+// //php>7.1,为了使用这个扩展,你必须将extension=php_sodium.dll添加到php.ini
+// if (function_exists('\sodium_crypto_aead_aes256gcm_is_available') && \sodium_crypto_aead_aes256gcm_is_available()) {
+// //$APIv3_KEY就是在商户平台后端设置是APIv3秘钥
+// $orderData = \sodium_crypto_aead_aes256gcm_decrypt($ciphertext, $associatedData, $nonceStr, $this->config['apiv3_private_key']);
+// $orderData = json_decode($orderData, true);
+// if ($orderData['refund_status']=='SUCCESS'){
+// $transaction_id=$orderData['transaction_id']; //退款单号
+//
+// /*业务处理*/
+// return json(['code'=>'SUCCESS','message'=>'成功']);
+// }
+// }
+ }
+
+
+ // 预充电余额退款
+ public function Refund2($charge_id, $openid, $refundAmount, $OriginalOrderAmount, $out_trade_no)
+ { //商户订单号,微信生成的退款订单号 二选一即可
+ $file = file_get_contents(__DIR__ . config('wx.apiclientKey'));
+ $mch_private_key = openssl_get_privatekey($file);
+
+ $time = time();
+ $out_refund_no = $this->generate_tuikuan(6);
+ $refundData = [
+ 'out_trade_no' => $out_trade_no,
+ 'out_refund_no' => $out_refund_no,
+ 'reason' => '预充电余额退款',
+ 'notify_url' => 'https://' . $_SERVER['HTTP_HOST'] . '/refund_notify2',
+ 'funds_account' => 'AVAILABLE',
+ 'amount' => [
+ 'refund' => floor($refundAmount * 100), //退款标价金额,单位为分,可以做部分退款
+ 'total' => $OriginalOrderAmount * 100, //订单总金额,单位为分
+ 'currency' => 'CNY'
+ ]
+ ];
+
+ $url = 'https://api.mch.weixin.qq.com/v3/refund/domestic/refunds';
+ $url_parts = parse_url($url); //拆解为:[scheme=>https,host=>api.mch.weixin.qq.com,path=>/v3/pay/transactions/native]
+ $mchid = config('wx.merchantId');//商户ID
+ $xlid = config('wx.merchantSerialNumber');//证书序列号
+ $refundData = json_encode($refundData);
+ $nonce = date('YmdHis', time()) . rand(1000, 9999);
+ $canonical_url = ($url_parts['path'] . (!empty($url_parts['query']) ? "?${url_parts['query']}" : ""));
+// $key = $this->getSign($refundData,$urlarr['path'],$nonce,$time);
+ $message = 'POST' . "\n" .
+ $canonical_url . "\n" .
+ $time . "\n" .
+ $nonce . "\n" .
+ $refundData . "\n";
+ openssl_sign($message, $signature, $mch_private_key, "sha256WithRSAEncryption");
+ $sign = base64_encode($signature);
+ $schema = 'WECHATPAY2-SHA256-RSA2048';
+ $token = sprintf('mchid="%s",serial_no="%s",nonce_str="%s",timestamp="%d",signature="%s"', $mchid, $xlid, $nonce, $time, $sign);
+ $header = "Authorization: " . $schema . " " . $token;
+
+ $res = $this->http_post($url, $header, $refundData);
+ $res_array = json_decode($res, true);
+
+
+ if (isset($res_array['status']) && ($res_array['status'] == 'PROCESSING' || $res_array['status'] == 'SUCCESS')) {
+
+ $info = Db::table('zxc_charge_order')
+ ->where('order_id', $charge_id)->where('is_wind', 0)->find();
+ if ($info) {
+ Db::table('zxc_charge_order')
+ ->where('order_id', $charge_id)
+ ->update([
+ 'directly_refund_no' => $out_refund_no,
+ 'directly_refund_status' => 1,
+ 'directly_refund_amount' => $res_array['amount']['refund'],
+ 'directly_refund_time' => time(),
+ 'is_wind' => 1
+ ]);
+
+
+ $create_time = $res_array['create_time'];
+ $create_time = str_replace('T', ' ', $create_time);
+ $create_time = substr($create_time, 0, -6);
+ Db::table('zxc_refund')
+ ->save([
+ 'openid' => $openid,
+ 'create_time' => $create_time,
+ 'out_trade_no' => $res_array['out_trade_no'],
+ 'out_refund_no' => $res_array['out_refund_no'],
+ 'refund_id' => $res_array['refund_id'],
+ 'status' => $res_array['status'],
+ 'transaction_id' => $res_array['transaction_id'],
+ 'user_received_account' => $res_array['user_received_account'],
+ 'refund_total' => $res_array['amount']['refund'],
+ ]);
+
+
+ \app\model\User::addMoneyLog($openid, $res_array['amount']['refund']/100, 3, '用户使用即充即退-退款');
+ }
+
+ return ['code' => 200, 'msg' => '退款受理成功'];
+ } else {
+ return ['code' => 1, 'msg' => $res_array['message']];
+ }
+ }
+
+ //退款回调地址
+ public function refund_notify2()
+ {
+ try {
+ //code...
+
+ $header = $this->getHeaders(); //读取http头信息 见下文
+ $body = file_get_contents('php://input'); //读取微信传过来的信息,是一个json字符串
+
+ if (empty($header) || empty($body)) {
+ throw new \Exception('通知参数为空', 2001);
+ }
+
+ $timestamp = $header['WECHATPAY-TIMESTAMP'];
+ $nonce = $header['WECHATPAY-NONCE'];
+ $signature = $header['WECHATPAY-SIGNATURE'];
+ $serialNo = $header['WECHATPAY-SERIAL'];
+ if (empty($timestamp) || empty($nonce) || empty($signature) || empty($serialNo)) {
+ throw new \Exception('通知头参数为空', 2002);
+ }
+ $cert = $this->getzhengshuDb(1);
+
+ if ($cert != $serialNo) {
+ throw new \Exception('验签失败', 2005);
+ }
+ $message = "$timestamp\n$nonce\n$body\n";
+
+ //校验签名
+ if (!$this->verify($message, $signature, __DIR__ . config('wx.pingtai_public_key_path'))) { //$this->pingtai_public_key_path是获取平台证书序列号$this->getzhengshuDb()时保存下来的平台公钥文件
+ throw new \Exception('验签失败', 2005);
+ }
+
+ $decodeBody = json_decode($body, true);
+ if (empty($decodeBody) || !isset($decodeBody['resource'])) {
+ throw new \Exception('通知参数内容为空', 2003);
+ }
+ $decodeBodyResource = $decodeBody['resource'];
+ $decodeData_res = $this->decryptToString($decodeBodyResource['associated_data'], $decodeBodyResource['nonce'], $decodeBodyResource['ciphertext'], ''); //解密resource
+ $decodeData = json_decode($decodeData_res, true);
+ Log::error('用户使用即充即退退款: ' . $decodeData_res);
+ //返回结果格式
+ //array (
+ // 'mchid' => 'xxx',
+ // 'appid' => 'xxxxxxx',
+ // 'out_trade_no' => '1217752501201407033233368026',
+ // 'transaction_id' => '4200001336202201037507057791',
+ // 'trade_type' => 'NATIVE',
+ // 'trade_state' => 'SUCCESS',
+ // 'trade_state_desc' => '支付成功',
+ // 'bank_type' => 'OTHERS',
+ // 'attach' => '',
+ // 'success_time' => '2022-01-03T19:43:05+08:00',
+ // 'payer' =>
+ // array (
+ // 'openid' => 'ovs326bgwfA4o8jlFQXMEma2JZek',
+ // ),
+ // 'amount' =>
+ // array (
+ // 'total' => 1,
+ // 'payer_total' => 1,
+ // 'currency' => 'CNY',
+ // 'payer_currency' => 'CNY',
+ // ),
+ // )
+ //执行自己的代码start
+ $out_refund_no = $decodeData['out_refund_no'];
+
+
+
+
+ $arr = array("code" => "SUCCESS", "message" => "");
+ echo json_encode($arr);
+
+ } catch (\Exception $e) {
+ Log::error($e->getMessage());
+ $arr = array("code" => "ERROR", "message" => $e->getMessage());
+ echo json_encode($arr);
+ }
+
+ }
+
+
+ private function verify($message, $signature, $merchantPublicKey)
+ {
+ if (!in_array('sha256WithRSAEncryption', \openssl_get_md_methods(true))) {
+ throw new \RuntimeException("当前PHP环境不支持SHA256withRSA");
+ }
+ $signature = base64_decode($signature);
+ $a = openssl_verify($message, $signature, $this->getWxPublicKey($merchantPublicKey), 'sha256WithRSAEncryption');
+ return $a;
+ }
+
+ public function getNonceStr()
+ {
+ $strs = "QWERTYUIOPASDFGHJKLZXCVBNM1234567890";
+ $name = substr(str_shuffle($strs), mt_rand(0, strlen($strs) - 11), 32);
+ return $name;
+ }
+
+ private function getzhengshuDb($getNew = 0)
+ {
+ if ($getNew !== 1) {
+ dump(file_get_contents(__DIR__ . config('wx.pingtai_public_key_path')));
+ }
+ $url = "https://api.mch.weixin.qq.com/v3/certificates";
+ $timestamp = time(); //时间戳
+ $nonce = $this->nonce_str(); //获取一个随机数
+ $body = "";
+ $mch_private_key = $this->getPrivateKey(); //读取商户api证书私钥
+ $merchant_id = config('wx.merchantId'); //服务商商户号
+ $serial_no = config('wx.merchantSerialNumber'); //在API安全中获取
+ $sign = $this->sign($url, 'GET', $timestamp, $nonce, $body, $mch_private_key, $merchant_id, $serial_no); //签名
+
+ $header = [
+ 'Authorization:WECHATPAY2-SHA256-RSA2048 ' . $sign,
+ 'Accept:application/json',
+ 'User-Agent:' . $merchant_id
+ ];
+ $result = $this->curl($url, '', $header, 'GET');
+ $result = json_decode($result, true);
+ $serial_no = $result['data'][0]['serial_no'];
+ file_put_contents(__DIR__ . '/../../Secret/tuikuan/serial_no.txt', $serial_no);
+
+
+ $encrypt_certificate = $result['data'][0]['encrypt_certificate'];
+ $sign_key = config('wx.apiV3key'); //在API安全中设置
+ $result = $this->decryptToString($encrypt_certificate['associated_data'], $encrypt_certificate['nonce'], $encrypt_certificate['ciphertext'], $sign_key); //解密
+
+ file_put_contents(__DIR__ . config('wx.pingtai_public_key_path'), $result);
+
+ return $serial_no;
+ }
+
+ private function getHeaders()
+ {
+ $header = array();
+ foreach ($_SERVER as $key => $value) {
+ if ('HTTP_' == substr($key, 0, 5)) {
+ $header[str_replace('_', '-', substr($key, 5))] = $value;
+ }
+ if (isset($_SERVER['PHP_AUTH_DIGEST'])) {
+ $header['AUTHORIZATION'] = $_SERVER['PHP_AUTH_DIGEST'];
+ } elseif (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
+ $header['AUTHORIZATION'] = base64_encode($_SERVER['PHP_AUTH_USER'] . ':' . $_SERVER['PHP_AUTH_PW']);
+ }
+ if (isset($_SERVER['CONTENT_LENGTH'])) {
+ $header['CONTENT-LENGTH'] = $_SERVER['CONTENT_LENGTH'];
+ }
+ if (isset($_SERVER['CONTENT_TYPE'])) {
+ $header['CONTENT-TYPE'] = $_SERVER['CONTENT_TYPE'];
+ }
+ }
+ return $header;
+ }
+
+ private function decryptToString($associatedData, $nonceStr, $ciphertext, $aesKey = '')
+ {
+ if (empty($aesKey)) {
+ $aesKey = config('wx.apiV3key'); //微信商户平台 api安全中设置获取
+ }
+ $ciphertext = \base64_decode($ciphertext);
+ if (strlen($ciphertext) <= self::AUTH_TAG_LENGTH_BYTE) {
+ return false;
+ }
+ // ext-sodium (default installed on >= PHP 7.2)
+ if (
+ function_exists('\sodium_crypto_aead_aes256gcm_is_available') && \sodium_crypto_aead_aes256gcm_is_available()
+ ) {
+ return \sodium_crypto_aead_aes256gcm_decrypt($ciphertext, $associatedData, $nonceStr, $aesKey);
+ }
+
+ // ext-libsodium (need install libsodium-php 1.x via pecl)
+ if (
+ function_exists('\Sodium\crypto_aead_aes256gcm_is_available') && \Sodium\crypto_aead_aes256gcm_is_available()
+ ) {
+ return \Sodium\crypto_aead_aes256gcm_decrypt($ciphertext, $associatedData, $nonceStr, $aesKey);
+ }
+
+ // openssl (PHP >= 7.1 support AEAD)
+ if (PHP_VERSION_ID >= 70100 && in_array('aes-256-gcm', \openssl_get_cipher_methods())) {
+ $ctext = substr($ciphertext, 0, -self::AUTH_TAG_LENGTH_BYTE);
+ $authTag = substr($ciphertext, -self::AUTH_TAG_LENGTH_BYTE);
+
+ return \openssl_decrypt(
+ $ctext,
+ 'aes-256-gcm',
+ $aesKey,
+ \OPENSSL_RAW_DATA,
+ $nonceStr,
+ $authTag,
+ $associatedData
+ );
+ }
+
+ throw new \RuntimeException('AEAD_AES_256_GCM需要PHP 7.1以上或者安装libsodium-php');
+ }
+
+ private function http_post($url, $header, $data)
+ {
+ $headers[] = "Accept:application/json";
+ $headers[] = "Content-Type:application/json";
+ $headers[] = "User-Agent:application/json";
+ $headers[] = $header;
+
+ $curl = curl_init(); // 启动一个CURL会话
+ curl_setopt($curl, CURLOPT_URL, $url);
+ curl_setopt($curl, CURLOPT_HEADER, 0);
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($curl, CURLOPT_POST, 1);
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
+ curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在
+ curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
+ $tmpInfo = curl_exec($curl);
+ //关闭URL请求
+ curl_close($curl);
+ return $tmpInfo;
+ }
+
+ //生成随机字符串
+ public function nonce_str($length = 32)
+ {
+ $chars = "abcdefghijklmnopqrstuvwxyz0123456789";
+ $str = "";
+ for ($i = 0; $i < $length; $i++) {
+ $str .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
+ }
+ return $str;
+ }
+
+ //读取商户api证书私钥
+ public function getPrivateKey()
+ {
+ return openssl_get_privatekey(file_get_contents(__DIR__ . config('wx.apiclientKey'))); //微信商户平台中下载下来,保存到服务器直接读取
+
+ }
+
+ //签名
+ public function sign($url, $http_method, $timestamp, $nonce, $body, $mch_private_key, $merchant_id, $serial_no)
+ {
+ $url_parts = parse_url($url);
+ $canonical_url = ($url_parts['path'] . (!empty($url_parts['query']) ? "?${url_parts['query']}" : ""));
+ $message =
+ $http_method . "\n" .
+ $canonical_url . "\n" .
+ $timestamp . "\n" .
+ $nonce . "\n" .
+ $body . "\n";
+ openssl_sign($message, $raw_sign, $mch_private_key, 'sha256WithRSAEncryption');
+ $sign = base64_encode($raw_sign);
+ $schema = 'WECHATPAY2-SHA256-RSA2048';
+ $token = sprintf(
+ 'mchid="%s",nonce_str="%s",signature="%s",timestamp="%d",serial_no="%s"',
+ $merchant_id,
+ $nonce,
+ $sign,
+ $timestamp,
+ $serial_no
+ );
+ return $token;
+ }
+
+ //curl提交
+ public function curl($url, $data = [], $header, $method = 'POST')
+ {
+ $curl = curl_init();
+ curl_setopt($curl, CURLOPT_URL, $url);
+ curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
+ curl_setopt($curl, CURLOPT_HEADER, false);
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
+ if ($method == "POST") {
+ curl_setopt($curl, CURLOPT_POST, TRUE);
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
+ }
+ $result = curl_exec($curl);
+ curl_close($curl);
+ return $result;
+ }
+
+ protected function generate_tuikuan($length)
+ {
+ $chars = '0123456789';
+ $time = time();
+ $password = 'DZZS' . $time . 'TK';
+ for ($i = 0; $i < $length; $i++) {
+ $password .= $chars[mt_rand(0, strlen($chars) - 1)];
+ }
+ return $password;
+ }
+
+ protected function getWxPublicKey($key)
+ {
+ $public_content = file_get_contents($key);
+ $a = openssl_get_publickey($public_content);
+ return $a;
+ }
+
+}
\ No newline at end of file
diff --git a/app/controller/WxGetPhone.php b/app/controller/WxGetPhone.php
new file mode 100644
index 0000000..32beffb
--- /dev/null
+++ b/app/controller/WxGetPhone.php
@@ -0,0 +1,90 @@
+getCurl($url_get);
+ $token = $tmptoken['access_token'];
+
+
+ $url = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=" . $token;
+ $data['code'] = $code;
+ $info = $this->Post(json_encode($data), $url);
+ $tmpinfo = json_decode($info, true);
+
+
+ $phoneNumber = $tmpinfo['phone_info']['phoneNumber'];
+
+ if ($tmpinfo['errcode'] != 0) {
+ return json(['code' => 1, 'msg' => $tmpinfo['errmsg']]);
+ }
+
+ $table = 'zxc_user';
+ $checkPhone = Db::table($table)->where('openid', $openid)->value('phone');
+ if (empty($checkPhone)) {
+ Db::table($table)->where('openid', $openid)->save(['phone' => $phoneNumber]);
+ return json(['code' => 200, 'msg' => '获取手机号成功', 'phone' => $phoneNumber]);
+ } else {
+ $type = Db::table($table)->where('openid', $openid)->value('type');
+ if ($type == 3 && $checkPhone != $phoneNumber) {
+ Db::startTrans();
+ try {
+ EnterpriseUser::where('openid', $openid)->save(['phone' => $phoneNumber]);
+ Db::table($table)->where('openid', $openid)->save(['phone' => $phoneNumber]);
+ // 提交事务
+ Db::commit();
+ return json(['code' => 200, 'msg' => '更改手机号成功', 'phone' => $phoneNumber]);
+ } catch (\Exception $e) {
+ Db::rollback();
+ }
+ } else {
+ Db::table($table)->where('openid', $openid)->save(['phone' => $phoneNumber]);
+ return json(['code' => 200, 'msg' => '获取手机号成功', 'phone' => $phoneNumber]);
+ }
+ }
+
+
+ }
+
+ private function getCurl($url)
+ {
+ $headerArray = array("Content-type:application/json;", "Accept:application/json");
+ $ch = curl_init();//初始化CURL
+ curl_setopt($ch, CURLOPT_URL, $url);//设置访问地址
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);//HTTPS访问设置 关闭监视
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);//HTTPS访问设置 关闭监视访问地址
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArray);//设置访问头部信息
+ $output = curl_exec($ch);//获取结果
+ curl_close($ch);//关闭连接
+ $output = json_decode($output, true);//json数据转换
+ return $output;
+ }
+
+ private function Post($curlPost, $url, $ssl = false)
+ {
+ $curl = curl_init();
+
+ curl_setopt($curl, CURLOPT_URL, $url);
+ curl_setopt($curl, CURLOPT_HEADER, false);
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($curl, CURLOPT_NOBODY, true);
+ curl_setopt($curl, CURLOPT_POST, true);
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $curlPost);
+ if (!$ssl) {
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
+ curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
+ }
+ $return_str = curl_exec($curl);
+ curl_close($curl);
+ return $return_str;
+ }
+}
\ No newline at end of file
diff --git a/app/controller/mytrate.php b/app/controller/mytrate.php
new file mode 100644
index 0000000..43862c4
--- /dev/null
+++ b/app/controller/mytrate.php
@@ -0,0 +1,519 @@
+connect('127.0.0.1',6379);
+ $value=$redis->get(self::$Owner.'Token');
+ if($value==false){
+ $data = self::getTokenDate();
+ $url = self::$url . 'query_token';
+ $da = self::CurlSend($url, $data);
+ $decode = self::decryptString($da['Data']);
+ $decode = json_decode($decode, true);
+ $token = $decode['AccessToken'];
+ $redis->set(self::$Owner.'Token',$token,3500*$hour);
+ }else{
+ $token=$redis->get(self::$Owner.'Token');
+ }
+ return $token;
+ }
+ static function CurlSend($url, $data = '', $token = '')
+ {
+ $data = json_encode($data);
+ $ch = curl_init();
+ $headers = array();
+ if ($token) {
+ $headers[] = 'Authorization: Bearer ' . $token;
+ }
+ $headers[] = 'Content-Type: application/json;charset=utf-8';
+ $headers[] = 'Content-Length: ' . strlen($data);
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 对认证证书来源的检查
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在
+ curl_setopt($ch, CURLOPT_HEADER, 0);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+ curl_setopt($ch, CURLOPT_POST, 1);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+ $curl_return = curl_exec($ch);
+ curl_close($ch);
+ return json_decode(trim($curl_return), true);
+ }
+ static function checkParams($params){
+ $arr = ['OperatorID', 'Data', 'TimeStamp', 'Seq','Sig'];
+ // 参数检查
+ foreach ($arr as $v) {
+ if (empty($params[$v])) {
+ return $v;
+ }
+ }
+ self::$TimeStamp=$params['TimeStamp'];
+ self::$Seq=$params['Seq'];
+ return 2;
+ }
+ /**
+ * @param $OperatorID
+ * @param $params
+ * @return int|string
+ */
+ static function checkSig($OperatorID,$params){
+ $sig=$OperatorID.$params['Data'].$params['TimeStamp'].$params['Seq'];
+ $ecry_sig=self::hmac_md5($sig);
+ if($params['Sig']!=$ecry_sig){
+ return 1;
+ }
+ return 2;
+ }
+ static function fillParams($OperatorID){
+ $datas=self::getParams($OperatorID);
+ if(empty($datas)){
+ return 1;
+ }
+ self::$OperatorID = $OperatorID;
+ self::$OperatorSecret= $datas['OperatorSecret'];
+ self::$AesSecret = $datas['AesSecret'];
+ self::$AesIv = $datas['AesIv'];
+ self::$SigSecret =$datas['SigSecret'];
+ self::$Owner =$datas['Owner'];
+ }
+ /**
+ * @param $data
+ * @param $ret
+ * @param string $msg
+ * @return string
+ */
+ static function encodeData($data,$ret,$msg=''){
+ $data=json_encode($data);
+ $data=self::encryptString($data);
+
+ $seq=empty(self::$Seq)? '0001' : self::$Seq;
+ $datetime=empty(self::$TimeStamp)? date('YmdHis') :self::$TimeStamp;
+
+ $sig= self::$OperatorID . $data . $datetime . $seq;
+ $s= self::hmac_md5($sig);
+
+ return ['Msg'=>$msg,'Ret'=>$ret,'Data'=>$data,'Sig'=>$s];
+ }
+ static function getStr(){
+ return Yii::$app->security->generateRandomString();
+ }
+ static function checkToken($token){
+
+ $redis=Common::createRedis();
+ $key='token-'.self::$Owner.'-';
+ $redisToken=$redis->get($key);
+ if($redisToken&&($redisToken==$token)){
+ return 2;
+ }
+ return 1;
+ }
+ static function getParams($OperatorID){
+ $datas=[];// $datas里面是企业信息数组
+ $arr=[];
+ foreach ($datas as $k=> $v){
+ if($v['OperatorID']==$OperatorID){
+ $arr=$datas[$k];
+ }
+ }
+ return $arr;
+ }
+ static function getFile ($filename)
+ {
+ $ret = @file_get_contents($filename);
+ return json_decode($ret, true);
+ }
+
+ /**
+ * @param $log
+ * @param $filename
+ */
+ static function setFile ($log, $filename,$append=False){
+ if (!is_dir(dirname($filename))) {
+ mkdir(dirname($filename), 0777, true);
+ @chmod(dirname($filename), 0777);
+ }
+ @chmod($filename, 0777);
+ if($append==true){
+ file_put_contents($filename, json_encode($log)."\r\n",FILE_APPEND);
+ }else{
+ file_put_contents($filename, json_encode($log));
+ }
+ }
+ static function hmac_md5($s)
+ {
+ $ctx = hash_init('md5', HASH_HMAC,self::$SigSecret);
+ hash_update($ctx, $s);
+ $rs = hash_final($ctx);
+ $rs = strtoupper($rs);
+ return $rs;
+ }
+
+ static function encryptString($input)
+ {
+ $size = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
+ $input = self::pkcs5_pad($input, $size);
+ $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
+ mcrypt_generic_init($td, self::$AesSecret, self::$AesIv);
+ $data = mcrypt_generic($td, $input);
+ mcrypt_generic_deinit($td);
+ mcrypt_module_close($td);
+ $data = base64_encode($data);
+ return $data;
+ }
+
+ static function pkcs5_pad($text, $blocksize)
+ {
+ $pad = $blocksize - (strlen($text) % $blocksize);
+ return $text . str_repeat(chr($pad), $pad);
+ }
+
+ static function decryptString($sStr)
+ {
+ mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
+ //$iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
+ $iv = self::$AesIv;
+ $decrypted = @mcrypt_decrypt(MCRYPT_RIJNDAEL_128, self::$AesSecret, base64_decode($sStr), MCRYPT_MODE_CBC, $iv);
+ $dec_s = strlen($decrypted);
+ $padding = ord($decrypted[$dec_s - 1]);
+ $decrypted = substr($decrypted, 0, -$padding);
+ return $decrypted;
+ }
+ static function getCityCode(){
+ $file = file(Yii::getAlias('@app').'/commands/areaCode.txt');
+ $files = array();
+ foreach($file as $v){
+ $f = explode(' ',$v);
+ //这里用trim()函数去除头尾的空格不起效果,因为是全角格式。所以用功能更强大的正则来去除空格
+ $f[1] = mb_ereg_replace('^( | )+', '', $f[1]);
+ array_push($files,$f);
+ }
+ return $files;
+ }
+ static function getCityName($AreaCode,$cityCode){
+ $city='';
+ $pattern='/^(500)/';
+ if(preg_match($pattern,$AreaCode))
+ $city='重庆市';
+
+ $pattern='/^(310)/';
+ if(preg_match($pattern,$AreaCode))
+ $city='上海市';
+
+ $pattern='/^(120)/';
+ if(preg_match($pattern,$AreaCode))
+ $city='天津市';
+
+ $pattern='/^(110)/';
+ if(preg_match($pattern,$AreaCode))
+ $city='北京市';
+
+ $pattern='/^(4690)/';
+ if(preg_match($pattern,$AreaCode)){
+ $code=$AreaCode;
+ }else{
+ $code=substr($AreaCode,0,4).'00';
+ }
+ if(empty($city)){
+ foreach ($cityCode as $v1){
+ if($v1[0]==$code){
+ $city=$v1[1];
+ }
+ }
+ }
+ return $city;
+ }
+ //php5.5不支持array_column()
+ static function formArr($piles){
+ $arr=[];
+ foreach ($piles as $v){
+ $arr[]=$v['pile_id'];
+ }
+ return $arr;
+ }
+ static function insertPile($stations,$pile)
+ {
+ $time=time();
+ $arr=[];
+ foreach ($stations['StationInfos'] as $v){
+ foreach ($v['EquipmentInfos'] as $v1){
+ if($pile&&in_array($v1['EquipmentID'],$pile))
+ continue;
+ $station_status=($v['StationStatus']==50)? 1 : 0;
+ if($v1['EquipmentID'])
+ $arr[]=[$v1['EquipmentID'],self::$Owner,$v['StationID'],$v1['EquipmentType'],$time,$station_status];
+ }
+
+ }
+ if($arr)
+ @Yii::$app->db->createCommand()->batchInsert('pile', ['pile_id', 'owner','zhan_id','eleType','time','station_status'],
+ $arr)->execute();
+ }
+ static function insertPic($arr=[],$id,$owner){
+ $imgDir=[];
+ foreach ($arr as $v){
+ if($v){
+ $dirInfo=self::getImage($v,$owner);
+ if($dirInfo['save_path']!=2){
+ $imgDir[]=[
+ 'url'=>$dirInfo['save_path'],
+ 'zhan_id'=>$id,
+ 'timer'=>date('Y-m-d H:i:s'),
+ 'user'=>'',
+ 'ischeck'=>0
+ ];
+ }
+ }
+ }
+ if($imgDir){
+ Yii::$app->db->createCommand()->batchInsert(Zhanpic::tableName(), ['url','zhan_id','timer','user','ischeck'], $imgDir)->execute();
+ }
+ }
+ static function getImage($url,$owner){
+ $filename=substr($url,(strripos($url,'/')+1));
+ if($filename=='default.png')
+ return ['save_path'=>2];
+ ob_start();
+ @readfile($url);
+ $img=ob_get_contents();
+ ob_end_clean();
+ if($img){
+ $sub_dir=$owner.'/'.date('Y-m-d').'/';
+ $dir=Yii::getAlias('@app').'/../uploadfile/'.$sub_dir;
+ if(!file_exists($dir)){
+ mkdir($dir,0777,true);
+ }
+ $fp2=@fopen($dir.$filename,'a');
+ fwrite($fp2,$img);
+ fclose($fp2);
+ unset($img,$url);
+ return ['save_path'=>$sub_dir.$filename];
+ }else{
+ return ['save_path'=>2];
+ }
+ }
+ static function insertInfo($hour){
+ $token=self::getToken($hour);
+ if(!$token)
+ die('token 不能为空');
+ $data = self::getStationDate();
+
+ $url = self::$url.'query_stations_info';
+
+ $da = self::CurlSend($url, $data, $token);
+
+ $stations=self::decryptString($da['Data']);
+
+ $stations=json_decode($stations,true);
+// echo '';
+// print_r($stations);
+// die();
+ if($stations){
+ $sql = "SELECT pile_id FROM pile where owner=:owner ";
+ $piles = Yii::$app->db->createCommand($sql, [':owner' => self::$Owner])->queryAll();
+ if($piles)
+ $piles=self::formArr($piles);
+ self::insertPile($stations,$piles);
+ $zhanList=Zhanlist::find()->select(['zhan_id'])->where(['supplier'=>self::$Owner])->asArray()->all();
+ if(!empty($zhanList)){
+ $aa=[];
+ foreach ($zhanList as $k=>$v){
+ $aa[]=$v['zhan_id'];
+ }
+ $zhanList=$aa;
+ }
+
+ $cityCode=static::getCityCode();
+
+ self::insertStation($stations,$cityCode,$zhanList);
+
+ $page=$stations['PageCount'];
+ //所有页信息
+ for($i=2;$i<=$page;$i++){
+ $data2=self::getStationDate($i);
+ $da2 = self::CurlSend($url, $data2, $token);
+ $da2=self::decryptString($da2['Data']);
+ $da2=json_decode($da2,true);
+ if($da2)
+ self::insertStation($da2,$cityCode,$zhanList);
+ self::insertPile($da2,$piles);
+ }
+ }
+ }
+ static function padZero($str){
+ $len=strlen(substr($str,strpos($str,'.')+1));
+ $len=16-$len;
+ for($i=0;$i<$len;$i++){
+ $str.=0;
+ }
+ return $str;
+ }
+ static function pushCheck($fileName='change_status.txt'){
+ $authorization=Yii::$app->request->headers->get('Authorization');
+ $params=file_get_contents('php://input');
+ $params=json_decode($params,true);
+// if(!empty($fileName))
+// self::writeLog($fileName,$params);
+ $auths=explode(' ',trim($authorization));
+ $auth=$auths[count($auths)-1];
+
+ $checkParams=self::checkParams($params);
+ if($checkParams!=2)
+ return ['Msg'=>$checkParams.'为空','Ret'=>4003,'Data'=>['Status'=>1]];
+
+ $re=self::fillParams($params['OperatorID']);
+ if($re==1)
+ return ['Msg'=>'OperatorID不存在','Ret'=>4003,'Data'=>['Status'=>1]];
+
+ if($auth){
+ if(self::checkToken($auth)==1)
+ return self::encodeData(['Status'=>1],4002,'Token过期或者无效');
+ $checkSig=self::checkSig($params['OperatorID'],$params);
+ if($checkSig==1)
+ return self::encodeData(['Status'=>1],4001,'签名错误');
+
+ $data=self::decryptString($params['Data']);
+ $data=json_decode($data,true);
+// if(!empty($fileName))
+// self::writeLog($fileName,$data);
+ return ['code'=>200,'data'=>$data];
+ }
+ return self::encodeData(['Status'=>1],4002,'Bearer 未添加');
+ }
+ static function writeLog($name,$arr){
+ if(is_array($arr)){
+ if (@$_SERVER["HTTP_X_FORWARDED_FOR"])
+ $ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
+ else if (@$_SERVER["HTTP_CLIENT_IP"])
+ $ip = $_SERVER["HTTP_CLIENT_IP"];
+ else if (@$_SERVER["REMOTE_ADDR"])
+ $ip = $_SERVER["REMOTE_ADDR"];
+ else if (@getenv("HTTP_X_FORWARDED_FOR"))
+ $ip = getenv("HTTP_X_FORWARDED_FOR");
+ else if (@getenv("HTTP_CLIENT_IP"))
+ $ip = getenv("HTTP_CLIENT_IP");
+ else if (@getenv("REMOTE_ADDR"))
+ $ip = getenv("REMOTE_ADDR");
+ else
+ $ip = $_SERVER['REMOTE_ADDR'];
+ $pushTime=['logTime'=>date('Y-m-d H:i:s',time()),'ip'=>$ip];
+ $arr=array_merge($pushTime,$arr);
+ $sub_dir=date('Y-m-d');
+ $dir=Yii::getAlias('@app').'/../../../'.$sub_dir.'/'.$name;
+ self::setFile($arr,$dir,true);
+ }
+ }
+ public static function initeStatus(){
+ $redis=Common::createRedis();
+ $datas=Zhanlist::find()->select(['zhan_id'])->where(['supplier'=>self::$Owner])->asArray()->all();
+ $token=self::getToken(2);
+ self::$url=self::$url.'query_station_status';
+ $data=[];
+ foreach ($datas as $k=>$v){
+ $data[]=$v['zhan_id'];
+ $i=$k+1;
+ if($i%25==0){
+ $dd=self::statusDate($data);
+ $da = self::CurlSend(self::$url, $dd,$token);
+ $decode = self::decryptString($da['Data']);
+ $decode = json_decode($decode, true);
+ if($decode){
+ foreach ($decode['StationStatusInfos'] as $v1){
+
+ foreach ($v1['ConnectorStatusInfos'] as $v2){
+ $key=self::$Owner.'--'.$v2['ConnectorID'];
+ $value=$v2['Status'];
+ $redis->set($key,$value);
+ }
+ }
+ }
+ $data=[];
+ }
+ }
+ if($data){
+ $dd=self::statusDate($data);
+ $da = self::CurlSend(self::$url, $dd,$token);
+ $decode = self::decryptString($da['Data']);
+ $decode = json_decode($decode, true);
+ if($decode){
+ if($decode['StationStatusInfos']){
+ foreach ($decode['StationStatusInfos'] as $v1){
+ if(empty($decode['ConnectorStatusInfos']))
+ continue;
+ foreach ($v1['ConnectorStatusInfos'] as $v2){
+ $key=self::$Owner.$v2['ConnectorID'];
+ $value=$v2['Status'];
+ $redis->set($key,$value);
+ }
+ }
+ }
+ }
+ }
+ }
+ public static function statusDate($id){
+ $datetime= date('YmdHis');
+ $kk['StationIDs']=$id;
+ $en = self::encryptString(json_encode($kk));
+ $sig= self::$OperatorID . $en . $datetime . "0002";
+ $s= self::hmac_md5($sig);
+ $rr['OperatorID'] = self::$OperatorID;
+ $rr['Data']= $en;
+ $rr['TimeStamp']= $datetime;
+ $rr['Seq']= '0002';
+ $rr['Sig'] = $s;
+ return $rr;
+ }
+}
\ No newline at end of file
diff --git a/app/controller/open.php b/app/controller/open.php
new file mode 100644
index 0000000..63952a3
--- /dev/null
+++ b/app/controller/open.php
@@ -0,0 +1,67 @@
+$checkParams.'为空','Ret'=>4003,'Data'=>['Status'=>1]];
+ }
+ $re=self::fillParams($params['OperatorID']);
+ if($re==1)
+ return ['Msg'=>'OperatorID不存在','Ret'=>4003,'Data'=>['Status'=>1]];
+ $checkSig=self::checkSig($OperatorID,$params);
+ if($checkSig==1)
+ return self::encodeData(['OperatorID'=>$OperatorID,'SuccStat'=>1,'FailReason'=>4],4001,'签名错误');
+
+ $data=self::decryptString($params['Data']);
+ $datas=json_decode($data,true);
+ if(isset($datas['OperatorID'])&&isset($datas['OperatorSecret'])){
+ if(($datas['OperatorID']==$OperatorID)&&($datas['OperatorSecret']==self::$OperatorSecret)){
+ $AccessToken=self::getStr();
+ $redis=Common::createRedis();
+ $key='token-'.self::$Owner.'-';
+ $redis->set($key,$AccessToken,86400);
+ $strr=['OperatorID'=>$OperatorID,'SuccStat'=>0,'AccessToken'=>$AccessToken,
+ 'TokenAvailableTime'=>86400,'FailReason'=>0];
+ self::writeLog('query_token.txt',$strr);
+ return self::encodeData($strr,0);
+ }
+ $re=['OperatorID'=>$OperatorID,'SuccStat'=>1,'FailReason'=>5];
+ return self::encodeData($re,4003,'OperatorID,Data错误');
+ }
+ $re=['OperatorID'=>$OperatorID,'SuccStat'=>1,'FailReason'=>6];
+ return self::encodeData($re,4003,'OperatorID,Data缺失');
+ }
+
+ public function actionNotification_stationstatus(){
+ $receive=self::pushCheck();
+ if(isset($receive['code'])&&$receive['code']==200){
+ $da=$receive['data']['ConnectorStatusInfo'];
+ if(isset($da['ConnectorID'])&&isset($da['Status'])){
+ $redis=Common::createRedis();
+ $key=self::$Owner.'--'.$da['ConnectorID'];
+ $status=$da['Status'];
+ $redis->set($key,$status);
+ $result=1;
+// self::writeLog('change_status.txt',$da);
+ if($result){
+ return self::encodeData(['Status'=>0],0);
+ }else{
+ return self::encodeData(['Status'=>1],0);
+ }
+ }else{
+ return self::encodeData(['Status'=>1],4004,'Aes加密错误');
+ }
+ }else{
+ return $receive;
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/app/controller/utils.php b/app/controller/utils.php
new file mode 100644
index 0000000..8b02df5
--- /dev/null
+++ b/app/controller/utils.php
@@ -0,0 +1,74 @@
+ $code, 'Msg' => $msg, 'Data' => $data]);
+ }
+
+ public function getDateFromRange($startdate, $enddate): array
+ {
+
+ $stimestamp = strtotime($startdate);
+ $etimestamp = strtotime($enddate);
+ // 计算日期段内有多少天
+ $days = ($etimestamp - $stimestamp) / 86400;
+ // 保存每天日期
+ $date = array();
+ for ($i = 0; $i < $days + 1; $i++) {
+
+ $date[] = date('Y-m-d', $stimestamp + (86400 * $i));
+ }
+
+ return $date;
+ }
+
+ public function Fee($station_number, $openid): array
+ {
+
+ $table = 'zxc_user';
+
+ $ElectricityFee = Db::table('charge_station')->where('charge_station_number', $station_number)->value('ElectricityFee');
+ $station_type = Db::table('charge_station')->where('charge_station_number', $station_number)->value('station_type');
+ $type = Db::table($table)->where('openid', $openid)->value('type');
+ if ($type == 3) {
+ $group_id = Db::table($table)->where('openid', $openid)->value('group_id');
+ $ServiceFee = ServiceFee::where('type', $type)->where('group_id', $group_id)->where('station_type', $station_type)->value('service_fee');
+ } else {
+ $ServiceFee = ServiceFee::where('type', $type)->where('station_type', $station_type)->value('service_fee');
+ }
+// $ServiceFee= Db::table('charge_station')->where('charge_station_number',$station_number)->value('ServiceFee');
+ $ElectricityFee = str_replace('电费:', '', $ElectricityFee);
+ $Elect = explode(',', $ElectricityFee);
+ for ($index = 0; $index < count($Elect); $index++) {
+ $kk['time_interval'] = substr($Elect[$index], 0, 11);
+ $kk['univalence'] = explode(':', $Elect[$index])[3];
+ $ss[] = $kk;
+ }
+ $ServiceFee = str_replace('服务费:', '', $ServiceFee);
+ $Server = explode(',', $ServiceFee);
+ $wk_day = date('w');
+ $now_time = time();
+ $start_time = '2023-03-18 00:00:00';
+ $start_time = strtotime($start_time);
+ $wkday_ar = array('日', '一', '二', '三', '四', '五', '六');
+ for ($index = 0; $index < count($Server); $index++) {
+ $ll['time_interval'] = substr($Server[$index], 0, -5);
+
+ // if ($wkday_ar[$wk_day] == '三' && $now_time > $start_time && $type == 1) {
+ // $ll['univalence'] = number_format((float)(substr($Server[$index], Strlen($Server[$index]) - 4) - 0.20), 2);
+ // } else {
+ $ll['univalence'] = substr($Server[$index], Strlen($Server[$index]) - 4);
+ // }
+ $mm[] = $ll;
+ }
+ return ['code' => 200, 'ElectricityFee' => $ss, 'ServiceFee' => $mm];
+ }
+}
\ No newline at end of file
diff --git a/app/event.php b/app/event.php
new file mode 100644
index 0000000..e9851bb
--- /dev/null
+++ b/app/event.php
@@ -0,0 +1,17 @@
+ [
+ ],
+
+ 'listen' => [
+ 'AppInit' => [],
+ 'HttpRun' => [],
+ 'HttpEnd' => [],
+ 'LogLevel' => [],
+ 'LogWrite' => [],
+ ],
+
+ 'subscribe' => [
+ ],
+];
diff --git a/app/middleware.php b/app/middleware.php
new file mode 100644
index 0000000..961a6e1
--- /dev/null
+++ b/app/middleware.php
@@ -0,0 +1,12 @@
+pathinfo(), ['/favicon.ico'])) {
+ return $response;
+ }
+
+ try {
+ $log = [
+ 'method' => $request->method(),
+ 'url' => $request->url(),
+ 'params' => $this->filterParams($request->param()),
+ 'ip' => $request->ip(),
+ 'user_agent' => $request->header() ? $request->header('user-agent') : '无',
+ 'user_id' => $request->userId ?? 0, // 需要根据你的认证系统调整
+ 'response_code' => $response->getCode(),
+ 'response_time' => round(microtime(true) - $startTime, 3),
+ ];
+
+ SystemRequestLog::create($log);
+ } catch (\Exception $e) {
+ // 记录失败不影响主流程
+ \think\facade\Log::error('请求日志记录失败:'.$e->getMessage());
+ }
+
+ return $response;
+ }
+
+ protected function filterParams($params)
+ {
+ // 过滤敏感字段
+ $sensitiveFields = ['password', 'pwd', 'token', 'access_token'];
+ foreach ($sensitiveFields as $field) {
+ if (isset($params[$field])) {
+ $params[$field] = '******';
+ }
+ }
+ return $params;
+ }
+}
\ No newline at end of file
diff --git a/app/middleware/WxAppCheck.php b/app/middleware/WxAppCheck.php
new file mode 100644
index 0000000..5a3a251
--- /dev/null
+++ b/app/middleware/WxAppCheck.php
@@ -0,0 +1,65 @@
+header('token');
+
+ //验证token
+ $res=checkToken_s($token);
+
+ //对返回结果进行判断
+ if (!is_numeric($res)){
+ return json(['code'=>1,'message'=>$res]);
+ }
+ //保存用户ID
+ $request->uid=$res;
+ return $next($request);
+
+ }
+
+}
+
+function checkToken_s($token)
+{
+ $key = 'zbcazbc';
+ $key = new Key($key, 'HS256');
+ $status = array("code" => 2);
+// echo $token;
+ try {
+ JWT::$leeway = 60;//当前时间减去60,把时间留点余地
+ $decoded = JWT::decode($token, $key, array('HS256')); //HS256方式,这里要和签发的时候对应
+ $arr = (array)$decoded;
+// print_r($arr);
+ $res['code'] = 1;
+ $res['data'] = $arr['data'];
+ return $res['data']->uid;
+ } catch (\Firebase\JWT\SignatureInvalidException $e) { //签名不正确
+ $status['msg'] = "签名不正确";
+ return $status['msg'];
+ } catch (\Firebase\JWT\BeforeValidException $e) { // 签名在某个时间点之后才能用
+ $status['msg'] = "token失效";
+ return $status['msg'];
+ } catch (\Firebase\JWT\ExpiredException $e) { // token过期
+ $status['msg'] = "token失效";
+ return $status['msg'];
+ } catch (\Exception $e) { //其他错误
+ $status['msg'] = "未知错误";
+ return $status['msg'];
+ }
+}
diff --git a/app/model/Access.php b/app/model/Access.php
new file mode 100644
index 0000000..e7f1cdf
--- /dev/null
+++ b/app/model/Access.php
@@ -0,0 +1,11 @@
+belongsToMany(Role::class,Access::class,'role_id','admin_id');
+// }
+
+ public function searchUsernameAttr($query, $value)
+ {
+ return $value ? $query->where('username', 'like', '%'.$value.'%') : '';
+ }
+
+ public function searchNicknameAttr($query, $value)
+ {
+ return $value ? $query->where('Nickname', 'like', '%'.$value.'%') : '';
+ }
+
+ public function searchEmailAttr($query, $value)
+ {
+ return $value ? $query->where('email', 'like', '%'.$value.'%') : '';
+ }
+
+ public function searchPhoneAttr($query, $value)
+ {
+ return $value ? $query->where('phone', 'like', '%'.$value.'%') : '';
+ }
+
+
+}
\ No newline at end of file
diff --git a/app/model/ChargeOrder.php b/app/model/ChargeOrder.php
new file mode 100644
index 0000000..5bea1eb
--- /dev/null
+++ b/app/model/ChargeOrder.php
@@ -0,0 +1,41 @@
+where('order_number', 'like', '%'.$value.'%') : '';
+ }
+
+ public function searchChargeStationIdAttr($query, $value)
+ {
+ return $value ? $query->where('charge_station_id', '=', $value) : '';
+ }
+
+ public function searchOpenidAttr($query, $value)
+ {
+ return $value ? $query->where('openid', 'like', '%'.$value.'%') : '';
+ }
+
+ public function searchChargeDateAttr($query, $value)
+ {
+ return $value ? $query->whereTime('charge_date', '>=', $value) : '';
+ }
+
+ public function searchStatusAttr($query, $value)
+ {
+ return $value ? $query->where('status', '=', "'".$value."'") : '';
+ }
+}
diff --git a/app/model/ChargeStation.php b/app/model/ChargeStation.php
new file mode 100644
index 0000000..6f7752f
--- /dev/null
+++ b/app/model/ChargeStation.php
@@ -0,0 +1,48 @@
+where('charge_station_name', 'like', '%'.$value.'%') : '';
+ }
+
+ public function searchStationTypeAttr($query, $value)
+ {
+ return $value ? $query->where('station_type', '=', $value) : '';
+ }
+
+ public function searchCityAttr($query, $value)
+ {
+ return $value ? $query->where('city', 'like', '%'.$value.'%') : '';
+ }
+
+ public function searchAreaAttr($query, $value)
+ {
+ return $value ? $query->where('area', 'like', '%'.$value.'%') : '';
+ }
+
+ public function searchStreetAttr($query, $value)
+ {
+ return $value ? $query->where('street', 'like', '%'.$value.'%') : '';
+ }
+
+ public function searchAddressAttr($query, $value)
+ {
+ return $value ? $query->where('address', 'like', '%'.$value.'%') : '';
+ }
+
+ public function searchPriceAttr($query, $value)
+ {
+ return $value ? $query->where('price', 'between', [intval($value),intval($value)+1]) : '';
+ }
+
+}
diff --git a/app/model/Enterprise.php b/app/model/Enterprise.php
new file mode 100644
index 0000000..217a0f9
--- /dev/null
+++ b/app/model/Enterprise.php
@@ -0,0 +1,12 @@
+ 'json',
+ ];
+}
\ No newline at end of file
diff --git a/app/model/User.php b/app/model/User.php
new file mode 100644
index 0000000..71d999b
--- /dev/null
+++ b/app/model/User.php
@@ -0,0 +1,27 @@
+insert([
+ 'openid' => $openid,
+ 'money' => $money,
+ 'type' => $type,
+ 'mark' => $mark,
+ 'createtime' => date('Y-m-d H:i:s', time()),
+ ]);
+ }
+
+}
diff --git a/app/model/Vinlicense.php b/app/model/Vinlicense.php
new file mode 100644
index 0000000..aab6af1
--- /dev/null
+++ b/app/model/Vinlicense.php
@@ -0,0 +1,10 @@
+ Request::class,
+ 'think\exception\Handle' => ExceptionHandle::class,
+];
diff --git a/app/service.php b/app/service.php
new file mode 100644
index 0000000..db1ee6a
--- /dev/null
+++ b/app/service.php
@@ -0,0 +1,9 @@
+ ['规则1','规则2'...]
+ *
+ * @var array
+ */
+ protected $rule = [
+
+ ];
+
+ /**
+ * 定义错误信息
+ * 格式:'字段名.规则名' => '错误信息'
+ *
+ * @var array
+ */
+ protected $message = [
+ 'username.require' => '用户名不得为空~',
+ 'username.min' => '用户名不得小于 2 位~',
+ 'username.max' => '用户名不得大于 10 位~',
+ 'username.chsDash' => '用户名只能是汉字、字母、数字或下划线以及破折号~',
+ 'nickname.require' => '昵称不得为空~',
+ 'nickname.min' => '昵称不得小于 2 位~',
+ 'nickname.max' => '昵称不得大于 10 位~',
+ 'nickname.chsDash' => '昵称只能是汉字、字母、数字或下划线以及破折号~',
+ 'username.unique' => '用户名已存在~',
+ 'password.require' => '密码不得为空~',
+ 'password.min' => '密码不得小于 6 位~',
+ 'passwordnot.require' => '密码确认不得为空~',
+ 'passwordnot.confirm' => '密码确认和密码不一致~',
+ 'email.require' => '电子邮件不得为空~',
+ 'email.email' => '电子邮件格式不正确~',
+ 'email.unique' => '电子邮件已存在~',
+ 'phone.require' => '电话不得为空~',
+ 'phone.number' => '必须全部为数字~',
+ 'phone.length' => '手机号长度必须为11位',
+ 'phone.unique' => '手机号已存在~'
+
+ ];
+}
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..527abe4
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,57 @@
+{
+ "name": "topthink/think",
+ "description": "the new thinkphp framework",
+ "type": "project",
+ "keywords": [
+ "framework",
+ "thinkphp",
+ "ORM"
+ ],
+ "homepage": "https://www.thinkphp.cn/",
+ "license": "Apache-2.0",
+ "authors": [
+ {
+ "name": "liu21st",
+ "email": "liu21st@gmail.com"
+ },
+ {
+ "name": "yunwuxin",
+ "email": "448901948@qq.com"
+ }
+ ],
+ "require": {
+ "php": ">=7.2.5",
+ "topthink/framework": "^6.1.0",
+ "topthink/think-orm": "^2.0",
+ "topthink/think-filesystem": "^1.0",
+ "overtrue/pinyin": "^4.0",
+ "wechatpay/wechatpay": "^1.4",
+ "firebase/php-jwt": "^6.3",
+ "topthink/think-worker": "^3.0",
+ "curl/curl": "^2.4",
+ "ext-json": "*",
+ "easy-task/easy-task": "^2.4",
+ "ext-redis": "*"
+ },
+ "require-dev": {
+ "symfony/var-dumper": "^4.2",
+ "topthink/think-trace": "^1.0"
+ },
+ "autoload": {
+ "psr-4": {
+ "app\\": "app"
+ },
+ "psr-0": {
+ "": "extend/"
+ }
+ },
+ "config": {
+ "preferred-install": "dist"
+ },
+ "scripts": {
+ "post-autoload-dump": [
+ "@php think service:discover",
+ "@php think vendor:publish"
+ ]
+ }
+}
diff --git a/composer.lock b/composer.lock
new file mode 100644
index 0000000..f6b1569
--- /dev/null
+++ b/composer.lock
@@ -0,0 +1,2377 @@
+{
+ "_readme": [
+ "This file locks the dependencies of your project to a known state",
+ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
+ "This file is @generated automatically"
+ ],
+ "content-hash": "57b73d283fd656fb7c5e09339a0ab6c4",
+ "packages": [
+ {
+ "name": "curl/curl",
+ "version": "2.4.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-mod/curl.git",
+ "reference": "ba385e40c5907850c555db24505c127fe29f1e44"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-mod/curl/zipball/ba385e40c5907850c555db24505c127fe29f1e44",
+ "reference": "ba385e40c5907850c555db24505c127fe29f1e44",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "ext-curl": "*",
+ "php": "^5.6 | ^7.0 | ^8.0"
+ },
+ "require-dev": {
+ "yoast/phpunit-polyfills": "^0.2.0"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-0": {
+ "Curl": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "php-curl-class",
+ "homepage": "https://github.com/php-curl-class"
+ },
+ {
+ "name": "Hassan Amouhzi",
+ "email": "hassan@anezi.net",
+ "homepage": "http://hassan.amouhzi.com"
+ },
+ {
+ "name": "user52",
+ "homepage": "https://github.com/user52"
+ }
+ ],
+ "description": "cURL class for PHP",
+ "homepage": "https://github.com/php-mod/curl",
+ "keywords": [
+ "curl",
+ "dot"
+ ],
+ "support": {
+ "issues": "https://github.com/php-mod/curl/issues",
+ "source": "https://github.com/php-mod/curl/tree/2.4.0"
+ },
+ "time": "2022-08-29T08:52:24+00:00"
+ },
+ {
+ "name": "easy-task/easy-task",
+ "version": "V2.4.5",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/thinker-gao/easy-task.git",
+ "reference": "3b5245ebee8624cdaa0b609547e9cbc01dffbd0b"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/thinker-gao/easy-task/zipball/3b5245ebee8624cdaa0b609547e9cbc01dffbd0b",
+ "reference": "3b5245ebee8624cdaa0b609547e9cbc01dffbd0b",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "ext-curl": "*",
+ "ext-json": "*",
+ "ext-mbstring": "*",
+ "php": ">=5.4"
+ },
+ "suggest": {
+ "ext-event": "For better performance. "
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "EasyTask\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "Apache-2.0"
+ ],
+ "authors": [
+ {
+ "name": "GaoJiuFeng",
+ "email": "392223903@qq.com"
+ }
+ ],
+ "description": "easy-task, simple timer, timing task",
+ "keywords": [
+ "easy-task"
+ ],
+ "support": {
+ "issues": "https://github.com/thinker-gao/easy-task/issues",
+ "source": "https://github.com/thinker-gao/easy-task/tree/v1.0"
+ },
+ "time": "2022-07-31T08:10:56+00:00"
+ },
+ {
+ "name": "firebase/php-jwt",
+ "version": "v6.3.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/firebase/php-jwt.git",
+ "reference": "ddfaddcb520488b42bca3a75e17e9dd53c3667da"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/firebase/php-jwt/zipball/ddfaddcb520488b42bca3a75e17e9dd53c3667da",
+ "reference": "ddfaddcb520488b42bca3a75e17e9dd53c3667da",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "php": "^7.1||^8.0"
+ },
+ "require-dev": {
+ "guzzlehttp/guzzle": "^6.5||^7.4",
+ "phpspec/prophecy-phpunit": "^1.1",
+ "phpunit/phpunit": "^7.5||^9.5",
+ "psr/cache": "^1.0||^2.0",
+ "psr/http-client": "^1.0",
+ "psr/http-factory": "^1.0"
+ },
+ "suggest": {
+ "paragonie/sodium_compat": "Support EdDSA (Ed25519) signatures when libsodium is not present"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Firebase\\JWT\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Neuman Vong",
+ "email": "neuman+pear@twilio.com",
+ "role": "Developer"
+ },
+ {
+ "name": "Anant Narayanan",
+ "email": "anant@php.net",
+ "role": "Developer"
+ }
+ ],
+ "description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.",
+ "homepage": "https://github.com/firebase/php-jwt",
+ "keywords": [
+ "jwt",
+ "php"
+ ],
+ "support": {
+ "issues": "https://github.com/firebase/php-jwt/issues",
+ "source": "https://github.com/firebase/php-jwt/tree/v6.3.1"
+ },
+ "time": "2022-11-01T21:20:08+00:00"
+ },
+ {
+ "name": "guzzlehttp/guzzle",
+ "version": "7.5.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/guzzle/guzzle.git",
+ "reference": "b50a2a1251152e43f6a37f0fa053e730a67d25ba"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/guzzle/guzzle/zipball/b50a2a1251152e43f6a37f0fa053e730a67d25ba",
+ "reference": "b50a2a1251152e43f6a37f0fa053e730a67d25ba",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "ext-json": "*",
+ "guzzlehttp/promises": "^1.5",
+ "guzzlehttp/psr7": "^1.9 || ^2.4",
+ "php": "^7.2.5 || ^8.0",
+ "psr/http-client": "^1.0",
+ "symfony/deprecation-contracts": "^2.2 || ^3.0"
+ },
+ "provide": {
+ "psr/http-client-implementation": "1.0"
+ },
+ "require-dev": {
+ "bamarni/composer-bin-plugin": "^1.8.1",
+ "ext-curl": "*",
+ "php-http/client-integration-tests": "^3.0",
+ "phpunit/phpunit": "^8.5.29 || ^9.5.23",
+ "psr/log": "^1.1 || ^2.0 || ^3.0"
+ },
+ "suggest": {
+ "ext-curl": "Required for CURL handler support",
+ "ext-intl": "Required for Internationalized Domain Name (IDN) support",
+ "psr/log": "Required for using the Log middleware"
+ },
+ "type": "library",
+ "extra": {
+ "bamarni-bin": {
+ "bin-links": true,
+ "forward-command": false
+ },
+ "branch-alias": {
+ "dev-master": "7.5-dev"
+ }
+ },
+ "autoload": {
+ "files": [
+ "src/functions_include.php"
+ ],
+ "psr-4": {
+ "GuzzleHttp\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Graham Campbell",
+ "email": "hello@gjcampbell.co.uk",
+ "homepage": "https://github.com/GrahamCampbell"
+ },
+ {
+ "name": "Michael Dowling",
+ "email": "mtdowling@gmail.com",
+ "homepage": "https://github.com/mtdowling"
+ },
+ {
+ "name": "Jeremy Lindblom",
+ "email": "jeremeamia@gmail.com",
+ "homepage": "https://github.com/jeremeamia"
+ },
+ {
+ "name": "George Mponos",
+ "email": "gmponos@gmail.com",
+ "homepage": "https://github.com/gmponos"
+ },
+ {
+ "name": "Tobias Nyholm",
+ "email": "tobias.nyholm@gmail.com",
+ "homepage": "https://github.com/Nyholm"
+ },
+ {
+ "name": "Márk Sági-Kazár",
+ "email": "mark.sagikazar@gmail.com",
+ "homepage": "https://github.com/sagikazarmark"
+ },
+ {
+ "name": "Tobias Schultze",
+ "email": "webmaster@tubo-world.de",
+ "homepage": "https://github.com/Tobion"
+ }
+ ],
+ "description": "Guzzle is a PHP HTTP client library",
+ "keywords": [
+ "client",
+ "curl",
+ "framework",
+ "http",
+ "http client",
+ "psr-18",
+ "psr-7",
+ "rest",
+ "web service"
+ ],
+ "support": {
+ "issues": "https://github.com/guzzle/guzzle/issues",
+ "source": "https://github.com/guzzle/guzzle/tree/7.5.0"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/GrahamCampbell",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/Nyholm",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-08-28T15:39:27+00:00"
+ },
+ {
+ "name": "guzzlehttp/promises",
+ "version": "1.5.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/guzzle/promises.git",
+ "reference": "b94b2807d85443f9719887892882d0329d1e2598"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/guzzle/promises/zipball/b94b2807d85443f9719887892882d0329d1e2598",
+ "reference": "b94b2807d85443f9719887892882d0329d1e2598",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "php": ">=5.5"
+ },
+ "require-dev": {
+ "symfony/phpunit-bridge": "^4.4 || ^5.1"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.5-dev"
+ }
+ },
+ "autoload": {
+ "files": [
+ "src/functions_include.php"
+ ],
+ "psr-4": {
+ "GuzzleHttp\\Promise\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Graham Campbell",
+ "email": "hello@gjcampbell.co.uk",
+ "homepage": "https://github.com/GrahamCampbell"
+ },
+ {
+ "name": "Michael Dowling",
+ "email": "mtdowling@gmail.com",
+ "homepage": "https://github.com/mtdowling"
+ },
+ {
+ "name": "Tobias Nyholm",
+ "email": "tobias.nyholm@gmail.com",
+ "homepage": "https://github.com/Nyholm"
+ },
+ {
+ "name": "Tobias Schultze",
+ "email": "webmaster@tubo-world.de",
+ "homepage": "https://github.com/Tobion"
+ }
+ ],
+ "description": "Guzzle promises library",
+ "keywords": [
+ "promise"
+ ],
+ "support": {
+ "issues": "https://github.com/guzzle/promises/issues",
+ "source": "https://github.com/guzzle/promises/tree/1.5.2"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/GrahamCampbell",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/Nyholm",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-08-28T14:55:35+00:00"
+ },
+ {
+ "name": "guzzlehttp/psr7",
+ "version": "2.4.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/guzzle/psr7.git",
+ "reference": "67c26b443f348a51926030c83481b85718457d3d"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/guzzle/psr7/zipball/67c26b443f348a51926030c83481b85718457d3d",
+ "reference": "67c26b443f348a51926030c83481b85718457d3d",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "php": "^7.2.5 || ^8.0",
+ "psr/http-factory": "^1.0",
+ "psr/http-message": "^1.0",
+ "ralouphie/getallheaders": "^3.0"
+ },
+ "provide": {
+ "psr/http-factory-implementation": "1.0",
+ "psr/http-message-implementation": "1.0"
+ },
+ "require-dev": {
+ "bamarni/composer-bin-plugin": "^1.8.1",
+ "http-interop/http-factory-tests": "^0.9",
+ "phpunit/phpunit": "^8.5.29 || ^9.5.23"
+ },
+ "suggest": {
+ "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses"
+ },
+ "type": "library",
+ "extra": {
+ "bamarni-bin": {
+ "bin-links": true,
+ "forward-command": false
+ },
+ "branch-alias": {
+ "dev-master": "2.4-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "GuzzleHttp\\Psr7\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Graham Campbell",
+ "email": "hello@gjcampbell.co.uk",
+ "homepage": "https://github.com/GrahamCampbell"
+ },
+ {
+ "name": "Michael Dowling",
+ "email": "mtdowling@gmail.com",
+ "homepage": "https://github.com/mtdowling"
+ },
+ {
+ "name": "George Mponos",
+ "email": "gmponos@gmail.com",
+ "homepage": "https://github.com/gmponos"
+ },
+ {
+ "name": "Tobias Nyholm",
+ "email": "tobias.nyholm@gmail.com",
+ "homepage": "https://github.com/Nyholm"
+ },
+ {
+ "name": "Márk Sági-Kazár",
+ "email": "mark.sagikazar@gmail.com",
+ "homepage": "https://github.com/sagikazarmark"
+ },
+ {
+ "name": "Tobias Schultze",
+ "email": "webmaster@tubo-world.de",
+ "homepage": "https://github.com/Tobion"
+ },
+ {
+ "name": "Márk Sági-Kazár",
+ "email": "mark.sagikazar@gmail.com",
+ "homepage": "https://sagikazarmark.hu"
+ }
+ ],
+ "description": "PSR-7 message implementation that also provides common utility methods",
+ "keywords": [
+ "http",
+ "message",
+ "psr-7",
+ "request",
+ "response",
+ "stream",
+ "uri",
+ "url"
+ ],
+ "support": {
+ "issues": "https://github.com/guzzle/psr7/issues",
+ "source": "https://github.com/guzzle/psr7/tree/2.4.3"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/GrahamCampbell",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/Nyholm",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-10-26T14:07:24+00:00"
+ },
+ {
+ "name": "guzzlehttp/uri-template",
+ "version": "v1.0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/guzzle/uri-template.git",
+ "reference": "b945d74a55a25a949158444f09ec0d3c120d69e2"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/guzzle/uri-template/zipball/b945d74a55a25a949158444f09ec0d3c120d69e2",
+ "reference": "b945d74a55a25a949158444f09ec0d3c120d69e2",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "php": "^7.2.5 || ^8.0",
+ "symfony/polyfill-php80": "^1.17"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^8.5.19 || ^9.5.8",
+ "uri-template/tests": "1.0.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "GuzzleHttp\\UriTemplate\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Graham Campbell",
+ "email": "hello@gjcampbell.co.uk",
+ "homepage": "https://github.com/GrahamCampbell"
+ },
+ {
+ "name": "Michael Dowling",
+ "email": "mtdowling@gmail.com",
+ "homepage": "https://github.com/mtdowling"
+ },
+ {
+ "name": "George Mponos",
+ "email": "gmponos@gmail.com",
+ "homepage": "https://github.com/gmponos"
+ },
+ {
+ "name": "Tobias Nyholm",
+ "email": "tobias.nyholm@gmail.com",
+ "homepage": "https://github.com/Nyholm"
+ }
+ ],
+ "description": "A polyfill class for uri_template of PHP",
+ "keywords": [
+ "guzzlehttp",
+ "uri-template"
+ ],
+ "support": {
+ "issues": "https://github.com/guzzle/uri-template/issues",
+ "source": "https://github.com/guzzle/uri-template/tree/v1.0.1"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/GrahamCampbell",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/Nyholm",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/uri-template",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2021-10-07T12:57:01+00:00"
+ },
+ {
+ "name": "league/flysystem",
+ "version": "1.1.9",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/thephpleague/flysystem.git",
+ "reference": "094defdb4a7001845300334e7c1ee2335925ef99"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/094defdb4a7001845300334e7c1ee2335925ef99",
+ "reference": "094defdb4a7001845300334e7c1ee2335925ef99",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "ext-fileinfo": "*",
+ "league/mime-type-detection": "^1.3",
+ "php": "^7.2.5 || ^8.0"
+ },
+ "conflict": {
+ "league/flysystem-sftp": "<1.0.6"
+ },
+ "require-dev": {
+ "phpspec/prophecy": "^1.11.1",
+ "phpunit/phpunit": "^8.5.8"
+ },
+ "suggest": {
+ "ext-ftp": "Allows you to use FTP server storage",
+ "ext-openssl": "Allows you to use FTPS server storage",
+ "league/flysystem-aws-s3-v2": "Allows you to use S3 storage with AWS SDK v2",
+ "league/flysystem-aws-s3-v3": "Allows you to use S3 storage with AWS SDK v3",
+ "league/flysystem-azure": "Allows you to use Windows Azure Blob storage",
+ "league/flysystem-cached-adapter": "Flysystem adapter decorator for metadata caching",
+ "league/flysystem-eventable-filesystem": "Allows you to use EventableFilesystem",
+ "league/flysystem-rackspace": "Allows you to use Rackspace Cloud Files",
+ "league/flysystem-sftp": "Allows you to use SFTP server storage via phpseclib",
+ "league/flysystem-webdav": "Allows you to use WebDAV storage",
+ "league/flysystem-ziparchive": "Allows you to use ZipArchive adapter",
+ "spatie/flysystem-dropbox": "Allows you to use Dropbox storage",
+ "srmklive/flysystem-dropbox-v2": "Allows you to use Dropbox storage for PHP 5 applications"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.1-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "League\\Flysystem\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Frank de Jonge",
+ "email": "info@frenky.net"
+ }
+ ],
+ "description": "Filesystem abstraction: Many filesystems, one API.",
+ "keywords": [
+ "Cloud Files",
+ "WebDAV",
+ "abstraction",
+ "aws",
+ "cloud",
+ "copy.com",
+ "dropbox",
+ "file systems",
+ "files",
+ "filesystem",
+ "filesystems",
+ "ftp",
+ "rackspace",
+ "remote",
+ "s3",
+ "sftp",
+ "storage"
+ ],
+ "support": {
+ "issues": "https://github.com/thephpleague/flysystem/issues",
+ "source": "https://github.com/thephpleague/flysystem/tree/1.1.9"
+ },
+ "funding": [
+ {
+ "url": "https://offset.earth/frankdejonge",
+ "type": "other"
+ }
+ ],
+ "time": "2021-12-09T09:40:50+00:00"
+ },
+ {
+ "name": "league/flysystem-cached-adapter",
+ "version": "1.1.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/thephpleague/flysystem-cached-adapter.git",
+ "reference": "d1925efb2207ac4be3ad0c40b8277175f99ffaff"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/thephpleague/flysystem-cached-adapter/zipball/d1925efb2207ac4be3ad0c40b8277175f99ffaff",
+ "reference": "d1925efb2207ac4be3ad0c40b8277175f99ffaff",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "league/flysystem": "~1.0",
+ "psr/cache": "^1.0.0"
+ },
+ "require-dev": {
+ "mockery/mockery": "~0.9",
+ "phpspec/phpspec": "^3.4",
+ "phpunit/phpunit": "^5.7",
+ "predis/predis": "~1.0",
+ "tedivm/stash": "~0.12"
+ },
+ "suggest": {
+ "ext-phpredis": "Pure C implemented extension for PHP"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "League\\Flysystem\\Cached\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "frankdejonge",
+ "email": "info@frenky.net"
+ }
+ ],
+ "description": "An adapter decorator to enable meta-data caching.",
+ "support": {
+ "issues": "https://github.com/thephpleague/flysystem-cached-adapter/issues",
+ "source": "https://github.com/thephpleague/flysystem-cached-adapter/tree/master"
+ },
+ "time": "2020-07-25T15:56:04+00:00"
+ },
+ {
+ "name": "league/mime-type-detection",
+ "version": "1.11.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/thephpleague/mime-type-detection.git",
+ "reference": "ff6248ea87a9f116e78edd6002e39e5128a0d4dd"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/thephpleague/mime-type-detection/zipball/ff6248ea87a9f116e78edd6002e39e5128a0d4dd",
+ "reference": "ff6248ea87a9f116e78edd6002e39e5128a0d4dd",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "ext-fileinfo": "*",
+ "php": "^7.2 || ^8.0"
+ },
+ "require-dev": {
+ "friendsofphp/php-cs-fixer": "^3.2",
+ "phpstan/phpstan": "^0.12.68",
+ "phpunit/phpunit": "^8.5.8 || ^9.3"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "League\\MimeTypeDetection\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Frank de Jonge",
+ "email": "info@frankdejonge.nl"
+ }
+ ],
+ "description": "Mime-type detection for Flysystem",
+ "support": {
+ "issues": "https://github.com/thephpleague/mime-type-detection/issues",
+ "source": "https://github.com/thephpleague/mime-type-detection/tree/1.11.0"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/frankdejonge",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/league/flysystem",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-04-17T13:12:02+00:00"
+ },
+ {
+ "name": "overtrue/pinyin",
+ "version": "4.0.8",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/overtrue/pinyin.git",
+ "reference": "04bdb4d33d50e8fb1aa5a824064c5151c4b15dc2"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/overtrue/pinyin/zipball/04bdb4d33d50e8fb1aa5a824064c5151c4b15dc2",
+ "reference": "04bdb4d33d50e8fb1aa5a824064c5151c4b15dc2",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "php": ">=7.1"
+ },
+ "require-dev": {
+ "brainmaestro/composer-git-hooks": "^2.7",
+ "friendsofphp/php-cs-fixer": "^2.16",
+ "phpunit/phpunit": "~8.0"
+ },
+ "type": "library",
+ "extra": {
+ "hooks": {
+ "pre-commit": [
+ "composer test",
+ "composer fix-style"
+ ],
+ "pre-push": [
+ "composer test",
+ "composer check-style"
+ ]
+ }
+ },
+ "autoload": {
+ "files": [
+ "src/const.php"
+ ],
+ "psr-4": {
+ "Overtrue\\Pinyin\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "overtrue",
+ "email": "anzhengchao@gmail.com",
+ "homepage": "http://github.com/overtrue"
+ }
+ ],
+ "description": "Chinese to pinyin translator.",
+ "homepage": "https://github.com/overtrue/pinyin",
+ "keywords": [
+ "Chinese",
+ "Pinyin",
+ "cn2pinyin"
+ ],
+ "support": {
+ "issues": "https://github.com/overtrue/pinyin/issues",
+ "source": "https://github.com/overtrue/pinyin/tree/4.0.8"
+ },
+ "funding": [
+ {
+ "url": "https://www.patreon.com/overtrue",
+ "type": "patreon"
+ }
+ ],
+ "time": "2021-07-19T03:43:32+00:00"
+ },
+ {
+ "name": "psr/cache",
+ "version": "1.0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/cache.git",
+ "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8",
+ "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "php": ">=5.3.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Psr\\Cache\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "http://www.php-fig.org/"
+ }
+ ],
+ "description": "Common interface for caching libraries",
+ "keywords": [
+ "cache",
+ "psr",
+ "psr-6"
+ ],
+ "support": {
+ "source": "https://github.com/php-fig/cache/tree/master"
+ },
+ "time": "2016-08-06T20:24:11+00:00"
+ },
+ {
+ "name": "psr/container",
+ "version": "1.1.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/container.git",
+ "reference": "513e0666f7216c7459170d56df27dfcefe1689ea"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea",
+ "reference": "513e0666f7216c7459170d56df27dfcefe1689ea",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "php": ">=7.4.0"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Psr\\Container\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "https://www.php-fig.org/"
+ }
+ ],
+ "description": "Common Container Interface (PHP FIG PSR-11)",
+ "homepage": "https://github.com/php-fig/container",
+ "keywords": [
+ "PSR-11",
+ "container",
+ "container-interface",
+ "container-interop",
+ "psr"
+ ],
+ "support": {
+ "issues": "https://github.com/php-fig/container/issues",
+ "source": "https://github.com/php-fig/container/tree/1.1.2"
+ },
+ "time": "2021-11-05T16:50:12+00:00"
+ },
+ {
+ "name": "psr/http-client",
+ "version": "1.0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/http-client.git",
+ "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/http-client/zipball/2dfb5f6c5eff0e91e20e913f8c5452ed95b86621",
+ "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "php": "^7.0 || ^8.0",
+ "psr/http-message": "^1.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Psr\\Http\\Client\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "http://www.php-fig.org/"
+ }
+ ],
+ "description": "Common interface for HTTP clients",
+ "homepage": "https://github.com/php-fig/http-client",
+ "keywords": [
+ "http",
+ "http-client",
+ "psr",
+ "psr-18"
+ ],
+ "support": {
+ "source": "https://github.com/php-fig/http-client/tree/master"
+ },
+ "time": "2020-06-29T06:28:15+00:00"
+ },
+ {
+ "name": "psr/http-factory",
+ "version": "1.0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/http-factory.git",
+ "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/http-factory/zipball/12ac7fcd07e5b077433f5f2bee95b3a771bf61be",
+ "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "php": ">=7.0.0",
+ "psr/http-message": "^1.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Psr\\Http\\Message\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "http://www.php-fig.org/"
+ }
+ ],
+ "description": "Common interfaces for PSR-7 HTTP message factories",
+ "keywords": [
+ "factory",
+ "http",
+ "message",
+ "psr",
+ "psr-17",
+ "psr-7",
+ "request",
+ "response"
+ ],
+ "support": {
+ "source": "https://github.com/php-fig/http-factory/tree/master"
+ },
+ "time": "2019-04-30T12:38:16+00:00"
+ },
+ {
+ "name": "psr/http-message",
+ "version": "1.0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/http-message.git",
+ "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
+ "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "php": ">=5.3.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Psr\\Http\\Message\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "http://www.php-fig.org/"
+ }
+ ],
+ "description": "Common interface for HTTP messages",
+ "homepage": "https://github.com/php-fig/http-message",
+ "keywords": [
+ "http",
+ "http-message",
+ "psr",
+ "psr-7",
+ "request",
+ "response"
+ ],
+ "support": {
+ "source": "https://github.com/php-fig/http-message/tree/master"
+ },
+ "time": "2016-08-06T14:39:51+00:00"
+ },
+ {
+ "name": "psr/log",
+ "version": "1.1.4",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/log.git",
+ "reference": "d49695b909c3b7628b6289db5479a1c204601f11"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11",
+ "reference": "d49695b909c3b7628b6289db5479a1c204601f11",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "php": ">=5.3.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.1.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Psr\\Log\\": "Psr/Log/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "https://www.php-fig.org/"
+ }
+ ],
+ "description": "Common interface for logging libraries",
+ "homepage": "https://github.com/php-fig/log",
+ "keywords": [
+ "log",
+ "psr",
+ "psr-3"
+ ],
+ "support": {
+ "source": "https://github.com/php-fig/log/tree/1.1.4"
+ },
+ "time": "2021-05-03T11:20:27+00:00"
+ },
+ {
+ "name": "psr/simple-cache",
+ "version": "1.0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/simple-cache.git",
+ "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
+ "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "php": ">=5.3.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Psr\\SimpleCache\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "http://www.php-fig.org/"
+ }
+ ],
+ "description": "Common interfaces for simple caching",
+ "keywords": [
+ "cache",
+ "caching",
+ "psr",
+ "psr-16",
+ "simple-cache"
+ ],
+ "support": {
+ "source": "https://github.com/php-fig/simple-cache/tree/master"
+ },
+ "time": "2017-10-23T01:57:42+00:00"
+ },
+ {
+ "name": "ralouphie/getallheaders",
+ "version": "3.0.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/ralouphie/getallheaders.git",
+ "reference": "120b605dfeb996808c31b6477290a714d356e822"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822",
+ "reference": "120b605dfeb996808c31b6477290a714d356e822",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "php": ">=5.6"
+ },
+ "require-dev": {
+ "php-coveralls/php-coveralls": "^2.1",
+ "phpunit/phpunit": "^5 || ^6.5"
+ },
+ "type": "library",
+ "autoload": {
+ "files": [
+ "src/getallheaders.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Ralph Khattar",
+ "email": "ralph.khattar@gmail.com"
+ }
+ ],
+ "description": "A polyfill for getallheaders.",
+ "support": {
+ "issues": "https://github.com/ralouphie/getallheaders/issues",
+ "source": "https://github.com/ralouphie/getallheaders/tree/develop"
+ },
+ "time": "2019-03-08T08:55:37+00:00"
+ },
+ {
+ "name": "symfony/deprecation-contracts",
+ "version": "v2.5.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/deprecation-contracts.git",
+ "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e8b495ea28c1d97b5e0c121748d6f9b53d075c66",
+ "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "php": ">=7.1"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "2.5-dev"
+ },
+ "thanks": {
+ "name": "symfony/contracts",
+ "url": "https://github.com/symfony/contracts"
+ }
+ },
+ "autoload": {
+ "files": [
+ "function.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "A generic function and convention to trigger deprecation notices",
+ "homepage": "https://symfony.com",
+ "support": {
+ "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.2"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-01-02T09:53:40+00:00"
+ },
+ {
+ "name": "symfony/polyfill-php80",
+ "version": "v1.26.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/polyfill-php80.git",
+ "reference": "cfa0ae98841b9e461207c13ab093d76b0fa7bace"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/cfa0ae98841b9e461207c13ab093d76b0fa7bace",
+ "reference": "cfa0ae98841b9e461207c13ab093d76b0fa7bace",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "php": ">=7.1"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "1.26-dev"
+ },
+ "thanks": {
+ "name": "symfony/polyfill",
+ "url": "https://github.com/symfony/polyfill"
+ }
+ },
+ "autoload": {
+ "files": [
+ "bootstrap.php"
+ ],
+ "psr-4": {
+ "Symfony\\Polyfill\\Php80\\": ""
+ },
+ "classmap": [
+ "Resources/stubs"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Ion Bazan",
+ "email": "ion.bazan@gmail.com"
+ },
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "polyfill",
+ "portable",
+ "shim"
+ ],
+ "support": {
+ "source": "https://github.com/symfony/polyfill-php80/tree/v1.26.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-05-10T07:21:04+00:00"
+ },
+ {
+ "name": "topthink/framework",
+ "version": "v6.1.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/top-think/framework.git",
+ "reference": "2cb56f3e6f3c479fe90ea5f28d38d3b5ef6c4210"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/top-think/framework/zipball/2cb56f3e6f3c479fe90ea5f28d38d3b5ef6c4210",
+ "reference": "2cb56f3e6f3c479fe90ea5f28d38d3b5ef6c4210",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "ext-json": "*",
+ "ext-mbstring": "*",
+ "php": ">=7.2.5",
+ "psr/container": "~1.0",
+ "psr/http-message": "^1.0",
+ "psr/log": "~1.0",
+ "psr/simple-cache": "^1.0",
+ "topthink/think-helper": "^3.1.1",
+ "topthink/think-orm": "^2.0"
+ },
+ "require-dev": {
+ "guzzlehttp/psr7": "^2.1.0",
+ "mikey179/vfsstream": "^1.6",
+ "mockery/mockery": "^1.2",
+ "phpunit/phpunit": "^7.0"
+ },
+ "type": "library",
+ "autoload": {
+ "files": [],
+ "psr-4": {
+ "think\\": "src/think/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "Apache-2.0"
+ ],
+ "authors": [
+ {
+ "name": "liu21st",
+ "email": "liu21st@gmail.com"
+ },
+ {
+ "name": "yunwuxin",
+ "email": "448901948@qq.com"
+ }
+ ],
+ "description": "The ThinkPHP Framework.",
+ "homepage": "http://thinkphp.cn/",
+ "keywords": [
+ "framework",
+ "orm",
+ "thinkphp"
+ ],
+ "support": {
+ "issues": "https://github.com/top-think/framework/issues",
+ "source": "https://github.com/top-think/framework/tree/v6.1.1"
+ },
+ "time": "2022-10-26T03:48:53+00:00"
+ },
+ {
+ "name": "topthink/think-filesystem",
+ "version": "v1.0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/top-think/think-filesystem.git",
+ "reference": "cfc510520db9bcd22d8d80f51d7e415a2f470af6"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/top-think/think-filesystem/zipball/cfc510520db9bcd22d8d80f51d7e415a2f470af6",
+ "reference": "cfc510520db9bcd22d8d80f51d7e415a2f470af6",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "league/flysystem": "^1.1.4",
+ "league/flysystem-cached-adapter": "^1.0",
+ "php": ">=7.2.5",
+ "topthink/framework": "^6.1"
+ },
+ "require-dev": {
+ "mikey179/vfsstream": "^1.6",
+ "mockery/mockery": "^1.2",
+ "phpunit/phpunit": "^8.0"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "think\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "Apache-2.0"
+ ],
+ "authors": [
+ {
+ "name": "yunwuxin",
+ "email": "448901948@qq.com"
+ }
+ ],
+ "description": "The ThinkPHP6.1 Filesystem Package",
+ "support": {
+ "issues": "https://github.com/top-think/think-filesystem/issues",
+ "source": "https://github.com/top-think/think-filesystem/tree/v1.0.1"
+ },
+ "time": "2022-10-26T03:50:24+00:00"
+ },
+ {
+ "name": "topthink/think-helper",
+ "version": "v3.1.6",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/top-think/think-helper.git",
+ "reference": "769acbe50a4274327162f9c68ec2e89a38eb2aff"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/top-think/think-helper/zipball/769acbe50a4274327162f9c68ec2e89a38eb2aff",
+ "reference": "769acbe50a4274327162f9c68ec2e89a38eb2aff",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "php": ">=7.1.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^9.5"
+ },
+ "type": "library",
+ "autoload": {
+ "files": [
+ "src/helper.php"
+ ],
+ "psr-4": {
+ "think\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "Apache-2.0"
+ ],
+ "authors": [
+ {
+ "name": "yunwuxin",
+ "email": "448901948@qq.com"
+ }
+ ],
+ "description": "The ThinkPHP6 Helper Package",
+ "support": {
+ "issues": "https://github.com/top-think/think-helper/issues",
+ "source": "https://github.com/top-think/think-helper/tree/v3.1.6"
+ },
+ "time": "2021-12-15T04:27:55+00:00"
+ },
+ {
+ "name": "topthink/think-orm",
+ "version": "v2.0.54",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/top-think/think-orm.git",
+ "reference": "97b061b47616301ff29fbd4c35ed9184e1162e4e"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/top-think/think-orm/zipball/97b061b47616301ff29fbd4c35ed9184e1162e4e",
+ "reference": "97b061b47616301ff29fbd4c35ed9184e1162e4e",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "ext-json": "*",
+ "ext-pdo": "*",
+ "php": ">=7.1.0",
+ "psr/log": "^1.0|^2.0",
+ "psr/simple-cache": "^1.0|^2.0",
+ "topthink/think-helper": "^3.1"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^7|^8|^9.5"
+ },
+ "type": "library",
+ "autoload": {
+ "files": [
+ "stubs/load_stubs.php"
+ ],
+ "psr-4": {
+ "think\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "Apache-2.0"
+ ],
+ "authors": [
+ {
+ "name": "liu21st",
+ "email": "liu21st@gmail.com"
+ }
+ ],
+ "description": "think orm",
+ "keywords": [
+ "database",
+ "orm"
+ ],
+ "support": {
+ "issues": "https://github.com/top-think/think-orm/issues",
+ "source": "https://github.com/top-think/think-orm/tree/v2.0.54"
+ },
+ "time": "2022-07-05T05:25:51+00:00"
+ },
+ {
+ "name": "topthink/think-worker",
+ "version": "v3.0.7",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/top-think/think-worker.git",
+ "reference": "9ba54333f337ee2c3f06054bb896bba9696d926c"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/top-think/think-worker/zipball/9ba54333f337ee2c3f06054bb896bba9696d926c",
+ "reference": "9ba54333f337ee2c3f06054bb896bba9696d926c",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "ext-fileinfo": "*",
+ "topthink/framework": "^6.0",
+ "workerman/gateway-worker": "^3.0.0",
+ "workerman/workerman": "^3.5.23"
+ },
+ "type": "library",
+ "extra": {
+ "think": {
+ "services": [
+ "think\\worker\\Service"
+ ],
+ "config": {
+ "worker": "src/config/worker.php",
+ "worker_server": "src/config/server.php",
+ "gateway_worker": "src/config/gateway.php"
+ }
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "think\\worker\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "Apache-2.0"
+ ],
+ "authors": [
+ {
+ "name": "liu21st",
+ "email": "liu21st@gmail.com"
+ }
+ ],
+ "description": "workerman extend for thinkphp6.0",
+ "support": {
+ "issues": "https://github.com/top-think/think-worker/issues",
+ "source": "https://github.com/top-think/think-worker/tree/v3.0.7"
+ },
+ "time": "2022-10-26T08:04:08+00:00"
+ },
+ {
+ "name": "wechatpay/wechatpay",
+ "version": "1.4.6",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/wechatpay-apiv3/wechatpay-php.git",
+ "reference": "edbdb6bb19e0818b0576043b265ff1b1e188d668"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/wechatpay-apiv3/wechatpay-php/zipball/edbdb6bb19e0818b0576043b265ff1b1e188d668",
+ "reference": "edbdb6bb19e0818b0576043b265ff1b1e188d668",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "ext-curl": "*",
+ "ext-libxml": "*",
+ "ext-openssl": "*",
+ "ext-simplexml": "*",
+ "guzzlehttp/guzzle": "^6.5 || ^7.0",
+ "guzzlehttp/uri-template": "^0.2 || ^1.0",
+ "php": ">=7.1.2"
+ },
+ "require-dev": {
+ "phpstan/phpstan": "^0.12.89 || ^1.0",
+ "phpunit/phpunit": "^7.5 || ^8.5.16 || ^9.3.5"
+ },
+ "bin": [
+ "bin/CertificateDownloader.php"
+ ],
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "WeChatPay\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "Apache-2.0"
+ ],
+ "authors": [
+ {
+ "name": "James ZHANG",
+ "homepage": "https://github.com/TheNorthMemory"
+ },
+ {
+ "name": "WeChatPay Community",
+ "homepage": "https://developers.weixin.qq.com/community/pay"
+ }
+ ],
+ "description": "[A]Sync Chainable WeChatPay v2&v3's OpenAPI SDK for PHP",
+ "homepage": "https://pay.weixin.qq.com/",
+ "keywords": [
+ "AES-GCM",
+ "aes-ecb",
+ "openapi-chainable",
+ "rsa-oaep",
+ "wechatpay",
+ "xml-builder",
+ "xml-parser"
+ ],
+ "support": {
+ "issues": "https://github.com/wechatpay-apiv3/wechatpay-php/issues",
+ "source": "https://github.com/wechatpay-apiv3/wechatpay-php/tree/v1.4.6"
+ },
+ "time": "2022-08-19T09:14:39+00:00"
+ },
+ {
+ "name": "workerman/gateway-worker",
+ "version": "v3.0.22",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/walkor/GatewayWorker.git",
+ "reference": "a615036c482d11f68b693998575e804752ef9068"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/walkor/GatewayWorker/zipball/a615036c482d11f68b693998575e804752ef9068",
+ "reference": "a615036c482d11f68b693998575e804752ef9068",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "workerman/workerman": ">=3.5.0"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "GatewayWorker\\": "./src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "homepage": "http://www.workerman.net",
+ "keywords": [
+ "communication",
+ "distributed"
+ ],
+ "support": {
+ "issues": "https://github.com/walkor/GatewayWorker/issues",
+ "source": "https://github.com/walkor/GatewayWorker/tree/v3.0.22"
+ },
+ "funding": [
+ {
+ "url": "https://opencollective.com/walkor",
+ "type": "open_collective"
+ },
+ {
+ "url": "https://www.patreon.com/walkor",
+ "type": "patreon"
+ }
+ ],
+ "time": "2021-12-23T13:13:09+00:00"
+ },
+ {
+ "name": "workerman/workerman",
+ "version": "v3.5.33",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/walkor/workerman.git",
+ "reference": "5eb02cf161ec1e5b7c0e4a8556d0541654c2b6da"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/walkor/workerman/zipball/5eb02cf161ec1e5b7c0e4a8556d0541654c2b6da",
+ "reference": "5eb02cf161ec1e5b7c0e4a8556d0541654c2b6da",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "php": ">=5.3"
+ },
+ "suggest": {
+ "ext-event": "For better performance. "
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Workerman\\": "./"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "walkor",
+ "email": "walkor@workerman.net",
+ "homepage": "http://www.workerman.net",
+ "role": "Developer"
+ }
+ ],
+ "description": "An asynchronous event driven PHP framework for easily building fast, scalable network applications.",
+ "homepage": "http://www.workerman.net",
+ "keywords": [
+ "asynchronous",
+ "event-loop"
+ ],
+ "support": {
+ "email": "walkor@workerman.net",
+ "forum": "http://wenda.workerman.net/",
+ "issues": "https://github.com/walkor/workerman/issues",
+ "source": "https://github.com/walkor/workerman",
+ "wiki": "http://doc.workerman.net/"
+ },
+ "funding": [
+ {
+ "url": "https://opencollective.com/workerman",
+ "type": "open_collective"
+ },
+ {
+ "url": "https://www.patreon.com/walkor",
+ "type": "patreon"
+ }
+ ],
+ "time": "2022-11-17T03:32:28+00:00"
+ }
+ ],
+ "packages-dev": [
+ {
+ "name": "symfony/polyfill-mbstring",
+ "version": "v1.26.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/polyfill-mbstring.git",
+ "reference": "9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e",
+ "reference": "9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "php": ">=7.1"
+ },
+ "provide": {
+ "ext-mbstring": "*"
+ },
+ "suggest": {
+ "ext-mbstring": "For best performance"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "1.26-dev"
+ },
+ "thanks": {
+ "name": "symfony/polyfill",
+ "url": "https://github.com/symfony/polyfill"
+ }
+ },
+ "autoload": {
+ "files": [
+ "bootstrap.php"
+ ],
+ "psr-4": {
+ "Symfony\\Polyfill\\Mbstring\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony polyfill for the Mbstring extension",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "mbstring",
+ "polyfill",
+ "portable",
+ "shim"
+ ],
+ "support": {
+ "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.26.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-05-24T11:49:31+00:00"
+ },
+ {
+ "name": "symfony/polyfill-php72",
+ "version": "v1.26.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/polyfill-php72.git",
+ "reference": "bf44a9fd41feaac72b074de600314a93e2ae78e2"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/bf44a9fd41feaac72b074de600314a93e2ae78e2",
+ "reference": "bf44a9fd41feaac72b074de600314a93e2ae78e2",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "php": ">=7.1"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "1.26-dev"
+ },
+ "thanks": {
+ "name": "symfony/polyfill",
+ "url": "https://github.com/symfony/polyfill"
+ }
+ },
+ "autoload": {
+ "files": [
+ "bootstrap.php"
+ ],
+ "psr-4": {
+ "Symfony\\Polyfill\\Php72\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "polyfill",
+ "portable",
+ "shim"
+ ],
+ "support": {
+ "source": "https://github.com/symfony/polyfill-php72/tree/v1.26.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-05-24T11:49:31+00:00"
+ },
+ {
+ "name": "symfony/var-dumper",
+ "version": "v4.4.46",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/var-dumper.git",
+ "reference": "90425fd98d1ecad98e4b2dca9f54f62069193b15"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/var-dumper/zipball/90425fd98d1ecad98e4b2dca9f54f62069193b15",
+ "reference": "90425fd98d1ecad98e4b2dca9f54f62069193b15",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "php": ">=7.1.3",
+ "symfony/polyfill-mbstring": "~1.0",
+ "symfony/polyfill-php72": "~1.5",
+ "symfony/polyfill-php80": "^1.16"
+ },
+ "conflict": {
+ "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0",
+ "symfony/console": "<3.4"
+ },
+ "require-dev": {
+ "ext-iconv": "*",
+ "symfony/console": "^3.4|^4.0|^5.0",
+ "symfony/process": "^4.4|^5.0",
+ "twig/twig": "^1.43|^2.13|^3.0.4"
+ },
+ "suggest": {
+ "ext-iconv": "To convert non-UTF-8 strings to UTF-8 (or symfony/polyfill-iconv in case ext-iconv cannot be used).",
+ "ext-intl": "To show region name in time zone dump",
+ "symfony/console": "To use the ServerDumpCommand and/or the bin/var-dump-server script"
+ },
+ "bin": [
+ "Resources/bin/var-dump-server"
+ ],
+ "type": "library",
+ "autoload": {
+ "files": [
+ "Resources/functions/dump.php"
+ ],
+ "psr-4": {
+ "Symfony\\Component\\VarDumper\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Provides mechanisms for walking through any arbitrary PHP variable",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "debug",
+ "dump"
+ ],
+ "support": {
+ "source": "https://github.com/symfony/var-dumper/tree/v4.4.46"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-09-03T23:07:25+00:00"
+ },
+ {
+ "name": "topthink/think-trace",
+ "version": "v1.5",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/top-think/think-trace.git",
+ "reference": "55027fd79abb744f32a3be8d9e1ccf873a3ca9b7"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/top-think/think-trace/zipball/55027fd79abb744f32a3be8d9e1ccf873a3ca9b7",
+ "reference": "55027fd79abb744f32a3be8d9e1ccf873a3ca9b7",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "php": ">=7.1.0",
+ "topthink/framework": "^6.0"
+ },
+ "type": "library",
+ "extra": {
+ "think": {
+ "services": [
+ "think\\trace\\Service"
+ ],
+ "config": {
+ "trace": "src/config.php"
+ }
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "think\\trace\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "Apache-2.0"
+ ],
+ "authors": [
+ {
+ "name": "liu21st",
+ "email": "liu21st@gmail.com"
+ }
+ ],
+ "description": "thinkphp debug trace",
+ "support": {
+ "issues": "https://github.com/top-think/think-trace/issues",
+ "source": "https://github.com/top-think/think-trace/tree/v1.5"
+ },
+ "time": "2022-10-26T07:56:45+00:00"
+ }
+ ],
+ "aliases": [],
+ "minimum-stability": "stable",
+ "stability-flags": [],
+ "prefer-stable": false,
+ "prefer-lowest": false,
+ "platform": {
+ "php": ">=7.2.5",
+ "ext-json": "*"
+ },
+ "platform-dev": [],
+ "plugin-api-version": "2.3.0"
+}
diff --git a/config/app.php b/config/app.php
new file mode 100644
index 0000000..8c15313
--- /dev/null
+++ b/config/app.php
@@ -0,0 +1,32 @@
+ env('app.host', ''),
+ // 应用的命名空间
+ 'app_namespace' => '',
+ // 是否启用路由
+ 'with_route' => true,
+ // 默认应用
+ 'default_app' => 'index',
+ // 默认时区
+ 'default_timezone' => 'Asia/Shanghai',
+
+ // 应用映射(自动多应用模式有效)
+ 'app_map' => [],
+ // 域名绑定(自动多应用模式有效)
+ 'domain_bind' => [],
+ // 禁止URL访问的应用列表(自动多应用模式有效)
+ 'deny_app_list' => [],
+
+ // 异常页面的模板文件
+ 'exception_tmpl' => app()->getThinkPath() . 'tpl/think_exception.tpl',
+
+ // 错误显示信息,非调试模式有效
+ 'error_message' => '页面错误!请稍后再试~',
+ // 显示错误信息
+ 'show_error_msg' => true,
+];
diff --git a/config/cache.php b/config/cache.php
new file mode 100644
index 0000000..b4d484e
--- /dev/null
+++ b/config/cache.php
@@ -0,0 +1,41 @@
+ env('cache.driver', 'file'),
+
+ // 缓存连接方式配置
+ 'stores' => [
+ 'file' => [
+ // 驱动方式
+ 'type' => 'File',
+ // 缓存保存目录
+ 'path' => '',
+ // 缓存前缀
+ 'prefix' => '',
+ // 缓存有效期 0表示永久缓存
+ 'expire' => 0,
+ // 缓存标签前缀
+ 'tag_prefix' => 'tag:',
+ // 序列化机制 例如 ['serialize', 'unserialize']
+ 'serialize' => [],
+ ],
+ // 更多的缓存连接
+ 'redis' => [
+ 'type' => 'redis',
+ 'host' => '127.0.0.1',
+ 'port' => '6379',
+ 'password' => '',
+ 'select' => '0',
+ // 全局缓存有效期(0为永久有效)
+ 'expire' => 0,
+ // 缓存前缀
+ 'prefix' => '',
+ 'timeout' => 0,
+ ],
+ ],
+];
diff --git a/config/command.php b/config/command.php
new file mode 100644
index 0000000..31f3bd4
--- /dev/null
+++ b/config/command.php
@@ -0,0 +1,5 @@
+ 'app\command\ReservationTask',
+];
\ No newline at end of file
diff --git a/config/console.php b/config/console.php
new file mode 100644
index 0000000..54028f5
--- /dev/null
+++ b/config/console.php
@@ -0,0 +1,11 @@
+ [
+ 'reservation:task' => 'app\command\ReservationTask',
+ 'test:task' => 'app\command\TestTask',
+ ],
+];
diff --git a/config/cookie.php b/config/cookie.php
new file mode 100644
index 0000000..d3b3aab
--- /dev/null
+++ b/config/cookie.php
@@ -0,0 +1,20 @@
+ 0,
+ // cookie 保存路径
+ 'path' => '/',
+ // cookie 有效域名
+ 'domain' => '',
+ // cookie 启用安全传输
+ 'secure' => false,
+ // httponly设置
+ 'httponly' => false,
+ // 是否使用 setcookie
+ 'setcookie' => true,
+ // samesite 设置,支持 'strict' 'lax'
+ 'samesite' => '',
+];
diff --git a/config/database.php b/config/database.php
new file mode 100644
index 0000000..056f45a
--- /dev/null
+++ b/config/database.php
@@ -0,0 +1,63 @@
+ env('database.driver', 'mysql'),
+
+ // 自定义时间查询规则
+ 'time_query_rule' => [],
+
+ // 自动写入时间戳字段
+ // true为自动识别类型 false关闭
+ // 字符串则明确指定时间字段类型 支持 int timestamp datetime date
+ 'auto_timestamp' => true,
+
+ // 时间字段取出后的默认时间格式
+ 'datetime_format' => 'Y-m-d H:i:s',
+
+ // 时间字段配置 配置格式:create_time,update_time
+ 'datetime_field' => '',
+
+ // 数据库连接配置信息
+ 'connections' => [
+ 'mysql' => [
+ // 数据库类型
+ 'type' => env('database.type', 'mysql'),
+ // 服务器地址
+ 'hostname' => env('database.hostname', '127.0.0.1'),
+ // 数据库名
+ 'database' => env('database.database', 'charge'),
+ // 用户名
+ 'username' => env('database.username', 'root'),
+ // 密码
+ 'password' => env('database.password', ''),
+ // 端口
+ 'hostport' => env('database.hostport', '3306'),
+ // 数据库连接参数
+ 'params' => [],
+ // 数据库编码默认采用utf8
+ 'charset' => env('database.charset', 'utf8'),
+ // 数据库表前缀
+ 'prefix' => env('database.prefix', ''),
+
+ // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
+ 'deploy' => 0,
+ // 数据库读写是否分离 主从式有效
+ 'rw_separate' => false,
+ // 读写分离后 主服务器数量
+ 'master_num' => 1,
+ // 指定从服务器序号
+ 'slave_no' => '',
+ // 是否严格检查字段是否存在
+ 'fields_strict' => true,
+ // 是否需要断线重连
+ 'break_reconnect' => false,
+ // 监听SQL
+ 'trigger_sql' => env('app_debug', true),
+ // 开启字段缓存
+ 'fields_cache' => false,
+ ],
+
+ // 更多的数据库配置信息
+ ],
+];
diff --git a/config/filesystem.php b/config/filesystem.php
new file mode 100644
index 0000000..fecdd02
--- /dev/null
+++ b/config/filesystem.php
@@ -0,0 +1,24 @@
+ env('filesystem.driver', 'local'),
+ // 磁盘列表
+ 'disks' => [
+ 'local' => [
+ 'type' => 'local',
+ 'root' => app()->getRuntimePath() . 'storage',
+ ],
+ 'public' => [
+ // 磁盘类型
+ 'type' => 'local',
+ // 磁盘路径
+ 'root' => app()->getRootPath() . 'public/static',
+ // 磁盘路径对应的外部URL路径
+ 'url' => '/static',
+ // 可见性
+ 'visibility' => 'public',
+ ],
+ // 更多的磁盘配置信息
+ ],
+];
diff --git a/config/gateway_worker.php b/config/gateway_worker.php
new file mode 100644
index 0000000..21d1ebe
--- /dev/null
+++ b/config/gateway_worker.php
@@ -0,0 +1,45 @@
+
+// +----------------------------------------------------------------------
+// +----------------------------------------------------------------------
+// | Workerman设置 仅对 php think worker:gateway 指令有效
+// +----------------------------------------------------------------------
+return [
+ // 扩展自身需要的配置
+ 'protocol' => 'websocket', // 协议 支持 tcp udp unix http websocket text
+ 'host' => '0.0.0.0', // 监听地址
+ 'port' => 2348, // 监听端口
+ 'socket' => '', // 完整监听地址
+ 'context' => [], // socket 上下文选项
+ 'register_deploy' => true, // 是否需要部署register
+ 'businessWorker_deploy' => true, // 是否需要部署businessWorker
+ 'gateway_deploy' => true, // 是否需要部署gateway
+
+ // Register配置
+ 'registerAddress' => '127.0.0.1:1236',
+
+ // Gateway配置
+ 'name' => 'thinkphp',
+ 'count' => 1,
+ 'lanIp' => '127.0.0.1',
+ 'startPort' => 2000,
+ 'daemonize' => false,
+ 'pingInterval' => 30,
+ 'pingNotResponseLimit' => 0,
+ 'pingData' => '{"type":"ping"}',
+
+ // BusinsessWorker配置
+ 'businessWorker' => [
+ 'name' => 'BusinessWorker',
+ 'count' => 1,
+ 'eventHandler' => '\think\worker\Events',
+ ],
+
+];
diff --git a/config/hard.php b/config/hard.php
new file mode 100644
index 0000000..67c703e
--- /dev/null
+++ b/config/hard.php
@@ -0,0 +1,19 @@
+ "MACFHBM3X",//运营商标识
+ "OperatorSecret" => "kZ91W50hNZdjuKR2",//运营商秘钥 e30efd732c2eda2a
+ "DataSecret" => "DNY4L10eWqrw1Ei9",//消息密钥 48535870e30efd732c2eda2aafad899b
+ "DataSecretIV" => "jdJptx39XUdOhN1f",//消息密钥初始化向量 08c4202c5961b521
+ "SigSecret" => "p1d8h63I9Z3lxDnY",//签名密钥 4a62990208c4202c5961b521314782b4
+
+ //seq
+ "Seq" => '0001',
+ 'url' => 'https://hlht.teld.cn/evcs/v20191230/',
+];
\ No newline at end of file
diff --git a/config/lang.php b/config/lang.php
new file mode 100644
index 0000000..59f320f
--- /dev/null
+++ b/config/lang.php
@@ -0,0 +1,27 @@
+ env('lang.default_lang', 'zh-cn'),
+ // 允许的语言列表
+ 'allow_lang_list' => [],
+ // 多语言自动侦测变量名
+ 'detect_var' => 'lang',
+ // 是否使用Cookie记录
+ 'use_cookie' => true,
+ // 多语言cookie变量
+ 'cookie_var' => 'think_lang',
+ // 多语言header变量
+ 'header_var' => 'think-lang',
+ // 扩展语言包
+ 'extend_list' => [],
+ // Accept-Language转义为对应语言包名称
+ 'accept_language' => [
+ 'zh-hans-cn' => 'zh-cn',
+ ],
+ // 是否支持语言分组
+ 'allow_group' => false,
+];
diff --git a/config/log.php b/config/log.php
new file mode 100644
index 0000000..c277a0c
--- /dev/null
+++ b/config/log.php
@@ -0,0 +1,45 @@
+ env('log.channel', 'file'),
+ // 日志记录级别
+ 'level' => ['warning','error'],//'warning','error'
+ // 日志类型记录的通道 ['error'=>'email',...]
+ 'type_channel' => [],
+ // 关闭全局日志写入
+ 'close' => false,
+ // 全局日志处理 支持闭包
+ 'processor' => null,
+
+ // 日志通道列表
+ 'channels' => [
+ 'file' => [
+ // 日志记录方式
+ 'type' => 'File',
+ // 日志保存目录
+ 'path' => '',
+ // 单文件日志写入
+ 'single' => false,
+ // 独立日志级别
+ 'apart_level' => [],
+ // 最大日志文件数量
+ 'max_files' => 1000,
+ // 使用JSON格式记录
+ 'json' => false,
+ // 日志处理
+ 'processor' => null,
+ // 关闭通道日志写入
+ 'close' => false,
+ // 日志输出格式化
+ 'format' => '[%s][%s] %s',
+ // 是否实时写入
+ 'realtime_write' => false,
+ ],
+ // 其它日志通道配置
+ ],
+
+];
diff --git a/config/middleware.php b/config/middleware.php
new file mode 100644
index 0000000..7e1972f
--- /dev/null
+++ b/config/middleware.php
@@ -0,0 +1,8 @@
+ [],
+ // 优先级设置,此数组中的中间件会按照数组中的顺序优先执行
+ 'priority' => [],
+];
diff --git a/config/route.php b/config/route.php
new file mode 100644
index 0000000..2f4cd12
--- /dev/null
+++ b/config/route.php
@@ -0,0 +1,45 @@
+ '/',
+ // URL伪静态后缀
+ 'url_html_suffix' => 'html',
+ // URL普通方式参数 用于自动生成
+ 'url_common_param' => true,
+ // 是否开启路由延迟解析
+ 'url_lazy_route' => false,
+ // 是否强制使用路由
+ 'url_route_must' => false,
+ // 合并路由规则
+ 'route_rule_merge' => false,
+ // 路由是否完全匹配
+ 'route_complete_match' => false,
+ // 访问控制器层名称
+ 'controller_layer' => 'controller',
+ // 空控制器名
+ 'empty_controller' => 'Error',
+ // 是否使用控制器后缀
+ 'controller_suffix' => false,
+ // 默认的路由变量规则
+ 'default_route_pattern' => '[\w\.]+',
+ // 是否开启请求缓存 true自动缓存 支持设置请求缓存规则
+ 'request_cache_key' => false,
+ // 请求缓存有效期
+ 'request_cache_expire' => null,
+ // 全局请求缓存排除规则
+ 'request_cache_except' => [],
+ // 默认控制器名
+ 'default_controller' => 'Index',
+ // 默认操作名
+ 'default_action' => 'index',
+ // 操作方法后缀
+ 'action_suffix' => '',
+ // 默认JSONP格式返回的处理方法
+ 'default_jsonp_handler' => 'jsonpReturn',
+ // 默认JSONP处理方法
+ 'var_jsonp_handler' => 'callback',
+];
diff --git a/config/session.php b/config/session.php
new file mode 100644
index 0000000..c1ef6e1
--- /dev/null
+++ b/config/session.php
@@ -0,0 +1,19 @@
+ 'PHPSESSID',
+ // SESSION_ID的提交变量,解决flash上传跨域
+ 'var_session_id' => '',
+ // 驱动方式 支持file cache
+ 'type' => 'file',
+ // 存储连接标识 当type使用cache的时候有效
+ 'store' => null,
+ // 过期时间
+ 'expire' => 1440,
+ // 前缀
+ 'prefix' => '',
+];
diff --git a/config/trace.php b/config/trace.php
new file mode 100644
index 0000000..fad2392
--- /dev/null
+++ b/config/trace.php
@@ -0,0 +1,10 @@
+ 'Html',
+ // 读取的日志通道名
+ 'channel' => '',
+];
diff --git a/config/view.php b/config/view.php
new file mode 100644
index 0000000..01259a0
--- /dev/null
+++ b/config/view.php
@@ -0,0 +1,25 @@
+ 'Think',
+ // 默认模板渲染规则 1 解析为小写+下划线 2 全部转换小写 3 保持操作方法
+ 'auto_rule' => 1,
+ // 模板目录名
+ 'view_dir_name' => 'view',
+ // 模板后缀
+ 'view_suffix' => 'html',
+ // 模板文件名分隔符
+ 'view_depr' => DIRECTORY_SEPARATOR,
+ // 模板引擎普通标签开始标记
+ 'tpl_begin' => '{',
+ // 模板引擎普通标签结束标记
+ 'tpl_end' => '}',
+ // 标签库标签开始标记
+ 'taglib_begin' => '{',
+ // 标签库标签结束标记
+ 'taglib_end' => '}',
+];
diff --git a/config/worker.php b/config/worker.php
new file mode 100644
index 0000000..498812c
--- /dev/null
+++ b/config/worker.php
@@ -0,0 +1,30 @@
+
+// +----------------------------------------------------------------------
+
+// +----------------------------------------------------------------------
+// | Workerman设置 仅对 php think worker 指令有效
+// +----------------------------------------------------------------------
+return [
+ // 扩展自身需要的配置
+ 'host' => '0.0.0.0', // 监听地址
+ 'port' => 2346, // 监听端口
+ 'root' => '', // WEB 根目录 默认会定位public目录
+ 'app_path' => '', // 应用目录 守护进程模式必须设置(绝对路径)
+ 'file_monitor' => false, // 是否开启PHP文件更改监控(调试模式下自动开启)
+ 'file_monitor_interval' => 2, // 文件监控检测时间间隔(秒)
+ 'file_monitor_path' => [], // 文件监控目录 默认监控application和config目录
+
+ // 支持workerman的所有配置参数
+ 'name' => 'thinkphp',
+ 'count' => 4,
+ 'daemonize' => false,
+ 'pidFile' => '',
+];
diff --git a/config/worker_server.php b/config/worker_server.php
new file mode 100644
index 0000000..c754f4e
--- /dev/null
+++ b/config/worker_server.php
@@ -0,0 +1,55 @@
+
+// +----------------------------------------------------------------------
+
+// +----------------------------------------------------------------------
+// | Workerman设置 仅对 php think worker:server 指令有效
+// +----------------------------------------------------------------------
+return [
+ // 扩展自身需要的配置
+ 'protocol' => 'websocket', // 协议 支持 tcp udp unix http websocket text
+ 'host' => '0.0.0.0', // 监听地址
+ 'port' => 2345, // 监听端口
+ 'socket' => '', // 完整监听地址
+ 'context' => [], // socket 上下文选项
+ 'worker_class' => 'app\controller\Push', // 自定义Workerman服务类名 支持数组定义多个服务
+
+ // 支持workerman的所有配置参数
+ 'name' => 'thinkphp',
+ 'count' => 4,
+ 'daemonize' => false,
+ 'pidFile' => '',
+
+ // 支持事件回调
+ // onWorkerStart
+ 'onWorkerStart' => function ($worker) {
+
+ },
+ // onWorkerReload
+ 'onWorkerReload' => function ($worker) {
+
+ },
+ // onConnect
+ 'onConnect' => function ($connection) {
+
+ },
+ // onMessage
+ 'onMessage' => function ($connection, $data) {
+ $connection->send('receive success');
+ },
+ // onClose
+ 'onClose' => function ($connection) {
+
+ },
+ // onError
+ 'onError' => function ($connection, $code, $msg) {
+ echo "error [ $code ] $msg\n";
+ },
+];
diff --git a/config/wx.php b/config/wx.php
new file mode 100644
index 0000000..bdb4bd6
--- /dev/null
+++ b/config/wx.php
@@ -0,0 +1,16 @@
+ "wx4bc5d93d4eaf3bbc",
+ "AppSecret" => "0477ff73388c26ad9cebd310e520b359",
+ 'url' => 'https://api.weixin.qq.com/sns/jscode2session?appid=%s&secret=%s&js_code=%s&grant_type=authorization_code',
+ //商户号
+ 'merchantId' => '1723553926',
+ //证书序列号
+ 'merchantSerialNumber' => '1941FF47383FF19E8D74EC6D26D3A754301A6D2B',
+
+ 'apiV3key' => 'C051282425C483CA4083413CBC793C83',
+ //平台证书,不是商户的证书,
+ 'pingtai_public_key_path' => '/../../Secret/apiclient_cert.pem',
+ //商户api私钥
+ 'apiclientKey' => '/../../Secret/apiclient_key.pem',
+];
\ No newline at end of file
diff --git a/config/wxphone.php b/config/wxphone.php
new file mode 100644
index 0000000..1cdf125
--- /dev/null
+++ b/config/wxphone.php
@@ -0,0 +1,5 @@
+"wxd4a063976744b464",
+ "AppSecret"=>"5ab34e75ad5c0cbdade655f0aa04f7bd",
+];
\ No newline at end of file
diff --git a/extend/.gitignore b/extend/.gitignore
new file mode 100644
index 0000000..c96a04f
--- /dev/null
+++ b/extend/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
\ No newline at end of file
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..86aeca2
--- /dev/null
+++ b/index.html
@@ -0,0 +1,39 @@
+
+
+
+
+ 恭喜,站点创建成功!
+
+
+
+
+
恭喜, 站点创建成功!
+
这是默认index.html,本页面由系统自动生成
+
+ - 本页面在FTP根目录下的index.html
+ - 您可以修改、删除或覆盖本页面
+ - FTP相关信息,请到“面板系统后台 > FTP” 查看
+
+
+
+
\ No newline at end of file
diff --git a/public/.htaccess b/public/.htaccess
new file mode 100644
index 0000000..e69de29
diff --git a/public/.user.ini b/public/.user.ini
new file mode 100644
index 0000000..2df6812
--- /dev/null
+++ b/public/.user.ini
@@ -0,0 +1 @@
+open_basedir=/www/wwwroot/qianjiang.test/:/tmp/
\ No newline at end of file
diff --git a/public/Z0rkckMXHZ.txt b/public/Z0rkckMXHZ.txt
new file mode 100644
index 0000000..4c5e68c
--- /dev/null
+++ b/public/Z0rkckMXHZ.txt
@@ -0,0 +1 @@
+541c4e3855cc0a3f1b1ab7d8e39bfe67
\ No newline at end of file
diff --git a/public/favicon.ico b/public/favicon.ico
new file mode 100644
index 0000000..e71815a
Binary files /dev/null and b/public/favicon.ico differ
diff --git a/public/index.php b/public/index.php
new file mode 100644
index 0000000..9bc69a5
--- /dev/null
+++ b/public/index.php
@@ -0,0 +1,24 @@
+
+// +----------------------------------------------------------------------
+
+// [ 应用入口文件 ]
+namespace think;
+
+require __DIR__ . '/../vendor/autoload.php';
+define('PROJECT_ROOT', dirname(__DIR__));
+// 执行HTTP应用并响应
+$http = (new App())->http;
+
+$response = $http->run();
+
+$response->send();
+
+$http->end($response);
diff --git a/public/nginx.htaccess b/public/nginx.htaccess
new file mode 100644
index 0000000..7038fc5
--- /dev/null
+++ b/public/nginx.htaccess
@@ -0,0 +1,4 @@
+if (!-e $request_filename) {
+ rewrite ^/(.*)$ /index.php?s=$1 last;
+ break;
+ }
\ No newline at end of file
diff --git a/public/qrcode/9920000040358A.jpeg b/public/qrcode/9920000040358A.jpeg
new file mode 100644
index 0000000..3efe3d3
Binary files /dev/null and b/public/qrcode/9920000040358A.jpeg differ
diff --git a/public/qrcode/9920000040358B.jpeg b/public/qrcode/9920000040358B.jpeg
new file mode 100644
index 0000000..61536b4
Binary files /dev/null and b/public/qrcode/9920000040358B.jpeg differ
diff --git a/public/qrcode/9920000040359A.jpeg b/public/qrcode/9920000040359A.jpeg
new file mode 100644
index 0000000..d4ad5cf
Binary files /dev/null and b/public/qrcode/9920000040359A.jpeg differ
diff --git a/public/qrcode/9920000040359B.jpeg b/public/qrcode/9920000040359B.jpeg
new file mode 100644
index 0000000..9cde021
Binary files /dev/null and b/public/qrcode/9920000040359B.jpeg differ
diff --git a/public/qrcode/9920000040361A.jpeg b/public/qrcode/9920000040361A.jpeg
new file mode 100644
index 0000000..2dceb49
Binary files /dev/null and b/public/qrcode/9920000040361A.jpeg differ
diff --git a/public/qrcode/9920000040361B.jpeg b/public/qrcode/9920000040361B.jpeg
new file mode 100644
index 0000000..90e9e69
Binary files /dev/null and b/public/qrcode/9920000040361B.jpeg differ
diff --git a/public/qrcode/9920000040365A.jpeg b/public/qrcode/9920000040365A.jpeg
new file mode 100644
index 0000000..5120f6e
Binary files /dev/null and b/public/qrcode/9920000040365A.jpeg differ
diff --git a/public/qrcode/9920000040365B.jpeg b/public/qrcode/9920000040365B.jpeg
new file mode 100644
index 0000000..241d3bc
Binary files /dev/null and b/public/qrcode/9920000040365B.jpeg differ
diff --git a/public/qrcode/9920000040367A.jpeg b/public/qrcode/9920000040367A.jpeg
new file mode 100644
index 0000000..9904fb0
Binary files /dev/null and b/public/qrcode/9920000040367A.jpeg differ
diff --git a/public/qrcode/9920000040367B.jpeg b/public/qrcode/9920000040367B.jpeg
new file mode 100644
index 0000000..ed482d0
Binary files /dev/null and b/public/qrcode/9920000040367B.jpeg differ
diff --git a/public/qrcode/9920000040369A.jpeg b/public/qrcode/9920000040369A.jpeg
new file mode 100644
index 0000000..5e14331
Binary files /dev/null and b/public/qrcode/9920000040369A.jpeg differ
diff --git a/public/qrcode/9920000040369B.jpeg b/public/qrcode/9920000040369B.jpeg
new file mode 100644
index 0000000..23c54fd
Binary files /dev/null and b/public/qrcode/9920000040369B.jpeg differ
diff --git a/public/qrcode/9920000040377A.jpeg b/public/qrcode/9920000040377A.jpeg
new file mode 100644
index 0000000..04bab96
Binary files /dev/null and b/public/qrcode/9920000040377A.jpeg differ
diff --git a/public/qrcode/9920000040377B.jpeg b/public/qrcode/9920000040377B.jpeg
new file mode 100644
index 0000000..f9e1a9d
Binary files /dev/null and b/public/qrcode/9920000040377B.jpeg differ
diff --git a/public/qrcode/9920000040378A.jpeg b/public/qrcode/9920000040378A.jpeg
new file mode 100644
index 0000000..bd08039
Binary files /dev/null and b/public/qrcode/9920000040378A.jpeg differ
diff --git a/public/qrcode/9920000040378B.jpeg b/public/qrcode/9920000040378B.jpeg
new file mode 100644
index 0000000..be88583
Binary files /dev/null and b/public/qrcode/9920000040378B.jpeg differ
diff --git a/public/qrcode/9920000040383A.jpeg b/public/qrcode/9920000040383A.jpeg
new file mode 100644
index 0000000..6657b19
Binary files /dev/null and b/public/qrcode/9920000040383A.jpeg differ
diff --git a/public/qrcode/9920000040383B.jpeg b/public/qrcode/9920000040383B.jpeg
new file mode 100644
index 0000000..e60d160
Binary files /dev/null and b/public/qrcode/9920000040383B.jpeg differ
diff --git a/public/qrcode/9920000040384A.jpeg b/public/qrcode/9920000040384A.jpeg
new file mode 100644
index 0000000..fa048f7
Binary files /dev/null and b/public/qrcode/9920000040384A.jpeg differ
diff --git a/public/qrcode/9920000040384B.jpeg b/public/qrcode/9920000040384B.jpeg
new file mode 100644
index 0000000..29f00f5
Binary files /dev/null and b/public/qrcode/9920000040384B.jpeg differ
diff --git a/public/qrcode/9920000040385A.jpeg b/public/qrcode/9920000040385A.jpeg
new file mode 100644
index 0000000..cc0b1b5
Binary files /dev/null and b/public/qrcode/9920000040385A.jpeg differ
diff --git a/public/qrcode/9920000040385B.jpeg b/public/qrcode/9920000040385B.jpeg
new file mode 100644
index 0000000..c4d3f99
Binary files /dev/null and b/public/qrcode/9920000040385B.jpeg differ
diff --git a/public/qrcode/9920000040386A.jpeg b/public/qrcode/9920000040386A.jpeg
new file mode 100644
index 0000000..68e8e5a
Binary files /dev/null and b/public/qrcode/9920000040386A.jpeg differ
diff --git a/public/qrcode/9920000040386B.jpeg b/public/qrcode/9920000040386B.jpeg
new file mode 100644
index 0000000..9583f89
Binary files /dev/null and b/public/qrcode/9920000040386B.jpeg differ
diff --git a/public/qrcode/9920000040388A.jpeg b/public/qrcode/9920000040388A.jpeg
new file mode 100644
index 0000000..98c31ae
Binary files /dev/null and b/public/qrcode/9920000040388A.jpeg differ
diff --git a/public/qrcode/9920000040388B.jpeg b/public/qrcode/9920000040388B.jpeg
new file mode 100644
index 0000000..13a1fdd
Binary files /dev/null and b/public/qrcode/9920000040388B.jpeg differ
diff --git a/public/qrcode/9920000040389A.jpeg b/public/qrcode/9920000040389A.jpeg
new file mode 100644
index 0000000..17e666e
Binary files /dev/null and b/public/qrcode/9920000040389A.jpeg differ
diff --git a/public/qrcode/9920000040389B.jpeg b/public/qrcode/9920000040389B.jpeg
new file mode 100644
index 0000000..129c033
Binary files /dev/null and b/public/qrcode/9920000040389B.jpeg differ
diff --git a/public/qrcode/9920000040392A.jpeg b/public/qrcode/9920000040392A.jpeg
new file mode 100644
index 0000000..b213d3d
Binary files /dev/null and b/public/qrcode/9920000040392A.jpeg differ
diff --git a/public/qrcode/9920000040392B.jpeg b/public/qrcode/9920000040392B.jpeg
new file mode 100644
index 0000000..e8a7945
Binary files /dev/null and b/public/qrcode/9920000040392B.jpeg differ
diff --git a/public/qrcode/9920000040395A.jpeg b/public/qrcode/9920000040395A.jpeg
new file mode 100644
index 0000000..e0b9c79
Binary files /dev/null and b/public/qrcode/9920000040395A.jpeg differ
diff --git a/public/qrcode/9920000040395B.jpeg b/public/qrcode/9920000040395B.jpeg
new file mode 100644
index 0000000..a656ed9
Binary files /dev/null and b/public/qrcode/9920000040395B.jpeg differ
diff --git a/public/qrcode/9920000040396A.jpeg b/public/qrcode/9920000040396A.jpeg
new file mode 100644
index 0000000..0aec095
Binary files /dev/null and b/public/qrcode/9920000040396A.jpeg differ
diff --git a/public/qrcode/9920000040396B.jpeg b/public/qrcode/9920000040396B.jpeg
new file mode 100644
index 0000000..04e1620
Binary files /dev/null and b/public/qrcode/9920000040396B.jpeg differ
diff --git a/public/qrcode/9920000040397A.jpeg b/public/qrcode/9920000040397A.jpeg
new file mode 100644
index 0000000..ff3ca5d
Binary files /dev/null and b/public/qrcode/9920000040397A.jpeg differ
diff --git a/public/qrcode/9920000040397B.jpeg b/public/qrcode/9920000040397B.jpeg
new file mode 100644
index 0000000..ec40ad4
Binary files /dev/null and b/public/qrcode/9920000040397B.jpeg differ
diff --git a/public/qrcode/9920000040399A.jpeg b/public/qrcode/9920000040399A.jpeg
new file mode 100644
index 0000000..2c0a9b5
Binary files /dev/null and b/public/qrcode/9920000040399A.jpeg differ
diff --git a/public/qrcode/9920000040399B.jpeg b/public/qrcode/9920000040399B.jpeg
new file mode 100644
index 0000000..366f808
Binary files /dev/null and b/public/qrcode/9920000040399B.jpeg differ
diff --git a/public/qrcode/9920000040401A.jpeg b/public/qrcode/9920000040401A.jpeg
new file mode 100644
index 0000000..5521bb9
Binary files /dev/null and b/public/qrcode/9920000040401A.jpeg differ
diff --git a/public/qrcode/9920000040401B.jpeg b/public/qrcode/9920000040401B.jpeg
new file mode 100644
index 0000000..0bfb102
Binary files /dev/null and b/public/qrcode/9920000040401B.jpeg differ
diff --git a/public/qrcode/9920000040805A.jpeg b/public/qrcode/9920000040805A.jpeg
new file mode 100644
index 0000000..c4d04c7
Binary files /dev/null and b/public/qrcode/9920000040805A.jpeg differ
diff --git a/public/qrcode/9920000040805B.jpeg b/public/qrcode/9920000040805B.jpeg
new file mode 100644
index 0000000..05c6b5c
Binary files /dev/null and b/public/qrcode/9920000040805B.jpeg differ
diff --git a/public/qrcode/9920000040806A.jpeg b/public/qrcode/9920000040806A.jpeg
new file mode 100644
index 0000000..2025c70
Binary files /dev/null and b/public/qrcode/9920000040806A.jpeg differ
diff --git a/public/qrcode/9920000040806B.jpeg b/public/qrcode/9920000040806B.jpeg
new file mode 100644
index 0000000..1a113ad
Binary files /dev/null and b/public/qrcode/9920000040806B.jpeg differ
diff --git a/public/qrcode/9920000040808A.jpeg b/public/qrcode/9920000040808A.jpeg
new file mode 100644
index 0000000..58054a6
Binary files /dev/null and b/public/qrcode/9920000040808A.jpeg differ
diff --git a/public/qrcode/9920000040808B.jpeg b/public/qrcode/9920000040808B.jpeg
new file mode 100644
index 0000000..b9c5915
Binary files /dev/null and b/public/qrcode/9920000040808B.jpeg differ
diff --git a/public/qrcode/9920000040812A.jpeg b/public/qrcode/9920000040812A.jpeg
new file mode 100644
index 0000000..0561df7
Binary files /dev/null and b/public/qrcode/9920000040812A.jpeg differ
diff --git a/public/qrcode/9920000040812B.jpeg b/public/qrcode/9920000040812B.jpeg
new file mode 100644
index 0000000..a2a989e
Binary files /dev/null and b/public/qrcode/9920000040812B.jpeg differ
diff --git a/public/qrcode/9920000040835A.jpeg b/public/qrcode/9920000040835A.jpeg
new file mode 100644
index 0000000..13ae446
Binary files /dev/null and b/public/qrcode/9920000040835A.jpeg differ
diff --git a/public/qrcode/9920000040835B.jpeg b/public/qrcode/9920000040835B.jpeg
new file mode 100644
index 0000000..202cb80
Binary files /dev/null and b/public/qrcode/9920000040835B.jpeg differ
diff --git a/public/qrcode/9920000040837A.jpeg b/public/qrcode/9920000040837A.jpeg
new file mode 100644
index 0000000..b302b52
Binary files /dev/null and b/public/qrcode/9920000040837A.jpeg differ
diff --git a/public/qrcode/9920000040837B.jpeg b/public/qrcode/9920000040837B.jpeg
new file mode 100644
index 0000000..24b589f
Binary files /dev/null and b/public/qrcode/9920000040837B.jpeg differ
diff --git a/public/qrcode/9920000040861A.jpeg b/public/qrcode/9920000040861A.jpeg
new file mode 100644
index 0000000..acadcff
Binary files /dev/null and b/public/qrcode/9920000040861A.jpeg differ
diff --git a/public/qrcode/9920000040861B.jpeg b/public/qrcode/9920000040861B.jpeg
new file mode 100644
index 0000000..ea730ad
Binary files /dev/null and b/public/qrcode/9920000040861B.jpeg differ
diff --git a/public/qrcode/9920000040862A.jpeg b/public/qrcode/9920000040862A.jpeg
new file mode 100644
index 0000000..bc7b482
Binary files /dev/null and b/public/qrcode/9920000040862A.jpeg differ
diff --git a/public/qrcode/9920000040862B.jpeg b/public/qrcode/9920000040862B.jpeg
new file mode 100644
index 0000000..52ef2f5
Binary files /dev/null and b/public/qrcode/9920000040862B.jpeg differ
diff --git a/public/qrcode/9920000040866A.jpeg b/public/qrcode/9920000040866A.jpeg
new file mode 100644
index 0000000..97bf3d0
Binary files /dev/null and b/public/qrcode/9920000040866A.jpeg differ
diff --git a/public/qrcode/9920000040866B.jpeg b/public/qrcode/9920000040866B.jpeg
new file mode 100644
index 0000000..7c19b70
Binary files /dev/null and b/public/qrcode/9920000040866B.jpeg differ
diff --git a/public/qrcode/qrcode_ndaLC.zip b/public/qrcode/qrcode_ndaLC.zip
new file mode 100644
index 0000000..e884730
Binary files /dev/null and b/public/qrcode/qrcode_ndaLC.zip differ
diff --git a/public/robots.txt b/public/robots.txt
new file mode 100644
index 0000000..eb05362
--- /dev/null
+++ b/public/robots.txt
@@ -0,0 +1,2 @@
+User-agent: *
+Disallow:
diff --git a/public/router.php b/public/router.php
new file mode 100644
index 0000000..9b39a62
--- /dev/null
+++ b/public/router.php
@@ -0,0 +1,19 @@
+
+// +----------------------------------------------------------------------
+// $Id$
+
+if (is_file($_SERVER["DOCUMENT_ROOT"] . $_SERVER["SCRIPT_NAME"])) {
+ return false;
+} else {
+ $_SERVER["SCRIPT_FILENAME"] = __DIR__ . '/index.php';
+
+ require __DIR__ . "/index.php";
+}
diff --git a/public/static/.gitignore b/public/static/.gitignore
new file mode 100644
index 0000000..c96a04f
--- /dev/null
+++ b/public/static/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
\ No newline at end of file
diff --git a/route/app.php b/route/app.php
new file mode 100644
index 0000000..99b5ff1
--- /dev/null
+++ b/route/app.php
@@ -0,0 +1,192 @@
+
+// +----------------------------------------------------------------------
+use think\facade\Route;
+
+
+Route::get('think', function () {
+ return 'hello,ThinkPHP6!';
+});
+
+
+Route::get('hello/:name', 'index/hello');
+Route::get('login', 'Login/index');
+Route::post('login_check', 'Login/check');
+Route::any('admin_list', 'Admin/index');
+Route::get('logout', 'Login/out');
+Route::resource('index', 'Index');
+Route::resource('test', 'Test');
+Route::post('test/save', 'test/save');
+Route::post('test/AdmenAmont', 'test/AdmenAmont');
+Route::post('user/save', 'User/save');
+Route::post('admin/save', 'Admin/save');
+Route::post('StationPrice', 'user/StationPrice');
+Route::post('StationPriceUpdate', 'user/StationPriceUpdate');
+Route::post('OrderQuery', 'ChargeOrder/OrderQuery');
+Route::resource('admin', 'Admin');
+Route::resource('user', 'User');
+Route::resource('station', 'ChargeStation');
+
+//把小程序接口全放里面
+Route::group(function () {
+ Route::post('Collect', 'UserCollect/Collect');
+ Route::post('TheLastFive', 'ChargeStation/The_Last_Five');
+ Route::post('SearchStation', 'ChargeStation/SearchStation');
+ Route::post('WxGetArea', 'user/WxGetArea');
+ Route::post('InnerChargeStation', 'ChargeStation/InnerChargeStation');
+ Route::post('MyCollect', 'UserCollect/MyCollect');
+ Route::post('UserInfo', 'user/UserInfo');
+ Route::post('UserEdit', 'user/UserEdit');
+ Route::post('WechatPay', 'WechatPay/config');
+ Route::post('RechargeRecord', 'ChargeOrder/RechargeRecord');
+ Route::post('UserBalance', 'User/UserBalance');
+ Route::post('GennerateOrder', 'ChargeOrder/GennerateOrder');
+ Route::post('OrderDetail', 'ChargeOrder/OrderDetail');
+ Route::post('EndOrder', 'ChargeOrder/EndOrder');
+
+ Route::post('OrderNum', 'ChargeOrder/OrderNum');
+ Route::post('StationFee', 'ChargeOrder/StationFee');
+ Route::post('QueryPayStatus', 'ChargeOrder/QueryPayStatus');
+ Route::post('QRCode', 'ChargeOrder/QRCode');
+// Route::post('UserRefund', 'user/UserRefund');
+ Route::post('GetDiscounts', 'ChargeStation/GetDiscounts');
+ Route::post('EventList', 'Event/EventList');
+ Route::post('EventDetail', 'Event/EventDetail');
+ Route::post('NavMessage', 'Navigation/NavMessage');
+ Route::post('UserVip', 'UserGroup/UserVip');
+ Route::post('GetLastStation', 'Navigation/GetLastStation');
+ Route::post('getWxPhone', 'WxGetPhone/getWxPhone');
+ Route::post('UserReimburse', 'UserRefund/UserReimburse');
+ Route::post('TKRecord', 'UserRefund/TKRecord');
+})->middleware(\app\middleware\WxAppCheck::class);//Token验证中间件
+
+Route::post('OrderList', 'ChargeOrder/OrderList');
+Route::post('AmountExcel', 'Order.CountExcel/AmountExcel');
+Route::post('Bus/ChangeSpecialUserBalance', 'Bus.AlterBalance/ChangeSpecialUserBalance');
+Route::post('Bus/TimeTask', 'Bus.AlterBalance/ChangeSpecialUserBalance');
+Route::post('Order/AdmenAmont', 'Order.TimeTask/AdmenAmont');
+Route::post('Bus/SearchMessage', 'Bus.SearchMessage/BusOrder');
+Route::post('Bus/BusOrderPark', 'Bus.SearchMessage/BusOrderPark');
+Route::post('Bus/ParkNo', 'Bus.SearchMessage/ParkNo');
+Route::post('Bus/DataStatistics', 'Bus.BusBill/DataStatistics');
+Route::post('Bus/ShowVinLicense', 'Bus.VinBindLicense/ShowVinLicense');
+Route::post('Bus/AddVinLicense', 'Bus.VinBindLicense/AddVinLicense');
+Route::post('Bus/UpdateVinLicense', 'Bus.VinBindLicense/UpdateVinLicense');
+Route::post('Bus/DeleteVinLicense', 'Bus.VinBindLicense/DeleteVinLicense');
+Route::post('RechargeMessage', 'Order.RechargeRecord/RechargeRecord');
+Route::post('RefundMessage', 'Order.RefundRecord/RefundRecord');
+Route::post('sharenotify', 'WechatPay/sharenotify');
+Route::post('FuzzyOrder', 'ChargeOrder/FuzzyOrder');
+Route::post('RechargeAll', 'ChargeOrder/RechargeAll');
+Route::post('FindRechargeOrder', 'Refund/FindRechargeOrder');
+Route::post('UpdateDiscount', 'user/UpdateDiscount');
+Route::post('RechargeAllExport', 'ChargeOrder/RechargeAllExport');
+Route::post('OrderExport', 'ChargeOrder/OrderExport');
+Route::post('ShowEvent', 'Event/ShowEvent');
+Route::post('AddEvent', 'Event/AddEvent');
+Route::post('EditEvent', 'Event/EditEvent');
+Route::post('DeleteEvent', 'Event/DeleteEvent');
+Route::post('Upload', 'Event/upload');
+Route::post('EventList2', 'Event/EventList');
+//Route::post('EventDetail', 'Event/EventDetail');
+Route::post('MonitorList', 'Monitor/MonitorList');
+Route::post('MonitorId', 'Monitor/MonitorId');
+Route::post('FindEvent', 'Event/FindEvent');
+Route::post('UpdatePermission', 'admin/UpdatePermission');
+
+//VIP用户分组接口
+Route::post('UserList', 'UserGroup/UserList');
+Route::post('EnterpriseGroupAdd', 'UserGroup/EnterpriseGroupAdd');
+Route::post('NormalSearch', 'UserGroup/NormalSearch');
+Route::post('NormalToEnterprise', 'UserGroup/NormalToEnterprise');
+Route::post('GetGroup', 'UserGroup/GetGroup');
+Route::post('DeleteEnterpriseUser', 'UserGroup/DeleteEnterpriseUser');
+Route::post('DeleteEnterpriseGroup', 'UserGroup/DeleteEnterpriseGroup');
+Route::post('PhoneSearch', 'UserGroup/PhoneSearch');
+Route::post('EnterpriserUserEdit', 'UserGroup/EnterpriserUserEdit');
+Route::post('ShowServiceFee', 'UserGroup/ShowServiceFee');
+Route::post('UpdateServiceFee', 'UserGroup/UpdateServiceFee');
+Route::post('Electricity', 'UserGroup/Electricity');
+
+//硬件推送接口 需要token验证
+Route::post('query_token', 'HardMessage/query_token');
+Route::post('notification_stationStatus', 'HardMessage/notification_station');
+Route::post('notification_start_charge_result', 'HardMessage/notification_start_charge_result');
+Route::post('Get_query_equip_auth', 'HardMessage/Get_query_equip_auth');
+Route::post('Get_query_start_charge', 'HardMessage/Get_query_start_charge');
+Route::post('notification_equip_charge_status', 'HardMessage/notification_equip_charge_status');
+Route::post('notification_stop_charge_result', 'HardMessage/notification_stop_charge_result');
+Route::post('notification_charge_order_info', 'HardMessage/notification_charge_order_info');
+Route::post('insert_start_charge', 'Bus.PlugCharge/insert_start_charge');
+Route::post('ModifyAppointmentTime', 'Bus.PlugCharge/ModifyAppointmentTime');
+Route::post('ShowAppointmentTime', 'Bus.PlugCharge/ShowAppointmentTime');
+Route::post('RefundQuery', 'UserRefund/RefundQuery');
+Route::post('Refund_Total', 'UserRefund/Refund_Total');
+
+Route::post('refund_notify', 'WechatReimburse/refund_notify');
+
+
+
+
+
+
+
+// 新增接口
+
+Route::resource('getEnterpriseList', 'Enterprise');
+
+Route::resource('getEnterpriseUserList', 'EnterpriseUser');
+
+Route::resource('getEnterpriseCarList', 'EnterpriseCar');
+
+Route::get('getChargeOrder','Order.ChargeOrder/charge_order');
+Route::get('getRechargeOrder','Order.ChargeOrder/recharge_order');
+Route::get('getRefundOrder','Order.ChargeOrder/refund_order');
+
+
+Route::get('getRoleList','Auth/getRoleList');
+Route::get('getMenuList','Auth/getMenuList');
+Route::get('getCouponList','Auth/getCouponList');
+
+
+Route::get('getLogList','Auth/getLogList');
+Route::get('getYunYingData','Auth/getYunYingData');
+Route::get('getCaiWuData','Auth/getCaiWuData');
+
+
+
+// 新增的小程序使用企业路由
+Route::post('getEnterpriseInfo', 'User/getEnterpriseInfo');
+
+
+Route::post('enterpriseConfig', 'WechatPay/EnterpriseConfig');
+Route::post('enterpriseChargeNotify', 'WechatPay/enterpriseChargeNotify');
+
+Route::post('enterpriseRechange', 'User/enterpriseRechange');
+Route::post('getEnterpriseReangeLog', 'User/getEnterpriseReangeLog');
+
+Route::post('goCharge', 'ChargeOrder/GennerateOrder2');//潜江充电
+Route::post('startCharging', 'ChargeOrder/startCharging');//潜江充电---启动充电
+Route::post('directlychargenotify', 'WechatPay/directlychargenotify');//即充即退支付回调
+
+Route::post('refund_notify2', 'WechatReimburse/refund_notify2');//即充即退退款
+Route::post('OrderList2', 'ChargeOrder/OrderList2');//订单列表
+Route::post('EndOrder2', 'ChargeOrder/EndOrder2');//结束订单
+Route::post('OrderDetail2', 'ChargeOrder/OrderDetail2');//订单列表
+
+
+Route::post('getConnectorIDCharge', 'ChargeStation/getConnectorIDCharge');//订单列表
+Route::post('getMoneyLog', 'User/getMoneyLog');//用户余额记录
+
+
+// tld 测试环境
+Route::post('testIndex', 'TeldTest/index');//测试环境
+
+
diff --git a/runtime/.gitignore b/runtime/.gitignore
new file mode 100644
index 0000000..c96a04f
--- /dev/null
+++ b/runtime/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
\ No newline at end of file
diff --git a/think b/think
new file mode 100644
index 0000000..2429d22
--- /dev/null
+++ b/think
@@ -0,0 +1,10 @@
+#!/usr/bin/env php
+console->run();
\ No newline at end of file
diff --git a/view/README.md b/view/README.md
new file mode 100644
index 0000000..360eb24
--- /dev/null
+++ b/view/README.md
@@ -0,0 +1 @@
+如果不使用模板,可以删除该目录
\ No newline at end of file
diff --git a/view/Test.php b/view/Test.php
new file mode 100644
index 0000000..55c3c69
--- /dev/null
+++ b/view/Test.php
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+ Document
+
+
+
+
+
+