commit
4c2fa448cb
@ -20,6 +20,7 @@ use app\adminapi\controller\BaseAdminController;
|
|||||||
use app\adminapi\lists\task_template\TaskTemplateLists;
|
use app\adminapi\lists\task_template\TaskTemplateLists;
|
||||||
use app\common\logic\task_template\TaskTemplateLogic;
|
use app\common\logic\task_template\TaskTemplateLogic;
|
||||||
use app\adminapi\validate\task_template\TaskTemplateValidate;
|
use app\adminapi\validate\task_template\TaskTemplateValidate;
|
||||||
|
use app\common\model\Company;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,8 +54,19 @@ class TaskTemplateController extends BaseAdminController
|
|||||||
{
|
{
|
||||||
$params = (new TaskTemplateValidate())->post()->goCheck('add');
|
$params = (new TaskTemplateValidate())->post()->goCheck('add');
|
||||||
$params['admin_id'] = $this->adminId;
|
$params['admin_id'] = $this->adminId;
|
||||||
|
$company = Company::find($params['company_id']);
|
||||||
|
if ($company->company_type == 41) {
|
||||||
|
// 创建 镇管理公司 任务模板
|
||||||
|
$result = TaskTemplateLogic::addTownTaskTemplate($params);
|
||||||
|
} else {
|
||||||
$result = TaskTemplateLogic::add($params);
|
$result = TaskTemplateLogic::add($params);
|
||||||
|
}
|
||||||
|
|
||||||
if (true === $result) {
|
if (true === $result) {
|
||||||
|
/**
|
||||||
|
* 如果是公司第一次创建安排任务,则初始化公司的提现周期截止时间
|
||||||
|
*/
|
||||||
|
TaskTemplateLogic::initCompanyWithdrawDeadline($params['company_id']);
|
||||||
return $this->success('添加成功', [], 1, 1);
|
return $this->success('添加成功', [], 1, 1);
|
||||||
}
|
}
|
||||||
return $this->fail(TaskTemplateLogic::getError());
|
return $this->fail(TaskTemplateLogic::getError());
|
||||||
|
@ -52,7 +52,7 @@ class WithdrawLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
->where($this->queryWhere())
|
->where($this->queryWhere())
|
||||||
->withAttr('company_name', function ($value, $data) {
|
->withAttr('company_name', function ($value, $data) {
|
||||||
$company = Company::where(['admin_id'=>$data['admin_id']])->find();
|
$company = Company::where(['admin_id'=>$data['admin_id']])->find();
|
||||||
return $company['company_name'];
|
return $company['company_name']??'';
|
||||||
})
|
})
|
||||||
->withAttr('s_date', function ($value, $data) {
|
->withAttr('s_date', function ($value, $data) {
|
||||||
$withdrawedCount = Withdraw::where(['user_id'=>$data['user_id'], 'status'=>3])->count();
|
$withdrawedCount = Withdraw::where(['user_id'=>$data['user_id'], 'status'=>3])->count();
|
||||||
|
@ -36,8 +36,8 @@ class DictDataLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
public function setSearch(): array
|
public function setSearch(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'%like%' => ['name', 'type_value'],
|
'%like%' => ['name'],
|
||||||
'=' => ['status', 'type_id']
|
'=' => ['status', 'type_id', 'type_value']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,8 +62,8 @@ class TaskSchedulingPlanLists extends BaseAdminDataLists implements ListsSearchI
|
|||||||
}
|
}
|
||||||
return TaskSchedulingPlan::where($this->searchWhere)
|
return TaskSchedulingPlan::where($this->searchWhere)
|
||||||
->where($where)
|
->where($where)
|
||||||
->with(['template'])
|
->with(['template','templateInfo'])
|
||||||
->field(['id', 'create_user_id', 'template_id', 'scheduling_id', 'start_time', 'end_time', 'status'])
|
// ->field(['id', 'create_user_id', 'template_id', 'scheduling_id', 'start_time', 'end_time', 'status'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()
|
->select()
|
||||||
|
@ -50,7 +50,7 @@ class ApproveLogic extends BaseLogic
|
|||||||
$status = $params['check_status'] == 2? 1: 2;
|
$status = $params['check_status'] == 2? 1: 2;
|
||||||
// 通知商城审批状态
|
// 通知商城审批状态
|
||||||
$requestResponse = HttpClient::create()->request('POST', env('url.shop_prefix') . '/api/merchant/syncStatus/'.$shopMerchantInfo['mer_intention_id'], [
|
$requestResponse = HttpClient::create()->request('POST', env('url.shop_prefix') . '/api/merchant/syncStatus/'.$shopMerchantInfo['mer_intention_id'], [
|
||||||
'body' => ['status' => $status, 'type' => $approve['type'] ==2 ? 1: 2]
|
'body' => ['status' => $status, 'type' => $approve['type'] ==2 ? 1: 2, 'remark'=> $params['remark']??'']
|
||||||
]);
|
]);
|
||||||
Log::info('通知商城审批状态-参数', ['status' => $status, 'type' => $approve['type']]);
|
Log::info('通知商城审批状态-参数', ['status' => $status, 'type' => $approve['type']]);
|
||||||
Log::info('通知商城审批状态-响应', [$requestResponse->getContent()]);
|
Log::info('通知商城审批状态-响应', [$requestResponse->getContent()]);
|
||||||
|
@ -45,17 +45,7 @@ class TaskTemplateLogic extends BaseLogic
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
// 如果是公司第一次创建安排任务,初始化公司的可提现周期
|
|
||||||
$templateCount = TaskTemplate::where(['company_id'=>$params['company_id']])->count();
|
|
||||||
if ($templateCount == 0) {
|
|
||||||
$dictData = ConfigLogic::getDictTypeValueByType('withdraw_cycle');
|
|
||||||
$cycle = $dictData['withdraw_cycle_1']['value']; // 数据字典-提现周期 单位:天数
|
|
||||||
$today = strtotime(date('Y-m-d'));
|
|
||||||
$withdrawDeadline = $today + $cycle * 24 * 60 * 60 + 86400;
|
|
||||||
$company = Company::find([$params['company_id']]);
|
|
||||||
$company->withdraw_deadline = $withdrawDeadline;
|
|
||||||
$company->save();
|
|
||||||
}
|
|
||||||
$find=TaskTemplate::where('task_scheduling', $params['task_scheduling'])->where('company_id',$params['company_id'])->where('type',$params['type'])->field('id,types,type')->find();
|
$find=TaskTemplate::where('task_scheduling', $params['task_scheduling'])->where('company_id',$params['company_id'])->where('type',$params['type'])->field('id,types,type')->find();
|
||||||
if($find&&$params['type']==$find['type']){
|
if($find&&$params['type']==$find['type']){
|
||||||
self::setError('已经有同一种任务类型了');
|
self::setError('已经有同一种任务类型了');
|
||||||
@ -91,12 +81,14 @@ class TaskTemplateLogic extends BaseLogic
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($params['types']!=33){
|
// 除了长期任务,其他阶段类型没有长期金额
|
||||||
|
if($params['types']!=2){
|
||||||
$params['money_three']=0;
|
$params['money_three']=0;
|
||||||
}
|
}
|
||||||
if($params['type']==35){
|
if($params['type']==35){
|
||||||
$params['extend']=['shareholder'=>['user_id'=>$params['task_admin']]];
|
$params['extend']=['shareholder'=>['user_id'=>$params['task_admin']]];
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskTemplate::create([
|
TaskTemplate::create([
|
||||||
'title' => $params['title'],
|
'title' => $params['title'],
|
||||||
'admin_id' => $params['admin_id'],
|
'admin_id' => $params['admin_id'],
|
||||||
@ -171,7 +163,8 @@ class TaskTemplateLogic extends BaseLogic
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($params['types']!=33){
|
// 除了长期任务,其他阶段类型没有长期金额
|
||||||
|
if($params['types']!=2){
|
||||||
$params['money_three']=0;
|
$params['money_three']=0;
|
||||||
}
|
}
|
||||||
if($params['type']==35){
|
if($params['type']==35){
|
||||||
@ -229,4 +222,88 @@ class TaskTemplateLogic extends BaseLogic
|
|||||||
{
|
{
|
||||||
return TaskTemplate::findOrEmpty($params['id'])->toArray();
|
return TaskTemplate::findOrEmpty($params['id'])->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function initCompanyWithdrawDeadline($companyId)
|
||||||
|
{
|
||||||
|
// 如果是公司第一次创建安排任务,初始化公司的可提现周期截止时间
|
||||||
|
$templateCount = TaskTemplate::where(['company_id' => $companyId])->count();
|
||||||
|
if ($templateCount == 1) {
|
||||||
|
$dictData = ConfigLogic::getDictTypeValueByType('withdraw_cycle');
|
||||||
|
$cycle = $dictData['withdraw_cycle_1']['value']; // 数据字典-提现周期 单位:天数
|
||||||
|
$today = strtotime(date('Y-m-d'));
|
||||||
|
$withdrawDeadline = $today + $cycle * 24 * 60 * 60 + 86400;
|
||||||
|
$company = Company::find($companyId);
|
||||||
|
$company->withdraw_deadline = $withdrawDeadline;
|
||||||
|
$company->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加任务模板
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/08/06 17:30
|
||||||
|
*/
|
||||||
|
public static function addTownTaskTemplate(array $params): bool
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
Db::startTrans();
|
||||||
|
|
||||||
|
$find = TaskTemplate::where('task_scheduling', $params['task_scheduling'])->where('company_id',$params['company_id'])->where('type',$params['type'])->field('id,types,type')->find();
|
||||||
|
if($find && $params['type'] == $find['type']){
|
||||||
|
self::setError('已经有同一种任务类型了');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$moeny = TaskTemplate::where('company_id', $params['company_id'])->sum('money');
|
||||||
|
if($moeny + $params['money'] > 200){
|
||||||
|
self::setError('任务模板一阶段合计金额不能大于任务调度金额');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$moneyTwo = TaskTemplate::where('company_id', $params['company_id'])->sum('money_two');
|
||||||
|
if($moneyTwo + $params['money_two'] > 200){
|
||||||
|
self::setError('任务模板二阶段合计金额不能大于任务调度金额');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$newMoneyThree = TaskTemplate::where('company_id', $params['company_id'])->sum('new_money_three');
|
||||||
|
if($newMoneyThree + $params['new_money_three'] > 200){
|
||||||
|
self::setError('任务模板三阶段合计金额不能大于任务调度金额');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$moneyThree = TaskTemplate::where('company_id', $params['company_id'])->sum('money_three');
|
||||||
|
if($moneyThree + $params['money_three']>200){
|
||||||
|
self::setError('任务模板长期合计金额不能大于任务调度金额');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
TaskTemplate::create([
|
||||||
|
'title' => $params['title'],
|
||||||
|
'admin_id' => $params['admin_id'],
|
||||||
|
'company_id' => $params['company_id'],
|
||||||
|
'task_scheduling' => $params['task_scheduling']??0,
|
||||||
|
'money' => $params['money'],
|
||||||
|
'money_two' => $params['money_two'],
|
||||||
|
'money_three' => $params['money_three'],
|
||||||
|
'type' => $params['type'],
|
||||||
|
'types' => $params['types'],
|
||||||
|
'status' => $params['status'],
|
||||||
|
'content' => $params['content'],
|
||||||
|
'extend'=>json_encode($params['extend']),
|
||||||
|
'stage_day_one' => $params['stage_day_one']??0,
|
||||||
|
'proportion_one' => $params['proportion_one']??0,
|
||||||
|
'stage_day_two' => $params['stage_day_two']??0,
|
||||||
|
'proportion_two' => $params['proportion_two']??0,
|
||||||
|
'recharge' => $params['recharge']??0,
|
||||||
|
'stage_day_three' => $params['stage_day_three']??0,
|
||||||
|
'new_money_three' => $params['new_money_three']??0,
|
||||||
|
]);
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
self::setError($e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -15,13 +15,15 @@ class TaskSettlementCron extends Task{
|
|||||||
// $this->everyMinute();//每分钟
|
// $this->everyMinute();//每分钟
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 任务结算
|
* 小组服务公司任务结算
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
protected function execute()
|
protected function execute()
|
||||||
{
|
{
|
||||||
//yesterday
|
//yesterday
|
||||||
$all=TaskSchedulingPlan::whereDay('end_time','yesterday')->where('is_pay',0)->with(['template_info','scheduling'])->select()->toArray();
|
$all=TaskSchedulingPlan::whereDay('end_time','yesterday')->where('is_pay',0)->with(['template_info','scheduling'=>function($query){
|
||||||
|
$query->where('company_type', 18);
|
||||||
|
}])->select()->toArray();
|
||||||
foreach($all as $k=>$v){
|
foreach($all as $k=>$v){
|
||||||
queue(TaskInformationJob::class,$v);
|
queue(TaskInformationJob::class,$v);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user