| xqd
@@ -0,0 +1,41 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace App\Admin\Actions\backstage\Refund;
|
|
|
+
|
|
|
+use App\Models\Order;
|
|
|
+use App\Models\OrderPack;
|
|
|
+use Encore\Admin\Actions\RowAction;
|
|
|
+use Illuminate\Database\Eloquent\Model;
|
|
|
+
|
|
|
+class RefundServicePackAction extends RowAction
|
|
|
+{
|
|
|
+ public $name = '服务包退款';
|
|
|
+
|
|
|
+ public function handle(Model $model)
|
|
|
+ {
|
|
|
+ // $model ...
|
|
|
+ //获取到订单类型
|
|
|
+ $product_type = $this->row->product_type;
|
|
|
+ //获取到支付的服务包订单的id
|
|
|
+ $pay_order_pack_id = $this->row->pay_order_pack_id;
|
|
|
+ //根据订单类型进行退款
|
|
|
+ if ($product_type == 3)
|
|
|
+ {
|
|
|
+ //获取到原来剩余的次数
|
|
|
+ $appoint_num = OrderPack::where('id',$pay_order_pack_id)->value('appoint_num');
|
|
|
+ $new_appoint_num = $appoint_num+1;
|
|
|
+ OrderPack::where('id',$pay_order_pack_id)->update(['appoint_num'=>$new_appoint_num]);
|
|
|
+ Order::where('id',$this->row->id)->update(['payment_status'=>4]);
|
|
|
+ }
|
|
|
+ if ($product_type == 5)
|
|
|
+ {
|
|
|
+ //获取到原来剩余的次数
|
|
|
+ $nurses_limit_amount = OrderPack::where('id',$pay_order_pack_id)->value('nurses_limit_amount');
|
|
|
+ $new_nurses_limit_amount = $nurses_limit_amount+1;
|
|
|
+ OrderPack::where('id',$pay_order_pack_id)->update(['nurses_limit_amount'=>$new_nurses_limit_amount]);
|
|
|
+ Order::where('id',$this->row->id)->update(['payment_status'=>4]);
|
|
|
+ }
|
|
|
+ return $this->response()->success('服务包退款成功')->refresh();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|