/** * 生成二维码 */ public function mb_qrOp() { $url = urlShop('mb_app', 'index'); $mobile_app = 'mb_app.png'; require_once BASE_RESOURCE_PATH . DS . 'phpqrcode' . DS . 'index.php'; $PhpQRCode = new PhpQRCode(); $PhpQRCode->set('pngTempDir', BASE_UPLOAD_PATH . DS . ATTACH_COMMON . DS); $PhpQRCode->set('date', $url); $PhpQRCode->set('pngTempName', $mobile_app); $PhpQRCode->init(); $this->log('生成手机端二维码'); showMessage('生成二维码成功', 'index.php?act=mb_app&op=mb_app'); }
/** * 添加停车位 */ public function party_addOp() { require_once BASE_RESOURCE_PATH . DS . 'phpqrcode' . DS . 'index.php'; $PhpQRCode = new PhpQRCode(); $PhpQRCode->set('pngTempDir', BASE_UPLOAD_PATH . DS . ATTACH_STORE . DS . 'party' . DS); //$lang = Language::getLangContent(); $model_party_barcode = Model('party_barcode'); if (chksubmit()) { $obj_validate = new Validate(); $obj_validate->validateparam = array(array("input" => $_POST["code"], "require" => "true", "message" => "请输入编码"), array("input" => $_POST["address"], "require" => "true", "message" => "请输入地址")); $error = $obj_validate->validate(); if ($error != '') { showMessage($error); } else { $PB = array(); $PB['code'] = $_POST['code']; $PB['address'] = $_POST['address']; $PB['lastuptime'] = time(); $return = $model_party_barcode->addPB($PB); // 生成商品二维码 if (!empty($return)) { //QueueClient::push('createGoodsQRCode', array('store_id' => $_SESSION['store_id'], 'goodsid_array' => $goodsid_array)); // 生成停车位二维码 $PhpQRCode->set('date', $return); $PhpQRCode->set('pngTempName', $return . '.png'); $PhpQRCode->init(); // $model_party_barcode->editPB( // array('barcodeurl'=>trim($_GET['value'])), // 'spec' // ); } if ($return) { $url = array(array('url' => 'index.php?act=party_barcode&op=party_add', 'msg' => "继续添加"), array('url' => 'index.php?act=party_barcode&op=index', 'msg' => "查看所有")); $this->log('新建停车位[' . $_POST['s_name'] . ']', 1); showMessage("添加成功", $url); } else { $this->log('[新建停车位' . $_POST['s_name'] . ']', 0); showMessage("添加失败"); } } } // 一级商品分类 //$gc_list = H('party_codes') ? H('party_codes') : H('party_codes', true); //Tpl::output('gc_list', $gc_list); Tpl::showpage('party_barcode.add'); }
public function maker_qrcodeOp() { $store_id = $_SESSION['store_id']; require_once BASE_RESOURCE_PATH . DS . 'phpqrcode' . DS . 'index.php'; $PhpQRCode = new PhpQRCode(); $PhpQRCode->set('pngTempDir', BASE_UPLOAD_PATH . DS . ATTACH_STORE . DS . $_SESSION['store_id'] . DS); //print_r($PhpQRCode); $model_goods = Model('goods'); $where = array(); $where['store_id'] = $store_id; //$count=$model_goods->getGoodsCount($where); $lst = $model_goods->getGoodsList($where, 'goods_id'); if (empty($lst)) { echo '未找到商品信息'; retrun; } foreach ($lst as $k => $v) { $goods_id = $v['goods_id']; $qrcode_url = WAP_SITE_URL . '/tmpl/product_detail.html?goods_id=' . $goods_id; $PhpQRCode->set('date', $qrcode_url); $PhpQRCode->set('pngTempName', $goods_id . '.png'); $PhpQRCode->init(); echo '生成成功' . $qrcode_url; echo '<br/>'; } //生成店铺二维码 $qrcode_url = WAP_SITE_URL . '/tmpl/go_store.html?store_id=' . $store_id; $PhpQRCode->set('date', $qrcode_url); $PhpQRCode->set('pngTempName', $store_id . '_store.png'); $PhpQRCode->init(); echo '生成店铺二维码成功' . $qrcode_url; echo '<br/>'; echo '<br/><b>全部生成完成</b>'; }
/** * 保存商品(商品发布第二步使用) */ public function save_goodsOp() { if (chksubmit()) { // 验证表单 $obj_validate = new Validate(); $obj_validate->validateparam = array(array("input" => $_POST["g_name"], "require" => "true", "message" => L('store_goods_index_goods_name_null')), array("input" => $_POST["g_price"], "require" => "true", "validator" => "Double", "message" => L('store_goods_index_goods_price_null'))); $error = $obj_validate->validate(); if ($error != '') { showMessage(L('error') . $error, urlShop('seller_center'), 'html', 'error'); } $model_goods = Model('goods'); $model_type = Model('type'); $common_array = array(); $common_array['goods_name'] = $_POST['g_name']; $common_array['goods_jingle'] = $_POST['g_jingle']; $common_array['gc_id'] = intval($_POST['cate_id']); $common_array['gc_name'] = $_POST['cate_name']; $common_array['brand_id'] = $_POST['b_id']; $common_array['brand_name'] = $_POST['b_name']; $common_array['type_id'] = intval($_POST['type_id']); $common_array['goods_image'] = $_POST['image_path']; $common_array['goods_price'] = floatval($_POST['g_price']); $common_array['goods_marketprice'] = floatval($_POST['g_marketprice']); $common_array['goods_costprice'] = floatval($_POST['g_costprice']); $common_array['goods_discount'] = floatval($_POST['g_discount']); $common_array['goods_serial'] = $_POST['g_serial']; $common_array['goods_attr'] = serialize($_POST['attr']); $common_array['goods_body'] = $_POST['g_body']; $common_array['goods_commend'] = intval($_POST['g_commend']); $common_array['goods_state'] = $this->store_info['store_state'] != 1 ? 0 : intval($_POST['g_state']); // 店铺关闭时,商品下架 $common_array['goods_addtime'] = TIMESTAMP; $common_array['goods_selltime'] = strtotime($_POST['starttime']) + intval($_POST['starttime_H']) * 3600 + intval($_POST['starttime_i']) * 60; $common_array['goods_verify'] = C('goods_verify') == 1 ? 10 : 1; $common_array['store_id'] = $_SESSION['store_id']; $common_array['store_name'] = $_SESSION['store_name']; $common_array['spec_name'] = is_array($_POST['spec']) ? serialize($_POST['sp_name']) : serialize(null); $common_array['spec_value'] = is_array($_POST['spec']) ? serialize($_POST['sp_val']) : serialize(null); $common_array['goods_vat'] = intval($_POST['g_vat']); $common_array['areaid_1'] = intval($_POST['province_id']); $common_array['areaid_2'] = intval($_POST['city_id']); $common_array['transport_id'] = $_POST['freight'] == '0' ? '0' : intval($_POST['transport_id']); // 运费模板 $common_array['transport_title'] = $_POST['transport_title']; $common_array['goods_freight'] = floatval($_POST['g_freight']); $common_array['goods_stcids'] = ',' . implode(',', array_unique($_POST['sgcate_id'])) . ','; // 首尾需要加, $common_array['plateid_top'] = intval($_POST['plate_top']) > 0 ? intval($_POST['plate_top']) : ''; $common_array['plateid_bottom'] = intval($_POST['plate_bottom']) > 0 ? intval($_POST['plate_bottom']) : ''; // 保存数据 $common_id = $model_goods->addGoods($common_array, 'goods_common'); if ($common_id) { // 生成商品二维码 require_once BASE_RESOURCE_PATH . DS . 'phpqrcode' . DS . 'index.php'; $PhpQRCode = new PhpQRCode(); $PhpQRCode->set('pngTempDir', BASE_UPLOAD_PATH . DS . ATTACH_STORE . DS . $_SESSION['store_id'] . DS); // 商品规格 if (is_array($_POST['spec'])) { foreach ($_POST['spec'] as $value) { $goods = array(); $goods['goods_commonid'] = $common_id; $goods['goods_name'] = $common_array['goods_name'] . ' ' . implode(' ', $value['sp_value']); $goods['goods_jingle'] = $common_array['goods_jingle']; $goods['store_id'] = $common_array['store_id']; $goods['store_name'] = $_SESSION['store_name']; $goods['gc_id'] = $common_array['gc_id']; $goods['brand_id'] = $common_array['brand_id']; $goods['goods_price'] = $value['price']; $goods['goods_marketprice'] = $common_array['goods_marketprice']; $goods['goods_serial'] = $value['sku']; $goods['goods_spec'] = serialize($value['sp_value']); $goods['goods_storage'] = $value['stock']; $goods['goods_image'] = $common_array['goods_image']; $goods['goods_state'] = $common_array['goods_state']; $goods['goods_verify'] = $common_array['goods_verify']; $goods['goods_addtime'] = TIMESTAMP; $goods['goods_edittime'] = TIMESTAMP; $goods['areaid_1'] = $common_array['areaid_1']; $goods['areaid_2'] = $common_array['areaid_2']; $goods['color_id'] = intval($value['color']); $goods['transport_id'] = $common_array['transport_id']; $goods['goods_freight'] = $common_array['goods_freight']; $goods['goods_vat'] = $common_array['goods_vat']; $goods['goods_commend'] = $common_array['goods_commend']; $goods['goods_stcids'] = $common_array['goods_stcids']; $goods_id = $model_goods->addGoods($goods); $model_type->addGoodsType($goods_id, $common_id, array('cate_id' => $_POST['cate_id'], 'type_id' => $_POST['type_id'], 'attr' => $_POST['attr'])); // 生成商品二维码 $PhpQRCode->set('date', urlShop('goods', 'index', array('goods_id' => $goods_id))); $PhpQRCode->set('pngTempName', $goods_id . '.png'); $PhpQRCode->init(); } } else { $goods = array(); $goods['goods_commonid'] = $common_id; $goods['goods_name'] = $common_array['goods_name']; $goods['goods_jingle'] = $common_array['goods_jingle']; $goods['store_id'] = $common_array['store_id']; $goods['store_name'] = $_SESSION['store_name']; $goods['gc_id'] = $common_array['gc_id']; $goods['brand_id'] = $common_array['brand_id']; $goods['goods_price'] = $common_array['goods_price']; $goods['goods_marketprice'] = $common_array['goods_marketprice']; $goods['goods_serial'] = $common_array['goods_serial']; $goods['goods_spec'] = serialize(null); $goods['goods_storage'] = intval($_POST['g_storage']); $goods['goods_image'] = $common_array['goods_image']; $goods['goods_state'] = $common_array['goods_state']; $goods['goods_verify'] = $common_array['goods_verify']; $goods['goods_addtime'] = TIMESTAMP; $goods['goods_edittime'] = TIMESTAMP; $goods['areaid_1'] = $common_array['areaid_1']; $goods['areaid_2'] = $common_array['areaid_2']; $goods['color_id'] = 0; $goods['transport_id'] = $common_array['transport_id']; $goods['goods_freight'] = $common_array['goods_freight']; $goods['goods_vat'] = $common_array['goods_vat']; $goods['goods_commend'] = $common_array['goods_commend']; $goods['goods_stcids'] = $common_array['goods_stcids']; $goods_id = $model_goods->addGoods($goods); $model_type->addGoodsType($goods_id, $common_id, array('cate_id' => $_POST['cate_id'], 'type_id' => $_POST['type_id'], 'attr' => $_POST['attr'])); // 生成商品二维码 $PhpQRCode->set('date', urlShop('goods', 'index', array('goods_id' => $goods_id))); $PhpQRCode->set('pngTempName', $goods_id . '.png'); $PhpQRCode->init(); } // 商品加入上架队列 if (isset($_POST['starttime'])) { $selltime = strtotime($_POST['starttime']) + intval($_POST['starttime_H']) * 3600 + intval($_POST['starttime_i']) * 60; if ($selltime > TIMESTAMP) { $this->addcron(array('exetime' => $selltime, 'exeid' => $common_id, 'type' => 1)); } } // 记录日志 $this->recordSellerLog('添加商品,平台货号:' . $common_id); redirect(urlShop('store_goods_add', 'add_step_three', array('commonid' => $common_id))); } else { showMessage(L('store_goods_index_goods_add_fail'), getReferer(), 'html', 'error'); } } }
public function indexOp() { $lang = Language::getLangContent(); // 生成商店二维码 require_once BASE_RESOURCE_PATH . DS . 'phpqrcode' . DS . 'index.php'; $PhpQRCode = new PhpQRCode(); $PhpQRCode->set('pngTempDir', BASE_UPLOAD_PATH . DS . ATTACH_STORE . DS . $_SESSION['store_id'] . DS); if (!$_POST) { /** * 获取商品分类 */ $gc = Model('goods_class'); $gc_list = $gc->getGoodsClassList(array('gc_parent_id' => '0')); Tpl::output('gc_list', $gc_list); $model_store_class = Model('my_goods_class'); $store_goods_class = $model_store_class->getClassTree(array('store_id' => $_SESSION['store_id'], 'stc_state' => '1')); Tpl::output('store_goods_class', $store_goods_class); if ($_GET['step'] != '') { Tpl::output('step', $_GET['step']); } else { Tpl::output('step', '1'); } } else { $file = $_FILES['csv']; if (empty($file['name'])) { showMessage($lang['store_goods_import_choose_file'], '', 'html', 'error'); } if (!is_uploaded_file($file['tmp_name'])) { showMessage($lang['store_goods_import_unknown_file'], '', 'html', 'error'); } /** * 文件类型判定 */ $file_name_array = explode('.', $file['name']); if ($file_name_array[count($file_name_array) - 1] != 'csv') { showMessage($lang['store_goods_import_wrong_type'] . $file_name_array[count($file_name_array) - 1], '', 'html', 'error'); } /** * 文件大小判定 */ if ($file['size'] > intval(ini_get('upload_max_filesize')) * 1024 * 1024) { showMessage($lang['store_goods_import_size_limit'], '', 'html', 'error'); } /** * 商品分类判定 */ if (empty($_POST['gc_id'])) { showMessage($lang['store_goods_import_wrong_class'], '', 'html', 'error'); } $gc = Model('goods_class'); $gc_row = $gc->getGoodsClassLineForTag($_POST['gc_id']); if (!is_array($gc_row) or count($gc_row) == 0) { showMessage($lang['store_goods_import_wrong_class1'], '', 'html', 'error'); } $gc_sub_list = $gc->getGoodsClassList(array('gc_parent_id' => intval($_POST['gc_id']))); if (is_array($gc_sub_list) and count($gc_sub_list) > 0) { showMessage($lang['store_goods_import_wrong_class2'], '', 'html', 'error'); } /** * 店铺商品分类判定 */ $sgcate_ids = array(); $stc = Model('store_goods_class'); if (is_array($_POST['sgcate_id']) and count($_POST['sgcate_id']) > 0) { foreach ($_POST['sgcate_id'] as $sgcate_id) { if (!in_array($sgcate_id, $sgcate_ids)) { $stc_row = $stc->getOneById($sgcate_id); if (is_array($stc_row) and count($stc_row) > 0) { $sgcate_ids[] = $sgcate_id; } } } } /** * 上传文件的字符编码转换 */ $csv_string = unicodeToUtf8(file_get_contents($file['tmp_name'])); /* 兼容淘宝助理5 start */ $csv_array = explode("\tsyncStatus", $csv_string, 2); if (count($csv_array) == 2) { $csv_string = $csv_array[1]; } /* 兼容淘宝助理5 end */ /** * 将文件转换为二维数组形式的商品数据 */ $records = $this->parse_taobao_csv($csv_string); if ($records === false) { showMessage($lang['store_goods_import_wrong_column'], '', 'html', 'error'); } /** * 转码 */ if (strtoupper(CHARSET) == 'GBK') { $records = Language::getGBK($records); } $model_goodsclass = Model('goods_class'); $model_store_goods = Model('goods'); $model_type = Model('type'); // 商品数量 $goods_num = $model_store_goods->getGoodsCommonCount(array('store_id' => $_SESSION['store_id'])); /** * 商品数,空间使用,使用期限判断 */ $model_store = Model('store'); $store_info = $model_store->getStoreInfo(array('store_id' => $_SESSION['store_id'])); $model_store_grade = Model('store_grade'); $store_grade = $model_store_grade->getOneGrade($store_info['grade_id']); /*商品数判断*/ $remain_num = -1; if (intval($store_grade['sg_goods_limit']) != 0) { if ($goods_num >= $store_grade['sg_goods_limit']) { showMessage($lang['store_goods_index_goods_limit'] . $store_grade['sg_goods_limit'] . $lang['store_goods_index_goods_limit1'], 'index.php?act=store_goods&op=goods_list', 'html', 'error'); } $remain_num = $store_grade['sg_goods_limit'] - $goods_num; } /*使用期限判断*/ if (intval($store_info['store_end_time']) != 0) { if (time() >= $store_info['store_end_time']) { showMessage($lang['store_goods_index_time_limit'], 'index.php?act=store_goods&op=goods_list', 'html', 'error'); } } /** * 循环添加数据 */ $str = ''; if (is_array($records) and count($records) > 0) { foreach ($records as $k => $record) { if ($remain_num > 0 and $k >= $remain_num) { showMessage($lang['store_goods_index_goods_limit'] . $store_grade['sg_goods_limit'] . $lang['store_goods_index_goods_limit1'] . $lang['store_goods_import_end'] . (count($records) - $remain_num) . $lang['store_goods_import_products_no_import'], 'index.php?act=store_goods&op=taobao_import&step=4', 'html', 'error'); } if (is_array($record['goods_image'])) { $str .= implode(',', $record['goods_image']); $str .= "\r\n"; } else { $str .= $record['goods_image'] . "\r\n"; } file_put_contents('image.txt', $str, FILE_APPEND); $pic_array = $this->get_goods_image($record['goods_image']); if (empty($record['goods_name'])) { continue; } $param = array(); $param['goods_name'] = $record['goods_name']; $param['gc_id'] = intval($_POST['gc_id']); //$param['gc_name'] = $gc_row['gc_tag_name']; $param['store_id'] = $_SESSION['store_id']; $param['type_id'] = '0'; $param['goods_image'] = $pic_array['goods_image'][0]; $param['goods_marketprice'] = $record['goods_store_price']; $param['goods_price'] = $record['goods_store_price']; //$param['goods_show'] = '1'; $param['goods_commend'] = $record['goods_commend']; $param['goods_addtime'] = time(); $param['goods_body'] = $record['goods_body']; $param['goods_state'] = '0'; $param['goods_verify'] = '1'; $param['areaid_1'] = intval($_POST['province_id']); $param['areaid_2'] = intval($_POST['city_id']); $param['goods_stcids'] = ',' . implode(',', array_unique($_POST['sgcate_id'])) . ','; $param['goods_serial'] = $record['goods_serial']; $goods_id = $model_store_goods->addGoodsCommon($param); //添加库存 $param = array(); $param['goods_commonid'] = $goods_id; $param['goods_name'] = $record['goods_name']; $param['gc_id'] = intval($_POST['gc_id']); $param['store_id'] = $_SESSION['store_id']; $param['goods_image'] = $pic_array['goods_image'][0]; $param['goods_marketprice'] = $record['goods_store_price']; $param['goods_price'] = $record['goods_store_price']; //$param['goods_show'] = '1'; $param['goods_commend'] = $record['goods_commend']; $param['goods_addtime'] = time(); $param['goods_state'] = '0'; $param['goods_verify'] = '1'; $param['areaid_1'] = intval($_POST['province_id']); $param['areaid_2'] = intval($_POST['city_id']); $param['goods_stcids'] = $_POST['sgcate_id']; $param['goods_storage'] = $record['spec_goods_storage']; $param['goods_serial'] = $record['goods_serial']; $goods_id1 = $model_store_goods->addGoods($param); //规格导入 // 更新常用分类信息 $goods_class = $model_goodsclass->getGoodsClassLineForTag($_POST['gc_id']); $type_id = $goods_class['type_id']; //添加规格表 (防止BUG暂时不做了) if ($type_id > 0) { //$spec_id = $model_type->addGoodsType($goods_id1, $goods_id, array('cate_id' => $_POST['gc_id'], 'type_id' => $type_id, 'attr' => $_POST['attr'])); } $goods_id_str .= "," . $goods_id; if ($goods_id) { /** * 添加商品的店铺分类表 */ /** * 商品多图的添加 */ if (!empty($pic_array['goods_image']) && is_array($pic_array['goods_image'])) { $insert_array = array(); foreach ($pic_array['goods_image'] as $pic) { if ($pic == '') { continue; } $param = array(); $param['goods_image'] = $pic; $param['store_id'] = $_SESSION['store_id']; $param['goods_commonid'] = $goods_id; $insert_array[] = $param; } //$rs = Model('upload'); //$rs = $rs->add($param); $rs = $model_store_goods->addGoodsImagesAll($insert_array); } } } if ($goods_id_str != "") { Tpl::output('goods_id_str', substr($goods_id_str, 1, strlen($goods_id_str))); } } Tpl::output('step', '4'); } /** * 相册分类 */ $model_album = Model('album'); $param = array(); $param['album_aclass.store_id'] = $_SESSION['store_id']; $aclass_info = $model_album->getClassList($param); Tpl::output('aclass_info', $aclass_info); Tpl::output('PHPSESSID', session_id()); Tpl::output('menu_sign', 'taobao_import'); Tpl::showpage('store_goods_import'); }
/** * 修改店铺二维码 ajax */ public function ajax_change_store_codeOp() { /** * 实例化 */ $store_model = Model('store'); // 删除原有二维码图片 $store_info = $store_model->getOne($_SESSION['store_id']); if ($store_info['store_code'] != 'default_qrcode.png') { @unlink(ATTACH_STORE . DS . $store_info['store_code']); } // 生成新的二维码 require_once BasePath . DS . 'resource' . DS . 'phpqrcode' . DS . 'index.php'; $PhpQRCode = new PhpQRCode(); if (C('enabled_subdomain') == 1 && $store_info['store_domain'] != '') { $PhpQRCode->set('date', ncUrl(array('act' => 'show_store', 'id' => $_SESSION['store_id']), 'store', $store_info['store_domain'])); } else { $PhpQRCode->set('date', SiteUrl . DS . ncUrl(array('act' => 'show_store', 'id' => $_SESSION['store_id']), 'store', $store_info['store_domain'])); } $PhpQRCode->set('pngTempDir', ATTACH_STORE . DS); $url = $PhpQRCode->init(); $store_model->storeUpdate(array('store_code' => $url, 'store_id' => $_SESSION['store_id'])); echo json_encode($url); }
/** * 编辑商品保存 */ public function edit_save_goodsOp() { $common_id = intval($_POST['commonid']); if (!chksubmit() || $common_id <= 0) { showDialog(L('store_goods_index_goods_edit_fail'), urlShop('store_goods_online', 'index')); } // 验证表单 $obj_validate = new Validate(); $obj_validate->validateparam = array(array("input" => $_POST["g_name"], "require" => "true", "message" => L('store_goods_index_goods_name_null')), array("input" => $_POST["g_price"], "require" => "true", "validator" => "Double", "message" => L('store_goods_index_goods_price_null'))); $error = $obj_validate->validate(); if ($error != '') { showDialog(L('error') . $error, urlShop('store_goods_online', 'index')); } $gc_id = intval($_POST['cate_id']); // 验证商品分类是否存在且商品分类是否为最后一级 $data = H('goods_class') ? H('goods_class') : H('goods_class', true); if (!isset($data[$gc_id]) || isset($data[$gc_id]['child']) || isset($data[$gc_id]['childchild'])) { showDialog(L('store_goods_index_again_choose_category1')); } /* // 三方店铺验证是否绑定了该分类 if (!checkPlatformStore()) { $where = array(); $where['class_1|class_2|class_3'] = $gc_id; $where['store_id'] = $_SESSION['store_id']; $rs = Model('store_bind_class')->getStoreBindClassInfo($where); if (empty($rs)) { showDialog(L('store_goods_index_again_choose_category2')); } }*/ $model_goods = Model('goods'); $update_common = array(); $update_common['goods_name'] = $_POST['g_name']; $update_common['goods_jingle'] = $_POST['g_jingle']; $update_common['gc_id'] = $gc_id; $update_common['gc_name'] = $_POST['cate_name']; $update_common['brand_id'] = $_POST['b_id']; $update_common['brand_name'] = $_POST['b_name']; $update_common['type_id'] = intval($_POST['type_id']); $update_common['goods_image'] = $_POST['image_path']; $update_common['goods_price'] = floatval($_POST['g_price']); $update_common['goods_marketprice'] = floatval($_POST['g_marketprice']); $update_common['goods_costprice'] = floatval($_POST['g_costprice']); $update_common['goods_weight'] = intval($_POST['g_weight']); $update_common['goods_discount'] = floatval($_POST['g_discount']); $update_common['goods_serial'] = $_POST['g_serial']; $update_common['goods_attr'] = serialize($_POST['attr']); $update_common['goods_body'] = $_POST['g_body']; $update_common['goods_commend'] = intval($_POST['g_commend']); $update_common['goods_state'] = $this->store_info['store_state'] != 1 ? 0 : intval($_POST['g_state']); // 店铺关闭时,商品下架 $update_common['goods_selltime'] = strtotime($_POST['starttime']) + intval($_POST['starttime_H']) * 3600 + intval($_POST['starttime_i']) * 60; $update_common['goods_verify'] = C('goods_verify') == 1 ? 10 : 1; $update_common['spec_name'] = is_array($_POST['spec']) ? serialize($_POST['sp_name']) : serialize(null); $update_common['spec_value'] = is_array($_POST['spec']) ? serialize($_POST['sp_val']) : serialize(null); $update_common['goods_vat'] = intval($_POST['g_vat']); $update_common['areaid_1'] = intval($_POST['province_id']); $update_common['areaid_2'] = intval($_POST['city_id']); $update_common['transport_id'] = $_POST['freight'] == '0' ? '0' : intval($_POST['transport_id']); // 运费模板 $update_common['transport_title'] = $_POST['transport_title']; $update_common['goods_freight'] = floatval($_POST['g_freight']); $update_common['goods_stcids'] = ',' . implode(',', array_unique($_POST['sgcate_id'])) . ','; // 首尾需要加, $update_common['plateid_top'] = intval($_POST['plate_top']) > 0 ? intval($_POST['plate_top']) : ''; $update_common['plateid_bottom'] = intval($_POST['plate_bottom']) > 0 ? intval($_POST['plate_bottom']) : ''; $return = $model_goods->editGoodsCommon($update_common, array('goods_commonid' => $common_id, 'store_id' => $_SESSION['store_id'])); if ($return) { // 清除原有规格数据 $model_type = Model('type'); $model_type->delGoodsAttr(array('goods_commonid' => $common_id)); // 生成商品二维码 require_once BASE_RESOURCE_PATH . DS . 'phpqrcode' . DS . 'index.php'; $PhpQRCode = new PhpQRCode(); $PhpQRCode->set('pngTempDir', BASE_UPLOAD_PATH . DS . ATTACH_STORE . DS . $_SESSION['store_id'] . DS); // 更新商品规格 $goodsid_array = array(); $colorid_array = array(); if (is_array($_POST['spec'])) { foreach ($_POST['spec'] as $value) { $goods_info = $model_goods->getGoodsInfo(array('goods_id' => $value['goods_id'], 'goods_commonid' => $common_id, 'store_id' => $_SESSION['store_id']), 'goods_id'); if (!empty($goods_info)) { $goods_id = $goods_info['goods_id']; $update = array(); $update['goods_commonid'] = $common_id; $update['goods_name'] = $update_common['goods_name'] . ' ' . implode(' ', $value['sp_value']); $update['goods_jingle'] = $update_common['goods_jingle']; $update['store_id'] = $_SESSION['store_id']; $update['store_name'] = $_SESSION['store_name']; $update['gc_id'] = $update_common['gc_id']; $update['brand_id'] = $update_common['brand_id']; $update['goods_price'] = $value['price']; $update['goods_marketprice'] = $update_common['goods_marketprice']; $update['goods_weight'] = $update_common['goods_weight']; $update['goods_serial'] = $value['sku']; $update['goods_spec'] = serialize($value['sp_value']); $update['goods_storage'] = $value['stock']; $update['goods_state'] = $update_common['goods_state']; $update['goods_verify'] = $update_common['goods_verify']; $update['goods_edittime'] = TIMESTAMP; $update['areaid_1'] = $update_common['areaid_1']; $update['areaid_2'] = $update_common['areaid_2']; $update['color_id'] = intval($value['color']); $update['transport_id'] = $update_common['transport_id']; $update['goods_freight'] = $update_common['goods_freight']; $update['goods_vat'] = $update_common['goods_vat']; $update['goods_commend'] = $update_common['goods_commend']; $update['goods_stcids'] = $update_common['goods_stcids']; $model_goods->editGoods($update, array('goods_id' => $goods_id)); // 生成商品二维码 $PhpQRCode->set('date', urlShop('goods', 'index', array('goods_id' => $goods_id))); $PhpQRCode->set('pngTempName', $goods_id . '.png'); $PhpQRCode->init(); } else { $insert = array(); $insert['goods_commonid'] = $common_id; $insert['goods_name'] = $update_common['goods_name'] . ' ' . implode(' ', $value['sp_value']); $insert['goods_jingle'] = $update_common['goods_jingle']; $insert['store_id'] = $_SESSION['store_id']; $insert['store_name'] = $_SESSION['store_name']; $insert['gc_id'] = $update_common['gc_id']; $insert['brand_id'] = $update_common['brand_id']; $insert['goods_price'] = $value['price']; $insert['goods_marketprice'] = $update_common['goods_marketprice']; $insert['goods_weight'] = $update_common['goods_weight']; $insert['goods_serial'] = $value['sku']; $insert['goods_spec'] = serialize($value['sp_value']); $insert['goods_storage'] = $value['stock']; $insert['goods_image'] = $update_common['goods_image']; $insert['goods_state'] = $update_common['goods_state']; $insert['goods_verify'] = $update_common['goods_verify']; $insert['goods_addtime'] = TIMESTAMP; $insert['goods_edittime'] = TIMESTAMP; $insert['areaid_1'] = $update_common['areaid_1']; $insert['areaid_2'] = $update_common['areaid_2']; $insert['color_id'] = intval($value['color']); $insert['transport_id'] = $update_common['transport_id']; $insert['goods_freight'] = $update_common['goods_freight']; $insert['goods_vat'] = $update_common['goods_vat']; $insert['goods_commend'] = $update_common['goods_commend']; $insert['goods_stcids'] = $update_common['goods_stcids']; $goods_id = $model_goods->addGoods($insert); // 生成商品二维码 $PhpQRCode->set('date', urlShop('goods', 'index', array('goods_id' => $goods_id))); $PhpQRCode->set('pngTempName', $goods_id . '.png'); $PhpQRCode->init(); } $goodsid_array[] = intval($goods_id); $colorid_array[] = intval($value['color']); $model_type->addGoodsType($goods_id, $common_id, array('cate_id' => $_POST['cate_id'], 'type_id' => $_POST['type_id'], 'attr' => $_POST['attr'])); } } else { $goods_info = $model_goods->getGoodsInfo(array('goods_spec' => serialize(null), 'goods_commonid' => $common_id, 'store_id' => $_SESSION['store_id']), 'goods_id'); if (!empty($goods_info)) { $goods_id = $goods_info['goods_id']; $update = array(); $update['goods_commonid'] = $common_id; $update['goods_name'] = $update_common['goods_name']; $update['goods_jingle'] = $update_common['goods_jingle']; $update['store_id'] = $_SESSION['store_id']; $update['store_name'] = $_SESSION['store_name']; $update['gc_id'] = $update_common['gc_id']; $update['brand_id'] = $update_common['brand_id']; $update['goods_price'] = $update_common['goods_price']; $update['goods_marketprice'] = $update_common['goods_marketprice']; $update['goods_weight'] = $update_common['goods_weight']; $update['goods_serial'] = $update_common['goods_serial']; $update['goods_spec'] = serialize(null); $update['goods_storage'] = intval($_POST['g_storage']); $update['goods_state'] = $update_common['goods_state']; $update['goods_verify'] = $update_common['goods_verify']; $update['goods_edittime'] = TIMESTAMP; $update['areaid_1'] = $update_common['areaid_1']; $update['areaid_2'] = $update_common['areaid_2']; $update['color_id'] = 0; $update['transport_id'] = $update_common['transport_id']; $update['goods_freight'] = $update_common['goods_freight']; $update['goods_vat'] = $update_common['goods_vat']; $update['goods_commend'] = $update_common['goods_commend']; $update['goods_stcids'] = $update_common['goods_stcids']; $model_goods->editGoods($update, array('goods_id' => $goods_id)); // 生成商品二维码 $PhpQRCode->set('date', urlShop('goods', 'index', array('goods_id' => $goods_id))); $PhpQRCode->set('pngTempName', $goods_id . '.png'); $PhpQRCode->init(); } else { $insert = array(); $insert['goods_commonid'] = $common_id; $insert['goods_name'] = $update_common['goods_name']; $insert['goods_jingle'] = $update_common['goods_jingle']; $insert['store_id'] = $_SESSION['store_id']; $insert['store_name'] = $_SESSION['store_name']; $insert['gc_id'] = $update_common['gc_id']; $insert['brand_id'] = $update_common['brand_id']; $insert['goods_price'] = $update_common['goods_price']; $insert['goods_marketprice'] = $update_common['goods_marketprice']; $insert['goods_weight'] = $update_common['goods_weight']; $insert['goods_serial'] = $update_common['goods_serial']; $insert['goods_spec'] = serialize(null); $insert['goods_storage'] = intval($_POST['g_storage']); $insert['goods_image'] = $update_common['goods_image']; $insert['goods_state'] = $update_common['goods_state']; $insert['goods_verify'] = $update_common['goods_verify']; $insert['goods_addtime'] = TIMESTAMP; $insert['goods_edittime'] = TIMESTAMP; $insert['areaid_1'] = $update_common['areaid_1']; $insert['areaid_2'] = $update_common['areaid_2']; $insert['color_id'] = 0; $insert['transport_id'] = $update_common['transport_id']; $insert['goods_freight'] = $update_common['goods_freight']; $insert['goods_vat'] = $update_common['goods_vat']; $insert['goods_commend'] = $update_common['goods_commend']; $insert['goods_stcids'] = $update_common['goods_stcids']; $goods_id = $model_goods->addGoods($insert); // 生成商品二维码 $PhpQRCode->set('date', urlShop('goods', 'index', array('goods_id' => $goods_id))); $PhpQRCode->set('pngTempName', $goods_id . '.png'); $PhpQRCode->init(); } $goodsid_array[] = intval($goods_id); $colorid_array[] = 0; $model_type->addGoodsType($goods_id, $common_id, array('cate_id' => $_POST['cate_id'], 'type_id' => $_POST['type_id'], 'attr' => $_POST['attr'])); } // 清理商品数据 $model_goods->delGoods(array('goods_id' => array('not in', $goodsid_array), 'goods_commonid' => $common_id, 'store_id' => $_SESSION['store_id'])); // 清理商品图片表 $colorid_array = array_unique($colorid_array); $model_goods->delGoodsImages(array('goods_commonid' => $common_id, 'color_id' => array('not in', $colorid_array))); // 更新商品默认主图 $default_image_list = $model_goods->getGoodsImageList(array('goods_commonid' => $common_id, 'is_default' => 1), 'color_id,goods_image'); if (!empty($default_image_list)) { foreach ($default_image_list as $val) { $model_goods->editGoods(array('goods_image' => $val['goods_image']), array('goods_commonid' => $common_id, 'color_id' => $val['color_id'])); } } // 商品加入上架队列 if (isset($_POST['starttime'])) { $selltime = strtotime($_POST['starttime']) + intval($_POST['starttime_H']) * 3600 + intval($_POST['starttime_i']) * 60; if ($selltime > TIMESTAMP) { $this->addcron(array('exetime' => $selltime, 'exeid' => $common_id, 'type' => 1), true); } } // 添加操作日志 $this->recordSellerLog('编辑商品,平台货号:' . $common_id); showDialog(L('nc_common_op_succ'), $_POST['ref_url'], 'succ'); } else { showDialog(L('store_goods_index_goods_edit_fail'), urlShop('store_goods_online', 'index')); } }
public function maker_qrcodeOp() { //zmr>v30 header("content-type:text/html; charset=utf-8"); $store_id = $_SESSION['store_id']; // 生成商店二维码 require_once BASE_RESOURCE_PATH . DS . 'phpqrcode' . DS . 'index.php'; $PhpQRCode = new PhpQRCode(); $PhpQRCode->set('pngTempDir', BASE_UPLOAD_PATH . DS . ATTACH_STORE . DS . $_SESSION['store_id'] . DS); //print_r($PhpQRCode); $model_goods = Model('goods'); $where = array(); $where['store_id'] = $store_id; //$count=$model_goods->getGoodsCount($where); $lst = $model_goods->getGoodsList($where, 'goods_id'); if (empty($lst)) { echo '未找到商品信息'; retrun; } foreach ($lst as $k => $v) { $goods_id = $v['goods_id']; //zmr>v30生成二维码 $qrcode_url = WAP_SITE_URL . '/tmpl/product_detail.html?goods_id=' . $goods_id; $PhpQRCode->set('date', $qrcode_url); $PhpQRCode->set('pngTempName', $goods_id . '.png'); $PhpQRCode->init(); echo '生成成功》》》' . $qrcode_url; echo '<br/>'; } //zmr>v30 //生成店铺二维码 $qrcode_url = WAP_SITE_URL . '/tmpl/go_store.html?store_id=' . $store_id; $PhpQRCode->set('date', $qrcode_url); $PhpQRCode->set('pngTempName', $store_id . '_store.png'); $PhpQRCode->init(); echo '生成店铺二维码成功》》》' . $qrcode_url; echo '<br/>'; //zmr<<< echo '<br/><b style="color:blue">==========全部生成完成==========</b>'; }
/** * 生成商品二维码 */ public function createGoodsQRCode($param) { if (empty($param['goodsid_array'])) { return callback(true); } // 生成商品二维码 require_once BASE_RESOURCE_PATH . DS . 'phpqrcode' . DS . 'index.php'; $PhpQRCode = new PhpQRCode(); $PhpQRCode->set('pngTempDir', BASE_UPLOAD_PATH . DS . ATTACH_STORE . DS . $param['store_id'] . DS); foreach ($param['goodsid_array'] as $goods_id) { // 生成商品二维码 $PhpQRCode->set('date', urlShop('goods', 'index', array('goods_id' => $goods_id))); $PhpQRCode->set('pngTempName', $goods_id . '.png'); $PhpQRCode->init(); } return callback(true); }
/** * 保存商品(商品发布第二步使用) */ public function save_goodsOp() { if (chksubmit()) { // 验证表单 $obj_validate = new Validate(); $obj_validate->validateparam = array(array("input" => $_POST["g_name"], "require" => "true", "message" => L('store_goods_index_goods_name_null')), array("input" => $_POST["g_price"], "require" => "true", "validator" => "Double", "message" => L('store_goods_index_goods_price_null'))); $error = $obj_validate->validate(); if ($error != '') { showMessage(L('error') . $error, urlShop('seller_center'), 'html', 'error'); } $model_goods = Model('goods'); $model_type = Model('type'); // 分类信息 $goods_class = Model('goods_class')->getGoodsClassLineForTag(intval($_POST['cate_id'])); $common_array = array(); $common_array['goods_name'] = $_POST['g_name']; $common_array['goods_jingle'] = $_POST['g_jingle']; $common_array['gc_id'] = intval($_POST['cate_id']); $common_array['gc_id_1'] = intval($goods_class['gc_id_1']); $common_array['gc_id_2'] = intval($goods_class['gc_id_2']); $common_array['gc_id_3'] = intval($goods_class['gc_id_3']); $common_array['gc_name'] = $_POST['cate_name']; $common_array['brand_id'] = $_POST['b_id']; $common_array['brand_name'] = $_POST['b_name']; $common_array['type_id'] = intval($_POST['type_id']); $common_array['goods_image'] = $_POST['image_path']; $common_array['goods_price'] = floatval($_POST['g_price']); $common_array['goods_marketprice'] = floatval($_POST['g_marketprice']); $common_array['goods_costprice'] = floatval($_POST['g_costprice']); $common_array['goods_discount'] = floatval($_POST['g_discount']); $common_array['goods_serial'] = $_POST['g_serial']; $common_array['goods_storage_alarm'] = intval($_POST['g_alarm']); $common_array['goods_attr'] = serialize($_POST['attr']); $common_array['goods_body'] = $_POST['g_body']; // 序列化保存手机端商品描述数据 if ($_POST['m_body'] != '') { $_POST['m_body'] = str_replace('"', '"', $_POST['m_body']); $_POST['m_body'] = json_decode($_POST['m_body'], true); if (!empty($_POST['m_body'])) { $_POST['m_body'] = serialize($_POST['m_body']); } else { $_POST['m_body'] = ''; } } $common_array['mobile_body'] = $_POST['m_body']; $common_array['goods_commend'] = intval($_POST['g_commend']); $common_array['goods_state'] = $this->store_info['store_state'] != 1 ? 0 : intval($_POST['g_state']); // 店铺关闭时,商品下架 $common_array['goods_addtime'] = TIMESTAMP; $common_array['goods_selltime'] = strtotime($_POST['starttime']) + intval($_POST['starttime_H']) * 3600 + intval($_POST['starttime_i']) * 60; $common_array['goods_verify'] = C('goods_verify') == 1 ? 10 : 1; $common_array['store_id'] = $_SESSION['store_id']; $common_array['store_name'] = $_SESSION['store_name']; $common_array['spec_name'] = is_array($_POST['spec']) ? serialize($_POST['sp_name']) : serialize(null); $common_array['spec_value'] = is_array($_POST['spec']) ? serialize($_POST['sp_val']) : serialize(null); $common_array['goods_vat'] = intval($_POST['g_vat']); $common_array['areaid_1'] = intval($_POST['province_id']); $common_array['areaid_2'] = intval($_POST['city_id']); $common_array['transport_id'] = $_POST['freight'] == '0' ? '0' : intval($_POST['transport_id']); // 运费模板 $common_array['transport_title'] = $_POST['transport_title']; $common_array['goods_freight'] = floatval($_POST['g_freight']); //查询店铺商品分类 $goods_stcids_arr = array(); if (!empty($_POST['sgcate_id'])) { $sgcate_id_arr = array(); foreach ($_POST['sgcate_id'] as $k => $v) { $sgcate_id_arr[] = intval($v); } $sgcate_id_arr = array_unique($sgcate_id_arr); $store_goods_class = Model('store_goods_class')->getStoreGoodsClassList(array('store_id' => $_SESSION['store_id'], 'stc_id' => array('in', $sgcate_id_arr), 'stc_state' => '1')); if (!empty($store_goods_class)) { foreach ($store_goods_class as $k => $v) { if ($v['stc_id'] > 0) { $goods_stcids_arr[] = $v['stc_id']; } if ($v['stc_parent_id'] > 0) { $goods_stcids_arr[] = $v['stc_parent_id']; } } $goods_stcids_arr = array_unique($goods_stcids_arr); sort($goods_stcids_arr); } } if (empty($goods_stcids_arr)) { $common_array['goods_stcids'] = ''; } else { $common_array['goods_stcids'] = ',' . implode(',', $goods_stcids_arr) . ','; // 首尾需要加, } $common_array['plateid_top'] = intval($_POST['plate_top']) > 0 ? intval($_POST['plate_top']) : ''; $common_array['plateid_bottom'] = intval($_POST['plate_bottom']) > 0 ? intval($_POST['plate_bottom']) : ''; $common_array['is_virtual'] = intval($_POST['is_gv']); $common_array['virtual_indate'] = $_POST['g_vindate'] != '' ? strtotime($_POST['g_vindate']) + 24 * 60 * 60 - 1 : 0; // 当天的最后一秒结束 $common_array['virtual_limit'] = intval($_POST['g_vlimit']) > 10 || intval($_POST['g_vlimit']) < 0 ? 10 : intval($_POST['g_vlimit']); $common_array['virtual_invalid_refund'] = intval($_POST['g_vinvalidrefund']); $common_array['is_fcode'] = intval($_POST['is_fc']); $common_array['is_appoint'] = intval($_POST['is_appoint']); // 只有库存为零的商品可以预约 $common_array['appoint_satedate'] = $common_array['is_appoint'] == 1 ? strtotime($_POST['g_saledate']) : ''; // 预约商品的销售时间 $common_array['is_presell'] = $common_array['goods_state'] == 1 ? intval($_POST['is_presell']) : 0; // 只有出售中的商品可以预售 $common_array['presell_deliverdate'] = $common_array['is_presell'] == 1 ? strtotime($_POST['g_deliverdate']) : ''; // 预售商品的发货时间 $common_array['is_own_shop'] = in_array($_SESSION['store_id'], model('store')->getOwnShopIds()) ? 1 : 0; // 保存数据 $common_id = $model_goods->addGoodsCommon($common_array); if ($common_id) { // 生成的商品id(SKU) $goodsid_array = array(); require_once BASE_RESOURCE_PATH . DS . 'phpqrcode' . DS . 'index.php'; $PhpQRCode = new PhpQRCode(); $PhpQRCode->set('pngTempDir', BASE_UPLOAD_PATH . DS . ATTACH_STORE . DS . $_SESSION['store_id'] . DS); // 商品规格 if (is_array($_POST['spec'])) { foreach ($_POST['spec'] as $value) { $goods = array(); $goods['goods_commonid'] = $common_id; $goods['goods_name'] = $common_array['goods_name'] . ' ' . implode(' ', $value['sp_value']); $goods['goods_jingle'] = $common_array['goods_jingle']; $goods['store_id'] = $common_array['store_id']; $goods['store_name'] = $_SESSION['store_name']; $goods['gc_id'] = $common_array['gc_id']; $goods['gc_id_1'] = $common_array['gc_id_1']; $goods['gc_id_2'] = $common_array['gc_id_2']; $goods['gc_id_3'] = $common_array['gc_id_3']; $goods['brand_id'] = $common_array['brand_id']; $goods['goods_price'] = $value['price']; $goods['goods_promotion_price'] = $value['price']; $goods['goods_marketprice'] = $value['marketprice'] == 0 ? $common_array['goods_marketprice'] : $value['marketprice']; $goods['goods_serial'] = $value['sku']; $goods['goods_storage_alarm'] = intval($value['alarm']); $goods['goods_spec'] = serialize($value['sp_value']); $goods['goods_storage'] = $value['stock']; $goods['goods_image'] = $common_array['goods_image']; $goods['goods_state'] = $common_array['goods_state']; $goods['goods_verify'] = $common_array['goods_verify']; $goods['goods_addtime'] = TIMESTAMP; $goods['goods_edittime'] = TIMESTAMP; $goods['areaid_1'] = $common_array['areaid_1']; $goods['areaid_2'] = $common_array['areaid_2']; $goods['color_id'] = intval($value['color']); $goods['transport_id'] = $common_array['transport_id']; $goods['goods_freight'] = $common_array['goods_freight']; $goods['goods_vat'] = $common_array['goods_vat']; $goods['goods_commend'] = $common_array['goods_commend']; $goods['goods_stcids'] = $common_array['goods_stcids']; $goods['is_virtual'] = $common_array['is_virtual']; $goods['virtual_indate'] = $common_array['virtual_indate']; $goods['virtual_limit'] = $common_array['virtual_limit']; $goods['virtual_invalid_refund'] = $common_array['virtual_invalid_refund']; $goods['is_fcode'] = $common_array['is_fcode']; $goods['is_appoint'] = $common_array['is_appoint']; $goods['is_presell'] = $common_array['is_presell']; $goods['is_own_shop'] = $common_array['is_own_shop']; $goods_id = $model_goods->addGoods($goods); $model_type->addGoodsType($goods_id, $common_id, array('cate_id' => $_POST['cate_id'], 'type_id' => $_POST['type_id'], 'attr' => $_POST['attr'])); $goodsid_array[] = $goods_id; // 生成商品二维码 $PhpQRCode->set('date', WAP_SITE_URL . '/tmpl/product_detail.html?goods_id=' . $goods_id); $PhpQRCode->set('pngTempName', $goods_id . '.png'); $PhpQRCode->init(); } } else { $goods = array(); $goods['goods_commonid'] = $common_id; $goods['goods_name'] = $common_array['goods_name']; $goods['goods_jingle'] = $common_array['goods_jingle']; $goods['store_id'] = $common_array['store_id']; $goods['store_name'] = $_SESSION['store_name']; $goods['gc_id'] = $common_array['gc_id']; $goods['gc_id_1'] = $common_array['gc_id_1']; $goods['gc_id_2'] = $common_array['gc_id_2']; $goods['gc_id_3'] = $common_array['gc_id_3']; $goods['brand_id'] = $common_array['brand_id']; $goods['goods_price'] = $common_array['goods_price']; $goods['goods_promotion_price'] = $common_array['goods_price']; $goods['goods_marketprice'] = $common_array['goods_marketprice']; $goods['goods_serial'] = $common_array['goods_serial']; $goods['goods_storage_alarm'] = $common_array['goods_storage_alarm']; $goods['goods_spec'] = serialize(null); $goods['goods_storage'] = intval($_POST['g_storage']); $goods['goods_image'] = $common_array['goods_image']; $goods['goods_state'] = $common_array['goods_state']; $goods['goods_verify'] = $common_array['goods_verify']; $goods['goods_addtime'] = TIMESTAMP; $goods['goods_edittime'] = TIMESTAMP; $goods['areaid_1'] = $common_array['areaid_1']; $goods['areaid_2'] = $common_array['areaid_2']; $goods['color_id'] = 0; $goods['transport_id'] = $common_array['transport_id']; $goods['goods_freight'] = $common_array['goods_freight']; $goods['goods_vat'] = $common_array['goods_vat']; $goods['goods_commend'] = $common_array['goods_commend']; $goods['goods_stcids'] = $common_array['goods_stcids']; $goods['is_virtual'] = $common_array['is_virtual']; $goods['virtual_indate'] = $common_array['virtual_indate']; $goods['virtual_limit'] = $common_array['virtual_limit']; $goods['virtual_invalid_refund'] = $common_array['virtual_invalid_refund']; $goods['is_fcode'] = $common_array['is_fcode']; $goods['is_appoint'] = $common_array['is_appoint']; $goods['is_presell'] = $common_array['is_presell']; $goods['is_own_shop'] = $common_array['is_own_shop']; $goods_id = $model_goods->addGoods($goods); $model_type->addGoodsType($goods_id, $common_id, array('cate_id' => $_POST['cate_id'], 'type_id' => $_POST['type_id'], 'attr' => $_POST['attr'])); $goodsid_array[] = $goods_id; } // 生成商品二维码 if (!empty($goodsid_array)) { //QueueClient::push('createGoodsQRCode', array('store_id' => $_SESSION['store_id'], 'goodsid_array' => $goodsid_array)); $PhpQRCode->set('date', WAP_SITE_URL . '/tmpl/product_detail.html?goods_id=' . $goods_id); $PhpQRCode->set('pngTempName', $goods_id . '.png'); $PhpQRCode->init(); } // 商品加入上架队列 if (isset($_POST['starttime'])) { $selltime = strtotime($_POST['starttime']) + intval($_POST['starttime_H']) * 3600 + intval($_POST['starttime_i']) * 60; if ($selltime > TIMESTAMP) { $this->addcron(array('exetime' => $selltime, 'exeid' => $common_id, 'type' => 1), true); } } // 记录日志 $this->recordSellerLog('添加商品,平台货号:' . $common_id); // 生成F码 if ($common_array['is_fcode'] == 1) { QueueClient::push('createGoodsFCode', array('goods_commonid' => $common_id, 'fc_count' => intval($_POST['g_fccount']), 'fc_prefix' => $_POST['g_fcprefix'])); } redirect(urlShop('store_goods_add', 'add_step_three', array('commonid' => $common_id))); } else { showMessage(L('store_goods_index_goods_add_fail'), getReferer(), 'html', 'error'); } } }
/** * 保存店铺信息 * * @param * @return */ public function saveOp() { if ($_SESSION['store_id'] != '') { showDialog(Language::get('store_create_created'), 'index.php?act=member_snsindex', 'error'); } /** * 实例化店铺等级模型 */ // $model_grade = Model('store_grade'); // $store_grade = $model_grade->getOneGrade(intval($_POST['grade_id'])); $store_grade = ($setting = F('store_grade')) ? $setting : H('store_grade', true, 'file'); $store_grade = $store_grade[intval($_POST['grade_id'])]; if (empty($store_grade)) { showDialog(Language::get('store_create_grade_not_exists'), '', 'error'); } /** * 实例化店铺模型 */ $model_store = Model('store'); /** * 保存店铺信息 */ if (chksubmit()) { //判断是否有重名店铺 $_GET['store_name'] = $_POST["store_name"]; if (!$this->checknameinner()) { showDialog(Language::get('store_create_store_name_exists'), '', 'error'); } $obj_validate = new Validate(); $obj_validate->validateparam = array(array("input" => $_POST["store_name"], "require" => "true", "message" => Language::get('store_save_store_name_null')), array("input" => $_POST["sc_id"], "require" => "true", "validator" => "Number", "message" => Language::get('store_save_store_class_null')), array("input" => $_POST["area_id"], "require" => "true", "validator" => "Number", "message" => Language::get('store_save_area_null'))); $error = $obj_validate->validate(); if ($error != '') { showDialog(Language::get('error') . $error, '', 'error'); } $shop_array = array(); $shop_array['grade_id'] = $_POST['grade_id']; $shop_array['store_owner_card'] = $_POST['store_owner_card']; $shop_array['store_name'] = $_POST['store_name']; $shop_array['sc_id'] = $_POST['sc_id']; $shop_array['area_id'] = $_POST['area_id']; $shop_array['area_info'] = $_POST['area_info']; $shop_array['store_address'] = $_POST['store_address']; $shop_array['store_zip'] = $_POST['store_zip']; $shop_array['store_tel'] = $_POST['store_tel']; $shop_array['store_zy'] = $_POST['store_zy']; $shop_array['store_state'] = $store_grade['sg_confirm'] == 1 ? 2 : 1; $upload = new UploadFile(); $upload->set('default_dir', ATTACH_AUTH); if ($_FILES['image']['name'] != '') { $result = $upload->upfile('image'); if ($result) { $shop_array['store_image'] = $upload->file_name; $shop_array['name_auth'] = '2'; $upload->file_name = ''; } else { showdialog($upload->error, '', 'error'); } } if ($_FILES['image1']['name'] != '') { $result1 = $upload->upfile('image1'); if ($result1) { $shop_array['store_image1'] = $upload->file_name; $shop_array['store_auth'] = '2'; } else { showdialog($upload->error, '', 'error'); } } $state = $model_store->createStore($shop_array); if ($state) { $_SESSION['is_seller'] = 1; $_SESSION['store_id'] = $state; $_SESSION['store_name'] = $shop_array['store_name']; $_SESSION['grade_id'] = $shop_array['grade_id']; // 生成店铺二维码 require_once BasePath . DS . 'resource' . DS . 'phpqrcode' . DS . 'index.php'; $PhpQRCode = new PhpQRCode(); $PhpQRCode->set('date', SiteUrl . DS . ncUrl(array('act' => 'show_store', 'id' => $state), 'store')); $PhpQRCode->set('pngTempDir', ATTACH_STORE . DS); $model_store->storeUpdate(array('store_code' => $PhpQRCode->init(), 'store_id' => $state)); // 添加相册默认 $album_model = Model('album'); $album_arr = array(); $album_arr['aclass_name'] = Language::get('store_save_defaultalbumclass_name'); $album_arr['store_id'] = $state; $album_arr['aclass_des'] = ''; $album_arr['aclass_sort'] = '255'; $album_arr['aclass_cover'] = ''; $album_arr['upload_time'] = time(); $album_arr['is_default'] = '1'; $album_model->addClass($album_arr); $model = Model(); //插入店铺扩展表 $model->table('store_extend')->insert(array('store_id' => $state)); $msg = Language::get('store_save_create_success') . ($store_grade['sg_confirm'] == 1 ? Language::get('store_save_waiting_for_review') : ''); showDialog($msg, 'index.php?act=store', 'succ'); } else { showDialog(Language::get('store_save_create_fail'), '', 'error'); } } }
/** * 卖家店铺设置 * * @param string * @param string * @return */ public function store_settingOp() { /** * 实例化模型 */ $model_class = Model('store'); /** * 获取设置 */ // $setting_config = $GLOBALS['setting_config']; $config_subdomain_edit = C('subdomain_edit'); $config_subdomain_times = C('subdomain_times'); $config_subdomain_length = C('subdomain_length'); $config_subdomain_reserved = C('subdomain_reserved'); $config_enabled_subdomain = C('enabled_subdomain'); $store_id = $_SESSION['store_id']; //当前店铺ID /** * 获取店铺信息 */ $store_info = $model_class->getStoreInfoByID($store_id); $subdomain_edit = intval($config_subdomain_edit); //二级域名是否可修改 $subdomain_times = intval($config_subdomain_times); //系统设置二级域名可修改次数 $store_domain_times = intval($store_info['store_domain_times']); //店铺已修改次数 $subdomain_length = explode('-', $config_subdomain_length); $subdomain_length[0] = intval($subdomain_length[0]); $subdomain_length[1] = intval($subdomain_length[1]); if ($subdomain_length[0] < 1 || $subdomain_length[0] >= $subdomain_length[1]) { //域名长度 $subdomain_length[0] = 3; $subdomain_length[1] = 12; } Tpl::output('subdomain_length', $subdomain_length); /** * 保存店铺设置 */ if (chksubmit()) { $_POST['store_domain'] = trim($_POST['store_domain']); $store_domain = strtolower($_POST['store_domain']); //判断是否设置二级域名 if (!empty($store_domain) && $store_domain != $store_info['store_domain']) { $store_domain_count = strlen($store_domain); if ($store_domain_count < $subdomain_length[0] || $store_domain_count > $subdomain_length[1]) { showDialog(Language::get('store_setting_wrong_uri') . ': ' . $config_subdomain_length, 'reload', 'error'); } if (!preg_match('/^[\\w-]+$/i', $store_domain)) { //判断域名是否正确 showDialog(Language::get('store_setting_lack_uri')); } $store = $model_class->getStoreInfo(array('store_domain' => $store_domain)); //二级域名存在,则提示错误 if (!empty($store) && $store_id != $store['store_id']) { showDialog(Language::get('store_setting_exists_uri'), 'reload', 'error'); } //判断二级域名是否为系统禁止 $subdomain_reserved = @explode(',', $config_subdomain_reserved); if (!empty($subdomain_reserved) && is_array($subdomain_reserved)) { if (in_array($store_domain, $subdomain_reserved)) { showDialog(Language::get('store_setting_invalid_uri')); } } if ($subdomain_times > $store_domain_times) { //可继续修改 $param = array(); $param['store_domain'] = $store_domain; if (!empty($store_info['store_domain'])) { $param['store_domain_times'] = $store_domain_times + 1; } //第一次保存不计数 $model_class->editStore($param, array('store_id' => $store_id)); } $_POST['store_domain'] = ''; //避免重复更新 } $upload = new UploadFile(); /** * 上传店铺图片 */ if (!empty($_FILES['store_banner']['name'])) { $upload->set('default_dir', ATTACH_STORE); $upload->set('thumb_ext', ''); $upload->set('file_name', ''); $upload->set('ifremove', false); $result = $upload->upfile('store_banner'); if ($result) { $_POST['store_banner'] = $upload->file_name; } else { showDialog($upload->error); } } //删除旧店铺图片 if (!empty($_POST['store_banner']) && !empty($store_info['store_banner'])) { @unlink(BASE_UPLOAD_PATH . DS . ATTACH_STORE . DS . $store_info['store_banner']); } /** * 上传店铺图片 */ if (!empty($_FILES['store_label']['name'])) { $upload->set('default_dir', ATTACH_STORE); $upload->set('thumb_ext', ''); $upload->set('file_name', ''); $upload->set('ifremove', false); $result = $upload->upfile('store_label'); if ($result) { $_POST['store_label'] = $upload->file_name; } else { showDialog($upload->error); } } //删除旧店铺图片 if (!empty($_POST['store_label']) && !empty($store_info['store_label'])) { @unlink(BASE_UPLOAD_PATH . DS . ATTACH_STORE . DS . $store_info['store_label']); } //删除旧店铺图片 if (!empty($_POST['store_logo']) && !empty($store_info['store_logo'])) { @unlink(BASE_UPLOAD_PATH . DS . ATTACH_STORE . DS . $store_info['store_logo']); } /** * 更新入库 */ $param = array('store_label' => empty($_POST['store_label']) ? $store_info['store_label'] : $_POST['store_label'], 'store_banner' => empty($_POST['store_banner']) ? $store_info['store_banner'] : $_POST['store_banner'], 'store_avatar' => empty($_POST['store_avatar']) ? $store_info['store_avatar'] : $_POST['store_avatar'], 'store_qq' => $_POST['store_qq'], 'store_ww' => $_POST['store_ww'], 'store_phone' => $_POST['store_phone'], 'store_zy' => $_POST['store_zy'], 'store_keywords' => $_POST['seo_keywords'], 'store_description' => $_POST['seo_description']); if (!empty($_POST['store_theme'])) { $param['store_theme'] = $_POST['store_theme']; } //修改店铺名称 $store_name = $_POST['store_name']; if (!empty($_POST['store_name'])) { $store = $model_class->getStoreInfo(array('store_name' => $store_name)); //店铺名存在,则提示错误 if (!empty($store) && $store_id != $store['store_id']) { showDialog('此店铺名称已被其它人使用,请换其它名称。', 'reload', 'error'); return; } $param['store_name'] = $_POST['store_name']; } //如果店铺名称修改了zmr>v60 if ($store_name != $store_info['store_name'] && !empty($_POST['store_name'])) { $where = array(); $where['store_id'] = $store_id; $update = array(); $update['store_name'] = $store_name; $bllGoods = Model()->table('goods_common')->where($where)->update($update); $bllGoods = Model()->table('goods')->where($where)->update($update); } //zmr<v60 //zmr>>> //生成店铺二维码 require_once BASE_RESOURCE_PATH . DS . 'phpqrcode' . DS . 'index.php'; $PhpQRCode = new PhpQRCode(); $PhpQRCode->set('pngTempDir', BASE_UPLOAD_PATH . DS . ATTACH_STORE . DS . $store_id . DS); $PhpQRCode->set('date', WAP_SITE_URL . '/tmpl/go_store.html?store_id=' . $store_id); $PhpQRCode->set('pngTempName', $store_id . '_store.png'); $PhpQRCode->init(); //zmr<<< $model_class->editStore($param, array('store_id' => $store_id)); showDialog(Language::get('nc_common_save_succ'), 'index.php?act=store_setting&op=store_setting', 'succ'); } /** * 实例化店铺等级模型 */ // $model_store_grade = Model('store_grade'); // $store_grade = $model_store_grade->getOneGrade($store_info['grade_id']); // 从基类中读取店铺等级信息 $store_grade = $this->store_grade; //编辑器多媒体功能 $editor_multimedia = false; $sg_fun = @explode('|', $store_grade['sg_function']); if (!empty($sg_fun) && is_array($sg_fun)) { foreach ($sg_fun as $fun) { if ($fun == 'editor_multimedia') { $editor_multimedia = true; } } } Tpl::output('editor_multimedia', $editor_multimedia); if ($subdomain_edit == 1 && $subdomain_times > $store_domain_times) { //可继续修改二级域名 Tpl::output('subdomain_edit', $subdomain_edit); } /** * 输出店铺信息 */ self::profile_menu('store_setting'); Tpl::output('store_info', $store_info); Tpl::output('store_grade', $store_grade); Tpl::output('subdomain', $config_enabled_subdomain); Tpl::output('subdomain_times', $config_subdomain_times); /** * 页面输出 */ Tpl::showpage('store_setting_form'); }
/** * 新增店铺 */ public function store_addOp() { /** * 读取语言包 */ $lang = Language::getLangContent(); $model_store = Model('store'); if (chksubmit()) { /** * 添加第一步 验证会员是否存在 */ if ($_POST['step'] == 'one') { /** * 验证 */ $obj_validate = new Validate(); $obj_validate->setValidate(array("input" => $_POST["member_name"], "require" => "true", "message" => $lang['user_name_no_null'])); if ($_POST['need_password'] == 1) { $obj_validate->setValidate(array("input" => $_POST["member_passwd"], "require" => "true", "message" => $lang['pwd_no_null'])); } $error = $obj_validate->validate(); if ($error != '') { showMessage($error); } else { $model_member = Model('member'); $condition['member_name'] = trim($_POST['member_name']); $member_array = $model_member->infoMember($condition); /** * 判断该会员是否已经拥有店铺 */ if ($member_array['store_id'] > 0) { showMessage($lang['user_open_store']); } if (empty($member_array)) { showMessage($lang['user_no_exist']); } if ($_POST['need_password'] == 1) { if ($member_array['member_passwd'] !== md5($_POST['member_passwd'])) { showMessage($lang['pwd_fail']); } } /** * 店铺等级 */ $model_grade = Model('store_grade'); $grade_list = $model_grade->getGradeList($condition); /** * 店铺分类 */ $model_store_class = Model('store_class'); $parent_list = $model_store_class->getTreeClassList(2); if (is_array($parent_list)) { foreach ($parent_list as $k => $v) { $parent_list[$k]['sc_name'] = str_repeat(" ", $v['deep'] * 2) . $v['sc_name']; } } Tpl::output('class_list', $parent_list); Tpl::output('grade_list', $grade_list); Tpl::output('member_array', $member_array); Tpl::showpage('store.add_two'); } } /** * 添加第二步 添加 */ if ($_POST['step'] == 'two') { /** * 验证 */ $obj_validate = new Validate(); $obj_validate->validateparam = array(array("input" => $_POST["store_name"], "require" => "true", "message" => $lang['please_input_store_name_p'])); $error = $obj_validate->validate(); if ($error != '') { showMessage($error); } else { /** * 取店铺等级的审核 */ $model_grade = Model('store_grade'); $grade_array = $model_grade->getOneGrade(intval($_POST['grade_id'])); if (empty($grade_array)) { showMessage($lang['please_input_store_level']); } /** * 结束时间 */ if (trim($_POST['end_time']) != '') { $time = strtotime($_POST['end_time']); } $insert_array = array(); $insert_array['member_name'] = trim($_POST['member_name']); $insert_array['member_id'] = intval($_POST['member_id']); $insert_array['store_owner_card'] = trim($_POST['store_owner_card']); $insert_array['store_name'] = trim($_POST['store_name']); $insert_array['sc_id'] = intval($_POST['sc_id']); $insert_array['area_id'] = intval($_POST['area_id']); $insert_array['area_info'] = trim($_POST['area_info']); $insert_array['store_address'] = trim($_POST['store_address']); $insert_array['store_zip'] = trim($_POST['store_zip']); $insert_array['store_tel'] = trim($_POST['store_tel']); $insert_array['grade_id'] = intval($_POST['grade_id']); $insert_array['store_end_time'] = $time; $insert_array['store_time'] = time(); $insert_array['store_state'] = trim($_POST['store_state']); if ($_POST['store_state'] == '0') { $insert_array['store_close_info'] = $_POST['store_close_info']; $insert_array['store_recommend'] = 0; } else { $insert_array['store_recommend'] = trim($_POST['store_recommend']); } $insert_array['name_auth'] = trim($_POST['name_auth']); $insert_array['store_auth'] = trim($_POST['store_auth']); $insert_array['store_sort'] = intval($_POST['store_sort']); $store_info = $model_store->shopStore(array('store_name' => $insert_array['store_name'])); if ($store_info['store_id'] > 0) { //检查店铺名称是否存在 showMessage($lang['store_name_exists']); } $result = $model_store->add($insert_array); if ($result) { /** * 更新会员表 store_id 字段 */ $model_member = Model('member'); $update_array = array(); $update_array['store_id'] = $result; $model_member->updateMember($update_array, intval($_POST['member_id'])); // 生成店铺二维码 require_once BasePath . DS . 'resource' . DS . 'phpqrcode' . DS . 'index.php'; $PhpQRCode = new PhpQRCode(); $PhpQRCode->set('date', SiteUrl . DS . ncUrl(array('act' => 'show_store', 'id' => $result), 'store')); $PhpQRCode->set('pngTempDir', BasePath . DS . ATTACH_STORE . DS); $model_store->storeUpdate(array('store_code' => $PhpQRCode->init(), 'store_id' => $result)); // 添加相册默认 $album_model = Model('album'); $album_arr = array(); $album_arr['aclass_name'] = Language::get('store_save_defaultalbumclass_name'); $album_arr['store_id'] = $result; $album_arr['aclass_des'] = ''; $album_arr['aclass_sort'] = '255'; $album_arr['aclass_cover'] = ''; $album_arr['upload_time'] = time(); $album_arr['is_default'] = '1'; $album_model->addClass($album_arr); $url = array(array('url' => 'index.php?act=store&op=store', 'msg' => $lang['back_store_list']), array('url' => 'index.php?act=store&op=store_add', 'msg' => $lang['countinue_add_store'])); showMessage($lang['add_store_ok'], $url); } else { showMessage($lang['add_fail_fail']); } } } } Tpl::showpage('store.add_one'); }
/** * 编辑商品保存 */ public function edit_save_goodsOp() { $common_id = intval($_POST['commonid']); if (!chksubmit() || $common_id <= 0) { showDialog(L('store_goods_index_goods_edit_fail'), urlShop('store_goods_online', 'index')); } // 验证表单 $obj_validate = new Validate(); $obj_validate->validateparam = array(array("input" => $_POST["g_name"], "require" => "true", "message" => L('store_goods_index_goods_name_null')), array("input" => $_POST["g_price"], "require" => "true", "validator" => "Double", "message" => L('store_goods_index_goods_price_null'))); $error = $obj_validate->validate(); if ($error != '') { showDialog(L('error') . $error, urlShop('store_goods_online', 'index')); } $gc_id = intval($_POST['cate_id']); // 验证商品分类是否存在且商品分类是否为最后一级 $data = Model('goods_class')->getGoodsClassForCacheModel(); if (!isset($data[$gc_id]) || isset($data[$gc_id]['child']) || isset($data[$gc_id]['childchild'])) { showDialog(L('store_goods_index_again_choose_category1')); } // 三方店铺验证是否绑定了该分类 if (!checkPlatformStore()) { //商品分类 by shopjl. com 提供批量显示所有分类插件 $model_bind_class = Model('store_bind_class'); $goods_class = Model('goods_class')->getGoodsClassForCacheModel(); $where['store_id'] = $_SESSION['store_id']; $class_2 = $goods_class[$gc_id]['gc_parent_id']; $class_1 = $goods_class[$class_2]['gc_parent_id']; $where['class_1'] = $class_1; $where['class_2'] = $class_2; $where['class_3'] = $gc_id; $bind_info = $model_bind_class->getStoreBindClassInfo($where); if (empty($bind_info)) { $where['class_3'] = 0; $bind_info = $model_bind_class->getStoreBindClassInfo($where); if (empty($bind_info)) { $where['class_2'] = 0; $where['class_3'] = 0; $bind_info = $model_bind_class->getStoreBindClassInfo($where); if (empty($bind_info)) { $where['class_1'] = 0; $where['class_2'] = 0; $where['class_3'] = 0; $bind_info = $model_bind_class->getStoreBindClassInfo($where); if (empty($bind_info)) { showDialog(L('store_goods_index_again_choose_category2')); } } } } } // 分类信息 $goods_class = Model('goods_class')->getGoodsClassLineForTag(intval($_POST['cate_id'])); $model_goods = Model('goods'); $update_common = array(); $update_common['goods_name'] = $_POST['g_name']; $update_common['goods_jingle'] = $_POST['g_jingle']; $update_common['gc_id'] = $gc_id; $update_common['gc_id_1'] = intval($goods_class['gc_id_1']); $update_common['gc_id_2'] = intval($goods_class['gc_id_2']); $update_common['gc_id_3'] = intval($goods_class['gc_id_3']); $update_common['gc_name'] = $_POST['cate_name']; $update_common['brand_id'] = $_POST['b_id']; $update_common['brand_name'] = $_POST['b_name']; $update_common['type_id'] = intval($_POST['type_id']); $update_common['goods_image'] = $_POST['image_path']; $update_common['goods_price'] = floatval($_POST['g_price']); $update_common['goods_marketprice'] = floatval($_POST['g_marketprice']); $update_common['goods_costprice'] = floatval($_POST['g_costprice']); $update_common['goods_discount'] = floatval($_POST['g_discount']); $update_common['goods_serial'] = $_POST['g_serial']; $update_common['goods_storage_alarm'] = intval($_POST['g_alarm']); $update_common['goods_attr'] = serialize($_POST['attr']); $update_common['goods_body'] = $_POST['g_body']; // 序列化保存手机端商品描述数据 if ($_POST['m_body'] != '') { $_POST['m_body'] = str_replace('"', '"', $_POST['m_body']); $_POST['m_body'] = json_decode($_POST['m_body'], true); if (!empty($_POST['m_body'])) { $_POST['m_body'] = serialize($_POST['m_body']); } else { $_POST['m_body'] = ''; } } $update_common['mobile_body'] = $_POST['m_body']; $update_common['goods_commend'] = intval($_POST['g_commend']); $update_common['goods_state'] = $this->store_info['store_state'] != 1 ? 0 : intval($_POST['g_state']); // 店铺关闭时,商品下架 $update_common['goods_selltime'] = strtotime($_POST['starttime']) + intval($_POST['starttime_H']) * 3600 + intval($_POST['starttime_i']) * 60; $update_common['goods_verify'] = C('goods_verify') == 1 ? 10 : 1; $update_common['spec_name'] = is_array($_POST['spec']) ? serialize($_POST['sp_name']) : serialize(null); $update_common['spec_value'] = is_array($_POST['spec']) ? serialize($_POST['sp_val']) : serialize(null); $update_common['goods_vat'] = intval($_POST['g_vat']); $update_common['areaid_1'] = intval($_POST['province_id']); $update_common['areaid_2'] = intval($_POST['city_id']); $update_common['transport_id'] = $_POST['freight'] == '0' ? '0' : intval($_POST['transport_id']); // 运费模板 $update_common['transport_title'] = $_POST['transport_title']; $update_common['goods_freight'] = floatval($_POST['g_freight']); //查询店铺商品分类 $goods_stcids_arr = array(); if (!empty($_POST['sgcate_id'])) { $sgcate_id_arr = array(); foreach ($_POST['sgcate_id'] as $k => $v) { $sgcate_id_arr[] = intval($v); } $sgcate_id_arr = array_unique($sgcate_id_arr); $store_goods_class = Model('store_goods_class')->getStoreGoodsClassList(array('store_id' => $_SESSION['store_id'], 'stc_id' => array('in', $sgcate_id_arr), 'stc_state' => '1')); if (!empty($store_goods_class)) { foreach ($store_goods_class as $k => $v) { if ($v['stc_id'] > 0) { $goods_stcids_arr[] = $v['stc_id']; } if ($v['stc_parent_id'] > 0) { $goods_stcids_arr[] = $v['stc_parent_id']; } } $goods_stcids_arr = array_unique($goods_stcids_arr); sort($goods_stcids_arr); } } if (empty($goods_stcids_arr)) { $update_common['goods_stcids'] = ''; } else { $update_common['goods_stcids'] = ',' . implode(',', $goods_stcids_arr) . ','; } $update_common['plateid_top'] = intval($_POST['plate_top']) > 0 ? intval($_POST['plate_top']) : ''; $update_common['plateid_bottom'] = intval($_POST['plate_bottom']) > 0 ? intval($_POST['plate_bottom']) : ''; $update_common['is_virtual'] = intval($_POST['is_gv']); $update_common['virtual_indate'] = $_POST['g_vindate'] != '' ? strtotime($_POST['g_vindate']) + 24 * 60 * 60 - 1 : 0; // 当天的最后一秒结束 $update_common['virtual_limit'] = intval($_POST['g_vlimit']) > 10 || intval($_POST['g_vlimit']) < 0 ? 10 : intval($_POST['g_vlimit']); $update_common['virtual_invalid_refund'] = intval($_POST['g_vinvalidrefund']); $update_common['is_fcode'] = intval($_POST['is_fc']); $update_common['is_appoint'] = intval($_POST['is_appoint']); // 只有库存为零的商品可以预约 $update_common['appoint_satedate'] = $update_common['is_appoint'] == 1 ? strtotime($_POST['g_saledate']) : ''; // 预约商品的销售时间 $update_common['is_presell'] = $update_common['goods_state'] == 1 ? intval($_POST['is_presell']) : 0; // 只有出售中的商品可以预售 $update_common['presell_deliverdate'] = $update_common['is_presell'] == 1 ? strtotime($_POST['g_deliverdate']) : ''; // 预售商品的发货时间 $update_common['is_own_shop'] = in_array($_SESSION['store_id'], model('store')->getOwnShopIds()) ? 1 : 0; // 开始事务 Model()->beginTransaction(); $model_gift = Model('goods_gift'); // 清除原有规格数据 $model_type = Model('type'); $model_type->delGoodsAttr(array('goods_commonid' => $common_id)); // 生成商品二维码 require_once BASE_RESOURCE_PATH . DS . 'phpqrcode' . DS . 'index.php'; $PhpQRCode = new PhpQRCode(); $PhpQRCode->set('pngTempDir', BASE_UPLOAD_PATH . DS . ATTACH_STORE . DS . $_SESSION['store_id'] . DS); // 更新商品规格 $goodsid_array = array(); $colorid_array = array(); if (is_array($_POST['spec'])) { foreach ($_POST['spec'] as $value) { $goods_info = $model_goods->getGoodsInfo(array('goods_id' => $value['goods_id'], 'goods_commonid' => $common_id, 'store_id' => $_SESSION['store_id']), 'goods_id'); if (!empty($goods_info)) { $goods_id = $goods_info['goods_id']; $update = array(); $update['goods_commonid'] = $common_id; $update['goods_name'] = $update_common['goods_name'] . ' ' . implode(' ', $value['sp_value']); $update['goods_jingle'] = $update_common['goods_jingle']; $update['store_id'] = $_SESSION['store_id']; $update['store_name'] = $_SESSION['store_name']; $update['gc_id'] = $update_common['gc_id']; $update['gc_id_1'] = $update_common['gc_id_1']; $update['gc_id_2'] = $update_common['gc_id_2']; $update['gc_id_3'] = $update_common['gc_id_3']; $update['brand_id'] = $update_common['brand_id']; $update['goods_price'] = $value['price']; $update['goods_marketprice'] = $value['marketprice'] == 0 ? $update_common['goods_marketprice'] : $value['marketprice']; $update['goods_serial'] = $value['sku']; $update['goods_storage_alarm'] = intval($value['alarm']); $update['goods_spec'] = serialize($value['sp_value']); $update['goods_storage'] = $value['stock']; $update['goods_state'] = $update_common['goods_state']; $update['goods_verify'] = $update_common['goods_verify']; $update['goods_edittime'] = TIMESTAMP; $update['areaid_1'] = $update_common['areaid_1']; $update['areaid_2'] = $update_common['areaid_2']; $update['color_id'] = intval($value['color']); $update['transport_id'] = $update_common['transport_id']; $update['goods_freight'] = $update_common['goods_freight']; $update['goods_vat'] = $update_common['goods_vat']; $update['goods_commend'] = $update_common['goods_commend']; $update['goods_stcids'] = $update_common['goods_stcids']; $update['is_virtual'] = $update_common['is_virtual']; $update['virtual_indate'] = $update_common['virtual_indate']; $update['virtual_limit'] = $update_common['virtual_limit']; $update['virtual_invalid_refund'] = $update_common['virtual_invalid_refund']; $update['is_fcode'] = $update_common['is_fcode']; $update['is_appoint'] = $update_common['is_appoint']; $update['is_presell'] = $update_common['is_presell']; // 虚拟商品不能有赠品 if ($update_common['is_virtual'] == 1) { $update['have_gift'] = 0; $model_gift->delGoodsGift(array('goods_id' => $goods_id)); } $update['is_own_shop'] = $update_common['is_own_shop']; $model_goods->editGoodsById($update, $goods_id); // 生成商品二维码 $PhpQRCode->set('date', WAP_SITE_URL . '/tmpl/product_detail.html?goods_id=' . $goods_id); $PhpQRCode->set('pngTempName', $goods_id . '.png'); $PhpQRCode->init(); } else { $insert = array(); $insert['goods_commonid'] = $common_id; $insert['goods_name'] = $update_common['goods_name'] . ' ' . implode(' ', $value['sp_value']); $insert['goods_jingle'] = $update_common['goods_jingle']; $insert['store_id'] = $_SESSION['store_id']; $insert['store_name'] = $_SESSION['store_name']; $insert['gc_id'] = $update_common['gc_id']; $insert['gc_id_1'] = $update_common['gc_id_1']; $insert['gc_id_2'] = $update_common['gc_id_2']; $insert['gc_id_3'] = $update_common['gc_id_3']; $insert['brand_id'] = $update_common['brand_id']; $insert['goods_price'] = $value['price']; $insert['goods_promotion_price'] = $value['price']; $insert['goods_marketprice'] = $value['marketprice'] == 0 ? $update_common['goods_marketprice'] : $value['marketprice']; $insert['goods_serial'] = $value['sku']; $insert['goods_storage_alarm'] = intval($value['alarm']); $insert['goods_spec'] = serialize($value['sp_value']); $insert['goods_storage'] = $value['stock']; $insert['goods_image'] = $update_common['goods_image']; $insert['goods_state'] = $update_common['goods_state']; $insert['goods_verify'] = $update_common['goods_verify']; $insert['goods_addtime'] = TIMESTAMP; $insert['goods_edittime'] = TIMESTAMP; $insert['areaid_1'] = $update_common['areaid_1']; $insert['areaid_2'] = $update_common['areaid_2']; $insert['color_id'] = intval($value['color']); $insert['transport_id'] = $update_common['transport_id']; $insert['goods_freight'] = $update_common['goods_freight']; $insert['goods_vat'] = $update_common['goods_vat']; $insert['goods_commend'] = $update_common['goods_commend']; $insert['goods_stcids'] = $update_common['goods_stcids']; $insert['is_virtual'] = $update_common['is_virtual']; $insert['virtual_indate'] = $update_common['virtual_indate']; $insert['virtual_limit'] = $update_common['virtual_limit']; $insert['virtual_invalid_refund'] = $update_common['virtual_invalid_refund']; $insert['is_fcode'] = $update_common['is_fcode']; $insert['is_appoint'] = $update_common['is_appoint']; $insert['is_presell'] = $update_common['is_presell']; $insert['is_own_shop'] = $update_common['is_own_shop']; $goods_id = $model_goods->addGoods($insert); // 生成商品二维码 $PhpQRCode->set('date', WAP_SITE_URL . '/tmpl/product_detail.html?goods_id=' . $goods_id); $PhpQRCode->set('pngTempName', $goods_id . '.png'); $PhpQRCode->init(); } $goodsid_array[] = intval($goods_id); $colorid_array[] = intval($value['color']); $model_type->addGoodsType($goods_id, $common_id, array('cate_id' => $_POST['cate_id'], 'type_id' => $_POST['type_id'], 'attr' => $_POST['attr'])); } } else { $goods_info = $model_goods->getGoodsInfo(array('goods_spec' => serialize(null), 'goods_commonid' => $common_id, 'store_id' => $_SESSION['store_id']), 'goods_id'); if (!empty($goods_info)) { $goods_id = $goods_info['goods_id']; $update = array(); $update['goods_commonid'] = $common_id; $update['goods_name'] = $update_common['goods_name']; $update['goods_jingle'] = $update_common['goods_jingle']; $update['store_id'] = $_SESSION['store_id']; $update['store_name'] = $_SESSION['store_name']; $update['gc_id'] = $update_common['gc_id']; $update['gc_id_1'] = $update_common['gc_id_1']; $update['gc_id_2'] = $update_common['gc_id_2']; $update['gc_id_3'] = $update_common['gc_id_3']; $update['brand_id'] = $update_common['brand_id']; $update['goods_price'] = $update_common['goods_price']; $update['goods_marketprice'] = $update_common['goods_marketprice']; $update['goods_serial'] = $update_common['goods_serial']; $update['goods_storage_alarm'] = $update_common['goods_storage_alarm']; $update['goods_spec'] = serialize(null); $update['goods_storage'] = intval($_POST['g_storage']); $update['goods_state'] = $update_common['goods_state']; $update['goods_verify'] = $update_common['goods_verify']; $update['goods_edittime'] = TIMESTAMP; $update['areaid_1'] = $update_common['areaid_1']; $update['areaid_2'] = $update_common['areaid_2']; $update['color_id'] = 0; $update['transport_id'] = $update_common['transport_id']; $update['goods_freight'] = $update_common['goods_freight']; $update['goods_vat'] = $update_common['goods_vat']; $update['goods_commend'] = $update_common['goods_commend']; $update['goods_stcids'] = $update_common['goods_stcids']; $update['is_virtual'] = $update_common['is_virtual']; $update['virtual_indate'] = $update_common['virtual_indate']; $update['virtual_limit'] = $update_common['virtual_limit']; $update['virtual_invalid_refund'] = $update_common['virtual_invalid_refund']; $update['is_fcode'] = $update_common['is_fcode']; $update['is_appoint'] = $update_common['is_appoint']; $update['is_presell'] = $update_common['is_presell']; if ($update_common['is_virtual'] == 1) { $update['have_gift'] = 0; $model_gift->delGoodsGift(array('goods_id' => $goods_id)); } $update['is_own_shop'] = $update_common['is_own_shop']; $model_goods->editGoodsById($update, $goods_id); // 生成商品二维码 $PhpQRCode->set('date', WAP_SITE_URL . '/tmpl/product_detail.html?goods_id=' . $goods_id); $PhpQRCode->set('pngTempName', $goods_id . '.png'); $PhpQRCode->init(); } else { $insert = array(); $insert['goods_commonid'] = $common_id; $insert['goods_name'] = $update_common['goods_name']; $insert['goods_jingle'] = $update_common['goods_jingle']; $insert['store_id'] = $_SESSION['store_id']; $insert['store_name'] = $_SESSION['store_name']; $insert['gc_id'] = $update_common['gc_id']; $insert['gc_id_1'] = $update_common['gc_id_1']; $insert['gc_id_2'] = $update_common['gc_id_2']; $insert['gc_id_3'] = $update_common['gc_id_3']; $insert['brand_id'] = $update_common['brand_id']; $insert['goods_price'] = $update_common['goods_price']; $insert['goods_promotion_price'] = $update_common['goods_price']; $insert['goods_marketprice'] = $update_common['goods_marketprice']; $insert['goods_serial'] = $update_common['goods_serial']; $insert['goods_storage_alarm'] = $update_common['goods_storage_alarm']; $insert['goods_spec'] = serialize(null); $insert['goods_storage'] = intval($_POST['g_storage']); $insert['goods_image'] = $update_common['goods_image']; $insert['goods_state'] = $update_common['goods_state']; $insert['goods_verify'] = $update_common['goods_verify']; $insert['goods_addtime'] = TIMESTAMP; $insert['goods_edittime'] = TIMESTAMP; $insert['areaid_1'] = $update_common['areaid_1']; $insert['areaid_2'] = $update_common['areaid_2']; $insert['color_id'] = 0; $insert['transport_id'] = $update_common['transport_id']; $insert['goods_freight'] = $update_common['goods_freight']; $insert['goods_vat'] = $update_common['goods_vat']; $insert['goods_commend'] = $update_common['goods_commend']; $insert['goods_stcids'] = $update_common['goods_stcids']; $insert['is_virtual'] = $update_common['is_virtual']; $insert['virtual_indate'] = $update_common['virtual_indate']; $insert['virtual_limit'] = $update_common['virtual_limit']; $insert['virtual_invalid_refund'] = $update_common['virtual_invalid_refund']; $insert['is_fcode'] = $update_common['is_fcode']; $insert['is_appoint'] = $update_common['is_appoint']; $insert['is_presell'] = $update_common['is_presell']; $insert['is_own_shop'] = $update_common['is_own_shop']; $goods_id = $model_goods->addGoods($insert); } $goodsid_array[] = intval($goods_id); $colorid_array[] = 0; $model_type->addGoodsType($goods_id, $common_id, array('cate_id' => $_POST['cate_id'], 'type_id' => $_POST['type_id'], 'attr' => $_POST['attr'])); } // 生成商品二维码 if (!empty($goodsid_array)) { //QueueClient::push('createGoodsQRCode', array('store_id' => $_SESSION['store_id'], 'goodsid_array' => $goodsid_array)); // 生成商品二维码 $PhpQRCode->set('date', WAP_SITE_URL . '/tmpl/product_detail.html?goods_id=' . $goods_id); $PhpQRCode->set('pngTempName', $goods_id . '.png'); $PhpQRCode->init(); } // 清理商品数据 $model_goods->delGoods(array('goods_id' => array('not in', $goodsid_array), 'goods_commonid' => $common_id, 'store_id' => $_SESSION['store_id'])); // 清理商品图片表 $colorid_array = array_unique($colorid_array); $model_goods->delGoodsImages(array('goods_commonid' => $common_id, 'color_id' => array('not in', $colorid_array))); // 更新商品默认主图 $default_image_list = $model_goods->getGoodsImageList(array('goods_commonid' => $common_id, 'is_default' => 1), 'color_id,goods_image'); if (!empty($default_image_list)) { foreach ($default_image_list as $val) { $model_goods->editGoods(array('goods_image' => $val['goods_image']), array('goods_commonid' => $common_id, 'color_id' => $val['color_id'])); } } // 商品加入上架队列 if (isset($_POST['starttime'])) { $selltime = strtotime($_POST['starttime']) + intval($_POST['starttime_H']) * 3600 + intval($_POST['starttime_i']) * 60; if ($selltime > TIMESTAMP) { $this->addcron(array('exetime' => $selltime, 'exeid' => $common_id, 'type' => 1), true); } } // 添加操作日志 $this->recordSellerLog('编辑商品,平台货号:' . $common_id); if ($update_common['is_virtual'] == 1 || $update_common['is_fcode'] == 1 || $update_common['is_presell'] == 1) { // 如果是特殊商品清理促销活动,抢购、限时折扣、组合销售 QueueClient::push('clearSpecialGoodsPromotion', array('goods_commonid' => $common_id, 'goodsid_array' => $goodsid_array)); } else { // 更新商品促销价格 QueueClient::push('updateGoodsPromotionPriceByGoodsCommonId', $common_id); } // 生成F码 if ($update_common['is_fcode'] == 1) { QueueClient::push('createGoodsFCode', array('goods_commonid' => $common_id, 'fc_count' => intval($_POST['g_fccount']), 'fc_prefix' => $_POST['g_fcprefix'])); } $return = $model_goods->editGoodsCommon($update_common, array('goods_commonid' => $common_id, 'store_id' => $_SESSION['store_id'])); if ($return) { //提交事务 Model()->commit(); showDialog(L('nc_common_op_succ'), $_POST['ref_url'], 'succ'); } else { //回滚事务 Model()->rollback(); showDialog(L('store_goods_index_goods_edit_fail'), urlShop('store_goods_online', 'index')); } }
public function getPromoteOp() { // $team_member_info = Model("mz_member")->getMemberInfo(array('member_id'=>$this->member_info['member_id'])); $url = "http://mz.qiqin.net/index.html?pm=" . $this->member_info['member_id']; $mobile_app = 'mb_app.png'; require_once BASE_RESOURCE_PATH . DS . 'phpqrcode' . DS . 'index.php'; $PhpQRCode = new PhpQRCode(); $PhpQRCode->set('pngTempDir', BASE_UPLOAD_PATH . DS . ATTACH_MOBILE . DS); $PhpQRCode->set('date', $url); $PhpQRCode->set('matrixPointSize', 15); $PhpQRCode->set('pngTempName', $mobile_app); $PhpQRCode->init(); $data = array(); $data['url'] = $url; $data['qrcode'] = UPLOAD_SITE_URL . DS . ATTACH_MOBILE . DS . C('mobile_app'); output_data(array('data' => $data)); }