diff --git a/crmeb/app/api/controller/v1/PublicController.php b/crmeb/app/api/controller/v1/PublicController.php index 4f762b3dc..7c716f955 100644 --- a/crmeb/app/api/controller/v1/PublicController.php +++ b/crmeb/app/api/controller/v1/PublicController.php @@ -610,23 +610,27 @@ class PublicController */ public function getLangJson() { + /** @var LangTypeServices $langTypeServices */ + $langTypeServices = app()->make(LangTypeServices::class); + /** @var LangCountryServices $langCountryServices */ + $langCountryServices = app()->make(LangCountryServices::class); + $request = app()->request; //获取接口传入的语言类型 if (!$range = $request->header('cb-lang')) { - if ($request->header('accept-language') !== null) { - $range = explode(',', $request->header('accept-language'))[0]; - } else { - $range = 'zh-CN'; - } +// //根据浏览器语言显示,如果浏览器语言在库中找不到,则使用简体中文 +// if ($request->header('accept-language') !== null) { +// $range = explode(',', $request->header('accept-language'))[0]; +// } else { +// $range = 'zh-CN'; +// } + //没有传入则使用系统默认语言显示 + $range = $langTypeServices->value(['is_default'=>1],'file_name'); } // 获取type_id - /** @var LangCountryServices $langCountryServices */ - $langCountryServices = app()->make(LangCountryServices::class); $typeId = $langCountryServices->value(['code' => $range], 'type_id') ?: 1; // 获取缓存key - /** @var LangTypeServices $langTypeServices */ - $langTypeServices = app()->make(LangTypeServices::class); $langData = $langTypeServices->getColumn(['status' => 1, 'is_del' => 0], 'file_name', 'id'); $langStr = 'api_lang_' . str_replace('-', '_', $langData[$typeId]); diff --git a/crmeb/app/api/controller/v1/store/StoreProductController.php b/crmeb/app/api/controller/v1/store/StoreProductController.php index 690fe80da..99079a613 100644 --- a/crmeb/app/api/controller/v1/store/StoreProductController.php +++ b/crmeb/app/api/controller/v1/store/StoreProductController.php @@ -184,7 +184,7 @@ class StoreProductController /** @var StoreProductReplyServices $replyService */ $replyService = app()->make(StoreProductReplyServices::class); $list = $replyService->getProductReplyList($id, $type); - return app('json')->success(get_thumb_water($list, 'mid', ['pics'])); + return app('json')->success(get_thumb_water($list, 'big', ['pics'])); } /** diff --git a/crmeb/app/api/controller/v2/activity/LuckLotteryController.php b/crmeb/app/api/controller/v2/activity/LuckLotteryController.php index ad1066134..df405d509 100644 --- a/crmeb/app/api/controller/v2/activity/LuckLotteryController.php +++ b/crmeb/app/api/controller/v2/activity/LuckLotteryController.php @@ -33,7 +33,7 @@ class LuckLotteryController public function LotteryInfo(Request $request, $factor) { if (!$factor) return app('json')->fail(100100); - $lottery = $this->services->getFactorLottery((int)$factor); + $lottery = $this->services->getFactorLottery((int)$factor, '*', ['prize'], true); if (!$lottery) { return app('json')->fail(410318); } @@ -62,6 +62,9 @@ class LuckLotteryController * 参与抽奖 * @param Request $request * @return mixed + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException */ public function luckLottery(Request $request) { diff --git a/crmeb/app/dao/system/statistics/CapitalFlowDao.php b/crmeb/app/dao/system/statistics/CapitalFlowDao.php index 9e2de449a..a29220f62 100644 --- a/crmeb/app/dao/system/statistics/CapitalFlowDao.php +++ b/crmeb/app/dao/system/statistics/CapitalFlowDao.php @@ -52,29 +52,63 @@ class CapitalFlowDao extends BaseDao * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ - public function getRecordList($where, $page = 0, $limit = 0) + public function getRecordList($where, int $page = 0, int $limit = 0) { + $timeUnix = "%Y-%m-%d"; + switch ($where['type']) { + case "day" : + $timeUnix = "%Y-%m-%d"; + break; + case "week" : + $timeUnix = "%u"; + break; + case "month" : + $timeUnix = "%Y-%m"; + break; + } $model = $this->search($where) - ->when(isset($where['type']) && $where['type'] !== '', function ($query) use ($where) { - $timeUnix = '%d'; - switch ($where['type']) { - case "day" : - $timeUnix = "%d"; - break; - case "week" : - $timeUnix = "%u"; - break; - case "month" : - $timeUnix = "%m"; - break; - } - $query->field("FROM_UNIXTIME(add_time,'$timeUnix') as day,sum(if(price >= 0,price,0)) as income_price,sum(if(price < 0,price,0)) as exp_price,add_time,group_concat(id) as ids"); + ->when(isset($where['type']) && $where['type'] !== '', function ($query) use ($where, $timeUnix) { + $query->field("FROM_UNIXTIME(add_time,'$timeUnix') as day,sum(if(price >= 0,price,0)) as income_price,sum(if(price < 0,price,0)) as exp_price,add_time"); $query->group("FROM_UNIXTIME(add_time, '$timeUnix')"); }); $count = $model->count(); $list = $model->when($page && $limit, function ($query) use ($page, $limit) { $query->page($page, $limit); })->order('add_time desc')->select()->toArray(); + foreach ($list as &$item) { + if ($where['type'] == 'day') { + $item['ids'] = array_merge($this->getModel()->whereDay('add_time', $item['day'])->column('id')); + } elseif ($where['type'] == 'week') { + $day = $this->weekDayTime(date('Y'), $item['day']); + $item['ids'] = array_merge($this->getModel()->whereWeek('add_time', $day)->column('id')); + } elseif ($where['type'] == 'month') { + $item['ids'] = array_merge($this->getModel()->whereMonth('add_time', $item['day'])->column('id')); + } + } return compact('list', 'count'); } + + /** + * 获取某年第几周的开始日期 + * @param int $year + * @param int $week + * @return array|false|string + */ + public function weekDayTime(int $year, int $week = 1) + { + $year_start = mktime(0, 0, 0, 1, 1, $year); + // 判断第一天是否为第一周的开始 + if (intval(date('W', $year_start)) === 1) { + $start = $year_start;//把第一天做为第一周的开始 + } else { + $start = strtotime('+1 monday', $year_start);//把第一个周一作为开始 + } + // 第几周的开始时间 + if ($week === 1) { + $weekday = $start; + } else { + $weekday = strtotime('+' . ($week - 0) . ' monday', $start); + } + return date('Y-m-d', $weekday); + } } diff --git a/crmeb/app/services/activity/seckill/StoreSeckillServices.php b/crmeb/app/services/activity/seckill/StoreSeckillServices.php index 68cc1f9e7..620c3fb86 100644 --- a/crmeb/app/services/activity/seckill/StoreSeckillServices.php +++ b/crmeb/app/services/activity/seckill/StoreSeckillServices.php @@ -511,22 +511,28 @@ class StoreSeckillServices extends BaseServices //获取秒杀商品状态 if ($storeInfo['status'] == 1) { - /** @var SystemGroupDataServices $systemGroupDataService */ - $systemGroupDataService = app()->make(SystemGroupDataServices::class); - $seckillTime = array_column($systemGroupDataService->getConfigNameValue('routine_seckill_time'), null, 'id'); - $config = $seckillTime[$storeInfo['time_id']] ?? false; - if (!$config) { - throw new ApiException(410322); - } - $now_hour = date('H', time()); - $start_hour = $config['time']; - $end_hour = (int)$start_hour + (int)$config['continued']; - if ($start_hour <= $now_hour && $end_hour > $now_hour) { - $storeInfo['status'] = 1; - } else if ($start_hour > $now_hour) { + if ($storeInfo['start_time'] > time()) { $storeInfo['status'] = 2; - } else { + } elseif ($storeInfo['end_time'] < time()) { $storeInfo['status'] = 0; + } else { + /** @var SystemGroupDataServices $systemGroupDataService */ + $systemGroupDataService = app()->make(SystemGroupDataServices::class); + $seckillTime = array_column($systemGroupDataService->getConfigNameValue('routine_seckill_time'), null, 'id'); + $config = $seckillTime[$storeInfo['time_id']] ?? false; + if (!$config) { + throw new ApiException(410322); + } + $now_hour = date('H', time()); + $start_hour = $config['time']; + $end_hour = (int)$start_hour + (int)$config['continued']; + if ($start_hour <= $now_hour && $end_hour > $now_hour) { + $storeInfo['status'] = 1; + } else if ($start_hour > $now_hour) { + $storeInfo['status'] = 2; + } else { + $storeInfo['status'] = 0; + } } } else { $storeInfo['status'] == 0; diff --git a/crmeb/app/services/message/MessageSystemServices.php b/crmeb/app/services/message/MessageSystemServices.php index 55c579622..6e16e955b 100644 --- a/crmeb/app/services/message/MessageSystemServices.php +++ b/crmeb/app/services/message/MessageSystemServices.php @@ -8,13 +8,14 @@ // +---------------------------------------------------------------------- // | Author: CRMEB Team // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare (strict_types=1); namespace app\services\message; use app\dao\system\MessageSystemDao; use app\services\BaseServices; use crmeb\exceptions\ApiException; + /** * 站内信services类 * Class MessageSystemServices @@ -54,6 +55,9 @@ class MessageSystemServices extends BaseServices if (!$list) return ['list' => [], 'count' => 0]; foreach ($list as &$item) { $item['add_time'] = time_tran($item['add_time']); + if ($item['data'] != '') { + $item['content'] = getLang($this->getMsgCode($item['mark']), json_decode($item['data'], true)); + } } return ['list' => $list, 'count' => $count]; } @@ -76,7 +80,90 @@ class MessageSystemServices extends BaseServices if ($info['look'] == 0) { $this->update($info['id'], ['look' => 1]); } + if ($info['data'] != '') { + $info['content'] = getLang($this->getMsgCode($info['mark']), json_decode($info['data'], true)); + } $info['add_time'] = time_tran($info['add_time']); return $info; } + + public function getMsgCode($mark) + { + switch ($mark) { + case 'admin_pay_success_code': + $code = 500004; + break; + case 'bind_spread_uid': + $code = 500005; + break; + case 'order_pay_success': + $code = 500006; + break; + case 'order_take': + $code = 500007; + break; + case 'price_revision': + $code = 500008; + break; + case 'order_refund': + $code = 500009; + break; + case 'recharge_success': + $code = 500010; + break; + case 'integral_accout': + $code = 500011; + break; + case 'order_brokerage': + $code = 500012; + break; + case 'bargain_success': + $code = 500013; + break; + case 'order_user_groups_success': + $code = 500014; + break; + case 'send_order_pink_fial': + $code = 500015; + break; + case 'open_pink_success': + $code = 500016; + break; + case 'user_extract': + $code = 500017; + break; + case 'user_balance_change': + $code = 500018; + break; + case 'recharge_order_refund_status': + $code = 500019; + break; + case 'send_order_refund_no_status': + $code = 500020; + break; + case 'send_order_apply_refund': + $code = 500021; + break; + case 'order_deliver_success': + case 'order_postage_success': + $code = 500022; + break; + case 'send_order_pink_clone': + $code = 500023; + break; + case 'can_pink_success': + $code = 500024; + break; + case 'kefu_send_extract_application': + $code = 500025; + break; + case 'send_admin_confirm_take_over': + $code = 500026; + break; + case 'order_pay_false': + $code = 500027; + break; + } + return $code; + } } diff --git a/crmeb/app/services/message/notice/SystemMsgService.php b/crmeb/app/services/message/notice/SystemMsgService.php index 7fc1c7535..9952d783f 100644 --- a/crmeb/app/services/message/notice/SystemMsgService.php +++ b/crmeb/app/services/message/notice/SystemMsgService.php @@ -67,6 +67,7 @@ class SystemMsgService extends NoticeService $sdata['title'] = $title; $sdata['type'] = 1; $sdata['add_time'] = time(); + $sdata['data'] = json_encode($data); /** @var MessageSystemServices $MessageSystemServices */ $MessageSystemServices = app()->make(MessageSystemServices::class); $MessageSystemServices->save($sdata); @@ -105,6 +106,7 @@ class SystemMsgService extends NoticeService $save[$key]['title'] = $title; $save[$key]['type'] = 2; $save[$key]['add_time'] = time(); + $save[$key]['data'] = json_encode($data); } $MessageSystemServices->saveAll($save); } diff --git a/crmeb/app/services/other/QrcodeServices.php b/crmeb/app/services/other/QrcodeServices.php index 1f8857ae5..b8f61e2ac 100644 --- a/crmeb/app/services/other/QrcodeServices.php +++ b/crmeb/app/services/other/QrcodeServices.php @@ -52,7 +52,7 @@ class QrcodeServices extends BaseServices $where['third_id'] = $id; $where['third_type'] = $type; $res = $this->dao->getOne($where); - if ($res) { + if (!$res) { $this->createTemporaryQrcode($id, $type); $res = $this->getTemporaryQrcode($type, $id); } else if (empty($res['expire_seconds']) || $res['expire_seconds'] < time()) { diff --git a/crmeb/app/services/out/OutInterfaceServices.php b/crmeb/app/services/out/OutInterfaceServices.php index 1853b6975..0fe72d909 100644 --- a/crmeb/app/services/out/OutInterfaceServices.php +++ b/crmeb/app/services/out/OutInterfaceServices.php @@ -24,11 +24,13 @@ class OutInterfaceServices extends BaseServices { $rule = trim(strtolower($request->rule()->getRule())); $method = trim(strtolower($request->method())); - $authList = $this->dao->getColumn([['id', 'in', $request->outInfo()['rules']]], 'method,url'); + $authList = $this->dao->getColumn([['id', 'in', $request->outInfo()['rules']], ['type', '=', 1]], 'method,url'); $rolesAuth = []; foreach ($authList as $item) { $rolesAuth[trim(strtolower($item['method']))][] = trim(strtolower(str_replace(' ', '', $item['url']))); } + $rule = str_replace('<', '{', $rule); + $rule = str_replace('>', '}', $rule); if (in_array('/' . $rule, $rolesAuth[$method])) { return true; } else { diff --git a/crmeb/app/services/product/product/StoreProductServices.php b/crmeb/app/services/product/product/StoreProductServices.php index c6fded46d..6c7442b18 100644 --- a/crmeb/app/services/product/product/StoreProductServices.php +++ b/crmeb/app/services/product/product/StoreProductServices.php @@ -1368,7 +1368,7 @@ class StoreProductServices extends BaseServices /** @var StoreProductReplyServices $storeProductReplyService */ $storeProductReplyService = app()->make(StoreProductReplyServices::class); - $data['reply'] = get_thumb_water($storeProductReplyService->getRecProductReply($id), 'small', ['pics']); + $data['reply'] = get_thumb_water($storeProductReplyService->getRecProductReply($id), 'big', ['pics']); [$replyCount, $goodReply, $replyChance] = $storeProductReplyService->getProductReplyData($id); $data['replyChance'] = $replyChance; $data['replyCount'] = $replyCount; diff --git a/crmeb/app/services/system/admin/AdminAuthServices.php b/crmeb/app/services/system/admin/AdminAuthServices.php index 9eb847a62..1c0e447f3 100644 --- a/crmeb/app/services/system/admin/AdminAuthServices.php +++ b/crmeb/app/services/system/admin/AdminAuthServices.php @@ -43,7 +43,7 @@ class AdminAuthServices extends BaseServices * @return array * @throws \Psr\SimpleCache\InvalidArgumentException */ - public function parseToken(string $token,int $code = 110003): array + public function parseToken(string $token, int $code = 110003): array { /** @var CacheService $cacheService */ $cacheService = app()->make(CacheService::class); @@ -96,7 +96,7 @@ class AdminAuthServices extends BaseServices $this->authFailAfter($id, $type); throw new AuthException($code); } - if ($pwd !== md5($adminInfo->pwd)) { + if ($pwd !== '' && $pwd !== md5($adminInfo->pwd)) { throw new AuthException($code); } diff --git a/crmeb/app/services/user/UserBillServices.php b/crmeb/app/services/user/UserBillServices.php index abc1e162f..6461cef0d 100644 --- a/crmeb/app/services/user/UserBillServices.php +++ b/crmeb/app/services/user/UserBillServices.php @@ -408,8 +408,11 @@ class UserBillServices extends BaseServices * @param array $where_time * @param string $field * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException */ - public function getIntegralList(int $uid = 0, $where_time = [], string $field = '*') + public function getIntegralList(int $uid = 0, array $where_time = [], string $field = '*') { [$page, $limit] = $this->getPageValue(); $where = ['category' => 'integral'];