|
@@ -826,14 +826,14 @@ class CardService
|
|
|
}
|
|
|
$data['goods_detail_slider_json'] = rtrim($slider, ',');
|
|
|
}
|
|
|
- $extendJson = [];
|
|
|
+ $goodsAttributeJson = [];
|
|
|
if (!empty($data['goods_attribute_json'])) {
|
|
|
- $extendJson = json_decode($data['goods_attribute_json'], true);
|
|
|
- $data['goods_attribute_json'] = $extendJson;
|
|
|
+ $goodsAttributeJson = json_decode($data['goods_attribute_json'], true);
|
|
|
+ $data['goods_attribute_json'] = $goodsAttributeJson;
|
|
|
}
|
|
|
- if (!empty($extendJson['card_main_id'])) {
|
|
|
- $data['card_main_id'] = $extendJson['card_main_id'];
|
|
|
- $cardMain = CardMain::with('category')->where('card_main_id', $extendJson['card_main_id'])->first();
|
|
|
+ if (!empty($goodsAttributeJson['card_main_id'])) {
|
|
|
+ $data['card_main_id'] = $goodsAttributeJson['card_main_id'];
|
|
|
+ $cardMain = CardMain::with('category')->where('card_main_id', $goodsAttributeJson['card_main_id'])->first();
|
|
|
if (!empty($cardMain) && !empty($cardMain->card_main_valid_mode)) {
|
|
|
$validTerm = '';
|
|
|
if ($cardMain->card_main_valid_mode == 'LONG') {
|
|
@@ -855,6 +855,8 @@ class CardService
|
|
|
];
|
|
|
}
|
|
|
}
|
|
|
+ $data['protocol'] = $goodsAttributeJson['protocol'] ?? '';
|
|
|
+ $data['protocol_name'] = $goodsAttributeJson['protocol_name'] ?? '';
|
|
|
|
|
|
$data['express_json'] = [];
|
|
|
if (!empty($data['goods_express_json'])) {
|
|
@@ -1271,82 +1273,37 @@ class CardService
|
|
|
|
|
|
$model->goods_json = '[]';
|
|
|
|
|
|
+ $attributeJson = [];
|
|
|
+ if (!empty($model->goods_attribute_json)) {
|
|
|
+ $attributeJson = json_decode($model->goods_attribute_json, true);
|
|
|
+ }
|
|
|
if (!empty($params['goods_premisses'])) {
|
|
|
- $attributeJson = [];
|
|
|
- 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['premisses'] = $params['goods_premisses'];
|
|
|
- $model->goods_attribute_json = json_encode($attributeJson);
|
|
|
- }
|
|
|
-
|
|
|
- if (!empty($params['goods_theme_color']) && !empty($params['goods_theme_icon'])) {
|
|
|
- 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['bg'] = $params['goods_theme_color'];
|
|
|
- $attributeJson['icon'] = str_replace(getenv('STORAGE_DOMAIN'), '', $params['goods_theme_icon']);
|
|
|
- $model->goods_attribute_json = json_encode($attributeJson);
|
|
|
}
|
|
|
if (!empty($params['address'])) {
|
|
|
- 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['address'] = $params['address'];
|
|
|
- $model->goods_attribute_json = json_encode($attributeJson);
|
|
|
}
|
|
|
if (!empty($params['position'])) {
|
|
|
- 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['position'] = $params['position'];
|
|
|
- $model->goods_attribute_json = json_encode($attributeJson);
|
|
|
}
|
|
|
if (isset($params['goods_service_premises'])) {
|
|
|
- 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['service_premises_id'] = $params['goods_service_premises'];
|
|
|
- $model->goods_attribute_json = json_encode($attributeJson);
|
|
|
}
|
|
|
if (isset($params['min_count'])) {
|
|
|
- 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['min-count'] = $params['min_count'];
|
|
|
- $model->goods_attribute_json = json_encode($attributeJson);
|
|
|
- }
|
|
|
- if (isset($params['teachers'])) {
|
|
|
- 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['teachers'] = $params['teachers'];
|
|
|
- $model->goods_attribute_json = json_encode($attributeJson);
|
|
|
}
|
|
|
if (!empty($params['card_main_id'])) {
|
|
|
- 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['payment'] = 'Wx+Ali';
|
|
|
$attributeJson['card_main_id'] = $params['card_main_id'];
|
|
|
- $model->goods_attribute_json = json_encode($attributeJson, JSON_UNESCAPED_UNICODE);
|
|
|
}
|
|
|
+ if (!empty($params['protocol'])){
|
|
|
+ $attributeJson['protocol'] = $params['protocol'];
|
|
|
+ }
|
|
|
+ if (!empty($params['protocol_name'])){
|
|
|
+ $attributeJson['protocol_name'] = $params['protocol_name'];
|
|
|
+ }
|
|
|
+ $model->goods_attribute_json = json_encode($attributeJson);
|
|
|
+
|
|
|
if ($model->save()) {
|
|
|
return $model->goods_id;
|
|
|
}
|
|
@@ -1598,6 +1555,16 @@ class CardService
|
|
|
if (!empty($params['card_main_id'])) {
|
|
|
$attributeJson['card_main_id'] = $params['card_main_id'];
|
|
|
}
|
|
|
+ if (!empty($params['protocol'])){
|
|
|
+ $attributeJson['protocol'] = $params['protocol'];
|
|
|
+ }else{
|
|
|
+ unset($attributeJson['protocol']);
|
|
|
+ }
|
|
|
+ if (!empty($params['protocol_name'])){
|
|
|
+ $attributeJson['protocol_name'] = $params['protocol_name'];
|
|
|
+ }else{
|
|
|
+ unset($attributeJson['protocol_name']);
|
|
|
+ }
|
|
|
|
|
|
$data['goods_attribute_json'] = json_encode($attributeJson, JSON_UNESCAPED_UNICODE);
|
|
|
|