Beispiel #1
0
	/**
	 * 新增/编辑发货地址
	 */
    public function daddress_addOp() {
        Language::read('member_member_index');
        $lang	= Language::getLangContent();
        $model_daddress = Model('daddress');
        if (chksubmit()) {
            //保存 新增/编辑 表单
			$obj_validate = new Validate();
			$obj_validate->validateparam = array(
				array("input"=>$_POST["seller_name"],"require"=>"true","message"=>$lang['store_daddress_receiver_null']),
				array("input"=>$_POST["area_id"],"require"=>"true","validator"=>"Number","message"=>$lang['store_daddress_wrong_area']),
				array("input"=>$_POST["city_id"],"require"=>"true","validator"=>"Number","message"=>$lang['store_daddress_wrong_area']),
				array("input"=>$_POST["area_info"],"require"=>"true","message"=>$lang['store_daddress_area_null']),
				array("input"=>$_POST["address"],"require"=>"true","message"=>$lang['store_daddress_address_null']),
				array("input"=>$_POST['telphone'],'require'=>'true','message'=>$lang['store_daddress_phone_and_mobile'])
			);
			$error = $obj_validate->validate();
			if ($error != ''){
				showValidateError($error);
			}
			$data = array(
				'store_id' => $_SESSION['store_id'],
				'seller_name' => $_POST['seller_name'],
				'area_id' => $_POST['area_id'],
				'city_id' => $_POST['city_id'],
				'area_info' => $_POST['area_info'],
				'address' => $_POST['address'],
				'telphone' => $_POST['telphone'],
				'company' => $_POST['company']
			);
			$address_id = intval($_POST['address_id']);
			if ($address_id > 0){
			    $condition = array();
			    $condition['address_id'] = $address_id;
			    $condition['store_id'] = $_SESSION['store_id'];
				$update = $model_daddress->editAddress($data,$condition);
				if (!$update){
					showDialog($lang['store_daddress_modify_fail'],'','error');
				}
			} else {
				$insert = $model_daddress->addAddress($data);
				if (!$insert){
					showDialog($lang['store_daddress_add_fail'],'','error');
				}
			}
			showDialog($lang['nc_common_op_succ'],'reload','succ','CUR_DIALOG.close()');
        } elseif (is_numeric($_GET['address_id']) > 0) {
            //编辑
            $condition = array();
            $condition['address_id'] = intval($_GET['address_id']);
            $condition['store_id'] = $_SESSION['store_id'];
            $address_info = $model_daddress->getAddressInfo($condition);
            if (empty($address_info) && !is_array($address_info)){
                showMessage($lang['store_daddress_wrong_argument'],'index.php?act=store_deliver_set&op=daddress_list','html','error');
            }
            Tpl::output('address_info',$address_info);
        }
        Tpl::showpage('store_deliver_set.daddress_add','null_layout');
    }
Beispiel #2
0
 /**
  * 我的资料【email修改】
  *
  * @param 
  * @return 
  */
 public function emailOp()
 {
     /**
      * 读取语言包
      */
     Language::read('member_home_member');
     $lang = Language::getLangContent();
     /**
      * 实例化模型
      */
     $model_member = Model('member');
     if (chksubmit()) {
         /**
          * 填写密码信息验证
          */
         $obj_validate = new Validate();
         $obj_validate->validateparam = array(array("input" => $_POST["orig_password"], "require" => "true", "message" => $lang['home_member_password_null']), array("input" => $_POST["email"], "require" => "true", "validator" => "email", "message" => $lang['home_member_input_email_again_format']));
         $error = $obj_validate->validate();
         if ($error != '') {
             showValidateError($error);
         }
         /**
          * 邮箱是否存在检查
          */
         $email_array = $model_member->getby_member_email(trim($_POST['email']));
         if (!empty($email_array) && is_array($email_array)) {
             showDialog($lang['home_member_input_email_again_exists']);
         }
         /**
          * 密码是否正确检查
          */
         $member_info = $model_member->where(array('member_name' => trim($_SESSION['member_name']), 'member_passwd' => md5(trim($_POST['orig_password']))))->find();
         if (empty($member_info)) {
             showDialog($lang['home_member_input_password_again_wrong']);
         }
         /**
          * 修改电子邮件地址
          */
         $update = $model_member->update(array('member_email' => trim($_POST['email']), 'member_id' => $_SESSION['member_id']));
         if ($update) {
             $_SESSION['member_email'] = trim($_POST['email']);
             $message = $lang['nc_common_save_succ'];
         } else {
             $message = $lang['nc_common_save_fail'];
         }
         showDialog($message, 'reload', $update ? 'succ' : 'error');
     }
     self::profile_menu('member', 'email');
     Tpl::output('menu_sign', 'profile');
     Tpl::output('menu_sign_url', 'index.php?act=member&op=home');
     Tpl::output('menu_sign1', 'email');
     Tpl::setLayout('member_pub_layout');
     Tpl::showpage('member_email');
 }
Beispiel #3
0
 public function inform_saveOp()
 {
     //检查当前用户是否允许举报
     $this->check_member_allow_inform();
     $goods_id = intval($_POST['inform_goods_id']);
     //获取商品详细信息
     $goods_info = $this->get_goods_info_byid($goods_id);
     //检查是否是本店商品
     if (!empty($_SESSION['store_id'])) {
         if ($goods_info['store_id'] == $_SESSION['store_id']) {
             showDialog(Language::get('para_error'));
         }
     }
     //实例化举报模型
     $model_inform = Model('inform');
     //检查是否当前正在举报
     if ($model_inform->isProcessOfInform($goods_id)) {
         showDialog(Language::get('inform_handling'));
     }
     //处理用户输入的数据
     $input = array();
     $input['inform_member_id'] = $_SESSION['member_id'];
     $input['inform_member_name'] = $_SESSION['member_name'];
     $input['inform_goods_id'] = $goods_id;
     $input['inform_goods_name'] = $goods_info['goods_name'];
     $input['inform_goods_image'] = $goods_info['goods_image'];
     list($input['inform_subject_id'], $input['inform_subject_content']) = explode(",", trim($_POST['inform_subject']));
     $input['inform_content'] = trim($_POST['inform_content']);
     //上传图片
     $inform_pic = array();
     $inform_pic[1] = 'inform_pic1';
     $inform_pic[2] = 'inform_pic2';
     $inform_pic[3] = 'inform_pic3';
     $pic_name = $this->inform_upload_pic($inform_pic);
     $input['inform_pic1'] = $pic_name[1];
     $input['inform_pic2'] = $pic_name[2];
     $input['inform_pic3'] = $pic_name[3];
     $input['inform_datetime'] = time();
     $input['inform_store_id'] = $goods_info['store_id'];
     $input['inform_store_name'] = $goods_info['store_name'];
     $input['inform_state'] = 1;
     $input['inform_handle_message'] = '';
     $input['inform_handle_member_id'] = 0;
     $input['inform_handle_datetime'] = 1;
     //验证输入的数据
     $obj_validate = new Validate();
     $obj_validate->validateparam = array(array("input" => $input["inform_content"], "require" => "true", "validator" => "Length", "min" => "1", "max" => "100", "message" => Language::get('inform_content_null')), array("input" => $input["inform_subject_content"], "require" => "true", "validator" => "Length", "min" => "1", "max" => "50", "message" => Language::get('para_error')));
     $error = $obj_validate->validate();
     if ($error != '') {
         showValidateError($error);
     }
     //保存
     if ($model_inform->saveInform($input)) {
         showDialog(Language::get('inform_success'), 'index.php?act=member_inform&op=inform_list', 'succ');
     } else {
         showDialog(Language::get('inform_fail'), 'index.php?act=member_inform&op=inform_list', 'error');
     }
 }
