protected function ajaxExecute(MUser $me, MShop $shop) { $cid = MRequest::request('cid'); // 所属类别id $title = MRequest::request('title'); $imgmd5 = MRequest::request('imgmd5'); // 图片MD5 $imgtype = MRequest::request('imgtype'); // 图片类型(image/png, image/jpeg) $price = MRequest::request('price'); // $stock = MRequest::request('stock'); // 库存 $stock = 999; // 库存 $onsale = MRequest::request('onsale'); // 是否在售 $listtime = MRequest::request('listtime'); // 上架时间 $delisttime = MRequest::request('delisttime'); // 下架时间 $listtime = strtotime($listtime); $delisttime = strtotime($delisttime); DalItem::beginTransaction(); try { DalItem::addItem($shop->getID(), $cid, $title, $imgmd5, $imgtype, $price, $stock, $onsale, $listtime, $delisttime); $num_iid = DalItem::getInsertId(); $item = DalItem::getShopItem($shop->getID(), $num_iid, 'w'); DalItem::commit(); } catch (Exception $e) { DalItem::rollback(); return MJsonRespond::respondFail($e->getMessage()); } return MJsonRespond::respondSuccess('成功', array('item' => $item)); }
protected function ajaxExecute(MUser $me, MShop $shop) { $num_iid = MRequest::post('iid'); // 商品id $cid = MRequest::post('cid'); // 分类id $title = MRequest::post('title'); $imgmd5 = MRequest::post('imgmd5'); $imgtype = MRequest::post('imgtype'); $price = MRequest::post('price'); $stock = null; // $stock = MRequest::post('stock'); $onsale = MRequest::post('onsale'); $listtime = MRequest::post('listtime'); $delisttime = MRequest::post('delisttime'); $listtime = strtotime($listtime); $delisttime = strtotime($delisttime); DalItem::beginTransaction(); try { DalItem::updateShopItem($num_iid, $shop->getID(), $cid, $title, $imgmd5, $imgtype, $price, $stock, $onsale, $listtime, $delisttime); $item = DalItem::getShopItem($shop->getID(), $num_iid, 'w'); if (!$item) { throw new Exception("item not exists", -100); } } catch (Exception $e) { DalItem::rollback(); return MJsonRespond::respondFail($e->getMessage()); } DalItem::commit(); return MJsonRespond::respondSuccess('成功', array('item' => $item)); }