WIN-2308041133\Administrator 1 天之前
父節點
當前提交
4db60940ca
共有 1 個文件被更改,包括 14 次插入4 次删除
  1. 14 4
      app/admin/model/store/DeviceRepair.php

+ 14 - 4
app/admin/model/store/DeviceRepair.php

@@ -61,11 +61,21 @@ class DeviceRepair extends Model
      * @param int $uid
      * @return bool|string
      */
-    public static function getNewOrderId($uid = 0)
+//    public static function getNewOrderId($uid = 0)
+//    {
+//        if (!$uid) return false;
+//        $count = (int)self::where('uid', $uid)->where('add_time', '>=', strtotime(date("Y-m-d")))->where('add_time', '<', strtotime(date("Y-m-d", strtotime('+1 day'))))->count();
+//        return 'bx' . date('YmdHis', time()) . (10000 + $count + $uid);
+//    }
+
+    public static function getNewOrderId()
     {
-        if (!$uid) return false;
-        $count = (int)self::where('uid', $uid)->where('add_time', '>=', strtotime(date("Y-m-d")))->where('add_time', '<', strtotime(date("Y-m-d", strtotime('+1 day'))))->count();
-        return 'bx' . date('YmdHis', time()) . (10000 + $count + $uid);
+        do {
+            list($msec, $sec) = explode(' ', microtime());
+            $msectime = number_format((floatval($msec) + floatval($sec)) * 1000, 0, '', '');
+            $orderId = 'bx' . $msectime . mt_rand(10000, 99999);
+        } while (self::be(['order_id' => $orderId]));// $orderId = 'wx' . $msectime . mt_rand(10000, 99999);
+        return $orderId;
     }
     /**
      * 后台获取报修列表(带分页、状态筛选)