|
@@ -19,17 +19,45 @@ class OrderService
|
|
|
*/
|
|
|
public static function AutomaticReceipt()
|
|
|
{
|
|
|
- $redis = Redis::connection();
|
|
|
- $key = Order::AUTOMATIC_RECEIPT_PREFIX . date('Ymd');
|
|
|
- if (!$redis->exists($key)) {
|
|
|
- return;
|
|
|
+ try {
|
|
|
+ Db::beginTransaction();
|
|
|
+ $timeUnix = strtotime("-7 days");
|
|
|
+ $orders = Order::where('order_status_system', 'SIGNED')
|
|
|
+ ->where('order_addtimes', '<', $timeUnix)
|
|
|
+ ->get();
|
|
|
+ foreach ($orders as $order) {
|
|
|
+ // 订单主表
|
|
|
+ Order::where('order_id', $order->order_id)->update([
|
|
|
+ 'order_is_complete' => 'Y',
|
|
|
+ 'order_status_system' => 'CONFIRM'
|
|
|
+ ]);
|
|
|
+ // 订单详情表
|
|
|
+ OrderSheet::where('join_sheet_order_id', $order->order_id)->update(['order_sheet_status' => 'CONFIRM']);
|
|
|
+ }
|
|
|
+ Db::commit();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ Db::rollBack();
|
|
|
}
|
|
|
- Db::beginTransaction();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function checkPayingOrder()
|
|
|
+ {
|
|
|
try {
|
|
|
- $orderIds = $redis->smembers($key);
|
|
|
- Order::whereIn('order_id', $orderIds)->update(['order_is_complete' => 'Y', 'order_status_system' => 'CONFIRM']);
|
|
|
- OrderSheet::whereIn('join_sheet_order_id', $orderIds)->update(['order_sheet_status' => 'CONFIRM']);
|
|
|
- $redis->del($key);
|
|
|
+ Db::beginTransaction();
|
|
|
+ $timeUnix = strtotime("-15 minutes");
|
|
|
+ $orders = Order::where('order_status_system', 'PAYING')
|
|
|
+ ->where('order_addtimes', '<', $timeUnix)
|
|
|
+ ->get();
|
|
|
+ foreach ($orders as $order) {
|
|
|
+ // 订单主表
|
|
|
+ Order::where('order_id', $order->order_id)->update([
|
|
|
+ 'order_category' => 'CANCEL',
|
|
|
+ 'order_status_system' => 'CANCEL',
|
|
|
+ 'order_status_payment' => 'CANCEL'
|
|
|
+ ]);
|
|
|
+ // 订单详情表
|
|
|
+ OrderSheet::where('join_sheet_order_id', $order->order_id)->update(['order_sheet_status' => 'CANCEL']);
|
|
|
+ }
|
|
|
|
|
|
Db::commit();
|
|
|
} catch (\Exception $e) {
|