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::request('iid'); try { DalItem::deleteShopItem($num_iid, $shop->getID()); Observer::postNotify('item.delete', $num_iid); } catch (Exception $e) { return MJsonRespond::respondFail('删除失败'); } return MJsonRespond::respondSuccess('成功'); }
protected function ajaxExecute(MUser $me, MShop $shop) { $cid = MRequest::request('cid'); $newName = MRequest::request('name'); try { $shop->updateCategory($cid, $newName); $category = $shop->getCategory($cid); } catch (Exception $e) { return MJsonRespond::respondFail('更新失败'); } return MJsonRespond::respondSuccess('成功', array('category' => $category)); }
protected function ajaxExecute(MUser $me, MShop $shop) { $oid = MRequest::request('oid'); try { LibOrder::shipShopOrder($shop->getID(), $oid); } catch (Exception $e) { return MJsonRespond::respondFail($e->getMessage()); } $order = DalOrder::getShopOrder($shop->getID(), $oid); $order = array_pop(LibOrder::fillOrders(array($order))); return MJsonRespond::respondSuccess('成功', array('order' => $order)); }
protected function ajaxExecute(MUser $me, MShop $shop) { $cid = MRequest::request('cid'); try { $shop->deleteCategory($cid); } catch (Exception $e) { if (in_array($e->getCode(), array(ERR_CATEGORY_NOT_EXIST))) { return MJsonRespond::respondFail($e->getMessage()); } return MJsonRespond::respondFail('删除失败'); } return MJsonRespond::respondSuccess('成功'); }
protected function signinExecute(MUser $me) { $img = MRequest::file('img'); $context = MRequest::request('context'); $tmpName = $img['tmp_name']; $md5 = md5_file($tmpName); $imgPath = MShopImageService::getImagePath($md5, true); if (!move_uploaded_file($tmpName, $imgPath)) { echo '<script>try{ window.parent.uploadImageFail(-1, "upload fail", "' . $context . '");}catch(e){}</script>'; return; } $imgType = $img['type']; $imgUrl = MShopImageService::getImageUrl($md5); echo '<script>try{ window.parent.uploadImageSuccess("' . $md5 . '","' . $imgType . '", "' . $imgUrl . '", "' . $context . '");}catch(e){}</script>'; }
protected function ajaxExecute() { $tel = MRequest::request('tel'); $invitecode = MRequest::request('invitecode'); try { $verify = DalUser::getUserVerify($tel); if ($verify) { return MJsonRespond::respond(ERR_VERIFY_CODE_ALREADY_SEND, '验证码已发出,请不要频繁请求'); } $verify = LibUser::generateUserVerify($tel, $invitecode); //TODO:send verify code } catch (DBException $e) { return MJsonRespond::respondFail('获取验证码失败'); } return MJsonRespond::respondSuccess('获取验证码成功', array('verify' => $verify)); }
protected function ajaxExecute(MUser $me, MShop $shop) { $parent_cid = intval(MRequest::request('parent_cid')); $name = MRequest::request('name'); $sid = $shop->getID(); $intro = ''; try { $cid = $shop->addCategory($parent_cid, $name, time()); } catch (DBException $e) { return MJsonRespond::respondFail('创建失败'); } try { $category = DalCategory::getCategory($cid, $shop->getID()); } catch (DBException $e) { return MJsonRespond::respondFail('数据库访问失败'); } return MJsonRespond::respondSuccess('创建成功', array('category' => $category)); }