cqp 3 тижнів тому
батько
коміт
22b58fed11

+ 12 - 0
app/Http/Controllers/Api/StatisticsController.php

@@ -66,4 +66,16 @@ class StatisticsController extends BaseController
             return $this->json_return(201,$data);
         }
     }
+
+    public function statisticsEmployeeSalary(Request $request){
+        $service = new StatisticsService();
+        $userData = $request->userData->toArray();
+        list($status,$data) = $service->statisticsEmployeeSalary($request->all(),$userData);
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
 }

+ 16 - 0
app/Http/Controllers/Api/TPlusController.php

@@ -38,4 +38,20 @@ class TPlusController extends BaseController
             return $this->json_return(201,$data);
         }
     }
+
+    public function synSalaryEmployee(Request $request)
+    {
+        $service = new TPlusServerService();
+        $error = $service->getError();
+        if(! empty($error)) return $this->json_return(201, $error);
+
+        $userData = $request->userData->toArray();
+        list($status,$data) = $service->synSalaryEmployee($request->all(),$userData);
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
 }

+ 14 - 4
app/Jobs/ProcessDataJob.php

@@ -21,13 +21,15 @@ class ProcessDataJob implements ShouldQueue
 
     protected $data;
     protected $user;
+    protected $type;
 
     public $timeout = 1800;
 
-    public function __construct($data, $user)
+    public function __construct($data, $user, $type = 1)
     {
         $this->data = $data;
         $this->user = $user;
+        $this->type = $type;
     }
 
     public function handle()
@@ -36,8 +38,15 @@ class ProcessDataJob implements ShouldQueue
         try {
             $data = $this->data;
             $user = $this->user;
+            $type = $this->type;
+
+            if($type == 1){
+                //收付款单
+                list($status, $msg) = $service->synRevenueCostFromTPlus($data, $user);
+            }else{
+                list($status, $msg) = $service->synSalaryEmployeeFromMine($data, $user);
+            }
 
-            list($status, $msg) = $service->synRevenueCostFromTPlus($data, $user);
             $this->finalDo($msg, $service);
         } catch (\Throwable $e) {
             $this->finalDo("异常:" . $e->getMessage(), $service);
@@ -46,8 +55,9 @@ class ProcessDataJob implements ShouldQueue
     }
 
     private function finalDo($msg, $service){
-        $service->delTableKey();
-        $service->clearTmpTable();
+        $type = $this->type;
+        $service->delTableKey($type);
+        if($type == 1) $service->clearTmpTable();
 
         $user = $this->user;
         $data = $this->data;

+ 2 - 0
app/Model/RevenueCost.php

@@ -23,6 +23,7 @@ class RevenueCost extends Model
     ];
 
     const job = 'yf_revenue_cost';
+    const job2 = 'salary_employee';
 
     public static $field = ['id','order_time','order_type','price_1','price_1_total','price_2','price_2_total','price_3','price_3_total','price_4','price_4_total','payment_amount','profit','profit_rate','employee_id_1','employee_id_1_title'];
     public static $field_xhd = ['id','order_type','order_number','order_time','employee_id_1','employee_id_1_title','employee_id_2','employee_id_2_title','customer_code','customer_title','channel_finance','channel_details','product_code','product_title','product_size','unit','price_1','price_1_total','price_2','price_2_total','quantity','price_3','price_3_total','price_4','price_4_total','profit','profit_rate'];
@@ -30,4 +31,5 @@ class RevenueCost extends Model
     public static $field_hkd_main = ['order_id as id','order_type','order_number','order_time','employee_id_1','employee_id_1_title','employee_id_2','employee_id_2_title','payment_amount','profit','order_id'];
     public static $field_hkd_detail = ['order_type','order_number','order_time','employee_id_1','employee_id_1_title','employee_id_2','employee_id_2_title','customer_code','customer_title','product_code','product_title','product_size','unit','price_1','price_1_total','price_2','price_2_total','quantity','price_3','price_3_total','price_4','price_4_total','profit','profit_rate','order_number_upstream','payment_amount'];
     public static $field_hkd_profit_main = ['rc.employee_id_2','rc.employee_id_2_title','rc.payment_amount','employee_index.start_time','employee_index.end_time','employee_index.index','employee_index.id'];
