Browse Source

Merge branch 'master' of http://gits.hdlkeji.com:3000/zhangguidong/yutang

PC-20230314RMCU\Administrator 2 years ago
parent
commit
1e47c8cb42

+ 16 - 15
application/api/controller/Writeoff.php

@@ -9,11 +9,11 @@ use app\admin\model\Order;
 use app\admin\model\Ordercode;
 use app\admin\model\Orderitem;
 use app\admin\model\Third;
+use app\api\model\OrderCodeWriteOffLog;
 use app\common\controller\Api;
 use think\Queue;
 use Yansongda\Pay\Exceptions\GatewayException;
 use Yansongda\Pay\Pay;
-use function AlibabaCloud\Client\value;
 
 class Writeoff extends Api
 {
@@ -38,11 +38,6 @@ class Writeoff extends Api
             $code_info=$order_code_model->where('yajin_number',$data['yajin'])->find();
         }
         $order_info=$order_model->where('id',$code_info['order_id'])->find();
-
-        if((new Method())->wher('id', $order_info->method_id)->value('huodong_time') != date('Y-m-d')) {
-            $this->error('当前时间不在活动时间内');
-        }
-
         $item_info = $order_item_model->where('order_id',$code_info['order_id'])->find();
         $data_info['order_id'] =$order_info;
         $data_info['item_info']=$item_info;
@@ -59,10 +54,7 @@ class Writeoff extends Api
         $dakuanlog_model = new Dakuanlog();
         $user = $this->auth->getUser();
         $admin_id=$user->id;
-
-        $role = 1;
         if($user->pid>0){
-            $role = 2;
             $admin_id = $user->pid;
         }
 
@@ -106,10 +98,10 @@ class Writeoff extends Api
 
              }
             //入场码核销信息
-            $order_code_model->isUpdate('true', ['ruchang_number' => $data['ruchang']])->save(['ruchang_status' => 2, 'ruchang_time' => $time]);
-            $order_model->isUpdate('true', ['id' => $code_info['order_id']])->save(['status' => 3, 'write_off_role' => $order_model->write_off_role . $role . ',']);
+            $order_code_model->isUpdate('true',['ruchang_number'=>$data['ruchang']])->save(['ruchang_status'=>2,'ruchang_time'=>$time]);
+            $order_model->isUpdate('true',['id'=>$code_info['order_id']])->save(['status'=>3]);
 
-            $this->recordFirstWriteOffTime($code_info['order_id'], $time);
+            $this->recordFirstWriteOffTime($code_info['order_id'], $time, $code_info->id, 'ruchang');
 
             $this->success('入场核销码,核销成功');
 
@@ -156,7 +148,7 @@ class Writeoff extends Api
             //午餐码核销信息
             $order_code_model->isUpdate('true',['wucan_number'=>$data['wucan']])->save(['wucan_status'=>2,'wucan_time'=>$time]);
 
-            $this->recordFirstWriteOffTime($code_info['order_id'], $time);
+            $this->recordFirstWriteOffTime($code_info['order_id'], $time, $code_info->id, 'wucan');
 
             $this->success('午餐核销码,核销成功');
 
@@ -189,13 +181,13 @@ class Writeoff extends Api
             $order_code_model->isUpdate('true',['yajin_number'=>$data['yajin']])->save(['yajin_status'=>2,'yajin_time'=>$time]);
             $order_model->isUpdate('true',['id'=>$code_info['order_id']])->save(['status'=>4]);
 
-            $this->recordFirstWriteOffTime($code_info['order_id'], $time);
+            $this->recordFirstWriteOffTime($code_info['order_id'], $time, $code_info->id, 'yajin');
 
             $this->success('押金核销码,核销成功');
         }
     }
 
-    protected function recordFirstWriteOffTime($order_id, $time)
+    protected function recordFirstWriteOffTime($order_id, $time, $code_id, $type)
     {
         $order = Order::where('id', $order_id)->find();
         if (!$order->first_writer_off_time) {
@@ -205,6 +197,15 @@ class Writeoff extends Api
             $subTime = $subTime < 0 ? 1 : $subTime;
             Queue::later($subTime, '\app\job\OrderSendSms@sendSms', ['order_id' => $order_id], 'shopro');
         }
+
+        OrderCodeWriteOffLog::create([
+            'order_id' => $order_id,
+            'order_code_id' => $code_id,
+            'type' => $type,
+            'user_id' => $this->auth->id,
+            'write_off_time' => date('Y-m-d H:i:s', $time),
+            'created_time' => date('Y-m-d H:i:s')
+        ]);
     }
 
     public function refund_order($amount,$order_no,$type)

+ 10 - 0
application/api/model/OrderCodeWriteOffLog.php

@@ -0,0 +1,10 @@
+<?php
+
+
+namespace app\api\model;
+
+
+class OrderCodeWriteOffLog extends \think\Model
+{
+
+}