Example #1
0
 public function actionShop_edit()
 {
     $this->setauth();
     //检查有无权限
     $p_db = Yii::app()->p_db;
     $id = $_GET['id'];
     $shop = VcosShop::model()->findByPk($id);
     if ($_POST) {
         $code = isset($_POST['code']) ? $_POST['code'] : '';
         $name = isset($_POST['name']) ? $_POST['name'] : '';
         $desc = isset($_POST['desc']) ? $_POST['desc'] : '';
         $people = isset($_POST['people']) ? $_POST['people'] : '';
         $company = isset($_POST['company']) ? $_POST['company'] : '';
         $address = isset($_POST['address']) ? $_POST['address'] : '';
         $price = isset($_POST['price']) ? $_POST['price'] * 100 : '';
         $products = isset($_POST['products']) ? $_POST['products'] : '';
         $photo = '';
         if ($_FILES['photo']['error'] != 4) {
             $result = Helper::upload_file('photo', Yii::app()->params['img_save_url'] . 'shop_images/' . Yii::app()->params['month'], 'image', 3);
             $photo = $result['filename'];
         }
         $photo1 = '';
         if ($_FILES['photo1']['error'] != 4) {
             $result = Helper::upload_file('photo1', Yii::app()->params['img_save_url'] . 'shop_images/' . Yii::app()->params['month'], 'image', 3);
             $photo1 = $result['filename'];
         }
         $photo2 = '';
         if ($_FILES['photo2']['error'] != 4) {
             $result = Helper::upload_file('photo2', Yii::app()->params['img_save_url'] . 'shop_images/' . Yii::app()->params['month'], 'image', 3);
             $photo1 = $result['filename'];
         }
         $photo_url2 = 'shop_images/' . Yii::app()->params['month'] . '/' . $photo2;
         $photo_url1 = 'shop_images/' . Yii::app()->params['month'] . '/' . $photo1;
         $photo_url = 'shop_images/' . Yii::app()->params['month'] . '/' . $photo;
         $state = isset($_POST['state']) ? $_POST['state'] : '0';
         $create_times = date("Y/m/d H:i:s", time());
         $cruise_id = Yii::app()->params['cruise_id'];
         //事务处理
         $transaction = $p_db->beginTransaction();
         try {
             $shop->shop_code = $code;
             $shop->shop_title = $name;
             if ($photo) {
                 $shop->shop_logo = $photo_url;
             }
             if ($photo1) {
                 $shop->business_license = $photo_url1;
             }
             if ($photo2) {
                 $shop->shop_img_url = $photo_url2;
             }
             $shop->shop_desc = $desc;
             $shop->legal_representative = $people;
             $shop->company_name = $company;
             $shop->shop_address = $address;
             $shop->cash_deposit = $price;
             $shop->main_products = $products;
             $shop->created = $create_times;
             $shop->shop_status = $state;
             $shop->cruise_id = $cruise_id;
             $shop->save();
             $transaction->commit();
             Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Shop/shop_list"));
         } catch (Exception $e) {
             $transaction->rollBack();
             Helper::show_message(yii::t('vcos', '修改失败。'));
         }
     }
     $this->render('shop_edit', array('shop' => $shop));
 }
