getSetList('product/price_rule_sku', $where, $goods_category)); } # 配置商品 public function setGoods_api() { $data = array(); $data['price_rule_id'] = Dever::input('id', 1); $price = Dever::db('product/price_rule')->find($data['price_rule_id']); $goods_category = ''; $data['type'] = 1; $data['sell_num'] = $data['sell_num'] = 0; if ($price) { $goods_category = $price['category']; $data['type'] = $price['type']; $data['sell_num'] = $price['sell_num']; $data['buy_num'] = $price['buy_num']; } $data['host'] = Dever::url('lib/price.setGoods', 'product'); $data['url'] = Dever::url('lib/price.goods?price_rule_id=' . $data['price_rule_id'] . '&goods_category=' . $goods_category . '&price=' . $data['sell_num'] . '&buy_price=' . $data['buy_num'], 'product'); $data['submit'] = Dever::url('lib/price.setGoods_action_commit?json=1', 'product'); return Dever::render('set_price_goods', $data); } # 配置商品 public function setGoods_action_commit_api() { $goods = Dever::input('goods'); if (!$goods) { Dever::alert('请传入商品'); } $goods = Dever::json_decode($goods); $price_rule_id = Dever::input('price_rule_id'); $shop = Dever::db('product/price')->one($price_rule_id); $where['option_price_rule_id'] = $price_rule_id; $where['set_state'] = 2; Dever::db('product/price_rule_sku')->updates($where); foreach ($goods as $k => $v) { if ($v['del'] == 1) { $temp = explode('-', $k); $goods_id = $temp[0]; $sku_id = -1; if (isset($temp[1])) { $sku_id = $temp[1]; } $goods_info = Dever::db('product/info')->one($goods_id); $w = array(); $w['goods_id'] = $goods_id; $w['sku_id'] = $sku_id; $w['price_rule_id'] = $price_rule_id; $sku_info = Dever::db('product/price_rule_sku')->one($w); $w['status'] = $goods_info['status']; if (isset($v['price']) && $v['price']) { $w['price'] = $v['price']; } if (isset($v['buy_price']) && $v['buy_price']) { $w['buy_price'] = $v['buy_price']; } if (!$sku_info) { Dever::db('product/price_rule_sku')->insert($w); } else { $w['where_id'] = $sku_info['id']; $w['state'] = 1; Dever::db('product/price_rule_sku')->update($w); } } } return 'refer'; } }