Beispiel #4
0
 public function appeal_saveOp()
 {
     $complain_id = intval($_POST['input_complain_id']);
     //获取投诉详细信息
     $complain_info = $this->get_complain_info($complain_id);
     //检查当前是不是投诉状态
     if (intval($complain_info['complain_state']) !== self::STATE_APPEAL) {
         showDialog(Language::get('para_error'), 'reload');
     }
     $input = array();
     $input['appeal_message'] = trim($_POST['input_appeal_message']);
     //验证输入的信息
     $obj_validate = new Validate();
     $obj_validate->validateparam = array(array("input" => $input['appeal_message'], "require" => "true", "validator" => "Length", "min" => "1", "max" => "255", "message" => Language::get('appeal_message_error')));
     $error = $obj_validate->validate();
     if ($error != '') {
         showValidateError($error);
     }
     //上传图片
     $appeal_pic = array();
     $appeal_pic[1] = 'input_appeal_pic1';
     $appeal_pic[2] = 'input_appeal_pic2';
     $appeal_pic[3] = 'input_appeal_pic3';
     $pic_name = array();
     $upload = new UploadFile();
     $uploaddir = ATTACH_PATH . DS . 'complain' . DS;
     $upload->set('default_dir', $uploaddir);
     $upload->set('allow_type', array('jpg', 'jpeg', 'gif', 'png'));
     $count = 1;
     foreach ($appeal_pic as $pic) {
         if (!empty($_FILES[$pic]['name'])) {
             $result = $upload->upfile($pic);
             if ($result) {
                 $pic_name[$count] = $upload->file_name;
                 $upload->file_name = '';
             } else {
                 $pic_name[$count] = '';
             }
         }
         $count++;
     }
     $input['appeal_pic1'] = $pic_name[1];
     $input['appeal_pic2'] = $pic_name[2];
     $input['appeal_pic3'] = $pic_name[3];
     $input['appeal_datetime'] = time();
     $input['complain_state'] = self::STATE_TALK;
     $where_array = array();
     $where_array['complain_id'] = $complain_id;
     //保存申诉信息
     $model_complain = Model('complain');
     $complain_id = $model_complain->updateComplain($input, $where_array);
     $this->recordSellerLog('投诉申诉处理,投诉编号:' . $complain_id);
     showDialog(Language::get('appeal_submit_success'), 'index.php?act=store_complain', 'succ');
 }
Beispiel #5
0
 /**
  * 会员地址
  *
  * @param
  * @return
  */
 public function addressOp()
 {
     /**
      * 读取语言包
      */
     Language::read('member_member_index');
     $lang = Language::getLangContent();
     /**
      * 实例化模型
      */
     $address_class = Model('address');
     /**
      * 判断页面类型
      */
     if (!empty($_GET['type'])) {
         /**
          * 新增/编辑地址页面
          */
         if (intval($_GET['id']) > 0) {
             /**
              * 得到地址信息
              */
             $address_info = $address_class->getOneAddress(intval($_GET['id']));
             if ($address_info['member_id'] != $_SESSION['member_id']) {
                 showMessage($lang['member_address_wrong_argument'], 'index.php?act=member&op=address', 'html', 'error');
             }
             /**
              * 输出地址信息
              */
             Tpl::output('address_info', $address_info);
         }
         /**
          * 增加/修改页面输出
          */
         Tpl::output('type', $_GET['type']);
         Tpl::showpage('address_form', 'null_layout');
         exit;
     }
     /**
      * 判断操作类型
      */
     if (chksubmit()) {
         /**
          * 验证表单信息
          */
         $obj_validate = new Validate();
         $obj_validate->validateparam = array(array("input" => $_POST["true_name"], "require" => "true", "message" => $lang['member_address_receiver_null']), array("input" => $_POST["area_id"], "require" => "true", "validator" => "Number", "message" => $lang['member_address_wrong_area']), array("input" => $_POST["city_id"], "require" => "true", "validator" => "Number", "message" => $lang['member_address_wrong_area']), array("input" => $_POST["area_info"], "require" => "true", "message" => $lang['member_address_area_null']), array("input" => $_POST["address"], "require" => "true", "message" => $lang['member_address_address_null']), array("input" => $_POST['tel_phone'] . $_POST['mob_phone'], 'require' => 'true', 'message' => $lang['member_address_phone_and_mobile']));
         $error = $obj_validate->validate();
         if ($error != '') {
             showValidateError($error);
         }
         $data = array();
         $data['member_id'] = $_SESSION['member_id'];
         $data['true_name'] = $_POST['true_name'];
         $data['area_id'] = intval($_POST['area_id']);
         $data['city_id'] = intval($_POST['city_id']);
         $data['area_info'] = $_POST['area_info'];
         $data['address'] = $_POST['address'];
         $data['tel_phone'] = $_POST['tel_phone'];
         $data['mob_phone'] = $_POST['mob_phone'];
         if (intval($_POST['id']) > 0) {
             $rs = $address_class->editAddress($data, array('address_id' => $_POST['id']));
             if (!$rs) {
                 showDialog($lang['member_address_modify_fail'], '', 'error');
             }
         } else {
             $rs = $address_class->addAddress($data);
             if (!$rs) {
                 showDialog($lang['member_address_add_fail'], '', 'error');
             }
         }
         showDialog($lang['nc_common_op_succ'], 'reload', 'succ', 'CUR_DIALOG.close()');
     }
     $del_id = isset($_GET['id']) ? intval(trim($_GET['id'])) : 0;
     if ($del_id > 0) {
         $rs = $address_class->delAddress(array('address_id' => $del_id, 'member_id' => $_SESSION['member_id']));
         if ($rs) {
             showDialog(Language::get('member_address_del_succ'), 'index.php?act=member&op=address', 'succ');
         } else {
             showDialog(Language::get('member_address_del_fail'), '', 'error');
         }
     }
     $address_list = $address_class->getAddressList(array('member_id' => $_SESSION['member_id']));
     /**
      * 页面输出
      */
     self::profile_menu('address', 'address');
     Tpl::output('menu_sign', 'address');
     Tpl::output('address_list', $address_list);
     Tpl::output('menu_sign_url', 'index.php?act=member&op=address');
     Tpl::output('menu_sign1', 'address_list');
     Tpl::setLayout('member_pub_layout');
     Tpl::showpage('address_index');
 }
