Prechádzať zdrojové kódy

Merge branch 'master' into wecall_0321

dongxiaoqin 1 rok pred
rodič
commit
7cf7e870e7
30 zmenil súbory, kde vykonal 2006 pridanie a 11 odobranie
  1. 115 0
      app/adminapi/controller/group_activity/GroupActivityController.php
  2. 59 0
      app/adminapi/controller/group_activity/GroupOrderController.php
  3. 43 0
      app/adminapi/controller/group_activity/GroupUserOrderController.php
  4. 84 0
      app/adminapi/lists/group_activity/GroupActivityLists.php
  5. 96 0
      app/adminapi/lists/group_activity/GroupOrderLists.php
  6. 97 0
      app/adminapi/lists/group_activity/GroupUserOrderLists.php
  7. 1 1
      app/adminapi/lists/user/UserLists.php
  8. 191 0
      app/adminapi/logic/group_activity/GroupActivityLogic.php
  9. 55 0
      app/adminapi/logic/group_activity/GroupOrderLogic.php
  10. 118 0
      app/adminapi/validate/group_activity/GroupActivityValidate.php
  11. 69 0
      app/adminapi/validate/group_activity/GroupOrderValidate.php
  12. 161 0
      app/api/controller/GroupActivityController.php
  13. 3 1
      app/api/lists/UserEquityLists.php
  14. 62 0
      app/api/lists/group_activity/UserOrderLists.php
  15. 346 0
      app/api/logic/GroupActivityLogic.php
  16. 1 1
      app/api/logic/ServiceOrderLogic.php
  17. 64 0
      app/api/validate/GroupOrderValidate.php
  18. 174 0
      app/common/command/GroupOrder.php
  19. 1 0
      app/common/enum/RefundEnum.php
  20. 27 0
      app/common/logic/PayNotifyLogic.php
  21. 63 7
      app/common/logic/PaymentLogic.php
  22. 3 0
      app/common/model/equity/UserEquity.php
  23. 11 0
      app/common/model/equity/UserEquityLog.php
  24. 47 0
      app/common/model/group_activity/GroupActivity.php
  25. 35 0
      app/common/model/group_activity/GroupOrder.php
  26. 45 0
      app/common/model/group_activity/GroupUserOrder.php
  27. 23 0
      app/common/model/service_area/ServiceArea.php
  28. 2 1
      composer.json
  29. 2 0
      config/console.php
  30. 8 0
      config/custom.php

+ 115 - 0
app/adminapi/controller/group_activity/GroupActivityController.php

@@ -0,0 +1,115 @@
+<?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\group_activity;
+
+
+use app\adminapi\controller\BaseAdminController;
+use app\adminapi\lists\group_activity\GroupActivityLists;
+use app\adminapi\logic\group_activity\GroupActivityLogic;
+use app\adminapi\validate\group_activity\GroupActivityValidate;
+
+
+/**
+ * 拼团活动控制器
+ * Class GroupActivityController
+ * @package app\adminapi\controller\group_activity
+ */
+class GroupActivityController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取拼团活动列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/03/13 10:31
+     */
+    public function lists()
+    {
+        return $this->dataLists(new GroupActivityLists());
+    }
+
+
+    /**
+     * @notes 添加拼团活动
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/03/13 10:31
+     */
+    public function add()
+    {
+        $params = (new GroupActivityValidate())->post()->goCheck('add');
+        $result = GroupActivityLogic::add($params);
+        if (true === $result) {
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(GroupActivityLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑拼团活动
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/03/13 10:31
+     */
+    public function edit()
+    {
+        $params = (new GroupActivityValidate())->post()->goCheck('edit');
+        $result = GroupActivityLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(GroupActivityLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除拼团活动
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/03/13 10:31
+     */
+    public function delete()
+    {
+        $params = (new GroupActivityValidate())->post()->goCheck('delete');
+        GroupActivityLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取拼团活动详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/03/13 10:31
+     */
+    public function detail()
+    {
+        $params = (new GroupActivityValidate())->goCheck('detail');
+        $result = GroupActivityLogic::detail($params);
+        return $this->data($result);
+    }
+    /**
+     * 获取活动二维码
+     */
+    public function getQRCode()
+    {
+        $params = (new GroupActivityValidate())->post()->goCheck('detail');
+        return $this->success('',['qrcode'=>GroupActivityLogic::getQRCode($params, $this->request->domain())], 1, 1);
+    }
+
+}

+ 59 - 0
app/adminapi/controller/group_activity/GroupOrderController.php

@@ -0,0 +1,59 @@
+<?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\group_activity;
+
+
+use app\adminapi\controller\BaseAdminController;
+use app\adminapi\lists\group_activity\GroupOrderLists;
+use app\adminapi\logic\group_activity\GroupOrderLogic;
+use app\adminapi\validate\group_activity\GroupOrderValidate;
+
+
+/**
+ * 拼团订单控制器
+ * Class GroupOrderController
+ * @package app\adminapi\controller\group_activity
+ */
+class GroupOrderController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取拼团订单列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/03/13 10:31
+     */
+    public function lists()
+    {
+        return $this->dataLists(new GroupOrderLists());
+    }
+
+    /**
+     * @notes 获取拼团活动详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/03/13 10:31
+     */
+    public function detail()
+    {
+        $params = (new GroupOrderValidate())->goCheck('detail');
+        $result = GroupOrderLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+}

+ 43 - 0
app/adminapi/controller/group_activity/GroupUserOrderController.php

@@ -0,0 +1,43 @@
+<?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\group_activity;
+
+
+use app\adminapi\controller\BaseAdminController;
+use app\adminapi\lists\group_activity\GroupUserOrderLists;
+
+
+/**
+ * 用户拼团订单控制器
+ * Class GroupOrderController
+ * @package app\adminapi\controller\group_activity
+ */
+class GroupUserOrderController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取拼团订单列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/03/13 10:31
+     */
+    public function lists()
+    {
+        return $this->dataLists(new GroupUserOrderLists());
+    }
+
+}

+ 84 - 0
app/adminapi/lists/group_activity/GroupActivityLists.php

@@ -0,0 +1,84 @@
+<?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\group_activity;
+
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\group_activity\GroupActivity;
+use app\common\lists\ListsSearchInterface;
+
+
+/**
+ * 拼团活动列表
+ * Class GroupActivityLists
+ * @package app\adminapi\listsgroup_activity
+ */
+class GroupActivityLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2025/03/13 10:31
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['type', 'is_simulate_form'],
+            '%like%' => ['title'],
+        ];
+    }
+
+
+    /**
+     * @notes 获取拼团活动列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2025/03/13 10:31
+     */
+    public function lists(): array
+    {
+        $list = GroupActivity::where($this->searchWhere)
+            ->field(['id', 'title', 'image','equity_id','origin_price','price','start_time', 'end_time', 'participant_num', 'type', 'form_time_limit', 'is_simulate_form', 'simulate_num'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+        foreach ($list as $key => &$item) {
+            $item['price'] = $item['price'] ? explode(',', $item['price']) : [];
+            $item['participant_num'] = $item['participant_num'] ? explode(',', $item['participant_num']) : [];
+            $item['simulate_num'] = $item['simulate_num'] ? explode(',', $item['simulate_num']) : [];
+        }
+        return $list;
+    }
+
+
+    /**
+     * @notes 获取拼团活动数量
+     * @return int
+     * @author likeadmin
+     * @date 2025/03/13 10:31
+     */
+    public function count(): int
+    {
+        return GroupActivity::where($this->searchWhere)->count();
+    }
+
+}

+ 96 - 0
app/adminapi/lists/group_activity/GroupOrderLists.php

@@ -0,0 +1,96 @@
+<?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\group_activity;
+
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\group_activity\GroupOrder;
+use app\common\lists\ListsSearchInterface;
+
+
+/**
+ * 拼团订单列表
+ * Class GroupOrderLists
+ * @package app\adminapi\listsgroup_activity
+ */
+class GroupOrderLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2025/03/13 10:31
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['a.group_activity_id', 'a.sn','a.goods_id','a.equity_id','a.status','a.user_id'],
+        ];
+    }
+
+    public function queryWhere(){
+        $where = [];
+        if(!empty($this->params['title'])){
+            $where[] = ['b.title', 'like', '%'.$this->params['title'].'%'];
+        }
+        if (!empty($this->params['account'])) {
+            $where[] = ['c.account', 'like', '%'.$this->params['account'].'%'];
+        }
+        return $where;
+    }
+
+    /**
+     * @notes 获取拼团订单列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2025/03/13 10:31
+     */
+    public function lists(): array
+    {
+        $list = GroupOrder::alias('a')->leftJoin('group_activity b', 'b.id = a.group_activity_id')
+            ->leftJoin('user c', 'c.id = a.user_id')
+            ->where($this->searchWhere)
+            ->where($this->queryWhere())
+            ->field(['a.*', 'b.title', 'b.image','c.account'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['a.id' => 'desc'])
+            ->select()
+            ->toArray();
+        return $list;
+    }
+
+
+    /**
+     * @notes 获取拼团活动数量
+     * @return int
+     * @author likeadmin
+     * @date 2025/03/13 10:31
+     */
+    public function count(): int
+    {
+        return GroupOrder::alias('a')
+        ->leftJoin('group_activity b', 'b.id = a.group_activity_id')
+        ->leftJoin('user c', 'c.id = a.user_id')
+        ->where($this->searchWhere)
+        ->where($this->queryWhere())
+        ->count();
+    }
+
+}

+ 97 - 0
app/adminapi/lists/group_activity/GroupUserOrderLists.php

@@ -0,0 +1,97 @@
+<?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\group_activity;
+
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\common\lists\ListsSearchInterface;
+use app\common\model\group_activity\GroupUserOrder;
+
+
+/**
+ * 拼团订单列表
+ * Class GroupUserOrderLists
+ * @package app\adminapi\listsgroup_activity
+ */
+class GroupUserOrderLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2025/03/13 10:31
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['a.mobile', 'a.sn','a.status','a.pay_status','a.pay_way','a.refund_status','a.group_activity_id','a.user_equity_id','a.group_order_id','c.group_order_status'],
+        ];
+    }
+
+    public function queryWhere(){
+        $where = [];
+        if(!empty($this->params['real_name'])){
+            $where[] = ['a.real_name', 'like', '%'.$this->params['real_name'].'%'];
+        }
+        if(!empty($this->params['title'])){
+            $where[] = ['b.title', 'like', '%'.$this->params['title'].'%'];
+        }
+        return $where;
+    }
+
+    /**
+     * @notes 获取拼团订单列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2025/03/13 10:31
+     */
+    public function lists(): array
+    {
+        $list = GroupUserOrder::alias('a')
+            ->leftJoin('group_activity b', 'b.id = a.group_activity_id')
+            ->leftJoin('group_order c', 'c.id = a.group_order_id')
+            ->where($this->searchWhere)
+            ->where($this->queryWhere())
+            ->field(['a.*', 'b.title','b.image','c.status as group_order_status'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['a.id' => 'desc'])
+            ->select()
+            ->toArray();
+        return $list;
+    }
+
+
+    /**
+     * @notes 获取拼团活动数量
+     * @return int
+     * @author likeadmin
+     * @date 2025/03/13 10:31
+     */
+    public function count(): int
+    {
+        return GroupUserOrder::alias('a')
+        ->leftJoin('group_activity b', 'b.id = a.group_activity_id')
+        ->leftJoin('group_order c', 'c.id = a.group_order_id')
+        ->where($this->searchWhere)
+        ->where($this->queryWhere())
+        ->count();
+    }
+
+}

