pengchanglu 3 years ago
parent
commit
fdfc7ab8f6

+ 0 - 12
application/admin/model/p/Order.php

@@ -1,12 +0,0 @@
-<?php
-
-namespace app\admin\model\p;
-
-use think\Model;
-
-class Order extends Model
-{
-    // 表名
-    protected $name = 'p_order';
-    
-}

+ 0 - 12
application/admin/model/p/Province.php

@@ -1,12 +0,0 @@
-<?php
-
-namespace app\admin\model\p;
-
-use think\Model;
-
-class Province extends Model
-{
-    // 表名
-    protected $name = 'p_province';
-    
-}

+ 41 - 0
application/common/model/pig/Code.php

@@ -0,0 +1,41 @@
+<?php
+
+namespace app\common\model\pig;
+
+use think\Cache;
+use think\Model;
+
+class Code extends Model
+{
+
+    // 表名
+    protected $name = 'p_code';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = 'int';
+
+    // 定义时间戳字段名
+    protected $createTime = 'createtime';
+    protected $updateTime = 'updatetime';
+    protected $deleteTime = 'deletetime';
+
+    // 追加属性
+    protected $append = [
+        'status_text'
+    ];
+    
+
+    
+    public function getStatusList()
+    {
+        return ['1' => __('Status 1'), '2' => __('Status 2'), '3' => __('Status 3')];
+    }
+
+
+    public function getStatusTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
+        $list = $this->getStatusList();
+        return isset($list[$value]) ? $list[$value] : '';
+    }
+}

+ 64 - 0
application/common/model/pig/Company.php

@@ -0,0 +1,64 @@
+<?php
+
+namespace app\common\model\pig;
+
+use think\Cache;
+use think\Model;
+
+class Company extends Model
+{
+
+    // 表名
+    protected $name = 'p_company';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = 'int';
+
+    // 定义时间戳字段名
+    protected $createTime = 'createtime';
+    protected $updateTime = 'updatetime';
+    protected $deleteTime = 'deletetime';
+
+    // 追加属性
+    protected $append = [
+        'type_text',
+        'status_text'
+    ];
+    
+
+    
+    public function getTypeList()
+    {
+        //return ['1' => __('Type 1'), '2' => __('Type 2'), '3' => __('Type 3')];
+        return ['1' => __('Type 1'), '2' => __('Type 2')];
+    }
+
+    public function getStatusList()
+    {
+        return ['1' => __('Status 1'), '2' => __('Status 2'), '3' => __('Status 3')];
+    }
+
+
+    public function getTypeTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
+        $list = $this->getTypeList();
+        return isset($list[$value]) ? $list[$value] : '';
+    }
+
+
+    public function getStatusTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
+        $list = $this->getStatusList();
+        return isset($list[$value]) ? $list[$value] : '';
+    }
+
+
+
+
+    public function province()
+    {
+        return $this->belongsTo('app\admin\model\p\Province', 'province_id', 'id', [], 'LEFT')->setEagerlyType(0);
+    }
+}

+ 73 - 0
application/common/model/pig/Order.php

@@ -0,0 +1,73 @@
+<?php
+
+namespace app\common\model\pig;
+
+use think\Cache;
+use think\Model;
+
+class Order extends Model
+{
+
+    // 表名
+    protected $name = 'p_order';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = 'int';
+
+    // 定义时间戳字段名
+    protected $createTime = 'createtime';
+    protected $updateTime = 'updatetime';
+    protected $deleteTime = 'deletetime';
+
+    // 追加属性
+    protected $append = [
+        'arrivetime_text',
+        'leavetime_text',
+        'status_text'
+    ];
+    
+
+    
+    public function getStatusList()
+    {
+        return ['1' => __('Status 1'), '2' => __('Status 2'), '3' => __('Status 3')];
+    }
+
+
+    public function getArrivetimeTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['arrivetime']) ? $data['arrivetime'] : '');
+        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+    }
+
+
+    public function getLeavetimeTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['leavetime']) ? $data['leavetime'] : '');
+        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+    }
+
+
+    public function getStatusTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
+        $list = $this->getStatusList();
+        return isset($list[$value]) ? $list[$value] : '';
+    }
+
+    protected function setArrivetimeAttr($value)
+    {
+        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+    }
+
+    protected function setLeavetimeAttr($value)
+    {
+        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+    }
+
+
+    public function province()
+    {
+        return $this->belongsTo('app\admin\model\general\Province', 'supplier_id', 'id', [], 'LEFT')->setEagerlyType(0);
+    }
+}

+ 37 - 0
application/index/controller/Index.php

@@ -3,6 +3,9 @@
 namespace app\index\controller;
 
 use app\common\controller\Frontend;
+use app\common\model\pig\Code;
+use app\common\model\pig\Company;
+use app\common\model\pig\Order;
 
 class Index extends Frontend
 {
@@ -19,6 +22,40 @@ class Index extends Frontend
     public function code()
     {
         $code = $this->request->request('code');
+        if (!$code) {
+            $this->error("CODE为空,非法访问!");
+            exit;
+        }
+        $id = decrypt($code);
+        $id = 1;
+        $code = new Code();
+        $codeinfo = $code->find($id);
+        if (!$codeinfo) {
+            $this->error("参数错误!");
+            exit;
+        }
+        $orderid = $codeinfo->orderid;
+        if (!$orderid) {
+            $this->error("参数错误~");
+            exit;
+        }
+
+        $order = new Order();
+        $orderinfo = $order->where('orderid', $orderid)->find();
+
+        $company = new Company();
+        $companyinfo = $Company->where('admin_id', $orderid->admin_id)->where('type', 3)->find();
+
+        //供应商
+        $supplier = $company->find($orderinfo->supplier_id);
+
+        //客户
+        $customer = $company->find($orderinfo->customer_id);
+
+
+
+        print_r($orderinfo);
+
         echo $code;
         /**/
         $encode = encrypt($code);