Browse Source

餐饮单品半价

gorden 6 months ago
parent
commit
b2f4c5eca7

+ 1 - 1
app/admin/controller/order/DishesController.php

@@ -149,7 +149,7 @@ class DishesController extends Curd{
             $item['sheet'] = $item['sheets'][0] ?? [];
             if (!empty($item['sheet'])) {
                 $goods = Goods::where('goods_id', $item['sheet']['join_sheet_goods_id'])->first();
-                if(count($item['sheets']) > 1 && $goods->goods_classify == 'MEALS'){
+                if(count($item['sheets']) > 1 && $goods && $goods->goods_classify == 'MEALS'){
                     $sheetDeng = ' 等餐品';
                 }
                 $item['sheet']['goods_name'] = ($goods && $goods->goods_name) ? $goods->goods_name.$sheetDeng : '';

+ 21 - 0
app/admin/service/coupon/CouponService.php

@@ -0,0 +1,21 @@
+<?php
+
+namespace app\admin\service\coupon;
+
+use app\model\CouponDetail;
+use support\Db;
+
+class CouponService
+{
+    public static function checkCouponExpired()
+    {
+        $couponDetails = Db::select("select * from app_coupon_detail where cast(UNIX_TIMESTAMP('coupon_detail_deadline_datetime') as SIGNED) < ".time());
+        dump($couponDetails);
+        foreach ($couponDetails as $detail){
+            $endTimeUnix = strtotime($detail->coupon_detail_deadline_datetime);
+            if ($endTimeUnix < time()){
+                CouponDetail::where('join_detail_coupon_id',$detail->$detail)->update(['coupon_detail_status'=>'EXPIRED']);
+            }
+        }
+    }
+}

+ 4 - 0
process/Task.php

@@ -4,6 +4,7 @@ namespace process;
 
 use app\admin\controller\notify\RechargeController;
 use app\admin\service\client\MessageService;
+use app\admin\service\coupon\CouponService;
 use app\admin\service\goods\GoodsService;
 use app\admin\service\order\OrderService;
 use app\admin\service\order\PayDetailService;
@@ -28,6 +29,9 @@ class Task
 
             // 会员消息 30分钟未读,发送站内信
             MessageService::unreadChatMessage();
+
+            // 优惠券自动过期
+//            CouponService::checkCouponExpired();
         });
 
         // 每天的2点执行,注意这里省略了秒位