コード例 #1
0
ファイル: coupontypes.php プロジェクト: iHamburg/kqserver
 function create($parentId = '')
 {
     //处理post的值
     if ($this->input->post('title')) {
         //			var_dump($_POST);
         $title = $this->input->post('title');
         $parentId = $this->input->post('parentId');
         $continuous = $this->input->post('continuous');
         if (empty($parentId)) {
             //一级类型
             $objectId = $this->model->create(array('title' => $title));
         } else {
             //二级类型
             $objectId = $this->model->create(array('title' => $title, 'parent' => avosPointer('CouponType', $parentId)));
         }
         if (empty($continuous)) {
             // redirect to index
             $this->session->set_flashdata('msg', '创建成功');
             redirect('admin/coupontypes/index', 'refresh');
         }
     }
     // display form
     $data['title'] = '新建类型';
     $data['main'] = 'admin_coupontypes_create';
     if (!empty($parentId)) {
         $data['parentId'] = $parentId;
     }
     $this->load->view($this->config->item('admin_template'), $data);
 }
コード例 #2
0
ファイル: coupon_m.php プロジェクト: iHamburg/kqserver
 function addInShop($couponId, $shopId)
 {
     $json = $this->avoslibrary->addPointerInArray('Shop', $shopId, 'coupons', avosPointer('Coupon', $couponId));
     $result = json_decode($json, true);
     if (!empty($result['error'])) {
         return $json;
         return Error_Add_Object_In_Array;
     }
     return true;
 }
コード例 #3
0
ファイル: shops.php プロジェクト: iHamburg/kqserver
 function editShopbranch($id)
 {
     if ($this->input->post('title')) {
         //			var_dump($_POST);
         $keys = array('title', 'openTime', 'phone', 'address');
         foreach ($keys as $key) {
             $data[$key] = $this->input->post($key);
         }
         $data['district'] = avosPointer('District', $this->input->post('districtId'));
         $data['subDistrict'] = avosPointer('District', $this->input->post('subDistrictId'));
         $latitude = doubleval($this->input->post('latitude'));
         $longitude = doubleval($this->input->post('longitude'));
         $data['location'] = avosGeoPoint($latitude, $longitude);
         $result = $this->model->update($id, $data);
         if ($result < 0) {
             echo $result;
         } else {
             $this->session->set_flashdata('msg', '创建成功');
             redirect('admin/shops/index', 'refresh');
         }
         return;
     }
     $headDistricts = $this->district_m->get_all_headDistrict();
     $subDistricts = array();
     foreach ($headDistricts as $district) {
         $subDistricts = array_merge($subDistricts, $district['subDistricts']);
     }
     $data['title'] = '子商户';
     $data['main'] = 'admin_shops_editshopbranch';
     $data['model'] = $this->model->get($id);
     $data['headDistricts'] = $headDistricts;
     $data['subDistricts'] = $subDistricts;
     $this->load->view($this->config->item('admin_template'), $data);
 }
コード例 #4
0
ファイル: kqapi.php プロジェクト: iHamburg/kqserver
 private function isCouponFavorited($uid = '', $couponId = '')
 {
     $value = array('people' => avosPointer('_User', $uid), 'coupon' => avosPointer('Coupon', $couponId));
     $json = $this->kq->retrieveObjects('FavoritedCoupon', json_encode($value));
     $results = resultsWithJson($json);
     if (empty($results)) {
         return false;
     } else {
         return true;
     }
 }
コード例 #5
0
ファイル: kqapi3.php プロジェクト: iHamburg/kqserver
 /**
  * 
  * 返回总店的所有分店信息
  * param: parentId
  */
 public function shopbranches_get()
 {
     $url = HOST . "/classes/Shop?";
     $parentId = $this->get('parentId');
     if (empty($parentId)) {
         outputError(-1, '没有总店信息');
     }
     $where = array('parent' => avosPointer('Shop', $parentId));
     $url .= 'where=' . json_encode($where);
     $json = $this->kq->get($url);
     $error = checkResponseError($json);
     if (!empty($error)) {
         return $error;
     }
     $results = resultsWithJson($json);
     foreach ($results as $result) {
         $array[] = array_slice_keys($result, array('title', 'objectId', 'phone', 'address', 'openTime', 'location'));
     }
     if (!isLocalhost()) {
         $this->output->cache(CacheTime);
     }
     return $this->output_results($array);
 }
