$spec) { $spvalue_ids = array(); $specvalue_list = array(); foreach ($spec['value'] as $val) { $val['spvalue_name'] = trim($val['spvalue_name']); if (!empty($val['spvalue_name'])) { if (isset($val['spvalue_id'])) { $spvalue_ids[] = $val['spvalue_id']; $condition = array(); $condition[] = array('store_id', '=', $this->store_info['store_id']); $condition[] = array('spvalue_id', '=', $val['spvalue_id']); $update = array( 'spvalue_name' => $val['spvalue_name'], ); $spec_model->editSpecvalue($update, $condition); } else { $specvalue_list[] = array( 'spvalue_name' => $val['spvalue_name'], 'sp_id' => $sp_id, 'gc_id' => $gc_id, 'store_id' => $this->store_info['store_id'], 'spvalue_color' => '', 'spvalue_sort' => 255 ); } } } $condition = array(); $condition[] = array('store_id', '=', $this->store_info['store_id']); $condition[] = array('sp_id', '=', $sp_id); if (!empty($spvalue_ids)) { $condition[] = array('spvalue_id', 'not in', $spvalue_ids); } $spec_model->delSpecvalue($condition); if (!empty($specvalue_list)) { $spec_model->addSpecvalueALL($specvalue_list); } } ds_json_encode(10000, lang('ds_common_op_succ')); } }