Explorar el Código

拼团订单提交

dongxiaoqin hace 1 año
padre
commit
d6db10ce3a

+ 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());
+    }
+
+}

+ 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.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);
     }
 

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

@@ -0,0 +1,54 @@
+<?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['goods_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();
+        }
+        return $detail;
+    }
+}

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

@@ -0,0 +1,68 @@
+<?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',
+        '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']);
+    }
+
+}

+ 8 - 3
app/api/controller/GroupActivityController.php

@@ -61,13 +61,13 @@ class GroupActivityController extends BaseApiController
         //订单信息
         $order = PaymentLogic::getPayGroupOrderInfo($params);
         if (false === $order) {
-            return $this->fail(PaymentLogic::getError(), $params);
+            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(), $params);
+            return $this->fail(PaymentLogic::getError());
         }
         $result['sn'] = $order['sn'];
         return $this->success('', $result);
@@ -116,6 +116,11 @@ class GroupActivityController extends BaseApiController
             '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());
         }
@@ -124,7 +129,7 @@ class GroupActivityController extends BaseApiController
 
     public function deleteOrder()
     {
-        $params = (new GroupOrderValidate())->goCheck('refund',[
+        $params = (new GroupOrderValidate())->post()->goCheck('refund',[
             'user_id' => $this->userId
         ]);
         $result = GroupActivityLogic::deleteOrder($params);

+ 23 - 9
app/api/logic/GroupActivityLogic.php

@@ -224,7 +224,7 @@ class GroupActivityLogic extends BaseLogic
             $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')->findOrEmpty()->toArray();
+                ])->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('订单不存在');
             }
@@ -233,14 +233,17 @@ class GroupActivityLogic extends BaseLogic
             }
             if ($order['user_equity_id']) {
                 //判断权益卡是否已使用
-                $used = UserEquityLog::where(['user_equity_id' => $order['user_equity_id'],'user_id' => $params['user_id']])->findOrEmpty();
+                $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' => 2,'refund_status' => 1]);
+            GroupUserOrder::where('id',$order['id'])->update(['status' => 3,'refund_status' => 1]);
 
             // 生成退款记录
             $recordSn = generate_sn(RefundRecord::class, 'sn');
@@ -258,15 +261,22 @@ class GroupActivityLogic extends BaseLogic
             ]);
 
             // 退款
-            RefundLogic::refund($order, $record['id'], $order['order_amount'], 1);
+            $result = RefundLogic::refund($order, $record['id'], $order['order_amount'], 1);
             
+            $flag = true;
+            $resultMsg = '退款成功';
+            if ($result !== true) {
+                $flag = false;
+                $resultMsg = RefundLogic::getError();
+            }
+
             Db::commit();
-            return true;
+            return [$flag, $resultMsg];
         }
         catch (\Exception $e) {
             Db::rollback();
-            self::setError($e->getMessage());
-            return false;
+            self::$error = $e->getMessage();
+            return [false, $e->getMessage()];
         }
     }
 
@@ -274,13 +284,17 @@ class GroupActivityLogic extends BaseLogic
     {
         try{
             $order =  GroupUserOrder::where([
-                'status' => 0,
-                'user_id' => $params['worker_iuser_idd'],
+                '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){

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

@@ -0,0 +1,173 @@
+<?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());
+        }
+    }
+
+}

+ 4 - 4
app/common/logic/PaymentLogic.php

@@ -275,10 +275,10 @@ class PaymentLogic extends BaseLogic
         }
 
         //todo 测试订单
-       if($order['id']==2){
-           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()
     {

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

@@ -26,10 +26,17 @@ use think\model\concern\SoftDelete;
  */
 class GroupUserOrder extends BaseModel
 {
+    use SoftDelete;
+    protected $deleteTime = 'delete_time';
     protected $name = 'group_user_order';
 
     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']):'';
+    }
 }

+ 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',
     ],
 ];