wesley hace 6 años
padre
commit
7fc124bf28
Se han modificado 1 ficheros con 18 adiciones y 2 borrados
  1. 18 2
      app/Http/Controllers/Api/V1/HomeController.php

+ 18 - 2
app/Http/Controllers/Api/V1/HomeController.php

xqd xqd xqd xqd xqd xqd
@@ -898,6 +898,10 @@ class HomeController extends Controller
      *                      "discount": "7",                        //折扣
      *                      "discount_price": null,                 //优惠金额
      *                      "product_id": "1,2",                    //可使用的产品id
+     *                      "product":[                             //可使用产品名字
+     *                              "证件照",
+     *                              "履历照"
+     *                          ]
      *                      "count": 10,                            //剩余数量
      *                      "end_time": "2018-07-31",               //有效期
      *                      "created_at": "2018-07-13 07:29:27",
@@ -1032,14 +1036,14 @@ class HomeController extends Controller
             if (strtotime($value->coupon->end_time) < strtotime(Carbon::now('Asia/Shanghai'))) {
                 return false;
             } else {
-                $value->product = CouponInfoModel::find($value->coupon->id)?CouponInfoModel::find($value->coupon->id)->product():'';
+                $value->coupon->product = CouponInfoModel::find($value->coupon->id) ? CouponInfoModel::find($value->coupon->id)->product() : '';
                 return true;
             }
 
         });
 
         $mycards = CardInfoModel::where('user_id', $user->id)->where('status', 1)->where('end_time', '>', now())->get();
-        foreach ($mycards as $card){
+        foreach ($mycards as $card) {
             $card->product = $card->product();
         }
         return $this->api(compact('mycards', 'mycoupons'));
@@ -1269,6 +1273,10 @@ class HomeController extends Controller
      *                      "discount": "7",
      *                      "discount_price": null,
      *                      "product_id": "1,2",
+     *                      "product":[                  //可使用产品名字
+     *                              "证件照",
+     *                              "履历照"
+     *                          ],
      *                      "count": 7,
      *                      "end_time": "2018-07-31",
      *                      "created_at": "2018-07-13 07:29:27",
@@ -1290,6 +1298,10 @@ class HomeController extends Controller
      *                  "remark": "",
      *                  "end_time": "2019-07-31",
      *                  "product_id": "1,2",
+     *                  "product":[                  //可使用产品名字
+     *                              "证件照",
+     *                              "履历照"
+     *                          ],
      *                  "deleted_at": null,
      *                  "created_at": "2018-07-18 10:17:04",
      *                  "updated_at": "2018-08-09 02:11:36"
@@ -1348,6 +1360,7 @@ class HomeController extends Controller
 
             $price = $product->current_price ? $product->current_price : $product->origin_price;
             if ((strtotime($value->coupon->end_time) > strtotime(Carbon::now('Asia/Shanghai'))) && in_array($product->category_id, $products) && ($price >= $value->coupon->min_price)) {
+                $value->coupon->product = CouponInfoModel::find($value->coupon->id) ? CouponInfoModel::find($value->coupon->id)->product() : '';
                 $flag = true;
             } else {
                 $flag = false;
@@ -1358,6 +1371,9 @@ class HomeController extends Controller
         });
 
         $usableCards = CardInfoModel::where('user_id', $user->id)->where('status', 1)->where('end_time', '>=', now())->where('product_id', 'like', '%' . request('product_id') . '%')->get();
+        foreach ($usableCards as $card) {
+            $card->product = $card->product();
+        }
 
 
         return $this->api(compact('usablecoupons', 'usableCards'));