moonsflyer 5 месяцев назад
Родитель
Сommit
6a10f471a1
2 измененных файлов с 48 добавлено и 30 удалено
  1. 10 11
      app/shopapi/lists/OrderLists.php
  2. 38 19
      app/shopapi/logic/Order/OrderBtnLogic.php

+ 10 - 11
app/shopapi/lists/OrderLists.php

@@ -45,45 +45,44 @@ class OrderLists extends BaseShopDataLists
 //        if($this->params['type'] == 'return'){
 //            $r_where[] = ['is_after_sale', '=', 1];
 //        }
-        $c_type = $this->params['type'] ;
+        $c_type = $this->params['type'];
 //        outFileLog($c_type,'getexpress','c_type');
         $lists = Order::withSearch(['order_type', 'user_id'], [
-                'order_type' => $this->params['type'],
-                'user_id' => $this->userId
-            ])
+            'order_type' => $this->params['type'],
+            'user_id' => $this->userId
+        ])
             ->with(['order_goods' => function ($query) {
                 $query->field('goods_id,order_id,goods_snap,goods_name,goods_price,goods_num,is_comment,original_price')
                     ->append(['goods_image', 'spec_value_str'])
                     ->hidden(['goods_snap']);
             }])
 //            ->where($r_where)
-            ->field(['id', 'sn', 'order_type', 'order_status', 'total_num', 'order_amount', 'delivery_type', 'is_team_success', 'pay_way', 'pay_status', 'pay_time', 'express_status','delivery_content', 'delivery_content1', 'delivery_content_type', 'create_time', 'presell_id', 'transaction_id' ,'is_after_sale' ,'after_sale_status' ])
+            ->field(['id', 'sn', 'order_type', 'order_status', 'total_num', 'order_amount', 'delivery_type', 'is_team_success', 'pay_way', 'pay_status', 'pay_time', 'express_status', 'delivery_content', 'delivery_content1', 'delivery_content_type', 'create_time', 'presell_id', 'transaction_id', 'is_after_sale', 'after_sale_status'])
             ->append(['btn'])
             ->order(['id' => 'desc'])
             ->limit($this->limitOffset, $this->limitLength)
             ->select()->toArray();
 
 
