update
This commit is contained in:
parent
5b796fe48c
commit
6199e2a702
@ -0,0 +1,108 @@
|
||||
<?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\marketing;
|
||||
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\marketing\MarketingContractChangeLists;
|
||||
use app\adminapi\logic\marketing\MarketingContractChangeLogic;
|
||||
use app\adminapi\validate\marketing\MarketingContractChangeValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 市场经营--合同信息--合同变更控制器
|
||||
* Class MarketingContractChangeController
|
||||
* @package app\adminapi\controller\marketing
|
||||
*/
|
||||
class MarketingContractChangeController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取市场经营--合同信息--合同变更列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/04/13 14:19
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new MarketingContractChangeLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加市场经营--合同信息--合同变更
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/04/13 14:19
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new MarketingContractChangeValidate())->post()->goCheck('add');
|
||||
$result = MarketingContractChangeLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(MarketingContractChangeLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑市场经营--合同信息--合同变更
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/04/13 14:19
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new MarketingContractChangeValidate())->post()->goCheck('edit');
|
||||
$result = MarketingContractChangeLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(MarketingContractChangeLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除市场经营--合同信息--合同变更
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/04/13 14:19
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new MarketingContractChangeValidate())->post()->goCheck('delete');
|
||||
MarketingContractChangeLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取市场经营--合同信息--合同变更详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/04/13 14:19
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new MarketingContractChangeValidate())->goCheck('detail');
|
||||
$result = MarketingContractChangeLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -62,8 +62,7 @@
|
||||
$date = explode(',', $params['collection_date']);
|
||||
$where[] = ['collection_date', 'between', [strtotime($date[0] . ' 00:00:00'), strtotime($date[1] . ' 23:59:59')]];
|
||||
}
|
||||
return FinancialCollectionPlan::where($this->searchWhere)->where($where)
|
||||
->field(['id', 'contract_id', 'collection_amount', 'collection_date', 'collection_user', 'remark', 'annex'])
|
||||
return FinancialCollectionPlan::withoutField('create_time,update_time,delete_time')->where($this->searchWhere)->where($where)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($data) {
|
||||
|
@ -0,0 +1,95 @@
|
||||
<?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\marketing;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\marketing\MarketingContract;
|
||||
use app\common\model\marketing\MarketingContractChange;
|
||||
|
||||
|
||||
/**
|
||||
* 市场经营--合同信息--合同变更列表
|
||||
* Class MarketingContractChangeLists
|
||||
* @package app\adminapi\listsmarketing
|
||||
*/
|
||||
class MarketingContractChangeLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2024/04/13 14:19
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['contract_id', 'change_user'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取市场经营--合同信息--合同变更列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2024/04/13 14:19
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$params = $this->request->get();
|
||||
$where = [];
|
||||
if (!empty($params['change_date'])) {
|
||||
$date = explode(',', $params['change_date']);
|
||||
$where[] = ['change_date', 'between', [strtotime($date[0] . ' 00:00:00'), strtotime($date[1] . ' 23:59:59')]];
|
||||
}
|
||||
return MarketingContractChange::withoutField('create_time,update_time,delete_time')->where($this->searchWhere)->where($where)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($data) {
|
||||
$contract = MarketingContract::field('contract_name,contract_type,business_nature,signed_amount')->where('id', $data['contract_id'])->findOrEmpty();
|
||||
$data['contract_name'] = $contract?->contract_name;
|
||||
$data['contract_type'] = $contract?->contract_type_text;
|
||||
$data['business_nature'] = $contract?->business_nature_text;
|
||||
$data['signed_amount'] = $contract?->signed_amount;
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取市场经营--合同信息--合同变更数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2024/04/13 14:19
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
$params = $this->request->get();
|
||||
$where = [];
|
||||
if (!empty($params['change_date'])) {
|
||||
$date = explode(',', $params['change_date']);
|
||||
$where[] = ['change_date', 'between', [strtotime($date[0] . ' 00:00:00'), strtotime($date[1] . ' 23:59:59')]];
|
||||
}
|
||||
return MarketingContractChange::where($this->searchWhere)->where($where)->count();
|
||||
}
|
||||
|
||||
}
|
121
app/adminapi/logic/marketing/MarketingContractChangeLogic.php
Normal file
121
app/adminapi/logic/marketing/MarketingContractChangeLogic.php
Normal file
@ -0,0 +1,121 @@
|
||||
<?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\marketing;
|
||||
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\marketing\MarketingContract;
|
||||
use app\common\model\marketing\MarketingContractChange;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 市场经营--合同信息--合同变更逻辑
|
||||
* Class MarketingContractChangeLogic
|
||||
* @package app\adminapi\logic\marketing
|
||||
*/
|
||||
class MarketingContractChangeLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加市场经营--合同信息--合同变更
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/04/13 14:19
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
MarketingContractChange::create([
|
||||
'contract_id' => $params['contract_id'],
|
||||
'change_amount' => $params['change_amount'],
|
||||
'change_user' => $params['change_user'],
|
||||
'change_date' => !empty($params['change_date']) ? strtotime($params['change_date']) : 0,
|
||||
'change_content' => $params['change_content'] ?? '',
|
||||
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
|
||||
]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑市场经营--合同信息--合同变更
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/04/13 14:19
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
MarketingContractChange::where('id', $params['id'])->update([
|
||||
'contract_id' => $params['contract_id'],
|
||||
'change_amount' => $params['change_amount'],
|
||||
'change_user' => $params['change_user'],
|
||||
'change_date' => !empty($params['change_date']) ? strtotime($params['change_date']) : 0,
|
||||
'change_content' => $params['change_content'] ?? '',
|
||||
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
|
||||
]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除市场经营--合同信息--合同变更
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/04/13 14:19
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return MarketingContractChange::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取市场经营--合同信息--合同变更详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2024/04/13 14:19
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
$data = MarketingContractChange::withoutField('create_time,update_time,delete_time')->findOrEmpty($params['id']);
|
||||
$contract = MarketingContract::field('contract_name,contract_type,business_nature,signed_amount')->where('id', $data['contract_id'])->findOrEmpty();
|
||||
$data['contract_name'] = $contract?->contract_name;
|
||||
$data['contract_type'] = $contract?->contract_type_text;
|
||||
$data['business_nature'] = $contract?->business_nature_text;
|
||||
$data['signed_amount'] = $contract?->signed_amount;
|
||||
return $data->toArray();
|
||||
}
|
||||
}
|
@ -0,0 +1,125 @@
|
||||
<?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\marketing;
|
||||
|
||||
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\marketing\MarketingContract;
|
||||
use app\common\model\marketing\MarketingContractChange;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 市场经营--合同信息--合同变更验证器
|
||||
* Class MarketingContractChangeValidate
|
||||
* @package app\adminapi\validate\marketing
|
||||
*/
|
||||
class MarketingContractChangeValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require|checkData',
|
||||
'contract_id' => 'require|checkContract',
|
||||
'change_amount' => 'require|float|egt:0',
|
||||
'change_user' => 'require|checkChangeUser',
|
||||
'change_date' => 'require|dateFormat:Y-m-d',
|
||||
'annex' => 'checkAnnex',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
'contract_id' => '合同id',
|
||||
'change_amount' => '签证变更后金额',
|
||||
'change_user' => '签证变更人员',
|
||||
'change_date' => '变更日期',
|
||||
'change_content' => '变更事项',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return MarketingContractChangeValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/04/13 14:19
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['contract_id', 'change_amount', 'change_user', 'change_date', 'change_content', 'annex']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return MarketingContractChangeValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/04/13 14:19
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id', 'contract_id', 'change_amount', 'change_user', 'change_date', 'change_content', 'annex']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return MarketingContractChangeValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/04/13 14:19
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id'])->remove('id', 'checkData');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return MarketingContractChangeValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/04/13 14:19
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function checkData($value): bool|string
|
||||
{
|
||||
$data = MarketingContractChange::where('id', $value)->findOrEmpty();
|
||||
return $data->isEmpty() ? '数据不存在' : true;
|
||||
}
|
||||
|
||||
public function checkContract($value): bool|string
|
||||
{
|
||||
$data = MarketingContract::where('id', $value)->findOrEmpty();
|
||||
return $data->isEmpty() ? '合同数据不存在' : true;
|
||||
}
|
||||
|
||||
public function checkChangeUser($value): bool|string
|
||||
{
|
||||
$data = Admin::where('id', $value)->findOrEmpty();
|
||||
return $data->isEmpty() ? '签证变更人员数据不存在' : true;
|
||||
}
|
||||
|
||||
}
|
38
app/common/model/marketing/MarketingContractChange.php
Normal file
38
app/common/model/marketing/MarketingContractChange.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?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\marketing;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
/**
|
||||
* 市场经营--合同信息--合同变更模型
|
||||
* Class MarketingContractChange
|
||||
* @package app\common\model\marketing
|
||||
*/
|
||||
class MarketingContractChange extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
|
||||
protected $name = 'marketing_contract_change';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
public function getChangeDateAttr($value): string
|
||||
{
|
||||
return !empty($value) ? date('Y-m-d', $value) : '';
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user