Просмотр исходного кода

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

liaofei 2 лет назад
Родитель
Сommit
8c81f353ef

+ 1 - 1
crmeb/app/event.php

@@ -38,7 +38,7 @@ 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],//定时任务事件
+        'Crontab' => [\app\listener\crontab\SystemCrontab::class],//定时任务事件
     ],
 ];
 

+ 214 - 0
crmeb/app/listener/crontab/SystemCrontab.php

@@ -0,0 +1,214 @@
+<?php
+
+namespace app\listener\crontab;
+
+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 SystemCrontab implements ListenerInterface
+{
+    public function handle($event): void
+    {
+        $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 */
+        $systemTimerServices = app()->make(SystemTimerServices::class);
+        $list = $systemTimerServices->selectList(['is_del' => 0, 'is_open' => 1])->toArray();
+        foreach ($list as &$item) {
+            //获取定时任务时间字符串
+            $timeStr = $this->getTimerStr($item);
+            //未支付自动取消订单
+            if ($item['mark'] == 'order_cancel') {
+                new Crontab($timeStr, function () use ($date, $timer_log_open) {
+                    try {
+                        /** @var StoreOrderServices $orderServices */
+                        $orderServices = app()->make(StoreOrderServices::class);
+                        $orderServices->orderUnpaidCancel();
+                        $this->crontabLog(' 执行未支付自动取消订单');
+                    } catch (\Throwable $e) {
+                        Log::error('自动取消订单失败,失败原因:' . $e->getMessage());
+                    }
+                });
+            }
+            //拼团到期订单处理
+            if ($item['mark'] == 'pink_expiration') {
+                new Crontab($timeStr, function () use ($date, $timer_log_open) {
+                    try {
+                        /** @var StorePinkServices $storePinkServices */
+                        $storePinkServices = app()->make(StorePinkServices::class);
+                        $storePinkServices->statusPink();
+                        $this->crontabLog(' 执行拼团到期订单处理');
+                    } catch (\Throwable $e) {
+                        Log::error('拼团到期订单处理失败,失败原因:' . $e->getMessage());
+                    }
+                });
+            }
+            //自动解绑上级绑定
+            if ($item['mark'] == 'agent_unbind') {
+                new Crontab($timeStr, function () use ($date, $timer_log_open) {
+                    try {
+                        /** @var AgentManageServices $agentManage */
+                        $agentManage = app()->make(AgentManageServices::class);
+                        $agentManage->removeSpread();
+                        $this->crontabLog(' 执行自动解绑上级绑定');
+                    } catch (\Throwable $e) {
+                        Log::error('自动解除上级绑定失败,失败原因:' . $e->getMessage());
+                    }
+                });
+            }
+            //更新直播商品状态
+            if ($item['mark'] == 'live_product_status') {
+                new Crontab($timeStr, function () use ($date, $timer_log_open) {
+                    try {
+                        /** @var LiveGoodsServices $liveGoods */
+                        $liveGoods = app()->make(LiveGoodsServices::class);
+                        $liveGoods->syncGoodStatus();
+                        $this->crontabLog(' 执行更新直播商品状态');
+                    } catch (\Throwable $e) {
+                        Log::error('更新直播商品状态失败,失败原因:' . $e->getMessage());
+                    }
+                });
+            }
+            //更新直播间状态
+            if ($item['mark'] == 'live_room_status') {
+                new Crontab($timeStr, function () use ($date, $timer_log_open) {
+                    try {
+                        /** @var LiveRoomServices $liveRoom */
+                        $liveRoom = app()->make(LiveRoomServices::class);
+                        $liveRoom->syncRoomStatus();
+                        $this->crontabLog(' 执行更新直播间状态');
+
+                    } catch (\Throwable $e) {
+                        Log::error('更新直播间状态失败,失败原因:' . $e->getMessage());
+                    }
+                });
+            }
+            //自动收货
+            if ($item['mark'] == 'take_delivery') {
+                new Crontab($timeStr, function () use ($date, $timer_log_open) {
+                    try {
+                        /** @var StoreOrderTakeServices $services */
+                        $services = app()->make(StoreOrderTakeServices::class);
+                        $services->autoTakeOrder();
+                        $this->crontabLog(' 执行自动收货');
+                    } catch (\Throwable $e) {
+                        Log::error('自动收货失败,失败原因:' . $e->getMessage());
+                    }
+                });
+            }
+            //查询预售到期商品自动下架
+            if ($item['mark'] == 'advance_off') {
+                new Crontab($timeStr, function () use ($date, $timer_log_open) {
+                    try {
+                        /** @var StoreProductServices $product */
+                        $product = app()->make(StoreProductServices::class);
+                        $product->downAdvance();
+                        $this->crontabLog(' 执行预售到期商品自动下架');
+                    } catch (\Throwable $e) {
+                        Log::error('预售到期商品自动下架失败,失败原因:' . $e->getMessage());
+                    }
+                });
+            }
+            //自动好评
+            if ($item['mark'] == 'product_replay') {
+                new Crontab($timeStr, function () use ($date, $timer_log_open) {
+                    try {
+                        /** @var StoreOrderServices $orderServices */
+                        $orderServices = app()->make(StoreOrderServices::class);
+                        $orderServices->autoComment();
+                        $this->crontabLog(' 执行自动好评');
+                    } catch (\Throwable $e) {
+                        Log::error('自动好评失败,失败原因:' . $e->getMessage());
+                    }
+                });
+            }
+            //清除昨日海报
+            if ($item['mark'] == 'clear_poster') {
+                new Crontab($timeStr, function () use ($date, $timer_log_open) {
+                    try {
+                        /** @var SystemAttachmentServices $attach */
+                        $attach = app()->make(SystemAttachmentServices::class);
+                        $attach->emptyYesterdayAttachment();
+                        $this->crontabLog(' 执行清除昨日海报');
+                    } catch (\Throwable $e) {
+                        Log::error('清除昨日海报失败,失败原因:' . $e->getMessage());
+                    }
+                });
+            }
+        }
+    }
+
+    /** 定时任务日志
+     * @param $msg
+     */
+    public function crontabLog($msg)
+    {
+        $timer_log_open = config("log.timer_log", false);
+        if ($timer_log_open){
+            $date = date('Y-m-d H:i:s', time());
+            Log::notice($date . ' 执行清除昨日海报');
+        }
+    }
+    /**
+     *  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位,则最小时间粒度是分钟]
+     */
+    /**
+     * 获取定时任务时间表达式
+     * @param $data
+     * @return string
+     */
+    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 ' . $data['minute'] . ' */' . $data['hour'] . ' * * *';
+                break;
+            case 4:// 每隔几日第几小时第几分钟执行
+                $timeStr = '0 ' . $data['minute'] . ' ' . $data['hour'] . ' */' . $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;
+    }
+}