-        foreach ($lists as &$list){
+        foreach ($lists as &$list) {
             //查看提货码按钮
             $list['btn']['pickup_btn'] = ($list['order_status'] == OrderEnum::STATUS_WAIT_DELIVERY && $list['delivery_type'] == DeliveryEnum::SELF_DELIVERY) ? 1 : 0;
             //订单状态描述
             $list['order_status_desc'] = ($list['order_status'] == OrderEnum::STATUS_WAIT_DELIVERY && $list['delivery_type'] == DeliveryEnum::SELF_DELIVERY) ? '待取货' : OrderEnum::getOrderStatusDesc($list['order_status']);
-            if ($list['order_type'] == OrderEnum::TEAM_ORDER && $list['is_team_success'] != TeamEnum::TEAM_FOUND_SUCCESS){
+            if ($list['order_type'] == OrderEnum::TEAM_ORDER && $list['is_team_success'] != TeamEnum::TEAM_FOUND_SUCCESS) {
                 $list['btn']['pickup_btn'] = 0;
                 $list['order_status_desc'] = ($list['order_status'] == OrderEnum::STATUS_WAIT_DELIVERY) ? TeamEnum::getStatusDesc($list['is_team_success']) : OrderEnum::getOrderStatusDesc($list['order_status']);
             }
 
             //订单类型
             $list['order_type_desc'] = ($list['delivery_type'] == DeliveryEnum::SELF_DELIVERY) ? '自提订单' : OrderEnum::getOrderTypeDesc($list['order_type']);
-            
+
             // 预售信息
             if ($list['order_type'] == OrderEnum::PRESELL_ORDER) {
                 $list['presell'] = CommonPresellLogic::orderInfo($list);
             }
-            $list['btn']['after_sale_btn'] = ($list['is_after_sale'] == 1) ? 1 : 0;
-            if($this->params['type'] == 'return'){
-                $afterOrder = AfterSale::where(['order_id'=>$list['id']])->find();
+            if ($this->params['type'] == 'return') {
+                $afterOrder = AfterSale::where(['order_id' => $list['id']])->find();
                 $list['after_order'] = $afterOrder;
 //                $list['btn']['confirm_btn'] = 0 ;
 //                $list['btn']['delivery_btn'] = 0 ;

+ 38 - 19
app/shopapi/logic/Order/OrderBtnLogic.php

@@ -43,18 +43,19 @@ class OrderBtnLogic extends BaseLogic
      * @author 段誉
      * @date 2021/8/2 20:07
      */
-    public static function getOrderBtn(Order $order )
+    public static function getOrderBtn(Order $order)
     {
         return [
-            'pay_btn'       => self::getPayBtn($order),
-            'cancel_btn'    => self::getCancelBtn($order),  //撤销
-            'delivery_btn'  => self::getDeliveryBtn($order),
-            'confirm_btn'   => self::getConfirmBtn($order),
-            'finish_btn'    => self::getFinishBtn($order),
-            'comment_btn'   => self::getCommentBtn($order),
-            'refund_btn'    => self::getRefundBtn($order),
-            'delete_btn'    => self::getDeletedBtn($order),
-            'content_btn'   => self::getContentBtn($order),
+            'after_sale_btn' => self::getAfterSaleBtn($order),
+            'pay_btn' => self::getPayBtn($order),
+            'cancel_btn' => self::getCancelBtn($order),  //撤销
+            'delivery_btn' => self::getDeliveryBtn($order),
+            'confirm_btn' => self::getConfirmBtn($order),
+            'finish_btn' => self::getFinishBtn($order),
+            'comment_btn' => self::getCommentBtn($order),
+            'refund_btn' => self::getRefundBtn($order),
+            'delete_btn' => self::getDeletedBtn($order),
+            'content_btn' => self::getContentBtn($order),
 //            'express_btn'   => self::getExpressBtn($order), //快递单号btn
 //            'reapply_btn'   => self::getReapplyBtn($order), //重新申请
 //            'return_cancel_btn'    => self::getReturnCancelBtn($order),  //撤销申请
@@ -124,7 +125,7 @@ class OrderBtnLogic extends BaseLogic
         if ($order['order_status'] == OrderEnum::STATUS_WAIT_DELIVERY && $order['pay_status'] == PayEnum::ISPAID && $order['express_status'] == DeliveryEnum::PART_SHIPPED && $order['delivery_type'] == DeliveryEnum::EXPRESS_DELIVERY) {
             $btn = OrderEnum::BTN_SHOW;
         }
-        if (in_array($order['order_status'],[OrderEnum::STATUS_WAIT_RECEIVE,OrderEnum::STATUS_FINISH]) && $order['delivery_type'] == DeliveryEnum::EXPRESS_DELIVERY) {
+        if (in_array($order['order_status'], [OrderEnum::STATUS_WAIT_RECEIVE, OrderEnum::STATUS_FINISH]) && $order['delivery_type'] == DeliveryEnum::EXPRESS_DELIVERY) {
             $btn = OrderEnum::BTN_SHOW;
         }
         return $btn;
@@ -144,7 +145,7 @@ class OrderBtnLogic extends BaseLogic
         if ($order['order_status'] == OrderEnum::STATUS_WAIT_RECEIVE) {
             $btn = OrderEnum::BTN_SHOW;
         }
-        
+
         return $btn;
     }
 
@@ -239,17 +240,18 @@ class OrderBtnLogic extends BaseLogic
      * @author cjhao
      * @date 2022/4/20 17:23
      */
-    public static function getContentBtn($order){
+    public static function getContentBtn($order)
+    {
 
         $btn = OrderEnum::BTN_HIDE;
         //虚拟订单,有发货内容
-        if(
+        if (
             OrderEnum::VIRTUAL_ORDER == $order['order_type']
             &&
             ($order['delivery_content'] || $order['delivery_content1'])
             &&
-            in_array($order['order_status'], [OrderEnum::STATUS_WAIT_RECEIVE,OrderEnum::STATUS_FINISH])
-        ){
+            in_array($order['order_status'], [OrderEnum::STATUS_WAIT_RECEIVE, OrderEnum::STATUS_FINISH])
+        ) {
             $btn = OrderEnum::BTN_SHOW;
         }
         return $btn;
@@ -265,11 +267,12 @@ class OrderBtnLogic extends BaseLogic
     public static function getExpressBtn($order)
     {
         $btn = OrderEnum::BTN_HIDE;
-        if($order['is_after_sale'] == 1 && $order['after_sale_status']  == 4 ){
+        if ($order['is_after_sale'] == 1 && $order['after_sale_status'] == 4) {
             $btn = OrderEnum::BTN_SHOW;
         }
         return $btn;
     }
+
     /**
      * @notes 重新申请
      * @param $order
@@ -281,7 +284,7 @@ class OrderBtnLogic extends BaseLogic
     {
         $btn = OrderEnum::BTN_HIDE;
 
-        if($order['is_after_sale'] == 1 && $order['after_sale_status']  == 3){
+        if ($order['is_after_sale'] == 1 && $order['after_sale_status'] == 3) {
             $btn = OrderEnum::BTN_SHOW;
         }
 
@@ -303,8 +306,24 @@ class OrderBtnLogic extends BaseLogic
         if ($order['after_sale_status'] == 1 || $order['after_sale_status'] == 4) {
             $btn = OrderEnum::BTN_SHOW;
         }
-        
+
         return $btn;
     }
 
+    /**
+     * @notes 售后菜单
+     * @param $order
+     * @return int
+     * @author 段誉
+     * @date 2021/8/2 20:25
+     */
+    public static function getAfterSaleBtn($order)
+    {
+        $btn = OrderEnum::BTN_HIDE;
+
+        if ($order['is_after_sale'] == 1) {
+            $btn = OrderEnum::BTN_SHOW;
+        }
+        return $btn;
+    }
 }