cqp 2 hónapja
szülő
commit
5a87d92e5b

+ 0 - 76
app/Http/Controllers/Api/GiveOutController.php

@@ -1,76 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-use App\Service\GiveOutService;
-use Illuminate\Http\Request;
-
-class GiveOutController extends BaseController
-{
-    public function giveOutEdit(Request $request)
-    {
-        $service = new GiveOutService();
-        $user = $request->userData;
-        list($status,$data) = $service->giveOutEdit($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function giveOutAdd(Request $request)
-    {
-        $service = new GiveOutService();
-        $user = $request->userData;
-        list($status,$data) = $service->giveOutAdd($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-
-    }
-
-    public function giveOutDel(Request $request)
-    {
-        $service = new GiveOutService();
-        $user = $request->userData;
-        list($status,$data) = $service->giveOutDel($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-
-    }
-
-    public function giveOutList(Request $request)
-    {
-        $service = new GiveOutService();
-        $user = $request->userData;
-        list($status,$data) = $service->giveOutList($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function giveOutDetail(Request $request)
-    {
-        $service = new GiveOutService();
-        $user = $request->userData;
-        list($status,$data) = $service->giveOutDetail($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-}

+ 5 - 0
app/Service/EmployeeService.php

@@ -17,6 +17,7 @@ use App\Model\RoleMenuButton;
 use App\Model\SysMenu;
 use App\Model\SysMenuButton;
 use App\Model\Team;
+use App\Model\WxEmployee;
 use App\Model\WxEmployeeOfficial;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Hash;
@@ -207,6 +208,10 @@ class EmployeeService extends Service
             ]);
             EmployeeDepartPermission::whereIn('employee_id',$data['id'])->delete();
 
+            //解除微信小程序账号绑定
+            $appid = config("wx_msg.appid");
+            WxEmployee::whereIn('employee_id', $data['id'])->where('appid',$appid)->delete();
+
             DB::commit();
         }catch (\Throwable $exception){
             DB::rollBack();

+ 0 - 182
app/Service/GiveOutService.php

@@ -1,182 +0,0 @@
-<?php
-
-namespace App\Service;
-
-use App\Model\Employee;
-use App\Model\GiveOut;
-use Illuminate\Support\Facades\DB;
-
-/**
- * 发放
- */
-class GiveOutService extends Service
-{
-    public function giveOutEdit($data,$user){
-        list($status,$msg) = $this->giveOutRule($data, $user, false);
-        if(!$status) return [$status,$msg];
-
-        try {
-            DB::beginTransaction();
-
-            $model = GiveOut::where('id',$data['id'])->first();
-            $model->give_out_amount = $data['give_out_amount'] ?? 0;
-            $model->employee_id_1 = $data['employee_id_1'] ?? 0;
-            $model->employee_id_1_title = $data['employee_id_1_title'] ?? "";
-            $model->send_time = $data['send_time'] ?? 0;
-            $model->start_time = $data['start_time'] ?? 0;
-            $model->end_time = $data['end_time'] ?? 0;
-            $model->mark = $data['mark'] ?? "";
-            $model->save();
-
-            DB::commit();
-        }catch (\Exception $exception){
-            DB::rollBack();
-            return [false,$exception->getMessage()];
-        }
-
-        return [true, ''];
-    }
-
-    public function giveOutAdd($data,$user){
-        list($status,$msg) = $this->giveOutRule($data, $user);
-        if(!$status) return [$status,$msg];
-
-        try {
-            DB::beginTransaction();
-
-            $model = new GiveOut();
-            $model->give_out_amount = $data['give_out_amount'] ?? 0;
-            $model->employee_id_1 = $data['employee_id_1'] ?? 0;
-            $model->employee_id_1_title = $data['employee_id_1_title'] ?? "";
-            $model->send_time = $data['send_time'] ?? 0;
-            $model->start_time = $data['start_time'] ?? 0;
-            $model->end_time = $data['end_time'] ?? 0;
-            $model->crt_id = $user['id'];
-            $model->mark = $data['mark'] ?? "";
-            $model->save();
-
-            DB::commit();
-        }catch (\Exception $exception){
-            DB::rollBack();
-            return [false,$exception->getMessage()];
-        }
-
-        return [true, ''];
-    }
-
-    public function giveOutDel($data){
-        if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
-
-        try {
-            DB::beginTransaction();
-            $time = time();
-
-            GiveOut::where('del_time',0)
-                ->whereIn('id',$data['id'])
-                ->update(['del_time' => $time]);
-
-            DB::commit();
-        }catch (\Exception $exception){
-            DB::rollBack();
-            return [false,$exception->getMessage()];
-        }
-
-        return [true, ''];
-    }
-
-    public function giveOutDetail($data,$user){
-        if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
-        $customer = GiveOut::where('del_time',0)
-            ->where('id',$data['id'])
-            ->first();
-        if(empty($customer)) return [false,'发放记录不存在或已被删除'];
-        $customer = $customer->toArray();
-
-        $customer['crt_name'] = Employee::where('id',$customer['crt_id'])->value('emp_name');
-        $customer['crt_time'] = $customer['crt_time'] ? date("Y-m-d H:i:s",$customer['crt_time']): '';
-
-        return [true, $customer];
-    }
-
-    public function giveOutCommon($data,$user, $field = []){
-        if(empty($field)) $field = GiveOut::$field;
-
-        $model = GiveOut::Clear($user,$data);
-        $model = $model->where('del_time',0)
-            ->select($field)
-            ->orderby('id', 'desc');
-
-        if(! empty($data['employee_id_1_title'])) $model->where('employee_id_1_title', 'LIKE', '%'.$data['employee_id_1_title'].'%');
-        if(! empty($data['send_time'][0]) && ! empty($data['send_time'][1])) {
-            $return = $this->changeDateToTimeStampAboutRange($data['send_time']);
-            $model->where('send_time','>=',$return[0]);
-            $model->where('send_time','<=',$return[1]);
-        }
-        if(! empty($data['belong_time'][0]) && ! empty($data['belong_time'][1])) {
-            $return = $this->changeDateToTimeStampAboutRange($data['belong_time']);
-            $model->where('start_time','>=',$return[0]);
-            $model->where('end_time','<=',$return[1]);
-        }
-
-        return $model;
-    }
-
-    public function giveOutList($data,$user){
-        $model = $this->giveOutCommon($data, $user);
-        $list = $this->limit($model,'',$data);
-        $list = $this->fillData($list);
-
-        $list['count'] = $this->countTotal($list['data'], $user['header_default']);
-
-        return [true, $list];
-    }
-
-    public function giveOutRule(&$data, $user, $is_add = true){
-        if(empty($data['give_out_amount'])) return [false, '分红已发金额不能为空'];
-        $res = $this->checkNumber($data['give_out_amount'],2,'positive');
-        if(! $res['valid']) return [false,'分红已发金额:' . $res['error']];
-        if(empty($data['employee_id_1'])) return [false, '业务员不能为空'];
-        $employee = Employee::where('del_time',0)
-            ->where('id',$data['employee_id_1'])
-            ->first();
-        if(empty($employee)) return [false, '业务员不存在或已被删除'];
-        $data['employee_id_1_title'] = $employee->emp_name;
-
-        if(empty($data['send_time'])) return [false, '发放日期不能为空'];
-        $data['send_time'] = $this->changeDateToDate($data['send_time']);
-        if($data['send_time'] == null) return [false, '发放日期错误'];
-
-        if(empty($data['belong_time'][0]) || empty($data['belong_time'][1])) return [false, '归属日期不能为空'];
-        list($start_time,$end_time) = $this->changeDateToTimeStampAboutRange($data['belong_time'], false);
-        if ($start_time === null || $end_time === null || $start_time > $end_time) return [false, "归属日期的区间无效"];
-        $data['start_time'] = $start_time;
-        $data['end_time'] = $end_time;
-
-        if($is_add){
-
-        }else{
-            if(empty($data['id'])) return [false,'ID不能为空'];
-            $bool = GiveOut::where('id',$data['id'])
-                ->where('del_time',0)
-                ->exists();
-            if(! $bool) return [false,'发放记录不存在或已被删除'];
-        }
-
-        return [true, $data];
-    }
-
-    public function fillData($data){
-        if(empty($data['data'])) return $data;
-
-        foreach ($data['data'] as $key => $value){
-            $data['data'][$key]['send_time'] = $value['send_time'] ? date('Y-m-d',$value['send_time']) : '';
-            $start = $value['start_time'] ? date('Y-m-d',$value['start_time']) : '';
-            $end = $value['end_time'] ? date('Y-m-d',$value['end_time']) : '';
-            $string = "";
-            if(! empty($start) && ! empty($end)) $string = $start . "|" . $end;
-            $data['data'][$key]['belong_time'] = $string;
-        }
-
-        return $data;
-    }
-}