新增收银app更新相关功能

This commit is contained in:
mkm 2024-05-30 10:30:18 +08:00
parent 06ce28a988
commit e7585cbfd8
7 changed files with 380 additions and 2 deletions

View File

@ -0,0 +1,95 @@
<?php
namespace app\admin\controller\app_update;
use app\admin\controller\BaseAdminController;
use app\admin\lists\app_update\AppUpdateLists;
use app\admin\logic\app_update\AppUpdateLogic;
use app\admin\validate\app_update\AppUpdateValidate;
/**
* 收银app更新控制器
* Class AppUpdateController
* @package app\admin\controller\app_update
*/
class AppUpdateController extends BaseAdminController
{
/**
* @notes 获取收银app更新列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/05/30 10:25
*/
public function lists()
{
return $this->dataLists(new AppUpdateLists());
}
/**
* @notes 添加收银app更新
* @return \think\response\Json
* @author likeadmin
* @date 2024/05/30 10:25
*/
public function add()
{
$params = (new AppUpdateValidate())->post()->goCheck('add');
$result = AppUpdateLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(AppUpdateLogic::getError());
}
/**
* @notes 编辑收银app更新
* @return \think\response\Json
* @author likeadmin
* @date 2024/05/30 10:25
*/
public function edit()
{
$params = (new AppUpdateValidate())->post()->goCheck('edit');
$result = AppUpdateLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(AppUpdateLogic::getError());
}
/**
* @notes 删除收银app更新
* @return \think\response\Json
* @author likeadmin
* @date 2024/05/30 10:25
*/
public function delete()
{
$params = (new AppUpdateValidate())->post()->goCheck('delete');
AppUpdateLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取收银app更新详情
* @return \think\response\Json
* @author likeadmin
* @date 2024/05/30 10:25
*/
public function detail()
{
$params = (new AppUpdateValidate())->goCheck('detail');
$result = AppUpdateLogic::detail($params);
return $this->data($result);
}
}

View File

@ -0,0 +1,65 @@
<?php
namespace app\admin\lists\app_update;
use app\admin\lists\BaseAdminDataLists;
use app\common\model\app_update\AppUpdate;
use app\common\lists\ListsSearchInterface;
/**
* 收银app更新列表
* Class AppUpdateLists
* @package app\admin\listsapp_update
*/
class AppUpdateLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/05/30 10:25
*/
public function setSearch(): array
{
return [
'=' => ['title', 'content', 'type', 'version', 'dow_url', 'force', 'quiet'],
];
}
/**
* @notes 获取收银app更新列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/05/30 10:25
*/
public function lists(): array
{
return AppUpdate::where($this->searchWhere)
->field(['id', 'title', 'content', 'type', 'version', 'dow_url', 'force', 'quiet'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->toArray();
}
/**
* @notes 获取收银app更新数量
* @return int
* @author likeadmin
* @date 2024/05/30 10:25
*/
public function count(): int
{
return AppUpdate::where($this->searchWhere)->count();
}
}

View File

@ -32,7 +32,7 @@ class OpurchaseclassofferLists extends BaseAdminDataLists implements ListsSearch
{
return [
'=' => ['is_adopt', 'is_storage', 'order_id'],
'between_time'=>'create_time'
'between_time' => 'create_time'
];
}

View File

@ -0,0 +1,106 @@
<?php
namespace app\admin\logic\app_update;
use app\common\model\app_update\AppUpdate;
use app\common\logic\BaseLogic;
use think\facade\Db;
/**
* 收银app更新逻辑
* Class AppUpdateLogic
* @package app\admin\logic\app_update
*/
class AppUpdateLogic extends BaseLogic
{
/**
* @notes 添加收银app更新
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/05/30 10:25
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
AppUpdate::create([
'title' => $params['title'],
'content' => $params['content'],
'type' => $params['type'],
'version' => $params['version'],
'dow_url' => $params['dow_url'],
'force' => $params['force'],
'quiet' => $params['quiet']
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 编辑收银app更新
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/05/30 10:25
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
AppUpdate::where('id', $params['id'])->update([
'title' => $params['title'],
'content' => $params['content'],
'type' => $params['type'],
'version' => $params['version'],
'dow_url' => $params['dow_url'],
'force' => $params['force'],
'quiet' => $params['quiet']
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 删除收银app更新
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/05/30 10:25
*/
public static function delete(array $params): bool
{
return AppUpdate::destroy($params['id']);
}
/**
* @notes 获取收银app更新详情
* @param $params
* @return array
* @author likeadmin
* @date 2024/05/30 10:25
*/
public static function detail($params): array
{
return AppUpdate::findOrEmpty($params['id'])->toArray();
}
}

View File

@ -0,0 +1,82 @@
<?php
namespace app\admin\validate\app_update;
use app\common\validate\BaseValidate;
/**
* 收银app更新验证器
* Class AppUpdateValidate
* @package app\admin\validate\app_update
*/
class AppUpdateValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
];
/**
* @notes 添加场景
* @return AppUpdateValidate
* @author likeadmin
* @date 2024/05/30 10:25
*/
public function sceneAdd()
{
return $this->remove('id', true);
}
/**
* @notes 编辑场景
* @return AppUpdateValidate
* @author likeadmin
* @date 2024/05/30 10:25
*/
public function sceneEdit()
{
return $this->only(['id']);
}
/**
* @notes 删除场景
* @return AppUpdateValidate
* @author likeadmin
* @date 2024/05/30 10:25
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return AppUpdateValidate
* @author likeadmin
* @date 2024/05/30 10:25
*/
public function sceneDetail()
{
return $this->only(['id']);
}
}

View File

@ -4,6 +4,7 @@ namespace app\api\lists\operation;
use app\admin\lists\BaseAdminDataLists;
use app\common\lists\ListsExtendInterface;
use app\common\lists\ListsSearchInterface;
use app\common\model\goods\Goods;
use app\common\model\goods\Unit;
@ -14,7 +15,7 @@ use app\common\model\opurchase\OpurchaseGoodsOffer;
* Class OpurchaseclassLists
* @package app\api\operation
*/
class OpurchaseGoodsOfferList extends BaseAdminDataLists implements ListsSearchInterface
class OpurchaseGoodsOfferList extends BaseAdminDataLists implements ListsSearchInterface,ListsExtendInterface
{
@ -90,4 +91,11 @@ class OpurchaseGoodsOfferList extends BaseAdminDataLists implements ListsSearchI
}
return OpurchaseGoodsOffer::where($this->searchWhere)->where('supplier_id', $supplier_id)->where($where)->count();
}
public function extend(){
$supplier_id = $this->request->userInfo['supplier']['id'] ?? 0;
$where=['supplier_id'=> $supplier_id,'is_adopt'=>2,'status'=>0];
$delivery=OpurchaseGoodsOffer::where($this->searchWhere)->where($where)->count();
return ['delivery'=>$delivery];
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace app\common\model\app_update;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* 收银app更新模型
* Class AppUpdate
* @package app\common\model\app_update
*/
class AppUpdate extends BaseModel
{
use SoftDelete;
protected $name = 'app_update';
protected $deleteTime = 'delete_time';
}