Prechádzať zdrojové kódy

Merge branch 'master' of http://git.9026.com/swdz-WangHaijun/BaoMa

Swdz-WangHaiJun 4 rokov pred
rodič
commit
7272f07c37

+ 44 - 0
app/Admin/Actions/backstage/Coupon/UpdateCouponType.php

xqd
@@ -0,0 +1,44 @@
+<?php
+
+namespace App\Admin\Actions\backstage\Coupon;
+
+use App\Models\CouponType;
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Http\Request;
+
+class UpdateCouponType extends RowAction
+{
+    public $name = '修改可用类型';
+
+    public function handle(Model $model,Request $request)
+    {
+        $type = request('type');
+        //先删除原来的数据,再添加新的数据
+        CouponType::where('coupon_id',$this->row->id)->where('user_coupon_id',0)->delete();
+        $arr = [
+            'coupon_id' =>  $this->row->id,
+            'user_coupon_id' =>  0,
+            'product_type' =>  0,
+        ];
+        foreach ($type as $value)
+        {
+            $arr['product_type'] = $value;
+            CouponType::create($arr);
+        }
+        return $this->response()->success('修改可用产品成功')->refresh();
+    }
+    public function form(){
+        $value = CouponType::where('coupon_id',$this->row->id)->where('user_coupon_id',0)->pluck('product_type')->toArray();
+        $this->multipleSelect('type','可用类型')->options([
+            1=>'电话咨询',
+            2=>'图文咨询',
+            3=>'门诊咨询',
+            4=>'疫苗接种',
+            5=>'儿保预约',
+            6=>'服务包',
+            7=>'充值',
+        ])->value($value);
+    }
+
+}

+ 1 - 1
app/Admin/Controllers/CouponManagement/CouponDistributionUserList.php

xqd
@@ -48,7 +48,7 @@ class CouponDistributionUserList extends AdminController
             $batch->add(new AllCouponBatchGrant());
         });
         $grid->disableActions();
-        $grid ->model()->where('status','>=','0');
+        $grid ->model()->where('status','>=','0')->where('is_docter',0);
         $grid->column('id', __('用户id'))->sortable();
         $grid->column('nickname', __('用户名'));
         $grid->column('sex', __('性别'))->using([0=>'未知',1=>'男',2=>'女']);

+ 37 - 19
app/Admin/Controllers/CouponManagement/CouponManagementController.php

xqd xqd xqd xqd xqd
@@ -5,7 +5,9 @@ namespace App\Admin\Controllers\CouponManagement;
 use App\Admin\Actions\backstage\Coupon\CouponDetails;
 use App\Admin\Actions\backstage\Coupon\CouponDistribution;
 use App\Admin\Actions\backstage\Coupon\CouponDistributions;
+use App\Admin\Actions\backstage\Coupon\UpdateCouponType;
 use App\Models\Coupon;
+use App\Models\CouponType;
 use Encore\Admin\Controllers\AdminController;
 use Encore\Admin\Form;
 use Encore\Admin\Grid;
