Compare commits
No commits in common. "master" and "mkm-2" have entirely different histories.
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,25 +18,16 @@ 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;
|
||||
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;
|
||||
use app\common\model\contract\Contract;
|
||||
use app\common\model\task_scheduling\TaskScheduling;
|
||||
use app\common\model\user\User;
|
||||
use think\facade\Log;
|
||||
|
||||
/**
|
||||
* Company控制器
|
||||
@ -45,7 +36,8 @@ use think\facade\Log;
|
||||
*/
|
||||
class CompanyController extends BaseAdminController
|
||||
{
|
||||
public array $notNeedLogin = ['createShopMerchant'];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return \think\response\Json
|
||||
@ -160,18 +152,17 @@ class CompanyController extends BaseAdminController
|
||||
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->success($result['msg'], $result['data']);
|
||||
}
|
||||
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());
|
||||
}
|
||||
@ -207,24 +198,16 @@ class CompanyController extends BaseAdminController
|
||||
'id' => $company['id'],
|
||||
];
|
||||
$res = app(JunziqianController::class)->EnterpriseCertification($data);
|
||||
Log::info(['企业认证同步结果',$res]);
|
||||
if ($res->success == true) {
|
||||
$email = substr(uniqid(),2,5).$res->data;
|
||||
// 企业人脸上传
|
||||
// $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()]));
|
||||
// 修改法人邮箱
|
||||
Db::name('company')->where('id', $params['id'])->update(['master_email' => $email]);
|
||||
// return $this->success('认证成功',[],1, 1);
|
||||
return $this->success('系统认证中,请稍后刷新页面查看', ['email' => $res->data], 1, 1);
|
||||
} else {
|
||||
@ -252,7 +235,7 @@ class CompanyController extends BaseAdminController
|
||||
];
|
||||
$res = app(JunziqianController::class)->organizationReapply($data);
|
||||
if ($res->success == true) {
|
||||
Db::name('company')->where('id', $params['id'])->update(['master_email' => $res->data, 'face_create_status'=>1]); //todo 上人脸采集功能时
|
||||
Db::name('company')->where('id', $params['id'])->update(['master_email' => $res->data]);
|
||||
return $this->success('系统认证中,请稍后刷新页面查看', ['email' => $res->data], 1, 1);
|
||||
} else {
|
||||
return $this->fail($res->msg);
|
||||
@ -267,7 +250,7 @@ class CompanyController extends BaseAdminController
|
||||
$company = Db::name('company')->where('id', $params['id'])->find();
|
||||
$re = CompanyLogic::originationFaceCreate($company);
|
||||
if ($re === true) {
|
||||
return $this->success('人脸采集中,请稍后刷新页面查看',[],1, 1);
|
||||
return $this->success('成功',[],1, 1);
|
||||
} else {
|
||||
return $this->fail($re);
|
||||
}
|
||||
@ -326,7 +309,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');
|
||||
@ -364,200 +346,4 @@ class CompanyController extends BaseAdminController
|
||||
}
|
||||
return $this->success('success', array_unique($data));
|
||||
}
|
||||
public function createShopMerchant()
|
||||
{
|
||||
try {
|
||||
$params = $this->request->param();
|
||||
Log::info(['商户入驻申请-请求参数', $params]);
|
||||
// if (empty($params['company_name'])) {
|
||||
// throw new Exception('商户名称不能为空');
|
||||
// }
|
||||
// if (empty($params['organization_code'])) {
|
||||
// throw new Exception('社会统一信用代码不能为空');
|
||||
// }
|
||||
// if (empty($params['master_name'])) {
|
||||
// throw new Exception('商户法人名称不能为空');
|
||||
// }
|
||||
// $master_email=Db::name('company_form')->where('organization_code',$params['organization_code'])->value('master_email');
|
||||
//
|
||||
// $isQueryStatus = false; // 需要进一步查询是否已做过企业认证
|
||||
// // $master_email为空表示没有做过认证
|
||||
// if($master_email){
|
||||
// $isQueryStatus = true;asdasd,fsdfdf
|
||||
// }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];
|
||||
}
|
||||
$data = [
|
||||
'mer_intention_id' => $params['mer_intention_id']??'', // 商城商户入驻申请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([])
|
||||
];
|
||||
$approveModel = new Approve();
|
||||
$shopApproveType = $params['type']; // 商户申请类型 1入驻 2开通交易
|
||||
// 插入审批流
|
||||
$approveModel->type = $shopApproveType == 1? 2: 3; // 审批类型,后台配置 1 其他任务 2商户入驻 3开通交易
|
||||
$approveModel->flow_id = 2;
|
||||
$approveModel->name = $shopApproveType == 1? '商户入驻审批': '开通交易审批';
|
||||
$approveModel->admin_id = 0; // 后台发起人id 暂时为0
|
||||
$approveModel->department_id = '0';
|
||||
$approveModel->check_admin_ids = $company['admin_id']; // 当前审批人ID 镇农科公司负责人
|
||||
$approveModel->check_status = 1; // 状态 0待审核,1审核中,2审核通过,3审核不通过,4撤销审核
|
||||
$approveModel->other_type = 6;
|
||||
$approveModel->extend = json_encode(array_merge($params, $data));
|
||||
$approveModel->create_time = time();
|
||||
$approveModel->update_time = time();
|
||||
$approveModel->save();
|
||||
|
||||
// $shopMerchantModel = ShopMerchant::create($data);
|
||||
|
||||
// 如果是通滩镇的商户,查询一下企业认证状态,通过的情况,则直接发起生成合同
|
||||
// if ($params['street'] == '510502106' && $isQueryStatus) {
|
||||
// $statusRe = app(JunziqianController::class)->shopMerchantStatusQuery($master_email);
|
||||
// Log::info(['商户入驻请求-通滩镇商户-认证状态查询结果', $statusRe]);
|
||||
// if($statusRe->success == true) {
|
||||
// $statusData = json_decode($statusRe->data, true);
|
||||
// if ($statusData['status'] == 1) {
|
||||
// // 生成合同
|
||||
// $createContractData = [
|
||||
// 'id' => $shopMerchantModel->id,
|
||||
// 'party_a' => 1,
|
||||
// 'party_a_name' => '泸州市海之农科技有限公司',
|
||||
// 'party_b' => $shopMerchantModel->id,
|
||||
// 'party_b_name' => $params['company_name'],
|
||||
// 'contract_type' => 22,
|
||||
// ];
|
||||
// $shopContractModel = new ShopContract();
|
||||
// $shopContractModel->contract_no = time();
|
||||
// $shopContractModel->create_time = time();
|
||||
// $shopContractModel->check_status = 1;
|
||||
// $shopContractModel->update_time = time();
|
||||
// $shopContractModel->setAttrs($createContractData);
|
||||
// $shopContractModel->save($createContractData);
|
||||
// return $this->success('已做过企业认证,直接生成合同成功', [], 1, 1);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
// if (!$shopMerchantModel->isEmpty()) {
|
||||
// // 自动发起企业认证
|
||||
// $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,
|
||||
// ];
|
||||
// app(JunziqianController::class)->ShopMerchantCertification($shopMerchantCertificationData);
|
||||
// } else {
|
||||
// throw new Exception('商户创建失败');
|
||||
// }
|
||||
return $this->success('审批创建成功', [], 1, 1);
|
||||
} catch (Exception $exception) {
|
||||
Log::error(['商户入驻审批失败', $exception->getMessage()]);
|
||||
return $this->fail($exception->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 押金凭证录入,并将押金写入公司押金账户,新增一条押金充值流水
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -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\CompanyFormLists;
|
||||
use app\adminapi\logic\CompanyFormLogic;
|
||||
use app\adminapi\validate\CompanyFormValidate;
|
||||
|
||||
|
||||
/**
|
||||
* CompanyForm控制器
|
||||
* Class CompanyFormController
|
||||
* @package app\adminapi\controller
|
||||
*/
|
||||
class CompanyFormController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/09/15 14:00
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new CompanyFormLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/09/15 14:00
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new CompanyFormValidate())->post()->goCheck('add');
|
||||
$result = CompanyFormLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(CompanyFormLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/09/15 14:00
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new CompanyFormValidate())->post()->goCheck('edit');
|
||||
$result = CompanyFormLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(CompanyFormLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/09/15 14:00
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new CompanyFormValidate())->post()->goCheck('delete');
|
||||
CompanyFormLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/09/15 14:00
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new CompanyFormValidate())->goCheck('detail');
|
||||
$result = CompanyFormLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,201 +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\ShopContractLists;
|
||||
use app\adminapi\logic\ShopContractLogic;
|
||||
use app\adminapi\validate\ShopContractValidate;
|
||||
use app\api\controller\JunziqianController;
|
||||
use app\api\logic\SmsLogic;
|
||||
use app\common\logic\contract\ContractLogic;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\contract\Contract;
|
||||
use app\common\model\ShopContract;
|
||||
use app\common\model\ShopMerchant;
|
||||
use app\Request;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* ShopContract控制器
|
||||
* Class ShopContractController
|
||||
* @package app\adminapi\controller
|
||||
*/
|
||||
class ShopContractController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/09/13 17:01
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new ShopContractLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/09/13 17:01
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new ShopContractValidate())->post()->goCheck('add');
|
||||
$result = ShopContractLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(ShopContractLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/09/13 17:01
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new ShopContractValidate())->post()->goCheck('edit');
|
||||
$result = ShopContractLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(ShopContractLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/09/13 17:01
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new ShopContractValidate())->post()->goCheck('delete');
|
||||
ShopContractLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/09/13 17:01
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new ShopContractValidate())->goCheck('detail');
|
||||
$result = ShopContractLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
// 上传合同
|
||||
public function wind_control()
|
||||
{
|
||||
$params = $this->request->param();
|
||||
$file = $params['file'];
|
||||
$res = ShopContract::where('id', $params['id'])->update(['file' => $file, 'check_status' => 2]);
|
||||
if ($res) {
|
||||
$find = ShopContract::where('id', $params['id'])->field('type,party_b,party_a')
|
||||
->find()->toArray();
|
||||
|
||||
$find['party_a_info'] = ShopMerchant::where('id', $find['party_a'])->field('company_name name,master_phone phone')->find()->toArray();
|
||||
$find['party_b_info'] = ShopMerchant::where('id', $find['party_b'])->field('company_name name,master_phone phone')->find()->toArray();
|
||||
|
||||
$a = [
|
||||
'mobile' => $find['party_a_info']['phone'],
|
||||
'name' => $find['party_a_info']['name'],
|
||||
'scene' => 'WQTZ'
|
||||
];
|
||||
SmsLogic::contractUrl($a);
|
||||
$b = [
|
||||
'mobile' => $find['party_b_info']['phone'],
|
||||
'name' => $find['party_b_info']['name'],
|
||||
'scene' => 'WQTZ'
|
||||
];
|
||||
SmsLogic::contractUrl($b);
|
||||
return $this->success('上传成功', [], 1, 1);
|
||||
} else {
|
||||
if ($res == 0) {
|
||||
return $this->success('没有更新', [], 1, 1);
|
||||
}
|
||||
return $this->fail('上传失败');
|
||||
}
|
||||
}
|
||||
|
||||
// 发送合同
|
||||
public function Draftingcontracts()
|
||||
{
|
||||
$params = $this->request->param();
|
||||
$result = ShopContractLogic::Draftingcontracts($params);
|
||||
if ($result == true) {
|
||||
return $this->success('生成合同成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(ContractLogic::getError());
|
||||
}
|
||||
|
||||
//**发送短信 */ 接口可能要做调整
|
||||
|
||||
public function postsms()
|
||||
{
|
||||
$params = $this->request->param();
|
||||
$re = ShopContractLogic::postsms($params);
|
||||
if (!$re) {
|
||||
return $this->fail(ShopContractLogic::getError());
|
||||
}
|
||||
return $this->success('成功');
|
||||
}
|
||||
|
||||
public function evidence()
|
||||
{
|
||||
$id = $this->request->param('id');
|
||||
$detail=ShopContract::where('id',$id)->find();
|
||||
if(!empty($detail['evidence_url'])){
|
||||
return $this->success('获取成功', ['url' => env('url.url_prefix').$detail['evidence_url']]);
|
||||
}
|
||||
$company=ShopMerchant::where('id',$detail['party_a'])->find();
|
||||
$request = array(
|
||||
"applyNo" => $detail['contract_no'],
|
||||
"fullName" => $company['company_name'],
|
||||
"identityCard" => $company['organization_code'],
|
||||
"identityType" => 12,
|
||||
);
|
||||
return app(JunziqianController::class)->EvidenceShopDownload($request);
|
||||
}
|
||||
|
||||
public function addNote()
|
||||
{
|
||||
$params = $this->request->param(); // id notes
|
||||
$shopContract = ShopContract::where('id', $params['id'])->find();
|
||||
if (empty($shopContract)) {
|
||||
return $this->fail('合同不存在');
|
||||
}
|
||||
$shopContract->notes = $params['notes'];
|
||||
$shopContract->save();
|
||||
return $this->success('成功');
|
||||
}
|
||||
}
|
@ -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\ShopMerchantLists;
|
||||
use app\adminapi\logic\ShopMerchantLogic;
|
||||
use app\adminapi\validate\ShopMerchantValidate;
|
||||
|
||||
|
||||
/**
|
||||
* ShopMerchant控制器
|
||||
* Class ShopMerchantController
|
||||
* @package app\adminapi\controller
|
||||
*/
|
||||
class ShopMerchantController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/09/13 16:45
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new ShopMerchantLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/09/13 16:45
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new ShopMerchantValidate())->post()->goCheck('add');
|
||||
$result = ShopMerchantLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(ShopMerchantLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/09/13 16:45
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new ShopMerchantValidate())->post()->goCheck('edit');
|
||||
$result = ShopMerchantLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(ShopMerchantLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/09/13 16:45
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new ShopMerchantValidate())->post()->goCheck('delete');
|
||||
ShopMerchantLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/09/13 16:45
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new ShopMerchantValidate())->goCheck('detail');
|
||||
$result = ShopMerchantLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,427 +0,0 @@
|
||||
<?php
|
||||
|
||||
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
|
||||
{
|
||||
public function lists()
|
||||
{
|
||||
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
|
||||
$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) {
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
Db::commit();
|
||||
return $this->success('审核成功');
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
return $this->fail($e->getFile().$e->getLine().$e->getMessage());
|
||||
}
|
||||
}
|
||||
// 通过
|
||||
private function pass($approve, $params=[])
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// 拒绝
|
||||
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
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 股金任务审批
|
||||
*/
|
||||
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]);
|
||||
}
|
||||
}
|
@ -114,14 +114,14 @@ class ContractController extends BaseAdminController
|
||||
{
|
||||
$params = Request::param();
|
||||
$file = $params['file'];
|
||||
$res = Contract::where('id', $params['id'])->update(['file' => $file, 'check_status' => 2]);
|
||||
$res = Contract::where('id', $params['id'])->update(['file' => $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();
|
||||
$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'],
|
||||
@ -137,62 +137,45 @@ class ContractController extends BaseAdminController
|
||||
SmsLogic::contractUrl($b);
|
||||
return $this->success('上传成功', [], 1, 1);
|
||||
} else {
|
||||
if ($res == 0) {
|
||||
if($res==0){
|
||||
return $this->success('没有更新', [], 1, 1);
|
||||
}
|
||||
return $this->fail('上传失败');
|
||||
}
|
||||
}
|
||||
|
||||
//**发送短信 */ 接口可能要做调整
|
||||
|
||||
public function postsms()
|
||||
{
|
||||
$params = Request::param();
|
||||
$find = Db::name('contract')->where('id', $params['id'])
|
||||
->withAttr('contract_type_name', function ($value, $data) {
|
||||
return Db::name('dict_data')->where('id', $data['contract_type'])->value('name');
|
||||
})
|
||||
->withAttr('user_info', function ($value, $data) {
|
||||
if ($data['type'] == 1) {
|
||||
return Db::name('admin')->where('id', $data['party_b'])->field('name,phone')->find();
|
||||
//**发送短信 */ 接口可能要做调整
|
||||
|
||||
public function postsms()
|
||||
{
|
||||
$params = Request::param();
|
||||
$find = Db::name('contract')->where('id', $params['id'])
|
||||
->withAttr('contract_type_name', function ($value, $data) {
|
||||
return Db::name('dict_data')->where('id', $data['contract_type'])->value('name');
|
||||
})
|
||||
->withAttr('user_info', function ($value, $data) {
|
||||
if($data['type']==1){
|
||||
return Db::name('admin')->where('id', $data['party_b'])->field('name,phone')->find();
|
||||
}else{
|
||||
return Db::name('user')->where('id', $data['party_b'])->field('nickname name,mobile phone')->find();
|
||||
}
|
||||
})
|
||||
->find();
|
||||
if ($find && $find['url'] != '') {
|
||||
//发送短信
|
||||
$sms = [
|
||||
'mobile' => $find['user_info']['phone'],
|
||||
'name' => $find['user_info']['name'],
|
||||
'type' => '《' . $find['contract_type_name'] . '》',
|
||||
'code' => 'api/Hetong/url?id=' . $find['id'],
|
||||
'scene' => 'WQ'
|
||||
];
|
||||
$result = SmsLogic::contractUrl($sms);
|
||||
if (true === $result) {
|
||||
return $this->success('发送成功');
|
||||
} else {
|
||||
return Db::name('user')->where('id', $data['party_b'])->field('nickname name,mobile phone')->find();
|
||||
return $this->fail(SmsLogic::getError());
|
||||
}
|
||||
})
|
||||
->find();
|
||||
if ($find && $find['url'] != '') {
|
||||
//发送短信
|
||||
$sms = [
|
||||
'mobile' => $find['user_info']['phone'],
|
||||
'name' => $find['user_info']['name'],
|
||||
'type' => '《' . $find['contract_type_name'] . '》',
|
||||
'code' => 'api/Hetong/url?id=' . $find['id'],
|
||||
'scene' => 'WQ'
|
||||
];
|
||||
$result = SmsLogic::contractUrl($sms);
|
||||
if (true === $result) {
|
||||
return $this->success('发送成功');
|
||||
} else {
|
||||
return $this->fail(SmsLogic::getError());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function evidence()
|
||||
{
|
||||
$id = Request::param('id');
|
||||
$detail=Contract::where('id',$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);
|
||||
}
|
||||
}
|
||||
|
@ -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,36 @@ 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{
|
||||
//更新物流系统
|
||||
curl_post(env('project.logistic_domain').'/api/contractUpdate',[],[
|
||||
'id' => $vehicle_contract['contract_logistic_id'],
|
||||
'file' => $params['file'],
|
||||
'status' => 1,
|
||||
]);
|
||||
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 +154,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 +165,14 @@ 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);
|
||||
$this->sendSms($params['id'],'《租赁合同》');
|
||||
return $this->success('合同发送成功');
|
||||
} else {
|
||||
return $this->fail($signRes->msg);
|
||||
@ -269,49 +250,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);
|
||||
}
|
||||
|
||||
}
|
@ -3,26 +3,22 @@
|
||||
namespace app\adminapi\controller\finance;
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\finance\WithdrawLists;
|
||||
use app\common\logic\finance\WithdrawLogic;
|
||||
use app\common\model\user\Withdraw;
|
||||
use think\Exception;
|
||||
|
||||
class WithdrawController extends BaseAdminController
|
||||
{
|
||||
|
||||
public function index()
|
||||
{
|
||||
return $this->dataLists(new WithdrawLists());
|
||||
// [$page, $limit] = $this->getPage();
|
||||
// $status = $this->request->param('status');
|
||||
// $query = Withdraw::with('user');
|
||||
// if ($status !== '') {
|
||||
// $query->where('status', $status);
|
||||
// }
|
||||
// $count = $query->count();
|
||||
// $list = $query->order('id', 'desc')->page($page)->limit($limit)->select()->toArray();
|
||||
// return $this->success('success', ['count' => $count, 'data' => $list]);
|
||||
[$page, $limit] = $this->getPage();
|
||||
$status = $this->request->param('status');
|
||||
$query = Withdraw::with('user');
|
||||
if ($status !== '') {
|
||||
$query->where('status', $status);
|
||||
}
|
||||
$count = $query->count();
|
||||
$list = $query->order('id', 'desc')->page($page)->limit($limit)->select()->toArray();
|
||||
return $this->success('success', ['count' => $count, 'data' => $list]);
|
||||
}
|
||||
|
||||
public function update($id)
|
||||
@ -41,20 +37,4 @@ class WithdrawController extends BaseAdminController
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提现申请审核
|
||||
*/
|
||||
public function audit()
|
||||
{
|
||||
try {
|
||||
$params = $this->request->param();
|
||||
$re = WithdrawLogic::audit($params);
|
||||
if (!$re) {
|
||||
return $this->fail(WithdrawLogic::getError());
|
||||
}
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
} catch (Exception $exception) {
|
||||
return $this->fail($exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
@ -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,8 @@ 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;
|
||||
|
||||
|
||||
/**
|
||||
@ -56,21 +53,8 @@ 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) {
|
||||
// 创建 镇合伙人公司 任务模板
|
||||
$result = TaskTemplateLogic::addTownTaskTemplate($params);
|
||||
} else if ($company->company_type == 17) {
|
||||
$result = TaskTemplateLogic::addVillageTaskTemplate($params);
|
||||
} else {
|
||||
$result = TaskTemplateLogic::add($params);
|
||||
}
|
||||
|
||||
$result = TaskTemplateLogic::add($params);
|
||||
if (true === $result) {
|
||||
/**
|
||||
* 如果是公司第一次创建安排任务,则初始化公司的提现周期截止时间
|
||||
*/
|
||||
TaskTemplateLogic::initCompanyWithdrawDeadline($params['company_id']);
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(TaskTemplateLogic::getError());
|
||||
@ -103,10 +87,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 +105,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);
|
||||
}
|
||||
|
||||
}
|
@ -55,7 +55,7 @@ class AppUpdateLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
public function lists(): array
|
||||
{
|
||||
return AppUpdate::where($this->searchWhere)
|
||||
->field(['id', 'title', 'content', 'type', 'version', 'dow_url', 'force', 'quiet', 'create_time', 'update_time'])
|
||||
->field(['id', 'title', 'content', 'type', 'version', 'dow_url', 'force', 'quiet'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
@ -1,77 +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\CompanyForm;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
/**
|
||||
* CompanyForm列表
|
||||
* Class CompanyFormLists
|
||||
* @package app\adminapi\lists
|
||||
*/
|
||||
class CompanyFormLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2023/09/15 14:00
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['company_name', 'organization_code', 'address', 'master_name', 'type', 'master_email', 'notes'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2023/09/15 14:00
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return CompanyForm::where($this->searchWhere)
|
||||
->field(['id', 'company_name', 'organization_code', 'address', 'master_name', 'type', 'master_email', 'notes'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2023/09/15 14:00
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return CompanyForm::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,10 +88,9 @@ 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'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->append(['notes'], true)
|
||||
->withAttr('company_type',function($value,$data){
|
||||
return Db::name('dict_data')->where('id',$value)->value('name');
|
||||
})
|
||||
@ -105,14 +103,6 @@ class CompanyLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
->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();
|
||||
}
|
||||
@ -127,23 +117,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
|
||||
|
@ -1,79 +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\ShopContract;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
/**
|
||||
* ShopContract列表
|
||||
* Class ShopContractLists
|
||||
* @package app\adminapi\lists
|
||||
*/
|
||||
class ShopContractLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2023/09/13 17:01
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['contract_no', 'party_a', 'party_b', 'check_status'],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2023/09/13 17:01
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return ShopContract::where($this->searchWhere)
|
||||
->field(['id', 'contract_no', 'party_a', 'party_b', 'area_manager', 'type', 'evidence_url', 'check_status', 'status', 'notes'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->with(['partyA', 'partyB'])
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2023/09/13 17:01
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return ShopContract::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
@ -1,83 +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\ShopMerchant;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* ShopMerchant列表
|
||||
* Class ShopMerchantLists
|
||||
* @package app\adminapi\lists
|
||||
*/
|
||||
class ShopMerchantLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2023/09/13 16:45
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['company_name', 'master_name', 'master_phone'],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2023/09/13 16:45
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return ShopMerchant::where($this->searchWhere)
|
||||
->field(['id', 'company_name', 'organization_code', 'master_name', 'master_phone'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->append(['notes'], true)
|
||||
->withAttr('notes',function($value,$data){
|
||||
return Db::name('company_authentication_fail_log')->where('company_id',$data['id'])->where('log_type', 3)->order(['id'=>'desc'])->limit(1)->value('fail_reason');
|
||||
})
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2023/09/13 16:45
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return ShopMerchant::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
@ -1,142 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\lists\approve;
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
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
|
||||
{
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2023/08/31 11:08
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'in' => ['type'],
|
||||
'='=>['check_status']
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function queryWhere()
|
||||
{
|
||||
$where = [];
|
||||
// $where[] = ['check_admin_ids', '=', $this->adminId]; // todo 放开过滤条件,只有片区经理才能查看
|
||||
return $where;
|
||||
}
|
||||
|
||||
public function lists(): array
|
||||
{
|
||||
return 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){
|
||||
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');
|
||||
})
|
||||
->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
|
||||
{
|
||||
return Approve::where($this->searchWhere)->count();
|
||||
}
|
||||
}
|
@ -90,13 +90,9 @@ class ContractLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
}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='暂无片区经理';
|
||||
}
|
||||
$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='暂无片区经理';
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
@ -16,7 +16,6 @@ namespace app\adminapi\lists\finance;
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\enum\user\AccountLogEnum;
|
||||
use app\common\lists\ListsExcelInterface;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\user\UserAccountLog;
|
||||
use app\common\model\user\UserRole;
|
||||
@ -28,42 +27,9 @@ use app\common\service\FileService;
|
||||
* Class AccountLogLists
|
||||
* @package app\adminapi\lists\finance
|
||||
*/
|
||||
class AccountLogLists extends BaseAdminDataLists implements ListsSearchInterface,ListsExcelInterface
|
||||
class AccountLogLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 导出字段
|
||||
* @return string[]
|
||||
* @author 段誉
|
||||
* @date 2023/2/24 16:07
|
||||
*/
|
||||
public function setExcelFields(): array
|
||||
{
|
||||
return [
|
||||
'user_info_sn' => '用户编号',
|
||||
'company_info_company_name' => '归属公司',
|
||||
'user_info_nickname' => '用户昵称',
|
||||
'user_info_group_name' => '角色名称',
|
||||
'user_info_mobile' => '手机号码',
|
||||
'change_amount' => '变动金额',
|
||||
'left_amount' => '剩余金额',
|
||||
'change_type_desc' => '变动类型',
|
||||
'source_sn' => '来源单号',
|
||||
'create_time' => '记录时间',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 导出表名
|
||||
* @return string
|
||||
* @author 段誉
|
||||
* @date 2023/2/24 16:07
|
||||
*/
|
||||
public function setFileName(): string
|
||||
{
|
||||
return '余额明细';
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 搜索条件
|
||||
* @return array
|
||||
@ -123,12 +89,6 @@ class AccountLogLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
$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'];
|
||||
}
|
||||
|
||||
return $lists;
|
||||
|
@ -97,6 +97,7 @@ class RefundRecordLists extends BaseAdminDataLists implements ListsSearchInterfa
|
||||
foreach ($lists as &$item) {
|
||||
$item['avatar'] = FileService::getFileUrl($item['avatar']);
|
||||
}
|
||||
|
||||
return $lists;
|
||||
}
|
||||
|
||||
|
@ -1,96 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\lists\finance;
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\user\UserAccountLog;
|
||||
use app\common\model\user\Withdraw;
|
||||
|
||||
class WithdrawLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 搜索条件
|
||||
* @return array
|
||||
* @author 段誉
|
||||
* @date 2023/2/24 15:26
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['order_sn','user_id', 'amount', 'status'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 搜索条件
|
||||
* @author 段誉
|
||||
* @date 2023/2/24 15:26
|
||||
*/
|
||||
public function queryWhere()
|
||||
{
|
||||
$where = [];
|
||||
// 用户余额
|
||||
return $where;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return array
|
||||
* @author 段誉
|
||||
* @date 2023/2/24 15:31
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$lists = Withdraw::where($this->searchWhere)
|
||||
->append(['s_date', 'e_date', 'company_name'], true)
|
||||
->with('user')
|
||||
->where($this->queryWhere())
|
||||
->withAttr('company_name', function ($value, $data) {
|
||||
$company = Company::where(['admin_id'=>$data['admin_id']])->find();
|
||||
return $company['company_name']??'';
|
||||
})
|
||||
->withAttr('s_date', function ($value, $data) {
|
||||
$withdrawedCount = Withdraw::where(['user_id'=>$data['user_id'], 'status'=>3])->count();
|
||||
$company = Company::where(['admin_id'=>$data['admin_id']])->find();
|
||||
// 开始时间 如果用户第一次提现申请,则以该公司内用户 周期内第一条数据的生成时间为开始时间
|
||||
if ($withdrawedCount == 0) {
|
||||
$firstUserLog = UserAccountLog::where(['company_id'=>$company['id']])->order('id', 'asc')->find();
|
||||
return $firstUserLog['create_time'];
|
||||
} else {
|
||||
// 如果用户已成功申请过提现,则以上次提现的截止日期为开始时间
|
||||
$withdrawedCount = Withdraw::where(['user_id'=>$data['user_id'], 'status'=>3])->order('id', 'desc')->find();
|
||||
return $withdrawedCount['transfer_end_cycel'];
|
||||
}
|
||||
})
|
||||
->withAttr('e_date', function ($value, $data) {
|
||||
// 结束时间
|
||||
return date('Y-m-d H:i:s', $data['transfer_end_cycel']);
|
||||
})
|
||||
->order('id', 'desc')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->select()
|
||||
->toArray();
|
||||
unset($item);
|
||||
return $lists;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
* @return int
|
||||
* @author 段誉
|
||||
* @date 2023/2/24 15:36
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return Withdraw::where($this->queryWhere())
|
||||
->where($this->searchWhere)
|
||||
->count();
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -36,8 +36,8 @@ class DictDataLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'%like%' => ['name'],
|
||||
'=' => ['status', 'type_id', 'type_value']
|
||||
'%like%' => ['name', 'type_value'],
|
||||
'=' => ['status', 'type_id']
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -62,8 +62,8 @@ class TaskSchedulingPlanLists extends BaseAdminDataLists implements ListsSearchI
|
||||
}
|
||||
return TaskSchedulingPlan::where($this->searchWhere)
|
||||
->where($where)
|
||||
->with(['template','templateInfo'])
|
||||
// ->field(['id', 'create_user_id', 'template_id', 'scheduling_id', 'start_time', 'end_time', 'status'])
|
||||
->with(['template'])
|
||||
->field(['id', 'create_user_id', 'template_id', 'scheduling_id', 'start_time', 'end_time', 'status'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
|
@ -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)
|
||||
|
@ -78,8 +78,7 @@ class AppUpdateLogic extends BaseLogic
|
||||
'version' => $params['version'],
|
||||
'dow_url' => $params['dow_url'],
|
||||
'force' => $params['force'],
|
||||
'quiet' => $params['quiet'],
|
||||
'update_time'=>time()
|
||||
'quiet' => $params['quiet']
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
|
@ -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,118 +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\CompanyForm;
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* CompanyForm逻辑
|
||||
* Class CompanyFormLogic
|
||||
* @package app\adminapi\logic
|
||||
*/
|
||||
class CompanyFormLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2023/09/15 14:00
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
CompanyForm::create([
|
||||
'company_name' => $params['company_name'],
|
||||
'organization_code' => $params['organization_code'],
|
||||
'address' => $params['address'],
|
||||
'master_name' => $params['master_name'],
|
||||
'type' => $params['type'],
|
||||
'master_email' => $params['master_email'],
|
||||
'notes' => $params['notes'],
|
||||
]);
|
||||
|
||||
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/15 14:00
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
CompanyForm::where('id', $params['id'])->update([
|
||||
'company_name' => $params['company_name'],
|
||||
'organization_code' => $params['organization_code'],
|
||||
'address' => $params['address'],
|
||||
'master_name' => $params['master_name'],
|
||||
'type' => $params['type'],
|
||||
'master_email' => $params['master_email'],
|
||||
'notes' => $params['notes'],
|
||||
]);
|
||||
|
||||
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/15 14:00
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return CompanyForm::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2023/09/15 14:00
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return CompanyForm::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
}
|
@ -99,36 +99,6 @@ class ConfigLogic
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 根据类型获取字典类型
|
||||
* @param $type
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2022/9/27 19:09
|
||||
*/
|
||||
public static function getDictTypeValueByType($type)
|
||||
{
|
||||
if (!is_string($type)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$type = explode(',', $type);
|
||||
$lists = DictData::whereIn('type_value', $type)->select()->toArray();
|
||||
|
||||
if (empty($lists)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$result = [];
|
||||
foreach ($lists as $dict) {
|
||||
$result[$dict['name']] = $dict;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,264 +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\api\controller\JunziqianController;
|
||||
use app\api\logic\SmsLogic;
|
||||
use app\common\logic\CompanyLogic;
|
||||
use app\common\logic\contract\ContractLogic;
|
||||
use app\common\logic\UserLogic;
|
||||
use app\common\model\ShopContract;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\ShopMerchant;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* ShopContract逻辑
|
||||
* Class ShopContractLogic
|
||||
* @package app\adminapi\logic
|
||||
*/
|
||||
class ShopContractLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2023/09/13 17:01
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
ShopContract::create([
|
||||
'contract_no' => $params['contract_no'],
|
||||
'type' => $params['type'],
|
||||
'contract_url' => $params['contract_url'],
|
||||
'evidence_url' => $params['evidence_url'],
|
||||
'url' => $params['url'],
|
||||
'signing_timer' => $params['signing_timer'],
|
||||
]);
|
||||
|
||||
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/13 17:01
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
ShopContract::where('id', $params['id'])->update([
|
||||
'file' => $params['file'],
|
||||
]);
|
||||
|
||||
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/13 17:01
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return ShopContract::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2023/09/13 17:01
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
$data = Db::name('shop_contract')->where('id', $params['id'])
|
||||
->withAttr('party_b_info', function ($value, $data) {
|
||||
|
||||
$field = ['id,company_name,company_type,company_type company_type_name,organization_code,
|
||||
province,city,area,street,village,brigade,address,province province_name,city city_name,area area_name,street street_name,village village_name,brigade brigade_name,master_phone,master_name,
|
||||
qualification'];
|
||||
$shopMerchant = ShopMerchant::where(['id' => $data['party_b']])->field($field)->find()->toArray();
|
||||
$shopMerchant['qualification'] = json_decode($shopMerchant['qualification'], true);
|
||||
if($shopMerchant['qualification'] && isset($shopMerchant['qualification']['other_qualifications'])){
|
||||
$shopMerchant['qualification']['other_qualifications']=json_decode($shopMerchant['qualification']['other_qualifications'],true);
|
||||
}
|
||||
return $shopMerchant;
|
||||
})
|
||||
->withAttr('party_a_info', function ($value, $data) {
|
||||
$field = ['id,company_name,company_type,company_type company_type_name,organization_code,
|
||||
province,city,area,street,village,brigade,address,province province_name,city city_name,area area_name,street street_name,village village_name,brigade brigade_name,master_phone,master_name,
|
||||
qualification'];
|
||||
$shopMerchant = ShopMerchant::where(['id' => $data['party_a']])->field($field)->find()->toArray();
|
||||
if($shopMerchant['qualification'] && isset($shopMerchant['qualification']['other_qualifications'])){
|
||||
$shopMerchant['qualification']['other_qualifications']=json_decode($shopMerchant['qualification']['other_qualifications'],true);
|
||||
}
|
||||
return $shopMerchant;
|
||||
})
|
||||
->withAttr('status_name', function ($value, $data) {
|
||||
return $data['status'] == 1 ? '已签约' : '未签约';
|
||||
})
|
||||
->find();
|
||||
$data['signed_contract_url'] = self::getSignedContract($data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getSignedContract($contract)
|
||||
{
|
||||
$signedContractUrl = '';
|
||||
if($contract['status'] == 1){
|
||||
if ($contract['contract_url'] == '') {
|
||||
$res = app(JunziqianController::class)->download_shop_file($contract['contract_no'])->getData();
|
||||
if ($res['code'] == 1) {
|
||||
$signedContractUrl = $res['data']['url'];
|
||||
}
|
||||
}else {
|
||||
$signedContractUrl = env('url.url_prefix').$contract['contract_url'];
|
||||
}
|
||||
}
|
||||
return $signedContractUrl;
|
||||
}
|
||||
|
||||
|
||||
// /**发送合同 */
|
||||
public static function Draftingcontracts($params,$type=1)
|
||||
{
|
||||
$result = ShopMerchantLogic::detail($params);
|
||||
if ($result && isset($result['contract']) && isset($result['contract']['file']) && $result['contract']['file'] != '') {
|
||||
if ($result['contract']['check_status'] == 3) {
|
||||
return self::setError('你已经生成过合同,请勿重复生成');
|
||||
}
|
||||
|
||||
$name=$result['company_name'];
|
||||
$data = [
|
||||
'name' => $name . '的合同',
|
||||
'signatories' => [
|
||||
['fullName' => $name, 'identityType' => 12, 'identityCard' => $result['organization_code'], 'email' => $result['master_email'], 'noNeedVerify' => 1, 'signLevel' => 1], // 'authLevel'=>[11], 签约时验证人脸识别
|
||||
['fullName' => $result['contract']['party_a_info']['company_name'], 'identityType' => 12, 'identityCard' => $result['contract']['party_a_info']['organization_code'], 'email' => $result['contract']['party_a_info']['master_email'], 'noNeedVerify' => 1, 'signLevel' => 1]
|
||||
],
|
||||
'url' => $result['contract']['file'],
|
||||
];
|
||||
|
||||
$res = app(JunziqianController::class)->shopContractSigning($data, $result['contract']['id']);
|
||||
if ($res->success == true) {
|
||||
Db::name('shop_contract')->where('id', $result['contract']['id'])->update(['contract_no' => $res->data, 'check_status' => 3]);
|
||||
self::postsms(['id'=>$result['contract']['id']]);
|
||||
return true;
|
||||
} else {
|
||||
return self::setError($res->msg);
|
||||
}
|
||||
} else {
|
||||
return self::setError('生成合同成功失败,联系管理员');
|
||||
}
|
||||
}
|
||||
|
||||
//**发送短信 */
|
||||
public static function postsms($params)
|
||||
{
|
||||
$result = self::detail($params);
|
||||
if ($result && $result['file'] != '') {
|
||||
//发送短信
|
||||
$data = [
|
||||
[
|
||||
"applyNo" => $result['contract_no'], //TODO *
|
||||
"fullName" => $result['party_a_info']['company_name'], //TODO *
|
||||
"identityCard" => $result['party_a_info']['organization_code'], //TODO *
|
||||
"identityType" => 12, //TODO *
|
||||
"master_phone" => $result['party_a_info']['master_phone'],
|
||||
"type"=>"party_a"
|
||||
],
|
||||
];
|
||||
|
||||
$data[]= [
|
||||
"applyNo" => $result['contract_no'], //TODO *
|
||||
"fullName" => $result['party_b_info']['company_name'], //TODO *
|
||||
"identityCard" => $result['party_b_info']['organization_code'], //TODO *
|
||||
"identityType" => 12, //TODO *
|
||||
"master_phone" => $result['party_b_info']['master_phone'],
|
||||
"type"=>"party_b"
|
||||
|
||||
];
|
||||
|
||||
$find = Db::name('shop_contract')->where('id', $params['id'])
|
||||
->withAttr('contract_type_name', function ($value, $data) {
|
||||
return Db::name('dict_data')->where('id', $data['contract_type'])->value('name');
|
||||
})->find();
|
||||
|
||||
$url = [];
|
||||
foreach ($data as $k => $v) {
|
||||
$res = app(JunziqianController::class)->SigningLink($v);
|
||||
if ($res->success == true) {
|
||||
if ($v['type'] == 'party_a') {
|
||||
$url['a'] =$res->data;
|
||||
} else {
|
||||
$url['b'] =$res->data;
|
||||
}
|
||||
if ($v['type'] == 'party_a') {
|
||||
$v['type'] = 'a';
|
||||
}
|
||||
if ($v['type'] == 'party_b') {
|
||||
$v['type'] = 'b';
|
||||
}
|
||||
//发送短信
|
||||
$sms = [
|
||||
'mobile' => $v['master_phone'],
|
||||
'name' => $v['fullName'],
|
||||
'type' => '《商户入驻合同》',
|
||||
'code' => 'api/Hetong/url?id=' . $find['id'].'&type='.$v['type'].'&t=1',
|
||||
'scene' => 'WQ'
|
||||
];
|
||||
$result = SmsLogic::contractUrl($sms);
|
||||
if ($result != true) {
|
||||
return self::setError(SmsLogic::getError());
|
||||
}
|
||||
} else {
|
||||
return self::setError($res->msg);
|
||||
}
|
||||
}
|
||||
Db::name('shop_contract')->where('id', $find['id'])->update(['url' => json_encode($url)]);
|
||||
return true;
|
||||
}else{
|
||||
return self::setError('没找到合同,联系管理员');
|
||||
}
|
||||
}
|
||||
}
|
@ -1,120 +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\auth\Admin;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\contract\Contract;
|
||||
use app\common\model\contract\ShopContract;
|
||||
use app\common\model\ShopMerchant;
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* ShopMerchant逻辑
|
||||
* Class ShopMerchantLogic
|
||||
* @package app\adminapi\logic
|
||||
*/
|
||||
class ShopMerchantLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2023/09/13 16:45
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
ShopMerchant::create([
|
||||
|
||||
]);
|
||||
|
||||
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/13 16:45
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
ShopMerchant::where('id', $params['id'])->update([
|
||||
|
||||
]);
|
||||
|
||||
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/13 16:45
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return ShopMerchant::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2023/09/13 16:45
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
$data = ShopMerchant::findOrEmpty($params['id'])->toArray();
|
||||
if ($data) {
|
||||
$where[]=['party_b','=', $data['id']];
|
||||
if(isset($params['contract_type'])){
|
||||
$where[]=['contract_type','=',$params['contract_type']];
|
||||
}
|
||||
$data['contract'] = ShopContract::where($where)->with(['party_a_info', 'contractType'])->find();
|
||||
|
||||
}
|
||||
return $data;
|
||||
// return ShopMerchant::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,100 +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;
|
||||
|
||||
|
||||
/**
|
||||
* CompanyForm验证器
|
||||
* Class CompanyFormValidate
|
||||
* @package app\adminapi\validate
|
||||
*/
|
||||
class CompanyFormValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'company_name' => 'require',
|
||||
'organization_code' => 'require',
|
||||
'master_name' => 'require',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
'company_name' => '商户名称',
|
||||
'organization_code' => '社会信用统一代码',
|
||||
'master_name' => '法人名称',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return CompanyFormValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/09/15 14:00
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['company_name','organization_code','master_name']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return CompanyFormValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/09/15 14:00
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id','company_name','organization_code','master_name']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return CompanyFormValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/09/15 14:00
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return CompanyFormValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/09/15 14:00
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
}
|
@ -35,7 +35,7 @@ class CompanyValidate extends BaseValidate
|
||||
'company_name' => 'require|unique:Company',
|
||||
'organization_code' => 'require',
|
||||
'master_name' => 'require',
|
||||
// 'id_card' => 'require',
|
||||
'id_card' => 'require',
|
||||
'master_position' => 'require',
|
||||
'master_phone' => 'require',
|
||||
'master_email' => 'require',
|
||||
@ -53,7 +53,7 @@ class CompanyValidate extends BaseValidate
|
||||
'company_name' => '公司名称',
|
||||
'organization_code' => '组织机构代码',
|
||||
'master_name' => '主联系人姓名',
|
||||
// 'id_card' => '主联系人身份证',
|
||||
'id_card' => '主联系人身份证',
|
||||
'master_position' => '主联系人职务',
|
||||
'master_phone' => '主联系人手机',
|
||||
'master_email' => '主联系人邮箱',
|
||||
@ -70,7 +70,7 @@ class CompanyValidate extends BaseValidate
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['company_name','organization_code','master_name','master_position','master_phone']);
|
||||
return $this->only(['company_name','organization_code','master_name','id_card','master_position','master_phone']);
|
||||
}
|
||||
|
||||
|
||||
@ -82,7 +82,7 @@ class CompanyValidate extends BaseValidate
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id','company_name','organization_code','master_name','master_position','master_phone']);
|
||||
return $this->only(['id','company_name','organization_code','master_name','id_card','master_position','master_phone']);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* ShopContract验证器
|
||||
* Class ShopContractValidate
|
||||
* @package app\adminapi\validate
|
||||
*/
|
||||
class ShopContractValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return ShopContractValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/09/13 17:01
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id', true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return ShopContractValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/09/13 17:01
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return ShopContractValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/09/13 17:01
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return ShopContractValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/09/13 17:01
|
||||
*/
|
||||
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;
|
||||
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* ShopMerchant验证器
|
||||
* Class ShopMerchantValidate
|
||||
* @package app\adminapi\validate
|
||||
*/
|
||||
class ShopMerchantValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return ShopMerchantValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/09/13 16:45
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id', true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return ShopMerchantValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/09/13 16:45
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return ShopMerchantValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/09/13 16:45
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return ShopMerchantValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/09/13 16:45
|
||||
*/
|
||||
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' => '参数缺失',
|
||||
];
|
||||
|
||||
|
||||
|
@ -1,51 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\lists\approve\ApproveLists;
|
||||
use app\common\logic\approve\ApproveLogic;
|
||||
use app\common\model\Approve;
|
||||
use Symfony\Component\HttpClient\HttpClient;
|
||||
use think\Exception;
|
||||
use think\facade\Db;
|
||||
|
||||
class ApproveController extends BaseApiController
|
||||
{
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new ApproveLists());
|
||||
}
|
||||
|
||||
public function approveType()
|
||||
{
|
||||
$list = Db::name('flow_type')->where(['status' => 1])->field(['id, title'])->select()->toArray();
|
||||
return $this->success('成功', $list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 前台通用审批接口 审批后的业务逻辑,需要具体拆解
|
||||
*/
|
||||
public function audit()
|
||||
{
|
||||
try {
|
||||
$params = $this->request->param(); // id check_status remark
|
||||
$approve = Approve::find($params['id']);
|
||||
if (!$approve) {
|
||||
throw new Exception('数据不存在');
|
||||
}
|
||||
ApproveLogic::audit($approve, $params, $this->userInfo);
|
||||
return $this->success('操作成功');
|
||||
} catch (Exception $exception) {
|
||||
return $this->fail(ApproveLogic::getError() ?? $exception->getMessage());
|
||||
}
|
||||
}
|
||||
public function detail()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
$detail = ApproveLogic::detail($param['id']);
|
||||
if (!$detail) {
|
||||
$this->fail('数据不存在');
|
||||
}
|
||||
return $this->success('成功', $detail->toArray());
|
||||
}
|
||||
}
|
@ -1,281 +1,56 @@
|
||||
<?php
|
||||
|
||||
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\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 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'];
|
||||
|
||||
/**
|
||||
* 任务结算
|
||||
*/
|
||||
public function index()
|
||||
{ //1201
|
||||
{
|
||||
|
||||
$id = 9;
|
||||
$shopMerchant = ShopMerchant::find(['id', $id]);
|
||||
// $data=json_decode($parmas['data'],true);
|
||||
// if($data['status']==1){
|
||||
// if($data['organizationRegNo']!=$shopMerchant->organization_code){
|
||||
// Log::error(['认证回调错误:',$parmas]);
|
||||
// return json(['success' => false, 'msg' => '认证回调错误']);
|
||||
// $transaction_pool=780;
|
||||
// $shang_date_total_price=[
|
||||
// 'arr'=>['total_price'=>305,'day_money'=>580]
|
||||
// ];
|
||||
// if(bcadd($shang_date_total_price['arr']['total_price'],$transaction_pool,2)>$shang_date_total_price['arr']['day_money']){
|
||||
// if($shang_date_total_price['arr']['total_price']<$shang_date_total_price['arr']['day_money']){
|
||||
// $shang_date_total_price['arr']['supplement']=bcsub($shang_date_total_price['arr']['day_money'],$shang_date_total_price['arr']['total_price'],2);
|
||||
// }else{
|
||||
// $shang_date_total_price['arr']['supplement']=0;
|
||||
// $shang_date_total_price['arr']['after_transaction_pool']=0;
|
||||
// }
|
||||
// $shang_date_total_price['arr']['before_transaction_pool']=$transaction_pool;
|
||||
// Task::where('id', 839)->update(['status' => 3,'extend'=>json_encode($shang_date_total_price)]);
|
||||
|
||||
$shopMerchant->save(['is_authentication' => 1]);
|
||||
// 生成合同
|
||||
$createContractData = [
|
||||
'id' => $id,
|
||||
'party_a' => 1,
|
||||
'party_a_name' => '泸州市海之农科技有限公司',
|
||||
'party_b' => $id,
|
||||
'party_b_name' => $shopMerchant->company_name,
|
||||
'contract_type' => 22,
|
||||
];
|
||||
$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);
|
||||
// $day_money=bcsub($shang_date_total_price['arr']['total_price'],$shang_date_total_price['arr']['day_money'],2);//当天还剩多少
|
||||
|
||||
// TaskTemplate::where('id',109)->update(['transaction_pool'=>bcadd($transaction_pool,$day_money,2)]);
|
||||
// }
|
||||
halt($res);
|
||||
|
||||
$select = Db::name('company_form')->where('type', 0)
|
||||
->select();
|
||||
$id = 0;
|
||||
foreach ($select as $key => $value) {
|
||||
$id = $value['id'];
|
||||
if ($value['organization_code'] != '' || $value['organization_code'] != null) {
|
||||
// $pattern = "/\*/";
|
||||
$name = $value['master_name'];
|
||||
|
||||
// if(preg_match($pattern, $name)){
|
||||
// $name=$value['master_name'];
|
||||
// }
|
||||
// if ($value['master_email']) {
|
||||
$email = $value['master_email'];
|
||||
// } else {
|
||||
// $email = substr(md5(uniqid()), rand(0, 22), 10) . "@lihai.com";
|
||||
// }
|
||||
$shopMerchantCertificationData = [
|
||||
'name' => $name,
|
||||
'organization_code' => $value['organization_code'],
|
||||
'business_license' => 'https://lihai001.oss-cn-chengdu.aliyuncs.com/def/561f8202305171526091317.png',
|
||||
'master_name' => $value['master_name'],
|
||||
'master_email' => $email,
|
||||
'id' => $value['id'],
|
||||
];
|
||||
// Db::name('company_form')->where('id', $value['id'])->update(['master_email' => $email]);
|
||||
queue(TaskTenZehn::class,$shopMerchantCertificationData);
|
||||
} else {
|
||||
Db::name('company_form')->where('id', $value['id'])->update(['type' => -1]);
|
||||
continue;
|
||||
}
|
||||
// $a=app(JunziqianController::class)->ShopMerchantCertification($shopMerchantCertificationData);
|
||||
$all=TaskSchedulingPlan::where('id',943)->with(['template_info','scheduling'])->select()->toArray();
|
||||
foreach($all as $k=>$v){
|
||||
queue(TaskInformationJob::class,$v);
|
||||
}
|
||||
|
||||
halt($id);
|
||||
}
|
||||
|
||||
public function ceshi1()
|
||||
{
|
||||
//认证一条龙
|
||||
$shopMerchantCertificationData = [
|
||||
'name' => 1212,
|
||||
'organization_code' => 2323,
|
||||
'business_license' => 'https://lihai001.oss-cn-chengdu.aliyuncs.com/def/561f8202305171526091317.png',
|
||||
'master_name' => 3423,
|
||||
'master_email' => 343,
|
||||
'id' => 123,
|
||||
];
|
||||
app(JunziqianController::class)->ShopMerchantCertification($shopMerchantCertificationData);
|
||||
halt(111);
|
||||
}
|
||||
public function ceshi2()
|
||||
{
|
||||
//重新认证
|
||||
$shopMerchantCertificationData = [
|
||||
'name' => 1212,
|
||||
'organization_code' => 2323,
|
||||
'business_license' => 'https://lihai001.oss-cn-chengdu.aliyuncs.com/def/561f8202305171526091317.png',
|
||||
'master_name' => 3423,
|
||||
'master_email' => 343,
|
||||
'id' => 123,
|
||||
];
|
||||
app(JunziqianController::class)->organizationReapply($shopMerchantCertificationData);
|
||||
halt(111);
|
||||
}
|
||||
|
||||
/**
|
||||
* 企业认证
|
||||
*/
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
return $this->fail("公司不存在");
|
||||
}
|
||||
}
|
||||
|
||||
/**发起合同
|
||||
* 请求参数如下
|
||||
* id: 14
|
||||
* party_a: 13
|
||||
* party_a_name: 史丹利农业集团股份有限公司
|
||||
* party_b: 14
|
||||
* party_b_name: 中国乐凯集团有限公司
|
||||
* contract_type: 25
|
||||
* contract_no:
|
||||
*/
|
||||
public function initiate_contract()
|
||||
{
|
||||
$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());
|
||||
}
|
||||
|
||||
/** 发送合同 发送君子签签约请求,成功后会发送回短信
|
||||
* 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();
|
||||
return true;
|
||||
$plan_all = TaskScheduling::where('id',119)->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();
|
||||
|
||||
$all = TaskTemplate::where('id', 116)->where('task_scheduling', $v['id'])->limit(30)->select()->toArray();
|
||||
$plan_ids[] = $v['id'];
|
||||
if ($all) {
|
||||
$plan_all[$k]['template'] = $all;
|
||||
@ -286,437 +61,88 @@ 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();
|
||||
public function ceshi(){
|
||||
return false;
|
||||
$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',99)->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]);
|
||||
}
|
||||
}
|
||||
$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();
|
||||
}
|
||||
|
||||
public function stage_inspection($v,$moeny_type='moeny',$title='一'){
|
||||
$count_moeny=0;
|
||||
foreach($v['template'] as $kkkk=>$vvvv){
|
||||
$count_moeny+=$vvvv[$moeny_type];
|
||||
}
|
||||
if($count_moeny>200){
|
||||
Log::info($title.'阶段金额大于200无法下达'.json_encode($v['company_info']));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//三轮车判断
|
||||
public function ceshi1(){
|
||||
$params=[
|
||||
'car_id'=>3,
|
||||
'start_time'=>'2023-08-18',
|
||||
'end_time'=>'2023-08-18 23:59:59'
|
||||
];
|
||||
$task=Task::where('id',487)->select()->toArray();
|
||||
foreach($task as $k=>$v){
|
||||
if(isset($v['extend']['terminus']['lnglat'])&& isset($v['extend']['transfer']['lnglat'])){
|
||||
$arr=$v['extend']['terminus']['lnglat'];
|
||||
$a=app(RemoteController::class)->coordinate($params,$arr[0],$arr[1]);
|
||||
|
||||
$arr_two=$v['extend']['transfer']['lnglat'];
|
||||
$b=app(RemoteController::class)->coordinate($params,$arr_two[0],$arr_two[1]);
|
||||
if($a<500 && $b<500){
|
||||
Task::where('id',$v['id'])->update(['status'=>3]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function ceshi2(){
|
||||
$all=TaskSchedulingPlan::where('id',699)->where('is_pay',0)->with(['template_info','scheduling'])->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);
|
||||
// $company = Company::where('id', $data['company_id'])->field('id,deposit,company_money,user_id,day_count,company_type,province,city,area,street,village,brigade')->find(); // 可能要判断预存金是否满足
|
||||
$task = Task::where('id', $data['task_id'])->field('director_uid')->where('status', 3)->with('director_info')->find();
|
||||
$arr['money'] = $data['template_info']['money'];
|
||||
$arr['company_id'] = $data['scheduling']['company_id'];
|
||||
$arr['msg'] = '来自任务【' . $data['template_info']['title'] . '】,完成人,的任务结算';
|
||||
$arr['proportion_one'] = $data['template_info']['proportion_one'];
|
||||
$arr['proportion_two'] = $data['template_info']['proportion_two'];
|
||||
$arr['sn'] = $data['sn'];
|
||||
$arr['id'] = $data['id'];
|
||||
}
|
||||
Log::info('小组服务公司定时任务结算执行成功'.date('Y-m-d H:i:s'));
|
||||
return $this->success('小组服务公司定时任务结算执行成功');
|
||||
halt($arr);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 镇农科公司任务下发 线上事故调试和紧急修复预案接口
|
||||
*/
|
||||
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('镇农科公司定时任务结算执行成功');
|
||||
}
|
||||
}
|
@ -4,11 +4,9 @@ namespace app\api\controller;
|
||||
|
||||
|
||||
use app\api\logic\IndexLogic;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\contract\VehicleContract;
|
||||
use app\Request;
|
||||
use think\facade\Db;
|
||||
use think\facade\Log;
|
||||
use think\response\Json;
|
||||
|
||||
|
||||
@ -21,26 +19,16 @@ class HetongController extends BaseApiController
|
||||
{
|
||||
|
||||
|
||||
public array $notNeedLogin = ['url','info', 'toFaceCreate', 'notifyOrganizationFaceCreate'];
|
||||
public array $notNeedLogin = ['url','info', 'toFaceCreate'];
|
||||
|
||||
public function url()
|
||||
{
|
||||
$id = Request()->get('id');
|
||||
$type = Request()->get('type');
|
||||
$params = Request()->param();
|
||||
$msg='合同不存在';
|
||||
if(empty($type)){
|
||||
$msg='参数错误';
|
||||
}
|
||||
if (isset($params['t']) && $params['t'] == 1) {
|
||||
$find = Db::name('shop_contract')->where('id', $id)->find();
|
||||
if ($find && $find['url']) {
|
||||
$url = json_decode($find['url'], true);
|
||||
if(isset($url[$type])){
|
||||
return redirect($url[$type]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($id && $type) {
|
||||
$find = Db::name('contract')->where('id', $id)->find();
|
||||
if ($find && $find['url']) {
|
||||
@ -83,21 +71,4 @@ class HetongController extends BaseApiController
|
||||
}
|
||||
return '<style type="text/css"> * { padding: 0; margin: 0; } div { padding: 4px 48px; } a { color: #2E5CD5; cursor: pointer; text-decoration: none } a:hover { text-decoration: underline; } body { background: #fff; font-family: "Century Gothic", "Microsoft yahei"; color: #333; font-size: 18px; } h1 { font-size: 100px; font-weight: normal; margin-bottom: 12px; } p { line-height: 1.6em; font-size: 42px } </style> <div style="padding: 24px 48px;"> <h1>:) </h1> <p>'.$msg.'</p> </div>';
|
||||
}
|
||||
|
||||
public function notifyOrganizationFaceCreate()
|
||||
{
|
||||
$parmas = Request()->param();
|
||||
Log::info(['人脸识别采集校验回调:',$parmas]);
|
||||
$result = json_decode($parmas['data'], true);
|
||||
$msg = '人脸采集成功';
|
||||
if (isset($result['status']) && $result['status'] == 1) {
|
||||
// 修改人脸采集状态
|
||||
Company::where(['organization_code'=>$result['organizationRegNo']])->update(['face_create_status'=>1]);
|
||||
} else {
|
||||
$msg = '采集失败,原因:'.$result['msg'];
|
||||
// 记录错误日志
|
||||
Db::name('company_authentication_fail_log')->insert(['company_id'=>$result['orderNo'], 'log_type'=>2,'fail_reason'=>$msg, 'create_time'=>time()]);
|
||||
}
|
||||
return '<style type="text/css"> * { padding: 0; margin: 0; } div { padding: 4px 48px; } a { color: #2E5CD5; cursor: pointer; text-decoration: none } a:hover { text-decoration: underline; } body { background: #fff; font-family: "Century Gothic", "Microsoft yahei"; color: #333; font-size: 18px; } h1 { font-size: 100px; font-weight: normal; margin-bottom: 12px; } p { line-height: 1.6em; font-size: 42px } </style> <div style="padding: 24px 48px;"> <h1>:) </h1> <p>'.$msg.'</p> </div>';
|
||||
}
|
||||
}
|
||||
|
@ -14,20 +14,12 @@
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\logic\IndexLogic;
|
||||
use app\common\logic\RedisLogic;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\company\CompanyProperty;
|
||||
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;
|
||||
use think\facade\Db;
|
||||
use think\facade\Log;
|
||||
use think\model\Pivot;
|
||||
use think\response\Json;
|
||||
|
||||
|
||||
@ -38,11 +30,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', 'systemCarRent', 'selfCarRent', 'cancelRent'];
|
||||
|
||||
/**
|
||||
* @notes 首页数据
|
||||
@ -59,6 +47,7 @@ class IndexController extends BaseApiController
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 全局配置
|
||||
* @return Json
|
||||
@ -113,7 +102,7 @@ class IndexController extends BaseApiController
|
||||
if ($find) {
|
||||
if ($find['signing_timer'] == 0) {
|
||||
Db::name('contract')->where('id', $a['id'])->update(['signing_timer' => 1]);
|
||||
return json(['success' => true, 'msg' => '成功']);
|
||||
return true;
|
||||
} else if ($find['signing_timer'] == 1) {
|
||||
Db::name('contract')->where('id', $a['id'])->update(['status' => 1, 'signing_timer' => 2]);
|
||||
if ($find['type'] == 1) {
|
||||
@ -128,38 +117,6 @@ class IndexController extends BaseApiController
|
||||
}
|
||||
return json(['success' => true, 'msg' => '成功']);
|
||||
}
|
||||
/**商户合同签约回调 */
|
||||
public function shopContractNotifyUrl()
|
||||
{
|
||||
$a = Request()->param();
|
||||
Log::info(['商户合同签约回调', $a]);
|
||||
// 获取合同详情
|
||||
if ($a) {
|
||||
$find = Db::name('shop_contract')->where('id', $a['id'])->find();
|
||||
|
||||
if ($find) {
|
||||
// 合同一方已签约
|
||||
if ($find['signing_timer'] == 0) {
|
||||
Db::name('shop_contract')->where('id', $a['id'])->update(['signing_timer' => 1]);
|
||||
return json(['success' => true, 'msg' => '成功']);
|
||||
} else if ($find['signing_timer'] == 1) {
|
||||
// 合同另一方已签约,修改合同状态,修改公司状态
|
||||
Db::name('shop_contract')->where('id', $a['id'])->update(['status' => 1, 'signing_timer' => 2]);
|
||||
Db::name('shop_merchant')->where('id', $find['party_a'])->update(['status' => 1, 'is_contract' => 1]);
|
||||
Db::name('shop_merchant')->where('id', $find['party_b'])->update(['status' => 1, 'is_contract' => 1]);
|
||||
// 通知商城,商户签约完成
|
||||
$shopMerchant = ShopMerchant::find(['id' => $find['party_b']]);
|
||||
$requestUtil = HttpClient::create()->request('POST', env('url.shop_prefix') . '/api/merchant/syncStatus/'.$shopMerchant['mer_intention_id'], [
|
||||
'body' => ['status' => 1]
|
||||
]);
|
||||
Log::info(['商户合同签约回调-商城响应', env('url.shop_prefix') . '/api/merchant/syncStatus/'.$shopMerchant['mer_intention_id']]);
|
||||
Log::info(['商户合同签约回调-商城响应', $requestUtil->getContent()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return json(['success' => true, 'msg' => '成功']);
|
||||
}
|
||||
|
||||
|
||||
//镇街车辆租赁回调
|
||||
public function townCarRent() {
|
||||
@ -179,66 +136,26 @@ class IndexController extends BaseApiController
|
||||
//更新本地合同状态
|
||||
$updateLocalRes = VehicleContract::where('id',$contract['id'])->update(['signing_timer'=>1]);
|
||||
//更新远程
|
||||
$updateSverRes =curl_post(env('project.logistic_domain').'/api/contractUpdate',[],[
|
||||
$updateSverRes =curl_post(env('project.logistic_domain').'/api/index/notifyContractUpdate',[],[
|
||||
'id' => $contract['contract_logistic_id'],
|
||||
'signing_timer' => 1,
|
||||
'update_time' => time()
|
||||
]);
|
||||
if(!$updateLocalRes || $updateSverRes['code']==0){
|
||||
return json(['success' => false, 'msg' => '更新失败']);
|
||||
}
|
||||
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]);
|
||||
//将车辆加入到本地租赁列表
|
||||
$cars = json_decode($contract['cars_info'], true);
|
||||
$data = [];
|
||||
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]['rent_time'] = 0;
|
||||
$data[$k]['create_time'] = strtotime($contract['create_time']);
|
||||
}
|
||||
}
|
||||
$vehicleRent = new VehicleRent();
|
||||
$vehicleRent->saveAll($data);
|
||||
$updateLocalRes = VehicleContract::where('id',$contract['id'])->update(['signing_timer'=>2,'status' => 3]);
|
||||
//更新远程
|
||||
$updateSverRes = curl_post(env('project.logistic_domain').'/api/contractUpdate',[],[
|
||||
$updateSverRes =curl_post(env('project.logistic_domain').'/api/index/notifyContractUpdate',[],[
|
||||
'id' => $contract['contract_logistic_id'],
|
||||
'signing_timer' => 2,
|
||||
'status' => 3,
|
||||
'contract_url'=>$signContractFile,
|
||||
'contract_evidence'=>$contractEvidence,
|
||||
'update_time' => time()
|
||||
'status' => 3
|
||||
]);
|
||||
if(!$updateLocalRes || $updateSverRes['code']==0){
|
||||
return json(['success' => false, 'msg' => '更新失败']);
|
||||
}else{
|
||||
return json(['success' => true, 'msg' => '更新成功']);
|
||||
}
|
||||
}
|
||||
return json(['success' => true, 'msg' => '更新成功@']);
|
||||
}
|
||||
|
||||
//系统车辆租赁回来
|
||||
@ -272,33 +189,30 @@ class IndexController extends BaseApiController
|
||||
//获取签约后的合同
|
||||
$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
|
||||
]);
|
||||
//更改合同状态
|
||||
VehicleContract::where('id', $id)->update(['signing_timer' => 2, 'status' => 3,'contract_url'=>$signContractFile,'contract_evidence'=>$contractEvidence]);
|
||||
VehicleContract::where('id', $id)->update(['signing_timer' => 2, 'status' => 3,'contract_url'=>$signContractFile]);
|
||||
//添加车辆到租赁列表
|
||||
$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 +249,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,28 +259,18 @@ 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 ?? '';
|
||||
//获取签约后的证据
|
||||
$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
|
||||
]);
|
||||
VehicleContract::where('id', $id)->update(['cars_info'=>$cars_info,'update_time'=>time(),'signing_timer'=>2,'status'=>3,'contract_url'=>$signContractFile,'contract_evidence'=>$contractEvidence]);
|
||||
VehicleContract::where('id', $id)->update(['cars_info'=>$cars_info,'update_time'=>time(),'signing_timer'=>2,'status'=>3,'contract_url'=>$signContractFile]);
|
||||
VehicleRent::create([
|
||||
'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 +284,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' => '成功']);
|
||||
@ -415,250 +326,24 @@ class IndexController extends BaseApiController
|
||||
//获取签约后的合同
|
||||
$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
|
||||
]);
|
||||
$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,
|
||||
VehicleContract::where('id', $id)->update(['signing_timer'=>2,'status'=>3,'contract_url'=>$signContractFile]);
|
||||
//更改租赁列表车辆状态
|
||||
$vehicle = json_decode($contract['cars_info'], true);
|
||||
//获取租赁车辆信息
|
||||
$vehicleRentInfo = VehicleRent::where('car_id', $vehicle['id'])->find();
|
||||
//更新原始合同类型
|
||||
VehicleContract::where('id', $vehicleRentInfo['contract_id'])->update(['type' => 2]);
|
||||
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' => '成功']);
|
||||
}
|
||||
}
|
||||
@ -682,18 +367,15 @@ class IndexController extends BaseApiController
|
||||
if ($result && isset($param['status']) && $param['status'] == 3) {
|
||||
$data = [];
|
||||
foreach ($cars as $k => $v) {
|
||||
$hasCar = VehicleRent::where('car_id',$v['id'])->findOrEmpty();
|
||||
if($hasCar->isEmpty()) {
|
||||
$data[$k]['car_id'] = $v['id'];
|
||||
$data[$k]['car_license'] = $v['license'];
|
||||
$data[$k]['type'] = 0;
|
||||
$data[$k]['status'] = 0;
|
||||
$data[$k]['company_id'] = $model['company_b_id'];
|
||||
$data[$k]['rent_time'] = 0;
|
||||
$data[$k]['rent_company_id'] = 0;
|
||||
$data[$k]['contract_id'] = $model['id'];
|
||||
$data[$k]['create_time'] = strtotime($model['create_time']);
|
||||
}
|
||||
$data[$k]['car_id'] = $v['id'];
|
||||
$data[$k]['car_license'] = $v['license'];
|
||||
$data[$k]['type'] = 0;
|
||||
$data[$k]['status'] = 0;
|
||||
$data[$k]['company_id'] = $model['company_b_id'];
|
||||
$data[$k]['rent_time'] = 0;
|
||||
$data[$k]['rent_company_id'] = 0;
|
||||
$data[$k]['contract_id'] = $model['id'];
|
||||
$data[$k]['create_time'] = strtotime($model['create_time']);
|
||||
}
|
||||
$vehicleRent = new VehicleRent();
|
||||
$vehicleRent->saveAll($data);
|
||||
@ -744,104 +426,22 @@ class IndexController extends BaseApiController
|
||||
{
|
||||
$parmas = Request()->param();
|
||||
Log::info(['认证回调:',$parmas]);
|
||||
|
||||
try {
|
||||
$data=json_decode($parmas['data'],true);
|
||||
|
||||
if($data['status']==2){
|
||||
return json(['success' => false, 'msg' => '失败']);
|
||||
}
|
||||
if ($parmas) {
|
||||
// 商城系统商户入驻
|
||||
if (isset($parmas['type']) && $parmas['type'] == 'shop_merchant') {
|
||||
Db::name('company_form')->where('master_email',$data['emailOrMobile'])->update(['type' => 1]);
|
||||
$this->shopMerchantCall($parmas);
|
||||
return json(['success' => true, 'msg' => '成功']);
|
||||
} else {
|
||||
$data=json_decode($parmas['data'],true);
|
||||
// 成功回调标记
|
||||
$redis = RedisLogic::getInstance();
|
||||
$cache = $redis->get('authentication_company_id_'.$parmas['id']);
|
||||
if (!empty($cache)) {
|
||||
$cacheData = json_decode($cache, true);
|
||||
$cacheData['is_callback'] = 1;
|
||||
$redis->set('authentication_company_id_'.$parmas['id'], json_encode($cacheData));
|
||||
}
|
||||
if($data['status']==1){
|
||||
Company::where('id', $parmas['id'])->update(['is_authentication' => 1]);
|
||||
}
|
||||
if($data['status']==2){
|
||||
// 记录认证失败原因
|
||||
Db::name('company_authentication_fail_log')->insert(['company_id'=>$parmas['id'],'fail_reason'=>$data['msg'],'create_time'=>time()]);
|
||||
Company::where('id', $parmas['id'])->update([ 'is_contract'=>0]);
|
||||
}
|
||||
return json(['success' => true, 'msg' => '成功']);
|
||||
$data=json_decode($parmas['data'],true);
|
||||
if($data['status']==1){
|
||||
Company::where('id', $parmas['id'])->update(['is_authentication' => 1]);
|
||||
}
|
||||
|
||||
if($data['status']==2){
|
||||
// 记录认证失败原因
|
||||
Db::name('company_authentication_fail_log')->insert(['company_id'=>$parmas['id'],'fail_reason'=>$data['msg']]);
|
||||
}
|
||||
return json(['success' => true, 'msg' => '成功']);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error('认证回调错误569:'.$e->getMessage());
|
||||
Log::error('认证回调错误:'.$e->getMessage());
|
||||
}
|
||||
|
||||
return json(['success' => false, 'msg' => '失败,没有参数']);
|
||||
}
|
||||
|
||||
private function shopMerchantCall($parmas)
|
||||
{
|
||||
$shopMerchant = ShopMerchant::find(['id', $parmas['id']]);
|
||||
Log::error($shopMerchant);
|
||||
if($shopMerchant==null){
|
||||
// Log::error(['没有商户580:',$parmas]);
|
||||
return json(['success' => false, 'msg' => '认证回调错误']);
|
||||
}
|
||||
$data=json_decode($parmas['data'],true);
|
||||
if($data['status']==1){
|
||||
if($data['organizationRegNo']!=$shopMerchant['organization_code']){
|
||||
Log::error(['认证回调错误586:',$parmas]);
|
||||
return json(['success' => false, 'msg' => '认证回调错误']);
|
||||
}
|
||||
|
||||
$shopMerchant->save(['is_authentication' => 1]);
|
||||
// 生成合同
|
||||
$createContractData = [
|
||||
'id' => $parmas['id'],
|
||||
'party_a' => 1,
|
||||
'party_a_name' => '泸州市海之农科技有限公司',
|
||||
'party_b' => $parmas['id'],
|
||||
'party_b_name' => $shopMerchant->company_name,
|
||||
'contract_type' => 22,
|
||||
];
|
||||
$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);
|
||||
}
|
||||
if($data['status']==2){
|
||||
// 记录认证失败原因
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ use app\common\model\contract\VehicleContract;
|
||||
use app\Request;
|
||||
use junziqian\sdk\bean\req\sign\ApplySignReq;
|
||||
use junziqian\sdk\bean\req\user\OrganizationCreateReq;
|
||||
use junziqian\sdk\bean\req\user\OrganizationFaceCreateReq;
|
||||
use junziqian\sdk\util\exception\ResultInfoException;
|
||||
use junziqian\sdk\util\RequestUtils;
|
||||
use junziqian\sdk\util\ShaUtils;
|
||||
@ -18,21 +17,11 @@ class JunziqianController extends BaseApiController
|
||||
public array $notNeedLogin = ['download_file'];
|
||||
|
||||
/**请求地址*/
|
||||
private $serviceUrl;
|
||||
private $serviceUrl = 'https://api.sandbox.junziqian.com';
|
||||
/**appkey*/
|
||||
private $appkey;
|
||||
private $appkey = '3121e0d911b7943d';
|
||||
/**secret*/
|
||||
private $appSecret;
|
||||
|
||||
public function initialize()
|
||||
{
|
||||
$this->serviceUrl=env('junzi.url_prefix');
|
||||
$this->appkey=env('junzi.app_key');
|
||||
$this->appSecret=env('junzi.app_secret');
|
||||
|
||||
parent::initialize();
|
||||
|
||||
}
|
||||
private $appSecret = '1e66d8b73121e0d911b7943d82bba174';
|
||||
/**请求地址*/
|
||||
// private $serviceUrl = 'https://api.junziqian.com';
|
||||
// /**appkey*/
|
||||
@ -88,44 +77,19 @@ class JunziqianController extends BaseApiController
|
||||
$request->organizationRegNo = $data['organization_code'];
|
||||
$request->organizationRegImg = $data['business_license']; //new CURLFile('D:/tmp/test.png',null,"test.png");
|
||||
$request->legalName = $data["master_name"]; //法人
|
||||
// $request->legalIdentityCard = $data["master_id_card"]; // 法人身份证 签约时人脸识别需要
|
||||
// $request->legalMobile = $data["master_phone"]; // 法人手机号 预留 签约时短信验证需要
|
||||
|
||||
$request->legalIdentityCard = $data["master_id_card"]; // 法人身份证 签约时人脸识别需要
|
||||
$request->legalMobile = $data["master_phone"]; // 法人手机号 预留 签约时短信验证需要
|
||||
if (isset($data['master_email'])) {
|
||||
$request->emailOrMobile = $data['master_email']; //邮箱
|
||||
}
|
||||
// $request->notifyUrl = env('url.url_prefix').'/notifyAuthentication?ids=22222';
|
||||
$request->notifyUrl = env('url.url_prefix') . '/notifyAuthentication?id=' . $data['id'];
|
||||
$request->notifyUrl = env('url.url_prefix').'/notifyAuthentication?id='.$data['id'];
|
||||
// halt($request);
|
||||
//发起创建企业请求
|
||||
$response = $requestUtils->doPost("/v2/user/organizationCreate", $request);
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @return object
|
||||
* 商城商户入驻,实名认证
|
||||
*/
|
||||
public function ShopMerchantCertification($data)
|
||||
{
|
||||
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
|
||||
$request = new OrganizationCreateReq();
|
||||
$request->name = $data['name'];
|
||||
$request->identificationType = 1; //证件类型:0多证,1多证合一
|
||||
$request->organizationType = 0; //组织类型 0企业,1事业单位
|
||||
$request->organizationRegNo = $data['organization_code'];
|
||||
$request->organizationRegImg = $data['business_license'];
|
||||
$request->legalName = $data["master_name"]; //法人
|
||||
if (isset($data['master_email'])) {
|
||||
$request->emailOrMobile = $data['master_email']; //邮箱
|
||||
}
|
||||
$request->notifyUrl = env('url.url_prefix') . '/notifyAuthentication?id=' . $data['id'].'&type=shop_merchant'; // 回调增加type参数,用于回调是辨别是商户认证会带
|
||||
//发起创建企业请求
|
||||
$response = $requestUtils->doPost("/v2/user/organizationCreate", $request);
|
||||
return $response;
|
||||
}
|
||||
|
||||
//重新提交企业实名认证
|
||||
public function organizationReapply($data)
|
||||
{
|
||||
@ -137,8 +101,8 @@ class JunziqianController extends BaseApiController
|
||||
$request->organizationRegNo = $data['organization_code'];
|
||||
$request->organizationRegImg = $data['business_license']; //new CURLFile('D:/tmp/test.png',null,"test.png");
|
||||
$request->legalName = $data["master_name"]; //法人
|
||||
// $request->legalIdentityCard = $data["master_id_card"]; // 法人身份证 签约时人脸识别需要
|
||||
// $request->legalMobile = $data["master_phone"]; // 法人手机号 预留 短信验证需要
|
||||
$request->legalIdentityCard = $data["master_id_card"]; // 法人身份证 签约时人脸识别需要
|
||||
$request->legalMobile = $data["master_phone"]; // 法人手机号 预留 短信验证需要
|
||||
$request->emailOrMobile = $data['master_email']; //邮箱
|
||||
//发起创建企业请求
|
||||
$response = $requestUtils->doPost("/v2/user/organizationReapply", $request);
|
||||
@ -160,19 +124,6 @@ class JunziqianController extends BaseApiController
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function shopMerchantStatusQuery($email)
|
||||
{
|
||||
$param = Request()->param();
|
||||
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
|
||||
//初始化合同参数
|
||||
$request = array(
|
||||
"emailOrMobile" => $email, //TODO *
|
||||
);
|
||||
//发起请求
|
||||
$response = $requestUtils->doPost("/v2/user/organizationAuditStatus", $request);
|
||||
return $response;
|
||||
}
|
||||
|
||||
//企业自定义公章
|
||||
public function Custom_seal()
|
||||
{
|
||||
@ -189,38 +140,18 @@ class JunziqianController extends BaseApiController
|
||||
//签约
|
||||
public function Signing($data, $id, $notify = '')
|
||||
{
|
||||
if ($notify == '') {
|
||||
$notify = env('url.url_prefix') . '/notify_url';
|
||||
if($notify==''){
|
||||
$notify=env('url.url_prefix').'/notify_url';
|
||||
}
|
||||
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
|
||||
$request = new ApplySignReq();
|
||||
$request->contractName = $data['name'];
|
||||
$request->signatories = $data['signatories']; //签约方
|
||||
// $request->faceThreshold = 79; // 人脸识别阀值:默认等级(1-100之间整数),建议范围(60-79)
|
||||
$request->faceThreshold = 79; // 人脸识别阀值:默认等级(1-100之间整数),建议范围(60-79)
|
||||
$request->serverCa = 1; //是否需要服务端云证书
|
||||
$request->fileType = 1; //合同上传方式 url
|
||||
$request->url = $data['url'];
|
||||
$request->notifyUrl = $notify . '?id=' . $id;
|
||||
$request->needQifengSign = 1;
|
||||
//发起PING请求
|
||||
// halt($request);
|
||||
$response = $requestUtils->doPost("/v2/sign/applySign", $request);
|
||||
return $response;
|
||||
}
|
||||
public function shopContractSigning($data, $id, $notify = '')
|
||||
{
|
||||
if ($notify == '') {
|
||||
$notify = env('url.url_prefix') . '/shop_contract_notify_url';
|
||||
}
|
||||
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
|
||||
$request = new ApplySignReq();
|
||||
$request->contractName = $data['name'];
|
||||
$request->signatories = $data['signatories']; //签约方
|
||||
// $request->faceThreshold = 79; // 人脸识别阀值:默认等级(1-100之间整数),建议范围(60-79)
|
||||
$request->serverCa = 1; //是否需要服务端云证书
|
||||
$request->fileType = 1; //合同上传方式 url
|
||||
$request->url = $data['url'];
|
||||
$request->notifyUrl = $notify . '?id=' . $id;
|
||||
$request->notifyUrl = $notify.'?id='.$id;
|
||||
$request->needQifengSign = 1;
|
||||
//发起PING请求
|
||||
// halt($request);
|
||||
@ -232,19 +163,18 @@ class JunziqianController extends BaseApiController
|
||||
public function OrganizationFaceCreate($data)
|
||||
{
|
||||
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
|
||||
$request = new OrganizationFaceCreateReq();
|
||||
$request->orderNo = $data['id'];
|
||||
$request->email = $data['master_email'];
|
||||
$request->enterpriseName = $data['company_name'];
|
||||
$request->identityNo = $data['organization_code'];
|
||||
// $request-> facePerType = 0;
|
||||
$request->legalPersonName = $data['master_name'];
|
||||
$request->legalIdentityCard = $data['master_id_card']; //法人证件号
|
||||
$request->legalMobile = $data['master_phone'];
|
||||
$request->faceAgantIdenName = $data['master_name'];
|
||||
$request->faceAgantIdenCard = $data['master_id_card'];
|
||||
$request->backUrl = env('url.url_prefix') . '/api/Hetong/notifyOrganizationFaceCreate';
|
||||
$response = $requestUtils->doPost("/v2/user/organizationFaceCreate", $request);
|
||||
$request=new OrganizationCreateReq();
|
||||
$request-> orderNo = uniqid();
|
||||
$request-> email = $data['master_email'];
|
||||
$request-> enterpriseName = $data['company_name'];
|
||||
$request-> identityNo = $data['organization_code'];
|
||||
$request-> legalPersonName = $data['master_name'];
|
||||
$request-> legalIdentityCard = $data['master_id_card'];//法人证件号
|
||||
$request-> legalMobile = $data['master_phone'];
|
||||
$request-> faceAgantIdenName = $data['master_name'];
|
||||
$request-> faceAgantIdenCard = $data['master_id_card'];
|
||||
$request-> backUrl = env('url.url_prefix').'/mobile'; // 做完人脸识别后,指定跳转到供销系统mobile首页
|
||||
$response = $requestUtils->doPost("/v2/user/organizationFaceCreate",$request);
|
||||
return $response;
|
||||
}
|
||||
|
||||
@ -257,7 +187,7 @@ class JunziqianController extends BaseApiController
|
||||
$request->serverCa = 1; //是否需要服务端云证书
|
||||
$request->fileType = 1; //合同上传方式 url
|
||||
$request->url = $data['url'];
|
||||
$request->notifyUrl = $notify . '?id=' . $id;
|
||||
$request->notifyUrl = $notify.'?id='.$id;
|
||||
|
||||
$request->needQifengSign = 1;
|
||||
//发起PING请求
|
||||
@ -266,8 +196,7 @@ class JunziqianController extends BaseApiController
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function downloadVehicleContractFile($applyNo)
|
||||
{
|
||||
public function downloadVehicleContractFile($applyNo) {
|
||||
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
|
||||
$contract_url = VehicleContract::where('contract_no', $applyNo)->value('contract_url');
|
||||
if ($contract_url && !empty($contract_url)) {
|
||||
@ -280,28 +209,7 @@ class JunziqianController extends BaseApiController
|
||||
$response = $requestUtils->doPost("/v2/sign/linkFile", $request);
|
||||
if ($response->success) {
|
||||
$this->getDownload($response->data, root_path() . 'public/uploads/vehicle_contract/' . $applyNo . '.pdf');
|
||||
return env('project.website_domain') . '/uploads/vehicle_contract/' . $applyNo . '.pdf';
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function downloadVehicleContractEvidence($applyNo, $companyName, $companyCode)
|
||||
{
|
||||
//构建请求工具
|
||||
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
|
||||
//初始化合同参数
|
||||
$request = array(
|
||||
"applyNo" => $applyNo,
|
||||
"fullName" => $companyName, //签约人名称(合同发起接口中传入的签署人姓名)
|
||||
"identityCard" => $companyCode, //统一社会信用代码
|
||||
"identityType" => 12, //证件类型 1身份证, 2护照, 3台胞证, 4港澳居民来往内地通行证, 11营业执照, 12统一社会信用代码, 20子账号, 99其他
|
||||
"dealType" => 1
|
||||
);
|
||||
$response = $requestUtils->doPost("/v2/sign/presLinkFile", $request);
|
||||
if ($response->success) {
|
||||
$this->getDownload($response->data, root_path().'public/uploads/vehicle_contract_evidence/'.$applyNo.'_'.$companyCode.'.zip');
|
||||
return env('project.website_domain').'/uploads/vehicle_contract_evidence/'.$applyNo.'_'.$companyCode.'.zip';;
|
||||
return env('project.website_domain').'/uploads/vehicle_contract/' . $applyNo . '.pdf';
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@ -344,7 +252,7 @@ class JunziqianController extends BaseApiController
|
||||
$request->serverCa = 1; //是否需要服务端云证书
|
||||
$request->fileType = 3;
|
||||
$request->htmlContent = $data['content'];
|
||||
$request->notifyUrl = env('url.url_prefix') . '/notify_url?id=' . $id;
|
||||
$request->notifyUrl = env('url.url_prefix').'/notify_url?id=' . $id;
|
||||
$request->needQifengSign = 1;
|
||||
|
||||
//发起PING请求
|
||||
@ -352,9 +260,6 @@ class JunziqianController extends BaseApiController
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载合同
|
||||
*/
|
||||
public function download_file($applyNo)
|
||||
{
|
||||
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
|
||||
@ -370,81 +275,11 @@ class JunziqianController extends BaseApiController
|
||||
if ($response->success == true) {
|
||||
$this->getDownload($response->data, root_path() . 'public/uploads/contract/' . $applyNo . '.pdf');
|
||||
Db::name('contract')->where('contract_no', $applyNo)->update(['contract_url' => '/uploads/contract/' . $applyNo . '.pdf']);
|
||||
return $this->success('获取成功', ['url' => env('url.url_prefix') . '/uploads/contract/' . $applyNo . '.pdf']);
|
||||
return $this->success('获取成功', ['url' => env('url.url_prefix').'/uploads/contract/' . $applyNo . '.pdf']);
|
||||
} else {
|
||||
return $this->fail('获取失败');
|
||||
}
|
||||
}
|
||||
public function download_shop_file($applyNo)
|
||||
{
|
||||
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
|
||||
$find = Db::name('contract')->where('contract_no', $applyNo)->value('contract_url');
|
||||
if ($find) {
|
||||
return $this->success('获取成功', ['url' => env('url.url_prefix') . $find]);
|
||||
}
|
||||
//初始化请求参数
|
||||
$request = array(
|
||||
"applyNo" => $applyNo, //TODO +
|
||||
);
|
||||
$response = $requestUtils->doPost("/v2/sign/linkFile", $request);
|
||||
if ($response->success == true) {
|
||||
$this->getDownload($response->data, root_path() . 'public/uploads/contract/' . $applyNo . '.pdf');
|
||||
Db::name('shop_contract')->where('contract_no', $applyNo)->update(['contract_url' => '/uploads/contract/' . $applyNo . '.pdf']);
|
||||
return $this->success('获取成功', ['url' => env('url.url_prefix') . '/uploads/contract/' . $applyNo . '.pdf']);
|
||||
} else {
|
||||
return $this->fail('获取失败');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 保全后合同文件及证据包下载
|
||||
*/
|
||||
public function EvidenceDownload($param)
|
||||
{
|
||||
//初始化请求参数
|
||||
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
|
||||
|
||||
$request = array(
|
||||
"applyNo" => $param['applyNo'],
|
||||
"fullName" => $param['fullName'],
|
||||
"identityCard" => $param['identityCard'],
|
||||
"identityType" => 12,
|
||||
"dealType" => 1,
|
||||
);
|
||||
$response = $requestUtils->doPost("/v2/sign/presLinkFile", $request);
|
||||
if ($response->success == true) {
|
||||
$this->getDownload($response->data, root_path() . 'public/uploads/evidence/' . $param['applyNo'] . '.zip');
|
||||
Db::name('contract')->where('contract_no', $param['applyNo'])->update(['evidence_url' => '/uploads/evidence/' . $param['applyNo'] . '.zip']);
|
||||
return $this->success('获取成功', ['url' => env('url.url_prefix') . '/uploads/evidence/' . $param['applyNo'] . '.zip']);
|
||||
} else {
|
||||
return $this->fail('获取失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保全后合同文件及证据包下载
|
||||
*/
|
||||
public function EvidenceShopDownload($param)
|
||||
{
|
||||
//初始化请求参数
|
||||
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
|
||||
|
||||
$request = array(
|
||||
"applyNo" => $param['applyNo'],
|
||||
"fullName" => $param['fullName'],
|
||||
"identityCard" => $param['identityCard'],
|
||||
"identityType" => 12,
|
||||
"dealType" => 1,
|
||||
);
|
||||
$response = $requestUtils->doPost("/v2/sign/presLinkFile", $request);
|
||||
if ($response->success == true) {
|
||||
$this->getDownload($response->data, root_path() . 'public/uploads/evidence_shop_contract/' . $param['applyNo'] . '.zip');
|
||||
Db::name('shop_contract')->where('contract_no', $param['applyNo'])->update(['evidence_url' => '/uploads/evidence_shop_contract/' . $param['applyNo'] . '.zip']);
|
||||
return $this->success('获取成功', ['url' => env('url.url_prefix') . '/uploads/evidence_shop_contract/' . $param['applyNo'] . '.zip']);
|
||||
} else {
|
||||
return $this->fail('获取失败');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getDownload($url, $publicDir = '', $fileName = '', $type = 0)
|
||||
{
|
||||
|
@ -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']]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -12,15 +12,16 @@ class RemoteController extends BaseApiController
|
||||
|
||||
public array $notNeedLogin = ['index'];
|
||||
|
||||
public function shang_date_total_price($company, $arr = [], $template_id = 0)
|
||||
public function shang_date_total_price($company,$arr=[],$template_id=0)
|
||||
{
|
||||
$start_time = date('Y-m-d');
|
||||
$time = strtotime($start_time) + 86399;
|
||||
$end_time = date('Y-m-d H:i:s', $time);
|
||||
$time=strtotime($start_time)+86399;
|
||||
$end_time=date('Y-m-d H:i:s',$time);
|
||||
|
||||
if (isset($arr['start_time']) && $arr['end_time']) {
|
||||
if(isset($arr['start_time']) && $arr['end_time']){
|
||||
$start_time = $arr['start_time'];
|
||||
$end_time = $arr['end_time'];
|
||||
|
||||
}
|
||||
$parmas = [
|
||||
"start_date" => $start_time,
|
||||
@ -54,11 +55,11 @@ class RemoteController extends BaseApiController
|
||||
break;
|
||||
default:
|
||||
Log::error('任务结算失败,公司类型错误:' . $company['company_type']);
|
||||
Log::error('片区交易错误:' . $company);
|
||||
Log::error('片区交易错误:'.$company);
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
$res = HttpClient::create()->request('GET', env('url.shop_prefix') . '/api/order/statistics', [
|
||||
$res = HttpClient::create()->request('GET', env('url.shop_prefix').'/api/order/statistics', [
|
||||
'query' => $parmas,
|
||||
]);
|
||||
$json = json_decode($res->getContent(), true);
|
||||
@ -70,11 +71,11 @@ class RemoteController extends BaseApiController
|
||||
$arr['total_price'] = $json['data']['total_price'];
|
||||
//基础金额*(每日基户数*天数)//且户数小于公司总户数
|
||||
$user_count = UserInformationg::where('company_id', $company['id'])->count();
|
||||
$day_count = TaskTemplate::where('id', $template_id)->value('day_count');
|
||||
$day_count=TaskTemplate::where('id',$template_id)->value('day_count');
|
||||
//
|
||||
if ($day_count == 0) {
|
||||
if($day_count==0){
|
||||
$user_count_two = 5 * 1;
|
||||
} else {
|
||||
}else{
|
||||
$user_count_two = 5 * $day_count;
|
||||
}
|
||||
if ($user_count_two > $user_count) {
|
||||
@ -97,15 +98,20 @@ class RemoteController extends BaseApiController
|
||||
}
|
||||
}
|
||||
|
||||
public function shang_date_list($company, $querys)
|
||||
{
|
||||
$start_time = date('Y-m-d');
|
||||
$time = strtotime($start_time) + 86399;
|
||||
$end_time = date('Y-m-d H:i:s', $time);
|
||||
|
||||
if (isset($querys['start_time']) && isset($querys['end_time'])) {
|
||||
public function shang_date_list($company,$is_day,$querys){
|
||||
if($is_day==1){
|
||||
$start_time = date('Y-m-d');
|
||||
$time=strtotime($start_time)+86399;
|
||||
$end_time=date('Y-m-d H:i:s',$time);
|
||||
}else{
|
||||
$start_time = date('Y-m-d',strtotime('-1 day', time()));
|
||||
$time=strtotime($start_time)+86399;
|
||||
$end_time=date('Y-m-d H:i:s',$time);
|
||||
}
|
||||
if(isset($querys['start_time']) && isset($querys['end_time'])){
|
||||
$start_time = $querys['start_time'];
|
||||
$end_time = $querys['end_time'];
|
||||
|
||||
}
|
||||
$parmas = [
|
||||
"start_date" => $start_time,
|
||||
@ -141,54 +147,54 @@ class RemoteController extends BaseApiController
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isset($querys['page'])) {
|
||||
$parmas['page'] = $querys['page'];
|
||||
if(isset($querys['page'])){
|
||||
$parmas['page']=$querys['page'];
|
||||
}
|
||||
|
||||
try {
|
||||
$list = HttpClient::create()->request('GET', env('url.shop_prefix') . '/api/region/order', [
|
||||
try{
|
||||
$list = HttpClient::create()->request('GET', env('url.shop_prefix').'/api/region/order', [
|
||||
'query' => $parmas,
|
||||
]);
|
||||
$json_list = json_decode($list->getContent(), true);
|
||||
|
||||
$data = [];
|
||||
if ($json_list['status'] == 200) {
|
||||
$data = $json_list['data']['list'];
|
||||
$data=[];
|
||||
if($json_list['status'] == 200){
|
||||
$data=$json_list['data']['list'];
|
||||
}
|
||||
return $data;
|
||||
} catch (\Exception $e) {
|
||||
}catch(\Exception $e){
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 获取坐标的距离
|
||||
*/
|
||||
public function coordinate($parmas, $longitude1, $latitude1)
|
||||
{
|
||||
$res = HttpClient::create()->request('GET', env('project.logistic_domain') . '/api/getCarHistory', [
|
||||
public function coordinate($parmas,$longitude1,$latitude1){
|
||||
$res = HttpClient::create()->request('GET', env('project.logistic_domain').'/api/getCarHistory', [
|
||||
'query' => $parmas,
|
||||
]);
|
||||
$json = json_decode($res->getContent(), true);
|
||||
$points = $json['data'];
|
||||
if (empty($points)) {
|
||||
$json=json_decode($res->getContent(),true);
|
||||
$points=$json['data'];
|
||||
if(empty($points)){
|
||||
return false;
|
||||
}
|
||||
$target = [
|
||||
"lat" => $latitude1,
|
||||
"lon" => $longitude1
|
||||
$target =[
|
||||
"lat"=> $latitude1,
|
||||
"lon"=> $longitude1
|
||||
];
|
||||
$closestPoint = $this->getClosestPoint($points, $target);
|
||||
return $this->calculateDistance($target['lon'], $target['lat'], $closestPoint[0]['lon'], $closestPoint[0]['lat']);
|
||||
return $this->calculateDistance($target['lon'], $target['lat'], $closestPoint[0]['lon'], $closestPoint[0]['lat']);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 计算两点之间的距离
|
||||
*/
|
||||
function getClosestPoint($points, $target)
|
||||
{
|
||||
function getClosestPoint($points, $target) {
|
||||
$minDistance = PHP_INT_MAX;
|
||||
$closestPoint = null;
|
||||
foreach ($points as $point) {
|
||||
@ -197,30 +203,29 @@ class RemoteController extends BaseApiController
|
||||
if ($distance < $minDistance) {
|
||||
$minDistance = $distance;
|
||||
$closestPoint = $point;
|
||||
} else {
|
||||
$distance = 0;
|
||||
}else{
|
||||
$distance=0;
|
||||
}
|
||||
}
|
||||
|
||||
return [$closestPoint, $distance];
|
||||
|
||||
return [$closestPoint,$distance];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 计算两点之间的距离
|
||||
* 返回米
|
||||
*/
|
||||
function calculateDistance($longitude1, $latitude1, $longitude2, $latitude2)
|
||||
{
|
||||
function calculateDistance( $longitude1,$latitude1, $longitude2,$latitude2 ) {
|
||||
$earthRadius = 6371; // 地球半径,单位为公里
|
||||
|
||||
|
||||
$dLat = deg2rad($latitude2 - $latitude1);
|
||||
$dLon = deg2rad($longitude2 - $longitude1);
|
||||
|
||||
$a = sin($dLat / 2) * sin($dLat / 2) +
|
||||
|
||||
$a = sin($dLat/2) * sin($dLat/2) +
|
||||
cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) *
|
||||
sin($dLon / 2) * sin($dLon / 2);
|
||||
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'));
|
||||
}
|
||||
}
|
@ -3,58 +3,35 @@
|
||||
namespace app\api\controller;
|
||||
|
||||
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;
|
||||
|
||||
use think\facade\Log;
|
||||
|
||||
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,119 +50,31 @@ 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']);
|
||||
if ($find != false) {
|
||||
if($time<time()){
|
||||
$transaction_pool=TaskTemplate::where('id',$item['template_id'])->value('transaction_pool');
|
||||
$res[$k]['extend']['transaction'] = $find;
|
||||
if($transaction_pool==0){
|
||||
$res[$k]['extend']['transaction']['arr']['transaction_pool']=$find['arr']['total_price'];
|
||||
$find['transaction_pool']=0;
|
||||
}else{
|
||||
$res[$k]['extend']['transaction']['arr']['transaction_pool']=bcadd($res[$k]['extend']['transaction']['arr']['total_price'],$transaction_pool,2);
|
||||
$find['transaction_pool']=$transaction_pool;
|
||||
}
|
||||
$res[$k]['extend']['transaction'] = $find;
|
||||
}
|
||||
// Task::where('id',$item['id'])->update(['extend'=>json_encode(['transaction'=>$find],true)]);
|
||||
} else {
|
||||
$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);
|
||||
}
|
||||
|
||||
@ -197,28 +86,21 @@ class TaskController extends BaseApiController
|
||||
if(!$task){
|
||||
return $this->fail('任务不存在');
|
||||
}
|
||||
$task=$task->toArray();
|
||||
$transaction_pool=TaskTemplate::where('id',$task['template_id'])->value('transaction_pool');
|
||||
|
||||
$company = Company::where('id', $task['company_id'])->field('id,deposit,company_money,user_id,day_count,company_type,province,city,area,street,village,brigade,responsible_area')->find(); // 可能要判断预存金是否满足
|
||||
// $list = App(RemoteController::class)->shang_date_list($company, 1, $parmas);
|
||||
$parmas['start_time']=date('Y-m-d',$task['start_time']);
|
||||
$parmas['end_time']=$task['end_time'].' 23:59:59';
|
||||
$list = App(RemoteController::class)->shang_date_list($company, $parmas);
|
||||
$shang_date_total_price = App(RemoteController::class)->shang_date_total_price($company,$parmas,$task['template_id']);
|
||||
$list = App(RemoteController::class)->shang_date_list($company, 1, $parmas);
|
||||
if ($task != false) {
|
||||
$find['list'] = $list;
|
||||
if($transaction_pool==0){
|
||||
$task['extend']['transaction']['arr']['transaction_pool']=$shang_date_total_price['arr']['total_price'];
|
||||
}else{
|
||||
$task['extend']['transaction']['arr']['transaction_pool']=bcadd($shang_date_total_price['arr']['total_price'],$transaction_pool,2);
|
||||
}
|
||||
if($task['start_time']<strtotime(date('Y-m-d'))){
|
||||
$task['extend']['transaction']['arr']['is_show']=false;
|
||||
}else{
|
||||
$task['extend']['transaction']['arr']['is_show']=true;
|
||||
}
|
||||
$find['extend']=$task['extend'];
|
||||
if($transaction_pool==0){
|
||||
$find['transaction_pool']=0;
|
||||
}else{
|
||||
$find['transaction_pool']=$transaction_pool;
|
||||
}
|
||||
return $this->success('ok', $find);
|
||||
}
|
||||
return $this->success('ok');
|
||||
@ -230,12 +112,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 +131,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 +148,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 +158,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()
|
||||
@ -332,686 +195,4 @@ class TaskController extends BaseApiController
|
||||
}
|
||||
return $this->success('ok', $list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 其他任务详情
|
||||
*/
|
||||
public function other_task_detail(){
|
||||
$parmas = $this->request->param();
|
||||
$task = TaskLogic::detail($parmas);
|
||||
$extend = $task['extend'];
|
||||
if (isset($extend['other']) && $extend['other']['is_commit'] == 1) {
|
||||
$approve = Approve::where(['task_id' =>$task['id']])->find();
|
||||
$task['approve_status'] = $approve['check_status']; //审核状态
|
||||
$task['deny_notes'] = $approve['remark']; // 拒绝原因
|
||||
}
|
||||
return $this->success('ok', $task);
|
||||
}
|
||||
|
||||
/**
|
||||
* 其他任务 -提交
|
||||
*/
|
||||
public function commit_other_task()
|
||||
{
|
||||
try {
|
||||
$parmas = $this->request->param(); //id note annex vedio_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']]];
|
||||
Db::startTrans();
|
||||
Task::where(['id' => $parmas['id']])->update(['extend' => json_encode($extend), 'update_time'=>time(), 'director_uid'=>$this->userId]); // director_uid 指派人
|
||||
|
||||
// 片区经理
|
||||
$areaManagerId = User::where(['id' => $this->userId])->with('company')->value('area_manager');
|
||||
|
||||
// 没有则创建审批任务
|
||||
$approveModel = Approve::where(['task_id' => $task['id']])->findOrEmpty();
|
||||
if ($approveModel->isEmpty()) {
|
||||
$approveModel->type = Approve::APPROVE_TYPE_1;
|
||||
$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->create_time = time();
|
||||
$approveModel->update_time = time();
|
||||
$re = $approveModel->save();
|
||||
} else {
|
||||
// 有则更新状态
|
||||
$approveModel->check_status = 1; // 状态 0待审核,1审核中,2审核通过,3审核不通过,4撤销审核
|
||||
$approveModel->save();
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return $this->success('ok', []);
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 镇负责人公司任务详情
|
||||
*/
|
||||
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('成功', []);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,40 +44,6 @@ class UploadController extends BaseApiController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 上传视频
|
||||
* @return Json
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 16:27
|
||||
*/
|
||||
public function video()
|
||||
{
|
||||
try {
|
||||
$cid = $this->request->post('cid', 0);
|
||||
$result = UploadService::video($cid);
|
||||
return $this->success('上传成功', $result);
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 上传文件
|
||||
* @return Json
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 16:27
|
||||
*/
|
||||
public function file()
|
||||
{
|
||||
try {
|
||||
$cid = $this->request->post('cid', 0);
|
||||
$result = UploadService::file($cid);
|
||||
return $this->success('上传成功', $result);
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -14,19 +14,14 @@
|
||||
namespace app\api\controller;
|
||||
|
||||
|
||||
use app\adminapi\logic\ConfigLogic;
|
||||
use app\api\logic\UserLogic;
|
||||
use app\common\logic\UserLogic as CommonUserLogic;
|
||||
use app\api\validate\PasswordValidate;
|
||||
use app\api\validate\SetUserInfoValidate;
|
||||
use app\api\validate\UserValidate;
|
||||
use app\common\logic\contract\ContractLogic;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\contract\Contract;
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\user\UserAccountLog;
|
||||
use app\common\model\user\Withdraw;
|
||||
use Common;
|
||||
use think\facade\Db;
|
||||
|
||||
@ -161,26 +156,9 @@ class UserController extends BaseApiController
|
||||
return $this->fail(UserLogic::getError());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户当前可提现的截止时间以及可提现的金额
|
||||
*/
|
||||
public function getCurrCycleWithdraw()
|
||||
{
|
||||
$userInfo = User::find(['id' => $this->userId]);
|
||||
$company = Company::find(['id' => $userInfo['company_id']]);
|
||||
// 用户提现周期截止日期
|
||||
$endCycle = $company['withdraw_deadline'];
|
||||
$isDraw = time() >= $endCycle? 1: 0; // 当前时间大于截止时间,可提现
|
||||
// 计算公司周期内所有用户已完成的 变动类型为任务收益金额增加 动作为增加的 未提现状态 的变动金额之和
|
||||
$currTotalWithdrawMoney = UserAccountLog::where(['company_id'=>$userInfo['company_id'], 'action'=>1, 'status'=>1, 'is_withdraw'=>0, 'change_type'=>202])->where('create_time', '<', $endCycle)->sum('change_amount');
|
||||
return $this->success('成功', ['is_draw' => $isDraw,'end_cycle'=>$endCycle, 'user_currrent_total_withdraw_money'=>$currTotalWithdrawMoney], 1, 1);
|
||||
}
|
||||
public function withdraw()
|
||||
{
|
||||
$params = $this->request->param();
|
||||
if(!isset($params['amount'])) {
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
$params['user_id'] = $this->userId;
|
||||
$result = UserLogic::withdraw($params);
|
||||
if ($result) {
|
||||
|
@ -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('status','<>',3)->where('type',0)->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)->where('status','<>',4)->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;
|
||||
@ -310,41 +299,15 @@ class VehicleController extends BaseApiController
|
||||
if($vehicleContract['company_a_id'] != $this->userInfo['company_id']){
|
||||
return $this->fail('数据不匹配');
|
||||
}
|
||||
//判断合同类型
|
||||
if($vehicleContract['type'] == 2){
|
||||
Db::startTrans();
|
||||
try{
|
||||
//查找原合同
|
||||
$car = json_decode($vehicleContract['cars_info'],true);
|
||||
$carRentInfo = VehicleRent::where('car_id',$car['id'])->findOrEmpty();
|
||||
$oldVehicleContractUpdate = VehicleContract::where('id',$carRentInfo['contract_id'])->update(['status'=>3]);
|
||||
//更新
|
||||
$result = VehicleContract::where('id',$params['id'])->update([
|
||||
'status' => 4,
|
||||
'reject_message' => $params['content']
|
||||
]);
|
||||
if($oldVehicleContractUpdate && $result){
|
||||
Db::commit();
|
||||
return $this->success('驳回成功');
|
||||
}else{
|
||||
Db::rollback();
|
||||
return $this->fail('驳回失败');
|
||||
}
|
||||
}catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
//更新
|
||||
$result = VehicleContract::where('id',$params['id'])->update([
|
||||
'status' => 4,
|
||||
'reject_message' => $params['content']
|
||||
]);
|
||||
if($result){
|
||||
return $this->success('驳回成功');
|
||||
}else{
|
||||
//更新
|
||||
$result = VehicleContract::where('id',$params['id'])->update([
|
||||
'status' => 4,
|
||||
'reject_message' => $params['content']
|
||||
]);
|
||||
if($result){
|
||||
return $this->success('驳回成功');
|
||||
}else{
|
||||
return $this->fail('驳回失败');
|
||||
}
|
||||
return $this->fail('驳回失败');
|
||||
}
|
||||
}
|
||||
|
||||
@ -364,7 +327,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 +348,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){
|
||||
@ -406,24 +361,14 @@ class VehicleController extends BaseApiController
|
||||
})->toArray();
|
||||
//获取该公司已签约的小组服务公司数量
|
||||
$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('status','<>', 3)->where('type',0)->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 +377,6 @@ class VehicleController extends BaseApiController
|
||||
'rent_num' => $rentCar,
|
||||
'can_rent_num' => intval($doubleRentCar),
|
||||
'self_num' => $selfCar,
|
||||
'buy_num' => $buyCar,
|
||||
'apply_num' => $applyCar
|
||||
];
|
||||
//返回
|
||||
@ -441,44 +385,66 @@ 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'])->order('id desc')->find();
|
||||
if(empty($vehicleContract)){
|
||||
return $this->success('没有数据,请申请',['status'=>-2]);
|
||||
}
|
||||
//获取签约合同
|
||||
return $this->success('请求成功',$data->toArray());
|
||||
if($vehicleContract['type'] == 2){
|
||||
return $this->success('合同已解除',['status'=>-3]);
|
||||
}
|
||||
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('请求成功',$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{
|
||||
@ -562,22 +528,12 @@ class VehicleController extends BaseApiController
|
||||
'update_time' => time(),
|
||||
'old_file' => $contract['contract_url'],
|
||||
];
|
||||
Db::startTrans();
|
||||
try{
|
||||
//写入数据
|
||||
$new_result = VehicleContract::create($data);
|
||||
//修改原合同状态
|
||||
$old_result = VehicleContract::where('id',$contract['id'])->update(['status'=>5]);
|
||||
if($new_result && $old_result){
|
||||
Db::commit();
|
||||
return $this->success('申请成功,待镇街公司审核');
|
||||
}else{
|
||||
Db::rollback();
|
||||
return $this->fail('申请失败,请稍后重试');
|
||||
}
|
||||
}catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
return $this->fail($e->getMessage());
|
||||
//写入数据
|
||||
$result = VehicleContract::create($data);
|
||||
if($result){
|
||||
return $this->success('申请成功,待镇街公司审核');
|
||||
}else{
|
||||
return $this->fail('申请失败,请稍后重试');
|
||||
}
|
||||
}
|
||||
|
||||
@ -587,7 +543,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 +612,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');
|
||||
}
|
||||
}
|
@ -1,451 +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 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;
|
||||
|
||||
/**
|
||||
* 讯飞
|
||||
* Class WechatController
|
||||
*/
|
||||
class XunFeiController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['chat', 'iat', 'tts', 'ocr', 'iatWss', 'analyse'];
|
||||
|
||||
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' => '']);
|
||||
}
|
||||
$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
|
||||
]);
|
||||
|
||||
$client->send($data);
|
||||
$answer = "";
|
||||
while(true){
|
||||
$response = $client->receive();
|
||||
$resp = json_decode($response, true);
|
||||
$code = $resp["header"]["code"] ?? 0;
|
||||
if(0 == $code){
|
||||
$status = $resp["header"]["status"];
|
||||
if($status != 2){
|
||||
$content = $resp['payload']['choices']['text'][0]['content'];
|
||||
$answer .= $content;
|
||||
}else{
|
||||
$content = $resp['payload']['choices']['text'][0]['content'];
|
||||
$answer .= $content;
|
||||
break;
|
||||
}
|
||||
}else{
|
||||
return $this->fail( "服务返回报错 " . $response);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $this->data(['answer' => $answer]);
|
||||
} 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
|
||||
]);
|
||||
|
||||
$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]);
|
||||
}
|
||||
|
||||
//语音听写(流式版)
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\lists\approve;
|
||||
|
||||
use app\api\lists\BaseApiDataLists;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\Approve;
|
||||
use app\common\model\user\User;
|
||||
|
||||
class ApproveLists extends BaseApiDataLists implements ListsSearchInterface
|
||||
{
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2023/08/31 11:08
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
$param = $this->request->param();
|
||||
if (isset($param['check_status']) && $param['check_status'] == 0) {
|
||||
return [
|
||||
'=' =>['type']
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
'=' =>['type', 'check_status']
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function queryWhere()
|
||||
{
|
||||
$where = [];
|
||||
|
||||
// if (isset($param['type']) && $param['type'] == 2) {
|
||||
$adminId = User::where(['id' => $this->userId])->with('company')->value('admin_id');
|
||||
$where[] = ['check_admin_ids', '=', $adminId]; // 只有片区经理才能查看
|
||||
// }
|
||||
return $where;
|
||||
}
|
||||
|
||||
public function lists(): array
|
||||
{
|
||||
return Approve::where($this->searchWhere)
|
||||
->where($this->queryWhere())
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->withAttr('extend',function ($value, $data) {
|
||||
return json_decode($data['extend'], true);
|
||||
})
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
public function count(): int
|
||||
{
|
||||
return Approve::where($this->searchWhere)->count();
|
||||
}
|
||||
}
|
@ -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,15 +70,6 @@ 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)) {
|
||||
self::setError('公司已创建服务部长账号');
|
||||
return false;
|
||||
}
|
||||
$group_id=14;
|
||||
}
|
||||
User::create([
|
||||
'sn' => $userSn,
|
||||
'avatar' => $avatar,
|
||||
@ -147,9 +125,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();
|
||||
@ -192,16 +167,7 @@ class LoginLogic extends BaseLogic
|
||||
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);
|
||||
$userInfo = UserTokenService::setToken($user->id, 3);
|
||||
//返回登录信息
|
||||
$avatar = $user->avatar ?: Config::get('project.default_image.user_avatar');
|
||||
$avatar = FileService::getFileUrl($avatar);
|
||||
@ -217,116 +183,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 [
|
||||
|
@ -18,12 +18,12 @@ use app\common\{enum\notice\NoticeEnum,
|
||||
enum\user\UserTerminalEnum,
|
||||
enum\YesNoEnum,
|
||||
logic\BaseLogic,
|
||||
model\Company,
|
||||
model\user\User,
|
||||
model\user\UserAuth,
|
||||
model\user\Withdraw,
|
||||
service\sms\SmsDriver,
|
||||
service\wechat\WeChatMnpService};
|
||||
service\wechat\WeChatMnpService
|
||||
};
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\model\user\UserAccountLog;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
@ -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');
|
||||
@ -302,52 +302,33 @@ class UserLogic extends BaseLogic
|
||||
Db::startTrans();
|
||||
try {
|
||||
$user = User::findOrEmpty($params['user_id']);
|
||||
|
||||
if ($user->isEmpty()) {
|
||||
throw new DataNotFoundException('用户不存在');
|
||||
}
|
||||
|
||||
$company = Company::find(['id'=>$user->company_id]);
|
||||
if ($company->isEmpty()) {
|
||||
throw new DataNotFoundException('账户异常,关联公司不存在');
|
||||
}
|
||||
|
||||
// 是否有在途的提现申请
|
||||
$withdraw = Withdraw::where(['user_id'=>$params['user_id'], 'status'=>0])->find();
|
||||
if (!empty($withdraw)) {
|
||||
throw new ValidateException('您已有一笔审核中的提现申请,暂无法继续申请提现');
|
||||
}
|
||||
|
||||
// 校验提现金额
|
||||
if ($params['amount'] <= 0) {
|
||||
throw new ValidateException('提现金额错误');
|
||||
}
|
||||
|
||||
// 校验提现金额
|
||||
if ($params['amount'] > $company->company_money) {
|
||||
if ($params['amount'] > $user['user_money']) {
|
||||
throw new ValidateException('余额不足');
|
||||
}
|
||||
|
||||
// 发票校验
|
||||
if (empty($params['invoice'])) {
|
||||
throw new ValidateException('没有上传电子发票');
|
||||
}
|
||||
|
||||
// 保存提现记录
|
||||
$withdraw = new Withdraw();
|
||||
$withdraw->user_id = $user['id'];
|
||||
$withdraw->admin_id = $user['admin_id'];
|
||||
$withdraw->order_sn = $withdraw->buildOrderSn();
|
||||
$withdraw->amount = $params['amount'];
|
||||
$withdraw->transfer_end_cycel = $params['transfer_end_cycel'];
|
||||
$withdraw->invoice = $params['invoice'];
|
||||
$withdraw->create_time = time();
|
||||
$withdraw->update_time = time();
|
||||
$withdraw->save();
|
||||
|
||||
// 扣除余额
|
||||
// $user->user_money = $user['user_money'] - $params['amount'];
|
||||
// $user->save();
|
||||
$user->user_money = $user['user_money'] - $params['amount'];
|
||||
$user->save();
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
|
@ -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'=>[]];
|
||||
}
|
||||
}
|
@ -116,4 +116,6 @@ class BaseLikeAdminController extends BaseController
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -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]);
|
||||
}
|
||||
}
|
@ -47,7 +47,6 @@ class AccountLogEnum
|
||||
*/
|
||||
const UM_DEC_ADMIN = 100;
|
||||
const UM_DEC_RECHARGE_REFUND = 101;
|
||||
const UM_DEC_WITHDRAW = 102; // 提现
|
||||
|
||||
/**
|
||||
* 用户余额增加类型
|
||||
@ -64,7 +63,6 @@ class AccountLogEnum
|
||||
const UM_DEC = [
|
||||
self::UM_DEC_ADMIN,
|
||||
self::UM_DEC_RECHARGE_REFUND,
|
||||
self::UM_DEC_WITHDRAW
|
||||
];
|
||||
|
||||
|
||||
@ -117,7 +115,6 @@ class AccountLogEnum
|
||||
self::UM_INC_TASK => '任务收益金额增加',
|
||||
self::UM_INC_TASKUSER => '任务账户余额增加',
|
||||
self::UM_DEC_RECHARGE_REFUND => '充值订单退款减少余额',
|
||||
self::UM_DEC_WITHDRAW => '提现减少余额'
|
||||
];
|
||||
if ($flag) {
|
||||
return $desc;
|
||||
|
@ -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;
|
||||
@ -58,15 +57,10 @@ class CompanyLogic extends BaseLogic
|
||||
// }
|
||||
|
||||
// 手机号不能重复
|
||||
$companyInfo = Company::where(['master_phone'=>$params['master_phone']])->whereNull('delete_time')->find();
|
||||
$companyInfo = Company::where(['master_phone'=>$params['master_phone']])->find();
|
||||
if (!empty($companyInfo)) {
|
||||
throw new Exception('手机号已存在');
|
||||
}
|
||||
// 社会统一信用代码不能重复
|
||||
$companyInfo = Company::where(['organization_code'=>$params['organization_code']])->whereNull('delete_time')->find();
|
||||
if (!empty($companyInfo)) {
|
||||
throw new Exception('社会代码已存在');
|
||||
}
|
||||
$arr=[
|
||||
'company_name' => $params['company_name'],
|
||||
'organization_code' => $params['organization_code'],
|
||||
@ -82,7 +76,7 @@ class CompanyLogic extends BaseLogic
|
||||
'master_id_card' => $params['id_card'], // 主联系人证件号 todo DDL 新增字段
|
||||
'master_position' => $params['master_position'],
|
||||
'master_phone' => $params['master_phone'],
|
||||
'master_email' => substr(md5(uniqid()),rand(0, 22),10)."@lihai.com", // 随机邮箱
|
||||
'master_email' => $params['master_email'],
|
||||
'other_contacts' => $params['other_contacts'],
|
||||
'area_manager' => $params['area_manager'] ?? 0,
|
||||
'qualification' => $params['qualification'],
|
||||
@ -103,10 +97,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]);
|
||||
@ -116,10 +110,6 @@ 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; // 前台角色
|
||||
}
|
||||
$userSn = User::createUserSn();
|
||||
$admin['admin_id']=$admin_id;
|
||||
@ -135,15 +125,12 @@ class CompanyLogic extends BaseLogic
|
||||
$user_id = User::strict(false)->insertGetId($admin);
|
||||
Company::where('id',$data['id'])->update(['admin_id'=>$admin_id,'user_id'=>$user_id]);
|
||||
|
||||
// 平台公司没有合同和发布业务
|
||||
if ($params['company_type'] != 30){
|
||||
$scheduling=[
|
||||
'create_user_id'=>$params['area_manager'] ?? 0,
|
||||
'company_id'=>$data['id'],
|
||||
'company_type'=>$params['company_type'],
|
||||
];
|
||||
TaskScheduling::create($scheduling);
|
||||
}
|
||||
$scheduling=[
|
||||
'create_user_id'=>$params['area_manager'] ?? 0,
|
||||
'company_id'=>$data['id'],
|
||||
'company_type'=>$params['company_type'],
|
||||
];
|
||||
TaskScheduling::create($scheduling);
|
||||
|
||||
// 企业人脸校验上传
|
||||
// self::originationFaceCreate($data);
|
||||
@ -164,17 +151,18 @@ class CompanyLogic extends BaseLogic
|
||||
'organization_code' => $data['organization_code'],
|
||||
'master_name' => $data['master_name'],
|
||||
'master_id_card' => $data['master_id_card'],
|
||||
'master_email' => substr(uniqid(),3,5).$data['master_email'],
|
||||
'master_email' => $data['master_email'],
|
||||
'master_phone' => $data['master_phone'],
|
||||
'id' => $data['id'],
|
||||
];
|
||||
|
||||
// 公司数据合法性校验
|
||||
$checkCompany = self::companyCheck($organizationFaceCreateData);
|
||||
if ($checkCompany !== true){
|
||||
return $checkCompany;
|
||||
}
|
||||
|
||||
$res = app(JunziqianController::class)->organizationFaceCreate($organizationFaceCreateData);
|
||||
$res = app(JunziqianController::class)->organizationFaceCreate($data);
|
||||
if ($res->success == true && !empty($res->data)) {
|
||||
// 保存人脸识别地址 todo 新增字段的DDL
|
||||
Company::where('id',$data['id'])->update(['face_create_url'=>$res->data]);
|
||||
@ -220,19 +208,11 @@ class CompanyLogic extends BaseLogic
|
||||
Db::startTrans();
|
||||
try {
|
||||
// 手机号不能重复
|
||||
$companyInfo = Company::where(['master_phone'=>$params['master_phone']])->where('id','<>',$params['id'])->whereNull('delete_time')->find();
|
||||
$companyInfo = Company::where(['master_phone'=>$params['master_phone']])->where('id','<>',$params['id'])->find();
|
||||
if (!empty($companyInfo)) {
|
||||
Db::rollback();
|
||||
throw new Exception('手机号已存在');
|
||||
}
|
||||
|
||||
// 社会代码不能重复
|
||||
$companyInfo = Company::where(['organization_code'=>$params['organization_code']])->where('id','<>',$params['id'])->whereNull('delete_time')->find();
|
||||
if (!empty($companyInfo)) {
|
||||
Db::rollback();
|
||||
throw new Exception('社会代码已存在');
|
||||
}
|
||||
|
||||
$arr=[
|
||||
'company_name' => $params['company_name'],
|
||||
'organization_code' => $params['organization_code'],
|
||||
@ -266,76 +246,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 +264,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 +340,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,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic;
|
||||
|
||||
class RedisLogic extends BaseLogic
|
||||
{
|
||||
public static function getInstance()
|
||||
{
|
||||
$redisInstance = new \Redis();
|
||||
$redisInstance->connect(env('redis.host'));
|
||||
if (env('redis.auth', '') != '') {
|
||||
$redisInstance->auth(env('redis.auth'));
|
||||
}
|
||||
return $redisInstance;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,78 +0,0 @@
|
||||
<?php
|
||||
|
||||
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;
|
||||
|
||||
|
||||
class ApproveLogic extends BaseLogic
|
||||
{
|
||||
public static function audit($approve, $params, $userInfo)
|
||||
{
|
||||
// 拒绝通过
|
||||
if ($params['check_status'] == 3) {
|
||||
if (empty($params['remark'])) {
|
||||
self::setError('请输入拒绝理由');
|
||||
}
|
||||
self::refuse($approve, $params);
|
||||
}
|
||||
// 修改任务完成状态
|
||||
if ($params['check_status'] == 2) {
|
||||
self::pass($approve);
|
||||
}
|
||||
|
||||
// 回调商城,通知审核状态
|
||||
if (in_array($approve['type'], [2, 3])) {
|
||||
$shopMerchantInfo = json_decode($approve['extend'], true);
|
||||
self::shopCallBack($approve, $shopMerchantInfo, $params, $userInfo);
|
||||
}
|
||||
}
|
||||
|
||||
private static function pass(Approve $approve)
|
||||
{
|
||||
$approve->check_status = 2;
|
||||
$approve->save();
|
||||
}
|
||||
|
||||
private static function refuse(Approve $approve, $params)
|
||||
{
|
||||
$approve->check_status = 3;
|
||||
$approve->remark = $params['remark'];
|
||||
$approve->save();
|
||||
}
|
||||
|
||||
private static function shopCallBack(Approve $approve, $shopMerchantInfo, $params, $userInfo)
|
||||
{
|
||||
$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()]]);
|
||||
}
|
||||
|
||||
public static function detail($id)
|
||||
{
|
||||
return Approve::where('id', $id)->withAttr('extend', function ($value, $data) {
|
||||
return json_decode($data['extend'], true);
|
||||
})->find();
|
||||
}
|
||||
}
|
@ -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逻辑
|
||||
@ -190,7 +189,7 @@ class ContractLogic extends BaseLogic
|
||||
$signedContractUrl = '';
|
||||
if($contract['status'] == 1){
|
||||
if ($contract['contract_url'] == '') {
|
||||
$res = app(JunziqianController::class)->download_file($contract['contract_no'])->getData();
|
||||
$res = app(JunziqianController::class)->download_file($contract['contract_no']);
|
||||
if ($res['code'] == 1) {
|
||||
$signedContractUrl = $res['data']['url'];
|
||||
}
|
||||
@ -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('你已经生成过合同,请勿重复生成');
|
||||
@ -265,8 +261,8 @@ class ContractLogic extends BaseLogic
|
||||
$data = [
|
||||
'name' => $name . '的合同',
|
||||
'signatories' => [
|
||||
['fullName' => $name, 'identityType' => 12, 'identityCard' => $result['organization_code'], 'email' => $result['master_email'], 'noNeedVerify' => 1, 'signLevel' => 1], // 'authLevel'=>[11], 签约时验证人脸识别
|
||||
['fullName' => $result['contract']['party_a_info']['company_name'], 'identityType' => 12, 'identityCard' => $result['contract']['party_a_info']['organization_code'], 'email' => $result['contract']['party_a_info']['master_email'], 'noNeedVerify' => 1, 'signLevel' => 1]
|
||||
['fullName' => $name, 'identityType' => 12, 'identityCard' => $result['organization_code'], 'email' => $result['master_email'], 'noNeedVerify' => 1, 'authLevel'=>[11],'signLevel' => 1],
|
||||
['fullName' => $result['contract']['party_a_info']['company_name'], 'identityType' => 12, 'identityCard' => $result['contract']['party_a_info']['organization_code'], 'email' => $result['contract']['party_a_info']['master_email'], 'noNeedVerify' => 1, 'authLevel'=>[11],'signLevel' => 1]
|
||||
],
|
||||
'url' => $result['contract']['file'],
|
||||
];
|
||||
@ -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);
|
||||
|
@ -1,544 +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\UserAccountLog;
|
||||
use app\common\model\user\User;
|
||||
use think\facade\Db;
|
||||
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)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
|
||||
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
|
||||
|
||||
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']);;
|
||||
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_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 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,139 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic\finance;
|
||||
|
||||
use app\adminapi\logic\ConfigLogic;
|
||||
use app\common\enum\user\AccountLogEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\company\CompanyAccountLog;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\user\UserAccountLog;
|
||||
use app\common\model\user\Withdraw;
|
||||
use think\Exception;
|
||||
use think\facade\Db;
|
||||
use think\facade\Log;
|
||||
|
||||
class WithdrawLogic extends BaseLogic
|
||||
{
|
||||
public static function audit($params)
|
||||
{
|
||||
try {
|
||||
$withDrawInfo = Withdraw::find(['id'=>$params['id']]);
|
||||
Log::info(['提现申请审核-申请单', $withDrawInfo]);
|
||||
if (empty($withDrawInfo)) {
|
||||
throw new Exception('数据不存在');
|
||||
}
|
||||
if ($withDrawInfo->status !== 0) {
|
||||
throw new Exception('状态异常,当前申请已审核');
|
||||
}
|
||||
|
||||
$userInfo = User::find(['id'=>$withDrawInfo['user_id']]);
|
||||
Log::info(['提现申请审核-申请人账户', $userInfo]);
|
||||
if (empty($userInfo)) {
|
||||
throw new Exception('账户异常,提现账户不存在');
|
||||
}
|
||||
if ($userInfo['admin_id'] === 0) {
|
||||
throw new Exception('账户异常,该账户没有提现权限');
|
||||
}
|
||||
$companyInfo = Company::find($userInfo['company_id']);
|
||||
Log::info(['提现申请审核-公司', $userInfo]);
|
||||
if (empty($companyInfo)) {
|
||||
throw new Exception('账户异常,提现账户没有关联公司');
|
||||
}
|
||||
|
||||
// 拒绝通过审核,记录备注原因
|
||||
if ($params['status'] == 2) {
|
||||
Withdraw::where(['id'=>$withDrawInfo['id']])->update(['status'=>2, 'deny_desc'=>$params['deny_desc'] ?? '']);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (empty($params['transfer_voucher'])) {
|
||||
throw new Exception('请上传转账凭证');
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
$endCycle = $withDrawInfo['transfer_end_cycel']; // 提现周期截止时间戳
|
||||
|
||||
/**
|
||||
* 1.扣除 公司账户余额 和 添加公司账户余额变动记录
|
||||
* 2.扣除公司内用户的余额(在本次提现周期内增加的金额总和)和用户账户变动记录,并且将用户周期内的账户变动记录变更为已提现状态
|
||||
*
|
||||
*/
|
||||
|
||||
// 1.扣除公司账户余额
|
||||
$amount = $withDrawInfo['amount']; // 提现金额
|
||||
$leftMoney = bcsub($companyInfo['company_money'], $amount, 2); // 提现后剩余金额
|
||||
if ($leftMoney < 0) {
|
||||
throw new Exception('公司账户余额不足');
|
||||
}
|
||||
$companyInfo->save(['company_money'=>$leftMoney]);
|
||||
|
||||
$companyAccountLog = [
|
||||
'sn' => generate_sn(UserAccountLog::class, 'sn', 20),
|
||||
'company_id' => $companyInfo['id'],
|
||||
'change_object' => CompanyAccountLog::COMPANY_MONEY, //变动对象
|
||||
'change_type' => CompanyAccountLog::WITHDRAW_DEC_DEPOSIT, //变动类型
|
||||
'action' => CompanyAccountLog::DEC, //1-增加 2-减少
|
||||
'left_amount' => $leftMoney, //变动后数量
|
||||
'change_amount' => $amount, //变动数量
|
||||
'remark' => '减少原因:提现',
|
||||
'status' => 1,
|
||||
];
|
||||
// 添加公司账户余额变动记录
|
||||
CompanyAccountLog::create($companyAccountLog);
|
||||
|
||||
// 2.扣除公司内用户在本次提现周期内增加的金额总和 和 用户账户变动记录,并且将周期内的用户的账户变动记录变更为已提现状态
|
||||
$companyUserList = User::where(['company_id'=>$companyInfo['id']])->select();
|
||||
foreach ($companyUserList as $user) {
|
||||
$tempUserMoneySycleTotal = 0;
|
||||
$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);
|
||||
if( $tempUserLeftMoney < 0 ){
|
||||
throw new Exception('账户异常,用户余额不足,user_id:'.$user->id.",扣除金额:".$tempUserMoneySycleTotal);
|
||||
}
|
||||
// 扣除用户余额
|
||||
$user->save(['user_money'=>$tempUserLeftMoney]);
|
||||
// 用户账户变动记录
|
||||
$data = [
|
||||
'sn' => generate_sn(UserAccountLog::class, 'sn', 20),
|
||||
'user_id' => $user->id,
|
||||
'company_id'=> $user->company_id,
|
||||
'change_object' => AccountLogEnum::UM,
|
||||
'change_type' => AccountLogEnum::UM_DEC_WITHDRAW,
|
||||
'action' => AccountLogEnum::DEC,
|
||||
'left_amount' => $tempUserLeftMoney,
|
||||
'change_amount' => $tempUserMoneySycleTotal,
|
||||
'source_sn' => '',
|
||||
'remark' => '减少原因:公司提现',
|
||||
'extra' => '',
|
||||
'status'=> 1,
|
||||
'is_withdraw'=> 1
|
||||
];
|
||||
UserAccountLog::create($data);
|
||||
// 将用户周期内的账户变动记录变更为已提现状态
|
||||
UserAccountLog::where(['user_id'=>$user->id, 'status'=>1, 'action'=>1, 'change_type'=>202, 'is_withdraw'=>0])->where('create_time','<', $endCycle)->update(['is_withdraw'=>1]);
|
||||
}
|
||||
|
||||
// 重置公司可提现截止日期 上一次截止日期 + 长期周期天数
|
||||
$dictData = ConfigLogic::getDictTypeValueByType('withdraw_cycle');
|
||||
$cycle = $dictData['withdraw_cycle_long']['value']; // 数据字典-提现周期 单位:天数
|
||||
$withdrawDeadline = $endCycle + $cycle * 24 * 60 * 60;
|
||||
$companyInfo->save(['withdraw_deadline' => $withdrawDeadline]);
|
||||
|
||||
// 更新状态,保存转账凭证
|
||||
Withdraw::where(['id'=>$withDrawInfo['id']])->update(['status'=>3, 'transfer_voucher'=>$params['transfer_voucher']]);
|
||||
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (Exception $exception) {
|
||||
Db::rollback();
|
||||
self::setError($exception->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -15,15 +15,11 @@
|
||||
namespace app\common\logic\task_template;
|
||||
|
||||
|
||||
use app\adminapi\logic\ConfigLogic;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\task_template\TaskTemplate;
|
||||
use app\common\logic\BaseLogic;
|
||||
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;
|
||||
|
||||
|
||||
@ -45,26 +41,21 @@ class TaskTemplateLogic extends BaseLogic
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
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,20 +72,18 @@ 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;
|
||||
}
|
||||
}
|
||||
// 除了长期任务,其他阶段类型没有长期金额
|
||||
if($params['types']!=2){
|
||||
if($params['types']!=33){
|
||||
$params['money_three']=0;
|
||||
}
|
||||
if($params['type']==35){
|
||||
$params['extend']=['shareholder'=>['user_id'=>$params['task_admin']]];
|
||||
}
|
||||
|
||||
TaskTemplate::create([
|
||||
'title' => $params['title'],
|
||||
'admin_id' => $params['admin_id'],
|
||||
@ -113,8 +102,8 @@ 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;
|
||||
} catch (\Exception $e) {
|
||||
@ -136,49 +125,41 @@ 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;
|
||||
}
|
||||
}
|
||||
// 除了长期任务,其他阶段类型没有长期金额
|
||||
if($params['types']!=2){
|
||||
if($params['types']!=33){
|
||||
$params['money_three']=0;
|
||||
}
|
||||
if($params['type']==35){
|
||||
@ -194,7 +175,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,
|
||||
@ -236,191 +217,4 @@ class TaskTemplateLogic extends BaseLogic
|
||||
{
|
||||
return TaskTemplate::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
|
||||
public static function initCompanyWithdrawDeadline($companyId)
|
||||
{
|
||||
// 如果是公司第一次创建安排任务,初始化公司的可提现周期截止时间
|
||||
$templateCount = TaskTemplate::where(['company_id' => $companyId])->count();
|
||||
if ($templateCount == 1) {
|
||||
$dictData = ConfigLogic::getDictTypeValueByType('withdraw_cycle');
|
||||
$cycle = $dictData['withdraw_cycle_1']['value']; // 数据字典-提现周期 单位:天数
|
||||
$today = strtotime(date('Y-m-d'));
|
||||
$withdrawDeadline = $today + $cycle * 24 * 60 * 60 + 86400;
|
||||
$company = Company::find($companyId);
|
||||
$company->withdraw_deadline = $withdrawDeadline;
|
||||
$company->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 添加任务模板
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2023/08/06 17:30
|
||||
*/
|
||||
public static function addTownTaskTemplate(array $params): bool
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
|
||||
// $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']);
|
||||
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'] > 200){
|
||||
self::setError('任务模板一阶段合计金额不能大于任务调度金额');
|
||||
return false;
|
||||
}
|
||||
$moneyTwo = TaskTemplate::where('company_id', $params['company_id'])->sum('money_two');
|
||||
if($moneyTwo + $params['money_two'] > 200){
|
||||
self::setError('任务模板二阶段合计金额不能大于任务调度金额');
|
||||
return false;
|
||||
}
|
||||
$newMoneyThree = TaskTemplate::where('company_id', $params['company_id'])->sum('new_money_three');
|
||||
if($newMoneyThree + $params['new_money_three'] > 200){
|
||||
self::setError('任务模板三阶段合计金额不能大于任务调度金额');
|
||||
return false;
|
||||
}
|
||||
$moneyThree = TaskTemplate::where('company_id', $params['company_id'])->sum('money_three');
|
||||
if($moneyThree + $params['money_three']>200){
|
||||
self::setError('任务模板长期合计金额不能大于任务调度金额');
|
||||
return false;
|
||||
}
|
||||
|
||||
TaskTemplate::create([
|
||||
'title' => $params['title'],
|
||||
'admin_id' => $params['admin_id'],
|
||||
'company_id' => $params['company_id'],
|
||||
'task_scheduling' => $params['task_scheduling']??0,
|
||||
'money' => $params['money'],
|
||||
'money_two' => $params['money_two'],
|
||||
'money_three' => $params['money_three'],
|
||||
'type' => $params['type'],
|
||||
'types' => $params['types'],
|
||||
'status' => $params['status'],
|
||||
'content' => $params['content'],
|
||||
'extend'=>json_encode($params['extend']),
|
||||
'stage_day_one' => $params['stage_day_one']??0,
|
||||
'proportion_one' => $params['proportion_one']??0,
|
||||
'stage_day_two' => $params['stage_day_two']??0,
|
||||
'proportion_two' => $params['proportion_two']??0,
|
||||
'recharge' => $params['recharge']??0,
|
||||
'stage_day_three' => $params['stage_day_three']??0,
|
||||
'new_money_three' => $params['new_money_three']??0,
|
||||
// 'cron_time' => strtotime($params['cron_time']), // 定时下发日期
|
||||
]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\model\task\Task;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
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()
|
||||
{
|
||||
return $this->hasOne(Task::class, 'id', 'task_id');
|
||||
}
|
||||
|
||||
}
|
@ -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';
|
||||
}
|
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