mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-01-28 06:38:10 +00:00
更新v4.7
This commit is contained in:
parent
dd8b3d6eb3
commit
e69b0bf39e
22
README.md
22
README.md
@ -2,26 +2,12 @@
|
||||
<div align="center" >
|
||||
<img src="https://images.gitee.com/uploads/images/2021/1109/164354_0aafe3d2_892944.gif" />
|
||||
</div>
|
||||
<div align="center">
|
||||
<div align="center">
|
||||
|
||||
支持免费商用的PHP **多语言** 商城系统
|
||||
|
||||
</div>
|
||||
|
||||
<div align="center" >
|
||||
<a href="http://www.crmeb.com">
|
||||
<img src="https://img.shields.io/badge/Licence-GPL3.0-green.svg?style=flat" />
|
||||
</a>
|
||||
<a href="http://www.crmeb.com">
|
||||
<img src="https://img.shields.io/badge/Edition-4.5-blue.svg" />
|
||||
</a>
|
||||
<a href="https://gitee.com/ZhongBangKeJi/CRMEB/repository/archive/master.zip">
|
||||
<img src="https://img.shields.io/badge/Download-150m-red.svg" />
|
||||
</a>
|
||||
<a href='https://gitee.com/ZhongBangKeJi/CRMEB/stargazers'>
|
||||
<img src='https://gitee.com/ZhongBangKeJi/CRMEB/badge/star.svg?theme=gvp' alt='star'></img>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
####
|
||||
|
||||
@ -44,6 +30,8 @@ CRMEB打通版是历经6年时间匠心之作!系统全开源可商用,包
|
||||
|
||||
CRMEB开源商城Java版:https://gitee.com/ZhongBangKeJi/crmeb_java
|
||||
|
||||
|
||||
|
||||
### 系统亮点
|
||||
~~~
|
||||
多 语 言:后台随时配置语言包,移动端支持多语言切换;
|
||||
@ -124,11 +112,13 @@ APP下载:http://app.crmeb.cn/bzv (苹果手机直接在APP Store里搜索CR
|
||||
| [](https://gitee.com/layui/layui-vue) | [](https://gitee.com/layui/layui-vue/stargazers) | layui-vue(谐音:类UI)是一套Vue3.0 的桌面端组件库. |
|
||||
| [](https://gitee.com/ntdgg/tpflow) | [](https://gitee.com/ntdgg/tpflow/stargazers) | TpFlow工作流引擎是一套规范化的流程管理系统,基于业务而驱动系统生命力的一套引擎. |
|
||||
|
||||
### 贡献支持
|
||||
### 商业版购买
|
||||
开源不易,以下如果有需要,请支持一下,感谢您的支持,让我们更多动力!
|
||||
|
||||
[](https://www.crmeb.com/index/criteria)
|
||||
|
||||
### 🔥🔥庆祝:CRMEB开源商城系统Gitee star突破10000+ 专属活动福利 [点击了解](https://www.crmeb.com/ask/thread/20738)
|
||||
|
||||
### 感谢参与开发者
|
||||
感谢大神们提交代码(排名不分先后)
|
||||
|
||||
|
||||
@ -1 +0,0 @@
|
||||
APP_DEBUG = false
[APP]
DEFAULT_TIMEZONE = Asia/Shanghai
[DATABASE]
TYPE = mysql
HOSTNAME =
HOSTPORT = 3306
USERNAME =
PASSWORD =
DATABASE =
PREFIX = eb_
CHARSET = utf8
DEBUG = true
[LANG]
default_lang = zh-cn
[REDIS]
REDIS_HOSTNAME =
PORT = 6379
REDIS_PASSWORD =
SELECT = 0
[QUEUE]
QUEUE_NAME =
|
||||
@ -1 +0,0 @@
|
||||
APP_DEBUG = false
[APP]
DEFAULT_TIMEZONE = Asia/Shanghai
[DATABASE]
TYPE = mysql
HOSTNAME =
HOSTPORT = 3306
USERNAME =
PASSWORD =
DATABASE =
PREFIX = eb_
CHARSET = utf8
DEBUG = true
[LANG]
default_lang = zh-cn
[REDIS]
REDIS_HOSTNAME =
PORT = 6379
REDIS_PASSWORD =
SELECT = 0
[QUEUE]
QUEUE_NAME =
|
||||
22
crmeb/.phpstorm.meta.php
Normal file
22
crmeb/.phpstorm.meta.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace PHPSTORM_META {
|
||||
|
||||
use think\Container;
|
||||
use function \app;
|
||||
|
||||
override(
|
||||
\app(),
|
||||
map([
|
||||
'json' => \crmeb\utils\Json::class
|
||||
])
|
||||
);
|
||||
|
||||
override(
|
||||
\think\Container::make(),
|
||||
map([
|
||||
'' => '@'
|
||||
])
|
||||
);
|
||||
|
||||
}
|
||||
@ -1,5 +1,4 @@
|
||||
version=CRMEB-KY v4.6.0
|
||||
version_code=460
|
||||
platform=github
|
||||
version=CRMEB-KY v4.7.0
|
||||
version_code=470
|
||||
platform=gitee
|
||||
app_id=ze7x9rxsv09l6pvsyo
|
||||
app_key=fuF7U9zaybLa5gageVQzxtxQMFnvU2OI
|
||||
|
||||
@ -1,29 +1,86 @@
|
||||
版权所有 (c)2017-2027,西安众邦网络科技有限公司 保留所有权利。
|
||||
感谢您选择CRMEB开源客户管理+电商系统(简称CRMEB),CRMEB是国内稳定、功能强大、技术先进的互联网电商平台解决方案之一,CRMEB基于 PHP + MySQL 的技术,采用ThinkPHP5.0框架开发。
|
||||
为了使你正确并合法的使用本软件,请你在使用前务必阅读清楚下面的协议条款:
|
||||
本授权协议适用且仅适用于CRMEB任何版本,CRMEB官方对本授权协议的最终解释权和修改权。
|
||||
# 软件使用许可协议
|
||||
本协议是您因使用CRMEB开源商城系统软件与西安众邦网络科技有限公司所订立的有效合约。
|
||||
CRMEB是国内稳定、强大、先进的互联网电商平台解决方案之一,CRMEB基于 PHP + MySQL 的技术,采用ThinkPHP框架开发。
|
||||
CRMEB开源商城系统(以下简称“CRMEB”或“许可软件”或“本软件”),由西安众邦网络科技有限公司(以下称“众邦科技”)自主独创开发,CRMEB官方网站:http://www.crmeb.com,您在使用CRMEB客户管理+电商系统(以下称“许可软件”或“本软件”)之前,请您仔细阅读本协议,特别是法律适用和争议解决条款,您需要重点阅读。如您对协议有任何疑问,可咨询CRMEB官方客服。如果您安装或以其他任何方式使用本软件,则视为已经接受本协议。如果您不接受本协议的全部或部分条款,您将无权使用本软件,请立即终止安装、或以其他方式使用该软件,删除您已经安装或保留的该软件的任何组件。
|
||||
|
||||
一、协议许可的权利
|
||||
1、您可以在完全遵守本最终用户授权协议的基础上,将本软件应用于非商业用途,而不必支付软件版权授权费用。
|
||||
2、您可以在协议规定的约束和限制范围内修改 CRMEB 源代码或界面风格以适应您的网站要求。
|
||||
3、您拥有使用本软件构建的网站全部内容所有权,并独立承担与这些内容的相关法律义务。
|
||||
4、您可以将本软件应用于商业用途,但必须保留版权,去版权需要申请。
|
||||
一、定义
|
||||
软件(许可软件或本软件):本协议中的“软件”是指CRMEB开源商城系统,由若干模块或功能组成的已经植入或即将植入众邦科技指定产品内的信息处理程序或支持文件,其中支持文件具体包括软件的源代码、目标码的全部或部分,还包括与本软件或众邦科技产品相关的所有描述其功能、特点、内容、质量、测试、用户手册、用户许可协议等纸质或电子版的资料、技术文档等。
|
||||
您:本协议中的“您”是指安装、使用本软件的个人或法人实体,法人实体包括公司、企业、机构、组织或单位。
|
||||
我们:本协议中的“我们”即是CRMEB官方,即指西安众邦网络科技有限公司及其关联公司。
|
||||
二次开发:本协议中的“二次开发”是指在本软件上进行定制修改、功能扩展。
|
||||
|
||||
二、协议许可的权利和限制
|
||||
1、未获去版权授权之前,不得删除网站底部及相应的官方版权信息和链接。购买商业授权请联系西安众邦网络科技有限公司了解最新说明。CRMEB著作权已在中华人民共和国国家版权局注册(中国国家版权局著作权登记号 2018SR024463),著作权受到法律和国际公约保护。
|
||||
2、未经官方许可,不得对本软件或与之关联的商业授权进行出租、出售、抵押或发放子许可证。
|
||||
3、不管你的网站是否整体使用 CRMEB ,还是部份栏目使用 CRMEB,在你使用了 CRMEB 的网站主页上必须加上 CRMEB 官方网址(www.crmeb.com)的链接。
|
||||
4、未经官方许可,禁止在 CRMEB 的整体或任何部分基础上以发展任何派生版本、修改版本或第三方版本用于重新分发。
|
||||
5、如果您未能遵守本协议的条款,您的授权将被终止,所被许可的权利将被收回,并承担相应法律责任。
|
||||
二、软件许可使用内容
|
||||
您在遵守本软件开源协议的相关约定前提下,通过我们指定合法渠道下载软件后,您需遵守的补充约定:
|
||||
2.1 以自用为目的,您可将本软件用于盈利或非盈利项目上,且不受任何限制。
|
||||
2.2 以自用为目的,在保留版权标识的前提下您可任意修改程序源码。
|
||||
2.3 禁止以任何方式破坏CRMEB的商业授权机制(包括但不限于收集CRMEB源码后经营与CRMEB同类型、同性质服务等)。
|
||||
2.4 禁止利用CRMEB发表、传送、传播、储存违反国家法律、危害国家安全、社会稳定、公序良俗的内容,或任何不当的、侮辱诽谤的、淫秽的、暴力的及任何违反国家法律法规政策的内容。
|
||||
2.5 CRMEB著作权已在中华人民共和国国家版权局注册(中国国家版权局著作权登记号 2018SR024463),著作权受到法律和国际公约保护。未经我们书面许可,不得删除网站底部及相应的官方链接。购买商业版授权请联系众邦科技客服,了解最新说明。
|
||||
2.6 安装前请仔细阅读本软件帮助文档,查看本软件适用运营环境,在软件相关文档中已经明确提示,如因软件安装不符运营环境造成的故障,众邦科技不承担任何责任。
|
||||
2.7 保留本软件原有的许可声明和版权、专利、商标情况等标识;
|
||||
|
||||
三、有限担保和免责声明
|
||||
1、本软件及所附带的文件是作为不提供任何明确的或隐含的赔偿或担保的形式提供的。
|
||||
2、本软件提供源代码,您在使用过程中产生的责任与西安众邦网络科技有限公司无关。
|
||||
3、用户出于自愿而使用本软件,您必须了解使用本软件的风险,在尚未购买产品技术服务之前,我们不承诺对免费用户提供任何形式的技术支持、使用担保,也不承担任何因使用本软件而产生问题的相关责任。
|
||||
4、电子文本形式的授权协议如同双方书面签署的协议一样,具有完全的和等同的法律效力。您一旦开始确认本协议并安装 CRMEB,即被视为完全理解并接受本协议的各项条款,在享有上述条款授予的权力的同时,受到相关的约束和限制。协议许可范围以外的行为,将直接违反本授权协议并构成侵权,我们有权随时终止授权,责令停止损害,并保留追究相关责任的权力。
|
||||
三、CRMEB遵守的约定
|
||||
3.1 CRMEB保证遵循中国的法律法规及相关政策规范。
|
||||
3.2 除付费功能插件外,确保所有代码用户皆可阅读。
|
||||
3.3 确保用户在完成所有系统部署后,在不依赖CRMEB支持下也可永久运行。
|
||||
3.4 除商业版本付费授权相关功能插件外,禁止对源代码进行加密和混淆。
|
||||
3.5 禁止不经用户许可的情况下以任何方式自动安装加密代码。
|
||||
3.6 禁止不经用户许可的情况下以任何方式收集用户数据。
|
||||
3.7 确保本软件无后门。
|
||||
3.8 CRMEB不提供与任何开源软件有关的或软件中可能使用的、集成的或与共同提供的第三方技术有关的任何保证。
|
||||
|
||||
协议发布时间: 2017年8月01日
|
||||
版本最新更新: 2022年6月15日 By CRMEB
|
||||
四、权利保留
|
||||
1、众邦科技依法保留未在本协议中明确授予给您的其他一切在法律上属于众邦科技的权利。
|
||||
2、本软件受著作权法、国际著作权条约和其他的知识产权法律或国际条约保护。根据本协议,在此仅许可您非独占性的、非排他性的一般许可使用该软件的权利,而不是出售或转让。
|
||||
3、商标权:本协议不授予您众邦科技或其供应商的任何商标或服务标志相关的任何权利。
|
||||
4、本软件所涉及到的一切知识产权,包括但不限于专利权、著作权、商标权、商业秘密、技术秘密,均属于各自内容拥有者的财产,众邦科技保留从其所拥有的知识产权获取利益的权利。
|
||||
5、您一旦开始确认本协议并安装本软件,即被视为完全理解并接受本协议的各项条款,在享有上述条款授予的权力的同时,受到相关的约束和限制。协议许可范围以外的行为,将直接违反本授权协议并构成侵权,我们有权立即终止授权,责令停止损害,并保留追究相关责任的权力。
|
||||
|
||||
五、知识产权
|
||||
1、我们拥有许可软件的著作权、商业秘密以及其他相关的知识产权,包括与许可软件有关的各种文档资料。许可软件的相关标识属于我们及我们的关联公司的知识产权,并受到相关法律法规的保护。
|
||||
2、在未获得我们明确同意前,您不得修改或删除应用产品中体现我们及其关联公司的任何标识、图标或身份信息。
|
||||
3、除非在此明确地许可或授予,本协议并不涉及任何技术转让,软件里所包含和涉及所有权利,产权和利益属于我们独自所有。除非在此明确地许可,本合同并不将任何技术转让给您。
|
||||
4、CRMEB欢迎并感谢您在保留CRMEB版权信息的前期下,将本软件原始系统发布在您的个人网站、企业官网或者其他的第三方网站。
|
||||
|
||||
六、升级版本
|
||||
1、我们会根据需要在后续进行一系列免费升级操作,您只有在获得商业使用授权许可后,才享有软件免费升级权益。我们有权决定将升级包何时以何种方式发送给您。
|
||||
2、升级版本的许可:如果该软件经众邦科技同意升级,除非升级版本有替代的软件许可协议,否则升级版本仍应遵循本协议条款。
|
||||
3、不论软件是否升级,您必须遵守本协议。
|
||||
|
||||
七、无担保和责任限制
|
||||
7.1 除众邦科技明确明示保证的事项以外,对其他任何默示、特定用途、适销性不做任何默示或明示的保证,由此引起的风险由您自己承担。
|
||||
7.2 有关本软件在使用过程中存在不适用性情况,您应当立即以书面方式反馈给我们,在我们现有技术可以解决的情况下,将依照众邦科技的软件产品标准保修政策规定。
|
||||
1)众邦科技不对试用期及免费试用软件因使用而产生的损失承担任何明示或暗示的责任。
|
||||
2)众邦科技承担的所有责任以您购买该软件所支付的价款为限。
|
||||
7.3 对因意外事故、滥用、错误使用、擅自修改所引起的软件使用问题,我们不承担任何责任,也不做任何保证。对因软件产品存在被攻击,或者自然灾害等不可抗力因素或非众邦科技原因导致软件不能使用,或造成损失的,我们不承担任何责任,也不做任何保证。
|
||||
7.4 对因使用软件引起的其他任何附带的、间接的或惩罚性的损失,包括但不限于商业利润的损失、信息或数据的丢失,众邦科技不承担任何责任,即使众邦科技已被告知存在此种损害的可能性也不例外。
|
||||
7.5 除法律法规有明确规定外,我们将尽最大努力确保许可软件及其所涉及的技术及信息安全、有效、准确、可靠,但受限于我们现有技术,您充分理解我们不能对此进行担保。您理解,对于因您自身、不可抗力及第三方原因导致的您的直接或间接损失,我们无法承担责任。
|
||||
7.6 由于您因下述任一情况所引起或与此有关的人身伤害或附带的、间接的损害赔偿,包括但不限于利润损失、资料损失、业务中断的损害赔偿或其他商业损害赔偿或损失,需由您自行承担:使用或未能使用许可软件;第三方未经批准的使用许可软件或更改您的数据;使用许可软件进行的行为产生的费用及损失;您对许可软件的误解;非因我们的原因而引起的与许可软件有关的其他损失。
|
||||
7.7 您清楚互联网软件的特殊性,本软件与大多数互联网软件一样,受包括但不限于用户原因、网络服务质量、社会环境等因素的影响,可能受到各种安全问题的侵扰,如用户下载安装的其他软件或访问的其他网站中含有“木马”等病毒,威胁到用户的计算机信息和数据的安全,继而影响本软件的正常使用等,用户应加强信息安全及使用资料的保护,以免遭受损失。
|
||||
|
||||
八、保密条款
|
||||
双方都应为可能获知另一方的商业计划、客户方资料、技术、产品、代码、文档和其他作为该方商业秘密的秘密信息予以保密。秘密信息包括所有有形的或无形的、标明为秘密的信息。秘密信息归披露方所有,除非经披露方声明许可否则不得披露或使用。
|
||||
|
||||
九、协议终止和违约责任
|
||||
1、如果您没有遵守本协议的部分或全部条款,众邦科技可以随时单方终止本协议。协议终止后,您必须立即停止使用该软件,对已经安装的软件进行卸载,如果由于您违反了本协议的规定给众邦科技造成损失,应承担损失赔偿责任。
|
||||
2、您应理解按授权范围使用许可软件、尊重软件及软件包含内容的知识产权、按规范使用软件、按本协议约定履行义务是您获取我们授权使用软件的前提,如您违反本协议,我们有权终止使用许可。
|
||||
3、您对软件的使用有赖于我们及关联公司为您提供的配套服务,您违反与我们或我们关联公司的条款、协议、规则、通告等相关规定,我们有权终止使用许可。您违反了本协议的规定给众邦科技造成损失,应承担给我们造成损失的赔偿责任。
|
||||
4、您理解出于维护软件系统及软件平台秩序的目的,如果您向我们及(或)我们的关联公司作出任何形式的承诺,且相关公司已确认您违反了该承诺并通知我们依据您与其相关约定进行处理的,则我们可按您的承诺或协议约定的方式对您的使用许可及其他我们可控制的权益采取限制措施,包括中止或终止对您的使用许可,并追究您相关法律责任的权利。
|
||||
5、您如从获得我们授权认可的第三方取得许可软件,您需要遵守本协议及第三方对您使用许可软件方式与限制的约定,如果您违反本协议及与第三方约定,我们有权终止对您的使用许可,并追究您相关法律责任。
|
||||
6、您应对从本软件获得的代码、文档等技术信息保密,不得对源代码、文档及框架进行删改,不得破译加密部分,不得非法进行倒卖本软件,我们不对非法软件使用后果承担任何责任,并有权追究您的法律责任,您应当赔偿因您的侵权行为给我们造成的直接和间接损失。
|
||||
7、如您违反本协议规定的条款,则构成违约,必须立即停止使用本软件,如给我们或其他用户造成损失的,您必须承担全部的赔偿责任(包括直接损失和间接损失),包括但不限于咨询费、诉讼费、执行费、保全费、保险费、律师费等费用。
|
||||
|
||||
十、管辖法律及可分割性
|
||||
1、本协议之效力、解释、变更、执行与争议解决均适用中华人民共和国法律,如无相关法律规定的,则应参照通用国际商业惯例和(或)行业惯例。本协议由您与我们于我们服务器所在地陕西省西安市莲湖区签署。因本协议产生或与本协议有关的争议,您可与我们以友好协商,协商不成时,提交西安仲裁委员会予以裁决。仲裁裁决是终局的,对双方均有拘束力。
|
||||
2、本协议任何条款被认定为无效的,不应影响其他条款或其任何部分的效力,您与我们仍应善意履行。
|
||||
|
||||
十一、其他
|
||||
1、本协议未约定的,由双方另行商定。
|
||||
2、本协议的所有标题仅是为了醒目及阅读方便,本身并没有实际涵义,不能作为解释本协议涵义的依据。(正文完)
|
||||
|
||||
西安众邦网络科技有限公司
|
||||
协议发布时间: 2017年08月01日
|
||||
版本最新更新: 2023年02月03日 By CRMEB
|
||||
|
||||
CRMEB官方网站:http://www.crmeb.com
|
||||
CRMEB演示站:http://demo.crmeb.com
|
||||
@ -31,4 +88,4 @@ CRMEB演示站:http://demo.crmeb.com
|
||||
运营团队: 众邦科技
|
||||
电 话: 400-8888-794
|
||||
邮 箱: admin@xazbkj.com
|
||||
网 址: http://www.xazbkj.com
|
||||
网 址: http://www.xazbkj.com
|
||||
@ -84,9 +84,9 @@ class AdminApiExceptionHandle extends Handle
|
||||
'trace' => $e->getTrace(),
|
||||
'previous' => $e->getPrevious(),
|
||||
] : [];
|
||||
$message = Env::get('app_debug', false) ? '接口报错:' . $e->getMessage() : '很抱歉,系统开小差了';
|
||||
$message = Env::get('app_debug', false) ? $e->getMessage() : '很抱歉,系统开小差了';
|
||||
// 添加自定义异常处理机制
|
||||
if ($e instanceof AuthException || $e instanceof AdminException || $e instanceof ApiException) {
|
||||
if ($e instanceof AuthException || $e instanceof AdminException || $e instanceof ApiException || $e instanceof ValidateException) {
|
||||
return app('json')->make($e->getCode() ?: 400, $message, $massageData);
|
||||
} else {
|
||||
return app('json')->fail($message, $massageData);
|
||||
|
||||
@ -361,30 +361,8 @@ class Common extends AuthController
|
||||
*/
|
||||
public function copyright()
|
||||
{
|
||||
try {
|
||||
if (Cache::has('nncnL_crmeb_copyright')) {
|
||||
$copyrightContext = Cache::get('nncnL_crmeb_copyright');
|
||||
} else {
|
||||
/** @var SystemConfigServices $services */
|
||||
$services = app()->make(SystemConfigServices::class);
|
||||
$copyrightContext = $services->value(['menu_name' => 'nncnL_crmeb_copyright'], 'value');
|
||||
$copyrightContext = $copyrightContext ? json_decode($copyrightContext, true) : null;
|
||||
Cache::set('nncnL_crmeb_copyright', $copyrightContext, 3600);
|
||||
}
|
||||
|
||||
if (Cache::has('nncnL_crmeb_copyright_image')) {
|
||||
$copyrightImage = Cache::get('nncnL_crmeb_copyright_image');
|
||||
} else {
|
||||
/** @var SystemConfigServices $services */
|
||||
$services = app()->make(SystemConfigServices::class);
|
||||
$copyrightImage = $services->value(['menu_name' => 'nncnL_crmeb_copyright_image'], 'value');
|
||||
$copyrightImage = $copyrightImage ? json_decode($copyrightImage, true) : null;
|
||||
Cache::set('nncnL_crmeb_copyright_image', $copyrightImage, 3600);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
$copyrightContext = '';
|
||||
$copyrightImage = '';
|
||||
}
|
||||
$copyrightContext = sys_config('nncnL_crmeb_copyright', '');
|
||||
$copyrightImage = sys_config('nncnL_crmeb_copyright_image', '');
|
||||
return app('json')->success(compact('copyrightContext', 'copyrightImage'));
|
||||
}
|
||||
|
||||
@ -395,15 +373,10 @@ class Common extends AuthController
|
||||
public function saveCopyright()
|
||||
{
|
||||
[$copyright, $copyrightImg] = $this->request->postMore(['copyright', 'copyright_img',], true);
|
||||
|
||||
/** @var SystemConfigServices $services */
|
||||
$services = app()->make(SystemConfigServices::class);
|
||||
if ($services->count(['menu_name' => 'nncnL_crmeb_copyright'])) {
|
||||
$services->update([
|
||||
'menu_name' => 'nncnL_crmeb_copyright'
|
||||
], [
|
||||
'value' => json_encode($copyright)
|
||||
]);
|
||||
$services->update(['menu_name' => 'nncnL_crmeb_copyright'], ['value' => json_encode($copyright)]);
|
||||
} else {
|
||||
$services->save([
|
||||
'menu_name' => 'nncnL_crmeb_copyright',
|
||||
@ -415,13 +388,8 @@ class Common extends AuthController
|
||||
'info' => ''
|
||||
]);
|
||||
}
|
||||
|
||||
if ($services->count(['menu_name' => 'nncnL_crmeb_copyright_image'])) {
|
||||
$services->update([
|
||||
'menu_name' => 'nncnL_crmeb_copyright_image'
|
||||
], [
|
||||
'value' => json_encode($copyrightImg)
|
||||
]);
|
||||
$services->update(['menu_name' => 'nncnL_crmeb_copyright_image'], ['value' => json_encode($copyrightImg)]);
|
||||
} else {
|
||||
$services->save([
|
||||
'menu_name' => 'nncnL_crmeb_copyright_image',
|
||||
@ -433,9 +401,6 @@ class Common extends AuthController
|
||||
'info' => ''
|
||||
]);
|
||||
}
|
||||
|
||||
Cache::set('nncnL_crmeb_copyright', $copyright, 3600);
|
||||
Cache::set('nncnL_crmeb_copyright_image', $copyrightImg, 3600);
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
|
||||
@ -104,14 +104,14 @@ class Login extends AuthController
|
||||
$this->validate(['account' => $account, 'pwd' => $password], \app\adminapi\validate\setting\SystemAdminValidata::class, 'get');
|
||||
$result = $this->services->login($account, $password, 'admin', $key);
|
||||
if (!$result) {
|
||||
$num = CacheService::redisHandler()->get('login_captcha',1);
|
||||
$num = CacheService::get('login_captcha',1);
|
||||
if ($num > 1) {
|
||||
return app('json')->fail(400140, ['login_captcha' => 1]);
|
||||
}
|
||||
CacheService::redisHandler()->set('login_captcha', $num + 1, 60);
|
||||
CacheService::set('login_captcha', $num + 1, 60);
|
||||
return app('json')->fail(400140, ['login_captcha' => 0]);
|
||||
}
|
||||
CacheService::redisHandler()->delete('login_captcha');
|
||||
CacheService::delete('login_captcha');
|
||||
return app('json')->success($result);
|
||||
}
|
||||
|
||||
|
||||
@ -61,7 +61,7 @@ class RoutineTemplate extends AuthController
|
||||
}
|
||||
if ($all['list']) {
|
||||
foreach ($all['list'] as $template) {
|
||||
SyncMessageJob::dispatchDo('SyncSubscribe', [$template]);
|
||||
SyncMessageJob::dispatch('SyncSubscribe', [$template]);
|
||||
}
|
||||
}
|
||||
return app('json')->success(100038);
|
||||
|
||||
@ -54,7 +54,7 @@ class WechatTemplate extends AuthController
|
||||
WechatService::deleleTemplate($v['template_id']);
|
||||
}
|
||||
foreach ($all['list'] as $template) {
|
||||
SyncMessageJob::dispatchDo('SyncWechat', [$template]);
|
||||
SyncMessageJob::dispatch('SyncWechat', [$template]);
|
||||
}
|
||||
return app('json')->success(100038);
|
||||
}
|
||||
|
||||
@ -89,6 +89,7 @@ class Diy extends AuthController
|
||||
}
|
||||
}
|
||||
$data['value'] = json_encode($value);
|
||||
$data['version'] = uniqid();
|
||||
$this->services->saveData($id, $data);
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
@ -169,6 +170,7 @@ class Diy extends AuthController
|
||||
$data['version'] = '1.0';
|
||||
$data['type'] = 2;
|
||||
$data['is_diy'] = 1;
|
||||
$data['version'] = uniqid();
|
||||
return app('json')->success($id ? 100001 : 100000, ['id' => $this->services->saveData($id, $data)]);
|
||||
}
|
||||
|
||||
|
||||
@ -49,6 +49,132 @@ class ExportExcel extends AuthController
|
||||
$this->service = $services;
|
||||
}
|
||||
|
||||
public function userList()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['page', 1],
|
||||
['limit', 20],
|
||||
['nickname', ''],
|
||||
['status', ''],
|
||||
['pay_count', ''],
|
||||
['is_promoter', ''],
|
||||
['order', ''],
|
||||
['data', ''],
|
||||
['user_type', ''],
|
||||
['country', ''],
|
||||
['province', ''],
|
||||
['city', ''],
|
||||
['user_time_type', ''],
|
||||
['user_time', ''],
|
||||
['sex', ''],
|
||||
[['level', 0], 0],
|
||||
[['group_id', 'd'], 0],
|
||||
['label_id', ''],
|
||||
['now_money', 'normal'],
|
||||
['field_key', ''],
|
||||
['isMember', '']
|
||||
]);
|
||||
return app('json')->success($this->service->exportUserList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单导出
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function orderList()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['status', ''],
|
||||
['real_name', ''],
|
||||
['is_del', ''],
|
||||
['data', '', '', 'time'],
|
||||
['type', ''],
|
||||
['pay_type', ''],
|
||||
['order', ''],
|
||||
['field_key', ''],
|
||||
]);
|
||||
$where['is_system_del'] = 0;
|
||||
$where['pid'] = 0;
|
||||
return app('json')->success($this->service->exportOrderList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品列表导出
|
||||
* @return mixed
|
||||
*/
|
||||
public function productList()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['store_name', ''],
|
||||
['cate_id', ''],
|
||||
['type', 1]
|
||||
]);
|
||||
return app('json')->success($this->service->exportProductList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价商品列表导出
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function bargainList()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['status', ''],
|
||||
['store_name', ''],
|
||||
]);
|
||||
$where['is_del'] = 0;
|
||||
return app('json')->success($this->service->exportBargainList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团商品导出
|
||||
* @return mixed
|
||||
*/
|
||||
public function combinationList()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['is_show', ''],
|
||||
['store_name', '']
|
||||
]);
|
||||
$where['is_del'] = 0;
|
||||
return app('json')->success($this->service->exportCombinationList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 秒杀商品导出
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function seckillList()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
[['status', 's'], ''],
|
||||
[['store_name', 's'], '']
|
||||
]);
|
||||
return app('json')->success($this->service->exportSeckillList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员卡导出
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function memberCardList($id)
|
||||
{
|
||||
return app('json')->success($this->service->exportMemberCard($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存用户资金监控的excel表格
|
||||
* @param UserBillServices $services
|
||||
@ -239,7 +365,7 @@ class ExportExcel extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 产品导出
|
||||
* 商品导出
|
||||
* @param StoreProductServices $services
|
||||
* @return mixed
|
||||
*/
|
||||
|
||||
@ -62,7 +62,7 @@ class StoreService extends AuthController
|
||||
['data', '', '', 'time'],
|
||||
['type', '', '', 'user_type'],
|
||||
]);
|
||||
[$list, $count] = $services->getWhereUserList($where, 'u.nickname,u.uid,u.avatar as headimgurl,w.subscribe,w.province,w.country,w.city,w.sex,w.user_type,u.is_del');
|
||||
[$list, $count] = $services->getWhereUserList($where, 'u.nickname,u.uid,u.avatar as headimgurl,w.subscribe,w.province,w.country,w.city,w.sex,u.user_type,u.is_del');
|
||||
return app('json')->success(compact('list', 'count'));
|
||||
}
|
||||
|
||||
|
||||
@ -67,10 +67,11 @@ class StoreCouponIssue extends AuthController
|
||||
['is_permanent', 0],
|
||||
['total_count', 0],
|
||||
['product_id', ''],
|
||||
['category_id', 0],
|
||||
['category_id', []],
|
||||
['type', 0],
|
||||
['sort', 0],
|
||||
['status', 0],
|
||||
['receive_limit', 1],
|
||||
]);
|
||||
$res = $this->services->saveCoupon($data);
|
||||
if ($res) return app('json')->success(100000);
|
||||
@ -110,6 +111,12 @@ class StoreCouponIssue extends AuthController
|
||||
];
|
||||
}
|
||||
}
|
||||
if ($info['category_id'] != '') {
|
||||
$info['category_id'] = explode(',', $info['category_id']);
|
||||
foreach ($info['category_id'] as &$category_id) {
|
||||
$category_id = (int)$category_id;
|
||||
}
|
||||
}
|
||||
return app('json')->success($info);
|
||||
}
|
||||
|
||||
|
||||
@ -64,7 +64,7 @@ class SmsConfig extends AuthController
|
||||
*/
|
||||
public function is_login(ServeServices $services)
|
||||
{
|
||||
$sms_info = CacheService::redisHandler()->get('sms_account');
|
||||
$sms_info = CacheService::get('sms_account');
|
||||
$data = ['status' => false, 'info' => ''];
|
||||
if ($sms_info) {
|
||||
try {
|
||||
@ -87,7 +87,7 @@ class SmsConfig extends AuthController
|
||||
if ($account && $password) {
|
||||
$res = $services->user()->login($account, $password);
|
||||
if ($res) {
|
||||
CacheService::redisHandler()->set('sms_account', $account);
|
||||
CacheService::set('sms_account', $account);
|
||||
$data['status'] = true;
|
||||
$data['info'] = $account;
|
||||
}
|
||||
@ -103,7 +103,7 @@ class SmsConfig extends AuthController
|
||||
*/
|
||||
public function logout()
|
||||
{
|
||||
$res = CacheService::redisHandler()->delete('sms_account');
|
||||
$res = CacheService::delete('sms_account');
|
||||
if ($res) {
|
||||
$this->services->updateSmsConfig('', '');
|
||||
CacheService::clear();
|
||||
|
||||
@ -479,9 +479,15 @@ class StoreOrder extends AuthController
|
||||
|
||||
$orderInfo = $this->services->tidyOrder($orderInfo->toArray(), true, true);
|
||||
//核算优惠金额
|
||||
$vipTruePrice = array_column($orderInfo['cartInfo'], 'vip_sum_truePrice');
|
||||
$vipTruePrice = round(array_sum($vipTruePrice), 2);
|
||||
$orderInfo['vip_true_price'] = $vipTruePrice ?: 0;
|
||||
$vipTruePrice = $levelPrice = $memberPrice = 0;
|
||||
foreach ($orderInfo['cartInfo'] as $cart) {
|
||||
$vipTruePrice = bcadd((string)$vipTruePrice, (string)$cart['vip_sum_truePrice'], 2);
|
||||
if ($cart['price_type'] == 'member') $memberPrice = bcadd((string)$memberPrice, (string)$cart['vip_sum_truePrice'], 2);
|
||||
if ($cart['price_type'] == 'level') $levelPrice = bcadd((string)$levelPrice, (string)$cart['vip_sum_truePrice'], 2);
|
||||
}
|
||||
$orderInfo['vip_true_price'] = $vipTruePrice;
|
||||
$orderInfo['levelPrice'] = $levelPrice;
|
||||
$orderInfo['memberPrice'] = $memberPrice;
|
||||
$orderInfo['total_price'] = bcadd($orderInfo['total_price'], $orderInfo['vip_true_price'], 2);
|
||||
if ($orderInfo['store_id'] && $orderInfo['shipping_type'] == 2) {
|
||||
/** @var $storeServices */
|
||||
@ -687,15 +693,17 @@ class StoreOrder extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 易联云打印机打印
|
||||
* 小票打印机打印
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function order_print($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
|
||||
$res = $this->services->orderPrint($id);
|
||||
$res = $this->services->orderPrintTicket($id, true);
|
||||
if ($res) {
|
||||
return app('json')->success(100010);
|
||||
} else {
|
||||
|
||||
@ -107,7 +107,7 @@ class Login extends AuthController
|
||||
$res = $this->services->user()->login($account, $password);
|
||||
if ($res) {
|
||||
CacheService::clear();
|
||||
CacheService::redisHandler()->set('sms_account', $account);
|
||||
CacheService::set('sms_account', $account);
|
||||
$services->updateSmsConfig($account, $password);
|
||||
return app('json')->success(400139, $res);
|
||||
} else {
|
||||
|
||||
@ -44,7 +44,7 @@ class Serve extends AuthController
|
||||
*/
|
||||
public function is_login()
|
||||
{
|
||||
$sms_info = CacheService::redisHandler()->get('sms_account');
|
||||
$sms_info = CacheService::get('sms_account');
|
||||
if ($sms_info) {
|
||||
return app('json')->success(['status' => true, 'info' => $sms_info]);
|
||||
} else {
|
||||
@ -188,7 +188,7 @@ class Serve extends AuthController
|
||||
|
||||
$data['password'] = md5($data['password']);
|
||||
$this->services->user()->modify($data);
|
||||
CacheService::redisHandler()->delete('sms_account');
|
||||
CacheService::delete('sms_account');
|
||||
return app('json')->success(100001);
|
||||
}
|
||||
|
||||
@ -207,7 +207,7 @@ class Serve extends AuthController
|
||||
$this->validate($data, ServeValidata::class, 'phone');
|
||||
|
||||
$this->services->user()->modifyPhone($data);
|
||||
CacheService::redisHandler()->delete('sms_account');
|
||||
CacheService::delete('sms_account');
|
||||
return app('json')->success(100001);
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ class LangType extends AuthController
|
||||
['status', 0]
|
||||
]);
|
||||
$this->services->langTypeSave($data);
|
||||
CacheService::redisHandler()->delete('lang_type_data');
|
||||
CacheService::delete('lang_type_data');
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
@ -89,7 +89,7 @@ class LangType extends AuthController
|
||||
public function langTypeDel(int $id = 0)
|
||||
{
|
||||
$this->services->langTypeDel($id);
|
||||
CacheService::redisHandler()->delete('lang_type_data');
|
||||
CacheService::delete('lang_type_data');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
}
|
||||
@ -169,7 +169,7 @@ class SystemAdmin extends AuthController
|
||||
['new_pwd', ''],
|
||||
['conf_pwd', ''],
|
||||
]);
|
||||
if(!preg_match('/^(?![^a-zA-Z]+$)(?!\D+$).{6,}$/',$data['new_pwd'])){
|
||||
if (!preg_match('/^(?![^a-zA-Z]+$)(?!\D+$).{6,}$/', $data['new_pwd'])) {
|
||||
return app('json')->fail(400183);
|
||||
}
|
||||
if ($this->services->updateAdmin($this->adminId, $data))
|
||||
@ -177,6 +177,7 @@ class SystemAdmin extends AuthController
|
||||
else
|
||||
return app('json')->fail(100007);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改当前登陆admin的文件管理密码
|
||||
* @return mixed
|
||||
@ -187,7 +188,7 @@ class SystemAdmin extends AuthController
|
||||
['file_pwd', ''],
|
||||
['conf_file_pwd', ''],
|
||||
]);
|
||||
if(!preg_match('/^(?![^a-zA-Z]+$)(?!\D+$).{6,}$/',$data['file_pwd'])){
|
||||
if (!preg_match('/^(?![^a-zA-Z]+$)(?!\D+$).{6,}$/', $data['file_pwd'])) {
|
||||
return app('json')->fail(400183);
|
||||
}
|
||||
if ($this->services->setFilePassword($this->adminId, $data))
|
||||
@ -203,7 +204,7 @@ class SystemAdmin extends AuthController
|
||||
public function logout()
|
||||
{
|
||||
$key = trim(ltrim($this->request->header(Config::get('cookie.token_name')), 'Bearer'));
|
||||
CacheService::redisHandler()->delete($key);
|
||||
CacheService::delete(md5($key));
|
||||
return app('json')->success();
|
||||
}
|
||||
}
|
||||
|
||||
92
crmeb/app/adminapi/controller/v1/system/SystemTimer.php
Normal file
92
crmeb/app/adminapi/controller/v1/system/SystemTimer.php
Normal file
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller\v1\system;
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\services\system\timer\SystemTimerServices;
|
||||
use think\facade\App;
|
||||
|
||||
class SystemTimer extends AuthController
|
||||
{
|
||||
public function __construct(App $app, SystemTimerServices $services)
|
||||
{
|
||||
parent::__construct($app);
|
||||
$this->services = $services;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取定时任务列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTimerList()
|
||||
{
|
||||
$where = ['is_del' => 0];
|
||||
return app('json')->success($this->services->getTimerList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取定时任务详情
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTimerInfo($id)
|
||||
{
|
||||
return app('json')->success($this->services->getTimerInfo($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取定时任务类型
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMarkList()
|
||||
{
|
||||
return app('json')->success($this->services->getMarkList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存定时任务
|
||||
* @return mixed
|
||||
*/
|
||||
public function saveTimer()
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['id', 0],
|
||||
['name', ''],
|
||||
['mark', ''],
|
||||
['content', ''],
|
||||
['type', 0],
|
||||
['is_open', 0],
|
||||
['week', 0],
|
||||
['day', 0],
|
||||
['hour', 0],
|
||||
['minute', 0],
|
||||
['second', 0],
|
||||
]);
|
||||
$this->services->saveTimer($data);
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除定时任务
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function delTimer($id)
|
||||
{
|
||||
$this->services->delTimer($id);
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置定时任务状态
|
||||
* @param $id
|
||||
* @param $is_open
|
||||
* @return mixed
|
||||
*/
|
||||
public function setTimerStatus($id, $is_open)
|
||||
{
|
||||
$this->services->setTimerStatus($id, $is_open);
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
|
||||
}
|
||||
@ -107,19 +107,19 @@ class User extends AuthController
|
||||
['is_promoter', 0],
|
||||
['status', 0]
|
||||
]);
|
||||
if ($data['phone']) {
|
||||
if (!check_phone($data['phone'])) {
|
||||
return app('json')->fail(400252);
|
||||
}
|
||||
if ($this->services->count(['phone' => $data['phone'], 'is_del' => 0])) {
|
||||
return app('json')->fail(400314);
|
||||
}
|
||||
if (trim($data['real_name']) != '') {
|
||||
$data['nickname'] = $data['real_name'];
|
||||
} else {
|
||||
$data['nickname'] = substr_replace($data['phone'], '****', 3, 4);
|
||||
}
|
||||
if (!$data['real_name']) {
|
||||
return app('json')->fail(410245);
|
||||
}
|
||||
if (!$data['phone']) {
|
||||
return app('json')->fail(410245);
|
||||
}
|
||||
if (!check_phone($data['phone'])) {
|
||||
return app('json')->fail(400252);
|
||||
}
|
||||
if ($this->services->count(['phone' => $data['phone'], 'is_del' => 0])) {
|
||||
return app('json')->fail(400314);
|
||||
}
|
||||
$data['nickname'] = $data['real_name'];
|
||||
if ($data['card_id']) {
|
||||
if (!check_card($data['card_id'])) return app('json')->fail(400315);
|
||||
}
|
||||
@ -130,6 +130,9 @@ class User extends AuthController
|
||||
if ($data['pwd'] != $data['true_pwd']) {
|
||||
return app('json')->fail(400264);
|
||||
}
|
||||
if (strlen($data['pwd']) < 6 || strlen($data['pwd']) > 32) {
|
||||
return app('json')->fail(400762);
|
||||
}
|
||||
$data['pwd'] = md5($data['pwd']);
|
||||
} else {
|
||||
unset($data['pwd']);
|
||||
@ -389,6 +392,9 @@ class User extends AuthController
|
||||
if ($data['pwd'] != $data['true_pwd']) {
|
||||
return app('json')->fail(400264);
|
||||
}
|
||||
if (strlen($data['pwd']) < 6 || strlen($data['pwd']) > 32) {
|
||||
return app('json')->fail(400762);
|
||||
}
|
||||
$data['pwd'] = md5($data['pwd']);
|
||||
} else {
|
||||
unset($data['pwd']);
|
||||
|
||||
@ -63,18 +63,16 @@ class UserLevel extends AuthController
|
||||
['icon', ''],
|
||||
['image', ''],
|
||||
['is_show', ''],
|
||||
['explain', ''],
|
||||
['exp_num', 0]
|
||||
]);
|
||||
if ($data['valid_date'] == 0) $data['is_forever'] = 1;//有效时间为0的时候就是永久
|
||||
if (!$data['name']) return app('json')->fail(400324);
|
||||
if (!$data['grade']) return app('json')->fail(400325);
|
||||
if (!$data['explain']) return app('json')->fail(400326);
|
||||
if (!$data['icon']) return app('json')->fail(400327);
|
||||
if (!$data['image']) return app('json')->fail(400328);
|
||||
if (!$data['exp_num']) return app('json')->fail(400329);
|
||||
|
||||
return app('json')->success($this->services->save((int)$data['id'], $data));
|
||||
$this->services->save((int)$data['id'], $data);
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -14,6 +14,21 @@ use think\facade\Route;
|
||||
* 导出excel相关路由
|
||||
*/
|
||||
Route::group('export', function () {
|
||||
//用户列表
|
||||
Route::get('user_list', 'v1.export.ExportExcel/userList')->option(['real_name' => '用户列表导出']);
|
||||
//订单列表
|
||||
Route::get('order_list', 'v1.export.ExportExcel/orderList')->option(['real_name' => '订单列表导出']);
|
||||
//商品列表
|
||||
Route::get('product_list', 'v1.export.ExportExcel/productList')->option(['real_name' => '商品列表导出']);
|
||||
//砍价列表
|
||||
Route::get('bargain_list', 'v1.export.ExportExcel/bargainList')->option(['real_name' => '砍价商品列表导出']);
|
||||
//拼团列表
|
||||
Route::get('combination_list', 'v1.export.ExportExcel/combinationList')->option(['real_name' => '拼团商品列表导出']);
|
||||
//秒杀列表
|
||||
Route::get('seckill_list', 'v1.export.ExportExcel/seckillList')->option(['real_name' => '秒杀商品列表导出']);
|
||||
//导出会员卡
|
||||
Route::get('member_card/:id', 'v1.export.ExportExcel/memberCardList')->option(['real_name' => '会员卡导出']);
|
||||
|
||||
//用户资金监控
|
||||
Route::get('userFinance', 'v1.export.ExportExcel/userFinance')->option(['real_name' => '用户资金导出']);
|
||||
//用户佣金
|
||||
|
||||
@ -36,6 +36,7 @@ Route::group(function () {
|
||||
Route::get('get_workerman_url', 'PublicController/getWorkerManUrl')->option(['real_name' => '获取客服数据']);
|
||||
//测试
|
||||
Route::get('index', 'Test/index')->option(['real_name' => '测试地址']);
|
||||
Route::get('h5', 'Test/h5pay')->option(['real_name' => '测试地址2']);
|
||||
})->middleware(AllowOriginMiddleware::class);
|
||||
|
||||
/**
|
||||
|
||||
@ -96,6 +96,21 @@ Route::group('system', function () {
|
||||
Route::get('upgrade_export/:id/:type', 'UpgradeController/export')->option(['real_name' => '导出备份']);
|
||||
//文件管理登录
|
||||
Route::post('file/login', 'v1.system.SystemFile/login')->option(['real_name' => '文件管理登录']);
|
||||
|
||||
/** 定时任务 */
|
||||
//定时任务列表
|
||||
Route::get('timer/list', 'v1.system.SystemTimer/getTimerList')->option(['real_name' => '定时任务列表']);
|
||||
//定时任务类型
|
||||
Route::get('timer/mark', 'v1.system.SystemTimer/getMarkList')->option(['real_name' => '定时任务类型']);
|
||||
//定时任务详情
|
||||
Route::get('timer/info/:id', 'v1.system.SystemTimer/getTimerInfo')->option(['real_name' => '定时任务详情']);
|
||||
//定时任务添加编辑
|
||||
Route::post('timer/save', 'v1.system.SystemTimer/saveTimer')->option(['real_name' => '定时任务添加编辑']);
|
||||
//删除定时任务
|
||||
Route::delete('timer/del/:id', 'v1.system.SystemTimer/delTimer')->option(['real_name' => '删除定时任务']);
|
||||
//定时任务是否开启开关
|
||||
Route::get('timer/set_open/:id/:is_open', 'v1.system.SystemTimer/setTimerStatus')->option(['real_name' => '定时任务是否开启开关']);
|
||||
|
||||
})->middleware([
|
||||
\app\http\middleware\AllowOriginMiddleware::class,
|
||||
\app\adminapi\middleware\AdminAuthTokenMiddleware::class,
|
||||
|
||||
@ -84,9 +84,9 @@ class ApiExceptionHandle extends Handle
|
||||
'trace' => $e->getTrace(),
|
||||
'previous' => $e->getPrevious(),
|
||||
] : [];
|
||||
$message = Env::get('app_debug', false) ? '接口报错:' . $e->getMessage() : '很抱歉,系统开小差了';
|
||||
$message = Env::get('app_debug', false) ? $e->getMessage() : '很抱歉,系统开小差了';
|
||||
// 添加自定义异常处理机制
|
||||
if ($e instanceof AuthException || $e instanceof AdminException || $e instanceof ApiException) {
|
||||
if ($e instanceof AuthException || $e instanceof AdminException || $e instanceof ApiException || $e instanceof ValidateException) {
|
||||
return app('json')->make($e->getCode() ?: 400, $message, $massageData);
|
||||
} else {
|
||||
return app('json')->fail($message, $massageData);
|
||||
|
||||
@ -68,10 +68,11 @@ class ProductController
|
||||
*/
|
||||
public function getProductRoutineCode(Request $request)
|
||||
{
|
||||
list($product_id) = $request->getMore([
|
||||
list($product_id, $type) = $request->getMore([
|
||||
['product_id', 0],
|
||||
['type', 'product'],
|
||||
], true);
|
||||
$routineCode = $this->services->getProductRoutineCode((int)$product_id);
|
||||
$routineCode = $this->services->getProductRoutineCode((int)$product_id, $type);
|
||||
return app('json')->success(['routineCode' => $routineCode]);
|
||||
}
|
||||
|
||||
|
||||
@ -53,7 +53,7 @@ class LoginController
|
||||
[$account, $password, $spread] = $request->postMore([
|
||||
'account', 'password', 'spread'
|
||||
], true);
|
||||
TaskJob::dispatchDo('emptyYesterdayAttachment');
|
||||
TaskJob::dispatch('emptyYesterdayAttachment');
|
||||
if (!$account || !$password) {
|
||||
return app('json')->fail(410000);
|
||||
}
|
||||
@ -68,7 +68,7 @@ class LoginController
|
||||
public function logout(Request $request)
|
||||
{
|
||||
$key = trim(ltrim($request->header(Config::get('cookie.token_name')), 'Bearer'));
|
||||
CacheService::redisHandler()->delete($key);
|
||||
CacheService::delete(md5($key));
|
||||
return app('json')->success(410002);
|
||||
}
|
||||
|
||||
|
||||
@ -46,6 +46,12 @@ class PayController
|
||||
$pay = app()->make(Pay::class);
|
||||
}
|
||||
return $pay->handleNotify()->getContent();
|
||||
default:
|
||||
if (strstr($type, 'allin') !== false) {
|
||||
/** @var Pay $pay */
|
||||
$pay = app()->make(Pay::class, ['allin_pay']);
|
||||
return $pay->handleNotify($type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -284,12 +284,14 @@ class PublicController
|
||||
/**
|
||||
* 记录用户分享
|
||||
* @param Request $request
|
||||
* @param UserBillServices $services
|
||||
* @return mixed
|
||||
*/
|
||||
public function user_share(Request $request, UserBillServices $services)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
return app('json')->success($services->setUserShare($uid));
|
||||
$services->setUserShare($uid);
|
||||
return app('json')->success(100012);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -306,11 +308,11 @@ class PublicController
|
||||
if ($imageUrl !== '' && !preg_match('/.*(\.png|\.jpg|\.jpeg|\.gif)$/', $imageUrl)) {
|
||||
return app('json')->success(['code' => false, 'image' => false]);
|
||||
}
|
||||
if ($codeUrl !== '' && !preg_match('/.*(\.png|\.jpg|\.jpeg|\.gif)$/', $codeUrl)) {
|
||||
if ($codeUrl !== '' && !(preg_match('/.*(\.png|\.jpg|\.jpeg|\.gif)$/', $codeUrl) || strpos($codeUrl, 'https://mp.weixin.qq.com/cgi-bin/showqrcode') !== false)) {
|
||||
return app('json')->success(['code' => false, 'image' => false]);
|
||||
}
|
||||
try {
|
||||
$code = CacheService::get($codeUrl, function () use ($codeUrl) {
|
||||
$code = CacheService::remember($codeUrl, function () use ($codeUrl) {
|
||||
$codeTmp = $code = $codeUrl ? image_to_base64($codeUrl) : false;
|
||||
if (!$codeTmp) {
|
||||
$putCodeUrl = put_image($codeUrl);
|
||||
@ -319,7 +321,7 @@ class PublicController
|
||||
}
|
||||
return $code;
|
||||
});
|
||||
$image = CacheService::get($imageUrl, function () use ($imageUrl) {
|
||||
$image = CacheService::remember($imageUrl, function () use ($imageUrl) {
|
||||
$imageTmp = $image = $imageUrl ? image_to_base64($imageUrl) : false;
|
||||
if (!$imageTmp) {
|
||||
$putImageUrl = put_image($imageUrl);
|
||||
@ -556,32 +558,11 @@ class PublicController
|
||||
*/
|
||||
public function copyright()
|
||||
{
|
||||
try {
|
||||
if (Cache::has('nncnL_crmeb_copyright')) {
|
||||
$copyrightContext = Cache::get('nncnL_crmeb_copyright');
|
||||
} else {
|
||||
/** @var SystemConfigServices $services */
|
||||
$services = app()->make(SystemConfigServices::class);
|
||||
$copyrightContext = $services->value(['menu_name' => 'nncnL_crmeb_copyright'], 'value');
|
||||
$copyrightContext = $copyrightContext ? json_decode($copyrightContext, true) : null;
|
||||
Cache::set('nncnL_crmeb_copyright', $copyrightContext, 3600);
|
||||
}
|
||||
|
||||
// dump(Cache::has('nncnL_crmeb_copyright_image'));
|
||||
if (Cache::has('nncnL_crmeb_copyright_image')) {
|
||||
$copyrightImage = Cache::get('nncnL_crmeb_copyright_image');
|
||||
} else {
|
||||
/** @var SystemConfigServices $services */
|
||||
$services = app()->make(SystemConfigServices::class);
|
||||
$copyrightImage = $services->value(['menu_name' => 'nncnL_crmeb_copyright_image'], 'value');
|
||||
$copyrightImage = $copyrightImage ? json_decode($copyrightImage, true) : null;
|
||||
Cache::set('nncnL_crmeb_copyright_image', $copyrightImage, 3600);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
$copyrightContext = '';
|
||||
$copyrightImage = '';
|
||||
}
|
||||
return app('json')->success(compact('copyrightContext', 'copyrightImage'));
|
||||
$copyrightContext = sys_config('nncnL_crmeb_copyright', '');
|
||||
$copyrightImage = sys_config('nncnL_crmeb_copyright_image', '');
|
||||
$siteName = sys_config('site_name', '');
|
||||
$siteLogo = sys_config('wap_login_logo', '');
|
||||
return app('json')->success(compact('copyrightContext', 'copyrightImage', 'siteName', 'siteLogo'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -636,7 +617,7 @@ class PublicController
|
||||
$langStr = 'api_lang_' . str_replace('-', '_', $langData[$typeId]);
|
||||
|
||||
//读取当前语言的语言包
|
||||
$lang = CacheService::redisHandler()->remember($langStr, function () use ($typeId, $range) {
|
||||
$lang = CacheService::remember($langStr, function () use ($typeId, $range) {
|
||||
/** @var LangCodeServices $langCodeServices */
|
||||
$langCodeServices = app()->make(LangCodeServices::class);
|
||||
return $langCodeServices->getColumn(['type_id' => $typeId, 'is_admin' => 0], 'lang_explain', 'code');
|
||||
|
||||
119
crmeb/app/api/controller/v1/TimerController.php
Normal file
119
crmeb/app/api/controller/v1/TimerController.php
Normal file
@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller\v1;
|
||||
|
||||
use app\services\activity\combination\StorePinkServices;
|
||||
use app\services\activity\live\LiveGoodsServices;
|
||||
use app\services\activity\live\LiveRoomServices;
|
||||
use app\services\agent\AgentManageServices;
|
||||
use app\services\order\StoreOrderServices;
|
||||
use app\services\order\StoreOrderTakeServices;
|
||||
use app\services\product\product\StoreProductServices;
|
||||
use app\services\system\attachment\SystemAttachmentServices;
|
||||
|
||||
class TimerController
|
||||
{
|
||||
/**
|
||||
* 检测定时任务是否正常,必须6秒执行一次
|
||||
*/
|
||||
public function timerCheck()
|
||||
{
|
||||
file_put_contents(runtime_path() . '.timer', time());
|
||||
}
|
||||
|
||||
/**
|
||||
* 未支付自动取消订单
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function orderUnpaidCancel()
|
||||
{
|
||||
/** @var StoreOrderServices $orderServices */
|
||||
$orderServices = app()->make(StoreOrderServices::class);
|
||||
$orderServices->orderUnpaidCancel();
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团到期订单处理
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function pinkExpiration()
|
||||
{
|
||||
/** @var StorePinkServices $storePinkServices */
|
||||
$storePinkServices = app()->make(StorePinkServices::class);
|
||||
$storePinkServices->statusPink();
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动解绑上级绑定
|
||||
*/
|
||||
public function agentUnbind()
|
||||
{
|
||||
/** @var AgentManageServices $agentManage */
|
||||
$agentManage = app()->make(AgentManageServices::class);
|
||||
$agentManage->removeSpread();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新直播商品状态
|
||||
*/
|
||||
public function syncGoodStatus()
|
||||
{
|
||||
/** @var LiveGoodsServices $liveGoods */
|
||||
$liveGoods = app()->make(LiveGoodsServices::class);
|
||||
$liveGoods->syncGoodStatus();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新直播间状态
|
||||
*/
|
||||
public function syncRoomStatus()
|
||||
{
|
||||
/** @var LiveRoomServices $liveRoom */
|
||||
$liveRoom = app()->make(LiveRoomServices::class);
|
||||
$liveRoom->syncRoomStatus();
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动收货
|
||||
*/
|
||||
public function autoTakeOrder()
|
||||
{
|
||||
/** @var StoreOrderTakeServices $services */
|
||||
$services = app()->make(StoreOrderTakeServices::class);
|
||||
$services->autoTakeOrder();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询预售到期商品自动下架
|
||||
*/
|
||||
public function downAdvance()
|
||||
{
|
||||
/** @var StoreProductServices $product */
|
||||
$product = app()->make(StoreProductServices::class);
|
||||
$product->downAdvance();
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动好评
|
||||
*/
|
||||
public function autoComment()
|
||||
{
|
||||
/** @var StoreOrderServices $orderServices */
|
||||
$orderServices = app()->make(StoreOrderServices::class);
|
||||
$orderServices->autoComment();
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除昨日海报
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function emptyYesterdayAttachment()
|
||||
{
|
||||
/** @var SystemAttachmentServices $attach */
|
||||
$attach = app()->make(SystemAttachmentServices::class);
|
||||
$attach->emptyYesterdayAttachment();
|
||||
}
|
||||
}
|
||||
@ -39,7 +39,8 @@ class StoreSeckillController
|
||||
//秒杀时间段
|
||||
$seckillTime = GroupDataService::getData('routine_seckill_time') ?? [];
|
||||
$seckillTimeIndex = -1;
|
||||
$timeCount = count($seckillTime);
|
||||
$timeCount = count($seckillTime);//总数
|
||||
$unTimeCunt = 0;//即将开始
|
||||
if ($timeCount) {
|
||||
$today = strtotime(date('Y-m-d'));
|
||||
$currentHour = date('H');
|
||||
@ -62,6 +63,7 @@ class StoreSeckillController
|
||||
$value['state'] = '即将开始';
|
||||
$value['status'] = 2;
|
||||
$value['stop'] = (int)bcadd($today, bcmul($activityEndHour, 3600, 0));
|
||||
$unTimeCunt += 1;
|
||||
} else if ($currentHour >= $activityEndHour) {
|
||||
$value['time'] = strlen((int)$value['time']) == 2 ? (int)$value['time'] . ':00' : '0' . (int)$value['time'] . ':00';
|
||||
$value['state'] = '已结束';
|
||||
@ -71,9 +73,16 @@ class StoreSeckillController
|
||||
}
|
||||
}
|
||||
//有时间段但是都不在抢购中
|
||||
if ($seckillTimeIndex == -1) {
|
||||
if ($currentHour < (int)$seckillTime[0]['time'] ?? 0) {
|
||||
if ($seckillTimeIndex == -1 && $currentHour <= (int)$seckillTime[$timeCount - 1]['time'] ?? 0) {
|
||||
if ($currentHour < (int)$seckillTime[0]['time'] ?? 0) {//当前时间
|
||||
$seckillTimeIndex = 0;
|
||||
} elseif ($unTimeCunt) {//存在未开始的
|
||||
foreach ($seckillTime as $key => $item) {
|
||||
if ($item['status'] == 2) {
|
||||
$seckillTimeIndex = $key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$seckillTimeIndex = $timeCount - 1;
|
||||
}
|
||||
@ -123,11 +132,11 @@ class StoreSeckillController
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function code(Request $request, $id, $stop_time = '')
|
||||
public function code(Request $request, $id)
|
||||
{
|
||||
/** @var QrcodeServices $qrcodeService */
|
||||
$qrcodeService = app()->make(QrcodeServices::class);
|
||||
$url = $qrcodeService->getRoutineQrcodePath($id, $request->uid(), 2, compact('stop_time'));
|
||||
$url = $qrcodeService->getRoutineQrcodePath($id, $request->uid(), 2);
|
||||
if ($url) {
|
||||
return app('json')->success(['code' => $url]);
|
||||
} else {
|
||||
|
||||
@ -130,6 +130,7 @@ class StoreOrderController
|
||||
if (!$order) return app('json')->fail(410173);
|
||||
if ($order['paid']) {
|
||||
$order['nickname'] = $userServices->value(['uid' => $order['uid']], 'nickname');
|
||||
$order['config_export_open'] = (bool)((int)sys_config('config_export_open'));
|
||||
$order = $order->hidden(['uid', 'status', 'paid'])->toArray();
|
||||
return app('json')->success($order);
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ use app\services\pay\YuePayServices;
|
||||
use app\services\user\member\MemberCardServices;
|
||||
use app\services\user\UserServices;
|
||||
use crmeb\services\CacheService;
|
||||
use crmeb\services\SystemConfigService;
|
||||
use crmeb\services\pay\extend\allinpay\AllinPay;
|
||||
use app\Request;
|
||||
|
||||
/**
|
||||
@ -115,6 +115,8 @@ class OtherOrderController
|
||||
|
||||
$info = compact('order_id');
|
||||
|
||||
$payType = get_pay_type($payType);
|
||||
|
||||
if ($order_id) {
|
||||
switch ($payType) {
|
||||
case PayServices::WEIXIN_PAY:
|
||||
@ -168,10 +170,20 @@ class OtherOrderController
|
||||
$payKey = md5($orderInfo['order_id']);
|
||||
CacheService::set($payKey, ['order_id' => $orderInfo['order_id'], 'other_pay_type' => true], 300);
|
||||
$info['pay_key'] = $payKey;
|
||||
return app('json')->status(PayServices::ALIAPY_PAY . '_pay', 410196, $info);
|
||||
return app('json')->status(PayServices::ALIAPY_PAY . '_pay', 410196, $info);
|
||||
}
|
||||
case PayServices::OFFLINE_PAY:
|
||||
return app('json')->status('success', 410196, $info);
|
||||
case PayServices::ALLIN_PAY:
|
||||
/** @var OrderPayServices $payServices */
|
||||
$payServices = app()->make(OrderPayServices::class);
|
||||
$info['jsConfig'] = $payServices->orderPay($orderInfo, $payType, [
|
||||
'returl' => sys_config('site_url') . '/pages/index/index',
|
||||
]);
|
||||
if ($request->isWechat()) {
|
||||
$info['pay_url'] = AllinPay::UNITODER_H5UNIONPAY;
|
||||
}
|
||||
return app('json')->status(PayServices::ALLIN_PAY . '_pay', 410196, $info);
|
||||
}
|
||||
} else return app('json')->fail(410200);
|
||||
}
|
||||
@ -182,9 +194,8 @@ class OtherOrderController
|
||||
*/
|
||||
public function pay_type(Request $request)
|
||||
{
|
||||
/** @var SystemConfigService $systemConfigService */
|
||||
$systemConfigService = app()->make(SystemConfigService::class);
|
||||
$payType = $systemConfigService->more(['ali_pay_status', 'pay_weixin_open']);
|
||||
$payType['ali_pay_status'] = is_ali_pay();
|
||||
$payType['pay_weixin_open'] = is_wecaht_pay();
|
||||
$payType['site_name'] = sys_config('site_name');
|
||||
$payType['now_money'] = $request->user('now_money');
|
||||
$payType['offline_pay_status'] = true;
|
||||
|
||||
@ -15,6 +15,7 @@ use app\services\pay\PayServices;
|
||||
use app\services\shipping\ExpressServices;
|
||||
use app\services\system\admin\SystemAdminServices;
|
||||
use app\services\user\UserInvoiceServices;
|
||||
use crmeb\services\pay\extend\allinpay\AllinPay;
|
||||
use app\services\activity\{lottery\LuckLotteryServices,
|
||||
bargain\StoreBargainServices,
|
||||
combination\StoreCombinationServices,
|
||||
@ -213,7 +214,7 @@ class StoreOrderController
|
||||
}
|
||||
}
|
||||
if ($from != 'pc') {
|
||||
if (!$this->services->checkPaytype($payType)) {
|
||||
if (!$this->services->checkPaytype(get_pay_type($payType))) {
|
||||
return app('json')->fail(410213);
|
||||
}
|
||||
} else {
|
||||
@ -342,6 +343,16 @@ class StoreOrderController
|
||||
case 'pc':
|
||||
case 'friend':
|
||||
return app('json')->status('success', 410203, $info);
|
||||
case PayServices::ALLIN_PAY:
|
||||
/** @var OrderPayServices $payServices */
|
||||
$payServices = app()->make(OrderPayServices::class);
|
||||
$info['jsConfig'] = $payServices->orderPay($orderInfo, $payType, [
|
||||
'returl' => sys_config('site_url') . '/pages/index/index',
|
||||
]);
|
||||
if ($request->isWechat()) {
|
||||
$info['pay_url'] = AllinPay::UNITODER_H5UNIONPAY;
|
||||
}
|
||||
return app('json')->status(PayServices::ALLIN_PAY . '_pay', 410203, $info);
|
||||
}
|
||||
} else return app('json')->fail(410200);
|
||||
}
|
||||
@ -408,8 +419,7 @@ class StoreOrderController
|
||||
break;
|
||||
case 'routine':
|
||||
if ($type == 1 || in_array($order['is_channel'], [0, 2, 3, 4])) {
|
||||
$order['order_id'] = app()->make(StoreOrderCreateServices::class)->getNewOrderId('cp');
|
||||
$this->services->update($order['id'], ['order_id' => $order['order_id']], 'id');
|
||||
$order['order_id'] = mt_rand(100, 999) . '_' . $order['order_id'];
|
||||
}
|
||||
break;
|
||||
case 'app':
|
||||
@ -423,7 +433,7 @@ class StoreOrderController
|
||||
break;
|
||||
}
|
||||
}
|
||||
$order['pay_type'] = $paytype; //重新支付选择支付方式
|
||||
$order['pay_type'] = get_pay_type($paytype); //重新支付选择支付方式
|
||||
switch ($order['pay_type']) {
|
||||
case PayServices::WEIXIN_PAY:
|
||||
$jsConfig = $payServices->orderPay($order->toArray(), $from);
|
||||
@ -460,6 +470,16 @@ class StoreOrderController
|
||||
return app('json')->status('success', 410203);
|
||||
else
|
||||
return app('json')->status('success', 410216);
|
||||
case PayServices::ALLIN_PAY:
|
||||
/** @var OrderPayServices $payServices */
|
||||
$payServices = app()->make(OrderPayServices::class);
|
||||
$info['jsConfig'] = $payServices->orderPay($order->toArray(), $order['pay_type'], [
|
||||
'returl' => sys_config('site_url') . '/pages/index/index',
|
||||
]);
|
||||
if ($request->isWechat()) {
|
||||
$info['pay_url'] = AllinPay::UNITODER_H5UNIONPAY;
|
||||
}
|
||||
return app('json')->status(PayServices::ALLIN_PAY . '_pay', 410203, $info);
|
||||
}
|
||||
return app('json')->fail(410218);
|
||||
}
|
||||
@ -501,7 +521,7 @@ class StoreOrderController
|
||||
$where['is_system_del'] = 0;
|
||||
if (in_array($where['status'], [-1, -2, -3])) {
|
||||
$where['not_pid'] = 1;
|
||||
} elseif (in_array($where['status'], [0, 1, 2, 3, 4])) {
|
||||
} elseif (in_array($where['status'], [0, 1, 2, 3, 4, 9])) {
|
||||
$where['pid'] = 0;
|
||||
}
|
||||
$list = $this->services->getOrderApiList($where);
|
||||
@ -778,7 +798,7 @@ class StoreOrderController
|
||||
*/
|
||||
public function data(Request $request)
|
||||
{
|
||||
return app('json')->success($this->services->getOrderData((int)$request->uid(), true));
|
||||
return app('json')->success($this->services->getOrderData((int)$request->uid()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -33,7 +33,7 @@ class ArticleCategoryController
|
||||
*/
|
||||
public function lst()
|
||||
{
|
||||
$cateInfo = CacheService::get('ARTICLE_CATEGORY', function () {
|
||||
$cateInfo = CacheService::remember('ARTICLE_CATEGORY', function () {
|
||||
$cateInfo = $this->services->getArticleCategory();
|
||||
array_unshift($cateInfo, ['id' => 0, 'title' => '热门']);
|
||||
return $cateInfo;
|
||||
|
||||
@ -38,4 +38,15 @@ class CategoryController
|
||||
$category = $this->services->getCategory($where);
|
||||
return app('json')->success($category);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2022/11/11
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCategoryVersion()
|
||||
{
|
||||
return app('json')->success(['version' => $this->services->getCategoryVersion()]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ class StoreCouponsController
|
||||
|
||||
/** @var StoreCouponIssueServices $couponIssueService */
|
||||
$couponIssueService = app()->make(StoreCouponIssueServices::class);
|
||||
$couponIssueService->issueUserCoupon($couponId, $request->user());
|
||||
$couponIssueService->issueUserCoupon($couponId, $request->user(), true);
|
||||
return app('json')->success(410319);
|
||||
}
|
||||
|
||||
|
||||
@ -55,7 +55,8 @@ class StoreProductController
|
||||
[['type', 0], 0],
|
||||
['ids', ''],
|
||||
['selectId', ''],
|
||||
['productId', '']
|
||||
['productId', ''],
|
||||
['coupon_category_id', '']
|
||||
]);
|
||||
if ($where['selectId'] && (!$where['sid'] || !$where['cid'])) {
|
||||
if ($services->value(['id' => $where['selectId']], 'pid')) {
|
||||
|
||||
@ -388,7 +388,11 @@ class UserBillController
|
||||
|
||||
/**
|
||||
* 获取海报详细信息
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getSpreadInfo(Request $request)
|
||||
{
|
||||
@ -402,8 +406,18 @@ class UserBillController
|
||||
$routineSpreadBanner[] = ['pic' => $item];
|
||||
}
|
||||
}
|
||||
|
||||
if (sys_config('share_qrcode', 0) && request()->isWechat()) {
|
||||
/** @var QrcodeServices $qrcodeService */
|
||||
$qrcodeService = app()->make(QrcodeServices::class);
|
||||
$qrcode = $qrcodeService->getTemporaryQrcode('spread', $request->uid())->url;
|
||||
} else {
|
||||
$qrcode = '';
|
||||
}
|
||||
|
||||
return app('json')->success([
|
||||
'spread' => $routineSpreadBanner,
|
||||
'qrcode' => $qrcode,
|
||||
'nickname' => $request->user('nickname'),
|
||||
'site_name' => sys_config('site_name')
|
||||
]);
|
||||
@ -413,6 +427,9 @@ class UserBillController
|
||||
* 积分记录
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function integral_list(Request $request)
|
||||
{
|
||||
|
||||
@ -93,9 +93,9 @@ class UserController
|
||||
}
|
||||
$uid = (int)$request->uid();
|
||||
if ($this->services->eidtNickname($uid, ['avatar' => $avatar, 'nickname' => $nickname])) {
|
||||
return app('json')->success(100001);
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
return app('json')->fail(100007);
|
||||
return app('json')->fail(100015);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -74,6 +74,21 @@ class PublicController
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return mixed
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/2/8
|
||||
*/
|
||||
public function getVersion($id = 0)
|
||||
{
|
||||
/** @var DiyServices $diyService */
|
||||
$diyService = app()->make(DiyServices::class);
|
||||
$version = $diyService->getDiyVersion((int)$id);
|
||||
return app('json')->success(['version' => $version ?: '']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否强制绑定手机号
|
||||
* @return mixed
|
||||
|
||||
@ -75,10 +75,10 @@ class LuckLotteryController
|
||||
|
||||
$uid = (int)$request->uid();
|
||||
$key = 'lucklotter_limit_' . $uid;
|
||||
if (CacheService::redisHandler()->get($key)) {
|
||||
if (CacheService::get($key)) {
|
||||
return app('json')->fail('您求的频率太过频繁,请稍后请求!');
|
||||
}
|
||||
CacheService::redisHandler()->set('lucklotter_limit_' . $uid, $uid, 1);
|
||||
CacheService::set('lucklotter_limit_' . $uid, $uid, 1);
|
||||
|
||||
if ($type == 5 && request()->isWechat()) {
|
||||
/** @var WechatServices $wechat */
|
||||
|
||||
@ -35,13 +35,57 @@ class AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序授权登录
|
||||
* @param Request $request
|
||||
* 静默授权
|
||||
* @param $code
|
||||
* @param string $spread_code
|
||||
* @param string $spread_spid
|
||||
* @return mixed
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function silenceAuth($code, $spread_code = '', $spread_spid = '')
|
||||
{
|
||||
$token = $this->services->silenceAuth($code, $spread_code, $spread_spid);
|
||||
if ($token && isset($token['key'])) {
|
||||
return app('json')->success(410022, $token);
|
||||
} else if ($token) {
|
||||
return app('json')->success(410001, ['token' => $token['token'], 'expires_time' => $token['params']['exp'], 'new_user' => $token['new_user']]);
|
||||
} else
|
||||
return app('json')->fail(410019);
|
||||
}
|
||||
|
||||
/**
|
||||
* 授权获取小程序用户手机号 直接绑定
|
||||
* @param string $code
|
||||
* @param string $iv
|
||||
* @param string $encryptedData
|
||||
* @param string $spread_code
|
||||
* @param string $spread_spid
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function authBindingPhone($code = '', $iv = '', $encryptedData = '', $spread_code = '', $spread_spid = '', $key = '')
|
||||
{
|
||||
if (!$code || !$iv || !$encryptedData)
|
||||
return app('json')->fail(100100);
|
||||
$token = $this->services->authBindingPhone($code, $iv, $encryptedData, $spread_code, $spread_spid, $key);
|
||||
if ($token) {
|
||||
return app('json')->success(410001, $token);
|
||||
} else
|
||||
return app('json')->fail(410019);
|
||||
}
|
||||
|
||||
/** 以下方法该版本暂未使用 */
|
||||
/**
|
||||
* 小程序授权登录
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function auth(Request $request)
|
||||
{
|
||||
@ -63,30 +107,13 @@ class AuthController
|
||||
return app('json')->fail(410019);
|
||||
}
|
||||
|
||||
/**
|
||||
* 静默授权
|
||||
* @param $code
|
||||
* @param string $spread_code
|
||||
* @param string $spread_spid
|
||||
* @return mixed
|
||||
*/
|
||||
public function silenceAuth($code, $spread_code = '', $spread_spid = '')
|
||||
{
|
||||
$token = $this->services->silenceAuth($code, $spread_code, $spread_spid);
|
||||
if ($token && isset($token['key'])) {
|
||||
return app('json')->success(410022, $token);
|
||||
} else if ($token) {
|
||||
return app('json')->success(410001, ['token' => $token['token'], 'expires_time' => $token['params']['exp']]);
|
||||
} else
|
||||
return app('json')->fail(410019);
|
||||
}
|
||||
|
||||
/**
|
||||
* 静默授权 不登录
|
||||
* @param $code
|
||||
* @param string $spread_code
|
||||
* @param string $spread_spid
|
||||
* @return mixed
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
*/
|
||||
public function silenceAuthNoLogin($code, $spread_code = '', $spread_spid = '')
|
||||
{
|
||||
@ -107,7 +134,8 @@ class AuthController
|
||||
* @param string $phone
|
||||
* @param string $captcha
|
||||
* @return mixed
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function silenceAuthBindingPhone($code = '', $spread_code = '', $spread_spid = '', $phone = '', $captcha = '')
|
||||
{
|
||||
@ -123,37 +151,19 @@ class AuthController
|
||||
CacheService::delete('code_' . $phone);
|
||||
$token = $this->services->silenceAuthBindingPhone($code, $spread_code, $spread_spid, $phone);
|
||||
if ($token) {
|
||||
return app('json')->success(410001, ['token' => $token['token'], 'expires_time' => $token['params']['exp']]);
|
||||
return app('json')->success(410001, ['token' => $token['token'], 'expires_time' => $token['params']['exp'], 'new_user' => $token['new_user']]);
|
||||
} else
|
||||
return app('json')->fail(410019);
|
||||
}
|
||||
|
||||
/**
|
||||
* 授权获取小程序用户手机号 直接绑定
|
||||
* @param string $code
|
||||
* @param string $iv
|
||||
* @param string $encryptedData
|
||||
* @param string $spread_code
|
||||
* @param string $spread_spid
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function authBindingPhone($code = '', $iv = '', $encryptedData ='', $spread_code ='', $spread_spid = '', $key = '')
|
||||
{
|
||||
if (!$code || !$iv || !$encryptedData)
|
||||
return app('json')->fail(100100);
|
||||
$token = $this->services->authBindingPhone($code, $iv, $encryptedData, $spread_code, $spread_spid, $key);
|
||||
if ($token) {
|
||||
return app('json')->success(410001, $token);
|
||||
} else
|
||||
return app('json')->fail(410019);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户信息
|
||||
* 更新用户信息
|
||||
* @param Request $request
|
||||
* @param $userInfo
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function updateInfo(Request $request, $userInfo)
|
||||
{
|
||||
|
||||
70
crmeb/app/api/middleware/BlockerMiddleware.php
Normal file
70
crmeb/app/api/middleware/BlockerMiddleware.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\api\middleware;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use crmeb\exceptions\ApiException;
|
||||
use crmeb\interfaces\MiddlewareInterface;
|
||||
use crmeb\services\CacheService;
|
||||
use think\facade\Config;
|
||||
|
||||
/**
|
||||
* Redis锁
|
||||
* Class BlockerMiddleware
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/2/8
|
||||
* @package app\api\middleware
|
||||
*/
|
||||
class BlockerMiddleware implements MiddlewareInterface
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param \Closure $next
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2022/11/21
|
||||
*/
|
||||
public function handle(Request $request, \Closure $next)
|
||||
{
|
||||
if (Config::get('cache.default') == 'file') {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
$uid = $request->uid();
|
||||
$key = md5($request->rule()->getRule() . $uid);
|
||||
if (!CacheService::setMutex($key)) {
|
||||
throw new ApiException('请求太过频繁,请稍后再试');
|
||||
}
|
||||
|
||||
$response = $next($request);
|
||||
|
||||
$this->after($response, $key);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $response
|
||||
* @param $key
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2022/11/22
|
||||
*/
|
||||
public function after($response, $key)
|
||||
{
|
||||
CacheService::delMutex($key);
|
||||
}
|
||||
}
|
||||
@ -28,7 +28,7 @@ Route::group('pc', function () {
|
||||
Route::get('get_banner', 'pc.HomeController/getBanner')->name('getBanner');//PC首页轮播图
|
||||
Route::get('get_category_product', 'pc.HomeController/getCategoryProduct')->name('getCategoryProduct');//首页分类尚品
|
||||
Route::get('get_products', 'pc.ProductController/getProductList')->name('getProductList');//商品列表
|
||||
Route::get('get_product_code/:product_id', 'pc.ProductController/getProductRoutineCode')->name('getProductRoutineCode');//商品详情小程序二维码
|
||||
Route::get('get_product_code/:product_id/[:type]', 'pc.ProductController/getProductRoutineCode')->name('getProductRoutineCode');//商品详情小程序二维码
|
||||
Route::get('get_city/:pid', 'pc.PublicController/getCity')->name('getCity');//获取城市数据
|
||||
Route::get('check_order_status/:order_id/:end_time', 'pc.OrderController/checkOrderStatus')->name('checkOrderStatus');//轮询订单状态接口
|
||||
Route::get('get_company_info', 'pc.PublicController/getCompanyInfo')->name('getCompanyInfo');//获取公司信息
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
use app\api\middleware\BlockerMiddleware;
|
||||
use think\facade\Route;
|
||||
use think\facade\Config;
|
||||
use think\Response;
|
||||
@ -134,7 +135,7 @@ Route::group(function () {
|
||||
Route::get('sign/list', 'v1.user.UserSignController/sign_list')->name('signList');//签到列表
|
||||
Route::get('sign/month', 'v1.user.UserSignController/sign_month')->name('signIntegral');//签到列表(年月)
|
||||
Route::post('sign/user', 'v1.user.UserSignController/sign_user')->name('signUser');//签到用户信息
|
||||
Route::post('sign/integral', 'v1.user.UserSignController/sign_integral')->name('signIntegral');//签到
|
||||
Route::post('sign/integral', 'v1.user.UserSignController/sign_integral')->name('signIntegral')->middleware(BlockerMiddleware::class);//签到
|
||||
//优惠券类
|
||||
Route::post('coupon/receive', 'v1.store.StoreCouponsController/receive')->name('couponReceive'); //领取优惠券
|
||||
Route::post('coupon/receive/batch', 'v1.store.StoreCouponsController/receive_batch')->name('couponReceiveBatch'); //批量领取优惠券
|
||||
@ -151,14 +152,14 @@ Route::group(function () {
|
||||
Route::post('order/check_shipping', 'v1.order.StoreOrderController/checkShipping')->name('checkShipping'); //检测是否显示快递和自提标签
|
||||
Route::post('order/confirm', 'v1.order.StoreOrderController/confirm')->name('orderConfirm'); //订单确认
|
||||
Route::post('order/computed/:key', 'v1.order.StoreOrderController/computedOrder')->name('computedOrder'); //计算订单金额
|
||||
Route::post('order/create/:key', 'v1.order.StoreOrderController/create')->name('orderCreate'); //订单创建
|
||||
Route::post('order/create/:key', 'v1.order.StoreOrderController/create')->name('orderCreate')->middleware(BlockerMiddleware::class); //订单创建
|
||||
Route::get('order/data', 'v1.order.StoreOrderController/data')->name('orderData'); //订单统计数据
|
||||
Route::get('order/list', 'v1.order.StoreOrderController/lst')->name('orderList'); //订单列表
|
||||
Route::get('order/detail/:uni/[:cartId]', 'v1.order.StoreOrderController/detail')->name('orderDetail'); //订单详情
|
||||
Route::get('order/refund_detail/:uni/[:cartId]', 'v1.order.StoreOrderController/refund_detail')->name('refundDetail'); //退款订单详情
|
||||
Route::get('order/refund/reason', 'v1.order.StoreOrderController/refund_reason')->name('orderRefundReason'); //订单退款理由
|
||||
Route::post('order/refund/verify', 'v1.order.StoreOrderController/refund_verify')->name('orderRefundVerify'); //订单退款审核
|
||||
Route::post('order/take', 'v1.order.StoreOrderController/take')->name('orderTake'); //订单收货
|
||||
Route::get('order/refund/reason', 'v1.order.StoreOrderController/refund_reason')->name('orderRefundReason')->middleware(BlockerMiddleware::class); //订单退款理由
|
||||
Route::post('order/refund/verify', 'v1.order.StoreOrderController/refund_verify')->name('orderRefundVerify')->middleware(BlockerMiddleware::class); //订单退款审核
|
||||
Route::post('order/take', 'v1.order.StoreOrderController/take')->name('orderTake')->middleware(BlockerMiddleware::class); //订单收货
|
||||
Route::get('order/express/:uni/[:type]', 'v1.order.StoreOrderController/express')->name('orderExpress'); //订单查看物流
|
||||
Route::post('order/del', 'v1.order.StoreOrderController/del')->name('orderDel'); //订单删除
|
||||
Route::post('order/again', 'v1.order.StoreOrderController/again')->name('orderAgain'); //订单 再次下单
|
||||
@ -287,6 +288,7 @@ Route::group(function () {
|
||||
Route::get('search/keyword', 'v1.PublicController/search')->name('searchKeyword');//热门搜索关键字获取
|
||||
//商品分类类
|
||||
Route::get('category', 'v1.store.CategoryController/category')->name('category');
|
||||
Route::get('category_version', 'v1.store.CategoryController/getCategoryVersion')->name('getCategoryVersion');//商品分类类版本
|
||||
//商品类
|
||||
Route::post('image_base64', 'v1.PublicController/get_image_base64')->name('getImageBase64');// 获取图片base64
|
||||
Route::get('product/detail/:id/[:type]', 'v1.store.StoreProductController/detail')->name('detail');//商品详情
|
||||
@ -388,6 +390,30 @@ Route::group(function () {
|
||||
Route::get('get_lang_json', 'v1.PublicController/getLangJson')->name('getLangJson');
|
||||
//获取当前后台设置的默认语言类型
|
||||
Route::get('get_default_lang_type', 'v1.PublicController/getDefaultLangType')->name('getLangJson');
|
||||
|
||||
/** 定时任务接口 */
|
||||
//检测定时任务接口
|
||||
Route::get('timer/check', 'v1.TimerController/timerCheck')->name('timerCheck');
|
||||
//未支付自动取消订单
|
||||
Route::get('timer/order_cancel', 'v1.TimerController/orderUnpaidCancel')->name('orderUnpaidCancel');
|
||||
//拼团到期订单处理
|
||||
Route::get('timer/pink_expiration', 'v1.TimerController/pinkExpiration')->name('pinkExpiration');
|
||||
//自动解绑上级绑定
|
||||
Route::get('timer/agent_unbind', 'v1.TimerController/agentUnbind')->name('agentUnbind');
|
||||
//更新直播商品状态
|
||||
Route::get('timer/live_product_status', 'v1.TimerController/syncGoodStatus')->name('syncGoodStatus');
|
||||
//更新直播间状态
|
||||
Route::get('timer/live_room_status', 'v1.TimerController/syncRoomStatus')->name('syncRoomStatus');
|
||||
//自动收货
|
||||
Route::get('timer/take_delivery', 'v1.TimerController/autoTakeOrder')->name('autoTakeOrder');
|
||||
//查询预售到期商品自动下架
|
||||
Route::get('timer/advance_off', 'v1.TimerController/downAdvance')->name('downAdvance');
|
||||
//自动好评
|
||||
Route::get('timer/product_replay', 'v1.TimerController/autoComment')->name('autoComment');
|
||||
//清除昨日海报
|
||||
Route::get('timer/clear_poster', 'v1.TimerController/emptyYesterdayAttachment')->name('emptyYesterdayAttachment');
|
||||
|
||||
|
||||
})->middleware(\app\http\middleware\AllowOriginMiddleware::class)->middleware(\app\api\middleware\StationOpenMiddleware::class)->middleware(\app\api\middleware\AuthTokenMiddleware::class, false);
|
||||
|
||||
Route::miss(function () {
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
use app\api\middleware\BlockerMiddleware;
|
||||
use think\facade\Route;
|
||||
|
||||
/**
|
||||
@ -30,6 +31,7 @@ Route::group('v2', function () {
|
||||
Route::get('wechat/wx_silence_auth_login', 'v2.wechat.WechatController/silenceAuth');
|
||||
//DIY接口
|
||||
Route::get('diy/get_diy/[:name]', 'v2.PublicController/getDiy');
|
||||
Route::get('diy/get_version/[:name]', 'v2.PublicController/getVersion');
|
||||
//是否强制绑定手机号
|
||||
Route::get('bind_status', 'v2.PublicController/bindPhoneStatus');
|
||||
//小程序授权绑定手机号
|
||||
@ -79,9 +81,9 @@ Route::group('v2', function () {
|
||||
//抽奖活动详情
|
||||
Route::get('lottery/info/:factor', 'v2.activity.LuckLotteryController/lotteryInfo')->mame('lotteryInfo');
|
||||
//参与抽奖
|
||||
Route::post('lottery', 'v2.activity.LuckLotteryController/luckLottery')->mame('luckLottery');
|
||||
Route::post('lottery', 'v2.activity.LuckLotteryController/luckLottery')->mame('luckLottery')->middleware(BlockerMiddleware::class);
|
||||
//领取奖品
|
||||
Route::post('lottery/receive', 'v2.activity.LuckLotteryController/lotteryReceive')->mame('lotteryReceive');
|
||||
Route::post('lottery/receive', 'v2.activity.LuckLotteryController/lotteryReceive')->mame('lotteryReceive')->middleware(BlockerMiddleware::class);
|
||||
//抽奖记录
|
||||
Route::get('lottery/record', 'v2.activity.LuckLotteryController/lotteryRecord')->mame('lotteryRecord');
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
// 应用公共文件
|
||||
use app\services\pay\PayServices;
|
||||
use crmeb\services\CacheService;
|
||||
use crmeb\services\HttpService;
|
||||
use Fastknife\Service\ClickWordCaptchaService;
|
||||
@ -22,6 +23,87 @@ use app\services\system\lang\LangCodeServices;
|
||||
use app\services\system\lang\LangCountryServices;
|
||||
use think\facade\Config;
|
||||
|
||||
if (!function_exists('get_pay_type')) {
|
||||
|
||||
/**
|
||||
* @param string $payType
|
||||
* @return string
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/2/9
|
||||
*/
|
||||
function get_pay_type(string $payType)
|
||||
{
|
||||
$allinPay = (int)sys_config('allin_pay_status') == 1;
|
||||
|
||||
//微信支付没有开启,通联支付开启,用户访问端在小程序或者公众号的时候,使用通联微信H5支付
|
||||
if ($payType == PayServices::WEIXIN_PAY) {
|
||||
$wechat_pay_type = (int)sys_config('wechat_pay_type', 0);
|
||||
if ($wechat_pay_type == 1 && $allinPay && (request()->isRoutine() || request()->isWechat())) {
|
||||
$payType = PayServices::ALLIN_PAY;
|
||||
}
|
||||
}
|
||||
|
||||
//支付宝没有开启,通联支付开了,用户使用支付宝支付,并且在app端访问的时候,使用通联app支付宝支付
|
||||
if ($payType == PayServices::ALIAPY_PAY) {
|
||||
$alipay_pay_type = (int)sys_config('alipay_pay_type', 0);
|
||||
if ($alipay_pay_type == 1 && $allinPay && request()->isApp()) {
|
||||
$payType = PayServices::ALLIN_PAY;
|
||||
}
|
||||
}
|
||||
|
||||
return $payType;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('is_wechat_pay')) {
|
||||
/**
|
||||
* @return bool
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/2/8
|
||||
*/
|
||||
function is_wecaht_pay()
|
||||
{
|
||||
$wechat_pay_type = (int)sys_config('wechat_pay_type', 0);
|
||||
$wechatPay = (int)sys_config('pay_weixin_open') == 1;
|
||||
$allinPay = (int)sys_config('allin_pay_status') == 1;
|
||||
|
||||
if ($wechat_pay_type == 0 && $wechatPay) {
|
||||
return true;
|
||||
} elseif ($wechat_pay_type == 1 && $allinPay) {
|
||||
if ((request()->isRoutine() || request()->isWechat())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('is_ali_pay')) {
|
||||
/**
|
||||
* @return bool
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/2/8
|
||||
*/
|
||||
function is_ali_pay()
|
||||
{
|
||||
$alipay_pay_type = (int)sys_config('alipay_pay_type', 0);
|
||||
$aliPay = (int)sys_config('ali_pay_status') == 1;
|
||||
$allinPay = (int)sys_config('allin_pay_status') == 1;
|
||||
|
||||
if ($alipay_pay_type == 0 && $aliPay) {
|
||||
return true;
|
||||
} elseif ($alipay_pay_type == 1 && $allinPay) {
|
||||
if (request()->isApp()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('getWorkerManUrl')) {
|
||||
|
||||
/**
|
||||
@ -932,7 +1014,10 @@ if (!function_exists('getLang')) {
|
||||
//获取接口传入的语言类型
|
||||
if (!$range = $request->header('cb-lang')) {
|
||||
//没有传入则使用系统默认语言显示
|
||||
if (!$range = $langTypeServices->value(['is_default' => 1], 'file_name')) {
|
||||
$range = $langTypeServices->cacheDriver()->remember('range_name', function () use ($langTypeServices) {
|
||||
return $langTypeServices->value(['is_default' => 1], 'file_name');
|
||||
});
|
||||
if (!$range) {
|
||||
//系统没有设置默认语言的话,根据浏览器语言显示,如果浏览器语言在库中找不到,则使用简体中文
|
||||
if ($request->header('accept-language') !== null) {
|
||||
$range = explode(',', $request->header('accept-language'))[0];
|
||||
@ -943,10 +1028,12 @@ if (!function_exists('getLang')) {
|
||||
}
|
||||
|
||||
// 获取type_id
|
||||
$typeId = $langCountryServices->value(['code' => $range], 'type_id') ?: 1;
|
||||
$typeId = $langCountryServices->cacheDriver()->remember('type_id_' . $range, function () use ($langCountryServices, $range) {
|
||||
return $langCountryServices->value(['code' => $range], 'type_id') ?: 1;
|
||||
}, 3600);
|
||||
|
||||
// 获取类型
|
||||
$langData = CacheService::redisHandler()->remember('lang_type_data', function () use ($langTypeServices) {
|
||||
$langData = CacheService::remember('lang_type_data', function () use ($langTypeServices) {
|
||||
return $langTypeServices->getColumn(['status' => 1, 'is_del' => 0], 'file_name', 'id');
|
||||
}, 3600);
|
||||
|
||||
@ -954,7 +1041,7 @@ if (!function_exists('getLang')) {
|
||||
$langStr = 'lang_' . str_replace('-', '_', $langData[$typeId]);
|
||||
|
||||
//读取当前语言的语言包
|
||||
$lang = CacheService::redisHandler()->remember($langStr, function () use ($typeId, $range, $langCodeServices) {
|
||||
$lang = CacheService::remember($langStr, function () use ($typeId, $range, $langCodeServices) {
|
||||
return $langCodeServices->getColumn(['type_id' => $typeId, 'is_admin' => 1], 'lang_explain', 'code');
|
||||
}, 3600);
|
||||
//获取返回文字
|
||||
|
||||
@ -126,6 +126,17 @@ abstract class BaseDao
|
||||
return $this->getModel()->getPk();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/2/8
|
||||
*/
|
||||
public function getTableName()
|
||||
{
|
||||
return $this->getModel()->getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一条数据
|
||||
* @param $id
|
||||
|
||||
@ -74,7 +74,7 @@ class StoreCouponIssueDao extends BaseDao
|
||||
* 获取优惠券列表
|
||||
* @param int $uid 用户ID
|
||||
* @param int $type 0通用,1分类,2商品
|
||||
* @param int $typeId 分类ID或商品ID
|
||||
* @param array|int $typeId 分类ID或商品ID
|
||||
* @param int $page
|
||||
* @param int $limit
|
||||
* @return array
|
||||
@ -101,7 +101,13 @@ class StoreCouponIssueDao extends BaseDao
|
||||
}])
|
||||
->where('type', $type)
|
||||
->when($type == 1, function ($query) use ($typeId) {
|
||||
if ($typeId) $query->where('category_id', 'in', $typeId);
|
||||
if ($typeId) {
|
||||
$query->where(function ($query) use ($typeId) {
|
||||
$query->where('id', 'in', function ($query) use ($typeId) {
|
||||
$query->name('store_coupon_product')->whereIn('category_id', $typeId)->field(['coupon_id'])->select();
|
||||
})->whereOr('category_id', 'in', $typeId);
|
||||
});
|
||||
}
|
||||
})
|
||||
->when($type == 2, function ($query) use ($typeId) {
|
||||
if ($typeId) $query->whereFindinSet('product_id', $typeId);
|
||||
@ -138,7 +144,9 @@ class StoreCouponIssueDao extends BaseDao
|
||||
$query->where('uid', $uid);
|
||||
}])->where(function ($query) use ($product_id, $cate_ids) {
|
||||
if ($product_id != 0 && $cate_ids != []) {
|
||||
$query->whereFindinSet('product_id', $product_id)->whereOr('category_id', 'in', $cate_ids)->whereOr('type', 0);
|
||||
$query->whereFindinSet('product_id', $product_id)->whereOr('id', 'in', function ($query) use ($cate_ids) {
|
||||
$query->name('store_coupon_product')->whereIn('category_id', $cate_ids)->field(['coupon_id'])->select();
|
||||
})->whereOr('category_id', 'in', $cate_ids)->whereOr('type', 0);
|
||||
}
|
||||
})->when($limit > 0, function ($query) use ($limit) {
|
||||
$query->limit($limit);
|
||||
@ -147,11 +155,11 @@ class StoreCouponIssueDao extends BaseDao
|
||||
|
||||
/**
|
||||
* 获取优惠券数量
|
||||
* @param int $productId
|
||||
* @param int $cateId
|
||||
* @param $productId
|
||||
* @param $cateId
|
||||
* @return mixed
|
||||
*/
|
||||
public function getIssueCouponCount($productId = 0, $cateId = 0)
|
||||
public function getIssueCouponCount($productId, $cateId)
|
||||
{
|
||||
$model = function ($query) {
|
||||
$query->where('status', 1)
|
||||
@ -168,12 +176,18 @@ class StoreCouponIssueDao extends BaseDao
|
||||
});
|
||||
};
|
||||
$count[0] = $this->getModel()->where($model)->where('type', 0)->count();
|
||||
$count[1] = $this->getModel()->where($model)->where('type', 1)->when($cateId != 0, function ($query) use ($cateId) {
|
||||
if ($cateId) $query->where('category_id', 'in', $cateId);
|
||||
})->count();
|
||||
$count[2] = $this->getModel()->where($model)->where('type', 2)->when($productId != 0, function ($query) use ($productId) {
|
||||
if ($productId) $query->whereFindinSet('product_id', $productId);
|
||||
})->count();
|
||||
$count[1] = $this->getModel()->where($model)->where('type', 1)
|
||||
->when(count($cateId) != 0, function ($query) use ($cateId) {
|
||||
$query->where(function ($query) use ($cateId) {
|
||||
$query->where('id', 'in', function ($query) use ($cateId) {
|
||||
$query->name('store_coupon_product')->whereIn('category_id', $cateId)->field(['coupon_id'])->select();
|
||||
})->whereOr('category_id', 'in', $cateId);
|
||||
});
|
||||
})->count();
|
||||
$count[2] = $this->getModel()->where($model)->where('type', 2)
|
||||
->when($productId != 0, function ($query) use ($productId) {
|
||||
if ($productId) $query->whereFindinSet('product_id', $productId);
|
||||
})->count();
|
||||
return $count;
|
||||
}
|
||||
|
||||
|
||||
@ -164,18 +164,24 @@ class StoreCategoryDao extends BaseDao
|
||||
|
||||
/**
|
||||
* 通过分类id 获取(自己以及下级)的所有分类
|
||||
* @param int $id
|
||||
* @param $id
|
||||
* @param string $field
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getAllById(int $id, string $field = 'id')
|
||||
public function getAllById($id, string $field = 'id')
|
||||
{
|
||||
return $this->getModel()->where(function ($query) use ($id) {
|
||||
$query->where('id', $id)->whereOr('pid', $id);
|
||||
})->where('is_show', 1)->field($field)->select()->toArray();
|
||||
if (is_array($id)) {
|
||||
return $this->getModel()->where(function ($query) use ($id) {
|
||||
$query->whereIn('id', $id)->whereOr('pid', 'in', $id);
|
||||
})->where('is_show', 1)->field($field)->select()->toArray();
|
||||
} else {
|
||||
return $this->getModel()->where(function ($query) use ($id) {
|
||||
$query->where('id', $id)->whereOr('pid', $id);
|
||||
})->where('is_show', 1)->field($field)->select()->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -124,6 +124,12 @@ class StoreProductDao extends BaseDao
|
||||
$query->name('store_category')->where('pid', $where['cid'])->field('id')->select();
|
||||
})->field('product_id')->select();
|
||||
});
|
||||
})->when(isset($where['coupon_category_id']) && $where['coupon_category_id'] != '', function ($query) use ($where) {
|
||||
$query->whereIn('id', function ($query) use ($where) {
|
||||
$query->name('store_product_cate')->whereIn('cate_id', function ($query) use ($where) {
|
||||
$query->name('store_category')->whereIn('pid', $where['coupon_category_id'])->field('id')->select();
|
||||
})->whereOr('cate_id', 'in', $where['coupon_category_id'])->field('product_id')->select();
|
||||
});
|
||||
})->when(isset($where['ids']) && $where['ids'], function ($query) use ($where) {
|
||||
if ((isset($where['priceOrder']) && $where['priceOrder'] != '') || (isset($where['salesOrder']) && $where['salesOrder'] != '')) {
|
||||
$query->whereIn('id', $where['ids']);
|
||||
|
||||
18
crmeb/app/dao/system/timer/SystemTimerDao.php
Normal file
18
crmeb/app/dao/system/timer/SystemTimerDao.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace app\dao\system\timer;
|
||||
|
||||
use app\dao\BaseDao;
|
||||
use app\model\system\timer\SystemTimer;
|
||||
|
||||
class SystemTimerDao extends BaseDao
|
||||
{
|
||||
/**
|
||||
* 设置模型
|
||||
* @return string
|
||||
*/
|
||||
protected function setModel(): string
|
||||
{
|
||||
return SystemTimer::class;
|
||||
}
|
||||
}
|
||||
@ -23,8 +23,7 @@ return [
|
||||
'LogLevel' => [],
|
||||
'LogWrite' => [],
|
||||
'queue.start' => [\app\listener\queue\QueueStart::class],
|
||||
'user.login' => [\app\listener\user\Login::class], //
|
||||
'admin.info' => [\app\listener\admin\AdminInfo::class],//管理员登录前获取登录信息事件
|
||||
'user.login' => [\app\listener\user\Login::class],
|
||||
'admin.login' => [\app\listener\admin\AdminLogin::class],//管理员登录
|
||||
'user.register' => [\app\listener\user\Register::class], //用户注册后置事件
|
||||
'wechat.auth' => [\app\listener\wechat\Auth::class], //用户授权后置事件
|
||||
@ -39,10 +38,8 @@ return [
|
||||
'user.userVisit' => [\app\listener\user\UserVisit::class], //用户访问事件
|
||||
'notice.notice' => [\app\listener\notice\Notice::class], //通知->消息事件
|
||||
'pay.notify' => [\app\listener\pay\Notify::class],//支付异步回调
|
||||
'SystemTimer' => [\app\listener\timer\SystemTimer::class],//定时任务事件
|
||||
],
|
||||
'subscribe' => [
|
||||
\app\subscribes\TaskSubscribe::class,//定时任务事件订阅类
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
|
||||
@ -26,8 +26,7 @@ class CheckQueueJob extends BaseJobs
|
||||
{
|
||||
use QueueTrait;
|
||||
|
||||
|
||||
public function handle($key)
|
||||
public function doJob($key)
|
||||
{
|
||||
$path = root_path('runtime') . '.queue';
|
||||
file_put_contents($path, $key);
|
||||
|
||||
@ -212,7 +212,7 @@ class OrderJob extends BaseJobs
|
||||
$description .= '砍价商品:' . $title;
|
||||
$image = $bargainServices->value(['id' => $order['bargain_id']], 'image');
|
||||
} else {
|
||||
$productIds = $cartInfoServices->getCartIdsProduct($order['cart_id']);
|
||||
$productIds = $cartInfoServices->getCartIdsProduct($order['id']);
|
||||
$storeProduct = $services->getProductArray([['id', 'in', $productIds]], 'image,store_name', 'id');
|
||||
if (count($storeProduct)) {
|
||||
foreach ($storeProduct as $value) {
|
||||
|
||||
@ -31,11 +31,11 @@ class OutPushJob extends BaseJobs
|
||||
/** @var OutStoreOrderServices $services */
|
||||
$services = app()->make(OutStoreOrderServices::class);
|
||||
if (!$services->orderCreatePush($oid, $pushUrl)) {
|
||||
OutPushJob::dispatchSece(($step + 1) * 5, 'orderCreate', [$oid, $pushUrl, $step + 1]);
|
||||
OutPushJob::dispatchSecs(($step + 1) * 5, 'orderCreate', [$oid, $pushUrl, $step + 1]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error('订单' . $oid . '推送失败,失败原因:' . $e->getMessage());
|
||||
OutPushJob::dispatchSece(($step + 1) * 5, 'orderCreate', [$oid, $pushUrl, $step + 1]);
|
||||
OutPushJob::dispatchSecs(($step + 1) * 5, 'orderCreate', [$oid, $pushUrl, $step + 1]);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -59,11 +59,11 @@ class OutPushJob extends BaseJobs
|
||||
/** @var OutStoreOrderServices $services */
|
||||
$services = app()->make(OutStoreOrderServices::class);
|
||||
if (!$services->paySuccessPush($oid, $pushUrl)) {
|
||||
OutPushJob::dispatchSece(($step + 1) * 5, 'paySuccess', [$oid, $pushUrl, $step + 1]);
|
||||
OutPushJob::dispatchSecs(($step + 1) * 5, 'paySuccess', [$oid, $pushUrl, $step + 1]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error('订单支付' . $oid . '推送失败,失败原因:' . $e->getMessage());
|
||||
OutPushJob::dispatchSece(($step + 1) * 5, 'paySuccess', [$oid, $pushUrl, $step + 1]);
|
||||
OutPushJob::dispatchSecs(($step + 1) * 5, 'paySuccess', [$oid, $pushUrl, $step + 1]);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -87,11 +87,11 @@ class OutPushJob extends BaseJobs
|
||||
/** @var OutStoreOrderRefundServices $services */
|
||||
$services = app()->make(OutStoreOrderRefundServices::class);
|
||||
if (!$services->refundCreatePush($oid, $pushUrl)) {
|
||||
OutPushJob::dispatchSece(($step + 1) * 5, 'refundCreate', [$oid, $pushUrl, $step + 1]);
|
||||
OutPushJob::dispatchSecs(($step + 1) * 5, 'refundCreate', [$oid, $pushUrl, $step + 1]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error('售后单' . $oid . '推送失败,失败原因:' . $e->getMessage());
|
||||
OutPushJob::dispatchSece(($step + 1) * 5, 'refundCreate', [$oid, $pushUrl, $step + 1]);
|
||||
OutPushJob::dispatchSecs(($step + 1) * 5, 'refundCreate', [$oid, $pushUrl, $step + 1]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -114,11 +114,11 @@ class OutPushJob extends BaseJobs
|
||||
/** @var OutStoreOrderRefundServices $services */
|
||||
$services = app()->make(OutStoreOrderRefundServices::class);
|
||||
if (!$services->cancelApplyPush($oid, $pushUrl)) {
|
||||
OutPushJob::dispatchSece(($step + 1) * 5, 'refundCancel', [$oid, $pushUrl, $step + 1]);
|
||||
OutPushJob::dispatchSecs(($step + 1) * 5, 'refundCancel', [$oid, $pushUrl, $step + 1]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error('取消售后单' . $oid . '推送失败,失败原因:' . $e->getMessage());
|
||||
OutPushJob::dispatchSece(($step + 1) * 5, 'refundCancel', [$oid, $pushUrl, $step + 1]);
|
||||
OutPushJob::dispatchSecs(($step + 1) * 5, 'refundCancel', [$oid, $pushUrl, $step + 1]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -141,10 +141,10 @@ class OutPushJob extends BaseJobs
|
||||
/** @var UserServices $services */
|
||||
$services = app()->make(UserServices::class);
|
||||
if (!$services->userUpdate($data, $pushUrl)) {
|
||||
OutPushJob::dispatchSece(($step + 1) * 5, 'userUpdate', [$data, $pushUrl, $step + 1]);
|
||||
OutPushJob::dispatchSecs(($step + 1) * 5, 'userUpdate', [$data, $pushUrl, $step + 1]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
OutPushJob::dispatchSece(($step + 1) * 5, 'userUpdate', [$data, $pushUrl, $step + 1]);
|
||||
OutPushJob::dispatchSecs(($step + 1) * 5, 'userUpdate', [$data, $pushUrl, $step + 1]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -47,21 +47,21 @@ class ProductCopyJob extends BaseJobs
|
||||
} else {
|
||||
$d_image = 'http://' . ltrim($image, '\//');
|
||||
}
|
||||
$description_cache = CacheService::getTokenBucket('desc_images_' . $id);
|
||||
$description_cache = CacheService::get('desc_images_' . $id);
|
||||
if ($description_cache === null) {
|
||||
$description_cache = $description;
|
||||
CacheService::setTokenBucket('desc_images_count' . $id, 0);
|
||||
CacheService::set('desc_images_count' . $id, 0);
|
||||
}
|
||||
$res = $copyTaobao->downloadCopyImage($d_image);
|
||||
$description_cache = str_replace($image, $res, $description_cache);
|
||||
$desc_count = CacheService::getTokenBucket('desc_images_count' . $id) + 1;
|
||||
$desc_count = CacheService::get('desc_images_count' . $id) + 1;
|
||||
if ($desc_count == $count) {
|
||||
CacheService::clearToken('desc_images_' . $id);
|
||||
CacheService::clearToken('desc_images_count' . $id);
|
||||
CacheService::delete('desc_images_' . $id);
|
||||
CacheService::delete('desc_images_count' . $id);
|
||||
$storeDescriptionServices->saveDescription((int)$id, $description_cache);
|
||||
} else {
|
||||
CacheService::setTokenBucket('desc_images_' . $id, $description_cache);
|
||||
CacheService::setTokenBucket('desc_images_count' . $id, $desc_count);
|
||||
CacheService::set('desc_images_' . $id, $description_cache);
|
||||
CacheService::set('desc_images_count' . $id, $desc_count);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('下载商品详情图片失败,失败原因:' . $e->getMessage());
|
||||
@ -86,20 +86,20 @@ class ProductCopyJob extends BaseJobs
|
||||
//下载图片
|
||||
$res = $copyTaobao->downloadCopyImage($image);
|
||||
//获取缓存中的轮播图
|
||||
$slider_images = CacheService::getTokenBucket('slider_images_' . $id);
|
||||
$slider_images = CacheService::get('slider_images_' . $id);
|
||||
//缓存为null则赋值[]
|
||||
if ($slider_images === null) $slider_images = [];
|
||||
//将下载的图片插入数组
|
||||
array_push($slider_images, $res);
|
||||
//如果$slider_images中图片数量和传入的$count相等,说明已经下载完成,写入商品表,如果不等则继续插入缓存
|
||||
if (count($slider_images) == $count) {
|
||||
CacheService::clearToken('slider_images_' . $id);
|
||||
CacheService::delete('slider_images_' . $id);
|
||||
$image = $slider_images[0];
|
||||
$slider_images = $slider_images ? json_encode($slider_images) : '';
|
||||
$StoreProductServices->update($id, ['slider_image' => $slider_images, 'image' => $image]);
|
||||
$StoreProductAttrValueServices->update(['product_id' => $id], ['image' => $image]);
|
||||
} else {
|
||||
CacheService::setTokenBucket('slider_images_' . $id, $slider_images);
|
||||
CacheService::set('slider_images_' . $id, $slider_images);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('下载商品轮播图片失败,失败原因:' . $e->getMessage());
|
||||
|
||||
@ -29,7 +29,7 @@ class ProductStockJob extends BaseJobs
|
||||
{
|
||||
try {
|
||||
foreach ($data as $key => $item) {
|
||||
ProductStockJob::dispatchDo('calcValueStock', [$key]);
|
||||
ProductStockJob::dispatch('calcValueStock', [$key]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error(['msg' => '拆分计算失败,错误原因:' . $e->getMessage(), 'data' => $data]);
|
||||
|
||||
@ -25,25 +25,16 @@ class TaskJob extends BaseJobs
|
||||
{
|
||||
use QueueTrait;
|
||||
|
||||
/**
|
||||
* 修改短信发送记录短信状态
|
||||
*/
|
||||
public function modifyResultCode()
|
||||
{
|
||||
/** @var SmsRecordServices $smsRecord */
|
||||
$smsRecord = app()->make(SmsRecordServices::class);
|
||||
return $smsRecord->modifyResultCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除昨日海报
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function emptyYesterdayAttachment()
|
||||
public function emptyYesterdayAttachment(): bool
|
||||
{
|
||||
/** @var SystemAttachmentServices $attach */
|
||||
$attach = app()->make(SystemAttachmentServices::class);
|
||||
return $attach->emptyYesterdayAttachment();
|
||||
$attach->emptyYesterdayAttachment();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ class TemplateJob extends BaseJobs
|
||||
//判断小程序还是公众号,获取数据id
|
||||
$is_type = $type == 'wechat' ? 'is_wechat' : 'is_routine';
|
||||
$key = $is_type == 'is_wechat' ? 'wechat_' . $tempCode : 'routine_' . $tempCode;
|
||||
$tempid = CacheService::get($key, function () use ($type, $tempCode, $is_type) {
|
||||
$tempid = CacheService::remember($key, function () use ($type, $tempCode, $is_type) {
|
||||
/** @var SystemNotificationServices $notifyServices */
|
||||
$notifyServices = app()->make(SystemNotificationServices::class);
|
||||
return $notifyServices->getNotInfo(['type' => $is_type, 'mark' => $tempCode])['tempid'];
|
||||
|
||||
@ -11,8 +11,8 @@
|
||||
|
||||
namespace app\jobs\notice;
|
||||
|
||||
use app\services\message\notice\EnterpriseWechatService;
|
||||
use crmeb\basic\BaseJobs;
|
||||
use crmeb\services\HttpService;
|
||||
use crmeb\traits\QueueTrait;
|
||||
use think\facade\Log;
|
||||
|
||||
@ -20,45 +20,20 @@ class EnterpriseWechatJob extends BaseJobs
|
||||
{
|
||||
use QueueTrait;
|
||||
|
||||
|
||||
/**
|
||||
* 给企业微信群发送消息
|
||||
* @param $data
|
||||
* @return bool
|
||||
*/
|
||||
public function doJob($data, $url, $ent_wechat_text)
|
||||
public function doJob($data): bool
|
||||
{
|
||||
try {
|
||||
$str = $ent_wechat_text;
|
||||
foreach ($data as $key => $item) {
|
||||
$str = str_replace('{' . $key . '}', $item, $str);
|
||||
}
|
||||
$s = explode('\n', $str);
|
||||
$d = '';
|
||||
foreach ($s as $item) {
|
||||
$d .= $item . "\n>";
|
||||
}
|
||||
$d = substr($d, 0, strlen($d) - 2);
|
||||
$datas = [
|
||||
'msgtype' => 'markdown',
|
||||
'markdown' => ['content' => $d]
|
||||
];
|
||||
HttpService::postRequest($url, json_encode($datas));
|
||||
/** @var EnterpriseWechatService $enterpriseWechatService */
|
||||
$enterpriseWechatService = app()->make(EnterpriseWechatService::class);
|
||||
$enterpriseWechatService->weComSend($data);
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
} catch (\Exception $e) {
|
||||
Log::error('发送企业群消息失败,失败原因:' . $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 给企业微信群发送消息
|
||||
*/
|
||||
public function ceshi($data,$url, $ent_wechat_text = '')
|
||||
{
|
||||
$wdata = [
|
||||
'msgtype' => 'markdown',
|
||||
'markdown' => ['content' => '你好啊,测试队列消息'.$url.$ent_wechat_text]
|
||||
];
|
||||
HttpService::postRequest('https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=4d92900f-dc4a-4b2b-8d37-5ce2784dd618', json_encode($wdata));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,13 +11,11 @@
|
||||
|
||||
namespace app\jobs\notice;
|
||||
|
||||
|
||||
use app\services\order\StoreOrderServices;
|
||||
use crmeb\basic\BaseJobs;
|
||||
use crmeb\services\printer\Printer;
|
||||
use crmeb\traits\QueueTrait;
|
||||
use think\facade\Log;
|
||||
|
||||
|
||||
/**
|
||||
* 小票打印
|
||||
* Class PrintJob
|
||||
@ -29,28 +27,18 @@ class PrintJob extends BaseJobs
|
||||
|
||||
/**
|
||||
* 小票打印
|
||||
* @param $type
|
||||
* @param $configData
|
||||
* @param $order
|
||||
* @param $product
|
||||
* @param $id
|
||||
* @return bool|void
|
||||
*/
|
||||
public function doJob($type, $configData, $order, $product)
|
||||
public function doJob($id)
|
||||
{
|
||||
|
||||
try {
|
||||
$printer = new Printer($type, $configData);
|
||||
$printer->setPrinterContent([
|
||||
'name' => sys_config('site_name'),
|
||||
'url' => sys_config('site_url'),
|
||||
'orderInfo' => is_object($order) ? $order->toArray() : $order,
|
||||
'product' => $product
|
||||
])->startPrinter();
|
||||
/** @var StoreOrderServices $orderServices */
|
||||
$orderServices = app()->make(StoreOrderServices::class);
|
||||
$orderServices->orderPrintTicket((int)$id);
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('小票打印失败失败,失败原因:' . $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ class SmsJob extends BaseJobs
|
||||
$smsServices->send(true, $phone, $data, $template);
|
||||
return true;
|
||||
}catch (\Throwable $e) {
|
||||
Log::error('发送企业群消息失败,失败原因:' . $e->getMessage());
|
||||
Log::error('发送短信失败,失败原因:' . $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -94,6 +94,7 @@ class SyncMessageJob extends BaseJobs
|
||||
/**
|
||||
* 同步公众号模版消息
|
||||
* @param $template
|
||||
* @return bool
|
||||
*/
|
||||
public function syncWechat($template)
|
||||
{
|
||||
|
||||
@ -84,9 +84,9 @@ class KefuApiExceptionHandle extends Handle
|
||||
'trace' => $e->getTrace(),
|
||||
'previous' => $e->getPrevious(),
|
||||
] : [];
|
||||
$message = Env::get('app_debug', false) ? '接口报错:' . $e->getMessage() : '很抱歉,系统开小差了';
|
||||
$message = Env::get('app_debug', false) ? $e->getMessage() : '很抱歉,系统开小差了';
|
||||
// 添加自定义异常处理机制
|
||||
if ($e instanceof AuthException || $e instanceof AdminException || $e instanceof ApiException) {
|
||||
if ($e instanceof AuthException || $e instanceof AdminException || $e instanceof ApiException || $e instanceof ValidateException) {
|
||||
return app('json')->make($e->getCode() ?: 400, $message, $massageData);
|
||||
} else {
|
||||
return app('json')->fail($message, $massageData);
|
||||
|
||||
@ -147,7 +147,7 @@ class User extends AuthController
|
||||
public function logout()
|
||||
{
|
||||
$key = trim(ltrim($this->request->header(Config::get('cookie.token_name')), 'Bearer'));
|
||||
CacheService::redisHandler()->delete(md5($key));
|
||||
CacheService::delete(md5($key));
|
||||
return app('json')->success();
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\listener\admin;
|
||||
|
||||
|
||||
use app\jobs\CheckQueueJob;
|
||||
use crmeb\interfaces\ListenerInterface;
|
||||
|
||||
/**
|
||||
* 登录前获取信息
|
||||
* Class AdminInfo
|
||||
* @package app\listener\admin
|
||||
*/
|
||||
class AdminInfo implements ListenerInterface
|
||||
{
|
||||
|
||||
public function handle($event): void
|
||||
{
|
||||
CheckQueueJob::dispatch($event);
|
||||
}
|
||||
}
|
||||
@ -11,6 +11,9 @@
|
||||
|
||||
namespace app\listener\notice;
|
||||
|
||||
use app\jobs\notice\EnterpriseWechatJob;
|
||||
use app\jobs\notice\PrintJob;
|
||||
use app\services\order\StoreOrderServices;
|
||||
use app\services\message\notice\{
|
||||
EnterpriseWechatService,
|
||||
RoutineTemplateListService,
|
||||
@ -18,7 +21,6 @@ use app\services\message\notice\{
|
||||
SystemMsgService,
|
||||
WechatTemplateListService
|
||||
};
|
||||
use app\services\message\NoticeService;
|
||||
use app\services\order\StoreOrderCartInfoServices;
|
||||
use app\services\user\UserServices;
|
||||
use crmeb\interfaces\ListenerInterface;
|
||||
@ -36,9 +38,6 @@ class Notice implements ListenerInterface
|
||||
try {
|
||||
[$data, $mark] = $event;
|
||||
|
||||
/** @var NoticeService $NoticeService */
|
||||
$NoticeService = app()->make(NoticeService::class);
|
||||
|
||||
/** @var WechatTemplateListService $WechatTemplateList */
|
||||
$WechatTemplateList = app()->make(WechatTemplateListService::class);
|
||||
|
||||
@ -51,7 +50,7 @@ class Notice implements ListenerInterface
|
||||
/** @var EnterpriseWechatService $EnterpriseWechat */
|
||||
$EnterpriseWechat = app()->make(EnterpriseWechatService::class);
|
||||
|
||||
/** @var SmsService $NoticeSms */
|
||||
/** @var SmsService $NoticeSms */
|
||||
$NoticeSms = app()->make(SmsService::class);
|
||||
|
||||
/** @var StoreOrderCartInfoServices $orderInfoServices */
|
||||
@ -93,7 +92,7 @@ class Notice implements ListenerInterface
|
||||
$RoutineTemplateList->sendOrderSuccess($data['uid'], $data['pay_price'], $data['order_id']);
|
||||
//小票打印
|
||||
if (isset($data['cart_id']) && $data['cart_id']) {
|
||||
$NoticeService->orderPrint($data);
|
||||
PrintJob::dispatch([$data['id']]);
|
||||
}
|
||||
break;
|
||||
//发货给用户
|
||||
@ -157,7 +156,7 @@ class Notice implements ListenerInterface
|
||||
case 'price_revision':
|
||||
$order = $data['order'];
|
||||
$pay_price = $data['pay_price'];
|
||||
$order['storeName'] = $orderInfoServices->getCarIdByProductTitle($order['id'], $order['cart_id']);
|
||||
$order['storeName'] = $orderInfoServices->getCarIdByProductTitle((int)$order['id']);
|
||||
//短信
|
||||
$NoticeSms->sendSms($order['user_phone'], ['order_id' => $order['order_id'], 'pay_price' => $pay_price]);
|
||||
//站内信
|
||||
@ -170,7 +169,7 @@ class Notice implements ListenerInterface
|
||||
$order = $data['order'];
|
||||
$order['refund_price'] = $datas['refund_price'];
|
||||
$order['refund_no'] = $datas['refund_no'];
|
||||
$storeName = $orderInfoServices->getCarIdByProductTitle($order['id'], $order['cart_id']);
|
||||
$storeName = $orderInfoServices->getCarIdByProductTitle((int)$order['id']);
|
||||
$storeTitle = Str::substrUTf8($storeName, 20, 'UTF-8', '');
|
||||
//站内信
|
||||
$SystemMsg->sendMsg($order['uid'], ['order_id' => $order['order_id'], 'pay_price' => $order['pay_price'], 'refund_price' => $datas['refund_price']]);
|
||||
@ -334,7 +333,7 @@ class Notice implements ListenerInterface
|
||||
case 'order_pay_false':
|
||||
$order = $data['order'];
|
||||
$order_id = $order['order_id'];
|
||||
$order['storeName'] = $orderInfoServices->getCarIdByProductTitle($order['id'], $order['cart_id']);
|
||||
$order['storeName'] = $orderInfoServices->getCarIdByProductTitle((int)$order['id']);
|
||||
//短信
|
||||
$NoticeSms->sendSms($order['user_phone'], compact('order_id'));
|
||||
//站内信
|
||||
@ -349,13 +348,13 @@ class Notice implements ListenerInterface
|
||||
//短信
|
||||
$NoticeSms->sendAdminPaySuccess($order);
|
||||
//公众号小程序
|
||||
$storeName = $orderInfoServices->getCarIdByProductTitle($order['id'], $order['cart_id']);
|
||||
$storeName = $orderInfoServices->getCarIdByProductTitle((int)$order['id']);
|
||||
$title = '亲,来新订单啦!';
|
||||
$status = '新订单';
|
||||
$link = '/pages/admin/orderDetail/index?id=' . $order['order_id'];
|
||||
$WechatTemplateList->sendAdminOrder($order['order_id'], $storeName, $title, $status, $link);
|
||||
//企业微信通知
|
||||
$EnterpriseWechat->sendMsg(['order_id' => $order['order_id']]);
|
||||
EnterpriseWechatJob::dispatch(['order_id' => $order['order_id']]);
|
||||
break;
|
||||
//确认收货给客服
|
||||
case 'send_admin_confirm_take_over':
|
||||
@ -366,13 +365,13 @@ class Notice implements ListenerInterface
|
||||
//短信
|
||||
$NoticeSms->sendAdminConfirmTakeOver($order);
|
||||
//公众号
|
||||
$storeName = $orderInfoServices->getCarIdByProductTitle($order['id'], $order['cart_id']);
|
||||
$storeName = $orderInfoServices->getCarIdByProductTitle((int)$order['id']);
|
||||
$title = '亲,用户已经收到货物啦!';
|
||||
$status = '订单收货';
|
||||
$link = '/pages/admin/orderDetail/index?id=' . $order['order_id'];
|
||||
$WechatTemplateList->sendAdminOrder($order['order_id'], $storeName, $title, $status, $link);
|
||||
//企业微信通知
|
||||
$EnterpriseWechat->sendMsg(['storeTitle' => $storeTitle, 'order_id' => $order['order_id']]);
|
||||
EnterpriseWechatJob::dispatch(['storeTitle' => $storeTitle, 'order_id' => $order['order_id']]);
|
||||
break;
|
||||
//申请退款给客服发消息
|
||||
case 'send_order_apply_refund':
|
||||
@ -382,9 +381,9 @@ class Notice implements ListenerInterface
|
||||
//短信
|
||||
$NoticeSms->sendAdminRefund($order);
|
||||
//企业微信通知
|
||||
$EnterpriseWechat->sendMsg(['order_id' => $order['order_id']]);
|
||||
EnterpriseWechatJob::dispatch(['order_id' => $order['order_id']]);
|
||||
//公众号
|
||||
$storeName = $orderInfoServices->getCarIdByProductTitle($order['id'], $order['cart_id']);
|
||||
$storeName = $orderInfoServices->getCarIdByProductTitle((int)$order['id']);
|
||||
$title = '亲,您有个退款订单待处理!';
|
||||
$status = '订单退款';
|
||||
$link = '/pages/admin/orderDetail/index?id=' . $order['refund_no'] . '&types=-3';
|
||||
@ -395,7 +394,7 @@ class Notice implements ListenerInterface
|
||||
//站内信
|
||||
$SystemMsg->kefuSystemSend($data);
|
||||
//企业微信通知
|
||||
$EnterpriseWechat->sendMsg($data);
|
||||
EnterpriseWechatJob::dispatch($data);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ class OrderCreateAfter implements ListenerInterface
|
||||
$orderCreate->orderCreateAfter($order, $group, $combinationId || $seckillId || $bargainId);
|
||||
|
||||
//清除订单缓存
|
||||
CacheService::redisHandler()->delete('user_order_' . $uid . $key);
|
||||
CacheService::delete('user_order_' . $uid . $key);
|
||||
|
||||
//写入订单记录表
|
||||
/** @var StoreOrderStatusServices $statusService */
|
||||
@ -81,8 +81,8 @@ class OrderCreateAfter implements ListenerInterface
|
||||
$secs = $systemValue['order_cancel_time'];
|
||||
}
|
||||
//未支付10分钟后发送短信
|
||||
UnpaidOrderSend::dispatchSece(600, [$orderId]);
|
||||
UnpaidOrderSend::dispatchSecs(600, [$orderId]);
|
||||
//未支付根据系统设置事件取消订单
|
||||
UnpaidOrderCancelJob::dispatchSece((int)($secs * 3600), [$orderId]);
|
||||
UnpaidOrderCancelJob::dispatchSecs((int)($secs * 3600), [$orderId]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ class OrderDelivery implements ListenerInterface
|
||||
$time = sys_config('system_delivery_time') ?? 0;
|
||||
if ($time != 0) {
|
||||
$sevenDay = 24 * 3600 * $time;
|
||||
TakeOrderJob::dispatchSece((int)$sevenDay, [$orderInfo->id]);
|
||||
TakeOrderJob::dispatchSecs((int)$sevenDay, [$orderInfo->id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,15 +21,15 @@ class OutPush implements ListenerInterface
|
||||
if ($item['push_open'] == 1) {
|
||||
$token = $this->getPushToken($item);
|
||||
if ($type == 'order_create_push') {
|
||||
OutPushJob::dispatchDo('orderCreate', [$data['order_id'], $item['order_create_push'] . '?pushToken=' . $token]);
|
||||
OutPushJob::dispatch('orderCreate', [$data['order_id'], $item['order_create_push'] . '?pushToken=' . $token]);
|
||||
} elseif ($type == 'order_pay_push') {
|
||||
OutPushJob::dispatchDo('paySuccess', [$data['order_id'], $item['order_pay_push'] . '?pushToken=' . $token]);
|
||||
OutPushJob::dispatch('paySuccess', [$data['order_id'], $item['order_pay_push'] . '?pushToken=' . $token]);
|
||||
} elseif ($type == 'refund_create_push') {
|
||||
OutPushJob::dispatchDo('refundCreate', [$data['order_id'], $item['refund_create_push'] . '?pushToken=' . $token]);
|
||||
OutPushJob::dispatch('refundCreate', [$data['order_id'], $item['refund_create_push'] . '?pushToken=' . $token]);
|
||||
} elseif ($type == 'refund_cancel_push') {
|
||||
OutPushJob::dispatchDo('refundCancel', [$data['order_id'], $item['refund_cancel_push'] . '?pushToken=' . $token]);
|
||||
OutPushJob::dispatch('refundCancel', [$data['order_id'], $item['refund_cancel_push'] . '?pushToken=' . $token]);
|
||||
} elseif ($type == 'user_update_push') {
|
||||
OutPushJob::dispatchDo('userUpdate', [$data, $item['user_update_push'] . '?pushToken=' . $token]);
|
||||
OutPushJob::dispatch('userUpdate', [$data, $item['user_update_push'] . '?pushToken=' . $token]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -42,7 +42,7 @@ class OutPush implements ListenerInterface
|
||||
*/
|
||||
public function getPushToken(array $info)
|
||||
{
|
||||
$token = CacheService::redisHandler()->get('pushToken' . $info['id']);
|
||||
$token = CacheService::get('pushToken' . $info['id']);
|
||||
if (!$token) {
|
||||
$param = json_encode(['push_account' => $info['push_account'], 'push_password' => $info['push_password']], JSON_UNESCAPED_UNICODE);
|
||||
$res = HttpService::postRequest($info['push_token_url'], $param, ['Content-Type:application/json', 'Content-Length:' . strlen($param)]);
|
||||
@ -51,7 +51,7 @@ class OutPush implements ListenerInterface
|
||||
Log::error(['msg' => $info['title'] . ',获取token失败']);
|
||||
return false;
|
||||
}
|
||||
CacheService::redisHandler()->set('pushToken' . $info['id'], $res['token'], $res['time']);
|
||||
CacheService::set('pushToken' . $info['id'], $res['token'], $res['time']);
|
||||
return $res['token'];
|
||||
} else {
|
||||
return $token;
|
||||
|
||||
192
crmeb/app/listener/timer/SystemTimer.php
Normal file
192
crmeb/app/listener/timer/SystemTimer.php
Normal file
@ -0,0 +1,192 @@
|
||||
<?php
|
||||
|
||||
namespace app\listener\timer;
|
||||
|
||||
use app\services\activity\combination\StorePinkServices;
|
||||
use app\services\activity\live\LiveGoodsServices;
|
||||
use app\services\activity\live\LiveRoomServices;
|
||||
use app\services\agent\AgentManageServices;
|
||||
use app\services\order\StoreOrderServices;
|
||||
use app\services\order\StoreOrderTakeServices;
|
||||
use app\services\product\product\StoreProductServices;
|
||||
use app\services\system\attachment\SystemAttachmentServices;
|
||||
use app\services\system\timer\SystemTimerServices;
|
||||
use crmeb\interfaces\ListenerInterface;
|
||||
use think\facade\Log;
|
||||
use Workerman\Crontab\Crontab;
|
||||
|
||||
class SystemTimer implements ListenerInterface
|
||||
{
|
||||
public function handle($event): void
|
||||
{
|
||||
|
||||
new Crontab('*/6 * * * * *', function () {
|
||||
file_put_contents(runtime_path() . '.timer', time());
|
||||
});
|
||||
|
||||
/** @var SystemTimerServices $systemTimerServices */
|
||||
$systemTimerServices = app()->make(SystemTimerServices::class);
|
||||
$list = $systemTimerServices->selectList(['is_del' => 0, 'is_open' => 1])->toArray();
|
||||
foreach ($list as &$item) {
|
||||
//获取定时任务时间字符串
|
||||
$timeStr = $this->getTimerStr($item);
|
||||
// Log::error('mark:'.$item['mark']);
|
||||
// Log::error($timeStr);
|
||||
|
||||
if ($item['mark'] == 'order_cancel') {
|
||||
new Crontab($timeStr, function () {
|
||||
// Log::error('每隔30秒执行一次自动取消订单 '.date('Y-m-d H:i:s'));
|
||||
//未支付自动取消订单
|
||||
try {
|
||||
/** @var StoreOrderServices $orderServices */
|
||||
$orderServices = app()->make(StoreOrderServices::class);
|
||||
$orderServices->orderUnpaidCancel();
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('自动取消订单失败,失败原因:' . $e->getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if ($item['mark'] == 'pink_expiration') {
|
||||
new Crontab($timeStr, function () {
|
||||
// Log::error('每隔1分钟执行一次拼团到期订单处理 '.date('Y-m-d H:i:s'));
|
||||
//拼团到期订单处理
|
||||
try {
|
||||
/** @var StorePinkServices $storePinkServices */
|
||||
$storePinkServices = app()->make(StorePinkServices::class);
|
||||
$storePinkServices->statusPink();
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('拼团到期订单处理失败,失败原因:' . $e->getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if ($item['mark'] == 'agent_unbind') {
|
||||
new Crontab($timeStr, function () {
|
||||
// Log::error('每隔1分钟执行一次自动解除上级绑定 '.date('Y-m-d H:i:s'));
|
||||
//自动解绑上级绑定
|
||||
try {
|
||||
/** @var AgentManageServices $agentManage */
|
||||
$agentManage = app()->make(AgentManageServices::class);
|
||||
$agentManage->removeSpread();
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('自动解除上级绑定失败,失败原因:' . $e->getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if ($item['mark'] == 'live_product_status') {
|
||||
new Crontab($timeStr, function () {
|
||||
// Log::error('每隔3分钟执行一次更新直播商品状态 '.date('Y-m-d H:i:s'));
|
||||
//更新直播商品状态
|
||||
try {
|
||||
/** @var LiveGoodsServices $liveGoods */
|
||||
$liveGoods = app()->make(LiveGoodsServices::class);
|
||||
$liveGoods->syncGoodStatus();
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('更新直播商品状态失败,失败原因:' . $e->getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if ($item['mark'] == 'live_room_status') {
|
||||
new Crontab($timeStr, function () {
|
||||
// Log::error('每隔3分钟执行一次更新直播间状态 '.date('Y-m-d H:i:s'));
|
||||
//更新直播间状态
|
||||
try {
|
||||
/** @var LiveRoomServices $liveRoom */
|
||||
$liveRoom = app()->make(LiveRoomServices::class);
|
||||
$liveRoom->syncRoomStatus();
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('更新直播间状态失败,失败原因:' . $e->getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if ($item['mark'] == 'take_delivery') {
|
||||
new Crontab($timeStr, function () {
|
||||
// Log::error('每隔5分钟执行一次自动收货 '.date('Y-m-d H:i:s'));
|
||||
//自动收货
|
||||
try {
|
||||
/** @var StoreOrderTakeServices $services */
|
||||
$services = app()->make(StoreOrderTakeServices::class);
|
||||
$services->autoTakeOrder();
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('自动收货失败,失败原因:' . $e->getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if ($item['mark'] == 'advance_off') {
|
||||
new Crontab($timeStr, function () {
|
||||
// Log::error('每隔5分钟执行一次查询预售到期商品自动下架 '.date('Y-m-d H:i:s'));
|
||||
//查询预售到期商品自动下架
|
||||
try {
|
||||
/** @var StoreProductServices $product */
|
||||
$product = app()->make(StoreProductServices::class);
|
||||
$product->downAdvance();
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('预售到期商品自动下架失败,失败原因:' . $e->getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if ($item['mark'] == 'product_replay') {
|
||||
new Crontab($timeStr, function () {
|
||||
// Log::error('每隔5分钟执行一次自动好评 '.date('Y-m-d H:i:s'));
|
||||
//自动好评
|
||||
try {
|
||||
/** @var StoreOrderServices $orderServices */
|
||||
$orderServices = app()->make(StoreOrderServices::class);
|
||||
$orderServices->autoComment();
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('自动好评失败,失败原因:' . $e->getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if ($item['mark'] == 'clear_poster') {
|
||||
new Crontab($timeStr, function () {
|
||||
// Log::error('每天0时30分0秒执行一次清除昨日海报 '.date('Y-m-d H:i:s'));
|
||||
//清除昨日海报
|
||||
try {
|
||||
/** @var SystemAttachmentServices $attach */
|
||||
$attach = app()->make(SystemAttachmentServices::class);
|
||||
$attach->emptyYesterdayAttachment();
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('清除昨日海报失败,失败原因:' . $e->getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getTimerStr($data): string
|
||||
{
|
||||
$timeStr = '';
|
||||
switch ($data['type']) {
|
||||
case 1:
|
||||
$timeStr = '*/' . $data['second'] . ' * * * * *';
|
||||
break;
|
||||
case 2:
|
||||
$timeStr = '0 */' . $data['minute'] . ' * * * *';
|
||||
break;
|
||||
case 3:
|
||||
$timeStr = '0 0 */' . $data['hour'] . ' * * *';
|
||||
break;
|
||||
case 4:
|
||||
$timeStr = '0 0 0 */' . $data['day'] . ' * *';
|
||||
break;
|
||||
case 5:
|
||||
$timeStr = $data['second'] . ' ' . $data['minute'] . ' ' . $data['hour'] . ' * * *';
|
||||
break;
|
||||
case 6:
|
||||
$timeStr = $data['second'] . ' ' . $data['minute'] . ' ' . $data['hour'] . ' * * ' . ($data['week'] == 7 ? 0 : $data['week']);
|
||||
break;
|
||||
case 7:
|
||||
$timeStr = $data['second'] . ' ' . $data['minute'] . ' ' . $data['hour'] . ' ' . $data['day'] . ' * *';
|
||||
break;
|
||||
}
|
||||
return $timeStr;
|
||||
}
|
||||
}
|
||||
@ -42,7 +42,7 @@ class StoreCouponIssue extends BaseModel
|
||||
*/
|
||||
public function used()
|
||||
{
|
||||
return $this->hasOne(StoreCouponIssueUser::class, 'issue_coupon_id', 'id')->field('issue_coupon_id');
|
||||
return $this->hasMany(StoreCouponIssueUser::class, 'issue_coupon_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -67,7 +67,7 @@ class SystemMenus extends BaseModel
|
||||
* @param $value
|
||||
* @return mixed|string
|
||||
*/
|
||||
public function getPidAttr($value)
|
||||
public function getPidStrAttr($value)
|
||||
{
|
||||
return !$value ? '顶级' : $this->where('pid', $value)->value('menu_name');
|
||||
}
|
||||
|
||||
23
crmeb/app/model/system/timer/SystemTimer.php
Normal file
23
crmeb/app/model/system/timer/SystemTimer.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace app\model\system\timer;
|
||||
|
||||
use crmeb\basic\BaseModel;
|
||||
use crmeb\traits\ModelTrait;
|
||||
|
||||
class SystemTimer extends BaseModel
|
||||
{
|
||||
use ModelTrait;
|
||||
|
||||
/**
|
||||
* 数据表主键
|
||||
* @var string
|
||||
*/
|
||||
protected $pk = 'id';
|
||||
|
||||
/**
|
||||
* 模型名称
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'system_timer';
|
||||
}
|
||||
@ -84,9 +84,9 @@ class OutApiExceptionHandle extends Handle
|
||||
'trace' => $e->getTrace(),
|
||||
'previous' => $e->getPrevious(),
|
||||
] : [];
|
||||
$message = Env::get('app_debug', false) ? '接口报错:' . $e->getMessage() : '很抱歉,系统开小差了';
|
||||
$message = Env::get('app_debug', false) ? $e->getMessage() : '很抱歉,系统开小差了';
|
||||
// 添加自定义异常处理机制
|
||||
if ($e instanceof AuthException || $e instanceof AdminException || $e instanceof ApiException) {
|
||||
if ($e instanceof AuthException || $e instanceof AdminException || $e instanceof ApiException || $e instanceof ValidateException) {
|
||||
return app('json')->make($e->getCode() ?: 400, $message, $massageData);
|
||||
} else {
|
||||
return app('json')->fail($message, $massageData);
|
||||
|
||||
@ -67,7 +67,7 @@ class StoreOrder extends AuthController
|
||||
], true);
|
||||
if ($status != '') $data['status'] = $status;
|
||||
$data['is_show'] = 1;
|
||||
$list = CacheService::get('EXPRESS_LIST', function () use ($services, $data) {
|
||||
$list = CacheService::remember('EXPRESS_LIST', function () use ($services, $data) {
|
||||
return $services->express($data);
|
||||
}, 86400);
|
||||
return app('json')->success($list);
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
|
||||
namespace app\services;
|
||||
|
||||
use crmeb\traits\ServicesTrait;
|
||||
use crmeb\utils\JwtAuth;
|
||||
use think\facade\Db;
|
||||
use think\facade\Config;
|
||||
@ -22,6 +23,9 @@ use think\facade\Route as Url;
|
||||
*/
|
||||
abstract class BaseServices
|
||||
{
|
||||
|
||||
use ServicesTrait;
|
||||
|
||||
/**
|
||||
* 模型注入
|
||||
* @var object
|
||||
@ -64,7 +68,9 @@ abstract class BaseServices
|
||||
* 创建token
|
||||
* @param int $id
|
||||
* @param $type
|
||||
* @param string $pwd
|
||||
* @return array
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
*/
|
||||
public function createToken(int $id, $type, $pwd = '')
|
||||
{
|
||||
|
||||
@ -18,6 +18,7 @@ use app\Request;
|
||||
use app\services\BaseServices;
|
||||
use app\services\order\StoreOrderServices;
|
||||
use app\services\other\PosterServices;
|
||||
use app\services\other\QrcodeServices;
|
||||
use app\services\product\product\StoreCategoryServices;
|
||||
use app\services\product\product\StoreDescriptionServices;
|
||||
use app\services\product\product\StoreProductServices;
|
||||
@ -864,6 +865,7 @@ class StoreBargainServices extends BaseServices
|
||||
* 获取砍价海报信息
|
||||
* @param int $bargainId
|
||||
* @param $user
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
@ -938,6 +940,12 @@ class StoreBargainServices extends BaseServices
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
}
|
||||
} else {
|
||||
if (sys_config('share_qrcode', 0) && request()->isWechat()) {
|
||||
/** @var QrcodeServices $qrcodeService */
|
||||
$qrcodeService = app()->make(QrcodeServices::class);
|
||||
$data['url'] = $qrcodeService->getTemporaryQrcode('bargain-' . $bargainId . '-' . $user['uid'], $user['uid'])->url;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
@ -17,7 +17,6 @@ use app\dao\activity\bargain\StoreBargainUserHelpDao;
|
||||
use app\services\user\UserServices;
|
||||
use crmeb\exceptions\AdminException;
|
||||
use crmeb\exceptions\ApiException;
|
||||
use crmeb\traits\ServicesTrait;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -29,8 +28,6 @@ use crmeb\traits\ServicesTrait;
|
||||
class StoreBargainUserHelpServices extends BaseServices
|
||||
{
|
||||
|
||||
use ServicesTrait;
|
||||
|
||||
/**
|
||||
* StoreBargainUserHelpServices constructor.
|
||||
* @param StoreBargainUserHelpDao $dao
|
||||
|
||||
@ -386,9 +386,14 @@ class StoreCombinationServices extends BaseServices
|
||||
$storeInfo['userLike'] = false;
|
||||
$storeInfo['store_name'] = $storeInfo['title'];
|
||||
|
||||
/** @var QrcodeServices $qrcodeService */
|
||||
$qrcodeService = app()->make(QrcodeServices::class);
|
||||
$storeInfo['code_base'] = $qrcodeService->getWechatQrcodePath($id . '_product_combination_detail_wap.jpg', '/pages/activity/goods_combination_details/index?id=' . $id);
|
||||
if (sys_config('share_qrcode', 0) && request()->isWechat()) {
|
||||
/** @var QrcodeServices $qrcodeService */
|
||||
$qrcodeService = app()->make(QrcodeServices::class);
|
||||
$storeInfo['wechat_code'] = $qrcodeService->getTemporaryQrcode('combination-' . $id, $uid)->url;
|
||||
} else {
|
||||
$storeInfo['wechat_code'] = '';
|
||||
}
|
||||
|
||||
$data['storeInfo'] = get_thumb_water($storeInfo, 'big', ['image', 'images']);
|
||||
$storeInfoNew = get_thumb_water($storeInfo, 'small');
|
||||
$data['storeInfo']['small_image'] = $storeInfoNew['image'];
|
||||
|
||||
@ -18,6 +18,7 @@ use app\services\BaseServices;
|
||||
use app\services\order\StoreOrderRefundServices;
|
||||
use app\services\order\StoreOrderServices;
|
||||
use app\services\other\PosterServices;
|
||||
use app\services\other\QrcodeServices;
|
||||
use app\services\system\attachment\SystemAttachmentServices;
|
||||
use app\services\user\UserServices;
|
||||
use crmeb\exceptions\ApiException;
|
||||
@ -465,7 +466,7 @@ class StorePinkServices extends BaseServices
|
||||
$number = (int)bcsub((string)$pink['people'], '1', 0);
|
||||
if ($number) CacheService::setStock(md5($pink['id']), $number, 3);
|
||||
|
||||
PinkJob::dispatchSece((int)(($product->effective_time * 3600) + 60), [$pink['id']]);
|
||||
PinkJob::dispatchSecs((int)(($product->effective_time * 3600) + 60), [$pink['id']]);
|
||||
// 开团成功发送模板消息
|
||||
event('notice.notice', [['orderInfo' => $orderInfo, 'title' => $product['title'], 'pink' => $pink], 'open_pink_success']);
|
||||
|
||||
@ -883,6 +884,12 @@ class StorePinkServices extends BaseServices
|
||||
$data['url'] = $url;
|
||||
if ($imageInfo['image_type'] == 1)
|
||||
$data['url'] = $siteUrl . $url;
|
||||
} else {
|
||||
if (sys_config('share_qrcode', 0) && request()->isWechat()) {
|
||||
/** @var QrcodeServices $qrcodeService */
|
||||
$qrcodeService = app()->make(QrcodeServices::class);
|
||||
$data['url'] = $qrcodeService->getTemporaryQrcode('pink-' . $id, $user['uid'])->url;
|
||||
}
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
}
|
||||
|
||||
@ -68,7 +68,8 @@ class StoreCouponIssueServices extends BaseServices
|
||||
return compact('list', 'count');
|
||||
}
|
||||
|
||||
/**获取会员优惠券列表
|
||||
/**
|
||||
* 获取会员优惠券列表
|
||||
* @param array $where
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
@ -117,17 +118,25 @@ class StoreCouponIssueServices extends BaseServices
|
||||
$data['end_time'] = strtotime((string)$data['end_time']);
|
||||
$data['title'] = $data['coupon_title'];
|
||||
$data['remain_count'] = $data['total_count'];
|
||||
$data['category_id'] = implode(',', $data['category_id']);
|
||||
if ($data['receive_type'] == 2 || $data['receive_type'] == 3) {
|
||||
$data['is_permanent'] = 1;
|
||||
$data['total_count'] = 0;
|
||||
}
|
||||
$data['add_time'] = time();
|
||||
$res = $this->dao->save($data);
|
||||
if ($data['product_id'] !== '' && $res) {
|
||||
$productIds = explode(',', $data['product_id']);
|
||||
if (($data['product_id'] !== '' || $data['category_id'] !== '') && $res) {
|
||||
$couponData = [];
|
||||
foreach ($productIds as $product_id) {
|
||||
$couponData[] = ['product_id' => $product_id, 'coupon_id' => $res->id];
|
||||
if ($data['product_id'] !== '') {
|
||||
$productIds = explode(',', $data['product_id']);
|
||||
foreach ($productIds as $product_id) {
|
||||
$couponData[] = ['product_id' => $product_id, 'coupon_id' => $res->id];
|
||||
}
|
||||
} elseif ($data['category_id'] !== '') {
|
||||
$categoryIds = explode(',', $data['category_id']);
|
||||
foreach ($categoryIds as $category_id) {
|
||||
$couponData[] = ['category_id' => $category_id, 'coupon_id' => $res->id];
|
||||
}
|
||||
}
|
||||
/** @var StoreCouponProductServices $storeCouponProductService */
|
||||
$storeCouponProductService = app()->make(StoreCouponProductServices::class);
|
||||
@ -237,30 +246,27 @@ class StoreCouponIssueServices extends BaseServices
|
||||
$ids = array_column($couponList, 'id');
|
||||
/** @var StoreCouponIssueUserServices $issueUser */
|
||||
$issueUser = app()->make(StoreCouponIssueUserServices::class);
|
||||
$userCouponIds = $issueUser->getColumn([['uid', '=', $uid], ['issue_coupon_id', 'in', $ids]], 'issue_coupon_id') ?? [];
|
||||
foreach ($couponList as $item) {
|
||||
if (!$userCouponIds || !in_array($item['id'], $userCouponIds)) {
|
||||
$data['cid'] = $item['id'];
|
||||
$data['uid'] = $uid;
|
||||
$data['coupon_title'] = $item['title'];
|
||||
$data['coupon_price'] = $item['coupon_price'];
|
||||
$data['use_min_price'] = $item['use_min_price'];
|
||||
if ($item['coupon_time']) {
|
||||
$data['add_time'] = $time;
|
||||
$data['end_time'] = $data['add_time'] + $item['coupon_time'] * 86400;
|
||||
} else {
|
||||
$data['add_time'] = $item['start_use_time'];
|
||||
$data['end_time'] = $item['end_use_time'];
|
||||
}
|
||||
$data['type'] = 'get';
|
||||
$issue['uid'] = $uid;
|
||||
$issue['issue_coupon_id'] = $item['id'];
|
||||
$issue['add_time'] = $time;
|
||||
$issueUserData[] = $issue;
|
||||
$couponData[] = $data;
|
||||
unset($data);
|
||||
unset($issue);
|
||||
$data['cid'] = $item['id'];
|
||||
$data['uid'] = $uid;
|
||||
$data['coupon_title'] = $item['title'];
|
||||
$data['coupon_price'] = $item['coupon_price'];
|
||||
$data['use_min_price'] = $item['use_min_price'];
|
||||
if ($item['coupon_time']) {
|
||||
$data['add_time'] = $time;
|
||||
$data['end_time'] = $data['add_time'] + $item['coupon_time'] * 86400;
|
||||
} else {
|
||||
$data['add_time'] = $item['start_use_time'];
|
||||
$data['end_time'] = $item['end_use_time'];
|
||||
}
|
||||
$data['type'] = 'get';
|
||||
$issue['uid'] = $uid;
|
||||
$issue['issue_coupon_id'] = $item['id'];
|
||||
$issue['add_time'] = $time;
|
||||
$issueUserData[] = $issue;
|
||||
$couponData[] = $data;
|
||||
unset($data);
|
||||
unset($issue);
|
||||
}
|
||||
if ($couponData) {
|
||||
/** @var StoreCouponUserServices $storeCouponUser */
|
||||
@ -290,24 +296,22 @@ class StoreCouponIssueServices extends BaseServices
|
||||
public function getIssueCouponList(int $uid, array $where)
|
||||
{
|
||||
[$page, $limit] = $this->getPageValue();
|
||||
$cateId = [];
|
||||
if ($where['product_id'] == 0) {
|
||||
$typeId = 0;
|
||||
$cateId = 0;
|
||||
if ($where['type'] == -1) { // PC端获取优惠券
|
||||
$list = $this->dao->getPcIssueCouponList($uid, [], 0, 0);
|
||||
$list = $this->dao->getPcIssueCouponList($uid, []);
|
||||
} else {
|
||||
$list = $this->dao->getIssueCouponList($uid, (int)$where['type'], $typeId, $page, $limit);
|
||||
if (!$list) $list = $this->dao->getIssueCouponList($uid, 1, $typeId, $page, $limit);
|
||||
if (!$list) $list = $this->dao->getIssueCouponList($uid, 2, $typeId, $page, $limit);
|
||||
$list = $this->dao->getIssueCouponList($uid, (int)$where['type'], 0, $page, $limit);
|
||||
if (!$list) $list = $this->dao->getIssueCouponList($uid, 1, 0, $page, $limit);
|
||||
if (!$list) $list = $this->dao->getIssueCouponList($uid, 2, 0, $page, $limit);
|
||||
}
|
||||
} else {
|
||||
/** @var StoreProductServices $storeProductService */
|
||||
$storeProductService = app()->make(StoreProductServices::class);
|
||||
/** @var StoreCategoryServices $storeCategoryService */
|
||||
$storeCategoryService = app()->make(StoreCategoryServices::class);
|
||||
|
||||
$cateId = $storeProductService->value(['id' => $where['product_id']], 'cate_id');
|
||||
$cateId = explode(',', $cateId);
|
||||
$cateId = explode(',', (string)$cateId);
|
||||
$cateId = array_merge($cateId, $storeCategoryService->cateIdByPid($cateId));
|
||||
$cateId = array_diff($cateId, [0]);
|
||||
if ($where['type'] == -1) { // PC端获取优惠券
|
||||
@ -326,10 +330,10 @@ class StoreCouponIssueServices extends BaseServices
|
||||
foreach ($list as &$v) {
|
||||
$v['coupon_price'] = floatval($v['coupon_price']);
|
||||
$v['use_min_price'] = floatval($v['use_min_price']);
|
||||
$v['is_use'] = $uid && isset($v['used']);
|
||||
$v['is_use'] = count($v['used']);
|
||||
if ($v['end_use_time']) {
|
||||
$v['start_use_time'] = date('Y/m/d', $v['start_use_time']);
|
||||
$v['end_use_time'] = $v['end_use_time'] ? date('Y/m/d', $v['end_use_time']) : date('Y/m/d', time() + 86400);
|
||||
$v['end_use_time'] = date('Y/m/d', $v['end_use_time']);
|
||||
}
|
||||
if ($v['start_time']) {
|
||||
$v['start_time'] = date('Y/m/d', $v['start_time']);
|
||||
@ -341,7 +345,16 @@ class StoreCouponIssueServices extends BaseServices
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function issueUserCoupon($id, $user)
|
||||
/**
|
||||
* 领取优惠券
|
||||
* @param $id
|
||||
* @param $user
|
||||
* @param bool $is_receive
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function issueUserCoupon($id, $user, bool $is_receive = false)
|
||||
{
|
||||
$issueCouponInfo = $this->dao->getInfo((int)$id);
|
||||
$uid = $user->uid;
|
||||
@ -354,9 +367,14 @@ class StoreCouponIssueServices extends BaseServices
|
||||
}
|
||||
/** @var StoreCouponIssueUserServices $issueUserService */
|
||||
$issueUserService = app()->make(StoreCouponIssueUserServices::class);
|
||||
if ($is_receive) {
|
||||
$alreadyReceived = $issueUserService->count(['uid' => $uid, 'issue_coupon_id' => $id]);
|
||||
if ($alreadyReceived >= $issueCouponInfo['receive_limit']) {
|
||||
throw new ApiException(400518);
|
||||
}
|
||||
}
|
||||
/** @var StoreCouponUserServices $couponUserService */
|
||||
$couponUserService = app()->make(StoreCouponUserServices::class);
|
||||
if ($issueUserService->getOne(['uid' => $uid, 'issue_coupon_id' => $id])) throw new ApiException(400517);
|
||||
if ($issueCouponInfo->remain_count <= 0 && !$issueCouponInfo->is_permanent) throw new ApiException(400518);
|
||||
$this->transaction(function () use ($issueUserService, $uid, $id, $couponUserService, $issueCouponInfo) {
|
||||
$issueUserService->save(['uid' => $uid, 'issue_coupon_id' => $id, 'add_time' => time()]);
|
||||
@ -432,29 +450,24 @@ class StoreCouponIssueServices extends BaseServices
|
||||
$storeCouponUser = app()->make(StoreCouponUserServices::class);
|
||||
/** @var StoreCouponIssueUserServices $storeCouponIssueUser */
|
||||
$storeCouponIssueUser = app()->make(StoreCouponIssueUserServices::class);
|
||||
$uids = $storeCouponIssueUser->getColumn(['issue_coupon_id' => $coupon['id']], 'uid');
|
||||
foreach ($user as $k => $v) {
|
||||
if (in_array($v, $uids)) {
|
||||
continue;
|
||||
$data[$k]['cid'] = $coupon['id'];
|
||||
$data[$k]['uid'] = $v;
|
||||
$data[$k]['coupon_title'] = $coupon['title'];
|
||||
$data[$k]['coupon_price'] = $coupon['coupon_price'];
|
||||
$data[$k]['use_min_price'] = $coupon['use_min_price'];
|
||||
$data[$k]['add_time'] = time();
|
||||
if ($coupon['coupon_time']) {
|
||||
$data[$k]['start_time'] = $data[$k]['add_time'];
|
||||
$data[$k]['end_time'] = $data[$k]['add_time'] + $coupon['coupon_time'] * 86400;
|
||||
} else {
|
||||
$data[$k]['cid'] = $coupon['id'];
|
||||
$data[$k]['uid'] = $v;
|
||||
$data[$k]['coupon_title'] = $coupon['title'];
|
||||
$data[$k]['coupon_price'] = $coupon['coupon_price'];
|
||||
$data[$k]['use_min_price'] = $coupon['use_min_price'];
|
||||
$data[$k]['add_time'] = time();
|
||||
if ($coupon['coupon_time']) {
|
||||
$data[$k]['start_time'] = $data[$k]['add_time'];
|
||||
$data[$k]['end_time'] = $data[$k]['add_time'] + $coupon['coupon_time'] * 86400;
|
||||
} else {
|
||||
$data[$k]['start_time'] = $coupon['start_use_time'];
|
||||
$data[$k]['end_time'] = $coupon['end_use_time'];
|
||||
}
|
||||
$data[$k]['type'] = 'send';
|
||||
$issueData[$k]['uid'] = $v;
|
||||
$issueData[$k]['issue_coupon_id'] = $coupon['id'];
|
||||
$issueData[$k]['add_time'] = time();
|
||||
$data[$k]['start_time'] = $coupon['start_use_time'];
|
||||
$data[$k]['end_time'] = $coupon['end_use_time'];
|
||||
}
|
||||
$data[$k]['type'] = 'send';
|
||||
$issueData[$k]['uid'] = $v;
|
||||
$issueData[$k]['issue_coupon_id'] = $coupon['id'];
|
||||
$issueData[$k]['add_time'] = time();
|
||||
}
|
||||
if (!empty($data)) {
|
||||
if (!$storeCouponUser->saveAll($data)) {
|
||||
@ -464,8 +477,6 @@ class StoreCouponIssueServices extends BaseServices
|
||||
throw new AdminException(100031);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
throw new AdminException(400519);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types = 1);
|
||||
declare (strict_types=1);
|
||||
|
||||
namespace app\services\activity\coupon;
|
||||
|
||||
@ -42,6 +42,10 @@ class StoreCouponIssueUserServices extends BaseServices
|
||||
{
|
||||
[$page, $limit] = $this->getPageValue();
|
||||
$list = $this->dao->getList($where, $page, $limit);
|
||||
$site_url = sys_config('site_url');
|
||||
foreach ($list as &$item) {
|
||||
$item['avatar'] = strpos($item['avatar'], 'http') === false ? ($site_url . $item['avatar']) : $item['avatar'];
|
||||
}
|
||||
$count = $this->dao->count($where);
|
||||
return compact('list', 'count');
|
||||
}
|
||||
|
||||
@ -145,9 +145,10 @@ class StoreCouponUserServices extends BaseServices
|
||||
case 1://品类券
|
||||
/** @var StoreCategoryServices $storeCategoryServices */
|
||||
$storeCategoryServices = app()->make(StoreCategoryServices::class);
|
||||
$cateGorys = $storeCategoryServices->getAllById((int)$coupon['category_id']);
|
||||
if ($cateGorys) {
|
||||
$cateIds = array_column($cateGorys, 'id');
|
||||
$coupon_category = explode(',', (string)$coupon['category_id']);
|
||||
$category_ids = $storeCategoryServices->getAllById($coupon_category);
|
||||
if ($category_ids) {
|
||||
$cateIds = array_column($category_ids, 'id');
|
||||
foreach ($cartInfo as $cart) {
|
||||
if (isset($cart['productInfo']['cate_id']) && array_intersect(explode(',', $cart['productInfo']['cate_id']), $cateIds)) {
|
||||
$price += bcmul((string)$cart['truePrice'], (string)$cart['cart_num'], 2);
|
||||
@ -302,18 +303,6 @@ class StoreCouponUserServices extends BaseServices
|
||||
}
|
||||
[$page, $limit] = $this->getPageValue();
|
||||
$list = $this->dao->getCouponListByOrder($where, 'status ASC,add_time DESC', $page, $limit);
|
||||
/** @var StoreCategoryServices $categoryServices */
|
||||
$categoryServices = app()->make(StoreCategoryServices::class);
|
||||
$category = $categoryServices->getColumn([], 'pid,cate_name', 'id');
|
||||
foreach ($list as &$item) {
|
||||
if ($item['category_id']) {
|
||||
$item['category_type'] = $category[$item['category_id']]['pid'] == 0 ? 1 : 2;
|
||||
$item['category_name'] = $category[$item['category_id']]['cate_name'];
|
||||
} else {
|
||||
$item['category_type'] = '';
|
||||
$item['category_name'] = '';
|
||||
}
|
||||
}
|
||||
return $list ? $this->tidyCouponList($list) : [];
|
||||
}
|
||||
|
||||
|
||||
@ -23,7 +23,6 @@ use crmeb\exceptions\AdminException;
|
||||
use crmeb\exceptions\ApiException;
|
||||
use crmeb\services\FormBuilder as Form;
|
||||
use crmeb\services\printer\Printer;
|
||||
use crmeb\traits\ServicesTrait;
|
||||
|
||||
/**
|
||||
* Class StoreIntegralOrderServices
|
||||
@ -35,8 +34,6 @@ use crmeb\traits\ServicesTrait;
|
||||
class StoreIntegralOrderServices extends BaseServices
|
||||
{
|
||||
|
||||
use ServicesTrait;
|
||||
|
||||
/**
|
||||
* 发货类型
|
||||
* @var string[]
|
||||
|
||||
@ -14,7 +14,6 @@ namespace app\services\activity\integral;
|
||||
|
||||
use app\dao\activity\integral\StoreIntegralOrderStatusDao;
|
||||
use app\services\BaseServices;
|
||||
use crmeb\traits\ServicesTrait;
|
||||
|
||||
/**
|
||||
* 订单状态
|
||||
@ -23,7 +22,6 @@ use crmeb\traits\ServicesTrait;
|
||||
*/
|
||||
class StoreIntegralOrderStatusServices extends BaseServices
|
||||
{
|
||||
use ServicesTrait;
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
|
||||
@ -162,7 +162,7 @@ class LiveAnchorServices extends BaseServices
|
||||
public function syncAnchor($is_job = false)
|
||||
{
|
||||
$key = md5('Live_sync_status');
|
||||
$res = CacheService::redisHandler()->get($key);
|
||||
$res = CacheService::get($key);
|
||||
if (!$res || $is_job) {
|
||||
$start = 0;
|
||||
$limit = 30;
|
||||
@ -187,8 +187,8 @@ class LiveAnchorServices extends BaseServices
|
||||
$this->dao->saveAll($dataAll);
|
||||
}
|
||||
//支付成功后发送消息
|
||||
if (!$is_job) LiveJob::dispatchSece(120);
|
||||
CacheService::redisHandler()->set($key, 1, 0);
|
||||
if (!$is_job) LiveJob::dispatchSecs(120);
|
||||
CacheService::set($key, 1, 0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user