Staffwages.php 3.77 KB
<?php

namespace addons\qingdong\controller;

use addons\qingdong\model\Staffwages as wagesModel;

use addons\fastflow\model\Jxbunq;
use addons\fastflow\model\Ekmdnj;

class Staffwages  extends StaffApi
{
    protected $noNeedLogin = ['*'];

    //工资列表
    public function wagesList(){

        $year = input('year',date('Y'));

        $staff_id = $this->auth->id;

        $list = (new wagesModel())->with('staff')->where('time','LIKE','%'.$year.'%')->where('staff_id',$staff_id)->select();

        $reimburse_all = (new wagesModel())->with('staff')->where('time','LIKE','%'.$year.'%')->where('staff_id',$staff_id)->sum('reimburse_price');

        $ekmdnjmodel = new Ekmdnj();
        $jxbunqmodel = new Jxbunq();

        foreach ($list as &$item){

            $takes_ids = $item['takes_ids'];

            $item['ekmdnj'] = $ekmdnjmodel->where("find_in_set(id,'$takes_ids')")->select();

            $reimburse_ids = $item['reimburse_ids'];

            $item['jxbunq'] = $jxbunqmodel->where("find_in_set(id,'$reimburse_ids')")->select();

            $item['reimburse_all'] =  $reimburse_all;

        }

        $this->success('工资列表',$list);

    }

    //提成 列表
    public function commissionList(){

        $year = input('year',date('Y'));

        $staff_id = $this->auth->id;

        $list = (new wagesModel())->with('staff')->where('time','LIKE','%'.$year.'%')->where('staff_id',$staff_id)->select();
        // halt((new wagesModel())->select());
        $ekmdnjmodel = new Ekmdnj();

        foreach ($list as &$item){

            $takes_ids = $item['takes_ids'];

            $item['ekmdnj'] = $ekmdnjmodel->where("find_in_set(id,'$takes_ids')")->select();

        }

        $this->success('提成列表',$list);

    }

    //报销     列表
    public function jxbunqList(){

        $year = input('year',date('Y'));

        $staff_id = $this->auth->id;

        $list = (new wagesModel())->with('staff')->where('time','LIKE','%'.$year.'%')->where('staff_id',$staff_id)->select();

        $reimburse_all = (new wagesModel())->with('staff')->where('time','LIKE','%'.$year.'%')->where('staff_id',$staff_id)->sum('reimburse_price');

        $jxbunqmodel = new Jxbunq();

        foreach ($list as &$item){

            $reimburse_ids = $item['reimburse_ids'];

            $item['jxbunq'] = $jxbunqmodel->where("find_in_set(id,'$reimburse_ids')")->select();

            $item['reimburse_all'] =  $reimburse_all;

        }

        $this->success('提成列表',$list);

    }

    //我的任务
    public function myTask(){

        $staffModel = new \addons\qingdong\model\Staff();

        $data = $staffModel->where('id',$this->auth->id)->field('id,admin_id,group_ids,role,rules,name,basic_task,target_task,monthly_salary')->find();

        $this->success('我的任务',$data);

    }

    //修改任务
    public function editmyTask(){

        $monthly_salary = input('monthly_salary','');
        $target_task = input('target_task','');

        $staffModel = new \addons\qingdong\model\Staff();

        $data = $staffModel->where('id',$this->auth->id)->field('id,admin_id,group_ids,role,rules,name,basic_task,target_task,monthly_salary')->find();

        $data->monthly_salary = $monthly_salary;
        $data->target_task = $target_task;
        $data->save();

        $this->success('修改成功');
    }

    //广告费用
    public function advertisement(){


        $contractModel = new \addons\qingdong\model\Contract();

        $list = $contractModel->with([
            'customer',
            'contacts',
            'ownerStaff',
        ])->where('owner_staff_id',$this->auth->id)->select();

        $price = $contractModel->where('owner_staff_id',$this->auth->id)->sum('main_ljpzvx');

        $this->success('广告费用',['list'=>$list,'price'=>$price]);
    }






}