瀏覽代碼

区分订单类型

chenxiqiang 6 年之前
父節點
當前提交
92cbc80364

+ 24
- 2
manage-server/app/Http/Controllers/HousekeeperOrderController.php 查看文件

@@ -2,11 +2,20 @@
2 2
 
3 3
 namespace App\Http\Controllers;
4 4
 
5
+use App\Models\Classify;
5 6
 use Illuminate\Http\Request;
6 7
 use App\Models\HousekeeperOrder;
7 8
 
8 9
 class HousekeeperOrderController extends Controller
9 10
 {
11
+    public $classify_map = [];
12
+
13
+    public function __construct() {
14
+        $classifies = Classify::all();
15
+        foreach ($classifies as $classify) {
16
+            $this->classify_map[$classify->id] = $classify;
17
+        }
18
+    }
10 19
 
11 20
     /**
12 21
      * 创建保姆订单
@@ -33,13 +42,22 @@ class HousekeeperOrderController extends Controller
33 42
         $notes = $request->input('notes');
34 43
         $status = $request->input('status');
35 44
         $price = $request->input('price');
36
-        $type = $request->input('type');
37 45
         //$photo = $request->input('photo');
38 46
         if ($id) {
39 47
             $housekeeperOrder = HousekeeperOrder::find($id);
40 48
             $housekeeperOrder->status = $status;
41 49
             $housekeeperOrder->price = $price;
42 50
 
51
+            $classify = $request->input('classify');
52
+            if($classify) {
53
+                $classify1 = $this->classify_map[$classify]->name;
54
+                $pid = $this->classify_map[$classify]->pid;
55
+                $classify2 = $this->classify_map[$pid]->name;
56
+                $housekeeperOrder->classify1 = $classify1;
57
+                $housekeeperOrder->classify2 = $classify2;
58
+                $housekeeperOrder->classify = $classify;
59
+            }
60
+
43 61
         } else {
44 62
             $housekeeperOrder = new HousekeeperOrder;
45 63
             $housekeeperOrder->status = 0;
@@ -55,7 +73,7 @@ class HousekeeperOrderController extends Controller
55 73
             $housekeeperOrder->contact = $contact;
56 74
             $housekeeperOrder->notes = $notes;
57 75
             $housekeeperOrder->phone = $phone;
58
-            $housekeeperOrder->type = $type;
76
+            $housekeeperOrder->classify = $classify;
59 77
             $housekeeperOrder->wechat_id = $wechat_id;
60 78
             $housekeeperOrder->photo = "https://wechat.sotype.com/storage/gOtuHM3GvKva6x68N340DJuN6cX1oIfaAhWi8yoq.jpeg";
61 79
             $housekeeperOrder->save();
@@ -81,4 +99,8 @@ class HousekeeperOrderController extends Controller
81 99
     {
82 100
         return HousekeeperOrder::paginate(20);
83 101
     }
102
+
103
+    public function classify() {
104
+
105
+    }
84 106
 }

+ 4
- 0
manage-server/app/Http/Controllers/MaternityMatronOrderController.php 查看文件

@@ -37,6 +37,10 @@ class MaternityMatronOrderController extends Controller
37 37
             $maternityMatronOrder->status = $status;
38 38
             $maternityMatronOrder->price = $price;
39 39
 
40
+            $maternityMatronOrder->classify1 = "家政";
41
+            $maternityMatronOrder->classify2 = "月嫂";
42
+            $maternityMatronOrder->classify = 6;
43
+
40 44
         } else {
41 45
             $maternityMatronOrder = new MaternityMatronOrder;
42 46
             $maternityMatronOrder->status = 0;

+ 1
- 1
manage-server/app/Models/HouseApplianceCleanOrder.php 查看文件

@@ -12,7 +12,7 @@ class HouseApplianceCleanOrder extends Order
12 12
 {
13 13
 
14 14
     function __construct() {
15
-        parent::__construct("家政", "家电清洁", "house_appliance_clean_order");
15
+        parent::__construct( "house_appliance_clean_order");
16 16
         $fillable = ['appliances'];// 项目, 数组形式,多个数量则出现多次
17 17
         parent::mergeFillable(parent::getFillable(), $fillable);
18 18
     }

+ 1
- 1
manage-server/app/Models/HouseCleanOrder.php 查看文件

@@ -12,7 +12,7 @@ class HouseCleanOrder extends Order
12 12
 {
13 13
 
14 14
     function __construct() {
15
-        parent::__construct("家政", "家居清洁", "house_clean_order");
15
+        parent::__construct( "house_clean_order");
16 16
         $fillable = [
17 17
             'type', // 清洁类型
18 18
             'area', // 清洁面积

+ 1
- 2
manage-server/app/Models/HousekeeperOrder.php 查看文件

@@ -12,7 +12,7 @@ class HousekeeperOrder extends Order
12 12
 {
13 13
 
14 14
     function __construct() {
15
-        parent::__construct("家政", "保姆", "housekeeper_order");
15
+        parent::__construct("housekeeper_order");
16 16
         $fillable = [
17 17
             'contents', // 服务内容, 数组形式,多个数量则出现多次
18 18
             'people_num', //人口数量
@@ -20,7 +20,6 @@ class HousekeeperOrder extends Order
20 20
             'server_time', // 服务时间: 全白天/住家
21 21
             'rest', // 休息安排
22 22
             'notes', // 备注
23
-            'type', //订单类型
24 23
         ];
25 24
         parent::mergeFillable(parent::getFillable(), $fillable);
26 25
     }

+ 1
- 1
manage-server/app/Models/MaternityMatronOrder.php 查看文件

@@ -12,7 +12,7 @@ class MaternityMatronOrder extends Order
12 12
 {
13 13
 
14 14
     function __construct() {
15
-        parent::__construct("家政", "月嫂", "maternity_matron_order");
15
+        parent::__construct("maternity_matron_order");
16 16
         $fillable = [
17 17
             'level', // 月嫂等级
18 18
             'expected_date', // 预产期

+ 5
- 6
manage-server/app/Models/Order.php 查看文件

@@ -6,13 +6,9 @@ use Illuminate\Database\Eloquent\Model;
6 6
 
7 7
 class Order extends Model
8 8
 {
9
-    public $classify1 = "";
10
-    public $classify2 = "";
11 9
     public $order_type = "";
12 10
 
13
-    function __construct($classify1 = "", $classify2 = "", $order_type = "") {
14
-        $this->classify1 = $classify1;
15
-        $this->classify2 = $classify2;
11
+    function __construct($order_type = "") {
16 12
         $this->order_type = $order_type;
17 13
     }
18 14
 
@@ -25,7 +21,10 @@ class Order extends Model
25 21
         'price', // 订单价格
26 22
         'photo', // 显示的图片
27 23
         'comment_id', // 评论id
28
-        'paid_at',  // 支付时间
24
+        'paid_at',  // 支付时间,
25
+        'classify_id', //订单类型,分类
26
+        'classify1', //分类1
27
+        'classify2', //分类2
29 28
     ];
30 29
 
31 30
     public function setFillable($fillable) {

+ 3
- 0
manage-server/database/migrations/2018_08_10_075128_create_maternity_matron_orders_table.php 查看文件

@@ -42,6 +42,9 @@ class CreateMaternityMatronOrdersTable extends Migration
42 42
             $table->unsignedInteger('comment_id');
43 43
             $table->timestamps();
44 44
             $table->timestamp("paid_at");
45
+            $table->unsignedInteger('classify_id');
46
+            $table->string('classify1');
47
+            $table->string('classify2');
45 48
         });
46 49
     }
47 50
 

+ 3
- 1
manage-server/database/migrations/2018_08_10_075742_create_housekeeper_orders_table.php 查看文件

@@ -43,7 +43,9 @@ class CreateHousekeeperOrdersTable extends Migration
43 43
             $table->double('price');
44 44
             $table->string('photo');
45 45
             $table->string('notes');
46
-            $table->string('type');
46
+            $table->unsignedInteger('classify_id');
47
+            $table->string('classify1');
48
+            $table->string('classify2');
47 49
             $table->unsignedInteger('comment_id');
48 50
             $table->timestamp("paid_at");
49 51
         });

+ 3
- 0
manage-server/database/migrations/2018_08_10_080158_create_house_clean_orders_table.php 查看文件

@@ -48,6 +48,9 @@ class CreateHouseCleanOrdersTable extends Migration
48 48
             $table->string('photo');
49 49
             $table->unsignedInteger('comment_id');
50 50
             $table->timestamp("paid_at");
51
+            $table->unsignedInteger('classify_id');
52
+            $table->string('classify1');
53
+            $table->string('classify2');
51 54
         });
52 55
     }
53 56
 

+ 3
- 0
manage-server/database/migrations/2018_08_10_080546_create_house_applicance_clean_orders_table.php 查看文件

@@ -36,6 +36,9 @@ class CreateHouseApplicanceCleanOrdersTable extends Migration
36 36
             $table->string('photo');
37 37
             $table->unsignedInteger('comment_id');
38 38
             $table->timestamp("paid_at");
39
+            $table->unsignedInteger('classify_id');
40
+            $table->string('classify1');
41
+            $table->string('classify2');
39 42
         });
40 43
     }
41 44
 

Loading…
取消
儲存