diff --git a/app/admin/controller/app_update/AppUpdateController.php b/app/admin/controller/app_update/AppUpdateController.php new file mode 100644 index 0000000..b9a84c1 --- /dev/null +++ b/app/admin/controller/app_update/AppUpdateController.php @@ -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); + } + + +} \ No newline at end of file diff --git a/app/admin/lists/app_update/AppUpdateLists.php b/app/admin/lists/app_update/AppUpdateLists.php new file mode 100644 index 0000000..09837e3 --- /dev/null +++ b/app/admin/lists/app_update/AppUpdateLists.php @@ -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(); + } + +} \ No newline at end of file diff --git a/app/admin/lists/operation/OpurchaseclassofferLists.php b/app/admin/lists/operation/OpurchaseclassofferLists.php index 64e0d4d..7f315d4 100644 --- a/app/admin/lists/operation/OpurchaseclassofferLists.php +++ b/app/admin/lists/operation/OpurchaseclassofferLists.php @@ -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' ]; } diff --git a/app/admin/logic/app_update/AppUpdateLogic.php b/app/admin/logic/app_update/AppUpdateLogic.php new file mode 100644 index 0000000..c322002 --- /dev/null +++ b/app/admin/logic/app_update/AppUpdateLogic.php @@ -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(); + } +} \ No newline at end of file diff --git a/app/admin/validate/app_update/AppUpdateValidate.php b/app/admin/validate/app_update/AppUpdateValidate.php new file mode 100644 index 0000000..d0bf90b --- /dev/null +++ b/app/admin/validate/app_update/AppUpdateValidate.php @@ -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']); + } + +} \ No newline at end of file diff --git a/app/api/lists/operation/OpurchaseGoodsOfferList.php b/app/api/lists/operation/OpurchaseGoodsOfferList.php index e44354a..b259db2 100644 --- a/app/api/lists/operation/OpurchaseGoodsOfferList.php +++ b/app/api/lists/operation/OpurchaseGoodsOfferList.php @@ -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]; + } + } diff --git a/app/common/model/app_update/AppUpdate.php b/app/common/model/app_update/AppUpdate.php new file mode 100644 index 0000000..4de527b --- /dev/null +++ b/app/common/model/app_update/AppUpdate.php @@ -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'; + + +} \ No newline at end of file