コード例 #6
0
ファイル: ctype_m.php プロジェクト: iHamburg/kqserver
 /**
  * 如果
  * @param unknown_type $id
  */
 public function delete($id, $parentId)
 {
     if (!empty($parentId)) {
         $this->avoslibary->removePointerInArray('CouponType', $parentId, 'subType', avosPointer('CouponType', $id));
         $error = checkResponseError($json);
         if (!empty($error)) {
             return false;
         }
     }
     $json = $this->avoslibrary->deleteObject('CouponType', $id);
     $error = checkResponseError($json);
     if (!empty($error)) {
         return false;
     }
     return true;
 }
コード例 #7
0
ファイル: user_m.php プロジェクト: iHamburg/kqserver
 public function get_user_downloaded_coupons($uid)
 {
     $where = json_encode(array('people' => avosPointer('_User', $uid)));
     $json = $this->avoslibrary->retrieveObjects('DownloadedCoupon', $where, 'coupon', '', 'coupon');
     $results = json_decode($json, true);
     if (empty($results['error'])) {
         foreach ($results['results'] as $record) {
             $coupons[] = $record['coupon'];
         }
         return $coupons;
     } else {
         return $results;
     }
 }
コード例 #8
0
ファイル: shop_m.php プロジェクト: iHamburg/kqserver
 public function deleteShopBranch($id, $parentId)
 {
     $json = $this->avoslibrary->removePointerInArray('Shop', $parentId, 'shopBranches', avosPointer('Shop', $id));
     $result = json_decode($json, true);
     if (!empty($result['error'])) {
         return Error_Remove_Object_In_Array;
     }
     $json = $this->avoslibrary->deleteObject('Shop', $id);
     $result = json_decode($json, true);
     if (!empty($result['error'])) {
         return Error_Delete_Object;
     }
     return true;
 }
コード例 #9
0
ファイル: district_m.php プロジェクト: iHamburg/kqserver
 /**
  * 
  * 创建类型
  * @param array $data
  * @return string $objectId
  */
 public function create($data)
 {
     $json = $this->avoslibrary->createObject('District', json_encode($data));
     $error = checkResponseError($json);
     if (!empty($error)) {
         return false;
     }
     $result = json_decode($json, true);
     $newId = $result['objectId'];
     if (!empty($data['parent'])) {
         $parentId = $data['parent']['objectId'];
         $this->avoslibrary->addPointerInArray('District', $parentId, 'subDistricts', avosPointer('District', $newId));
         $error = checkResponseError($json);
         if (!empty($error)) {
             return false;
         }
     }
     return $newId;
 }
コード例 #10
0
ファイル: avoslibrary.php プロジェクト: iHamburg/kqserver
 /**
  * 
  * 获得fatherClass的relate的所有sonClass, 不能是_User 
  * @param unknown_type $fatherClassName
  * @param unknown_type $fatherId
  * @param unknown_type $key
  * @param unknown_type $sonClassName
  */
 function retrieveRelation($fatherClassName, $fatherId, $key, $sonClassName)
 {
     $where = json_encode(array('$relatedTo' => array('object' => avosPointer($fatherClassName, $fatherId), 'key' => $key)));
     $url = HOST . '/classes/' . $sonClassName . '?where=' . $where;
     return $this->get($url);
 }
コード例 #11
0
ファイル: coupons.php プロジェクト: iHamburg/kqserver
 function edit($id)
 {
     if ($this->input->post('title')) {
         //			var_dump($_POST);
         $keys = array('title', 'discountContent', 'validate', 'usage', 'avatarUrl');
         foreach ($keys as $key) {
             $data[$key] = $this->input->post($key);
         }
         $shopId = $this->input->post('shopId');
         $data['shop'] = avosPointer('Shop', $shopId);
         $id = $this->input->post('id');
         //			echobr($id);
         //			var_dump($data);
         $objectId = $this->model->update($id, $data);
         if ($objectId < 0) {
             echo $objectId;
         } else {
             $this->session->set_flashdata('msg', '修改优惠券成功');
             redirect('admin/coupons/index', 'refresh');
         }
     } else {
         // display form
         $coupon = $this->model->get($id);
         $shopId = $coupon['shop']['objectId'];
         $shops = $this->shop_m->get_all_headShops(0, 200);
         if ($shops < 0) {
             var_dump($shops);
         }
         $data['title'] = '编辑优惠券';
         $data['main'] = 'admin_coupons_edit';
         $data['shopId'] = $shopId;
         $data['shops'] = $shops;
         $data['model'] = $coupon;
         $this->load->view($this->config->item('admin_template'), $data);
     }
 }
コード例 #12
0
ファイル: my_m.php プロジェクト: iHamburg/kqserver
 function remove_my_favorited_shop($uid, $sessionToken, $shopId)
 {
     $json = $this->avoslibrary->removePointerInArrayForUser($uid, $sessionToken, 'favoritedShops', avosPointer('Shop', $shopId));
     $result = json_decode($json, true);
     return $result;
 }