add:商户合同管理

This commit is contained in:
chenbo 2023-09-13 17:48:44 +08:00
parent 07c9ea2208
commit 87f3ff0ba8
6 changed files with 523 additions and 0 deletions

View File

@ -0,0 +1,145 @@
<?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\logic\SmsLogic;
use app\common\model\ShopContract;
use app\common\model\ShopMerchant;
use app\Request;
/**
* 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 = 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']['master_phone'],
'name' => $find['party_a_info']['company_name'],
'scene' => 'WQTZ'
];
SmsLogic::contractUrl($a);
$b = [
'mobile' => $find['party_b_info']['phone'],
'name' => $find['party_b_info']['name'],
'scene' => 'WQTZ'
];
SmsLogic::contractUrl($b);
return $this->success('上传成功', [], 1, 1);
} else {
if ($res == 0) {
return $this->success('没有更新', [], 1, 1);
}
return $this->fail('上传失败');
}
}
}

View File

@ -0,0 +1,77 @@
<?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'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->toArray();
}
/**
* @notes 获取数量
* @return int
* @author likeadmin
* @date 2023/09/13 17:01
*/
public function count(): int
{
return ShopContract::where($this->searchWhere)->count();
}
}

View File

@ -0,0 +1,153 @@
<?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\common\logic\contract\ContractLogic;
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();
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();
return $shopMerchant;
})
->withAttr('status_name', function ($value, $data) {
return $data['status'] == 1 ? '已签约' : '未签约';
})
->find();
dd($data);
$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;
}
}

View File

@ -0,0 +1,94 @@
<?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']);
}
}

View File

@ -332,6 +332,26 @@ class JunziqianController extends BaseApiController
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('获取失败');
}
}
/**
* 保全后合同文件及证据包下载
*/

View File

@ -0,0 +1,34 @@
<?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;
/**
* ShopContract模型
* Class ShopContract
* @package app\common\model
*/
class ShopContract extends BaseModel
{
protected $name = 'shop_contract';
}