1
0

GroupOrderLogic.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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\adminapi\logic\group_activity;
  15. use think\facade\Queue;
  16. use app\common\logic\BaseLogic;
  17. use app\common\model\user\User;
  18. use app\common\model\equity\EquityConfig;
  19. use app\common\model\group_activity\GroupOrder;
  20. use app\common\model\group_activity\GroupActivity;
  21. use app\common\model\group_activity\GroupUserOrder;
  22. /**
  23. * 拼团订单
  24. * Class GroupOrderLogic
  25. * @package app\adminapi\logic\group_activity
  26. */
  27. class GroupOrderLogic extends BaseLogic
  28. {
  29. /**
  30. * @notes 获取拼团订单详情
  31. * @param $params
  32. * @return array
  33. * @author likeadmin
  34. * @date 2025/03/13 10:31
  35. */
  36. public static function detail($params): array
  37. {
  38. $detail = GroupOrder::findOrEmpty($params['id'])->toArray();
  39. if ($detail) {
  40. //团长信息
  41. $detail['user'] = User::where('id', $detail['user_id'])->field('id,mobile')->findOrEmpty()->toArray();
  42. $detail['activity'] = GroupActivity::where('id', $detail['group_activity_id'])->findOrEmpty()->toArray();
  43. $detail['goods'] = EquityConfig::where('id', $detail['equity_id'])->findOrEmpty()->toArray();
  44. $detail['users'] = GroupUserOrder::alias('a')->leftJoin('user b','a.user_id=b.id')
  45. ->where('group_order_id', $detail['id'])
  46. ->field('a.*,b.mobile')
  47. ->select()->toArray();
  48. $detail['end_time'] = date('Y-m-d H:i:s',$detail['end_time']);
  49. }
  50. return $detail;
  51. }
  52. /**
  53. * @notes 生成服务工单
  54. * @return array
  55. * @throws \think\db\exception\DataNotFoundException
  56. * @throws \think\db\exception\DbException
  57. * @throws \think\db\exception\ModelNotFoundException
  58. */
  59. public static function changeWorkStatus($params)
  60. {
  61. $detail = GroupOrder::findOrEmpty($params['id']);
  62. if (!$detail->isEmpty() && $detail->work_status == 0 && $detail->status == 1) {
  63. //$detail->work_status = 1;
  64. //$detail->save();
  65. // 异步调用 changeWorkStatus 方法
  66. Queue::push(\app\job\AddServiceWorkJob::class, ['id' => $params['id']]);
  67. }
  68. return $detail->toArray();
  69. }
  70. }