Beispiel #6
0
 /**
  * 优惠券管理
  *
  * @param 
  * @return 
  */
 public function store_couponOp()
 {
     $model_coupon = Model('coupon');
     /**
      * 判断操作页面
      */
     if (!empty($_GET['type'])) {
         /*
          * 取得优惠券分类
          */
         $model_coupon_class = Model('coupon_class');
         $condition = array();
         $condition['class_show'] = '1';
         $condition['order'] = 'class_sort desc,class_id desc';
         $class_list = $model_coupon_class->getCouponClass($condition);
         if (empty($class_list)) {
             Tpl::output('msg', Language::get('store_coupon_null_class'));
             Tpl::showpage('../msg', 'null_layout');
             exit;
         }
         /**
          * 新增/编辑页面
          */
         if (trim($_GET['type'] == 'edit')) {
             $param = array();
             $coupon_array = array();
             $coupon_id = intval($_GET['coupon_id']);
             //检查优惠券是否属于该店铺
             if (!$model_coupon->checkCouponBelongStore($coupon_id, $_SESSION['store_id'])) {
                 showMessage(Language::get('store_coupon_error'), '', '', 'error');
             }
             $param['coupon_id'] = $coupon_id;
             $coupon_array = $model_coupon->getCoupon($param);
             $coupon_array = $coupon_array[0];
             $old_pic = $coupon_array['coupon_pic'];
             if ($coupon_array['coupon_lock'] == '2') {
                 Tpl::output('turnoff', yes);
             }
             $coupon_array['coupon_pic'] = $coupon_array['coupon_pic'] != '' ? $coupon_array['coupon_pic'] : SiteUrl . DS . ATTACH_COUPON . DS . 'default.gif';
             $coupon_array['coupon_desc'] = htmlspecialchars_decode($coupon_array['coupon_desc']);
             $coupon_array['coupon_start_date'] = date('Y-m-d', $coupon_array['coupon_start_date']);
             $coupon_array['coupon_end_date'] = date('Y-m-d', $coupon_array['coupon_end_date']);
             Tpl::output('coupon', $coupon_array);
             Tpl::output('old_pic', $old_pic);
         }
         Tpl::output('coupon_class', $class_list);
         Tpl::output('type', $_GET['type']);
         Tpl::showpage('member_coupon.form', 'null_layout');
         die;
     }
     /**
      * 验证提交
      */
     if (chksubmit()) {
         if ($_POST['type'] != '') {
             $validate = new Validate();
             $validate->validateparam = array(array('input' => trim($_POST['coupon_name']), 'require' => true, 'message' => Language::get('store_coupon_name_null')), array('input' => trim($_POST['coupon_value']), 'require' => true, 'validator' => 'Currency', 'message' => Language::get('store_coupon_price_error')), array('input' => $_POST['start_time'], 'require' => true, 'message' => Language::get('store_coupon_start_time_null')), array('input' => $_POST['end_time'], 'require' => true, 'message' => Language::get('store_coupon_end_time_null')));
             $error = $validate->validate();
             if ($error) {
                 showValidateError($error);
             }
             switch ($_POST['type']) {
                 case 'edit':
                     $flag = false;
                     $filename = '';
                     $update = array();
                     $update['coupon_title'] = trim($_POST['coupon_name']);
                     $update['coupon_price'] = trim($_POST['coupon_value']);
                     $update['coupon_desc'] = htmlspecialchars(trim($_POST['coupon_desc']));
                     $update['coupon_pic'] = trim($_POST['coupon_pic']);
                     $date = explode('-', $_POST['start_time']);
                     $update['coupon_start_date'] = mktime(0, 0, 0, $date[1], $date[2], $date[0]);
                     unset($date);
                     $date = explode('-', $_POST['end_time']);
                     $update['coupon_end_date'] = mktime(0, 0, 0, $date[1], $date[2], $date[0]);
                     unset($date);
                     $update['coupon_allowstate'] = '0';
                     //编辑信息后需要后台审核
                     $update['coupon_class_id'] = $_POST['coupon_class'];
                     $where['coupon_id'] = trim($_POST['coupon_id']);
                     $where['store_id'] = $_SESSION['store_id'];
                     if ($model_coupon->update_coupon($update, $where)) {
                         showDialog(Language::get('store_coupon_update_success'), 'index.php?act=store&op=store_coupon', 'succ', 'CUR_DIALOG.close();');
                     } else {
                         showDialog(Language::get('store_coupon_update_fail'));
                     }
                     break;
                 case 'add':
                     $update = array();
                     $update['coupon_title'] = trim($_POST['coupon_name']);
                     $update['coupon_price'] = trim($_POST['coupon_value']);
                     $update['coupon_desc'] = htmlspecialchars(trim($_POST['coupon_desc']));
                     $update['coupon_pic'] = trim($_POST['coupon_pic']);
                     $date = explode('-', $_POST['start_time']);
                     $update['coupon_start_date'] = mktime(0, 0, 0, $date[1], $date[2], $date[0]);
                     unset($date);
                     $date = explode('-', $_POST['end_time']);
                     $update['coupon_end_date'] = mktime(0, 0, 0, $date[1], $date[2], $date[0]);
                     unset($date);
                     $update['coupon_allowstate'] = '0';
                     //需要后台审核 0为待审核 1通过 2未通过
                     $update['coupon_state'] = '2';
                     //默认是上架状态,1是下架
                     $update['store_id'] = $_SESSION['store_id'];
                     $update['coupon_class_id'] = $_POST['coupon_class'];
                     $update['coupon_add_date'] = time();
                     if ($model_coupon->add_coupon($update)) {
                         showDialog(Language::get('store_coupon_add_success'), 'index.php?act=store&op=store_coupon', 'succ', 'CUR_DIALOG.close();');
                     } else {
                         showDialog(Language::get('store_coupon_add_fail'));
                     }
                     break;
             }
         }
     }
     if (trim($_GET['coupon_id'] != '')) {
         $update = array();
         $id_array = explode(',', trim($_GET['coupon_id']));
         $coupon_id = "'" . implode("','", $id_array) . "'";
         $update['coupon_id_in'] = trim($coupon_id);
         $update['store_id'] = $_SESSION['store_id'];
         $update['coupon_allowstate2'] = '1';
         //只有待审核和未通过的可删除
         if ($model_coupon->del_coupon($update)) {
             showDialog(Language::get('store_coupon_del_success'), 'index.php?act=store&op=store_coupon', 'succ');
             exit;
         } else {
             showDialog(Language::get('store_coupon_del_fail'), 'index.php?act=store&op=store_coupon');
             exit;
         }
     }
     $page = new Page();
     $page->setEachNum(8);
     $page->setStyle('admin');
     $condition = array();
     $condition = array();
     if (trim($_GET['key']) != '' && trim($_GET['key']) != Language::get('store_coupon_name')) {
         $condition['coupon_name_like'] = trim($_GET['key']);
     }
     if ($_GET['add_time_from'] != '') {
         $time = explode('-', $_GET['add_time_from']);
         $condition['time_from'] = mktime(0, 0, 0, $time[1], $time[2], $time[0]);
     }
     if ($_GET['add_time_to'] != '') {
         $time = explode('-', $_GET['add_time_to']);
         $condition['time_to'] = mktime(0, 0, 0, $time[1], $time[2], $time[0]);
     }
     if ($_GET['add_time_to'] != '' && $_GET['add_time_from'] != '' && $condition['time_from'] > $condition['time_to']) {
         $_GET['add_time_from'] = $_GET['add_time_to'] = '';
         showMessage(Language::get('store_coupon_time_error'), '', 'html', 'error');
     }
     /*
      * 读取店铺优惠券信息
      */
     $condition['store_id'] = $_SESSION['store_id'];
     $coupon_list = $model_coupon->getCoupon($condition, $page);
     if (is_array($coupon_list) && !empty($coupon_list)) {
         $state = array('1' => Language::get('nc_no'), '2' => Language::get('nc_yes'));
         $allowstate = array('0' => Language::get('store_coupon_allow_state'), '1' => Language::get('store_coupon_allow_yes'), '2' => Language::get('store_coupon_allow_no'));
         foreach ($coupon_list as $k => $v) {
             $coupon_list[$k]['pic'] = $v['coupon_pic'] ? $v['coupon_pic'] : SiteUrl . DS . ATTACH_COUPON . DS . 'defatul.gif';
             $coupon_list[$k]['state'] = $state[$v['coupon_state']];
             $coupon_list[$k]['allowstate'] = $allowstate[$v['coupon_allowstate']];
         }
     }
     $model_coupon->update_coupon(array('coupon_state' => '1'), array('coupon_state' => '2', 'coupon_novalid' => true, 'store_id' => $_SESSION['store_id']));
     /**
      * 页面输出
      */
     self::profile_menu('store_coupon', 'store_coupon');
     Tpl::output('count', count($coupon_list));
     Tpl::output('coupons', $coupon_list);
     Tpl::output('show_page', $page->show());
     Tpl::output('menu_sign', 'store_coupon');
     Tpl::output('menu_sign_url', 'index.php?act=store&op=store_coupon');
     Tpl::output('menu_sign1', 'coupon_list');
     Tpl::showpage('member_coupon.index');
 }
Beispiel #7
0
 /**
  * 品牌修改
  */
 public function brand_editOp()
 {
     $lang = Language::getLangContent();
     $model_brand = Model('brand');
     if ($_POST['form_submit'] == 'ok' and intval($_POST['brand_id']) != 0) {
         /**
          * 验证
          */
         $obj_validate = new Validate();
         $obj_validate->validateparam = array(array("input" => $_POST["brand_name"], "require" => "true", "message" => $lang['store_goods_brand_name_null']), array("input" => $_POST["brand_initial"], "require" => "true", "message" => '请填写首字母'));
         $error = $obj_validate->validate();
         if ($error != '') {
             showValidateError($error);
         } else {
             /**
              * 上传图片
              */
             if (!empty($_FILES['brand_pic']['name'])) {
                 $upload = new UploadFile();
                 $upload->set('default_dir', ATTACH_BRAND);
                 $upload->set('thumb_width', '150,450');
                 $upload->set('thumb_height', '50,50000');
                 $upload->set('thumb_ext', '_small,_big');
                 $upload->set('ifremove', FALSE);
                 $result = $upload->upfile('brand_pic');
                 if ($result) {
                     $_POST['brand_pic'] = $upload->thumb_image;
                 } else {
                     showDialog($upload->error);
                 }
             }
             $where = array();
             $where['brand_id'] = intval($_POST['brand_id']);
             $update_array = array();
             $update_array['brand_initial'] = strtoupper($_POST['brand_initial']);
             $update_array['brand_name'] = trim($_POST['brand_name']);
             $update_array['class_id'] = $_POST['class_id'];
             $update_array['brand_class'] = $_POST['brand_class'];
             if (!empty($_POST['brand_pic'])) {
                 $update_array['brand_pic'] = $_POST['brand_pic'];
             }
             //查出原图片路径,后面会删除图片
             $brand_info = $model_brand->getBrandInfo($where);
             $result = $model_brand->editBrand($where, $update_array);
             if ($result) {
                 //删除老图片
                 if (!empty($brand_info['brand_pic']) && $_POST['brand_pic']) {
                     @unlink(BASE_UPLOAD_PATH . DS . ATTACH_BRAND . DS . $brand_info['brand_pic']);
                 }
                 showDialog($lang['nc_common_save_succ'], 'index.php?act=store_brand&op=brand_list', 'succ', empty($_GET['inajax']) ? '' : 'CUR_DIALOG.close();');
             } else {
                 showDialog($lang['nc_common_save_fail']);
             }
         }
     } else {
         showDialog($lang['nc_common_save_fail']);
     }
 }
