dongxiaoqin 1 rok temu
rodzic
commit
2eb96093c4

+ 1 - 1
app/adminapi/lists/group_activity/GroupActivityLists.php

@@ -56,7 +56,7 @@ class GroupActivityLists extends BaseAdminDataLists implements ListsSearchInterf
     public function lists(): array
     public function lists(): array
     {
     {
         $list = GroupActivity::where($this->searchWhere)
         $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'])
+            ->field(['id', 'title', 'image','goods_id','origin_price','price','start_time', 'end_time', 'participant_num', 'type', 'form_time_limit', 'is_simulate_form', 'simulate_num'])
             ->limit($this->limitOffset, $this->limitLength)
             ->limit($this->limitOffset, $this->limitLength)
             ->order(['id' => 'desc'])
             ->order(['id' => 'desc'])
             ->select()
             ->select()

+ 2 - 2
app/adminapi/logic/group_activity/GroupActivityLogic.php

@@ -55,7 +55,7 @@ class GroupActivityLogic extends BaseLogic
             GroupActivity::create([
             GroupActivity::create([
                 'title' => $params['title'],
                 'title' => $params['title'],
                 'image' => $params['image'],
                 'image' => $params['image'],
-                'equity_id' => $params['equity_id'],
+                'goods_id' => $params['goods_id'],
                 'origin_price' => $params['origin_price'],
                 'origin_price' => $params['origin_price'],
                 'price' => $params['price'],
                 'price' => $params['price'],
                 'start_time' => strtotime($params['start_time']),
                 'start_time' => strtotime($params['start_time']),
@@ -106,7 +106,7 @@ class GroupActivityLogic extends BaseLogic
             GroupActivity::where('id', $params['id'])->update([
             GroupActivity::where('id', $params['id'])->update([
                 'title' => $params['title'],
                 'title' => $params['title'],
                 'image' => $params['image'],
                 'image' => $params['image'],
-                'equity_id' => $params['equity_id'],
+                'goods_id' => $params['goods_id'],
                 'origin_price' => $params['origin_price'],
                 'origin_price' => $params['origin_price'],
                 'price' => $params['price'],
                 'price' => $params['price'],
                 'start_time' => strtotime($params['start_time']),
                 'start_time' => strtotime($params['start_time']),

+ 4 - 4
app/adminapi/validate/group_activity/GroupActivityValidate.php

@@ -34,7 +34,7 @@ class GroupActivityValidate extends BaseValidate
         'id' => 'require',
         'id' => 'require',
         'title' => 'require',
         'title' => 'require',
         'image' => 'require',
         'image' => 'require',
-        'equity_id' => 'require',
+        'goods_id' => 'require',
         'origin_price' => 'require',
         'origin_price' => 'require',
         'price' => 'require',
         'price' => 'require',
         'start_time' => 'require',
         'start_time' => 'require',
@@ -55,7 +55,7 @@ class GroupActivityValidate extends BaseValidate
         'id' => 'id',
         'id' => 'id',
         'title' => '活动名称',
         'title' => '活动名称',
         'image' => '活动图片',
         'image' => '活动图片',
-        'equity_id' => '权益卡',
+        'goods_id' => '商品',
         'origin_price' => '拼团原价',
         'origin_price' => '拼团原价',
         'price' => '拼团价',
         'price' => '拼团价',
         'start_time' => '活动开始时间',
         'start_time' => '活动开始时间',
@@ -76,7 +76,7 @@ class GroupActivityValidate extends BaseValidate
      */
      */
     public function sceneAdd()
     public function sceneAdd()
     {
     {
-        return $this->only(['title','equity_id','start_time','end_time','participant_num','type','form_time_limit','is_simulate_form']);
+        return $this->only(['title','goods_id','start_time','end_time','participant_num','type','form_time_limit','is_simulate_form']);
     }
     }
 
 
 
 
@@ -88,7 +88,7 @@ class GroupActivityValidate extends BaseValidate
      */
      */
     public function sceneEdit()
     public function sceneEdit()
     {
     {
-        return $this->only(['id','title','equity_id','start_time','end_time','participant_num','type','form_time_limit','is_simulate_form']);
+        return $this->only(['id','title','goods_id','start_time','end_time','participant_num','type','form_time_limit','is_simulate_form']);
     }
     }
 
 
 
 

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

@@ -1,8 +1,10 @@
 <?php
 <?php
 namespace app\api\controller;
 namespace app\api\controller;
 
 
+use app\common\logic\PaymentLogic;
 use app\api\logic\GroupActivityLogic;
 use app\api\logic\GroupActivityLogic;
 use app\api\validate\GroupOrderValidate;
 use app\api\validate\GroupOrderValidate;
+use app\api\lists\group_activity\UserOrderLists;
 
 
 
 
 /**
 /**
@@ -27,6 +29,9 @@ class GroupActivityController extends BaseApiController
         $result = GroupActivityLogic::orderDetail($sn,$this->userId);
         $result = GroupActivityLogic::orderDetail($sn,$this->userId);
         return $this->data($result);
         return $this->data($result);
     }
     }
+    public function orderList(){
+        return $this->dataLists(new UserOrderLists());
+    }
 
 
     /**
     /**
      * 提交订单
      * 提交订单
@@ -36,6 +41,7 @@ class GroupActivityController extends BaseApiController
     {
     {
         $params = (new GroupOrderValidate())->post()->goCheck('add', [
         $params = (new GroupOrderValidate())->post()->goCheck('add', [
             'user_id' => $this->userId,
             'user_id' => $this->userId,
+            'terminal' => $this->userInfo['terminal'],
             'user_info' => $this->userInfo
             'user_info' => $this->userInfo
         ]);
         ]);
         $result = GroupActivityLogic::submitOrder($params);
         $result = GroupActivityLogic::submitOrder($params);
@@ -45,6 +51,45 @@ class GroupActivityController extends BaseApiController
         return $this->data($result);
         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(), $params);
+        }
+        //支付流程
+        $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);
+        }
+        $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
      * @return \think\response\Json
@@ -61,4 +106,32 @@ class GroupActivityController extends BaseApiController
         return $this->success('取消成功', [], 1, 1);
         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);
+        if (false === $result) {
+            return $this->fail(GroupActivityLogic::getError());
+        }
+        return $this->success('退款成功', [], 1, 1);
+    }
+
+    public function deleteOrder()
+    {
+        $params = (new GroupOrderValidate())->goCheck('refund',[
+            'user_id' => $this->userId
+        ]);
+        $result = GroupActivityLogic::deleteOrder($params);
+        if (false === $result) {
+            return $this->fail(GroupActivityLogic::getError());
+        }
+        return $this->success('删除成功', [], 1, 1);
+    }
+
 }
 }

+ 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.id', '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();
+    }
+
+}

+ 102 - 12
app/api/logic/GroupActivityLogic.php

@@ -3,7 +3,12 @@ namespace app\api\logic;
 
 
 use think\Exception;
 use think\Exception;
 use think\facade\Db;
 use think\facade\Db;
+use app\common\enum\RefundEnum;
 use app\common\logic\BaseLogic;
 use app\common\logic\BaseLogic;
+use app\common\logic\RefundLogic;
+use app\common\model\equity\UserEquity;
+use app\common\model\refund\RefundRecord;
+use app\common\model\equity\UserEquityLog;
 use app\common\model\service_area\ServiceArea;
 use app\common\model\service_area\ServiceArea;
 use app\common\model\group_activity\GroupOrder;
 use app\common\model\group_activity\GroupOrder;
 use app\common\model\group_activity\GroupActivity;
 use app\common\model\group_activity\GroupActivity;
@@ -42,11 +47,15 @@ class GroupActivityLogic extends BaseLogic
         $detail = GroupOrder::where(['sn'=>$sn])->findOrEmpty()->toArray();
         $detail = GroupOrder::where(['sn'=>$sn])->findOrEmpty()->toArray();
         if(!empty($detail)){
         if(!empty($detail)){
            
            
-            $detail['activity'] = GroupActivity::with('goods')->where(['id'=>$detail['group_activity_id']])->findOrEmpty()->toArray();
+            $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')
             $detail['users'] = GroupUserOrder::alias('a')
                                 ->leftJoin('user b','a.user_id=b.id')
                                 ->leftJoin('user b','a.user_id=b.id')
                                 ->where(['a.sn'=>$sn,'a.status'=>1])
                                 ->where(['a.sn'=>$sn,'a.status'=>1])
-                                ->visible(['a.id','a.user_id','a.status','a.create_time','b.avatar','b.nickname'])
+                                ->field(['a.id','a.user_id','a.status','a.create_time','b.avatar','b.nickname'])
+                                ->order('a.create_time','asc')
                                 ->select()
                                 ->select()
                                 ->toArray();
                                 ->toArray();
         }
         }
@@ -110,7 +119,7 @@ class GroupActivityLogic extends BaseLogic
                     'origin_price' => $activity['origin_price'],
                     'origin_price' => $activity['origin_price'],
                     'price' => $order_amount,
                     'price' => $order_amount,
                     'create_time' => time(),
                     'create_time' => time(),
-                    'end_time'   => time() + $activity['form_time_limit'] * 60,
+                    'end_time'   => time() + $activity['form_time_limit'] * 60 * 60,
                 ];
                 ];
                 $group_order = GroupOrder::create($data);
                 $group_order = GroupOrder::create($data);
             } else {
             } else {
@@ -119,16 +128,18 @@ class GroupActivityLogic extends BaseLogic
                 if (empty($group_order)) {
                 if (empty($group_order)) {
                     throw new Exception('拼团订单不存在!'); //拼团活动不存在
                     throw new Exception('拼团订单不存在!'); //拼团活动不存在
                 }
                 }
-                if ($group_order['status'] != 0) {
-                    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 (strtotime($group_order['end_time']) < time()) {
                 if (strtotime($group_order['end_time']) < time()) {
                     throw new Exception('拼团活动已结束!'); //拼团活动已结束
                     throw new Exception('拼团活动已结束!'); //拼团活动已结束
                 }
                 }
-                if ($group_order['num'] >= 100) {
-                    throw new Exception('拼团人数已满!'); //拼团人数已满
-                }
-
                 $order_amount = $group_order['price'];
                 $order_amount = $group_order['price'];
             }
             }
 
 
@@ -148,6 +159,7 @@ class GroupActivityLogic extends BaseLogic
                 'area_name' => $areas['area_name']??'',
                 'area_name' => $areas['area_name']??'',
                 'service_area_id' => $areas['id']??0,
                 'service_area_id' => $areas['id']??0,
                 'order_amount' => $order_amount,
                 'order_amount' => $order_amount,
+                'order_terminal' => $params['terminal'],
             ];
             ];
             $group_user_order = GroupUserOrder::create($data);
             $group_user_order = GroupUserOrder::create($data);
 
 
@@ -176,21 +188,22 @@ class GroupActivityLogic extends BaseLogic
             $detail =  GroupUserOrder::where([
             $detail =  GroupUserOrder::where([
                     'user_id' => $params['user_id'],
                     'user_id' => $params['user_id'],
                     'sn'=>$params['sn']
                     'sn'=>$params['sn']
-                ])->file('id,status')->findOrEmpty()->toArray();
+                ])->field('id,status')->findOrEmpty()->toArray();
             if(empty($detail)){
             if(empty($detail)){
                 throw new Exception('订单不存在');
                 throw new Exception('订单不存在');
             }
             }
             if($detail['status'] == 1){
             if($detail['status'] == 1){
-                throw new Exception('已支付订单不取消');
+                throw new Exception('已支付订单不支持取消');
             }
             }
             if($detail['status'] != 0){
             if($detail['status'] != 0){
-                throw new Exception('当前订单不取消');
+                throw new Exception('当前订单不支持取消');
             }
             }
 
 
             //将用户订单状态更新为已取消
             //将用户订单状态更新为已取消
             GroupUserOrder::where('id',$detail['id'])->update(['status' => 4, 'pay_status' => 2]);
             GroupUserOrder::where('id',$detail['id'])->update(['status' => 4, 'pay_status' => 2]);
             
             
             Db::commit();
             Db::commit();
+            return true;
         }
         }
         catch (\Exception $e) {
         catch (\Exception $e) {
             Db::rollback();
             Db::rollback();
@@ -198,4 +211,81 @@ class GroupActivityLogic extends BaseLogic
             return false;
             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')->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']])->findOrEmpty();
+                if ($used) {
+                    throw new Exception('当前权益卡已使用,不支持退款');
+                }
+            }
+
+            //将用户订单状态更新为申请退款
+            GroupUserOrder::where('id',$order['id'])->update(['status' => 2,'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']),
+            ]);
+
+            // 退款
+            RefundLogic::refund($order, $record['id'], $order['order_amount'], 1);
+            
+            Db::commit();
+            return true;
+        }
+        catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+    public static function deleteOrder($params):bool
+    {
+        try{
+            $order =  GroupUserOrder::where([
+                'status' => 0,
+                'user_id' => $params['worker_iuser_idd'],
+                'sn' => $params['sn']
+            ])->findOrEmpty();
+            if($order->isEmpty()){
+                throw new \Exception('订单不存在');
+            }
+            $order->delete();
+            return true;
+        } catch(\Exception $e){
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
 }
 }

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

@@ -58,4 +58,23 @@ class GroupOrderValidate extends BaseValidate
         return $this->only(['lon','lat']);
         return $this->only(['lon','lat']);
     }
     }
 
 
+    /**
+     * @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']);
+    }
+
 }
 }

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

@@ -35,6 +35,7 @@ class RefundEnum
     // 退款订单类型
     // 退款订单类型
     const ORDER_TYPE_ORDER = 'order'; // 普通订单
     const ORDER_TYPE_ORDER = 'order'; // 普通订单
     const ORDER_TYPE_RECHARGE = 'recharge'; // 充值订单
     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\user\AccountLogEnum;
 use app\common\enum\WorkEnum;
 use app\common\enum\WorkEnum;
 use app\common\model\equity\UserEquity;
 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\OrderGoods;
 use app\common\model\recharge\RechargeOrder;
 use app\common\model\recharge\RechargeOrder;
 use app\common\model\shops\ShopOrders;
 use app\common\model\shops\ShopOrders;
@@ -166,6 +168,31 @@ class PayNotifyLogic extends BaseLogic
         $order->shop_order_type = 2;
         $order->shop_order_type = 2;
         $order->save();
         $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\PayEnum;
 use app\common\enum\YesNoEnum;
 use app\common\enum\YesNoEnum;
 use app\common\model\effective\EffectiveCategory;
 use app\common\model\effective\EffectiveCategory;
+use app\common\model\group_activity\GroupOrder;
 use app\common\model\pay\PayWay;
 use app\common\model\pay\PayWay;
 use app\common\model\recharge\RechargeOrder;
 use app\common\model\recharge\RechargeOrder;
 use app\common\model\shops\ShopOrders;
 use app\common\model\shops\ShopOrders;
+use app\common\model\group_activity\GroupUserOrder;
 use app\common\model\user\User;
 use app\common\model\user\User;
 use app\common\service\pay\AliPayService;
 use app\common\service\pay\AliPayService;
 use app\common\service\pay\WeChatPayService;
 use app\common\service\pay\WeChatPayService;
@@ -101,8 +103,24 @@ class PaymentLogic extends BaseLogic
     public static function getPayStatus($params)
     public static function getPayStatus($params)
     {
     {
         try {
         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']);
             $payTime = empty($order['pay_time']) ? '' : date('Y-m-d H:i:s', $order['pay_time']);
             $orderInfo = [
             $orderInfo = [
                 'order_id' => $order['id'],
                 'order_id' => $order['id'],
@@ -128,7 +146,6 @@ class PaymentLogic extends BaseLogic
         }
         }
     }
     }
 
 
-
     /**
     /**
      * @notes 获取预支付订单信息
      * @notes 获取预支付订单信息
      * @param $params
      * @param $params
@@ -137,6 +154,7 @@ class PaymentLogic extends BaseLogic
     public static function getPayOrderInfo($params)
     public static function getPayOrderInfo($params)
     {
     {
         try {
         try {
+            
             $order = RechargeOrder::findOrEmpty($params['order_id']);
             $order = RechargeOrder::findOrEmpty($params['order_id']);
             if ($order->isEmpty()) {
             if ($order->isEmpty()) {
                 throw new Exception('订单不存在');
                 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 (strtotime($group_order['end_time']) < time()) {
+                throw new Exception('拼团活动已结束!');
+            }
+            return $order;
+        } catch (\Exception $e) {
+            self::$error = $e->getMessage();
+            return false;
+        }
+    }
 
 
     /**
     /**
      * @notes 支付
      * @notes 支付
@@ -211,6 +264,9 @@ class PaymentLogic extends BaseLogic
             case 'goods':
             case 'goods':
                 RechargeOrder::update(['pay_way' => $payWay, 'pay_sn' => $paySn], ['id' => $order['id']]);
                 RechargeOrder::update(['pay_way' => $payWay, 'pay_sn' => $paySn], ['id' => $order['id']]);
                 break;
                 break;
+            case 'group':
+                GroupUserOrder::update(['pay_way' => $payWay, 'pay_sn' => $paySn], ['id' => $order['id']]);
+                break;
         }
         }
 
 
         if ($order['order_amount'] == 0) {
         if ($order['order_amount'] == 0) {
@@ -219,10 +275,10 @@ class PaymentLogic extends BaseLogic
         }
         }
 
 
         //todo 测试订单
         //todo 测试订单
-//        if($order['id']==11){
-//            PayNotifyLogic::handle($from, $order['sn']);
-//            return ['sn' => $order['sn'],'need_pay'=>0];
-//        }
+       if($order['id']==2){
+           PayNotifyLogic::handle($from, $order['sn']);
+           return ['sn' => $order['sn'],'need_pay'=>0];
+       }
 
 
 
 
         $payService = null;
         $payService = null;

+ 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';
+
+}

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

@@ -32,4 +32,8 @@ class GroupOrder extends BaseModel
     {
     {
         return !empty($data['create_time'])?date('Y-m-d H:i:s',$data['create_time']):'';
         return !empty($data['create_time'])?date('Y-m-d H:i:s',$data['create_time']):'';
     }
     }
+    public function getEndTimeAttr($value,$data)
+    {
+        return !empty($data['end_time'])?date('Y-m-d H:i:s',$data['end_time']):'';
+    }
 }
 }