dever 3 gadi atpakaļ
vecāks
revīzija
ee250f4f15
3 mainītis faili ar 46 papildinājumiem un 3 dzēšanām
  1. 1 0
      app/shop/database/sell_order.php
  2. 44 2
      app/shop/lib/Cron.php
  3. 1 1
      app/shop/lib/Sell.php

+ 1 - 0
app/shop/database/sell_order.php

@@ -424,6 +424,7 @@ return array
             'option' => array
             (
                 'cdate' => array('yes', '>='),
+                'status' => 'yes',
                 'notice' => 'yes',
                 'note' => 'yes',
                 'state' => 1,

+ 44 - 2
app/shop/lib/Cron.php

@@ -11,9 +11,51 @@ class Cron
      *
      * @return mixed
      */
-    public function coupon()
+    public function coupon_api()
     {
-        
+        $coupon = Dever::db('shop/user_coupon')->getAll(array('status' => 1, 'edate' => time() - 86400));
+
+        if ($coupon && Dever::project('message')) {
+            foreach ($coupon as $k => $v) {
+                $coupon_info = Dever::db('goods/coupon')->find($v['coupon_id']);
+                $msg = $coupon_info['name'] . ",要到期啦!";
+                $msg_param['type'] = 2;//消息类型2是优惠券
+                $msg_param['id'] = $v['id'];
+                $msg_param['coupon_id'] = $v['coupon_id'];
+                $msg_param = Dever::json_encode($msg_param);
+                Dever::load('message/lib/data')->push(-1, $v['uid'], '优惠劵到期提醒', $msg, 2, 1, false, $msg_param);
+            }
+        }
+    }
+
+    /**
+     * 处理待支付订单提醒
+     *
+     * @return mixed
+     */
+    public function order_api()
+    {
+        # 获取超过5分钟未支付的订单
+        $time = time();
+        $where['status'] = 1;
+        $where['cdate'] = $time + 300;
+        $order = Dever::db('shop/sell_order')->getDataByTime($where);
+
+        if ($order && Dever::project('message')) {
+            foreach ($order as $k => $v) {
+                if ($time - $v['cdate'] >= 900) {
+                    Dever::db('shop/sell_order')->update(array('where_id' => $v['id'], 'status' => 11));
+                } else {
+                    $msg = "您有一笔待付款订单,请及时付款。\r\n订单15分钟内未付款自动取消~";
+                    $shop = Dever::db('shop/info')->one($v['shop_id']);
+                    $msg_param['type'] = 1;//消息类型1是订单消息
+                    $msg_param['id'] = $v['id'];
+                    $msg_param['name'] = $shop['name'];
+                    $msg_param = Dever::json_encode($msg_param);
+                    Dever::load('message/lib/data')->push(-1, $v['uid'], '订单待支付提醒', $msg, 2, 1, false, $msg_param);
+                }
+            }
+        }
     }
 
     /**

+ 1 - 1
app/shop/lib/Sell.php

@@ -143,7 +143,7 @@ class Sell
     {
         if ($info['status'] == 1) {
             # 15分钟内支付,900秒
-            $m = 9000;
+            $m = 900;
             # 支付倒计时
             $info['time'] = time() - $info['cdate'];
             if ($info['time'] >= $m) {