| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- <?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\agricultural_machinery;
- use app\common\enum\PayEnum;
- use app\common\enum\YesNoEnum;
- use app\common\logic\BaseLogic;
- use app\common\model\agricultural_machinery\UserService;
- use app\common\model\user\User;
- use app\common\model\agricultural_machinery\ServiceCategory as AgriculturalMachineryServiceCategory;
- use app\common\model\supply_demand\SupplyDemandInfo;
- use app\common\model\supply_demand\SupplyDemandCate;
- use app\common\model\recharge\RechargeOrder;
- use app\common\model\ServiceCharge;
- use think\facade\Db;
- /**
- * 供需管理逻辑
- * Class ArticleCateLogic
- * @package app\adminapi\logic\article
- */
- class SupplyDemandLogic extends BaseLogic
- {
- /**
- * @notes 删除农耕分类
- * @param array $params
- * @author heshihu
- * @date 2022/2/21 17:52
- */
- public static function delete(array $params)
- {
- SupplyDemandInfo::destroy($params['id']);
- }
- /**
- * @notes 查看供需详情
- * @param $params
- * @return array
- * @author heshihu
- * @date 2022/2/21 17:54
- */
- public static function detail($params) : array
- {
- return SupplyDemandInfo::with('area')->findOrEmpty($params['id'])->toArray();
- }
- /**
- * @notes 查看供需详情
- * @param $params
- * @return array
- * @author heshihu
- * @date 2022/2/21 17:54
- */
- public static function detailCate($params) : array
- {
- return SupplyDemandCate::findOrEmpty($params['id'])->toArray();
- }
- /**
- * @notes 更改服务商状态
- * @param array $params
- * @return bool
- * @author heshihu
- * @date 2022/2/21 18:04
- */
- public static function updateStatus(array $params)
- {
- SupplyDemandInfo::update([
- 'id' => $params['id'],
- 'status' => $params['status'],
- 'audit_time' =>time(),
- 'remark' => $params['remark']
- ]);
- return true;
- }
- /**
- * @notes 有效用户数据
- * @return array
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- * @author 段誉
- * @date 2022/10/13 10:53
- */
- public static function getValidUserData()
- {
- $list = User::where(['is_disable' => YesNoEnum::NO])
- ->field('id,sn,nickname')
- ->order([ 'id' => 'desc'])
- ->select()
- ->toArray();
- return $list;
- }
- /**
- * @notes 添加供应分类
- * @param array $params
- * @author heshihu
- * @date 2022/2/18 10:17
- */
- public static function addCate(array $params)
- {
- $pid = $params['pid'];
- $level = 1;
- $pidInfo = SupplyDemandCate::find($pid);
- if(!empty($pidInfo)){
- $level = $pidInfo['level'] + 1;
- }
- SupplyDemandCate::create([
- 'name' => $params['name'],
- 'level' => $level,
- 'pid' => $pid,
- 'type' => $params['type'] ?? 1,
- 'status' => $params['status'] ?? 1,
- 'sort' => $params['sort'] ?? 0
- ]);
- }
- public static function editCate(array $params) : bool
- {
- try {
- $pid = $params['pid'];
- $level = 1;
- $pidInfo = SupplyDemandCate::find($pid);
- if(!empty($pidInfo)){
- $level = $pidInfo['level'] + 1;
- }
- SupplyDemandCate::update([
- 'id' => $params['id'],
- 'name' => $params['name'],
- 'level' => $level,
- 'pid' => $pid,
- 'status' => $params['status'] ?? 1,
- 'sort' => $params['sort'] ?? 0
- ]);
- return true;
- } catch (\Exception $e) {
- self::setError($e->getMessage());
- return false;
- }
- }
- public static function updateCateStatus(array $params)
- {
- SupplyDemandCate::update([
- 'id' => $params['id'],
- 'status' => $params['status'],
- ]);
- return true;
- }
- public static function deleteCate(array $params)
- {
- SupplyDemandCate::destroy($params['id']);
- }
- }
|