+ 1 - 1
app/adminapi/lists/user/UserLists.php

@@ -35,7 +35,7 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface
      */
     public function setSearch(): array
     {
-        $allowSearch = ['keyword', 'channel', 'create_time_start', 'create_time_end'];
+        $allowSearch = ['keyword', 'channel', 'create_time_start', 'create_time_end','id'];
         return array_intersect(array_keys($this->params), $allowSearch);
     }
 

+ 191 - 0
app/adminapi/logic/group_activity/GroupActivityLogic.php

@@ -0,0 +1,191 @@
+<?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\group_activity;
+
+
+use think\Exception;
+use think\facade\Db;
+use think\facade\Log;
+use app\common\logic\BaseLogic;
+use app\common\service\wechat\WeChatMnpService;
+use app\common\model\group_activity\GroupActivity;
+
+/**
+ * 拼团活动逻辑
+ * Class GroupActivityLogic
+ * @package app\adminapi\logic\group_activity
+ */
+class GroupActivityLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加拼团活动
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2025/03/13 10:31
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            if ($params['type'] == 1) {
+                $params['price'] = $params['price'][0];
+                $params['participant_num'] = $params['participant_num'][0];
+            } else {
+                $params['price'] = implode(",",$params['price']);
+                $params['participant_num'] = implode(",",$params['participant_num']);
+            }
+            if ($params['is_simulate_form'] == 1) {
+                $params['simulate_num'] = $params['type'] == 1 ? $params['simulate_num'][0] : implode(",",$params['simulate_num']);
+            } else {
+                $params['simulate_num'] = '';
+            }
+            GroupActivity::create([
+                'title' => $params['title'],
+                'image' => $params['image'],
+                'equity_id' => $params['equity_id'],
+                'origin_price' => $params['origin_price'],
+                'price' => $params['price'],
+                'start_time' => strtotime($params['start_time']),
+                'end_time' => strtotime($params['end_time']),
+                'participant_num' => $params['participant_num'],
+                'type' => $params['type'],
+                'form_time_limit' => $params['form_time_limit'],
+                'is_online_join' => $params['is_online_join'],
+                'is_simulate_form' => $params['is_simulate_form'],
+                'simulate_num' => $params['simulate_num'],
+                'is_preheat' => $params['is_preheat'],
+                'is_support_refund' => $params['is_support_refund'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 编辑拼团活动
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2025/03/13 10:31
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            if ($params['type'] == 1) {
+                $params['price'] = $params['price'][0];
+                $params['participant_num'] = $params['participant_num'][0];
+            } else {
+                $params['price'] = implode(",",$params['price']);
+                $params['participant_num'] = implode(",",$params['participant_num']);
+            }
+            if ($params['is_simulate_form'] == 1) {
+                $params['simulate_num'] = $params['type'] == 1 ? $params['simulate_num'][0] : implode(",",$params['simulate_num']);
+            } else {
+                $params['simulate_num'] = '';
+            }
+            GroupActivity::where('id', $params['id'])->update([
+                'title' => $params['title'],
+                'image' => $params['image'],
+                'equity_id' => $params['equity_id'],
+                'origin_price' => $params['origin_price'],
+                'price' => $params['price'],
+                'start_time' => strtotime($params['start_time']),
+                'end_time' => strtotime($params['end_time']),
+                'participant_num' => $params['participant_num'],
+                'type' => $params['type'],
+                'form_time_limit' => $params['form_time_limit'],
+                'is_online_join' => $params['is_online_join'],
+                'is_simulate_form' => $params['is_simulate_form'],
+                'simulate_num' => $params['simulate_num'],
+                'is_preheat' => $params['is_preheat'],
+                'is_support_refund' => $params['is_support_refund'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 删除拼团活动
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2025/03/13 10:31
+     */
+    public static function delete(array $params): bool
+    {
+        return GroupActivity::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取拼团活动详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2025/03/13 10:31
+     */
+    public static function detail($params): array
+    {
+        return GroupActivity::findOrEmpty($params['id'])->toArray();
+    }
+
+    /**
+     * 获取活动二维码
+     * @return string|void
+     */
+    public static function getQRCode($params,$url='weixiu.kyjlkj.com')
+    {
+        try {
+            $mnp_page = 'pages/web_view/group';
+            
+            $scene_page = 'group';
+            Log::info('getQRCode:'.rawurlencode($scene_page));
+            $response = (new WeChatMnpService())->getUnlimitedQRCode(
+                'page='.$scene_page.'&id='.$params['id'],
+                $mnp_page,
+                env('miniprogram.mini_env_version', 'release'),
+                false
+            );
+            Log::info('getQRCode:'.json_encode([$response]));
+            $qrcode = $response->getContent();
+            if(!is_dir('./uploads/wx_qrcode/'.date('Ymd'))){
+                mkdir('./uploads/wx_qrcode/'.date('Ymd'));
+            }
+            $file_name = 'uploads/wx_qrcode/'.date('Ymd').'/'.time().rand(1000,9999).'.png';
+            file_put_contents($file_name, $qrcode);
+            return $url.'/'.$file_name;
+        } catch (\Throwable $e) {
+            Log::info('getQRCode:'.$e->getMessage());
+            return '';
+        }
+    }
+}

+ 55 - 0
app/adminapi/logic/group_activity/GroupOrderLogic.php

@@ -0,0 +1,55 @@
+<?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\group_activity;
+
+
+use app\common\logic\BaseLogic;
+use app\common\model\equity\EquityConfig;
+use app\common\model\user\User;
+use app\common\model\group_activity\GroupOrder;
+use app\common\model\group_activity\GroupActivity;
+use app\common\model\group_activity\GroupUserOrder;
+
+/**
+ * 拼团订单
+ * Class GroupOrderLogic
+ * @package app\adminapi\logic\group_activity
+ */
+class GroupOrderLogic extends BaseLogic
+{
+    /**
+     * @notes 获取拼团订单详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2025/03/13 10:31
+     */
+    public static function detail($params): array
+    {
+        $detail = GroupOrder::findOrEmpty($params['id'])->toArray();
+        if ($detail) {
+            //团长信息
+            $detail['user'] = User::where('id', $detail['user_id'])->field('id,account')->findOrEmpty()->toArray();
+            $detail['activity'] = GroupActivity::where('id', $detail['group_activity_id'])->findOrEmpty()->toArray();
+            $detail['goods'] = EquityConfig::where('id', $detail['equity_id'])->findOrEmpty()->toArray();
+            $detail['users'] = GroupUserOrder::alias('a')->leftJoin('user b','a.user_id=b.id')
+                                ->where('group_order_id', $detail['id'])
+                                ->field('a.*,b.account')
+                                ->select()->toArray();
+            $detail['end_time'] = date('Y-m-d H:i:s',$detail['end_time']);
+        }
+        return $detail;
+    }
+}

+ 118 - 0
app/adminapi/validate/group_activity/GroupActivityValidate.php

@@ -0,0 +1,118 @@
+<?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\group_activity;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * 拼团活动验证器
+ * Class GroupActivityValidate
+ * @package app\adminapi\validate\group_activity
+ */
+class GroupActivityValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'title' => 'require',
+        'image' => 'require',
+        'equity_id' => 'require',
+        'origin_price' => 'require',
+        'price' => 'require',
+        'start_time' => 'require',
+        'end_time' => 'require',
+        'participant_num' => 'require',
+        'type' => 'require',
+        'form_time_limit' => 'require',
+        'is_simulate_form' => 'require',
+
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'title' => '活动名称',
+        'image' => '活动图片',
+        'equity_id' => '权益卡',
+        'origin_price' => '拼团原价',
+        'price' => '拼团价',
+        'start_time' => '活动开始时间',
+        'end_time' => '活动结束时间',
+        'participant_num' => '参团人数',
+        'type' => '活动类型',
+        'form_time_limit' => '成团时限',
+        'is_simulate_form' => '是否开启模拟成团',
+
+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return GroupActivityValidate
+     * @author likeadmin
+     * @date 2025/03/13 10:31
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['title','equity_id','start_time','end_time','participant_num','type','form_time_limit','is_simulate_form']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return GroupActivityValidate
+     * @author likeadmin
+     * @date 2025/03/13 10:31
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','title','equity_id','start_time','end_time','participant_num','type','form_time_limit','is_simulate_form']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return GroupActivityValidate
+     * @author likeadmin
+     * @date 2025/03/13 10:31
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return GroupActivityValidate
+     * @author likeadmin
+     * @date 2025/03/13 10:31
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 69 - 0
app/adminapi/validate/group_activity/GroupOrderValidate.php

@@ -0,0 +1,69 @@
+<?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\group_activity;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * 拼团订单验证器
+ * Class GroupOrderValidate
+ * @package app\adminapi\validate\group_activity
+ */
+class GroupOrderValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'title' => 'require',
+        'image' => 'require',
+        'equity_id' => 'require',
+        'goods_id' => 'require',
+        'origin_price' => 'require',
+        'price' => 'require',
+        'start_time' => 'require',
+        'end_time' => 'require',
+        'participant_num' => 'require',
+        'type' => 'require',
+        'form_time_limit' => 'require',
+        'is_simulate_form' => 'require',
+
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+    ];
+
+    /**
+     * @notes 详情场景
+     * @author likeadmin
+     * @date 2025/03/13 10:31
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 161 - 0
app/api/controller/GroupActivityController.php

@@ -0,0 +1,161 @@
+<?php
+namespace app\api\controller;
+
+use app\common\logic\PaymentLogic;
+use app\api\logic\GroupActivityLogic;
+use app\api\validate\GroupOrderValidate;
+use app\api\lists\group_activity\UserOrderLists;
+
+
+/**
+ * 拼团活动控制器
+ * Class UserController
+ * @package app\api\controller
+ */
+class GroupActivityController extends BaseApiController
+{
+    public array $notNeedLogin = [];
+
+
+    /**
+     * 活动详情
+     */
+    public function detail()
+    {
+        $id = $this->request->param('id');
+        $result = GroupActivityLogic::detail($id,$this->userId);
+        return $this->data($result);
+    }
+
+    /**
+     * 拼团订单详情
+     */
+    public function orderDetail(){
+        $sn = $this->request->param('sn');
+        $result = GroupActivityLogic::orderDetail($sn,$this->request->domain());
+        return $this->data($result);
+    }
+
+    /**
+     * 用户订单详情
+     */
+    public function userOrderDetail(){
+        $sn = $this->request->param('sn');
+        $result = GroupActivityLogic::userOrderDetail($sn,$this->userId);
+        return $this->data($result);
+    }
+
+    /**
+     * 用户的订单列表
+     */
+    public function orderList(){
+        return $this->dataLists(new UserOrderLists());
+    }
+
+    /**
+     * 提交订单
+     * @return \think\response\Json
+     */
+    public function submitOrder()
+    {
+        $params = (new GroupOrderValidate())->post()->goCheck('add', [
+            'user_id' => $this->userId,
+            'terminal' => $this->userInfo['terminal'],
+            'user_info' => $this->userInfo
+        ]);
+        $result = GroupActivityLogic::submitOrder($params);
+        if (false === $result) {
+            return $this->fail(GroupActivityLogic::getError());
+        }
+        return $this->data($result);
+    }
+
+    /**
+     * @notes 预支付
+     * @return \think\response\Json
+     */
+    public function prepay()
+    {
+        $params = (new GroupOrderValidate())->post()->goCheck('pay');
+        //订单信息
+        $order = PaymentLogic::getPayGroupOrderInfo($params);
+        if (false === $order) {
+            return $this->fail(PaymentLogic::getError());
+        }
+        //支付流程
+        $redirectUrl = $params['redirect'] ?? '/pages/payment/payment';
+        $result = PaymentLogic::pay($params['pay_way'], 'group', $order, $this->userInfo['terminal'], $redirectUrl);
+        if (false === $result) {
+            return $this->fail(PaymentLogic::getError());
+        }
+        $result['sn'] = $order['sn'];
+        return $this->success('', $result);
+    }
+
+    /**
+     * @notes 获取支付状态
+     * @return \think\response\Json
+     */
+    public function payStatus()
+    {
+        $params = (new GroupOrderValidate())->post()->goCheck('status',[
+            'from' => 'group',
+            'user_id' => $this->userId,
+        ]);
+        $result = PaymentLogic::getPayStatus($params);
+        if ($result === false) {
+            return $this->fail(PaymentLogic::getError());
+        }
+        return $this->data($result);
+    }
+
+    /**
+     * 取消订单
+     * @return \think\response\Json
+     */
+    public function cancelOrder()
+    {
+        $params = (new GroupOrderValidate())->post()->goCheck('cancel', [
+            'user_id' => $this->userId
+        ]);
+        $result = GroupActivityLogic::cancelOrder($params);
+        if (false === $result) {
+            return $this->fail(GroupActivityLogic::getError());
+        }
+        return $this->success('取消成功', [], 1, 1);
+    }
+
+    /**
+     * 申请退款
+     * @return \think\response\Json
+     */
+    public function refundOrder()
+    {
+        $params = (new GroupOrderValidate())->post()->goCheck('refund', [
+            'user_id' => $this->userId
+        ]);
+        $result = GroupActivityLogic::refundOrder($params);
+        list($flag, $msg) = $result;
+        if(false === $flag) {
+            return $this->fail($msg);
+        }
+
+        if (false === $result) {
+            return $this->fail(GroupActivityLogic::getError());
+        }
+        return $this->success('退款成功', [], 1, 1);
+    }
+
+    public function deleteOrder()
+    {
+        $params = (new GroupOrderValidate())->post()->goCheck('refund',[
+            'user_id' => $this->userId
+        ]);
+        $result = GroupActivityLogic::deleteOrder($params);
+        if (false === $result) {
+            return $this->fail(GroupActivityLogic::getError());
+        }
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+}

+ 3 - 1
app/api/lists/UserEquityLists.php

@@ -1,6 +1,7 @@
 <?php
 namespace app\api\lists;
 
+use app\common\model\equity\EquityConfig;
 use app\common\model\equity\UserEquity;
 
 class UserEquityLists  extends BaseApiDataLists
@@ -11,7 +12,8 @@ class UserEquityLists  extends BaseApiDataLists
        $where[] = ['user_id','=',$this->userId];
        $where[] = ['number','>',0];
        $where[] = ['end_time','>=',time()];
-
+       $equityConfigIds = EquityConfig::where('status',1)->column('id')??[-1];
+       $where[] = ['equity_id','in',$equityConfigIds];
        if(isset($this->params['goods_id']) && !empty($this->params['goods_id'])){
            $where[] = ['goods_id','=',$this->params['goods_id']];
        }

+ 62 - 0
app/api/lists/group_activity/UserOrderLists.php

@@ -0,0 +1,62 @@
+<?php
+namespace app\api\lists\group_activity;
+
+use app\api\lists\BaseApiDataLists;
+use app\common\lists\ListsSearchInterface;
+use app\common\model\group_activity\GroupUserOrder;
+
+/**
+ * 拼团用户订单列表
+ * Class RechargeLists
+ * @package app\api\lists\group_activity
+ */
+class UserOrderLists extends BaseApiDataLists implements ListsSearchInterface
+{
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/07/07 18:37
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['a.status'],
+        ];
+    }
+    
+    /**
+     * @notes 获取列表
+     * @return array
+     */
+    public function lists(): array
+    {
+        $lists = GroupUserOrder::alias('a')->leftJoin('group_order b','a.group_order_id=b.id')
+            ->leftJoin('group_activity c','a.group_activity_id=c.id')
+            ->field('a.id,a.sn,a.group_activity_id,a.status,a.order_amount,a.paid_amount,a.pay_status,a.refund_status,a.create_time,b.goods_id,b.num,b.origin_price,b.end_time,c.title,c.image')
+            ->where([
+                'a.user_id' => $this->userId,
+            ])
+            ->where($this->searchWhere)
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order('a.create_time', 'desc')
+            ->select()
+            ->toArray();
+        return $lists;
+    }
+
+
+    /**
+     * @notes  获取数量
+     * @return int
+     */
+    public function count(): int
+    {
+        return GroupUserOrder::alias('a')->where([
+                'user_id' => $this->userId,
+            ])
+            ->where($this->searchWhere)
+            ->count();
+    }
+
+}

+ 346 - 0
app/api/logic/GroupActivityLogic.php

@@ -0,0 +1,346 @@
+<?php
+namespace app\api\logic;
+
+use think\Exception;
+use think\facade\Db;
+use app\common\enum\RefundEnum;
+use app\common\logic\BaseLogic;
+use app\common\logic\RefundLogic;
+use app\common\model\goods\Goods;
+use app\common\model\equity\UserEquity;
+use app\common\model\equity\EquityConfig;
+use app\common\model\refund\RefundRecord;
+use app\common\model\equity\UserEquityLog;
+use app\common\model\group_activity\GroupOrder;
+use app\common\model\group_activity\GroupActivity;
+use app\common\model\group_activity\GroupUserOrder;
+
+
+/**
+ * 拼团活动逻辑处理
+ * Class GroupActivityLogic
+ * @package app\api\logic
+ */
+class GroupActivityLogic extends BaseLogic
+{
+
+    /**
+     * @notes 拼团活动详情
+     */
+    public static function detail($id,$userId){
+        $detail = GroupActivity::with('goods')->where(['id'=>$id])->visible([
+            'id','title','image','start_time','end_time','type','equity_id',
+            'participant_num','origin_price','price','form_time_limit'
+        ])->findOrEmpty()->toArray();
+
+        if(!empty($detail)){
+            $detail['price'] = explode(",",$detail['price']);
+            $detail['participant_num'] = explode(",",$detail['participant_num']);
+            $detail['timestamp'] = time();
+            $goods = Goods::where('id',$detail['goods']['goods_id'])->field('service_image,goods_category_id')->findOrEmpty()->toArray();
+            $detail['goods'] = array_merge($detail['goods'],$goods);
+            //查询用户是否已有付款订单
+            $detail['order'] = GroupUserOrder::with('group_order')->where(['user_id'=>$userId,'group_activity_id'=>$detail['id'],'pay_status'=>1,'refund_status' => 0])->field('id,status,pay_way,pay_time,pay_status,remark,create_time,group_order_id')->findOrEmpty()->toArray();
+        }
+
+        return $detail;
+    }
+
+    /**
+     * @notes 拼团订单详情
+     */
+    public static function orderDetail($sn,$url){
+        $detail = GroupOrder::where(['sn'=>$sn])->findOrEmpty()->toArray();
+        if(!empty($detail)){
+           
+            $detail['activity'] = GroupActivity::with('goods')->where(['id'=>$detail['group_activity_id']])->visible([
+                'id','title','image','start_time','end_time','type','equity_id',
+                'participant_num','origin_price','price','form_time_limit'
+            ])->findOrEmpty()->toArray();
+            $detail['users'] = GroupUserOrder::alias('a')
+                                ->leftJoin('user b','a.user_id=b.id')
+                                ->where(['a.sn'=>$sn,'a.status'=>1])
+                                ->field(['a.id','a.user_id','a.status','a.create_time','b.avatar','b.nickname'])
+                                ->order('a.create_time','asc')
+                                ->select()
+                                ->toArray();
+            foreach($detail['users'] as &$item){
+                $item['avatar'] = config('custom.cdn_url').$item['avatar'];
+            }
+            //如果开启了模拟成团,成团后,自动填补剩余人数
+            if ($detail['status'] == 1 && $detail['num'] < $detail['activity']['participant_num']) {
+                $num = $detail['activity']['participant_num'] - $detail['num'];
+                $robot = self::getRobot($num,$url);
+                $detail['users'] = array_merge($detail['users'],$robot);
+            }
+            $detail['timestamp'] = time();
+        }
+        return $detail;
+    }
+
+    //模拟用户
+    private static function getRobot($num,$url){
+
+        $nicknames = ["草莓啵啵熊","甜心小奶喵","清风吟月","浅梦逸云","静听花落","星辰浅语","云卷云舒间","花影舞流年","月色如水柔","暖阳","星辰","云舒","悠然","素心","晚晴","素心","清风","月白","静雅","不羁的灵魂","独行侠逸风","叛逆的旋律","冷傲冰爵","烈焰狂歌者","酷玩潮咖","神秘暗影侠","朋克精灵","暴走的音符","个性涂鸦师","墨染书香","青衫烟雨客","素笺淡墨痕","简逸","微光","清风","浅笑","逸梦","逸尘","浅念","澜影","默言","素笺","心屿","墨染","弦音","竹影","浅酌","暮雪","星辰","雨薇","凝霜","云岫","流萤","晨曦","浅夏","诗韵","逸云","浅唱"];
+        shuffle($nicknames);
+        $users = [];
+        $num = $num > 10 ? 10 : $num;
+        for ($i=0; $i < $num; $i++) {
+            $users[] = [
+                'id' => 0,
+                'user_id' => 0,
+                'status' => 1,
+                'avatar' => $url.'/uploads/group_activity/robot/0be648e5767f18d6af2dbb630c53ba28'.rand(1,33).'.jpg',
+                'nickname' => $nicknames[$i],
+            ];
+        }
+        return $users;
+    }
+
+    /**
+     * @notes 用户订单详情
+     */
+    public static function userOrderDetail($sn,$userId){
+        $detail = GroupUserOrder::with('groupOrder')->where(['sn'=>$sn, 'user_id' => $userId])->field('id,status,pay_way,pay_time,pay_status,refund_status,remark,create_time,group_order_id,user_equity_id')->findOrEmpty()->toArray();
+        if ($detail) {
+            $detail['is_refund'] = 0;
+            if ($detail['pay_status'] == 1 && $detail['refund_status'] == 0) {
+                if ($detail['user_equity_id'] > 0) {
+                    $detail['is_refund'] = UserEquityLog::where('user_equity_id', $detail['user_equity_id'])->count() > 0 ? 0 : 1;
+                } else {
+                    $detail['is_refund'] = 1;
+                }
+            }
+            $detail['goods'] = EquityConfig::where('id', $detail['groupOrder']['equity_id'])->field('id,equity_name,number,day_num')->findOrEmpty()->toArray();
+            $detail['timestamp'] = time();
+        }
+        return $detail;
+    }
+
+    /**
+     * 提交订单
+     * @param array $params
+     * @return array|false
+     */
+    public static function submitOrder($params)
+    {
+        Db::startTrans();
+        try {
+            
+            $userOrder = GroupUserOrder::where(['group_activity_id' => $params['group_activity_id'], 'user_id' => $params['user_id']])->findOrEmpty()->toArray();
+            if ($userOrder && $userOrder['pay_status'] == 1 && $userOrder['refund_status'] == 0) {
+                throw new Exception('您已参加过该活动!');
+            }
+            
+            //校验拼团活动
+            if (empty($params['sn'])) {
+
+                //如果已有团单,直接加入
+                $groupOrder = GroupOrder::where(['group_activity_id' => $params['group_activity_id'],'user_id' => $params['user_id']])->findOrEmpty()->toArray();
+                if (!$groupOrder) {
+                    //新开团
+                    $activity = GroupActivity::findOrEmpty($params['group_activity_id']); //活动详情
+                    if ($activity->isEmpty()) {
+                        throw new Exception('拼团活动不存在!'); //拼团活动不存在
+                    }
+                    //校验活动时间
+                    if (time() < strtotime($activity['start_time'])) {
+                        throw new Exception('拼团活动未开始!'); //拼团活动未开始
+                    }
+                    if (time() > $activity['end_time']) {
+                        throw new Exception('拼团活动已结束!'); //拼团活动已结束
+                    }
+                        
+                    $order_amount = explode(",",$activity['price'])[0];
+                    //生成拼团单
+                    $data = [
+                        'sn' => generate_sn(GroupOrder::class, 'sn'),
+                        'group_activity_id' => $params['group_activity_id'],
+                        'equity_id' => $activity['equity_id'],
+                        'goods_id' => EquityConfig::where('id', $activity['equity_id'])->value('goods_id'),
+                        'user_id' => $params['user_id'],
+                        'origin_price' => $activity['origin_price'],
+                        'price' => $order_amount,
+                        'create_time' => time(),
+                        'end_time'   => time() + $activity['form_time_limit'] * 60 * 60,
+                    ];
+                    $group_order = GroupOrder::create($data);
+                }
+            } else {
+                //加入已开的拼团单
+                $group_order = GroupOrder::where(['group_activity_id' => $params['group_activity_id'], 'sn' => $params['sn']])->findOrEmpty()->toArray();
+                if (empty($group_order)) {
+                    throw new Exception('拼团订单不存在!'); //拼团活动不存在
+                }
+                if ($group_order['num'] >= 100) {
+                    throw new Exception('拼团人数已满!'); //拼团人数已满
+                }
+                if ($group_order['status'] == 1 ) {
+                    throw new Exception('活动已成团');
+                }
+                if ($group_order['status'] >= 1 ) {
+                    throw new Exception('拼团已取消!');
+                }
+                if ($group_order['end_time'] < time()) {
+                    throw new Exception('拼团活动已结束!'); //拼团活动已结束
+                }
+                $order_amount = $group_order['price'];
+            }
+
+            //生成用户拼单订单
+            $data = [
+                'sn' => $group_order['sn'],
+                'group_order_id' => $group_order['id'],
+                'group_activity_id' => $params['group_activity_id'],
+                'user_id' => $params['user_id'],
+                'remark' => $params['remark'],
+                'order_amount' => $order_amount,
+                'order_terminal' => $params['terminal'],
+            ];
+            if ($userOrder) {
+                $data['create_time'] = time();
+                $data['update_time'] = $data['delete_time'] = null;
+                GroupUserOrder::where('id',$userOrder['id'])->update($data); 
+            } else {
+                $userOrder = GroupUserOrder::create($data);    
+            }
+            Db::commit();
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+
+        return [
+            'order_id' => (int)$userOrder['id'],
+            'sn' => $group_order['sn']
+        ];
+    }
+
+    /**
+     * 取消订单
+     * @param $params
+     * @return false|void
+     */
+    public static function cancelOrder($params)
+    {
+        Db::startTrans();
+        try {
+            $detail =  GroupUserOrder::where([
+                    'user_id' => $params['user_id'],
+                    'sn'=>$params['sn']
+                ])->field('id,status')->findOrEmpty()->toArray();
+            if(empty($detail)){
+                throw new Exception('订单不存在');
+            }
+            if($detail['status'] == 1){
+                throw new Exception('已支付订单不支持取消');
+            }
+            if($detail['status'] != 0){
+                throw new Exception('当前订单不支持取消');
+            }
+
+            //将用户订单状态更新为已取消
+            GroupUserOrder::where('id',$detail['id'])->update(['status' => 4, 'pay_status' => 2]);
+            
+            Db::commit();
+            return true;
+        }
+        catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+    /**
+     * 订单退款
+     * @param $params
+     * @return false|void
+     */
+    public static function refundOrder($params)
+    {
+        Db::startTrans();
+        try {
+            $order =  GroupUserOrder::where([
+                    'user_id' => $params['user_id'],
+                    'sn'=>$params['sn']
+                ])->field('id,sn,status,order_amount,pay_status,pay_way,user_equity_id,user_id,order_terminal')->findOrEmpty()->toArray();
+            if(empty($order)){
+                throw new Exception('订单不存在');
+            }
+            if($order['status'] != 1 || $order['pay_status'] != 1){
+                throw new Exception('当前订单不支持退款');
+            }
+            if ($order['user_equity_id']) {
+                //判断权益卡是否已使用
+                $used = UserEquityLog::where(['user_equity_id' => $order['user_equity_id'],'user_id' => $params['user_id']])->count();
+                if ($used) {
+                    throw new Exception('当前权益卡已使用,不支持退款');
+                }
+                //删除用户权益卡
+                $userEquity = UserEquity::where(['id' => $order['user_equity_id'],'user_id' => $params['user_id']])->findOrEmpty();
+                $userEquity->delete();
+            }
+
+            //将用户订单状态更新为申请退款
+            GroupUserOrder::where('id',$order['id'])->update(['status' => 3,'refund_status' => 1]);
+
+            // 生成退款记录
+            $recordSn = generate_sn(RefundRecord::class, 'sn');
+            $record = RefundRecord::create([
+                'sn' => $recordSn,
+                'user_id' => $order['user_id'],
+                'order_id' => $order['id'],
+                'order_sn' => $order['sn'],
+                'order_type' => RefundEnum::ORDER_TYPE_GROUP,
+                'order_amount' => $order['order_amount'],
+                'refund_amount' => $order['order_amount'],
+                'refund_type' => RefundEnum::TYPE_ADMIN,
+                'transaction_id' => $order['transaction_id'] ?? '',
+                'refund_way' => RefundEnum::getRefundWayByPayWay($order['pay_way']),
+            ]);
+
+            // 退款
+            $result = RefundLogic::refund($order, $record['id'], $order['order_amount'], 1);
+            
+            $flag = true;
+            $resultMsg = '退款成功';
+            if ($result !== true) {
+                $flag = false;
+                $resultMsg = RefundLogic::getError();
+            }
+
+            Db::commit();
+            return [$flag, $resultMsg];
+        }
+        catch (\Exception $e) {
+            Db::rollback();
+            self::$error = $e->getMessage();
+            return [false, $e->getMessage()];
+        }
+    }
+
+    public static function deleteOrder($params):bool
+    {
+        try{
+            $order =  GroupUserOrder::where([
+                'user_id' => $params['user_id'],
+                'sn' => $params['sn']
+            ])->findOrEmpty();
+            if($order->isEmpty()){
+                throw new \Exception('订单不存在');
+            }
+
+            if($order['status'] == 1){
+                throw new Exception('已支付订单不支持删除');
+            }
+
+            $order->delete();
+            return true;
+        } catch(\Exception $e){
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+}

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

@@ -187,7 +187,7 @@ class ServiceOrderLogic extends BaseLogic
 
             //使用权益卡时订单应支付金额=0
             if(isset($params['user_equity_id']) && $params['user_equity_id']){
-                $userEquity = UserEquity::with(['equityConfig'])->where(['status'=>1,'user_id'=>$params['user_id'],'id'=>$params['user_equity_id']])->findOrEmpty();
+                $userEquity = UserEquity::with(['equityConfig'])->where(['user_id'=>$params['user_id'],'id'=>$params['user_equity_id']])->findOrEmpty();
                 if($userEquity->isEmpty() || (int)$userEquity['equityConfig']['status'] === 2){
                     throw new Exception('您的权益卡已关闭,请重新选择权益卡!');
                 }

+ 64 - 0
app/api/validate/GroupOrderValidate.php

@@ -0,0 +1,64 @@
+<?php
+namespace app\api\validate;
+
+use app\common\validate\BaseValidate;
+
+/**
+ * 拼团订单验证器
+ * Class GroupOrderValidate
+ * @package app\api\validate
+ */
+class GroupOrderValidate extends BaseValidate
+{
+
+    protected $rule = [
+        'order_id'=>'require',
+        'sn'=>'require',
+        'pay_way' => 'require',
+        'group_activity_id' => 'require',
+    ];
+
+
+    protected $message = [
+        'order_id.require' => '订单ID错误',
+        'sn.require' => '订单编号错误',
+        'pay_way.require' => '请选择支付方式',
+        'group_activity_id.require' => '拼团活动不存在',
+    ];
+
+
+    public function sceneAdd()
+    {
+        return $this->only(['pay_way','group_activity_id,remark']);
+    }
+
+    public function sceneDetail()
+    {
+        return $this->only(['sn']);
+    }
+
+    public function sceneCancel()
+    {
+        return $this->only(['sn']);
+    }
+
+    /**
+     * @notes 支付方式场景
+     * @return ShopPayValidate
+     */
+    public function scenePay()
+    {
+        return $this->only(['pay_way' ,'order_id']);
+    }
+
+    public function sceneRefund()
+    {
+        return $this->only(['sn']);
+    }
+
+    public function sceneStatus()
+    {
+        return $this->only(['order_id']);
+    }
+
+}

+ 174 - 0
app/common/command/GroupOrder.php

@@ -0,0 +1,174 @@
+<?php
+namespace app\common\command;
+
+use think\facade\Db;
+use think\facade\Log;
+use think\console\Input;
+use think\console\Output;
+use think\console\Command;
+use app\common\enum\RefundEnum;
+use app\common\model\equity\UserEquity;
+use app\common\model\equity\EquityConfig;
+use app\common\model\refund\RefundRecord;
+use app\common\model\group_activity\GroupUserOrder;
+use app\common\model\group_activity\GroupOrder as GroupOrderModel;
+use app\common\logic\RefundLogic;
+
+/*
+** 拼团订单,活动结束,校验是否拼团成功, 如果成功,则给用户发放权益卡,失败批量退款
+*/
+class GroupOrder extends Command
+{
+    protected function configure()
+    {
+        $this->setName('group_order')
+            ->setDescription('拼团结束,发放权益卡或批量退款');
+    }
+
+    protected function execute(Input $input, Output $output)
+    {
+        //更新拼团结束的订单状态
+        $this->updateGroupOrder();
+
+    }
+
+    /**
+     * 更新拼团结束的订单状态
+     */
+    protected function updateGroupOrder()
+    {
+        $last_id = 0;
+        while($last_id >= 0) {
+            $list = GroupOrderModel::alias('a')
+                        ->leftJoin('group_activity b','a.group_activity_id=b.id')
+                        ->where('a.status',0)
+                        ->where('a.end_time','<',time())
+                        ->where('a.id','>',$last_id)
+                        ->field('a.id,a.num,a.goods_id,b.participant_num,b.is_simulate_form,b.simulate_num')
+                        ->order('a.id','asc')
+                        ->limit(30)
+                        ->select()->toArray();
+                        
+            if (!$list) {
+                $last_id = -1;
+                break;
+            }
+            foreach($list as $item) {
+                $last_id = $item['id'];
+
+                $list = GroupUserOrder::where([
+                    'group_order_id' => $item['id'],
+                    'pay_status' => 1,
+                    'status' => 1,
+                    'refund_status' => 0,
+                ])
+                ->field('id,user_id,sn,remark,order_amount,pay_way,transaction_id,order_terminal')->order('id','asc')->select()->toArray();
+                $num = count($list);
+                if (($item['is_simulate_form'] == 1 && $num >= $item['simulate_num']) || ($item['is_simulate_form'] == 0 && $num >= $item['participant_num'])) {
+                    //模拟成团
+                    $this->gruopSuccess($item,$list);
+                } else {
+                    //拼团失败
+                    $this->groupFail($item,$list);
+                }
+            }
+        }
+        
+    }
+
+    /**
+     * 拼团成功(给已支付的用户发放权益卡)
+     * @param $item
+     */
+    protected function gruopSuccess($order,$list)
+    {
+        $max_id = UserEquity::max('id');
+        try {
+            Db::startTrans();
+            $equityConfig = EquityConfig::where('id',$order['goods_id'])->findOrEmpty();
+            foreach($list as $item) {
+                //用户发放权益卡
+                $max_id++;
+                //创建用户权益卡
+                $userEquity = UserEquity::create([
+                    'user_id' => $item['user_id'],
+                    'equity_id' => $order['goods_id'],
+                    'goods_id' => $equityConfig['goods_id'],
+                    'number' => $equityConfig['number'],
+                    'create_time' => time(),
+                    'end_time' => time() + $equityConfig['day_num'] * 86400,
+                    'remark' => '拼团单id:'.$item['id'],
+                    'code' => generateRandomString((8-strlen($max_id)),2).$max_id,
+                ]);
+                //更新用户拼团订单
+                GroupUserOrder::where('id',$item['id'])->update(['user_equity_id' => $userEquity->id]);
+            }
+
+            //更新拼团订单
+            GroupOrderModel::where('id',$order['id'])->update([
+                'status' => 1,
+                'num' => count($list)
+            ]);
+
+            Db::commit();
+        } catch (\Exception $e) {
+            Db::rollback();
+            Log::error('拼团失败,批量退款失败:'.$e->getMessage());
+        }
+    }
+
+    
+    /*
+     * 批量退款,关闭订单
+     * @param $item
+    */
+    protected function groupFail($order,$list)
+    {
+        try {
+            Db::startTrans();
+            foreach($list as $item) {
+                $remark = $item['remark'] ?? '';
+
+                // 生成退款记录
+                $recordSn = generate_sn(RefundRecord::class, 'sn');
+                $record = RefundRecord::create([
+                    'sn' => $recordSn,
+                    'user_id' => $item['user_id'],
+                    'order_id' => $item['id'],
+                    'order_sn' => $item['sn'],
+                    'order_type' => RefundEnum::ORDER_TYPE_GROUP,
+                    'order_amount' => $item['order_amount'],
+                    'refund_amount' => $item['order_amount'],
+                    'refund_type' => RefundEnum::TYPE_ADMIN,
+                    'transaction_id' => $item['transaction_id'] ?? '',
+                    'refund_way' => RefundEnum::getRefundWayByPayWay($item['pay_way']),
+                ]);
+
+                // 退款
+                $result = RefundLogic::refund($item, $record['id'], $item['order_amount'], 1);
+                
+                if ($result !== true) {
+                    //退款失败
+                    $remark .= RefundLogic::getError();
+                    GroupUserOrder::where('id',$item['id'])->update(['remark' => $remark]);
+                } else {
+                    //退款成功
+                    GroupUserOrder::where('id',$item['id'])->update(['status' => 3,'refund_status' => 1]);
+                }
+
+            }
+
+            //更新拼团订单
+            GroupOrderModel::where('id',$order['id'])->update([
+                'status' => 2,
+                'num' => count($list)
+            ]);
+
+            Db::commit();
+        } catch (\Exception $e) {
+            Db::rollback();
+            Log::error('拼团失败,批量退款失败:'.$e->getMessage());
+        }
+    }
+
+}

+ 1 - 0
app/common/enum/RefundEnum.php

@@ -35,6 +35,7 @@ class RefundEnum
     // 退款订单类型
     const ORDER_TYPE_ORDER = 'order'; // 普通订单
     const ORDER_TYPE_RECHARGE = 'recharge'; // 充值订单
+    const ORDER_TYPE_GROUP = 'group'; // 拼团订单
 
 
     /**

+ 27 - 0
app/common/logic/PayNotifyLogic.php

@@ -18,6 +18,8 @@ use app\common\enum\PayEnum;
 use app\common\enum\user\AccountLogEnum;
 use app\common\enum\WorkEnum;
 use app\common\model\equity\UserEquity;
+use app\common\model\group_activity\GroupOrder;
+use app\common\model\group_activity\GroupUserOrder;
 use app\common\model\recharge\OrderGoods;
 use app\common\model\recharge\RechargeOrder;
 use app\common\model\shops\ShopOrders;
@@ -166,6 +168,31 @@ class PayNotifyLogic extends BaseLogic
         $order->shop_order_type = 2;
         $order->save();
     }
+    /**
+     * @notes 服务回调
+     * @param $orderSn
+     * @param array $extra
+     */
+    public static function group($orderSn, array $extra = [])
+    {
+        $order = GroupUserOrder::where('sn', $orderSn)->findOrEmpty();
+        Log::write($order->toArray(),JSON_UNESCAPED_UNICODE);
+        if(!$order->isEmpty()){
+            // 更新用户拼团订单状态
+            $order->transaction_id = $extra['transaction_id'] ?? '';
+            $order->pay_status = PayEnum::ISPAID;
+            $order->pay_time = time();
+            $order->paid_amount = $order->order_amount;
+            $order->status = 1;
+
+            $order->save();
+            $group_order = GroupOrder::findOrEmpty($order->group_order_id);
 
+            if(!$group_order->isEmpty()){
+                $group_order->num += 1;
+                $group_order->save();
+            }
+        }
+    }
 
 }

+ 63 - 7
app/common/logic/PaymentLogic.php

@@ -18,9 +18,11 @@ namespace app\common\logic;
 use app\common\enum\PayEnum;
 use app\common\enum\YesNoEnum;
 use app\common\model\effective\EffectiveCategory;
+use app\common\model\group_activity\GroupOrder;
 use app\common\model\pay\PayWay;
 use app\common\model\recharge\RechargeOrder;
 use app\common\model\shops\ShopOrders;
+use app\common\model\group_activity\GroupUserOrder;
 use app\common\model\user\User;
 use app\common\service\pay\AliPayService;
 use app\common\service\pay\WeChatPayService;
@@ -101,8 +103,24 @@ class PaymentLogic extends BaseLogic
     public static function getPayStatus($params)
     {
         try {
-            $order = RechargeOrder::where(['user_id' => $params['user_id'], 'id' => $params['order_id']])
-                ->findOrEmpty();
+            switch ($params['from']) {
+                case 'recharge':
+                    $order = RechargeOrder::where(['user_id' => $params['user_id'], 'id' => $params['order_id']])
+                        ->findOrEmpty();
+                    break;
+                case 'goods':
+                    $order = RechargeOrder::where(['user_id' => $params['user_id'], 'id' => $params['order_id']])
+                        ->findOrEmpty();
+                    break;
+                case 'group':
+                    $order = GroupUserOrder::where(['user_id' => $params['user_id'], 'id' => $params['order_id']])
+                        ->findOrEmpty();
+                    break;
+                default:
+                    throw new \Exception('订单不存在');
+                    break;
+            }
+            
             $payTime = empty($order['pay_time']) ? '' : date('Y-m-d H:i:s', $order['pay_time']);
             $orderInfo = [
                 'order_id' => $order['id'],
@@ -128,7 +146,6 @@ class PaymentLogic extends BaseLogic
         }
     }
 
-
     /**
      * @notes 获取预支付订单信息
      * @param $params
@@ -137,6 +154,7 @@ class PaymentLogic extends BaseLogic
     public static function getPayOrderInfo($params)
     {
         try {
+            
             $order = RechargeOrder::findOrEmpty($params['order_id']);
             if ($order->isEmpty()) {
                 throw new Exception('订单不存在');
@@ -182,7 +200,42 @@ class PaymentLogic extends BaseLogic
         }
     }
 
+     /**
+     * @notes 获取拼团预支付订单信息
+     * @param $params
+     * @return RechargeOrder|array|false|\think\Model
+     */
+    public static function getPayGroupOrderInfo($params)
+    {
+        try {
+            $order = GroupUserOrder::findOrEmpty($params['order_id']);
+            if ($order->isEmpty()) {
+                throw new Exception('订单不存在');
+            }
+            
+            if ($order['pay_status'] == PayEnum::ISPAID) {
+                throw new Exception('订单已支付');
+            }
 
+            $group_order = GroupOrder::where(['id'=>$order['group_order_id']])->findOrEmpty();
+            if ($group_order['num'] >= 100) {
+                throw new Exception('拼团人数已满!');
+            }
+            if ($group_order['status'] == 1 ) {
+                throw new Exception('订单已支付!');
+            }
+            if ($group_order['status'] >= 1 ) {
+                throw new Exception('订单已取消!');
+            }
+            if ($group_order['end_time'] < time()) {
+                throw new Exception('拼团活动已结束!');
+            }
+            return $order;
+        } catch (\Exception $e) {
+            self::$error = $e->getMessage();
+            return false;
+        }
+    }
 
     /**
      * @notes 支付
@@ -211,6 +264,9 @@ class PaymentLogic extends BaseLogic
             case 'goods':
                 RechargeOrder::update(['pay_way' => $payWay, 'pay_sn' => $paySn], ['id' => $order['id']]);
                 break;
+            case 'group':
+                GroupUserOrder::update(['pay_way' => $payWay, 'pay_sn' => $paySn], ['id' => $order['id']]);
+                break;
         }
 
         if ($order['order_amount'] == 0) {
@@ -219,10 +275,10 @@ class PaymentLogic extends BaseLogic
         }
 
         //todo 测试订单
-//        if($order['id']==11){
-//            PayNotifyLogic::handle($from, $order['sn']);
-//            return ['sn' => $order['sn'],'need_pay'=>0];
-//        }
+    //    if($order['id']==11){
+    //        PayNotifyLogic::handle($from, $order['sn']);
+    //        return ['sn' => $order['sn'],'need_pay'=>0];
+    //    }
 
 
         $payService = null;

+ 3 - 0
app/common/model/equity/UserEquity.php

@@ -4,10 +4,13 @@ namespace app\common\model\equity;
 use app\common\model\BaseModel;
 use app\common\model\goods\Goods;
 use app\common\model\user\User;
+use think\model\concern\SoftDelete;
 
 class UserEquity extends BaseModel
 {
 
+    use SoftDelete;
+    protected $deleteTime = 'delete_time';
     protected $name = 'user_equity';
     public function equityConfig()
     {

+ 11 - 0
app/common/model/equity/UserEquityLog.php

@@ -0,0 +1,11 @@
+<?php
+
+namespace app\common\model\equity;
+use app\common\model\BaseModel;
+
+class UserEquityLog extends BaseModel
+{
+
+    protected $name = 'user_equity_log';
+
+}

+ 47 - 0
app/common/model/group_activity/GroupActivity.php

@@ -0,0 +1,47 @@
+<?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\group_activity;
+
+use app\common\model\BaseModel;
+use think\model\concern\SoftDelete;
+use app\common\model\equity\EquityConfig;
+
+
+/**
+ * 拼团活动模型
+ * Class GroupActivity
+ * @package app\common\model\group_activity
+ */
+class GroupActivity extends BaseModel
+{
+    use SoftDelete;
+    protected $name = 'group_activity';
+    protected $deleteTime = 'delete_time';
+    public function goods()
+    {
+        return $this->hasOne(EquityConfig::class, 'id', 'equity_id')
+            ->field('id,equity_name,number,day_num,goods_id');
+    }
+
+    public function getCreateTimeAttr($value,$data)
+    {
+        return !empty($data['create_time'])?date('Y-m-d H:i:s',$data['create_time']):'';
+    }
+    public function getStartTimeAttr($value,$data)
+    {
+        return !empty($data['start_time'])?date('Y-m-d H:i:s',$data['start_time']):'';
+    }
+    
+}

+ 35 - 0
app/common/model/group_activity/GroupOrder.php

@@ -0,0 +1,35 @@
+<?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\group_activity;
+
+
+use app\common\model\BaseModel;
+use think\model\concern\SoftDelete;
+
+
+/**
+ * 拼团活动模型
+ * Class GroupOrder
+ * @package app\common\model\group_order
+ */
+class GroupOrder extends BaseModel
+{
+    protected $name = 'group_order';
+
+    public function getCreateTimeAttr($value,$data)
+    {
+        return !empty($data['create_time'])?date('Y-m-d H:i:s',$data['create_time']):'';
+    }
+}

+ 45 - 0
app/common/model/group_activity/GroupUserOrder.php

@@ -0,0 +1,45 @@
+<?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\group_activity;
+
+
+use app\common\model\BaseModel;
+use think\model\concern\SoftDelete;
+
+
+/**
+ * 拼团活动模型
+ * Class GroupUserOrder
+ * @package app\common\model\group_user_order
+ */
+class GroupUserOrder extends BaseModel
+{
+    use SoftDelete;
+    protected $deleteTime = 'delete_time';
+    protected $name = 'group_user_order';
+
+    public function groupOrder(){
+        return $this->hasOne(GroupOrder::class,'id','group_order_id')->field('id,equity_id,goods_id,sn,status,num,create_time,end_time');
+    }
+    public function getCreateTimeAttr($value,$data)
+    {
+        return !empty($data['create_time'])?date('Y-m-d H:i:s',$data['create_time']):'';
+    }
+    
+    public function getPayTimeAttr($value,$data)
+    {
+        return !empty($data['pay_time'])?date('Y-m-d H:i:s',$data['pay_time']):'';
+    }
+}

+ 23 - 0
app/common/model/service_area/ServiceArea.php

@@ -55,4 +55,27 @@ class ServiceArea extends BaseModel
         }
         return 0;
     }
+
+    /**
+     * 根据经纬度,返回服务区城市信息
+     * @param $params
+     * @return bool
+     */
+    public static function serviceArea($params):array
+    {
+        if (empty($params['lon']) || empty($params['lat'])) {
+            return [];
+        }
+        // 查询服务区所有的地点
+        $rules = ServiceArea::field(['id', 'province', 'city','county', 'area_name', 'electronic_fence'])->select()->toArray();
+        $point=['lng'=> $params['lon'],'lat'=> $params['lat']];
+        foreach ($rules as $value){
+            foreach ($value['electronic_fence'] as $polygon) {
+                if (isPointInPolygon($point, $polygon)) {
+                    return $value;
+                }
+            }
+        }
+        return [];
+    }
 }

+ 2 - 1
composer.json

@@ -35,7 +35,8 @@
         "w7corp/easywechat": "^6.8",
         "tencentcloud/sms": "^3.0",
         "alipaysdk/easysdk": "^2.2",
-        "php-amqplib/php-amqplib": "^3.6"
+        "php-amqplib/php-amqplib": "^3.6",
+        "endroid/qr-code": "^5.1"
     },
     "require-dev": {
         "symfony/var-dumper": ">=4.2",

+ 2 - 0
config/console.php

@@ -19,5 +19,7 @@ return [
         'cancel_dispatch' => 'app\common\command\CancelDispatch',
         //工程师每周更新一次综合评分和服务时长
         'update_worker_score' => 'app\common\command\UpdateWorkerScore',
+        //拼团订单结束
+        'group_order' => 'app\common\command\GroupOrder',
     ],
 ];

+ 8 - 0
config/custom.php

@@ -0,0 +1,8 @@
+<?php
+// +----------------------------------------------------------------------
+// | 应用设置
+// +----------------------------------------------------------------------
+
+return [
+    'cdn_url' => 'https://cdnweixiu.kyjlkj.com/',
+];