+    public static $field_hkd_salary_main = ['order_id as id','order_type','order_number','order_time','employee_id_1','employee_id_1_title','employee_id_2','employee_id_2_title','payment_amount','profit','order_id'];
 }

+ 16 - 0
app/Model/SalaryEmployee.php

@@ -0,0 +1,16 @@
+<?php
+
+namespace App\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+class SalaryEmployee extends Model
+{
+    protected $guarded = [];
+    protected $table = "salary_employee"; //指定表
+    const CREATED_AT = 'crt_time';
+    const UPDATED_AT = 'upd_time';
+    protected $dateFormat = 'U';
+
+    public static $field = ['id','order_time','order_type','payment_amount','payment_amount_not_include_activity','payment_amount_activity','payment_amount_lower_than_rate','payment_amount_greater_than_rate','business','sale_bonus','index_1','pay_in_advance','basic_salary','should_pay','employee_id_1','employee_id_1_title'];
+}

+ 32 - 1
app/Service/ExportFileService.php

@@ -8,6 +8,7 @@ use App\Model\GiveOut;
 use App\Model\Product;
 use App\Model\RevenueCost;
 use App\Model\RevenueCostTotal;
+use App\Model\SalaryEmployee;
 use Illuminate\Support\Facades\DB;
 use Maatwebsite\Excel\Facades\Excel;
 
@@ -52,7 +53,7 @@ class ExportFileService extends Service
         self::type_six => '回款单统计表',
         self::type_seven => '发放统计表',
         self::type_eight => '利润分配统计表',
-        self::type_nine => '虚拟采购单',
+        self::type_nine => '业务员工资统计表',
         self::type_ten => '客户',
         self::type_eve => '现存量',
         self::type_twl => '库存台账',
@@ -343,6 +344,36 @@ class ExportFileService extends Service
         return $this->saveExportData($return,$header);
     }
 
