Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
047deaa6a4
@ -15,6 +15,6 @@
|
||||
return [
|
||||
'middleware' => [
|
||||
// 权限认证
|
||||
app\middleapi\http\middleware\AuthMiddleware::class,
|
||||
// app\middleapi\http\middleware\AuthMiddleware::class,
|
||||
],
|
||||
];
|
||||
|
200
app/middleapi/controller/ApproveController.php
Normal file
200
app/middleapi/controller/ApproveController.php
Normal file
@ -0,0 +1,200 @@
|
||||
<?php
|
||||
|
||||
namespace app\middleapi\controller;
|
||||
|
||||
use app\adminapi\lists\approve\ApproveLists;
|
||||
use app\common\logic\task\TaskLogic;
|
||||
use app\common\model\Approve;
|
||||
use app\common\model\task\Task;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\task_scheduling_plan\TaskSchedulingPlan;
|
||||
use app\common\model\task_template\TaskTemplate;
|
||||
use think\facade\Db;
|
||||
use app\common\controller\BaseLikeAdminController;
|
||||
|
||||
class ApproveController extends BaseLikeAdminController
|
||||
{
|
||||
public function lists()
|
||||
{
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$params=$this->request->post(['page_no','page_size','type','check_status']);
|
||||
$where = [];
|
||||
if (isset($params['check_status']) && $params['check_status'] != '') {
|
||||
$where[] = ['check_status', '=', $params['check_status']];
|
||||
}
|
||||
if (isset($params['type']) && $params['type'] != '') {
|
||||
$where[] = ['type', 'in', $params['type']];
|
||||
}
|
||||
$pageNo = !empty($params['page_no']) ? $params['page_no'] : 1;
|
||||
$pageSize = !empty($params['page_size']) ? $params['page_size'] : 20;
|
||||
$data = Approve::where($where)
|
||||
->with('task')
|
||||
->field('*')
|
||||
->append(['area_manager', 'company_name'], true)
|
||||
->page($pageNo, $pageSize)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->withAttr('area_manager',function($value,$data){
|
||||
return Admin::where(['id' => $data['check_admin_ids']])->value('name');
|
||||
})
|
||||
->withAttr('company_name',function($value,$data){
|
||||
$task = Task::where('id', $data['task_id'])->find();
|
||||
return Company::where(['id' => $task['company_id'] ?? 0])->value('company_name');
|
||||
})
|
||||
->toArray();
|
||||
$count = Approve::where($where)->count();
|
||||
$result = [
|
||||
'lists' => $data,
|
||||
'count' => $count,
|
||||
'page_no' => $pageNo,
|
||||
'page_size' => $pageSize
|
||||
];
|
||||
return $this->success('请求成功',$result);
|
||||
}
|
||||
|
||||
public function audit()
|
||||
{
|
||||
try {
|
||||
$params = $this->request->param();
|
||||
if(empty($params['id'])){
|
||||
return $this->fail('缺少必要参数id');
|
||||
}
|
||||
if(empty($params['check_status'])){
|
||||
return $this->fail('缺少必要参数审核状态');
|
||||
}
|
||||
$approve = Approve::find($params['id']);
|
||||
if (!$approve) {
|
||||
$this->fail('数据不存在');
|
||||
}
|
||||
Db::startTrans();
|
||||
// 拒绝通过 要让用户今天可以继续做任务
|
||||
if ($params['check_status'] == 3) {
|
||||
$this->refuse($params, $approve);
|
||||
}
|
||||
// 修改任务完成状态
|
||||
if ($params['check_status'] == 2) {
|
||||
if ($approve->type == Approve::APPROVE_TYPE_7) {
|
||||
$taskTemplate = TaskTemplate::where(['id'=>$approve->business_id])->find();
|
||||
// 提前完成
|
||||
if ($taskTemplate['day_count'] < $taskTemplate['stage_day_one']) {
|
||||
if (bccomp($params['amount'], 300000, 2) == -1) {
|
||||
$this->fail('该任务提前完成条件:销售总额必须达到30万元及以上');
|
||||
} else {
|
||||
// 提前完成标识
|
||||
$extend = json_decode($taskTemplate['extend'], true);
|
||||
$extend['early_finish'] = 1;
|
||||
$taskTemplate->extend = json_encode($extend);
|
||||
$taskTemplate->save();
|
||||
$this->pass($approve, $params);
|
||||
}
|
||||
} else {
|
||||
$this->pass($approve, $params);
|
||||
}
|
||||
} else {
|
||||
$this->pass($approve);
|
||||
}
|
||||
|
||||
}
|
||||
Db::commit();
|
||||
return $this->success('审核成功');
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
return $this->fail($e->getFile().$e->getLine().$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// 通过
|
||||
private function pass($approve, $params=[])
|
||||
{
|
||||
$approve->check_status = 2;
|
||||
$approve->update_time = time();
|
||||
$approve->save();
|
||||
// 任务
|
||||
$task = Task::find($approve['task_id']);
|
||||
if ($task['status'] == 2) {
|
||||
$task->status = 3;
|
||||
$task->save();
|
||||
}
|
||||
// 镇农科公司任务-数字农贸宣传业务、加工业务的建设和招商工作任务 结算
|
||||
if ($approve->type == Approve::APPROVE_TYPE_4) {
|
||||
$taskSchedulePlan = TaskSchedulingPlan::where('la_task_scheduling_plan.id', $task['scheduling_plan_id'])
|
||||
->where('is_pay',0)
|
||||
->with(['template_info'])
|
||||
->withJoin(['scheduling'], 'left')
|
||||
->where('scheduling.company_type', 41)
|
||||
->find()
|
||||
->toArray();
|
||||
TaskLogic::dealTaskMarketingDirector10($taskSchedulePlan, $approve);
|
||||
}
|
||||
|
||||
if ($approve->type == Approve::APPROVE_TYPE_5) {
|
||||
$taskSchedulePlan = TaskSchedulingPlan::where('la_task_scheduling_plan.id', $task['scheduling_plan_id'])
|
||||
->where('is_pay',0)
|
||||
->with(['template_info'])
|
||||
->withJoin(['scheduling'], 'left')
|
||||
->where('scheduling.company_type', 17)
|
||||
->find()
|
||||
->toArray();
|
||||
TaskLogic::dealVillageTask6($taskSchedulePlan);
|
||||
}
|
||||
|
||||
if ($approve->type == Approve::APPROVE_TYPE_6) {
|
||||
$taskSchedulePlan = TaskSchedulingPlan::where('la_task_scheduling_plan.id', $task['scheduling_plan_id'])
|
||||
->where('is_pay',0)
|
||||
->with(['template_info'])
|
||||
->withJoin(['scheduling'], 'left')
|
||||
->where('scheduling.company_type', 17)
|
||||
->find()
|
||||
->toArray();
|
||||
TaskLogic::dealVillageTask8($taskSchedulePlan);
|
||||
}
|
||||
if ($approve->type == Approve::APPROVE_TYPE_7) {
|
||||
// 需要手动输入销售总额
|
||||
$approve->amount = $params['amount'];
|
||||
$approve->save();
|
||||
}
|
||||
if ($approve->type == Approve::APPROVE_TYPE_8) {
|
||||
// 需要手动输入申请的政策补贴金额
|
||||
$approve->amount = $params['amount'];
|
||||
$approve->save();
|
||||
}
|
||||
if ($approve->type == Approve::APPROVE_TYPE_9) {
|
||||
$taskSchedulePlan = TaskSchedulingPlan::where('la_task_scheduling_plan.id', $task['scheduling_plan_id'])
|
||||
->where('is_pay',0)
|
||||
->with(['template_info'])
|
||||
->withJoin(['scheduling'], 'left')
|
||||
->where('scheduling.company_type', 17)
|
||||
->find()
|
||||
->toArray();
|
||||
TaskLogic::masterTask8Settlement($taskSchedulePlan);
|
||||
}
|
||||
}
|
||||
|
||||
// 拒绝
|
||||
private function refuse($params, $approve)
|
||||
{
|
||||
$approve->check_status = $params['check_status'];
|
||||
$approve->remark = $params['remark'];
|
||||
$approve->update_time = time();
|
||||
$approve->save();
|
||||
|
||||
// 更新schedule_plan时间和task的时间为今天依旧可提交
|
||||
$schedulePlan = TaskSchedulingPlan::find(['tast_id' => $approve['task_id']]);
|
||||
if (empty($schedule_plan)) {
|
||||
return $this->fail('数据异常,任务计划不存在');
|
||||
}
|
||||
$time = strtotime(date('Y-m-d'));
|
||||
TaskSchedulingPlan::where(['id' => $schedulePlan['id']])->update([
|
||||
'start_time'=>$time,
|
||||
'end_time'=>$time + 86399
|
||||
]);
|
||||
Task::where('id', $approve['task_id'])->update([
|
||||
'start_time'=>$time,
|
||||
'end_time'=>$time + 86399
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
77
app/middleapi/controller/DictDataController.php
Normal file
77
app/middleapi/controller/DictDataController.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace app\middleapi\controller;
|
||||
|
||||
use app\common\model\dict\DictData;
|
||||
use app\adminapi\logic\setting\dict\DictDataLogic;
|
||||
use app\common\controller\BaseLikeAdminController;
|
||||
|
||||
|
||||
/**
|
||||
* 字典数据
|
||||
* Class DictDataController
|
||||
* @package app\adminapi\controller\dictionary
|
||||
*/
|
||||
class DictDataController extends BaseLikeAdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取字典数据列表
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 16:35
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$params=$this->request->post(['page_no','page_size','name','type_id','type_value']);
|
||||
$where = [];
|
||||
if(!empty($params['name'])){
|
||||
$where[] = ['name','like','%' . $params['name'] . '%'];
|
||||
}
|
||||
if(!empty($params['type_id'])){
|
||||
$where[] = ['type_id', '=', $params['type_id']];
|
||||
}
|
||||
if(!empty($params['type_value'])){
|
||||
$where[] = ['type_value', '=', $params['type_value']];
|
||||
}
|
||||
$pageNo = !empty($params['page_no']) ? $params['page_no'] : 1;
|
||||
$pageSize = !empty($params['page_size']) ? $params['page_size'] : 20;
|
||||
$data = DictData::where($where)
|
||||
->append(['status_desc'])
|
||||
->page($pageNo, $pageSize)
|
||||
->order(['sort' => 'desc', 'id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
$count = DictData::where($where)->count();
|
||||
$result = [
|
||||
'lists' => $data,
|
||||
'count' => $count,
|
||||
'page_no' => $pageNo,
|
||||
'page_size' => $pageSize
|
||||
];
|
||||
return $this->success('请求成功',$result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取字典详情
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 17:14
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new DictDataValidate())->goCheck('id');
|
||||
$result = DictDataLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
public function getTaskApproveTypeList()
|
||||
{
|
||||
$result = DictDataLogic::getTaskApproveTypeList();
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
}
|
180
app/middleapi/controller/ShopContractController.php
Normal file
180
app/middleapi/controller/ShopContractController.php
Normal file
@ -0,0 +1,180 @@
|
||||
<?php
|
||||
|
||||
namespace app\middleapi\controller;
|
||||
|
||||
use app\adminapi\logic\ShopContractLogic;
|
||||
use app\adminapi\validate\ShopContractValidate;
|
||||
use app\api\controller\JunziqianController;
|
||||
use app\api\logic\SmsLogic;
|
||||
use app\common\controller\BaseLikeAdminController;
|
||||
use app\common\logic\contract\ContractLogic;
|
||||
use app\common\model\ShopContract;
|
||||
use app\common\model\ShopMerchant;
|
||||
use think\response\Json;
|
||||
|
||||
class ShopContractController extends BaseLikeAdminController
|
||||
{
|
||||
//商户合同列表
|
||||
public function lists(): Json
|
||||
{
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$params = $this->request->post(['page_no','page_size','contract_no','party_a','party_b','status']);
|
||||
$pageNo = !empty($params['page_no']) ? $params['page_no'] : 1;
|
||||
$pageSize = !empty($params['page_size']) ? $params['page_size'] : 20;
|
||||
$where = [];
|
||||
if(!empty($params['contract_no'])){
|
||||
$where[] = ['contract_no','like','%'.$params['contract_no'].'%'];
|
||||
}
|
||||
if(isset($params['party_a']) && $params['party_a']!=''){
|
||||
$arr= ShopMerchant::where('company_name','like','%'.$params['party_a'].'%')->column('id');
|
||||
if($arr){
|
||||
$where[]=['party_a','in',$arr];
|
||||
}
|
||||
}
|
||||
if(isset($params['party_b']) && $params['party_b']!=''){
|
||||
$arr= ShopMerchant::where('company_name','like','%'.$params['party_b'].'%')->column('id');
|
||||
if($arr){
|
||||
$where[]=['party_b','in',$arr];
|
||||
}
|
||||
}
|
||||
if(isset($params['status']) && in_array($params['status'],[0,1])){
|
||||
$where[] = ['status','=',$params['status']];
|
||||
}
|
||||
|
||||
$data = ShopContract::where($where)
|
||||
->field(['id', 'contract_no', 'party_a', 'party_b', 'area_manager', 'type', 'evidence_url', 'check_status', 'status', 'notes'])
|
||||
->page($pageNo, $pageSize)->order(['id' => 'desc'])
|
||||
->with(['partyA', 'partyB'])->select()->toArray();
|
||||
$count = ShopContract::where($where)->count();
|
||||
$result = [
|
||||
'lists' => $data,
|
||||
'count' => $count,
|
||||
'page_no' => $pageNo,
|
||||
'page_size' => $pageSize
|
||||
];
|
||||
return $this->success('请求成功',$result);
|
||||
}
|
||||
|
||||
//商户合同详情
|
||||
public function detail(): Json
|
||||
{
|
||||
$params = (new ShopContractValidate())->post()->goCheck('detail');
|
||||
$result = ShopContractLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
//商户合同审核后
|
||||
public function check(): Json
|
||||
{
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$params = $this->request->post(['id','file']);
|
||||
if(empty($params['id']) || empty($params['file'])){
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
$res = ShopContract::where('id', $params['id'])->update(['file' => $params['file'], 'check_status' => 2]);
|
||||
if ($res) {
|
||||
$find = ShopContract::where('id', $params['id'])->field('type,party_b,party_a')->find()->toArray();
|
||||
$find['party_a_info'] = ShopMerchant::where('id', $find['party_a'])->field('company_name name,master_phone phone')->find()->toArray();
|
||||
$find['party_b_info'] = ShopMerchant::where('id', $find['party_b'])->field('company_name name,master_phone phone')->find()->toArray();
|
||||
$a = [
|
||||
'mobile' => $find['party_a_info']['phone'],
|
||||
'name' => $find['party_a_info']['name'],
|
||||
'scene' => 'WQTZ'
|
||||
];
|
||||
SmsLogic::contractUrl($a);
|
||||
$b = [
|
||||
'mobile' => $find['party_b_info']['phone'],
|
||||
'name' => $find['party_b_info']['name'],
|
||||
'scene' => 'WQTZ'
|
||||
];
|
||||
SmsLogic::contractUrl($b);
|
||||
return $this->success('上传成功', [], 1, 1);
|
||||
} else {
|
||||
if ($res == 0) {
|
||||
return $this->success('没有更新', [], 1, 1);
|
||||
}
|
||||
return $this->fail('上传失败');
|
||||
}
|
||||
}
|
||||
|
||||
//商户合同备注
|
||||
public function note(): Json
|
||||
{
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$params = $this->request->post(['id','notes']);
|
||||
if(empty($params['id']) || empty($params['notes'])){
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
$shopContract = ShopContract::where('id', $params['id'])->find();
|
||||
if (empty($shopContract)) {
|
||||
return $this->fail('合同不存在');
|
||||
}
|
||||
$shopContract->notes = $params['notes'];
|
||||
$shopContract->save();
|
||||
return $this->success('成功');
|
||||
}
|
||||
|
||||
//发送合同
|
||||
public function draftContract(): Json
|
||||
{
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$params = $this->request->post(['id']);
|
||||
if(empty($params['id'])){
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
$result = ShopContractLogic::Draftingcontracts($params);
|
||||
if ($result) {
|
||||
return $this->success('生成合同成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(ContractLogic::getError());
|
||||
}
|
||||
|
||||
//发送短信
|
||||
public function sendSms(): Json
|
||||
{
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$params = $this->request->post(['id']);
|
||||
if(empty($params['id'])){
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
$re = ShopContractLogic::postsms($params);
|
||||
if (!$re) {
|
||||
return $this->fail(ShopContractLogic::getError());
|
||||
}
|
||||
return $this->success('成功');
|
||||
}
|
||||
|
||||
//下载证据包
|
||||
public function evidence()
|
||||
{
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$params = $this->request->post(['id']);
|
||||
if(empty($params['id'])){
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
$detail=ShopContract::where('id',$params['id'])->find();
|
||||
if(!empty($detail['evidence_url'])){
|
||||
return $this->success('获取成功', ['url' => env('url.url_prefix').$detail['evidence_url']]);
|
||||
}
|
||||
$company=ShopMerchant::where('id',$detail['party_a'])->find();
|
||||
$request = array(
|
||||
"applyNo" => $detail['contract_no'],
|
||||
"fullName" => $company['company_name'],
|
||||
"identityCard" => $company['organization_code'],
|
||||
"identityType" => 12,
|
||||
);
|
||||
return app(JunziqianController::class)->EvidenceShopDownload($request);
|
||||
}
|
||||
}
|
106
app/middleapi/controller/TaskSchedulingController.php
Normal file
106
app/middleapi/controller/TaskSchedulingController.php
Normal file
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace app\middleapi\controller;
|
||||
|
||||
use app\common\model\task_scheduling\TaskScheduling;
|
||||
use app\common\model\Company;
|
||||
use app\adminapi\validate\task_scheduling\TaskSchedulingValidate;
|
||||
use app\common\logic\task_scheduling\TaskSchedulingLogic;
|
||||
use app\common\controller\BaseLikeAdminController;
|
||||
|
||||
/**
|
||||
* 任务公司排期控制器
|
||||
* Class TaskSchedulingController
|
||||
* @package app\adminapi\controller\task_scheduling
|
||||
*/
|
||||
class TaskSchedulingController extends BaseLikeAdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取任务公司排期列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/08/08 10:08
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$params=$this->request->post(['page_no','page_size','company_id']);
|
||||
$where = [];
|
||||
if (isset($params['company_id']) && $params['company_id'] != '') {
|
||||
$arr = Company::where('company_name', 'like', '%' . $params['company_id'] . '%')->column('id');
|
||||
if ($arr) {
|
||||
$where[] = ['company_id', 'in', $arr];
|
||||
} else {
|
||||
$where[] = ['company_id', 'in', [0]];
|
||||
}
|
||||
}
|
||||
$pageNo = !empty($params['page_no']) ? $params['page_no'] : 1;
|
||||
$pageSize = !empty($params['page_size']) ? $params['page_size'] : 20;
|
||||
$data = TaskScheduling::where($where)
|
||||
->with(['admin', 'company', 'company_type'])
|
||||
->page($pageNo, $pageSize)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
$count = TaskScheduling::where($where)->count();
|
||||
$result = [
|
||||
'lists' => $data,
|
||||
'count' => $count,
|
||||
'page_no' => $pageNo,
|
||||
'page_size' => $pageSize
|
||||
];
|
||||
return $this->success('请求成功',$result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 编辑任务公司排期
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/08/08 10:08
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new TaskSchedulingValidate())->post()->goCheck('edit');
|
||||
$result = TaskSchedulingLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(TaskSchedulingLogic::getError());
|
||||
}
|
||||
|
||||
//编辑金额
|
||||
public function editMoney()
|
||||
{
|
||||
$params = $this->request->param();
|
||||
if(empty($params['id'])){
|
||||
return $this->fail('缺少必要参数id');
|
||||
}
|
||||
if(empty($params['money'])){
|
||||
return $this->fail('缺少必要参数金额');
|
||||
}
|
||||
$moeny = $params['money'];
|
||||
$result = TaskScheduling::where(['id'=>$params['id']])->update(['money'=>$moeny]);
|
||||
if ( $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail('编辑失败');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取任务公司排期详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/08/08 10:08
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new TaskSchedulingValidate())->post()->goCheck('detail');
|
||||
$result = TaskSchedulingLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
62
app/middleapi/controller/TaskSchedulingPlanController.php
Normal file
62
app/middleapi/controller/TaskSchedulingPlanController.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace app\middleapi\controller;
|
||||
|
||||
use app\common\model\task_scheduling_plan\TaskSchedulingPlan;
|
||||
use app\common\controller\BaseLikeAdminController;
|
||||
|
||||
/**
|
||||
* 任务排期日历控制器
|
||||
* Class TaskSchedulingPlanController
|
||||
* @package app\adminapi\controller\task_scheduling_plan
|
||||
*/
|
||||
class TaskSchedulingPlanController extends BaseLikeAdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取任务排期日历列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/08/08 10:34
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$params=$this->request->post(['page_no','page_size','template_id','scheduling_id','status','start_time','end_time']);
|
||||
$where = [];
|
||||
if (isset($params['template_id']) && $params['template_id'] != '') {
|
||||
$where[] = ['template_id', '=', $params['template_id']];
|
||||
}
|
||||
if (isset($params['scheduling_id']) && $params['scheduling_id'] != '') {
|
||||
$where[] = ['scheduling_id', '=', $params['scheduling_id']];
|
||||
}
|
||||
if (isset($params['status']) && $params['status'] != '') {
|
||||
$where[] = ['status', '=', $params['status']];
|
||||
}
|
||||
if (isset($params['start_time']) && $params['start_time'] != '') {
|
||||
$where[] = ['start_time', '>=', strtotime($params['start_time'])];
|
||||
}
|
||||
if (isset($params['end_time']) && $params['end_time'] != '') {
|
||||
$where[] = ['end_time', '<=', strtotime($params['end_time'])];
|
||||
}
|
||||
$pageNo = !empty($params['page_no']) ? $params['page_no'] : 1;
|
||||
$pageSize = !empty($params['page_size']) ? $params['page_size'] : 20;
|
||||
$data = TaskSchedulingPlan::where($where)
|
||||
->with(['template','templateInfo'])
|
||||
->page($pageNo, $pageSize)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
$count = TaskSchedulingPlan::where($where)->count();
|
||||
$result = [
|
||||
'lists' => $data,
|
||||
'count' => $count,
|
||||
'page_no' => $pageNo,
|
||||
'page_size' => $pageSize
|
||||
];
|
||||
return $this->success('请求成功',$result);
|
||||
}
|
||||
|
||||
}
|
142
app/middleapi/controller/TaskTemplateController.php
Normal file
142
app/middleapi/controller/TaskTemplateController.php
Normal file
@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
namespace app\middleapi\controller;
|
||||
|
||||
use app\common\logic\task_template\TaskTemplateLogic;
|
||||
use app\adminapi\validate\task_template\TaskTemplateValidate;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\task_template\TaskTemplate;
|
||||
use app\common\model\task_scheduling\TaskScheduling;
|
||||
use app\common\controller\BaseLikeAdminController;
|
||||
|
||||
/**
|
||||
* 任务模板控制器
|
||||
* Class TaskTemplateController
|
||||
* @package app\adminapi\controller\task_template
|
||||
*/
|
||||
class TaskTemplateController extends BaseLikeAdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取任务模板列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/08/06 17:30
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$params=$this->request->post(['page_no','page_size','title', 'type', 'status', 'company_id']);
|
||||
$where = [];
|
||||
if (isset($params['title']) && $params['title'] != '') {
|
||||
$where[] = ['title', 'like', '%' . $params['title'] . '%'];
|
||||
}
|
||||
if (isset($params['type']) && $params['type'] != '') {
|
||||
$where[] = ['type', '=', $params['type']];
|
||||
}
|
||||
if (isset($params['status']) && $params['status'] != '') {
|
||||
$where[] = ['status', '=', $params['status']];
|
||||
}
|
||||
if (isset($params['company_id']) && $params['company_id'] != '') {
|
||||
$where[] = ['company_id', '=', $params['company_id']];
|
||||
}
|
||||
$pageNo = !empty($params['page_no']) ? $params['page_no'] : 1;
|
||||
$pageSize = !empty($params['page_size']) ? $params['page_size'] : 20;
|
||||
$data = TaskTemplate::where($where)
|
||||
->with(['admin','data_type'])
|
||||
->page($pageNo, $pageSize)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
$count = TaskTemplate::where($where)->count();
|
||||
$result = [
|
||||
'lists' => $data,
|
||||
'count' => $count,
|
||||
'page_no' => $pageNo,
|
||||
'page_size' => $pageSize
|
||||
];
|
||||
return $this->success('请求成功',$result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加任务模板
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/08/06 17:30
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new TaskTemplateValidate())->post()->goCheck('add');
|
||||
$params['admin_id'] = 1;
|
||||
if (empty($params['extend'])) {
|
||||
$params['extend'] = '{}';
|
||||
}
|
||||
$company = Company::find($params['company_id']);
|
||||
if ($company->company_type == 41) {
|
||||
// 创建 镇农科公司 任务模板
|
||||
$result = TaskTemplateLogic::addTownTaskTemplate($params);
|
||||
} else if ($company->company_type == 17) {
|
||||
$result = TaskTemplateLogic::addVillageTaskTemplate($params);
|
||||
} else {
|
||||
$result = TaskTemplateLogic::add($params);
|
||||
}
|
||||
if (true === $result) {
|
||||
TaskTemplateLogic::initCompanyWithdrawDeadline($params['company_id']);
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(TaskTemplateLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑任务模板
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/08/06 17:30
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new TaskTemplateValidate())->post()->goCheck('edit');
|
||||
if (empty($params['extend'])) {
|
||||
$params['extend'] = '{}';
|
||||
}
|
||||
$params['admin_id'] = 1;
|
||||
$result = TaskTemplateLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(TaskTemplateLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除任务模板
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/08/06 17:30
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new TaskTemplateValidate())->post()->goCheck('delete');
|
||||
TaskTemplateLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取任务模板详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/08/06 17:30
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new TaskTemplateValidate())->post()->goCheck('detail');
|
||||
$result = TaskTemplateLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user