1.提交缺失的东西
This commit is contained in:
@ -254,7 +254,7 @@ class GoodsLogic extends BaseLogic
|
||||
$free_shipping_template_id = $post['free_shipping_type'] == 3 ? $post['free_shipping_template_id']: '';
|
||||
|
||||
$old_spec_type = Db::name('goods')
|
||||
->where('id', $post['goods_id'])
|
||||
->where('id', $post['id'])
|
||||
->value('spec_type');
|
||||
|
||||
// 替换内容中图片地址
|
||||
@ -316,22 +316,22 @@ class GoodsLogic extends BaseLogic
|
||||
];
|
||||
|
||||
Db::name('goods')
|
||||
->where(['id' => $post['goods_id']])
|
||||
->where(['id' => $post['id']])
|
||||
->update($data);
|
||||
|
||||
// 下架或删除商品,更新商品收藏
|
||||
if ($data['status'] != 1) {
|
||||
Hook::listen('update_collect', ['goods_id' => $post['goods_id']]);
|
||||
Hook::listen('update_collect', ['goods_id' => $post['id']]);
|
||||
}
|
||||
|
||||
//重新更新图片表
|
||||
Db::name('goods_image')
|
||||
->where(['goods_id' => $post['goods_id']])
|
||||
->where(['goods_id' => $post['id']])
|
||||
->delete();
|
||||
$data = [];
|
||||
foreach ($post['goods_image'] as $k => $v) {
|
||||
$data[] = [
|
||||
'goods_id' => $post['goods_id'],
|
||||
'goods_id' => $post['id'],
|
||||
'uri' => $v,
|
||||
];
|
||||
}
|
||||
@ -355,27 +355,27 @@ class GoodsLogic extends BaseLogic
|
||||
'bar_code' => $post['one_bar_code'],
|
||||
];
|
||||
Db::name('goods_item')
|
||||
->where(['goods_id' => $post['goods_id']])
|
||||
->where(['goods_id' => $post['id']])
|
||||
->update($data);
|
||||
} else {
|
||||
//原来非单规格
|
||||
//删除多规格
|
||||
Db::name('goods_spec')
|
||||
->where('goods_id', $post['goods_id'])
|
||||
->where('goods_id', $post['id'])
|
||||
->delete();
|
||||
Db::name('goods_spec_value')
|
||||
->where('goods_id', $post['goods_id'])
|
||||
->where('goods_id', $post['id'])
|
||||
->delete();
|
||||
Db::name('goods_item')
|
||||
->where('goods_id', $post['goods_id'])
|
||||
->where('goods_id', $post['id'])
|
||||
->delete();
|
||||
$goods_spec_id = Db::name('goods_spec')
|
||||
->insertGetId(['goods_id' => $post['goods_id'], 'name' => '默认']);
|
||||
->insertGetId(['goods_id' => $post['id'], 'name' => '默认']);
|
||||
$goods_spec_value_id = Db::name('goods_spec_value')
|
||||
->insertGetId(['spec_id' => $goods_spec_id, 'goods_id' => $post['goods_id'], 'value' => '默认']);
|
||||
->insertGetId(['spec_id' => $goods_spec_id, 'goods_id' => $post['id'], 'value' => '默认']);
|
||||
$data = [
|
||||
'image' => $post['one_spec_image'],
|
||||
'goods_id' => $post['goods_id'],
|
||||
'goods_id' => $post['id'],
|
||||
'spec_value_ids' => $goods_spec_value_id,
|
||||
'spec_value_str' => '默认',
|
||||
'market_price' => $post['one_market_price'],
|
||||
@ -394,7 +394,7 @@ class GoodsLogic extends BaseLogic
|
||||
|
||||
$goods_specs = [];
|
||||
foreach ($post['spec_name'] as $k => $v) {
|
||||
$temp = ['goods_id' => $post['goods_id'], 'name' => $v, 'spec_id' => $post['spec_id'][$k]];
|
||||
$temp = ['goods_id' => $post['id'], 'name' => $v, 'spec_id' => $post['spec_id'][$k]];
|
||||
$goods_specs[] = $temp;
|
||||
}
|
||||
$new_spec_name_ids = [];
|
||||
@ -402,23 +402,23 @@ class GoodsLogic extends BaseLogic
|
||||
if ($v['spec_id']) {
|
||||
//更新规格名
|
||||
Db::name('goods_spec')
|
||||
->where(['goods_id' => $post['goods_id'], 'id' => $v['spec_id']])
|
||||
->where(['goods_id' => $post['id'], 'id' => $v['spec_id']])
|
||||
->update(['name' => $v['name']]);
|
||||
$new_spec_name_ids[] = $v['spec_id'];
|
||||
} else {
|
||||
//添加规格名
|
||||
$new_spec_name_ids[] = Db::name('goods_spec')
|
||||
->insertGetId(['goods_id' => $post['goods_id'], 'name' => $v['name']]);
|
||||
->insertGetId(['goods_id' => $post['id'], 'name' => $v['name']]);
|
||||
}
|
||||
}
|
||||
//删除规格名
|
||||
$all_spec_ids = Db::name('goods_spec')
|
||||
->where('goods_id', $post['goods_id'])
|
||||
->where('goods_id', $post['id'])
|
||||
->column('id');
|
||||
$del_spec_name_ids = array_diff($all_spec_ids, $new_spec_name_ids);
|
||||
if (!empty($del_spec_name_ids)) {
|
||||
Db::name('goods_spec')
|
||||
->where('goods_id', $post['goods_id'])
|
||||
->where('goods_id', $post['id'])
|
||||
->where('id', 'in', $del_spec_name_ids)
|
||||
->delete();
|
||||
}
|
||||
@ -426,7 +426,7 @@ class GoodsLogic extends BaseLogic
|
||||
|
||||
$new_spec_value_ids = [];
|
||||
$goods_spec_name_key_id = Db::name('goods_spec')
|
||||
->where(['goods_id' => $post['goods_id']])
|
||||
->where(['goods_id' => $post['id']])
|
||||
->where('name', 'in', $post['spec_name'])
|
||||
->column('id', 'name');
|
||||
|
||||
@ -440,7 +440,7 @@ class GoodsLogic extends BaseLogic
|
||||
throw new Exception('请勿添加相同规格值');
|
||||
}
|
||||
$temp = [
|
||||
'goods_id' => $post['goods_id'],
|
||||
'goods_id' => $post['id'],
|
||||
'spec_id' => $goods_spec_name_key_id[$post['spec_name'][$k]],
|
||||
'value' => $v2,
|
||||
];
|
||||
@ -459,20 +459,20 @@ class GoodsLogic extends BaseLogic
|
||||
}
|
||||
}
|
||||
$all_spec_value_ids = Db::name('goods_spec_value')
|
||||
->where('goods_id', $post['goods_id'])
|
||||
->where('goods_id', $post['id'])
|
||||
->column('id');
|
||||
$del_spec_value_ids = array_diff($all_spec_value_ids, $new_spec_value_ids);
|
||||
if (!empty($del_spec_value_ids)) {
|
||||
//删除规格值
|
||||
Db::name('goods_spec_value')
|
||||
->where('goods_id', $post['goods_id'])
|
||||
->where('goods_id', $post['id'])
|
||||
->where('id', 'in', $del_spec_value_ids)
|
||||
->delete();
|
||||
}
|
||||
|
||||
$new_item_id = [];
|
||||
$goods_spec_name_value_id = Db::name('goods_spec_value')
|
||||
->where(['goods_id' => $post['goods_id']])
|
||||
->where(['goods_id' => $post['id']])
|
||||
->column('id', 'value');
|
||||
foreach ($spec_lists as $k => $v) {
|
||||
$spec_lists[$k]['spec_value_ids'] = '';
|
||||
@ -483,7 +483,7 @@ class GoodsLogic extends BaseLogic
|
||||
$spec_lists[$k]['spec_value_ids'] = trim($spec_lists[$k]['spec_value_ids'], ',');
|
||||
$spec_lists[$k]['image'] = str_replace(UrlServer::getFileUrl('/'), '', $spec_lists[$k]['spec_image']);
|
||||
unset($spec_lists[$k]['spec_image']);
|
||||
$spec_lists[$k]['goods_id'] = $post['goods_id'];
|
||||
$spec_lists[$k]['goods_id'] = $post['id'];
|
||||
unset($spec_lists[$k]['spec_id']);
|
||||
$item_id = $spec_lists[$k]['item_id'];
|
||||
unset($spec_lists[$k]['item_id']);
|
||||
@ -498,20 +498,20 @@ class GoodsLogic extends BaseLogic
|
||||
}
|
||||
}
|
||||
$all_item_id = Db::name('goods_item')
|
||||
->where('goods_id', $post['goods_id'])
|
||||
->where('goods_id', $post['id'])
|
||||
->column('id');
|
||||
$del_item_ids = array_diff($all_item_id, $new_item_id);
|
||||
if (!empty($del_item_ids)) {
|
||||
//删除规格值
|
||||
Db::name('goods_item')
|
||||
->where('goods_id', $post['goods_id'])
|
||||
->where('goods_id', $post['id'])
|
||||
->where('id', 'in', $del_item_ids)
|
||||
->delete();
|
||||
}
|
||||
}
|
||||
|
||||
$newItemIds = GoodsItem::where('goods_id', $post['id'])->column('id');
|
||||
$destroyIds = DistributionGoods::where('goods_id', $post['goods_id'])->column('id');
|
||||
$destroyIds = DistributionGoods::where('goods_id', $post['id'])->column('id');
|
||||
|
||||
// 删除原来的分销设置
|
||||
if ($oldItemIds != $newItemIds && $destroyIds) {
|
||||
|
||||
Reference in New Issue
Block a user