Compare commits
No commits in common. "master" and "dev_towntask" have entirely different histories.
master
...
dev_townta
35
.example.env
35
.example.env
@ -1,34 +1 @@
|
||||
APP_DEBUG = true
|
||||
|
||||
[APP]
|
||||
DEFAULT_TIMEZONE = Asia/Shanghai
|
||||
|
||||
[DATABASE]
|
||||
TYPE = mysql
|
||||
HOSTNAME = 127.0.0.1
|
||||
DATABASE = test
|
||||
USERNAME = username
|
||||
PASSWORD = password
|
||||
HOSTPORT = 3306
|
||||
CHARSET = utf8
|
||||
DEBUG = true
|
||||
PREFIX = la_
|
||||
|
||||
[LANG]
|
||||
default_lang = zh-cn
|
||||
|
||||
[PROJECT]
|
||||
UNIQUE_IDENTIFICATION = likeadmin
|
||||
# 演示环境
|
||||
DEMO_ENV = false
|
||||
|
||||
[DATABASE]
|
||||
TYPE = "mysql"
|
||||
HOSTNAME = "47.109.36.146"
|
||||
DATABASE = "worker_task"
|
||||
USERNAME = "worker_task"
|
||||
PASSWORD = "p4WGD67TezzzX3Mc"
|
||||
HOSTPORT = "3306"
|
||||
CHARSET = "utf8mb4"
|
||||
DEBUG = "0"
|
||||
PREFIX = "la_"
|
||||
APP_DEBUG = true
[APP]
DEFAULT_TIMEZONE = Asia/Shanghai
[DATABASE]
TYPE = mysql
HOSTNAME = 127.0.0.1
DATABASE = test
USERNAME = username
PASSWORD = password
HOSTPORT = 3306
CHARSET = utf8
DEBUG = true
PREFIX = la_
[LANG]
default_lang = zh-cn
[PROJECT]
UNIQUE_IDENTIFICATION = likeadmin
# 演示环境
DEMO_ENV = false
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -10,5 +10,3 @@
|
||||
/public/nginx.htaccess
|
||||
/public/.htaccess
|
||||
vendor/ebaoquan/junziqian_sdk
|
||||
vendor/workerman/workerman.log
|
||||
vendor/workerman/*.pid
|
@ -20,7 +20,7 @@ install:
|
||||
- composer require --update-no-dev --no-interaction "topthink/think-migration:^1.0"
|
||||
- composer require --update-no-dev --no-interaction "topthink/think-captcha:^1.0"
|
||||
- composer require --update-no-dev --no-interaction "topthink/think-mongo:^1.0"
|
||||
- composer require --update-no-dev --no-interaction "topthink/think-workerim:^1.0"
|
||||
- composer require --update-no-dev --no-interaction "topthink/think-worker:^1.0"
|
||||
- composer require --update-no-dev --no-interaction "topthink/think-helper:^1.0"
|
||||
- composer require --update-no-dev --no-interaction "topthink/think-queue:^1.0"
|
||||
- composer require --update-no-dev --no-interaction "topthink/think-angular:^1.0"
|
||||
|
@ -1,108 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\CompanyComplaintFeedbackLists;
|
||||
use app\adminapi\logic\CompanyComplaintFeedbackLogic;
|
||||
use app\adminapi\validate\CompanyComplaintFeedbackValidate;
|
||||
|
||||
|
||||
/**
|
||||
* CompanyComplaintFeedback控制器
|
||||
* Class CompanyComplaintFeedbackController
|
||||
* @package app\adminapi\controller
|
||||
*/
|
||||
class CompanyComplaintFeedbackController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/09/23 15:14
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new CompanyComplaintFeedbackLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/09/23 15:14
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new CompanyComplaintFeedbackValidate())->post()->goCheck('add');
|
||||
$result = CompanyComplaintFeedbackLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(CompanyComplaintFeedbackLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/09/23 15:14
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new CompanyComplaintFeedbackValidate())->post()->goCheck('edit');
|
||||
$result = CompanyComplaintFeedbackLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(CompanyComplaintFeedbackLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/09/23 15:14
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new CompanyComplaintFeedbackValidate())->post()->goCheck('delete');
|
||||
CompanyComplaintFeedbackLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/09/23 15:14
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new CompanyComplaintFeedbackValidate())->goCheck('detail');
|
||||
$result = CompanyComplaintFeedbackLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -18,7 +18,6 @@ namespace app\adminapi\controller;
|
||||
|
||||
use app\adminapi\lists\CompanyLists;
|
||||
use app\adminapi\logic\auth\AdminLogic;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\logic\CompanyLogic;
|
||||
use app\adminapi\validate\CompanyValidate;
|
||||
use app\api\controller\JunziqianController;
|
||||
@ -26,10 +25,6 @@ use app\common\logic\RedisLogic;
|
||||
use app\common\model\Approve;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\company\CompanyAccountLog;
|
||||
use app\common\model\CompanyDepositVoucher;
|
||||
use app\common\model\recharge\RechargeOrder;
|
||||
use app\common\model\user\UserAccountLog;
|
||||
use think\Exception;
|
||||
use think\facade\Db;
|
||||
use app\common\logic\contract\ContractLogic;
|
||||
@ -164,14 +159,13 @@ class CompanyController extends BaseAdminController
|
||||
}
|
||||
return $this->fail(ContractLogic::getError());
|
||||
}
|
||||
|
||||
// /**发送合同 */
|
||||
// /**生成合同 */
|
||||
public function Draftingcontracts()
|
||||
{
|
||||
$params = $this->request->param();
|
||||
$result = ContractLogic::Draftingcontracts($params);
|
||||
if ($result == true) {
|
||||
return $this->success('发送合同成功', [], 1, 1);
|
||||
return $this->success('生成合同成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(ContractLogic::getError());
|
||||
}
|
||||
@ -326,7 +320,6 @@ class CompanyController extends BaseAdminController
|
||||
return $this->fail('参数不能为空');
|
||||
}
|
||||
$where[] = [$parmas['key'], '=', $parmas['value']];
|
||||
$where[] = ['company_type', '=', $parmas['company_type']];
|
||||
switch ($parmas['key']) {
|
||||
case 'city':
|
||||
// $geo_area=Db::name('geo_area')->where('city_code', '=', $parmas['value'])->column('area_code');
|
||||
@ -383,21 +376,15 @@ class CompanyController extends BaseAdminController
|
||||
// $isQueryStatus = false; // 需要进一步查询是否已做过企业认证
|
||||
// // $master_email为空表示没有做过认证
|
||||
// if($master_email){
|
||||
// $isQueryStatus = true;asdasd,fsdfdf
|
||||
// $isQueryStatus = true;
|
||||
// }else{
|
||||
// $master_email=substr(md5(uniqid()),rand(0, 22),10)."@lihai.com";
|
||||
// }
|
||||
|
||||
// 市级供应链直接和海之农签约
|
||||
if (isset($params['type_id']) && $params['type_id'] == 12) {
|
||||
$company = Company::where(['company_name' => '泸州市海之农科技有限公司'])->find();
|
||||
} else {
|
||||
// 根据street码查询所属镇农科公司
|
||||
$company_select=Db::query("select * from la_company where company_type=:company_type and FIND_IN_SET(:street,responsible_area)", ['company_type' => 41,'street'=>$params['street']], true);
|
||||
if(empty($company_select)) {
|
||||
throw new Exception('当前区域无镇农科公司');
|
||||
}
|
||||
$company=$company_select[0];
|
||||
// 根据street码查询所属镇管理公司
|
||||
$company = Company::where(['street' => $params['street'], 'company_type' => 41])->find();
|
||||
if(empty($company)) {
|
||||
throw new Exception('未找到所属镇管理公司');
|
||||
}
|
||||
$data = [
|
||||
'mer_intention_id' => $params['mer_intention_id']??'', // 商城商户入驻申请id,签约完成后回调使用
|
||||
@ -420,13 +407,13 @@ class CompanyController extends BaseAdminController
|
||||
// 插入审批流
|
||||
$approveModel->type = $shopApproveType == 1? 2: 3; // 审批类型,后台配置 1 其他任务 2商户入驻 3开通交易
|
||||
$approveModel->flow_id = 2;
|
||||
$approveModel->name = $shopApproveType == 1? '商户入驻审批': '开通交易审批';
|
||||
$approveModel->name = $shopApproveType == 1? '商户入驻审批': '商户开通交易审批';
|
||||
$approveModel->admin_id = 0; // 后台发起人id 暂时为0
|
||||
$approveModel->department_id = '0';
|
||||
$approveModel->check_admin_ids = $company['admin_id']; // 当前审批人ID 镇农科公司负责人
|
||||
$approveModel->check_admin_ids = $company['area_manager']; // 当前审批人ID 片区经理的admin_id
|
||||
$approveModel->check_status = 1; // 状态 0待审核,1审核中,2审核通过,3审核不通过,4撤销审核
|
||||
$approveModel->other_type = 6;
|
||||
$approveModel->extend = json_encode(array_merge($params, $data));
|
||||
$approveModel->extend = json_encode($data);
|
||||
$approveModel->create_time = time();
|
||||
$approveModel->update_time = time();
|
||||
$approveModel->save();
|
||||
@ -484,80 +471,4 @@ class CompanyController extends BaseAdminController
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 押金凭证录入,并将押金写入公司押金账户,新增一条押金充值流水
|
||||
public function depositRechargeTransferVoucher()
|
||||
{
|
||||
try {
|
||||
$param = $this->request->param();
|
||||
Db::startTrans();
|
||||
$data = [
|
||||
'company_id' => $param['company_id'],
|
||||
'deposit' => $param['deposit'],
|
||||
'voucher' => $param['voucher'],
|
||||
'create_admin_id' => $this->adminId,
|
||||
'create_time' => time(),
|
||||
'update_time' => time()
|
||||
];
|
||||
$result = (new CompanyDepositVoucher())->save($data);
|
||||
|
||||
$companyModel = Company::where(['id' => $param['company_id']])->find();
|
||||
$left_amount = bcadd($companyModel['deposit'], $param['deposit'], 2);
|
||||
|
||||
// 添加流水记录
|
||||
$datas = [
|
||||
'sn' => generate_sn(CompanyAccountLog::class, 'sn', 20),
|
||||
'user_id' => 0,
|
||||
'company_id' => $param['company_id'],
|
||||
'change_type' => CompanyAccountLog::COMPANY_DEPOSIT,
|
||||
'change_object' => CompanyAccountLog::DEPOSIT,
|
||||
'action' => 1,
|
||||
'change_amount' => $param['deposit'],
|
||||
'left_amount' =>$left_amount,
|
||||
'remark' => '后台押金转账凭证充值',
|
||||
'status' => 1,
|
||||
];
|
||||
CompanyAccountLog::create($datas);
|
||||
|
||||
// 更新公司押金金额
|
||||
$companyModel->deposit = $left_amount;
|
||||
$companyModel->save();
|
||||
Db::commit();
|
||||
return $this->success('成功');
|
||||
} catch (Exception $exception) {
|
||||
Db::rollback();
|
||||
return $this->fail($exception->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getPartyA()
|
||||
{
|
||||
$companyId = $this->request->param('company_id');
|
||||
$re = CompanyLogic::getPartyA($companyId);
|
||||
if ($re === false) {
|
||||
return $this->fail(CompanyLogic::getError());
|
||||
}
|
||||
return $this->success('成功', $re);
|
||||
}
|
||||
|
||||
public function getDepositRechargeTransferVoucherList()
|
||||
{
|
||||
$companyId = $this->request->param('company_id');
|
||||
$re = (new CompanyLists())->list_three($companyId);
|
||||
|
||||
return $this->success('成功', $re);
|
||||
}
|
||||
|
||||
|
||||
public function depositRechargeTransferVoucherDetail()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
$companyDepositVoucher = CompanyDepositVoucher::where(['id' => $param['id']])->findOrEmpty()->toArray();
|
||||
if (empty($companyDepositVoucher)) {
|
||||
return $this->fail('数据不存在');
|
||||
}
|
||||
$contract = Contract::where(['party_b'=>$companyDepositVoucher['company_id']])->with(['partyA', 'partyB'])->findOrEmpty()->toArray();
|
||||
return $this->success('成功', array_merge($companyDepositVoucher, $contract));
|
||||
}
|
||||
}
|
||||
|
@ -4,17 +4,9 @@ namespace app\adminapi\controller\approve;
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\approve\ApproveLists;
|
||||
use app\common\enum\user\AccountLogEnum;
|
||||
use app\common\logic\AccountLogLogic;
|
||||
use app\common\logic\task\TaskLogic;
|
||||
use app\common\model\Approve;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\company\CompanyAccountLog;
|
||||
use app\common\model\task\Task;
|
||||
use app\common\model\task_scheduling_plan\TaskSchedulingPlan;
|
||||
use app\common\model\task_template\TaskTemplate;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\user\UserAccountLog;
|
||||
use think\facade\Db;
|
||||
|
||||
class ApproveController extends BaseAdminController
|
||||
@ -24,24 +16,14 @@ class ApproveController extends BaseAdminController
|
||||
return $this->dataLists(new ApproveLists());
|
||||
}
|
||||
|
||||
public function lists2()
|
||||
{
|
||||
return $this->success('成功',(new ApproveLists())->lists2());
|
||||
}
|
||||
|
||||
public function lists3()
|
||||
{
|
||||
return $this->success('成功',(new ApproveLists())->lists3());
|
||||
}
|
||||
public function audit()
|
||||
{
|
||||
try {
|
||||
$params = $this->request->param(); // id check_status remark amount
|
||||
$params = $this->request->param(); // id check_status remark
|
||||
$approve = Approve::find($params['id']);
|
||||
if (!$approve) {
|
||||
$this->fail('数据不存在');
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
// 拒绝通过 要让用户今天可以继续做任务
|
||||
if ($params['check_status'] == 3) {
|
||||
@ -49,111 +31,23 @@ class ApproveController extends BaseAdminController
|
||||
}
|
||||
// 修改任务完成状态
|
||||
if ($params['check_status'] == 2) {
|
||||
if ($approve->type == Approve::APPROVE_TYPE_7) {
|
||||
$taskTemplate = TaskTemplate::where(['id'=>$approve->business_id])->find();
|
||||
// 提前完成
|
||||
if ($taskTemplate['day_count'] < $taskTemplate['stage_day_one']) {
|
||||
if (bccomp($params['amount'], 300000, 2) == -1) {
|
||||
return $this->fail('该任务提前完成条件:销售总额必须达到30万元及以上');
|
||||
} else {
|
||||
// 提前完成标识
|
||||
$extend = $taskTemplate['extend'];
|
||||
$extend['early_finish'] = 1;
|
||||
$taskTemplate->extend = json_encode($extend);
|
||||
$taskTemplate->save();
|
||||
$this->pass($approve, $params);
|
||||
}
|
||||
} else {
|
||||
$this->pass($approve, $params);
|
||||
}
|
||||
} else {
|
||||
$this->pass($approve, $params);
|
||||
}
|
||||
|
||||
$this->pass($approve);
|
||||
}
|
||||
Db::commit();
|
||||
return $this->success('审核成功');
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
return $this->fail($e->getFile().$e->getLine().$e->getMessage());
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
// 通过
|
||||
private function pass($approve, $params=[])
|
||||
private function pass($approve)
|
||||
{
|
||||
Db::startTrans();
|
||||
$approve->check_status = 2;
|
||||
$approve->update_time = time();
|
||||
$approve->save();
|
||||
// 任务
|
||||
$task = Task::find($approve['task_id']);
|
||||
if ($task['status'] == 2) {
|
||||
$task->status = 3;
|
||||
$task->save();
|
||||
}
|
||||
Db::commit();
|
||||
|
||||
// 镇合伙人公司任务-数字农贸宣传业务、加工业务的建设和招商工作任务 结算
|
||||
if ($approve->type == Approve::APPROVE_TYPE_4) {
|
||||
$taskSchedulePlan = TaskSchedulingPlan::where('la_task_scheduling_plan.id', $task['scheduling_plan_id'])
|
||||
->where('is_pay',0)
|
||||
->with(['template_info'])
|
||||
->withJoin(['scheduling'], 'left')
|
||||
->where('scheduling.company_type', 16)
|
||||
->find()
|
||||
->toArray();
|
||||
TaskLogic::dealTaskMarketingDirector10($taskSchedulePlan, $approve);
|
||||
}
|
||||
|
||||
if ($approve->type == Approve::APPROVE_TYPE_5) {
|
||||
$taskSchedulePlan = TaskSchedulingPlan::where('la_task_scheduling_plan.id', $task['scheduling_plan_id'])
|
||||
->where('is_pay',0)
|
||||
->with(['template_info'])
|
||||
->withJoin(['scheduling'], 'left')
|
||||
->where('scheduling.company_type', 17)
|
||||
->find()
|
||||
->toArray();
|
||||
TaskLogic::dealVillageTask6($taskSchedulePlan);
|
||||
}
|
||||
|
||||
if ($approve->type == Approve::APPROVE_TYPE_6) {
|
||||
$taskSchedulePlan = TaskSchedulingPlan::where('la_task_scheduling_plan.id', $task['scheduling_plan_id'])
|
||||
->where('is_pay',0)
|
||||
->with(['template_info'])
|
||||
->withJoin(['scheduling'], 'left')
|
||||
->where('scheduling.company_type', 17)
|
||||
->find()
|
||||
->toArray();
|
||||
TaskLogic::dealVillageTask8($taskSchedulePlan);
|
||||
}
|
||||
if ($approve->type == Approve::APPROVE_TYPE_7) {
|
||||
// 需要手动输入销售总额
|
||||
$approve->amount = $params['amount'];
|
||||
$approve->save();
|
||||
}
|
||||
if ($approve->type == Approve::APPROVE_TYPE_8) {
|
||||
// 需要手动输入申请的政策补贴金额
|
||||
$approve->amount = $params['amount'];
|
||||
$approve->save();
|
||||
$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', 16)
|
||||
->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', 16)
|
||||
->find()
|
||||
->toArray();
|
||||
TaskLogic::masterTask8Settlement($taskSchedulePlan);
|
||||
}
|
||||
}
|
||||
|
||||
// 拒绝
|
||||
@ -180,248 +74,4 @@ class ApproveController extends BaseAdminController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 股金任务审批
|
||||
*/
|
||||
public function shareholderMoneyTaskAudit()
|
||||
{
|
||||
// try {
|
||||
$params = $this->request->param(); // id check_status remark
|
||||
$approve = Approve::find($params['id']);
|
||||
if (!empty($approve)) {
|
||||
$this->fail('数据不存在');
|
||||
}
|
||||
// 拒绝通过 要让用户今天可以继续做任务
|
||||
if ($params['check_status'] == 3) {
|
||||
$this->refuse1($params, $approve);
|
||||
}
|
||||
if ($params['check_status'] == 2) {
|
||||
$this->pass1($approve, $params);
|
||||
}
|
||||
// } catch (\Exception $e) {
|
||||
// return $this->fail($e->getMessage());
|
||||
// }
|
||||
}
|
||||
|
||||
private function refuse1($params, $approve)
|
||||
{
|
||||
$approve->check_status = $params['check_status'];
|
||||
$approve->remark = $params['remark'];
|
||||
$approve->update_time = time();
|
||||
$approve->save();
|
||||
}
|
||||
|
||||
private function pass1($approve, $params)
|
||||
{
|
||||
Db::startTrans();
|
||||
|
||||
// 审批
|
||||
$approve->check_status = 2;
|
||||
$approve->update_time = time();
|
||||
$approve->remark = $params['remark'];
|
||||
$approve->save();
|
||||
|
||||
// 任务
|
||||
$task = Task::find($approve['task_id']);
|
||||
if ($task['status'] == 2) {
|
||||
$task->status = 3;
|
||||
$task->save();
|
||||
}
|
||||
Db::commit();
|
||||
// 小组服务公司股金上交 小组服务团队-入股任务
|
||||
// if ($approve->type == Approve::APPROVE_TYPE_10) {
|
||||
// // 小组服务公司
|
||||
// $subordinateCompany = Company::where(['id'=>$approve->department_id])->find();
|
||||
// // 村公司
|
||||
// $parentCompany = Company::where(['village'=>$subordinateCompany['village'], 'company_type'=>17])->find();
|
||||
// }
|
||||
//
|
||||
// // 村联络员-督促小组服务团队入股任务
|
||||
// if ( $approve->type == Approve::APPROVE_TYPE_11) {
|
||||
// $parentCompany = Company::where(['id'=>$approve->department_id])->find();
|
||||
// }
|
||||
//
|
||||
// // 村管理公司股金上交 村联络员任务-入股甲方公司
|
||||
// if ($approve->type == Approve::APPROVE_TYPE_12) {
|
||||
// // 村公司
|
||||
// $subordinateCompany = Company::where(['id'=>$approve->department_id])->find();
|
||||
// // 镇农科公司 负责区域包含有村公司的street码
|
||||
// $parentCompany = Db::query("select * from la_company where company_type=:company_type and FIND_IN_SET(:street,responsible_area)", ['company_type' => 41,'street'=>$subordinateCompany['street']], true)[0];
|
||||
// }
|
||||
//
|
||||
// // 镇农科服务部长-督促小组服务团队入股村管理公司任务
|
||||
// if ($approve->type == Approve::APPROVE_TYPE_13) {
|
||||
// $parentCompany = Company::where(['id'=>$approve->department_id])->find(); //无法确定那个小组服务公司入股到哪个村管理公司
|
||||
// }
|
||||
//
|
||||
// // 镇农科负责人任务-促成村联络员入股甲方
|
||||
// if ($approve->type == Approve::APPROVE_TYPE_14) {
|
||||
// // 镇农科公司
|
||||
// $parentCompany = Company::where(['id'=>$approve->department_id])->find();
|
||||
// }
|
||||
//
|
||||
// $amount = $approve->amount; // 上交股金金额
|
||||
//
|
||||
// $subordinateCompany->shareholder_money = $amount;
|
||||
// $subordinateCompany->save();
|
||||
//
|
||||
// // 添加入股记录
|
||||
// $this->addConpanyAccountLog($parentCompany, $amount, $task);
|
||||
|
||||
|
||||
// 小组服务团队-入股任务结算
|
||||
if ($approve->type == Approve::APPROVE_TYPE_10) {
|
||||
$taskSchedulingPaln = TaskSchedulingPlan::where(['task_id' => $task->id])
|
||||
->withJoin(['scheduling'], 'left')
|
||||
->where('scheduling.company_type', 18)
|
||||
->where('is_pay',0)
|
||||
->with(['template_info'])
|
||||
->select()
|
||||
->toArray()[0];
|
||||
$taskInfo = $task->toArray();
|
||||
$company = Company::where(['id' => $taskInfo['company_id']])->find();
|
||||
$this->taskSettlement($taskInfo, $company, $taskSchedulingPaln);
|
||||
}
|
||||
// 村联络员-督促小组服务团队入股
|
||||
if ($approve->type == Approve::APPROVE_TYPE_11) {
|
||||
$taskSchedulingPaln = TaskSchedulingPlan::where(['task_id' => $task->id])
|
||||
->withJoin(['scheduling'], 'left')
|
||||
->where('scheduling.company_type', 17)
|
||||
->where('is_pay',0)
|
||||
->with(['template_info'])
|
||||
->select()
|
||||
->toArray()[0];
|
||||
TaskLogic::dealVillageTask4($taskSchedulingPaln, $approve);
|
||||
}
|
||||
// 村联络员-入股甲方公司
|
||||
if ($approve->type == Approve::APPROVE_TYPE_12) {
|
||||
$taskSchedulingPaln = TaskSchedulingPlan::where(['task_id' => $task->id])
|
||||
->withJoin(['scheduling'], 'left')
|
||||
->where('scheduling.company_type', 17)
|
||||
->where('is_pay',0)
|
||||
->with(['template_info'])
|
||||
->select()
|
||||
->toArray()[0];
|
||||
TaskLogic::dealVillageTask5($taskSchedulingPaln, $approve);
|
||||
}
|
||||
// 镇合伙人服务部长-督促小组服务团队入股村管理公司任务
|
||||
if ($approve->type == Approve::APPROVE_TYPE_13) {
|
||||
$taskSchedulingPaln = TaskSchedulingPlan::where(['task_id' => $task->id])
|
||||
->withJoin(['scheduling'], 'left')
|
||||
->where('scheduling.company_type', 16)
|
||||
->where('is_pay',0)
|
||||
->with(['template_info'])
|
||||
->select()
|
||||
->toArray()[0];
|
||||
TaskLogic::dealTownTask6($taskSchedulingPaln, $approve);
|
||||
}
|
||||
// 镇合伙人负责人-促成村联络员入股甲方
|
||||
if ($approve->type == Approve::APPROVE_TYPE_14) {
|
||||
$taskSchedulingPaln = TaskSchedulingPlan::where(['task_id' => $task->id])
|
||||
->withJoin(['scheduling'], 'left')
|
||||
->where('scheduling.company_type', 16)
|
||||
->where('is_pay',0)
|
||||
->with(['template_info'])
|
||||
->select()
|
||||
->toArray()[0];
|
||||
TaskLogic::masterTask6Settlement($taskSchedulingPaln, $approve);
|
||||
}
|
||||
return $this->success('成功');
|
||||
}
|
||||
|
||||
private function addConpanyAccountLog($parentCompany, $amount, $task)
|
||||
{
|
||||
// 接收股金公司股金变更 + 公司股金增加记录
|
||||
$addAmount = bcadd($parentCompany['shareholder_money'], $amount, 2);
|
||||
Company::where('id', $parentCompany['id'])->save(['shareholder_money'=>$addAmount]);
|
||||
|
||||
// 公司账户变动记录
|
||||
$company_log2 = [
|
||||
'sn' => generate_sn(UserAccountLog::class, 'sn', 20),
|
||||
'company_id' => $parentCompany['id'],
|
||||
'change_object' => CompanyAccountLog::SHAREHOLDER, // 变动对象 1余额 2股金
|
||||
'change_type' => CompanyAccountLog::TASK_INC_SHAREHOLDER_MONEY, //变动类型
|
||||
'action' => CompanyAccountLog::INC, //1-增加 2-减少
|
||||
'left_amount' => $addAmount, //变动后数量
|
||||
'change_amount' => $amount, //变动数量
|
||||
'extend' => json_encode(['task_id' => $task->id]),
|
||||
'status' => 1,
|
||||
];
|
||||
CompanyAccountLog::create($company_log2);
|
||||
}
|
||||
|
||||
public function taskSettlement($data, $company, $datas = [])
|
||||
{
|
||||
$proportion = 0;
|
||||
$remark = '来自任务【' . $datas['template_info']['title'] . '】,';
|
||||
//总金额除以2等于不可提现账号金额和收益
|
||||
$master_money = bcdiv($data['money'], 2, 2);
|
||||
//收益的百分之25为负责人的收益其余为成员的平分收益
|
||||
$master_money_user = bcdiv($master_money, 2, 2);
|
||||
|
||||
//成员数量
|
||||
$userAll = User::where('company_id', $data['company_id'])->where('admin_id', 0)->field('id,user_money')->select();
|
||||
$yser_all_count = count($userAll);
|
||||
$member_money_user = bcdiv($master_money_user, $yser_all_count, 2);
|
||||
|
||||
//负责人
|
||||
$arr = [$company['user_id'], AccountLogEnum::UM_INC_TASK, AccountLogEnum::INC, $master_money_user, $datas['sn'], $remark . '获得收益' . $master_money_user . '元', ['company_id' => $data['company_id'], 'proportion' => $proportion], $data['status']];
|
||||
$this->master($arr);
|
||||
$arr_two = [$company['user_id'], AccountLogEnum::UM_INC_TASKUSER, AccountLogEnum::INC, $master_money_user, $datas['sn'], $remark. '获得账户余额' . $master_money_user . '元', ['company_id' => $data['company_id'], 'proportion' => $proportion], $data['status']];
|
||||
$this->Account($arr_two);
|
||||
|
||||
//成员
|
||||
foreach ($userAll as $value) {
|
||||
$arr = [$value['id'], AccountLogEnum::UM_INC_TASK, AccountLogEnum::INC, $member_money_user, $datas['sn'], $remark . '获得收益' . $member_money_user . '元', ['company_id' => $data['company_id'], 'proportion' => $proportion], $data['status']];
|
||||
$this->member($arr);
|
||||
$arr_two = [$value['id'], AccountLogEnum::UM_INC_TASKUSER, AccountLogEnum::INC, $member_money_user, $datas['sn'], $remark. '获得账户余额' . $member_money_user . '元', ['company_id' => $data['company_id'], 'proportion' => $proportion], $data['status']];
|
||||
$this->Account($arr_two);
|
||||
}
|
||||
|
||||
//公司
|
||||
$deposit_count = bcadd($company['deposit'], $master_money, 2);
|
||||
$this->AccountLog($data['company_id'], $deposit_count, $master_money);
|
||||
|
||||
$company_money_count = bcadd($company['company_money'], $master_money, 2);
|
||||
$this->AccountLog($data['company_id'], $company_money_count, $master_money);
|
||||
Company::where('id', $data['company_id'])->update(['deposit' => Db::raw('deposit+' . $master_money), 'company_money' => Db::raw('company_money+' . $master_money)]);
|
||||
}
|
||||
|
||||
public function AccountLog($companyId, $left_amount, $changeAmount, $change_object = 1, $change_type = 1, $action = 1)
|
||||
{
|
||||
$company_log = [
|
||||
'sn' => generate_sn(UserAccountLog::class, 'sn', 20),
|
||||
'company_id' => $companyId,
|
||||
'change_object' => $change_object, //变动对象
|
||||
'change_type' => $change_type, //变动类型
|
||||
'action' => $action, //1-增加 2-减少
|
||||
'left_amount' => $left_amount, //变动后数量
|
||||
'change_amount' => $changeAmount, //变动数量
|
||||
'status' => 1,
|
||||
];
|
||||
CompanyAccountLog::create($company_log);
|
||||
}
|
||||
|
||||
/**负责人的分润
|
||||
* @param $data
|
||||
*/
|
||||
private function master($data)
|
||||
{
|
||||
User::where('id', $data[0])->update(['deposit'=>Db::raw('deposit+' . $data[3]),'user_money'=>Db::raw('user_money+' . $data[3])]);
|
||||
return AccountLogLogic::add($data[0], $data[1], $data[2], $data[3], $data[4], $data[5], $data[6], $data[7]);
|
||||
}
|
||||
|
||||
/**成员分润
|
||||
* @param $data
|
||||
*/
|
||||
private function member($data)
|
||||
{
|
||||
User::where('id', $data[0])->update(['deposit'=>Db::raw('deposit+' . $data[3]),'user_money'=>Db::raw('user_money+' . $data[3])]);
|
||||
return AccountLogLogic::add($data[0], $data[1], $data[2], $data[3], $data[4], $data[5], $data[6], $data[7]);
|
||||
}
|
||||
|
||||
private function Account($data)
|
||||
{
|
||||
return AccountLogLogic::add($data[0], $data[1], $data[2], $data[3], $data[4], $data[5], $data[6], $data[7]);
|
||||
}
|
||||
}
|
@ -6,7 +6,6 @@ use app\adminapi\controller\BaseAdminController;
|
||||
use app\api\controller\JunziqianController;
|
||||
use app\common\enum\notice\NoticeEnum;
|
||||
use app\common\model\contract\VehicleContract;
|
||||
use app\common\model\vehicle\VehicleRent;
|
||||
|
||||
class VehicleContractController extends BaseAdminController
|
||||
{
|
||||
@ -36,26 +35,30 @@ class VehicleContractController extends BaseAdminController
|
||||
}
|
||||
//更新本地
|
||||
try {
|
||||
$data = [
|
||||
'id' => $vehicle_contract['contract_logistic_id'],
|
||||
'file' => $params['file'],
|
||||
'status' => 1,
|
||||
'update_time' => time()
|
||||
];
|
||||
//判断合同类型
|
||||
if($vehicle_contract['type'] == 0 && $vehicle_contract['contract_logistic_id'] != 0){
|
||||
$data['cars_info'] = $params['cars'];
|
||||
}
|
||||
if(!empty($vehicle_contract['contract_logistic_id'])){
|
||||
//更新物流系统
|
||||
curl_post(env('project.logistic_domain').'/api/contractUpdate',[],$data);
|
||||
curl_post(env('project.logistic_domain').'/api/contractUpdate',[],[
|
||||
'id' => $vehicle_contract['contract_logistic_id'],
|
||||
'file' => $params['file'],
|
||||
'status' => 1,
|
||||
'cars_info' => $params['cars']
|
||||
]);
|
||||
VehicleContract::where('id', $params['id'])->update(['file' => $params['file'],'cars_info' => $params['cars'],'status'=>1]);
|
||||
}else{
|
||||
VehicleContract::where('id', $params['id'])->update(['file' => $params['file'],'status'=>1]);
|
||||
}
|
||||
unset($data['id']);
|
||||
VehicleContract::where('id', $params['id'])->update($data);
|
||||
|
||||
}catch (\Exception $e){
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
//发送短信
|
||||
$sms = [
|
||||
'mobile' => $vehicle_contract['company_a_phone'],
|
||||
'name' => $vehicle_contract['company_user'],
|
||||
'scene' => 'WQTZ'
|
||||
];
|
||||
$this->rentNoticeSms($sms);
|
||||
return $this->success('上传成功', [], 1, 1);
|
||||
}
|
||||
|
||||
@ -145,7 +148,7 @@ class VehicleContractController extends BaseAdminController
|
||||
if($contract->isEmpty()){
|
||||
return $this->fail('数据不存在');
|
||||
}
|
||||
if(!($contract['status'] == 1 || ($contract['status'] == 2 && $contract['signing_timer'] != 2))){
|
||||
if($contract['status'] != 1){
|
||||
return $this->fail('合同状态错误');
|
||||
}
|
||||
$signData = [
|
||||
@ -156,42 +159,19 @@ class VehicleContractController extends BaseAdminController
|
||||
],
|
||||
'url' => $contract['file']
|
||||
];
|
||||
$notify_url = '';
|
||||
if($contract['type'] == 0){
|
||||
$smsTitle = '《租赁合同》';
|
||||
if(empty($contract['contract_logistic_id'])){
|
||||
$notify_url = env('project.website_domain').'/api/index/systemCarRent';
|
||||
}else{
|
||||
$notify_url = env('project.website_domain').'/api/index/townCarRent';
|
||||
}
|
||||
}elseif($contract['type'] == 1){
|
||||
$smsTitle = '《自有车辆上传合同》';
|
||||
$notify_url = env('project.website_domain').'/api/index/selfCarRent';
|
||||
}elseif($contract['type'] == 2){
|
||||
$smsTitle = '《解约合同》';
|
||||
$notify_url = env('project.website_domain').'/api/index/cancelRent';
|
||||
}elseif($contract['type'] == 3){
|
||||
$smsTitle = '《购买合同》';
|
||||
$notify_url = env('project.website_domain').'/api/index/buyCar';
|
||||
}
|
||||
$signRes = app(JunziqianController::class)->VehicleRentSigning($signData, $params['id'],$notify_url);
|
||||
$signRes = app(JunziqianController::class)->VehicleRentSigning($signData, $params['id'],env('project.website_domain').'/api/index/townCarRent');
|
||||
if ($signRes->success) {
|
||||
$contract->save([
|
||||
'id' => $contract['id'],
|
||||
'contract_no' => $signRes->data,
|
||||
'status' => 2,
|
||||
'signing_timer' => 0
|
||||
'status' => 2
|
||||
]);
|
||||
if(!empty($contract['contract_logistic_id'])){
|
||||
curl_post(env('project.logistic_domain').'/api/contractUpdate',[],[
|
||||
'id' => $contract['contract_logistic_id'],
|
||||
'contract_no' => $signRes->data,
|
||||
'status' => 2,
|
||||
'signing_timer' => 0,
|
||||
'update_time' => time()
|
||||
]);
|
||||
}
|
||||
$this->sendSms($params['id'],$smsTitle);
|
||||
curl_post(env('project.logistic_domain').'/api/contractUpdate',[],[
|
||||
'id' => $contract['contract_logistic_id'],
|
||||
'contract_no' => $signRes->data,
|
||||
'status' => 2,
|
||||
]);
|
||||
$this->sendSms($params['id'],'《租赁合同》');
|
||||
return $this->success('合同发送成功');
|
||||
} else {
|
||||
return $this->fail($signRes->msg);
|
||||
@ -269,49 +249,14 @@ class VehicleContractController extends BaseAdminController
|
||||
if($data->isEmpty()){
|
||||
return $this->fail('未查找到数据');
|
||||
}
|
||||
$cars = json_decode($data['cars_info'],true);
|
||||
//判断合同类型
|
||||
if(!empty($data['contract_logistic_id']) && $data['type'] == 0){
|
||||
if($data['type'] == 0 && $data['contract_logistic_id'] != 0){
|
||||
//获取平台车辆
|
||||
$carList = curl_get(env('project.logistic_domain').'/api/getAvailableVehicles');
|
||||
$data['car_list'] = $carList&&$carList['code']==1 ? $carList['data'] : [];
|
||||
}else{
|
||||
$data['cars_info'] = json_decode($data['cars_info'],true);
|
||||
}
|
||||
if(!empty($cars)){
|
||||
foreach ($cars as $k=>$v) {
|
||||
if($data['type'] == 0){
|
||||
$cars[$k]['type'] = 0;
|
||||
}
|
||||
if($data['type'] == 1){
|
||||
if(empty($v['id'])){
|
||||
$cars[$k]['type'] = 1;
|
||||
}else{
|
||||
$rentInfo = VehicleRent::where('car_id',$v['id'])->findOrEmpty();
|
||||
if($rentInfo->isEmpty()){
|
||||
$cars[$k]['type'] = 0;
|
||||
}else{
|
||||
$cars[$k]['type'] = $rentInfo['type'];
|
||||
}
|
||||
}
|
||||
}
|
||||
if($data['type'] == 2){
|
||||
$rentInfo = VehicleRent::where('car_id',$v['id'])->findOrEmpty();
|
||||
if($rentInfo->isEmpty()){
|
||||
$cars[$k]['type'] = 0;
|
||||
}else{
|
||||
$cars[$k]['type'] = $rentInfo['type'];
|
||||
}
|
||||
}
|
||||
if($data['type'] == 3){
|
||||
$rentInfo = VehicleRent::where('car_id',$v['id'])->findOrEmpty();
|
||||
if($rentInfo->isEmpty()){
|
||||
$cars[$k]['type'] = 2;
|
||||
}else{
|
||||
$cars[$k]['type'] = $rentInfo['type'];
|
||||
}
|
||||
}
|
||||
$cars[$k]['rent_time'] = $data['update_time'];
|
||||
}
|
||||
}
|
||||
$data['cars_info'] = $cars;
|
||||
return $this->success('success',$data->toArray());
|
||||
}
|
||||
}
|
@ -1,131 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\adminapi\controller\create_task_template;
|
||||
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\create_task_template\CreateTaskTemplateLists;
|
||||
use app\adminapi\logic\create_task_template\CreateTaskTemplateLogic;
|
||||
use app\adminapi\validate\create_task_template\CreateTaskTemplateValidate;
|
||||
use app\common\model\dict\DictData;
|
||||
|
||||
|
||||
/**
|
||||
* CreateTaskTemplate控制器
|
||||
* Class CreateTaskTemplateController
|
||||
* @package app\adminapi\controller\create_task_template
|
||||
*/
|
||||
class CreateTaskTemplateController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/12/18 14:50
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new CreateTaskTemplateLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/12/18 14:50
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new CreateTaskTemplateValidate())->post()->goCheck('add');
|
||||
$params['admin_id'] = $this->adminId;
|
||||
$result = CreateTaskTemplateLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(CreateTaskTemplateLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/12/18 14:50
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new CreateTaskTemplateValidate())->post()->goCheck('edit');
|
||||
$result = CreateTaskTemplateLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(CreateTaskTemplateLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/12/18 14:50
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new CreateTaskTemplateValidate())->post()->goCheck('delete');
|
||||
CreateTaskTemplateLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/12/18 14:50
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new CreateTaskTemplateValidate())->goCheck('detail');
|
||||
$result = CreateTaskTemplateLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
public function taskTypeList()
|
||||
{
|
||||
$taskRoleId = $this->request->param('task_role_id');
|
||||
$result = CreateTaskTemplateLogic::taskTypeList($taskRoleId);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
public function selectList()
|
||||
{
|
||||
|
||||
$role = $this->request->param('task_role_id');
|
||||
$list = CreateTaskTemplateLogic::getList($role);
|
||||
return $this->data($list);
|
||||
}
|
||||
|
||||
public function taskTypeInfo()
|
||||
{
|
||||
$type = ['town_task_type_master', 'town_task_type_marketing_director', 'town_task_type', 'village_task_type', 'task_type'];
|
||||
$lists = DictData::whereIn('type_value', $type)->column('name', 'id');
|
||||
return $this->data($lists);
|
||||
}
|
||||
|
||||
}
|
@ -17,7 +17,6 @@ namespace app\adminapi\controller\finance;
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\finance\AccountLogLists;
|
||||
use app\common\enum\user\AccountLogEnum;
|
||||
use app\common\model\user\User;
|
||||
|
||||
/***
|
||||
* 账户流水控制器
|
||||
@ -51,12 +50,5 @@ class AccountLogController extends BaseAdminController
|
||||
return $this->data(AccountLogEnum::getUserMoneyChangeTypeDesc());
|
||||
}
|
||||
|
||||
public function getCompanyUserList()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
$companyId = $param['company_id'];
|
||||
$userList = User::where(['company_id' => $companyId])->field('id,nickname,avatar,sn,mobile,group_id,deposit,income,user_money')->select()->toArray();
|
||||
return $this->success('成功', $userList);
|
||||
}
|
||||
|
||||
}
|
@ -95,22 +95,5 @@ class DictDataController extends BaseAdminController
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
public function getContractPartyACompanyTypeList()
|
||||
{
|
||||
$result = DictDataLogic::getContractPartyACompanyTypeList();
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
public function getTaskApproveTypeList()
|
||||
{
|
||||
$result = DictDataLogic::getTaskApproveTypeList();
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
public function getShareholderMoneyTaskApproveTypeList()
|
||||
{
|
||||
$result = DictDataLogic::getShareholderMoneyTaskApproveTypeList();
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
}
|
@ -116,19 +116,5 @@ class TaskSchedulingPlanController extends BaseAdminController
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
public function getDayTaskList()
|
||||
{
|
||||
$companyId = $this->request->param('company_id', 0);
|
||||
$date = $this->request->param('date',);
|
||||
$lists = TaskSchedulingPlan::where(['company_id' => $companyId])
|
||||
->where('start_time', strtotime($date))
|
||||
->with(['template','templateInfo', 'task'])
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
return $this->success('', compact('lists'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -18,11 +18,9 @@ namespace app\adminapi\controller\task_template;
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\task_template\TaskTemplateLists;
|
||||
use app\common\logic\ShopRequestLogic;
|
||||
use app\common\logic\task_template\TaskTemplateLogic;
|
||||
use app\adminapi\validate\task_template\TaskTemplateValidate;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\task\Task;
|
||||
|
||||
|
||||
/**
|
||||
@ -57,11 +55,9 @@ class TaskTemplateController extends BaseAdminController
|
||||
$params = (new TaskTemplateValidate())->post()->goCheck('add');
|
||||
$params['admin_id'] = $this->adminId;
|
||||
$company = Company::find($params['company_id']);
|
||||
if ($company->company_type == 16) {
|
||||
// 创建 镇合伙人公司 任务模板
|
||||
if ($company->company_type == 41) {
|
||||
// 创建 镇管理公司 任务模板
|
||||
$result = TaskTemplateLogic::addTownTaskTemplate($params);
|
||||
} else if ($company->company_type == 17) {
|
||||
$result = TaskTemplateLogic::addVillageTaskTemplate($params);
|
||||
} else {
|
||||
$result = TaskTemplateLogic::add($params);
|
||||
}
|
||||
@ -103,10 +99,6 @@ class TaskTemplateController extends BaseAdminController
|
||||
public function delete()
|
||||
{
|
||||
$params = (new TaskTemplateValidate())->post()->goCheck('delete');
|
||||
$task = Task::where(['template_id' =>$params['id']])->whereDay('start_time', 'today')->find();
|
||||
if(!empty($task)) {
|
||||
return $this->fail('该任务今天已在进行中,无法删除');
|
||||
}
|
||||
TaskTemplateLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
@ -125,44 +117,5 @@ class TaskTemplateController extends BaseAdminController
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
public function getProductList()
|
||||
{
|
||||
$param = $this->request->param(); // page keyword
|
||||
$p['page'] = $param['page_no'] ?? 1;
|
||||
$p['keyword'] = $param['keyword'] ??'';
|
||||
$result = ShopRequestLogic::getProductList($p);;
|
||||
// $result['data']['count'] = 1000;
|
||||
$data = [
|
||||
'lists' => $result['data']['data'],
|
||||
'count' => $result['data']['count'],
|
||||
'page_no' => $result['data']['page'],
|
||||
'page_size' => 10,
|
||||
];
|
||||
return $this->data($data);
|
||||
}
|
||||
|
||||
public function checkRole()
|
||||
{
|
||||
$params = $this->request->param();
|
||||
if ($params['task_role'] == 1) {
|
||||
$serviceManagerUser = (new User())->searchMaster($params['company_id']);
|
||||
if (empty($serviceManagerUser)) {
|
||||
return $this->fail('公司还没有负责人,无法指派任务');
|
||||
}
|
||||
}
|
||||
if ($params['task_role'] == 2) {
|
||||
$serviceManagerUser = (new User())->searchMarketingManager($params['company_id']);
|
||||
if (empty($serviceManagerUser)) {
|
||||
return $this->fail('公司还没有市场部长,无法指派任务');
|
||||
}
|
||||
}
|
||||
|
||||
if ($params['task_role'] == 3) {
|
||||
$serviceManagerUser = (new User())->searchServiceManager($params['company_id']);
|
||||
if (empty($serviceManagerUser)) {
|
||||
return $this->fail('公司还没有服务部长,无法指派任务');
|
||||
}
|
||||
}
|
||||
return $this->success('成功');
|
||||
}
|
||||
}
|
@ -18,7 +18,6 @@ use app\adminapi\lists\user\UserLists;
|
||||
use app\adminapi\logic\user\UserLogic;
|
||||
use app\adminapi\validate\user\AdjustUserMoney;
|
||||
use app\adminapi\validate\user\UserValidate;
|
||||
use app\common\logic\CompanyLogic;
|
||||
use think\facade\Db;
|
||||
use think\facade\Request;
|
||||
use app\common\logic\contract\ContractLogic;
|
||||
@ -56,15 +55,6 @@ class UserController extends BaseAdminController
|
||||
return $this->success('', $detail);
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
$params = $this->request->param();
|
||||
$re = UserLogic::addUser($params);
|
||||
if ($re) {
|
||||
return $this->success('添加成功');
|
||||
}
|
||||
return $this->fail(UserLogic::getError());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 编辑用户信息
|
||||
@ -114,16 +104,11 @@ class UserController extends BaseAdminController
|
||||
public function Draftingcontracts()
|
||||
{
|
||||
$params = Request::param();
|
||||
$result = ContractLogic::Draftingcontracts($params, 2);
|
||||
$result = ContractLogic::Draftingcontracts($params);
|
||||
if ($result === true) {
|
||||
return $this->success('发送合同成功', [], 1, 1);
|
||||
} else {
|
||||
return $this->fail(ContractLogic::getError());
|
||||
}
|
||||
}
|
||||
|
||||
public function getCompanyList()
|
||||
{
|
||||
return $this->data(CompanyLogic::getList());
|
||||
}
|
||||
}
|
@ -104,10 +104,5 @@ class UserRoleController extends BaseAdminController
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
public function getList()
|
||||
{
|
||||
$list = UserRoleLogic::getList();
|
||||
return $this->data($list);
|
||||
}
|
||||
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\lists;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\CompanyComplaintFeedback;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
/**
|
||||
* CompanyComplaintFeedback列表
|
||||
* Class CompanyComplaintFeedbackLists
|
||||
* @package app\adminapi\lists
|
||||
*/
|
||||
class CompanyComplaintFeedbackLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2023/09/23 15:14
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['company_id', 'content'],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2023/09/23 15:14
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return CompanyComplaintFeedback::where($this->searchWhere)
|
||||
->field(['id', 'company_id', 'content'])
|
||||
->append(['company_name'], true)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->withAttr('company_name', function ($value, $data) {
|
||||
$company = Company::where('id', $data['company_id'])->find();
|
||||
return $company['company_name'];
|
||||
})
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2023/09/23 15:14
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return CompanyComplaintFeedback::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
@ -19,7 +19,6 @@ use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\Company;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\CompanyDepositVoucher;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
@ -89,7 +88,7 @@ class CompanyLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
}
|
||||
return Company::where($this->searchWhere)
|
||||
->where($where)
|
||||
->field(['is_authentication','id', 'id contract', 'company_name', 'organization_code', 'city', 'area', 'street', 'company_type', 'master_name', 'master_position', 'master_phone', 'master_email', 'area_manager', 'is_contract', 'deposit', 'company_money', 'shareholder_money', 'deposit_time', 'status', 'face_create_status'])
|
||||
->field(['is_authentication','id', 'id contract', 'company_name', 'organization_code', 'city', 'area', 'street', 'company_type', 'master_name', 'master_position', 'master_phone', 'master_email', 'area_manager', 'is_contract', 'deposit', 'deposit_time', 'status', 'face_create_status'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->append(['notes'], true)
|
||||
@ -127,23 +126,13 @@ class CompanyLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
};
|
||||
$count=Company::where($where)->count();
|
||||
$list= Company::where($where)
|
||||
->field(['is_authentication','id', 'company_name', 'organization_code', 'province', 'province province_name','city', 'city city_name', 'area','area area_name', 'street','street street_name', 'village','village village_name', 'brigade', 'brigade brigade_name', 'company_type', 'master_name', 'master_position', 'master_phone', 'master_email', 'other_contacts', 'area_manager', 'is_contract', 'deposit', 'deposit_time', 'qualification', 'status'])
|
||||
->field(['is_authentication','id', 'company_name', 'organization_code', 'city', 'area','area area_name', 'street','street street_name', 'company_type', 'master_name', 'master_position', 'master_phone', 'master_email', 'other_contacts', 'area_manager', 'is_contract', 'deposit', 'deposit_time', 'qualification', 'status'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
return ['list'=>$list,'page_no'=>$this->limitOffset+1,'page_size'=>$this->limitLength,'count'=>$count];
|
||||
}
|
||||
public function list_three($companyId): array
|
||||
{
|
||||
$list = CompanyDepositVoucher::where(['company_id' => $companyId])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
$count=CompanyDepositVoucher::where(['company_id' => $companyId])->count();
|
||||
return ['list'=>$list,'page_no'=>$this->limitOffset+1,'page_size'=>$this->limitLength,'count'=>$count];
|
||||
}
|
||||
/**
|
||||
* @notes 获取数量
|
||||
* @return int
|
||||
|
@ -7,7 +7,6 @@ use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\Approve;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\task\Task;
|
||||
use think\facade\Db;
|
||||
|
||||
class ApproveLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
@ -20,10 +19,7 @@ class ApproveLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'in' => ['type'],
|
||||
'='=>['check_status']
|
||||
];
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
@ -48,92 +44,11 @@ class ApproveLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
return Admin::where(['id' => $data['check_admin_ids']])->value('name');
|
||||
})
|
||||
->withAttr('company_name',function($value,$data){
|
||||
$task = Task::where('id', $data['task_id'])->find();
|
||||
return Company::where(['id' => $task['company_id']])->value('company_name');
|
||||
return Company::where(['admin_id' => $data['check_admin_ids']])->value('company_name');
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
public function lists2(): array
|
||||
{
|
||||
$list = Approve::where($this->searchWhere)
|
||||
->where($this->queryWhere())
|
||||
->with('task')
|
||||
->field('*')
|
||||
->append(['area_manager', 'company_name'], true)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->withAttr('area_manager',function($value,$data){
|
||||
$company = Company::where(['admin_id'=>$data['check_admin_ids']])->find();
|
||||
return Admin::where(['id' => $company['area_manager']])->value('name');
|
||||
})
|
||||
->withAttr('company_name',function($value,$data){
|
||||
$company = Company::where(['admin_id'=>$data['check_admin_ids']])->find();
|
||||
return $company['company_name'];
|
||||
})
|
||||
->toArray();
|
||||
$count = Approve::where($this->searchWhere)
|
||||
->where($this->queryWhere())->count();
|
||||
|
||||
return [
|
||||
'lists' => $list,
|
||||
'count' => $count,
|
||||
'page_no' => $this->pageNo,
|
||||
'page_size' => $this->pageSize,
|
||||
];
|
||||
}
|
||||
|
||||
public function lists3(): array
|
||||
{
|
||||
$list = Approve::where($this->searchWhere)
|
||||
->where($this->queryWhere())
|
||||
->with('task')
|
||||
->field('*')
|
||||
->append(['area_manager', 'company_a_name', 'company_b_name'], true)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->withAttr('area_manager',function($value,$data){
|
||||
return Admin::where(['id' => $data['check_admin_ids']])->value('name');
|
||||
})
|
||||
->withAttr('company_b_name',function($value,$data){
|
||||
$task = Task::where('id', $data['task_id'])->find();
|
||||
if ($data['type'] == Approve::APPROVE_TYPE_11) {
|
||||
return '下属小组服务公司';
|
||||
}
|
||||
if ($data['type'] == Approve::APPROVE_TYPE_13) {
|
||||
$townCompanyName = Company::where(['id' => $task['company_id']])->value('company_name');
|
||||
return $townCompanyName.'(镇农科公司)下属小组服务公司';
|
||||
}
|
||||
if ($data['type'] == Approve::APPROVE_TYPE_14) {
|
||||
return '下属村管理公司';
|
||||
}
|
||||
return Company::where(['id' => $task['company_id']])->value('company_name');
|
||||
})
|
||||
->withAttr('company_a_name',function($value,$data){
|
||||
$task = Task::where('id', $data['task_id'])->find();
|
||||
$companyB = Company::where(['id' => $task['company_id']])->find();
|
||||
if ($data['type'] == Approve::APPROVE_TYPE_12 || $data['type'] == Approve::APPROVE_TYPE_14) {
|
||||
return Db::query("select * from la_company where company_type=:company_type and FIND_IN_SET(:street,responsible_area)", ['company_type' => 41,'street'=>$companyB['street']], true)[0]['company_name'];
|
||||
}
|
||||
if ($data['type'] == Approve::APPROVE_TYPE_13) {
|
||||
$townCompanyName = Company::where(['id' => $task['company_id']])->value('company_name');
|
||||
return $townCompanyName.'(镇农科公司)下属村管理公司';
|
||||
}
|
||||
return Company::where(['village' => $companyB['village'], 'company_type'=>17])->value('company_name');
|
||||
})
|
||||
->toArray();
|
||||
$count = Approve::where($this->searchWhere)
|
||||
->where($this->queryWhere())->count();
|
||||
|
||||
return [
|
||||
'lists' => $list,
|
||||
'count' => $count,
|
||||
'page_no' => $this->pageNo,
|
||||
'page_size' => $this->pageSize,
|
||||
];
|
||||
}
|
||||
|
||||
public function count(): int
|
||||
{
|
||||
|
@ -1,82 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\lists\create_task_template;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\create_task_template\CreateTaskTemplate;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
/**
|
||||
* CreateTaskTemplate列表
|
||||
* Class CreateTaskTemplateLists
|
||||
* @package app\adminapi\listscreate_task_template
|
||||
*/
|
||||
class CreateTaskTemplateLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2023/12/18 14:50
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['title', 'task_role_id', 'type'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2023/12/18 14:50
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return CreateTaskTemplate::where($this->searchWhere)
|
||||
->field(['id', 'title', 'admin_id', 'task_role_id', 'type', 'stage_day_one', 'money', 'proportion_one', 'stage_day_two', 'proportion_two', 'money_two', 'stage_day_three', 'new_money_three', 'money_longtime', 'types', 'recharge', 'content'])
|
||||
->append(['admin_name'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->withAttr('admin_name', function ($value, $data) {
|
||||
return Admin::where('id', $data['admin_id'])->value('name');
|
||||
})
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2023/12/18 14:50
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return CreateTaskTemplate::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
@ -97,6 +97,7 @@ class RefundRecordLists extends BaseAdminDataLists implements ListsSearchInterfa
|
||||
foreach ($lists as &$item) {
|
||||
$item['avatar'] = FileService::getFileUrl($item['avatar']);
|
||||
}
|
||||
|
||||
return $lists;
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,6 @@ namespace app\adminapi\lists\informationg;
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\informationg\UserInformationg;
|
||||
use app\common\model\informationg\UserInformationgDemand;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
@ -62,23 +61,6 @@ class UserInformationgLists extends BaseAdminDataLists implements ListsSearchInt
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->select()
|
||||
->toArray();
|
||||
$informationIdArray = [];
|
||||
foreach($lists as $k=>$v) {
|
||||
$informationIdArray[] = $v['id'];
|
||||
}
|
||||
$data = UserInformationgDemand::whereIn('information_id', $informationIdArray)->order('id', 'desc')->select();
|
||||
$aianalyseArray = [];
|
||||
foreach($data as $kk=>$vv) {
|
||||
if (!empty($vv['ai_aianalyse'])) {
|
||||
$aianalyseArray[$vv['information_id']][] = $vv['id'];
|
||||
}
|
||||
}
|
||||
foreach($lists as $k=>$v) {
|
||||
$lists[$k]['aianalyse_status'] = 0;
|
||||
if (!empty($aianalyseArray[$v['id']])) {
|
||||
$lists[$k]['aianalyse_status'] = 1;
|
||||
}
|
||||
}
|
||||
return $lists;
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,6 @@ use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\task_template\TaskTemplate;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\task_scheduling\TaskScheduling;
|
||||
use app\common\model\user\User;
|
||||
|
||||
/**
|
||||
* 任务模板列表
|
||||
@ -60,16 +59,6 @@ class TaskTemplateLists extends BaseAdminDataLists implements ListsSearchInterfa
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->append(['task_admin_name'])
|
||||
->withAttr("task_admin_name", function ($value,$data) {
|
||||
if ($data['type'] == 35) {
|
||||
$extend = json_decode($data['extend'], true);
|
||||
$userName = User::where('id', $extend['shareholder']['user_id'])->value('nickname');
|
||||
return $userName;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,6 @@ namespace app\adminapi\lists\user;
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\enum\user\UserTerminalEnum;
|
||||
use app\common\lists\ListsExcelInterface;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\contract\Contract;
|
||||
use app\common\model\user\User;
|
||||
use think\facade\Db;
|
||||
@ -38,11 +37,7 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
$allowSearch = ['keyword', 'channel', 'create_time_start', 'create_time_end', 'company_id'];
|
||||
if (empty($this->params['company_id'])) {
|
||||
unset($allowSearch['company_id']);
|
||||
unset($this->params['company_id']);
|
||||
}
|
||||
$allowSearch = ['keyword', 'channel', 'create_time_start', 'create_time_end'];
|
||||
return array_intersect(array_keys($this->params), $allowSearch);
|
||||
}
|
||||
|
||||
@ -72,9 +67,7 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$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::withSearch($this->setSearch(), $this->params)
|
||||
->with(['company'])
|
||||
->where($where)
|
||||
|
@ -1,106 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\logic;
|
||||
|
||||
|
||||
use app\common\model\CompanyComplaintFeedback;
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* CompanyComplaintFeedback逻辑
|
||||
* Class CompanyComplaintFeedbackLogic
|
||||
* @package app\adminapi\logic
|
||||
*/
|
||||
class CompanyComplaintFeedbackLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2023/09/23 15:08
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
CompanyComplaintFeedback::create([
|
||||
'content' => $params['content'],
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2023/09/23 15:08
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
CompanyComplaintFeedback::where('id', $params['id'])->update([
|
||||
'content' => $params['content'],
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2023/09/23 15:08
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return CompanyComplaintFeedback::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2023/09/23 15:08
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return CompanyComplaintFeedback::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
}
|
@ -1,174 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\logic\create_task_template;
|
||||
|
||||
|
||||
use app\adminapi\logic\ConfigLogic;
|
||||
use app\common\model\create_task_template\CreateTaskTemplate;
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* CreateTaskTemplate逻辑
|
||||
* Class CreateTaskTemplateLogic
|
||||
* @package app\adminapi\logic\create_task_template
|
||||
*/
|
||||
class CreateTaskTemplateLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2023/12/18 14:50
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
CreateTaskTemplate::create([
|
||||
'title' => $params['title'],
|
||||
'admin_id' => $params['admin_id'],
|
||||
'task_role_id' => $params['task_role_id'],
|
||||
'type' => $params['type'],
|
||||
'stage_day_one' => $params['stage_day_one'],
|
||||
'money' => $params['money'],
|
||||
'proportion_one' => $params['proportion_one'],
|
||||
'stage_day_two' => $params['stage_day_two'],
|
||||
'proportion_two' => $params['proportion_two'],
|
||||
'money_two' => $params['money_two'],
|
||||
'stage_day_three' => $params['stage_day_three'],
|
||||
'new_money_three' => $params['new_money_three'],
|
||||
'money_longtime' => $params['money_longtime'],
|
||||
'types' => $params['types'],
|
||||
'recharge' => $params['recharge'],
|
||||
'content' => $params['content']
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2023/12/18 14:50
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
CreateTaskTemplate::where('id', $params['id'])->update([
|
||||
'title' => $params['title'],
|
||||
'admin_id' => $params['admin_id'],
|
||||
'task_role_id' => $params['task_role_id'],
|
||||
'type' => $params['type'],
|
||||
'stage_day_one' => $params['stage_day_one'],
|
||||
'money' => $params['money'],
|
||||
'proportion_one' => $params['proportion_one'],
|
||||
'stage_day_two' => $params['stage_day_two'],
|
||||
'proportion_two' => $params['proportion_two'],
|
||||
'money_two' => $params['money_two'],
|
||||
'stage_day_three' => $params['stage_day_three'],
|
||||
'new_money_three' => $params['new_money_three'],
|
||||
'money_longtime' => $params['money_longtime'],
|
||||
'types' => $params['types'],
|
||||
'recharge' => $params['recharge'],
|
||||
'content' => $params['content']
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2023/12/18 14:50
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return CreateTaskTemplate::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2023/12/18 14:50
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return CreateTaskTemplate::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
|
||||
public static function taskTypeList($taskRoleId=0)
|
||||
{
|
||||
$type = '';
|
||||
switch ($taskRoleId) {
|
||||
case 1:
|
||||
$type = 'town_task_type_master';
|
||||
break;
|
||||
case 2:
|
||||
$type = 'town_task_type_marketing_director';
|
||||
break;
|
||||
case 3:
|
||||
$type = 'town_task_type';
|
||||
break;
|
||||
case 4:
|
||||
$type = 'village_task_type';
|
||||
break;
|
||||
case 5:
|
||||
$type = 'task_type';
|
||||
break;
|
||||
}
|
||||
if ($type) {
|
||||
$data = ConfigLogic::getDictByType($type);
|
||||
return $data;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
public static function getList($role)
|
||||
{
|
||||
return CreateTaskTemplate::field(['id', 'title', 'admin_id', 'task_role_id', 'type', 'stage_day_one', 'money', 'proportion_one', 'stage_day_two', 'proportion_two', 'money_two', 'stage_day_three', 'new_money_three', 'money_longtime', 'types', 'recharge', 'content'])
|
||||
->order(['id' => 'desc'])
|
||||
->whereIn('task_role_id', explode(',', $role))
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
}
|
@ -144,17 +144,14 @@ class UserInformationgLogic extends BaseLogic
|
||||
$datas = [];
|
||||
if ($data) {
|
||||
foreach ($data as $k => $v) {
|
||||
$a = $v['data']; // json_decode($v['data'], true);
|
||||
$a = json_decode($v['data'], true);
|
||||
$arr = [
|
||||
'id' => $v['id'],
|
||||
'category_id' => $v['category_id'],
|
||||
'category_child' => $v['category_child'],
|
||||
'create_time' => $v['create_time'],
|
||||
'update_time' => $v['update_time'],
|
||||
'datas' => $a,
|
||||
'data_field' => json_decode($v['data_field']),
|
||||
'ai_question' => $v['ai_question'],
|
||||
'ai_aianalyse' => $v['ai_aianalyse'],
|
||||
'datas' => $a
|
||||
];
|
||||
if ($a) {
|
||||
array_push($datas, $arr);
|
||||
|
@ -99,13 +99,11 @@ class RechargeLogic extends BaseLogic
|
||||
]);
|
||||
|
||||
// 更新用户余额及累计充值金额
|
||||
$userInfo = User::where(['id' => $order['user_id']])->findOrEmpty();
|
||||
if ($userInfo['total_recharge_amount'] >= $order['order_amount']) {
|
||||
User::where(['id' => $order['user_id']])
|
||||
->dec('total_recharge_amount', $order['order_amount'])
|
||||
->dec('user_money', $order['order_amount'])
|
||||
->update();
|
||||
}
|
||||
User::where(['id' => $order['user_id']])
|
||||
->dec('total_recharge_amount', $order['order_amount'])
|
||||
->dec('user_money', $order['order_amount'])
|
||||
->update();
|
||||
|
||||
// 记录日志
|
||||
AccountLogLogic::add(
|
||||
$order['user_id'],
|
||||
|
@ -80,18 +80,5 @@ class DictDataLogic extends BaseLogic
|
||||
return DictData::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
|
||||
public static function getContractPartyACompanyTypeList()
|
||||
{
|
||||
return DictData::whereIn('id', [30,16,41])->order('sort')->select()->toArray();
|
||||
}
|
||||
|
||||
public static function getTaskApproveTypeList()
|
||||
{
|
||||
return DictData::where(['type_value' => 'task_approve_type', 'status' => 1])->column('value');
|
||||
}
|
||||
|
||||
public static function getShareholderMoneyTaskApproveTypeList()
|
||||
{
|
||||
return DictData::where(['type_value' => 'shareholder_money_task_approve_type', 'status' => 1])->column('value');
|
||||
}
|
||||
}
|
@ -20,8 +20,6 @@ use app\common\logic\BaseLogic;
|
||||
use app\common\model\contract\Contract;
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\model\user\User;
|
||||
use app\common\service\ConfigService;
|
||||
use think\facade\Config;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
@ -124,70 +122,4 @@ class UserLogic extends BaseLogic
|
||||
}
|
||||
}
|
||||
|
||||
public static function addUser($params)
|
||||
{
|
||||
// 手机号已被使用
|
||||
$mobileUser = User::where(['account' => $params['account']])->find();
|
||||
if (!empty($mobileUser)) {
|
||||
self::setError('手机号已被注册');
|
||||
return false;
|
||||
}
|
||||
$count = User::where('company_id', $params['company_id'])->count();
|
||||
$value = DictData::where('id', 28)->value('value');
|
||||
if ($count >= $value) {
|
||||
self::setError('你创建的账号已达上限');
|
||||
return false;
|
||||
}
|
||||
$group_id = $params['group_id'];
|
||||
// 每个公司市场部长只有1个
|
||||
if($group_id == 16) {
|
||||
$marketManger = User::where(['group_id' =>$group_id,'company_id'=>$params['company_id']])->findOrEmpty();
|
||||
if (!$marketManger->isEmpty()) {
|
||||
self::setError('公司已创建市场部长账号');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// 每个公司服务部长只有1个
|
||||
if($group_id == 14) {
|
||||
$marketManger = User::where(['group_id' =>$group_id,'company_id'=>$params['company_id']])->findOrEmpty();
|
||||
if (!$marketManger->isEmpty()) {
|
||||
self::setError('公司已创建服务部长账号');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$userSn = User::createUserSn();
|
||||
$passwordSalt = Config::get('project.unique_identification');
|
||||
$password = create_password(123456, $passwordSalt);
|
||||
if ($params['avatar'] != '') {
|
||||
$avatar = $params['avatar'];
|
||||
} else {
|
||||
$avatar = ConfigService::get('default_image', 'user_avatar');
|
||||
}
|
||||
|
||||
|
||||
User::create([
|
||||
'sn' => $userSn,
|
||||
'avatar' => $avatar,
|
||||
'is_captain' => $group_id == 2? 1: 0,
|
||||
'nickname' => $params['nickname'],
|
||||
'account' => $params['account'],
|
||||
'mobile' => $params['account'],
|
||||
'id_card' => $params['id_card'],
|
||||
'password' => $password,
|
||||
'channel' => 0,
|
||||
'sex' => $params['sex'],
|
||||
'province' => $params['province'],
|
||||
'city' => $params['city'],
|
||||
'area' => $params['area'],
|
||||
'street' => $params['street'],
|
||||
'village' => $params['village'],
|
||||
'brigade' => $params['brigade'],
|
||||
'address' => $params['address'],
|
||||
'qualification' => json_encode($params['qualification']),
|
||||
'company_id' => $params['company_id'],
|
||||
'group_id' => $group_id,
|
||||
]);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -1,96 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate;
|
||||
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* CompanyComplaintFeedback验证器
|
||||
* Class CompanyComplaintFeedbackValidate
|
||||
* @package app\adminapi\validate
|
||||
*/
|
||||
class CompanyComplaintFeedbackValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'content' => 'require',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
'content' => '内容',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return CompanyComplaintFeedbackValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/09/23 15:08
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['content']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return CompanyComplaintFeedbackValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/09/23 15:08
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id','content']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return CompanyComplaintFeedbackValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/09/23 15:08
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return CompanyComplaintFeedbackValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/09/23 15:08
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
}
|
@ -1,94 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\create_task_template;
|
||||
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* CreateTaskTemplate验证器
|
||||
* Class CreateTaskTemplateValidate
|
||||
* @package app\adminapi\validate\create_task_template
|
||||
*/
|
||||
class CreateTaskTemplateValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return CreateTaskTemplateValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/12/18 14:50
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id', true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return CreateTaskTemplateValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/12/18 14:50
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return CreateTaskTemplateValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/12/18 14:50
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return CreateTaskTemplateValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/12/18 14:50
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
}
|
@ -36,8 +36,8 @@ class RechargeRefundValidate extends BaseValidate
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'recharge_id.require' => '参数缺失recharge_id',
|
||||
'record_id.require' => '参数缺失record_id',
|
||||
'recharge_id.require' => '参数缺失',
|
||||
'record_id.require' => '参数缺失',
|
||||
];
|
||||
|
||||
|
||||
|
@ -33,7 +33,7 @@ class ApproveController extends BaseApiController
|
||||
if (!$approve) {
|
||||
throw new Exception('数据不存在');
|
||||
}
|
||||
ApproveLogic::audit($approve, $params, $this->userInfo);
|
||||
ApproveLogic::audit($approve, $params);
|
||||
return $this->success('操作成功');
|
||||
} catch (Exception $exception) {
|
||||
return $this->fail(ApproveLogic::getError() ?? $exception->getMessage());
|
||||
|
@ -2,51 +2,28 @@
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
|
||||
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\CompanyLogic;
|
||||
use app\common\logic\task\TaskLogic;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\contract\Contract;
|
||||
use app\common\model\company\CompanyAccountLog;
|
||||
use app\common\model\task\Task;
|
||||
use app\common\model\task_scheduling\TaskScheduling;
|
||||
use app\common\model\task_scheduling_plan\TaskSchedulingPlan;
|
||||
use app\common\model\task_template\TaskTemplate;
|
||||
use app\common\model\user\User as UserModel;
|
||||
use app\common\model\user\UserAccountLog;
|
||||
use think\facade\Log;
|
||||
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 app\api\controller\JunziqianController;
|
||||
use think\facade\Db;
|
||||
use app\common\model\ShopMerchant;
|
||||
use app\common\model\contract\ShopContract;
|
||||
|
||||
class CeshiController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = [ 'index',
|
||||
'ceshi',
|
||||
'ceshi1',
|
||||
'ceshi2',
|
||||
'service_group_task_add_test', // 小组服务任务下发
|
||||
'service_group_task_settlement_test', // 小组服务任务结算
|
||||
'town_task_add_ceshi', // 镇农科任务下发
|
||||
'town_task_settlement_ceshi', // 镇农科任务结算
|
||||
'authentication', // 企业认证
|
||||
'initiate_contract', // 发起合同
|
||||
'Draftingcontracts', // 发送合同
|
||||
'postsms', // 发送短信
|
||||
'addSupplyMerchant', // 添加供应商
|
||||
'signSupplyMerchantContract', // 生成合同
|
||||
'countRate',
|
||||
'village_task_add_test',
|
||||
'village_task_settlement_test',
|
||||
'testShopApi'
|
||||
];
|
||||
public array $notNeedLogin = ['index', 'ceshi', 'ceshi1', 'ceshi2', 'task_ceshi'];
|
||||
|
||||
public function index()
|
||||
{ //1201
|
||||
@ -147,135 +124,40 @@ class CeshiController extends BaseApiController
|
||||
}
|
||||
|
||||
/**
|
||||
* 企业认证
|
||||
* 任务刷新
|
||||
*/
|
||||
public function authentication()
|
||||
{
|
||||
$params = (new CompanyValidate())->goCheck('detail');
|
||||
$company = Db::name('company')->where('id', $params['id'])->find();
|
||||
$qualification = json_decode($company['qualification'], true);
|
||||
if ($company && $qualification['business_license']) {
|
||||
$data = [
|
||||
'name' => $company['company_name'],
|
||||
'organization_code' => $company['organization_code'],
|
||||
'business_license' => 'https://lihai001.oss-cn-chengdu.aliyuncs.com/def/561f8202305171526091317.png', //$qualification['business_license'],
|
||||
'master_name' => $company['master_name'],
|
||||
'master_email' => $company['master_email'],
|
||||
'master_phone' => $company['master_phone'],
|
||||
'master_id_card' => $company['master_id_card'],
|
||||
'id' => $company['id'],
|
||||
];
|
||||
$res = app(JunziqianController::class)->EnterpriseCertification($data);
|
||||
Log::info(['企业认证同步结果',$res]);
|
||||
if ($res->success == true) {
|
||||
// 企业人脸上传
|
||||
// $company['master_email'] = $email; // 法人邮箱
|
||||
// $faceCreateRe = CompanyLogic::originationFaceCreate($company);
|
||||
// if ($faceCreateRe !== true) {
|
||||
// return $this->fail($faceCreateRe);
|
||||
// }
|
||||
//
|
||||
if ($company['company_type'] == 30) {
|
||||
// 平台公司不用初始化生成合同 合同签约暂不用人脸识别,预留人脸采集状态为已采集
|
||||
Db::name('company')->where('id', $params['id'])->update([ 'is_contract'=>1,'face_create_status'=>1]);
|
||||
} else {
|
||||
Db::name('company')->where('id', $params['id'])->update([ 'face_create_status'=>1]);
|
||||
}
|
||||
|
||||
// 加入缓存中,is_callback用于判断是否获取到异步通知
|
||||
RedisLogic::getInstance()->set('authentication_company_id_'.$company['id'], json_encode(['company_id'=>$company['id'],'is_callback'=>0, 'timing'=>time()]));
|
||||
// return $this->success('认证成功',[],1, 1);
|
||||
return $this->success('系统认证中,请稍后刷新页面查看', ['email' => $res->data], 1, 1);
|
||||
} else {
|
||||
return $this->fail($res->msg);
|
||||
public function ceshi(){
|
||||
$time=strtotime(date('Y-m-d'));
|
||||
// $time=strtotime(date('Y-m-d'));
|
||||
// $tiem_end=$time+86399;where('cron_time','<',$time)->
|
||||
$plan_all=TaskScheduling::where('id',8)->with('company_info')->select()->toArray();
|
||||
foreach($plan_all as $k=>$v){
|
||||
$all=TaskTemplate::where('status',1)->where('task_scheduling',$v['id'])->limit(30)->select()->toArray();
|
||||
if($all){
|
||||
$plan_all[$k]['template']=$all;
|
||||
}else{
|
||||
unset($plan_all[$k]);
|
||||
}
|
||||
} else {
|
||||
return $this->fail("公司不存在");
|
||||
}
|
||||
$company_id=[];
|
||||
foreach($plan_all as $k=>$v){
|
||||
foreach($v['template'] as $kk=>$vv){
|
||||
TaskLogic::CronAdd($vv,$v);
|
||||
}
|
||||
$company_id[]=$v['company_id'];
|
||||
}
|
||||
Company::where('id','in',$company_id)->inc('day_count')->update();
|
||||
}
|
||||
|
||||
/**发起合同
|
||||
* 请求参数如下
|
||||
* id: 14
|
||||
* party_a: 13
|
||||
* party_a_name: 史丹利农业集团股份有限公司
|
||||
* party_b: 14
|
||||
* party_b_name: 中国乐凯集团有限公司
|
||||
* contract_type: 25
|
||||
* contract_no:
|
||||
*/
|
||||
public function initiate_contract()
|
||||
public function task_ceshi()
|
||||
{
|
||||
$params = $this->request->param();
|
||||
if (isset($params['party_a']) && $params['party_a'] > 0) {
|
||||
$params['party_a'] = $params['party_a'];
|
||||
} else {
|
||||
$params['party_a'] = $this->adminInfo['company_id'];
|
||||
}
|
||||
$area_manager = Company::where('id', $params['party_a'])->value('area_manager');
|
||||
$params['area_manager'] = $area_manager;
|
||||
$params['type'] = 1;
|
||||
$params['party_b'] = $params['id'];
|
||||
unset($params['id']);
|
||||
$result = ContractLogic::initiate_contract($params);
|
||||
if (!empty($result) && $result['code'] == 1) {
|
||||
return $this->success($result['msg'], $result['data'], 1, 1);
|
||||
}
|
||||
return $this->fail(ContractLogic::getError());
|
||||
}
|
||||
$time = strtotime(date('Y-m-d'));
|
||||
// $tiem_end=$time+86399;
|
||||
$plan_all = TaskScheduling::where('cron_time', '<', $time)->where('status', 1)->where('company_type', 18)->with('company_info')->select()->toArray();
|
||||
|
||||
/** 发送合同 发送君子签签约请求,成功后会发送回短信
|
||||
* id: 14
|
||||
* contract_id: 14
|
||||
*/
|
||||
public function Draftingcontracts()
|
||||
{
|
||||
$params = $this->request->param();
|
||||
$result = ContractLogic::Draftingcontracts($params);
|
||||
if ($result == true) {
|
||||
return $this->success('发送合同成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(ContractLogic::getError());
|
||||
}
|
||||
|
||||
/**发送短信
|
||||
*
|
||||
*/
|
||||
public function postsms()
|
||||
{
|
||||
$params = (new CompanyValidate())->goCheck('detail');
|
||||
$id = Contract::where('party_b', $params['id'])->value('id');
|
||||
$res = ContractLogic::postsms(['id' => $id]);
|
||||
if ($res == true) {
|
||||
return $this->success('发送成功', [], 1, 1);
|
||||
} else {
|
||||
return $this->fail(ContractLogic::getError());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 小组服务公司任务下发 线上事故调试和紧急修复预案接口
|
||||
*/
|
||||
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())
|
||||
->where('status', 1)
|
||||
->where('company_type', 18)
|
||||
->where('company_id', $companyId)
|
||||
->with('company_info')
|
||||
->select()
|
||||
->toArray();
|
||||
$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;
|
||||
@ -286,437 +168,12 @@ class CeshiController extends BaseApiController
|
||||
$company_id = [];
|
||||
foreach ($plan_all as $k => $v) {
|
||||
foreach ($v['template'] as $kk => $vv) {
|
||||
// queue(TaskAdd::class,['data'=>$vv,'data_two'=>$v]);
|
||||
TaskLogic::CronAdd($vv, $v);
|
||||
queue(TaskAdd::class,['data'=>$vv,'data_two'=>$v]);
|
||||
}
|
||||
$company_id[] = $v['company_id'];
|
||||
}
|
||||
Company::where('id', 'in', $company_id)->inc('day_count')->update();
|
||||
TaskScheduling::where('id', 'in', $plan_ids)->update(['cron_time' => time()]);
|
||||
Log::info('小组服务公司定时任务下发执行成功' . date('Y-m-d H:i:s'));
|
||||
return $this->success('定时任务下发执行成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 小组服务公司任务结算 线上事故调试和紧急修复预案接口
|
||||
*/
|
||||
public function service_group_task_settlement_test()
|
||||
{
|
||||
//
|
||||
$all = TaskSchedulingPlan::whereDay('end_time','today')
|
||||
->withJoin(['scheduling'], 'left')
|
||||
->where('scheduling.company_type', 18)
|
||||
->where('scheduling.company_id', 34)
|
||||
// ->where('is_pay',0)
|
||||
->with(['template_info'])
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
foreach($all as $k=>$data){
|
||||
try {
|
||||
TaskSchedulingPlan::where('id', $data['id'])->update(['is_pay' => 1]);
|
||||
$company = Company::where('id', $data['company_id'])->field('id,deposit,responsible_area,company_money,shareholder_money,user_id,day_count,company_type,province,city,area,street,village,brigade')->find(); // 可能要判断预存金是否满足
|
||||
$arr['status'] = 0;
|
||||
$arr['company_account_type'] = 1;
|
||||
//信息更新
|
||||
if ($data['template_info']['type'] == 31) {
|
||||
if ($data['template_info']['information_count'] < $data['template_info']['information_day_count']) {
|
||||
Log::info('信息更新任务,信息更新未达到要求:' . json_encode($data));
|
||||
Task::where('id', $data['task_id'])->update(['status' => 5]);
|
||||
TaskTemplate::where('id',$data['template_id'])->update(['information_count'=>$data['template_info']['information_day_count']]);
|
||||
return false;
|
||||
}
|
||||
$name = '小组队长';
|
||||
$arr['status'] = 1;
|
||||
$task = Task::where('id', $data['task_id'])->field('director_uid,money')->where('status', 3)->find();
|
||||
$arr['money'] = $task['money'];
|
||||
Task::where('id', $data['task_id'])->update(['status' => 3]);
|
||||
} elseif
|
||||
//交易金额
|
||||
($data['template_info']['type'] == 33) {
|
||||
$shang_date_total_price = App(RemoteController::class)->shang_date_total_price($company,[],$data['template_id']);
|
||||
if ($shang_date_total_price == false) {
|
||||
Log::info('交易金额任务,交易金额未达到要求:' . json_encode($data));
|
||||
Task::where('id', $data['task_id'])->update(['status' => 5]);
|
||||
return false;
|
||||
}
|
||||
$transaction_pool=$data['template_info']['transaction_pool'];//交易金额剩余池
|
||||
$count_money=bcadd($shang_date_total_price['arr']['total_price'],$transaction_pool,2);//交易金额加资金池金额
|
||||
if($count_money>$shang_date_total_price['arr']['day_money']){
|
||||
$day_money=bcsub($count_money,$shang_date_total_price['arr']['day_money'],2);//当计算剩余池before_transaction_pool
|
||||
$shang_date_total_price['arr']['before_transaction_pool']=$transaction_pool;//变化前
|
||||
$shang_date_total_price['arr']['after_count_transaction_pool']=$count_money;//变化后
|
||||
$shang_date_total_price['arr']['after_transaction_pool']=$day_money;//变化后
|
||||
Task::where('id', $data['task_id'])->update(['status' => 3,'extend'=>json_encode(['transaction'=>$shang_date_total_price])]);
|
||||
TaskTemplate::where('id',$data['template_info']['id'])->update(['transaction_pool'=>$day_money]);
|
||||
$shang_date_total_price['arr']['status']=1;
|
||||
}else{
|
||||
Log::info('交易金额任务,交易金额小于今日金额:' . json_encode($data));
|
||||
Task::where('id', $data['task_id'])->update(['status' => 5]);
|
||||
return false;
|
||||
}
|
||||
$name = $shang_date_total_price['name'];
|
||||
$arr['status'] = $shang_date_total_price['arr']['status'];
|
||||
$task = Task::where('id', $data['task_id'])->field('money')->find();
|
||||
$arr['money'] = $task['money'];
|
||||
} elseif
|
||||
//三轮车
|
||||
($data['template_info']['type'] == 32){
|
||||
$task = Task::where('id', $data['task_id'])->field('director_uid,money')->where('status', 3)->with('director_info')->find();
|
||||
if(empty($task)){
|
||||
Log::info('三轮车任务 ' . $data['template_info']['title'] . '结算失败,任务为空:' . json_encode($data));
|
||||
Task::where('id', $data['task_id'])->update(['status' => 5]);
|
||||
return true;
|
||||
}
|
||||
$name=$task['director_info']['nickname'];
|
||||
$arr['status'] = 1;
|
||||
$arr['money'] = $task['money'];
|
||||
}elseif
|
||||
//入股任务
|
||||
($data['template_info']['type'] == 35){
|
||||
$task_35 = Task::where('id', $data['task_id'])->field('director_uid,status,money,start_time,end_time')->with('director_info')->find();
|
||||
if($task_35){
|
||||
$day= $data['template_info']['stage_day_one'] + $data['template_info']['stage_day_two'];
|
||||
// if($task_35['status']==3 && $data['template_info']['day_count']<=$day){
|
||||
// $name = $task_35['director_info']['nickname'];
|
||||
// $arr['status'] = 1;
|
||||
// $arr['money'] = $task_35['money'];
|
||||
// $arr['company_account_type'] = 2;
|
||||
// }else{
|
||||
if ($task_35['status'] == 3) {
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* 判断入股任务 单次类型 是否超时
|
||||
* 未超时时刷新开始结束时间
|
||||
* 超时则关闭
|
||||
*/
|
||||
if($data['template_info']['day_count']<=$day){
|
||||
TaskSchedulingPlan::where('id', $data['id'])->update(['is_pay' => 0]);
|
||||
try{
|
||||
Task::where('id', $data['task_id'])->update(['create_time' => $task_35['start_time']+86400,'update_time' =>time(),'start_time'=>$task_35['start_time']+86400,'end_time'=>$task_35['start_time']+86400+86399]);
|
||||
}catch(\Exception $e){
|
||||
$start_time = strtotime(date('Y-m-d'));
|
||||
Task::where('id', $data['task_id'])->update(['create_time' => $start_time+86400,'update_time' =>time(),'start_time'=>$start_time+86400,'end_time'=> $start_time + 86400+86399]);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if($data['template_info']['day_count']>$day){
|
||||
Task::where('id', $data['task_id'])->update(['status' =>5]);
|
||||
Log::info('入股任务 ' . $data['template_info']['title'] . '结算失败,任务为超时:' . json_encode($data));
|
||||
return false;
|
||||
}
|
||||
// }
|
||||
}else{
|
||||
Log::info('入股任务 ' . $data['template_info']['title'] . '结算失败,任务为空:' . json_encode($data));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
//其他类型任务
|
||||
$task = Task::where('id', $data['task_id'])->with('director_info')->find();
|
||||
if ($task['status'] == 3) {
|
||||
$name = $task['director_info']['nickname'];
|
||||
$arr['status'] = 1;
|
||||
$arr['money'] = $task['money'];
|
||||
} else if ($task['status'] == 2) {
|
||||
// 是否超时
|
||||
$day= $data['template_info']['stage_day_one'] + $data['template_info']['stage_day_two'];
|
||||
|
||||
if($data['template_info']['day_count'] >= $day){
|
||||
Task::where('id', $data['task_id'])->update(['status' =>5]);
|
||||
Log::info( $data['template_info']['title'] . '结算失败,任务为超时:' . json_encode($data));
|
||||
return false;
|
||||
}
|
||||
|
||||
if($data['template_info']['day_count'] < $day){
|
||||
TaskSchedulingPlan::where('id', $data['id'])->update(['is_pay' => 0]);
|
||||
try{
|
||||
Task::where('id', $data['task_id'])->update(['create_time' => $task['start_time']+86400,'update_time' =>time(),'start_time'=>$task['start_time']+86400,'end_time'=>$task['start_time']+86400+86399]);
|
||||
}catch(\Exception $e){
|
||||
$start_time = strtotime(date('Y-m-d'));
|
||||
Task::where('id', $data['task_id'])->update(['create_time' => $start_time+86400,'update_time' =>time(),'start_time'=>$start_time+86400,'end_time'=> $start_time + 86400+86399]);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error('line:'.$e->getLine().'异常报错:任务结算失败:' . $data['template_info']['title'] . $e->getMessage() . json_encode($data));
|
||||
return false;
|
||||
}
|
||||
if ($arr['status'] == 1) {
|
||||
$arr['company_id'] = $data['scheduling']['company_id'];
|
||||
$arr['msg'] = '来自任务【' . $data['template_info']['title'] . '】,完成方:' . $name . ',任务结算';
|
||||
// $arr['proportion_one'] = $data['template_info']['proportion_one'];
|
||||
// $arr['proportion_two'] = $data['template_info']['proportion_two'];
|
||||
$arr['sn'] = $data['sn'];
|
||||
$arr['id'] = $data['id'];
|
||||
(new ShareProfit())->first($arr, $company,$data);
|
||||
} else {
|
||||
Task::where('id', $data['task_id'])->update(['status' => 5]);
|
||||
Log::info('任务status=0结算失败:' . $data['template_info']['title'] . '未完成' . json_encode($data));
|
||||
}
|
||||
// queue(TaskInformationJob::class,$v);
|
||||
}
|
||||
Log::info('小组服务公司定时任务结算执行成功'.date('Y-m-d H:i:s'));
|
||||
return $this->success('小组服务公司定时任务结算执行成功');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 镇农科公司任务下发 线上事故调试和紧急修复预案接口
|
||||
*/
|
||||
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', 16)
|
||||
->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);
|
||||
|
||||
}
|
||||
|
||||
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 town_task_settlement_ceshi()
|
||||
{
|
||||
// 今日未结算的任务计划
|
||||
$taskSchedulingPlanList = TaskSchedulingPlan::whereDay('end_time','today')
|
||||
->withJoin(['scheduling'], 'left')
|
||||
->where('scheduling.company_type', 16)
|
||||
->where('is_pay',0)
|
||||
->with(['template_info'])
|
||||
->select()
|
||||
->toArray();
|
||||
dd($taskSchedulingPlanList);
|
||||
foreach($taskSchedulingPlanList as $taskSchedulingPlan) {
|
||||
if ($taskSchedulingPlan['company_id'] == 30 && $taskSchedulingPlan['template_info']['type'] == 50) {
|
||||
|
||||
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','yesterday')
|
||||
->withJoin(['scheduling'], 'left')
|
||||
->where('scheduling.company_type', 17)
|
||||
->where('scheduling.company_id', 33)
|
||||
->where('is_pay',0)
|
||||
->with(['template_info'])
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
foreach($taskSchedulingPlanList as $taskSchedulingPlan){
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ use think\facade\Db;
|
||||
|
||||
class CommonController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['city', 'area', 'street','province','village','brigade','dict_data_lists','dict_data_lists_by_type_value','getMiniProgramInfo'];
|
||||
public array $notNeedLogin = ['city', 'area', 'street','province','village','brigade','dict_data_lists'];
|
||||
|
||||
//**省列表 */
|
||||
public function province()
|
||||
@ -58,23 +58,4 @@ class CommonController extends BaseApiController
|
||||
return $this->data($data->toArray());
|
||||
|
||||
}
|
||||
|
||||
public function dict_data_lists_by_type_value($type_value)
|
||||
{
|
||||
$data= DictData::where(['type_value' => $type_value])
|
||||
->append(['status_desc'])
|
||||
->limit(100)
|
||||
->order(['sort' => 'desc', 'id' => 'desc'])
|
||||
->select();
|
||||
|
||||
return $this->data($data->toArray());
|
||||
|
||||
}
|
||||
|
||||
public function getMiniProgramInfo()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
$data = Db::name('miniprogram')->where(['name' => $param['name']])->order('id', 'desc')->find();
|
||||
return $this->data($data);
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ class CompanyAccountLogController extends BaseApiController{
|
||||
$where=[];
|
||||
$where['company_id']=$this->userInfo['company_id'];
|
||||
$where['change_object']=CompanyAccountLog::SHAREHOLDER;
|
||||
// $where['change_type']=CompanyAccountLog::TASK_INC_SHAREHOLDER_MONEY;
|
||||
$where['change_type']=CompanyAccountLog::TASK_INC_SHAREHOLDER_MONEY;
|
||||
$count=CompanyAccountLog::where($where)->count();
|
||||
$lists=CompanyAccountLog::where($where)->page($page,$limit)->order('id','desc')->select();
|
||||
return $this->success('ok',['count'=>$count,'list'=>$lists]);
|
||||
|
@ -2,17 +2,12 @@
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\logic\CompanyLogic;
|
||||
use app\common\logic\contract\ContractLogic;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\company\CompanyAccountLog;
|
||||
use app\common\model\CompanyDepositVoucher;
|
||||
use app\common\model\contract\Contract;
|
||||
use app\common\model\task\Task;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\user\UserAccountLog;
|
||||
use think\Exception;
|
||||
use think\facade\Db;
|
||||
use app\common\model\informationg\UserInformationg;
|
||||
use app\common\model\informationg\UserInformationgDemand;
|
||||
@ -23,8 +18,6 @@ use app\common\model\informationg\UserInformationgDemand;
|
||||
*/
|
||||
class CompanyController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['street_company'];
|
||||
|
||||
|
||||
//**签约公司*/
|
||||
public function index()
|
||||
@ -146,14 +139,7 @@ class CompanyController extends BaseApiController
|
||||
$query = User::where('id', $id);
|
||||
$user = $query->with(['company' => function ($query) {
|
||||
$query->field('id,company_name');
|
||||
}])
|
||||
->field('id,sex,avatar,nickname name,account,mobile phone,id_card,qualification,province,province province_name,city,city city_name,area,area area_name,street,street street_name,village,village village_name,brigade,brigade brigade_name, is_contract,company_id,is_captain, group_id')
|
||||
->append(['is_service_manager'], true)
|
||||
->withAttr('is_service_manager', function ($value, $data) {
|
||||
return $data['group_id'] == 14 ?1 :0;
|
||||
})
|
||||
->find()
|
||||
->toArray();
|
||||
}])->field('id,sex,avatar,nickname name,account,mobile phone,id_card,qualification,province,province province_name,city,city city_name,area,area area_name,street,street street_name,village,village village_name,brigade,brigade brigade_name, is_contract,company_id,is_captain')->find()->toArray();
|
||||
|
||||
$contract = Contract::where("type", 2)->where('party_b', $id)->append(['contract_type_name'])->find();
|
||||
$user['contract'] = $contract;
|
||||
@ -208,7 +194,7 @@ class CompanyController extends BaseApiController
|
||||
public function shareholder_info()
|
||||
{
|
||||
// $params = $this->request->param();
|
||||
$find = Company::where('id', $this->userInfo['company_id'])->field('id,shareholder_money,village')->find()->toArray();
|
||||
$find = Company::where('id', $this->userInfo['company_id'])->field('shareholder_money,village')->find()->toArray();
|
||||
$find['is_contract'] = 0;
|
||||
$find['check_status'] = 0;
|
||||
if ($find) {
|
||||
@ -234,17 +220,10 @@ class CompanyController extends BaseApiController
|
||||
} else {
|
||||
$find['is_village'] = 0;
|
||||
}
|
||||
// 股金任务是否完成
|
||||
$task = Task::where(['company_id' => $find['id'], 'type' => 35, 'status' => 3])->find();
|
||||
$find['is_done_task'] = 0;
|
||||
if (!empty($task)) {
|
||||
$find['is_done_task'] = 1;
|
||||
}
|
||||
} else {
|
||||
$find['contract_url'] = '';
|
||||
$find['contract_time'] = '';
|
||||
$find['is_village'] = 0;
|
||||
$find['is_done_task'] = 0;
|
||||
}
|
||||
return $this->success('ok', $find);
|
||||
}
|
||||
@ -276,126 +255,8 @@ class CompanyController extends BaseApiController
|
||||
}
|
||||
return $this->fail(ContractLogic::getError());
|
||||
}
|
||||
|
||||
/**
|
||||
* 小组服务公司股金上交
|
||||
*/
|
||||
public function pay_share_capital()
|
||||
{
|
||||
try {
|
||||
// 小组服务公司
|
||||
$serviceGroupCompany = Company::where('id', $this->userInfo['company_id'])->find()->toArray();
|
||||
// 村管理公司
|
||||
$villageCompany = Company::where(['village'=>$serviceGroupCompany['village'], 'company_type' => 17])->find()->toArray();
|
||||
Db::startTrans();
|
||||
// 上交股金金额
|
||||
$amount = $serviceGroupCompany['shareholder_money'];
|
||||
if ($amount == 0) {
|
||||
return $this->fail('股金金额不能为0');
|
||||
}
|
||||
$sharecapitalChangeLogData = [
|
||||
'subordinate_company_id' => $serviceGroupCompany['id'],
|
||||
'parent_company_id' => $villageCompany['id'],
|
||||
'amount' => $amount,
|
||||
'create_time' => time(),
|
||||
'update_time' => time(),
|
||||
];
|
||||
$sharecapitalChangeLogInsertId = Db::name('company_sharecapital_change_log')->insertGetId($sharecapitalChangeLogData);
|
||||
|
||||
// 小组服务公司股金变动 + 公司股金减少记录
|
||||
$leftAmount = bcsub($serviceGroupCompany['shareholder_money'], $amount, 2);
|
||||
Company::where('id', $this->userInfo['company_id'])->save(['shareholder_money'=> $leftAmount]);
|
||||
$company_log1 = [
|
||||
'sn' => generate_sn(UserAccountLog::class, 'sn', 20),
|
||||
'company_id' => $serviceGroupCompany['id'],
|
||||
'change_object' => 2, // 变动对象 1余额 2股金
|
||||
'change_type' => CompanyAccountLog::SHAREHOLDER_DEC_DEPOSIT, //变动类型
|
||||
'action' => 2, //1-增加 2-减少
|
||||
'left_amount' => $leftAmount, //变动后数量
|
||||
'change_amount' => $amount, //变动数量
|
||||
'extend' => json_encode(['company_sharecapital_change_log_id' => $sharecapitalChangeLogInsertId]),
|
||||
'status' => 1,
|
||||
];
|
||||
CompanyAccountLog::create($company_log1);
|
||||
|
||||
// 村管理公司股金变动 + 公司股金增加记录
|
||||
$addAmount = bcadd($villageCompany['shareholder_money'], $amount, 2);
|
||||
Company::where('id', $villageCompany['id'])->save(['shareholder_money'=>$addAmount]);
|
||||
|
||||
// 公司账户变动记录
|
||||
$company_log2 = [
|
||||
'sn' => generate_sn(UserAccountLog::class, 'sn', 20),
|
||||
'company_id' => $villageCompany['id'],
|
||||
'change_object' => 2, // 变动对象 1余额 2股金
|
||||
'change_type' => CompanyAccountLog::TASK_INC_SHAREHOLDER_MONEY, //变动类型
|
||||
'action' => 1, //1-增加 2-减少
|
||||
'left_amount' => $addAmount, //变动后数量
|
||||
'change_amount' => $amount, //变动数量
|
||||
'extend' => json_encode(['company_sharecapital_change_log_id' => $sharecapitalChangeLogInsertId]),
|
||||
'status' => 1,
|
||||
];
|
||||
CompanyAccountLog::create($company_log2);
|
||||
Db::commit();
|
||||
return $this->success('上交成功', [], 1, 1);
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function complaint_feedback()
|
||||
{
|
||||
$params = $this->request->param();
|
||||
$company = Company::where('id', $this->userInfo['company_id'])->find()->toArray();
|
||||
Db::name('company_complaint_feedback')->insertGetId(['company_id'=>$company['id'], 'content'=>$params['content'],'create_time'=>time(), 'update_time'=>time()]);
|
||||
return $this->success('成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询镇农科公司
|
||||
*/
|
||||
public function street_company(){
|
||||
$street=$this->request->param('street_code', '');
|
||||
$area=$this->request->param('area_code', '');
|
||||
if (!empty($street)) {
|
||||
$company=Db::query("select * from la_company where company_type=:company_type and FIND_IN_SET(:street,responsible_area)", ['company_type' => 41,'street'=>$street], true);
|
||||
if($company){
|
||||
return $this->success('ok',['title'=>$company[0]['company_name'],'organization_code'=>$company[0]['organization_code']]);
|
||||
}else{
|
||||
return $this->fail('当前区域无镇农科公司');
|
||||
}
|
||||
}
|
||||
if(!empty($area)) {
|
||||
$company= Company::where(['company_type'=>15, 'area'=>$area])->findOrEmpty();
|
||||
if(!$company->isEmpty()){
|
||||
return $this->success('ok',['title'=>$company['company_name'],'organization_code'=>$company['organization_code']]);
|
||||
}else{
|
||||
return $this->fail('当前区域无供投公司');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询签约的甲方公司
|
||||
*/
|
||||
public function getPartyACompany()
|
||||
{
|
||||
$re = CompanyLogic::getPartyA($this->userInfo['company_id']);
|
||||
if ($re === false) {
|
||||
return $this->fail(CompanyLogic::getError());
|
||||
}
|
||||
return $this->success('成功',$re);
|
||||
}
|
||||
|
||||
public function getDepositRechargeTransferVoucherList()
|
||||
{
|
||||
[$page, $limit] = $this->getPage();
|
||||
$list = CompanyDepositVoucher::where(['company_id' => $this->userInfo['company_id']])
|
||||
->order(['id' => 'desc'])
|
||||
->page($page)->limit($limit)->select();;
|
||||
$count=CompanyDepositVoucher::where(['company_id' => $this->userInfo['company_id']])->count();
|
||||
return $this->success('success', ['count' => $count, 'data' => $list]);
|
||||
// return
|
||||
}
|
||||
}
|
||||
|
@ -3,10 +3,6 @@
|
||||
namespace app\api\controller;
|
||||
use app\common\model\task_scheduling_plan\TaskSchedulingPlan;
|
||||
use app\job\TaskInformationJob;
|
||||
use app\job\TownTaskAdd;
|
||||
use app\job\TownTaskSettlementJob;
|
||||
use app\job\VillageTaskAdd;
|
||||
use app\job\VillageTaskSettlementJob;
|
||||
use think\facade\Log;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\task_template\TaskTemplate;
|
||||
@ -21,19 +17,27 @@ use app\job\TaskAdd;
|
||||
*/
|
||||
class CronController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['settlement','task_add', 'town_task_add', 'town_task_settlement','village_task_add', 'village_task_settlement'];
|
||||
public array $notNeedLogin = ['settlement','task_add'];
|
||||
|
||||
/**
|
||||
* 小组服务公司任务下发
|
||||
* 结算
|
||||
*/
|
||||
public function settlement(){
|
||||
$all=TaskSchedulingPlan::where('is_pay',0)->with(['template_info','scheduling'])->select()->toArray();
|
||||
foreach($all as $k=>$v){
|
||||
queue(TaskInformationJob::class,$v);
|
||||
}
|
||||
Log::info('定时任务结算执行成功'.date('Y-m-d H:i:s'));
|
||||
return $this->success('定时任务结算执行成功');
|
||||
|
||||
}
|
||||
|
||||
public function task_add(){
|
||||
//任务下发
|
||||
//任务下发
|
||||
// $time=strtotime(date('Y-m-d',strtotime('-1 day')));
|
||||
$time = strtotime(date('Y-m-d'));
|
||||
// $tiem_end=$time+86399;
|
||||
// $plan_all = TaskScheduling::where('cron_time', '<', $time)->where('status', 1)->with('company_info')->select()->toArray();
|
||||
$plan_all = TaskScheduling::where('cron_time', '<', $time)->where('status', 1)->where('company_type', 18)->with('company_info')->select()->toArray();
|
||||
|
||||
$plan_all = TaskScheduling::where('cron_time', '<', $time)->where('status', 1)->with('company_info')->select()->toArray();
|
||||
$plan_ids = [];
|
||||
foreach ($plan_all as $k => $v) {
|
||||
$all = TaskTemplate::where('status', 1)->where('task_scheduling', $v['id'])->limit(30)->select()->toArray();
|
||||
@ -53,167 +57,7 @@ class CronController extends BaseApiController
|
||||
}
|
||||
Company::where('id', 'in', $company_id)->inc('day_count')->update();
|
||||
TaskScheduling::where('id', 'in', $plan_ids)->update(['cron_time' => time()]);
|
||||
Log::info('小组服务公司定时任务下发执行成功' . date('Y-m-d H:i:s'));
|
||||
Log::info('定时任务下发执行成功' . date('Y-m-d H:i:s'));
|
||||
return $this->success('定时任务下发执行成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 小组服务公司任务结算
|
||||
*/
|
||||
public function settlement(){
|
||||
// $all=TaskSchedulingPlan::where('is_pay',0)->with(['template_info','scheduling'])->select()->toArray();
|
||||
$all = TaskSchedulingPlan::whereDay('end_time','today')
|
||||
->withJoin(['scheduling'], 'left')
|
||||
->where('scheduling.company_type', 18)
|
||||
->where('is_pay',0)
|
||||
->with(['template_info'])
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
foreach($all as $k=>$v){
|
||||
// 任务运行中,后台删除了任务模板
|
||||
if (empty($v['template_info'])) {
|
||||
continue;
|
||||
}
|
||||
queue(TaskInformationJob::class,$v);
|
||||
}
|
||||
Log::info('小组服务公司定时任务结算执行成功'.date('Y-m-d H:i:s'));
|
||||
return $this->success('小组服务公司定时任务结算执行成功');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 村管理公司任务下发
|
||||
*/
|
||||
public function village_task_add()
|
||||
{
|
||||
//任务下发
|
||||
$time = strtotime(date('Y-m-d'));
|
||||
// 查询系统 所有镇农科公司 未下发 的 任务安排
|
||||
$taskSchedulingList = TaskScheduling::where('cron_time', '<', $time)
|
||||
->where('status', 1)
|
||||
->where('company_type', 17)
|
||||
->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) {
|
||||
queue(VillageTaskAdd::class, $template);
|
||||
// TaskLogic::TownCronAdd($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()
|
||||
{
|
||||
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('is_pay',0)
|
||||
->with(['template_info'])
|
||||
->select()
|
||||
->toArray();
|
||||
foreach($taskSchedulingPlanList as $taskSchedulingPlan){
|
||||
// 任务运行中,后台删除了任务模板
|
||||
if (empty($taskSchedulingPlan['template_info'])) {
|
||||
continue;
|
||||
}
|
||||
queue(VillageTaskSettlementJob::class, $taskSchedulingPlan);
|
||||
}
|
||||
Log::info('村管理公司定时任务结算执行-结束'.date('Y-m-d H:i:s'));
|
||||
return $this->success('村管理公司定时任务结算执行成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 镇合伙人公司任务下发
|
||||
*/
|
||||
public function town_task_add()
|
||||
{
|
||||
//任务下发
|
||||
$time = strtotime(date('Y-m-d'));
|
||||
// 查询系统 所有镇农科公司 未下发 的 任务安排
|
||||
$taskSchedulingList = TaskScheduling::where('cron_time', '<', $time)
|
||||
->where('status', 1)
|
||||
->where('company_type', 16)
|
||||
->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) {
|
||||
queue(TownTaskAdd::class, $template);
|
||||
// TaskLogic::TownCronAdd($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 town_task_settlement()
|
||||
{
|
||||
Log::info('镇合伙人公司定时任务结算执行-开始'.date('Y-m-d H:i:s'));
|
||||
//today 今日未结算的任务计划
|
||||
$taskSchedulingPlanList = TaskSchedulingPlan::whereDay('end_time','today')
|
||||
->withJoin(['scheduling'], 'left')
|
||||
->where('scheduling.company_type', 16)
|
||||
->where('is_pay',0)
|
||||
->with(['template_info'])
|
||||
->select()
|
||||
->toArray();
|
||||
foreach($taskSchedulingPlanList as $taskSchedulingPlan){
|
||||
// 任务运行中,后台删除了任务模板
|
||||
if (empty($taskSchedulingPlan['template_info'])) {
|
||||
continue;
|
||||
}
|
||||
// 解耦 三个角色分开结算,避免某个角色的结算逻辑出现异常,导致整个镇农科公司的任务结算都终止
|
||||
$taskTemplateInfo = $taskSchedulingPlan['template_info'];
|
||||
// 负责人任务结算
|
||||
if ($taskTemplateInfo['extend']['task_role'] == 1) {
|
||||
queue(TownTaskSettlementJob::class, $taskSchedulingPlan);
|
||||
}
|
||||
// 市场部长任务结算
|
||||
if ($taskTemplateInfo['extend']['task_role'] == 2) {
|
||||
queue(TownTaskSettlementJob::class, $taskSchedulingPlan);
|
||||
}
|
||||
// 服务部长任务结算
|
||||
if ($taskTemplateInfo['extend']['task_role'] == 3) {
|
||||
queue(TownTaskSettlementJob::class, $taskSchedulingPlan);
|
||||
}
|
||||
}
|
||||
Log::info('镇镇合伙人公司定时任务结算执行-结束'.date('Y-m-d H:i:s'));
|
||||
return $this->success('镇农科公司定时任务结算执行成功');
|
||||
}
|
||||
}
|
@ -21,7 +21,6 @@ use app\common\model\contract\Contract;
|
||||
use app\common\model\contract\ShopContract;
|
||||
use app\common\model\contract\VehicleContract;
|
||||
use app\common\model\ShopMerchant;
|
||||
use app\common\model\vehicle\VehicleBuyRecord;
|
||||
use app\common\model\vehicle\VehicleRent;
|
||||
use Symfony\Component\HttpClient\HttpClient;
|
||||
use think\cache\driver\Redis;
|
||||
@ -38,11 +37,7 @@ use think\response\Json;
|
||||
*/
|
||||
class IndexController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = [
|
||||
'index', 'config', 'policy', 'decorate', 'notifyUrl',
|
||||
'notifyProperty', 'notifyAuthentication', 'notifyVehicleContractUpdate',
|
||||
'townCarRent','systemCarRent', 'selfCarRent', 'cancelRent', 'buyCar',
|
||||
'vehicleCarList', 'getCompanyBankInfo'];
|
||||
public array $notNeedLogin = ['index', 'config', 'policy', 'decorate', 'notifyUrl', 'notifyProperty', 'notifyAuthentication', 'notifyVehicleContractUpdate','townCarRent','systemCarRent', 'selfCarRent', 'cancelRent'];
|
||||
|
||||
/**
|
||||
* @notes 首页数据
|
||||
@ -182,7 +177,6 @@ class IndexController extends BaseApiController
|
||||
$updateSverRes =curl_post(env('project.logistic_domain').'/api/contractUpdate',[],[
|
||||
'id' => $contract['contract_logistic_id'],
|
||||
'signing_timer' => 1,
|
||||
'update_time' => time()
|
||||
]);
|
||||
if(!$updateLocalRes || $updateSverRes['code']==0){
|
||||
return json(['success' => false, 'msg' => '更新失败']);
|
||||
@ -209,15 +203,14 @@ class IndexController extends BaseApiController
|
||||
foreach ($cars as $k => $v) {
|
||||
$hasCar = VehicleRent::where('car_id',$v['id'])->findOrEmpty();
|
||||
if($hasCar->isEmpty()){
|
||||
$data[$k]['contract_id'] = $contract['id'];
|
||||
$data[$k]['company_id'] = $contract['company_b_id'];
|
||||
$data[$k]['car_id'] = $v['id'];
|
||||
$data[$k]['car_license'] = $v['license'];
|
||||
$data[$k]['type'] = 0;
|
||||
$data[$k]['status'] = 0;
|
||||
$data[$k]['rent_contract_id'] = 0;
|
||||
$data[$k]['rent_company_id'] = 0;
|
||||
$data[$k]['company_id'] = $contract['company_b_id'];
|
||||
$data[$k]['rent_time'] = 0;
|
||||
$data[$k]['rent_company_id'] = 0;
|
||||
$data[$k]['contract_id'] = $contract['id'];
|
||||
$data[$k]['create_time'] = strtotime($contract['create_time']);
|
||||
}
|
||||
}
|
||||
@ -229,8 +222,7 @@ class IndexController extends BaseApiController
|
||||
'signing_timer' => 2,
|
||||
'status' => 3,
|
||||
'contract_url'=>$signContractFile,
|
||||
'contract_evidence'=>$contractEvidence,
|
||||
'update_time' => time()
|
||||
'contract_evidence'=>$contractEvidence
|
||||
]);
|
||||
if(!$updateLocalRes || $updateSverRes['code']==0){
|
||||
return json(['success' => false, 'msg' => '更新失败']);
|
||||
@ -285,20 +277,26 @@ class IndexController extends BaseApiController
|
||||
VehicleContract::where('id', $id)->update(['signing_timer' => 2, 'status' => 3,'contract_url'=>$signContractFile,'contract_evidence'=>$contractEvidence]);
|
||||
//添加车辆到租赁列表
|
||||
$vehicle = json_decode($contract['cars_info'], true);
|
||||
VehicleRent::where('car_id', $vehicle[0]['id'])->update([
|
||||
VehicleRent::where('car_id', $vehicle['id'])->update([
|
||||
'status' => 2,
|
||||
'rent_contract_id' => $contract['id'],
|
||||
'rent_company_id' => $contract['company_b_id'],
|
||||
'rent_time' => time(),
|
||||
'rent_company_id' => $contract['company_b_id'],
|
||||
]);
|
||||
$party_b = Company::where('id', $contract['company_b_id'])->find();
|
||||
//通知物流系统跟新
|
||||
curl_post(env('project.logistic_domain').'/api/updateVehicleRent', [], [
|
||||
'car_id' => $vehicle[0]['id'],
|
||||
'car_id' => $vehicle['id'],
|
||||
'use_user_id' => $party_b['user_id'],
|
||||
'use_user_name' => $party_b['master_name'],
|
||||
'use_user_phone' => $party_b['master_phone']
|
||||
]);
|
||||
CompanyProperty::create([
|
||||
'company_id' => $contract['company_b_id'],
|
||||
'object_id' => $vehicle['id'],
|
||||
'type' => 1,
|
||||
'create_time' => time(),
|
||||
'update_time' => time(),
|
||||
]);
|
||||
return json(['success' => true, 'msg' => '成功']);
|
||||
} else {
|
||||
return json(['success' => true, 'msg' => '成功']);
|
||||
@ -335,8 +333,8 @@ class IndexController extends BaseApiController
|
||||
//添加车辆到物流系统
|
||||
$vehicle = json_decode($contract['cars_info'], true);
|
||||
$curl_res = curl_post(env('project.logistic_domain').'/api/addSelfCar', [], [
|
||||
'license' => $vehicle[0]['license'],
|
||||
'pic' => $vehicle[0]['pic'],
|
||||
'license' => $vehicle['license'],
|
||||
'pic' => $vehicle['pic'],
|
||||
'company_id' => $contract['company_a_id'],
|
||||
'company_name' => $contract['company_a_name'],
|
||||
'company_user' => $contract['company_a_user'],
|
||||
@ -345,7 +343,7 @@ class IndexController extends BaseApiController
|
||||
if (!$curl_res || $curl_res['code'] == 0) {
|
||||
return json(['success' => false, 'msg' => '失败2.6']);
|
||||
}
|
||||
$cars_info = json_encode([['id' => $curl_res['data']['car_id'], 'license' => $vehicle[0]['license']]]);
|
||||
$cars_info = json_encode(['id' => $curl_res['data']['car_id'], 'license' => $vehicle['license']]);
|
||||
//获取签约后的合同
|
||||
$signContractFile = app(JunziqianController::class)->downloadVehicleContractFile($contract['contract_no']);
|
||||
$signContractFile = $signContractFile ?? '';
|
||||
@ -363,10 +361,9 @@ class IndexController extends BaseApiController
|
||||
'car_id' => $curl_res['data']['car_id'],
|
||||
'contract_id' => $contract['id'],
|
||||
'company_id' => $contract['company_a_id'],
|
||||
'car_license' => $vehicle[0]['license'],
|
||||
'car_license' => $vehicle['license'],
|
||||
'status' => 2,
|
||||
'rent_time' => time(),
|
||||
'rent_contract_id' => $contract['id'],
|
||||
'rent_company_id' => $contract['company_b_id'],
|
||||
'create_time' => time(),
|
||||
'type' => 1
|
||||
@ -380,6 +377,13 @@ class IndexController extends BaseApiController
|
||||
'use_user_name' => $party_b['master_name'],
|
||||
'use_user_phone' => $party_b['master_phone']
|
||||
]);
|
||||
CompanyProperty::create([
|
||||
'company_id' => $contract['company_b_id'],
|
||||
'object_id' => $car_id,
|
||||
'type' => 1,
|
||||
'create_time' => time(),
|
||||
'update_time' => time(),
|
||||
]);
|
||||
return json(['success' => true, 'msg' => '成功']);
|
||||
} else {
|
||||
return json(['success' => true, 'msg' => '成功']);
|
||||
@ -424,241 +428,24 @@ class IndexController extends BaseApiController
|
||||
'party_a' => $signContractEvidenceToPartyA,
|
||||
'party_b' => $signContractEvidenceToPartyB
|
||||
]);
|
||||
$cars = json_decode($contract['cars_info'],true);
|
||||
$cars_ids = array_column($cars,'id');
|
||||
//更改合同状态
|
||||
VehicleContract::where('id', $id)->update(['signing_timer'=>2,'status'=>3,'contract_url'=>$signContractFile,'contract_evidence'=>$contractEvidence]);
|
||||
if(!empty($contract['contract_logistic_id'])){
|
||||
curl_post(env('project.logistic_domain').'/api/contractUpdate',[],[
|
||||
'id' => $contract['contract_logistic_id'],
|
||||
'signing_timer' => 2,
|
||||
'status' => 3,
|
||||
'contract_url'=>$signContractFile,
|
||||
'contract_evidence'=>$contractEvidence,
|
||||
'update_time' => time()
|
||||
]);
|
||||
}
|
||||
//判断合同是否存在购买记录表中
|
||||
$vehicleBuyRecord = VehicleBuyRecord::where('contract_id',$contract['id'])->findOrEmpty();
|
||||
if(!$vehicleBuyRecord->isEmpty()){
|
||||
//小组公司与镇街公司解约
|
||||
if($vehicleBuyRecord['status'] == 1){
|
||||
//获取租赁车辆信息
|
||||
$rentCarsInfo = VehicleRent::where('car_id',$cars_ids[0])->findOrEmpty();
|
||||
if($rentCarsInfo['type'] == 0){
|
||||
//修改租赁车俩状态
|
||||
VehicleRent::where('id',$rentCarsInfo['id'])->update(['status'=>0,'rent_company_id'=>0,'rent_contract_id'=>0,'rent_time'=>0]);
|
||||
}
|
||||
if($rentCarsInfo['type'] == 1){
|
||||
//修改租赁车俩状态
|
||||
VehicleRent::where('id',$rentCarsInfo['id'])->delete();
|
||||
}
|
||||
//删除原合同
|
||||
VehicleContract::where('id',$rentCarsInfo['rent_contract_id'])->delete();
|
||||
//修改物流系统车辆租赁信息
|
||||
curl_post(env('project.logistic_domain').'/api/Vehicle/delRentUseInfo', [], [
|
||||
'car_id' => $cars_ids[0]
|
||||
]);
|
||||
//发送购买合同给物流系统
|
||||
$curl_result = curl_post(env('project.logistic_domain').'/api/signContract',[],[
|
||||
'num' => $vehicleBuyRecord['num'],
|
||||
'company_id' => $vehicleBuyRecord['company_id'],
|
||||
'company_name' => $vehicleBuyRecord['company_name'],
|
||||
'company_code' => $vehicleBuyRecord['company_code'],
|
||||
'company_user' => $vehicleBuyRecord['company_user'],
|
||||
'company_phone' => $vehicleBuyRecord['company_phone'],
|
||||
'company_email' => $vehicleBuyRecord['company_email'],
|
||||
'cars_info' => $vehicleBuyRecord['cars_info'],
|
||||
'type' => 3
|
||||
]);
|
||||
if(empty($curl_result)){
|
||||
return $this->fail('null return from logistic');
|
||||
}
|
||||
if($curl_result['code'] == 0){
|
||||
return $this->fail($curl_result['msg'].' from logistic');
|
||||
}
|
||||
//生成本地合同
|
||||
VehicleContract::create($curl_result['data']);
|
||||
VehicleBuyRecord::where('id',$vehicleBuyRecord['id'])->update(['status'=>4]);
|
||||
return json(['success' => true, 'msg' => '成功']);
|
||||
}
|
||||
//小组公司与镇街公司解约,然后镇街公司与平台公司解约
|
||||
if($vehicleBuyRecord['status'] == 2){
|
||||
//获取租赁车辆信息
|
||||
$rentCarsInfo = VehicleRent::where('car_id',$cars_ids[0])->findOrEmpty();
|
||||
if($rentCarsInfo['type'] == 0){
|
||||
//修改租赁车俩状态
|
||||
VehicleRent::where('id',$rentCarsInfo['id'])->update(['status'=>0,'rent_company_id'=>0,'rent_contract_id'=>0,'rent_time'=>0]);
|
||||
}
|
||||
if($rentCarsInfo['type'] == 1){
|
||||
//修改租赁车俩状态
|
||||
VehicleRent::where('id',$rentCarsInfo['id'])->delete();
|
||||
}
|
||||
//删除原合同
|
||||
VehicleContract::where('id',$rentCarsInfo['rent_contract_id'])->delete();
|
||||
//修改物流系统车辆租赁信息
|
||||
curl_post(env('project.logistic_domain').'/api/Vehicle/delRentUseInfo', [], [
|
||||
'car_id' => $cars_ids[0]
|
||||
]);
|
||||
//获取镇街公司信息
|
||||
$zjCompany = Company::where('id',$rentCarsInfo['company_id'])->findOrEmpty();
|
||||
//判断购买车辆中是否包含镇街公司租赁的车辆
|
||||
$car_ids = array_column(json_decode($vehicleBuyRecord['cars_info'],true),'id');
|
||||
$zjRentCars = VehicleRent::field('car_id as id,car_license as license')->where('company_id',$zjCompany['id'])->where('car_id','in',$car_ids)->where('status',0)->where('type',0)->select();
|
||||
//发送镇公司与平台公司的解约合同
|
||||
$curl_result = curl_post(env('project.logistic_domain').'/api/signContract',[],[
|
||||
'num' => count($zjRentCars),
|
||||
'company_id' => $zjCompany['id'],
|
||||
'company_name' => $zjCompany['company_name'],
|
||||
'company_code' => $zjCompany['organization_code'],
|
||||
'company_user' => $zjCompany['master_name'],
|
||||
'company_phone' => $zjCompany['master_phone'],
|
||||
'company_email' => $zjCompany['master_email'],
|
||||
'cars_info' => json_encode($zjRentCars),
|
||||
'type' => 2
|
||||
]);
|
||||
if(empty($curl_result)){
|
||||
return $this->fail('null return from logistic');
|
||||
}
|
||||
if($curl_result['code'] == 0){
|
||||
return $this->fail($curl_result['msg'].' from logistic');
|
||||
}
|
||||
//生成本地合同
|
||||
$res = VehicleContract::create($curl_result['data']);
|
||||
VehicleBuyRecord::where('id',$vehicleBuyRecord['id'])->update(['status'=>3,'contract_id'=>$res->id]);
|
||||
return json(['success' => true, 'msg' => '成功']);
|
||||
}
|
||||
//镇街公司与平台公司解约
|
||||
if($vehicleBuyRecord['status'] == 3){
|
||||
//删除本地租赁信息
|
||||
VehicleRent::where('car_id','in',$cars_ids)->delete();
|
||||
//删除物流系统租赁信息
|
||||
curl_post(env('project.logistic_domain').'/api/cancelRent', [], [
|
||||
'car_ids' => implode(',',$cars_ids)
|
||||
]);
|
||||
//发送购买合同给物流系统
|
||||
$curl_result = curl_post(env('project.logistic_domain').'/api/signContract',[],[
|
||||
'num' => $vehicleBuyRecord['num'],
|
||||
'company_id' => $vehicleBuyRecord['company_id'],
|
||||
'company_name' => $vehicleBuyRecord['company_name'],
|
||||
'company_code' => $vehicleBuyRecord['company_code'],
|
||||
'company_user' => $vehicleBuyRecord['company_user'],
|
||||
'company_phone' => $vehicleBuyRecord['company_phone'],
|
||||
'company_email' => $vehicleBuyRecord['company_email'],
|
||||
'cars_info' => $vehicleBuyRecord['cars_info'],
|
||||
'type' => 3
|
||||
]);
|
||||
if(empty($curl_result)){
|
||||
return $this->fail('null return from logistic');
|
||||
}
|
||||
if($curl_result['code'] == 0){
|
||||
return $this->fail($curl_result['msg'].' from logistic');
|
||||
}
|
||||
//生成本地合同
|
||||
VehicleContract::create($curl_result['data']);
|
||||
VehicleBuyRecord::where('id',$vehicleBuyRecord['id'])->update(['status'=>4]);
|
||||
return json(['success' => true, 'msg' => '成功']);
|
||||
}
|
||||
}else{
|
||||
//更改租赁列表车辆状态
|
||||
$vehicle = json_decode($contract['cars_info'], true);
|
||||
//获取租赁车辆信息
|
||||
$vehicleRentInfo = VehicleRent::where('car_id', $vehicle[0]['id'])->find();
|
||||
//更新原始合同类型
|
||||
VehicleContract::where('id', $vehicleRentInfo['rent_contract_id'])->delete();
|
||||
VehicleRent::where('car_id', $vehicle[0]['id'])->delete();
|
||||
//通知物流系统跟新
|
||||
curl_post(env('project.logistic_domain').'/api/Vehicle/delRentUseInfo', [], [
|
||||
'car_id' => $vehicle[0]['id']
|
||||
]);
|
||||
return json(['success' => true, 'msg' => '成功']);
|
||||
}
|
||||
} else {
|
||||
return json(['success' => true, 'msg' => '成功']);
|
||||
}
|
||||
}
|
||||
|
||||
//购买合同回调
|
||||
public function buyCar() {
|
||||
//获取参数
|
||||
$id = $this->request->get('id');
|
||||
if (empty($id)) {
|
||||
return json(['success' => false, 'msg' => '失败4.1']);
|
||||
}
|
||||
//获取合同数据
|
||||
$contract = VehicleContract::where('id', $id)->find();
|
||||
if (empty($contract)) {
|
||||
return json(['success' => false, 'msg' => '失败4.2']);
|
||||
}
|
||||
if ($contract['type'] != 3) {
|
||||
return json(['success' => false, 'msg' => '失败4.3']);
|
||||
}
|
||||
if ($contract['status'] != 2) {
|
||||
return json(['success' => false, 'msg' => '失败4.4']);
|
||||
}
|
||||
if ($contract['signing_timer'] == 0) {
|
||||
$res = VehicleContract::where('id', $id)->update(['signing_timer' => 1]);
|
||||
if (!$res) {
|
||||
return json(['success' => false, 'msg' => '失败4.5']);
|
||||
}
|
||||
return json(['success' => true, 'msg' => '成功']);
|
||||
}else if ($contract['signing_timer'] == 1) {
|
||||
//获取签约后的合同
|
||||
$signContractFile = app(JunziqianController::class)->downloadVehicleContractFile($contract['contract_no']);
|
||||
$signContractFile = $signContractFile ?? '';
|
||||
//获取签约后的证据
|
||||
$signContractEvidenceToPartyA = app(JunziqianController::class)->downloadVehicleContractEvidence($contract['contract_no'],$contract['company_a_name'],$contract['company_a_code']);
|
||||
$signContractEvidenceToPartyA = $signContractEvidenceToPartyA ?? '';
|
||||
$signContractEvidenceToPartyB = app(JunziqianController::class)->downloadVehicleContractEvidence($contract['contract_no'],$contract['company_b_name'],$contract['company_b_code']);
|
||||
$signContractEvidenceToPartyB = $signContractEvidenceToPartyB ?? '';
|
||||
$contractEvidence = json_encode([
|
||||
'party_a' => $signContractEvidenceToPartyA,
|
||||
'party_b' => $signContractEvidenceToPartyB
|
||||
]);
|
||||
//更新本地合同状态
|
||||
$updateLocalRes = VehicleContract::where('id',$contract['id'])->update(['signing_timer'=>2,'status' => 3,'contract_url'=>$signContractFile,'contract_evidence'=>$contractEvidence]);
|
||||
//判断是否有监管车辆
|
||||
$jgCars = VehicleRent::where('rent_company_id',$contract['company_b_id'])->where('status',2)->where('type',2)->findOrEmpty();
|
||||
if($jgCars->isEmpty()){
|
||||
//获取镇街公司信息
|
||||
$zjCompany = Contract::field('party_a')->where('party_b',$contract['company_b_id'])->where('signing_timer',2)->findOrEmpty();
|
||||
//将车辆加入到本地租赁列表
|
||||
$cars = json_decode($contract['cars_info'], true);
|
||||
//写入数据
|
||||
$data = [
|
||||
'car_id' => $cars[0]['id'],
|
||||
'car_license' => $cars[0]['license'],
|
||||
'type' => 2,
|
||||
'status' => 2,
|
||||
'company_id' => $zjCompany['party_a'],
|
||||
'rent_time' => time(),
|
||||
'rent_company_id' => $contract['company_b_id'],
|
||||
'contract_id' => $contract['id'],
|
||||
'create_time' => time()
|
||||
];
|
||||
$vehicleRent = new VehicleRent();
|
||||
$vehicleRent->save($data);
|
||||
}
|
||||
//获取签约公司信息
|
||||
$compay = Company::where('id',$contract['company_b_id'])->findOrEmpty();
|
||||
//更新远程
|
||||
$updateSverRes = curl_post(env('project.logistic_domain').'/api/contractUpdate',[],[
|
||||
'id' => $contract['contract_logistic_id'],
|
||||
'signing_timer' => 2,
|
||||
//更改租赁列表车辆状态
|
||||
$vehicle = json_decode($contract['cars_info'], true);
|
||||
//获取租赁车辆信息
|
||||
$vehicleRentInfo = VehicleRent::where('car_id', $vehicle['id'])->find();
|
||||
//更新原始合同类型
|
||||
VehicleContract::where('id', $vehicleRentInfo['contract_id'])->update(['status' => 6]);
|
||||
VehicleRent::where('car_id', $vehicle['id'])->update([
|
||||
'status' => 3,
|
||||
'contract_url'=>$signContractFile,
|
||||
'contract_evidence'=>$contractEvidence,
|
||||
'use_user_id' =>$compay['user_id'],
|
||||
'use_user_name' =>$compay['master_name'],
|
||||
'use_user_phone' =>$compay['master_phone'],
|
||||
'update_time' => time()
|
||||
]);
|
||||
if(!$updateLocalRes || $updateSverRes['code']==0){
|
||||
return json(['success' => false, 'msg' => '更新失败']);
|
||||
}else{
|
||||
return json(['success' => true, 'msg' => '更新成功']);
|
||||
}
|
||||
}else{
|
||||
//通知物流系统跟新
|
||||
curl_post(env('project.logistic_domain').'/api/cancelRent', [], [
|
||||
'car_id' => $vehicle['id'],
|
||||
'status' => 1
|
||||
]);
|
||||
return json(['success' => true, 'msg' => '成功']);
|
||||
} else {
|
||||
return json(['success' => true, 'msg' => '成功']);
|
||||
}
|
||||
}
|
||||
@ -824,24 +611,4 @@ class IndexController extends BaseApiController
|
||||
Db::name('company_authentication_fail_log')->insert(['company_id'=>$parmas['id'], 'log_type'=>3, 'fail_reason'=>$data['msg'], 'create_time'=>time()]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getCompanyBankInfo()
|
||||
{
|
||||
$parmas = $this->request->param();
|
||||
$company = Db::query("select company_name,qualification from la_company where company_type=:company_type and FIND_IN_SET(:street,responsible_area)", ['company_type' => 41,'street'=>$parmas['street_code']], true);
|
||||
|
||||
if (empty($company)) {
|
||||
return $this->success('成功', ['corporate_account'=> '22170201040004168', 'corporate_bank'=> '中国农业银行股份有限公司泸州石洞支行', 'company_name' => '泸州里海农业科技有限公司', 'corporate_bank_address'=> '泸州市龙马潭区张家祠东路竹林馨居东侧约60米']);
|
||||
}
|
||||
$company=$company[0];
|
||||
$company['qualification'] = json_decode($company['qualification'], true);
|
||||
|
||||
if (!empty($company['qualification']['corporate_account']) && !empty($company['qualification']['corporate_bank'])) {
|
||||
return $this->success('成功', ['corporate_account'=> $company['qualification']['corporate_account'], 'corporate_bank'=> $company['qualification']['corporate_bank'], 'company_name' => $company['company_name'], 'corporate_bank_address'=> $company['qualification']['corporate_bank_address'] ]);
|
||||
}
|
||||
|
||||
return $this->success('成功', ['corporate_account'=> '22170201040004168', 'corporate_bank'=> '中国农业银行股份有限公司泸州石洞支行', 'company_name' => '泸州里海农业科技有限公司', 'corporate_bank_address'=> '' ]);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -2,19 +2,14 @@
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\model\Company;
|
||||
use app\common\model\informationg\UserInformationg;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\informationg\UserInformationgDemand;
|
||||
use app\common\model\task\Task;
|
||||
use app\common\model\task_template\TaskTemplate;
|
||||
use app\common\model\user\User;
|
||||
use think\response\Json;
|
||||
|
||||
class InformationController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['groupServiceInfo','captainInfo','farmerInfo','farmerInfoByPhone','farmerLandInfo','farmerPondInfo','farmerList'];
|
||||
|
||||
public function list()
|
||||
{
|
||||
$param = Request()->param();
|
||||
@ -118,6 +113,7 @@ class InformationController extends BaseApiController
|
||||
}
|
||||
|
||||
UserInformationg::where('id', $param['id'])->update(['update_time' => time(), 'is_update' => 1]);
|
||||
|
||||
return $this->success('成功');
|
||||
}
|
||||
|
||||
@ -133,404 +129,4 @@ class InformationController extends BaseApiController
|
||||
}
|
||||
return $this->success('成功');
|
||||
}
|
||||
|
||||
//获取吓阻服务公司用户信息
|
||||
public function groupServiceInfo(): Json
|
||||
{
|
||||
//获取参数
|
||||
$params = $this->request->post(['user_id']);
|
||||
if(empty($params['user_id'])){
|
||||
return $this->fail('参数错误_worker');
|
||||
}
|
||||
$userData = User::field('id,company_id,nickname as name,avatar')->where('id',$params['user_id'])->findOrEmpty();
|
||||
if($userData->isEmpty()){
|
||||
return $this->fail('用户数据不存在');
|
||||
}
|
||||
$companyData = Company::field('id,company_name,company_type')->where('id',$userData['company_id'])->findOrEmpty();
|
||||
if($companyData->isEmpty() || $companyData['company_type'] != 18){
|
||||
return $this->fail('当前用户不是小组服务公司用户');
|
||||
}
|
||||
$userData['company_name'] = $companyData['company_name'];
|
||||
//获取小组服务公司下面的队长
|
||||
$captainList = User::field('id,nickname as name,avatar,province,province province_name,city,city city_name,area,area area_name,street,street street_name,village,village village_name,brigade,brigade brigade_name')->where('company_id',$userData['company_id'])->where('is_captain',1)->select()->each(function($item){
|
||||
$item['address'] = $item['province_name'].$item['city_name'].$item['area_name'].$item['street_name'].$item['village_name'].$item['brigade_name'];
|
||||
unset($item['province'],$item['province_name'],$item['city'],$item['city_name'],$item['area'],$item['area_name'],$item['street'],$item['street_name'],$item['village'],$item['village_name'],$item['brigade'],$item['brigade_name']);
|
||||
$farmerList = UserInformationg::where('create_user_id', $item['id'])->field('id')->select()->each(function($val){
|
||||
//获取农户档案详情
|
||||
$information = UserInformationgDemand::field('id,category_child,data')->where('information_id', $val['id'])->where('category_id',6)->where('category_child','in','7,32')->order('id', 'desc')->select()->toArray();
|
||||
//总面积
|
||||
$val['land_total_area'] = 0;
|
||||
$val['pond_total_area'] = 0;
|
||||
$val['animal_total_area'] = 0;
|
||||
$val['poultry_total_area'] = 0;
|
||||
//种养类型
|
||||
$val['is_zz_user'] = false;
|
||||
$val['is_sc_user'] = false;
|
||||
$val['is_jc_user'] = false;
|
||||
$val['is_jq_user'] = false;
|
||||
foreach($information as $v){
|
||||
if($v['category_child'] == 7){
|
||||
$val['is_zz_user'] = true;
|
||||
$val['land_total_area'] += floatval($v['data']['area']);
|
||||
}
|
||||
if($v['category_child'] == 32){
|
||||
if($v['data']['breeding_type'] == 1){//水产
|
||||
$val['is_sc_user'] = true;
|
||||
$val['pond_total_area'] += floatval($v['data']['area']);
|
||||
}elseif ($v['data']['breeding_type'] == 2) {//脯乳动物
|
||||
$val['is_jc_user'] = true;
|
||||
$val['animal_total_area'] += floatval($v['data']['area']);
|
||||
}elseif ($v['data']['breeding_type'] == 3){//家禽
|
||||
$val['is_jq_user'] = true;
|
||||
$val['poultry_total_area'] += floatval($v['data']['area']);
|
||||
}
|
||||
}
|
||||
}
|
||||
$val['total_area'] = $val['land_total_area'] + $val['pond_total_area'] + $val['animal_total_area'] + $val['poultry_total_area'];
|
||||
return $val;
|
||||
})->toArray();
|
||||
$item['farmer_total'] = count($farmerList);
|
||||
$item['farmer_area'] = array_sum(array_column($farmerList,'total_area'));
|
||||
$item['farmer_zz_total'] = 0;
|
||||
$item['farmer_sc_total'] = 0;
|
||||
$item['farmer_jc_total'] = 0;
|
||||
$item['farmer_jq_total'] = 0;
|
||||
$item['farmer_zz_area'] = 0;
|
||||
$item['farmer_sc_area'] = 0;
|
||||
$item['farmer_jc_area'] = 0;
|
||||
$item['farmer_jq_area'] = 0;
|
||||
foreach($farmerList as $v){
|
||||
if($v['is_zz_user']){
|
||||
$item['farmer_zz_total'] += 1;
|
||||
}
|
||||
if($v['is_sc_user']){
|
||||
$item['farmer_sc_total'] += 1;
|
||||
}
|
||||
if($v['is_jc_user']){
|
||||
$item['farmer_jc_total'] += 1;
|
||||
}
|
||||
if($v['is_jq_user']){
|
||||
$item['farmer_jq_total'] += 1;
|
||||
}
|
||||
$item['farmer_zz_area'] += $v['land_total_area'];
|
||||
$item['farmer_sc_area'] += $v['pond_total_area'];
|
||||
$item['farmer_jc_area'] += $v['animal_total_area'];
|
||||
$item['farmer_jq_area'] += $v['poultry_total_area'];
|
||||
}
|
||||
return $item;
|
||||
})->toArray();
|
||||
$userData['captain_list'] = $captainList;
|
||||
return $this->success('请求成功',$userData->toArray());
|
||||
}
|
||||
|
||||
//获取生产队长信息
|
||||
public function captainInfo(): Json
|
||||
{
|
||||
//获取参数
|
||||
$params = $this->request->post(['user_id']);
|
||||
if(empty($params['user_id'])){
|
||||
return $this->fail('参数错误_worker');
|
||||
}
|
||||
$userData = User::field('id,nickname as name,avatar,province,province province_name,city,city city_name,area,area area_name,street,street street_name,village,village village_name,brigade,brigade brigade_name')->where('id',$params['user_id'])->where('is_captain',1)->findOrEmpty();
|
||||
if($userData->isEmpty()){
|
||||
return $this->fail('用户数据不存在');
|
||||
}
|
||||
$userData['address'] = $userData['province_name'].$userData['city_name'].$userData['area_name'].$userData['street_name'].$userData['village_name'].$userData['brigade_name'];
|
||||
unset($userData['province'],$userData['province_name'],$userData['city'],$userData['city_name'],$userData['area'],$userData['area_name'],$userData['street'],$userData['street_name'],$userData['village'],$userData['village_name'],$userData['brigade'],$userData['brigade_name']);
|
||||
//获取生产队长下面的农户
|
||||
$farmerList = UserInformationg::where('create_user_id', $params['user_id'])->field('id,name,phone,area_id,street_id,village_id,brigade_id,area_id area_name,street_id street_name,village_id village_name,brigade_id brigade_name')->select()->each(function($item){
|
||||
$item['address'] = $item['area_name'].$item['street_name'].$item['village_name'].$item['brigade_name'];
|
||||
unset($item['area_id'],$item['area_name'],$item['street_id'],$item['street_name'],$item['village_id'],$item['village_name'],$item['brigade_id'],$item['brigade_name']);
|
||||
//获取农户档案详情
|
||||
$information = UserInformationgDemand::field('id,category_child,data')->where('information_id', $item['id'])->where('category_id',6)->where('category_child','in','7,32')->order('id', 'desc')->select()->toArray();
|
||||
//总面积
|
||||
$item['land_total_area'] = 0;
|
||||
$item['pond_total_area'] = 0;
|
||||
$item['animal_total_area'] = 0;
|
||||
$item['poultry_total_area'] = 0;
|
||||
//种养类型
|
||||
$item['is_zz_user'] = false;
|
||||
$item['is_sc_user'] = false;
|
||||
$item['is_jc_user'] = false;
|
||||
$item['is_jq_user'] = false;
|
||||
foreach($information as $v){
|
||||
if($v['category_child'] == 7){
|
||||
$item['is_zz_user'] = true;
|
||||
$item['land_total_area'] += floatval($v['data']['area']);
|
||||
}
|
||||
if($v['category_child'] == 32){
|
||||
if($v['data']['breeding_type'] == 1){//水产
|
||||
$item['is_sc_user'] = true;
|
||||
$item['pond_total_area'] += floatval($v['data']['area']);
|
||||
}elseif ($v['data']['breeding_type'] == 2) {//脯乳动物
|
||||
$item['is_jc_user'] = true;
|
||||
$item['animal_total_area'] += floatval($v['data']['area']);
|
||||
}elseif ($v['data']['breeding_type'] == 3){//家禽
|
||||
$item['is_jq_user'] = true;
|
||||
$item['poultry_total_area'] += floatval($v['data']['area']);
|
||||
}
|
||||
}
|
||||
}
|
||||
$item['total_area'] = $item['land_total_area'] + $item['pond_total_area'] + $item['animal_total_area'] + $item['poultry_total_area'];
|
||||
return $item;
|
||||
})->toArray();
|
||||
$userData['farmer_total'] = count($farmerList);
|
||||
$userData['farmer_area'] = array_sum(array_column($farmerList,'total_area'));
|
||||
$userData['farmer_zz_total'] = 0;
|
||||
$userData['farmer_sc_total'] = 0;
|
||||
$userData['farmer_jc_total'] = 0;
|
||||
$userData['farmer_jq_total'] = 0;
|
||||
$userData['farmer_zz_area'] = 0;
|
||||
$userData['farmer_sc_area'] = 0;
|
||||
$userData['farmer_jc_area'] = 0;
|
||||
$userData['farmer_jq_area'] = 0;
|
||||
foreach($farmerList as $v){
|
||||
if($v['is_zz_user']){
|
||||
$userData['farmer_zz_total'] += 1;
|
||||
}
|
||||
if($v['is_sc_user']){
|
||||
$userData['farmer_sc_total'] += 1;
|
||||
}
|
||||
if($v['is_jc_user']){
|
||||
$userData['farmer_jc_total'] += 1;
|
||||
}
|
||||
if($v['is_jq_user']){
|
||||
$userData['farmer_jq_total'] += 1;
|
||||
}
|
||||
$userData['farmer_zz_area'] += $v['land_total_area'];
|
||||
$userData['farmer_sc_area'] += $v['pond_total_area'];
|
||||
$userData['farmer_jc_area'] += $v['animal_total_area'];
|
||||
$userData['farmer_jq_area'] += $v['poultry_total_area'];
|
||||
}
|
||||
$userData['farmer_list'] = $farmerList;
|
||||
return $this->success('请求成功',$userData->toArray());
|
||||
}
|
||||
|
||||
//获取农户信息,该接口溯源系统调用
|
||||
public function farmerInfo(): Json
|
||||
{
|
||||
//获取参数
|
||||
$params = $this->request->post(['user_id']);
|
||||
if(empty($params['user_id'])){
|
||||
return $this->fail('参数错误_worker');
|
||||
}
|
||||
//获取农户信息
|
||||
$farmerInfo = UserInformationg::alias('f')
|
||||
->leftJoin('company c','f.company_id = c.id')
|
||||
->leftJoin('user u','u.id = f.create_user_id')
|
||||
->leftJoin('user g','g.id = c.user_id')
|
||||
->where('f.id', $params['user_id'])
|
||||
->field('f.id,f.create_user_id,f.company_id,f.name,f.phone,f.area_id,f.street_id,f.village_id,f.brigade_id,f.area_id area_name,f.street_id street_name,f.village_id village_name,f.brigade_id brigade_name,c.company_name,f.address,u.nickname as captain_name,g.nickname as group_name')
|
||||
->findOrEmpty()->toArray();
|
||||
if(empty($farmerInfo)){
|
||||
return $this->fail('用户不存在_worker');
|
||||
}
|
||||
unset($farmerInfo['area_id'],$farmerInfo['street_id'],$farmerInfo['village_id'],$farmerInfo['brigade_id']);
|
||||
$data = UserInformationgDemand::field('id,category_child,data')->where('information_id', $params['user_id'])->where('category_id',6)->where('category_child','in','7,32')->order('id', 'desc')->select()->toArray();
|
||||
//是否是种植户
|
||||
$farmerInfo['is_zz_user'] = false;
|
||||
//是否是水产养殖户
|
||||
$farmerInfo['is_sc_user'] = false;
|
||||
//是否是家禽养殖户
|
||||
$farmerInfo['is_jq_user'] = false;
|
||||
//是否是大型动物养殖户
|
||||
$farmerInfo['is_dw_user'] = false;
|
||||
//土地总面积
|
||||
$farmerInfo['total_land_area'] = 0;
|
||||
//池塘总面积
|
||||
$farmerInfo['total_pond_area'] = 0;
|
||||
//家禽养殖场总面积
|
||||
$farmerInfo['total_henhouse_area'] = 0;
|
||||
//动物养殖场总面积
|
||||
$farmerInfo['total_pasture_area'] = 0;
|
||||
foreach($data as $v){
|
||||
if($v['category_child'] == 7){
|
||||
$farmerInfo['is_zz_user'] = true;
|
||||
$farmerInfo['total_land_area'] += floatval($v['data']['area']);
|
||||
$farmerInfo['land_detail'][] = [
|
||||
'land_id' => $v['id'],
|
||||
'land_area' => $v['data']['area'],
|
||||
'land_notes' => $v['data']['notes'],
|
||||
];
|
||||
}
|
||||
if($v['category_child'] == 32){
|
||||
if($v['data']['breeding_type'] == 1){//水产
|
||||
$farmerInfo['is_sc_user'] = true;
|
||||
$farmerInfo['total_pond_area'] += floatval($v['data']['area']);
|
||||
$farmerInfo['pond_detail'][] = [
|
||||
'pond_id' => $v['id'],
|
||||
'pond_area' => $v['data']['area'],
|
||||
'pond_notes' => $v['data']['notes'],
|
||||
];
|
||||
}elseif ($v['data']['breeding_type'] == 2) {//脯乳动物
|
||||
$farmerInfo['is_jq_user'] = true;
|
||||
$farmerInfo['total_henhouse_area'] += floatval($v['data']['area']);
|
||||
}elseif ($v['data']['breeding_type'] == 3){//家禽
|
||||
$farmerInfo['is_dw_user'] = true;
|
||||
$farmerInfo['total_pasture_area'] += floatval($v['data']['area']);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->success('请求成功',$farmerInfo);
|
||||
}
|
||||
|
||||
//通过手机号码查找农户
|
||||
public function farmerInfoByPhone(): Json
|
||||
{
|
||||
$params = $this->request->post(['phone']);
|
||||
if(empty($params['phone'])){
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
$data = UserInformationg::where('phone',$params['phone'])
|
||||
->field('id,name,phone,area_id,street_id,village_id,brigade_id,area_id area_name,street_id street_name,village_id village_name,brigade_id brigade_name,address')
|
||||
->findOrEmpty();
|
||||
return !$data->isEmpty() ? $this->success('请求成功',$data->toArray()) : $this->fail('请求失败');
|
||||
}
|
||||
|
||||
//获取农户土地信息
|
||||
public function farmerLandInfo(): Json
|
||||
{
|
||||
//获取参数
|
||||
$params = $this->request->post(['user_id','land_id']);
|
||||
if(empty($params['user_id']) || empty($params['land_id'])){
|
||||
return $this->fail('参数错误_worker');
|
||||
}
|
||||
//获取农户信息
|
||||
$data = UserInformationgDemand::field('id,data')->where('id',$params['land_id'])->where('information_id', $params['user_id'])->where('category_id',6)->where('category_child',7)->findOrEmpty()->toArray();
|
||||
if(empty($data)){
|
||||
return $this->fail('数据不存在_worker');
|
||||
}
|
||||
$resData = [
|
||||
'land_id' => $data['id'],
|
||||
'land_area' => $data['data']['area']
|
||||
];
|
||||
return $this->success('请求成功',$resData);
|
||||
}
|
||||
|
||||
//获取农户鱼塘信息
|
||||
public function farmerPondInfo(): Json
|
||||
{
|
||||
//获取参数
|
||||
$params = $this->request->post(['user_id','pond_id']);
|
||||
if(empty($params['user_id']) || empty($params['pond_id'])){
|
||||
return $this->fail('参数错误_worker');
|
||||
}
|
||||
//获取农户信息
|
||||
$data = UserInformationgDemand::field('id,data')->where('id',$params['pond_id'])->where('information_id', $params['user_id'])->where('category_id',6)->where('category_child',32)->findOrEmpty()->toArray();
|
||||
if(empty($data) || empty($data['data'])){
|
||||
return $this->fail('数据不存在_worker');
|
||||
}
|
||||
if($data['data']['breeding_type'] != 1){
|
||||
return $this->fail('数据错误_work');
|
||||
}
|
||||
$resData = [
|
||||
'pond_id' => $data['id'],
|
||||
'pond_area' => $data['data']['area']
|
||||
];
|
||||
return $this->success('请求成功',$resData);
|
||||
}
|
||||
|
||||
//获取农户列表
|
||||
public function farmerList(): Json
|
||||
{
|
||||
$params = $this->request->post(['farmer_name','farmer_phone','group_name','captain_name','page_no','page_size']);
|
||||
if(empty($params['page_no']) || empty($params['page_size'])){
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
$search = [];
|
||||
if(!empty($params['farmer_name'])){
|
||||
$search[] = ['f.name','like','%'.$params['farmer_name'].'%'];
|
||||
}
|
||||
if(!empty($params['farmer_phone'])){
|
||||
$search[] = ['f.phone','like','%'.$params['farmer_phone'].'%'];
|
||||
}
|
||||
if(!empty($params['group_name'])){
|
||||
$search[] = ['g.nickname','like','%'.$params['group_name'].'%'];
|
||||
}
|
||||
if(!empty($params['captain_name'])){
|
||||
$search[] = ['u.nickname','like','%'.$params['captain_name'].'%'];
|
||||
}
|
||||
$data = UserInformationg::alias('f')
|
||||
->field('f.id,f.create_user_id,f.company_id,f.name,f.phone,f.area_id,f.street_id,f.village_id,f.brigade_id,c.company_name,u.nickname as captain_name,g.nickname as group_name,f.area_id area_name,f.street_id street_name,f.village_id village_name,f.brigade_id brigade_name,f.address')
|
||||
->leftJoin('company c','f.company_id = c.id')
|
||||
->leftJoin('user u','u.id = f.create_user_id')
|
||||
->leftJoin('user g','g.id = c.user_id')
|
||||
->where($search)
|
||||
->page($params['page_no'],$params['page_size'])->order('id desc')->select()
|
||||
->each(function($item){
|
||||
$item['address'] = $item['area_name'].$item['street_name'].$item['village_name'].$item['brigade_name'].$item['address'];
|
||||
unset($item['area_name'],$item['street_name'],$item['village_name'],$item['brigade_name'],$item['area_id'],$item['street_id'],$item['village_id'],$item['brigade_id']);
|
||||
$userInformationgDemand = UserInformationgDemand::field('id,category_child,data')->where('information_id', $item['id'])->where('category_id',6)->where('category_child','in','7,32')->order('id', 'desc')->select()->toArray();
|
||||
//是否是种植户
|
||||
$is_zz_user = false;
|
||||
//是否是水产养殖户
|
||||
$is_sc_user = false;
|
||||
//是否是家禽养殖户
|
||||
$is_jq_user = false;
|
||||
//是否是大型动物养殖户
|
||||
$is_dw_user = false;
|
||||
//土地总面积
|
||||
$total_land_area = 0;
|
||||
//池塘总面积
|
||||
$total_pond_area = 0;
|
||||
//家禽养殖场总面积
|
||||
$total_henhouse_area = 0;
|
||||
//动物养殖场总面积
|
||||
$total_pasture_area = 0;
|
||||
foreach($userInformationgDemand as $v){
|
||||
if($v['category_child'] == 7){
|
||||
$is_zz_user = true;
|
||||
$total_land_area += floatval($v['data']['area']);
|
||||
}
|
||||
if($v['category_child'] == 32){
|
||||
if($v['data']['breeding_type'] == 1){//水产
|
||||
$is_sc_user = true;
|
||||
$total_pond_area += floatval($v['data']['area']);
|
||||
}elseif ($v['data']['breeding_type'] == 2) {//脯乳动物
|
||||
$is_jq_user = true;
|
||||
$total_henhouse_area += floatval($v['data']['area']);
|
||||
}elseif ($v['data']['breeding_type'] == 3){//家禽
|
||||
$is_dw_user = true;
|
||||
$total_pasture_area += floatval($v['data']['area']);
|
||||
}
|
||||
}
|
||||
}
|
||||
$str = [];
|
||||
$area = [];
|
||||
if($is_zz_user){
|
||||
$str[] = '种植户';
|
||||
$area[] = $total_land_area;
|
||||
}
|
||||
if($is_sc_user){
|
||||
$str[] = '水产养殖户';
|
||||
$area[] = $total_pond_area;
|
||||
}
|
||||
if($is_jq_user){
|
||||
$str[] = '家禽养殖户';
|
||||
$area[] = $total_henhouse_area;
|
||||
}
|
||||
if($is_dw_user){
|
||||
$str[] = '家畜养殖户';
|
||||
$area[] = $total_pasture_area;
|
||||
}
|
||||
$item['farmer_type'] = implode('/',$str);
|
||||
$item['farmer_area'] = implode('/',$area);
|
||||
return $item;
|
||||
})->toArray();
|
||||
$count = UserInformationg::alias('f')
|
||||
->field('f.id,f.create_user_id,f.company_id,f.name,f.phone,f.area_id,f.street_id,f.village_id,f.brigade_id,c.company_name,u.nickname as captain_name,g.nickname as group_name,f.area_id area_name,f.street_id street_name,f.village_id village_name,f.brigade_id brigade_name,f.address')
|
||||
->leftJoin('company c','f.company_id = c.id')
|
||||
->leftJoin('user u','u.id = f.create_user_id')
|
||||
->leftJoin('user g','g.id = c.user_id')
|
||||
->where($search)
|
||||
->count();
|
||||
$result = [
|
||||
'count' => $count,
|
||||
'page_no' => $params['page_no'],
|
||||
'page_size' => $params['page_size'],
|
||||
'lists' => $data
|
||||
];
|
||||
return $this->success('请求成功',$result);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -14,8 +14,6 @@
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\cache\UserTokenCache;
|
||||
use app\common\model\Company;
|
||||
use app\api\validate\{LoginAccountValidate, RegisterValidate, WebScanLoginValidate, WechatLoginValidate};
|
||||
use app\api\logic\LoginLogic;
|
||||
use app\api\logic\UserLogic;
|
||||
@ -34,7 +32,7 @@ use app\common\service\FileService;
|
||||
class LoginController extends BaseApiController
|
||||
{
|
||||
|
||||
public array $notNeedLogin = ['register', 'account', 'logout', 'codeUrl', 'oaLogin', 'mnpLogin', 'getScanCode', 'scanLogin', 'shop_account','checkToken', 'parseToken'];
|
||||
public array $notNeedLogin = ['register', 'account', 'logout', 'codeUrl', 'oaLogin', 'mnpLogin', 'getScanCode', 'scanLogin', 'shop_account'];
|
||||
|
||||
|
||||
/**
|
||||
@ -257,36 +255,4 @@ class LoginController extends BaseApiController
|
||||
LoginLogic::updateUser($params, $this->userId);
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
|
||||
public function checkToken(): \think\response\Json
|
||||
{
|
||||
$token = $this->request->post('token');
|
||||
if(empty($token)){
|
||||
return $this->fail('token参数错误');
|
||||
}
|
||||
$userInfo = (new UserTokenCache())->getUserInfo($token);
|
||||
if(!$userInfo){
|
||||
return $this->fail('token无效');
|
||||
}
|
||||
//获取公司信息
|
||||
$company = Company::field('company_name,company_type')->where('id',$userInfo['company_id'])->findOrEmpty();
|
||||
if(!$company->isEmpty()){
|
||||
$userInfo['company_name'] = $company['company_name'];
|
||||
$userInfo['company_type'] = $company['company_type'];
|
||||
}
|
||||
return $this->success('请求成功', $userInfo);
|
||||
}
|
||||
|
||||
public function parseToken()
|
||||
{
|
||||
$token = $this->request->post('token');
|
||||
if(empty($token)){
|
||||
return $this->fail('token参数不能为空');
|
||||
}
|
||||
$result = LoginLogic::parseToken($token);
|
||||
if (false === $result) {
|
||||
return $this->fail(LoginLogic::getError() ?? '登录失败');
|
||||
}
|
||||
return $this->success('请求成功', $result);
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ namespace app\api\controller;
|
||||
use app\api\lists\recharge\RechargeLists;
|
||||
use app\api\logic\RechargeLogic;
|
||||
use app\api\validate\RechargeValidate;
|
||||
use app\common\model\company\CompanyAccountLog;
|
||||
|
||||
|
||||
/**
|
||||
* 充值控制器
|
||||
@ -36,18 +36,6 @@ class RechargeController extends BaseApiController
|
||||
{
|
||||
return $this->dataLists(new RechargeLists());
|
||||
}
|
||||
public function deposit_lists()
|
||||
{
|
||||
$params=$this->request->param();
|
||||
$list=CompanyAccountLog::where('company_id',$this->userInfo['company_id'])->page($params['page_no'],15)->order('id', 'desc')->select();
|
||||
$datas=[];
|
||||
foreach($list as $k=>$v){
|
||||
$datas[$k]['create_time']=$v['create_time'];
|
||||
$datas[$k]['order_amount']=$v['change_amount'];
|
||||
$datas[$k]['tips']='押金充值'.$v['change_amount'];
|
||||
}
|
||||
return $this->success('ok',['count'=>0,'extend'=>[],'lists'=>$datas,'page_no'=>$params['page_no'],'page_size'=>$params['page_size']]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -208,7 +208,6 @@ class RemoteController extends BaseApiController
|
||||
/**
|
||||
*
|
||||
* 计算两点之间的距离
|
||||
* 返回米
|
||||
*/
|
||||
function calculateDistance($longitude1, $latitude1, $longitude2, $latitude2)
|
||||
{
|
||||
@ -221,6 +220,7 @@ class RemoteController extends BaseApiController
|
||||
cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) *
|
||||
sin($dLon / 2) * sin($dLon / 2);
|
||||
$c = 2 * asin(sqrt($a));
|
||||
return round($earthRadius * $c*1000) ;
|
||||
|
||||
return $earthRadius * $c * 100;
|
||||
}
|
||||
}
|
||||
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\logic\task\TaskLogic;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\model\task\Task;
|
||||
use app\common\model\task_template\TaskTemplate;
|
||||
use think\Exception;
|
||||
use think\facade\Db;
|
||||
use think\facade\Log;
|
||||
|
||||
/**
|
||||
* 商城主动调用接口类
|
||||
*/
|
||||
class ShopCallController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['getVillageCompany'];
|
||||
public function getVillageCompany()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
$geoVillage = Db::name('geo_village')->where('village_id', $param['village_id'])->find();
|
||||
$company = Company::where(['village' =>$geoVillage['village_code'], 'company_type'=>17])->find();
|
||||
$find= Admin::where('id', $company['admin_id'])->field('avatar,id_card')->find();
|
||||
if($find){
|
||||
$company['avatar']=$find['avatar'];
|
||||
$company['id_card']=$find['id_card'];
|
||||
}else{
|
||||
$company['avatar']='';
|
||||
$company['id_card']='';
|
||||
}
|
||||
return $this->success('成功', compact('company'));
|
||||
}
|
||||
}
|
@ -6,55 +6,36 @@ use app\common\logic\task\TaskLogic;
|
||||
use app\common\model\Approve;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\company\CompanyProperty;
|
||||
use app\common\model\contract\Contract;
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\model\flow\Flow;
|
||||
use app\common\model\informationg\UserInformationg;
|
||||
use app\common\model\task\Task;
|
||||
use app\common\model\task_template\TaskTemplate;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\vehicle\VehicleRent;
|
||||
use think\Exception;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
class TaskController extends BaseApiController
|
||||
{
|
||||
|
||||
public function lists()
|
||||
{
|
||||
$param = Request()->param();
|
||||
[$page, $limit] = $this->getPage();
|
||||
$time = strtotime(date('Y-m-d'));
|
||||
$userCompanyInfo = Company::where('id', $this->userInfo['company_id'])->find();
|
||||
$where = [];
|
||||
// 公司负责人直接看公司的全部任务
|
||||
if ($this->userInfo['admin_id'] != 0) {
|
||||
$where[] = ['company_id', '=', $this->userInfo['company_id']];
|
||||
} else {
|
||||
// 其他角色看个人的任务
|
||||
if ($userCompanyInfo['company_type'] == 18) {
|
||||
$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];
|
||||
// }
|
||||
$where[] = ['company_id', '=', $this->userInfo['company_id']];
|
||||
}
|
||||
|
||||
if ($userCompanyInfo['company_type'] == 16) {
|
||||
$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];
|
||||
// $where[] = ['company_id', '=', $this->userInfo['company_id']];
|
||||
}
|
||||
if ($userCompanyInfo['company_type'] == 17) {
|
||||
$where[] = ['director_uid', '=', $this->userId];
|
||||
// $where[] = ['company_id', '=', $this->userInfo['company_id']];
|
||||
}
|
||||
$where[] = ['company_id', '=', $this->userInfo['company_id']];
|
||||
}
|
||||
|
||||
|
||||
if (isset($param['date_time']) && $param['date_time'] != '') {
|
||||
$time = strtotime($param['date_time']);
|
||||
$param['start_time']=date('Y-m-d H:i:s',$time);
|
||||
@ -73,36 +54,12 @@ class TaskController extends BaseApiController
|
||||
if (isset($param['status']) && $param['status'] > 0) {
|
||||
$where[] = ['status', '=', $param['status']];
|
||||
}
|
||||
$serviceGroupTaskTypeList = DictData::where(['type_value' => 'task_type', 'status' => 1])->column('value', 'id');
|
||||
$villageTaskTypeList = DictData::where(['type_value' => 'village_task_type', 'status' => 1])->column('value', 'id');
|
||||
$townTaskTypeList = DictData::where(['type_value' => 'town_task_type', 'status' => 1])->column('value', 'id');
|
||||
$townMarketingManagerTaskTypeList = DictData::where(['type_value' => 'town_task_type_marketing_director', 'status' => 1])->column('value', 'id');
|
||||
$townMasterTaskTypeList = DictData::where(['type_value' => 'town_task_type_master', 'status' => 1])->column('value', 'id');
|
||||
|
||||
$res = Task::where($where)
|
||||
->with(['directorInfo'])
|
||||
->field(['id', 'title', 'money', 'template_id', 'director_uid', 'company_id', 'start_time', 'end_time', 'type', 'status', 'content', 'extend'])
|
||||
->field(['id', 'title', 'money', 'template_id', 'director_uid', 'company_id', 'start_time', 'end_time', 'director_uid', 'type', 'status', 'content', 'extend'])
|
||||
->page($page, 25)
|
||||
->order(['id' => 'desc', 'status' => 'asc'])
|
||||
->select()->toArray();
|
||||
foreach ($res as $k => $item) {
|
||||
$res[$k]['task_type_value'] = '';
|
||||
if (isset($serviceGroupTaskTypeList[$item['type']])) {
|
||||
$res[$k]['task_type_value'] = $serviceGroupTaskTypeList[$item['type']];
|
||||
}
|
||||
if (isset($villageTaskTypeList[$item['type']])) {
|
||||
$res[$k]['task_type_value'] = $villageTaskTypeList[$item['type']];
|
||||
}
|
||||
if (isset($townTaskTypeList[$item['type']])) {
|
||||
$res[$k]['task_type_value'] = $townTaskTypeList[$item['type']];
|
||||
}
|
||||
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(); // 可能要判断预存金是否满足
|
||||
$find = App(RemoteController::class)->shang_date_total_price($company,$param,$item['template_id']);
|
||||
@ -121,71 +78,7 @@ class TaskController extends BaseApiController
|
||||
$res[$k]['extend']['transaction'] = '';
|
||||
}
|
||||
}
|
||||
if (isset($townTaskTypeList[$item['type']])) {
|
||||
if ($townTaskTypeList[$item['type']] == 'town_task_type_1') {
|
||||
// 协助总负责人开展工作任务
|
||||
$groupServiceCompanyCount = 0; // 已安排任务的小组服务公司总数
|
||||
$notDoneTaskGroupServiceCompanyCount = 0; // 未完成每日任务的小组服务公司总数
|
||||
|
||||
$townCompany = Company::where(['id' => $item['company_id']])->find();
|
||||
$groupServiceCompanyList = Company::where(['street' => $townCompany['street'], 'company_type' => 18])->select()->toArray();
|
||||
foreach ($groupServiceCompanyList as $groupServiceCompany) {
|
||||
// 小组服务公司是否有对应的每日任务安排
|
||||
$templateList = TaskTemplate::where(['company_id' => $groupServiceCompany['id']])->whereIn('type', [31, 32, 33])->select()->toArray();
|
||||
|
||||
if(count($templateList) === 3) {
|
||||
$groupServiceCompanyCount += 1;
|
||||
foreach ($templateList as $template) {
|
||||
$task = Task::where(['template_id' => $template['id'], 'status' => 3])->find();
|
||||
if (empty($task)) {
|
||||
$notDoneTaskGroupServiceCompanyCount += 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$res[$k]['extend'] = ['total' => $groupServiceCompanyCount, 'not_done_count' => $notDoneTaskGroupServiceCompanyCount];
|
||||
}
|
||||
if ($townTaskTypeList[$item['type']] == 'town_task_type_2') {
|
||||
// 拓展小组服务团队工作任务
|
||||
$contractCount = 15; // 小组服务合同总数
|
||||
$doneContractCount = 0; // 已完成小组服务合同数
|
||||
$townCompany = Company::where(['id' => $item['company_id']])->find();
|
||||
$doneContractCount = Contract::where(['party_a' => $townCompany['id'], 'status' => 1, 'contract_type' => 25])->count();
|
||||
$res[$k]['extend'] = ['total' => $contractCount, 'done_count' => $doneContractCount];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($townMarketingManagerTaskTypeList[$item['type']])) {
|
||||
// 数字农贸宣传、加工业务建设和招商任务 返回给前端当前任务模板进行到哪个阶段
|
||||
// 每个阶段不同,前台展示不同的资料上传页面,上传走审批接口
|
||||
if ($townMarketingManagerTaskTypeList[$item['type']] == 'town_task_type_marketing_director_10') {
|
||||
$templateInfo = TaskTemplate::where(['id' => $item['template_id']])->find();
|
||||
$dayCount = $templateInfo['day_count'];
|
||||
$stageDayOne = $templateInfo['stage_day_one'];
|
||||
$stageDayTwoCount = bcadd($templateInfo['stage_day_one'], $templateInfo['stage_day_two']);
|
||||
$stageDayThreeCount = bcadd($templateInfo['stage_day_three'], $stageDayTwoCount);
|
||||
// 第一阶段
|
||||
if ($dayCount < $stageDayOne) {
|
||||
$res[$k]['stage'] = 1;
|
||||
}
|
||||
// 第二阶段
|
||||
if ($dayCount > $stageDayOne && $dayCount <= $stageDayTwoCount) {
|
||||
$res[$k]['stage'] = 2;
|
||||
}
|
||||
// 第三阶段
|
||||
if ($dayCount > $stageDayTwoCount && $dayCount <= $stageDayThreeCount) {
|
||||
$res[$k]['stage'] = 3;
|
||||
}
|
||||
// 第四阶段
|
||||
if ($dayCount > $stageDayThreeCount) {
|
||||
$res[$k]['stage'] = 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->success('ok', $res);
|
||||
}
|
||||
|
||||
@ -230,12 +123,6 @@ class TaskController extends BaseApiController
|
||||
public function shareholder(){
|
||||
$parmas = $this->request->param();
|
||||
$task = TaskLogic::detail($parmas);
|
||||
$extend = $task['extend'];
|
||||
if (isset($extend['is_commit']) && $extend['is_commit'] == 1) {
|
||||
$approve = Approve::where(['task_id' =>$task['id']])->order('id', 'desc')->find();
|
||||
$task['approve_status'] = $approve['check_status']; //审核状态
|
||||
$task['deny_notes'] = $approve['remark']; // 拒绝原因
|
||||
}
|
||||
return $this->success('ok', $task);
|
||||
}
|
||||
/**
|
||||
@ -255,20 +142,15 @@ class TaskController extends BaseApiController
|
||||
{
|
||||
$parmas = $this->request->param();
|
||||
$task = Task::where('id', $parmas['id'])->find()->toArray();
|
||||
$VehicleRent = VehicleRent::where('rent_company_id', $this->userInfo['company_id'])->find();
|
||||
if(empty($VehicleRent)){
|
||||
self::setError('该公司没有三轮车,请先租赁三轮车');
|
||||
return false;
|
||||
$object_id=CompanyProperty::where('company_id',$this->userInfo['company_id'])->value('object_id');
|
||||
if(!$object_id){
|
||||
return $this->fail('该公司没有三轮车,请先租赁三轮车');
|
||||
}
|
||||
// $object_id=CompanyProperty::where('company_id',$this->userInfo['company_id'])->value('object_id');
|
||||
// if(!$object_id){
|
||||
// return $this->fail('该公司没有三轮车,请先租赁三轮车');
|
||||
// }
|
||||
$start_time = date('Y-m-d');
|
||||
$time=strtotime($start_time)+86399;
|
||||
$end_time=date('Y-m-d H:i:s',$time);
|
||||
$datas=[
|
||||
'car_id'=>$VehicleRent['car_id'],
|
||||
'car_id'=>$object_id,
|
||||
'start_time'=>$start_time.' 00:00:00',
|
||||
'end_time'=>$end_time
|
||||
];
|
||||
@ -277,13 +159,9 @@ class TaskController extends BaseApiController
|
||||
if( $parmas['terminus']['lnglat'][0]==null || $parmas['terminus']['lnglat'][0]<=0){
|
||||
return $this->fail('定位不存在');
|
||||
}
|
||||
$res = App(RemoteController::class)->calculateDistance($task['extend']['terminus']['lnglat'][0],$task['extend']['terminus']['lnglat'][1], $parmas['terminus']['lnglat'][0], $parmas['terminus']['lnglat'][1]);
|
||||
if($res>200){
|
||||
return $this->fail('定位坐标大于200米,请重新打卡。'.$res.'米');
|
||||
}
|
||||
$res_two = App(RemoteController::class)->coordinate($datas, $parmas['terminus']['lnglat'][0], $parmas['terminus']['lnglat'][1]);
|
||||
$res = App(RemoteController::class)->coordinate($datas, $parmas['terminus']['lnglat'][0], $parmas['terminus']['lnglat'][1]);
|
||||
if($res===false){
|
||||
return $this->fail('GPS无轨迹');
|
||||
return $this->fail('定位不存在|或GPS无轨迹');
|
||||
}
|
||||
$task['extend']['update']['terminus'] = $parmas['terminus'];
|
||||
}
|
||||
@ -291,25 +169,21 @@ class TaskController extends BaseApiController
|
||||
if( $parmas['transfer']['lnglat'][0]==null || $parmas['transfer']['lnglat'][0]<=0){
|
||||
return $this->fail('定位不存在');
|
||||
}
|
||||
$res = App(RemoteController::class)->calculateDistance($task['extend']['transfer']['lnglat'][0],$task['extend']['transfer']['lnglat'][1], $parmas['transfer']['lnglat'][0], $parmas['transfer']['lnglat'][1]);
|
||||
if($res>200){
|
||||
return $this->fail('定位坐标大于200米,请重新打卡。'.$res.'米');
|
||||
}
|
||||
$res_two = App(RemoteController::class)->coordinate($datas, $parmas['transfer']['lnglat'][0], $parmas['transfer']['lnglat'][1]);
|
||||
$res = App(RemoteController::class)->coordinate($datas, $parmas['transfer']['lnglat'][0], $parmas['transfer']['lnglat'][1]);
|
||||
if($res===false){
|
||||
return $this->fail('GPS无轨迹');
|
||||
return $this->fail('定位不存在|或GPS无轨迹');
|
||||
}
|
||||
$task['extend']['update']['transfer'] = $parmas['transfer'];
|
||||
}
|
||||
if (isset($task['extend']['update']['terminus']) && isset($task['extend']['update']['transfer'])) {
|
||||
$data['status'] = 3;
|
||||
}
|
||||
if($res_two<1000){
|
||||
if($res<100){
|
||||
$data['extend'] = json_encode($task['extend']);
|
||||
Task::where('id', $parmas['id'])->update($data);
|
||||
return $this->success('更新成功');
|
||||
}
|
||||
return $this->fail('定位坐标大于200米,请重新打卡。'.$res.'米');
|
||||
return $this->fail('定位坐标大于100米,请重新打卡');
|
||||
}
|
||||
|
||||
public function informationg_list()
|
||||
@ -340,7 +214,7 @@ class TaskController extends BaseApiController
|
||||
$parmas = $this->request->param();
|
||||
$task = TaskLogic::detail($parmas);
|
||||
$extend = $task['extend'];
|
||||
if (isset($extend['other']) && $extend['other']['is_commit'] == 1) {
|
||||
if ($extend['other']['is_commit'] == 1) {
|
||||
$approve = Approve::where(['task_id' =>$task['id']])->find();
|
||||
$task['approve_status'] = $approve['check_status']; //审核状态
|
||||
$task['deny_notes'] = $approve['remark']; // 拒绝原因
|
||||
@ -351,7 +225,7 @@ class TaskController extends BaseApiController
|
||||
/**
|
||||
* 其他任务 -提交
|
||||
*/
|
||||
public function commit_other_task()
|
||||
public function cimmit_other_task()
|
||||
{
|
||||
try {
|
||||
$parmas = $this->request->param(); //id note annex vedio_annex
|
||||
@ -359,10 +233,6 @@ class TaskController extends BaseApiController
|
||||
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']]];
|
||||
Db::startTrans();
|
||||
Task::where(['id' => $parmas['id']])->update(['extend' => json_encode($extend), 'update_time'=>time(), 'director_uid'=>$this->userId]); // director_uid 指派人
|
||||
@ -371,11 +241,12 @@ class TaskController extends BaseApiController
|
||||
$areaManagerId = User::where(['id' => $this->userId])->with('company')->value('area_manager');
|
||||
|
||||
// 没有则创建审批任务
|
||||
$approveModel = Approve::where(['task_id' => $task['id']])->findOrEmpty();
|
||||
$approveModel = Approve::where(['task_id' => $task['id']])->find();
|
||||
if ($approveModel->isEmpty()) {
|
||||
$approveModel->type = Approve::APPROVE_TYPE_1;
|
||||
$approveModel->type = 1;
|
||||
$approveModel->flow_id = 1;
|
||||
$approveModel->name = $task['title'];
|
||||
$approveModel->type = 1;
|
||||
$approveModel->admin_id = 0; // 后台发起人id 暂时为0
|
||||
$approveModel->user_id = $this->userId; // 前台发起人用户id
|
||||
$approveModel->task_id = $task['id']; // 前台发起人用户id
|
||||
@ -385,7 +256,7 @@ class TaskController extends BaseApiController
|
||||
$approveModel->other_type = 6;
|
||||
$approveModel->create_time = time();
|
||||
$approveModel->update_time = time();
|
||||
$re = $approveModel->save();
|
||||
$approveModel->save();
|
||||
} else {
|
||||
// 有则更新状态
|
||||
$approveModel->check_status = 1; // 状态 0待审核,1审核中,2审核通过,3审核不通过,4撤销审核
|
||||
@ -401,617 +272,4 @@ class TaskController extends BaseApiController
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 镇负责人公司任务详情
|
||||
*/
|
||||
public function service_task_detail()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
$task = TaskLogic::detail($param);
|
||||
$task['template_info'] = TaskTemplate::where(['id' => $task['template_id']])->find();
|
||||
return $this->success('成功', $task);
|
||||
}
|
||||
|
||||
/**
|
||||
* 镇负责人公司任务-督促小组服务团队学习任务 -提交
|
||||
*/
|
||||
public function commit_town_task_type4()
|
||||
{
|
||||
try {
|
||||
$parmas = $this->request->param(); //id study_photo sign_in_table study_content
|
||||
$extend = ['town_task_type_4' => ['study_photo'=>$parmas['study_photo'], 'sign_in_table'=>$parmas['sign_in_table'], 'study_content'=> $parmas['study_content']]];
|
||||
if (count($parmas['study_photo']) >= 5 && !empty($parmas['sign_in_table']) && strlen($parmas['study_content'])>=50) {
|
||||
Task::where('id', $parmas['id'])->save(['extend' => json_encode($extend), 'status' => 3]);
|
||||
} else {
|
||||
Task::where('id', $parmas['id'])->save(['extend' => json_encode($extend)]);
|
||||
}
|
||||
return $this->success('成功', []);
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 镇负责人公司任务-数字农贸宣传、加工业务建设和招商任务
|
||||
* 第一阶段 上传 宣传和加工两个业务 的手续办理完成证明
|
||||
* 第二阶段 上传 竣工验收单
|
||||
* 第三阶段 上传 两个业务体系招商入驻证明
|
||||
* 第四阶段 上传完成净利润的证明
|
||||
*
|
||||
* 将上传文件保存,走任务审批流程
|
||||
*/
|
||||
public function commit_town_task_type_marketing_director_10()
|
||||
{
|
||||
try {
|
||||
$parmas = $this->request->param(); //id stage stage_1第一阶段完成证明 stage_2 stage_3 stage_4
|
||||
$task = TaskLogic::detail($parmas);
|
||||
if (empty($task)) {
|
||||
$this->fail('任务不存在');
|
||||
}
|
||||
$extend = [];
|
||||
$stage = $parmas['stage']; // 当前做的是任务第几阶段
|
||||
if ($stage == 1) {
|
||||
$extend['stage1'] = $parmas['stage1'];
|
||||
$extend['stage1']['is_commit'] = 1;
|
||||
}
|
||||
if ($stage == 2) {
|
||||
$extend['stage2'] = $parmas['stage2'];
|
||||
$extend['stage2']['is_commit'] = 1;
|
||||
}
|
||||
if ($stage == 3) {
|
||||
$extend['stage3'] = $parmas['stage3'];
|
||||
$extend['stage3']['is_commit'] = 1;
|
||||
}
|
||||
if ($stage == 4) {
|
||||
$extend['stage4'] = $parmas['stage4'];
|
||||
$extend['stage4']['is_commit'] = 1;
|
||||
}
|
||||
$extend['stage'] = $stage;
|
||||
Task::where(['id' => $parmas['id']])->update(['extend' => json_encode($extend), 'update_time'=>time()]);
|
||||
|
||||
// 片区经理
|
||||
$areaManagerId = User::where(['id' => $this->userId])->with('company')->value('area_manager');
|
||||
|
||||
|
||||
// 创建审批任务
|
||||
$approveModel = new Approve();
|
||||
$approveModel->type = Approve::APPROVE_TYPE_4;
|
||||
$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();
|
||||
return $this->success('ok', []);
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function town_task_type_marketing_director_10_detail()
|
||||
{
|
||||
$parmas = $this->request->param();
|
||||
$task = TaskLogic::detail($parmas);
|
||||
$approve = Approve::where(['task_id' =>$task['id']])->order('id', 'desc')->find();
|
||||
if ($approve) {
|
||||
$task['approve_status'] = $approve['check_status']; //审核状态
|
||||
$task['deny_notes'] = $approve['remark']; // 拒绝原因
|
||||
$task['approve_extend'] = $approve['extend']; // 审批扩展信息
|
||||
}
|
||||
return $this->success('ok', $task);
|
||||
}
|
||||
|
||||
public function commit_village_task_type_6()
|
||||
{
|
||||
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()]);
|
||||
|
||||
// 片区经理
|
||||
$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_6;
|
||||
$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_village_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()]);
|
||||
|
||||
// 片区经理
|
||||
$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_6;
|
||||
$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_2()
|
||||
{
|
||||
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()]);
|
||||
|
||||
// 片区经理
|
||||
$areaManagerId = User::where(['id' => $this->userId])->with('company')->value('area_manager');
|
||||
|
||||
|
||||
// 查询是否 已有审批通过的
|
||||
$approveModel = Approve::where(['business_id' => $task['template_id'], 'check_status' => 2])->findOrEmpty();
|
||||
if ($approveModel->isEmpty()) {
|
||||
$approveModel->type = Approve::APPROVE_TYPE_7;
|
||||
$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->business_id = $task['template_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->create_time = time();
|
||||
$approveModel->update_time = time();
|
||||
$re = $approveModel->save();
|
||||
} else {
|
||||
// 有则更新状态
|
||||
return $this->fail('该任务已完成,请勿重复提交');
|
||||
}
|
||||
return $this->success('ok', []);
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交 镇合伙人负责人-信息收集
|
||||
* 将信息收集存入task_template表中
|
||||
*/
|
||||
publiC function commit_town_master_task_type_3()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
$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'];
|
||||
$taskTemplate->save(['extend'=>json_encode($extend)]);
|
||||
return $this->success('成功', []);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交 镇合伙人负责人-政策补贴申请
|
||||
* 上传凭证,后台审批,填写实际完成金额
|
||||
*/
|
||||
publiC function commit_town_master_task_type_7()
|
||||
{
|
||||
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()]);
|
||||
|
||||
// 片区经理
|
||||
$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_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()]);
|
||||
|
||||
// 片区经理
|
||||
$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
|
||||
$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_service_group_task()
|
||||
{
|
||||
try {
|
||||
$parmas = $this->request->param(); // id annex amount
|
||||
$task = TaskLogic::detail($parmas);
|
||||
if (empty($task)) {
|
||||
$this->fail('任务不存在');
|
||||
}
|
||||
$extend = $task['extend'];
|
||||
$extend['is_commit'] = 1;
|
||||
$extend['annex'] = $parmas['annex'];
|
||||
$extend['file_type'] = $parmas['file_type'];
|
||||
$extend['amount'] = $parmas['amount'];
|
||||
|
||||
Task::where(['id' => $parmas['id']])->update(['extend' => json_encode($extend), 'update_time' => time(), 'director_uid' => $this->userId]); // director_uid 指派人
|
||||
|
||||
// 创建审批任务
|
||||
$approveModel = new Approve();
|
||||
$approveModel->type = Approve::APPROVE_TYPE_10;
|
||||
$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 = $this->userInfo['company_id']; // 公司id
|
||||
$approveModel->check_status = 1; // 状态 0待审核,1审核中,2审核通过,3审核不通过,4撤销审核
|
||||
$approveModel->other_type = 6;
|
||||
$approveModel->amount = $parmas['amount']; // 入股金额
|
||||
$approveModel->extend = json_encode($extend);
|
||||
$approveModel->create_time = time();
|
||||
$approveModel->update_time = time();
|
||||
$re = $approveModel->save();
|
||||
return $this->success('ok', []);
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// 村联络员-督促小组服务团队入股任务提交
|
||||
public function commit_village_task_4()
|
||||
{
|
||||
try {
|
||||
$parmas = $this->request->param(); // id annex amount
|
||||
$task = TaskLogic::detail($parmas);
|
||||
if (empty($task)) {
|
||||
$this->fail('任务不存在');
|
||||
}
|
||||
$extend = $task['extend'];
|
||||
$extend['is_commit'] = 1;
|
||||
$extend['annex'] = $parmas['annex'];
|
||||
$extend['file_type'] = $parmas['file_type'];
|
||||
$extend['amount'] = $parmas['amount'];
|
||||
|
||||
Task::where(['id' => $parmas['id']])->update(['extend' => json_encode($extend), 'update_time' => time()]);
|
||||
|
||||
// 创建审批任务
|
||||
$approveModel = new Approve();
|
||||
$approveModel->type = Approve::APPROVE_TYPE_11;
|
||||
$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 = $this->userInfo['company_id']; // 公司id
|
||||
$approveModel->check_status = 1; // 状态 0待审核,1审核中,2审核通过,3审核不通过,4撤销审核
|
||||
$approveModel->other_type = 6;
|
||||
$approveModel->amount = $parmas['amount']; // 入股金额
|
||||
$approveModel->extend = json_encode($extend);
|
||||
$approveModel->create_time = time();
|
||||
$approveModel->update_time = time();
|
||||
$re = $approveModel->save();
|
||||
return $this->success('ok', []);
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// 村联络员-入股甲方公司任务提交
|
||||
public function commit_village_task_5()
|
||||
{
|
||||
try {
|
||||
$parmas = $this->request->param(); // id annex amount
|
||||
$task = TaskLogic::detail($parmas);
|
||||
if (empty($task)) {
|
||||
$this->fail('任务不存在');
|
||||
}
|
||||
$extend = $task['extend'];
|
||||
$extend['is_commit'] = 1;
|
||||
$extend['annex'] = $parmas['annex'];
|
||||
$extend['file_type'] = $parmas['file_type'];
|
||||
$extend['amount'] = $parmas['amount'];
|
||||
|
||||
Task::where(['id' => $parmas['id']])->update(['extend' => json_encode($extend), 'update_time' => time()]);
|
||||
|
||||
// 创建审批任务
|
||||
$approveModel = new Approve();
|
||||
$approveModel->type = Approve::APPROVE_TYPE_12;
|
||||
$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 = $this->userInfo['company_id']; // 公司id
|
||||
$approveModel->check_status = 1; // 状态 0待审核,1审核中,2审核通过,3审核不通过,4撤销审核
|
||||
$approveModel->other_type = 6;
|
||||
$approveModel->amount = $parmas['amount']; // 入股金额
|
||||
$approveModel->extend = json_encode($extend);
|
||||
$approveModel->create_time = time();
|
||||
$approveModel->update_time = time();
|
||||
$re = $approveModel->save();
|
||||
return $this->success('ok', []);
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// 镇合伙人服务部长-督促小组服务团队入股村管理公司
|
||||
public function commit_town_service_manager_task_6()
|
||||
{
|
||||
try {
|
||||
$parmas = $this->request->param(); // id annex amount
|
||||
$task = TaskLogic::detail($parmas);
|
||||
if (empty($task)) {
|
||||
$this->fail('任务不存在');
|
||||
}
|
||||
$extend = $task['extend'];
|
||||
$extend['is_commit'] = 1;
|
||||
$extend['annex'] = $parmas['annex'];
|
||||
$extend['file_type'] = $parmas['file_type'];
|
||||
$extend['amount'] = $parmas['amount'];
|
||||
|
||||
Task::where(['id' => $parmas['id']])->update(['extend' => json_encode($extend), 'update_time' => time()]);
|
||||
|
||||
// 创建审批任务
|
||||
$approveModel = new Approve();
|
||||
$approveModel->type = Approve::APPROVE_TYPE_13;
|
||||
$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 = $this->userInfo['company_id']; // 公司id
|
||||
$approveModel->check_status = 1; // 状态 0待审核,1审核中,2审核通过,3审核不通过,4撤销审核
|
||||
$approveModel->other_type = 6;
|
||||
$approveModel->amount = $parmas['amount']; // 入股金额
|
||||
$approveModel->extend = json_encode($extend);
|
||||
$approveModel->create_time = time();
|
||||
$approveModel->update_time = time();
|
||||
$re = $approveModel->save();
|
||||
return $this->success('ok', []);
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// 镇合伙人负责人-促成村联络员入股甲方
|
||||
public function commit_town_master_task_6()
|
||||
{
|
||||
try {
|
||||
$parmas = $this->request->param(); // id annex amount
|
||||
$task = TaskLogic::detail($parmas);
|
||||
if (empty($task)) {
|
||||
$this->fail('任务不存在');
|
||||
}
|
||||
$extend = $task['extend'];
|
||||
$extend['is_commit'] = 1;
|
||||
$extend['annex'] = $parmas['annex'];
|
||||
$extend['file_type'] = $parmas['file_type'];
|
||||
$extend['amount'] = $parmas['amount'];
|
||||
|
||||
Task::where(['id' => $parmas['id']])->update(['extend' => json_encode($extend), 'update_time' => time()]);
|
||||
|
||||
// 创建审批任务
|
||||
$approveModel = new Approve();
|
||||
$approveModel->type = Approve::APPROVE_TYPE_14;
|
||||
$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 = $this->userInfo['company_id']; // 公司id
|
||||
$approveModel->check_status = 1; // 状态 0待审核,1审核中,2审核通过,3审核不通过,4撤销审核
|
||||
$approveModel->other_type = 6;
|
||||
$approveModel->amount = $parmas['amount']; // 入股金额
|
||||
$approveModel->extend = json_encode($extend);
|
||||
$approveModel->create_time = time();
|
||||
$approveModel->update_time = time();
|
||||
$re = $approveModel->save();
|
||||
return $this->success('ok', []);
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// 任务开始通知
|
||||
public function taskStartNotice()
|
||||
{
|
||||
$startTime = strtotime(date('Y-m-d', time()));
|
||||
$endTime = strtotime(date('Y-m-d', strtotime('+2 day')));
|
||||
// 查询用户所在公司的任务安排
|
||||
$template = TaskTemplate::where('company_id', $this->userInfo['company_id'])
|
||||
->whereBetweenTime('cron_time', $startTime, $endTime)
|
||||
->order('cron_time', 'asc')
|
||||
->find();
|
||||
|
||||
if (!empty($template)) {
|
||||
$template['cron_time'] = date('Y-m-d', $template['cron_time']);
|
||||
return $this->success('成功', compact('template'));
|
||||
} else {
|
||||
return $this->success('成功', []);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ use app\common\enum\notice\NoticeEnum;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\contract\Contract;
|
||||
use app\common\model\contract\VehicleContract;
|
||||
use app\common\model\vehicle\VehicleBuyRecord;
|
||||
use app\common\model\vehicle\VehicleRent;
|
||||
use think\facade\Db;
|
||||
|
||||
@ -15,32 +14,22 @@ class VehicleController extends BaseApiController
|
||||
//镇街公司想物流平台申请租赁车辆
|
||||
public function setContractByTownCompany()
|
||||
{
|
||||
//获取参数 测试1111
|
||||
//获取参数
|
||||
$params = $this->request->post(['num']);
|
||||
//验证参数
|
||||
if(empty($params['num'])){
|
||||
return $this->fail('缺少必要参数');
|
||||
}
|
||||
//获取该公司已签约的小组服务公司数量
|
||||
$villageCompany = Contract::field('id')->where('party_a',$this->userInfo['company_id'])->where('signing_timer',2)->count();
|
||||
//已经租赁车辆
|
||||
$rentCar = VehicleRent::field('id')->where('company_id',$this->userInfo['company_id'])->whereNotIn('type','1,2')->count();
|
||||
//申请中的车辆
|
||||
$applyCar = VehicleContract::field('num')->where('company_b_id',$this->userInfo['company_id'])->where('status','in','-1,0,1,2')->sum('num');
|
||||
//自有车辆数量
|
||||
$selfCar = VehicleContract::field('id')->where('company_a_id',$this->userInfo['company_id'])->where('type',1)->where('status','in','-1,0,1,2,3')->sum('num');
|
||||
//购买车辆数量
|
||||
//获取下面的小组服务公司
|
||||
$villageCompanys = Contract::field('party_b')->where('party_a',$this->userInfo['company_id'])->where('signing_timer',2)->select()->toArray();
|
||||
$buyCar = 0;
|
||||
foreach ($villageCompanys as $v) {
|
||||
$aa = VehicleContract::field('id')->where('company_b_id',$v['party_b'])->where('type',3)->where('status','in','-1,0,1,2,3')->findOrEmpty();
|
||||
if(!$aa->isEmpty()){
|
||||
$buyCar += 1;
|
||||
}
|
||||
}
|
||||
//可在租车辆
|
||||
$doubleRentCar = max($villageCompany - $rentCar - $applyCar - $selfCar - $buyCar,0);
|
||||
//获取该公司已签约的小组服务公司数量
|
||||
$villageCompany = Contract::field('id')->where('party_a',$this->userInfo['company_id'])->where('signing_timer',2)->count();
|
||||
//已经租赁车辆
|
||||
$rentCar = VehicleRent::field('id')->where('company_id',$this->userInfo['company_id'])->where('type','<>', 1)->count();
|
||||
//申请中的车辆
|
||||
$applyCar = VehicleContract::field('num')->where('company_b_id',$this->userInfo['company_id'])->where('status','in','-1,0,1,2')->sum('num');
|
||||
//自有车辆数量
|
||||
$selfCar = VehicleRent::field('id')->where('company_id',$this->userInfo['company_id'])->where('status','<>',3)->where('type',1)->count();
|
||||
//可在租车辆
|
||||
$doubleRentCar = $villageCompany - $rentCar - $applyCar - $selfCar;
|
||||
if($params['num'] > $doubleRentCar ){
|
||||
return $this->fail('数量超过可再租车辆数');
|
||||
}
|
||||
@ -58,7 +47,7 @@ class VehicleController extends BaseApiController
|
||||
return $this->fail('数据不存在');
|
||||
}
|
||||
//判断是否是镇街公司
|
||||
if($party_b['company_type'] != 41){
|
||||
if($party_b['company_type'] != 16){
|
||||
return ['code'=>0,'msg'=>'非镇街公司不能签约'];
|
||||
}
|
||||
//发送生成合同给物流信息
|
||||
@ -121,7 +110,7 @@ class VehicleController extends BaseApiController
|
||||
if(empty($car)){
|
||||
return $this->fail('车辆数据有误');
|
||||
}
|
||||
$json = json_encode([$car->toArray()]);
|
||||
$json = json_encode($car->toArray());
|
||||
//更改车辆状态
|
||||
VehicleRent::where('car_id',$params['car_id'])->update(['status'=>1]);
|
||||
//更改状态
|
||||
@ -209,7 +198,7 @@ class VehicleController extends BaseApiController
|
||||
}
|
||||
|
||||
//小组服务公司租赁申请
|
||||
public function rentApply() {
|
||||
public function rentApply() {
|
||||
//验证请求类型
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求类型错误');
|
||||
@ -236,24 +225,24 @@ class VehicleController extends BaseApiController
|
||||
return $this->fail('当前小组服务公司未签约');
|
||||
}
|
||||
//获取签约信息
|
||||
$contract = Contract::where('party_b',$this->userInfo['company_id'])->where('signing_timer',2)->findOrEmpty();
|
||||
if($contract->isEmpty()){
|
||||
return $this->fail('未找到签约镇街公司');
|
||||
}
|
||||
$contract = Contract::where('party_b',$this->userInfo['company_id'])->where('signing_timer',2)->find();
|
||||
$party_a = Company::field('id,company_name,master_name,master_phone,master_email,is_contract,organization_code,company_type')->where('id',$contract['party_a'])->find();
|
||||
if($party_a['company_type'] != 41){
|
||||
if(empty($contract) || empty($party_a)){
|
||||
return $this->fail('未找到签约镇街公司');
|
||||
}
|
||||
if($party_a['company_type'] != 16){
|
||||
return $this->fail('不能与非镇街公司签约');
|
||||
}
|
||||
if($party_a['is_contract'] != 1){
|
||||
return $this->fail('当前镇街公司未签约');
|
||||
}
|
||||
//判断是否申请过
|
||||
$vehicleContract = VehicleContract::where('company_b_id',$this->userInfo['company_id'])->whereNotIn('type','2,3')->whereNotIn('status','4,5,6')->find();
|
||||
$vehicleContract = VehicleContract::where('company_b_id',$this->userInfo['company_id'])->where('type','<>',2)->whereNotIn('status','4,5,6')->find();
|
||||
if(!empty($vehicleContract)){
|
||||
return $this->fail('请勿重复申请');
|
||||
}
|
||||
if($params['type'] == 1){
|
||||
$cars_info = json_encode([['license'=>$params['license'],'pic'=>$params['pic']]]);
|
||||
$cars_info = json_encode(['license'=>$params['license'],'pic'=>$params['pic']]);
|
||||
$car_type = 1;
|
||||
}else{
|
||||
$cars_info = null;
|
||||
@ -364,7 +353,6 @@ class VehicleController extends BaseApiController
|
||||
}
|
||||
//获取数据
|
||||
$vehicleContract = VehicleContract::where('id',$id)->find();
|
||||
$vehicleContract['cars_info'] = json_decode($vehicleContract['cars_info'],true);
|
||||
if(empty($vehicleContract)){
|
||||
return $this->fail('获取数据失败');
|
||||
}
|
||||
@ -386,18 +374,11 @@ class VehicleController extends BaseApiController
|
||||
if(empty($company)){
|
||||
return $this->fail('数据错误');
|
||||
}
|
||||
if($company['company_type'] != 41){
|
||||
if($company['company_type'] != 16){
|
||||
return $this->fail('非镇街公司不能访问');
|
||||
}
|
||||
//获取小组服务公司申请信息
|
||||
$vehicleContract_pre = VehicleContract::where('company_a_id',$company['id'])->where('status','in','-1,0,1,2')->where('type','<>',2)->limit(4)->order('create_time desc')->select()->toArray();
|
||||
$vehicleContract = [];
|
||||
foreach ($vehicleContract_pre as $v) {
|
||||
$vehicleBuy = VehicleBuyRecord::where('contract_id',$v['id'])->findOrEmpty();
|
||||
if($vehicleBuy->isEmpty()){
|
||||
$vehicleContract[] = $v;
|
||||
}
|
||||
}
|
||||
$vehicleContract = VehicleContract::where('company_a_id',$company['id'])->where('status','in','-1,0,1,2')->limit(4)->order('create_time desc')->select()->toArray();
|
||||
//获取车辆列表
|
||||
$vehicleRentCars = VehicleRent::where('company_id',$company['id'])->where('status','in','0,1,2')->select()->each(function($item){
|
||||
if($item['status'] == 2){
|
||||
@ -407,23 +388,13 @@ class VehicleController extends BaseApiController
|
||||
//获取该公司已签约的小组服务公司数量
|
||||
$villageCompany = Contract::field('id')->where('party_a',$company['id'])->where('signing_timer',2)->count();
|
||||
//已经租赁车辆
|
||||
$rentCar = VehicleRent::field('id')->where('company_id',$company['id'])->whereNotIn('type','1,2')->count();
|
||||
$rentCar = VehicleRent::field('id')->where('company_id',$company['id'])->where('type','<>', 1)->count();
|
||||
//申请中的车辆
|
||||
$applyCar = VehicleContract::field('num')->where('company_b_id',$company['id'])->where('status','in','-1,0,1,2')->sum('num');
|
||||
//自有车辆数量
|
||||
$selfCar = VehicleContract::field('id')->where('company_a_id',$company['id'])->where('type',1)->where('status','in','-1,0,1,2,3')->sum('num');
|
||||
//购买车辆数量
|
||||
//获取下面的小组服务公司
|
||||
$villageCompanys = Contract::field('party_b')->where('party_a',$company['id'])->where('signing_timer',2)->select()->toArray();
|
||||
$buyCar = 0;
|
||||
foreach ($villageCompanys as $v) {
|
||||
$aa = VehicleContract::field('id')->where('company_b_id',$v['party_b'])->where('type',3)->where('status','in','-1,0,1,2,3')->findOrEmpty();
|
||||
if(!$aa->isEmpty()){
|
||||
$buyCar += 1;
|
||||
}
|
||||
}
|
||||
$selfCar = VehicleRent::field('id')->where('company_id',$company['id'])->where('status','<>',3)->where('type',1)->count();
|
||||
//可在租车辆
|
||||
$doubleRentCar = max($villageCompany - $rentCar - $applyCar - $selfCar - $buyCar,0);
|
||||
$doubleRentCar = $villageCompany - $rentCar - $applyCar - $selfCar;
|
||||
//设置数据
|
||||
$data = [
|
||||
'apply' => $vehicleContract,
|
||||
@ -432,7 +403,6 @@ class VehicleController extends BaseApiController
|
||||
'rent_num' => $rentCar,
|
||||
'can_rent_num' => intval($doubleRentCar),
|
||||
'self_num' => $selfCar,
|
||||
'buy_num' => $buyCar,
|
||||
'apply_num' => $applyCar
|
||||
];
|
||||
//返回
|
||||
@ -441,44 +411,60 @@ class VehicleController extends BaseApiController
|
||||
|
||||
public function villageCompanyIndex() {
|
||||
//获取公司信息
|
||||
$company = Company::field('id,master_name as user_name,master_phone as user_phone,company_name,company_type,province,city,area,street,village,brigade')->where('id',$this->userInfo['company_id'])->find()->append(['province_name', 'city_name', 'area_name', 'street_name', 'village_name','brigade_name']);
|
||||
$company = Company::field('id,company_type,province,city,area,street,village,brigade')->where('id',$this->userInfo['company_id'])->find()->append(['province_name', 'city_name', 'area_name', 'street_name', 'village_name','brigade_name']);
|
||||
if(empty($company)){
|
||||
return $this->fail('数据错误');
|
||||
}
|
||||
if($company['company_type'] != 18 ){
|
||||
return $this->fail('非小组公司不能访问');
|
||||
}
|
||||
//获取购买车辆记录
|
||||
$buyCarRent = VehicleBuyRecord::where('company_id',$company['id'])->where('status','<>',4)->findOrEmpty();
|
||||
if($buyCarRent->isEmpty()){
|
||||
$data = VehicleContract::where('company_b_id',$company['id'])->where('type','<>',2)->order('id desc')->findOrEmpty();
|
||||
}else{
|
||||
$data = $buyCarRent;
|
||||
$data['status'] = 0;
|
||||
$data['type'] = 0;
|
||||
//获取申请信息
|
||||
$vehicleContract = VehicleContract::where('company_b_id',$company['id'])->where('type','<>',2)->order('id desc')->findOrEmpty();
|
||||
if($vehicleContract['status'] == 3){
|
||||
if(!empty($vehicleContract['cars_info'])){
|
||||
$vehicleContract['cars_info'] = json_decode($vehicleContract['cars_info'],true);
|
||||
if(!empty($vehicleContract['cars_info'])){
|
||||
$arr = $vehicleContract['cars_info'];
|
||||
$arr['mileage'] = 0;
|
||||
$position = curl_get(env('project.logistic_domain').'/api/getCarLocal?car_id='.$arr['id']);
|
||||
if($position && $position['code'] == 1){
|
||||
$arr['lon'] = $position['data']['lon'];
|
||||
$arr['lat'] = $position['data']['lat'];
|
||||
}
|
||||
$vehicleContract['cars_info'] = $arr;
|
||||
}
|
||||
}
|
||||
$vehicleContract['province'] = $company['province_name'];
|
||||
$vehicleContract['city'] = $company['city_name'];
|
||||
$vehicleContract['area'] = $company['area_name'];
|
||||
$vehicleContract['street'] = $company['street_name'];
|
||||
$vehicleContract['village'] = $company['village_name'];
|
||||
$vehicleContract['brigade'] = $company['brigade_name'];
|
||||
}
|
||||
//获取签约合同
|
||||
return $this->success('请求成功',$data->toArray());
|
||||
//返回数据
|
||||
return $this->success('请求成功',$vehicleContract->toArray());
|
||||
}
|
||||
|
||||
//车辆详情
|
||||
public function vehicleInfo() {
|
||||
$id = $this->request->get('car_id');
|
||||
//获取数据
|
||||
if(!empty($id) && $id != 'undefined'){
|
||||
$data = VehicleRent::where('car_id',$id)->where('status',2)->findOrEmpty();
|
||||
}else{
|
||||
$data = VehicleRent::where('rent_company_id',$this->userInfo['company_id'])->where('status',2)->findOrEmpty();
|
||||
//获取参数
|
||||
$carId = $this->request->get('car_id');
|
||||
if(empty($carId)){
|
||||
return $this->fail('缺少必要参数');
|
||||
}
|
||||
if($data->isEmpty()){
|
||||
return $this->fail('数据不存在');
|
||||
//获取数据
|
||||
$data = VehicleRent::where('car_id',$carId)->find();
|
||||
if(empty($data)){
|
||||
return $this->fail('数据错误');
|
||||
}
|
||||
$data['mileage'] = 0;
|
||||
$data['company'] = Company::field('company_name,master_name as user_name,master_phone as user_phone,province,city,area,street,village,brigade')->where('id',$data['rent_company_id'])->find()->append(['province_name', 'city_name', 'area_name', 'street_name', 'village_name','brigade_name']);
|
||||
//获取合同
|
||||
$data['contract'] = VehicleContract::field('id,contract_no,contract_url,file,status,create_time,update_time')->where('id',$data['contract_id'])->findOrEmpty();
|
||||
if($data['status'] == 2){
|
||||
$data['company'] = Company::field('company_name,master_name as user_name,master_phone as user_phone,province,city,area,street,village,brigade')->where('id',$data['rent_company_id'])->find()->append(['province_name', 'city_name', 'area_name', 'street_name', 'village_name','brigade_name']);
|
||||
//获取合同
|
||||
$data['contract'] = VehicleContract::field('id,contract_no,contract_url,file,status,create_time,update_time')->where('id',$data['contract_id'])->findOrEmpty();
|
||||
}
|
||||
//当前坐标位置
|
||||
$position = curl_get(env('project.logistic_domain').'/api/getCarLocal?car_id='.$data['car_id']);
|
||||
$position = curl_get(env('project.logistic_domain').'/api/getCarLocal?car_id='.$carId);
|
||||
if($position && $position['code'] == 1){
|
||||
$data['position'] = $position['data'];
|
||||
}else{
|
||||
@ -587,7 +573,7 @@ class VehicleController extends BaseApiController
|
||||
if(empty($company)){
|
||||
return $this->fail('请求错误');
|
||||
}
|
||||
if($company['company_type'] != 41){
|
||||
if($company['company_type'] != 16){
|
||||
return $this->fail('非镇街公司不能访问');
|
||||
}
|
||||
$data = VehicleContract::field('id,contract_no,contract_url,status,create_time,update_time')->where('contract_logistic_id','<>',0)->where('company_b_id',$company['id'])->select();
|
||||
@ -656,215 +642,4 @@ class VehicleController extends BaseApiController
|
||||
}
|
||||
}
|
||||
|
||||
//获取空闲车辆列表
|
||||
public function getFreeCars(): \think\response\Json
|
||||
{
|
||||
//1、获取当前登录用户信息并判断其公司是否是小组服务公司
|
||||
$xzCompany = Company::field('id,company_type')->where('id',$this->userInfo['company_id'])->findOrEmpty();
|
||||
if($xzCompany->isEmpty() || $xzCompany['company_type'] != 18){
|
||||
return $this->fail('当前用户非小组服务公司');
|
||||
}
|
||||
//2、获取小组服务公司签约的镇街公司
|
||||
$zjCompany = Contract::field('party_a')->where('party_b',$this->userInfo['company_id'])->where('signing_timer',2)->findOrEmpty();
|
||||
if($zjCompany->isEmpty()){
|
||||
return $this->fail('未获取到小组服务公司签约的镇街公司');
|
||||
}
|
||||
//3、获取镇街公司向平台租赁的且未二次租赁给小组公司的车辆
|
||||
$zjRentCars = VehicleRent::field('car_id')->where('company_id',$zjCompany['party_a'])->where('status',0)->select()->toArray();
|
||||
$zjRentCars = array_column($zjRentCars,'car_id');
|
||||
//4、获取小组公司自己租赁的车辆
|
||||
$xzRentCars = VehicleRent::field('car_id')->where('company_id',$zjCompany['party_a'])->where('rent_company_id',$xzCompany['id'])->where('status',2)->where('type','<>',1)->where('type','<>',2)->select()->toArray();
|
||||
$xzRentCars = array_column($xzRentCars,'car_id');
|
||||
//5、获取平台未出租的车辆
|
||||
$result = curl_post(env('project.logistic_domain').'/api/Vehicle/getFreeCars',[],['ids'=>implode(',',array_merge($zjRentCars,$xzRentCars))]);
|
||||
foreach($result['data'] as $k => $v){
|
||||
$result['data'][$k]['checked'] = [];
|
||||
}
|
||||
//6、返回
|
||||
return $this->success('success',$result['data']);
|
||||
}
|
||||
|
||||
//申请购车
|
||||
public function buyCars() {
|
||||
//验证请求类型
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求类型错误');
|
||||
}
|
||||
//1、获取购买车辆的id参数
|
||||
$cars = $this->request->post('cars');
|
||||
$cars = json_decode($cars,true);
|
||||
if(empty($cars)){
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
//获取小组服务公司信息
|
||||
$xzCompany = Company::field('id,company_name,master_name,master_phone,master_email,organization_code,company_type')->where('id',$this->userInfo['company_id'])->findOrEmpty();
|
||||
if($xzCompany->isEmpty() || $xzCompany['company_type'] != 18){
|
||||
return $this->fail('当前用户非小组服务公司');
|
||||
}
|
||||
//获取镇街公司信息
|
||||
$zjCompany = Contract::field('party_a')->where('party_b',$this->userInfo['company_id'])->where('signing_timer',2)->findOrEmpty();
|
||||
if($zjCompany->isEmpty()){
|
||||
return $this->fail('签约镇街公司不存在');
|
||||
}
|
||||
//判断购买车辆中是否包含镇街公司租赁的车辆
|
||||
$car_ids = array_column($cars,'id');
|
||||
$zjRentCars = VehicleRent::field('car_id as id,car_license as license')->where('company_id',$zjCompany['party_a'])->where('car_id','in',$car_ids)->where('status',0)->where('type',0)->select();
|
||||
//判断小组服务公司是否租车或者有自有车辆
|
||||
$xzRentCars = VehicleRent::where('rent_company_id',$xzCompany['id'])->where('status','in','1,2')->where('type','<>',2)->findOrEmpty();
|
||||
//如果没有租赁车俩和上传自有车辆,也没有购买镇街公司租赁的车辆 则直接发起购买合同
|
||||
if($xzRentCars->isEmpty() && $zjRentCars->isEmpty()){
|
||||
//发送购买合同给物流系统
|
||||
$curl_result = curl_post(env('project.logistic_domain').'/api/signContract',[],[
|
||||
'num' => count($cars),
|
||||
'company_id' => $xzCompany['id'],
|
||||
'company_name' => $xzCompany['company_name'],
|
||||
'company_code' => $xzCompany['organization_code'],
|
||||
'company_user' => $xzCompany['master_name'],
|
||||
'company_phone' => $xzCompany['master_phone'],
|
||||
'company_email' => $xzCompany['master_email'],
|
||||
'cars_info' => json_encode($cars),
|
||||
'type' => 3
|
||||
]);
|
||||
if(empty($curl_result)){
|
||||
return $this->fail('null return from logistic');
|
||||
}
|
||||
if($curl_result['code'] == 0){
|
||||
return $this->fail($curl_result['msg'].' from logistic');
|
||||
}
|
||||
//生成本地合同
|
||||
VehicleContract::create($curl_result['data']);
|
||||
}
|
||||
//如果没有租赁车俩和上传自有车辆,但有购买镇街公司租赁的车辆 则发起镇街公司与平台公司的解约合同
|
||||
if($xzRentCars->isEmpty() && !$zjRentCars->isEmpty()){
|
||||
$zjCompanyInfo = Company::field('id,company_name,master_name,master_phone,master_email,organization_code')->where('id',$zjCompany['party_a'])->findOrEmpty();
|
||||
//发送解约合同给物流系统
|
||||
$curl_result = curl_post(env('project.logistic_domain').'/api/signContract',[],[
|
||||
'num' => count($zjRentCars),
|
||||
'company_id' => $zjCompanyInfo['id'],
|
||||
'company_name' => $zjCompanyInfo['company_name'],
|
||||
'company_code' => $zjCompanyInfo['organization_code'],
|
||||
'company_user' => $zjCompanyInfo['master_name'],
|
||||
'company_phone' => $zjCompanyInfo['master_phone'],
|
||||
'company_email' => $zjCompanyInfo['master_email'],
|
||||
'cars_info' => json_encode($zjRentCars),
|
||||
'type' => 2
|
||||
]);
|
||||
if(empty($curl_result)){
|
||||
return $this->fail('null return from logistic');
|
||||
}
|
||||
if($curl_result['code'] == 0){
|
||||
return $this->fail($curl_result['msg'].' from logistic');
|
||||
}
|
||||
//生成本地合同
|
||||
$res = VehicleContract::create($curl_result['data']);
|
||||
//生成关联记录
|
||||
VehicleBuyRecord::create([
|
||||
'company_id' => $xzCompany['id'],
|
||||
'company_name' => $xzCompany['company_name'],
|
||||
'company_code' => $xzCompany['organization_code'],
|
||||
'company_user' => $xzCompany['master_name'],
|
||||
'company_phone' => $xzCompany['master_phone'],
|
||||
'company_email' => $xzCompany['master_email'],
|
||||
'cars_info' => json_encode($cars),
|
||||
'num' => count($cars),
|
||||
'status' => 3,
|
||||
'contract_id' => $res->id,
|
||||
'create_time' => time()
|
||||
]);
|
||||
//更改本地车辆状态
|
||||
VehicleRent::where('car_id','in',$car_ids)->update(['status'=>1]);
|
||||
}
|
||||
//如果有租赁车俩和上传自有车辆,但没有购买镇街公司租赁的车辆 则先向镇街公司发起解约合同
|
||||
if(!$xzRentCars->isEmpty() && $zjRentCars->isEmpty()){
|
||||
//获取镇街公司信息
|
||||
$zjCompanyInfo = Company::field('id,company_name,master_name,master_phone,master_email,organization_code')->where('id',$zjCompany['party_a'])->findOrEmpty();
|
||||
//生成本地解约合同
|
||||
$res = VehicleContract::create([
|
||||
'contract_no' => time(),
|
||||
'contract_logistic_id' => 0,
|
||||
'company_a_id' => $zjCompanyInfo['id'],
|
||||
'company_a_name' => $zjCompanyInfo['company_name'],
|
||||
'company_a_code' => $zjCompanyInfo['organization_code'],
|
||||
'company_a_user' => $zjCompanyInfo['master_name'],
|
||||
'company_a_phone' => $zjCompanyInfo['master_phone'],
|
||||
'company_a_email' => $zjCompanyInfo['master_email'],
|
||||
'company_b_id' => $xzCompany['id'],
|
||||
'company_b_name' => $xzCompany['company_name'],
|
||||
'company_b_code' => $xzCompany['organization_code'],
|
||||
'company_b_user' => $xzCompany['master_name'],
|
||||
'company_b_phone' => $xzCompany['master_phone'],
|
||||
'company_b_email' => $xzCompany['master_email'],
|
||||
'num' =>1,
|
||||
'cars_info' => json_encode([['id'=>$xzRentCars['car_id'],'license'=>$xzRentCars['car_license']]]),
|
||||
'type' => 2,
|
||||
'status' => 0,
|
||||
'create_time' => time(),
|
||||
'update_time' => time(),
|
||||
]);
|
||||
//生成关联记录
|
||||
if($xzRentCars['type'] == 0){
|
||||
$status = 2;
|
||||
}else{
|
||||
$status = 1;
|
||||
}
|
||||
VehicleBuyRecord::create([
|
||||
'company_id' => $xzCompany['id'],
|
||||
'company_name' => $xzCompany['company_name'],
|
||||
'company_code' => $xzCompany['organization_code'],
|
||||
'company_user' => $xzCompany['master_name'],
|
||||
'company_phone' => $xzCompany['master_phone'],
|
||||
'company_email' => $xzCompany['master_email'],
|
||||
'cars_info' => json_encode($cars),
|
||||
'num' => count($cars),
|
||||
'status' => $status,
|
||||
'contract_id' => $res->id,
|
||||
'create_time' => time()
|
||||
]);
|
||||
}
|
||||
//如果有租赁车俩和上传自有车辆,也有购买镇街公司租赁的车辆 则先向镇街公司发起解约合同,再由镇街公司向平台公司发起解约合同
|
||||
if(!$xzRentCars->isEmpty() && !$zjRentCars->isEmpty()){
|
||||
//获取镇街公司信息
|
||||
$zjCompanyInfo = Company::field('id,company_name,master_name,master_phone,master_email,organization_code')->where('id',$zjCompany['party_a'])->findOrEmpty();
|
||||
//生成本地解约合同
|
||||
$res = VehicleContract::create([
|
||||
'contract_no' => time(),
|
||||
'contract_logistic_id' => 0,
|
||||
'company_a_id' => $zjCompanyInfo['id'],
|
||||
'company_a_name' => $zjCompanyInfo['company_name'],
|
||||
'company_a_code' => $zjCompanyInfo['organization_code'],
|
||||
'company_a_user' => $zjCompanyInfo['master_name'],
|
||||
'company_a_phone' => $zjCompanyInfo['master_phone'],
|
||||
'company_a_email' => $zjCompanyInfo['master_email'],
|
||||
'company_b_id' => $xzCompany['id'],
|
||||
'company_b_name' => $xzCompany['company_name'],
|
||||
'company_b_code' => $xzCompany['organization_code'],
|
||||
'company_b_user' => $xzCompany['master_name'],
|
||||
'company_b_phone' => $xzCompany['master_phone'],
|
||||
'company_b_email' => $xzCompany['master_email'],
|
||||
'num' =>1,
|
||||
'cars_info' => json_encode([['id'=>$xzRentCars['car_id'],'license'=>$xzRentCars['car_license']]]),
|
||||
'type' => 2,
|
||||
'status' => 0,
|
||||
'create_time' => time(),
|
||||
'update_time' => time(),
|
||||
]);
|
||||
//生成关联记录
|
||||
VehicleBuyRecord::create([
|
||||
'company_id' => $xzCompany['id'],
|
||||
'company_name' => $xzCompany['company_name'],
|
||||
'company_code' => $xzCompany['organization_code'],
|
||||
'company_user' => $xzCompany['master_name'],
|
||||
'company_phone' => $xzCompany['master_phone'],
|
||||
'company_email' => $xzCompany['master_email'],
|
||||
'cars_info' => json_encode($cars),
|
||||
'num' => count($cars),
|
||||
'status' => 2,
|
||||
'contract_id' => $res->id,
|
||||
'create_time' => time()
|
||||
]);
|
||||
}
|
||||
//更新物流系统
|
||||
curl_post(env('project.logistic_domain').'/api/Vehicle/updateVehicleStatusToBuy',[],['car_ids'=>implode(',',$car_ids)]);
|
||||
return $this->success('合同发起成功,等待审核 from task');
|
||||
}
|
||||
}
|
@ -15,15 +15,7 @@
|
||||
namespace app\api\controller;
|
||||
|
||||
use IFlytek\Xfyun\Speech\ChatClient;
|
||||
use IFlytek\Xfyun\Speech\IatClient;
|
||||
use IFlytek\Xfyun\Speech\TtsClient;
|
||||
use IFlytek\Xfyun\Speech\OcrClient;
|
||||
use think\facade\Db;
|
||||
use WebSocket\Client;
|
||||
use GuzzleHttp\Client as GzClient;
|
||||
use GuzzleHttp\Psr7\Request;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Guzzle\Http\Exception\RequestException;
|
||||
|
||||
/**
|
||||
* 讯飞
|
||||
@ -31,421 +23,99 @@ use Guzzle\Http\Exception\RequestException;
|
||||
*/
|
||||
class XunFeiController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['chat', 'iat', 'tts', 'ocr', 'iatWss', 'analyse'];
|
||||
public array $notNeedLogin = ['chat'];
|
||||
|
||||
private $app_id='2eda6c2e';
|
||||
|
||||
private $api_key='12ec1f9d113932575fc4b114a2f60ffd';
|
||||
|
||||
private $api_secret='MDEyMzE5YTc5YmQ5NjMwOTU1MWY4N2Y2';
|
||||
|
||||
//星火认知chat
|
||||
public function chat()
|
||||
{
|
||||
header('X-Accel-Buffering: no');
|
||||
$content = $this->request->param('content');
|
||||
if(empty($content)){
|
||||
return $this->data(['answer' => '']);
|
||||
$parmas=$this->request->param('content');
|
||||
if(empty($parmas)){
|
||||
return $this->success('success');
|
||||
}
|
||||
$chat=new ChatClient($this->app_id,$this->api_key,$this->api_secret);
|
||||
$client = new Client($chat->assembleAuthUrl('wss://spark-api.xf-yun.com/v2.1/chat'));
|
||||
// 连接到 WebSocket 服务器
|
||||
if ($client) {
|
||||
$header = [
|
||||
"app_id" => $this->app_id,
|
||||
"uid" => "1"
|
||||
];
|
||||
$parameter = [
|
||||
"chat" => [
|
||||
"domain" => "generalv2",
|
||||
"temperature" => 0.5,
|
||||
"max_tokens" => 1024
|
||||
]
|
||||
];
|
||||
$payload = [
|
||||
"message" => [
|
||||
"text" => [
|
||||
["role" => "user", "content" => $content]
|
||||
]
|
||||
]
|
||||
];
|
||||
$data = json_encode([
|
||||
"header" => $header,
|
||||
"parameter" => $parameter,
|
||||
"payload" => $payload
|
||||
]);
|
||||
// 发送数据到 WebSocket 服务器
|
||||
$data = $this->getBody($this->app_id,$parmas);
|
||||
|
||||
$client->send($data);
|
||||
// 从 WebSocket 服务器接收数据
|
||||
$answer = "";
|
||||
while(true){
|
||||
$response = $client->receive();
|
||||
$resp = json_decode($response, true);
|
||||
$code = $resp["header"]["code"] ?? 0;
|
||||
$resp = json_decode($response,true);
|
||||
$code = $resp["header"]["code"];
|
||||
// echo "从服务器接收到的数据: " . $response;
|
||||
if(0 == $code){
|
||||
$status = $resp["header"]["status"];
|
||||
if($status != 2){
|
||||
$content = $resp['payload']['choices']['text'][0]['content'];
|
||||
$answer .= $content;
|
||||
print($answer);
|
||||
ob_flush(); // 刷新输出缓冲区
|
||||
flush(); // 刷新系统输出缓冲区
|
||||
}else{
|
||||
$content = $resp['payload']['choices']['text'][0]['content'];
|
||||
$answer .= $content;
|
||||
$total_tokens = $resp['payload']['usage']['text']['total_tokens'];
|
||||
print("\n本次消耗token用量:\n");
|
||||
print($total_tokens);
|
||||
ob_flush(); // 刷新输出缓冲区
|
||||
flush(); // 刷新系统输出缓冲区
|
||||
break;
|
||||
}
|
||||
}else{
|
||||
return $this->fail( "服务返回报错 " . $response);
|
||||
return $this->fail( "服务返回报错".$response);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $this->data(['answer' => $answer]);
|
||||
ob_flush(); // 刷新输出缓冲区
|
||||
flush(); // 刷新系统输出缓冲区
|
||||
return $this->success('success');
|
||||
|
||||
} else {
|
||||
return $this->fail('无法连接到 WebSocket 服务器');
|
||||
}
|
||||
}
|
||||
|
||||
//AI分析信息
|
||||
public function analyse()
|
||||
{
|
||||
$informationg_demand_id = $this->request->param('informationg_demand_id');
|
||||
if(empty($informationg_demand_id)){
|
||||
return $this->fail('信息参数错误');
|
||||
}
|
||||
$informationg = Db::name('user_informationg_demand')->where('id', $informationg_demand_id)->where('status', 1)->find();
|
||||
$type_name = Db::name('category_business')->where('id', $informationg['category_child'])->value('name');
|
||||
$data_field = json_decode($informationg['data_field'], true);
|
||||
$demand = '';
|
||||
foreach($data_field as $k=>$v) {
|
||||
$demand .= $k . ':' . $v . ';';
|
||||
}
|
||||
$question = "根据以下{$type_name}信息【{$demand}】请问有那些商机?";
|
||||
$chat=new ChatClient($this->app_id,$this->api_key,$this->api_secret);
|
||||
$client = new Client($chat->assembleAuthUrl('wss://spark-api.xf-yun.com/v2.1/chat'));
|
||||
// 连接到 WebSocket 服务器
|
||||
if ($client) {
|
||||
$header = [
|
||||
"app_id" => $this->app_id,
|
||||
"uid" => "1"
|
||||
];
|
||||
$parameter = [
|
||||
"chat" => [
|
||||
"domain" => "generalv2",
|
||||
"temperature" => 0.5,
|
||||
"max_tokens" => 1024
|
||||
]
|
||||
];
|
||||
$payload = [
|
||||
"message" => [
|
||||
"text" => [
|
||||
["role" => "user", "content" => $question]
|
||||
]
|
||||
]
|
||||
];
|
||||
$data = json_encode([
|
||||
"header" => $header,
|
||||
"parameter" => $parameter,
|
||||
"payload" => $payload
|
||||
]);
|
||||
//构造参数体
|
||||
function getBody($appid,$question){
|
||||
$header = array(
|
||||
"app_id" => $appid,
|
||||
"uid" => "1"
|
||||
);
|
||||
|
||||
$parameter = array(
|
||||
"chat" => array(
|
||||
"domain" => "generalv2",
|
||||
"temperature" => 0.5,
|
||||
"max_tokens" => 1024
|
||||
)
|
||||
);
|
||||
|
||||
$payload = array(
|
||||
"message" => array(
|
||||
"text" => array(
|
||||
array("role" => "user", "content" => $question)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$json_string = json_encode(array(
|
||||
"header" => $header,
|
||||
"parameter" => $parameter,
|
||||
"payload" => $payload
|
||||
));
|
||||
|
||||
$client->send($data);
|
||||
$answer = '';
|
||||
while(true){
|
||||
$response = $client->receive();
|
||||
$resp = json_decode($response, true);
|
||||
$code = $resp["header"]["code"] ?? 0;
|
||||
if($code == 0){
|
||||
$status = $resp["header"]["status"];
|
||||
$content = $resp['payload']['choices']['text'][0]['content'] ?? '';
|
||||
$answer .= $content;
|
||||
if($status == 2){
|
||||
break;
|
||||
}
|
||||
}else{
|
||||
return $this->fail( "服务返回报错 " . $response);
|
||||
break;
|
||||
}
|
||||
}
|
||||
$data = [
|
||||
'ai_aianalyse' => $answer,
|
||||
'update_time' => time(),
|
||||
];
|
||||
$res = Db::name('user_informationg_demand')->where('id', $informationg_demand_id)->update($data);
|
||||
if (!$res) {
|
||||
return $this->fail('AI分析信息失败');
|
||||
}
|
||||
} else {
|
||||
return $this->fail('无法连接到 WebSocket 服务器');
|
||||
}
|
||||
return $this->data(['question'=>$question, 'answer' => $answer]);
|
||||
}
|
||||
return $json_string;
|
||||
|
||||
//语音听写(流式版)
|
||||
public function iat()
|
||||
{
|
||||
header('X-Accel-Buffering: no');
|
||||
$file = request()->file('audio');
|
||||
if (empty($file)) {
|
||||
return $this->fail('未上传音频文件');
|
||||
}
|
||||
// 上传音频临时文件
|
||||
$savename = \think\facade\Filesystem::putFile('audio', $file);
|
||||
|
||||
$file = app()->getRootPath() . '/runtime/storage/' . $savename;
|
||||
if (!file_exists($file)) {
|
||||
return $this->fail('未上传音频文件');
|
||||
}
|
||||
$filesize = filesize($file);
|
||||
if ($filesize > 1 * 1024 * 1024) {
|
||||
return $this->fail('录音文件太长');
|
||||
}
|
||||
$last_file = substr($savename, -36);
|
||||
$copyFile = app()->getRootPath() . '/public/uploads/iat/' . $last_file;
|
||||
|
||||
// ********** 临时方案 ********** //
|
||||
copy($file, $copyFile);
|
||||
// $last_file = 'a1fcdd96c7967b48add17b52ab456368.mp3';
|
||||
$curl_url = "https://dev.app.tword.cn/ffmpeg.php?file={$last_file}";
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $curl_url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
$file = "https://dev.app.tword.cn/iat/" . $last_file . ".pcm";
|
||||
// $ext = pathinfo($file, PATHINFO_EXTENSION);
|
||||
$ext = "pcm";
|
||||
$extArray = ['mp3', 'pcm'];
|
||||
if (!in_array($ext, $extArray)) {
|
||||
return $this->fail('录音格式错误');
|
||||
}
|
||||
// ********** 临时方案 ********** //
|
||||
$encoding = 'raw';
|
||||
if ($ext == 'mp3') {
|
||||
$encoding = 'lame';
|
||||
}
|
||||
if ($ext == 'pcm') {
|
||||
$encoding = 'raw';
|
||||
}
|
||||
$audioFile = fopen($file, 'rb');
|
||||
if ($audioFile === false) {
|
||||
return $this->fail('音频文件异常');
|
||||
}
|
||||
|
||||
try {
|
||||
$words = '';
|
||||
$iatHostUrl = "wss://iat-api.xfyun.cn/v2/iat";
|
||||
$iat = new IatClient($this->app_id, $this->api_key, $this->api_secret);
|
||||
$client = new Client($iat->assembleAuthUrl($iatHostUrl));
|
||||
$frameSize = 1280; //每一帧的音频大小
|
||||
$intervel = 20 * 1000; //发送音频间隔
|
||||
$status = 0;
|
||||
while (true) {
|
||||
$len = fread($audioFile, $frameSize);
|
||||
if ($len === false) {
|
||||
break;
|
||||
}
|
||||
if ($len === '') { //文件读取完了
|
||||
$status = 2;
|
||||
}
|
||||
switch ($status) {
|
||||
case 0: //发送第一帧音频,带business 参数
|
||||
$frameData = array(
|
||||
'common' => array(
|
||||
'app_id' => $this->app_id //appid 必须带上,只需第一帧发送
|
||||
),
|
||||
'business' => array( //business 参数,只需一帧发送
|
||||
'language' => 'zh_cn',
|
||||
'domain' => 'iat',
|
||||
'accent' => 'mandarin'
|
||||
),
|
||||
'data' => array(
|
||||
'status' => 0,
|
||||
'format' => 'audio/L16;rate=16000',
|
||||
'audio' => base64_encode($len),
|
||||
'encoding' => $encoding
|
||||
)
|
||||
);
|
||||
$client->send(json_encode($frameData));
|
||||
$status = 1;
|
||||
break;
|
||||
case 1:
|
||||
$frameData = array(
|
||||
'data' => array(
|
||||
'status' => 1,
|
||||
'format' => 'audio/L16;rate=16000',
|
||||
'audio' => base64_encode($len),
|
||||
'encoding' => $encoding
|
||||
)
|
||||
);
|
||||
$client->send(json_encode($frameData));
|
||||
break;
|
||||
case 2:
|
||||
$frameData = array(
|
||||
'data' => array(
|
||||
'status' => 2,
|
||||
'format' => 'audio/L16;rate=16000',
|
||||
'audio' => base64_encode($len),
|
||||
'encoding' => $encoding
|
||||
)
|
||||
);
|
||||
$client->send(json_encode($frameData));
|
||||
break 2;
|
||||
}
|
||||
//模拟音频采样间隔
|
||||
usleep($intervel);
|
||||
}
|
||||
while (true) {
|
||||
$response = $client->receive();
|
||||
if ($response === null) {
|
||||
break;
|
||||
}
|
||||
$resp = json_decode($response, true);
|
||||
$code = $resp['code'];
|
||||
if ($code != 0) {
|
||||
break;
|
||||
}
|
||||
$message = $resp['message'];
|
||||
$data = $resp['data'];
|
||||
$result = $data['result'];
|
||||
$status = $data['status'];
|
||||
foreach($result['ws'] as $v) {
|
||||
$words .= $v['cw'][0]['w'] ?? '';
|
||||
}
|
||||
if ($status === 2) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose($audioFile);
|
||||
// 删除临时音频文件
|
||||
if (file_exists($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
if (file_exists($file)) {
|
||||
// 删除临时文件
|
||||
unlink($file);
|
||||
}
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
return $this->data(['words' => $words]);
|
||||
}
|
||||
|
||||
//获取语音听写(流式版)websocket地址
|
||||
public function iatWss()
|
||||
{
|
||||
header('X-Accel-Buffering: no');
|
||||
$iatHostUrl = "wss://iat-api.xfyun.cn/v2/iat";
|
||||
$iat = new IatClient($this->app_id, $this->api_key, $this->api_secret);
|
||||
$iat_wss = $iat->assembleAuthUrl($iatHostUrl);
|
||||
//后期添加鉴权
|
||||
return $this->data(['iat_wss' => $iat_wss]);
|
||||
}
|
||||
|
||||
//语音合成(流式版)
|
||||
public function tts()
|
||||
{
|
||||
header('X-Accel-Buffering: no');
|
||||
$ttsHostUrl = "wss://tts-api.xfyun.cn/v2/tts";
|
||||
$text = request()->param('text');
|
||||
if (empty($text)) {
|
||||
return $this->fail('未上传文本参数');
|
||||
}
|
||||
$file_name = date('YmdHis', time()) . mt_rand(1000, 9999) . '.mp3';
|
||||
$date_path = date('Ymd');
|
||||
$dir = app()->getRootPath() . '/public/uploads/audio/' . $date_path;
|
||||
if (!is_dir($dir)) {
|
||||
mkdir($dir, 0755, true);
|
||||
}
|
||||
$audioFile = $dir . '/' . $file_name;
|
||||
$business = [
|
||||
'aue' => 'lame', //mp3格式
|
||||
'vcn' => 'aisjinger', //发音人
|
||||
'auf' => 'audio/L16;rate=16000', //音频采样率
|
||||
'speed' => 50, //语速
|
||||
'volume' => 100, //音量
|
||||
'pitch' => 50, //音高
|
||||
'tte' => 'UTF8'
|
||||
];
|
||||
try {
|
||||
$tts = new TtsClient($this->app_id, $this->api_key, $this->api_secret, $business);
|
||||
file_put_contents($audioFile, $tts->request($text)->getBody()->getContents());
|
||||
//生成语音文件需要定时清理
|
||||
} catch (\Exception $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
return $this->data(['audio_file' => request()->domain() . '/uploads/audio/' . $date_path . '/' . $file_name]);
|
||||
}
|
||||
|
||||
//通用文字识别
|
||||
public function ocr()
|
||||
{
|
||||
$ocrHostUrl = "https://api.xf-yun.com/v1/private/sf8e6aca1";
|
||||
$file = request()->param('image');
|
||||
if (empty($file)) {
|
||||
return $this->fail('未上传图片文件');
|
||||
}
|
||||
/*
|
||||
// 上传图片临时文件
|
||||
$savename = \think\facade\Filesystem::putFile('ocr', $file);
|
||||
$file = app()->getRootPath() . '/runtime/storage/' . $savename;
|
||||
if (!file_exists($file)) {
|
||||
return $this->fail('未上传图片文件');
|
||||
}
|
||||
$filesize = filesize($file);
|
||||
if ($filesize > 4 * 1024 * 1024) {
|
||||
return $this->fail('图片文件不能超过4M');
|
||||
}
|
||||
*/
|
||||
$ext = pathinfo($file, PATHINFO_EXTENSION);
|
||||
$base64_image = base64_encode(file_get_contents($file));
|
||||
$ocr = new OcrClient($this->app_id, $this->api_key, $this->api_secret);
|
||||
$ocrHostUrl = $ocr->assembleAuthUrl($ocrHostUrl);
|
||||
$requestBody = [
|
||||
'header' => [
|
||||
'app_id' => $this->app_id,
|
||||
'status' => 3
|
||||
],
|
||||
'parameter' => [
|
||||
'sf8e6aca1' => [
|
||||
'category' => 'ch_en_public_cloud',
|
||||
'result' => [
|
||||
'encoding' => 'utf8',
|
||||
'compress' => 'raw',
|
||||
'format' => 'json'
|
||||
]
|
||||
]
|
||||
],
|
||||
'payload' => [
|
||||
'sf8e6aca1_data_1' => [
|
||||
'encoding' => $ext,
|
||||
'status' => 3,
|
||||
'image' => $base64_image
|
||||
]
|
||||
]
|
||||
];
|
||||
$text = [];
|
||||
try {
|
||||
$client = new GzClient(['timeout' => 5]);
|
||||
$response = $client->request('POST', $ocrHostUrl, [
|
||||
'json' => $requestBody,
|
||||
'verify' => false
|
||||
]);
|
||||
$responseData = $response->getBody()->getContents();
|
||||
$responseArray = json_decode($responseData, true);
|
||||
if (empty($responseArray['payload']['result']['text'])) {
|
||||
return $this->fail('json解析错误');
|
||||
}
|
||||
$encodeText = $responseArray['payload']['result']['text'];
|
||||
$textArray = json_decode(base64_decode($encodeText), true);
|
||||
$lineArray = $textArray['pages'][0]['lines'] ?? [];
|
||||
foreach($lineArray as $item) {
|
||||
$content = $item['words'][0]['content'] ?? '';
|
||||
if ($content) {
|
||||
$text[] = $content;
|
||||
}
|
||||
}
|
||||
} catch (GuzzleException $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
return $this->data(['words' => $text]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,187 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use think\facade\Db;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Psr7\Request;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Guzzle\Http\Exception\RequestException;
|
||||
|
||||
use Darabonba\OpenApi\OpenApiClient;
|
||||
use AlibabaCloud\OpenApiUtil\OpenApiUtilClient;
|
||||
use Darabonba\OpenApi\Models\Config;
|
||||
use Darabonba\OpenApi\Models\Params;
|
||||
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
|
||||
use Darabonba\OpenApi\Models\OpenApiRequest;
|
||||
|
||||
/**
|
||||
* 阿里云直播
|
||||
* Class ZhiboController
|
||||
*/
|
||||
class ZhiboController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['createPushUrl', 'getPullUrl', 'forbidLiveStream', 'resumeLiveStream', 'test'];
|
||||
|
||||
private $access_key_id = 'LTAI5t7mhH3ij2cNWs1zhPmv';
|
||||
private $access_key_secret = 'gqo2wMpvi8h5bDBmCpMje6BaiXvcPu';
|
||||
|
||||
// 推流host
|
||||
private $push_host = 'rtmp://push-live.lihaink.cn';
|
||||
// 拉流host
|
||||
private $pull_host = 'rtmp://live.lihaink.cn';
|
||||
// URL推流鉴权key
|
||||
private $push_auth_key = '5WRlJV0QxK731AJe';
|
||||
// URL拉流鉴权key
|
||||
private $pull_auth_key = '59YEMIXP9260MZBe';
|
||||
|
||||
public function createPushUrl()
|
||||
{
|
||||
$uri = $this->push_host . '/app/ceshi';
|
||||
$key = $this->push_auth_key;
|
||||
$exp = time() + 3600;
|
||||
$authurl = $this->authKey($uri, $key, $exp);
|
||||
return $this->data(['push_url'=>$authurl]);
|
||||
}
|
||||
|
||||
public function getPullUrl()
|
||||
{
|
||||
$uri = $this->pull_host . '/app/ceshi';
|
||||
$key = $this->pull_auth_key;
|
||||
$exp = time() + 3600;
|
||||
$authurl = $this->authKey($uri, $key, $exp);
|
||||
return $this->data(['push_url'=>$authurl]);
|
||||
}
|
||||
|
||||
private function authKey($uri, $key, $exp)
|
||||
{
|
||||
preg_match("/^(rtmp:\/\/)?([^\/?]+)?(\/[^?]*)?(\\?.*)?$/", $uri, $matches);
|
||||
$scheme = $matches[1] ?? '';
|
||||
$host = $matches[2] ?? '';
|
||||
$path = $matches[3] ?? '';
|
||||
if (empty($scheme)) {
|
||||
$scheme ="rtmp://";
|
||||
}
|
||||
if (empty($path)) {
|
||||
$path ="/";
|
||||
}
|
||||
$uid = $rand = "0";
|
||||
$string = sprintf("%s-%u-%s-%s-%s", $path, $exp, $rand, $uid, $key);
|
||||
$hashvalue = md5($string);
|
||||
$auth_key = sprintf("%u-%s-%s-%s", $exp, $rand, $uid, $hashvalue);
|
||||
return sprintf("%s%s%s?auth_key=%s", $scheme, $host, $path, $auth_key);
|
||||
}
|
||||
|
||||
public function forbidLiveStream()
|
||||
{
|
||||
$config = new Config([
|
||||
"accessKeyId" => $this->access_key_id,
|
||||
"accessKeySecret" => $this->access_key_secret
|
||||
]);
|
||||
$config->endpoint = "live.aliyuncs.com";
|
||||
$client = new OpenApiClient($config);
|
||||
$params = new Params([
|
||||
"action" => "ForbidLiveStream",
|
||||
"version" => "2016-11-01",
|
||||
"protocol" => "HTTP",
|
||||
"method" => "POST",
|
||||
"authType" => "AK",
|
||||
"style" => "RPC",
|
||||
"pathname" => "/",
|
||||
"reqBodyType" => "json",
|
||||
"bodyType" => "json"
|
||||
]);
|
||||
|
||||
$queries = [];
|
||||
$queries["DomainName"] = "push-live.lihaink.cn";
|
||||
$queries["AppName"] = "app";
|
||||
$queries["StreamName"] = "ceshi";
|
||||
$queries["LiveStreamType"] = "publisher";
|
||||
|
||||
$runtime = new RuntimeOptions([]);
|
||||
$request = new OpenApiRequest([
|
||||
"query" => OpenApiUtilClient::query($queries)
|
||||
]);
|
||||
|
||||
$res = $client->callApi($params, $request, $runtime);
|
||||
halt($res);
|
||||
}
|
||||
|
||||
public function resumeLiveStream()
|
||||
{
|
||||
$config = new Config([
|
||||
"accessKeyId" => $this->access_key_id,
|
||||
"accessKeySecret" => $this->access_key_secret
|
||||
]);
|
||||
$config->endpoint = "live.aliyuncs.com";
|
||||
$client = new OpenApiClient($config);
|
||||
$params = new Params([
|
||||
"action" => "ResumeLiveStream",
|
||||
"version" => "2016-11-01",
|
||||
"protocol" => "HTTP",
|
||||
"method" => "POST",
|
||||
"authType" => "AK",
|
||||
"style" => "RPC",
|
||||
"pathname" => "/",
|
||||
"reqBodyType" => "json",
|
||||
"bodyType" => "json"
|
||||
]);
|
||||
|
||||
$queries = [];
|
||||
$queries["DomainName"] = "push-live.lihaink.cn";
|
||||
$queries["LiveStreamType"] = "publisher";
|
||||
$queries["AppName"] = "app";
|
||||
$queries["StreamName"] = "ceshi";
|
||||
|
||||
$runtime = new RuntimeOptions([]);
|
||||
$request = new OpenApiRequest([
|
||||
"query" => OpenApiUtilClient::query($queries)
|
||||
]);
|
||||
|
||||
$res = $client->callApi($params, $request, $runtime);
|
||||
halt($res);
|
||||
}
|
||||
|
||||
public function test() {
|
||||
$config = new Config([
|
||||
"accessKeyId" => $this->access_key_id,
|
||||
"accessKeySecret" => $this->access_key_secret
|
||||
]);
|
||||
$config->endpoint = "live.aliyuncs.com";
|
||||
$client = new OpenApiClient($config);
|
||||
$params = new Params([
|
||||
"action" => "DescribeLiveStreamsOnlineList",
|
||||
"version" => "2016-11-01",
|
||||
"protocol" => "HTTP",
|
||||
"method" => "POST",
|
||||
"authType" => "AK",
|
||||
"style" => "RPC",
|
||||
"pathname" => "/",
|
||||
"reqBodyType" => "json",
|
||||
"bodyType" => "json"
|
||||
]);
|
||||
$queries = [];
|
||||
$queries["DomainName"] = "live.lihaink.cn";
|
||||
|
||||
$runtime = new RuntimeOptions([]);
|
||||
$request = new OpenApiRequest([
|
||||
"query" => OpenApiUtilClient::query($queries)
|
||||
]);
|
||||
|
||||
$res = $client->callApi($params, $request, $runtime);
|
||||
halt($res);
|
||||
}
|
||||
|
||||
}
|
@ -31,13 +31,6 @@ use app\common\model\user\{User, UserAuth};
|
||||
use think\facade\{Db, Config};
|
||||
use Firebase\JWT\JWT;
|
||||
use Firebase\JWT\Key;
|
||||
use Firebase\JWT\SignatureInvalidException;
|
||||
use Firebase\JWT\BeforeValidException;
|
||||
use Firebase\JWT\ExpiredException;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Psr7\Request;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Guzzle\Http\Exception\RequestException;
|
||||
/**
|
||||
* 登录逻辑
|
||||
* Class LoginLogic
|
||||
@ -56,12 +49,6 @@ class LoginLogic extends BaseLogic
|
||||
public static function register(array $params)
|
||||
{
|
||||
try {
|
||||
// 手机号已被使用
|
||||
$mobileUser = User::where(['account' => $params['account']])->find();
|
||||
if (!empty($mobileUser)) {
|
||||
self::setError('手机号已被注册');
|
||||
return false;
|
||||
}
|
||||
$count = User::where('company_id', $params['company_id'])->count();
|
||||
$value = DictData::where('id', 28)->value('value');
|
||||
if ($count >= $value) {
|
||||
@ -83,7 +70,7 @@ class LoginLogic extends BaseLogic
|
||||
if ($params['is_captain']) {
|
||||
$group_id=2;
|
||||
}
|
||||
// 镇农科公司服务部长
|
||||
// 镇管理公司服务部长
|
||||
if ($params['is_service_manager'] == 1) {
|
||||
$user = User::where(['company_id' => $params['company_id'], 'group_id' => 14])->find();
|
||||
if (!empty($user)) {
|
||||
@ -147,9 +134,6 @@ 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();
|
||||
@ -217,116 +201,6 @@ class LoginLogic extends BaseLogic
|
||||
self::setError('无登录信息');
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function parseToken($token){
|
||||
$app_key = 'ae47e94a7dcd1fdfacb499b60e361a8d';
|
||||
try {
|
||||
JWT::$leeway = 10; //当前时间减去10秒,时间留点余地
|
||||
$decoded = JWT::decode($token, new Key($app_key, 'HS256'));
|
||||
$decodedArray = json_decode(json_encode($decoded), true);
|
||||
$jwtData = $decodedArray['data'] ?? [];
|
||||
if (empty($jwtData['uid']) || empty($jwtData['phone'])) {
|
||||
self::setError('当前账号未授权,请手动登录');
|
||||
return false;
|
||||
}
|
||||
$where = ['account|mobile' => $jwtData['phone']];
|
||||
$user = User::where($where)->findOrEmpty();
|
||||
if ($user->isEmpty()) {
|
||||
try {
|
||||
//适配解析商城token
|
||||
$parseHostUrl = env('url.shop_prefix') . '/api/parse/token';
|
||||
$client = new Client(['timeout' => 5]);
|
||||
$requestBody['token'] = $token;
|
||||
$response = $client->request('POST', $parseHostUrl, [
|
||||
'json' => $requestBody,
|
||||
'verify' => false
|
||||
]);
|
||||
$responseData = $response->getBody()->getContents();
|
||||
$responseArray = json_decode($responseData, true);
|
||||
if (empty($responseArray['data']['user']['uid'])) {
|
||||
self::setError('用户不存在,请联系管理员开通供销系统账户');
|
||||
return false;
|
||||
} else {
|
||||
$user_id = $responseArray['data']['user']['uid'];
|
||||
$find = Db::name('user_other')->where('other_user_id', $user_id)->where('type', 'shop_user')->find();
|
||||
if ($find) {
|
||||
$user = User::where('id', $find['user_id'])->findOrEmpty();
|
||||
if ($user->isEmpty()) {
|
||||
self::setError('用户不存在,请联系管理员开通供销系统账户');
|
||||
return false;
|
||||
}
|
||||
$terminal=3;
|
||||
$Android=IndexLogic::isAndroid();
|
||||
if($Android){
|
||||
$terminal=5;
|
||||
}
|
||||
$ios=IndexLogic::isIOS();
|
||||
if($ios){
|
||||
$terminal=6;
|
||||
}
|
||||
$userInfo = UserTokenService::setToken($user->id, $terminal);
|
||||
//返回登录信息
|
||||
$avatar = $user->avatar ?: Config::get('project.default_image.user_avatar');
|
||||
$avatar = FileService::getFileUrl($avatar);
|
||||
return [
|
||||
'nickname' => $userInfo['nickname'],
|
||||
'sn' => $userInfo['sn'],
|
||||
'mobile' => $userInfo['mobile'],
|
||||
'avatar' => $avatar,
|
||||
'token' => $userInfo['token'],
|
||||
];
|
||||
} else {
|
||||
self::setError('用户不存在,请联系管理员开通供销系统账户');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} catch (GuzzleException $e) {
|
||||
//return $this->fail($e->getMessage());self::setError('用户不存在,请联系管理员开通供销系统账户');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//更新登录信息
|
||||
$user->login_time = time();
|
||||
$user->login_ip = request()->ip();
|
||||
$user->save();
|
||||
$terminal=3;
|
||||
$Android=IndexLogic::isAndroid();
|
||||
if($Android){
|
||||
$terminal=5;
|
||||
}
|
||||
$ios=IndexLogic::isIOS();
|
||||
if($ios){
|
||||
$terminal=6;
|
||||
}
|
||||
//设置token
|
||||
$userInfo = UserTokenService::setToken($user->id, $terminal);
|
||||
//返回登录信息
|
||||
$avatar = $user->avatar ?: Config::get('project.default_image.user_avatar');
|
||||
$avatar = FileService::getFileUrl($avatar);
|
||||
$user_id = $jwtData['uid'];
|
||||
return [
|
||||
'nickname' => $userInfo['nickname'],
|
||||
'sn' => $userInfo['sn'],
|
||||
'mobile' => $userInfo['mobile'],
|
||||
'avatar' => $avatar,
|
||||
'token' => $userInfo['token'],
|
||||
];
|
||||
} catch(\Firebase\JWT\SignatureInvalidException $e) {
|
||||
self::setError('签名错误');
|
||||
return false;
|
||||
} catch(\Firebase\JWT\BeforeValidException $e) {
|
||||
self::setError('token无效');
|
||||
return false;
|
||||
} catch(\Firebase\JWT\ExpiredException $e) {
|
||||
self::setError('token已过期');
|
||||
return false;
|
||||
} catch(\Exception $e) {
|
||||
self::setError('非法请求');
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 退出登录
|
||||
* @param $userInfo
|
||||
|
@ -49,9 +49,6 @@ class RechargeLogic extends BaseLogic
|
||||
if(isset($params['task_id']) &&$params['task_id']>0){
|
||||
$data['extend']=json_encode(['task_id'=>$params['task_id'],'type'=>1]);
|
||||
}
|
||||
if(isset($params['type']) &&$params['type']==300){
|
||||
$data['change_type']=300;
|
||||
}
|
||||
$order = RechargeOrder::create($data);
|
||||
|
||||
return [
|
||||
|
@ -76,7 +76,7 @@ class UserLogic extends BaseLogic
|
||||
public static function info(int $userId)
|
||||
{
|
||||
$user = User::where(['id' => $userId])->with(['company'])
|
||||
->field('id,sn,sex,is_new_user,account,nickname,real_name,avatar,mobile,create_time,user_money,deposit,income,admin_id,company_id,is_captain,province,province province_name,city,city city_name,area,area area_name,street,street street_name,village,village village_name,brigade,brigade brigade_name, group_id')
|
||||
->field('id,sn,sex,is_new_user,account,nickname,real_name,avatar,mobile,create_time,user_money,deposit,income,admin_id,company_id,is_captain,province,province province_name,city,city city_name,area,area area_name,street,street street_name,village,village village_name,brigade,brigade brigade_name')
|
||||
->findOrEmpty();
|
||||
// $user['avatar'] = $user['avatar'] ? Request()->host() . $user['avatar'] : $user['avatar'];
|
||||
$user['day_money_count']=UserAccountLog::where(['user_id'=>$userId,'action'=>1])->whereDay('create_time')->sum('change_amount');
|
||||
|
@ -78,7 +78,7 @@ class UserTokenService
|
||||
public static function overtimeToken($token)
|
||||
{
|
||||
$time = time();
|
||||
$userSession = UserSession::where('token', '=', $token)->findOrEmpty();
|
||||
$userSession = UserSession::where('token', '=', $token)->find();
|
||||
if ($userSession->isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
// 应用公共文件
|
||||
use app\common\service\FileService;
|
||||
use JPush\Client;
|
||||
use think\helper\Str;
|
||||
|
||||
/**
|
||||
@ -510,23 +509,4 @@ function curl_post($url,$headers,$data) {
|
||||
$output = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return json_decode($output,true);
|
||||
}
|
||||
|
||||
function push_message($reg_id,$message){
|
||||
//获取配置信息
|
||||
$jpush_config = config('app.jpush');
|
||||
$app_key= $jpush_config['app_key']; //这是app密钥,填你自己的
|
||||
$master_secret= $jpush_config['master_secret']; //这也是密钥,填你自己的
|
||||
//实例化
|
||||
$client = new Client($app_key,$master_secret);
|
||||
$pusher = $client->push();
|
||||
$pusher->setPlatform('all');
|
||||
$pusher->addRegistrationId($reg_id);
|
||||
$pusher->setNotificationAlert($message);
|
||||
try {
|
||||
$res = $pusher->send();
|
||||
return ['code'=>1,'msg'=>'','data'=>$res];
|
||||
} catch (\JPush\Exceptions\JPushException $e) {
|
||||
return ['code'=>0,'msg'=>$e->getMessage(),'data'=>[]];
|
||||
}
|
||||
}
|
@ -1,403 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\controller;
|
||||
|
||||
use alioss\alioss;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\im\UserImMessage;
|
||||
use app\common\model\user\User;
|
||||
use GatewayClient\Gateway;
|
||||
use think\App;
|
||||
use think\facade\Db;
|
||||
use think\response\Json;
|
||||
|
||||
class ImController extends BaseLikeAdminController
|
||||
{
|
||||
public function __construct(App $app)
|
||||
{
|
||||
parent::__construct($app);
|
||||
Gateway::$registerAddress = "172.19.97.179:1256";
|
||||
}
|
||||
|
||||
//获取场景值
|
||||
private function sceneText($scene): string
|
||||
{
|
||||
if($scene == 0){
|
||||
$scene = 'app';
|
||||
}else{
|
||||
$scene = 'web';
|
||||
}
|
||||
return $scene;
|
||||
}
|
||||
|
||||
//获取发送者信息
|
||||
private function getFromUserInfo($uid,$scene): array
|
||||
{
|
||||
//如果是从app端发送的消息,发送者为app端的user用户
|
||||
//如果是从web端发送的消息,发送者为web端的admin用户
|
||||
if($scene == 0){
|
||||
//app端 获取user表数据
|
||||
$data = User::field('id,nickname as name,avatar,register_id')->where('id',$uid)->findOrEmpty()->toArray();
|
||||
}elseif($scene == 1){
|
||||
//web端 获取admin表数据
|
||||
$data = Admin::field('id,name,avatar')->where('id',$uid)->findOrEmpty()->toArray();
|
||||
|
||||
}else{
|
||||
$data = [];
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
//获取接收者信息
|
||||
private function getToUserInfo($uid,$scene): array
|
||||
{
|
||||
//如果是从app端发送的消息,接收者为web端的admin用户
|
||||
//如果是从web端发送的消息,接收者为app端的user用户
|
||||
if($scene == 0){
|
||||
//app端 获取admin表数据
|
||||
$data = Admin::field('id,name,avatar')->where('id',$uid)->findOrEmpty()->toArray();
|
||||
}elseif($scene == 1){
|
||||
//web端 获取user表数据
|
||||
$data = User::field('id,nickname as name,avatar,register_id')->where('id',$uid)->findOrEmpty()->toArray();
|
||||
}else{
|
||||
$data = [];
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/*****************************************************************************************************************************************************************************/
|
||||
|
||||
//绑定uid
|
||||
public function doBindUid(): Json
|
||||
{
|
||||
//验证请求方式
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
//获取请求参数
|
||||
$params = $this->request->post(['client_id','user_id','scene']);
|
||||
if(empty($params['client_id']) || empty($params['user_id']) || !isset($params['scene'])){
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
if(!in_array($params['scene'],[0,1])){
|
||||
return $this->fail('场景错误');
|
||||
}
|
||||
Gateway::bindUid($params['client_id'], $this->sceneText($params['scene']).'_'.$params['user_id']);
|
||||
return $this->success('绑定成功',['msg'=>$this->sceneText($params['scene']).'_'.$params['user_id']]);
|
||||
}
|
||||
|
||||
//发送消息
|
||||
public function sendTextMsg(): Json
|
||||
{
|
||||
//验证请求方式
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
//获取请求参数
|
||||
$params = $this->request->post(['from_user_id','to_user_id','msg_id','content','type','scene']);
|
||||
//验证请求参数
|
||||
if(empty($params['from_user_id']) || empty($params['to_user_id']) || empty($params['content']) || empty($params['msg_id']) || empty($params['type']) || !isset($params['scene'])){
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
if($params['type'] !== 'text'){
|
||||
return $this->fail('消息类型错误');
|
||||
}
|
||||
if(!in_array($params['scene'],[0,1])){
|
||||
return $this->fail('消息场景错误');
|
||||
}
|
||||
//获取发送者信息
|
||||
$fromUserInfo = $this->getFromUserInfo($params['from_user_id'],$params['scene']);
|
||||
if(empty($fromUserInfo)){
|
||||
return $this->fail('发送者信息错误');
|
||||
}
|
||||
//获取接收者信息
|
||||
$toUserInfo = $this->getToUserInfo($params['to_user_id'],$params['scene']);
|
||||
if(empty($toUserInfo)){
|
||||
return $this->fail('接收者信息错误');
|
||||
}
|
||||
//存储信息
|
||||
$saveData = [
|
||||
'from_user_id' => $params['from_user_id'],
|
||||
'to_user_id' => $params['to_user_id'],
|
||||
'content' => $params['content'],
|
||||
'msg_id' => $params['msg_id'],
|
||||
'type' => $params['type'],
|
||||
'is_read' => 0,
|
||||
'is_undo' => 0,
|
||||
'is_delete' => 0,
|
||||
'create_time' => time(),
|
||||
'extends' => null,
|
||||
];
|
||||
//保存消息
|
||||
try {
|
||||
$model = new UserImMessage();
|
||||
$model->save($saveData);
|
||||
if(empty($model->id)){
|
||||
return $this->fail('发送失败');
|
||||
}
|
||||
//发送消息
|
||||
$sendData = [
|
||||
'id' => $model->id,
|
||||
'from_user_id' => $params['from_user_id'],
|
||||
'from_user_name' => $fromUserInfo['name'],
|
||||
'from_user_avatar' => $fromUserInfo['avatar'],
|
||||
'to_user_id' => $params['to_user_id'],
|
||||
'to_user_name' => $toUserInfo['name'],
|
||||
'to_user_avatar' => $toUserInfo['avatar'],
|
||||
'content' => $params['content'],
|
||||
'msg_id' => $params['msg_id'],
|
||||
'type' => $params['type'],
|
||||
'is_read' => 0,
|
||||
'create_time' => $saveData['create_time'],
|
||||
'extends' => null,
|
||||
];
|
||||
if($params['scene'] == 0) {
|
||||
//给admin用户发
|
||||
Gateway::sendToUid($this->sceneText(1).'_'.$params['to_user_id'], json_encode($sendData));
|
||||
}else{
|
||||
//给user用户发
|
||||
Gateway::sendToUid($this->sceneText(0).'_'.$params['to_user_id'], json_encode($sendData));
|
||||
//极光推送
|
||||
if(isset($toUserInfo['register_id']) && !empty($toUserInfo['register_id'])){
|
||||
push_message($toUserInfo['register_id'],$fromUserInfo['name'].':'.$params['content']);
|
||||
}
|
||||
}
|
||||
return $this->success('发送成功',$sendData);
|
||||
}catch (\Exception $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//上传文件
|
||||
public function sendFileMsg(): Json
|
||||
{
|
||||
//验证请求方式
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
//获取请求参数
|
||||
$params = $this->request->post(['from_user_id','to_user_id','msg_id','type','scene']);
|
||||
//获取参数
|
||||
$file = $this->request->file('file');
|
||||
if(empty($file) || empty($params['from_user_id']) || empty($params['to_user_id']) || empty($params['msg_id']) || empty($params['type']) || !isset($params['scene'])){
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
if(!in_array($params['type'],['image','video'])){
|
||||
return $this->fail('消息类型错误');
|
||||
}
|
||||
if(!in_array($params['scene'],[0,1])){
|
||||
return $this->fail('消息场景错误');
|
||||
}
|
||||
//获取发送者信息
|
||||
$fromUserInfo = $this->getFromUserInfo($params['from_user_id'],$params['scene']);
|
||||
if(empty($fromUserInfo)){
|
||||
return $this->fail('发送者信息错误');
|
||||
}
|
||||
//获取接收者信息
|
||||
$toUserInfo = $this->getToUserInfo($params['to_user_id'],$params['scene']);
|
||||
if(empty($toUserInfo)){
|
||||
return $this->fail('接收者信息错误');
|
||||
}
|
||||
$filePath =$file->getRealPath();
|
||||
$fileType = $file->extension();
|
||||
$fileSize = $file->getSize();
|
||||
$ali_oss = new alioss();
|
||||
switch ($params['type']) {
|
||||
case 'image':
|
||||
$result = $ali_oss -> uploadImg($filePath,$fileType,$fileSize);
|
||||
break;
|
||||
case 'video':
|
||||
$result = $ali_oss -> uploadVideo($filePath,$fileType,$fileSize);
|
||||
break;
|
||||
default:
|
||||
return $this->fail('文件类型错误~');
|
||||
}
|
||||
if(!$result || $result['code'] == 0){
|
||||
return $this->fail($result['msg']);
|
||||
}
|
||||
//存储信息
|
||||
$saveData = [
|
||||
'from_user_id' => $params['from_user_id'],
|
||||
'to_user_id' => $params['to_user_id'],
|
||||
'content' => $result['data'],
|
||||
'msg_id' => $params['msg_id'],
|
||||
'type' => $params['type'],
|
||||
'is_read' => 0,
|
||||
'is_undo' => 0,
|
||||
'is_delete' => 0,
|
||||
'create_time' => time(),
|
||||
'extends' => $params['type'] == 'video' ? json_encode(['poster_img'=>$result['data'].'?x-oss-process=video/snapshot,t_1000,m_fast,w_800,f_png']) : null,
|
||||
];
|
||||
try {
|
||||
$model = new UserImMessage();
|
||||
$model->save($saveData);
|
||||
if(empty($model->id)){
|
||||
return $this->fail('发送失败');
|
||||
}
|
||||
//发送消息
|
||||
$sendData = [
|
||||
'id' => $model->id,
|
||||
'from_user_id' => $params['from_user_id'],
|
||||
'from_user_name' => $fromUserInfo['name'],
|
||||
'from_user_avatar' => $fromUserInfo['avatar'],
|
||||
'to_user_id' => $params['to_user_id'],
|
||||
'to_user_name' => $toUserInfo['name'],
|
||||
'to_user_avatar' => $toUserInfo['avatar'],
|
||||
'content' => $result['data'],
|
||||
'msg_id' => $params['msg_id'],
|
||||
'type' => $params['type'],
|
||||
'is_read' => 0,
|
||||
'create_time' => $saveData['create_time'],
|
||||
'extends' => $params['type'] == 'video' ? json_encode(['poster_img'=>$result['data'].'?x-oss-process=video/snapshot,t_1000,m_fast,w_800,f_png']) : null,
|
||||
];
|
||||
if($params['scene'] == 0) {
|
||||
//给admin用户发
|
||||
Gateway::sendToUid($this->sceneText(1).'_'.$params['to_user_id'], json_encode($sendData));
|
||||
}else{
|
||||
//给user用户发
|
||||
Gateway::sendToUid($this->sceneText(0).'_'.$params['to_user_id'], json_encode($sendData));
|
||||
//极光推送
|
||||
if(isset($toUserInfo['register_id']) && !empty($toUserInfo['register_id'])){
|
||||
$push_msg = $params['type'] == 'image' ? '[图片]' : '[视频]';
|
||||
push_message($toUserInfo['register_id'],$fromUserInfo['name'].':'.$push_msg);
|
||||
}
|
||||
}
|
||||
return $this->success('发送成功',$sendData );
|
||||
}catch (\Exception $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//消息列表
|
||||
public function msgList(): Json
|
||||
{
|
||||
//验证请求方式
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
//获取请求参数
|
||||
$params = $this->request->post(['from_user_id','to_user_id','scene','page_no','page_size']);
|
||||
if(empty($params['from_user_id']) || empty($params['to_user_id']) || !isset($params['scene']) || empty($params['page_no']) || empty($params['page_size'])){
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
if(!in_array($params['scene'],[0,1])){
|
||||
return $this->fail('消息场景错误');
|
||||
}
|
||||
//获取发送者信息
|
||||
$fromUserInfo = $this->getFromUserInfo($params['from_user_id'],$params['scene']);
|
||||
if(empty($fromUserInfo)){
|
||||
return $this->fail('发送者信息错误');
|
||||
}
|
||||
//获取接收者信息
|
||||
$toUserInfo = $this->getToUserInfo($params['to_user_id'],$params['scene']);
|
||||
if(empty($toUserInfo)){
|
||||
return $this->fail('接收者信息错误');
|
||||
}
|
||||
//将消息设置为已读
|
||||
UserImMessage::where([['from_user_id','=',$params['to_user_id']],['to_user_id','=',$params['from_user_id']]])->update(['is_read' => 1]);
|
||||
//获取用户消息
|
||||
$msgData = Db::name('user_im_message')->field('id,from_user_id,to_user_id,content,type,is_read,create_time,extends')
|
||||
->whereRaw("(from_user_id = {$params['from_user_id']} AND to_user_id = {$params['to_user_id']}) OR (from_user_id = {$params['to_user_id']} AND to_user_id = {$params['from_user_id']})")
|
||||
->order('create_time desc')
|
||||
->page($params['page_no'],$params['page_size'])
|
||||
->select()->toArray();
|
||||
foreach($msgData as $k=>$v){
|
||||
if($v['from_user_id'] == $params['from_user_id']){
|
||||
$msgData[$k]['from_user_name'] = $fromUserInfo['name'];
|
||||
$msgData[$k]['from_user_avatar'] = $fromUserInfo['avatar'];
|
||||
}else{
|
||||
$msgData[$k]['from_user_name'] = $toUserInfo['name'];
|
||||
$msgData[$k]['from_user_avatar'] = $toUserInfo['avatar'];
|
||||
}
|
||||
if($v['to_user_id'] == $params['to_user_id']){
|
||||
$msgData[$k]['to_user_name'] = $toUserInfo['name'];
|
||||
$msgData[$k]['to_user_avatar'] = $toUserInfo['avatar'];
|
||||
}else{
|
||||
$msgData[$k]['to_user_name'] = $fromUserInfo['name'];
|
||||
$msgData[$k]['to_user_avatar'] = $fromUserInfo['avatar'];
|
||||
}
|
||||
}
|
||||
//返回数据
|
||||
return $this->success('请求成功',$msgData);
|
||||
}
|
||||
|
||||
//获取联系人列表
|
||||
public function contactList(): Json{
|
||||
//验证请求方式
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
//获取请求参数
|
||||
$params = $this->request->post(['user_id','keywords']);
|
||||
if(empty($params['user_id'])){
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
//获取用户信息
|
||||
$userInfo = Admin::where('id',$params['user_id'])->findOrEmpty();
|
||||
//验证用户信息
|
||||
if($userInfo->isEmpty()){
|
||||
return $this->fail('未找到用户信息');
|
||||
}
|
||||
//验证用户身份
|
||||
if(empty($userInfo['role_id']) || $userInfo['role_id'][0] != 8){
|
||||
return $this->fail('用户角色错误');
|
||||
}
|
||||
//获取片区经理创建的公司
|
||||
$company = Company::field('id')->where('area_manager',$userInfo['id'])->column('id');
|
||||
//获取公司的成员
|
||||
$params['keywords'] = !empty($params['keywords']) ? $params['keywords'] : '';
|
||||
$users = User::field('id,nickname as name,avatar')->where('company_id','in',$company)->where('nickname','like','%'.$params['keywords'].'%')->select()->each(function($item) use($params) {
|
||||
//获取消息
|
||||
$msg_no_read = UserImMessage::field('id')->where('from_user_id',$item['id'])->where('to_user_id',$params['user_id'])->where('is_read',0)->count();
|
||||
$last_msg = Db::name('user_im_message')->field('id,content,type,create_time')
|
||||
->whereRaw("(from_user_id = {$item['id']} AND to_user_id = {$params['user_id']}) OR (from_user_id = {$params['user_id']} AND to_user_id = {$item['id']})")
|
||||
->order('create_time desc')->limit(1)->findOrEmpty();
|
||||
$item['no_read_num'] = $msg_no_read;
|
||||
$item['last_msg_content'] = empty($last_msg) ? '' : $last_msg['content'];
|
||||
$item['last_msg_type'] = empty($last_msg) ? '' : $last_msg['type'];
|
||||
$item['last_msg_time'] = empty($last_msg) ? '' : $last_msg['create_time'];
|
||||
})->toArray();
|
||||
$key = array_column($users,'last_msg_time');
|
||||
array_multisort($key,SORT_DESC,$users);
|
||||
//返回数据
|
||||
return $this->success('请求成功',$users);
|
||||
}
|
||||
|
||||
//获取片区经理用户id
|
||||
public function getAreaManager(): Json
|
||||
{
|
||||
//验证请求方式
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
//获取请求参数
|
||||
$params = $this->request->post(['user_id']);
|
||||
if(empty($params['user_id'])){
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
//获取其用户的公司id
|
||||
$userInfo = User::field('id,company_id')->where('id',$params['user_id'])->findOrEmpty();
|
||||
if(empty($userInfo)){
|
||||
return $this->fail('未获取到用户信息');
|
||||
}
|
||||
//获取公司信息
|
||||
$companyInfo = Company::field('area_manager')->where('id',$userInfo['company_id'])->findOrEmpty();
|
||||
if(empty($companyInfo)){
|
||||
return $this->fail('用户信息错误');
|
||||
}
|
||||
if($params['user_id'] == $companyInfo['area_manager']){
|
||||
return $this->fail('用户身份错误');
|
||||
}
|
||||
//获取用户信息
|
||||
$adminInfo = Admin::field('id,name,avatar')->where('id',$companyInfo['area_manager'])->findOrEmpty();
|
||||
//获取片区经理给用户发送的未读消息数
|
||||
$msg_num = UserImMessage::field('id')->where([
|
||||
['from_user_id','=',$adminInfo['id']],
|
||||
['to_user_id','=',$params['user_id']],
|
||||
['is_read','=',0]
|
||||
])->count();
|
||||
//返回
|
||||
return $this->success('请求成功',['to_user_id'=>$adminInfo['id'],'manager_name'=>$adminInfo['name'],'manager_avatar'=>$adminInfo['avatar'],'msg_num'=>$msg_num]);
|
||||
}
|
||||
}
|
@ -15,7 +15,6 @@
|
||||
namespace app\common\logic;
|
||||
|
||||
use app\adminapi\logic\auth\AdminLogic;
|
||||
use app\common\model\auth\AdminRole;
|
||||
use app\common\model\Company;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\auth\Admin;
|
||||
@ -103,10 +102,10 @@ class CompanyLogic extends BaseLogic
|
||||
$admin['password'] = create_password(123456, $passwordSalt);
|
||||
|
||||
$admin_id=Admin::strict(false)->insertGetId($admin);
|
||||
// 镇合伙人公司
|
||||
//镇/街公司
|
||||
if($params['company_type']==16){
|
||||
AdminLogic::insertRole($admin_id, [3]);
|
||||
$admin['group_id']=15;
|
||||
$admin['group_id']=4;
|
||||
}elseif($params['company_type']==17){
|
||||
//村管理公司
|
||||
AdminLogic::insertRole($admin_id, [4]);
|
||||
@ -117,9 +116,9 @@ class CompanyLogic extends BaseLogic
|
||||
AdminLogic::insertRole($admin_id, [6]);
|
||||
$admin['group_id']=5;
|
||||
} elseif ($params['company_type']==41) {
|
||||
//镇农科公司
|
||||
//镇管理公司 总负责人
|
||||
AdminLogic::insertRole($admin_id, [7]); //后台角色
|
||||
$admin['group_id']=4; // 前台角色
|
||||
$admin['group_id']=15; // 前台角色
|
||||
}
|
||||
$userSn = User::createUserSn();
|
||||
$admin['admin_id']=$admin_id;
|
||||
@ -266,76 +265,12 @@ class CompanyLogic extends BaseLogic
|
||||
$admin['avatar'] = !empty($params['avatar']) ? FileService::setFileUrl($params['avatar']) : $defaultAvatar;
|
||||
$admin['phone']=$params['master_phone'];
|
||||
|
||||
// 如果更改了公司类型,则更改公司后台账号和前台账号的角色,以及任务安排
|
||||
$editCompany = Company::where(['id'=>$params['id']])->find();
|
||||
|
||||
|
||||
if($editCompany['company_type'] != $params['company_type']) {
|
||||
if($editCompany['company_type'] == 30){
|
||||
// 平台公司 删除用户角色和任务安排 修改用户角色
|
||||
Db::rollback();
|
||||
throw new Exception('不可将已创建的平台公司变更为其他类型公司');
|
||||
}
|
||||
if($params['company_type'] == 30){
|
||||
// 平台公司 删除用户角色和任务安排 修改用户角色
|
||||
Db::rollback();
|
||||
throw new Exception('不可将已创建的企业变更为平台公司');
|
||||
}
|
||||
if($editCompany['company_type']==16){
|
||||
// 镇合伙人公司
|
||||
$oldAdminRoleId = 3;
|
||||
} elseif ($editCompany['company_type']==17){
|
||||
//村管理公司
|
||||
$oldAdminRoleId = 4;
|
||||
} elseif ($editCompany['company_type']==18) {
|
||||
//小组服务公司
|
||||
$oldAdminRoleId = 6;
|
||||
} elseif ($editCompany['company_type']==41) {
|
||||
//镇农科公司 总负责人
|
||||
$oldAdminRoleId = 7; //后台角色
|
||||
}
|
||||
|
||||
if($params['company_type']==16){
|
||||
$adminRoleId = 3;
|
||||
$userGroupId = 15;
|
||||
} elseif ($params['company_type']==17){
|
||||
$adminRoleId = 4;
|
||||
$userGroupId = 3;
|
||||
} elseif ($params['company_type']==18) {
|
||||
$adminRoleId = 6;
|
||||
$userGroupId = 5;
|
||||
} elseif ($params['company_type']==41) {
|
||||
$adminRoleId = 7; //后台角色
|
||||
$userGroupId = 4; // 前台角色
|
||||
}
|
||||
|
||||
// 更新后台账户角色
|
||||
$adminRoleModel = AdminRole::where(['admin_id'=>$params['admin_id'], 'role_id'=>$oldAdminRoleId])->findOrEmpty();
|
||||
if (!empty($adminRoleModel)) {
|
||||
$adminRoleModel->save(['role_id'=>$adminRoleId]);
|
||||
}
|
||||
|
||||
// 更新前台账户角色
|
||||
$userModel = User::where(['admin_id'=>$params['admin_id'], 'company_id'=>$editCompany['id']])->findOrEmpty();
|
||||
if (!empty($userModel)) {
|
||||
$userModel->save(['group_id'=>$userGroupId]);
|
||||
}
|
||||
|
||||
// 更新任务安排公司类型
|
||||
$taskScheduleModel = TaskScheduling::where(['company_id'=>$params['id'], 'company_type'=>$editCompany['company_type']])->findOrEmpty();
|
||||
if (!empty($taskScheduleModel)) {
|
||||
$taskScheduleModel->save(['company_type'=>$params['company_type']]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Admin::strict(false)->where('id',$params['admin_id'])->update($admin);
|
||||
$admin_id=Admin::where('id',$params['admin_id'])->value('id');
|
||||
Admin::strict(false)->where('account',$account)->update($admin);
|
||||
$admin_id=Admin::where('account',$account)->value('id');
|
||||
// if($params['company_type']==16){
|
||||
// AdminLogic::insertRole($admin_id, [3]);
|
||||
// }
|
||||
$user_id=User::where(['admin_id'=>$params['admin_id'], 'company_id'=> $params['id']])->value('id');
|
||||
$user_id=User::where('account',$account)->value('id');
|
||||
|
||||
$arr['admin_id']=$admin_id;
|
||||
$arr['user_id']=$user_id;
|
||||
@ -348,7 +283,7 @@ class CompanyLogic extends BaseLogic
|
||||
$admin['nickname']=$params['master_name'];
|
||||
$admin['mobile']=$params['master_phone'];
|
||||
$admin['phone']=$params['master_phone'];
|
||||
User::strict(false)->where('id', $user_id)->update($admin);
|
||||
User::strict(false)->where('account',$account)->update($admin);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
@ -424,23 +359,5 @@ class CompanyLogic extends BaseLogic
|
||||
$model->party_b = $companyId;
|
||||
$model->save();
|
||||
return $model->id;
|
||||
|
||||
}
|
||||
public static function getList()
|
||||
{
|
||||
return Company::field(['id', 'company_name', 'province', 'city', 'area', 'street', 'village', 'brigade'])->select()->toArray();
|
||||
}
|
||||
|
||||
public static function getPartyA($companyId)
|
||||
{
|
||||
$company = Company::where(['id' => $companyId])->find();
|
||||
$contract = Contract::where(['party_b'=>$company['id']])->find();
|
||||
if ($contract) {
|
||||
$partyA = Company::where(['id'=>$contract['party_a']])->find()->toArray();
|
||||
return $partyA;
|
||||
} else {
|
||||
self::setError("该公司未与上级公司签约,无法充值押金");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ namespace app\common\logic;
|
||||
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\enum\user\AccountLogEnum;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\company\CompanyAccountLog;
|
||||
use app\common\model\recharge\RechargeOrder;
|
||||
use app\common\model\task\Task;
|
||||
@ -67,31 +66,12 @@ 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;
|
||||
Task::where('id', $order['extend']['task_id'])->update(['status' => 3,'extend'=>json_encode($extend)]);
|
||||
TaskTemplate::where('id', $find['template_id'])->update(['over_decimal' => $order->order_amount]);
|
||||
} else {
|
||||
|
||||
if($order['change_type']==300){
|
||||
$company=Company::where('user_id',$order['user_id'])->find();
|
||||
$left_amount= $company['deposit']+$order->order_amount;
|
||||
$datas = [
|
||||
'sn' => $order->sn,
|
||||
'user_id' => $order->user_id,
|
||||
'company_id' => $company['id']??0,
|
||||
'change_type' => CompanyAccountLog::COMPANY_DEPOSIT,
|
||||
'change_object' => CompanyAccountLog::DEPOSIT,
|
||||
'action' => 1,
|
||||
'change_amount' => $order->order_amount,
|
||||
'left_amount' =>$left_amount,
|
||||
'remark' => '押金充值',
|
||||
];
|
||||
CompanyAccountLog::create($datas);
|
||||
Company::where('id',$company['id'])->update(['deposit'=>$left_amount]);
|
||||
}else{
|
||||
// 增加用户累计充值金额及用户余额
|
||||
$user = User::findOrEmpty($order->user_id);
|
||||
$user->total_recharge_amount += $order->order_amount;
|
||||
@ -107,8 +87,6 @@ class PayNotifyLogic extends BaseLogic
|
||||
$order->sn,
|
||||
'用户充值'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 更新充值订单状态
|
||||
|
@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic;
|
||||
|
||||
use Symfony\Component\HttpClient\HttpClient;
|
||||
|
||||
class PayRequestLogic extends BaseLogic
|
||||
{
|
||||
public static function getPrePayId($param)
|
||||
{
|
||||
try {
|
||||
$requestResponse = HttpClient::create()->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;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,234 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic;
|
||||
|
||||
use Symfony\Component\HttpClient\HttpClient;
|
||||
use think\Exception;
|
||||
|
||||
class ShopRequestLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* 查询时间范围内,某一农科公司下的 供应链商户入驻统计
|
||||
*/
|
||||
public static function getSupplyChainMerchantCount($param)
|
||||
{
|
||||
try {
|
||||
|
||||
$requestResponse = HttpClient::create()->request('GET', env('url.shop_prefix'). '/api/statistics/supply_chain_mer_count', [
|
||||
'query' => $param
|
||||
]);
|
||||
return json_decode($requestResponse->getContent(), true);
|
||||
} catch (Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询供应链商户入驻5天内是否完成商品上架
|
||||
*/
|
||||
public static function getProductListing($param)
|
||||
{
|
||||
try {
|
||||
$requestResponse = HttpClient::create()->request('GET', env('url.shop_prefix'). '/api/statistics/supply_chain_product_count', [
|
||||
'query' => $param
|
||||
]);
|
||||
return json_decode($requestResponse->getContent(), true);
|
||||
} catch (Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 供应链商户入驻20天后是否完成库存更新
|
||||
*/
|
||||
public static function getStockUpdate($param)
|
||||
{
|
||||
try {
|
||||
$requestResponse = HttpClient::create()->request('GET', env('url.shop_prefix'). '/api/statistics/supply_chain_product_stock_count', [
|
||||
'query' => $param
|
||||
]);
|
||||
return json_decode($requestResponse->getContent(), true);
|
||||
} catch (Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询商城商品列表 供任务,模板中指定商品
|
||||
*/
|
||||
public static function getProductList($param)
|
||||
{
|
||||
try {
|
||||
$requestResponse = HttpClient::create()->request('GET', env('url.shop_prefix'). '/api/statistics/product_list', [
|
||||
'query' => $param
|
||||
]);
|
||||
return json_decode($requestResponse->getContent(), true);
|
||||
} catch (Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询供应链商户指定商品采购金额
|
||||
*/
|
||||
public static function getPurchaseAmount($param)
|
||||
{
|
||||
try {
|
||||
$requestResponse = HttpClient::create()->request('GET', env('url.shop_prefix'). '/api/statistics/supply_chain_product_price_count', [
|
||||
'query' => $param
|
||||
]);
|
||||
return json_decode($requestResponse->getContent(), true);
|
||||
} catch (Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询供应链商户指定商品销售金额
|
||||
*/
|
||||
public static function getTradeAmount($param)
|
||||
{
|
||||
try {
|
||||
$requestResponse = HttpClient::create()->request('GET', env('url.shop_prefix'). '/api/statistics/supply_chain_product_price_count', [
|
||||
'query' => $param
|
||||
]);
|
||||
return json_decode($requestResponse->getContent(), true);
|
||||
} catch (Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询镇农科公司区域 指定时间范围内入驻的一般商户数量
|
||||
*/
|
||||
public static function getGeneralMerchantCount($param)
|
||||
{
|
||||
try {
|
||||
$requestResponse = HttpClient::create()->request('GET', env('url.shop_prefix'). '/api/statistics/supply_chain_mer_count', [
|
||||
'query' => $param
|
||||
]);
|
||||
return json_decode($requestResponse->getContent(), true);
|
||||
} catch (Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询一般商户入驻5天内是否完成商品上架
|
||||
*/
|
||||
public static function getGeneralMerchantProductListing($param)
|
||||
{
|
||||
try {
|
||||
$requestResponse = HttpClient::create()->request('GET', env('url.shop_prefix'). '/api/statistics/supply_chain_product_count', [
|
||||
'query' => $param
|
||||
]);
|
||||
return json_decode($requestResponse->getContent(), true);
|
||||
} catch (Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询一般商户入驻5天内是否完成库存更新
|
||||
*/
|
||||
public static function getGeneralMerchantStockUpdate($param)
|
||||
{
|
||||
try {
|
||||
$requestResponse = HttpClient::create()->request('GET', env('url.shop_prefix'). '/api/statistics/supply_chain_product_stock_count', [
|
||||
'query' => $param
|
||||
]);
|
||||
return json_decode($requestResponse->getContent(), true);
|
||||
} catch (Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询一般商户指定商品采购金额
|
||||
*/
|
||||
public static function getGeneralMerchantPurchaseAmount($param)
|
||||
{
|
||||
try {
|
||||
$requestResponse = HttpClient::create()->request('GET', env('url.shop_prefix'). '/api/statistics/supply_chain_street_product_price_count', [
|
||||
'query' => $param
|
||||
]);
|
||||
return json_decode($requestResponse->getContent(), true);
|
||||
} catch (Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询一般商户指定商品销售金额
|
||||
*/
|
||||
public static function getGeneralMerchantTradeAmount($param)
|
||||
{
|
||||
try {
|
||||
$requestResponse = HttpClient::create()->request('GET', env('url.shop_prefix'). '/api/statistics/supply_chain_street_product_price_count', [
|
||||
'query' => $param
|
||||
]);
|
||||
return json_decode($requestResponse->getContent(), true);
|
||||
} catch (Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询村管理公司负责片区内的种养殖商户交易额
|
||||
*/
|
||||
public static function getPlantingAndBreedingMerchantTradeAmount($param)
|
||||
{
|
||||
try {
|
||||
$requestResponse = HttpClient::create()->request('GET', env('url.shop_prefix'). '/api/statistics/supply_chain_village_breeding_price_count', [
|
||||
'query' => $param
|
||||
]);
|
||||
return json_decode($requestResponse->getContent(), true);
|
||||
} catch (Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询镇农科公司负责片区内的种养殖商户和供应链商户交易额 todo 商城还需确认种养殖商户是何种类型
|
||||
*/
|
||||
public static function getTownTradeAmount($param)
|
||||
{
|
||||
try {
|
||||
$requestResponse = HttpClient::create()->request('GET', env('url.shop_prefix'). '/api/statistics/supply_chain_breeding_street_product_count', [
|
||||
'query' => $param
|
||||
]);
|
||||
return json_decode($requestResponse->getContent(), true);
|
||||
} catch (Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询手机号用户的交易金额
|
||||
*/
|
||||
public static function getUserTradeAmount($param)
|
||||
{
|
||||
try {
|
||||
$requestResponse = HttpClient::create()->request('GET', env('url.shop_prefix'). '/api/statistics/store_order_user_trade_amount', [
|
||||
'query' => $param
|
||||
]);
|
||||
return json_decode($requestResponse->getContent(), true);
|
||||
} catch (Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -4,7 +4,6 @@ namespace app\common\logic\approve;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\Approve;
|
||||
use app\common\model\ShopMerchantSettleinLog;
|
||||
use Symfony\Component\HttpClient\HttpClient;
|
||||
use think\facade\Db;
|
||||
use think\facade\Log;
|
||||
@ -12,7 +11,7 @@ use think\facade\Log;
|
||||
|
||||
class ApproveLogic extends BaseLogic
|
||||
{
|
||||
public static function audit($approve, $params, $userInfo)
|
||||
public static function audit($approve, $params)
|
||||
{
|
||||
// 拒绝通过
|
||||
if ($params['check_status'] == 3) {
|
||||
@ -29,7 +28,7 @@ class ApproveLogic extends BaseLogic
|
||||
// 回调商城,通知审核状态
|
||||
if (in_array($approve['type'], [2, 3])) {
|
||||
$shopMerchantInfo = json_decode($approve['extend'], true);
|
||||
self::shopCallBack($approve, $shopMerchantInfo, $params, $userInfo);
|
||||
self::shopCallBack($approve, $shopMerchantInfo, $params);
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,27 +45,15 @@ class ApproveLogic extends BaseLogic
|
||||
$approve->save();
|
||||
}
|
||||
|
||||
private static function shopCallBack(Approve $approve, $shopMerchantInfo, $params, $userInfo)
|
||||
private static function shopCallBack(Approve $approve, $shopMerchantInfo, $params)
|
||||
{
|
||||
$status = $params['check_status'] == 2? 1: 2;
|
||||
// 通过商户入驻审批, 记录商户入驻时间,镇农科公司市场部长任务会使用到
|
||||
if ($status == 1 && $approve['type'] == 2) {
|
||||
$shopMerchantInfo = json_decode($approve['extend'], true);
|
||||
$data = [
|
||||
'town_company_id' => $userInfo['company_id'],
|
||||
'mer_intention_id' => $shopMerchantInfo['mer_intention_id'],
|
||||
'create_time' => time()
|
||||
];
|
||||
ShopMerchantSettleinLog::create($data);
|
||||
}
|
||||
|
||||
// 通知商城审批状态
|
||||
$requestResponse = HttpClient::create()->request('POST', env('url.shop_prefix') . '/api/merchant/syncStatus/'.$shopMerchantInfo['mer_intention_id'], [
|
||||
'body' => ['status' => $status, 'type' => $approve['type'] ==2 ? 1: 2, 'remark'=> $params['remark']??'']
|
||||
]);
|
||||
|
||||
Log::info(['通知商城审批状态-参数', ['status' => $status, 'type' => $approve['type']]]);
|
||||
Log::info(['通知商城审批状态-响应', [$requestResponse->getContent()]]);
|
||||
Log::info('通知商城审批状态-参数', ['status' => $status, 'type' => $approve['type']]);
|
||||
Log::info('通知商城审批状态-响应', [$requestResponse->getContent()]);
|
||||
}
|
||||
|
||||
public static function detail($id)
|
||||
|
@ -23,7 +23,6 @@ use think\facade\Db;
|
||||
use app\api\logic\SmsLogic;
|
||||
use app\common\logic\CompanyLogic;
|
||||
use app\common\logic\UserLogic;
|
||||
use think\facade\Log;
|
||||
|
||||
/**
|
||||
* Contract逻辑
|
||||
@ -245,9 +244,7 @@ class ContractLogic extends BaseLogic
|
||||
|
||||
}
|
||||
|
||||
/**发送合同
|
||||
* @type 1公司 2个人
|
||||
*/
|
||||
// /**发送合同 */
|
||||
public static function Draftingcontracts($params,$type=1)
|
||||
{
|
||||
if($type==1){
|
||||
@ -255,7 +252,6 @@ class ContractLogic extends BaseLogic
|
||||
}else{
|
||||
$result = UserLogic::detail($params['id']);
|
||||
}
|
||||
$result['contract']= Contract::where('id',$params['contract_id'])->with(['party_a_info', 'contractType'])->find();
|
||||
if ($result && isset($result['contract']) && isset($result['contract']['file']) && $result['contract']['file'] != '') {
|
||||
if ($result['contract']['check_status'] == 3) {
|
||||
return self::setError('你已经生成过合同,请勿重复生成');
|
||||
@ -298,7 +294,6 @@ class ContractLogic extends BaseLogic
|
||||
public static function postsms($params)
|
||||
{
|
||||
$result = self::detail($params);
|
||||
Log::info(['发送合同短信', $result]);
|
||||
if ($result && $result['file'] != '') {
|
||||
//发送短信
|
||||
$data = [
|
||||
@ -354,7 +349,6 @@ class ContractLogic extends BaseLogic
|
||||
'code' => 'api/Hetong/url?id=' . $find['id'].'&type='.$v['type'],
|
||||
'scene' => 'WQ'
|
||||
];
|
||||
Log::info(['发送合同短信-消息体', $sms]);
|
||||
$result = SmsLogic::contractUrl($sms);
|
||||
if ($result != true) {
|
||||
return self::setError(SmsLogic::getError());
|
||||
|
@ -52,15 +52,15 @@ class ShareProfit
|
||||
//公司
|
||||
if ($data['company_account_type'] == 1) {
|
||||
$deposit_count = bcadd($company['deposit'], $master_maoney, 2);
|
||||
$this->AccountLog($data['company_id'], $deposit_count, $master_maoney,1,1,1, $data['msg']);
|
||||
$this->AccountLog($data['company_id'], $deposit_count, $master_maoney);
|
||||
|
||||
$company_money_count = bcadd($company['company_money'], $master_maoney, 2);
|
||||
$this->AccountLog($data['company_id'], $company_money_count, $master_maoney, 1, 1,1, $data['msg']);
|
||||
$this->AccountLog($data['company_id'], $company_money_count, $master_maoney);
|
||||
|
||||
Company::where('id', $data['company_id'])->update(['deposit' => Db::raw('deposit+' . $master_maoney), 'company_money' => Db::raw('company_money+' . $master_maoney)]);
|
||||
} elseif ($data['company_account_type'] == 2) {
|
||||
$company_money_count = bcadd($company['shareholder_money'], $data['money'], 2);
|
||||
$this->AccountLog($data['company_id'], $company_money_count, $data['money'], 1, 2, 1, $data['msg']);
|
||||
$this->AccountLog($data['company_id'], $company_money_count, $data['money'], 1, 2);
|
||||
Company::where('id', $data['company_id'])->update([
|
||||
'deposit' => Db::raw('deposit+' . $master_maoney),
|
||||
'company_money' => Db::raw('company_money+' . $master_maoney),
|
||||
@ -81,7 +81,7 @@ class ShareProfit
|
||||
$money = bcdiv($datas['template_info']['over_decimal'], count($responsible_area), 2);
|
||||
$left_amount = 0;
|
||||
foreach ($responsible_area as $kkk => $vvv) {
|
||||
$left_amount += bcadd($company['shareholder_money'], $money, 2);
|
||||
$left_amount += bcadd(1000, $money, 2);
|
||||
$company_log = [
|
||||
'sn' => generate_sn(UserAccountLog::class, 'sn', 20),
|
||||
'company_id' => $datas['company_id'],
|
||||
@ -105,7 +105,7 @@ class ShareProfit
|
||||
}
|
||||
}
|
||||
|
||||
public function AccountLog($companyId, $left_amount, $changeAmount, $change_object = 1, $change_type = 1, $action = 1, $remark='')
|
||||
public function AccountLog($companyId, $left_amount, $changeAmount, $change_object = 1, $change_type = 1, $action = 1)
|
||||
{
|
||||
$company_log = [
|
||||
'sn' => generate_sn(UserAccountLog::class, 'sn', 20),
|
||||
@ -115,7 +115,6 @@ class ShareProfit
|
||||
'action' => $action, //1-增加 2-减少
|
||||
'left_amount' => $left_amount, //变动后数量
|
||||
'change_amount' => $changeAmount, //变动数量
|
||||
'remark' => $remark, //变动数量
|
||||
'status' => 1,
|
||||
];
|
||||
CompanyAccountLog::create($company_log);
|
||||
|
@ -7,8 +7,6 @@ use app\common\logic\AccountLogLogic;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\company\CompanyAccountLog;
|
||||
use app\common\model\task\Task;
|
||||
use app\common\model\task_scheduling_plan\TaskSchedulingPlan;
|
||||
use app\common\model\task_template\TaskTemplate;
|
||||
use app\common\model\user\UserAccountLog;
|
||||
use app\common\model\user\User;
|
||||
use think\facade\Db;
|
||||
@ -16,180 +14,46 @@ use think\facade\Log;
|
||||
|
||||
class TownShareProfit
|
||||
{
|
||||
public function townTaskType1($taskInfo, $townCompany, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function townTaskType2($taskInfo, $townCompany, $taskSchedulePlan, $step, $contractCount)
|
||||
public function townTaskType1($taskInfo, $company, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
$proportion = 0;
|
||||
//总金额除以2等于不可提现账号金额和收益
|
||||
$masterMoney = bcdiv($taskInfo['money'], 2, 2);
|
||||
|
||||
if ($step == 2 && $contractCount >= 15) {
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function townTaskType3($taskInfo, $townCompany, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public function townTaskType4($taskInfo, $townCompany, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function townTaskType5($taskInfo, $townCompany, $taskSchedulePlan, $leftTransactionPool)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
// 更新镇交易池
|
||||
(new TaskTemplate())->updateTransactionPool($taskSchedulePlan['template_info']['id'], $leftTransactionPool);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function townTaskType6($taskInfo, $townCompany, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public function townTaskType7($taskInfo, $townCompany, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 分润
|
||||
*/
|
||||
public function shareProfit($taskInfo, $company, $taskSchedulePlan)
|
||||
{
|
||||
$proportion = 0;
|
||||
//总金额除以2等于不可提现账号金额和收益
|
||||
$masterMoney = bcdiv($taskInfo['money'], 2, 2);
|
||||
|
||||
$remark = '来自任务【' . $taskSchedulePlan['template_info']['title'] . '】,';
|
||||
|
||||
//负责人收益
|
||||
if ($taskSchedulePlan['template_info']['extend']['task_role'] == 1) {
|
||||
$serviceManagerUser = (new User())->searchMaster($company['id']);
|
||||
Log::info([$taskSchedulePlan['template_info']['title'].'结算-市场部长用户信息', $serviceManagerUser]);
|
||||
}
|
||||
//市场部长收益
|
||||
if ($taskSchedulePlan['template_info']['extend']['task_role'] == 2) {
|
||||
$serviceManagerUser = (new User())->searchMarketingManager($company['id']);;
|
||||
Log::info([$taskSchedulePlan['template_info']['title'].'结算-市场部长用户信息', $serviceManagerUser]);
|
||||
}
|
||||
//服务部长收益 任务金额的50%为服务部长的收益
|
||||
if ($taskSchedulePlan['template_info']['extend']['task_role'] == 3) {
|
||||
$serviceManagerUser = (new User())->searchServiceManager($company['id']);;
|
||||
$remark = '来自任务【' . $taskSchedulePlan['template_info']['title'] . '】,';
|
||||
//服务部长收益 任务金额的50%为服务部长的收益
|
||||
$serviceManagerUser = User::where(['company_id' => $company['id'], 'group_id' => 14])->find();
|
||||
Log::info([$taskSchedulePlan['template_info']['title'].'结算-服务部长用户信息', $serviceManagerUser]);
|
||||
// 用户收益变动
|
||||
$arr = [$serviceManagerUser['id'], AccountLogEnum::UM_INC_TASK, AccountLogEnum::INC, $masterMoney, $taskSchedulePlan['sn'], $remark.'任务结算获得收益' . $masterMoney . '元', ['company_id' => $company['id'], 'proportion' => $proportion], 1];
|
||||
$this->master($arr);
|
||||
// 用户余额变动
|
||||
$arr_two = [$serviceManagerUser['id'], AccountLogEnum::UM_INC_TASKUSER, AccountLogEnum::INC, $masterMoney, $taskSchedulePlan['sn'], $remark . '获得账户余额' . $masterMoney . '元', ['company_id' => $company['id'], 'proportion' => $proportion], 1];
|
||||
$this->Account($arr_two);
|
||||
|
||||
// 公司
|
||||
$deposit_count = bcadd($company['deposit'], $masterMoney, 2);
|
||||
// 公司收益变动记录
|
||||
$this->AccountLog($company['id'], $deposit_count, $masterMoney, 1, CompanyAccountLog::TASK_INC_DEPOSIT);
|
||||
$company_money_count = bcadd($company['company_money'], $masterMoney, 2);
|
||||
//公司余额变动记录
|
||||
$this->AccountLog($company['id'], $company_money_count, $masterMoney, 1, CompanyAccountLog::TASK_INC_COMPANY_MONEY);
|
||||
// 变更公司收益和余额
|
||||
Company::where('id', $company['id'])->update(['deposit' => Db::raw('deposit+' . $masterMoney), 'company_money' => Db::raw('company_money+' . $masterMoney)]);
|
||||
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error('54-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// 用户收益变动
|
||||
$arr = [$serviceManagerUser['id'], AccountLogEnum::UM_INC_TASK, AccountLogEnum::INC, $masterMoney, $taskSchedulePlan['sn'], $remark.'任务结算获得收益' . $masterMoney . '元', ['company_id' => $company['id'], 'proportion' => $proportion], 1];
|
||||
$this->master($arr);
|
||||
// 用户余额变动
|
||||
$arr_two = [$serviceManagerUser['id'], AccountLogEnum::UM_INC_TASKUSER, AccountLogEnum::INC, $masterMoney, $taskSchedulePlan['sn'], $remark . '获得账户余额' . $masterMoney . '元', ['company_id' => $company['id'], 'proportion' => $proportion], 1];
|
||||
$this->Account($arr_two);
|
||||
|
||||
// 公司收益
|
||||
$deposit_count = bcadd($company['deposit'], $masterMoney, 2);
|
||||
// 公司收益变动记录
|
||||
$this->AccountLog($company['id'], $deposit_count, $masterMoney, 1, CompanyAccountLog::TASK_INC_INCOME);
|
||||
$company_money_count = bcadd($company['company_money'], $masterMoney, 2);
|
||||
//公司余额变动记录
|
||||
$this->AccountLog($company['id'], $company_money_count, $masterMoney, 1, CompanyAccountLog::TASK_INC_COMPANY_MONEY);
|
||||
// 变更公司收益和余额
|
||||
Company::where('id', $company['id'])->update(['deposit' => Db::raw('deposit+' . $masterMoney), 'company_money' => Db::raw('company_money+' . $masterMoney)]);
|
||||
}
|
||||
|
||||
public function AccountLog($companyId, $left_amount, $changeAmount, $change_object = 1, $change_type = 1, $action = 1)
|
||||
@ -228,317 +92,4 @@ class TownShareProfit
|
||||
{
|
||||
return AccountLogLogic::add($data[0], $data[1], $data[2], $data[3], $data[4], $data[5], $data[6], $data[7]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function dealTaskSettlementMarketingDirector1($taskInfo, $townCompany, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function dealTaskSettlementMarketingDirector2(Task $taskInfo, Company $townCompany, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function dealTaskSettlementMarketingDirector3(Task $taskInfo, Company $townCompany, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function dealTaskSettlementMarketingDirector4(Task $taskInfo, Company $townCompany, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function dealTaskSettlementMarketingDirector5(Task $taskInfo, Company $townCompany, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function dealTaskSettlementMarketingDirector6(Task $taskInfo, Company $townCompany, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function dealTaskSettlementMarketingDirector7(Task $taskInfo, Company $townCompany, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getFile(). $e->getLine(). $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function dealTaskSettlementMarketingDirector8(Task $taskInfo, Company $townCompany, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function dealTaskSettlementMarketingDirector9(Task $taskInfo, Company $townCompany, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function dealTaskSettlementMarketingDirector10(Task $taskInfo, Company $townCompany, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function dealTaskSettlementMaster2(Task $taskInfo, Company $townCompany, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function dealTaskSettlementMaster3(Task $taskInfo, Company $townCompany, $taskSchedulePlan, $leftTransactionPool)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
// 更新交易池
|
||||
(new TaskTemplate())->updateTransactionPool($taskSchedulePlan['template_info']['id'], $leftTransactionPool);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function dealTaskSettlementMaster4(Task $taskInfo, Company $townCompany, $taskSchedulePlan, $leftTransactionPool)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
// 更新交易池
|
||||
(new TaskTemplate())->updateTransactionPool($taskSchedulePlan['template_info']['id'], $leftTransactionPool);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function dealTaskSettlementMaster5(Task $taskInfo, Company $townCompany, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function dealTaskSettlementMaster6(Task $taskInfo, Company $townCompany, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function dealTaskSettlementMaster7(Task $taskInfo, Company $townCompany, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function dealTaskSettlementMaster8(Task $taskInfo, Company $townCompany, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,234 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic\finance;
|
||||
|
||||
use app\common\enum\user\AccountLogEnum;
|
||||
use app\common\logic\AccountLogLogic;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\company\CompanyAccountLog;
|
||||
use app\common\model\task\Task;
|
||||
use app\common\model\task_scheduling_plan\TaskSchedulingPlan;
|
||||
use app\common\model\task_template\TaskTemplate;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\user\UserAccountLog;
|
||||
use think\facade\Db;
|
||||
use think\facade\Log;
|
||||
|
||||
class VillageShareProfit
|
||||
{
|
||||
/**
|
||||
* 分润
|
||||
*/
|
||||
public function shareProfit($taskInfo, $company, $taskSchedulePlan)
|
||||
{
|
||||
$proportion = 0;
|
||||
//总金额除以2等于不可提现账号金额和收益
|
||||
$masterMoney = bcdiv($taskInfo['money'], 2, 2);
|
||||
|
||||
$remark = '来自任务【' . $taskSchedulePlan['template_info']['title'] . '】,';
|
||||
$liaisonMan = (new User())->searchLiaisonMan($company['id']);
|
||||
Log::info([$taskSchedulePlan['template_info']['title'].'结算-村联络员用户信息', $liaisonMan]);
|
||||
|
||||
// 用户收益变动
|
||||
$arr = [$liaisonMan['id'], AccountLogEnum::UM_INC_TASK, AccountLogEnum::INC, $masterMoney, $taskSchedulePlan['sn'], $remark.'任务结算获得收益' . $masterMoney . '元', ['company_id' => $company['id'], 'proportion' => $proportion], 1];
|
||||
$this->master($arr);
|
||||
// 用户余额变动
|
||||
$arr_two = [$liaisonMan['id'], AccountLogEnum::UM_INC_TASKUSER, AccountLogEnum::INC, $masterMoney, $taskSchedulePlan['sn'], $remark . '获得账户余额' . $masterMoney . '元', ['company_id' => $company['id'], 'proportion' => $proportion], 1];
|
||||
$this->Account($arr_two);
|
||||
|
||||
// 公司收益
|
||||
$deposit_count = bcadd($company['deposit'], $masterMoney, 2);
|
||||
// 公司收益变动记录
|
||||
$this->AccountLog($company['id'], $deposit_count, $masterMoney, 1, CompanyAccountLog::TASK_INC_INCOME);
|
||||
$company_money_count = bcadd($company['company_money'], $masterMoney, 2);
|
||||
//公司余额变动记录
|
||||
$this->AccountLog($company['id'], $company_money_count, $masterMoney, 1, CompanyAccountLog::TASK_INC_COMPANY_MONEY);
|
||||
// 变更公司收益和余额
|
||||
Company::where('id', $company['id'])->update(['deposit' => Db::raw('deposit+' . $masterMoney), 'company_money' => Db::raw('company_money+' . $masterMoney)]);
|
||||
}
|
||||
public function AccountLog($companyId, $left_amount, $changeAmount, $change_object = 1, $change_type = 1, $action = 1)
|
||||
{
|
||||
$company_log = [
|
||||
'sn' => generate_sn(UserAccountLog::class, 'sn', 20),
|
||||
'company_id' => $companyId,
|
||||
'change_object' => $change_object, //变动对象
|
||||
'change_type' => $change_type, //变动类型
|
||||
'action' => $action, //1-增加 2-减少
|
||||
'left_amount' => $left_amount, //变动后数量
|
||||
'change_amount' => $changeAmount, //变动数量
|
||||
'status' => 1,
|
||||
];
|
||||
CompanyAccountLog::create($company_log);
|
||||
}
|
||||
/**负责人的分润
|
||||
* @param $data
|
||||
*/
|
||||
private function master($data)
|
||||
{
|
||||
User::where('id', $data[0])->update(['deposit'=>Db::raw('deposit+' . $data[3]),'user_money'=>Db::raw('user_money+' . $data[3])]);
|
||||
return AccountLogLogic::add($data[0], $data[1], $data[2], $data[3], $data[4], $data[5], $data[6], $data[7]);
|
||||
}
|
||||
|
||||
/**成员分润
|
||||
* @param $data
|
||||
*/
|
||||
private function member($data)
|
||||
{
|
||||
User::where('id', $data[0])->update(['deposit'=>Db::raw('deposit+' . $data[3]),'user_money'=>Db::raw('user_money+' . $data[3])]);
|
||||
return AccountLogLogic::add($data[0], $data[1], $data[2], $data[3], $data[4], $data[5], $data[6], $data[7]);
|
||||
}
|
||||
|
||||
private function Account($data)
|
||||
{
|
||||
return AccountLogLogic::add($data[0], $data[1], $data[2], $data[3], $data[4], $data[5], $data[6], $data[7]);
|
||||
}
|
||||
|
||||
public function dealVillageTaskSettlement1(Task $taskInfo, Company $townCompany, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function dealVillageTaskSettlement2($taskInfo, $townCompany, $taskSchedulePlan, $leftTransactionPool)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
// 更新镇交易池
|
||||
(new TaskTemplate())->updateTransactionPool($taskSchedulePlan['template_info']['id'], $leftTransactionPool);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function dealVillageTaskSettlement3($taskInfo, $townCompany, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function dealVillageTaskSettlement4(Task $taskInfo, Company $townCompany, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function dealVillageTaskSettlement5(Task $taskInfo, Company $townCompany, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function dealVillageTaskSettlement6(Task $taskInfo, Company $townCompany, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function dealVillageTaskSettlement7(Task $taskInfo, Company $townCompany, $taskSchedulePlan, $leftTransactionPool)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
// 更新交易池
|
||||
(new TaskTemplate())->updateTransactionPool($taskSchedulePlan['template_info']['id'], $leftTransactionPool);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function dealVillageTaskSettlement8(Task $taskInfo, Company $townCompany, $taskSchedulePlan)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
// 更改结算状态
|
||||
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
|
||||
// 更改任务状态
|
||||
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3,'money' => $taskInfo['money']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -44,7 +44,7 @@ class WithdrawLogic extends BaseLogic
|
||||
|
||||
// 拒绝通过审核,记录备注原因
|
||||
if ($params['status'] == 2) {
|
||||
Withdraw::where(['id'=>$withDrawInfo['id']])->update(['status'=>2, 'deny_desc'=>$params['deny_desc'] ?? '']);
|
||||
Withdraw::where(['id'=>$withDrawInfo['id']])->update(['status'=>2, 'deny_desc'=>$params['deny_desc']]);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ class WithdrawLogic extends BaseLogic
|
||||
|
||||
// 1.扣除公司账户余额
|
||||
$amount = $withDrawInfo['amount']; // 提现金额
|
||||
$leftMoney = bcsub($companyInfo['company_money'], $amount, 2); // 提现后剩余金额
|
||||
$leftMoney = bcsub($companyInfo['company_money'], $amount); // 提现后剩余金额
|
||||
if ($leftMoney < 0) {
|
||||
throw new Exception('公司账户余额不足');
|
||||
}
|
||||
@ -72,7 +72,7 @@ class WithdrawLogic extends BaseLogic
|
||||
$companyAccountLog = [
|
||||
'sn' => generate_sn(UserAccountLog::class, 'sn', 20),
|
||||
'company_id' => $companyInfo['id'],
|
||||
'change_object' => CompanyAccountLog::COMPANY_MONEY, //变动对象
|
||||
'change_object' => CompanyAccountLog::TASK, //变动对象
|
||||
'change_type' => CompanyAccountLog::WITHDRAW_DEC_DEPOSIT, //变动类型
|
||||
'action' => CompanyAccountLog::DEC, //1-增加 2-减少
|
||||
'left_amount' => $leftMoney, //变动后数量
|
||||
@ -90,7 +90,7 @@ class WithdrawLogic extends BaseLogic
|
||||
$tempUserLeftMoney = 0;
|
||||
// 本次提现周期内增加的金额总和 周期内用户状态已完成的 变动类型为任务收益金额增加 动作为增加 未提现状态 的变动金额之和
|
||||
$tempUserMoneySycleTotal = UserAccountLog::where(['user_id'=>$user->id, 'status'=>1, 'action'=>1, 'change_type'=>202, 'is_withdraw'=>0])->where('create_time','<', $endCycle)->sum('change_amount');
|
||||
$tempUserLeftMoney = bcsub($user->user_money,$tempUserMoneySycleTotal, 2);
|
||||
$tempUserLeftMoney = bcsub($user->user_money,$tempUserMoneySycleTotal);
|
||||
if( $tempUserLeftMoney < 0 ){
|
||||
throw new Exception('账户异常,用户余额不足,user_id:'.$user->id.",扣除金额:".$tempUserMoneySycleTotal);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -23,7 +23,6 @@ use app\common\model\company\CompanyProperty;
|
||||
use app\common\model\informationg\UserInformationg;
|
||||
use app\common\model\task_scheduling\TaskScheduling;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\vehicle\VehicleRent;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
@ -48,23 +47,19 @@ class TaskTemplateLogic extends BaseLogic
|
||||
try {
|
||||
Db::startTrans();
|
||||
|
||||
// 其他任务可重复创建
|
||||
if ($params['type'] != 34) {
|
||||
$find=TaskTemplate::where('task_scheduling', $params['task_scheduling'])->where('company_id',$params['company_id'])->where('type',$params['type'])->field('id,types,type')->find();
|
||||
if($find&&$params['type']==$find['type']){
|
||||
self::setError('已经有同一种任务类型了');
|
||||
$find=TaskTemplate::where('task_scheduling', $params['task_scheduling'])->where('company_id',$params['company_id'])->where('type',$params['type'])->field('id,types,type')->find();
|
||||
if($find&&$params['type']==$find['type']){
|
||||
self::setError('已经有同一种任务类型了');
|
||||
return false;
|
||||
}
|
||||
if($params['type']==33){
|
||||
$count=UserInformationg::where('company_id',$params['company_id'])->where('status',1)->count();
|
||||
if($count<300){
|
||||
self::setError('用户档案数量300不足,无法创建任务模板');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// if($params['type']==33){
|
||||
// $count=UserInformationg::where('company_id',$params['company_id'])->where('status',1)->count();
|
||||
// if($count<300){
|
||||
// self::setError('用户档案数量300不足,无法创建任务模板');
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
$moeny=TaskTemplate::where('company_id', $params['company_id'])->sum('money');
|
||||
if($moeny+$params['money']>200){
|
||||
self::setError('任务模板一阶段合计金额不能大于任务调度金额');
|
||||
@ -81,8 +76,8 @@ class TaskTemplateLogic extends BaseLogic
|
||||
return false;
|
||||
}
|
||||
if($params['type']==32){
|
||||
$VehicleRent = VehicleRent::where('rent_company_id',$params['company_id'])->find();
|
||||
if(empty($VehicleRent)){
|
||||
$object_id=CompanyProperty::where('company_id',$params['company_id'])->value('object_id');
|
||||
if(!$object_id){
|
||||
self::setError('该公司没有三轮车,请先租赁三轮车');
|
||||
return false;
|
||||
}
|
||||
@ -113,7 +108,6 @@ class TaskTemplateLogic extends BaseLogic
|
||||
'stage_day_two' => $params['stage_day_two']??0,
|
||||
'proportion_two' => $params['proportion_two']??0,
|
||||
'recharge' => $params['recharge']??0,
|
||||
// 'cron_time' => strtotime($params['cron_time']), // 定时下发日期
|
||||
]);
|
||||
Db::commit();
|
||||
return true;
|
||||
@ -136,43 +130,36 @@ class TaskTemplateLogic extends BaseLogic
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$company = Company::find($params['company_id']);
|
||||
if ($company->company_type == 16) {
|
||||
// 创建 镇合伙人公司 任务模板
|
||||
$taskScheduleAmount = 700;
|
||||
} 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,extend')->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')->find();
|
||||
if($find && $find['id']!=$params['id']&&$params['type']==$find['type']){
|
||||
self::setError('已经有同一种任务类型了');
|
||||
return false;
|
||||
}
|
||||
// if($params['type']==33){
|
||||
// $count=UserInformationg::where('company_id',$params['company_id'])->where('status',1)->count();
|
||||
// if($count<300){
|
||||
// self::setError('用户档案数量300不足,无法创建任务模板');
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
if($params['type']==33){
|
||||
$count=UserInformationg::where('company_id',$params['company_id'])->where('status',1)->count();
|
||||
if($count<300){
|
||||
self::setError('用户档案数量300不足,无法创建任务模板');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$moeny=TaskTemplate::where('company_id', $params['company_id'])->sum('money');
|
||||
if($moeny+$params['money']-$find['money']>$taskScheduleAmount){
|
||||
if($moeny+$params['money']-$find['money']>200){
|
||||
self::setError('任务模板一阶段合计金额不能大于任务调度金额');
|
||||
return false;
|
||||
}
|
||||
$money_two=TaskTemplate::where('company_id', $params['company_id'])->sum('money_two');
|
||||
if($money_two+$params['money_two']-$find['money_two']>$taskScheduleAmount){
|
||||
if($money_two+$params['money_two']-$find['money_two']>200){
|
||||
self::setError('任务模板二阶段合计金额不能大于任务调度金额');
|
||||
return false;
|
||||
}
|
||||
$money_three=TaskTemplate::where('company_id', $params['company_id'])->sum('money_three');
|
||||
if($money_three+$params['money_three']-$find['money_three']>$taskScheduleAmount){
|
||||
if($money_three+$params['money_three']-$find['money_three']>200){
|
||||
self::setError('任务模板长期合计金额不能大于任务调度金额');
|
||||
return false;
|
||||
}
|
||||
if($params['type']==32){
|
||||
$VehicleRent = VehicleRent::where('rent_company_id',$params['company_id'])->find();
|
||||
if(empty($VehicleRent)){
|
||||
$object_id=CompanyProperty::where('company_id',$params['company_id'])->value('object_id');
|
||||
if(!$object_id){
|
||||
self::setError('该公司没有三轮车,请先租赁三轮车');
|
||||
return false;
|
||||
}
|
||||
@ -194,7 +181,7 @@ class TaskTemplateLogic extends BaseLogic
|
||||
'types' => $params['types'],
|
||||
'status' => $params['status'],
|
||||
'content' => $params['content'],
|
||||
'extend'=>json_encode(array_merge($find['extend'],$params['extend'])),
|
||||
'extend'=>json_encode($params['extend']),
|
||||
'stage_day_one' => $params['stage_day_one']??0,
|
||||
'proportion_one' => $params['proportion_one']??0,
|
||||
'stage_day_two' => $params['stage_day_two']??0,
|
||||
@ -264,108 +251,11 @@ class TaskTemplateLogic extends BaseLogic
|
||||
try {
|
||||
Db::startTrans();
|
||||
|
||||
// $params['extend']['task_role'] 扩展字段 任务角色 1总负责人 2市场部长 3服务部长
|
||||
$taskScheduleAmount = 700;
|
||||
if ($params['extend']['task_role'] == 1) {
|
||||
$serviceManagerUser = (new User())->searchMaster($params['company_id']);
|
||||
if (empty($serviceManagerUser)) {
|
||||
self::setError('公司还没有负责人,无法指派任务');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ($params['extend']['task_role'] == 2) {
|
||||
$serviceManagerUser = (new User())->searchMarketingManager($params['company_id']);
|
||||
if (empty($serviceManagerUser)) {
|
||||
self::setError('公司还没有市场部长,无法指派任务');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($params['extend']['task_role'] == 3) {
|
||||
$serviceManagerUser = (new User())->searchServiceManager($params['company_id']);
|
||||
if (empty($serviceManagerUser)) {
|
||||
self::setError('公司还没有服务部长,无法指派任务');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$find = TaskTemplate::where('task_scheduling', $params['task_scheduling'])->where('company_id',$params['company_id'])->where('type',$params['type'])->field('id,types,type')->find();
|
||||
if($find && $params['type'] == $find['type']){
|
||||
self::setError('已经有同一种任务类型了');
|
||||
return false;
|
||||
}
|
||||
|
||||
$moeny = TaskTemplate::where('company_id', $params['company_id'])->sum('money');
|
||||
if($moeny + $params['money'] > $taskScheduleAmount){
|
||||
self::setError('任务模板一阶段合计金额不能大于任务调度金额');
|
||||
return false;
|
||||
}
|
||||
$moneyTwo = TaskTemplate::where('company_id', $params['company_id'])->sum('money_two');
|
||||
if($moneyTwo + $params['money_two'] > $taskScheduleAmount){
|
||||
self::setError('任务模板二阶段合计金额不能大于任务调度金额');
|
||||
return false;
|
||||
}
|
||||
$newMoneyThree = TaskTemplate::where('company_id', $params['company_id'])->sum('new_money_three');
|
||||
if($newMoneyThree + $params['new_money_three'] > $taskScheduleAmount){
|
||||
self::setError('任务模板三阶段合计金额不能大于任务调度金额');
|
||||
return false;
|
||||
}
|
||||
$moneyThree = TaskTemplate::where('company_id', $params['company_id'])->sum('money_three');
|
||||
if($moneyThree + $params['money_three']>$taskScheduleAmount){
|
||||
self::setError('任务模板长期合计金额不能大于任务调度金额');
|
||||
return false;
|
||||
}
|
||||
|
||||
TaskTemplate::create([
|
||||
'title' => $params['title'],
|
||||
'admin_id' => $params['admin_id'],
|
||||
'company_id' => $params['company_id'],
|
||||
'task_scheduling' => $params['task_scheduling']??0,
|
||||
'money' => $params['money'],
|
||||
'money_two' => $params['money_two'],
|
||||
'money_three' => $params['money_three'],
|
||||
'type' => $params['type'],
|
||||
'types' => $params['types'],
|
||||
'status' => $params['status'],
|
||||
'content' => $params['content'],
|
||||
'extend'=>json_encode($params['extend']),
|
||||
'stage_day_one' => $params['stage_day_one']??0,
|
||||
'proportion_one' => $params['proportion_one']??0,
|
||||
'stage_day_two' => $params['stage_day_two']??0,
|
||||
'proportion_two' => $params['proportion_two']??0,
|
||||
'recharge' => $params['recharge']??0,
|
||||
'stage_day_three' => $params['stage_day_three']??0,
|
||||
'new_money_three' => $params['new_money_three']??0,
|
||||
// 'cron_time' => strtotime($params['cron_time']), // 定时下发日期
|
||||
]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @notes 添加任务模板
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2023/08/06 17:30
|
||||
*/
|
||||
public static function addVillageTaskTemplate(array $params): bool
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
|
||||
|
||||
$serviceManagerUser = (new User())->searchLiaisonMan($params['company_id']);
|
||||
$serviceManagerUser = (new User())->searchServiceManager($params['company_id']);
|
||||
if (empty($serviceManagerUser)) {
|
||||
self::setError('公司还没有村联络员,无法指派任务');
|
||||
self::setError('公司还没有服务部长,无法指派任务');
|
||||
return false;
|
||||
}
|
||||
|
||||
$find = TaskTemplate::where('task_scheduling', $params['task_scheduling'])->where('company_id',$params['company_id'])->where('type',$params['type'])->field('id,types,type')->find();
|
||||
if($find && $params['type'] == $find['type']){
|
||||
self::setError('已经有同一种任务类型了');
|
||||
@ -413,7 +303,6 @@ class TaskTemplateLogic extends BaseLogic
|
||||
'recharge' => $params['recharge']??0,
|
||||
'stage_day_three' => $params['stage_day_three']??0,
|
||||
'new_money_three' => $params['new_money_three']??0,
|
||||
// 'cron_time' => strtotime($params['cron_time']), // 定时下发日期
|
||||
]);
|
||||
Db::commit();
|
||||
return true;
|
||||
|
@ -109,11 +109,4 @@ class UserRoleLogic extends BaseLogic
|
||||
{
|
||||
return UserRole::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
|
||||
public static function getList()
|
||||
{
|
||||
return UserRole::order(['id' => 'desc'])->field(['id', 'name'])
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
}
|
@ -11,23 +11,6 @@ class Approve extends BaseModel
|
||||
use SoftDelete;
|
||||
protected $name = 'approve';
|
||||
protected $deleteTime = 'delete_time';
|
||||
const APPROVE_TYPE_1 = 1; // 其他任务
|
||||
const APPROVE_TYPE_2 = 2; // 商户入驻
|
||||
const APPROVE_TYPE_3 = 3; // 开通交易
|
||||
const APPROVE_TYPE_4 = 4; // 镇农科市场部长数字农贸宣传业务、加工业务的建设和招商任务
|
||||
|
||||
const APPROVE_TYPE_5 = 5; // 村联络员任务-信息平台铺设工作任务
|
||||
const APPROVE_TYPE_6 = 6; // 村联络员任务-日常管理及其他临时任务
|
||||
|
||||
const APPROVE_TYPE_7 = 7; // 镇农科负责人任务-应用软件推广
|
||||
|
||||
const APPROVE_TYPE_8 = 8; // 镇农科负责人任务-政策补贴申请
|
||||
const APPROVE_TYPE_9 = 9; // 镇农科负责人任务-日常管理及其他临时任务
|
||||
const APPROVE_TYPE_10 = 10; // 小组团队任务-入股任务
|
||||
const APPROVE_TYPE_11 = 11; // 村联络员任务-督促小组服务团队入股
|
||||
const APPROVE_TYPE_12 = 12; // 村联络员任务-入股甲方公司
|
||||
const APPROVE_TYPE_13 = 13; // 镇农科服务部长任务-督促入股村管理公司
|
||||
const APPROVE_TYPE_14 = 14; // 镇农科负责人任务-促成村联络员入股甲方
|
||||
|
||||
public function task()
|
||||
{
|
||||
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* CompanyComplaintFeedback模型
|
||||
* Class CompanyComplaintFeedback
|
||||
* @package app\common\model
|
||||
*/
|
||||
class CompanyComplaintFeedback extends BaseModel
|
||||
{
|
||||
|
||||
protected $name = 'company_complaint_feedback';
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
class CompanyDepositVoucher extends BaseModel
|
||||
{
|
||||
protected $name = 'company_deposit_voucher';
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
class ShopMerchantSettleinLog extends BaseModel
|
||||
{
|
||||
protected $name = 'shop_merchant_settlein_log';
|
||||
}
|
@ -41,18 +41,9 @@ class CompanyAccountLog extends BaseModel
|
||||
*/
|
||||
const TASK = 1;
|
||||
/**
|
||||
* 公司股金
|
||||
* 股金
|
||||
*/
|
||||
const SHAREHOLDER = 2;
|
||||
/**
|
||||
* 公司余额
|
||||
*/
|
||||
const COMPANY_MONEY = 3;
|
||||
|
||||
/**
|
||||
* 公司押金
|
||||
*/
|
||||
const DEPOSIT = 4;
|
||||
|
||||
/**
|
||||
* 动作
|
||||
@ -81,13 +72,13 @@ class CompanyAccountLog extends BaseModel
|
||||
const WITHDRAW_DEC_DEPOSIT = 102;
|
||||
|
||||
/**
|
||||
* 公司金额变动类型
|
||||
* 用户余额增加类型
|
||||
*/
|
||||
|
||||
/**
|
||||
* 任务收益
|
||||
*/
|
||||
const TASK_INC_INCOME = 200;
|
||||
const TASK_INC_DEPOSIT = 200;
|
||||
/**
|
||||
* 公司余额
|
||||
*/
|
||||
@ -97,9 +88,4 @@ class CompanyAccountLog extends BaseModel
|
||||
*/
|
||||
const TASK_INC_SHAREHOLDER_MONEY = 202;
|
||||
|
||||
/**
|
||||
* 押金
|
||||
*/
|
||||
const COMPANY_DEPOSIT = 300;
|
||||
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model\create_task_template;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
/**
|
||||
* CreateTaskTemplate模型
|
||||
* Class CreateTaskTemplate
|
||||
* @package app\common\model\create_task_template
|
||||
*/
|
||||
class CreateTaskTemplate extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
protected $name = 'create_task_template';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
|
||||
}
|
@ -44,13 +44,4 @@ class DictData extends BaseModel
|
||||
return $data['status'] ? '正常' : '停用';
|
||||
}
|
||||
|
||||
// 根据镇农科公司任务类型,获取code
|
||||
public function getTownTaskType($typeId){
|
||||
$townTaskTypeList = DictData::where(['type_value' => 'town_task_type', 'status' => 1])->column('value', 'id');
|
||||
if(isset($townTaskTypeList[$typeId])) {
|
||||
return $townTaskTypeList[$typeId];
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model\im;
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
|
||||
class UserImMessage extends BaseModel
|
||||
{
|
||||
protected $name = 'user_im_message';
|
||||
}
|
@ -8,7 +8,6 @@ use think\facade\Log;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\user\User;
|
||||
use app\job\AiAianalyse;
|
||||
|
||||
class UserInformationg extends BaseModel
|
||||
{
|
||||
@ -88,44 +87,24 @@ class UserInformationg extends BaseModel
|
||||
|
||||
public static function informationg_demand($param, $id, $admin_id)
|
||||
{
|
||||
$data_field = [];
|
||||
if (isset($param['card_id']) && $param['card_id'] > 0) {
|
||||
$category_info = Db::name('category_business')->where('id', $param['card_id'])->field(['pid', 'data_field'])->find();
|
||||
$category_id = Db::name('category_business')->where('id', $param['card_id'])->value('pid');
|
||||
$category_child = $param['card_id'];
|
||||
$field_array = json_decode($category_info['data_field'], true);
|
||||
if (!empty($field_array) && is_array($field_array)) {
|
||||
// 拼装词语
|
||||
foreach($param['datas'] as $k => $v) {
|
||||
if (!empty($field_array[$k]['text'])) {
|
||||
$key = $field_array[$k]['text'];
|
||||
if (!empty($field_array[$k]['enum'])) {
|
||||
$data_field[$key] = $field_array[$k]['enum'][$v] ?? '';
|
||||
} else {
|
||||
$data_field[$key] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$category_id = 0;
|
||||
$category_child = 0;
|
||||
}
|
||||
$data = [
|
||||
'create_user_id' => $admin_id,
|
||||
'category_id' => $category_info['pid'] ?? 0,
|
||||
'category_id' => $category_id,
|
||||
'category_child' => $category_child,
|
||||
'data' => json_encode($param['datas']),
|
||||
'data_field' => json_encode($data_field),
|
||||
'create_time' => time(),
|
||||
'update_time' => time(),
|
||||
'status' => 1,
|
||||
'information_id' => $id,
|
||||
];
|
||||
$res = UserInformationgDemand::create($data);
|
||||
if ($res) {
|
||||
queue(AiAianalyse::class, $data);
|
||||
}
|
||||
return $res;
|
||||
return UserInformationgDemand::create($data);
|
||||
}
|
||||
|
||||
public static function details($id)
|
||||
@ -133,20 +112,18 @@ class UserInformationg extends BaseModel
|
||||
$item = self::where('id', $id)->field('*,area_id area_name,street_id street_name,village_id village_name,brigade_id brigade_name')->find();
|
||||
$item['family'] = json_decode($item['family'], true);
|
||||
$item['child_arr'] = json_decode($item['child_arr'], true);
|
||||
$data = UserInformationgDemand::where('information_id', $id)->order('id', 'desc')->select()->toArray();
|
||||
$data = UserInformationgDemand::where('information_id', $id)->order('id', 'desc')->select();
|
||||
$item['datas'] = [];
|
||||
$datas = [];
|
||||
if ($data) {
|
||||
foreach ($data as $k => $v) {
|
||||
$a = json_decode($v['data'], true);
|
||||
$arr = [
|
||||
'id' => $v['category_child'],
|
||||
'update_time' => $v['update_time'],
|
||||
'datas' => $v['data'],
|
||||
'data_field' => json_decode($v['data_field']),
|
||||
'ai_question' => $v['ai_question'],
|
||||
'ai_aianalyse' => $v['ai_aianalyse'],
|
||||
'datas' => $a
|
||||
];
|
||||
if ($v['data']) {
|
||||
if ($a) {
|
||||
array_push($datas, $arr);
|
||||
}
|
||||
}
|
||||
@ -155,19 +132,6 @@ class UserInformationg extends BaseModel
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function business_opportunity($informationg_id_array)
|
||||
{
|
||||
$demand_id_array = UserInformationgDemand::whereIn('information_id', $informationg_id_array)->where('status', 1)->field(['max(id) as demand_id'])->group('information_id')->select()->column('demand_id');
|
||||
$data = UserInformationgDemand::whereIn('id', $demand_id_array)->column('*', 'information_id');
|
||||
foreach($data as &$item) {
|
||||
$item['data'] = json_decode($item['data'], true);
|
||||
$item['data_field'] = json_decode($item['data_field'], true);
|
||||
$item['relation_goods'] = [];
|
||||
}
|
||||
unset($item);
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function company()
|
||||
{
|
||||
return $this->hasOne(Company::class, 'id', 'company_id')->field(['id', 'company_name', 'admin_id']);
|
||||
|
@ -6,12 +6,5 @@ use app\common\model\BaseModel;
|
||||
|
||||
class UserInformationgDemand extends BaseModel
|
||||
{
|
||||
public function getDataAttr($value)
|
||||
{
|
||||
if($value){
|
||||
return json_decode($value,true);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ namespace app\common\model\task;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use app\common\model\task_scheduling_plan\TaskSchedulingPlan;
|
||||
use app\common\model\user\User;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
@ -48,9 +47,5 @@ class Task extends BaseModel
|
||||
{
|
||||
return $this->hasOne(User::class, 'id', 'director_uid')->field(['id', 'nickname', 'avatar']);
|
||||
}
|
||||
// 关闭任务
|
||||
public function closeTask($id) {
|
||||
return Task::where(['id'=>$id])->save(['status'=>5]);
|
||||
}
|
||||
|
||||
}
|
@ -17,7 +17,6 @@ namespace app\common\model\task_scheduling_plan;
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\task\Task;
|
||||
use app\common\model\task_scheduling\TaskScheduling;
|
||||
use app\common\model\task_template\TaskTemplate;
|
||||
use app\common\model\user\User;
|
||||
@ -47,10 +46,6 @@ class TaskSchedulingPlan extends BaseModel
|
||||
{
|
||||
return $this->hasOne(TaskTemplate::class, 'id', 'template_id')->bind(['template_name'=>'title']);
|
||||
}
|
||||
public function task()
|
||||
{
|
||||
return $this->hasOne(Task::class, 'id', 'task_id');
|
||||
}
|
||||
public function templateInfo()
|
||||
{
|
||||
return $this->hasOne(TaskTemplate::class, 'id', 'template_id');
|
||||
@ -62,7 +57,4 @@ class TaskSchedulingPlan extends BaseModel
|
||||
public function scheduling(){
|
||||
return $this->hasOne(TaskScheduling::class,'id','scheduling_id');
|
||||
}
|
||||
public function settlement($id=0){
|
||||
TaskSchedulingPlan::where('id', $id)->update(['is_pay' => 1]);
|
||||
}
|
||||
}
|
@ -53,8 +53,4 @@ class TaskTemplate extends BaseModel
|
||||
return json_decode($value,true);
|
||||
}
|
||||
}
|
||||
public function updateTransactionPool($id, $transactionPool)
|
||||
{
|
||||
return TaskTemplate::where('id', $id)->save(['transaction_pool' => $transactionPool]);
|
||||
}
|
||||
}
|
@ -221,27 +221,8 @@ class User extends BaseModel
|
||||
}
|
||||
}
|
||||
|
||||
// 查询镇合伙人服务部长
|
||||
public function searchServiceManager($companyId)
|
||||
{
|
||||
return User::where(['company_id' => $companyId, 'group_id'=> 14])->find();
|
||||
}
|
||||
|
||||
// 查询镇合伙人负责人
|
||||
public function searchMaster($companyId)
|
||||
{
|
||||
return User::where(['company_id' => $companyId, 'group_id'=> 15])->find();
|
||||
}
|
||||
|
||||
// 查询镇合伙人市场部长
|
||||
public function searchMarketingManager($companyId)
|
||||
{
|
||||
return User::where(['company_id' => $companyId, 'group_id'=> 16])->find();
|
||||
}
|
||||
|
||||
// 查询村联络员
|
||||
public function searchLiaisonMan($companyId)
|
||||
{
|
||||
return User::where(['company_id' => $companyId, 'group_id'=> 17])->find();
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model\vehicle;
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
|
||||
class VehicleBuyRecord extends BaseModel
|
||||
{
|
||||
protected $name = 'vehicle_buy_record';
|
||||
}
|
@ -376,7 +376,6 @@ class WeChatPayService extends BasePayService
|
||||
switch ($attach) {
|
||||
case 'recharge':
|
||||
$order = RechargeOrder::where(['sn' => $message['out_trade_no']])->findOrEmpty();
|
||||
Log::info('wechat pay notify: ' . var_export($order, true));
|
||||
if($order->isEmpty() || $order->pay_status == PayEnum::ISPAID) {
|
||||
return true;
|
||||
}
|
||||
|
@ -1,28 +0,0 @@
|
||||
<?php
|
||||
namespace app\common\service\workerim;
|
||||
|
||||
use GatewayClient\Gateway;
|
||||
|
||||
/**
|
||||
* 主逻辑
|
||||
* 主要是处理 onConnect onMessage onClose 三个方法
|
||||
* onConnect 和 onClose 如果不需要可以不用实现并删除
|
||||
*/
|
||||
class Events
|
||||
{
|
||||
|
||||
// 当有客户端连接时,将client_id返回,让mvc框架判断当前uid并执行绑定
|
||||
public static function onConnect($client_id): void
|
||||
{
|
||||
Gateway::sendToClient($client_id, json_encode(array(
|
||||
'type' => 'init',
|
||||
'client_id' => $client_id
|
||||
)));
|
||||
}
|
||||
|
||||
// GatewayWorker建议不做任何业务逻辑,onMessage留空即可
|
||||
public static function onMessage($client_id, $message): void
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
use GatewayWorker\BusinessWorker;
|
||||
use Workerman\Worker;
|
||||
|
||||
|
||||
// 自动加载类
|
||||
require_once __DIR__ . '/../../../../vendor/autoload.php';
|
||||
|
||||
// bussinessWorker 进程
|
||||
$worker = new BusinessWorker();
|
||||
|
||||
// worker名称
|
||||
$worker->name = 'PushBusinessWorker';
|
||||
|
||||
// bussinessWorker进程数量
|
||||
$worker->count = 4;
|
||||
|
||||
// 服务注册地址
|
||||
$worker->registerAddress = '172.19.97.179:1256';
|
||||
|
||||
// 注册服务类
|
||||
$worker->eventHandler = 'app\common\service\workerim\Events';
|
||||
|
||||
// 如果不是在根目录启动,则运行runAll方法
|
||||
if(!defined('GLOBAL_START'))
|
||||
{
|
||||
Worker::runAll();
|
||||
}
|
||||
|
@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
use \Workerman\Worker;
|
||||
use \GatewayWorker\Gateway;
|
||||
|
||||
// 自动加载类
|
||||
require_once __DIR__ . '/../../../../vendor/autoload.php';
|
||||
|
||||
// gateway 进程,这里使用Text协议,可以用telnet测试
|
||||
$gateway = new Gateway("Websocket://0.0.0.0:8282");
|
||||
|
||||
// gateway名称,status方便查看
|
||||
$gateway->name = 'worker_task_im';
|
||||
|
||||
// gateway进程数,一般设置2个就足够
|
||||
$gateway->count = 4;
|
||||
|
||||
// 本机ip,分布式部署时使用内网ip
|
||||
$gateway->lanIp = '172.19.97.179';
|
||||
|
||||
// 内部通讯起始端口,假如$gateway->count=2,起始端口为2900
|
||||
// 则一般会使用3900 3901 3902 3903 4个端口作为内部通讯端口
|
||||
$gateway->startPort = 3900;
|
||||
|
||||
// 服务注册地址
|
||||
$gateway->registerAddress = '172.19.97.179:1256';
|
||||
|
||||
// 心跳间隔
|
||||
$gateway->pingInterval = 20;
|
||||
|
||||
// 心跳数据
|
||||
$gateway->pingData = '{"type":"ping"}';
|
||||
|
||||
// 如果不是在根目录启动,则运行runAll方法
|
||||
if(!defined('GLOBAL_START'))
|
||||
{
|
||||
Worker::runAll();
|
||||
}
|
||||
|
@ -1,16 +0,0 @@
|
||||
<?php
|
||||
use \Workerman\Worker;
|
||||
use \GatewayWorker\Register;
|
||||
|
||||
// 自动加载类
|
||||
require_once __DIR__ . '/../../../../vendor/autoload.php';
|
||||
|
||||
// register 必须是text协议,切记不能将register端口开放给外网
|
||||
$register = new Register('text://172.19.97.179:1256');
|
||||
|
||||
// 如果不是在根目录启动,则运行runAll方法
|
||||
if(!defined('GLOBAL_START'))
|
||||
{
|
||||
Worker::runAll();
|
||||
}
|
||||
|
@ -1,93 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\job;
|
||||
|
||||
use app\common\model\informationg\UserInformationg;
|
||||
use think\facade\Db;
|
||||
use think\queue\Job;
|
||||
use IFlytek\Xfyun\Speech\ChatClient;
|
||||
use WebSocket\Client;
|
||||
use GuzzleHttp\Client as GzClient;
|
||||
use GuzzleHttp\Psr7\Request;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Guzzle\Http\Exception\RequestException;
|
||||
|
||||
|
||||
/**
|
||||
* 任务执行AI分析
|
||||
*/
|
||||
class AiAianalyse
|
||||
{
|
||||
private $app_id='2eda6c2e';
|
||||
private $api_key='12ec1f9d113932575fc4b114a2f60ffd';
|
||||
private $api_secret='MDEyMzE5YTc5YmQ5NjMwOTU1MWY4N2Y2';
|
||||
|
||||
public function fire(Job $job, $data)
|
||||
{
|
||||
if ($job->attempts() > 3) {
|
||||
//通过这个方法可以检查这个任务已经重试了几次了
|
||||
$job->delete();
|
||||
}
|
||||
$type_name = Db::name('category_business')->where('id', $data['category_child'])->value('name');
|
||||
$data_field = json_decode($data['data_field'], true);
|
||||
$demand = '';
|
||||
foreach($data_field as $k=>$v) {
|
||||
$demand .= $k . ':' . $v . ';';
|
||||
}
|
||||
$question = "根据以下{$type_name}信息【{$demand}】请问有那些商机?需要购买哪些商品?";
|
||||
try {
|
||||
$chat=new ChatClient($this->app_id,$this->api_key,$this->api_secret);
|
||||
$client = new Client($chat->assembleAuthUrl('wss://spark-api.xf-yun.com/v2.1/chat'));
|
||||
if ($client) {
|
||||
$header = [
|
||||
"app_id" => $this->app_id,
|
||||
"uid" => "1"
|
||||
];
|
||||
$parameter = [
|
||||
"chat" => [
|
||||
"domain" => "generalv2",
|
||||
"temperature" => 0.5,
|
||||
"max_tokens" => 1024
|
||||
]
|
||||
];
|
||||
$payload = [
|
||||
"message" => [
|
||||
"text" => [
|
||||
["role" => "user", "content" => $question]
|
||||
]
|
||||
]
|
||||
];
|
||||
$chat_data = json_encode([
|
||||
"header" => $header,
|
||||
"parameter" => $parameter,
|
||||
"payload" => $payload
|
||||
]);
|
||||
|
||||
$client->send($chat_data);
|
||||
$answer = '';
|
||||
while(true){
|
||||
$response = $client->receive();
|
||||
$resp = json_decode($response, true);
|
||||
$code = $resp["header"]["code"] ?? 0;
|
||||
if($code > 0){
|
||||
break;
|
||||
}
|
||||
$status = $resp["header"]["status"];
|
||||
$content = $resp['payload']['choices']['text'][0]['content'] ?? '';
|
||||
$answer .= $content;
|
||||
if($status == 2){
|
||||
break;
|
||||
}
|
||||
}
|
||||
$update_data = [
|
||||
'ai_question' => $question,
|
||||
'ai_aianalyse' => $answer,
|
||||
'update_time' => time(),
|
||||
];
|
||||
unset($data['data'], $data['data_field']);
|
||||
Db::name('user_informationg_demand')->where($data)->update($update_data);
|
||||
}
|
||||
} catch (\Exception $e) {}
|
||||
$job->delete();
|
||||
}
|
||||
}
|
@ -28,7 +28,6 @@ class TaskInformationJob
|
||||
$company = Company::where('id', $data['company_id'])->field('id,deposit,responsible_area,company_money,shareholder_money,user_id,day_count,company_type,province,city,area,street,village,brigade')->find(); // 可能要判断预存金是否满足
|
||||
$arr['status'] = 0;
|
||||
$arr['company_account_type'] = 1;
|
||||
$name = '';
|
||||
//信息更新
|
||||
if ($data['template_info']['type'] == 31) {
|
||||
if ($data['template_info']['information_count'] < $data['template_info']['information_day_count']) {
|
||||
@ -88,16 +87,12 @@ class TaskInformationJob
|
||||
$task_35 = Task::where('id', $data['task_id'])->field('director_uid,status,money,start_time,end_time')->with('director_info')->find();
|
||||
if($task_35){
|
||||
$day= $data['template_info']['stage_day_one'] + $data['template_info']['stage_day_two'];
|
||||
$name = $task_35['director_info']['nickname'];
|
||||
// if($task_35['status']==3 && $data['template_info']['day_count']<=$day){
|
||||
// $name = $task_35['director_info']['nickname'];
|
||||
// $arr['status'] = 1;
|
||||
// $arr['money'] = $task_35['money'];
|
||||
// $arr['company_account_type'] = 2;
|
||||
// }else{
|
||||
if ($task_35['status'] == 3) {
|
||||
return true;
|
||||
}
|
||||
if($task_35['status']==3 && $data['template_info']['day_count']<=$day){
|
||||
$name = $task_35['director_info']['nickname'];
|
||||
$arr['status'] = 1;
|
||||
$arr['money'] = $task_35['money'];
|
||||
$arr['company_account_type'] = 2;
|
||||
}else{
|
||||
/**
|
||||
* 判断入股任务 单次类型 是否超时
|
||||
* 未超时时刷新开始结束时间
|
||||
@ -119,7 +114,7 @@ class TaskInformationJob
|
||||
Log::info('入股任务 ' . $data['template_info']['title'] . '结算失败,任务为超时:' . json_encode($data));
|
||||
return false;
|
||||
}
|
||||
// }
|
||||
}
|
||||
}else{
|
||||
Log::info('入股任务 ' . $data['template_info']['title'] . '结算失败,任务为空:' . json_encode($data));
|
||||
return false;
|
||||
@ -138,7 +133,7 @@ class TaskInformationJob
|
||||
|
||||
if($data['template_info']['day_count'] >= $day){
|
||||
Task::where('id', $data['task_id'])->update(['status' =>5]);
|
||||
Log::info( $data['template_info']['title'] . '结算失败,任务为超时:' . json_encode($data));
|
||||
Log::info('入股任务 ' . $data['template_info']['title'] . '结算失败,任务为超时:' . json_encode($data));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ use app\common\logic\task\TaskLogic;
|
||||
use think\queue\Job;
|
||||
|
||||
/**
|
||||
* 镇农科公司任务下发执行的具体逻辑
|
||||
* 镇管理公司任务下发执行的具体逻辑
|
||||
*/
|
||||
class TownTaskAdd
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ use think\queue\Job;
|
||||
class TownTaskSettlementJob
|
||||
{
|
||||
/**
|
||||
* 镇农科公司任务结算
|
||||
* 镇管理公司任务结算
|
||||
*/
|
||||
public function fire(Job $job, $taskSchedulingPlan)
|
||||
{
|
||||
|
@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\job;
|
||||
|
||||
use app\common\logic\task\TaskLogic;
|
||||
use think\queue\Job;
|
||||
|
||||
/**
|
||||
* 镇农科公司任务下发执行的具体逻辑
|
||||
*/
|
||||
class VillageTaskAdd
|
||||
{
|
||||
|
||||
public function fire(Job $job, $template)
|
||||
{
|
||||
if ($job->attempts() > 3) {
|
||||
//通过这个方法可以检查这个任务已经重试了几次了
|
||||
}
|
||||
TaskLogic::VillageCronAdd($template);
|
||||
//如果任务执行成功后 记得删除任务,不然这个任务会重复执行,直到达到最大重试次数后失败后,执行failed方法
|
||||
$job->delete();
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\job;
|
||||
|
||||
use app\api\controller\RemoteController;
|
||||
use app\common\logic\finance\ShareProfit;
|
||||
use app\common\logic\task\TaskLogic;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\task\Task;
|
||||
use app\common\model\task_scheduling_plan\TaskSchedulingPlan;
|
||||
use app\common\model\task_template\TaskTemplate;
|
||||
use think\facade\Log;
|
||||
use think\queue\Job;
|
||||
|
||||
class VillageTaskSettlementJob
|
||||
{
|
||||
/**
|
||||
* 镇农科公司任务结算
|
||||
*/
|
||||
public function fire(Job $job, $taskSchedulingPlan)
|
||||
{
|
||||
TaskLogic::villageTaskSettlement($taskSchedulingPlan);
|
||||
//如果任务执行成功后 记得删除任务,不然这个任务会重复执行,直到达到最大重试次数后失败后,执行failed方法
|
||||
$job->delete();
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
return [
|
||||
'middleware' => [
|
||||
// 权限认证
|
||||
// app\middleapi\http\middleware\AuthMiddleware::class,
|
||||
],
|
||||
];
|
@ -1,100 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\middleapi\controller;
|
||||
|
||||
use app\common\enum\user\AccountLogEnum;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\user\UserAccountLog;
|
||||
use app\common\model\user\UserRole;
|
||||
use app\common\service\FileService;
|
||||
use app\common\controller\BaseLikeAdminController;
|
||||
|
||||
/***
|
||||
* 账户流水控制器
|
||||
* Class AccountLogController
|
||||
* @package app\adminapi\controller
|
||||
*/
|
||||
class AccountLogController extends BaseLikeAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 账户流水明细
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2023/2/24 15:25
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$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']];
|
||||
}
|
||||
if (!empty($params['start_time'])) {
|
||||
$where[] = ['create_time', '>=', strtotime($params['start_time'])];
|
||||
}
|
||||
if (!empty($params['end_time'])) {
|
||||
$where[] = ['create_time', '<=', strtotime($params['end_time'])];
|
||||
}
|
||||
$pageNo = !empty($params['page_no']) ? $params['page_no'] : 1;
|
||||
$pageSize = !empty($params['page_size']) ? $params['page_size'] : 20;
|
||||
$lists = UserAccountLog::where($where)
|
||||
->with(['company_info','user_info'])
|
||||
->order('id', 'desc')
|
||||
->page($pageNo, $pageSize)
|
||||
->select()
|
||||
->toArray();
|
||||
foreach ($lists as &$item) {
|
||||
$item['user_info']['avatar'] = FileService::getFileUrl($item['user_info']['avatar']);
|
||||
$item['user_info']['group_name']=UserRole::where('id',$item['user_info']['group_id'])->value('name');
|
||||
$item['change_type_desc'] = AccountLogEnum::getChangeTypeDesc($item['change_type']);
|
||||
$symbol = $item['action'] == AccountLogEnum::INC ? '+' : '-';
|
||||
$item['change_amount'] = $symbol . $item['change_amount'];
|
||||
// 用于导出
|
||||
$item['user_info_sn'] = $item['user_info']['sn'];
|
||||
$item['company_info_company_name'] = $item['company_info']['company_name'];
|
||||
$item['user_info_nickname'] = $item['user_info']['nickname'];
|
||||
$item['user_info_group_name'] = $item['user_info']['group_name'];
|
||||
$item['user_info_mobile'] = $item['user_info']['mobile'];
|
||||
}
|
||||
$count = UserAccountLog::where($where)->count();
|
||||
$result = [
|
||||
'lists' => $lists,
|
||||
'count' => $count,
|
||||
'page_no' => $pageNo,
|
||||
'page_size' => $pageSize
|
||||
];
|
||||
return $this->success('请求成功',$result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 用户余额变动类型
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2023/2/24 15:25
|
||||
*/
|
||||
public function getUmChangeType()
|
||||
{
|
||||
return $this->data(AccountLogEnum::getUserMoneyChangeTypeDesc());
|
||||
}
|
||||
|
||||
public function getCompanyUserList()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
$companyId = $param['company_id'] ?? 0;
|
||||
$userList = User::where(['company_id' => $companyId])->field('id,nickname,avatar,sn,mobile,group_id,deposit,income')->select()->toArray();
|
||||
return $this->success('成功', $userList);
|
||||
}
|
||||
|
||||
}
|
@ -1,200 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\middleapi\controller;
|
||||
|
||||
use app\adminapi\lists\approve\ApproveLists;
|
||||
use app\common\logic\task\TaskLogic;
|
||||
use app\common\model\Approve;
|
||||
use app\common\model\task\Task;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\task_scheduling_plan\TaskSchedulingPlan;
|
||||
use app\common\model\task_template\TaskTemplate;
|
||||
use think\facade\Db;
|
||||
use app\common\controller\BaseLikeAdminController;
|
||||
|
||||
class ApproveController extends BaseLikeAdminController
|
||||
{
|
||||
public function lists()
|
||||
{
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$params=$this->request->post(['page_no','page_size','type','check_status']);
|
||||
$where = [];
|
||||
if (isset($params['check_status']) && $params['check_status'] != '') {
|
||||
$where[] = ['check_status', '=', $params['check_status']];
|
||||
}
|
||||
if (isset($params['type']) && $params['type'] != '') {
|
||||
$where[] = ['type', 'in', $params['type']];
|
||||
}
|
||||
$pageNo = !empty($params['page_no']) ? $params['page_no'] : 1;
|
||||
$pageSize = !empty($params['page_size']) ? $params['page_size'] : 20;
|
||||
$data = Approve::where($where)
|
||||
->with('task')
|
||||
->field('*')
|
||||
->append(['area_manager', 'company_name'], true)
|
||||
->page($pageNo, $pageSize)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->withAttr('area_manager',function($value,$data){
|
||||
return Admin::where(['id' => $data['check_admin_ids']])->value('name');
|
||||
})
|
||||
->withAttr('company_name',function($value,$data){
|
||||
$task = Task::where('id', $data['task_id'])->find();
|
||||
return Company::where(['id' => $task['company_id'] ?? 0])->value('company_name');
|
||||
})
|
||||
->toArray();
|
||||
$count = Approve::where($where)->count();
|
||||
$result = [
|
||||
'lists' => $data,
|
||||
'count' => $count,
|
||||
'page_no' => $pageNo,
|
||||
'page_size' => $pageSize
|
||||
];
|
||||
return $this->success('请求成功',$result);
|
||||
}
|
||||
|
||||
public function audit()
|
||||
{
|
||||
try {
|
||||
$params = $this->request->param();
|
||||
if(empty($params['id'])){
|
||||
return $this->fail('缺少必要参数id');
|
||||
}
|
||||
if(empty($params['check_status'])){
|
||||
return $this->fail('缺少必要参数审核状态');
|
||||
}
|
||||
$approve = Approve::find($params['id']);
|
||||
if (!$approve) {
|
||||
$this->fail('数据不存在');
|
||||
}
|
||||
Db::startTrans();
|
||||
// 拒绝通过 要让用户今天可以继续做任务
|
||||
if ($params['check_status'] == 3) {
|
||||
$this->refuse($params, $approve);
|
||||
}
|
||||
// 修改任务完成状态
|
||||
if ($params['check_status'] == 2) {
|
||||
if ($approve->type == Approve::APPROVE_TYPE_7) {
|
||||
$taskTemplate = TaskTemplate::where(['id'=>$approve->business_id])->find();
|
||||
// 提前完成
|
||||
if ($taskTemplate['day_count'] < $taskTemplate['stage_day_one']) {
|
||||
if (bccomp($params['amount'], 300000, 2) == -1) {
|
||||
$this->fail('该任务提前完成条件:销售总额必须达到30万元及以上');
|
||||
} else {
|
||||
// 提前完成标识
|
||||
$extend = json_decode($taskTemplate['extend'], true);
|
||||
$extend['early_finish'] = 1;
|
||||
$taskTemplate->extend = json_encode($extend);
|
||||
$taskTemplate->save();
|
||||
$this->pass($approve, $params);
|
||||
}
|
||||
} else {
|
||||
$this->pass($approve, $params);
|
||||
}
|
||||
} else {
|
||||
$this->pass($approve);
|
||||
}
|
||||
|
||||
}
|
||||
Db::commit();
|
||||
return $this->success('审核成功');
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
return $this->fail($e->getFile().$e->getLine().$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// 通过
|
||||
private function pass($approve, $params=[])
|
||||
{
|
||||
$approve->check_status = 2;
|
||||
$approve->update_time = time();
|
||||
$approve->save();
|
||||
// 任务
|
||||
$task = Task::find($approve['task_id']);
|
||||
if ($task['status'] == 2) {
|
||||
$task->status = 3;
|
||||
$task->save();
|
||||
}
|
||||
// 镇农科公司任务-数字农贸宣传业务、加工业务的建设和招商工作任务 结算
|
||||
if ($approve->type == Approve::APPROVE_TYPE_4) {
|
||||
$taskSchedulePlan = TaskSchedulingPlan::where('la_task_scheduling_plan.id', $task['scheduling_plan_id'])
|
||||
->where('is_pay',0)
|
||||
->with(['template_info'])
|
||||
->withJoin(['scheduling'], 'left')
|
||||
->where('scheduling.company_type', 41)
|
||||
->find()
|
||||
->toArray();
|
||||
TaskLogic::dealTaskMarketingDirector10($taskSchedulePlan, $approve);
|
||||
}
|
||||
|
||||
if ($approve->type == Approve::APPROVE_TYPE_5) {
|
||||
$taskSchedulePlan = TaskSchedulingPlan::where('la_task_scheduling_plan.id', $task['scheduling_plan_id'])
|
||||
->where('is_pay',0)
|
||||
->with(['template_info'])
|
||||
->withJoin(['scheduling'], 'left')
|
||||
->where('scheduling.company_type', 17)
|
||||
->find()
|
||||
->toArray();
|
||||
TaskLogic::dealVillageTask6($taskSchedulePlan);
|
||||
}
|
||||
|
||||
if ($approve->type == Approve::APPROVE_TYPE_6) {
|
||||
$taskSchedulePlan = TaskSchedulingPlan::where('la_task_scheduling_plan.id', $task['scheduling_plan_id'])
|
||||
->where('is_pay',0)
|
||||
->with(['template_info'])
|
||||
->withJoin(['scheduling'], 'left')
|
||||
->where('scheduling.company_type', 17)
|
||||
->find()
|
||||
->toArray();
|
||||
TaskLogic::dealVillageTask8($taskSchedulePlan);
|
||||
}
|
||||
if ($approve->type == Approve::APPROVE_TYPE_7) {
|
||||
// 需要手动输入销售总额
|
||||
$approve->amount = $params['amount'];
|
||||
$approve->save();
|
||||
}
|
||||
if ($approve->type == Approve::APPROVE_TYPE_8) {
|
||||
// 需要手动输入申请的政策补贴金额
|
||||
$approve->amount = $params['amount'];
|
||||
$approve->save();
|
||||
}
|
||||
if ($approve->type == Approve::APPROVE_TYPE_9) {
|
||||
$taskSchedulePlan = TaskSchedulingPlan::where('la_task_scheduling_plan.id', $task['scheduling_plan_id'])
|
||||
->where('is_pay',0)
|
||||
->with(['template_info'])
|
||||
->withJoin(['scheduling'], 'left')
|
||||
->where('scheduling.company_type', 17)
|
||||
->find()
|
||||
->toArray();
|
||||
TaskLogic::masterTask8Settlement($taskSchedulePlan);
|
||||
}
|
||||
}
|
||||
|
||||
// 拒绝
|
||||
private function refuse($params, $approve)
|
||||
{
|
||||
$approve->check_status = $params['check_status'];
|
||||
$approve->remark = $params['remark'];
|
||||
$approve->update_time = time();
|
||||
$approve->save();
|
||||
|
||||
// 更新schedule_plan时间和task的时间为今天依旧可提交
|
||||
$schedulePlan = TaskSchedulingPlan::find(['tast_id' => $approve['task_id']]);
|
||||
if (empty($schedule_plan)) {
|
||||
return $this->fail('数据异常,任务计划不存在');
|
||||
}
|
||||
$time = strtotime(date('Y-m-d'));
|
||||
TaskSchedulingPlan::where(['id' => $schedulePlan['id']])->update([
|
||||
'start_time'=>$time,
|
||||
'end_time'=>$time + 86399
|
||||
]);
|
||||
Task::where('id', $approve['task_id'])->update([
|
||||
'start_time'=>$time,
|
||||
'end_time'=>$time + 86399
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\middleapi\controller;
|
||||
|
||||
use app\adminapi\logic\informationg\UserInformationgLogic;
|
||||
use app\adminapi\validate\informationg\UserInformationgValidate;
|
||||
use app\common\controller\BaseLikeAdminController;
|
||||
use app\common\model\informationg\UserInformationg;
|
||||
use app\common\model\informationg\UserInformationgDemand;
|
||||
use think\response\Json;
|
||||
|
||||
class ArchivesController extends BaseLikeAdminController
|
||||
{
|
||||
//档案列表
|
||||
public function lists(): Json
|
||||
{
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$params = $this->request->post(['page_no','page_size','name']);
|
||||
$pageNo = !empty($params['page_no']) ? $params['page_no'] : 1;
|
||||
$pageSize = !empty($params['page_size']) ? $params['page_size'] : 20;
|
||||
$where = [];
|
||||
if(!empty($params['name'])){
|
||||
$where[] = ['name','like','%'.$params['name'].'%'];
|
||||
}
|
||||
$lists = UserInformationg::where($where)
|
||||
->field(['id','create_user_id','company_id','area_id','area_id area_name','street_id','street_id street_name','village_id','village_id village_name', 'brigade_id','brigade_id brigade_name', 'address', 'name', 'phone', 'sex', 'age','update_time','create_time','status'])
|
||||
->append(['extend'])
|
||||
->order(['id' => 'desc'])
|
||||
->page($pageNo, $pageSize)
|
||||
->select()
|
||||
->toArray();
|
||||
$informationIdArray = [];
|
||||
foreach($lists as $k=>$v) {
|
||||
$informationIdArray[] = $v['id'];
|
||||
}
|
||||
$data = UserInformationgDemand::whereIn('information_id', $informationIdArray)->order('id', 'desc')->select();
|
||||
$aianalyseArray = [];
|
||||
foreach($data as $kk=>$vv) {
|
||||
if (!empty($vv['ai_aianalyse'])) {
|
||||
$aianalyseArray[$vv['information_id']][] = $vv['id'];
|
||||
}
|
||||
}
|
||||
foreach($lists as $k=>$v) {
|
||||
$lists[$k]['aianalyse_status'] = 0;
|
||||
if (!empty($aianalyseArray[$v['id']])) {
|
||||
$lists[$k]['aianalyse_status'] = 1;
|
||||
}
|
||||
}
|
||||
$count = UserInformationg::where($where)->count();
|
||||
$result = [
|
||||
'lists' => $lists,
|
||||
'count' => $count,
|
||||
'page_no' => $pageNo,
|
||||
'page_size' => $pageSize
|
||||
];
|
||||
return $this->success('请求成功',$result);
|
||||
}
|
||||
|
||||
//档案详情
|
||||
public function detail(): Json
|
||||
{
|
||||
$params = (new UserInformationgValidate())->post()->goCheck('detail');
|
||||
$result = UserInformationgLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\middleapi\controller;
|
||||
|
||||
use app\adminapi\validate\category_business\CategoryBusinessValidate;
|
||||
use app\common\controller\BaseLikeAdminController;
|
||||
use app\common\logic\category_business\CategoryBusinessLogic;
|
||||
use app\common\model\category_business\CategoryBusiness;
|
||||
use think\response\Json;
|
||||
|
||||
class BusinessController extends BaseLikeAdminController
|
||||
{
|
||||
//商机分类列表
|
||||
public function lists(): Json
|
||||
{
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$params = $this->request->post(['page_no','page_size','name','status']);
|
||||
$pageNo = !empty($params['page_no']) ? $params['page_no'] : 1;
|
||||
$pageSize = !empty($params['page_size']) ? $params['page_size'] : 20;
|
||||
$where = [];
|
||||
if(!empty($params['name'])){
|
||||
$where[] = ['name','like','%'.$params['name'].'%'];
|
||||
}
|
||||
if(!empty($params['status'])){
|
||||
$where[] = ['status','=',$params['status']];
|
||||
}
|
||||
$data = CategoryBusiness::where($where)->field(['id', 'name', 'pid', 'sort', 'status'])->order(['id' => 'desc'])->select()->toArray();
|
||||
$count = CategoryBusiness::where($where)->count();
|
||||
$result = [
|
||||
'lists' => linear_to_tree($data, 'children'),
|
||||
'count' => $count,
|
||||
'page_no' => $pageNo,
|
||||
'page_size' => $pageSize
|
||||
];
|
||||
return $this->success('请求成功',$result);
|
||||
}
|
||||
|
||||
//商机分类详情
|
||||
public function detail(): Json
|
||||
{
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$params = $this->request->post(['id']);
|
||||
if(empty($params['id'])){
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
$data = CategoryBusiness::where('id',$params['id'])->findOrEmpty();
|
||||
return $this->success('请求成功',$data->toArray());
|
||||
}
|
||||
|
||||
//新增商机分类
|
||||
public function create(): Json
|
||||
{
|
||||
$params = (new CategoryBusinessValidate())->post()->goCheck('add');
|
||||
$result = CategoryBusinessLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(CategoryBusinessLogic::getError());
|
||||
}
|
||||
|
||||
//编辑商机分类
|
||||
public function edit(): Json
|
||||
{
|
||||
$params = (new CategoryBusinessValidate())->post()->goCheck('edit');
|
||||
$result = CategoryBusinessLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(CategoryBusinessLogic::getError());
|
||||
}
|
||||
|
||||
//删除商机分类
|
||||
public function delete(): Json
|
||||
{
|
||||
$params = (new CategoryBusinessValidate())->post()->goCheck('delete');
|
||||
CategoryBusinessLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
}
|
@ -1,484 +0,0 @@
|
||||
<?php
|
||||
|
||||
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;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\company\CompanyAccountLog;
|
||||
use app\common\model\contract\Contract;
|
||||
use app\common\model\dict\DictData;
|
||||
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;
|
||||
|
||||
class CompanyController extends BaseLikeAdminController
|
||||
{
|
||||
//公司列表
|
||||
public function lists(): Json
|
||||
{
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$params=$this->request->post(['page_no','page_size','company_name','area_name','street_name','area_manager','company_type','is_contract']);
|
||||
$where = [];
|
||||
if(!empty($params['company_name'])){
|
||||
$where[] = ['company_name','like','%'.$params['company_name'].'%'];
|
||||
}
|
||||
if(!empty($params['area_name'])){
|
||||
$arr= Db::name('geo_area')->where('area_name','like','%'.$params['area_name'].'%')->column('area_code');
|
||||
if($arr){
|
||||
$where[]=['area','in',$arr];
|
||||
}
|
||||
}
|
||||
if(!empty($params['street_name'])){
|
||||
$arr= Db::name('geo_street')->where('street_name','like','%'.$params['street_name'].'%')->column('street_code');
|
||||
if($arr){
|
||||
$where[]=['street','in',$arr];
|
||||
}
|
||||
}
|
||||
if(!empty($params['area_manager'])){
|
||||
$arr= Admin::where('name','like','%'.$params['area_manager'].'%')->column('id');
|
||||
if($arr){
|
||||
$where[]=['area_manager','in',$arr];
|
||||
}
|
||||
}
|
||||
if(!empty($params['company_type'])){
|
||||
$where[] = ['company_type','=',$params['company_type']];
|
||||
}
|
||||
if(!empty($params['is_contract'])){
|
||||
$where[] = ['is_contract','=',$params['is_contract']];
|
||||
}
|
||||
$pageNo = !empty($params['page_no']) ? $params['page_no'] : 1;
|
||||
$pageSize = !empty($params['page_size']) ? $params['page_size'] : 20;
|
||||
$data = Company::where($where)
|
||||
->field(['is_authentication','id', 'id contract', 'company_name', 'organization_code', 'city', 'area', 'street', 'company_type', 'master_name', 'master_position', 'master_phone', 'master_email', 'area_manager', 'is_contract', 'deposit', 'company_money', 'shareholder_money', 'deposit_time', 'status', 'face_create_status'])
|
||||
->page($pageNo, $pageSize)
|
||||
->order(['id' => 'desc'])
|
||||
->append(['notes'], true)
|
||||
->withAttr('company_type',function($value,$data){
|
||||
return Db::name('dict_data')->where('id',$value)->value('name');
|
||||
})
|
||||
->withAttr('area',function($value,$data){
|
||||
return Db::name('geo_area')->where('area_code',$value)->value('area_name');
|
||||
})
|
||||
->withAttr('street',function($value,$data){
|
||||
return Db::name('geo_street')->where('street_code',$value)->value('street_name');
|
||||
})
|
||||
->withAttr('area_manager',function($value,$data){
|
||||
return Db::name('admin')->where('id',$value)->value('name');
|
||||
})
|
||||
->withAttr('notes',function($value,$data){
|
||||
if ($data['is_authentication'] == 1) {
|
||||
return Db::name('company_authentication_fail_log')->where('company_id',$data['id'])->where('log_type', 2)->order(['id'=>'desc'])->limit(1)->value('fail_reason');
|
||||
} else {
|
||||
return Db::name('company_authentication_fail_log')->where('company_id',$data['id'])->where('log_type', 1)->order(['id'=>'desc'])->limit(1)->value('fail_reason');
|
||||
}
|
||||
|
||||
})->select()->toArray();
|
||||
$count = Company::where($where)->count();
|
||||
$result = [
|
||||
'lists' => $data,
|
||||
'count' => $count,
|
||||
'page_no' => $pageNo,
|
||||
'page_size' => $pageSize
|
||||
];
|
||||
return $this->success('请求成功',$result);
|
||||
}
|
||||
|
||||
//公司详情
|
||||
public function detail(): Json
|
||||
{
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$params=$this->request->post(['id']);
|
||||
if(empty($params['id'])){
|
||||
return $this->fail('缺少必要参数');
|
||||
}
|
||||
$result = CompanyLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
//公司删除
|
||||
public function delete(): Json
|
||||
{
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$params=$this->request->post(['id']);
|
||||
if(empty($params['id'])){
|
||||
return $this->fail('缺少必要参数');
|
||||
}
|
||||
$admin_id = Company::where('id', $params['id'])->value('admin_id');
|
||||
User::where('company_id', $params['id'])->update(['delete_time' => time()]);
|
||||
TaskScheduling::where('company_id', $params['id'])->update(['delete_time' => time()]);
|
||||
AdminLogic::delete(['id' => $admin_id]);
|
||||
CompanyLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
//添加公司
|
||||
public function create(): Json
|
||||
{
|
||||
$params = (new CompanyValidate())->post()->goCheck('add');
|
||||
$params['other_contacts'] = json_encode($params['other_contacts']);
|
||||
$params['qualification'] = json_encode($params['qualification']);
|
||||
if (isset($params['responsible_area'])) {
|
||||
$params['responsible_area'] = implode(',', $params['responsible_area']);
|
||||
}
|
||||
$result = CompanyLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(CompanyLogic::getError());
|
||||
}
|
||||
|
||||
//修改公司
|
||||
public function edit(): Json
|
||||
{
|
||||
$params = (new CompanyValidate())->post()->goCheck('edit');
|
||||
$params['other_contacts'] = json_encode($params['other_contacts']);
|
||||
$params['qualification'] = json_encode($params['qualification']);
|
||||
if (isset($params['responsible_area'])) {
|
||||
$params['responsible_area'] = implode(',', $params['responsible_area']);
|
||||
}
|
||||
$result = CompanyLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(CompanyLogic::getError());
|
||||
}
|
||||
|
||||
//公司认证
|
||||
public function enterpriseCertification(): Json
|
||||
{
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$params=$this->request->post(['id']);
|
||||
if(empty($params['id'])){
|
||||
return $this->fail('缺少必要参数');
|
||||
}
|
||||
$company = Db::name('company')->where('id', $params['id'])->find();
|
||||
$qualification = json_decode($company['qualification'], true);
|
||||
if ($company && $qualification['business_license']) {
|
||||
$data = [
|
||||
'name' => $company['company_name'],
|
||||
'organization_code' => $company['organization_code'],
|
||||
'business_license' => 'https://lihai001.oss-cn-chengdu.aliyuncs.com/def/561f8202305171526091317.png', //$qualification['business_license'],
|
||||
'master_name' => $company['master_name'],
|
||||
'master_email' => $company['master_email'],
|
||||
'master_phone' => $company['master_phone'],
|
||||
'master_id_card' => $company['master_id_card'],
|
||||
'id' => $company['id'],
|
||||
];
|
||||
$res = app(JunziqianController::class)->EnterpriseCertification($data);
|
||||
Log::info(['企业认证同步结果',$res]);
|
||||
if ($res->success) {
|
||||
if ($company['company_type'] == 30) {
|
||||
// 平台公司不用初始化生成合同 合同签约暂不用人脸识别,预留人脸采集状态为已采集
|
||||
Db::name('company')->where('id', $params['id'])->update([ 'is_contract'=>1,'face_create_status'=>1]);
|
||||
} else {
|
||||
Db::name('company')->where('id', $params['id'])->update([ 'face_create_status'=>1]);
|
||||
}
|
||||
// 加入缓存中,is_callback用于判断是否获取到异步通知
|
||||
RedisLogic::getInstance()->set('authentication_company_id_'.$company['id'], json_encode(['company_id'=>$company['id'],'is_callback'=>0, 'timing'=>time()]));
|
||||
return $this->success('系统认证中,请稍后刷新页面查看', ['email' => $res->data], 1, 1);
|
||||
} else {
|
||||
return $this->fail($res->msg);
|
||||
}
|
||||
} else {
|
||||
return $this->fail("公司不存在");
|
||||
}
|
||||
}
|
||||
|
||||
//生成合同
|
||||
public function generateContract(): Json
|
||||
{
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$params=$this->request->post(['id','party_a','contract_type']);
|
||||
if(empty($params['id']) || empty($params['party_a']) || empty($params['contract_type'])){
|
||||
return $this->fail('缺少必要参数');
|
||||
}
|
||||
$area_manager = Company::where('id', $params['party_a'])->value('area_manager');
|
||||
$params['area_manager'] = $area_manager;
|
||||
$params['type'] = 1;
|
||||
$params['party_b'] = $params['id'];
|
||||
unset($params['id']);
|
||||
$result = ContractLogic::initiate_contract($params);
|
||||
if (!empty($result) && $result['code'] == 1) {
|
||||
return $this->success($result['msg'], $result['data'], 1, 1);
|
||||
}
|
||||
return $this->fail(ContractLogic::getError());
|
||||
}
|
||||
|
||||
//下属公司
|
||||
public function subsidiaryCompany(): Json
|
||||
{
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$params=$this->request->post(['id','page_no','page_size']);
|
||||
if(empty($params['id'])){
|
||||
return $this->fail('缺少必要参数');
|
||||
}
|
||||
$pageNo = !empty($params['page_no']) ? $params['page_no'] : 1;
|
||||
$pageSize = !empty($params['page_size']) ? $params['page_size'] : 20;
|
||||
$ids = Contract::where('party_a', $params['id'])->where('status', 1)->where('type', 1)->column('party_b');
|
||||
if ($ids) {
|
||||
$result = Company::where('id', 'in', $ids)->field('company_name,id,company_type,company_type company_type_name,area,area area_name,street,street street_name,is_contract,area_manager,area_manager area_manager_name,master_name,master_phone,is_authentication')->page($pageNo,$pageSize)->select();
|
||||
$count = Company::where('id', 'in', $ids)->count();
|
||||
} else {
|
||||
$result = [];
|
||||
$count = 0;
|
||||
}
|
||||
$data = [
|
||||
'lists' => $result,
|
||||
'count' => $count,
|
||||
'page_no' => $pageNo,
|
||||
'page_size' => $pageSize
|
||||
];
|
||||
return $this->success('success', $data);
|
||||
}
|
||||
|
||||
//公司类型
|
||||
public function companyType(): Json
|
||||
{
|
||||
$data = DictData::where('type_id',6)
|
||||
->append(['status_desc'])
|
||||
->order(['sort' => 'desc', 'id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
return $this->success('请求成功',$data);
|
||||
}
|
||||
|
||||
//合同类型
|
||||
public function contractType(): Json
|
||||
{
|
||||
$data = DictData::where('type_id',7)
|
||||
->append(['status_desc'])
|
||||
->order(['sort' => 'desc', 'id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
return $this->success('请求成功',$data);
|
||||
}
|
||||
|
||||
public function responsibleArea(): Json
|
||||
{
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$params = $this->request->post(['key','value','company_type']);
|
||||
if (empty($params['key']) || empty($params['value']) || empty($params['company_type'])) {
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
if ($params['key'] == 'city') {
|
||||
$where[] = ['area', '=', 0];
|
||||
}
|
||||
if ($params['value'] == '') {
|
||||
return $this->fail('参数不能为空');
|
||||
}
|
||||
$where[] = [$params['key'], '=', $params['value']];
|
||||
$where[] = ['company_type', '=', $params['company_type']];
|
||||
switch ($params['key']) {
|
||||
case 'city':
|
||||
// $geo_area=Db::name('geo_area')->where('city_code', '=', $parmas['value'])->column('area_code');
|
||||
// $where[] = ['area', 'in', $geo_area];
|
||||
break;
|
||||
case 'area':
|
||||
$street_code = Db::name('geo_street')->where('area_code', '=', $params['value'])->column('street_code');
|
||||
$where[] = ['street', 'in', $street_code];
|
||||
$where[] = ['village', '=', 0];
|
||||
break;
|
||||
case 'street':
|
||||
$street_code = Db::name('geo_village')->where('street_code', '=', $params['value'])->column('village_code');
|
||||
$where[] = ['village', 'in', $street_code];
|
||||
$where[] = ['brigade', '=', 0];
|
||||
break;
|
||||
case 'village':
|
||||
// $street_code = Db::name('geo_brigade')->where('street_code', '=', $parmas['value'])->column('village_code');
|
||||
$where[] = ['village', '=', $params['value']];
|
||||
// $where[] = ['brigade', '=', 0];
|
||||
break;
|
||||
}
|
||||
|
||||
$res = Company::where($where)->column('responsible_area');
|
||||
|
||||
foreach ($res as $k => $v) {
|
||||
$res[$k] = explode(',', $v);
|
||||
}
|
||||
$data = [];
|
||||
foreach ($res as $k => $v) {
|
||||
foreach ($v as $kk => $vv) {
|
||||
if ($vv != '') {
|
||||
$data[] = $vv;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->success('success', array_unique($data));
|
||||
}
|
||||
|
||||
public function getDepositRechargeTransferVoucherList(): Json
|
||||
{
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$params = $this->request->post(['page_no','page_size', 'account', 'mobile', 'company_id']);
|
||||
$where = [];
|
||||
if(isset($params['company_id']) && $params['company_id'] > 0){
|
||||
$where[] = ['company_id', '=', $params['company_id']];
|
||||
}
|
||||
$pageNo = !empty($params['page_no']) ? $params['page_no'] : 1;
|
||||
$pageSize = !empty($params['page_size']) ? $params['page_size'] : 20;
|
||||
$lists = CompanyDepositVoucher::where($where)
|
||||
->page($pageNo, $pageSize)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
$count=CompanyDepositVoucher::where($where)->count();
|
||||
|
||||
$result = [
|
||||
'lists' => $lists,
|
||||
'count' => $count,
|
||||
'page_no' => $pageNo,
|
||||
'page_size' => $pageSize
|
||||
];
|
||||
return $this->success('请求成功',$result);
|
||||
}
|
||||
|
||||
public function depositRechargeTransferVoucher(): Json
|
||||
{
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$param = $this->request->param();
|
||||
if(empty($param['company_id'])){
|
||||
return $this->fail('缺少company_id');
|
||||
}
|
||||
if(empty($param['deposit'])){
|
||||
return $this->fail('缺少押金金额');
|
||||
}
|
||||
if(empty($param['voucher'])){
|
||||
return $this->fail('缺少凭证文件');
|
||||
}
|
||||
try {
|
||||
$adminId = 1;
|
||||
Db::startTrans();
|
||||
$data = [
|
||||
'company_id' => $param['company_id'],
|
||||
'deposit' => $param['deposit'],
|
||||
'voucher' => $param['voucher'],
|
||||
'create_admin_id' => $adminId,
|
||||
'create_time' => time(),
|
||||
'update_time' => time()
|
||||
];
|
||||
$result = (new CompanyDepositVoucher())->save($data);
|
||||
|
||||
$companyModel = Company::where(['id' => $param['company_id']])->find();
|
||||
$left_amount = bcadd($companyModel['deposit'], $param['deposit'], 2);
|
||||
|
||||
// 添加流水记录
|
||||
$datas = [
|
||||
'sn' => generate_sn(CompanyAccountLog::class, 'sn', 20),
|
||||
'user_id' => 0,
|
||||
'company_id' => $param['company_id'],
|
||||
'change_type' => CompanyAccountLog::COMPANY_DEPOSIT,
|
||||
'change_object' => CompanyAccountLog::DEPOSIT,
|
||||
'action' => 1,
|
||||
'change_amount' => $param['deposit'],
|
||||
'left_amount' =>$left_amount,
|
||||
'remark' => '后台押金转账凭证充值',
|
||||
'status' => 1,
|
||||
];
|
||||
CompanyAccountLog::create($datas);
|
||||
|
||||
// 更新公司押金金额
|
||||
$companyModel->deposit = $left_amount;
|
||||
$companyModel->save();
|
||||
Db::commit();
|
||||
return $this->success('成功');
|
||||
} catch (Exception $exception) {
|
||||
Db::rollback();
|
||||
return $this->fail($exception->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getPartyA(): Json
|
||||
{
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$companyId = $this->request->param('company_id');
|
||||
if(empty($companyId)){
|
||||
return $this->fail('缺少公司id');
|
||||
}
|
||||
$re = CompanyLogic::getPartyA($companyId);
|
||||
if ($re === false) {
|
||||
return $this->fail(CompanyLogic::getError());
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
@ -1,181 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\middleapi\controller;
|
||||
|
||||
use app\adminapi\validate\contract\ContractValidate;
|
||||
use app\api\controller\JunziqianController;
|
||||
use app\api\logic\SmsLogic;
|
||||
use app\common\controller\BaseLikeAdminController;
|
||||
use app\common\logic\contract\ContractLogic;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\contract\Contract;
|
||||
use app\common\model\user\User;
|
||||
use think\facade\Db;
|
||||
use think\response\Json;
|
||||
|
||||
class ContractController extends BaseLikeAdminController
|
||||
{
|
||||
//合同列表
|
||||
public function lists(): Json
|
||||
{
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$params = $this->request->post(['page_no','page_size','contract_no','contract_type','contract_status','company_name','area_manager']);
|
||||
$where = [];
|
||||
if(isset($params['contract_no']) && $params['contract_no']!=''){
|
||||
$where[] = ['contract_no','like','%'.$params['contract_no'].'%'];
|
||||
}
|
||||
if(isset($params['contract_type']) && $params['contract_type']!=''){
|
||||
$where[] = ['contract_type','=',$params['contract_type']];
|
||||
}
|
||||
if(isset($params['contract_status']) && in_array($params['contract_status'],[0,1])){
|
||||
$where[] = ['status','=', $params['contract_status']];
|
||||
}
|
||||
if(isset($params['company_name']) && $params['company_name']!=''){
|
||||
$arr= Company::where('company_name','like','%'.$params['company_name'].'%')->column('id');
|
||||
if($arr){
|
||||
$where[]=['party_a|party_b','in',$arr];
|
||||
}
|
||||
}
|
||||
if(isset($params['area_manager']) && $params['area_manager']!=''){
|
||||
$arr= Admin::where('name','like','%'.$params['area_manager'].'%')->column('id');
|
||||
if($arr){
|
||||
$where[]=['area_manager','in',$arr];
|
||||
}
|
||||
}
|
||||
$pageNo = !empty($param['page_no']) ? $param['page_no'] : 1;
|
||||
$pageSize = !empty($param['page_size']) ? $param['page_size'] : 20;
|
||||
$data = Contract::where($where)->with(['companyName','party_a_info','contractType'])
|
||||
->page($pageNo, $pageSize)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($item) {
|
||||
if($item->type==1){
|
||||
$item->party_b_name=Db::name('company')->where('id',$item->party_b)->value('company_name');
|
||||
}else{
|
||||
$item->party_b_name=Db::name('user')->where('id',$item->party_b)->value('nickname');
|
||||
}
|
||||
if(!empty($item->party_a_info)){
|
||||
$area_manager_name=Db::name('admin')->where('id',$item->party_a_info->area_manager)->value('name');
|
||||
if($area_manager_name){
|
||||
$item->area_manager_name=$area_manager_name;
|
||||
}else{
|
||||
$item->area_manager_name='暂无片区经理';
|
||||
}
|
||||
}else{
|
||||
$item->area_manager_name='暂无片区经理';
|
||||
}
|
||||
$item->contract_type_name=Db::name('dict_data')->where('id',$item->contract_type)->value('name');
|
||||
$item->status_name=$item->status==1?'已签约':'未签约';
|
||||
})->toArray();
|
||||
$count = Contract::where($where)->count();
|
||||
$result = [
|
||||
'lists' => $data,
|
||||
'count' => $count,
|
||||
'page_no' => $pageNo,
|
||||
'page_size' => $pageSize
|
||||
];
|
||||
return $this->success('请求成功',$result);
|
||||
}
|
||||
|
||||
//合同详情
|
||||
public function detail(): Json
|
||||
{
|
||||
$params = (new ContractValidate())->post()->goCheck('detail');
|
||||
$result = ContractLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
//上传合同
|
||||
public function uploadContract(): Json
|
||||
{
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$params = $this->request->post(['id','file']);
|
||||
if(empty($params['id']) || empty($params['file'])){
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
$res = Contract::where('id', $params['id'])->update(['file' => $params['file'], 'check_status' => 2]);
|
||||
if ($res) {
|
||||
$find = Contract::where('id', $params['id'])->with(['party_a_info'])->field('type,party_b,party_a')->find()->toArray();
|
||||
if ($find['type'] == 1) {
|
||||
$find['party_b_info'] = Company::where('id', $find['party_b'])->field('company_name name,master_phone phone')->find()->toArray();
|
||||
} else {
|
||||
$find['party_b_info'] = User::where('id', $find['party_b'])->field('nickname name,mobile phone')->find()->toArray();
|
||||
}
|
||||
$a = [
|
||||
'mobile' => $find['party_a_info']['master_phone'],
|
||||
'name' => $find['party_a_info']['company_name'],
|
||||
'scene' => 'WQTZ'
|
||||
];
|
||||
SmsLogic::contractUrl($a);
|
||||
$b = [
|
||||
'mobile' => $find['party_b_info']['phone'],
|
||||
'name' => $find['party_b_info']['name'],
|
||||
'scene' => 'WQTZ'
|
||||
];
|
||||
SmsLogic::contractUrl($b);
|
||||
return $this->success('上传成功', [], 1, 1);
|
||||
} else {
|
||||
if ($res == 0) {
|
||||
return $this->success('没有更新', [], 1, 1);
|
||||
}
|
||||
return $this->fail('上传失败');
|
||||
}
|
||||
}
|
||||
|
||||
//发起合同
|
||||
public function DraftingContract(): Json
|
||||
{
|
||||
$params = $this->request->post(['id','part_b','type']);
|
||||
if(empty($params['id']) || empty($params['part_b']) || empty($params['type'])){
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
$data = [
|
||||
'id' => $params['part_b'],
|
||||
'contract_id' => $params['id']
|
||||
];
|
||||
$result = ContractLogic::Draftingcontracts($data,$params['type']);
|
||||
if ($result) {
|
||||
return $this->success('发送合同成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(ContractLogic::getError());
|
||||
}
|
||||
|
||||
//发送短信
|
||||
public function sendSms(): Json
|
||||
{
|
||||
$params = $this->request->post(['id']);
|
||||
if(empty($params['id'])){
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
$res = ContractLogic::postsms($params);
|
||||
if ($res) {
|
||||
return $this->success('发送成功', [], 1, 1);
|
||||
} else {
|
||||
return $this->fail(ContractLogic::getError());
|
||||
}
|
||||
}
|
||||
|
||||
//下载证据包
|
||||
public function evidence() {
|
||||
$params = $this->request->post(['id']);
|
||||
if(empty($params['id'])){
|
||||
$this->fail('参数错误');
|
||||
}
|
||||
$detail=Contract::where('id',$params['id'])->find();
|
||||
if(!empty($detail['evidence_url'])){
|
||||
return $this->success('获取成功', ['url' => env('url.url_prefix').$detail['evidence_url']]);
|
||||
}
|
||||
$company=Company::where('id',$detail['party_a'])->find();
|
||||
$request = array(
|
||||
"applyNo" => $detail['contract_no'],
|
||||
"fullName" => $company['company_name'],
|
||||
"identityCard" => $company['organization_code'],
|
||||
"identityType" => 12,
|
||||
);
|
||||
return app(JunziqianController::class)->EvidenceDownload($request);
|
||||
}
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\middleapi\controller;
|
||||
|
||||
use app\common\model\dict\DictData;
|
||||
use app\adminapi\logic\setting\dict\DictDataLogic;
|
||||
use app\common\controller\BaseLikeAdminController;
|
||||
|
||||
|
||||
/**
|
||||
* 字典数据
|
||||
* Class DictDataController
|
||||
* @package app\adminapi\controller\dictionary
|
||||
*/
|
||||
class DictDataController extends BaseLikeAdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取字典数据列表
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 16:35
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$params=$this->request->post(['page_no','page_size','name','type_id','type_value']);
|
||||
$where = [];
|
||||
if(!empty($params['name'])){
|
||||
$where[] = ['name','like','%' . $params['name'] . '%'];
|
||||
}
|
||||
if(!empty($params['type_id'])){
|
||||
$where[] = ['type_id', '=', $params['type_id']];
|
||||
}
|
||||
if(!empty($params['type_value'])){
|
||||
$where[] = ['type_value', '=', $params['type_value']];
|
||||
}
|
||||
$pageNo = !empty($params['page_no']) ? $params['page_no'] : 1;
|
||||
$pageSize = !empty($params['page_size']) ? $params['page_size'] : 20;
|
||||
$data = DictData::where($where)
|
||||
->append(['status_desc'])
|
||||
->page($pageNo, $pageSize)
|
||||
->order(['sort' => 'desc', 'id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
$count = DictData::where($where)->count();
|
||||
$result = [
|
||||
'lists' => $data,
|
||||
'count' => $count,
|
||||
'page_no' => $pageNo,
|
||||
'page_size' => $pageSize
|
||||
];
|
||||
return $this->success('请求成功',$result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取字典详情
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 17:14
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new DictDataValidate())->goCheck('id');
|
||||
$result = DictDataLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
public function getTaskApproveTypeList()
|
||||
{
|
||||
$result = DictDataLogic::getTaskApproveTypeList();
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user