gogs hace 1 año
padre
commit
dd40dcccba

+ 38 - 0
app/Console/Commands/CustomerPond.php

@@ -0,0 +1,38 @@
+<?php
+
+namespace App\Console\Commands;
+
+
+use App\Service\CustomerPondService;
+use Illuminate\Console\Command;
+
+
+class CustomerPond extends Command
+{
+
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+
+    protected $signature = 'customerPond';
+
+    protected $description = '';
+
+    protected $process;
+    protected $key = 'customerPond';
+
+    public function __construct()
+    {
+        parent::__construct();
+
+    }
+
+    public function handle()
+    {
+        $service = new CustomerPondService();
+        $service->updateCustomerPond();
+    }
+}

+ 0 - 35
app/Http/Controllers/Api/TestController.php

@@ -15,42 +15,7 @@ class TestController extends BaseController
 
 
     public function boxInsert(){
-        $data = [
-            'out_order_no' => 'test123',
-            'ext_1' => '1',
-            'ext_2' => '2',
-            'ext_3' => '3',
-            'ext_4' => '4',
-            'ext_5' => '5',
-            'detail' => [
-                [
-                    'top_id' => '1',
-                    'code' => '001',
-                    'title' => '产品名称',
-                    'ext_1' => '1',
-                    'ext_2' => '2',
-                    'ext_3' => '3',
-                    'ext_4' => '4',
-                    'ext_5' => '5',
-                ],[
-                    'top_id' => '2',
-                    'code' => '002',
-                    'title' => '产品名称1',
-                    'ext_1' => '11',
-                    'ext_2' => '22',
-                    'ext_3' => '33',
-                    'ext_4' => '44',
-                    'ext_5' => '55',
-                ],
-            ],
-        ];
 
-
-        $service = BoxHookService::getInstance();
-
-        list($status,$msg) = $service->boxInsert($data);
-        var_dump($status);
-        var_dump($msg);
     }
 
     public function aa(){

+ 38 - 0
app/Jobs/OperationLog.php

@@ -0,0 +1,38 @@
+<?php
+
+namespace App\Jobs;
+
+use App\Service\OperationLogService;
+use Illuminate\Bus\Queueable;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Foundation\Bus\Dispatchable;
+use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Queue\SerializesModels;
+
+class OperationLog implements ShouldQueue
+{
+    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
+
+    protected $insert;
+    /**
+     * Create a new job instance.
+     *
+     * @return void
+     */
+    public function __construct($insert)
+    {
+        //
+        $this->insert = $insert;
+    }
+
+    /**
+     * Execute the job.
+     *
+     * @return void
+     */
+    public function handle()
+    {
+        $insert = $this->insert;
+        OperationLogService::getInstance()->insertOperationLog($insert);
+    }
+}

+ 0 - 49
app/Jobs/OrderTag.php

@@ -1,49 +0,0 @@
-<?php
-
-namespace App\Jobs;
-
-use App\Service\Order\OrderTagService;
-use Illuminate\Bus\Queueable;
-use Illuminate\Contracts\Queue\ShouldQueue;
-use Illuminate\Foundation\Bus\Dispatchable;
-use Illuminate\Queue\InteractsWithQueue;
-use Illuminate\Queue\SerializesModels;
-use Illuminate\Support\Facades\DB;
-
-class OrderTag implements ShouldQueue
-{
-    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
-
-    protected $order_no;
-    /**
-     * Create a new job instance.
-     *
-     * @return void
-     */
-    public function __construct($order_no)
-    {
-        //
-        $this->order_no = $order_no;
-    }
-
-    /**
-     * Execute the job.
-     *
-     * @return void
-     */
-    public function handle()
-    {
-        //生成芯片数据更新订单产品部件信息
-        $service = new OrderTagService();
-        DB::beginTransaction();
-        try{
-            $service = $service->setTag($this->order_no);
-            DB::commit();
-        }catch (\Exception $e){
-            DB::rollBack();
-
-            $this->dispatch($this->order_no);
-        }
-
-    }
-}

+ 19 - 0
app/Model/OperationLog.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ *
+ * Class Unit
+ * @package App\Models
+ */
+class OperationLog extends Model
+{
+    protected $table = "operation_log"; //指定表
+    const CREATED_AT = 'crt_time';
+    const UPDATED_AT = null;
+    protected $dateFormat = 'U';
+
+}

+ 19 - 0
app/Model/OperationLogDetail.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ *
+ * Class Unit
+ * @package App\Models
+ */
+class OperationLogDetail extends Model
+{
+    protected $table = "operation_log_detail"; //指定表
+    const CREATED_AT = null;
+    const UPDATED_AT = null;
+    protected $dateFormat = 'U';
+
+}

+ 37 - 0
app/Service/CustomerPondService.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace App\Service;
+
+
+use App\Model\Customer;
+use App\Model\Setting;
+
+class CustomerPondService extends Service
+{
+
+    protected $rule;
+    public function updateCustomerPond(){
+        $customerModel = new Customer();
+        $customerList = $customerModel->where('pond_state',0)->where('del_time',0)->first();
+        $this->rule = Setting::where('setting_name','customer_pond_limit_time')->value('setting_value');
+        foreach ($customerList as $v){
+            if($this->customerPondRule($v)){
+
+            }
+        }
+    }
+
+    //
+    public function customerPondRule($customer){
+        if($this->finishRule($customer)){
+
+        }
+//        if()
+    }
+
+    //关于客户的进入公海池流程(后续再出)
+    public function finishRule(){
+        $time = $this->rule;
+        return true;
+    }
+}

+ 163 - 0
app/Service/OperationLogService.php

@@ -0,0 +1,163 @@
+<?php
+
+namespace App\Service;
+
+
+
+use App\Model\OperationLog;
+use App\Model\OperationLogDetail;
+use Illuminate\Support\Facades\DB;
+
+class OperationLogService extends Service
+{
+    protected static $instance;
+    public static function getInstance(): self
+    {
+        if (self::$instance == null) {
+            self::$instance = new OperationLogService();
+        }
+        return self::$instance;
+    }
+
+
+    public function insertOperationLog($insert){
+        try {
+            DB::beginTransaction();
+            $menu_id = $insert['menu_id'];
+            $user_id = $insert['user_id'];
+            $ip = $insert['ip'];
+            $parent_id = $insert['parent_id'];
+            $type = $insert['type']??2;
+            $logModel = new OperationLog();
+            $logModel->user_id = $user_id;
+            $logModel->ip = $ip;
+            $logModel->menu_id = $menu_id;
+            $logModel->type = $type;
+            $logModel->parent_id = $parent_id;
+            $logModel->save();
+            $LogParent_id = $logModel->id;
+            if($type == 2){
+                $sub_datas = [];
+                $relationship_datas = [];
+                $table_Data = $insert['table_data'];
+                $sub_table_data = $insert['sub_table_data'] ?? [];
+                $relationship_table_data = $insert['relationship_table_data'] ?? [];
+                $table_Data = $this->findTableDatas($table_Data);
+                if(!empty($sub_table_data)) {
+
+                    foreach ($sub_table_data as $v){
+                        $sub_data = $this->findTableData($v);
+                        $sub_datas = array_merge($sub_datas,$sub_data);
+                    }
+
+                }
+                if(!empty($relationship_table_data)) {
+                    foreach ($sub_table_data as $v){
+                        $relationship_data = $this->findTableData($relationship_table_data);
+                        $relationship_datas = array_merge($relationship_datas,$relationship_data);
+                    }
+
+                }
+                $insert_detail_data =  array_merge($table_Data,$sub_datas,$relationship_datas);
+                $table_Data = $this->dealOperationLogDetail($insert_detail_data,$LogParent_id);
+                OperationLogDetail::insert($table_Data);
+            }
+
+
+
+
+            DB::commit();
+            return [true,''];
+        }catch (\Exception $e){
+            DB::rollBack();
+            return [false,$e->getLine().':'.$e->getMessage()];
+        }
+
+    }
+
+    public function dealOperationLogDetail($data,$log_id){
+        foreach ($data as $k=>$v){
+            $data[$k]['log_id'] = $log_id;
+        }
+
+        return $data;
+    }
+
+    public function findTableData($data){
+        $table = $data['table'];
+        $param = $data['param'];
+        $parent_id = $data['parent_id'];
+        $parent_key = $data['parent_key']??'id';
+        $model = DB::table($table)->where($parent_key,$parent_id);
+        $select_list = [];
+        $new_data_list = [];
+        foreach ($param as $v){
+            $select_list[] = $v['key'];
+            $new_data_list[$v['key']] = [
+                'new_data' => $v['value'],
+                'parent_id' => $parent_id,
+            ];
+        }
+        $detail = $model->select($select_list)->first()->toArray();
+        foreach ($new_data_list as $k=>$v){
+            $new_data_list[$k]['old_data'] = $detail[$k];
+        }
+        sort($new_data_list);
+        return $new_data_list;
+    }
+
+    public function findTableDatas($data){
+        $table = $data['table'];
+        $parent_id = $data['parent_id'];
+        $parent_key = $data['parent_key']??'id';
+        $key = $data['key'];
+        $value = $data['value'];
+        $model = DB::table($table)->where($parent_key,$parent_id);
+
+        $old_data = implode(',',$model->where($parent_key,$parent_id)->pluck($key)->toArray());
+        return [['old_data'=>$old_data,'new_data'=>implode(',',$value),'parent_id'=>$parent_id]];
+    }
+
+    public function setParam()
+    {
+        //3种格式类型,1:单张表数据更新,只需要数组种有key,value;2.子表更新,也是单条数据更新只需要数组种有key,value;3.子表更新,但是是删除数据更新,则传old data 和 new data
+        $insert = [
+                'menu_id'=>1,
+                'user_id'=>'1',
+                'ip'=>'1',
+                'parent_id'=>'1',
+                'table_data'=>[
+                    'table'=>'table',
+                    'parent_id'=>'1',
+                    'param'=>[
+                        [
+                            'key' => 'd',
+                            'value' => 'd',
+                        ]
+                    ]
+                ],
+                'sub_table_data'=>[
+                    [
+                        'table'=>'table',
+                        'parent_id'=>'1',
+                        'parent_key'=>'1',
+                        'param'=>[
+                            [
+                                'key' => 'd',
+                                'value' => 'd',
+                            ]
+                        ],
+                    ]
+                ],
+                'relationship_table_data'=>[
+                    [
+                        'table'=>'table',
+                        'parent_id'=>'table',
+                        'parent_key'=>'table',
+                        'key'=>'title',
+                        'value'=>[1,2,3,4,5],
+                    ]
+                ]
+        ];
+    }
+}

+ 12 - 0
app/Service/Service.php

@@ -3,6 +3,7 @@
 namespace App\Service;
 
 
+use App\Jobs\OperationLog;
 use Illuminate\Support\Facades\Redis;
 
 /**
@@ -326,4 +327,15 @@ class Service
 
         return $formattedDate;
     }
+
+    /**
+     * 用于用户行为操作日志记录
+     * @param $insert
+     * @return void
+     */
+    public function insertLog($insert){
+
+        OperationLog::dispatch($insert);
+
+    }
 }

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 236 - 166
composer.lock


Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio