Просмотр исходного кода

将首页和产品首页修改单独抽出来

chenxiqiang 6 лет назад
Родитель
Сommit
47fbad4c1b

+ 29
- 0
manage-server/app/Http/Controllers/ClassifyController.php Просмотреть файл

@@ -2,6 +2,7 @@
2 2
 
3 3
 namespace App\Http\Controllers;
4 4
 
5
+use App\Models\HomePage;
5 6
 use Illuminate\Http\Request;
6 7
 use App\Models\Classify;
7 8
 
@@ -13,6 +14,34 @@ class ClassifyController extends Controller
13 14
         return Classify::paginate(100);
14 15
     }
15 16
 
17
+    public function setHome(Request $request) {
18
+        $top1 = $request->input("top1");
19
+        $top2 = $request->input("top2");
20
+        $top3 = $request->input("top3");
21
+        $bottom = $request->input("bottom");
22
+        $introduce = $request->input("introduce");
23
+
24
+        if($top1 && $top2 && $top3 && $bottom && $introduce) {
25
+            $homePage = HomePage::find(1);
26
+            $homePage->top1 = $top1;
27
+            $homePage->top2 = $top2;
28
+            $homePage->top3 = $top3;
29
+            $homePage->bottom = $bottom;
30
+            $homePage->introduce = $introduce;
31
+            $homePage->save();
32
+
33
+            return response()->json([
34
+                "status" => 0,
35
+                "message" => '修改成功'
36
+            ]);
37
+        } else {
38
+            return Response()->json([
39
+                "status" => -1,
40
+                "message" => "信息不能为空!"
41
+            ]);
42
+        }
43
+    }
44
+
16 45
     /**
17 46
      * 每页20进行分页
18 47
      * @param Request $request

+ 24
- 0
manage-server/app/Http/Controllers/ProductController.php Просмотреть файл

@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
4 4
 
5 5
 use Illuminate\Http\Request;
6 6
 use App\Models\Product;
7
+use App\Models\ProductPage;
7 8
 
8 9
 class ProductController extends Controller
9 10
 {
@@ -116,4 +117,27 @@ class ProductController extends Controller
116 117
         ]);
117 118
     }
118 119
 
120
+    public function setHome(Request $request) {
121
+        $top1 = $request->input("top1");
122
+        $top2 = $request->input("top2");
123
+        $top3 = $request->input("top3");
124
+
125
+        if($top1 && $top2 && $top3 ) {
126
+            $homePage = ProductPage::find(1);
127
+            $homePage->top1 = $top1;
128
+            $homePage->top2 = $top2;
129
+            $homePage->top3 = $top3;
130
+            $homePage->save();
131
+
132
+            return response()->json([
133
+                "status" => 0,
134
+                "message" => '修改成功'
135
+            ]);
136
+        } else {
137
+            return Response()->json([
138
+                "status" => -1,
139
+                "message" => "信息不能为空!"
140
+            ]);
141
+        }
142
+    }
119 143
 }

+ 28
- 1
manage-server/app/Http/Controllers/RewardController.php Просмотреть файл

@@ -4,17 +4,44 @@ namespace App\Http\Controllers;
4 4
 
5 5
 use Illuminate\Http\Request;
6 6
 use App\Models\Reward;
7
+use App\Models\RewardPrice;
7 8
 use Carbon\Carbon;
8 9
 
9 10
 
10 11
 class RewardController extends Controller
11 12
 {
13
+    public $price = 0;
14
+
15
+    public function __construct() {
16
+        $rewardPrice = RewardPrice::find(1);
17
+        $this->price = $rewardPrice->price;
18
+    }
19
+
20
+    public function price(Request $request) {
21
+        $price = $request->input("price");
22
+        if($price) {
23
+            $rewardPrice = RewardPrice::find(1);
24
+            $rewardPrice->price = $price;
25
+            $rewardPrice->save();
26
+            $this->price = $price;
27
+
28
+            return response()->json([
29
+                "status" => 0,
30
+                "message" => '修改成功'
31
+            ]);
32
+        } else {
33
+            return Response()->json([
34
+                "status" => -1,
35
+                "message" => "信息不能为空!"
36
+            ]);
37
+        }
38
+    }
12 39
 
13 40
     public function reward(Request $request) {
14 41
 
15 42
         $wechat_id = $request->header("openid");
16 43
         if($wechat_id) {
17
-            $price = 0.01;
44
+            $price = $this->price;
18 45
             $order_type = "reward";
19 46
             $reward = new Reward;
20 47
             $reward->status = 0;

+ 16
- 0
manage-server/app/Models/HomePage.php Просмотреть файл

@@ -0,0 +1,16 @@
1
+<?php
2
+
3
+namespace App\Models;
4
+
5
+use Illuminate\Database\Eloquent\Model;
6
+
7
+class HomePage extends Model
8
+{
9
+    protected $fillable = [
10
+        'top1',
11
+        'top2',
12
+        'top3',
13
+        'introduce',
14
+        'bottom'
15
+    ];
16
+}

+ 15
- 0
manage-server/app/Models/ProductPage.php Просмотреть файл

@@ -0,0 +1,15 @@
1
+<?php
2
+
3
+namespace App\Models;
4
+
5
+use Illuminate\Database\Eloquent\Model;
6
+
7
+class ProductPage extends Model
8
+{
9
+
10
+    protected $fillable = [
11
+        'top1',
12
+        'top2',
13
+        'top3',
14
+    ];
15
+}

+ 13
- 0
manage-server/app/Models/RewardPrice.php Просмотреть файл

@@ -0,0 +1,13 @@
1
+<?php
2
+
3
+namespace App\Models;
4
+
5
+use Illuminate\Database\Eloquent\Model;
6
+
7
+class RewardPrice extends Model
8
+{
9
+
10
+    protected $fillable = [
11
+        'price',
12
+    ];
13
+}

+ 34
- 0
manage-server/database/migrations/2018_09_22_180621_create_product_pages_table.php Просмотреть файл

@@ -0,0 +1,34 @@
1
+<?php
2
+
3
+use Illuminate\Support\Facades\Schema;
4
+use Illuminate\Database\Schema\Blueprint;
5
+use Illuminate\Database\Migrations\Migration;
6
+
7
+class CreateProductPagesTable extends Migration
8
+{
9
+    /**
10
+     * Run the migrations.
11
+     *
12
+     * @return void
13
+     */
14
+    public function up()
15
+    {
16
+        Schema::create('product_pages', function (Blueprint $table) {
17
+            $table->increments('id');
18
+            $table->timestamps();
19
+            $table->unsignedInteger('top1');
20
+            $table->unsignedInteger('top2');
21
+            $table->unsignedInteger('top3');
22
+        });
23
+    }
24
+
25
+    /**
26
+     * Reverse the migrations.
27
+     *
28
+     * @return void
29
+     */
30
+    public function down()
31
+    {
32
+        Schema::dropIfExists('product_pages');
33
+    }
34
+}

+ 37
- 0
manage-server/database/migrations/2018_09_22_180635_create_home_pages_table.php Просмотреть файл

@@ -0,0 +1,37 @@
1
+<?php
2
+
3
+use Illuminate\Support\Facades\Schema;
4
+use Illuminate\Database\Schema\Blueprint;
5
+use Illuminate\Database\Migrations\Migration;
6
+
7
+class CreateHomePagesTable extends Migration
8
+{
9
+    /**
10
+     * Run the migrations.
11
+     *
12
+     * @return void
13
+     */
14
+    public function up()
15
+    {
16
+        Schema::create('home_pages', function (Blueprint $table) {
17
+            $table->increments('id');
18
+            $table->timestamps();
19
+            $table->unsignedInteger('top1');
20
+            $table->unsignedInteger('top2');
21
+            $table->unsignedInteger('top3');
22
+            $table->unsignedInteger('bottom');
23
+            $table->text('introduce');
24
+
25
+        });
26
+    }
27
+
28
+    /**
29
+     * Reverse the migrations.
30
+     *
31
+     * @return void
32
+     */
33
+    public function down()
34
+    {
35
+        Schema::dropIfExists('home_pages');
36
+    }
37
+}

+ 32
- 0
manage-server/database/migrations/2018_09_22_181655_create_reward_price_table.php Просмотреть файл

@@ -0,0 +1,32 @@
1
+<?php
2
+
3
+use Illuminate\Support\Facades\Schema;
4
+use Illuminate\Database\Schema\Blueprint;
5
+use Illuminate\Database\Migrations\Migration;
6
+
7
+class CreateRewardPriceTable extends Migration
8
+{
9
+    /**
10
+     * Run the migrations.
11
+     *
12
+     * @return void
13
+     */
14
+    public function up()
15
+    {
16
+        Schema::create('reward_price', function (Blueprint $table) {
17
+            $table->increments('id');
18
+            $table->double('price');
19
+            $table->timestamps();
20
+        });
21
+    }
22
+
23
+    /**
24
+     * Reverse the migrations.
25
+     *
26
+     * @return void
27
+     */
28
+    public function down()
29
+    {
30
+        Schema::dropIfExists('reward_price');
31
+    }
32
+}

+ 6
- 0
manage-server/routes/web.php Просмотреть файл

@@ -60,4 +60,10 @@ Route::middleware(['manage.token'])->group(function () {
60 60
     Route::post('/maternity_matron_order/store', 'MaternityMatronOrderController@store');
61 61
     Route::post('/product_order/store', 'ProductOrderController@store');
62 62
     Route::post('/server_info/store', 'ServerInfoController@store');
63
+
64
+
65
+    Route::post('/reward/price', 'RewardController@price');
66
+
67
+    Route::post('/product/home', 'ProductController@setHome');
68
+    Route::post('/classify/home', 'ClassifyController@setHome');
63 69
 });

Загрузка…
Отмена
Сохранить