Beispiel #8
0
 /**
  * 品牌修改
  */
 public function brand_editOp()
 {
     $lang = Language::getLangContent();
     $model_brand = Model('brand');
     if ($_POST['form_submit'] == 'ok' and intval($_POST['brand_id']) != 0) {
         /**
          * 验证
          */
         $obj_validate = new Validate();
         $obj_validate->validateparam = array(array("input" => $_POST["brand_name"], "require" => "true", "message" => $lang['store_goods_brand_name_null']));
         $error = $obj_validate->validate();
         if ($error != '') {
             showValidateError($error);
         } else {
             /**
              * 上传图片
              */
             if (!empty($_FILES['brand_pic']['name'])) {
                 $upload = new UploadFile();
                 $upload->set('default_dir', ATTACH_BRAND);
                 $upload->set('thumb_width', 150);
                 $upload->set('thumb_height', 50);
                 $upload->set('thumb_ext', '_small');
                 $upload->set('ifremove', true);
                 $result = $upload->upfile('brand_pic');
                 if ($result) {
                     $_POST['brand_pic'] = $upload->thumb_image;
                 } else {
                     showDialog($upload->error);
                 }
             }
             $update_array = array();
             $update_array['brand_id'] = $_POST['brand_id'];
             $update_array['brand_name'] = $_POST['brand_name'];
             $update_array['brand_class'] = $_POST['brand_class'];
             if (!empty($_POST['brand_pic'])) {
                 $update_array['brand_pic'] = $_POST['brand_pic'];
             }
             $result = $model_brand->update($update_array);
             if ($result) {
                 /**
                  * 删除老图片
                  */
                 if (!empty($_POST['brand_pic'])) {
                     @unlink(BasePath . DS . ATTACH_BRAND . DS . $_POST['old_brand_pic']);
                 }
                 showDialog($lang['nc_common_save_succ'], 'index.php?act=store_goods&op=brand_list', 'succ', empty($_GET['inajax']) ? '' : 'CUR_DIALOG.close();');
             } else {
                 showDialog($lang['nc_common_save_fail']);
             }
         }
     } else {
         showDialog($lang['nc_common_save_fail']);
     }
 }
Beispiel #9
0
 public function complain_saveOp()
 {
     //获取输入的投诉信息
     $input = array();
     $input['order_id'] = intval($_POST['input_order_id']);
     //检查是不是正在进行投诉
     if ($this->check_complain_exist($input['order_id'])) {
         showDialog(Language::get('complain_repeat'), '', 'error');
     }
     list($input['complain_subject_id'], $input['complain_subject_content']) = explode(',', trim($_POST['input_complain_subject']));
     $input['complain_content'] = trim($_POST['input_complain_content']);
     //验证输入的信息
     $obj_validate = new Validate();
     $obj_validate->validateparam = array(array("input" => $input['complain_content'], "require" => "true", "validator" => "Length", "min" => "1", "max" => "255", "message" => Language::get('complain_content_error')));
     $error = $obj_validate->validate();
     if ($error != '') {
         showValidateError($error);
     }
     //获取有问题的商品
     $checked_goods = $_POST['input_goods_check'];
     $goods_problem = $_POST['input_goods_problem'];
     if (empty($checked_goods)) {
         showDialog(Language::get('para_error'), '', 'error');
     }
     $order_info = $this->get_order_info($input['order_id']);
     $input['accuser_id'] = $order_info['buyer_id'];
     $input['accuser_name'] = $order_info['buyer_name'];
     $input['accused_id'] = $order_info['store_id'];
     $input['accused_name'] = $order_info['store_name'];
     //上传图片
     $complain_pic = array();
     $complain_pic[1] = 'input_complain_pic1';
     $complain_pic[2] = 'input_complain_pic2';
     $complain_pic[3] = 'input_complain_pic3';
     $pic_name = $this->upload_pic($complain_pic);
     $input['complain_pic1'] = $pic_name[1];
     $input['complain_pic2'] = $pic_name[2];
     $input['complain_pic3'] = $pic_name[3];
     $input['complain_datetime'] = time();
     $input['complain_state'] = self::STATE_NEW;
     $input['complain_active'] = self::STATE_UNACTIVE;
     //保存投诉信息
     $model_complain = Model('complain');
     $complain_id = $model_complain->saveComplain($input);
     //保存被投诉的商品详细信息
     $model_complain_goods = Model('complain_goods');
     $order_goods_list = $order_info['extend_order_goods'];
     foreach ($order_goods_list as $goods) {
         $order_goods_id = $goods['rec_id'];
         if (array_key_exists($order_goods_id, $checked_goods)) {
             //验证提交的商品属于订单
             $input_checked_goods['complain_id'] = $complain_id;
             $input_checked_goods['order_goods_id'] = $order_goods_id;
             $input_checked_goods['order_goods_type'] = $goods['goods_type'];
             $input_checked_goods['goods_id'] = $goods['goods_id'];
             $input_checked_goods['goods_name'] = $goods['goods_name'];
             $input_checked_goods['goods_price'] = $goods['goods_price'];
             $input_checked_goods['goods_num'] = $goods['goods_num'];
             $input_checked_goods['goods_image'] = $goods['goods_image'];
             $input_checked_goods['complain_message'] = $goods_problem[$order_goods_id];
             $model_complain_goods->saveComplainGoods($input_checked_goods);
         }
     }
     showDialog(Language::get('complain_submit_success'), 'index.php?act=member_complain', 'succ');
 }
Beispiel #10
0
 public function pop_addressOp()
 {
     if (chksubmit()) {
         $obj_validate = new Validate();
         $obj_validate->validateparam = array(array("input" => $_POST["seller_name"], "require" => "true", "message" => $lang['store_daddress_receiver_null']), array("input" => $_POST["area_id"], "require" => "true", "validator" => "Number", "message" => $lang['store_daddress_wrong_area']), array("input" => $_POST["city_id"], "require" => "true", "validator" => "Number", "message" => $lang['store_daddress_wrong_area']), array("input" => $_POST["area_info"], "require" => "true", "message" => $lang['store_daddress_area_null']), array("input" => $_POST["address"], "require" => "true", "message" => $lang['store_daddress_address_null']), array("input" => $_POST['tel_phone'] . $_POST['mob_phone'], 'require' => 'true', 'message' => $lang['store_daddress_phone_and_mobile']));
         $error = $obj_validate->validate();
         if ($error != '') {
             showValidateError($error);
         }
         $data = array('store_id' => $_SESSION['store_id'], 'seller_name' => $_POST['seller_name'], 'area_id' => $_POST['area_id'], 'city_id' => $_POST['city_id'], 'area_info' => $_POST['area_info'], 'address' => $_POST['address'], 'zip_code' => $_POST['zip_code'], 'tel_phone' => $_POST['tel_phone'], 'mob_phone' => $_POST['mob_phone'], 'company' => $_POST['company'], 'content' => $_POST['content']);
         $model = Model('daddress');
         $insert = $model->insert($data);
         if (!$insert) {
             showDialog(Language::get('nc_common_op_fail'), '', 'error');
         }
         $extend_js = array($_POST['area_info'] . $_POST['address'], $_POST['zip_code'], $_POST['seller_name'], $_POST['tel_phone'], $_POST['mob_phone']);
         $extend_js = implode(' ', $extend_js);
         $extend_js .= "<a href=\"javascript:void(0);\" onclick=\"ajax_form(\\'modfiy_daddress\\', \\'" . Language::get('store_deliver_select_daddress') . "\\', \\'index.php?act=deliver&op=pop_address&type=select\\', 550,0);\" class=\"fr\">" . Language::get('store_deliver_select_ather_daddress') . "</a>";
         $extend_js = "\$('#daddress').html('" . $extend_js . "');";
         showDialog(Language::get('nc_common_op_succ'), '', 'succ', 'CUR_DIALOG.close();$("#dadress_id").val(' . $insert . ');' . $extend_js);
     }
     if ($_GET['type'] == 'select') {
         $model = Model('daddress');
         $daddress_list = $model->where(array('store_id' => $_SESSION['store_id']))->limit(10)->select();
         Tpl::output('daddress_list', $daddress_list);
         Tpl::showpage('store_deliver_daddress_select', 'null_layout');
     } else {
         Tpl::showpage('store_deliver_daddress_add', 'null_layout');
     }
 }