+ 1 - 1
crmeb/app/services/user/UserServices.php

@@ -1632,7 +1632,7 @@ class UserServices extends BaseServices
                 $check = true;
             }
         }
-        if ($userInfo['uid'] == $spreadUid || $userInfo['spread_uid'] == $userSpreadUid) $check = false;
+        if ($userInfo['uid'] == $spreadUid || $userInfo['uid'] == $userSpreadUid) $check = false;
         if ($check) {
             $spreadInfo = $this->dao->get($spreadUid, ['division_id', 'agent_id', 'staff_id']);
             $data = [];

+ 1 - 1
crmeb/crmeb/command/Timer.php

@@ -62,7 +62,7 @@ class Timer extends Command
         date_default_timezone_set('PRC');
         $task->count = 1;
         $task->onWorkerStart = function () {
-            event('SystemTimer');
+            event('Crontab');
         };
         $task->runAll();
     }

+ 1 - 1
crmeb/crmeb/services/app/WechatService.php

@@ -80,7 +80,7 @@ class WechatService
         ];
         if (isset($wechat['wechat_encode']) && (int)$wechat['wechat_encode'] > 0 && isset($wechat['wechat_encodingaeskey']) && !empty($wechat['wechat_encodingaeskey']))
             $config['aes_key'] = $wechat['wechat_encodingaeskey'];
