예제 #1
0
 /** 
  * 返回优惠券的详情, 包括shop和shopBranches
  * @param id
  * 
  * @return coupon: coupon的数据
  * 
  * 
  */
 public function coupon_get()
 {
     $id = $this->get('id');
     if (!empty($id)) {
         //优惠券id不为空
         $result = $this->coupon_m->get($id, 'shop,shop.shopBranches');
         return $this->output_results($result, '获得对象失败');
     } else {
         $url = HOST . "/classes/Coupon?";
         $json = $this->jsonWithGETUrl($url);
         $error = checkResponseError($json);
         if (!empty($error)) {
             return $error;
         }
         $results = resultsWithJson($json);
         $this->output_results($results);
         //			if (!isLocalhost())
         //				$this->output->cache(CacheTime);
         //			$this->load->library('avoslibrary');
         //			$json = $this->avoslibrary->get($url);
         //			return $this->outputArray($results);
     }
 }
예제 #2
0
 /** 
  * 返回优惠券的详情, 包括shop和shopBranches
  * @param id
  * 
  * @return coupon: coupon的数据
  * 
  * 
  */
 public function coupon_get()
 {
     $id = $this->get('id');
     if (!empty($id)) {
         $result = $this->coupon_m->get($id, 'shop,shop.shopBranches');
         if ($result < 0) {
             return $this->api_output_error($result, '获得对象失败');
         }
         //  			return $this->outputArray($result);
         return $this->output_results($result, '获得对象失败');
     } else {
         $url = HOST . "/classes/Coupon?";
         $json = $this->jsonWithGETUrl($url);
         $error = checkResponseError($json);
         if (!empty($error)) {
             return $error;
         }
         $results = resultsWithJson($json);
         if (!isLocalhost()) {
             $this->output->cache(CacheTime);
         }
         return $this->outputArray($results);
     }
 }
예제 #3
0
 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);
     }
 }