コード例 #1
0
 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));
 }
コード例 #2
0
 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));
 }
コード例 #3
0
 protected function ajaxExecute(MUser $me, MShop $shop)
 {
     try {
         $category = $shop->allCategories();
     } catch (Exception $e) {
         return MJsonRespond::respondFail('获取店铺分类失败');
     }
     return MJsonRespond::respondSuccess('成功', array('category' => $category));
 }
コード例 #4
0
 protected function ajaxExecute(MUser $me, MShop $shop)
 {
     $numiid = MRequest::get('iid');
     try {
         $item = $shop->getItem($numiid);
     } catch (Exception $e) {
         return MJsonRespond::respondFail('获取商品列表失败');
     }
     return MJsonRespond::respondSuccess('成功', array('item' => $item->getMain()));
 }
コード例 #5
0
 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('成功');
 }
コード例 #6
0
 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));
 }
コード例 #7
0
 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));
 }
コード例 #8
0
 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('成功');
 }
コード例 #9
0
 protected function ajaxExecute(MUser $me, MShop $shop)
 {
     $lng = MRequest::post('lng');
     $lat = MRequest::post('lat');
     $address = MRequest::post('address');
     $radius = MRequest::post('radius');
     $servetime = MRequest::post('servetime');
     try {
         DalShop::addOrUpdateShopGeo($shop->getID(), $lng, $lat, $address, $radius, $servetime);
     } catch (Exception $e) {
         return MJsonRespond::respondFail($e->getMessage());
     }
     return MJsonRespond::respondSuccess('成功');
 }
コード例 #10
0
 protected function ajaxExecute(MUser $me, MShop $shop)
 {
     $img = MRequest::file('img');
     $tmpName = $img['tmp_name'];
     $md5 = md5_file($tmpName);
     $imgPath = MShopImageService::getImagePath($md5, true);
     if (!move_uploaded_file($tmpName, $imgPath)) {
         return MJsonRespond::respondFail();
     }
     $imgType = $img['type'];
     $imgUrl = MShopImageService::getImageUrl($md5);
     $response = array('md5' => $md5, 'imgType' => $imgType, 'imgUrl' => $imgUrl);
     return MJsonRespond::respondSuccess('上传成功', $response);
 }
コード例 #11
0
 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));
 }
コード例 #12
0
 protected function ajaxExecute(MUser $me, MShop $shop)
 {
     $shopname = MRequest::post('shopname');
     $intro = MRequest::post('intro');
     $imgmd5 = MRequest::post('imgmd5');
     $imgtype = MRequest::post('imgtype');
     $tel = MRequest::post('tel');
     $bulletin = '';
     $qq = '';
     $email = '';
     try {
         DalShop::updateShop($shop->getID(), $shopname, $intro, $bulletin, $qq, $tel, $email, $imgmd5, $imgtype);
     } catch (Exception $e) {
         return MJsonRespond::respondFail($e->getMessage());
     }
     return MJsonRespond::respondSuccess('成功');
 }
コード例 #13
0
 protected function ajaxExecute(MUser $me, MShop $shop)
 {
     $cid = MRequest::post('cid');
     $ps = (int) MRequest::post('ps');
     $pn = (int) MRequest::post('pn');
     $ps = max(0, $ps);
     if (!$pn) {
         $pn = 20;
     }
     try {
         $itemlist = $shop->getShopItems($cid, $ps, $pn);
         $foundrows = $shop->totalCount();
     } catch (Exception $e) {
         return MJsonRespond::respondFail('获取商品列表失败');
     }
     return MJsonRespond::respondSuccess('成功', array('itemlist' => $itemlist, 'total' => $foundrows));
 }
コード例 #14
0
 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));
 }
コード例 #15
0
 protected function ajaxExecute(MUser $me, MShop $shop)
 {
     $ps = (int) MRequest::get('ps');
     $pn = (int) MRequest::get('pn');
     $sid = $shop->getID();
     $status = (int) MRequest::get('st');
     $sort = (int) MRequest::get('sort');
     $ps = max(0, $ps);
     if (!$pn) {
         $pn = 20;
     }
     if ($sort === 0) {
         $orders = DalOrder::getShopEarliestOrders($sid, $status, $ps, $pn);
     } else {
         $orders = DalOrder::getShopLatestOrders($sid, $status, $ps, $pn);
     }
     $total = DalOrder::totalCount();
     if (empty($orders)) {
         return MJsonRespond::respondSuccess('', array('orders' => $orders, 'total' => $total));
     }
     $orders = LibOrder::fillOrders($orders);
     return MJsonRespond::respondSuccess('成功', array('orders' => $orders, 'total' => $total));
 }