12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- namespace app\admin\service\order;
- use app\model\Order;
- use app\model\OrderSheet;
- use app\model\SysDept;
- use support\Db;
- use support\Redis;
- class OrderService
- {
-
- public static function AutomaticReceipt()
- {
- 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_status_system' => 'CONFIRM'
- ]);
-
- OrderSheet::where('join_sheet_order_id', $order->order_id)->update(['order_sheet_status' => 'CONFIRM']);
-
-
- $redis = Redis::connection();
- $key = Order::AUTOMATIC_COMPLETE_PREFIX . date('Ymd', strtotime("+7 days"));
- $redis->sadd($key, $order->order_id);
- }
- Db::commit();
- } catch (\Exception $e) {
- Db::rollBack();
- }
- }
- public static function checkPayingOrder()
- {
- try {
- Db::beginTransaction();
- $timeUnix = strtotime("-30 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) {
- Db::rollBack();
- }
- }
- public static function generateWriteOffData($params) {
- return [
- 'charge'=>[
- 'charge_amount'=>1,
- 'charge_content'=>$params['order_remark'] ?? '',
- 'charge_user_id'=>$params['write_off_member_id'],
- 'charge_premises'=>$params['dept_premises_id'],
- ],
- 'member_id'=>$params['join_order_member_id']
- ];
- }
- }
|