Beispiel #11
0
 /**
  * 会员添加操作
  *
  * @param
  * @return
  */
 public function usersaveOp()
 {
     //重复注册验证
     if (check_repeat('reg', 40)) {
         showDialog(Language::get('nc_common_op_repeat'), 'index.php');
     }
     /**
      * 读取语言包
      */
     Language::read("home_login_register");
     $lang = Language::getLangContent();
     /**
      * 实例化模型
      */
     $model_member = Model('member');
     /**
      * 检查登录状态
      */
     $model_member->checkloginMember();
     /**
      * 注册验证
      */
     $obj_validate = new Validate();
     $obj_validate->validateparam = array(array("input" => $_POST["user_name"], "require" => "true", "message" => $lang['login_usersave_username_isnull']), array("input" => $_POST["password"], "require" => "true", "message" => $lang['login_usersave_password_isnull']), array("input" => $_POST["password_confirm"], "require" => "true", "validator" => "Compare", "operator" => "==", "to" => $_POST["password"], "message" => $lang['login_usersave_password_not_the_same']), array("input" => $_POST["email"], "require" => "true", "validator" => "email", "message" => $lang['login_usersave_wrong_format_email']), array("input" => strtoupper($_POST["captcha"]), "require" => C('captcha_status_register') == '1' ? "true" : "false", "message" => $lang['login_usersave_code_isnull']), array("input" => $_POST["agree"], "require" => "true", "message" => $lang['login_usersave_you_must_agree']));
     $error = $obj_validate->validate();
     if ($error != '') {
         showValidateError($error);
     }
     if (C('captcha_status_login')) {
         if (!checkSeccode($_POST['nchash'], $_POST['captcha'])) {
             showDialog($lang['login_usersave_wrong_code']);
         }
     }
     $check_member_name = $model_member->infoMember(array('member_name' => trim($_POST['user_name'])));
     if (is_array($check_member_name) and count($check_member_name) > 0) {
         showDialog($lang['login_usersave_your_username_exists']);
     }
     $check_member_email = $model_member->infoMember(array('member_email' => trim($_POST['email'])));
     if (is_array($check_member_email) and count($check_member_email) > 0) {
         showDialog($lang['login_usersave_your_email_exists']);
     }
     $user_array = array();
     if (C('ucenter_status')) {
         /**
          * Ucenter处理
          */
         $model_ucenter = Model('ucenter');
         $uid = $model_ucenter->addUser(trim($_POST['user_name']), trim($_POST['password']), trim($_POST['email']));
         if ($uid < 1) {
             showMessage($lang['login_usersave_regist_fail'], '', 'html', 'error');
         }
         $user_array['member_id'] = $uid;
     }
     /**
     * 注册会员发送短信<?php echo $_POST["name"]; ?>----------------------------------------------------------------------------
     */
     $phone_zc = $_POST['mobile'];
     //注册填写的手机号
     $user = $GLOBALS['setting_config']['dxuser'];
     //短信接口账号
     $passwd = $GLOBALS['setting_config']['dxmima'];
     //短信接口密码
     $message_mj = $GLOBALS['setting_config']['hyzctz'];
     //会员注册时的短信内容
     $gateway_1 = $GLOBALS['setting_config']['hyzctzjk'];
     //HTTP_POST接口代码
     $gateway_1 = iconv("UTF-8", "GB2312//IGNORE", $gateway_1);
     $rccc_1 = @file_get_contents($gateway_1);
     //短信发送结束------------------------------------------------------------------------------------------------------------
     /**
      * 会员添加<?php echo $_POST["name"]; ?>
      */
     $user_array['member_name'] = $_POST['user_name'];
     $user_array['member_passwd'] = $_POST['password'];
     $user_array['member_email'] = $_POST['email'];
     $user_array['member_mobile'] = $_POST['mobile'];
     $result = $model_member->addMember($user_array);
     if ($result) {
         //注册时间标记,访问灌入垃圾用户
         setNcCookie('rp_reg', time());
         $_SESSION['is_login'] = '******';
         $_SESSION['member_id'] = $result;
         $_SESSION['member_name'] = trim($user_array['member_name']);
         $_SESSION['member_email'] = trim($user_array['member_email']);
         $_SESSION['member_mobile'] = trim($user_array['member_mobile']);
         $this->mergecart();
         // cookie中的cart存入数据库
         //添加会员积分
         if ($GLOBALS['setting_config']['points_isuse'] == 1) {
             $points_model = Model('points');
             $points_model->savePointsLog('regist', array('pl_memberid' => $_SESSION['member_id'], 'pl_membername' => $_SESSION['member_name']), false);
         }
         $_POST['ref_url'] = strstr($_POST['ref_url'], 'logout') === false && !empty($_POST['ref_url']) ? $_POST['ref_url'] : 'index.php?act=home&op=member';
         showDialog(str_replace('site_name', C('site_name'), $lang['login_usersave_regist_success_ajax']), $_POST['ref_url'], 'succ', '', 3);
     } else {
         showDialog(Language::get('login_usersave_regist_fail'));
     }
 }
Beispiel #12
0
 /**
  * 登录操作
  *
  */
 public function indexOp()
 {
     Language::read("home_login_index");
     $lang = Language::getLangContent();
     $model_member = Model('member');
     //检查登录状态
     $model_member->checkloginMember();
     $result = chksubmit(true, C('captcha_status_login'), 'num');
     if ($result !== false) {
         if ($result === -11) {
             showDialog($lang['login_index_login_illegal']);
         } elseif ($result === -12) {
             showDialog($lang['login_index_wrong_checkcode']);
         }
         if (processClass::islock('login')) {
             showDialog($lang['nc_common_op_repeat'], SHOP_SITE_URL);
         }
         $obj_validate = new Validate();
         $obj_validate->validateparam = array(array("input" => $_POST["user_name"], "require" => "true", "message" => $lang['login_index_username_isnull']), array("input" => $_POST["password"], "require" => "true", "message" => $lang['login_index_password_isnull']));
         $error = $obj_validate->validate();
         if ($error != '') {
             showValidateError($error);
             exit;
         }
         $array = array();
         $array['member_name'] = $_POST['user_name'];
         $array['member_passwd'] = md5($_POST['password']);
         $member_info = $model_member->infoMember($array);
         if (is_array($member_info) and !empty($member_info)) {
             if (!$member_info['member_state']) {
                 showDialog($lang['login_index_account_stop']);
             }
         } else {
             processClass::addprocess('login');
             showDialog($lang['login_index_login_fail']);
         }
         $model_member->createSession($member_info);
         processClass::clear('login');
         // cookie中的cart存入数据库
         $this->mergecart($member_info);
         //添加会员积分
         if (C('points_isuse')) {
             //一天内只有第一次登录赠送积分
             if (trim(@date('Y-m-d', $member_info['member_login_time'])) != trim(date('Y-m-d'))) {
                 $points_model = Model('points');
                 $points_model->savePointsLog('login', array('pl_memberid' => $member_info['member_id'], 'pl_membername' => $member_info['member_name']), true);
             }
         }
         showDialog($lang['login_index_login_success'], $_POST['ref_url'], 'succ', $extrajs);
     } else {
         //登录表单页面
         $_pic = @unserialize(C('login_pic'));
         if ($_pic[0] != '') {
             Tpl::output('lpic', UPLOAD_SITE_URL . '/' . ATTACH_LOGIN . '/' . $_pic[array_rand($_pic)]);
         } else {
             Tpl::output('lpic', UPLOAD_SITE_URL . '/' . ATTACH_LOGIN . '/' . rand(1, 4) . '.jpg');
         }
         if (empty($_GET['ref_url'])) {
             $ref_url = getReferer();
             if (!preg_match('/act=login&op=logout/', $ref_url)) {
                 $_GET['ref_url'] = $ref_url;
             }
         }
         Tpl::output('html_title', C('site_name') . ' - ' . $lang['login_index_login']);
         if ($_GET['inajax'] == 1) {
             Tpl::showpage('login_inajax', 'null_layout');
         } else {
             Tpl::showpage('login');
         }
     }
 }
