Merge branch 'v4.7.0dev' of https://gitee.com/ZhongBangKeJi/CRMEB into v4.7.0dev

This commit is contained in:
From-wh 2023-02-20 11:42:33 +08:00
commit 679af7a76f
12 changed files with 70 additions and 50 deletions

View File

@ -106,10 +106,7 @@ class StoreSeckill extends AuthController
$storeProductAttrValueServices = app()->make(StoreProductAttrValueServices::class);
$unique = $storeProductAttrValueServices->value(['product_id' => $id, 'type' => 1], 'unique');
if ($unique) {
$name = 'seckill_' . $unique . '_1';
/** @var CacheService $cache */
$cache = app()->make(CacheService::class);
$cache->del($name);
CacheService::delete('seckill_' . $unique . '_1');
}
return app('json')->success(100002);
}

View File

@ -19,8 +19,12 @@ class SystemTimer implements ListenerInterface
{
public function handle($event): void
{
new Crontab('*/6 * * * * *', function () {
file_put_contents(root_path() . 'runtime/.timer', time());
$time = time();
$date = date('Y-m-d H:i:s', time());
$timer_log_open = config("log.timer_log", false);
new Crontab('*/6 * * * * *', function () use ($time) {
file_put_contents(root_path() . 'runtime/.timer', $time);
});
/** @var SystemTimerServices $systemTimerServices */
@ -31,11 +35,12 @@ class SystemTimer implements ListenerInterface
$timeStr = $this->getTimerStr($item);
//未支付自动取消订单
if ($item['mark'] == 'order_cancel') {
new Crontab($timeStr, function () {
new Crontab($timeStr, function () use ($date, $timer_log_open) {
try {
/** @var StoreOrderServices $orderServices */
$orderServices = app()->make(StoreOrderServices::class);
$orderServices->orderUnpaidCancel();
if ($timer_log_open) Log::notice($date . ' 执行未支付自动取消订单');
} catch (\Throwable $e) {
Log::error('自动取消订单失败,失败原因:' . $e->getMessage());
}
@ -43,11 +48,12 @@ class SystemTimer implements ListenerInterface
}
//拼团到期订单处理
if ($item['mark'] == 'pink_expiration') {
new Crontab($timeStr, function () {
new Crontab($timeStr, function () use ($date, $timer_log_open) {
try {
/** @var StorePinkServices $storePinkServices */
$storePinkServices = app()->make(StorePinkServices::class);
$storePinkServices->statusPink();
if ($timer_log_open) Log::notice($date . ' 执行拼团到期订单处理');
} catch (\Throwable $e) {
Log::error('拼团到期订单处理失败,失败原因:' . $e->getMessage());
}
@ -55,11 +61,12 @@ class SystemTimer implements ListenerInterface
}
//自动解绑上级绑定
if ($item['mark'] == 'agent_unbind') {
new Crontab($timeStr, function () {
new Crontab($timeStr, function () use ($date, $timer_log_open) {
try {
/** @var AgentManageServices $agentManage */
$agentManage = app()->make(AgentManageServices::class);
$agentManage->removeSpread();
if ($timer_log_open) Log::notice($date . ' 执行自动解绑上级绑定');
} catch (\Throwable $e) {
Log::error('自动解除上级绑定失败,失败原因:' . $e->getMessage());
}
@ -67,11 +74,12 @@ class SystemTimer implements ListenerInterface
}
//更新直播商品状态
if ($item['mark'] == 'live_product_status') {
new Crontab($timeStr, function () {
new Crontab($timeStr, function () use ($date, $timer_log_open) {
try {
/** @var LiveGoodsServices $liveGoods */
$liveGoods = app()->make(LiveGoodsServices::class);
$liveGoods->syncGoodStatus();
if ($timer_log_open) Log::notice($date . ' 执行更新直播商品状态');
} catch (\Throwable $e) {
Log::error('更新直播商品状态失败,失败原因:' . $e->getMessage());
}
@ -79,11 +87,12 @@ class SystemTimer implements ListenerInterface
}
//更新直播间状态
if ($item['mark'] == 'live_room_status') {
new Crontab($timeStr, function () {
new Crontab($timeStr, function () use ($date, $timer_log_open) {
try {
/** @var LiveRoomServices $liveRoom */
$liveRoom = app()->make(LiveRoomServices::class);
$liveRoom->syncRoomStatus();
if ($timer_log_open) Log::notice($date . ' 执行更新直播间状态');
} catch (\Throwable $e) {
Log::error('更新直播间状态失败,失败原因:' . $e->getMessage());
}
@ -91,11 +100,12 @@ class SystemTimer implements ListenerInterface
}
//自动收货
if ($item['mark'] == 'take_delivery') {
new Crontab($timeStr, function () {
new Crontab($timeStr, function () use ($date, $timer_log_open) {
try {
/** @var StoreOrderTakeServices $services */
$services = app()->make(StoreOrderTakeServices::class);
$services->autoTakeOrder();
if ($timer_log_open) Log::notice($date . ' 执行自动收货');
} catch (\Throwable $e) {
Log::error('自动收货失败,失败原因:' . $e->getMessage());
}
@ -103,11 +113,12 @@ class SystemTimer implements ListenerInterface
}
//查询预售到期商品自动下架
if ($item['mark'] == 'advance_off') {
new Crontab($timeStr, function () {
new Crontab($timeStr, function () use ($date, $timer_log_open) {
try {
/** @var StoreProductServices $product */
$product = app()->make(StoreProductServices::class);
$product->downAdvance();
if ($timer_log_open) Log::notice($date . ' 执行预售到期商品自动下架');
} catch (\Throwable $e) {
Log::error('预售到期商品自动下架失败,失败原因:' . $e->getMessage());
}
@ -115,11 +126,12 @@ class SystemTimer implements ListenerInterface
}
//自动好评
if ($item['mark'] == 'product_replay') {
new Crontab($timeStr, function () {
new Crontab($timeStr, function () use ($date, $timer_log_open) {
try {
/** @var StoreOrderServices $orderServices */
$orderServices = app()->make(StoreOrderServices::class);
$orderServices->autoComment();
if ($timer_log_open) Log::notice($date . ' 执行自动好评');
} catch (\Throwable $e) {
Log::error('自动好评失败,失败原因:' . $e->getMessage());
}
@ -127,11 +139,12 @@ class SystemTimer implements ListenerInterface
}
//清除昨日海报
if ($item['mark'] == 'clear_poster') {
new Crontab($timeStr, function () {
new Crontab($timeStr, function () use ($date, $timer_log_open) {
try {
/** @var SystemAttachmentServices $attach */
$attach = app()->make(SystemAttachmentServices::class);
$attach->emptyYesterdayAttachment();
if ($timer_log_open) Log::notice($date . ' 执行清除昨日海报');
} catch (\Throwable $e) {
Log::error('清除昨日海报失败,失败原因:' . $e->getMessage());
}
@ -141,13 +154,13 @@ class SystemTimer implements ListenerInterface
}
/**
* 0 1 2 3 4 5
| | | | | |
| | | | | +------ day of week (0 - 6) (Sunday=0)
| | | | +------ month (1 - 12)
| | | +-------- day of month (1 - 31)
| | +---------- hour (0 - 23)
| +------------ min (0 - 59)
+-------------- sec (0-59)[可省略,如果没有0位,则最小时间粒度是分钟]
* | | | | | |
* | | | | | +------ day of week (0 - 6) (Sunday=0)
* | | | | +------ month (1 - 12)
* | | | +-------- day of month (1 - 31)
* | | +---------- hour (0 - 23)
* | +------------ min (0 - 59)
* +-------------- sec (0-59)[可省略,如果没有0位,则最小时间粒度是分钟]
*/
/**
* 获取定时任务时间表达式

View File

@ -256,7 +256,7 @@ class AgentLevelServices extends BaseServices
*/
public function createForm()
{
$field[] = Form::input('name', '等级名称')->col(24);
$field[] = Form::input('name', '等级名称')->maxlength(8)->col(24);
$field[] = Form::number('grade', '等级', 0)->min(0)->precision(0);
$field[] = Form::frameImage('image', '背景图', Url::buildUrl('admin/widget.images/index', array('fodder' => 'image')))->icon('ios-add')->width('950px')->height('505px')->modal(['footer-hide' => true]);
$field[] = Form::number('one_brokerage', '一级上浮', 0)->info('在分销一级佣金基础上浮(0-1000之间整数)百分比')->min(0)->max(1000)->precision(0);
@ -278,7 +278,7 @@ class AgentLevelServices extends BaseServices
throw new AdminException(100026);
$field = [];
$field[] = Form::hidden('id', $id);
$field[] = Form::input('name', '等级名称', $levelInfo['name'])->col(24);
$field[] = Form::input('name', '等级名称', $levelInfo['name'])->maxlength(8)->col(24);
$field[] = Form::number('grade', '等级', $levelInfo['grade'])->min(0)->precision(0);
$field[] = Form::frameImage('image', '背景图', Url::buildUrl('admin/widget.images/index', array('fodder' => 'image')), $levelInfo['image'])->icon('ios-add')->width('950px')->height('505px')->modal(['footer-hide' => true]);
$field[] = Form::number('one_brokerage', '一级上浮', $levelInfo['one_brokerage'])->info('在分销一级佣金基础上浮(0-1000之间整数)百分比')->min(0)->max(1000)->precision(0);

View File

@ -82,11 +82,6 @@ class StoreOrderComputedServices extends BaseServices
$offlinePayStatus = (int)sys_config('offline_pay_status') ?? (int)2;
$systemPayType = PayServices::PAY_TYPE;
if ($offlinePayStatus == 2) unset($systemPayType['offline']);
if (strtolower($payType) != 'pc' && strtolower($payType) != 'friend') {
if (!array_key_exists($payType, $systemPayType)) {
throw new ApiException(410241);
}
}
if (!$userInfo) {
/** @var UserServices $userServices */
$userServices = app()->make(UserServices::class);

View File

@ -95,7 +95,7 @@ class StoreCategoryServices extends BaseServices
$where = [];
if ($show !== '') $where['is_show'] = $show;
if (!$type) $where['pid'] = 0;
$data = get_tree_children($this->dao->getTierList($where, ['id as value', 'cate_name as label', 'pid']), 'children', 'value');
$data = get_tree_children($this->dao->getTierList($where, ['id', 'cate_name as title', 'pid']), 'children', 'id');
foreach ($data as &$item) {
if (!isset($item['children'])) {
$item['disabled'] = true;

View File

@ -13,6 +13,7 @@ use app\services\order\StoreOrderTakeServices;
use app\services\product\product\StoreProductServices;
use app\services\system\attachment\SystemAttachmentServices;
use crmeb\exceptions\AdminException;
use think\facade\Log;
class SystemTimerServices extends BaseServices
{
@ -204,40 +205,52 @@ class SystemTimerServices extends BaseServices
*/
public function timerRun()
{
file_put_contents(root_path() . 'runtime/.timer', time()); //检测定时任务是否正常
$time = time();
$date = date('Y-m-d H:i:s', time());
$timer_log_open = config("log.timer_log", false);
file_put_contents(root_path() . 'runtime/.timer', $time); //检测定时任务是否正常
$list = $this->dao->selectList(['is_open' => 1, 'is_del' => 0])->toArray();
foreach ($list as $item) {
if ($item['next_execution_time'] < time()) {
if ($item['next_execution_time'] < $time) {
if ($item['mark'] == 'order_cancel') {
//未支付自动取消订单
app()->make(StoreOrderServices::class)->orderUnpaidCancel();
if($timer_log_open) Log::notice($date . ' 执行未支付自动取消订单');
} elseif ($item['mark'] == 'pink_expiration') {
//拼团到期订单处理
app()->make(StorePinkServices::class)->statusPink();
if($timer_log_open) Log::notice($date . ' 执行拼团到期订单处理');
} elseif ($item['mark'] == 'agent_unbind') {
//自动解绑上级绑定
app()->make(AgentManageServices::class)->removeSpread();
if($timer_log_open) Log::notice($date . ' 执行自动解绑上级绑定');
} elseif ($item['mark'] == 'live_product_status') {
//更新直播商品状态
app()->make(LiveGoodsServices::class)->syncGoodStatus();
if($timer_log_open) Log::notice($date . ' 执行更新直播商品状态');
} elseif ($item['mark'] == 'live_room_status') {
//更新直播间状态
app()->make(LiveRoomServices::class)->syncRoomStatus();
if($timer_log_open) Log::notice($date . ' 执行更新直播间状态');
} elseif ($item['mark'] == 'take_delivery') {
//自动收货
app()->make(StoreOrderTakeServices::class)->autoTakeOrder();
if($timer_log_open) Log::notice($date . ' 执行自动收货');
} elseif ($item['mark'] == 'advance_off') {
//查询预售到期商品自动下架
app()->make(StoreProductServices::class)->downAdvance();
if($timer_log_open) Log::notice($date . ' 执行预售到期商品自动下架');
} elseif ($item['mark'] == 'product_replay') {
//自动好评
app()->make(StoreOrderServices::class)->autoComment();
if($timer_log_open) Log::notice($date . ' 执行自动好评');
} elseif ($item['mark'] == 'clear_poster') {
//清除昨日海报
app()->make(SystemAttachmentServices::class)->emptyYesterdayAttachment();
if($timer_log_open) Log::notice($date . ' 执行清除昨日海报');
}
//写入本次执行时间和下次执行时间
$this->dao->update(['mark' => $item['mark']], ['last_execution_time' => time(), 'next_execution_time' => $this->getTimerCycleTime($item)]);
$this->dao->update(['mark' => $item['mark']], ['last_execution_time' => $time, 'next_execution_time' => $this->getTimerCycleTime($item)]);
}
}
}

View File

@ -24,6 +24,8 @@ return [
'success_log' => false,
//是否开启业务失败日志
'fail_log' => false,
//是否开启定时任务日志
'timer_log' => false,
// 日志通道列表
'channels' => [
'file' => [

View File

@ -126,17 +126,17 @@ class Cos extends BaseUpload
if (!$isStream) {
$fileHandle = app()->request->file($file);
if (!$fileHandle) {
return $this->setError('Upload file does not exist');
return $this->setError('上传的文件不存在');
}
if ($this->validate) {
if (!in_array(pathinfo($fileHandle->getOriginalName(), PATHINFO_EXTENSION), $this->validate['fileExt'])) {
return $this->setError('Upload fileExt error');
return $this->setError('不合法的文件后缀');
}
if (filesize($fileHandle) > $this->validate['filesize']) {
return $this->setError('Upload filesize error');
return $this->setError('文件过大');
}
if (!in_array($fileHandle->getOriginalMime(), $this->validate['fileMime'])) {
return $this->setError('Upload fileMine error');
return $this->setError('不合法的文件类型');
}
}
$key = $this->saveFileName($fileHandle->getRealPath(), $fileHandle->getOriginalExtension());

View File

@ -113,17 +113,17 @@ class Local extends BaseUpload
{
$fileHandle = app()->request->file($file);
if (!$fileHandle) {
return $this->setError('Upload file does not exist');
return $this->setError('上传的文件不存在');
}
if ($this->validate) {
if (!in_array(pathinfo($fileHandle->getOriginalName(), PATHINFO_EXTENSION), $this->validate['fileExt'])) {
return $this->setError('Upload fileExt error');
return $this->setError('不合法的文件后缀');
}
if (filesize($fileHandle) > $this->validate['filesize']) {
return $this->setError('Upload filesize error');
return $this->setError('文件过大');
}
if (!in_array($fileHandle->getOriginalMime(), $this->validate['fileMime'])) {
return $this->setError('Upload fileMine error');
return $this->setError('不合法的文件类型');
}
}
if ($realName) {

View File

@ -121,17 +121,17 @@ class Oss extends BaseUpload
{
$fileHandle = app()->request->file($file);
if (!$fileHandle) {
return $this->setError('Upload file does not exist');
return $this->setError('上传的文件不存在');
}
if ($this->validate) {
if (!in_array(pathinfo($fileHandle->getOriginalName(), PATHINFO_EXTENSION), $this->validate['fileExt'])) {
return $this->setError('Upload fileExt error');
return $this->setError('不合法的文件后缀');
}
if (filesize($fileHandle) > $this->validate['filesize']) {
return $this->setError('Upload filesize error');
return $this->setError('文件过大');
}
if (!in_array($fileHandle->getOriginalMime(), $this->validate['fileMime'])) {
return $this->setError('Upload fileMine error');
return $this->setError('不合法的文件类型');
}
}
$key = $this->saveFileName($fileHandle->getRealPath(), $fileHandle->getOriginalExtension());

View File

@ -117,17 +117,17 @@ class Qiniu extends BaseUpload
{
$fileHandle = app()->request->file($file);
if (!$fileHandle) {
return $this->setError('Upload file does not exist');
return $this->setError('上传的文件不存在');
}
if ($this->validate) {
if (!in_array(pathinfo($fileHandle->getOriginalName(), PATHINFO_EXTENSION), $this->validate['fileExt'])) {
return $this->setError('Upload fileExt error');
return $this->setError('不合法的文件后缀');
}
if (filesize($fileHandle) > $this->validate['filesize']) {
return $this->setError('Upload filesize error');
return $this->setError('文件过大');
}
if (!in_array($fileHandle->getOriginalMime(), $this->validate['fileMime'])) {
return $this->setError('Upload fileMine error');
return $this->setError('不合法的文件类型');
}
}
$key = $this->saveFileName($fileHandle->getRealPath(), $fileHandle->getOriginalExtension());

View File

@ -10,7 +10,7 @@
<view class='text acea-row row-between'>
<view class='name line2'>{{item.productInfo.store_name}}</view>
<view class='money'>
<view>{{$t(`¥`)}}{{item.truePrice}}</view>
<view>{{$t(`¥`)}}{{(parseFloat(item.truePrice)+parseFloat(item.postage_price)).toFixed(2)}}</view>
<view class='num'>x{{item.cart_num}}</view>
</view>
</view>