From 18c733890353eeeeb7d9b9527a7b2cd37141bace Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Fri, 20 Oct 2023 10:46:50 +0800 Subject: [PATCH 1/8] =?UTF-8?q?update=EF=BC=9A=E4=BB=BB=E5=8A=A1=E5=AE=A1?= =?UTF-8?q?=E6=89=B9=E8=81=94=E8=B0=83-=E5=B8=82=E5=9C=BA=E9=83=A8?= =?UTF-8?q?=E9=95=BF=E6=95=B0=E5=AD=97=E5=86=9C=E8=B4=B8=E5=AE=A3=E4=BC=A0?= =?UTF-8?q?=E4=B8=9A=E5=8A=A1=E3=80=81=E5=8A=A0=E5=B7=A5=E4=B8=9A=E5=8A=A1?= =?UTF-8?q?=E7=9A=84=E5=BB=BA=E8=AE=BE=E5=92=8C=E6=8B=9B=E5=95=86=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/approve/ApproveController.php | 11 ++-- app/api/controller/TaskController.php | 13 ++--- app/common/logic/finance/TownShareProfit.php | 18 +++--- app/common/logic/task/TaskLogic.php | 58 ++++++++++++++++--- 4 files changed, 71 insertions(+), 29 deletions(-) diff --git a/app/adminapi/controller/approve/ApproveController.php b/app/adminapi/controller/approve/ApproveController.php index 237fefdc6..c28e511a2 100644 --- a/app/adminapi/controller/approve/ApproveController.php +++ b/app/adminapi/controller/approve/ApproveController.php @@ -38,7 +38,7 @@ class ApproveController extends BaseAdminController return $this->success('审核成功'); } catch (\Exception $e) { Db::rollback(); - return $this->fail($e->getMessage()); + return $this->fail($e->getFile().$e->getLine().$e->getMessage()); } } // 通过 @@ -58,12 +58,13 @@ class ApproveController extends BaseAdminController // 结算 if ($approve->type == Approve::APPROVE_TYPE_4) { - $taskSchedulePlan = TaskSchedulingPlan::where(['id', $task['scheduling_plan_id']]) - ->withJoin(['scheduling'], 'left') - ->where('scheduling.company_type', 41) + $taskSchedulePlan = TaskSchedulingPlan::where('la_task_scheduling_plan.id', $task['scheduling_plan_id']) ->where('is_pay',0) ->with(['template_info']) - ->find(); + ->withJoin(['scheduling'], 'left') + ->where('scheduling.company_type', 41) + ->find() + ->toArray(); TaskLogic::dealTaskMarketingDirector10($taskSchedulePlan, $approve); } } diff --git a/app/api/controller/TaskController.php b/app/api/controller/TaskController.php index d9405633b..b165521dd 100644 --- a/app/api/controller/TaskController.php +++ b/app/api/controller/TaskController.php @@ -404,24 +404,23 @@ class TaskController extends BaseApiController } $extend = []; $stage = $parmas['stage']; // 当前做的是任务第几阶段 - $extend['stage'] = $stage; if ($stage == 1) { - $extend = $parmas['stage1']; - $extend['stage1']['is_commit'] = 1; + $parmas['stage1']['is_commit'] = 1; + $extend['stage1'] = $parmas['stage1']; } if ($stage == 2) { - $extend = $parmas['stage2']; $extend['stage2']['is_commit'] = 1; + $extend['stage2'] = $parmas['stage2']; } if ($stage == 3) { - $extend = $parmas['stage3']; $extend['stage3']['is_commit'] = 1; + $extend['stage3'] = $parmas['stage3']; } if ($stage == 4) { - $extend = $parmas['stage4']; $extend['stage4']['is_commit'] = 1; + $extend['stage4'] = $parmas['stage4']; } - + $extend['stage'] = $stage; Task::where(['id' => $parmas['id']])->update(['extend' => json_encode($extend), 'update_time'=>time(), 'director_uid'=>$this->userId]); // director_uid 指派人 diff --git a/app/common/logic/finance/TownShareProfit.php b/app/common/logic/finance/TownShareProfit.php index f5c38592b..74269ce54 100644 --- a/app/common/logic/finance/TownShareProfit.php +++ b/app/common/logic/finance/TownShareProfit.php @@ -249,7 +249,7 @@ class TownShareProfit } } - public function dealTaskSettlementMarketingDirector2(Task $taskInfo, Company $townCompany, TaskSchedulingPlan $taskSchedulePlan) + public function dealTaskSettlementMarketingDirector2(Task $taskInfo, Company $townCompany, $taskSchedulePlan) { try { Db::startTrans(); @@ -267,7 +267,7 @@ class TownShareProfit } } - public function dealTaskSettlementMarketingDirector3(Task $taskInfo, Company $townCompany, TaskSchedulingPlan $taskSchedulePlan) + public function dealTaskSettlementMarketingDirector3(Task $taskInfo, Company $townCompany, $taskSchedulePlan) { try { Db::startTrans(); @@ -285,7 +285,7 @@ class TownShareProfit } } - public function dealTaskSettlementMarketingDirector4(Task $taskInfo, Company $townCompany, TaskSchedulingPlan $taskSchedulePlan) + public function dealTaskSettlementMarketingDirector4(Task $taskInfo, Company $townCompany, $taskSchedulePlan) { try { Db::startTrans(); @@ -303,7 +303,7 @@ class TownShareProfit } } - public function dealTaskSettlementMarketingDirector5(Task $taskInfo, Company $townCompany, TaskSchedulingPlan $taskSchedulePlan) + public function dealTaskSettlementMarketingDirector5(Task $taskInfo, Company $townCompany, $taskSchedulePlan) { try { Db::startTrans(); @@ -321,7 +321,7 @@ class TownShareProfit } } - public function dealTaskSettlementMarketingDirector6(Task $taskInfo, Company $townCompany, TaskSchedulingPlan $taskSchedulePlan) + public function dealTaskSettlementMarketingDirector6(Task $taskInfo, Company $townCompany, $taskSchedulePlan) { try { Db::startTrans(); @@ -339,7 +339,7 @@ class TownShareProfit } } - public function dealTaskSettlementMarketingDirector7(Task $taskInfo, Company $townCompany, TaskSchedulingPlan $taskSchedulePlan) + public function dealTaskSettlementMarketingDirector7(Task $taskInfo, Company $townCompany, $taskSchedulePlan) { try { Db::startTrans(); @@ -357,7 +357,7 @@ class TownShareProfit } } - public function dealTaskSettlementMarketingDirector8(Task $taskInfo, Company $townCompany, TaskSchedulingPlan $taskSchedulePlan) + public function dealTaskSettlementMarketingDirector8(Task $taskInfo, Company $townCompany, $taskSchedulePlan) { try { Db::startTrans(); @@ -375,7 +375,7 @@ class TownShareProfit } } - public function dealTaskSettlementMarketingDirector9(Task $taskInfo, Company $townCompany, TaskSchedulingPlan $taskSchedulePlan) + public function dealTaskSettlementMarketingDirector9(Task $taskInfo, Company $townCompany, $taskSchedulePlan) { try { Db::startTrans(); @@ -393,7 +393,7 @@ class TownShareProfit } } - public function dealTaskSettlementMarketingDirector10(Task $taskInfo, Company $townCompany, TaskSchedulingPlan $taskSchedulePlan) + public function dealTaskSettlementMarketingDirector10(Task $taskInfo, Company $townCompany, $taskSchedulePlan) { try { Db::startTrans(); diff --git a/app/common/logic/task/TaskLogic.php b/app/common/logic/task/TaskLogic.php index 516ad22ec..5cd6d0521 100644 --- a/app/common/logic/task/TaskLogic.php +++ b/app/common/logic/task/TaskLogic.php @@ -699,12 +699,13 @@ class TaskLogic extends BaseLogic // 请求商城接口,获取完成几家 todo $param['start_time'] = strtotime(date('Y-m-d', $templateInfo['cretate_time'])) + 86400; $param['end_time'] = time(); + $param['responsible_area'] = $townCompany['responsible_area']; $result = ShopRequestLogic::getSupplyChainMerchantCount($param); if (!$result) { Log::error('查询供应链商户统计接口失败'.ShopRequestLogic::getError()); return false; } - $count = 0; // todo 从$result取值 + $count = $result['count']; // todo 从$result取值 // 完成数小于3,关闭任务,不做结算 if ($count < 3){ @@ -752,8 +753,8 @@ class TaskLogic extends BaseLogic ]; $result = ShopRequestLogic::getProductListing($param); Log::info(['4.市场部长-供应链商户完成商品上架和库存更新任务-查询商城接口结果', json_encode($result)]); - // 完成则结算 todo 返回字段要对接 - if ($result['is_done'] == 1){ + // 达到目标数 完成则结算 todo 返回字段要对接 + if ($result['count'] >= $templateInfo['extend']['target']){ // 结算金额 任务金额/目标数 * 天数 $taskInfo['money'] = bcmul($templateInfo['stage_day_one'], bcdiv($templateInfo['money'], $templateInfo['extend']['target'])); Log::info(['5.市场部长-供应链商户完成商品上架任务-$taskSchedulePlan', json_encode($taskSchedulePlan)]); @@ -1278,10 +1279,10 @@ class TaskLogic extends BaseLogic // todo 返回字段要对接 $result = ShopRequestLogic::getGeneralMerchantProductListing($param); - $isDone = $result['is_done']; + $count = $result['count']; Log::info(['4.市场部长-一般商户完成商品上架任务-查询商城接口结果', json_encode($result)]); // 任一商户未完成,判定为未完成 - if (!$isDone) { + if ($count < 200) { $taskIsDone = false; } } @@ -1511,13 +1512,13 @@ class TaskLogic extends BaseLogic ]; // todo 对接接口实际返回参数 $result = ShopRequestLogic::getGeneralMerchantTradeAmount($param); - $procureAmount = $result['procure_amount']; - $rate = bcdiv($procureAmount, $targetProcureAmount, 1); + $tradeAmount = $result['trade_amount']; + $rate = bcdiv($tradeAmount, $targetProcureAmount, 1); if (bccomp($rate, 0.5, 1) == -1) { return 0; } $taskMoney = 0; - if ($procureAmount >= 100000) { + if ($tradeAmount >= 100000) { $taskMoney = $totalMoney; } else { // 计算结算金额 周期天数*(money/目标数)*实际完成率*对应发放比例 @@ -2074,6 +2075,47 @@ class TaskLogic extends BaseLogic // 关闭任务 (new Task())->closeTask($task['id']); } + } + + /** + * 村管理公司任务结算 + */ + public static function villageTaskSettlement($taskSchedulePlan) + { + try { + Log::info(['镇农科公司定时任务结算执行-任务计划', $taskSchedulePlan]); + $taskTemplateInfo = $taskSchedulePlan['template_info']; + // 任务类型用的数据字典主键id,将id和value作映射,避免测试和正式环境数据字典数据不一致时出问题 + $townTaskTypeList = DictData::where(['type_value' => 'village_task_type', 'status' => 1])->column('value', 'id'); + switch ($townTaskTypeList[$taskTemplateInfo['type']]){ + // 组建小组服务团队 + case 'village_task_type_1': + + break; + // 协助小组服务团队完成辖区内的交易任务 + case 'village_task_type_2': + break; + // 负责辖区内农产品安检和溯源 + case 'village_task_type_3': + break; + // 督促小组服务团队入股 + case 'village_task_type_4': + break; + // 入股甲方公司 + case 'village_task_type_5': + break; + // 信息平台铺设工作 + case 'village_task_type_6': + break; + // 种养殖基地订单匹配 + case 'village_task_type_7': + break; + default: + return true; + } + } catch (Exception $e) { + Log::error(['镇农科任务结算失败',$e->getFile(), $e->getLine(), $e->getMessage()]); + } } } From ee01071f928148ab25319e58bd6d581798cb3adb Mon Sep 17 00:00:00 2001 From: weiz Date: Fri, 20 Oct 2023 14:08:07 +0800 Subject: [PATCH 2/8] im port change --- extend/workerim/start_gateway.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extend/workerim/start_gateway.php b/extend/workerim/start_gateway.php index f74ae5502..29c00f012 100644 --- a/extend/workerim/start_gateway.php +++ b/extend/workerim/start_gateway.php @@ -16,7 +16,7 @@ $gateway->name = 'worker_im'; $gateway->count = 4; // 本机ip,分布式部署时使用内网ip -$gateway->lanIp = '127.0.0.1'; +$gateway->lanIp = '172.19.97.179'; // 内部通讯起始端口,假如$gateway->count=2,起始端口为2900 // 则一般会使用2900 2901 2902 2903 4个端口作为内部通讯端口 From 85cc16a8cd6ef23453f33dbeac577e425a17a8c0 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Fri, 20 Oct 2023 15:41:52 +0800 Subject: [PATCH 3/8] =?UTF-8?q?update=EF=BC=9A=E5=B0=8F=E7=BB=84=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=85=AC=E5=8F=B8=E7=AE=A1=E7=90=86=E5=91=98=E5=8F=AF?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E5=85=AC=E5=8F=B8=E6=89=80=E6=9C=89=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/TaskController.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/api/controller/TaskController.php b/app/api/controller/TaskController.php index b165521dd..5491f14db 100644 --- a/app/api/controller/TaskController.php +++ b/app/api/controller/TaskController.php @@ -34,10 +34,11 @@ class TaskController extends BaseApiController $is_captain = User::where('id', $this->userId)->value('is_captain'); if ($is_captain == 1) { $where[] = ['type', 'in', [31,33]]; - } else { - $where[] = ['type', '=', 33]; - $where[] = ['director_uid', '=', $this->userId]; } +// else { +// $where[] = ['type', '=', 33]; +// $where[] = ['director_uid', '=', $this->userId]; +// } // $where[] = ['company_id', '=', $this->userInfo['company_id']]; } From 775fabd1268a4eb19f229aa3855f402bd1046478 Mon Sep 17 00:00:00 2001 From: weiz Date: Fri, 20 Oct 2023 16:29:26 +0800 Subject: [PATCH 4/8] test --- extend/workerim/start_gateway.php | 1 + 1 file changed, 1 insertion(+) diff --git a/extend/workerim/start_gateway.php b/extend/workerim/start_gateway.php index 29c00f012..4d3e35507 100644 --- a/extend/workerim/start_gateway.php +++ b/extend/workerim/start_gateway.php @@ -16,6 +16,7 @@ $gateway->name = 'worker_im'; $gateway->count = 4; // 本机ip,分布式部署时使用内网ip + //ce_shi $gateway->lanIp = '172.19.97.179'; // 内部通讯起始端口,假如$gateway->count=2,起始端口为2900 From 5c1273ba4c04a89cecaf082640a7771655069bee Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Fri, 20 Oct 2023 16:38:16 +0800 Subject: [PATCH 5/8] =?UTF-8?q?fixed=EF=BC=9A=E5=85=B6=E4=BB=96=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E6=8F=90=E4=BA=A4=E5=92=8C=E5=AE=A1=E6=89=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/TaskController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/api/controller/TaskController.php b/app/api/controller/TaskController.php index 5491f14db..e0ffe3860 100644 --- a/app/api/controller/TaskController.php +++ b/app/api/controller/TaskController.php @@ -300,7 +300,7 @@ class TaskController extends BaseApiController $parmas = $this->request->param(); $task = TaskLogic::detail($parmas); $extend = $task['extend']; - if ($extend['other']['is_commit'] == 1) { + if (isset($extend['other']) && $extend['other']['is_commit'] == 1) { $approve = Approve::where(['task_id' =>$task['id']])->find(); $task['approve_status'] = $approve['check_status']; //审核状态 $task['deny_notes'] = $approve['remark']; // 拒绝原因 @@ -341,7 +341,7 @@ class TaskController extends BaseApiController $approveModel->other_type = 6; $approveModel->create_time = time(); $approveModel->update_time = time(); - $approveModel->strict(false)->save(); + $re = $approveModel->save(); } else { // 有则更新状态 $approveModel->check_status = 1; // 状态 0待审核,1审核中,2审核通过,3审核不通过,4撤销审核 From 121de0459d4a049a2e323efd8de1a0d4584d2e52 Mon Sep 17 00:00:00 2001 From: weiz Date: Fri, 20 Oct 2023 16:41:08 +0800 Subject: [PATCH 6/8] fixed --- extend/workerim/start_gateway.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/extend/workerim/start_gateway.php b/extend/workerim/start_gateway.php index 4d3e35507..3885d8004 100644 --- a/extend/workerim/start_gateway.php +++ b/extend/workerim/start_gateway.php @@ -10,13 +10,12 @@ require_once __DIR__ . '/../../vendor/autoload.php'; $gateway = new Gateway("Websocket://0.0.0.0:8282"); // gateway名称,status方便查看 -$gateway->name = 'worker_im'; +$gateway->name = 'worker_task_im'; // gateway进程数,一般设置2个就足够 $gateway->count = 4; // 本机ip,分布式部署时使用内网ip - //ce_shi $gateway->lanIp = '172.19.97.179'; // 内部通讯起始端口,假如$gateway->count=2,起始端口为2900 From 790d357c49d815ed1a21fce5b85580453214314d Mon Sep 17 00:00:00 2001 From: weiz Date: Fri, 20 Oct 2023 17:11:47 +0800 Subject: [PATCH 7/8] fixed --- extend/workerim/start_gateway.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extend/workerim/start_gateway.php b/extend/workerim/start_gateway.php index 3885d8004..6dd9ce80a 100644 --- a/extend/workerim/start_gateway.php +++ b/extend/workerim/start_gateway.php @@ -19,8 +19,8 @@ $gateway->count = 4; $gateway->lanIp = '172.19.97.179'; // 内部通讯起始端口,假如$gateway->count=2,起始端口为2900 -// 则一般会使用2900 2901 2902 2903 4个端口作为内部通讯端口 -$gateway->startPort = 2900; +// 则一般会使用3900 3901 3902 3903 4个端口作为内部通讯端口 +$gateway->startPort = 3900; // 服务注册地址 $gateway->registerAddress = '127.0.0.1:1236'; From d79fabc5634119a5ea375c348defb1da031a4ebc Mon Sep 17 00:00:00 2001 From: weiz Date: Fri, 20 Oct 2023 17:21:57 +0800 Subject: [PATCH 8/8] fixed --- extend/workerim/start_gateway.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extend/workerim/start_gateway.php b/extend/workerim/start_gateway.php index 6dd9ce80a..1840cedf7 100644 --- a/extend/workerim/start_gateway.php +++ b/extend/workerim/start_gateway.php @@ -23,7 +23,7 @@ $gateway->lanIp = '172.19.97.179'; $gateway->startPort = 3900; // 服务注册地址 -$gateway->registerAddress = '127.0.0.1:1236'; +$gateway->registerAddress = '172.19.97.179:1236'; // 心跳间隔 $gateway->pingInterval = 20;