Beispiel #13
0
 /**
  * 登录操作
  *
  */
 public function indexOp()
 {
     Language::read("home_login_index");
     $lang = Language::getLangContent();
     $model_member = Model('member');
     //检查登录状态
     $model_member->checkloginMember();
     if ($_GET['inajax'] == 1 && C('captcha_status_login') == '1') {
         $script = "document.getElementById('codeimage').src='" . APP_SITE_URL . "/index.php?act=seccode&op=makecode&nchash=" . getNchash() . "&t=' + Math.random();";
     }
     $result = chksubmit(true, C('captcha_status_login'), 'num');
     if ($result !== false) {
         if ($result === -11) {
             showDialog($lang['login_index_login_illegal']);
         } elseif ($result === -12) {
             showDialog($lang['login_index_wrong_checkcode']);
         }
         if (processClass::islock('login')) {
             showDialog($lang['nc_common_op_repeat'], SHOP_SITE_URL);
         }
         $obj_validate = new Validate();
         $obj_validate->validateparam = array(array("input" => $_POST["user_name"], "require" => "true", "message" => $lang['login_index_username_isnull']), array("input" => $_POST["password"], "require" => "true", "message" => $lang['login_index_password_isnull']));
         $error = $obj_validate->validate();
         if ($error != '') {
             showValidateError($error);
             exit;
         }
         if (C('ucenter_status')) {
             $model_ucenter = Model('ucenter');
             $member_id = $model_ucenter->userLogin(trim($_POST['user_name']), trim($_POST['password']));
             if (intval($member_id) == 0) {
                 showDialog($lang['login_index_login_again']);
             }
         }
         $array = array();
         $array['member_name'] = $_POST['user_name'];
         $array['member_passwd'] = md5($_POST['password']);
         $member_info = $model_member->infoMember($array);
         if (is_array($member_info) and !empty($member_info)) {
             if (!$member_info['member_state']) {
                 showDialog($lang['login_index_account_stop']);
             }
         } else {
             processClass::addprocess('login');
             showDialog($lang['login_index_login_fail']);
         }
         $model_member->createSession($member_info);
         processClass::clear('login');
         //            echo "member_identity:".$member_info['member_identity'];
         //            echo "inajax:".$_GET['inajax'];
         //            echo "ref_url:".$_POST['ref_url'];
         if ($member_info['member_identity'] != null && $member_info['member_verifycode'] != null) {
             //从积分系统获取预备金信息
             $this->getPredeposit($member_info);
         }
         // cookie中的cart存入数据库
         $this->mergecart($member_info);
         //添加会员积分
         if (C('points_isuse')) {
             //一天内只有第一次登录赠送积分
             if (trim(@date('Y-m-d', $member_info['member_login_time'])) != trim(date('Y-m-d'))) {
                 $points_model = Model('points');
                 $points_model->savePointsLog('login', array('pl_memberid' => $member_info['member_id'], 'pl_membername' => $member_info['member_name']), true);
             }
         }
         if (C('ucenter_status')) {
             $extrajs = $model_ucenter->outputLogin($member_info['member_id'], trim($_POST['password']));
         } elseif (empty($_GET['inajax'])) {
             if (empty($_POST['ref_url'])) {
                 @header('location: index.php');
                 exit;
             } else {
                 @header('location: ' . $_POST['ref_url']);
                 exit;
             }
         }
         showDialog($lang['login_index_login_success'], $_POST['ref_url'], 'succ', $extrajs);
     } else {
         //登录表单页面
         $_pic = @unserialize(C('login_pic'));
         if ($_pic[0] != '') {
             Tpl::output('lpic', UPLOAD_SITE_URL . '/' . ATTACH_LOGIN . '/' . $_pic[array_rand($_pic)]);
         } else {
             Tpl::output('lpic', UPLOAD_SITE_URL . '/' . ATTACH_LOGIN . '/' . rand(1, 4) . '.jpg');
         }
         if (empty($_GET['ref_url'])) {
             $ref_url = getReferer();
             if (!preg_match('/act=login&op=logout/', $ref_url)) {
                 $_GET['ref_url'] = $ref_url;
             }
         }
         Tpl::output('html_title', C('site_name') . ' - ' . $lang['login_index_login']);
         if ($_GET['inajax'] == 1) {
             Tpl::showpage('login_inajax', 'null_layout');
         } else {
             Tpl::showpage('login');
         }
     }
 }
Beispiel #14
0
 public function appeal_saveOp()
 {
     $complain_id = intval($_POST['input_complain_id']);
     //获取投诉详细信息
     $complain_info = $this->get_complain_info($complain_id);
     //检查当前用户是不是被投诉人
     if ($complain_info['member_status'] !== 'accused') {
         showDialog(Language::get('para_error'), 'reload');
     }
     //检查当前是不是投诉状态
     if (intval($complain_info['complain_state']) !== self::STATE_APPEAL) {
         showDialog(Language::get('para_error'), 'reload');
     }
     $input = array();
     $input['appeal_message'] = trim($_POST['input_appeal_message']);
     //验证输入的信息
     $obj_validate = new Validate();
     $obj_validate->validateparam = array(array("input" => $input['appeal_message'], "require" => "true", "validator" => "Length", "min" => "1", "max" => "255", "message" => Language::get('appeal_message_error')));
     $error = $obj_validate->validate();
     if ($error != '') {
         showValidateError($error);
     }
     //上传图片
     $appeal_pic = array();
     $appeal_pic[1] = 'input_appeal_pic1';
     $appeal_pic[2] = 'input_appeal_pic2';
     $appeal_pic[3] = 'input_appeal_pic3';
     $pic_name = $this->upload_pic($appeal_pic);
     $input['appeal_pic1'] = $pic_name[1];
     $input['appeal_pic2'] = $pic_name[2];
     $input['appeal_pic3'] = $pic_name[3];
     $input['appeal_datetime'] = time();
     $input['complain_state'] = self::STATE_TALK;
     $where_array = array();
     $where_array['complain_id'] = $complain_id;
     //保存投诉信息
     $model_complain = Model('complain');
     $complain_id = $model_complain->updateComplain($input, $where_array);
     //发送消息
     $this->send_message('appeal', $complain_info);
     showDialog(Language::get('appeal_submit_success'), 'index.php?act=store_complain', 'succ');
 }
Beispiel #15
0
 /**
  * 绑定手机
  */
 public function modify_mobileOp()
 {
     $model_member = Model('member');
     $member_info = $model_member->getMemberInfoByID($_SESSION['member_id'], 'member_mobile_bind');
     if (chksubmit()) {
         $obj_validate = new Validate();
         $obj_validate->validateparam = array(array("input" => $_POST["mobile"], "require" => "true", 'validator' => 'mobile', "message" => '请正确填写手机号'), array("input" => $_POST["vcode"], "require" => "true", 'validator' => 'number', "message" => '请正确填写手机验证码'));
         $error = $obj_validate->validate();
         if ($error != '') {
             showValidateError($error);
         }
         $condition = array();
         $condition['member_id'] = $_SESSION['member_id'];
         $condition['auth_code'] = intval($_POST['vcode']);
         $member_common_info = $model_member->getMemberCommonInfo($condition, 'send_acode_time');
         if (!$member_common_info) {
             showDialog('手机验证码错误,请重新输入');
         }
         if (TIMESTAMP - $member_common_info['send_acode_time'] > 1800) {
             showDialog('手机验证码已过期,请重新获取验证码');
         }
         $data = array();
         $data['auth_code'] = '';
         $data['send_acode_time'] = 0;
         $update = $model_member->editMemberCommon($data, array('member_id' => $_SESSION['member_id']));
         if (!$update) {
             showDialog('系统发生错误,如有疑问请与管理员联系');
         }
         $update = $model_member->editMember(array('member_id' => $_SESSION['member_id']), array('member_mobile_bind' => 1));
         if (!$update) {
             showDialog('系统发生错误,如有疑问请与管理员联系');
         }
         showDialog('手机号绑定成功', 'index.php?act=member_security&op=index', 'succ');
     }
 }