+    public function nine($ergs,$user){
+        $id = $ergs['id'];
+
+        $field = SalaryEmployee::$field;
+
+        $return = [];
+        $header_default = config("header.73") ?? [];
+        $column = array_column($header_default, 'key');
+        $header = array_column($header_default, 'value');
+        DB::table('salary_employee')
+            ->where('del_time', 0)
+            ->whereIn('id', $id)
+            ->select($field)
+            ->orderBy('order_time','desc')
+            ->chunkById(500, function ($data) use (&$return, $column) {
+                $data = Collect($data)->map(function ($object) {
+                    return (array)$object;
+                })->toArray();
+                $list['data'] = $data;
+
+                //订单数据
+                $service = new StatisticsService();
+                $list = $service->statisticsEmployeeSalaryFillData($list);
+
+                $this->fillData($list['data'], $column, $return);
+            });
+
+        return $this->saveExportData($return,$header);
+    }
+
     public function getListForSearch($ergs, $user){
         $data = $ergs['order_search'];
         $id = [];

+ 52 - 5
app/Service/StatisticsService.php

@@ -6,6 +6,7 @@ use App\Model\EmployeeIndex;
 use App\Model\GiveOut;
 use App\Model\RevenueCost;
 use App\Model\RevenueCostTotal;
+use App\Model\SalaryEmployee;
 use Illuminate\Support\Facades\DB;
 
 class StatisticsService extends Service
@@ -147,7 +148,7 @@ class StatisticsService extends Service
 
     public function statisticsRevenueCostThreeCommon($data,$user, $field = []){
         if(empty($field)) {
-            $field = RevenueCost::$field_hkd_main;
+            $field = RevenueCost::$field_hkd_salary_main;
             $field[] = DB::raw('sum(payment_amount) as payment_amount');
             $field[] = DB::raw('sum(price_4_total) as price_4_total');
             $field[] = DB::raw('sum(profit) as profit');
@@ -310,8 +311,10 @@ class StatisticsService extends Service
 
         // 取出所有涉及的 employee_id 和时间区间
         $employeeIds = array_column($existingData, 'employee_id_2');
-        $minStart = min(array_column($existingData, 'start_time'));
-        $maxEnd   = max(array_column($existingData, 'end_time'));
+        $start_time = array_column($existingData, 'start_time');
+        $minStart = ! empty($start_time) ? min($start_time) : 0;
+        $end_time = array_column($existingData, 'end_time');
+        $maxEnd   = ! empty($end_time) ? max($end_time) : 0;
 
         // 一次性查出这些员工在最大区间范围内的所有指标
         $results = EmployeeIndex::where('del_time', 0)
@@ -333,8 +336,11 @@ class StatisticsService extends Service
 
         // 取出所有涉及的 employee_id 和时间区间
         $employeeIds = array_column($existingData, 'employee_id_2');
-        $minStart = min(array_column($existingData, 'start_time'));
-        $maxEnd   = max(array_column($existingData, 'end_time'));
+
+        $start_time = array_column($existingData, 'start_time');
+        $minStart = ! empty($start_time) ? min($start_time) : 0;
+        $end_time = array_column($existingData, 'end_time');
+        $maxEnd   = ! empty($end_time) ? max($end_time) : 0;
 
         // 一次性查出这些员工在最大区间范围内的所有指标
         $results = GiveOut::where('del_time', 0)
@@ -406,4 +412,45 @@ class StatisticsService extends Service
         }
         $data['payed'] = $give_out;
     }
+
+    public function statisticsEmployeeSalaryCommon($data,$user, $field = []){
+        if(empty($field)) {
+            $field = SalaryEmployee::$field;
+        }
+        $model = SalaryEmployee::where('del_time',0)
+            ->where('order_type',RevenueCost::ORDER_THREE)
+            ->select($field)
+            ->orderby('order_time', 'desc');
+        if(! empty($data['order_time'][0]) && ! empty($data['order_time'][1])){
+            list($start_time, $end_time) = $this->changeDateToTimeStampAboutRange($data['order_time'],false);
+            if ($start_time === null || $end_time === null || $start_time > $end_time) return [false, "单据日期的区间无效"];
+            $start_time = strtotime(date("Y-m-01",$start_time));
+            $end_time = strtotime(date("Y-m-01",$end_time));
+            $model->where('order_time', '>=', $start_time)
+                ->where('order_time', '<=', $end_time);
+        }
+        if(! empty($data['employee_id_1_title'])) $model->where('employee_id_1_title', 'LIKE', '%'.$data['employee_id_1_title'].'%');
+
+        return [true, $model];
+    }
+
+    public function statisticsEmployeeSalary($data,$user){
+        list($status, $model) = $this->statisticsEmployeeSalaryCommon($data, $user);
+        if(! $status) return [false, $model];
+        $list = $this->limit($model,'',$data);
+        $list = $this->statisticsEmployeeSalaryFillData($list);
+
+        return [true, $list];
+    }
+
+    public function statisticsEmployeeSalaryFillData($data){
+        if(empty($data['data'])) return $data;
+
+        foreach ($data['data'] as $key => $value){
+            $order_time = $value['order_time'] ? date('Y-m',$value['order_time']) : '';
+            $data['data'][$key]['order_time'] = $order_time;
+        }
+
+        return $data;
+    }
 }

+ 237 - 2
app/Service/TPlusServerService.php

@@ -6,9 +6,11 @@ use App\Jobs\ProcessDataJob;
 use App\Model\Depart;
 use App\Model\Employee;
 use App\Model\EmployeeDepartPermission;
+use App\Model\EmployeeIndex;
 use App\Model\Product;
 use App\Model\RevenueCost;
 use App\Model\RevenueCostTotal;
+use App\Model\SalaryEmployee;
 use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Schema;
@@ -46,6 +48,7 @@ class TPlusServerService extends Service
     }
 
     private $table = "tmp_revenue_cost_data";
