Просмотр исходного кода

add - 物业/户主下单管理,客服后台下单接口

刘观赐 1 год назад
Родитель
Сommit
75e7001671

+ 112 - 0
app/adminapi/controller/property/PropertyHeadController.php

@@ -0,0 +1,112 @@
+<?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\controller\property;
+
+
+use app\adminapi\controller\BaseAdminController;
+use app\adminapi\lists\property\PropertyHeadLists;
+use app\adminapi\logic\property\PropertyHeadLogic;
+use app\adminapi\logic\user\UserLogic;
+use app\adminapi\validate\property\PropertyHeadValidate;
+
+
+/**
+ * PropertyHead控制器
+ * Class PropertyHeadController
+ * @package app\adminapi\controller
+ */
+class PropertyHeadController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/09/19 10:48
+     */
+    public function lists()
+    {
+        return $this->dataLists(new PropertyHeadLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/09/19 10:48
+     */
+    public function add()
+    {
+        $params = (new PropertyHeadValidate())->post()->goCheck('add');
+        $result = PropertyHeadLogic::add($params);
+        if (true === $result) {
+            // 通过手机号查询用户是否注册 - 已注册绑定id ,未注册注册再绑定id
+            $userId = UserLogic::getUserIdByMobile($params['head_mobile']);
+            PropertyHeadLogic::updateUserId($params['head_mobile'],$userId);
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(PropertyHeadLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/09/19 10:48
+     */
+    public function edit()
+    {
+        $params = (new PropertyHeadValidate())->post()->goCheck('edit');
+        $result = PropertyHeadLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(PropertyHeadLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/09/19 10:48
+     */
+    public function delete()
+    {
+        $params = (new PropertyHeadValidate())->post()->goCheck('delete');
+        PropertyHeadLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/09/19 10:48
+     */
+    public function detail()
+    {
+        $params = (new PropertyHeadValidate())->goCheck('detail');
+        $result = PropertyHeadLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+}

+ 130 - 0
app/adminapi/controller/property/PropertyOrderController.php

@@ -0,0 +1,130 @@
+<?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\controller\property;
+
+
+use app\adminapi\controller\BaseAdminController;
+use app\adminapi\lists\property\PropertyOrderLists;
+use app\adminapi\logic\property\PropertyOrderLogic;
+use app\adminapi\validate\property\PropertyOrderValidate;
+use app\api\validate\ServiceOrderValidate;
+
+
+/**
+ * PropertyOrder控制器
+ * Class PropertyOrderController
+ * @package app\adminapi\controller
+ */
+class PropertyOrderController extends BaseAdminController
+{
+    public array $notNeedLogin = ['placeOrder'];
+
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/09/19 14:48
+     */
+    public function lists()
+    {
+        return $this->dataLists(new PropertyOrderLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/09/19 14:48
+     */
+    public function add()
+    {
+        $params = (new PropertyOrderValidate())->post()->goCheck('add');
+        $result = PropertyOrderLogic::add($params);
+        if (true === $result) {
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(PropertyOrderLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/09/19 14:48
+     */
+    public function edit()
+    {
+        $params = (new PropertyOrderValidate())->post()->goCheck('edit');
+        $result = PropertyOrderLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(PropertyOrderLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/09/19 14:48
+     */
+    public function delete()
+    {
+        $params = (new PropertyOrderValidate())->post()->goCheck('delete');
+        PropertyOrderLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/09/19 14:48
+     */
+    public function detail()
+    {
+        $params = (new PropertyOrderValidate())->goCheck('detail');
+        $result = PropertyOrderLogic::detail($params);
+        return $this->data($result);
+    }
+
+    /**
+     * @notes 客服下工单
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/09/19 14:48
+     */
+    public function placeOrder()
+    {
+        $serviceOrderParams = (new ServiceOrderValidate())->post()->goCheck('add');
+        if (empty($serviceOrderParams['id'])){
+            return $this->fail('物业单id不能为空');
+        }
+        $result = PropertyOrderLogic::placeOrder($serviceOrderParams);
+        if (true === $result) {
+            return $this->success('客服下单成功', [], 1, 1);
+        }
+        return $this->fail(PropertyOrderLogic::getError());
+    }
+
+
+
+}

+ 108 - 0
app/adminapi/controller/property/PropertyUserController.php

@@ -0,0 +1,108 @@
+<?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\controller\property;
+
+
+use app\adminapi\controller\BaseAdminController;
+use app\adminapi\lists\property\PropertyUserLists;
+use app\adminapi\logic\property\PropertyUserLogic;
+use app\adminapi\validate\property\PropertyUserValidate;
+
+
+/**
+ * PropertyUser控制器
+ * Class PropertyUserController
+ * @package app\adminapi\controller
+ */
+class PropertyUserController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/09/19 14:35
+     */
+    public function lists()
+    {
+        return $this->dataLists(new PropertyUserLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/09/19 14:35
+     */
+    public function add()
+    {
+        $params = (new PropertyUserValidate())->post()->goCheck('add');
+        $result = PropertyUserLogic::add($params);
+        if (true === $result) {
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(PropertyUserLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/09/19 14:35
+     */
+    public function edit()
+    {
+        $params = (new PropertyUserValidate())->post()->goCheck('edit');
+        $result = PropertyUserLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(PropertyUserLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/09/19 14:35
+     */
+    public function delete()
+    {
+        $params = (new PropertyUserValidate())->post()->goCheck('delete');
+        PropertyUserLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/09/19 14:35
+     */
+    public function detail()
+    {
+        $params = (new PropertyUserValidate())->goCheck('detail');
+        $result = PropertyUserLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+}

+ 78 - 0
app/adminapi/lists/property/PropertyHeadLists.php

@@ -0,0 +1,78 @@
+<?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\lists\property;
+
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\property\PropertyHead;
+use app\common\lists\ListsSearchInterface;
+
+
+/**
+ * PropertyHead列表
+ * Class PropertyHeadLists
+ * @package app\adminapi\lists
+ */
+class PropertyHeadLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/09/19 10:48
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['property_name', 'village_name', 'address', 'head_name', 'head_mobile', 'commission_rules', 'head_bank_card', 'remark', 'user_id', 'all_profit_amount', 'surplus_profit_amount', 'extract_profit_amount'],
+
+        ];
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/09/19 10:48
+     */
+    public function lists(): array
+    {
+        return PropertyHead::where($this->searchWhere)
+            ->field(['id', 'property_name', 'village_name', 'address', 'head_name', 'head_mobile', 'commission_rules', 'head_bank_card', 'remark', 'user_id', 'all_profit_amount', 'surplus_profit_amount', 'extract_profit_amount'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/09/19 10:48
+     */
+    public function count(): int
+    {
+        return PropertyHead::where($this->searchWhere)->count();
+    }
+
+}

+ 78 - 0
app/adminapi/lists/property/PropertyOrderLists.php

@@ -0,0 +1,78 @@
+<?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\lists\property;
+
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\property\PropertyOrder;
+use app\common\lists\ListsSearchInterface;
+
+
+/**
+ * PropertyOrder列表
+ * Class PropertyOrderLists
+ * @package app\adminapi\lists
+ */
+class PropertyOrderLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/09/19 14:48
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['property_head_id', 'property_user_id', 'remark', 'order_status', 'work_id'],
+
+        ];
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/09/19 14:48
+     */
+    public function lists(): array
+    {
+        return PropertyOrder::where($this->searchWhere)
+            ->field(['id', 'property_head_id', 'property_user_id', 'remark', 'order_status', 'work_id'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/09/19 14:48
+     */
+    public function count(): int
+    {
+        return PropertyOrder::where($this->searchWhere)->count();
+    }
+
+}

+ 78 - 0
app/adminapi/lists/property/PropertyUserLists.php

@@ -0,0 +1,78 @@
+<?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\lists\property;
+
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\property\PropertyUser;
+use app\common\lists\ListsSearchInterface;
+
+
+/**
+ * PropertyUser列表
+ * Class PropertyUserLists
+ * @package app\adminapi\lists
+ */
+class PropertyUserLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/09/19 14:35
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['property_head_id', 'householder_name', 'householder_mobile', 'address', 'user_id'],
+
+        ];
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/09/19 14:35
+     */
+    public function lists(): array
+    {
+        return PropertyUser::where($this->searchWhere)
+            ->field(['id', 'property_head_id', 'householder_name', 'householder_mobile', 'address', 'user_id'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/09/19 14:35
+     */
+    public function count(): int
+    {
+        return PropertyUser::where($this->searchWhere)->count();
+    }
+
+}

+ 135 - 0
app/adminapi/logic/property/PropertyHeadLogic.php

@@ -0,0 +1,135 @@
+<?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\property;
+
+
+use app\common\model\property\PropertyHead;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * PropertyHead逻辑
+ * Class PropertyHeadLogic
+ * @package app\adminapi\logic
+ */
+class PropertyHeadLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/09/19 10:48
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            PropertyHead::create([
+                'property_name' => $params['property_name'],
+                'village_name' => $params['village_name'],
+                'address' => $params['address'],
+                'head_name' => $params['head_name'],
+                'head_mobile' => $params['head_mobile'],
+                'commission_rules' => $params['commission_rules'],
+                'head_bank_card' => $params['head_bank_card'],
+                'remark' => $params['remark']
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 编辑
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/09/19 10:48
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            PropertyHead::where('id', $params['id'])->update([
+                'property_name' => $params['property_name'],
+                'village_name' => $params['village_name'],
+                'address' => $params['address'],
+                'head_name' => $params['head_name'],
+                'head_mobile' => $params['head_mobile'],
+                'commission_rules' => $params['commission_rules'],
+                'head_bank_card' => $params['head_bank_card'],
+                'remark' => $params['remark']
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 删除
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/09/19 10:48
+     */
+    public static function delete(array $params): bool
+    {
+        return PropertyHead::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2024/09/19 10:48
+     */
+    public static function detail($params): array
+    {
+        return PropertyHead::findOrEmpty($params['id'])->toArray();
+    }
+
+    public static function updateUserId(string $head_mobile,int $userId): bool
+    {
+        Db::startTrans();
+        try {
+            PropertyHead::where('head_mobile', $head_mobile)->update(['user_id' => $userId]);
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+}

+ 206 - 0
app/adminapi/logic/property/PropertyOrderLogic.php

@@ -0,0 +1,206 @@
+<?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\property;
+
+
+use app\adminapi\logic\user\UserLogic;
+use app\api\logic\ServiceOrderLogic;
+use app\common\logic\PaymentLogic;
+use app\common\model\property\PropertyOrder;
+use app\common\logic\BaseLogic;
+use think\Exception;
+use think\facade\Db;
+use think\facade\Log;
+
+
+/**
+ * PropertyOrder逻辑
+ * Class PropertyOrderLogic
+ * @package app\adminapi\logic
+ */
+class PropertyOrderLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/09/19 14:48
+     */
+    public static function add(array $params): bool
+    {
+        // 判断户主是否存在 返回户主id
+        $propertyUserId = PropertyUserLogic::getPropertyUserIdByMobile($params);
+        Db::startTrans();
+        try {
+            PropertyOrder::create([
+                'property_head_id' => $params['property_head_id'],
+                'property_user_id' => $propertyUserId,
+                'remark' => $params['remark']
+            ]);
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 编辑
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/09/19 14:48
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            $upData = ['remark' => $params['remark']];
+            if($params['order_status'] == 2){
+                $upData['order_status'] = $params['order_status'];
+            }
+            PropertyOrder::where('id', $params['id'])->update($upData);
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 删除
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/09/19 14:48
+     */
+    public static function delete(array $params): bool
+    {
+        return PropertyOrder::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2024/09/19 14:48
+     */
+    public static function detail($params): array
+    {
+        return PropertyOrder::findOrEmpty($params['id'])->toArray();
+    }
+
+
+    /**
+     * @notes 客服下单
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/09/19 14:48
+     */
+    public static function placeOrder(array $params): bool
+    {
+        // 客服手动下单
+        /*
+            1. 按照用户原预约下单参数创建 工单
+            2. 由 工单id 状态-已接单 更新当前订单状态信息
+            // 订单状态:0=未接单,1=已接单,2=取消单,3=已完结
+        */
+
+        $orderInfo = PropertyOrder::where('id', $params['id'])->findOrEmpty()->toArray();
+        $propertyUserInfo = PropertyUserLogic::detail(['id'=>$orderInfo['property_user_id']]);
+        $userInfo = UserLogic::detail($propertyUserInfo['user_id']);
+        if($orderInfo['order_status'] != 0){
+            self::setError('当前订单状态不允许操作');
+            return false;
+        }
+        Db::startTrans();
+        try {
+
+            if($orderInfo['work_id'] == 0 && $orderInfo['order_status'] == 0){
+                /*// 'address','appointment_time','pay_way','goods_id','contact_number','contact_people'
+                'sn.require' => '订单编号错误',
+                'address.require' => '请填写地址',
+                'appointment_time.require' => '请填写预约上门时间',
+                'appointment_time.dateFormat' => '预约上门时间格式错误',
+                'pay_way.require' => '请选择支付方式',
+                'goods_id.require' => '订单商品不存在',
+                'contact_number.require' => '联系电话不存在',
+                'contact_people.require' => '联系人不存在',*/
+                $serviceOrderParams = array_merge($params,[
+                    'user_id' => $propertyUserInfo['user_id'],
+                    'terminal' => 4,
+                    'user_info' => ['mobile'=>$userInfo['mobile']]
+                ]);
+                Log::write(json_encode($serviceOrderParams,JSON_UNESCAPED_UNICODE));
+                $result = ServiceOrderLogic::submitOrder($serviceOrderParams);
+                if($result === false){
+                    throw new Exception(PropertyOrderLogic::getError());
+                }
+                // $result['order_id'] $result['work_id']
+                $upData = [];
+                if(isset($result['work_id']) && !empty($result['work_id'])){
+                    $upData['work_id'] = $result['work_id'];
+                    $upData['order_status'] = 1;
+                }
+                if($upData){
+                    $propertyOrder =  PropertyOrder::where('id', $params['id'])->update($upData);
+                }
+                if($propertyOrder){
+                    //订单信息  pay_way=2 goods  order_id
+                    $params['from'] = 'goods';
+                    $order = PaymentLogic::getPayOrderInfo(['order_id'=>$result['order_id']]);
+                    Log::info('ServiceOrder:',$result);
+                    if (false === $order) {
+                        Log::info(PaymentLogic::getError());
+                        return false;
+                        //throw new Exception(PaymentLogic::getError());
+                    }
+                    if ($order['order_amount'] == 0) {
+                        //0元时自动支付
+                        $redirectUrl = $params['redirect'] ?? '/pages/payment/payment';
+                        PaymentLogic::pay($params['pay_way'], $params['from'], $order, 4, $redirectUrl);
+                    }
+                }
+            }
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+
+
+
+
+
+
+}

+ 136 - 0
app/adminapi/logic/property/PropertyUserLogic.php

@@ -0,0 +1,136 @@
+<?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\property;
+
+
+use app\adminapi\logic\user\UserLogic;
+use app\api\logic\LoginLogic;
+use app\common\model\property\PropertyUser;
+use app\common\logic\BaseLogic;
+use app\common\model\user\User;
+use think\facade\Db;
+
+
+/**
+ * PropertyUser逻辑
+ * Class PropertyUserLogic
+ * @package app\adminapi\logic
+ */
+class PropertyUserLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/09/19 14:35
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            PropertyUser::create([
+                'property_head_id' => $params['property_head_id'],
+                'householder_name' => $params['householder_name'],
+                'householder_mobile' => $params['householder_mobile'],
+                'address' => $params['address'],
+                'user_id' => $params['user_id'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 编辑
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/09/19 14:35
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            PropertyUser::where('id', $params['id'])->update([
+                'property_head_id' => $params['property_head_id'],
+                'householder_name' => $params['householder_name'],
+                'householder_mobile' => $params['householder_mobile'],
+                'address' => $params['address'],
+                'user_id' => $params['user_id'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 删除
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/09/19 14:35
+     */
+    public static function delete(array $params): bool
+    {
+        return PropertyUser::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2024/09/19 14:35
+     */
+    public static function detail($params): array
+    {
+        return PropertyUser::findOrEmpty($params['id'])->toArray();
+    }
+
+
+    public static function getPropertyUserIdByMobile(array $params)
+    {
+        $propertyUser = PropertyUser::where(['householder_mobile' => $params['householder_mobile']])->findOrEmpty();
+        if ($propertyUser->isEmpty()) {
+            //注册用户
+            $userId = UserLogic::getUserIdByMobile($params['householder_mobile']);
+            $propertyUser = PropertyUser::create([
+                'property_head_id' => $params['property_head_id'],
+                'householder_name' => $params['householder_name'],
+                'householder_mobile' => $params['householder_mobile'],
+                'address' => $params['address']??'',
+                'user_id' => $userId??0,
+            ]);
+        }
+        return $propertyUser->id;
+    }
+
+}

+ 22 - 0
app/adminapi/logic/user/UserLogic.php

@@ -13,6 +13,7 @@
 // +----------------------------------------------------------------------
 // +----------------------------------------------------------------------
 namespace app\adminapi\logic\user;
 namespace app\adminapi\logic\user;
 
 
+use app\api\logic\LoginLogic;
 use app\common\enum\user\AccountLogEnum;
 use app\common\enum\user\AccountLogEnum;
 use app\common\enum\user\UserTerminalEnum;
 use app\common\enum\user\UserTerminalEnum;
 use app\common\logic\AccountLogLogic;
 use app\common\logic\AccountLogLogic;
@@ -116,4 +117,25 @@ class UserLogic extends BaseLogic
         }
         }
     }
     }
 
 
+    public static function getUserIdByMobile(string $mobile)
+    {
+        $user = User::where(['mobile' => $mobile])->findOrEmpty();
+        if ($user->isEmpty()) {
+            //注册用户
+            $params['account'] = $mobile;
+            $params['mobile'] = $mobile;
+            $params['channel'] = 4;
+            $params['user_type'] = 2;
+            $user = LoginLogic::register($params);
+        }
+        return $user->id;
+    }
+
+
+
+
+
+
+
+
 }
 }

+ 108 - 0
app/adminapi/validate/property/PropertyHeadValidate.php

@@ -0,0 +1,108 @@
+<?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\validate\property;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * PropertyHead验证器
+ * Class PropertyHeadValidate
+ * @package app\adminapi\validate
+ */
+class PropertyHeadValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'property_name' => 'require',
+        'village_name' => 'require',
+        'address' => 'require',
+        'head_name' => 'require',
+        'head_mobile' => 'require',
+        'commission_rules' => 'require',
+        'head_bank_card' => 'require',
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'property_name' => '物业名称',
+        'village_name' => '小区名称',
+        'address' => '小区地址',
+        'head_name' => '负责人名称',
+        'head_mobile' => '负责人手机号/电话',
+        'commission_rules' => '提成规则json',
+        'head_bank_card' => '负责人银行卡号',
+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return PropertyHeadValidate
+     * @author likeadmin
+     * @date 2024/09/19 10:48
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['property_name','village_name','address','head_name','head_mobile','commission_rules','head_bank_card']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return PropertyHeadValidate
+     * @author likeadmin
+     * @date 2024/09/19 10:48
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','property_name','village_name','address','head_name','head_mobile','commission_rules','head_bank_card']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return PropertyHeadValidate
+     * @author likeadmin
+     * @date 2024/09/19 10:48
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return PropertyHeadValidate
+     * @author likeadmin
+     * @date 2024/09/19 10:48
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 101 - 0
app/adminapi/validate/property/PropertyOrderValidate.php

@@ -0,0 +1,101 @@
+<?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\validate\property;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * PropertyOrder验证器
+ * Class PropertyOrderValidate
+ * @package app\adminapi\validate
+ */
+class PropertyOrderValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'property_head_id' => 'require',
+        'householder_name' => 'require',
+        'householder_mobile' => 'require',
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'property_head_id' => '物业负责人ID',
+        'householder_name' => '户主名称',
+        'householder_mobile' => '户主手机号',
+
+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return PropertyOrderValidate
+     * @author likeadmin
+     * @date 2024/09/19 14:48
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['property_head_id','user_name','user_mobile']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return PropertyOrderValidate
+     * @author likeadmin
+     * @date 2024/09/19 14:48
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','property_head_id','user_name','user_mobile']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return PropertyOrderValidate
+     * @author likeadmin
+     * @date 2024/09/19 14:48
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return PropertyOrderValidate
+     * @author likeadmin
+     * @date 2024/09/19 14:48
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 106 - 0
app/adminapi/validate/property/PropertyUserValidate.php

@@ -0,0 +1,106 @@
+<?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\validate\property;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * PropertyUser验证器
+ * Class PropertyUserValidate
+ * @package app\adminapi\validate
+ */
+class PropertyUserValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'property_head_id' => 'require',
+        'householder_name' => 'require',
+        'householder_mobile' => 'require',
+        'address' => 'require',
+        'user_id' => 'require',
+
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'property_head_id' => '物业负责人ID',
+        'householder_name' => '户主人名称',
+        'householder_mobile' => '户主手机号/电话',
+        'address' => '详细地址',
+        'user_id' => '注册用户ID',
+
+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return PropertyUserValidate
+     * @author likeadmin
+     * @date 2024/09/19 14:35
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['property_head_id','householder_name','householder_mobile','address','user_id']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return PropertyUserValidate
+     * @author likeadmin
+     * @date 2024/09/19 14:35
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','property_head_id','householder_name','householder_mobile','address','user_id']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return PropertyUserValidate
+     * @author likeadmin
+     * @date 2024/09/19 14:35
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return PropertyUserValidate
+     * @author likeadmin
+     * @date 2024/09/19 14:35
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 1 - 0
app/api/logic/LoginLogic.php

@@ -58,6 +58,7 @@ class LoginLogic extends BaseLogic
             'mobile' => !empty($params['mobile'])?$params['mobile']:'',
             'mobile' => !empty($params['mobile'])?$params['mobile']:'',
             'password' => $password,
             'password' => $password,
             'channel' => $params['channel'],
             'channel' => $params['channel'],
+            'user_type' => $params['user_type']??0,
         ]);
         ]);
 
 
         return $user;
         return $user;

+ 1 - 0
app/api/logic/ServiceOrderLogic.php

@@ -168,6 +168,7 @@ class ServiceOrderLogic extends BaseLogic
 
 
         return [
         return [
             'order_id' => (int)$order['id'],
             'order_id' => (int)$order['id'],
+            'work_id' => (int)$order['work_id'],
         ];
         ];
     }
     }
 
 

+ 34 - 0
app/common/model/property/PropertyHead.php

@@ -0,0 +1,34 @@
+<?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\common\model\property;
+
+
+use app\common\model\BaseModel;
+
+
+
+/**
+ * PropertyHead模型
+ * Class PropertyHead
+ * @package app\common\model
+ */
+class PropertyHead extends BaseModel
+{
+    
+    protected $name = 'property_head';
+    
+
+    
+}

+ 34 - 0
app/common/model/property/PropertyOrder.php

@@ -0,0 +1,34 @@
+<?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\common\model\property;
+
+
+use app\common\model\BaseModel;
+
+
+
+/**
+ * PropertyOrder模型
+ * Class PropertyOrder
+ * @package app\common\model
+ */
+class PropertyOrder extends BaseModel
+{
+    
+    protected $name = 'property_order';
+    
+
+    
+}

+ 34 - 0
app/common/model/property/PropertyUser.php

@@ -0,0 +1,34 @@
+<?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\common\model\property;
+
+
+use app\common\model\BaseModel;
+
+
+
+/**
+ * PropertyUser模型
+ * Class PropertyUser
+ * @package app\common\model
+ */
+class PropertyUser extends BaseModel
+{
+    
+    protected $name = 'property_user';
+    
+
+    
+}

+ 3 - 1
app/common/model/works/ServiceWork.php

@@ -31,7 +31,9 @@ class ServiceWork extends BaseModel
 {
 {
     
     
     protected $name = 'service_work';
     protected $name = 'service_work';
-
+    protected $type = [
+        'goods_category_ids' =>  'array',
+    ];
     public static function onAfterUpdate($model)
     public static function onAfterUpdate($model)
     {
     {
         if($model->user_confirm_status == 5 and $model->work_status == 7 and $model->work_pay_status==1){
         if($model->user_confirm_status == 5 and $model->work_status == 7 and $model->work_pay_status==1){