wang jun 2 years ago
parent
commit
d398a18715

+ 3 - 3
application/admin/logic/MealLogic.php

@@ -206,7 +206,7 @@ class MealLogic
         if ($count <= 0) {
             return backarr(0, "无数据");
         }
-        $totalpage = ceil($count / $size);
+        $totalpage = ceil((int) $count / $size);
         $page > $totalpage && $page = $totalpage;
         $field = ['m.*', 'mc.name_center'];
         $list = $m_m->getListJoinCenter($where, $field, $page, $size);
@@ -473,7 +473,7 @@ class MealLogic
         if ($count <= 0) {
             return backarr(0, "无数据");
         }
-        $totalpage = ceil($count / $size);
+        $totalpage = ceil((int) $count / $size);
         $page > $totalpage && $page = $totalpage;
         $list = $m_mc->getListJoinInfo($where, '*', $page, $size);
         $data = [
@@ -522,7 +522,7 @@ class MealLogic
         if ($count <= 0) {
             return backarr(0, "无数据");
         }
-        $totalpage = ceil($count / $size);
+        $totalpage = ceil((int) $count / $size);
         $page > $totalpage && $page = $totalpage;
         $field = ['cb.*', 'mc.name_center'];
         $list = $m_cb->getListjoinMC($where, $field, $page, $size);

+ 25 - 0
application/api/controller/Data.php

@@ -0,0 +1,25 @@
+<?php
+namespace app\api\controller;
+
+use app\api\logic\DataLogic;
+
+class Data
+{
+    /**
+     * 获取招聘类型列表
+     *
+     * @return void
+     * @author wj
+     * @date 2022-12-09
+     */
+    public function getetlist()
+    {
+        $post = request()->post();
+        $l_d = new DataLogic();
+        $result = $l_d->getetlist($post);
+        if (empty($result['status'])) {
+            return backjson2(0, $result['msg']);
+        }
+        return backjson2(200, $result['msg'], $result['data']);
+    }
+}

+ 18 - 0
application/api/controller/User.php

@@ -93,4 +93,22 @@ class User
         }
         return backjson2(200, $result['msg'], $result['data']);
     }
+
+    /**
+     * 招聘人员登陆
+     *
+     * @return void
+     * @author wj
+     * @date 2022-12-09
+     */
+    public function loginforengage()
+    {
+        $post = request()->post();
+        $l_u = new UserLogic();
+        $result = $l_u->loginforengage($post);
+        if (empty($result['status'])) {
+            return backjson2(0, $result['msg']);
+        }
+        return backjson2(200, $result['msg'], $result['data']);
+    }
 }

+ 27 - 0
application/api/logic/DataLogic.php

@@ -0,0 +1,27 @@
+<?php
+namespace app\api\logic;
+
+use app\common\model\EngageTypeModel;
+
+/**
+ * 获取项目相关数据
+ *
+ * @author wj
+ * @date 2022-12-09
+ */
+class DataLogic
+{
+    /**
+     * 获取招聘类型列表
+     *
+     * @return void
+     * @author wj
+     * @date 2022-12-09
+     */
+    public function getetlist()
+    {
+        $m_et = new EngageTypeModel();
+        $list = $m_et->getList();
+        return backarr(1, '查询成功', $list, 1, 0, 'id asc');
+    }
+}

+ 88 - 1
application/api/logic/UserLogic.php

@@ -1,6 +1,9 @@
 <?php
 namespace app\api\logic;
 
+use app\common\model\CourierModel;
+use app\common\model\EngageUserModel;
+use app\common\model\MealcenterModel;
 use app\common\model\UserAddressModel;
 use app\common\model\UserModel;
 
@@ -71,7 +74,7 @@ class UserLogic
         $field = ['id', 'phone', 'token'];
         $where = ['id' => $uid];
         $uinfo = $m_u->getInfo($where, $field);
-        return backarr($uinfo, "登录成功", $uinfo);
+        return backarr(1, "登录成功", $uinfo);
     }
     private function checkpasswd($pwd, $hash)
     {
@@ -240,4 +243,88 @@ class UserLogic
         ];
         return backarr(1, "查询成功", $data);
     }
