getData($id); } # 设置商品 public function home_api() { $data = array(); $data['link'] = Dever::decode(Dever::input('refer')); $data['prize_id'] = Dever::input('id', 1); Dever::setInput('prize_id', $data['prize_id']); $data['host'] = Dever::url('lib/prize_set.home?id=' . $data['prize_id'], 'agent'); $data['url'] = Dever::url('lib/prize_set.goods?prize_id=' . $data['prize_id'], 'agent'); $data['submit'] = Dever::url('lib/prize_set.action_commit?json=1', 'agent'); return Dever::render('setPrizeGoods', $data); } # 设置 public function action_commit_api() { $goods = Dever::input('goods'); if (!$goods) { Dever::alert('请传入商品'); } $goods = Dever::json_decode($goods); $prize_id = Dever::input('prize_id'); $where['option_prize_id'] = $prize_id; $where['set_state'] = 2; Dever::db('setting/prize_goods')->updates($where); foreach ($goods as $k => $v) { $type = 1; $type_id = $k; $sku_id = -1; if (strstr($k, '_')) { $temp = explode('_', $k); $type_id = $temp[0]; $type = $temp[1]; } elseif (strstr($k, '-')) { $temp = explode('-', $k); $type_id = $temp[0]; $sku_id = $temp[1]; } if ($v['total'] <= 0) { continue; } $w = array(); $w['type'] = $type; $w['type_id'] = $type_id; $w['prize_id'] = $prize_id; $w['sku_id'] = $sku_id; $info = Dever::db('setting/prize_goods')->one($w); if ($v['del'] == 2) { if ($info) { Dever::db('setting/prize_goods')->update(array('where_id' => $info['id'], 'state' => 2)); } } else { $w['num'] = $v['total']; if (!$info) { Dever::db('setting/prize_goods')->insert($w); } else { $w['where_id'] = $info['id']; $w['state'] = 1; Dever::db('setting/prize_goods')->update($w); } } } return 'reload'; } }