@@ -35,6 +37,10 @@ class CouponManagementController extends AdminController
         $grid->actions(function ($actions) {
             $actions->disableView();
             $actions->add(new CouponDetails());
+            if ($actions->row->usable_type == 2)
+            {
+                $actions->add(new UpdateCouponType());
+            }
         });
         $grid->filter(function($filter){
             $filter->timestampBetween('start_time', "有效期开始时间")->datetime();
@@ -138,11 +144,12 @@ class CouponManagementController extends AdminController
     protected function form()
     {
         $form = new Form(new Coupon());
-
+        $form->hidden('id', __('id'));
         $form->text('name', __('优惠券名称'));
         $form->text('title', __('券标题'));
         $form->text('desc', __('使用说明'));
         $form->text('rules', __('使用规则'));
+//        dd($form->toArray());
         $form->image('icon', __('券图标'))->help('图标大小48px * 48px');
         $form->select('type', '类型')
             ->options([
@@ -157,23 +164,34 @@ class CouponManagementController extends AdminController
             });
         $form->select('position_type',__('发放平台'))->options([1=>'领券中心',2=>'后台发放']);
         $form->number('num', __('数量'));
-        $form->select('usable_type',__('可用类型'))
-            ->options([
-                1=>'全部产品通用',
-                2=>'部分产品可用'
-            ])->when(2,function (Form $form){
-                $form->hasMany('CouponType','可用类型',function (Form\NestedForm $form){
-                    $form->select('product_type','可用类型')->options([
-                        1=>'电话咨询',
-                        2=>'图文咨询',
-                        3=>'门诊咨询',
-                        4=>'疫苗接种',
-                        5=>'儿保预约',
-                        6=>'服务包',
-                        7=>'充值',
-                    ]);
+        if ($form->isCreating())
+        {
+            $form->select('usable_type',__('可用类型'))
+                ->options([
+                    1=>'全部产品通用',
+                    2=>'部分产品可用'
+                ])->when(2,function (Form $form){
+                    $form->hasMany('CouponType','可用类型',function (Form\NestedForm $form){
+                        $form->select('product_type','可用类型')->options([
+                            1=>'电话咨询',
+                            2=>'图文咨询',
+                            3=>'门诊咨询',
+                            4=>'疫苗接种',
+                            5=>'儿保预约',
+                            6=>'服务包',
+                            7=>'充值',
+                        ]);
+                    });
                 });
-            });
+        }else
+        {
+            $form->select('usable_type',__('可用类型'))
+                ->options([
+                    1=>'全部产品通用',
+                    2=>'部分产品可用'
+                ]);
+        }
+
         $form->select('expire_type', '过期类型')
             ->options([
                 1 => '领取N天过期',
@@ -186,9 +204,9 @@ class CouponManagementController extends AdminController
                 $form->saving(function ($form){
                     $form->start_time = strtotime($form->start_time);
                     $form->end_time = strtotime($form->end_time);
+                    $form->money = $form->money*100;
+                    $form->max_reduce_amount = $form->max_reduce_amount*100;
                 });
-
-
             });
         return $form;
     }

+ 1 - 9
app/Admin/Controllers/UserManagement/BmUser/UserListController.php

xqd xqd
@@ -62,22 +62,16 @@ class UserListController extends AdminController
                     0    => '黑名单',
                     1    => '正常',
                 ]);
-//                $filter->equal('is_pack','用户状态')->radio([
-//                    ''   => '全部用户',
-//                    0    => '普通用户',
-//                    1    => '服务包用户',
-//                ]);
                 $filter->between('created_at', '注册时间')->datetime();
                 $filter->timestampBetween('last_login_time', "最后登录时间")->datetime();
             });
         });
-            $grid ->model()->where('status','>=','0')->orderBy('id','desc');
+            $grid ->model()->where('status','>=','0')->where('is_docter',0)->orderBy('id','desc');
             $grid->column('id', __('用户id'))->sortable();
             $grid->column('avatar', __('头像'))->lightbox(['width' =>'', 'height' => 30]);
             $grid->column('nickname', __('用户名'));
             $grid->column('phone', __('手机号码'));
             $grid->column('status', __('状态'))->using([0=>'黑名单',1=>'正常',]);
-//            $grid->column('is_pack', __('用户身份'))->using([0=>'普通用户',1=>'付费用户']);
             $grid->column('balance', __('当前余额'))->display(function ($price){
                 return $price/100;
             });
@@ -85,8 +79,6 @@ class UserListController extends AdminController
             $grid->column('last_login_time', __('最后登录时间'))->display(function ($time){
                 return date("Y-m-d H:i",$time);
             });
-//            $grid->column('patient', __('患者姓名'))->pluck('name')->map('ucwords')->implode(',');
-//            $grid->column('patient', __('患者姓名'))->pluck('name')->label('default');
         return $grid;
     }