-        if (isset($payment['pay_weixin_open']) && $payment['pay_weixin_open'] == 1) {
+        if (isset($payment['pay_weixin_open']) && $payment['pay_weixin_open'] == 'weixin') {
             $config['payment'] = [
                 'app_id' => $appId,
                 'merchant_id' => trim($payment['pay_weixin_mchid']),

Разница между файлами не показана из-за своего большого размера
+ 315 - 311
crmeb/public/install/crmeb.sql


+ 2 - 2
template/uni-app/components/payment/index.vue

@@ -265,7 +265,7 @@
 								let data = res.data;
 								if (data.status == "WECHAT_H5_PAY") {
 									uni.hideLoading();
-									location.replace(data.result.jsConfig.mweb_url);
+									location.replace(data.result.jsConfig.h5_url);
 									return that.$util.Tips({
 										title: that.$t(`支付成功`),
 										icon: 'success'
@@ -563,4 +563,4 @@
 	.icon-haoyoudaizhifu {
 		color: #F34C3E !important;
 	}
-</style>
+</style>

+ 1 - 1
template/uni-app/pages/annex/offline_pay/index.vue

@@ -322,7 +322,7 @@
 						uni.showToast({
 							title: res.msg,
 							success() {
-								location.href = jsConfig.mweb_url;
+								location.href = jsConfig.h5_url;
 							}
 						});
 						break;

+ 4 - 4
template/uni-app/pages/annex/vip_paid/index.vue

@@ -225,8 +225,8 @@
 				toLogin();
 			}
 		},
-		onShow() {
-			this.payClose();
+		onShow() {
+			this.payClose();
 			let options = wx.getEnterOptionsSync();
 			if (options.scene == '1038' && options.referrerInfo.appId == 'wxef277996acc166c3' && this.initIn) {
 				// 代表从收银台小程序返回
@@ -669,7 +669,7 @@
 						uni.showToast({
 							title: data.msg,
 							success() {
-								location.href = jsConfig.mweb_url;
+								location.href = jsConfig.h5_url;
 							}
 						});
 						break;
@@ -1280,4 +1280,4 @@
 			color: #FFFFFF;
 		}
 	}
-</style>
+</style>

+ 4 - 4
template/uni-app/pages/goods/cashier/index.vue

@@ -94,7 +94,7 @@
 				orderId: 0,
 				fromType: '',
 				active: 0,
-				payPrice: 0,
+				payPrice: 0,
 				payPriceShow: 0,
 				payPostage: 0,
 				offlinePostage: false,
@@ -506,14 +506,14 @@
 						case "WECHAT_H5_PAY":
 							uni.hideLoading();
 							that.$util.Tips({
-								title: that.$t(`订单创建成功`)
+								title: that.$t(`等待支付中`)
 							}, {
 								tab: 4,
 								url: goPages + '&status=0'
 							});
 							setTimeout(() => {
-								location.href = res.data.result.jsConfig.mweb_url;
-							}, 2000);
+								location.href = res.data.result.jsConfig.h5_url;
+							}, 1500);
 							break;
 
 						case 'ALIPAY_PAY':

+ 4 - 4
template/uni-app/pages/goods/order_confirm/index.vue

@@ -1206,7 +1206,7 @@
 					// 			url: goPages + '&status=0'
 					// 		});
 					// 		setTimeout(() => {
-					// 			location.href = res.data.result.jsConfig.mweb_url;
+					// 			location.href = res.data.result.jsConfig.h5_url;
 					// 		}, 2000);
 					// 		break;
 
@@ -1670,7 +1670,7 @@
 		height: 135rpx;
 		border-radius: 3rpx;
 		margin-top: 30rpx;
-		padding: 25rpx 28rpx;
+		padding: 25rpx 28rpx;
 		font-size: 28rpx;
 		box-sizing: border-box;
 	}
@@ -1761,7 +1761,7 @@
 		box-sizing: border-box;
 		position: fixed;
 		left: 0;
-		bottom: 0;
+		bottom: 0;
 		padding: 15rpx 30rpx;
 		padding-bottom: calc(15rpx + constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
 		padding-bottom: calc(15rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
@@ -1822,4 +1822,4 @@
 	.fontC {
 		color: grey;
 	}
-</style>
+</style>

+ 1 - 5
template/uni-app/pages/goods/order_pay_status/index.vue

@@ -146,12 +146,8 @@
 				deep: true
 			}
 		},
-		onLoad: function(options) {
+		onLoad(options) {
 			this.options = options
-			console.log(options, 'options')
-			uni.setNavigationBarTitle({
-				title: ''
-			});
 			if (!options.order_id) return this.$util.Tips({
 				title: this.$t(`缺少参数无法查看订单支付状态`)
 			}, {

+ 0 - 2
template/uni-app/pages/goods_cate/goods_cate1.vue

@@ -113,7 +113,6 @@
 			})
 		},
 		mounted() {
-			console.log(this.version)
 			let that = this
 			// #ifdef H5
 			uni.getSystemInfo({
@@ -187,7 +186,6 @@
 			},
 			getAllCategory: function() {
 				let that = this;
-				console.log(this.version, '1', uni.getStorageSync('CAT_VERSION'))
 				if (this.isNew || !uni.getStorageSync('CAT1_DATA')) {
 					getCategoryList().then(res => {
 						uni.setStorageSync('CAT1_DATA', res.data)

+ 6 - 4
template/uni-app/pages/user/index.vue

@@ -59,9 +59,9 @@
 								</view>
 								<!-- #endif -->
 								<!-- #ifdef H5 -->
-								<view class="name" v-if="!userInfo.uid && isWeixin" @click="openAuto"
+								<view class="name" v-if="!userInfo.uid" @click="openAuto"
 									style="height: 100%; display: flex; align-items: center;">
-									{{$t('请点击授权')}}
+									{{$t(isWeixin ? '请点击授权' : '请点击登录')}}
 								</view>
 								<!-- #endif -->
 								<view class="name" v-if="userInfo.uid">
@@ -1008,9 +1008,11 @@
 							align-items: center;
 							color: #fff;
 							font-size: 31rpx;
-							.nickname{
-								max-width: 8em;
+
+							.nickname {
+								max-width: 8em;
 							}
+
 							.vip {
 								margin-left: 10rpx;
 

+ 1 - 4
template/uni-app/pages/users/user_payment/index.vue

@@ -404,11 +404,8 @@
 
 						case "WECHAT_H5_PAY":
 							uni.hideLoading();
-							that.$util.Tips({
-								title: that.$t(`订单创建成功`)
-							});
 							setTimeout(() => {
-								location.href = res.data.result.jsConfig.mweb_url;
+								location.href = res.data.result.jsConfig.h5_url;
 							}, 2000);
 							break;