Example #2
0
 public function actionShop_edit()
 {
     $this->setauth();
     //检查有无权限
     $p_db = Yii::app()->p_db;
     $id = $_GET['id'];
     $shop = VcosShop::model()->findByPk($id);
     if ($_POST) {
         $code = isset($_POST['code']) ? $_POST['code'] : '';
         $name = isset($_POST['name']) ? $_POST['name'] : '';
         $desc = isset($_POST['desc']) ? $_POST['desc'] : '';
         $people = isset($_POST['people']) ? $_POST['people'] : '';
         $company = isset($_POST['company']) ? $_POST['company'] : '';
         $address = isset($_POST['address']) ? $_POST['address'] : '';
         $price = isset($_POST['price']) ? $_POST['price'] * 100 : '';
         $products = isset($_POST['products']) ? $_POST['products'] : '';
         $photo = '';
         if ($_FILES['photo']['error'] != 4) {
             $result = Helper::upload_file('photo', Yii::app()->params['img_save_url'] . 'shop_images/' . Yii::app()->params['month'], 'image', 3);
             $photo = $result['filename'];
         }
         $photo_url = 'shop_images/' . Yii::app()->params['month'] . '/' . $photo;
         $photo1 = '';
         if ($_FILES['photo1']['error'] != 4) {
             $result = Helper::upload_file('photo1', Yii::app()->params['img_save_url'] . 'shop_images/' . Yii::app()->params['month'], 'image', 3);
             $photo1 = $result['filename'];
         }
         $photo_url1 = 'shop_images/' . Yii::app()->params['month'] . '/' . $photo1;
         $photo2 = '';
         if ($_FILES['photo2']['error'] != 4) {
             $result = Helper::upload_file('photo2', Yii::app()->params['img_save_url'] . 'shop_images/' . Yii::app()->params['month'], 'image', 3);
             $photo2 = $result['filename'];
         }
         $photo_url2 = 'shop_images/' . Yii::app()->params['month'] . '/' . $photo2;
         $state = isset($_POST['state']) ? $_POST['state'] : '0';
         $create_times = date("Y/m/d H:i:s", time());
         $cruise_id = Yii::app()->params['cruise_id'];
         //事务处理
         $transaction = $p_db->beginTransaction();
         try {
             $shop->shop_code = $code;
             $shop->shop_title = $name;
             if ($photo) {
                 $shop->shop_logo = $photo_url;
             }
             if ($photo1) {
                 $shop->shop_img_url = $photo_url1;
             }
             if ($photo2) {
                 $shop->business_license = $photo_url2;
             }
             $shop->shop_desc = $desc;
             $shop->legal_representative = $people;
             $shop->company_name = $company;
             $shop->shop_address = $address;
             $shop->cash_deposit = $price;
             $shop->main_products = $products;
             $shop->created = $create_times;
             $shop->shop_status = $state;
             $shop->cruise_id = $cruise_id;
             $shop->save();
             //修改活动商品(栏目页面配置是否有效问题)
             $sql = "SELECT is_delete FROM `vcos_shop` WHERE shop_id='{$id}'";
             $this_data = Yii::app()->p_db->createCommand($sql)->queryRow();
             if ($state == 0) {
                 $flag = 1;
             } else {
                 if ($state == 1) {
                     if ($this_data['is_delete'] == 1) {
                         $flag = 1;
                     } else {
                         $flag = 0;
                     }
                 }
             }
             if ($flag == 1) {
                 $sql = "UPDATE `vcos_activity_product` SET is_overdue=1 WHERE product_id='{$id}' AND product_type=3";
             } else {
                 if ($flag == 0) {
                     $sql = "UPDATE `vcos_activity_product` SET is_overdue=0 WHERE product_id='{$id}' AND product_type=3";
                 }
             }
             $p_db->createCommand($sql)->execute();
             $transaction->commit();
             Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Shop/shop_list"));
         } catch (Exception $e) {
             $transaction->rollBack();
             Helper::show_message(yii::t('vcos', '修改失败。'));
         }
     }
     $sql = "SELECT a.*,b.name,c.name parent_name FROM `vcos_shop_operation_category` a LEFT JOIN `vcos_category` b ON a.category_code=b.category_code LEFT JOIN `vcos_category` c ON a.parent_catogory_code=c.category_code WHERE a.status=1 AND a.shop_id=" . $id;
     $shop_operation = Yii::app()->p_db->createCommand($sql)->queryAll();
     $shop_operation = self::shopsortOut($shop_operation);
     //var_dump($shop_operation);exit;
     $sql = "SELECT * FROM `vcos_shop_category` a LEFT JOIN\r\n\t\t(SELECT parent_cid,count(parent_cid) count FROM `vcos_shop_category` b WHERE shop_id=" . $id . " GROUP BY parent_cid) b ON a.parent_cid=b.parent_cid\r\n\t\tWHERE a.shop_id=" . $id . " ORDER BY sort_order";
     $shop_cat = $p_db->createCommand($sql)->queryAll();
     $shop_cat = self::sortOut($shop_cat);
     $this->render('shop_edit', array('shop_cat' => $shop_cat, 'shop' => $shop, 'auth' => $this->auth, 'shop_operation' => $shop_operation));
 }