public function edit() { $goodsId = I('goods_id'); if (IS_POST) { $p['title'] = I('title'); $p['goods_type'] = I('goods_type'); $p['cate_id'] = I('cate_id'); $p['tid'] = I('tid'); $p['seo_title'] = I('seo_title'); $p['seo_keywords'] = I('seo_keywords'); $p['seo_description'] = I('seo_description'); $p['price'] = I('post.price', 0.0, 'floatval'); $p['discount_price'] = I('post.discount_price', 0.0, 'floatval'); $p['child_price'] = I('child_price', 0.0, 'floatval'); $p['city'] = I('city'); $p['days'] = I('days'); $p['aheaddays'] = I('aheaddays'); $p['traffic'] = I('traffic'); $p['volume'] = I('volume'); $p['status'] = I('status'); $p['item_body'] = I('item_body'); $p['maxdays'] = I('maxdays'); $p['audition'] = I('audition'); $p['invite'] = I('invite'); $p['pic_url'] = I('pic_url'); $p["add_id"] = session('user_auth_admin.uid'); $p["add_uname"] = session('user_auth_admin.username'); $tag = I('tag'); $p['tags'] = implode($tag, ","); $GoodsModel = new GoodsModel(); $GoodsModel->addTags($tag, $goodsId); if (!$p['title']) { $this->error('请填写商品名称'); } if (!$p['price']) { $this->error('请填写商品价格'); } if (!$p['cate_id']) { $this->error('请填选择分类'); } if (empty($goodsId) && empty($p['pic_url'])) { $this->error('请上传商品图片'); } $goodsM = D('goods'); if (empty($goodsId)) { $goodsM->add($p); } else { $goodsM->where("goods_id='{$goodsId}'")->save($p); } $this->success('操作成功', U('index')); } $category = D('CategoryGoods')->getCategoryList(); $this->assign('mytag', explode(",", D('Goods')->getGoodsInfo($goodsId, "tags"))); $this->assign('tags', M('tag')->select()); $this->assign('category', $category); $this->assign('topic', M('topic')->where("state=1")->select()); $this->assign('sid', $sid); $this->assign('goodstype', M('goods_type')->where("status > 0")->order("sort")->select()); $this->assign('goods_id', $goodsId); $this->assign('goods', M('goods')->find($goodsId)); $this->display(); }