소스 검색

券包调整

gorden 1 개월 전
부모
커밋
d387a3d879
1개의 변경된 파일25개의 추가작업 그리고 0개의 파일을 삭제
  1. 25 0
      app/admin/controller/coupon/CouponPacketSequenceController.php

+ 25 - 0
app/admin/controller/coupon/CouponPacketSequenceController.php

@@ -188,6 +188,31 @@ class CouponPacketSequenceController extends Curd
                 }
             }
         }
+        $coupons = [];
+        if (!empty($sequence->coupon_packet_sequence_json)) {
+            $sequenceJson = json_decode($sequence->coupon_packet_sequence_json, true);
+            if (isset($sequenceJson['coupons'])) {
+                $couponIds = array_keys($sequenceJson['coupons']);
+                $couponModel = Coupon::whereIn('coupon_id', $couponIds)
+                    ->select('coupon_id', 'coupon_name','coupon_classify','coupon_value','coupon_minimum_limit','coupon_category')
+                    ->get()
+                    ->toArray();
+                foreach ($couponModel as $coupon) {
+                    foreach ($sequenceJson['coupons'] as $key => $jsonCoupon) {
+                        if ($coupon['coupon_id'] == $key) {
+                            $coupons[] = [
+                                'id' => $key,
+                                'name' => $coupon['coupon_name'],
+                                'nbr' => $jsonCoupon['num'],
+                                'classify'=>$coupon['coupon_classify'],
+                                'info'=>CouponService::couponClassifyInfo($coupon['coupon_classify'],$coupon['coupon_category'],$coupon['coupon_value'],$coupon['coupon_minimum_limit'])
+                            ];
+                        }
+                    }
+                }
+            }
+        }
+        $sequence->coupons = $coupons;
 
         return json_success('', $sequence);
     }