+    private $table_2 = "tmp_salary_employee";
 
     /**
      * 同步人员部门
@@ -741,7 +744,239 @@ class TPlusServerService extends Service
         if (Schema::hasTable($this->table)) DB::table($this->table)->truncate();
     }
 
-    public function delTableKey(){
-        $this->dellimitingSendRequest($this->table);
+    public function delTableKey($type = 1){
+        $key = $this->table;
+        if($type == 2) $key = $this->table_2;
+        $this->dellimitingSendRequest($key);
+    }
+
+    public function synSalaryEmployee($data, $user){
+        if(empty($data['crt_time'][0]) || empty($data['crt_time'][1])) return [false, '同步时间不能为空'];
+        list($start_time, $end_time) = $this->changeDateToTimeStampAboutRange($data['crt_time'],false);
+        if ($start_time === null || $end_time === null || $start_time > $end_time) return [false, "同步时间:时间区间无效"];
+        list($bool, $bool_msg) = $this->isOverThreeMonths($start_time, $end_time);
+        if(! $bool) return [false, $bool_msg];
+        $data['start_timeStamp'] = $start_time;
+        $data['end_timeStamp'] = $end_time;
+        $data['start_time'] = strtotime(date("Y-m-01",$data['start_timeStamp']));
+        $data['end_time'] = strtotime(date("Y-m-01"),$data['end_timeStamp']);
+        $data['operation_time'] = time();
+
+        list($status,$msg) = $this->limitingSendRequest($this->table_2);
+        if(! $status) return [false, '业务员工资同步正在后台运行,请稍后'];
+
+        //同步
+//        list($status, $msg) = $this->synSalaryEmployeeFromMine($data, $user);
+//        if(! $status) {
+//            $this->dellimitingSendRequest($this->table_2);
+//            return [false, $msg];
+//        }
+
+        //队列
+        ProcessDataJob::dispatch($data, $user, 2)->onQueue(RevenueCost::job2);
+
+        return [true, '业务员工资相关信息同步已进入后台任务'];
+    }
+
+    public function synSalaryEmployeeFromMine($data, $user){
+        //创建临时表 如果不存在
+        $this->createTmpTable2();
+        //清理临时表 如果内容不为空
+        $this->clearTmpTable2();
+
+        //写入临时表
+        DB::table('revenue_cost')
+            ->where('del_time', 0)
+            ->where('order_type', RevenueCost::ORDER_THREE)
+            ->where('order_time','>=',$data['start_timeStamp'])
+            ->where('order_time','<=',$data['end_timeStamp'])
+            ->select([
+                'employee_id_1',
+                'employee_id_1_title',
+                DB::raw("DATE_FORMAT(FROM_UNIXTIME(order_time), '%Y-%m-01') as order_time"),
+                DB::raw("SUM(payment_amount) as payment_amount"),
+                DB::raw("SUM(CASE WHEN is_activity = 0 THEN payment_amount ELSE 0 END) as payment_amount_not_include_activity"),
+                DB::raw("SUM(CASE WHEN is_activity = 1 THEN payment_amount ELSE 0 END) as payment_amount_activity"),
+                DB::raw("SUM(CASE WHEN profit_rate < customer_profit_rate and is_activity = 0 THEN payment_amount ELSE 0 END) as payment_amount_lower_than_rate"),
+                DB::raw("SUM(CASE WHEN profit_rate >= customer_profit_rate and is_activity = 0 THEN payment_amount ELSE 0 END) as payment_amount_greater_than_rate"),
+                DB::raw("SUM(CASE WHEN profit_rate >= customer_profit_rate and is_activity = 0 THEN price_4_total ELSE 0 END) as business"),
+                DB::raw("ROW_NUMBER() OVER (ORDER BY MIN(id)) as fake_id")
+            ])
+            ->groupBy('employee_id_1', DB::raw("DATE_FORMAT(FROM_UNIXTIME(order_time), '%Y-%m-01')"))
+            ->orderBy('order_time', 'desc')
+            ->chunkById(500, function ($data){
+                $dataArray = Collect($data)->map(function ($object){
+                    return (array)$object;
+                })->toArray();
+
+                $indexes = $this->getEmployeeIndex($dataArray);
+                foreach ($dataArray as $key => $value){
+                    $value['index_' . EmployeeIndex::TYPE_ONE] = 0;
+                    $value['index_' . EmployeeIndex::TYPE_SIX] = 0;
+                    $value['index_' . EmployeeIndex::TYPE_EIGHT] = 0;
+                    $this->findIndex($indexes, $value);
+
+                    $dataArray[$key]['order_type'] = RevenueCost::ORDER_THREE;
+                    $dataArray[$key]['order_time'] = strtotime($value['order_time']);
+                    $dataArray[$key]['sale_bonus'] = $value['index_' . EmployeeIndex::TYPE_EIGHT];
+                    $dataArray[$key]['index_' . EmployeeIndex::TYPE_ONE] = $value['index_' . EmployeeIndex::TYPE_ONE];
+                    $rate = bcdiv($value['index_' . EmployeeIndex::TYPE_ONE],100,2);
+                    $pay_in_advance = bcmul($rate, $value['payment_amount_greater_than_rate'],2);
+                    $dataArray[$key]['pay_in_advance'] = $pay_in_advance;
+                    $dataArray[$key]['basic_salary'] = $value['index_' . EmployeeIndex::TYPE_SIX];
+                    $dataArray[$key]['should_pay'] = bcadd(bcadd($value['index_' . EmployeeIndex::TYPE_EIGHT], $pay_in_advance,2),$value['index_' . EmployeeIndex::TYPE_SIX],2);
+
+                    unset($dataArray[$key]['fake_id']);
+                }
+
+                DB::table($this->table_2)->insert($dataArray);
+            }, 'fake_id');
+
+        //更新数据
+        list($status,$msg) = $this->updateSalaryEmployee($data);
+        if(! $status) return [false, $msg];
+
+        //清理临时表 如果内容不为空
+        $this->clearTmpTable2();
+        //释放redis
+        $this->delTableKey(2);
+
+        return [true, '同步成功'];
+    }
+
+    private function getEmployeeIndex($existingData)
+    {
+        if (empty($existingData)) {
+            return collect();
+        }
+
+        // 取出所有涉及的 employee_id 和时间区间
+        $employeeIds = array_column($existingData, 'employee_id_2');
+        $time = array_column($existingData, 'order_time');
+        $minStart = ! empty($time) ? min($time) : 0;
+        $maxEnd   = ! empty($time) ? max($time) : 0;
+
+        // 一次性查出这些员工在最大区间范围内的所有指标
+        $results = EmployeeIndex::where('del_time', 0)
+            ->whereIn('type', [EmployeeIndex::TYPE_ONE, EmployeeIndex::TYPE_EIGHT])
+            ->whereIn('employee_id', $employeeIds)
+            ->where('start_time', '<=', $maxEnd)
+            ->where('end_time', '>=', $minStart)
+            ->select('start_time','end_time','employee_id','index','type')
+            ->get();
+
+        return $results;
+    }
+
+    private function findIndex($indexes, &$value){
+        // 找到所有符合条件的 index(可能多个 type)
+        $matchedIndexes = $indexes->filter(function ($item) use ($value) {
+            return $item['employee_id'] == $value['employee_id_1']
+                && $item['start_time'] <= $value['end_time']
+                && $item['end_time'] >= $value['start_time'];
+        });
+        // 按 type 去重,只保留第一次出现的
+        $uniqueByType = [];
+        foreach ($matchedIndexes as $item) {
+            $index = "index_" . $item['type'];
+            if (! isset($uniqueByType[$index])) {
+                $uniqueByType[$index] = $item['index'];
+            }
+        }
+        $value = array_merge($value, $uniqueByType);
+    }
+
+    private function createTmpTable2(){
+        $table = $this->table_2;
+        if (! Schema::hasTable($table)) {
+            // 可以通过 migration 创建,或程序启动时检查
+            Schema::create($table, function (Blueprint $table) {
+                $table->bigIncrements('id'); // BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY
+                $table->integer('order_type')->default(0);
+                $table->integer('order_time')->default(0);
+                $table->string('employee_id_1_title', 100)->default('');
+                $table->bigInteger('employee_id_1')->default(0);
+                $table->decimal('payment_amount', 12, 2)->default(0);
+                $table->decimal('payment_amount_not_include_activity', 12, 2)->default(0);
+                $table->decimal('payment_amount_activity', 12, 2)->default(0);
+                $table->decimal('payment_amount_lower_than_rate', 12, 2)->default(0);
+                $table->decimal('payment_amount_greater_than_rate', 12, 2)->default(0);
+                $table->decimal('business', 12, 2)->default(0);
+                $table->decimal('sale_bonus', 12, 2)->default(0);
+                $table->decimal('index_1', 10, 2)->default(0);
+                $table->decimal('pay_in_advance', 12, 2)->default(0);
+                $table->decimal('basic_salary', 12, 2)->default(0);
+                $table->decimal('should_pay', 12, 2)->default(0);
+            });
+        }
+    }
+
+    public function clearTmpTable2(){
+        if (Schema::hasTable($this->table_2)) DB::table($this->table_2)->truncate();
+    }
+
+    private function updateSalaryEmployee($data){
+        try {
+            $start_timeStamp = $data['start_time'];
+            $end_timeStamp = $data['end_time'];
+            $tmpTable = $this->table_2;
+            $time = time();
+            $ergs = $data;
+
+            DB::transaction(function () use ($start_timeStamp, $end_timeStamp, $tmpTable,$time, $ergs) {
+                // 1. 先软删除旧数据(你已有)
+                SalaryEmployee::where('del_time', 0)
+                    ->where('order_time', '>=', $start_timeStamp)
+                    ->where('order_time', '<=', $end_timeStamp)
+                    ->update(['del_time' => $time]);
+
+                // 2. 分批从临时表插入新数据
+                $batchSize = 500;
+                $lastId = 0;
+                do {
+                    $chunk = DB::table($tmpTable)
+                        ->where('id', '>', $lastId)
+                        ->orderBy('id')
+                        ->limit($batchSize)
+                        ->get();
+
+                    if ($chunk->isEmpty()) {
+                        break;
+                    }
+
+                    $data = $chunk->map(function ($item) use($time){
+                        return [
+                            'order_type' => $item->order_type,
+                            'order_time' => $item->order_time,
+                            'employee_id_1_title' => $item->employee_id_1_title,
+                            'employee_id_1' => $item->employee_id_1 ?? 0,
+                            'payment_amount' => $item->payment_amount,
+                            'payment_amount_not_include_activity' => $item->payment_amount_not_include_activity,
+                            'payment_amount_activity' => $item->payment_amount_activity,
+                            'payment_amount_lower_than_rate' => $item->payment_amount_lower_than_rate,
+                            'payment_amount_greater_than_rate' => $item->payment_amount_greater_than_rate,
+                            'business' => $item->business,
+                            'sale_bonus' => $item->sale_bonus,
+                            'index_1' => $item->index_1,
+                            'pay_in_advance' => $item->pay_in_advance,
+                            'basic_salary' => $item->basic_salary,
+                            'should_pay' => $item->should_pay,
+                            'crt_time' => $time,
+                        ];
+                    })->toArray();
+
+                    // 每批单独插入(可选:加小事务)
+                    SalaryEmployee::insert($data);
+
+                    // 更新 lastId
+                    $lastId = $chunk->last()->id;
+
+                } while ($chunk->count() == $batchSize);
+            });
+        }catch  (\Throwable $exception){
+            return [false, "单据明细同步异常" . $exception->getMessage() . "|" . $exception->getLine() . "|" . $exception->getFile()];
+        }
+
+        return [true, ''];
     }
 }

+ 91 - 0
config/header/73.php

@@ -0,0 +1,91 @@
+<?php
+/**
+ * '菜单ID' => [
+ *     '字段英文名' =》 '字段中文名'
+ * ]
+ */
+
+return [
+    [
+        'key' =>'order_time',
+        'value' => '统计年月',
+    ],
+    [
+        'key' =>'employee_id_1_title',
+        'value' => '业务员',
+    ],
+    [
+        'key' =>'payment_amount',
+        'value' => '回款总金额',
+        'is_total' => true,
+    ],
+    [
+        'key' =>'payment_amount_not_include_activity',
+        'value' => '回款金额(非活动)',
+        'value1' => '业务员所有非活动属性的回款单金额总计',
+        'is_total' => true,
+    ],
+    [
+        'key' =>'payment_amount_activity',
+        'value' => '回款金额(活动)',
+        'value1' => '业务员所有活动属性的回款单金额总计',
+        'is_total' => true,
+    ],
+    [
+        'key' =>'payment_amount_lower_than_rate',
+        'value' => '回款金额(毛利率低于预设的客户毛利率)',
+        'value1' => '汇总条件
+                     一:非活动属性的回款单
+                     二:回款单明细的毛利率<T+中的客户档案的毛利率
+                     达成条件,则汇总回款金额',
+        'is_total' => true,
+    ],
+    [
+        'key' =>'payment_amount_greater_than_rate',
+        'value' => '回款金额(毛利率高于预设的客户毛利率)',
+        'value1' => '汇总条件
+                     一:非活动属性的回款单
+                     二:回款单明细的毛利率>=T+中的客户档案的毛利率
+                     达成条件,则汇总回款金额',
+        'is_total' => true,
+    ],
+    [
+        'key' =>'business',
+        'value' => '成本金额',
+        'value1' => '汇总条件
+                     一:非活动属性的回款单
+                     二:回款单明细的毛利率>=T+中的客户档案的毛利率
+                     达成条件,则汇总存货的存货业务成本金额',
+        'is_total' => true,
+    ],
+    [
+        'key' =>'salary_bonus',
+        'value' => '销售奖金',
+        'value1' => '人员档案中该业务员统计年月内的销售奖金',
+        'is_total' => true,
+    ],
+    [
+        'key' =>'index_1',
+        'value' => '预支分红比例',
+        'value1' => '人员档案中该业务员统计年月内的预支分红比例',
+        'is_total' => false,
+    ],
+    [
+        'key' =>'pay_in_advance',
+        'value' => '预支分红提成',
+        'value1' => '回款金额(毛利率高于预设的客户毛利率) * 预支分红比例',
+        'is_total' => true,
+    ],
+    [
+        'key' =>'basic_salary',
+        'value' => '基本工资',
+        'value1' => '人员档案中该业务员统计年月内的基本工资',
+        'is_total' => true,
+    ],
+    [
+        'key' =>'should_pay',
+        'value' => '应发金额',
+        'value1' => '销售奖金 + 预支分红提成 + 基本工资',
+        'is_total' => true,
+    ],
+];

+ 3 - 0
routes/api.php

@@ -134,6 +134,7 @@ Route::group(['middleware'=> ['checkLogin']],function ($route){
     //同步T+人员部门结构
     $route->any('synPersonDepart', 'Api\TPlusController@synPersonDepart');
     $route->any('synRevenueCost', 'Api\TPlusController@synRevenueCost');
+    $route->any('synSalaryEmployee', 'Api\TPlusController@synSalaryEmployee');
 
     //收入成本
     $route->any('statisticsRevenueCost', 'Api\StatisticsController@statisticsRevenueCost');
@@ -142,4 +143,6 @@ Route::group(['middleware'=> ['checkLogin']],function ($route){
     $route->any('statisticsRevenueCostThreeDetail', 'Api\StatisticsController@statisticsRevenueCostThreeDetail');
     //利润分配
     $route->any('statisticsProfit', 'Api\StatisticsController@statisticsProfit');
+    //业务员工资
+    $route->any('statisticsEmployeeSalary', 'Api\StatisticsController@statisticsEmployeeSalary');
 });