Browse Source

用户的优惠券列表添加了可用产品的显示

ChenWuJie 4 years ago
parent
commit
82a2397b70

+ 30 - 0
app/Admin/Controllers/UserManagement/BmUser/UserCouponsController.php

xqd
@@ -40,6 +40,36 @@ class UserCouponsController extends AdminController
         $grid->column('title', __('券标题'));
         $grid->column('type', __('类型'))->using([1=>'满减券',2=>'折扣券']);
         $grid->column('usable_type', __('可用类型'))->using([1=>'全部产品通用',2=>'部分产品可用']);
+        $grid->column('CouponType', __('可用产品'))->pluck('product_type','id')->display(function ($i){
+            $name = [];
+            foreach ($i as $value)
+            {
+                switch ($value){
+                    case 1:
+                        array_push($name,'电话咨询');
+                        break;
+                    case 2:
+                        array_push($name,'图文咨询');
+                        break;
+                    case 3:
+                        array_push($name,'门诊咨询');
+                        break;
+                    case 4:
+                        array_push($name,'疫苗接种');
+                        break;
+                    case 5:
+                        array_push($name,'儿保预约');
+                        break;
+                    case 6:
+                        array_push($name,'服务包');
+                        break;
+                    case 7:
+                        array_push($name,'充值');
+                        break;
+                }
+            }
+            return $name;
+        })->label('info');
         $grid->column('money', __('满减券的优惠钱数'))->display(function ($money){
             return $money/100;
         });

+ 3 - 0
app/Models/CouponType.php

xqd
@@ -13,4 +13,7 @@ class CouponType extends BaseModel
     public function coupon (){
         return $this->belongsTo(Coupon::class);
     }
+    public function userCoupon (){
+        return $this->belongsTo(UserCoupon::class);
+    }
 }

+ 4 - 0
app/Models/UserCoupon.php

xqd
@@ -47,4 +47,8 @@ class UserCoupon extends BaseModel
 
         return $discountAmount;
     }
+
+    public function couponType (){
+        return $this->hasMany(CouponType::class);
+    }
 }