12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- namespace app\service;
- use app\model\Enterprises;
- use think\console\command\Lists;
- use think\db\exception\DataNotFoundException;
- use think\db\exception\DbException;
- use think\db\exception\ModelNotFoundException;
- use think\facade\Db;
- use think\Model;
- class EnterprisesService
- {
- public static function selectLoginInfo($loginInfo){
- $map[] = ["username","=",$loginInfo["username"]];
- $map[] = ["password","=",$loginInfo["password"]];
- return (new Enterprises())->where($map)->field("qydm, fzr_name")->find();
- }
- /**
- * @throws ModelNotFoundException
- * @throws DataNotFoundException
- * @throws DbException
- */
- public static function getEnterPrisesList($page, $xzqdm){
- switch (strlen($xzqdm) ){
- case 4:
- $map[]=["city","=",$xzqdm];
- break;
- case 6:
- $map[] = ["country","=",$xzqdm];
- break;
- case 9:
- $map[] = ["towns","=",$xzqdm];
- break;
- default:
- $map[]=["city","<>",""];
- }
- $res["row"] = (new Enterprises)->where($map)->page($page["page"],$page["size"])->select();
- $res["count"] = (new Enterprises)->where($map)->count();
- return $res;
- }
- public static function getEnterprisesInfoByQydm($qydm){
- return Db::name("enterprises")->field("t_enterprises.*,x.xzqmc as cityname,e.xzqmc as countyname,f.xzqmc as townsname")->where("qydm",$qydm)->leftJoin("t_zd_xzq x","t_enterprises.city=x.xzqdm")->leftJoin("t_zd_xzq e","t_enterprises.county=e.xzqdm")->leftJoin("t_zd_xzq f","t_enterprises.towns=f.xzqdm")->find();
- }
- /**
- * @throws ModelNotFoundException
- * @throws DataNotFoundException
- * @throws DbException
- */
- public static function getEnterprisesInfoById($id){
- return (new Enterprises)->find($id);
- }
- public static function editEnterprisesInfo($info,$id): Enterprises
- {
- return Enterprises::update($info,["id"=>$id]);
- }
- public static function addEnterprises($info): bool
- {
- return (new Enterprises)->save($info);
- }
- public static function delEnterprises($id): bool
- {
- return Enterprises::destroy($id);
- }
- }
|