|
@@ -185,7 +185,7 @@ class GoodsService
|
|
|
$query->where('goods_classify', $classify);
|
|
|
}
|
|
|
})
|
|
|
- ->orderBy('goods_sort','DESC')
|
|
|
+ ->orderBy('goods_sort', 'DESC')
|
|
|
->orderBy('goods_addtimes', 'DESC')
|
|
|
->forPage($page, $pageSize)
|
|
|
->get()
|
|
@@ -251,7 +251,7 @@ class GoodsService
|
|
|
->OrWhere('goods_title', 'like', '%' . $goodsName . '%');
|
|
|
});
|
|
|
})->whereIn('join_goods_category_id', $categoryId)
|
|
|
- ->orderBy('goods_sort','DESC')
|
|
|
+ ->orderBy('goods_sort', 'DESC')
|
|
|
->orderBy('goods_addtimes', 'DESC')
|
|
|
->forPage($page, $pageSize)
|
|
|
->get()
|
|
@@ -312,7 +312,7 @@ class GoodsService
|
|
|
->OrWhere('goods_title', 'like', '%' . $goodsName . '%');
|
|
|
});
|
|
|
})->whereIn('join_goods_category_id', $categoryIds)
|
|
|
- ->orderBy('goods_sort','DESC')
|
|
|
+ ->orderBy('goods_sort', 'DESC')
|
|
|
->orderBy('goods_addtimes', 'DESC')
|
|
|
->forPage($page, $pageSize)
|
|
|
->get()
|
|
@@ -362,7 +362,7 @@ class GoodsService
|
|
|
$query->where('join_goods_category_id', $categoryId);
|
|
|
})
|
|
|
->where('goods_classify', 'PACKAGE')
|
|
|
- ->orderBy('goods_sort','DESC')
|
|
|
+ ->orderBy('goods_sort', 'DESC')
|
|
|
->orderBy('goods_addtimes', 'DESC')
|
|
|
->forPage($page, $pageSize)
|
|
|
->get()
|
|
@@ -592,13 +592,14 @@ class GoodsService
|
|
|
$data['goods_premisses'] = $extendJson['premisses'];
|
|
|
$data['goods_premisses_str'] = SysDept::whereIn('dept_id', $extendJson['premisses'])->pluck('dept_name');
|
|
|
}
|
|
|
- if (isset($extendJson['bg'])){
|
|
|
+ if (isset($extendJson['bg'])) {
|
|
|
$data['goods_theme_color'] = $extendJson['bg'];
|
|
|
}
|
|
|
- if (isset($extendJson['icon'])){
|
|
|
- $data['goods_theme_icon'] = getenv('STORAGE_DOMAIN').$extendJson['icon'];
|
|
|
+ if (isset($extendJson['icon'])) {
|
|
|
+ $data['goods_theme_icon'] = getenv('STORAGE_DOMAIN') . $extendJson['icon'];
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
$data['appointment_times'] = [];
|
|
|
if ($data['is_support_appointment'] == 'Y' && isset($extendJson['dates'])) {
|
|
|
$data['dates'] = $extendJson['dates'] ?? [];
|
|
@@ -626,6 +627,23 @@ class GoodsService
|
|
|
if (isset($extendJson['label'])) {
|
|
|
$data['appointment_label'] = $extendJson['label'];
|
|
|
}
|
|
|
+
|
|
|
+ }
|
|
|
+ if (isset($extendJson['month']) && $data['is_support_appointment'] == 'Y'){
|
|
|
+ $times = [];
|
|
|
+ foreach ($extendJson['month'] as $monKey => $months){
|
|
|
+ foreach ($months as $day => $person){
|
|
|
+ $times[] = [
|
|
|
+ 'days'=>date('Y-m-d',strtotime($monKey.$day)),
|
|
|
+ 'person'=>$person
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $data['appointment_times'] = $times;
|
|
|
+ $data['travel_begin'] = $extendJson['travel-begin'];
|
|
|
+ $data['travel_day'] = $extendJson['travel-day'];
|
|
|
+ $data['travel_night'] = $extendJson['travel-night'];
|
|
|
+ $data['travel_trans'] = $extendJson['travel-trans'];
|
|
|
}
|
|
|
if (!empty($data['goods_json']) && $data['join_goods_category_id'] == 65) {
|
|
|
// foreach ($data['goods_json'] as $key => $datum) {
|
|
@@ -814,11 +832,11 @@ class GoodsService
|
|
|
Db::commit();
|
|
|
} catch (\PDOException $e) {
|
|
|
Db::rollBack();
|
|
|
- dump($e->getFile().'('.$e->getLine().'):'.$e->getMessage());
|
|
|
+ dump($e->getFile() . '(' . $e->getLine() . '):' . $e->getMessage());
|
|
|
return json_fail('数据写入失败~');
|
|
|
} catch (BusinessException $e) {
|
|
|
Db::rollBack();
|
|
|
- dump($e->getFile().'('.$e->getLine().'):'.$e->getMessage());
|
|
|
+ dump($e->getFile() . '(' . $e->getLine() . '):' . $e->getMessage());
|
|
|
return json_fail($e->getMessage());
|
|
|
} catch (\Exception $e) {
|
|
|
Db::rollBack();
|
|
@@ -1116,7 +1134,7 @@ class GoodsService
|
|
|
$model->is_support_appointment = $params['is_support_appointment'] ?? 'N';
|
|
|
$model->goods_addtimes = time();
|
|
|
|
|
|
- if (!empty($params['is_support_appointment']) && $params['is_support_appointment'] == 'Y' && !empty($params['appointment_times'])) {
|
|
|
+ if (!empty($params['is_support_appointment']) && $params['is_support_appointment'] == 'Y' && !empty($params['appointment_times']) && $params['goods_category'] != 'TRAVEL') {
|
|
|
$times = [];
|
|
|
$attributeJsonTimeArr = [];
|
|
|
$personTotal = 0;
|
|
@@ -1178,6 +1196,32 @@ class GoodsService
|
|
|
// '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) {
|
|
@@ -1437,7 +1481,12 @@ class GoodsService
|
|
|
$newKey = Goods::LISTING_KEY_PREFIX . date('YmdHi', $data['goods_on_addtimes']);
|
|
|
$redis->sadd($newKey, $data['goods_id']);
|
|
|
}
|
|
|
- if (!empty($params['is_support_appointment']) && $params['is_support_appointment'] == 'Y' && !empty($params['appointment_times'])) {
|
|
|
+
|
|
|
+ if (!empty($params['is_support_appointment']) && $params['is_support_appointment'] == 'Y' && !empty($params['appointment_times']) && $params['goods_category'] != 'TRAVEL') {
|
|
|
+ $attributeJson = [];
|
|
|
+ if (!empty($row->goods_attribute_json)) {
|
|
|
+ $attributeJson = json_decode($row->goods_attribute_json, true);
|
|
|
+ }
|
|
|
$times = [];
|
|
|
$attributeJsonTimeArr = [];
|
|
|
$personTotal = 0;
|
|
@@ -1469,14 +1518,19 @@ class GoodsService
|
|
|
} else if (self::$week[$lastDate] - self::$week[$currentDate] + 1 == count($newDates)) {
|
|
|
$attributeJsonDate = $currentDate . '至' . $lastDate;
|
|
|
}
|
|
|
- $attributeJson = [
|
|
|
- 'icon' => '',
|
|
|
- 'date' => $attributeJsonDate,
|
|
|
- 'time' => $attributeJsonTime,
|
|
|
- 'dates' => $newDates ? array_values($newDates) : [],
|
|
|
- 'times' => $times,
|
|
|
- 'person' => $personTotal
|
|
|
- ];
|
|
|
+ $attributeJson['date'] = $attributeJsonDate;
|
|
|
+ $attributeJson['time'] = $attributeJsonTime;
|
|
|
+ $attributeJson['dates'] = $newDates ? array_values($newDates) : [];
|
|
|
+ $attributeJson['times'] = $times;
|
|
|
+ $attributeJson['person'] = $personTotal;
|
|
|
+// $attributeJson = [
|
|
|
+// 'icon' => '',
|
|
|
+// 'date' => $attributeJsonDate,
|
|
|
+// 'time' => $attributeJsonTime,
|
|
|
+// 'dates' => $newDates ? array_values($newDates) : [],
|
|
|
+// 'times' => $times,
|
|
|
+// 'person' => $personTotal
|
|
|
+// ];
|
|
|
if (!empty($params['appointment_label'])) {
|
|
|
$attributeJson['label'] = $params['appointment_label'];
|
|
|
}
|
|
@@ -1486,6 +1540,32 @@ class GoodsService
|
|
|
}
|
|
|
$data['goods_attribute_json'] = json_encode($attributeJson, JSON_UNESCAPED_UNICODE);
|
|
|
}
|
|
|
+
|
|
|
+ if (!empty($params['is_support_appointment']) && $params['is_support_appointment'] == 'Y' && !empty($params['appointment_times']) && $params['goods_category'] == 'TRAVEL') {
|
|
|
+ $attributeJson = [];
|
|
|
+ if (!empty($row->goods_attribute_json)) {
|
|
|
+ $attributeJson = json_decode($row->goods_attribute_json, true);
|
|
|
+ }
|
|
|
+ $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;
|
|
|
+ $data['goods_attribute_json'] = json_encode($attributeJson, JSON_UNESCAPED_UNICODE);
|
|
|
+ }
|
|
|
if (!empty($params['goods_premisses'])) {
|
|
|
if (!empty($data['goods_attribute_json']) && !is_array($data['goods_attribute_json'])) {
|
|
|
if (is_json($data['goods_attribute_json'])) {
|