getSetList('role/seller_goods_sku', $where, $goods_category)); } # 配置商品 public function setGoods_api() { $data = array(); $data['seller_id'] = Dever::input('id', 1); $info = Dever::db('role/seller')->find($data['seller_id']); $data['info'] = $info; $goods_category = $info['category']; $data['host'] = Dever::url('lib/seller.setGoods', 'role'); $data['url'] = Dever::url('lib/seller.goods?seller_id=' . $data['seller_id'] . '&goods_category=' . $goods_category, 'role'); //$data['search'] = Dever::url('lib/seller.search?yes='.$data['seller_id'].'&json=1', 'role'); $data['submit'] = Dever::url('lib/seller.setGoods_action_commit?json=1', 'role'); return Dever::render('set_seller_goods', $data); } # 配置商品 public function setGoods_action_commit_api() { $goods = Dever::input('goods'); if (!$goods) { Dever::alert('请传入商品'); } $goods = Dever::json_decode($goods); $seller_id = Dever::input('seller_id'); $seller = Dever::db('role/seller')->one($seller_id); $where['option_seller_id'] = $seller_id; $where['set_state'] = 2; Dever::db('role/seller_goods')->updates($where); Dever::db('role/seller_goods_sku')->updates($where); foreach ($goods as $k => $v) { $temp = explode('-', $k); $goods_id = $temp[0]; if (isset($temp[1])) { $sku_id = $temp[1]; } else { $sku_id = -1; } if ($v['num'] < 0) { continue; } if ($v['del'] == 2) { $w = array(); $w['goods_id'] = $goods_id; $w['seller_id'] = $seller_id; $w['sku_id'] = $sku_id; $sku_info = Dever::db('role/seller_goods_sku')->one($w); if ($sku_info) { Dever::db('role/seller_goods_sku')->update(array('where_id' => $sku_info['id'], 'state' => 2)); } unset($w['sku_id']); $t = $w; $t['state'] = 1; $total = Dever::db('role/seller_goods_sku')->total($t); if ($total <= 0) { $info = Dever::db('role/seller_goods')->one($w); if ($info) { Dever::db('role/seller_goods')->update(array('where_id' => $info['id'], 'state' => 2)); } } } else { $goods_info = Dever::db('product/info')->one($goods_id); $w = array(); $w['goods_id'] = $goods_id; $w['seller_id'] = $seller_id; $info = Dever::db('role/seller_goods')->one($w); $w['in_num'] = $v['num']; $w['min'] = $v['min']; if (!$info) { Dever::db('role/seller_goods')->insert($w); } else { $w['in_num'] += $info['in_num']; $w['where_id'] = $info['id']; $w['state'] = 1; Dever::db('role/seller_goods')->update($w); } $w = array(); $w['goods_id'] = $goods_id; $w['seller_id'] = $seller_id; $w['sku_id'] = $sku_id; $info = Dever::db('role/seller_goods_sku')->one($w); $w['in_num'] = $v['num']; $w['min'] = $v['min']; if (!$info) { Dever::db('role/seller_goods_sku')->insert($w); } else { $w['in_num'] += $info['in_num']; $w['where_id'] = $info['id']; $w['state'] = 1; Dever::db('role/seller_goods_sku')->update($w); } } } return 'refer'; } }