|
@@ -4,6 +4,7 @@ namespace app\admin\service\goods;
|
|
|
|
|
|
use app\common\Tree;
|
|
|
use app\model\Appointment;
|
|
|
+use app\model\Coupon;
|
|
|
use app\model\Goods;
|
|
|
use app\model\GoodsComponent;
|
|
|
use app\model\GoodsDetail;
|
|
@@ -156,7 +157,7 @@ class GoodsService
|
|
|
$goodsCategory = $request->get('goods_category', null);
|
|
|
$goodsSupplierId = $request->get('join_goods_supplier_id', null);
|
|
|
$goodsStatus = $request->get('goods_status', null);
|
|
|
- $type = $request->get('type','');
|
|
|
+ $type = $request->get('type', '');
|
|
|
if ($categoryId != null) {
|
|
|
$categoryPath = SysCategory::where('category_id', $categoryId)->value('category_super_path');
|
|
|
$categoryPath .= '#' . $categoryId . '#';
|
|
@@ -182,7 +183,7 @@ class GoodsService
|
|
|
'user' => function ($query) {
|
|
|
$query->select('user_id', 'user_name');
|
|
|
}
|
|
|
- ])->leftJoin('goods_running','goods_running.join_running_goods_id','=','goods.goods_id')
|
|
|
+ ])->leftJoin('goods_running', 'goods_running.join_running_goods_id', '=', 'goods.goods_id')
|
|
|
->select('goods_id', 'join_goods_category_id', 'join_goods_supplier_id', 'creator_user_id', 'goods_status', 'goods_sales_price', 'goods_category', 'goods_name', 'goods_title', 'goods_cover', 'goods_sort', 'goods_attribute_json', 'goods_addtimes', 'goods_updatetimes')
|
|
|
->when($goodsName != '', function ($query) use ($goodsName) {
|
|
|
$query->where(function ($q) use ($goodsName) {
|
|
@@ -200,13 +201,13 @@ class GoodsService
|
|
|
} else if ($classify != 'GOODS' && empty($categoryId)) {
|
|
|
$query->where('goods_classify', $classify);
|
|
|
}
|
|
|
- })->when( !empty($type),function ($query) use ($type){
|
|
|
- if ($type == 'storageWarning'){
|
|
|
- $query->where('goods_running.goods_running_storage','<=',2);
|
|
|
+ })->when(!empty($type), function ($query) use ($type) {
|
|
|
+ if ($type == 'storageWarning') {
|
|
|
+ $query->where('goods_running.goods_running_storage', '<=', 2);
|
|
|
}
|
|
|
- })->when(!empty($goodsSupplierId),function($query) use ($goodsSupplierId){
|
|
|
+ })->when(!empty($goodsSupplierId), function ($query) use ($goodsSupplierId) {
|
|
|
$query->where('join_goods_supplier_id', $goodsSupplierId);
|
|
|
- })->when(!empty($goodsStatus),function($query) use ($goodsStatus){
|
|
|
+ })->when(!empty($goodsStatus), function ($query) use ($goodsStatus) {
|
|
|
$query->where('goods_status', $goodsStatus);
|
|
|
})
|
|
|
->orderBy('goods_sort', 'DESC')
|
|
@@ -215,31 +216,31 @@ class GoodsService
|
|
|
->get()
|
|
|
->toArray();
|
|
|
|
|
|
- $total = Goods::leftJoin('goods_running','goods_running.join_running_goods_id','=','goods.goods_id')
|
|
|
- ->when($goodsName != '', function ($query) use ($goodsName) {
|
|
|
- $query->where(function ($q) use ($goodsName) {
|
|
|
- $q->where('goods_name', 'like', '%' . $goodsName . '%')
|
|
|
- ->OrWhere('goods_title', 'like', '%' . $goodsName . '%');
|
|
|
- });
|
|
|
- })->when($categoryId != null, function ($query) use ($categoryId) {
|
|
|
- $query->whereIn('join_goods_category_id', $categoryId);
|
|
|
- })->when($goodsCategory != null, function ($query) use ($goodsCategory) {
|
|
|
- $query->where('goods_category', $goodsCategory);
|
|
|
- })->when($classify != '', function ($query) use ($classify, $categoryId) {
|
|
|
- if ($classify == 'GOODS' && empty($categoryId)) {
|
|
|
- $query->whereIn('join_goods_category_id', ['6', '7', '8', '9', '10', '11', '12', '30']);
|
|
|
- } else if ($classify != 'GOODS' && empty($categoryId)) {
|
|
|
- $query->where('goods_classify', $classify);
|
|
|
- }
|
|
|
- })->when( !empty($type),function ($query) use ($type){
|
|
|
- if ($type == 'storageWarning'){
|
|
|
- $query->where('goods_running.goods_running_storage','<=',2);
|
|
|
- }
|
|
|
- })->when(!empty($goodsSupplierId),function($query) use ($goodsSupplierId){
|
|
|
- $query->where('join_goods_supplier_id', $goodsSupplierId);
|
|
|
- })->when(!empty($goodsStatus),function($query) use ($goodsStatus){
|
|
|
- $query->where('goods_status', $goodsStatus);
|
|
|
- })
|
|
|
+ $total = Goods::leftJoin('goods_running', 'goods_running.join_running_goods_id', '=', 'goods.goods_id')
|
|
|
+ ->when($goodsName != '', function ($query) use ($goodsName) {
|
|
|
+ $query->where(function ($q) use ($goodsName) {
|
|
|
+ $q->where('goods_name', 'like', '%' . $goodsName . '%')
|
|
|
+ ->OrWhere('goods_title', 'like', '%' . $goodsName . '%');
|
|
|
+ });
|
|
|
+ })->when($categoryId != null, function ($query) use ($categoryId) {
|
|
|
+ $query->whereIn('join_goods_category_id', $categoryId);
|
|
|
+ })->when($goodsCategory != null, function ($query) use ($goodsCategory) {
|
|
|
+ $query->where('goods_category', $goodsCategory);
|
|
|
+ })->when($classify != '', function ($query) use ($classify, $categoryId) {
|
|
|
+ if ($classify == 'GOODS' && empty($categoryId)) {
|
|
|
+ $query->whereIn('join_goods_category_id', ['6', '7', '8', '9', '10', '11', '12', '30']);
|
|
|
+ } else if ($classify != 'GOODS' && empty($categoryId)) {
|
|
|
+ $query->where('goods_classify', $classify);
|
|
|
+ }
|
|
|
+ })->when(!empty($type), function ($query) use ($type) {
|
|
|
+ if ($type == 'storageWarning') {
|
|
|
+ $query->where('goods_running.goods_running_storage', '<=', 2);
|
|
|
+ }
|
|
|
+ })->when(!empty($goodsSupplierId), function ($query) use ($goodsSupplierId) {
|
|
|
+ $query->where('join_goods_supplier_id', $goodsSupplierId);
|
|
|
+ })->when(!empty($goodsStatus), function ($query) use ($goodsStatus) {
|
|
|
+ $query->where('goods_status', $goodsStatus);
|
|
|
+ })
|
|
|
->count();
|
|
|
|
|
|
foreach ($rows as &$row) {
|
|
@@ -527,76 +528,76 @@ class GoodsService
|
|
|
|
|
|
public static function selectCascaderList(Request $request)
|
|
|
{
|
|
|
- $categoryIds = $request->get('category_id','');
|
|
|
- $categorySuperId = $request->get('category_super_id','');
|
|
|
- $joinGoodsCategoryId = $request->get('join_goods_category_id','');
|
|
|
- $type = $request->get('type','');
|
|
|
- if (!$categoryIds && !$categorySuperId && !$joinGoodsCategoryId){
|
|
|
+ $categoryIds = $request->get('category_id', '');
|
|
|
+ $categorySuperId = $request->get('category_super_id', '');
|
|
|
+ $joinGoodsCategoryId = $request->get('join_goods_category_id', '');
|
|
|
+ $type = $request->get('type', '');
|
|
|
+ if (!$categoryIds && !$categorySuperId && !$joinGoodsCategoryId) {
|
|
|
return json_fail('参数异常');
|
|
|
}
|
|
|
$data = [];
|
|
|
$categorys = [];
|
|
|
- if (!empty($categoryIds)){
|
|
|
- $categorys = SysCategory::whereIn('category_id',$categoryIds)
|
|
|
- ->where('category_status','ACTIVED')
|
|
|
- ->select('category_id as id','category_name as name','category_super_id as pid','category_super_path')
|
|
|
- ->orderBy('category_sort','DESC')
|
|
|
- ->get()
|
|
|
- ->toArray();
|
|
|
- $data = array_merge($data,$categorys);
|
|
|
- }else if(!empty($categorySuperId)){
|
|
|
- $categorys = SysCategory::where('category_super_id',$categorySuperId)
|
|
|
- ->where('category_status','ACTIVED')
|
|
|
- ->select('category_id as id','category_name as name','category_super_id as pid','category_super_path')
|
|
|
- ->orderBy('category_sort','DESC')
|
|
|
- ->get()
|
|
|
- ->toArray();
|
|
|
- $data = array_merge($data,$categorys);
|
|
|
+ if (!empty($categoryIds)) {
|
|
|
+ $categorys = SysCategory::whereIn('category_id', $categoryIds)
|
|
|
+ ->where('category_status', 'ACTIVED')
|
|
|
+ ->select('category_id as id', 'category_name as name', 'category_super_id as pid', 'category_super_path')
|
|
|
+ ->orderBy('category_sort', 'DESC')
|
|
|
+ ->get()
|
|
|
+ ->toArray();
|
|
|
+ $data = array_merge($data, $categorys);
|
|
|
+ } else if (!empty($categorySuperId)) {
|
|
|
+ $categorys = SysCategory::where('category_super_id', $categorySuperId)
|
|
|
+ ->where('category_status', 'ACTIVED')
|
|
|
+ ->select('category_id as id', 'category_name as name', 'category_super_id as pid', 'category_super_path')
|
|
|
+ ->orderBy('category_sort', 'DESC')
|
|
|
+ ->get()
|
|
|
+ ->toArray();
|
|
|
+ $data = array_merge($data, $categorys);
|
|
|
}
|
|
|
|
|
|
- foreach ($categorys as $category){
|
|
|
+ foreach ($categorys as $category) {
|
|
|
// if(empty($category['category_super_path'])){
|
|
|
- $category['category_super_path'] = '#'.$category['id'].'#';
|
|
|
+ $category['category_super_path'] = '#' . $category['id'] . '#';
|
|
|
// }
|
|
|
- $subCategory = SysCategory::where('category_super_path','like','%'.$category['category_super_path'].'%')
|
|
|
- ->where('category_status','ACTIVED')
|
|
|
- ->select('category_id as id','category_name as name','category_super_id as pid','category_super_path')
|
|
|
- ->orderBy('category_sort','DESC')
|
|
|
+ $subCategory = SysCategory::where('category_super_path', 'like', '%' . $category['category_super_path'] . '%')
|
|
|
+ ->where('category_status', 'ACTIVED')
|
|
|
+ ->select('category_id as id', 'category_name as name', 'category_super_id as pid', 'category_super_path')
|
|
|
+ ->orderBy('category_sort', 'DESC')
|
|
|
->get()
|
|
|
->toArray();
|
|
|
- $data = array_merge($data,$subCategory);
|
|
|
+ $data = array_merge($data, $subCategory);
|
|
|
}
|
|
|
- if (empty($data) && !empty($joinGoodsCategoryId)){
|
|
|
+ if (empty($data) && !empty($joinGoodsCategoryId)) {
|
|
|
$goodsCategoryIds = $joinGoodsCategoryId;
|
|
|
- }else{
|
|
|
- $goodsCategoryIds = array_column($data,'id');
|
|
|
+ } else {
|
|
|
+ $goodsCategoryIds = array_column($data, 'id');
|
|
|
}
|
|
|
$goods = Goods::with('sku')
|
|
|
- ->leftJoin('goods_running','goods_running.join_running_goods_id','=','goods.goods_id')
|
|
|
- ->where('goods_running.goods_running_storage','>',0)
|
|
|
- ->whereIn('join_goods_category_id',$goodsCategoryIds)
|
|
|
- ->where('goods_status','ON');
|
|
|
+ ->leftJoin('goods_running', 'goods_running.join_running_goods_id', '=', 'goods.goods_id')
|
|
|
+ ->where('goods_running.goods_running_storage', '>', 0)
|
|
|
+ ->whereIn('join_goods_category_id', $goodsCategoryIds)
|
|
|
+ ->where('goods_status', 'ON');
|
|
|
|
|
|
- if ($type == 'dishes'){
|
|
|
+ if ($type == 'dishes') {
|
|
|
$uid = JwtToken::getCurrentId();
|
|
|
$user = SysUser::where('user_id', $uid)->first();
|
|
|
$restaurant = SysDept::where('dept_category', '餐厅')->where(function ($query) use ($user) {
|
|
|
$query->where('dept_id', $user->join_user_dept_id)->orWhere('dept_super_id', $user->join_user_dept_id);
|
|
|
})->first();
|
|
|
- $supplier = Supplier::where('join_supplier_dept_id',$restaurant->dept_id)->first();
|
|
|
- if ($supplier){
|
|
|
- $goods = $goods->where('join_goods_supplier_id',$supplier->supplier_id);
|
|
|
+ $supplier = Supplier::where('join_supplier_dept_id', $restaurant->dept_id)->first();
|
|
|
+ if ($supplier) {
|
|
|
+ $goods = $goods->where('join_goods_supplier_id', $supplier->supplier_id);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
- $goods = $goods->select('goods_id','goods_id as id','goods_name as name','join_goods_category_id as pid','goods_attribute_json','goods_classify','goods_sales_price','goods_cover','goods_running.goods_running_storage')
|
|
|
- ->orderBy('goods_sort','DESC')
|
|
|
- ->orderBy('goods_addtimes','DESC')
|
|
|
+ $goods = $goods->select('goods_id', 'goods_id as id', 'goods_name as name', 'join_goods_category_id as pid', 'goods_attribute_json', 'goods_classify', 'goods_sales_price', 'goods_cover', 'goods_running.goods_running_storage')
|
|
|
+ ->orderBy('goods_sort', 'DESC')
|
|
|
+ ->orderBy('goods_addtimes', 'DESC')
|
|
|
->get()
|
|
|
->toArray();
|
|
|
foreach ($goods as &$good) {
|
|
|
- $good['goods_cover'] = getenv('STORAGE_DOMAIN').$good['goods_cover'];
|
|
|
+ $good['goods_cover'] = getenv('STORAGE_DOMAIN') . $good['goods_cover'];
|
|
|
$good['goods_running_storage'] = intval($good['goods_running_storage']);
|
|
|
$good['nbr'] = 0;
|
|
|
if (!empty($good['sku'])) {
|
|
@@ -606,14 +607,14 @@ class GoodsService
|
|
|
|
|
|
$skuName = '';
|
|
|
foreach ($good['sku'][$key]['goods_sku_specs_json'] as $specsKey => $skuSpecs) {
|
|
|
- $keyStr = ($specsKey == '规格') ? '' : ($specsKey.':');
|
|
|
+ $keyStr = ($specsKey == '规格') ? '' : ($specsKey . ':');
|
|
|
if (is_array($skuSpecs)) {
|
|
|
- $skuName = $skuName .$keyStr . ' ' . implode(' ', $skuSpecs) . '; ';
|
|
|
+ $skuName = $skuName . $keyStr . ' ' . implode(' ', $skuSpecs) . '; ';
|
|
|
} else {
|
|
|
- $skuName = $skuName .$keyStr . ' ' . $skuSpecs . '; ';
|
|
|
+ $skuName = $skuName . $keyStr . ' ' . $skuSpecs . '; ';
|
|
|
}
|
|
|
}
|
|
|
- $good['sku'][$key]['sku_name'] = rtrim($skuName,'; ');
|
|
|
+ $good['sku'][$key]['sku_name'] = rtrim($skuName, '; ');
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
@@ -633,49 +634,49 @@ class GoodsService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- $data = array_merge($data,$goods);
|
|
|
+ $data = array_merge($data, $goods);
|
|
|
$tree = new Tree($data);
|
|
|
$cascaderData = $tree->getTree();
|
|
|
|
|
|
- foreach($cascaderData as $key1 => $cascader1){
|
|
|
- if(isset($cascader1['children'])){
|
|
|
- foreach($cascader1['children'] as $key2 => $cascader2){
|
|
|
- if(isset($cascader2['children'])){
|
|
|
- foreach($cascader2['children'] as $key3 => $cascader3){
|
|
|
- if(isset($cascader3['children'])){
|
|
|
- foreach($cascader3['children'] as $key4 => $cascader4){
|
|
|
- if (!isset($cascader4['goods_id'])){
|
|
|
+ foreach ($cascaderData as $key1 => $cascader1) {
|
|
|
+ if (isset($cascader1['children'])) {
|
|
|
+ foreach ($cascader1['children'] as $key2 => $cascader2) {
|
|
|
+ if (isset($cascader2['children'])) {
|
|
|
+ foreach ($cascader2['children'] as $key3 => $cascader3) {
|
|
|
+ if (isset($cascader3['children'])) {
|
|
|
+ foreach ($cascader3['children'] as $key4 => $cascader4) {
|
|
|
+ if (!isset($cascader4['goods_id'])) {
|
|
|
unset($cascaderData[$key1]['children'][$key2]['children'][$key3]['children'][$key4]);
|
|
|
}
|
|
|
}
|
|
|
- }else if (!isset($cascader3['goods_id'])){
|
|
|
+ } else if (!isset($cascader3['goods_id'])) {
|
|
|
unset($cascaderData[$key1]['children'][$key2]['children'][$key3]);
|
|
|
}
|
|
|
- if (isset($cascader3['children']) && count($cascaderData[$key1]['children'][$key2]['children']) == 0){
|
|
|
+ if (isset($cascader3['children']) && count($cascaderData[$key1]['children'][$key2]['children']) == 0) {
|
|
|
unset($cascaderData[$key1]['children'][$key2]);
|
|
|
}
|
|
|
- if (isset($cascader3['children']) && count($cascaderData[$key1]['children'][$key2]['children'][$key3]['children']) > 0){
|
|
|
+ if (isset($cascader3['children']) && count($cascaderData[$key1]['children'][$key2]['children'][$key3]['children']) > 0) {
|
|
|
$cascaderData[$key1]['children'][$key2]['children'][$key3]['children'] = array_values($cascaderData[$key1]['children'][$key2]['children'][$key3]['children']);
|
|
|
}
|
|
|
}
|
|
|
- }else if (!isset($cascader2['goods_id'])){
|
|
|
+ } else if (!isset($cascader2['goods_id'])) {
|
|
|
unset($cascaderData[$key1]['children'][$key2]);
|
|
|
}
|
|
|
- if (isset($cascader2['children']) && count($cascaderData[$key1]['children'][$key2]['children']) == 0){
|
|
|
+ if (isset($cascader2['children']) && count($cascaderData[$key1]['children'][$key2]['children']) == 0) {
|
|
|
unset($cascaderData[$key1]['children'][$key2]);
|
|
|
}
|
|
|
- if (isset($cascader2['children']) && isset($cascaderData[$key1]['children'][$key2]) && count($cascaderData[$key1]['children'][$key2]['children']) > 0){
|
|
|
+ if (isset($cascader2['children']) && isset($cascaderData[$key1]['children'][$key2]) && count($cascaderData[$key1]['children'][$key2]['children']) > 0) {
|
|
|
$cascaderData[$key1]['children'][$key2]['children'] = array_values($cascaderData[$key1]['children'][$key2]['children']);
|
|
|
}
|
|
|
}
|
|
|
- }else if (!isset($cascader1['goods_id'])){
|
|
|
+ } else if (!isset($cascader1['goods_id'])) {
|
|
|
unset($cascaderData[$key1]);
|
|
|
}
|
|
|
- if (isset($cascader1['children']) && count($cascaderData[$key1]['children']) == 0){
|
|
|
-
|
|
|
+ if (isset($cascader1['children']) && count($cascaderData[$key1]['children']) == 0) {
|
|
|
+
|
|
|
unset($cascaderData[$key1]);
|
|
|
}
|
|
|
- if (isset($cascader1['children']) && isset($cascaderData[$key1]) && count($cascaderData[$key1]['children']) > 0){
|
|
|
+ if (isset($cascader1['children']) && isset($cascaderData[$key1]) && count($cascaderData[$key1]['children']) > 0) {
|
|
|
$cascaderData[$key1]['children'] = array_values($cascaderData[$key1]['children']);
|
|
|
}
|
|
|
}
|
|
@@ -777,15 +778,15 @@ class GoodsService
|
|
|
|
|
|
// 供应商表
|
|
|
$supplier = [];
|
|
|
- if(isset($main['join_goods_supplier_id']) && !empty($main['join_goods_supplier_id'])){
|
|
|
- $supplierModel = Supplier::where('supplier_id',$main['join_goods_supplier_id'])->select('supplier_id','supplier_name')->first();
|
|
|
- if (!empty($supplierModel)){
|
|
|
+ if (isset($main['join_goods_supplier_id']) && !empty($main['join_goods_supplier_id'])) {
|
|
|
+ $supplierModel = Supplier::where('supplier_id', $main['join_goods_supplier_id'])->select('supplier_id', 'supplier_name')->first();
|
|
|
+ if (!empty($supplierModel)) {
|
|
|
$supplier = $supplierModel->toArray();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 合并数据
|
|
|
- $data = array_merge($main, $detail, $label, $running, ['sku' => $skus],['supplier'=>$supplier]);
|
|
|
+ $data = array_merge($main, $detail, $label, $running, ['sku' => $skus], ['supplier' => $supplier]);
|
|
|
$data['goods_sku_json_label'] = [];
|
|
|
|
|
|
$data['goods_label'] = !empty($data['goods_label']) ? explode(',', $data['goods_label']) : [];
|
|
@@ -832,6 +833,9 @@ class GoodsService
|
|
|
$data['goods_service_premises'] = $extendJson['service_premises_id'];
|
|
|
}
|
|
|
}
|
|
|
+ if (!empty($extendJson['coupon'])) {
|
|
|
+ $data['coupon_list'] = $extendJson['coupon'];
|
|
|
+ }
|
|
|
|
|
|
$data['express_json'] = [];
|
|
|
if (!empty($data['goods_express_json'])) {
|
|
@@ -1691,6 +1695,28 @@ class GoodsService
|
|
|
$attributeJson['time'] = $attributeJsonTime;
|
|
|
$model->goods_attribute_json = json_encode($attributeJson);
|
|
|
}
|
|
|
+ if (!empty($params['coupon_id']) && !empty($params['coupon_nbr'])) {
|
|
|
+ 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 = [];
|
|
|
+ }
|
|
|
+ $coupons = Coupon::whereIn('coupon_id', $params['coupon_id'])
|
|
|
+ ->select('coupon_id', 'coupon_name')
|
|
|
+ ->get()
|
|
|
+ ->toArray();
|
|
|
+ $couponList = [];
|
|
|
+ foreach ($coupons as $coupon) {
|
|
|
+ if (isset($params['coupon_nbr'][$coupon['coupon_id']])) {
|
|
|
+ $couponList[$coupon['coupon_id']] = [
|
|
|
+ 'num' => $params['coupon_nbr'][$coupon['coupon_id']],
|
|
|
+ 'name' => $coupon['coupon_name']
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $attributeJson['coupon'] = $couponList;
|
|
|
+ $model->goods_attribute_json = json_encode($attributeJson, JSON_UNESCAPED_UNICODE);
|
|
|
+ }
|
|
|
if ($model->save()) {
|
|
|
return $model->goods_id;
|
|
|
}
|
|
@@ -2046,6 +2072,27 @@ class GoodsService
|
|
|
$attributeJson['month'] = $months;
|
|
|
$data['goods_attribute_json'] = json_encode($attributeJson, JSON_UNESCAPED_UNICODE);
|
|
|
}
|
|
|
+ if (!empty($params['coupon_id']) && !empty($params['coupon_nbr'])) {
|
|
|
+ $attributeJson = [];
|
|
|
+ if (!empty($row->goods_attribute_json)) {
|
|
|
+ $attributeJson = json_decode($row->goods_attribute_json, true);
|
|
|
+ }
|
|
|
+ $coupons = Coupon::whereIn('coupon_id', $params['coupon_id'])
|
|
|
+ ->select('coupon_id', 'coupon_name')
|
|
|
+ ->get()
|
|
|
+ ->toArray();
|
|
|
+ $couponList = [];
|
|
|
+ foreach ($coupons as $coupon) {
|
|
|
+ if (isset($params['coupon_nbr'][$coupon['coupon_id']])) {
|
|
|
+ $couponList[$coupon['coupon_id']] = [
|
|
|
+ 'num' => $params['coupon_nbr'][$coupon['coupon_id']],
|
|
|
+ 'name' => $coupon['coupon_name']
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $attributeJson['coupon'] = $couponList;
|
|
|
+ $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'])) {
|
|
@@ -2414,7 +2461,7 @@ class GoodsService
|
|
|
}
|
|
|
if ($operation == 'update' && !empty($skusOldIds)) {
|
|
|
// GoodsSku::whereIn('goods_sku_id', $skusOldIds)->delete();
|
|
|
- GoodsSku::whereIn('goods_sku_id', $skusOldIds)->update(['goods_sku_status'=>'DISABLED']);
|
|
|
+ GoodsSku::whereIn('goods_sku_id', $skusOldIds)->update(['goods_sku_status' => 'DISABLED']);
|
|
|
}
|
|
|
|
|
|
Db::commit();
|