From 2c26571b2ec6dd7c4e3c8018d919ccf70e8b12a6 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Sat, 18 Nov 2023 17:33:09 +0800 Subject: [PATCH 01/27] =?UTF-8?q?fixed=20=E5=BA=94=E7=94=A8=E8=BD=AF?= =?UTF-8?q?=E4=BB=B6=E6=8E=A8=E5=B9=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/adminapi/controller/approve/ApproveController.php | 4 ++-- app/common/logic/task/TaskLogic.php | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/adminapi/controller/approve/ApproveController.php b/app/adminapi/controller/approve/ApproveController.php index e04b9135f..e19838a3a 100644 --- a/app/adminapi/controller/approve/ApproveController.php +++ b/app/adminapi/controller/approve/ApproveController.php @@ -36,7 +36,7 @@ class ApproveController extends BaseAdminController public function audit() { try { - $params = $this->request->param(); // id check_status remark + $params = $this->request->param(); // id check_status remark amount $approve = Approve::find($params['id']); if (!$approve) { $this->fail('数据不存在'); @@ -57,7 +57,7 @@ class ApproveController extends BaseAdminController $this->fail('该任务提前完成条件:销售总额必须达到30万元及以上'); } else { // 提前完成标识 - $extend = json_decode($taskTemplate['extend'], true); + $extend = $taskTemplate['extend']; $extend['early_finish'] = 1; $taskTemplate->extend = json_encode($extend); $taskTemplate->save(); diff --git a/app/common/logic/task/TaskLogic.php b/app/common/logic/task/TaskLogic.php index 78a0b7d84..b196bdf02 100644 --- a/app/common/logic/task/TaskLogic.php +++ b/app/common/logic/task/TaskLogic.php @@ -2974,12 +2974,11 @@ class TaskLogic extends BaseLogic Log::info(['镇农科公司定时任务结算执行-'.$taskSchedulePlan['template_info']['title']]); $taskTemplateInfo = $taskSchedulePlan['template_info']; $dayCount = $taskTemplateInfo['day_count']; - $target = $taskTemplateInfo['extend']['target']; $stageDayOne = $taskTemplateInfo['stage_day_one']; $stageDayTwoCount = bcadd($taskTemplateInfo['stage_day_one'], $taskTemplateInfo['stage_day_two']); $stageDayThreeCount = bcadd($stageDayTwoCount, $taskTemplateInfo['stage_day_three']); $villageCompany = Company::where(['id' => $taskTemplateInfo['company_id']])->find(); - $task = Task::where('id', $taskSchedulePlan['task_id'])->find(); + // 任务累计天数 < stage1 关闭任务 if ($dayCount < $stageDayOne) { @@ -3045,9 +3044,11 @@ class TaskLogic extends BaseLogic $param = [ 'start_time' => $startTime, 'end_time' => $endTime, - 'village' => $villageCompany['village'] + 'village' => $villageCompany['village'], + ]; $result = ShopRequestLogic::getPlantingAndBreedingMerchantTradeAmount($param); // todo 商城接口那边需要确定种养殖基地是何种类型的商户 + dd($result); $tradeAmount = $result['data']['procure_amount']; // 交易池 $transactionPool = $taskSchedulePlan['template_info']['transaction_pool']; From 75d34b1a84b00f5ec75f73e56068b52eca808b57 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Sat, 18 Nov 2023 18:25:17 +0800 Subject: [PATCH 02/27] =?UTF-8?q?fixed=20=E5=BA=94=E7=94=A8=E8=BD=AF?= =?UTF-8?q?=E4=BB=B6=E6=8E=A8=E5=B9=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/TaskController.php | 2 +- app/common/logic/task_template/TaskTemplateLogic.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/api/controller/TaskController.php b/app/api/controller/TaskController.php index 641b4cc0f..fc1242a23 100644 --- a/app/api/controller/TaskController.php +++ b/app/api/controller/TaskController.php @@ -674,7 +674,7 @@ class TaskController extends BaseApiController $task = Task::where(['id'=>$param['id']])->find(); $taskTemplate = TaskTemplate::where(['id'=>$task['template_id']])->find(); $extend = $taskTemplate['extend']; - $extend['purchase_sales_info'][] = $param['purchase_sales_info']; + $extend['purchase_sales_info'] = $param['purchase_sales_info']; $taskTemplate->save(['extend'=>json_encode($extend)]); return $this->success('成功', []); } diff --git a/app/common/logic/task_template/TaskTemplateLogic.php b/app/common/logic/task_template/TaskTemplateLogic.php index 4d5648872..da4499038 100644 --- a/app/common/logic/task_template/TaskTemplateLogic.php +++ b/app/common/logic/task_template/TaskTemplateLogic.php @@ -142,7 +142,7 @@ class TaskTemplateLogic extends BaseLogic } else { $taskScheduleAmount = 200; } - $find=TaskTemplate::where('task_scheduling', $params['task_scheduling'])->where('company_id',$params['company_id'])->where('type',$params['type'])->field('id,types,type,money,money_two,money_three')->find(); + $find=TaskTemplate::where('task_scheduling', $params['task_scheduling'])->where('company_id',$params['company_id'])->where('type',$params['type'])->field('id,types,type,money,money_two,money_three,extend')->find(); if($find && $find['id']!=$params['id']&&$params['type']==$find['type']){ self::setError('已经有同一种任务类型了'); return false; @@ -193,7 +193,7 @@ class TaskTemplateLogic extends BaseLogic 'types' => $params['types'], 'status' => $params['status'], 'content' => $params['content'], - 'extend'=>json_encode($params['extend']), + 'extend'=>json_encode(array_merge($find['extend'],$params['extend'])), 'stage_day_one' => $params['stage_day_one']??0, 'proportion_one' => $params['proportion_one']??0, 'stage_day_two' => $params['stage_day_two']??0, From 843f41c7cf93da5520bee5cd4b79a0058260fa69 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Sat, 18 Nov 2023 19:29:13 +0800 Subject: [PATCH 03/27] =?UTF-8?q?fixed=20=E5=8D=8F=E5=8A=A9=E6=80=BB?= =?UTF-8?q?=E8=B4=9F=E8=B4=A3=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/task/TaskLogic.php | 90 +++++++++++++++++++---------- 1 file changed, 59 insertions(+), 31 deletions(-) diff --git a/app/common/logic/task/TaskLogic.php b/app/common/logic/task/TaskLogic.php index b196bdf02..a178a28b5 100644 --- a/app/common/logic/task/TaskLogic.php +++ b/app/common/logic/task/TaskLogic.php @@ -981,7 +981,7 @@ class TaskLogic extends BaseLogic // 任务累计天数第一个周期结算 if ($dayCount == $stageOneDayCount) { $rate = bcdiv($liaisonManCount, $villageCount, 2); - if (bccomp($rate, 0.5, 2) == 1) { + if (bccomp($rate, 0.5, 2) == 1 || bccomp($rate, 0.5, 2) == 0) { // 按个数结算 $taskInfo['money'] = bcmul($liaisonManCount, 120, 2); (new TownShareProfit())->dealTaskSettlementMaster5($taskInfo, $townCompany, $taskSchedulePlan); @@ -1164,24 +1164,38 @@ class TaskLogic extends BaseLogic $taskTemplateInfo = $taskSchedulePlan['template_info']; $taskInfo = Task::where(['id' => $taskSchedulePlan['task_id']])->find(); $townCompany = Company::where(['id' => $taskTemplateInfo['company_id']])->find(); - $groupServiceCompanyList = Db::query("select * from la_company where company_type=:company_type and FIND_IN_SET(street,:responsible_area)", ['company_type' => 18,'responsible_area'=>$townCompany['responsible_area']], true); -// $groupServiceCompanyList = Company::where(['street' => $townCompany['street'], 'company_type' => 18])->select()->toArray(); $isDone = 1; // 任务是否完成标记 $isTaskSchedule = 0; // 下属小组服务公司是否有每日任务安排标记 - foreach ($groupServiceCompanyList as $groupServiceCompany) { - // 查询小组服务公司是否有对应的每日任务安排 - $templateList = TaskTemplate::where(['company_id' => $groupServiceCompany['id']])->whereIn('type', [31, 32, 33])->select()->toArray(); - // 未做任务安排的小组服务公司不在判定范围内,跳出本次循环 - if(count($templateList) === 3) { - $isTaskSchedule = 1; - // 查询小组服务公司的循环任务有没有全部做完 任意有一个任务没有做完,则判定为该小组服务公司没有完成每日任务,即协助总负责人开展工作任务也认定失败 - foreach ($templateList as $template) { - $task = Task::where(['template_id' => $template['id'], 'status' => 3])->find(); - if (empty($task)) { - $isDone = 0; - break; - } + // 负责人任务类型id列表 + $typeIds = []; + $townMasterTaskTypeList = DictData::where(['type_value' => 'town_task_type_master', 'status' => 1])->column('value', 'id'); + foreach ($townMasterTaskTypeList as $item) { + if ($item['value'] == 'town_task_type_master_3') { + $typeIds[] = $item['id']; + } + if ($item['value'] == 'town_task_type_master_4') { + $typeIds[] = $item['id']; + } + if ($item['value'] == 'town_task_type_master_5') { + $typeIds[] = $item['id']; + } + if ($item['value'] == 'town_task_type_master_8') { + $typeIds[] = $item['id']; + } + } + + // 查询 镇农科公司负责人是否有对应的每日任务安排 + $templateList = TaskTemplate::where(['company_id'=>$townCompany['id']])->whereIn('type', $typeIds)->select()->toArray(); + // 未做任务安排的小组服务公司不在判定范围内,跳出本次循环 + if(count($templateList) === 4) { + $isTaskSchedule = 1; + // 查询负责人的循环任务有没有全部做完 任意有一个任务没有做完,则判定为 协助总负责人开展工作任务 失败 + foreach ($templateList as $template) { + $task = Task::where(['template_id' => $template['id'], 'status' => 3])->find(); + if (empty($task)) { + $isDone = 0; + break; } } } @@ -2229,27 +2243,41 @@ class TaskLogic extends BaseLogic $taskTemplateInfo = $taskSchedulePlan['template_info']; $taskInfo = Task::where(['id' => $taskSchedulePlan['task_id']])->find(); $townCompany = Company::where(['id' => $taskTemplateInfo['company_id']])->find(); - $groupServiceCompanyList = Db::query("select * from la_company where company_type=:company_type and FIND_IN_SET(street,:responsible_area)", ['company_type' => 18,'responsible_area'=>$townCompany['responsible_area']], true); -// $groupServiceCompanyList = Company::where(['street' => $townCompany['street'], 'company_type' => 18])->select()->toArray(); $isDone = 1; // 任务是否完成标记 $isTaskSchedule = 0; // 下属小组服务公司是否有每日任务安排标记 - foreach ($groupServiceCompanyList as $groupServiceCompany) { - // 查询小组服务公司是否有对应的每日任务安排 - $templateList = TaskTemplate::where(['company_id' => $groupServiceCompany['id']])->whereIn('type', [31, 32, 33])->select()->toArray(); - // 未做任务安排的小组服务公司不在判定范围内,跳出本次循环 - if(count($templateList) === 3) { - $isTaskSchedule = 1; - // 查询小组服务公司的循环任务有没有全部做完 任意有一个任务没有做完,则判定为该小组服务公司没有完成每日任务,即协助总负责人开展工作任务也认定失败 - foreach ($templateList as $template) { - $task = Task::where(['template_id' => $template['id'], 'status' => 3])->find(); - if (empty($task)) { - $isDone = 0; - break; - } + // 负责人任务类型id列表 + $typeIds = []; + $townMasterTaskTypeList = DictData::where(['type_value' => 'town_task_type_master', 'status' => 1])->column('value', 'id'); + foreach ($townMasterTaskTypeList as $item) { + if ($item['value'] == 'town_task_type_master_3') { + $typeIds[] = $item['id']; + } + if ($item['value'] == 'town_task_type_master_4') { + $typeIds[] = $item['id']; + } + if ($item['value'] == 'town_task_type_master_5') { + $typeIds[] = $item['id']; + } + if ($item['value'] == 'town_task_type_master_8') { + $typeIds[] = $item['id']; + } + } + // 查询 镇农科公司负责人是否有对应的每日任务安排 + $templateList = TaskTemplate::where(['company_id'=>$townCompany['id']])->whereIn('type', $typeIds)->select()->toArray(); + // 未做任务安排的小组服务公司不在判定范围内,跳出本次循环 + if(count($templateList) === 4) { + $isTaskSchedule = 1; + // 查询负责人的循环任务有没有全部做完 任意有一个任务没有做完,则判定为 协助总负责人开展工作任务 失败 + foreach ($templateList as $template) { + $task = Task::where(['template_id' => $template['id'], 'status' => 3])->find(); + if (empty($task)) { + $isDone = 0; + break; } } } + // 下属小组服务公司有任务安排,也完成了任务 if ($isDone === 1 && $isTaskSchedule === 1) { // 做任务结算,分润 From e05552b2065ca9dcbdd3364c9ed9e0e824599536 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Sat, 18 Nov 2023 20:16:44 +0800 Subject: [PATCH 04/27] =?UTF-8?q?fixed=20=E8=B4=9F=E8=B4=A3=E4=BA=BA?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/approve/ApproveController.php | 12 +++- app/api/controller/TaskController.php | 57 ++++++++++++++++++- app/common/logic/task/TaskLogic.php | 18 ++++-- 3 files changed, 78 insertions(+), 9 deletions(-) diff --git a/app/adminapi/controller/approve/ApproveController.php b/app/adminapi/controller/approve/ApproveController.php index e19838a3a..f870f9bc0 100644 --- a/app/adminapi/controller/approve/ApproveController.php +++ b/app/adminapi/controller/approve/ApproveController.php @@ -67,7 +67,7 @@ class ApproveController extends BaseAdminController $this->pass($approve, $params); } } else { - $this->pass($approve); + $this->pass($approve, $params); } } @@ -135,13 +135,21 @@ class ApproveController extends BaseAdminController // 需要手动输入申请的政策补贴金额 $approve->amount = $params['amount']; $approve->save(); + $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::masterTask7Settlement($taskSchedulePlan); } 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) + ->where('scheduling.company_type', 41) ->find() ->toArray(); TaskLogic::masterTask8Settlement($taskSchedulePlan); diff --git a/app/api/controller/TaskController.php b/app/api/controller/TaskController.php index fc1242a23..63aeece46 100644 --- a/app/api/controller/TaskController.php +++ b/app/api/controller/TaskController.php @@ -712,7 +712,62 @@ class TaskController extends BaseApiController // 没有则创建审批任务 $approveModel = Approve::where(['task_id' => $task['id']])->findOrEmpty(); if ($approveModel->isEmpty()) { - $approveModel->type = Approve::APPROVE_TYPE_6; + $approveModel->type = Approve::APPROVE_TYPE_8; + $approveModel->flow_id = 1; + $approveModel->name = $task['title']; + $approveModel->admin_id = 0; // 后台发起人id 暂时为0 + $approveModel->user_id = $this->userId; // 前台发起人用户id + $approveModel->task_id = $task['id']; // 任务id + $approveModel->department_id = '0'; + $approveModel->check_admin_ids = $areaManagerId; // 当前审批人ID 片区经理的admin_id + $approveModel->check_status = 1; // 状态 0待审核,1审核中,2审核通过,3审核不通过,4撤销审核 + $approveModel->other_type = 6; + $approveModel->extend = json_encode($extend); + $approveModel->create_time = time(); + $approveModel->update_time = time(); + $re = $approveModel->save(); + } else { + // 有则更新状态 + $approveModel->check_status = 1; // 状态 0待审核,1审核中,2审核通过,3审核不通过,4撤销审核 + $approveModel->save(); + } + return $this->success('ok', []); + } catch (Exception $e) { + return $this->fail($e->getMessage()); + } + } + + + public function commit_town_master_task_type_8() + { + try { + $parmas = $this->request->param(); // id annex video_annex + $task = TaskLogic::detail($parmas); + if (empty($task)) { + $this->fail('任务不存在'); + } + if (empty($parmas['annex']) && empty($parmas['video_annex'])) { + $this->fail('没有上传凭证,无法提交审核'); + } + + $extend = [ + 'other'=> [ + 'is_commit' => 1, + 'note' => $parmas['note'], + 'annex' => $parmas['annex'], + 'video_annex' => $parmas['video_annex'], + ] + ]; + Task::where(['id' => $parmas['id']])->update(['extend' => json_encode($extend), 'update_time'=>time(), 'director_uid'=>$this->userId]); // director_uid 指派人 + + // 片区经理 + $areaManagerId = User::where(['id' => $this->userId])->with('company')->value('area_manager'); + + + // 没有则创建审批任务 + $approveModel = Approve::where(['task_id' => $task['id']])->findOrEmpty(); + if ($approveModel->isEmpty()) { + $approveModel->type = Approve::APPROVE_TYPE_9; $approveModel->flow_id = 1; $approveModel->name = $task['title']; $approveModel->admin_id = 0; // 后台发起人id 暂时为0 diff --git a/app/common/logic/task/TaskLogic.php b/app/common/logic/task/TaskLogic.php index a178a28b5..53acbd1c9 100644 --- a/app/common/logic/task/TaskLogic.php +++ b/app/common/logic/task/TaskLogic.php @@ -741,7 +741,16 @@ class TaskLogic extends BaseLogic break; // 政策补贴申请 case 'town_task_type_master_7': - self::masterTask7Settlement($taskSchedulePlan); + Log::info(['镇农科公司定时任务结算执行-'.$taskSchedulePlan['template_info']['title']]); + $taskTemplateInfo = $taskSchedulePlan['template_info']; + $dayCount = $taskTemplateInfo['day_count']; + $taskInfo = Task::where(['id' => $taskSchedulePlan['task_id']])->find(); + $townCompany = Company::where(['id' => $taskTemplateInfo['company_id']])->find(); + if($dayCount < $taskTemplateInfo['stage_day_one']) { + self::flushTaskTime($taskSchedulePlan); + return true; + } +// self::masterTask7Settlement($taskSchedulePlan); break; // 日常管理及其他临时任务 case 'town_task_type_master_8': @@ -1048,18 +1057,15 @@ class TaskLogic extends BaseLogic * @param $taskSchedulePlan * 政策补贴申请 单次 */ - private static function masterTask7Settlement($taskSchedulePlan) + public static function masterTask7Settlement($taskSchedulePlan) { Log::info(['镇农科公司定时任务结算执行-'.$taskSchedulePlan['template_info']['title']]); $taskTemplateInfo = $taskSchedulePlan['template_info']; $dayCount = $taskTemplateInfo['day_count']; $taskInfo = Task::where(['id' => $taskSchedulePlan['task_id']])->find(); $townCompany = Company::where(['id' => $taskTemplateInfo['company_id']])->find(); - if($dayCount < $taskTemplateInfo['stage_day_one']) { - self::flushTaskTime($taskSchedulePlan); - } - if ($dayCount == $taskTemplateInfo['stage_day_one']) { + if ($dayCount <= $taskTemplateInfo['stage_day_one']) { // 审批通过后,任务状态会变更为已完成状态,审批是会根据凭证填入实际申请的政策补贴金额,根据该金额计算任务结算金额 if ($taskInfo['status'] == 3) { $approve = Approve::where(['task_id' => $taskSchedulePlan['task_id']])->find(); From 75585f8e5f5ed1f9a7e5765968020f3c0f4a439d Mon Sep 17 00:00:00 2001 From: weiz Date: Mon, 20 Nov 2023 09:42:49 +0800 Subject: [PATCH 05/27] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=85=AC=E5=8F=B8?= =?UTF-8?q?=E6=88=90=E5=91=98=E5=AF=B9=E5=A4=96=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CompanyController.php | 56 ++++++++++++++++++- composer.json | 3 +- 2 files changed, 55 insertions(+), 4 deletions(-) diff --git a/app/middleapi/controller/CompanyController.php b/app/middleapi/controller/CompanyController.php index 07f2c74fc..a52d22fe2 100644 --- a/app/middleapi/controller/CompanyController.php +++ b/app/middleapi/controller/CompanyController.php @@ -3,9 +3,11 @@ namespace app\middleapi\controller; use app\adminapi\logic\auth\AdminLogic; + use app\adminapi\logic\user\UserLogic; use app\adminapi\validate\CompanyValidate; use app\api\controller\JunziqianController; use app\common\controller\BaseLikeAdminController; + use app\common\enum\user\UserTerminalEnum; use app\common\logic\CompanyLogic; use app\common\logic\contract\ContractLogic; use app\common\logic\RedisLogic; @@ -17,6 +19,7 @@ use app\common\model\task_scheduling\TaskScheduling; use app\common\model\user\User; use app\common\model\CompanyDepositVoucher; + use Exception; use think\facade\Db; use think\facade\Log; use think\response\Json; @@ -330,7 +333,7 @@ return $this->success('success', array_unique($data)); } - public function getDepositRechargeTransferVoucherList() + public function getDepositRechargeTransferVoucherList(): Json { if(!$this->request->isPost()){ return $this->fail('请求方式错误'); @@ -358,7 +361,7 @@ return $this->success('请求成功',$result); } - public function depositRechargeTransferVoucher() + public function depositRechargeTransferVoucher(): Json { if(!$this->request->isPost()){ return $this->fail('请求方式错误'); @@ -416,7 +419,7 @@ } - public function getPartyA() + public function getPartyA(): Json { if(!$this->request->isPost()){ return $this->fail('请求方式错误'); @@ -431,4 +434,51 @@ } return $this->success('成功', $re); } + + //获取公司成员 + public function companyUserLists(): Json + { + if(!$this->request->isPost()){ + return $this->fail('请求方式错误'); + } + $params = $this->request->post(['company_id','page_no','page_size']); + if(empty($params['company_id'])){ + return $this->fail('参数错误'); + } + $pageNo = !empty($params['page_no']) ? $params['page_no'] : 1; + $pageSize = !empty($params['page_size']) ? $params['page_size'] : 20; + $field = "id,id contract,sn,nickname,sex,avatar,account,mobile,channel,create_time,admin_id,company_id,street,street as street_name,is_contract"; + $lists = User::with(['company']) + ->where('company_id',$params['company_id']) + ->page($pageNo, $pageSize) + ->field($field) + ->order('id desc') + ->select() + ->toArray(); + foreach ($lists as &$item) { + $item['channel'] = UserTerminalEnum::getTermInalDesc($item['channel']); + } + $count = User::where('company_id',$params['company_id'])->count(); + $result = [ + 'lists' => $lists, + 'count' => $count, + 'page_no' => $pageNo, + 'page_size' => $pageSize + ]; + return $this->success('请求成功',$result); + } + + //获取公司成员详情 + public function companyUserDetail(): Json + { + if(!$this->request->isPost()){ + return $this->fail('请求方式错误'); + } + $params = $this->request->post(['user_id']); + if(empty($params['user_id'])){ + return $this->fail('参数错误'); + } + $detail = UserLogic::detail($params['user_id']); + return $this->success('', $detail); + } } \ No newline at end of file diff --git a/composer.json b/composer.json index 9214adbec..78f70ae3c 100755 --- a/composer.json +++ b/composer.json @@ -44,7 +44,8 @@ "jpush/jpush": "^3.6", "topthink/think-filesystem": "^2.0", "alibabacloud/live": "^1.8", - "alibabacloud/live-20161101": "1.1.1" + "alibabacloud/live-20161101": "1.1.1", + "ext-bcmath": "*" }, "require-dev": { "symfony/var-dumper": "^4.2", From b4c6f00ffeb9707fa40d0f6206a0f686567c0794 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Mon, 20 Nov 2023 10:09:34 +0800 Subject: [PATCH 06/27] fixed --- app/api/controller/TaskController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/api/controller/TaskController.php b/app/api/controller/TaskController.php index 63aeece46..1621321ba 100644 --- a/app/api/controller/TaskController.php +++ b/app/api/controller/TaskController.php @@ -94,6 +94,9 @@ class TaskController extends BaseApiController if (isset($townMasterTaskTypeList[$item['type']])) { $res[$k]['task_type_value'] = $townMasterTaskTypeList[$item['type']]; } + if (isset($townMarketingManagerTaskTypeList[$item['type']])) { + $res[$k]['task_type_value'] = $townMarketingManagerTaskTypeList[$item['type']]; + } if ($item['type'] == 33) { $company = Company::where('id', $item['company_id'])->field('id,deposit,company_money,user_id,day_count,company_type,province,city,area,street,village,brigade,responsible_area')->find(); // 可能要判断预存金是否满足 From b78ec6563207ffc451618a5d267df55dc8c21230 Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Mon, 20 Nov 2023 10:36:35 +0800 Subject: [PATCH 07/27] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/middleapi/controller/AccountLogController.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/middleapi/controller/AccountLogController.php b/app/middleapi/controller/AccountLogController.php index 8d529776b..c9d10ecef 100644 --- a/app/middleapi/controller/AccountLogController.php +++ b/app/middleapi/controller/AccountLogController.php @@ -29,11 +29,14 @@ class AccountLogController extends BaseLikeAdminController if(!$this->request->isPost()){ return $this->fail('请求方式错误'); } - $params = $this->request->post(['page_no','page_size', 'start_time', 'end_time', 'type','company_id']); + $params = $this->request->post(['page_no','page_size', 'start_time', 'end_time', 'user_info', 'type', 'change_type', 'company_id']); $where = []; if (isset($params['type']) && $params['type'] == 'um') { $where[] = ['change_type', 'in', AccountLogEnum::getUserMoneyChangeType()]; } + if (!empty($params['change_type'])) { + $where[] = ['change_type', '=', $params['change_type']]; + } if (!empty($params['company_id'])) { $where[] = ['company_id', '=', $params['company_id']]; } From 04d478d88075fcd6b2e38c26e35f4370751f40a8 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Mon, 20 Nov 2023 10:48:44 +0800 Subject: [PATCH 08/27] =?UTF-8?q?add=20=E4=BE=9B=E9=94=80=E5=AF=B9?= =?UTF-8?q?=E6=8E=A5=E6=94=AF=E4=BB=98=E7=B3=BB=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/PayController.php | 22 ++++++-- app/common/logic/PayRequestLogic.php | 21 ++++++++ app/common/service/pay/WeChatPayService.php | 57 +++++++++++---------- 3 files changed, 68 insertions(+), 32 deletions(-) create mode 100644 app/common/logic/PayRequestLogic.php diff --git a/app/api/controller/PayController.php b/app/api/controller/PayController.php index 5cf4e8e84..5bc88bf6c 100755 --- a/app/api/controller/PayController.php +++ b/app/api/controller/PayController.php @@ -16,8 +16,11 @@ namespace app\api\controller; use app\api\validate\PayValidate; +use app\common\enum\PayEnum; use app\common\enum\user\UserTerminalEnum; use app\common\logic\PaymentLogic; +use app\common\logic\PayRequestLogic; +use app\common\model\Company; use app\common\service\pay\WeChatPayService; use think\facade\Log; @@ -62,9 +65,19 @@ class PayController extends BaseApiController if (false === $order) { return $this->fail(PaymentLogic::getError(), $params); } - //支付流程 - $redirectUrl = $params['redirect'] ?? '/pages/payment/payment'; - $result = PaymentLogic::pay($params['pay_way'], $params['from'], $order, $this->userInfo['terminal'], $redirectUrl); + // 请求支付系统 + $companyInfo = Company::where(['company_id' => $this->userInfo['company_id']])->find(); + $requestData = [ + 'street' => $companyInfo['street'], + 'order_from' => 12, + 'order_type' => 101, + 'pay_user_role' => $this->userInfo['group_id'], + 'pay_user_info' => $this->userInfo, + 'business_order_no' => $order['order_no'], + 'total_fee' => $order['order_amount'], + 'business_callback_url' => (string)url('pay/notifyApp', [], false, true) + ]; + $result = PayRequestLogic::getPrePayId($requestData); if (false === $result) { return $this->fail(PaymentLogic::getError(), $params); } @@ -132,7 +145,8 @@ class PayController extends BaseApiController */ public function notifyApp() { - return (new WeChatPayService(UserTerminalEnum::ANDROID))->notify(); + $param = $this->request->param(); + return (new WeChatPayService(UserTerminalEnum::ANDROID))->notify($param); } diff --git a/app/common/logic/PayRequestLogic.php b/app/common/logic/PayRequestLogic.php new file mode 100644 index 000000000..b95f4b502 --- /dev/null +++ b/app/common/logic/PayRequestLogic.php @@ -0,0 +1,21 @@ +request('POST', env('url.pay_prefix'). '/api/wechat_pay_service_merchant_pay/appPrePay', [ + 'body' => $param + ]); + return json_decode($requestResponse->getContent(), true); + } catch (Exception $e) { + self::setError($e->getMessage()); + return false; + } + } +} \ No newline at end of file diff --git a/app/common/service/pay/WeChatPayService.php b/app/common/service/pay/WeChatPayService.php index e695208cc..511c134c0 100755 --- a/app/common/service/pay/WeChatPayService.php +++ b/app/common/service/pay/WeChatPayService.php @@ -362,35 +362,36 @@ class WeChatPayService extends BasePayService * @author 段誉 * @date 2023/2/28 14:20 */ - public function notify() + public function notify($param) { - $server = $this->app->getServer(); - // 支付通知 - $server->handlePaid(function (Message $message) { - $data = ['trade_state' => $message['trade_state'] ?? '', 'out_trade_no' => $message['out_trade_no'] ?? '', 'transaction_id' => $message['transaction_id'] ?? '', 'attach' => $message['attach'] ?? '']; - Log::info('wechat pay notify: ' . var_export($data, true)); - if ($message['trade_state'] === 'SUCCESS') { - $extra['transaction_id'] = $message['transaction_id']; - $attach = $message['attach']; - $message['out_trade_no'] = mb_substr($message['out_trade_no'], 0, 18); - switch ($attach) { - case 'recharge': - $order = RechargeOrder::where(['sn' => $message['out_trade_no']])->findOrEmpty(); - if($order->isEmpty() || $order->pay_status == PayEnum::ISPAID) { - return true; - } - PayNotifyLogic::handle('recharge', $message['out_trade_no'], $extra); - break; - } - } - return true; - }); - - // 退款通知 - $server->handleRefunded(function (Message $message) { - return true; - }); - return $server->serve(); + Log::info(['支付回调', $param]); +// $server = $this->app->getServer(); +// // 支付通知 +// $server->handlePaid(function (Message $message) { +// $data = ['trade_state' => $message['trade_state'] ?? '', 'out_trade_no' => $message['out_trade_no'] ?? '', 'transaction_id' => $message['transaction_id'] ?? '', 'attach' => $message['attach'] ?? '']; +// Log::info('wechat pay notify: ' . var_export($data, true)); +// if ($message['trade_state'] === 'SUCCESS') { +// $extra['transaction_id'] = $message['transaction_id']; +// $attach = $message['attach']; +// $message['out_trade_no'] = mb_substr($message['out_trade_no'], 0, 18); +// switch ($attach) { +// case 'recharge': +// $order = RechargeOrder::where(['sn' => $message['out_trade_no']])->findOrEmpty(); +// if($order->isEmpty() || $order->pay_status == PayEnum::ISPAID) { +// return true; +// } +// PayNotifyLogic::handle('recharge', $message['out_trade_no'], $extra); +// break; +// } +// } +// return true; +// }); +// +// // 退款通知 +// $server->handleRefunded(function (Message $message) { +// return true; +// }); +// return $server->serve(); } public function configForPayment($prepayId, $appId) From 6d08fba3a296904a20235c2ec30c5f682f90d45b Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Mon, 20 Nov 2023 10:51:09 +0800 Subject: [PATCH 09/27] fixed --- app/common/logic/task/TaskLogic.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/common/logic/task/TaskLogic.php b/app/common/logic/task/TaskLogic.php index 53acbd1c9..fe626ecde 100644 --- a/app/common/logic/task/TaskLogic.php +++ b/app/common/logic/task/TaskLogic.php @@ -3082,8 +3082,8 @@ class TaskLogic extends BaseLogic ]; $result = ShopRequestLogic::getPlantingAndBreedingMerchantTradeAmount($param); // todo 商城接口那边需要确定种养殖基地是何种类型的商户 - dd($result); - $tradeAmount = $result['data']['procure_amount']; + + $tradeAmount = $result['data']['trade_amount']; // 交易池 $transactionPool = $taskSchedulePlan['template_info']['transaction_pool']; $totalTradeAmount = bcadd($transactionPool, $tradeAmount, 2); From 98103e40ddbd333d0e654fccb59d4587e1aaeef0 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Mon, 20 Nov 2023 10:58:44 +0800 Subject: [PATCH 10/27] fixed --- app/api/controller/PayController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/controller/PayController.php b/app/api/controller/PayController.php index 5bc88bf6c..c0e6f0149 100755 --- a/app/api/controller/PayController.php +++ b/app/api/controller/PayController.php @@ -66,7 +66,7 @@ class PayController extends BaseApiController return $this->fail(PaymentLogic::getError(), $params); } // 请求支付系统 - $companyInfo = Company::where(['company_id' => $this->userInfo['company_id']])->find(); + $companyInfo = Company::where(['id' => $this->userInfo['company_id']])->find(); $requestData = [ 'street' => $companyInfo['street'], 'order_from' => 12, From a2d65de03e5c7004299322c88b3ad0eec040f18a Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Mon, 20 Nov 2023 11:01:39 +0800 Subject: [PATCH 11/27] fixed --- app/api/controller/PayController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/controller/PayController.php b/app/api/controller/PayController.php index c0e6f0149..99e496c45 100755 --- a/app/api/controller/PayController.php +++ b/app/api/controller/PayController.php @@ -77,7 +77,7 @@ class PayController extends BaseApiController 'total_fee' => $order['order_amount'], 'business_callback_url' => (string)url('pay/notifyApp', [], false, true) ]; - $result = PayRequestLogic::getPrePayId($requestData); + $result = PayRequestLogic::getPrePayId($requestData);dd($result); if (false === $result) { return $this->fail(PaymentLogic::getError(), $params); } From cc999b400f4a16eaca8e53438789fbc66d44fc8a Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Mon, 20 Nov 2023 12:06:19 +0800 Subject: [PATCH 12/27] =?UTF-8?q?up=20=E4=BE=9B=E9=94=80=E5=AF=B9=E6=8E=A5?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E7=B3=BB=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/PayController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/api/controller/PayController.php b/app/api/controller/PayController.php index 99e496c45..875a402c1 100755 --- a/app/api/controller/PayController.php +++ b/app/api/controller/PayController.php @@ -73,15 +73,15 @@ class PayController extends BaseApiController 'order_type' => 101, 'pay_user_role' => $this->userInfo['group_id'], 'pay_user_info' => $this->userInfo, - 'business_order_no' => $order['order_no'], + 'business_order_no' => $order['sn'], 'total_fee' => $order['order_amount'], 'business_callback_url' => (string)url('pay/notifyApp', [], false, true) ]; - $result = PayRequestLogic::getPrePayId($requestData);dd($result); + $result = PayRequestLogic::getPrePayId($requestData); if (false === $result) { return $this->fail(PaymentLogic::getError(), $params); } - return $this->success('', $result); + return $this->success('', $result['data']); } From 35f6dcf59158eae47289bbf276bae77e170ddd1a Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Mon, 20 Nov 2023 13:51:40 +0800 Subject: [PATCH 13/27] =?UTF-8?q?up=20=E4=BE=9B=E9=94=80=E5=AF=B9=E6=8E=A5?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E7=B3=BB=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/task/TaskLogic.php | 37 ++++++++++++++--------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/app/common/logic/task/TaskLogic.php b/app/common/logic/task/TaskLogic.php index fe626ecde..130ca195c 100644 --- a/app/common/logic/task/TaskLogic.php +++ b/app/common/logic/task/TaskLogic.php @@ -1176,18 +1176,18 @@ class TaskLogic extends BaseLogic // 负责人任务类型id列表 $typeIds = []; $townMasterTaskTypeList = DictData::where(['type_value' => 'town_task_type_master', 'status' => 1])->column('value', 'id'); - foreach ($townMasterTaskTypeList as $item) { - if ($item['value'] == 'town_task_type_master_3') { - $typeIds[] = $item['id']; + foreach ($townMasterTaskTypeList as $k => $item) { + if ($item == 'town_task_type_master_3') { + $typeIds[] = $k; } - if ($item['value'] == 'town_task_type_master_4') { - $typeIds[] = $item['id']; + if ($item == 'town_task_type_master_4') { + $typeIds[] =$k; } - if ($item['value'] == 'town_task_type_master_5') { - $typeIds[] = $item['id']; + if ($item == 'town_task_type_master_5') { + $typeIds[] = $k; } - if ($item['value'] == 'town_task_type_master_8') { - $typeIds[] = $item['id']; + if ($item == 'town_task_type_master_8') { + $typeIds[] = $k; } } @@ -1205,7 +1205,6 @@ class TaskLogic extends BaseLogic } } } - // 下属小组服务公司有任务安排,也完成了任务 if ($isDone === 1 && $isTaskSchedule === 1) { // 做任务结算,分润 @@ -2255,18 +2254,18 @@ class TaskLogic extends BaseLogic // 负责人任务类型id列表 $typeIds = []; $townMasterTaskTypeList = DictData::where(['type_value' => 'town_task_type_master', 'status' => 1])->column('value', 'id'); - foreach ($townMasterTaskTypeList as $item) { - if ($item['value'] == 'town_task_type_master_3') { - $typeIds[] = $item['id']; + foreach ($townMasterTaskTypeList as $k=>$item) { + if ($item == 'town_task_type_master_3') { + $typeIds[] = $k; } - if ($item['value'] == 'town_task_type_master_4') { - $typeIds[] = $item['id']; + if ($item == 'town_task_type_master_4') { + $typeIds[] = $k; } - if ($item['value'] == 'town_task_type_master_5') { - $typeIds[] = $item['id']; + if ($item == 'town_task_type_master_5') { + $typeIds[] = $k; } - if ($item['value'] == 'town_task_type_master_8') { - $typeIds[] = $item['id']; + if ($item == 'town_task_type_master_8') { + $typeIds[] = $k; } } // 查询 镇农科公司负责人是否有对应的每日任务安排 From 4daa667d6cf563cad3a8695b487d912bf046a185 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Mon, 20 Nov 2023 14:21:07 +0800 Subject: [PATCH 14/27] =?UTF-8?q?up=20=E4=BE=9B=E9=94=80=E5=AF=B9=E6=8E=A5?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E7=B3=BB=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/PayController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/controller/PayController.php b/app/api/controller/PayController.php index 875a402c1..a67580bb0 100755 --- a/app/api/controller/PayController.php +++ b/app/api/controller/PayController.php @@ -74,7 +74,7 @@ class PayController extends BaseApiController 'pay_user_role' => $this->userInfo['group_id'], 'pay_user_info' => $this->userInfo, 'business_order_no' => $order['sn'], - 'total_fee' => $order['order_amount'], + 'total_fee' => intval(bcmul($order['order_amount'], 100)), 'business_callback_url' => (string)url('pay/notifyApp', [], false, true) ]; $result = PayRequestLogic::getPrePayId($requestData); From 20d01ac6d9fb329620168a52abef39c5907d812b Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Mon, 20 Nov 2023 14:40:46 +0800 Subject: [PATCH 15/27] fixed --- app/common/logic/task/TaskLogic.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/common/logic/task/TaskLogic.php b/app/common/logic/task/TaskLogic.php index 130ca195c..a70a92715 100644 --- a/app/common/logic/task/TaskLogic.php +++ b/app/common/logic/task/TaskLogic.php @@ -1183,9 +1183,9 @@ class TaskLogic extends BaseLogic if ($item == 'town_task_type_master_4') { $typeIds[] =$k; } - if ($item == 'town_task_type_master_5') { - $typeIds[] = $k; - } +// if ($item == 'town_task_type_master_5') { +// $typeIds[] = $k; +// } if ($item == 'town_task_type_master_8') { $typeIds[] = $k; } @@ -1194,7 +1194,7 @@ class TaskLogic extends BaseLogic // 查询 镇农科公司负责人是否有对应的每日任务安排 $templateList = TaskTemplate::where(['company_id'=>$townCompany['id']])->whereIn('type', $typeIds)->select()->toArray(); // 未做任务安排的小组服务公司不在判定范围内,跳出本次循环 - if(count($templateList) === 4) { + if(count($templateList) === 3) { $isTaskSchedule = 1; // 查询负责人的循环任务有没有全部做完 任意有一个任务没有做完,则判定为 协助总负责人开展工作任务 失败 foreach ($templateList as $template) { @@ -2251,7 +2251,7 @@ class TaskLogic extends BaseLogic $isDone = 1; // 任务是否完成标记 $isTaskSchedule = 0; // 下属小组服务公司是否有每日任务安排标记 - // 负责人任务类型id列表 + // 负责人 每日任务类型id列表 $typeIds = []; $townMasterTaskTypeList = DictData::where(['type_value' => 'town_task_type_master', 'status' => 1])->column('value', 'id'); foreach ($townMasterTaskTypeList as $k=>$item) { @@ -2261,9 +2261,9 @@ class TaskLogic extends BaseLogic if ($item == 'town_task_type_master_4') { $typeIds[] = $k; } - if ($item == 'town_task_type_master_5') { - $typeIds[] = $k; - } +// if ($item == 'town_task_type_master_5') { +// $typeIds[] = $k; +// } if ($item == 'town_task_type_master_8') { $typeIds[] = $k; } From d7a76319af68e388b729276399c97cd9abb67b7e Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Mon, 20 Nov 2023 17:10:46 +0800 Subject: [PATCH 16/27] fixed --- app/common/logic/task/TaskLogic.php | 101 ++++++++++++++++++---------- 1 file changed, 67 insertions(+), 34 deletions(-) diff --git a/app/common/logic/task/TaskLogic.php b/app/common/logic/task/TaskLogic.php index a70a92715..6292aa637 100644 --- a/app/common/logic/task/TaskLogic.php +++ b/app/common/logic/task/TaskLogic.php @@ -863,32 +863,50 @@ class TaskLogic extends BaseLogic } } + + // 判断收集任务,整体是否已完成 + if ($dayCount == 60) { + $purchaseSalesInfo = $taskTemplateInfo['extend']['purchase_sales_info']; + $purchaseSalesCount = count($purchaseSalesInfo['planting']) + count($purchaseSalesInfo['supply']); + + $rate = bcdiv($purchaseSalesCount, $target, 2); + if ($rate >= 1) { + $rate = 1; + } + + $totalMoney = bcmul(bcdiv($taskTemplateInfo['money_two'], 2, 2),55, 2); + + $taskInfo['money'] = bcmul($totalMoney, $rate, 2); + (new TownShareProfit())->dealTaskSettlementMaster3($taskInfo, $townCompany, $taskSchedulePlan, $townTransactionPool); + } + + // 任务累计天数 大于 第一阶段 小于第一+第二阶段 判断交易任务是否完成,完成则结算,否则关闭任务 if ($dayCount > $taskTemplateInfo['stage_day_one'] && $dayCount < $stageDayTwoCount) { $purchaseSalesInfo = $taskTemplateInfo['extend']['purchase_sales_info']; $purchaseSalesCount = bcadd(count($purchaseSalesInfo['planting']), count($purchaseSalesInfo['supply'])); // 判断交易任务是否完成 - self::judgeMasterTask3Trade($taskTemplateInfo, $townCompany, $taskSchedulePlan, $purchaseSalesInfo, $townTransactionPool, $purchaseSalesCount); + self::judgeMasterTask3Trade($taskInfo, $taskTemplateInfo, $townCompany, $taskSchedulePlan, $purchaseSalesInfo, $townTransactionPool, $purchaseSalesCount); } // 任务累计天数 = 第一+第二阶段 判断信息收集和交易任务是否完成,完成则结算,否则关闭任务 - if ($dayCount == $stageDayTwoCount) { - $purchaseSalesInfo = $taskTemplateInfo['extend']['purchase_sales_info']; - $purchaseSalesCount = count($purchaseSalesInfo['planting']) + count($purchaseSalesInfo['supply']); - if ($purchaseSalesCount >= $target) { - $taskInfo['money'] = bcmul(bcdiv($taskTemplateInfo['money_two'], 2, 2), $taskTemplateInfo['stage_day_two'], 2); - (new TownShareProfit())->dealTaskSettlementMaster3($taskInfo, $townCompany, $taskSchedulePlan, $townTransactionPool); - } - } +// if ($dayCount == $stageDayTwoCount) { +// $purchaseSalesInfo = $taskTemplateInfo['extend']['purchase_sales_info']; +// $purchaseSalesCount = count($purchaseSalesInfo['planting']) + count($purchaseSalesInfo['supply']); +// if ($purchaseSalesCount >= $target) { +// $taskInfo['money'] = bcmul(bcdiv($taskTemplateInfo['money_two'], 2, 2), $taskTemplateInfo['stage_day_two'], 2); +// (new TownShareProfit())->dealTaskSettlementMaster3($taskInfo, $townCompany, $taskSchedulePlan, $townTransactionPool); +// } +// } // 任务累计天数 大于 第一+第二阶段 每日结算 判断交易任务是否完成,完成则结算,否则关闭任务 if ($dayCount >= $stageDayTwoCount) { // 判断交易任务是否完成 - self::judgeMasterTask3Trade($taskTemplateInfo, $townCompany, $taskSchedulePlan, $purchaseSalesInfo, $townTransactionPool, $target); + self::judgeMasterTask3Trade($taskInfo, $taskTemplateInfo, $townCompany, $taskSchedulePlan, $purchaseSalesInfo, $townTransactionPool, $target); } } - private static function judgeMasterTask3Trade($taskTemplateInfo, $townCompany, $taskSchedulePlan, $purchaseSalesInfo, $townTransactionPool, $target) + private static function judgeMasterTask3Trade($taskInfo, $taskTemplateInfo, $townCompany, $taskSchedulePlan, $purchaseSalesInfo, $townTransactionPool, $target) { // 查询收集到的用户在商城的交易金额(前置条件:信息收集中的手机号注册商城并交易) $phoneList = []; @@ -903,12 +921,18 @@ class TaskLogic extends BaseLogic 'end_time' => strtotime(date('Y-m-d', time())) + 86399, 'phone' => implode(',', $phoneList) ]; - $result = ShopRequestLogic::getUserTradeAmount($param); // todo 对接接口 - $tradeAmount = $result['data']['procure_amount']; + + $result = ShopRequestLogic::getUserTradeAmount($param); + + if(isset($result['status']) && $result['status']== 400) { + $tradeAmount = 0; + } + if(isset($result['status']) && $result['status']== 200) { + $tradeAmount = $result['data']['trade_amount']; + } $totalAmount = bcadd($tradeAmount, $townTransactionPool, 2); // 总的交易金额 = 当日交易额 + 累计交易池 - // 目标金额 = 274 * 收集用户数 $targetTradeAmount = bcmul($target, 274, 2); @@ -946,8 +970,9 @@ class TaskLogic extends BaseLogic 'responsible_area' => $townCompany['responsible_area'], 'type' => 'street', ]; - $result = ShopRequestLogic::getTownTradeAmount($param); // todo 对接接口 - $tradeAmount = $result['data']['procure_amount']; + $result = ShopRequestLogic::getTownTradeAmount($param); + + $tradeAmount = $result['data']['trade_amount']; // 总交易额 交易池金额+商城交易额 $totalAmount = bcadd($townTransactionPool, $tradeAmount, 2); @@ -1237,17 +1262,21 @@ class TaskLogic extends BaseLogic // 当前任务进行天数 = 第一阶段天数 判定任务完成情况,结算 if ($dayCount == $templateInfo['stage_day_one']) { // 请求商城接口,获取完成几家 - $param['start_time'] = strtotime(date('Y-m-d', $templateInfo['cretate_time'])) + 86400; + $param['start_time'] = strtotime(date('Y-m-d', strtotime($templateInfo['create_time']))) + 86400; $param['end_time'] = time(); $param['responsible_area'] = $townCompany['responsible_area']; $param['type'] = 'street'; $param['type_id'] = 17; + $result = ShopRequestLogic::getSupplyChainMerchantCount($param); + if ($result['status'] != 200) { Log::error('查询供应链商户统计接口失败'.ShopRequestLogic::getError()); - return false; + $count = 0; + } else { + $count = $result['data']['count']; } - $count = $result['data']['count']; + // 完成数小于3,关闭任务,不做结算 if ($count < 3){ @@ -1279,6 +1308,7 @@ class TaskLogic extends BaseLogic $taskInfo = Task::where(['id' => $taskSchedulePlan['task_id']])->find(); // 商城商户入驻申请id 与商户已关联 $shopMerchantSettleinLogList= ShopMerchantSettleinLog::where(['town_company_id'=>$townCompany['id']])->select()->toArray(); + // 遍历农科公司区域下的商户,对每个商户进行判定 foreach ($shopMerchantSettleinLogList as $item) { @@ -1294,12 +1324,16 @@ class TaskLogic extends BaseLogic 'mer_intention_id' => $merIntentionId, 'type_id' => 17, ]; + $result = ShopRequestLogic::getProductListing($param); + if ($result['status'] != 200) { Log::info(['4.市场部长-供应链商户完成商品上架和库存更新任务-查询商城接口失败', json_encode($result)]); - return false; + $count = 0; + } else { + $count = $result['data']['count']; } - $count = $result['data']['count']; + // 达到目标数 完成则结算 if ($count >= $templateInfo['extend']['target']){ // 结算金额 任务金额/目标数 * 天数 @@ -1323,11 +1357,14 @@ class TaskLogic extends BaseLogic 'type_id' => 17 ]; $result1 = ShopRequestLogic::getStockUpdate($param); + if ($result1['status'] != 200) { Log::info(['4.市场部长-供应链商户完成库存更新任务-查询商城接口结果', json_encode($result)]); - return false; + $count = 0; + } else { + $count = $result1['data']['count']; } - $count = $result1['data']['count']; + if ($count >= 1){ // 结算金额 任务金额/目标数 * 天数 $taskInfo['money'] = bcmul($templateInfo['stage_day_two'], bcdiv($templateInfo['money_two'], $templateInfo['extend']['target'])); @@ -1355,12 +1392,14 @@ class TaskLogic extends BaseLogic $taskInfo = Task::where(['id' => $taskSchedulePlan['task_id']])->find(); // 商城商户入驻申请id 与商户已关联 $shopMerchantSettleinLogList= ShopMerchantSettleinLog::where(['town_company_id'=>$townCompany['id']])->select()->toArray(); + // 遍历农科公司区域下的商户,对每个商户进行判定 foreach ($shopMerchantSettleinLogList as $item) { // 第一阶段 从入驻时间累计到第一阶段周期天数 为结算日期 只在截止日当天才结算 $startTime = strtotime(date('Y-m-d', strtotime($item['create_time']))); // 入驻当日 00:00:00 - $endTime = strtotime("{$templateInfo['stage_day_one']} day", $startTime); // $templateInfo['stage_day_one']天后的 00:00:00 + $endTime = strtotime("+{$templateInfo['stage_day_one']} day", $startTime); // $templateInfo['stage_day_one']天后的 00:00:00 + if (date('Y-m-d', $endTime) == date('Y-m-d', time())){ // 任务判定 self::judgeTaskMarketingDirector4($templateInfo, $item, $taskSchedulePlan, $startTime, $endTime, 1, $townCompany, $taskInfo); @@ -1369,7 +1408,7 @@ class TaskLogic extends BaseLogic // 第二阶段 从入驻时间累计到第二阶段周期天数 为结算日期 只在截止日当天才结算 $startTime1 = $endTime; // 第一阶段 截止日 00:00:00 $stageDayTwoCount = bcadd($templateInfo['stage_day_one'], $templateInfo['stage_day_two']); - $endTime1 = strtotime("{$stageDayTwoCount} day", $startTime); + $endTime1 = strtotime("+{$stageDayTwoCount} day", $startTime); if (date('Y-m-d', $endTime) == date('Y-m-d', time())){ self::judgeTaskMarketingDirector4($templateInfo, $item, $taskSchedulePlan, $startTime1, $endTime1, 2, $townCompany, $taskInfo); } @@ -1377,7 +1416,7 @@ class TaskLogic extends BaseLogic // 第三阶段 从入驻时间累计到第三阶段周期天数 为结算日期 只在截止日当天才结算 $startTime2 = $endTime1; // 第二阶段 截止日 00:00:00 $stageDayThreeCount = bcadd(bcadd($templateInfo['stage_day_one'], $templateInfo['stage_day_two']), $templateInfo['stage_day_three']); - $endTime2 = strtotime("{$stageDayThreeCount} day", $startTime); + $endTime2 = strtotime("+{$stageDayThreeCount} day", $startTime); if (date('Y-m-d', $endTime) == date('Y-m-d', time())){ self::judgeTaskMarketingDirector4($templateInfo, $item, $taskSchedulePlan, $startTime2, $endTime2, 3, $townCompany, $taskInfo); } @@ -1422,10 +1461,10 @@ class TaskLogic extends BaseLogic $result1 = ShopRequestLogic::getPurchaseAmount($param); if ($result1['status'] != 200) { Log::info(['4.市场部长-协助供应链商户采购任务-查询商城接口失败', json_encode($result1)]); - return false; + $result1['data']['procure_amount'] = 0; } if ($result1['data']['procure_amount'] > 0) { - $procureAmount = $result1['procure_amount']; + $procureAmount = $result1['data']['procure_amount']; // 采购金额 实际完成率 $rate = self::countRate($procureAmount, $step); @@ -1453,12 +1492,6 @@ class TaskLogic extends BaseLogic $taskMoney= self::countTaskMarketingDirector4TaskMoney($totalMoney, $rate); } $taskInfo['money'] = $taskMoney; - $taskSchedulePlan = TaskSchedulingPlan::where(['id', $taskInfo['scheduling_plan_id']]) - ->withJoin(['scheduling'], 'left') - ->where('scheduling.company_type', 41) - ->where('is_pay',0) - ->with(['template_info']) - ->find(); Log::info(['5.市场部长-供应链商户完成采购任务-$taskSchedulePlan', json_encode($taskSchedulePlan)]); (new TownShareProfit())->dealTaskSettlementMarketingDirector4($taskInfo, $townCompany, $taskSchedulePlan); } From 92f2abfc11e70dc4f85f1b832e4189b756063dac Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Mon, 20 Nov 2023 17:27:40 +0800 Subject: [PATCH 17/27] fixed --- app/common/logic/task/TaskLogic.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/common/logic/task/TaskLogic.php b/app/common/logic/task/TaskLogic.php index 6292aa637..aa414164e 100644 --- a/app/common/logic/task/TaskLogic.php +++ b/app/common/logic/task/TaskLogic.php @@ -1546,12 +1546,13 @@ class TaskLogic extends BaseLogic $taskInfo = Task::where(['id' => $taskSchedulePlan['task_id']])->find(); // 商城商户入驻申请id 与商户已关联 $shopMerchantSettleinLogList= ShopMerchantSettleinLog::where(['town_company_id'=>$townCompany['id']])->select()->toArray(); + // 遍历农科公司区域下的商户,对每个商户进行判定 foreach ($shopMerchantSettleinLogList as $item) { // 第一阶段 从入驻时间累计到第一阶段周期天数 为结算日期 只在截止日当天才结算 $startTime = strtotime(date('Y-m-d', strtotime($item['create_time']))); // 入驻当日 00:00:00 - $endTime = strtotime("{$templateInfo['stage_day_one']} day", $startTime); // $templateInfo['stage_day_one']天后的 00:00:00 + $endTime = strtotime("+{$templateInfo['stage_day_one']} day", $startTime); // $templateInfo['stage_day_one']天后的 00:00:00 if (date('Y-m-d', $endTime) == date('Y-m-d', time())){ // 任务判定 self::judgeTaskMarketingDirector5($templateInfo, $item, $taskSchedulePlan, $startTime, $endTime, 1, $townCompany, $taskInfo); @@ -1560,7 +1561,7 @@ class TaskLogic extends BaseLogic // 第二阶段 从入驻时间累计到第二阶段周期天数 为结算日期 只在截止日当天才结算 $startTime1 = $endTime; // 第一阶段 截止日 00:00:00 $stageDayTwoCount = bcadd($templateInfo['stage_day_one'], $templateInfo['stage_day_two']); - $endTime1 = strtotime("{$stageDayTwoCount} day", $startTime); + $endTime1 = strtotime("+{$stageDayTwoCount} day", $startTime); if (date('Y-m-d', $endTime) == date('Y-m-d', time())){ self::judgeTaskMarketingDirector5($templateInfo, $item, $taskSchedulePlan, $startTime1, $endTime1, 2, $townCompany, $taskInfo); } @@ -1568,7 +1569,7 @@ class TaskLogic extends BaseLogic // 第三阶段 从入驻时间累计到第三阶段周期天数 为结算日期 只在截止日当天才结算 $startTime2 = $endTime1; // 第二阶段 截止日 00:00:00 $stageDayThreeCount = bcadd(bcadd($templateInfo['stage_day_one'], $templateInfo['stage_day_two']), $templateInfo['stage_day_three']); - $endTime2 = strtotime("{$stageDayThreeCount} day", $startTime); + $endTime2 = strtotime("+{$stageDayThreeCount} day", $startTime); if (date('Y-m-d', $endTime) == date('Y-m-d', time())){ self::judgeTaskMarketingDirector5($templateInfo, $item, $taskSchedulePlan, $startTime2, $endTime2, 3, $townCompany, $taskInfo); } @@ -1611,11 +1612,13 @@ class TaskLogic extends BaseLogic 'type'=>300 ]; $result1 = ShopRequestLogic::getTradeAmount($param); - if ($result1['status'] != 200) { + if ($result1['status'] == 200) { + $tradeAmount = $result1['data']['procure_amount']; + } else { Log::info(['4.市场部长-协助供应链商户销售任务-查询商城接口失败', json_encode($result1)]); - return false; + $tradeAmount = 0; } - $tradeAmount = $result1['data']['procure_amount']; + if ($tradeAmount > 0) { // 采购金额 实际完成率 @@ -1627,6 +1630,7 @@ class TaskLogic extends BaseLogic $taskMoney = 0; // 全额完成可获得的总金额 $totalMoney = bcmul(30, bcdiv($templateInfo['money_three'], $templateInfo['extend']['target'], 2), 2); + // 已完成 计算结算金额 if ($step == 1) { $totalMoney = bcmul($templateInfo['stage_day_one'], bcdiv($templateInfo['money'], $templateInfo['extend']['target'], 2), 2); @@ -1644,6 +1648,7 @@ class TaskLogic extends BaseLogic // 计算结算金额 周期天数*(money/目标数)*实际完成率*对应发放比例 $taskMoney= self::countTaskMarketingDirector4TaskMoney($totalMoney, $rate); } + $taskInfo['money'] = $taskMoney; Log::info(['5.市场部长-供应链商户完成商品销售任务-$taskSchedulePlan', json_encode($taskSchedulePlan)]); (new TownShareProfit())->dealTaskSettlementMarketingDirector5($taskInfo, $townCompany, $taskSchedulePlan); From c9d14e48cb13a32561ec18319c3704af7ef753f7 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Mon, 20 Nov 2023 17:51:18 +0800 Subject: [PATCH 18/27] fixed --- app/common/logic/task/TaskLogic.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/common/logic/task/TaskLogic.php b/app/common/logic/task/TaskLogic.php index aa414164e..6683e4f16 100644 --- a/app/common/logic/task/TaskLogic.php +++ b/app/common/logic/task/TaskLogic.php @@ -1723,8 +1723,12 @@ class TaskLogic extends BaseLogic 'type_id' => 10 ]; $result = ShopRequestLogic::getGeneralMerchantCount($param); - Log::error('查询供应链商户统计接口失败'.ShopRequestLogic::getError()); - $count = $result['data']['count']; + if ($result['status'] == 200) { + $count = $result['data']['count']; + } else { + $count = 0; + } + if ($count >= $target) { $taskMoney = $totalMoney; return $taskMoney; From a9b29f03e840288f1f06e2520535398bfcaf915c Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Mon, 20 Nov 2023 18:04:03 +0800 Subject: [PATCH 19/27] fixed --- app/common/logic/task/TaskLogic.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/common/logic/task/TaskLogic.php b/app/common/logic/task/TaskLogic.php index 6683e4f16..1cc87785d 100644 --- a/app/common/logic/task/TaskLogic.php +++ b/app/common/logic/task/TaskLogic.php @@ -1806,10 +1806,10 @@ class TaskLogic extends BaseLogic // 任务累计天数==第一阶段 查询第一阶段期间入驻的商户是否完成商品上架任务 if ($dayCount == $stageDayOne) { - $taskIsDone = self::judgeTaskMarketingDirector7(-$townCompany); + $taskIsDone = self::judgeTaskMarketingDirector7($townCompany); // 结算分润 if($taskIsDone) { - $taskInfo['money'] = bcmul($taskIsDone, $templateInfo['money'], 2); + $taskInfo['money'] = bcmul($stageDayOne, $templateInfo['money'], 2); (new TownShareProfit())->dealTaskSettlementMarketingDirector7($taskInfo,$townCompany, $taskSchedulePlan); } else { (new Task())->closeTask($taskSchedulePlan['task_id']); @@ -1827,7 +1827,7 @@ class TaskLogic extends BaseLogic $taskIsDone = self::judgeTaskMarketingDirector7($townCompany); // 结算分润 if($taskIsDone) { - $taskInfo['money'] = bcmul($taskIsDone, $templateInfo['money'], 2); + $taskInfo['money'] = bcmul($templateInfo['stage_day_two'], $templateInfo['money'], 2); (new TownShareProfit())->dealTaskSettlementMarketingDirector7($taskInfo,$townCompany, $taskSchedulePlan); } else { (new Task())->closeTask($taskSchedulePlan['task_id']); From 959f7d642fe8ac8c40427ad59bc499f8a69bce40 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Mon, 20 Nov 2023 18:23:58 +0800 Subject: [PATCH 20/27] fixed --- app/api/controller/TaskController.php | 2 +- app/common/logic/task/TaskLogic.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/api/controller/TaskController.php b/app/api/controller/TaskController.php index 1621321ba..9c84f437f 100644 --- a/app/api/controller/TaskController.php +++ b/app/api/controller/TaskController.php @@ -447,7 +447,7 @@ class TaskController extends BaseApiController $stage = $parmas['stage']; // 当前做的是任务第几阶段 if ($stage == 1) { $extend['stage1'] = $parmas['stage1']; - $parmas['stage1']['is_commit'] = 1; + $extend['stage1']['is_commit'] = 1; } if ($stage == 2) { $extend['stage2'] = $parmas['stage2']; diff --git a/app/common/logic/task/TaskLogic.php b/app/common/logic/task/TaskLogic.php index 1cc87785d..6483aae3f 100644 --- a/app/common/logic/task/TaskLogic.php +++ b/app/common/logic/task/TaskLogic.php @@ -2132,7 +2132,7 @@ class TaskLogic extends BaseLogic return 0; } $taskMoney = 0; - if ($tradeAmount >= 100000) { + if ($tradeAmount >= $targetProcureAmount) { $taskMoney = $totalMoney; } else { // 计算结算金额 周期天数*(money/目标数)*实际完成率*对应发放比例 From 3d249a63ae2155ce41898b86dfdeea003eb79499 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Mon, 20 Nov 2023 19:01:21 +0800 Subject: [PATCH 21/27] fixed --- app/common/logic/task/TaskLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/common/logic/task/TaskLogic.php b/app/common/logic/task/TaskLogic.php index 6483aae3f..83d087fc9 100644 --- a/app/common/logic/task/TaskLogic.php +++ b/app/common/logic/task/TaskLogic.php @@ -2313,7 +2313,7 @@ class TaskLogic extends BaseLogic // 查询 镇农科公司负责人是否有对应的每日任务安排 $templateList = TaskTemplate::where(['company_id'=>$townCompany['id']])->whereIn('type', $typeIds)->select()->toArray(); // 未做任务安排的小组服务公司不在判定范围内,跳出本次循环 - if(count($templateList) === 4) { + if(count($templateList) === 3) { $isTaskSchedule = 1; // 查询负责人的循环任务有没有全部做完 任意有一个任务没有做完,则判定为 协助总负责人开展工作任务 失败 foreach ($templateList as $template) { From cdde963325669536638e0039cefcb88a1d540aa5 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Tue, 21 Nov 2023 09:09:10 +0800 Subject: [PATCH 22/27] fixed --- app/common/logic/task/TaskLogic.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/common/logic/task/TaskLogic.php b/app/common/logic/task/TaskLogic.php index 83d087fc9..02ee4e49b 100644 --- a/app/common/logic/task/TaskLogic.php +++ b/app/common/logic/task/TaskLogic.php @@ -1230,7 +1230,7 @@ class TaskLogic extends BaseLogic } } } - // 下属小组服务公司有任务安排,也完成了任务 + // 镇农科公司负责人有任务安排,也完成了任务 if ($isDone === 1 && $isTaskSchedule === 1) { // 做任务结算,分润 (new TownShareProfit())->dealTaskSettlementMarketingDirector1($taskInfo, $townCompany, $taskSchedulePlan); @@ -2612,12 +2612,13 @@ class TaskLogic extends BaseLogic if ($tempTask) { $plan = TaskSchedulingPlan::where(['id'=>$tempTask['scheduling_plan_id']])->find(); if ($plan['is_pay'] == 1) { - $extend = json_decode($tempTask['extend'], true); + $extend = $tempTask['extend']; $targetAmount += $extend['transaction']['arr']['day_money']; $townTotalTradeAmount += $extend['transaction']['arr']['total_price']; } } } + // 完成条件: 查镇所属小组服务公司当日实际完成金额总和+镇农科公司的资金池 > 查镇所属小组服务公司当日任务目标金额总和 if($targetAmount != 0 && bcadd($townTransactionPool, $townTotalTradeAmount, 2) >= $targetAmount) { // 将余下金额放入镇交易池 @@ -2640,12 +2641,10 @@ class TaskLogic extends BaseLogic $taskTemplateInfo = $taskSchedulePlan['template_info']; $taskDayCount = $taskTemplateInfo['day_count']; // 任务累计进行天数 $task = Task::where('id', $taskSchedulePlan['task_id'])->find(); - $stageDayOneAccumulative = $taskTemplateInfo['stage_day_one']; // 第一阶段累计天数 $stageDayTwoAccumulative = intval(bcadd($taskTemplateInfo['stage_day_one'], $taskTemplateInfo['stage_day_two'])); // 第二阶段累计天数 第一+第二 $townCompany = Company::where('id', $taskTemplateInfo['company_id'])->find(); // 镇农科公司 - $villageCompanyList = Company::where(['street' => $townCompany['street'], 'company_type'=> 17])->select()->toArray(); // 村管理公司 - + dd($taskDayCount, $stageDayTwoAccumulative); // 当前任务进行天数 <= 第一+第二阶段天数 判定任务是否完成 结算 分润 if($taskDayCount <= $stageDayTwoAccumulative) { // 小组服务公司总数 From 78b7c8ea0a805aa19a8f7caae6aed12af0519f61 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Tue, 21 Nov 2023 10:40:34 +0800 Subject: [PATCH 23/27] =?UTF-8?q?add=20=E5=AF=B9=E6=8E=A5=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E7=B3=BB=E7=BB=9F=EF=BC=8C=E5=9B=9E=E8=B0=83=E6=94=B9?= =?UTF-8?q?=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/PayController.php | 12 ++++--- app/common/logic/PayNotifyLogic.php | 3 +- app/common/service/pay/WeChatPayService.php | 40 +++------------------ 3 files changed, 15 insertions(+), 40 deletions(-) diff --git a/app/api/controller/PayController.php b/app/api/controller/PayController.php index a67580bb0..7a6ea7fe1 100755 --- a/app/api/controller/PayController.php +++ b/app/api/controller/PayController.php @@ -145,9 +145,13 @@ class PayController extends BaseApiController */ public function notifyApp() { - $param = $this->request->param(); - return (new WeChatPayService(UserTerminalEnum::ANDROID))->notify($param); + try { + $param = $this->request->param(); + Log::info(['支付系统回调', $param]) + (new WeChatPayService(UserTerminalEnum::ANDROID))->notify($param); + return $this->success('ok'); + } catch (\Exception $e) { + return $this->fail($e->getMessage()); + } } - - } diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 63e0691e4..36718fbcb 100755 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -67,6 +67,7 @@ class PayNotifyLogic extends BaseLogic $order = RechargeOrder::where('sn', $orderSn)->findOrEmpty(); if ($order && isset($order['extend']['type']) && $order['extend']['type'] == 1) { + // ***** 小组服务团队-入股任务逻辑 已废弃 ***** $find = Task::where('id', $order['extend']['task_id'])->find(); $extend=$find['extend']; $extend['shareholder']['order_sn']=$order->sn; @@ -112,7 +113,7 @@ class PayNotifyLogic extends BaseLogic // 更新充值订单状态 $order->transaction_id = $extra['transaction_id']; - $order->pay_status = PayEnum::ISPAID; + $order->pay_status = $extra['pay_status'];; $order->pay_time = time(); $order->save(); } diff --git a/app/common/service/pay/WeChatPayService.php b/app/common/service/pay/WeChatPayService.php index 511c134c0..9faf775dd 100755 --- a/app/common/service/pay/WeChatPayService.php +++ b/app/common/service/pay/WeChatPayService.php @@ -354,44 +354,14 @@ class WeChatPayService extends BasePayService /** * @notes 支付回调 - * @return \Psr\Http\Message\ResponseInterface - * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException - * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException - * @throws \ReflectionException - * @throws \Throwable - * @author 段誉 - * @date 2023/2/28 14:20 */ public function notify($param) { - Log::info(['支付回调', $param]); -// $server = $this->app->getServer(); -// // 支付通知 -// $server->handlePaid(function (Message $message) { -// $data = ['trade_state' => $message['trade_state'] ?? '', 'out_trade_no' => $message['out_trade_no'] ?? '', 'transaction_id' => $message['transaction_id'] ?? '', 'attach' => $message['attach'] ?? '']; -// Log::info('wechat pay notify: ' . var_export($data, true)); -// if ($message['trade_state'] === 'SUCCESS') { -// $extra['transaction_id'] = $message['transaction_id']; -// $attach = $message['attach']; -// $message['out_trade_no'] = mb_substr($message['out_trade_no'], 0, 18); -// switch ($attach) { -// case 'recharge': -// $order = RechargeOrder::where(['sn' => $message['out_trade_no']])->findOrEmpty(); -// if($order->isEmpty() || $order->pay_status == PayEnum::ISPAID) { -// return true; -// } -// PayNotifyLogic::handle('recharge', $message['out_trade_no'], $extra); -// break; -// } -// } -// return true; -// }); -// -// // 退款通知 -// $server->handleRefunded(function (Message $message) { -// return true; -// }); -// return $server->serve(); + Log::info(['支付回调', $param]); + $extra['transaction_id'] = $param['transaction_id']; + $extra['pay_status'] = $param['pay_status']; + PayNotifyLogic::handle('recharge', $param['out_trade_no'], $extra); + return true; } public function configForPayment($prepayId, $appId) From 6c44af1cf09ab0a1ec17bc1b945dbd4c07999ab6 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Tue, 21 Nov 2023 10:43:26 +0800 Subject: [PATCH 24/27] =?UTF-8?q?add=20=E5=AF=B9=E6=8E=A5=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E7=B3=BB=E7=BB=9F=EF=BC=8C=E5=9B=9E=E8=B0=83=E6=94=B9?= =?UTF-8?q?=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/PayController.php | 7 +------ app/common/service/pay/WeChatPayService.php | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/app/api/controller/PayController.php b/app/api/controller/PayController.php index 7a6ea7fe1..04deefac8 100755 --- a/app/api/controller/PayController.php +++ b/app/api/controller/PayController.php @@ -135,12 +135,7 @@ class PayController extends BaseApiController /** - * @notes app支付回调 - * @return \Psr\Http\Message\ResponseInterface - * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException - * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException - * @throws \ReflectionException - * @throws \Throwable + * @notes 支付系统回调 * @date 2023/2/28 14:21 */ public function notifyApp() diff --git a/app/common/service/pay/WeChatPayService.php b/app/common/service/pay/WeChatPayService.php index 9faf775dd..1a628c559 100755 --- a/app/common/service/pay/WeChatPayService.php +++ b/app/common/service/pay/WeChatPayService.php @@ -355,7 +355,7 @@ class WeChatPayService extends BasePayService /** * @notes 支付回调 */ - public function notify($param) + public function notify($param=[]) { Log::info(['支付回调', $param]); $extra['transaction_id'] = $param['transaction_id']; From d09758fa98f8087bdcda93882f81edb0673698f9 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Tue, 21 Nov 2023 11:15:40 +0800 Subject: [PATCH 25/27] =?UTF-8?q?add=20=E5=AF=B9=E6=8E=A5=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E7=B3=BB=E7=BB=9F=EF=BC=8C=E5=9B=9E=E8=B0=83=E6=94=B9?= =?UTF-8?q?=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/PayController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/controller/PayController.php b/app/api/controller/PayController.php index 04deefac8..5827cf5da 100755 --- a/app/api/controller/PayController.php +++ b/app/api/controller/PayController.php @@ -142,7 +142,7 @@ class PayController extends BaseApiController { try { $param = $this->request->param(); - Log::info(['支付系统回调', $param]) + Log::info(['支付系统回调', $param]); (new WeChatPayService(UserTerminalEnum::ANDROID))->notify($param); return $this->success('ok'); } catch (\Exception $e) { From 5993ecef3c6d6762e69f087992b42fb3ddf4f123 Mon Sep 17 00:00:00 2001 From: weiz Date: Wed, 22 Nov 2023 11:01:36 +0800 Subject: [PATCH 26/27] =?UTF-8?q?=E5=89=8D=E5=8F=B0=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=BD=93=E6=9C=BA?= =?UTF-8?q?=E6=9E=81=E5=85=89=E6=8E=A8=E9=80=81=E8=AE=BE=E5=A4=87id?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/LoginLogic.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/api/logic/LoginLogic.php b/app/api/logic/LoginLogic.php index 9c0051239..e70ca1ce6 100755 --- a/app/api/logic/LoginLogic.php +++ b/app/api/logic/LoginLogic.php @@ -140,6 +140,9 @@ class LoginLogic extends BaseLogic if (isset($params['register_id']) && $params['register_id'] != '') { $user->register_id = $params['register_id']; } + if (isset($params['ytj_register_id']) && $params['ytj_register_id'] != '') { + $user->ytj_register_id = $params['ytj_register_id']; + } //更新登录信息 $user->login_time = time(); $user->login_ip = request()->ip(); From 8357942b4124c36918af78105b4bb70029331d0f Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Wed, 22 Nov 2023 14:04:30 +0800 Subject: [PATCH 27/27] =?UTF-8?q?update=20=E6=89=8B=E5=8A=A8=E4=B8=8B?= =?UTF-8?q?=E5=8F=91=E4=BB=BB=E5=8A=A1=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/CeshiController.php | 234 ++++++++++++++++++++++++- 1 file changed, 225 insertions(+), 9 deletions(-) diff --git a/app/api/controller/CeshiController.php b/app/api/controller/CeshiController.php index a6c21264a..7422606e7 100644 --- a/app/api/controller/CeshiController.php +++ b/app/api/controller/CeshiController.php @@ -7,6 +7,7 @@ use app\adminapi\validate\CompanyValidate; use app\common\logic\contract\ContractLogic; use app\common\logic\finance\ShareProfit; use app\common\logic\RedisLogic; +use app\common\logic\ShopRequestLogic; use app\common\logic\task\TaskLogic; use app\common\model\Company; use app\common\model\contract\Contract; @@ -16,6 +17,9 @@ use app\common\model\task_scheduling_plan\TaskSchedulingPlan; use app\common\model\task_template\TaskTemplate; use app\job\TaskAdd; use app\job\TaskInformationJob; +use app\job\VillageTaskAdd; +use app\job\VillageTaskSettlementJob; +use think\Exception; use think\facade\Log; use app\job\TaskTenZehn; use think\facade\Db; @@ -36,6 +40,12 @@ class CeshiController extends BaseApiController 'initiate_contract', // 发起合同 'Draftingcontracts', // 发送合同 'postsms', // 发送短信 + 'addSupplyMerchant', // 添加供应商 + 'signSupplyMerchantContract', // 生成合同 + 'countRate', + 'village_task_add_test', + 'village_task_settlement_test', + 'testShopApi' ]; public function index() @@ -250,18 +260,22 @@ class CeshiController extends BaseApiController public function service_group_task_add_test() { //任务下发 + $companyId = $this->request->param('company_id'); $time = strtotime(date('Y-m-d')); // 今天的00:00:00 // 注意 cron_time - $plan_all = TaskScheduling::where('cron_time', '<', $time) + $plan_all = TaskScheduling::where('cron_time', '<', time()) ->where('status', 1) ->where('company_type', 18) + ->where('company_id', $companyId) ->with('company_info') ->select() ->toArray(); - dd($plan_all); $plan_ids = []; + dd($plan_all); foreach ($plan_all as $k => $v) { + $all = TaskTemplate::where('status', 1)->where('task_scheduling', $v['id'])->limit(30)->select()->toArray(); + $plan_ids[] = $v['id']; if ($all) { $plan_all[$k]['template'] = $all; @@ -292,12 +306,12 @@ class CeshiController extends BaseApiController $all = TaskSchedulingPlan::whereDay('end_time','today') ->withJoin(['scheduling'], 'left') ->where('scheduling.company_type', 18) + ->where('scheduling.company_id', 43) ->where('is_pay',0) ->with(['template_info']) ->select() ->toArray(); dd($all); - foreach($all as $k=>$data){ try { TaskSchedulingPlan::where('id', $data['id'])->update(['is_pay' => 1]); @@ -454,20 +468,32 @@ class CeshiController extends BaseApiController public function town_task_add_ceshi() { //任务下发 + $companyId = $this->request->param('company_id'); + $taskTypeIds = $this->request->param('task_type_ids'); $time = strtotime(date('Y-m-d')); // 查询系统 所有镇农科公司 未下发 的 任务安排 - $taskSchedulingList = TaskScheduling::where('cron_time', '<', $time)->where('status', 1)->where('company_type', 41)->with('company_info')->select()->toArray(); - dd($taskSchedulingList); + $taskSchedulingList = TaskScheduling::where('cron_time', '<', time()) + ->where('status', 1) + ->where('company_type', 41) + ->where('company_id', $companyId) + ->with('company_info') + ->select() + ->toArray(); + $taskSchedulingIds = []; $companyIds = []; foreach ($taskSchedulingList as $k => $taskScheduling) { $templateList = TaskTemplate::where('status', 1)->where('task_scheduling', $taskScheduling['id'])->limit(30)->select()->toArray(); + $taskSchedulingIds[] = $taskScheduling['id']; $companyIds[] = $taskScheduling['company_id']; foreach ($templateList as $template) { + if (in_array($template['type'], explode(',', $taskTypeIds))) { + TaskLogic::TownCronAdd($template); // 手动下发用 + } // queue(TownTaskAdd::class, $template); - TaskLogic::TownCronAdd($template); // 手动下发用 + } if (empty($templateList)) { @@ -477,6 +503,7 @@ class CeshiController extends BaseApiController Company::where('id', 'in', $companyIds)->inc('day_count')->update(); TaskScheduling::where('id', 'in', $taskSchedulingIds)->update(['cron_time' => time()]); Log::info('定时任务下发执行成功' . date('Y-m-d H:i:s')); + return $this->success('定时任务下发执行成功'); } /** @@ -494,10 +521,199 @@ class CeshiController extends BaseApiController ->toArray(); dd($taskSchedulingPlanList); foreach($taskSchedulingPlanList as $taskSchedulingPlan) { - if (in_array($taskSchedulingPlan['template_info']['type'], [44,45,46,47,48,49,50])) { - continue; + if ($taskSchedulingPlan['company_id'] == 30 && $taskSchedulingPlan['template_info']['type'] == 50) { + + TaskLogic::townTaskSettlement($taskSchedulingPlan); } - TaskLogic::townTaskSettlement($taskSchedulingPlan); + } + return $this->success('镇农科公司定时任务结算执行成功'); + } + + /** + * 村管理公司任务下发 + */ + public function village_task_add_test() + { + //任务下发 + $time = strtotime(date('Y-m-d')); + // 查询系统 所有镇农科公司 未下发 的 任务安排 + $taskSchedulingList = TaskScheduling::where('cron_time', '<', time()) + ->where('status', 1) + ->where('company_type', 17) + ->where('company_id', 33) + ->with('company_info') + ->select() + ->toArray(); + dd($taskSchedulingList); + $taskSchedulingIds = []; + $companyIds = []; + foreach ($taskSchedulingList as $k => $taskScheduling) { + $templateList = TaskTemplate::where('status', 1)->where('task_scheduling', $taskScheduling['id'])->limit(30)->select()->toArray(); + $taskSchedulingIds[] = $taskScheduling['id']; + $companyIds[] = $taskScheduling['company_id']; + foreach ($templateList as $template) { + + if ($template['type'] == 69) { + TaskLogic::VillageCronAdd($template); // 手动下发用 + } + + +// queue(VillageTaskAdd::class, $template); + + } + + if (empty($templateList)) { + unset($taskSchedulingList[$k]); + } + } + Company::where('id', 'in', $companyIds)->inc('day_count')->update(); + TaskScheduling::where('id', 'in', $taskSchedulingIds)->update(['cron_time' => time()]); + Log::info('村管理公司定时任务下发执行成功' . date('Y-m-d H:i:s')); + return $this->success('村管理公司定时任务下发执行成功'); + } + + /** + * 村管理公司任务结算 + */ + public function village_task_settlement_test() + { + Log::info('村管理公司定时任务结算执行-开始'.date('Y-m-d H:i:s')); + //today 今日未结算的任务计划 + $taskSchedulingPlanList = TaskSchedulingPlan::whereDay('end_time','today') + ->withJoin(['scheduling'], 'left') + ->where('scheduling.company_type', 17) + ->where('scheduling.company_id', 33) + ->where('is_pay',0) + ->with(['template_info']) + ->select() + ->toArray(); + dd($taskSchedulingPlanList); + foreach($taskSchedulingPlanList as $taskSchedulingPlan){ + if ($taskSchedulingPlan['template_info']['type'] == 69) { + TaskLogic::villageTaskSettlement($taskSchedulingPlan); + } +// queue(VillageTaskSettlementJob::class, $taskSchedulingPlan); + } + Log::info('村管理公司定时任务结算执行-结束'.date('Y-m-d H:i:s')); + return $this->success('村管理公司定时任务结算执行成功'); + } + + + public function countRate() + { + // 第一个月 + $startTime1 = strtotime(date('Y-m-d', time())); // 任务下发当天 00:00:00 + $endTime1 = strtotime("+30 day", $startTime1); // 30天后的00:00:00 + + + // 第二个月 + $startTime2 = strtotime(date('Y-m-d', $endTime1)); // 第一个月截止日 00:00:00 + $endTime2 = strtotime("+30 day", $startTime2); // 30天后的00:00:00 + dd([date('Y-m-d H:i:s', $startTime1), date('Y-m-d H:i:s', $endTime1), date('Y-m-d H:i:s', $startTime2), date('Y-m-d H:i:s', $endTime2)]); + $procureAmount = 1234; + $step = $this->request->param('step', 1); + // 商户入驻至今累计天数 + $targetProcureAmount = 10000; + // 目标采购额每阶段增幅30% + for ($i = 1; $i < $step; $i++) { + $targetProcureAmount = self::increase($targetProcureAmount); + } + dd($targetProcureAmount); + $rate = bcdiv($procureAmount, $targetProcureAmount, 2); + return $rate; + } + + private static function increase($value) + { + return bcmul($value, 1.3,2); + } + + /** + * 添加供应链商户 + */ + public function addSupplyMerchant() + { + try { + // 添加商户数据 + $params = $this->request->param(); + $data = [ + 'mer_intention_id' => 0, // 商城商户入驻申请id,签约完成后回调使用 + 'company_name' => $params['company_name']??'', + 'mer_name' => $params['mer_name']??'', // 店铺名称 + 'organization_code' => $params['organization_code']??'', + 'city' => $params['city']??'', + 'area' => $params['area']??'', + 'street' => $params['street']??'', + 'address' => $params['address']??'', + 'master_name' => $params['master_name']??'', + 'master_phone' => $params['master_phone']??'', + 'master_email' => $master_email??'', + 'type_name' => $params['type_name'] ?? '', //店铺类型 + 'category_name' => $params['category_name'] ?? '', //商户分类 + 'qualification' => !empty($params['images'])?$params['images']:json_encode([]) + ]; + $shopMerchantModel = ShopMerchant::create($data); + + $shopMerchantCertificationData = [ + 'name' => $shopMerchantModel->company_name, + 'organization_code' => $shopMerchantModel->organization_code, + 'business_license' => 'https://lihai001.oss-cn-chengdu.aliyuncs.com/def/561f8202305171526091317.png', + 'master_name' => $shopMerchantModel->master_name, + 'master_email' => $shopMerchantModel->master_email, + 'master_phone' => $shopMerchantModel->master_phone, + 'id' => $shopMerchantModel->id, + ]; + $re = app(JunziqianController::class)->ShopMerchantCertification($shopMerchantCertificationData); + + return $this->success('成功', $shopMerchantModel->toArray()); + } catch (Exception $e) { + return $this->fail($e->getMessage()); + } + + } + + // 生成合同 + public function signSupplyMerchantContract() + { + try { + $params = $this->request->param(); + // 生成合同 + $createContractData = [ + 'id' => $params['id'], + 'party_a' => $params['party_a'], + 'party_a_name' => $params['party_a_name'], + 'party_b' => $params['party_b'], + 'party_b_name' => $params['party_b_name'], + 'contract_type' => 58, // 供应链商户合同 + ]; + $model = new ShopContract(); + $model->contract_no = time(); + $model->create_time = time(); + $model->check_status = 1; + $model->update_time = time(); + $model->setAttrs($createContractData); + $res = $model->save($createContractData); + return $this->success('成功', $res->toArray()); + } catch (Exception $e) { + return $this->fail($e->getMessage()); } } + + public function testShopApi() + { + $id = $this->request->param('id'); + $templateInfo = TaskTemplate::where(['id'=>$id])->find(); + $townCompany = Company::where(['id' => $templateInfo['company_id']])->find(); + + $param['start_time'] = strtotime(date('Y-m-d', $templateInfo['cretate_time'])) + 86400; + $param['end_time'] = time(); + $param['mer_intention_id'] = 131; +// $param['goods_id'] = '17,18'; + $param['type_id'] = 10; + + + // todo 返回字段要对接 + $result = ShopRequestLogic::getGeneralMerchantProductListing($param); + dd($result); + } }