Browse Source

充值产品

gorden 6 months ago
parent
commit
960ef4d25f
1 changed files with 9 additions and 97 deletions
  1. 9 97
      app/admin/service/goods/MemberRechargeBenefitService.php

+ 9 - 97
app/admin/service/goods/MemberRechargeBenefitService.php

@@ -806,6 +806,9 @@ class MemberRechargeBenefitService
             if (!empty($data['goods_attribute_json'])) {
                 $extendJson = json_decode($data['goods_attribute_json'], true);
                 $data['goods_attribute_json'] = $extendJson;
+                if (isset($extendJson['added'])) {
+                    $data['added_rate'] = floatval($extendJson['added']['nbr']) * 100;
+                }
             }
             if (!empty($extendJson['coupon'])) {
                 foreach ($extendJson['coupon'] as $key => $coupon) {
@@ -1260,116 +1263,22 @@ class MemberRechargeBenefitService
                     $attributeJsonDate = $currentDate . '至' . $lastDate;
                 }
 
-                // if (isset($params['work_time'])){
-                //     $workTimeStart = date('H:i',strtotime($params['work_time'][0]));
-                //     $workTimeEnd = date('H:i',strtotime($params['work_time'][1]));
-                //     $attributeJsonTime = $workTimeStart.'至'.$workTimeEnd;
-                // }
-
                 $attributeJson = [
                     'icon' => $model->goods_cover,
                     'date' => $attributeJsonDate,
-                    // 'time' => $attributeJsonTime,
                     'dates' => $newDates ? array_values($newDates) : [],
                     'times' => $times,
                     'person' => $personTotal
                 ];
-                // if(isset($params['address'])){
-                //     $attributeJson['address'] = $params['address'];
-                // }
-                // if (isset($params['min_count'])){
-                //     $attributeJson['min-count'] = $params['min_count'];
-                // }else{
-                //     $attributeJson['min-count'] = 1;
-                // }
-                // if (isset($params['teachers'])){
-                //     $attributeJson['teachers'] = $params['teachers'];
-                // }
                 if (!empty($params['appointment_label'])) {
                     $attributeJson['label'] = $params['appointment_label'];
                 }
-                // if (!empty($params['address'])) {
-                //     $attributeJson['address'] = $params['address'];
-                // }
-                // if (!empty($params['position'])){
-                //     $attributeJson['position'] = $params['position'];
-                // }
-                // if (isset($params['goods_service_premises'])){
-                //     $attributeJson['service_premises_id'] = $params['goods_service_premises'];
-                // }
                 $model->goods_attribute_json = json_encode($attributeJson, JSON_UNESCAPED_UNICODE);
 
-//                $times = [];
-//                foreach ($params['appointment_times'] as $time) {
-//                    $times[$time['appointmentTimeStart']] = [
-//                        'person' => $time['person'],
-//                        'duration' => $time['appointmentTimeStart'] . '-' . $time['appointmentTimeEnd']
-//                    ];
-//                }
-//                $model->goods_attribute_json = json_encode([
-//                    'icon' => '',
-//                    'dates' => $params['dates'] ?? [],
-//                    'times' => $times
-//                ]);
-            }
-            if (!empty($params['is_support_appointment']) && $params['is_support_appointment'] == 'Y' && !empty($params['appointment_times']) && $params['goods_category'] == 'TRAVEL') {
-                if (!empty($model->goods_attribute_json) && !is_array($model->goods_attribute_json)) {
-                    $attributeJson = json_decode($model->goods_attribute_json, true);
-                } elseif (empty($model->goods_attribute_json)) {
-                    $attributeJson = [];
-                }
-                $attributeJson['travel-day'] = $params['travel_day'];
-                $attributeJson['travel-begin'] = $params['travel_begin'];
-                $attributeJson['travel-night'] = $params['travel_night'];
-                $attributeJson['travel-trans'] = $params['travel_trans'];
-
-                $unixs = [];
-                foreach ($params['appointment_times'] as $times) {
-                    $unix = strtotime($times['days']);
-                    $unixs[$unix] = $times['person'];
-                }
-                ksort($unixs);
-                $months = [];
-                foreach ($unixs as $key => $unix) {
-                    $month = date('Ym', $key);
-                    $day = date('d', $key);
-                    $months[$month][$day] = $unix;
-                }
-                $attributeJson['month'] = $months;
-                $model->goods_attribute_json = json_encode($attributeJson, JSON_UNESCAPED_UNICODE);
-            }
-            if (!empty($params['goods_json']) && $params['join_goods_category_id'] == 65) {
-                $goodsJson = json_decode($params['goods_json'], true);
-//                foreach ($goodsJson as $key => $item) {
-//                    $goodsJson[$key]['color'] = hexToRgb($item['color']);
-//                }
-//
-                $model->goods_json = json_encode($goodsJson);
-            } elseif (!empty($params['goods_json']) && $params['join_goods_category_id'] == 43) {
-                $goodsJson = json_decode($params['goods_json'], true);
-                $newGoodsJson = [];
-                foreach ($goodsJson as $item1) {
-                    if (empty($item1['title'])) {
-                        continue;
-                    }
-                    $newItem1 = [];
-                    foreach ($item1['items'] as $item2) {
-                        $newParams = [];
-                        foreach ($item2['params'] as $param) {
-                            if (!empty($param[0]) || !empty($param[1])) {
-                                $newParams[] = $param;
-                            }
-                        }
-                        $newItem1['items'][$item2['key']] = $newParams;
-                    }
-                    $newItem1['service'] = $item1['service'] ?? '';
-                    $newGoodsJson[$item1['title']] = $newItem1;
-                }
-                $model->goods_json = json_encode($newGoodsJson);
-            } else {
-                $model->goods_json = '[]';
             }
 
+            $model->goods_json = '[]';
+
             if (!empty($params['goods_premisses'])) {
                 $attributeJson = [];
                 if (!empty($model->goods_attribute_json) && !is_array($model->goods_attribute_json)) {
@@ -1720,6 +1629,9 @@ class MemberRechargeBenefitService
             if (!empty($row->goods_attribute_json)) {
                 $attributeJson = json_decode($row->goods_attribute_json, true);
             }
+            if (isset($params['added_rate'])) {
+                $attributeJson['added']['nbr'] = round($params['added_rate'] / 100, 2);
+            }
             if (!empty($params['chooseCoupons'])) {
                 $couponList = [];
                 foreach ($params['chooseCoupons'] as $chooseCoupon) {
@@ -1730,7 +1642,7 @@ class MemberRechargeBenefitService
                         'coupon_id' => $coupon->coupon_id,
                         'num' => $chooseCoupon['num'],
                         'name' => $coupon->coupon_name,
-                        'icon' => str_replace(getenv("STORAGE_DOMAIN"), '', str_replace('/thumb','',$chooseCoupon['icon'])),
+                        'icon' => str_replace(getenv("STORAGE_DOMAIN"), '', str_replace('/thumb', '', $chooseCoupon['icon'])),
                         'unit' => '张'
                     ];
                 }