From 20352cc696960bfd62f36342359467f59a782dcf Mon Sep 17 00:00:00 2001 From: evoxwht <442384644@qq.com> Date: Mon, 18 Dec 2023 12:20:58 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=A8=8B=E5=BA=8F=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E3=80=91=E6=9B=B4=E6=96=B0=E5=BC=80=E6=BA=90v5.2.2=E7=89=88?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crmeb/app/Request.php | 2 +- .../coupon/StoreCouponIssueServices.php | 45 +++++++++---------- .../app/services/out/OutInterfaceServices.php | 33 +++++++------- crmeb/app/services/system/UpgradeServices.php | 2 +- crmeb/app/services/user/UserSignServices.php | 3 +- 5 files changed, 43 insertions(+), 42 deletions(-) diff --git a/crmeb/app/Request.php b/crmeb/app/Request.php index 15a9fbf6f..dbdac4d0f 100644 --- a/crmeb/app/Request.php +++ b/crmeb/app/Request.php @@ -34,7 +34,7 @@ class Request extends \think\Request * @var array */ protected $except = ['menu_path', 'api_url', 'unique_auth', - 'description', 'custom_form', 'content', 'tableField','url']; + 'description', 'custom_form', 'content', 'tableField', 'url']; /** * 获取请求的数据 diff --git a/crmeb/app/services/activity/coupon/StoreCouponIssueServices.php b/crmeb/app/services/activity/coupon/StoreCouponIssueServices.php index bb782e494..d6ed3064d 100644 --- a/crmeb/app/services/activity/coupon/StoreCouponIssueServices.php +++ b/crmeb/app/services/activity/coupon/StoreCouponIssueServices.php @@ -102,18 +102,8 @@ class StoreCouponIssueServices extends BaseServices return (int)$data['id']; } - if ($data['start_time'] && $data['start_use_time']) { - - if ($data['start_time'] < date('Y-m-d 00:00:00')) { - throw new AdminException('开始领取时间不能小于当前时间'); - } - if ($data['start_use_time'] < date('Y-m-d 00:00:00')) { - throw new AdminException('开始使用时间不能小于当前时间'); - } - - if ($data['start_use_time'] < $data['start_time']) { - throw new AdminException(400513); - } + if (empty($data['coupon_title'])) { + throw new AdminException(400759); } if (!in_array((int)$data['receive_type'], [1, 2, 3, 4])) { @@ -124,20 +114,30 @@ class StoreCouponIssueServices extends BaseServices throw new AdminException(400758); } - if (empty($data['coupon_title'])) { - throw new AdminException(400759); - } - - if ($data['end_time'] && $data['end_use_time']) { - if ($data['end_use_time'] < $data['end_time']) { - throw new AdminException('用户领取数量不能大于优惠券发布数量'); - } - } - $data['start_use_time'] = strtotime((string)$data['start_use_time']); $data['end_use_time'] = strtotime((string)$data['end_use_time']); $data['start_time'] = strtotime((string)$data['start_time']); $data['end_time'] = strtotime((string)$data['end_time']); + + if ($data['start_time'] && $data['start_use_time']) { + + if ($data['start_time'] < date('Y-m-d 00:00:00')) { + throw new AdminException('开始领取时间不能小于当前时间'); + } + if ($data['start_use_time'] < date('Y-m-d 00:00:00')) { + throw new AdminException('开始使用时间不能小于当前时间'); + } + if ($data['start_use_time'] < $data['start_time']) { + throw new AdminException(400513); + } + } + + if ($data['end_time'] && $data['end_use_time']) { + if ($data['end_use_time'] < $data['end_time']) { + throw new AdminException('最后使用时间不能小于最后领取时间'); + } + } + $data['title'] = $data['coupon_title']; $data['remain_count'] = $data['total_count']; $data['category_id'] = implode(',', $data['category_id']); @@ -150,7 +150,6 @@ class StoreCouponIssueServices extends BaseServices throw new AdminException(500031); } - $data['add_time'] = time(); $res = $this->dao->save($data); if (($data['product_id'] !== '' || $data['category_id'] !== '') && $res) { diff --git a/crmeb/app/services/out/OutInterfaceServices.php b/crmeb/app/services/out/OutInterfaceServices.php index 0fe72d909..7baaedf0c 100644 --- a/crmeb/app/services/out/OutInterfaceServices.php +++ b/crmeb/app/services/out/OutInterfaceServices.php @@ -5,6 +5,8 @@ namespace app\services\out; use app\dao\out\OutInterfaceDao; use app\Request; use app\services\BaseServices; +use app\services\system\SystemRouteCateServices; +use app\services\system\SystemRouteServices; use crmeb\exceptions\AdminException; use crmeb\exceptions\AuthException; @@ -24,14 +26,14 @@ class OutInterfaceServices extends BaseServices { $rule = trim(strtolower($request->rule()->getRule())); $method = trim(strtolower($request->method())); - $authList = $this->dao->getColumn([['id', 'in', $request->outInfo()['rules']], ['type', '=', 1]], 'method,url'); + $authList = app()->make(SystemRouteServices::class)->getColumn([['id', 'in', $request->outInfo()['rules']], ['app_name', '=', 'outapi']], 'method,path'); $rolesAuth = []; foreach ($authList as $item) { - $rolesAuth[trim(strtolower($item['method']))][] = trim(strtolower(str_replace(' ', '', $item['url']))); + $rolesAuth[trim(strtolower($item['method']))][] = trim(strtolower(str_replace(' ', '', $item['path']))); } $rule = str_replace('<', '{', $rule); $rule = str_replace('>', '}', $rule); - if (in_array('/' . $rule, $rolesAuth[$method])) { + if (in_array($rule, $rolesAuth[$method])) { return true; } else { throw new AuthException(110000); @@ -47,24 +49,23 @@ class OutInterfaceServices extends BaseServices */ public function outInterfaceList(): array { - $list = $this->dao->selectList(['is_del' => 0], 'id,pid,method,type,name,name as title')->toArray(); - $data = []; - foreach ($list as $key => $item) { - if ($item['pid'] == 0) { - $data[] = $item; - unset($list[$key]); - } - } - foreach ($data as &$item_p) { - foreach ($list as $item_c) { - if ($item_p['id'] == $item_c['pid']) { - $item_p['children'][] = $item_c; + // 获取系统路由分类列表 + $list = app()->make(SystemRouteCateServices::class)->selectList(['app_name' => 'outapi'], 'id,pid,name,name as title')->toArray(); + // 获取系统路由列表 + $data = app()->make(SystemRouteServices::class)->selectList(['app_name' => 'outapi'], 'id,cate_id as pid,name,name as title')->toArray(); + // 遍历分类列表,将分类下的路由添加到对应的子节点中 + foreach ($list as &$item) { + foreach ($data as $k => $v) { + if ($item['id'] == $v['pid']) { + $item['children'][] = $v; } } } - return $data; + // 返回完整的外部接口列表 + return $list; } + /** * 新增对外接口文档 * @param $id diff --git a/crmeb/app/services/system/UpgradeServices.php b/crmeb/app/services/system/UpgradeServices.php index 326070d9f..62b1f6df7 100644 --- a/crmeb/app/services/system/UpgradeServices.php +++ b/crmeb/app/services/system/UpgradeServices.php @@ -46,7 +46,7 @@ class UpgradeServices extends BaseServices /** * @var int $timeStamp */ - private $timeStamp; + private $timeStamp = 0; /** * UpgradeServices constructor. diff --git a/crmeb/app/services/user/UserSignServices.php b/crmeb/app/services/user/UserSignServices.php index 74d325735..07dde0076 100644 --- a/crmeb/app/services/user/UserSignServices.php +++ b/crmeb/app/services/user/UserSignServices.php @@ -215,7 +215,8 @@ class UserSignServices extends BaseServices $this->transaction(function () use ($uid, $title, $sign_point, $user, $sign_exp) { $this->setSignData($uid, $title, $sign_point, $user['integral'], (int)$user['exp'], $sign_exp); $user->integral = (int)$user->integral + (int)$sign_point; - if ($sign_exp) $user->exp = (int)$user->exp + (int)$sign_exp; +// if ($sign_exp) $user->exp = (int)$user->exp + (int)$sign_exp; + if ($sign_exp) $user->exp = bcadd($user->exp, $sign_exp, 2); if (!$user->save()) { throw new ApiException(410287); }