Explorar el Código

地址列表 分类 获取服务商

moonsflyer hace 8 meses
padre
commit
b457654330

+ 1 - 0
app/adminapi/validate/LoginValidate.php

@@ -91,6 +91,7 @@ class LoginValidate extends BaseValidate
         }
 
         $passwordSalt = Config::get('project.unique_identification');
+
         if ($adminInfo['password'] !== create_password($password, $passwordSalt)) {
             $adminAccountSafeCache->record();
             return '密码错误';

+ 31 - 3
app/api/controller/ServiceController.php

@@ -14,9 +14,9 @@
 
 namespace app\api\controller;
 
-use app\api\lists\article\ArticleLists;
 use app\api\logic\UserGoodsLogic;
-use app\api\validate\{ServiceValidate, UserGoodsValidate,};
+use app\common\logic\PaymentLogic;
+use app\api\validate\{PayValidate, ServiceValidate, UserGoodsValidate};
 use app\api\logic\ServiceLogic;
 use app\api\lists\service\ServiceLists;
 
@@ -29,7 +29,7 @@ use app\api\lists\service\ServiceLists;
 class ServiceController extends BaseApiController
 {
 
-    public array $notNeedLogin = ['getServiceList'];
+    public array $notNeedLogin = ['getServiceList','getAreaList','getCateList'];
 
 
     /**
@@ -71,7 +71,18 @@ class ServiceController extends BaseApiController
 
     }
 
+    public function getAreaList(){
+        $get = $this->request->get();
+        $result = ServiceLogic::getsAreaLists($get);
+        return $this->data($result);
+    }
+
+    public function getCateList(){
 
+        $params = (new ServiceValidate())->get()->goCheck('cate');
+        $result = ServiceLogic::getsCateLists($params);
+        return $this->data($result);
+    }
     /**
      * @notes 服务商列表
      * @return \think\response\Json
@@ -82,4 +93,21 @@ class ServiceController extends BaseApiController
     {
         return $this->dataLists(new ServiceLists());
     }
+
+    /**
+     * @notes 查询服务商信息
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/9/7 15:38
+     */
+    public function getServiceInfo()
+    {
+
+        $params = (new ServiceValidate())->get()->goCheck('info');
+        $result = ServiceLogic::getInfo($params,$this->userId);
+        if ($result === false) {
+            return $this->fail(PaymentLogic::getError());
+        }
+        return $this->data($result);
+    }
 }

+ 11 - 4
app/api/lists/service/ServiceLists.php

@@ -55,9 +55,16 @@ class ServiceLists extends BaseApiDataLists implements ListsSearchInterface
     {
         $where[] = ['status', '=', 1];
         $where[] = ['expiration_time', '>=', time()];
-//        if (!empty($this->params['keyword'])) {
-//            $where[] = ['title', 'like', '%' . $this->params['keyword'] . '%'];
-//        }
+        if (!empty($this->params['cate_id'])) {
+
+            $where[] = ['cate_id', 'like', '%' . ',' .$this->params['cate_id'].',' . '%'];
+        }
+
+        if (!empty($this->params['area_id'])) {
+
+            $where[] = ['area_id', 'like', '%' . ',' .$this->params['area_id'].',' . '%'];
+        }
+
         return $where;
     }
 
@@ -80,7 +87,7 @@ class ServiceLists extends BaseApiDataLists implements ListsSearchInterface
             ->where($this->queryWhere())
             ->where($this->searchWhere)
             ->orderRaw($orderRaw)
-            ->append(['type_desc'])
+            ->append(['type_desc','cate_desc','area_desc'])
             ->limit($this->limitOffset, $this->limitLength)
             ->select()->toArray();
 

+ 51 - 48
app/api/logic/ServiceLogic.php

@@ -27,7 +27,9 @@ use app\common\service\{
     wechat\WeChatRequestService
 };
 use app\common\model\agricultural_machinery\UserService;
+use app\common\model\agricultural_machinery\ServiceCategory;
 use app\common\model\ServiceCharge;
+use app\common\model\asset\AssetArea;
 use app\common\model\recharge\RechargeOrder;
 use app\common\model\user\{User, UserAuth};
 use think\facade\{Db, Config};
@@ -51,10 +53,6 @@ class ServiceLogic extends BaseLogic
     {
         Db::startTrans();
         try {
-//            $userSn = User::createUserSn();
-//            $passwordSalt = Config::get('project.unique_identification');
-//            $password = create_password($params['password'], $passwordSalt);
-//            $avatar = ConfigService::get('default_image', 'user_avatar');
 
             $result = UserService::create([
                 'user_id' => $params['user_id'],
@@ -63,8 +61,8 @@ class ServiceLogic extends BaseLogic
                 'mobile' => $params['mobile'],
                 'agricultural_machinery_model' =>$params['agricultural_machinery_model'],
                 'images' => $params['images'],
-                'cate_id' => $params['cate_id'],
-                'area_id' => $params['area_id'],
+                'cate_id' => ','.$params['cate_id'].',',
+                'area_id' => ','.$params['area_id'].',',
                 'money' => $params['money'],
                 'content'=>$params['content']
             ]);
@@ -75,10 +73,10 @@ class ServiceLogic extends BaseLogic
                     case 1 :
                         $order_money =$service_fee['agricultural_machinery_service_fee'];
                         break;
-                    case 1 :
+                    case 2 :
                         $order_money =$service_fee['bake_service_fee'];
                         break;
-                    case 1 :
+                    case 3 :
                         $order_money =$service_fee['air_control_service_fee'];
                         break;
                 }
@@ -109,45 +107,38 @@ class ServiceLogic extends BaseLogic
 
 
     /**
-     * @notes 账号/手机号登录,手机号验证码
+     * @notes
      * @param $params
      * @return array|false
      * @author 段誉
      * @date 2022/9/6 19:26
      */
-    public static function login($params)
+    public static function getInfo($params,$user_id)
     {
         try {
-            // 账号/手机号 密码登录
-            $where = ['account|mobile' => $params['account']];
-            if ($params['scene'] == LoginEnum::MOBILE_CAPTCHA) {
-                //手机验证码登录
-                $where = ['mobile' => $params['account']];
-            }
 
-            $user = User::where($where)->findOrEmpty();
-            if ($user->isEmpty()) {
-                throw new \Exception('用户不存在');
+            $where = [];
+            $where[]=['user_id','=',$user_id];
+            $where[]=['type','=',$params['type']];
+
+            $serviceInfo = UserService::where($where)->findOrEmpty();
+
+            if($serviceInfo->isEmpty()){
+                $status = -1;
+            }else{
+                if($serviceInfo['status'] == 0){
+                    $status = 0;
+                }else if($serviceInfo['status'] == 2){
+                    $status = 2;
+                }else{
+                    $status = 1;
+                }
             }
 
-            //更新登录信息
-            $user->login_time = time();
-            $user->login_ip = request()->ip();
-            $user->save();
-
-            //设置token
-            $userInfo = UserTokenService::setToken($user->id, $params['terminal']);
-
-            //返回登录信息
-            $avatar = $user->avatar ?: Config::get('project.default_image.user_avatar');
-            $avatar = FileService::getFileUrl($avatar);
 
             return [
-                'nickname' => $userInfo['nickname'],
-                'sn' => $userInfo['sn'],
-                'mobile' => $userInfo['mobile'],
-                'avatar' => $avatar,
-                'token' => $userInfo['token'],
+                'status' => $status,
+                'info' => $serviceInfo,
             ];
         } catch (\Exception $e) {
             self::setError($e->getMessage());
@@ -157,27 +148,39 @@ class ServiceLogic extends BaseLogic
 
 
     /**
-     * @notes 退出登录
-     * @param $userInfo
-     * @return bool
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
+     * @notes 地址列表
      * @author 段誉
      * @date 2022/9/16 17:56
      */
-    public static function logout($userInfo)
+    public static function getsAreaLists($get)
     {
-        //token不存在,不注销
-        if (!isset($userInfo['token'])) {
-            return false;
+         $where=[];
+         $where[]=['status','=',1];
+         if(isset($get['title'])){
+             $where[]=['title','like','%'.$get['title'].'%'];
+         }
+         $area_list = AssetArea::where($where)->field('id,title')->order('sort desc,id asc')->select()->toArray();
+
+        return $area_list;
+    }
+    /**
+     * @notes 地址列表
+     * @author 段誉
+     * @date 2022/9/16 17:56
+     */
+    public static function getsCateLists($get)
+    {
+        $where=[];
+        $where[]=['type','=',$get['type']];
+        $where[]=['status','=',1];
+        if(isset($get['name'])){
+            $where[]=['name','like','%'.$get['name'].'%'];
         }
+        $cate_list = ServiceCategory::where($where)->field('id,name')->order('sort desc,id asc')->select()->toArray();
 
-        //设置token过期
-        return UserTokenService::expireToken($userInfo['token']);
+        return $cate_list;
     }
 
-
     /**
      * @notes 获取微信请求code的链接
      * @param string $url

+ 2 - 2
app/api/validate/ServiceValidate.php

@@ -68,8 +68,8 @@ class ServiceValidate extends BaseValidate
     ];
     protected $scene = [
         'agricultural_machinery_operator' => ['name','mobile','type','cate_id','area_id','agricultural_machinery_model','images','money'], //
-        'search' => ['goods_type'], //
-        'check_enroll'=>['c_id'],
+        'info' => ['type'], //
+        'cate'=>['type'],
         'checkFight'=>['fight_id'],
     ];
 

+ 27 - 2
app/common/model/agricultural_machinery/UserService.php

@@ -14,7 +14,9 @@
 
 namespace app\common\model\agricultural_machinery;
 
+use app\common\model\agricultural_machinery\ServiceCategory;
 use app\common\model\BaseModel;
+use app\common\model\asset\AssetArea;
 use think\model\concern\SoftDelete;
 
 /**
@@ -69,15 +71,38 @@ class UserService extends BaseModel
 //        return Article::where(['cid' => $data['id']])->count('id');
     }
 
-    public function getTypeDescArr($value,$data){
+    public function getTypeDescAttr($value,$data){
+        $type = $data['type'];
         $desc = [
             1 => '农机手',
             2 => '烘干服务',
             3 => '飞防服务',
         ];
 
-        return $desc[$data['type']] ?? '未知';
+        return $desc[$type] ?? '';
     }
 
+    public function getCateDescAttr($value,$data){
+       $cate_id_arr = explode(',',$data['cate_id']);
+       $cate_id_arr = array_filter($cate_id_arr);
+       $cateWhere = [];
+       $cateWhere[]=['id','in',$cate_id_arr];
+       $cate_list =  ServiceCategory::where($cateWhere)->field('id,name')->select()->toArray();
+       $cate_arr = array_column($cate_list,'name');
+       $cate_str = implode(',',$cate_arr);
 
+        return['cate_str'=>$cate_str,'cate_arr'=>$cate_list];
+    }
+
+    public function getAreaDescAttr($value,$data){
+        $area_id_arr = explode(',',$data['area_id']);
+        $area_id_arr = array_filter($area_id_arr);
+        $aresWhere = [];
+        $aresWhere[]=['id','in',$area_id_arr];
+        $area_list =  AssetArea::where($aresWhere)->field('id,title')->select()->toArray();
+        $area_arr = array_column($area_list,'title');
+        $area_str = implode(',',$area_arr);
+
+        return['area_str'=>$area_str,'area_arr'=>$area_list];
+    }
 }