PropertyOrderLogic.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\api\logic;
  15. use app\adminapi\logic\property\PropertyUserLogic;
  16. use app\common\model\property\PropertyOrder;
  17. use app\common\logic\BaseLogic;
  18. use think\Exception;
  19. use think\facade\Db;
  20. use think\facade\Log;
  21. /**
  22. * PropertyOrder逻辑
  23. * Class PropertyOrderLogic
  24. * @package app\api\logic
  25. */
  26. class PropertyOrderLogic extends BaseLogic
  27. {
  28. /**
  29. * @notes 添加 - 下物业单
  30. * @param array $params
  31. * @return bool
  32. */
  33. public static function add(array $params): bool
  34. {
  35. // 判断户主是否存在 返回户主id
  36. $propertyUserId = PropertyUserLogic::getPropertyUserIdByMobile($params);
  37. Db::startTrans();
  38. try {
  39. PropertyOrder::create([
  40. 'property_head_id' => $params['property_head_id'],
  41. 'property_user_id' => $propertyUserId,
  42. 'remark' => $params['remark']
  43. ]);
  44. Db::commit();
  45. return true;
  46. } catch (\Exception $e) {
  47. Db::rollback();
  48. self::setError($e->getMessage());
  49. return false;
  50. }
  51. }
  52. }