Beispiel #16
0
 /**
  * 保存广告购买信息
  */
 public function adv_buy_saveOp()
 {
     /**
      * 验证
      */
     $obj_validate = new Validate();
     $obj_validate->validateparam = array(array("input" => $_POST["adv_title"], "require" => "true", "message" => Language::get('advtitle_can_not_null')), array("input" => $_POST["adv_start_date"], "require" => "true", "message" => Language::get('adv_start_date_cannot_null')), array("input" => $_POST["buy_month"], "require" => "true", 'validator' => 'Number', "message" => Language::get('buymonth_must_num')));
     $error = $obj_validate->validate();
     if ($error != '') {
         showValidateError($error);
     } else {
         /**
          * 将广告信息入库
          */
         $adv = Model('adv');
         $upload = new UploadFile();
         $goldpay = intval($_POST['ap_price'] * $_POST['buy_month']);
         //查询会员现有金币数
         $member_model = Model('member');
         $member_array = $member_model->infoMember(array('member_id' => $_SESSION['member_id']));
         if ($member_array['member_goldnum'] < $goldpay) {
             showDialog(Language::get('sorry_you_have_no_gold'), 'index.php?act=store_adv&op=adv_manage');
         }
         if (intval($_POST['buy_month']) == '0') {
             showDialog(Language::get('buymonth_must_num_can_not_0'), 'index.php?act=store_adv&op=adv_manage');
         }
         //判断页面编码确定汉字所占字节数
         switch (CHARSET) {
             case 'UTF-8':
                 $charrate = 3;
                 break;
             case 'GBK':
                 $charrate = 2;
                 break;
         }
         $param['ap_id'] = $_POST['ap_id'];
         $param['adv_title'] = $_POST['adv_title'];
         if (intval($_POST['adv_order_flag']) === 1) {
             $adv_last_end_date = $adv->getLastDateById($param['ap_id']);
             $param['adv_start_date'] = $adv_last_end_date;
         } else {
             $param['adv_start_date'] = $this->getunixtime($_POST['adv_start_date']);
         }
         $param['adv_end_date'] = $param['adv_start_date'] + $_POST['buy_month'] * 2592000;
         //基本购买周期为一个月,一个月按30天计算,30天=2592000秒
         $param['member_id'] = $_SESSION['member_id'];
         $param['member_name'] = $member_array['member_name'];
         $param['buy_style'] = $_POST['style'];
         $param['goldpay'] = $goldpay;
         switch ($_POST['advclass']) {
             case '0':
                 if ($_FILES['adv_pic']['name'] == '') {
                     showDialog(Language::get('please_upload_pic'), '');
                 }
                 $upload->set('default_dir', ATTACH_ADV);
                 $result = $upload->upfile('adv_pic');
                 if (!$result) {
                     showDialog($upload->error);
                 }
                 $ac = array('adv_pic' => $upload->file_name, 'adv_pic_url' => $_POST['adv_pic_url']);
                 $ac = serialize($ac);
                 $param['adv_content'] = $ac;
                 break;
             case '1':
                 if (strlen($_POST['adv_word']) > $_POST['word_len_limit'] * $charrate) {
                     $error = Language::get('wordadv_info_too_long');
                     showDialog($error);
                 }
                 $ac = array('adv_word' => $_POST['adv_word'], 'adv_word_url' => $_POST['adv_word_url']);
                 $ac = serialize($ac);
                 $param['adv_content'] = $ac;
                 break;
             case '2':
                 if ($_FILES['adv_slide_pic']['name'] == '') {
                     showDialog(Language::get('please_upload_pic'));
                 }
                 $upload->set('default_dir', ATTACH_ADV);
                 $result = $upload->upfile('adv_slide_pic');
                 if (!$result) {
                     showDialog($upload->error);
                 }
                 $ac = array('adv_slide_pic' => $upload->file_name, 'adv_slide_url' => $_POST['adv_slide_url']);
                 $ac = serialize($ac);
                 $param['adv_content'] = $ac;
                 break;
             case '3':
                 if ($_FILES['flash_swf']['name'] == '') {
                     showDialog(Language::get('please_upload_swf'));
                 }
                 $upload->set('default_dir', ATTACH_ADV);
                 $result = $upload->upfile('flash_swf');
                 if (!$result) {
                     showDialog($upload->error);
                 }
                 $ac = array('flash_swf' => $upload->file_name, 'flash_url' => $_POST['flash_url']);
                 $ac = serialize($ac);
                 $param['adv_content'] = $ac;
                 break;
         }
         $result = $adv->adv_add($param);
         //修改用户金币信息
         $newmember_goldnum = intval($member_array['member_goldnum']) - $goldpay;
         $newmember_goldnumminus = intval($member_array['member_goldnumminus']) + $goldpay;
         $result2 = $member_model->updateMember(array('member_goldnum' => $newmember_goldnum, 'member_goldnumminus' => $newmember_goldnumminus), $_SESSION['member_id']);
         //添加金币日志
         $goldlog_model = Model('gold_log');
         $insert_goldlog = array();
         $insert_goldlog['glog_memberid'] = $_SESSION['member_id'];
         $insert_goldlog['glog_membername'] = $_SESSION['member_name'];
         $insert_goldlog['glog_storeid'] = $_SESSION['store_id'];
         $insert_goldlog['glog_storename'] = $_SESSION['store_name'];
         $insert_goldlog['glog_adminid'] = 0;
         $insert_goldlog['glog_adminname'] = '';
         $insert_goldlog['glog_goldnum'] = $goldpay;
         $insert_goldlog['glog_method'] = 2;
         $insert_goldlog['glog_addtime'] = time();
         $insert_goldlog['glog_desc'] = Language::get('buy_webinner_adv');
         $insert_goldlog['glog_stage'] = 'adv_buy';
         $result3 = $goldlog_model->add($insert_goldlog);
         if ($result && $result2 && $result3) {
             showDialog(Language::get('adv_buy_succ'), 'index.php?act=store_adv&op=adv_manage', 'succ');
         } else {
             showDialog(Language::get('adv_buy_failed'), 'index.php?act=store_adv&op=adv_manage');
         }
     }
 }
