|
|
@@ -20,6 +20,7 @@ use app\common\model\master_worker\EngineerSettlementPermanently;
|
|
|
use app\common\logic\BaseLogic;
|
|
|
use app\common\model\master_worker\MasterWorker;
|
|
|
use app\common\model\master_worker\SalaryItemPermanently;
|
|
|
+use app\common\model\works\ServiceWork;
|
|
|
use DateTime;
|
|
|
use think\facade\Db;
|
|
|
use think\facade\Log;
|
|
|
@@ -269,7 +270,7 @@ class EngineerSettlementPermanentlyLogic extends BaseLogic
|
|
|
{
|
|
|
try {
|
|
|
// 限制每周一才能结算上周
|
|
|
- if(date("w") != 1) return false;
|
|
|
+ //if(date("w") != 1) return false;
|
|
|
|
|
|
// 兼职工程师-每周 period_type = 2
|
|
|
self::partTimeMaster($masterWorker_id,2);
|
|
|
@@ -294,7 +295,7 @@ class EngineerSettlementPermanentlyLogic extends BaseLogic
|
|
|
|
|
|
try {
|
|
|
// 限制每月一才能结算上月
|
|
|
- if((int)date("d") != 1) return false;
|
|
|
+ //if((int)date("d") != 1) return false;
|
|
|
|
|
|
// 保单工程师 period_type = 3
|
|
|
self::longTermMaster($masterWorker_id,3);
|
|
|
@@ -310,11 +311,13 @@ class EngineerSettlementPermanentlyLogic extends BaseLogic
|
|
|
|
|
|
public static function partTimeMaster($masterWorker_id = 0,$period_type = 0)
|
|
|
{
|
|
|
- Db::startTrans();
|
|
|
+ //Db::startTrans();
|
|
|
try {
|
|
|
$master_type = 1;
|
|
|
- $wh = ['type' => $master_type];
|
|
|
- $masterWorker_id && $wh['id'] = $masterWorker_id;
|
|
|
+ $wh = [['type', '=', $master_type]];
|
|
|
+ $mwids = ServiceWork::where('service_status',3)->where('finished_time','between',[time() - 65*86400,time()])->column('master_worker_id')??[];
|
|
|
+ if(!empty($mwids)) $wh[] = ['id','in', array_values(array_unique($mwids))];
|
|
|
+ $masterWorker_id && $wh[] = ['id','=',$masterWorker_id];
|
|
|
// 获取上周的周一开始与周末结束时间
|
|
|
$period_type == 2 && list($startTime,$endTime) = self::lastWeekTime();
|
|
|
$period_type == 3 && list($startTime,$endTime) = self::lastManthTime();
|
|
|
@@ -361,10 +364,10 @@ class EngineerSettlementPermanentlyLogic extends BaseLogic
|
|
|
]);
|
|
|
}
|
|
|
}
|
|
|
- Db::commit();
|
|
|
+ //Db::commit();
|
|
|
return true;
|
|
|
} catch (\Exception $e) {
|
|
|
- Db::rollback();
|
|
|
+ //Db::rollback();
|
|
|
self::setError($e->getFile().':'.$e->getLine().':'.$e->getMessage());
|
|
|
return false;
|
|
|
}
|
|
|
@@ -372,11 +375,13 @@ class EngineerSettlementPermanentlyLogic extends BaseLogic
|
|
|
|
|
|
public static function longTermMaster($masterWorker_id = 0,$period_type = 0)
|
|
|
{
|
|
|
- Db::startTrans();
|
|
|
+ //Db::startTrans();
|
|
|
try {
|
|
|
- $master_type = 1;
|
|
|
- $wh = ['type' => $master_type];
|
|
|
- $masterWorker_id && $wh['id'] = $masterWorker_id;
|
|
|
+ $master_type = 2;
|
|
|
+ $wh = [['type', '=', $master_type]];
|
|
|
+ $mwids = ServiceWork::where('service_status',3)->where('finished_time','between',[time() - 65*86400,time()])->column('master_worker_id')??[];
|
|
|
+ if(!empty($mwids)) $wh[] = ['id','in', array_values(array_unique($mwids))];
|
|
|
+ $masterWorker_id && $wh[] = ['id','=',$masterWorker_id];
|
|
|
// 获取上周的周一开始与周末结束时间
|
|
|
$period_type == 2 && list($startTime,$endTime) = self::lastWeekTime();
|
|
|
$period_type == 3 && list($startTime,$endTime) = self::lastManthTime();
|
|
|
@@ -423,10 +428,10 @@ class EngineerSettlementPermanentlyLogic extends BaseLogic
|
|
|
]);
|
|
|
}
|
|
|
}
|
|
|
- Db::commit();
|
|
|
+ //Db::commit();
|
|
|
return true;
|
|
|
} catch (\Exception $e) {
|
|
|
- Db::rollback();
|
|
|
+ //Db::rollback();
|
|
|
self::setError($e->getFile().':'.$e->getLine().':'.$e->getMessage());
|
|
|
return false;
|
|
|
}
|
|
|
@@ -434,11 +439,13 @@ class EngineerSettlementPermanentlyLogic extends BaseLogic
|
|
|
|
|
|
public static function fullTimeMaster($masterWorker_id = 0,$period_type = 0)
|
|
|
{
|
|
|
- Db::startTrans();
|
|
|
+ //Db::startTrans();
|
|
|
try {
|
|
|
- $master_type = 1;
|
|
|
- $wh = ['type' => $master_type];
|
|
|
- $masterWorker_id && $wh['id'] = $masterWorker_id;
|
|
|
+ $master_type = 3;
|
|
|
+ $wh = [['type', '=', $master_type]];
|
|
|
+ $mwids = ServiceWork::where('service_status',3)->where('finished_time','between',[time() - 65*86400,time()])->column('master_worker_id')??[];
|
|
|
+ if(!empty($mwids)) $wh[] = ['id','in', array_values(array_unique($mwids))];
|
|
|
+ $masterWorker_id && $wh[] = ['id','=',$masterWorker_id];
|
|
|
// 获取上周的周一开始与周末结束时间
|
|
|
$period_type == 2 && list($startTime,$endTime) = self::lastWeekTime();
|
|
|
$period_type == 3 && list($startTime,$endTime) = self::lastManthTime();
|
|
|
@@ -485,10 +492,10 @@ class EngineerSettlementPermanentlyLogic extends BaseLogic
|
|
|
]);
|
|
|
}
|
|
|
}
|
|
|
- Db::commit();
|
|
|
+ //Db::commit();
|
|
|
return true;
|
|
|
} catch (\Exception $e) {
|
|
|
- Db::rollback();
|
|
|
+ //Db::rollback();
|
|
|
self::setError($e->getFile().':'.$e->getLine().':'.$e->getMessage());
|
|
|
return false;
|
|
|
}
|
|
|
@@ -505,7 +512,7 @@ class EngineerSettlementPermanentlyLogic extends BaseLogic
|
|
|
$last_week_sunday->modify('+6 days');
|
|
|
$last_week_start = $last_week_monday->getTimestamp(); // 上周一零点时间戳
|
|
|
$last_week_end = $last_week_sunday->getTimestamp()+86399; // 上周日零点时间戳
|
|
|
- return [$last_week_start,$last_week_end];
|
|
|
+ return [$last_week_start + 7*86400,$last_week_end + 7*86400];
|
|
|
/*return [
|
|
|
'startTime' => $last_week_start,
|
|
|
'endTime' => $last_week_end
|
|
|
@@ -523,7 +530,7 @@ class EngineerSettlementPermanentlyLogic extends BaseLogic
|
|
|
$firstDayOfLastMonth->modify('-1 month')->setTime(0, 0, 0); // 上个月的第一天
|
|
|
$last_manth_start = $firstDayOfLastMonth->getTimestamp();
|
|
|
$last_manth_end = $lastDayOfLastMonth->getTimestamp();
|
|
|
- return [$last_manth_start,$last_manth_end];
|
|
|
+ return [$last_manth_start + 30*86400,$last_manth_end + 30*86400];
|
|
|
/*return [
|
|
|
'startTime' => $last_manth_start,
|
|
|
'endTime' => $last_manth_end
|