+
+    /**
+     * 招聘人员登陆
+     *
+     * @param  [type] $arr
+     * @return void
+     * @author wj
+     * @date 2022-12-09
+     */
+    public function loginforengage($arr)
+    {
+        $fillfields = ['phone', 'passwd', 'type'];
+        foreach ($fillfields as $key => $value) {
+            if (!isset($arr[$value]) || empty($arr[$value])) {
+                return backarr(0, "参数缺少");
+            }
+        }
+        $m_u = new UserModel();
+        $phone = $arr['phone'];
+        $passwd = $phone . $arr['passwd'];
+        $type = $arr['type'];
+        $where = ['phone' => $phone, 'is_engage' => 1];
+        $uinfo = $m_u->getInfo($where);
+        if (empty($uinfo)) {
+            return backarr(0, "无用户信息");
+        }
+        $uid = $uinfo['id'];
+        $checked = $this->checkpasswd($passwd, $uinfo['passwd']);
+        if (!$checked) {
+            return backarr(0, "密码错误");
+        }
+        //校验type
+        $result = $this->getengageinfo($type, $uid);
+        if (empty($result['status'])) {
+            return backarr(0, $result['msg']);
+        }
+        $engageinfo = $result['data'];
+        $result = $this->changetoken($uid, $phone);
+        if (empty($result['status'])) {
+            return backarr(0, $result['msg']);
+        }
+        $field = ['id', 'phone', 'token'];
+        $where = ['id' => $uid];
+        $uinfo = $m_u->getInfo($where, $field);
+        $uinfo['engageinfo'] = $engageinfo;
+        return backarr(1, "登录成功", $uinfo);
+    }
+    /**
+     * 获取招聘人员信息
+     *
+     * @return void
+     * @author wj
+     * @date 2022-12-09
+     */
+    public function getengageinfo($type, $userid)
+    {
+        $m_eu = new EngageUserModel();
+        $euwhere = ['user_id' => $userid, 'et_id' => $type];
+        $euinfo = $m_eu->getInfo($euwhere);
+        if (empty($euinfo)) {
+            return backarr(0, "无用户权限");
+        }
+        switch ($type) {
+            case 1:
+                # 套餐配送
+                $m_c = new CourierModel();
+                $cwhere = ['user_id' => $userid];
+                $cinfo = $m_c->getInfo($cwhere);
+                if (empty($cinfo)) {
+                    return backarr(0, "无配送员信息");
+                }
+                if (1 != $cinfo['is_active']) {
+                    return backarr(0, "配送员已被禁用");
+                }
+                $m_mc = new MealcenterModel();
+                $mcinfo = $m_mc->getInfo(['id' => $cinfo['center_id']]);
+                $cinfo['mcinfo'] = $mcinfo;
+                return backarr(1, "配送员已被禁用", $cinfo);
+                break;
+            default:
+                return backarr(0, "类型错误");
+                break;
+        }
+    }
 }

+ 83 - 0
application/common/model/CourierModel.php

@@ -0,0 +1,83 @@
+<?php
+namespace app\common\model;
+
+use think\Model;
+
+class CourierModel extends Model
+{
+    protected $table = "t_courier";
+
+    public function insertData($data)
+    {
+        if (!isset($data['createtime']) || empty($data['createtime']) || !is_string($data['createtime'])) {
+            $data['createtime'] = date("Y-m-d H:i:s");
+        }
+        if (isset($data['id'])) {
+            unset($data['id']);
+        }
+        $data = $this->formatData($data);
+        if (empty($data)) {
+            return false;
+        }
+        $id = $this->insertGetId($data);
+        return $id ? $id : false;
+    }
+
+    /**
+     * 校验入库数据
+     * 20220119
+     */
+    private function formatData($data)
+    {
+        $useData = [];
+        $fields = $this->getTableFields();
+        foreach ($data as $key => $value) {
+            if (in_array($key, $fields)) {
+                $useData[$key] = $value;
+            }
+        }
+        return $useData;
+    }
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            if (empty($size)) {
+                $sqlObj = $sqlObj->field($field)->order($order)->group($group);
+            } else {
+                $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            }
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj->count();
+        }
+        return $data;
+    }
+}

+ 80 - 0
application/common/model/EngageTypeModel.php

@@ -0,0 +1,80 @@
+<?php
+namespace app\common\model;
+
+use think\Model;
+
+class EngageTypeModel extends Model
+{
+    protected $table = "t_engage_type";
+
+    public function insertData($data)
+    {
+        if (isset($data['id'])) {
+            unset($data['id']);
+        }
+        $data = $this->formatData($data);
+        if (empty($data)) {
+            return false;
+        }
+        $id = $this->insertGetId($data);
+        return $id ? $id : false;
+    }
+
+    /**
+     * 校验入库数据
+     * 20220119
+     */
+    private function formatData($data)
+    {
+        $useData = [];
+        $fields = $this->getTableFields();
+        foreach ($data as $key => $value) {
+            if (in_array($key, $fields)) {
+                $useData[$key] = $value;
+            }
+        }
+        return $useData;
+    }
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            if (empty($size)) {
+                $sqlObj = $sqlObj->field($field)->order($order)->group($group);
+            } else {
+                $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            }
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj->count();
+        }
+        return $data;
+    }
+}

+ 80 - 0
application/common/model/EngageUserModel.php

@@ -0,0 +1,80 @@
+<?php
+namespace app\common\model;
+
+use think\Model;
+
+class EngageUserModel extends Model
+{
+    protected $table = "t_engage_user";
+
+    public function insertData($data)
+    {
+        if (isset($data['id'])) {
+            unset($data['id']);
+        }
+        $data = $this->formatData($data);
+        if (empty($data)) {
+            return false;
+        }
+        $id = $this->insertGetId($data);
+        return $id ? $id : false;
+    }
+
+    /**
+     * 校验入库数据
+     * 20220119
+     */
+    private function formatData($data)
+    {
+        $useData = [];
+        $fields = $this->getTableFields();
+        foreach ($data as $key => $value) {
+            if (in_array($key, $fields)) {
+                $useData[$key] = $value;
+            }
+        }
+        return $useData;
+    }
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            if (empty($size)) {
+                $sqlObj = $sqlObj->field($field)->order($order)->group($group);
+            } else {
+                $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            }
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj->count();
+        }
+        return $data;
+    }
+}

+ 6 - 1
application/common/model/MealcookModel.php

@@ -136,7 +136,12 @@ class MealcookModel extends Model
         ];
         $field = ['mc.meal_id', 'mc.center_id', 'mc.week', 'cb.*'];
         $list = $this->getListJoinCB($where, $field, 1, 0);
-        return empty($list) ? [] : $list->toArray();
+        if (is_object($list)) {
+            $list->toArray();
+        } else {
+            $list = [];
+        }
+        return $list;
     }
 
     /**