Beispiel #17
0
 /**
  * 编辑直通车申请记录
  */
 public function edit_ztcOp()
 {
     $z_id = intval($_GET['z_id']);
     if (!$z_id) {
         showMessage(Language::get('store_ztc_parameter_error'), 'index.php?act=store_ztc&op=ztc_list', 'html', 'error');
     }
     $ztc_model = Model('ztc');
     //查询申请记录是否存在
     $ztc_info = $ztc_model->getZtcInfo(array('ztc_id' => $z_id, 'ztc_memberid' => $_SESSION['member_id']));
     if (!is_array($ztc_info) || count($ztc_info) <= 0) {
         showMessage(Language::get('store_ztc_record_error'), 'index.php?act=store_ztc&op=ztc_list', 'html', 'error');
     }
     //申请信息已经过审核操作,不可编辑
     if ($ztc_info['ztc_state'] != 0) {
         showMessage(Language::get('store_ztc_edit_reviewed_error'), 'index.php?act=store_ztc&op=ztc_list', 'html', 'error');
     } else {
         if ($ztc_info['ztc_paystate'] != 0) {
             showMessage(Language::get('store_ztc_edit_paid_error'), 'index.php?act=store_ztc&op=ztc_list', 'html', 'error');
         }
     }
     //查询会员现有金币数
     $member_model = Model('member');
     $member_array = $member_model->infoMember(array('member_id' => $_SESSION['member_id']));
     if (chksubmit()) {
         /**
          * 信息验证
          */
         $starttime = strtotime($_POST['ztc_stime']);
         $obj_validate = new Validate();
         $validate_arr[] = array("input" => $_POST["goods_id"], "require" => "true", 'validator' => 'Compare', "operator" => ' > ', 'to' => 1, "message" => Language::get('store_ztc_add_search_goodserror'));
         $validate_arr[] = array("input" => $_POST["ztc_goldnum"], "require" => "true", 'validator' => 'Range', 'min' => 1, 'max' => $member_array['member_goldnum'], "message" => Language::get('store_ztc_add_goldnum_error'));
         $validate_arr[] = array("input" => $_POST["ztc_remark"], "validator" => "Length", "max" => 100, "message" => Language::get('store_ztc_add_remarkerror'));
         if (!$ztc_info['ztc_type'] == 1) {
             //申请新纪录,验证开始时间是否正确
             $validate_arr[] = array("input" => $starttime, "validator" => "Compare", "operator" => ' > ', 'to' => time(), "message" => Language::get('store_ztc_add_starttime_error'));
         }
         $obj_validate->validateparam = $validate_arr;
         $error = $obj_validate->validate();
         if ($error != '') {
             showValidateError($error);
         }
         $goods_id = intval($_POST['goods_id']);
         //查询商品信息
         $goods_model = Model('goods');
         $goods_info = $goods_model->checkGoods(array('goods_id' => $goods_id));
         if (!is_array($goods_info) || count($goods_info) <= 0) {
             showDialog($lang['store_ztc_edit_search_goodserror']);
         }
         //判断直通车商品是否已经存在
         $ztc_model = Model('ztc');
         if ($ztc_info['ztc_type'] == 1) {
             //充值类型
             //计算所需要金币数
             $ztc_dayprod = intval($GLOBALS['setting_config']['ztc_dayprod']);
             $datetime = date('Y-m-d', time());
             $datetime = strtotime($datetime);
             $goldall = ($datetime - $goods_info['goods_ztclastdate']) / (3600 * 24) * intval($ztc_dayprod);
             //验证商品是否为直通车商品
             if ($goods_info['goods_isztc'] == 0 || !($goods_info['goods_isztc'] == 1 && $goods_info['goods_goldnum'] >= $goldall)) {
                 showDialog(Language::get('store_ztc_edit_recharge_goods_error'));
             }
         } else {
             //申请新纪录
             //验证商品是否为直通车商品
             if ($goods_info['goods_isztc'] == 1) {
                 showDialog(Language::get('store_ztc_edit_new_goods_error'));
             }
             //判断该商品是否已经申请了直通车并且未通过审核
             $ztc_checkinfo = $ztc_model->getZtcInfo(array('ztc_goodsid' => $goods_id, 'ztc_state' => 0, 'ztc_type' => 0));
             if ($ztc_checkinfo['ztc_id'] != $z_id && is_array($ztc_checkinfo) && count($ztc_checkinfo) > 0) {
                 showDialog(Language::get('store_ztc_edit_new_goodsexist_error'));
             }
         }
         //修改直通车申请
         $ztc_array = array();
         $ztc_array['ztc_goodsid'] = intval($_POST['goods_id']);
         $ztc_array['ztc_goodsname'] = $goods_info['goods_name'];
         $ztc_array['ztc_goodsimage'] = $goods_info['goods_image'];
         $ztc_array['ztc_gold'] = $_POST['ztc_goldnum'];
         $ztc_array['ztc_remark'] = $_POST['ztc_remark'];
         $ztc_array['ztc_startdate'] = strtotime($_POST['ztc_stime']);
         $result = $ztc_model->updateZtcOne($ztc_array, array('ztc_id' => $z_id));
         if ($result) {
             showDialog(Language::get('store_ztc_edit_success'), 'index.php?act=store_ztc&op=ztc_list', 'succ');
         } else {
             showDialog(Language::get('store_ztc_edit_fail'), 'index.php?act=store_ztc&op=ztc_list');
         }
     } else {
         Tpl::output('member_array', $member_array);
         Tpl::output('ztc_info', $ztc_info);
         Tpl::output('nowdate', date('Y-m-d', time()));
         self::profile_menu('edit_ztc');
         Tpl::output('menu_sign', 'store_ztc');
         Tpl::output('menu_sign_url', 'index.php?act=store_ztc&op=edit_ztc');
         Tpl::output('menu_sign1', 'ztc_list');
         Tpl::showpage('store_ztc.editform');
     }
 }
Beispiel #18
0
 /**
  * 团购保存
  **/
 public function groupbuy_saveOp()
 {
     //获取提交的数据
     $group_id = intval($_POST['group_id']);
     //获取模版信息
     $template_id = intval($_POST['input_groupbuy_template']);
     $model_groupbuy_template = Model('groupbuy_template');
     $template_info = $model_groupbuy_template->getOne($template_id);
     if (empty($template_info) || intval($template_info['state']) !== self::TEMPLATE_STATE_ACTIVE) {
         showDialog(Language::get('param_error'));
     }
     $goods_id = intval($_POST['input_goods_id']);
     if (empty($goods_id)) {
         showDialog(Language::get('param_error'));
     }
     //实例化团购模型
     $model_goods_group = Model('goods_group');
     //验证团购商品是否已经在本期发布
     if (empty($group_id)) {
         $param = array();
         $param['goods_id'] = $goods_id;
         $param['template_id'] = $template_id;
         if ($model_goods_group->isExist($param)) {
             showDialog(Language::get('group_goods_is_exist'));
         }
     }
     $param = array();
     $param['group_name'] = trim($_POST['input_group_name']);
     $param['template_id'] = $template_id;
     $param['template_name'] = $template_info['template_name'];
     $param['start_time'] = $template_info['start_time'];
     $param['end_time'] = $template_info['end_time'];
     $param['group_help'] = trim($_POST['input_group_help']);
     $param['groupbuy_price'] = floatval($_POST['input_groupbuy_price']);
     $param['virtual_quantity'] = intval($_POST['input_virtual_quantity']);
     $param['sale_quantity'] = intval($_POST['input_sale_quantity']);
     $param['max_num'] = intval($_POST['input_max_num']);
     $param['group_intro'] = trim($_POST['input_group_intro']);
     $param['class_id'] = intval($_POST['input_class_id']);
     $param['area_id'] = intval($_POST['input_area_id']);
     $group_pic = $this->upload_pic('input_group_pic');
     $goods_info = $this->get_goods_info($goods_id);
     if (empty($goods_info)) {
         showDialog(Language::get('param_error'));
     }
     if ($goods_info['store_id'] != $_SESSION['store_id']) {
         showDialog(Language::get('param_error'));
     }
     //更新商品表团购价格
     $model_goods = Model('goods');
     $model_goods->updateGoods(array('group_price' => $param['groupbuy_price']), $goods_id);
     $param['goods_id'] = $goods_info['goods_id'];
     $param['goods_name'] = $goods_info['goods_name'];
     $param['goods_price'] = $goods_info['goods_store_price'];
     $param['rebate'] = $param['groupbuy_price'] / floatval($goods_info['goods_store_price']) * 10;
     $param['state'] = self::STATE_VERIFY;
     //验证提交的数据
     $obj_validate = new Validate();
     $obj_validate->validateparam = array(array("input" => $param['group_name'], "require" => "true", "message" => Language::get('group_name_error')));
     $error = $obj_validate->validate();
     if ($error != '') {
         showValidateError($error);
     }
     if (empty($group_id)) {
         //新发布
         if (empty($group_pic)) {
             showDialog(Language::get('group_pic_error'));
         }
         $param['group_pic'] = $group_pic;
         $param['recommended'] = 0;
         $param['store_id'] = $_SESSION['store_id'];
         $param['store_name'] = $_SESSION['store_name'];
         //保存
         $result = $model_goods_group->save($param);
         if ($result) {
             // 自动发布动态
             // group_id,group_name,goods_id,goods_price,groupbuy_price,group_pic,rebate,start_time,end_time
             $data_array = array();
             $data_array['group_id'] = $result;
             $data_array['group_name'] = $param['group_name'];
             $data_array['goods_id'] = $param['goods_id'];
             $data_array['goods_price'] = $param['goods_price'];
             $data_array['groupbuy_price'] = $param['groupbuy_price'];
             $data_array['group_pic'] = $param['group_pic'];
             $data_array['rebate'] = $param['rebate'];
             $data_array['start_time'] = $template_info['start_time'];
             $data_array['end_time'] = $template_info['end_time'];
             $this->storeAutoShare($data_array, 'groupbuy');
             showDialog(Language::get('groupbuy_add_success'), 'index.php?act=store_groupbuy', 'succ');
         } else {
             showDialog(Language::get('groupbuy_add_fail'), 'index.php?act=store_groupbuy');
         }
     } else {
         //编辑
         if (!empty($group_pic)) {
             $param['group_pic'] = $group_pic;
         }
         $group_info = $model_goods_group->getOne($group_id);
         if (empty($group_info)) {
             showDialog(Language::get('param_error'));
         }
         $group_state = intval($group_info['state']);
         if ($group_state !== self::STATE_VERIFY && $group_state !== self::STATE_VERIFY_FAIL) {
             showDialog(Language::get('param_error'), '');
         }
         if (intval($group_info['store_id']) !== intval($_SESSION['store_id'])) {
             showDialog(Language::get('param_error'));
         }
         if ($model_goods_group->update($param, array('group_id' => $group_id))) {
             showDialog(Language::get('groupbuy_edit_success'), 'index.php?act=store_groupbuy', 'succ');
         } else {
             showDialog(Language::get('groupbuy_edit_fail'));
         }
     }
 }