|
@@ -9,6 +9,7 @@ use app\model\GoodsLabel;
|
|
|
use app\model\GoodsRunning;
|
|
|
use app\model\GoodsSku;
|
|
|
use app\model\SysCategory;
|
|
|
+use app\model\SysDept;
|
|
|
use app\model\SysSerial;
|
|
|
use support\Db;
|
|
|
use support\exception\BusinessException;
|
|
@@ -411,7 +412,7 @@ class GoodsService
|
|
|
{
|
|
|
try {
|
|
|
// 商品主表
|
|
|
- $main = Goods::where('goods_id', $goodsId)->first();
|
|
|
+ $main = Goods::with('category')->where('goods_id', $goodsId)->first();
|
|
|
if (!empty($main)) {
|
|
|
$main = $main->toArray();
|
|
|
$main['goods_sku_json'] = json_decode($main['goods_sku_json'], true);
|
|
@@ -448,6 +449,8 @@ class GoodsService
|
|
|
$goodsRunningOffJson = json_decode($running['goods_running_off_json'], true);
|
|
|
$running['goods_off_addtimes'] = isset($goodsRunningOffJson['time']) ? date("Y-m-d H:i", $goodsRunningOffJson['time']) : '';
|
|
|
}
|
|
|
+ $running['goods_running_storage'] = !empty($running['goods_running_storage']) ? intval($running['goods_running_storage']) : '';
|
|
|
+ $running['goods_running_sale'] = !empty($running['goods_running_sale']) ? intval($running['goods_running_sale']) : '';
|
|
|
} else {
|
|
|
$running = [];
|
|
|
}
|
|
@@ -512,6 +515,10 @@ class GoodsService
|
|
|
if (!empty($data['goods_attribute_json'])) {
|
|
|
$extendJson = json_decode($data['goods_attribute_json'], true);
|
|
|
$data['goods_attribute_json'] = $extendJson;
|
|
|
+ if (isset($extendJson['premisses'])) {
|
|
|
+ $data['goods_premisses'] = $extendJson['premisses'];
|
|
|
+ $data['goods_premisses_str'] = SysDept::whereIn('dept_id', $extendJson['premisses'])->pluck('dept_name');
|
|
|
+ }
|
|
|
}
|
|
|
$data['appointment_times'] = [];
|
|
|
if ($data['is_support_appointment'] == 'Y' && isset($extendJson['dates'])) {
|
|
@@ -805,7 +812,7 @@ class GoodsService
|
|
|
$goods->goods_attribute_json = json_encode($attributeJson);
|
|
|
}
|
|
|
$goods->save();
|
|
|
- $sku = GoodsSku::where('join_sku_goods_id',$params['goods_id'])->first();
|
|
|
+ $sku = GoodsSku::where('join_sku_goods_id', $params['goods_id'])->first();
|
|
|
$sku->goods_sku_status = $params['goods_status'];
|
|
|
$sku->goods_sku_specs_json = json_encode(['规格' => $params['goods_sales_price'] . '元']);
|
|
|
$sku->goods_sku_market_price = $params['goods_sales_price'];
|
|
@@ -1017,9 +1024,8 @@ class GoodsService
|
|
|
$model->goods_name = $params['goods_name'];
|
|
|
$model->goods_market_price = $params['goods_market_price'] ?? 0;
|
|
|
$model->goods_sales_price = $params['goods_sales_price'] ?? 0;
|
|
|
- $model->goods_sku_json = !empty($params['goods_sku_json_label']) ? json_encode($params['goods_sku_json_label']) : json_encode(['规格' => []]);
|
|
|
- $model->goods_attribute_json = !empty($params['goods_attribute_json']) ? $params['goods_attribute_json'] : '{}';
|
|
|
-// $model->goods_service_json = !empty($params['goods_service_json']) ? $params['goods_service_json'] : '{}';
|
|
|
+ $model->goods_sku_json = !empty($params['goods_sku_json_label']) ? json_encode($params['goods_sku_json_label']) : json_encode(['规格' => ['标准']]);
|
|
|
+ $model->goods_attribute_json = !empty($params['goods_attribute_json']) ? $params['goods_attribute_json'] : '[]';
|
|
|
$model->goods_title = $params['goods_title'] ?? '';
|
|
|
$model->goods_cover = $params['goods_cover'] ?? '';
|
|
|
$model->goods_on_addtimes = isset($params['goods_on_addtimes']) ? strtotime($params['goods_on_addtimes']) : null;
|
|
@@ -1124,6 +1130,17 @@ class GoodsService
|
|
|
$model->goods_json = '[]';
|
|
|
}
|
|
|
|
|
|
+ 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 ($model->save()) {
|
|
|
return $model->goods_id;
|
|
|
}
|
|
@@ -1378,6 +1395,15 @@ class GoodsService
|
|
|
}
|
|
|
$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'])) {
|
|
|
+ $data['goods_attribute_json'] = json_decode($data['goods_attribute_json'], true);
|
|
|
+ } elseif (empty($data['goods_attribute_json'])) {
|
|
|
+ $data['goods_attribute_json'] = [];
|
|
|
+ }
|
|
|
+ $data['goods_attribute_json']['premisses'] = $params['goods_premisses'];
|
|
|
+ $data['goods_attribute_json'] = json_encode($data['goods_attribute_json']);
|
|
|
+ }
|
|
|
if (!empty($data['goods_json']) && $data['join_goods_category_id'] == 65) {
|
|
|
$goodsJson = json_decode($data['goods_json'], true);
|
|
|
foreach ($goodsJson as $key => $item) {
|