/** * 添加商品 */ public function add_step_twoOp() { // 实例化商品分类模型 $model_goodsclass = Model('goods_class'); // 是否能使用编辑器 if (checkPlatformStore()) { // 平台店铺可以使用编辑器 $editor_multimedia = true; } else { // 三方店铺需要 $editor_multimedia = false; if ($this->store_grade['sg_function'] == 'editor_multimedia') { $editor_multimedia = true; } } Tpl::output('editor_multimedia', $editor_multimedia); $gc_id = intval($_GET['class_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['class_1|class_2|class_3'] = $gc_id; $where['store_id'] = $_SESSION['store_id']; $rs = Model('store_bind_class')->getStoreBindClassInfo($where); if (empty($rs)) { showMessage(L('store_goods_index_again_choose_category2')); } } // 更新常用分类信息 $goods_class = $model_goodsclass->getGoodsClassLineForTag($gc_id); Tpl::output('goods_class', $goods_class); Model('goods_class_staple')->autoIncrementStaple($goods_class, $_SESSION['member_id']); // 获取类型相关数据 if ($goods_class['type_id'] > 0) { $typeinfo = Model('type')->getAttr($goods_class['type_id'], $_SESSION['store_id'], $gc_id); list($spec_json, $spec_list, $attr_list, $brand_list) = $typeinfo; Tpl::output('sign_i', count($spec_list)); Tpl::output('spec_list', $spec_list); Tpl::output('attr_list', $attr_list); Tpl::output('brand_list', $brand_list); } // 实例化店铺商品分类模型 $store_goods_class = Model('my_goods_class')->getClassTree(array('store_id' => $_SESSION['store_id'], 'stc_state' => '1')); Tpl::output('store_goods_class', $store_goods_class); // 小时分钟显示 $hour_array = array('00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23'); Tpl::output('hour_array', $hour_array); $minute_array = array('05', '10', '15', '20', '25', '30', '35', '40', '45', '50', '55'); Tpl::output('minute_array', $minute_array); // 关联版式 $plate_list = Model('store_plate')->getPlateList(array('store_id' => $_SESSION['store_id']), 'plate_id,plate_name,plate_position'); $plate_list = array_under_reset($plate_list, 'plate_position', 2); Tpl::output('plate_list', $plate_list); Tpl::output('item_id', ''); Tpl::output('menu_sign', 'add_goods_stpe2'); Tpl::showpage('store_goods_add.step2'); }
private function checkStore() { if (!checkPlatformStore()) { // 是否到达商品数上限 $goods_num = Model('goods')->getGoodsCommonCount(array('store_id' => $_SESSION['store_id'])); if (intval($this->store_grade['sg_goods_limit']) != 0) { if ($goods_num >= $this->store_grade['sg_goods_limit']) { showMessage(L('store_goods_index_goods_limit') . $this->store_grade['sg_goods_limit'] . L('store_goods_index_goods_limit1'), 'index.php?act=store_goods&op=goods_list', 'html', 'error'); } } } }
/** * 取得店铺绑定的分类 * * @param number $store_id 店铺id * @param number $pid 父级分类id * @param number $deep 深度 * @return array 二维数组 */ public function getGoodsClass($store_id, $pid = 0, $deep = 1) { // 读取商品分类 $gc_list = $this->getGoodsClassList(array('gc_parent_id' => $pid), 'gc_id, gc_name, type_id'); // 如果店铺ID不为商城店铺的话,读取绑定分类 if (!checkPlatformStore()) { $gc_list = array_under_reset($gc_list, 'gc_id'); $model_storebindclass = Model('store_bind_class'); $gcid_array = $model_storebindclass->getStoreBindClassList(array('store_id' => $store_id), '', "class_{$deep} asc", "distinct class_{$deep}"); if (!empty($gcid_array)) { $tmp_gc_list = array(); foreach ($gcid_array as $value) { if (isset($gc_list[$value["class_{$deep}"]])) { $tmp_gc_list[] = $gc_list[$value["class_{$deep}"]]; } } $gc_list = $tmp_gc_list; } else { return array(); } } return $gc_list; }
/** * 关联版式添加 */ public function plate_addOp() { if (chksubmit()) { // 验证表单 $obj_validate = new Validate(); $obj_validate->validateparam = array(array("input" => $_POST["p_name"], "require" => "true", "message" => '请填写版式名称'), array("input" => $_POST["p_content"], "require" => "true", "message" => '请填写版式内容')); $error = $obj_validate->validate(); if ($error != '') { showDialog(L('error') . $error, urlShop('store_plate', 'index')); } $insert = array(); $insert['plate_name'] = $_POST['p_name']; $insert['plate_position'] = $_POST['p_position']; $insert['plate_content'] = $_POST['p_content']; $insert['store_id'] = $_SESSION['store_id']; $result = Model('store_plate')->addStorePlate($insert); if ($result) { showDialog(L('nc_common_op_succ'), urlShop('store_plate', 'index'), 'succ'); } else { showDialog(L('nc_common_op_fail'), urlShop('store_plate', 'index')); } } // 是否能使用编辑器 if (checkPlatformStore()) { // 平台店铺可以使用编辑器 $editor_multimedia = true; } else { // 三方店铺需要 $editor_multimedia = false; if ($this->store_grade['sg_function'] == 'editor_multimedia') { $editor_multimedia = true; } } Tpl::output('editor_multimedia', $editor_multimedia); $this->profile_menu('plate_add', 'plate_add'); Tpl::showpage('store_plate.add'); }
/** * 保存添加的满就送活动 **/ public function mansong_saveOp() { $mansong_name = trim($_POST['mansong_name']); $start_time = strtotime($_POST['start_time']); $end_time = strtotime($_POST['end_time']); $model_mansong_quota = Model('p_mansong_quota'); $model_mansong = Model('p_mansong'); $model_mansong_rule = Model('p_mansong_rule'); if ($start_time >= $end_time) { showDialog(Language::get('greater_than_start_time')); } if (empty($mansong_name)) { showDialog(Language::get('mansong_name_error')); } $start_time_limit = $model_mansong->getMansongNewStartTime($_SESSION['store_id']); if (!empty($start_time_limit) && $start_time_limit > $start_time) { $start_time = $start_time_limit; } if (!checkPlatformStore()) { //检查当前套餐是否可用 $current_mansong_quota = $model_mansong_quota->getMansongQuotaCurrent($_SESSION['store_id']); if (empty($current_mansong_quota)) { showDialog(Language::get('mansong_quota_current_error'), 'reload', 'error'); } //验证输入 $quota_start_time = intval($current_mansong_quota['start_time']); $quota_end_time = intval($current_mansong_quota['end_time']); if ($start_time < $quota_start_time) { showDialog(sprintf(Language::get('mansong_add_start_time_explain'), date('Y-m-d', $current_mansong_quota['start_time']))); } if ($end_time > $quota_end_time) { showDialog(sprintf(Language::get('mansong_add_end_time_explain'), date('Y-m-d', $current_mansong_quota['end_time']))); } } if (empty($_POST['mansong_rule'])) { showDialog('满即送规则不能为空'); } $param = array(); $param['mansong_name'] = $mansong_name; $param['start_time'] = $start_time; $param['end_time'] = $end_time; $param['store_id'] = $_SESSION['store_id']; $param['store_name'] = $_SESSION['store_name']; $param['member_id'] = $_SESSION['member_id']; $param['member_name'] = $_SESSION['member_name']; $param['quota_id'] = $current_mansong_quota['quota_id'] ? $current_mansong_quota['quota_id'] : 0; $param['remark'] = trim($_POST['remark']); $mansong_id = $model_mansong->addMansong($param); if ($mansong_id) { $mansong_rule_array = array(); foreach ($_POST['mansong_rule'] as $value) { list($price, $discount, $goods_id) = explode(',', $value); $mansong_rule = array(); $mansong_rule['mansong_id'] = $mansong_id; $mansong_rule['price'] = $price; $mansong_rule['discount'] = $discount; $mansong_rule['goods_id'] = $goods_id; $mansong_rule_array[] = $mansong_rule; } //生成规则 $result = $model_mansong_rule->addMansongRuleArray($mansong_rule_array); $this->recordSellerLog('添加满即送活动,活动名称:' . $mansong_name); // 自动发布动态 // mansong_name,start_time,end_time,store_id $data_array = array(); $data_array['mansong_name'] = $param['mansong_name']; $data_array['start_time'] = $param['start_time']; $data_array['end_time'] = $param['end_time']; $data_array['store_id'] = $_SESSION['store_id']; $this->storeAutoShare($data_array, 'mansong'); showDialog(Language::get('mansong_add_success'), urlShop('store_promotion_mansong', 'mansong_list'), 'succ'); } else { showDialog(Language::get('mansong_add_fail')); } }
/** * 记录店铺费用 * * @param $cost_price 费用金额 * @param $cost_remark 费用备注 */ protected function recordStoreCost($cost_price, $cost_remark) { // 平台店铺不记录店铺费用 if (checkPlatformStore()) { return false; } $model_store_cost = Model('store_cost'); $param = array(); $param['cost_store_id'] = $_SESSION['store_id']; $param['cost_seller_id'] = $_SESSION['seller_id']; $param['cost_price'] = $cost_price; $param['cost_remark'] = $cost_remark; $param['cost_state'] = 0; $param['cost_time'] = TIMESTAMP; $model_store_cost->addStoreCost($param); // 发送店铺消息 $param = array(); $param['code'] = 'store_cost'; $param['store_id'] = $_SESSION['store_id']; $param['param'] = array('price' => $cost_price, 'seller_name' => $_SESSION['seller_name'], 'remark' => $cost_remark); QueueClient::push('sendStoreMsg', $param); }
public function templateeditOp() { $t_id = intval($_GET['tid']); if ($t_id <= 0) { $t_id = intval($_POST['tid']); } if ($t_id <= 0) { showMessage(Language::get('wrong_argument'), 'index.php?act=store_voucher&op=templatelist', 'html', 'error'); } $model = Model('voucher'); //查询模板信息 $param = array(); $param['voucher_t_id'] = $t_id; $param['voucher_t_store_id'] = $_SESSION['store_id']; $param['voucher_t_state'] = $this->templatestate_arr['usable'][0]; $param['voucher_t_giveout'] = array('elt', '0'); $param['voucher_t_end_date'] = array('gt', time()); $t_info = $model->table('voucher_template')->where($param)->find(); if (empty($t_info)) { showMessage(Language::get('wrong_argument'), 'index.php?act=store_voucher&op=templatelist', 'html', 'error'); } if ($isOwnShop = checkPlatformStore()) { Tpl::output('isOwnShop', true); } else { //查询套餐信息 $quotainfo = $model->table('voucher_quota')->where(array('quota_id' => $t_info['voucher_t_quotaid'], 'quota_storeid' => $_SESSION['store_id']))->find(); if (empty($quotainfo)) { showMessage(Language::get('voucher_template_quotanull'), 'index.php?act=store_voucher&op=quotaadd', 'html', 'error'); } } //查询面额列表 $pricelist = $model->table('voucher_price')->order('voucher_price asc')->select(); if (empty($pricelist)) { showMessage(Language::get('voucher_template_pricelisterror'), 'index.php?act=store_voucher&op=templatelist', 'html', 'error'); } if (chksubmit()) { //验证提交的内容面额不能大于限额 $obj_validate = new Validate(); $obj_validate->validateparam = array(array("input" => $_POST['txt_template_title'], "require" => "true", "validator" => "Length", "min" => "1", "max" => "50", "message" => Language::get('voucher_template_title_error')), array("input" => $_POST['txt_template_total'], "require" => "true", "validator" => "Number", "message" => Language::get('voucher_template_total_error')), array("input" => $_POST['select_template_price'], "require" => "true", "validator" => "Number", "message" => Language::get('voucher_template_price_error')), array("input" => $_POST['txt_template_limit'], "require" => "true", "validator" => "Double", "message" => Language::get('voucher_template_limit_error')), array("input" => $_POST['txt_template_describe'], "require" => "true", "validator" => "Length", "min" => "1", "max" => "255", "message" => Language::get('voucher_template_describe_error'))); $error = $obj_validate->validate(); //金额验证 $price = intval($_POST['select_template_price']) > 0 ? intval($_POST['select_template_price']) : 0; foreach ($pricelist as $k => $v) { if ($v['voucher_price'] == $price) { $chooseprice = $v; //取得当前选择的面额记录 } } if (empty($chooseprice)) { $error .= Language::get('voucher_template_pricelisterror'); } $limit = intval($_POST['txt_template_limit']) > 0 ? intval($_POST['txt_template_limit']) : 0; if ($price >= $limit) { $error .= Language::get('voucher_template_price_error'); } if ($error) { showDialog($error, 'reload', 'error'); } else { $update_arr = array(); $update_arr['voucher_t_title'] = trim($_POST['txt_template_title']); $update_arr['voucher_t_desc'] = trim($_POST['txt_template_describe']); if ($_POST['txt_template_enddate']) { $enddate = strtotime($_POST['txt_template_enddate']); if (!$isOwnShop && $enddate > $quotainfo['quota_endtime']) { $enddate = $quotainfo['quota_endtime']; } $update_arr['voucher_t_end_date'] = $enddate; } else { //如果没有添加有效期则默认为套餐的结束时间 if ($isOwnShop) { $update_arr['voucher_t_end_date'] = time() + 2592000; } else { $update_arr['voucher_t_end_date'] = $quotainfo['quota_endtime']; } } $update_arr['voucher_t_price'] = $price; $update_arr['voucher_t_limit'] = $limit; $update_arr['voucher_t_sc_id'] = intval($_POST['sc_id']); $update_arr['voucher_t_state'] = intval($_POST['tstate']) == $this->templatestate_arr['usable'][0] ? $this->templatestate_arr['usable'][0] : $this->templatestate_arr['disabled'][0]; $update_arr['voucher_t_total'] = intval($_POST['txt_template_total']) > 0 ? intval($_POST['txt_template_total']) : 0; $update_arr['voucher_t_points'] = $chooseprice['voucher_defaultpoints']; $update_arr['voucher_t_eachlimit'] = intval($_POST['eachlimit']) > 0 ? intval($_POST['eachlimit']) : 0; //自定义图片 if (!empty($_FILES['customimg']['name'])) { $upload = new UploadFile(); $upload->set('default_dir', ATTACH_VOUCHER . DS . $_SESSION['store_id']); $upload->set('thumb_width', '160'); $upload->set('thumb_height', '160'); $upload->set('thumb_ext', '_small'); $result = $upload->upfile('customimg'); if ($result) { //删除原图 if (!empty($t_info['voucher_t_customimg'])) { //如果模板存在,则删除原模板图片 @unlink(BASE_UPLOAD_PATH . DS . ATTACH_VOUCHER . DS . $_SESSION['store_id'] . DS . $t_info['voucher_t_customimg']); @unlink(BASE_UPLOAD_PATH . DS . ATTACH_VOUCHER . DS . $_SESSION['store_id'] . DS . str_ireplace('.', '_small.', $t_info['voucher_t_customimg'])); } $update_arr['voucher_t_customimg'] = $upload->file_name; } } $rs = $model->table('voucher_template')->where(array('voucher_t_id' => $t_info['voucher_t_id']))->update($update_arr); if ($rs) { showDialog(Language::get('nc_common_op_succ'), 'index.php?act=store_voucher&op=templatelist', 'succ'); } else { showDialog(Language::get('nc_common_op_fail'), 'index.php?act=store_voucher&op=templatelist', 'error'); } } } else { if (!$t_info['voucher_t_customimg'] || !file_exists(BASE_UPLOAD_PATH . DS . ATTACH_VOUCHER . DS . $_SESSION['store_id'] . DS . $t_info['voucher_t_customimg'])) { $t_info['voucher_t_customimg'] = UPLOAD_SITE_URL . DS . defaultGoodsImage(240); } else { $t_info['voucher_t_customimg'] = UPLOAD_SITE_URL . DS . ATTACH_VOUCHER . DS . $_SESSION['store_id'] . DS . str_ireplace('.', '_small.', $t_info['voucher_t_customimg']); } TPL::output('type', 'edit'); TPL::output('t_info', $t_info); //店铺分类 $store_class = rkcache('store_class', true); Tpl::output('store_class', $store_class); //查询店铺详情 $store_info = Model('store')->getStoreInfoByID($_SESSION['store_id']); TPL::output('store_info', $store_info); TPL::output('quotainfo', $quotainfo); TPL::output('pricelist', $pricelist); $this->profile_menu('templateedit', 'templateedit'); Tpl::showpage('store_voucher_template.add'); } }
/** * 编辑商品保存 */ 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 33hao. 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'] = 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 groupbuy_add_vrOp() { $model_groupbuy_quota = Model('groupbuy_quota'); if (checkPlatformStore()) { Tpl::output('isOwnShop', true); } else { $current_groupbuy_quota = $model_groupbuy_quota->getGroupbuyQuotaCurrent($_SESSION['store_id']); if (empty($current_groupbuy_quota)) { showMessage('当前没有可用套餐,请先购买套餐', urlShop('store_groupbuy', 'groupbuy_quota_add'), '', 'error'); } Tpl::output('current_groupbuy_quota', $current_groupbuy_quota); } // 根据后台设置的审核期重新设置抢购开始时间 Tpl::output('groupbuy_start_time', TIMESTAMP + intval(C('groupbuy_review_day')) * 86400); // 虚拟抢购分类 // Tpl::output('groupbuy_vr_classes', Model('groupbuy')->getGroupbuyVrClasses()); $model_vr_groupbuy_class = Model('vr_groupbuy_class'); $classlist = $model_vr_groupbuy_class->getVrGroupbuyClassList(array('parent_class_id' => 0)); Tpl::output('classlist', $classlist); // 虚拟区域分类 // Tpl::output('groupbuy_vr_cities', Model('groupbuy')->getGroupbuyVrCities()); $model_vr_groupbuy_area = Model('vr_groupbuy_area'); $arealist = $model_vr_groupbuy_area->getVrGroupbuyAreaList(array('parent_area_id' => 0, 'hot_city' => 1), '', '100'); Tpl::output('arealist', $arealist); self::profile_menu('groupbuy_add_vr'); Tpl::showpage('store_groupbuy.add_vr'); }
/** * 保存添加的限时折扣活动 **/ public function xianshi_saveOp() { //验证输入 $xianshi_name = trim($_POST['xianshi_name']); $start_time = strtotime($_POST['start_time']); $end_time = strtotime($_POST['end_time']); $lower_limit = intval($_POST['lower_limit']); if ($lower_limit <= 0) { $lower_limit = 1; } if (empty($xianshi_name)) { showDialog(Language::get('xianshi_name_error')); } if ($start_time >= $end_time) { showDialog(Language::get('greater_than_start_time')); } if (!checkPlatformStore()) { //获取当前套餐 $model_xianshi_quota = Model('p_xianshi_quota'); $current_xianshi_quota = $model_xianshi_quota->getXianshiQuotaCurrent($_SESSION['store_id']); if (empty($current_xianshi_quota)) { showDialog('没有可用限时折扣套餐,请先购买套餐'); } $quota_start_time = intval($current_xianshi_quota['start_time']); $quota_end_time = intval($current_xianshi_quota['end_time']); if ($start_time < $quota_start_time) { showDialog(sprintf(Language::get('xianshi_add_start_time_explain'), date('Y-m-d', $current_xianshi_quota['start_time']))); } if ($end_time > $quota_end_time) { showDialog(sprintf(Language::get('xianshi_add_end_time_explain'), date('Y-m-d', $current_xianshi_quota['end_time']))); } } //生成活动 $model_xianshi = Model('p_xianshi'); $param = array(); $param['xianshi_name'] = $xianshi_name; $param['xianshi_title'] = $_POST['xianshi_title']; $param['xianshi_explain'] = $_POST['xianshi_explain']; $param['quota_id'] = $current_xianshi_quota['quota_id'] ? $current_xianshi_quota['quota_id'] : 0; $param['start_time'] = $start_time; $param['end_time'] = $end_time; $param['store_id'] = $_SESSION['store_id']; $param['store_name'] = $_SESSION['store_name']; $param['member_id'] = $_SESSION['member_id']; $param['member_name'] = $_SESSION['member_name']; $param['lower_limit'] = $lower_limit; $result = $model_xianshi->addXianshi($param); if ($result) { $this->recordSellerLog('添加限时折扣活动,活动名称:' . $xianshi_name . ',活动编号:' . $result); // 添加计划任务 $this->addcron(array('exetime' => $param['end_time'], 'exeid' => $result, 'type' => 7), true); showDialog(Language::get('xianshi_add_success'), self::LINK_XIANSHI_MANAGE . $result, 'succ', '', 3); } else { showDialog(Language::get('xianshi_add_fail')); } }
/** * 选择商品 */ public function choosed_goodsOp() { $gid = $_GET['gid']; if ($gid <= 0) { $data = array('result' => 'false', 'msg' => '参数错误'); $this->_echoJson($data); } // 验证商品是否存在 $goods_info = Model('goods')->getGoodsInfoByID($gid, 'goods_id,goods_name,goods_image,goods_price,store_id,gc_id'); if (empty($goods_info) || $goods_info['store_id'] != $_SESSION['store_id']) { $data = array('result' => 'false', 'msg' => '参数错误'); $this->_echoJson($data); } $model_booth = Model('p_booth'); if (!checkPlatformStore()) { // 验证套餐时候过期 $booth_info = $model_booth->getBoothQuotaInfo(array('store_id' => $_SESSION['store_id'], 'booth_quota_endtime' => array('gt', TIMESTAMP)), 'booth_quota_id'); if (empty($booth_info)) { $data = array('result' => 'false', 'msg' => '套餐过期请重新购买套餐'); $this->_echoJson($data); } } // 验证已添加商品数量,及选择商品是否已经被添加过 $bootgoods_info = $model_booth->getBoothGoodsList(array('store_id' => $_SESSION['store_id']), 'goods_id'); // 已添加商品总数 if (count($bootgoods_info) >= C('promotion_booth_goods_sum')) { $data = array('result' => 'false', 'msg' => '只能添加' . C('promotion_booth_goods_sum') . '个商品'); $this->_echoJson($data); } // 商品是否已经被添加 $bootgoods_info = array_under_reset($bootgoods_info, 'goods_id'); if (isset($bootgoods_info[$gid])) { $data = array('result' => 'false', 'msg' => '商品已经添加,请选择其他商品'); $this->_echoJson($data); } // 保存到推荐展位商品表 $insert = array(); $insert['store_id'] = $_SESSION['store_id']; $insert['goods_id'] = $goods_info['goods_id']; $insert['gc_id'] = $goods_info['gc_id']; $model_booth->addBoothGoods($insert); $this->recordSellerLog('添加推荐展位商品,商品id:' . $goods_info['goods_id']); // 输出商品信息 $goods_info['goods_image'] = thumb($goods_info); $goods_info['url'] = urlShop('goods', 'index', array('goods_id' => $goods_info['goods_id'])); $goods_class = Model('goods_class')->getGoodsClassInfoById($goods_info['gc_id']); $goods_info['gc_name'] = $goods_class['gc_name']; $goods_info['result'] = 'true'; $this->_echoJson($goods_info); }
<?php defined('InShopNC') or exit('Access Invalid!'); ?> <div class="tabmenu"> <?php include template('layout/submenu'); if ($notOwnShop = !checkPlatformStore()) { ?> <a href="javascript:void(0)" class="ncsc-btn ncsc-btn-green" nc_type="dialog" dialog_title="申请新的经营类目" dialog_id="my_goods_brand_apply" dialog_width="480" uri="index.php?act=store_info&op=bind_class_add">申请新的经营类目</a> <?php } ?> </div> <?php if (checkPlatformStoreBindingAllGoodsClass()) { ?> <table class="ncsc-default-table"> <tbody> <tr> <td colspan="20" class="norecord"><div class="warning-option"><span>店铺已绑定全部商品类目</span></div></td> </tr> </tbody> </table> <?php } else { ?>
echo $lang['store_validity'] . $lang['nc_colon']; ?> <strong><?php echo $output['store_info']['store_end_time_text']; ?> <?php if ($output['store_info']['reopen_tip']) { ?> <a href="index.php?act=store_info&op=reopen">马上续签</a> <?php } ?> </strong> </dd> </dl> <?php if (!checkPlatformStore()) { ?> <div class="detail-rate"> <h5> <strong><?php echo $lang['store_dynamic_evaluation'] . $lang['nc_colon']; ?> </strong> 与行业相比 </h5> <ul> <?php foreach ($output['store_info']['store_credit'] as $value) { ?> <li> <?php echo $value['text']; ?> <span class="credit"><?php echo $value['credit'];
/** * 套餐活动添加 */ public function bundling_addOp() { /** * 实例化模型 */ $model_bundling = Model('p_bundling'); // 验证套餐数量 if (intval(C('promotion_bundling_sum')) != 0 && !isset($_REQUEST['bundling_id'])) { $count = $model_bundling->getBundlingCount(array('store_id' => $_SESSION['store_id'])); if (intval(C('promotion_bundling_sum')) <= intval($count)) { showMessage(L('bundling_add_fail_quantity_beyond'), '', '', 'error'); } } if (chksubmit()) { // 插入套餐 $data = array(); if (isset($_POST['bundling_id'])) { $data['bl_id'] = intval($_POST['bundling_id']); } $data['bl_name'] = $_POST['bundling_name']; $data['store_id'] = $_SESSION['store_id']; $data['store_name'] = $_SESSION['store_name']; $data['bl_discount_price'] = $_POST['discount_price']; $data['bl_freight_choose'] = $_POST['bundling_freight_choose']; $data['bl_freight'] = $_POST['bundling_freight']; $data['bl_state'] = intval($_POST['state']); $return = $model_bundling->addBundling($data, true); if (!$return) { showDialog(L('nc_common_op_fail'), '', '', 'error'); } // 插入套餐商品 $model_goods = Model('goods'); $data_goods = array(); $appoint_goodsid = false; $model_bundling->delBundlingGoods(array('bl_id' => intval($_POST['bundling_id']))); if (!empty($_POST['goods']) && is_array($_POST['goods'])) { foreach ($_POST['goods'] as $key => $val) { // 验证是否为本店铺商品 $goods_info = $model_goods->getGoodsInfoByID($val['gid'], 'goods_id,goods_name,goods_image,store_id'); if (empty($goods_info) || $goods_info['store_id'] != $_SESSION['store_id']) { continue; } $data = array(); $data['bl_id'] = isset($_POST['bundling_id']) ? intval($_POST['bundling_id']) : $return; $data['goods_id'] = $goods_info['goods_id']; $data['goods_name'] = $goods_info['goods_name']; $data['goods_image'] = $goods_info['goods_image']; $data['bl_goods_price'] = ncPriceFormat($val['price']); $data['bl_appoint'] = intval($val['appoint']); if (!$appoint_goodsid && intval($val['appoint']) == 1) { $appoint_goodsid = intval($val['gid']); } $data_goods[] = $data; } } // 插入数据 $return = $model_bundling->addBundlingGoodsAll($data_goods); if (!isset($_POST['bundling_id']) && !$appoint_goodsid) { // 自动发布动态 // bl_id,bl_name,image_path,bl_discount_price,bl_freight_choose,bl_freight,store_id $data_array = array(); $data_array['bl_id'] = $return; $data_array['goods_id'] = $appoint_goodsid; $data_array['bl_name'] = $data['bl_name']; $data_array['bl_img'] = empty($_POST['image_path']) ? '' : $_POST['image_path'][0]; $data_array['bl_discount_price'] = $data['bl_discount_price']; $data_array['bl_freight_choose'] = $data['bl_freight_choose']; $data_array['bl_freight'] = $data['bl_freight']; $data_array['store_id'] = $_SESSION['store_id']; $this->storeAutoShare($data_array, 'bundling'); } $this->recordSellerLog('添加优惠套装,名称:' . $data['bl_name'] . ' id:' . $return); showDialog(L('nc_common_op_succ'), urlShop('store_promotion_bundling', 'bundling_list'), 'succ'); } // 是否能使用编辑器 if (checkPlatformStore()) { // 平台店铺可以使用编辑器 $editor_multimedia = true; } else { // 三方店铺需要 $editor_multimedia = false; if ($this->store_grade['sg_function'] == 'editor_multimedia') { $editor_multimedia = true; } } Tpl::output('editor_multimedia', $editor_multimedia); if (intval($_GET['bundling_id']) > 0) { $bundling_info = $model_bundling->getBundlingInfo(array('bl_id' => intval($_GET['bundling_id']), 'store_id' => $_SESSION['store_id'])); Tpl::output('bundling_info', $bundling_info); // 验证是否属于自己的组合套餐 if (empty($bundling_info['store_id'])) { showMessage(L('wrong_argument'), urlShop('store_promotion_bundling', 'bundling_list'), '', 'error'); } $b_goods_list = $model_bundling->getBundlingGoodsList(array('bl_id' => intval($_GET['bundling_id']))); if (!empty($b_goods_list)) { $goodsid_array = array(); foreach ($b_goods_list as $val) { $goodsid_array[] = $val['goods_id']; } $goods_list = Model('goods')->getGoodsList(array('goods_id' => array('in', $goodsid_array)), 'goods_id,goods_price,goods_image,goods_name'); Tpl::output('goods_list', array_under_reset($goods_list, 'goods_id')); } Tpl::output('b_goods_list', $b_goods_list); // 输出导航 self::profile_menu('bundling_edit', 'bundling_edit'); } else { // 输出导航 self::profile_menu('bundling_add', 'bundling_add'); } Tpl::showpage('store_promotion_bundling.add'); }
/** * 用户中心右边,小导航 * * @param string $menu_type 导航类型 * @param string $menu_key 当前导航的menu_key * @return */ private function profile_menu($menu_type, $menu_key = '') { Language::read('member_layout'); $menu_array = array(); switch ($menu_type) { case 'transport': case 'offpay_area': $menu_array = array(1 => array('menu_key' => 'transport', 'menu_name' => Language::get('nc_member_path_postage'), 'menu_url' => 'index.php?act=store_transport')); if (checkPlatformStore()) { $menu_array[] = array('menu_key' => 'offpay_area', 'menu_name' => '配送地区', 'menu_url' => 'index.php?act=store_transport&op=offpay_area'); } break; } Tpl::output('member_menu', $menu_array); Tpl::output('menu_key', $menu_key); }
/** * 用户中心右边,小导航 * * @param string $menu_type 导航类型 * @param string $menu_key 当前导航的menu_key * @param array $array 附加菜单 * @return */ private function profile_menu($menu_type, $menu_key = '', $array = array()) { Language::read('member_layout'); $lang = Language::getLangContent(); $menu_array = array(); switch ($menu_type) { case 'index': $menu_array[] = array('menu_key' => 'bind_class', 'menu_name' => $lang['nc_member_path_bind_class'], 'menu_url' => 'index.php?act=store_info&op=bind_class'); if (!checkPlatformStore()) { $menu_array[] = array('menu_key' => 'index', 'menu_name' => $lang['nc_member_path_store_info'], 'menu_url' => 'index.php?act=store_info&op=index'); $menu_array[] = array('menu_key' => 'reopen', 'menu_name' => $lang['nc_member_path_store_reopen'], 'menu_url' => 'index.php?act=store_info&op=reopen'); } break; case 'bind_class': $menu_array = array(array('menu_key' => 'index', 'menu_name' => $lang['nc_member_path_bind_class'], 'menu_url' => 'index.php?act=store_bind_class&op=index')); break; case 'add': $menu_array = array(array('menu_key' => 'index', 'menu_name' => $lang['nc_member_path_bind_class'], 'menu_url' => 'index.php?act=store_bind_class&op=index'), array('menu_key' => 'add', 'menu_name' => $lang['nc_member_path_bind_class_add'], 'menu_url' => 'index.php?act=store_bind_class&op=add')); break; } if (!empty($array)) { $menu_array[] = $array; } Tpl::output('member_menu', $menu_array); Tpl::output('menu_key', $menu_key); }
/** * 促销分析 */ public function generalOp() { $model = Model('stat'); //统计的日期0点 $stat_time = strtotime(date('Y-m-d', time())) - 86400; /* * 近30天 */ $stime = $stat_time - 86400 * 29; //30天前 $etime = $stat_time + 86400 - 1; //昨天23:59 $statnew_arr = array(); //查询订单表下单量、下单金额、下单客户数 $where = array(); $where['order_isvalid'] = 1; //计入统计的有效订单 $where['store_id'] = $_SESSION['store_id']; $where['order_add_time'] = array('between', array($stime, $etime)); $field = ' COUNT(*) as ordernum, SUM(order_amount) as orderamount, COUNT(DISTINCT buyer_id) as ordermembernum, AVG(order_amount) as avgorderamount '; $stat_order = $model->getoneByStatorder($where, $field); $statnew_arr['ordernum'] = ($t = $stat_order['ordernum']) ? $t : 0; $statnew_arr['orderamount'] = ncPriceFormat(($t = $stat_order['orderamount']) ? $t : 0); $statnew_arr['ordermembernum'] = ($t = $stat_order['ordermembernum']) > 0 ? $t : 0; $statnew_arr['avgorderamount'] = ncPriceFormat(($t = $stat_order['avgorderamount']) ? $t : 0); unset($stat_order); //下单高峰期 $where = array(); $where['order_isvalid'] = 1; //计入统计的有效订单 $where['store_id'] = $_SESSION['store_id']; $where['order_add_time'] = array('between', array($stime, $etime)); $field = ' HOUR(FROM_UNIXTIME(order_add_time)) as hourval,COUNT(*) as ordernum '; $orderlist = $model->statByStatorder($where, $field, 0, 0, 'ordernum desc,hourval asc', 'hourval'); foreach ((array) $orderlist as $k => $v) { if ($k < 2) { //取前两个订单量高的时间段 if (!$statnew_arr['hothour']) { $statnew_arr['hothour'] = $v['hourval'] . ":00~" . ($v['hourval'] + 1) . ":00"; } else { $statnew_arr['hothour'] .= "," . ($v['hourval'] . ":00~" . ($v['hourval'] + 1) . ":00"); } } } unset($orderlist); //查询订单商品表下单商品数 $where = array(); $where['order_isvalid'] = 1; //计入统计的有效订单 $where['store_id'] = $_SESSION['store_id']; $where['order_add_time'] = array('between', array($stime, $etime)); $field = ' SUM(goods_num) as ordergoodsnum, AVG(goods_pay_price/goods_num) as avggoodsprice '; $stat_ordergoods = $model->getoneByStatordergoods($where, $field); $statnew_arr['ordergoodsnum'] = ($t = $stat_ordergoods['ordergoodsnum']) ? $t : 0; $statnew_arr['avggoodsprice'] = ncPriceFormat(($t = $stat_ordergoods['avggoodsprice']) ? $t : 0); unset($stat_ordergoods); //商品总数、收藏量 $goods_list = $model->statByGoods(array('store_id' => $_SESSION['store_id'], 'is_virtual' => 0), 'COUNT(*) as goodsnum, SUM(goods_collect) as gcollectnum'); $statnew_arr['goodsnum'] = ($t = $goods_list[0]['goodsnum']) > 0 ? $t : 0; $statnew_arr['gcollectnum'] = ($t = $goods_list[0]['gcollectnum']) > 0 ? $t : 0; //店铺收藏量 $store_list = $model->getoneByStore(array('store_id' => $_SESSION['store_id']), 'store_collect'); $statnew_arr['store_collect'] = ($t = $store_list['store_collect']) > 0 ? $t : 0; /* * 销售走势 */ //构造横轴数据 for ($i = $stime; $i < $etime; $i += 86400) { //当前数据的时间 $timetext = date('n', $i) . '-' . date('j', $i); //统计图数据 $stat_list[$timetext] = 0; //横轴 $stat_arr['xAxis']['categories'][] = $timetext; } $where = array(); $where['order_isvalid'] = 1; //计入统计的有效订单 $where['store_id'] = $_SESSION['store_id']; $where['order_add_time'] = array('between', array($stime, $etime)); $field = ' order_add_time,SUM(order_amount) as orderamount,MONTH(FROM_UNIXTIME(order_add_time)) as monthval,DAY(FROM_UNIXTIME(order_add_time)) as dayval '; $stat_order = $model->statByStatorder($where, $field, 0, 0, '', 'monthval,dayval'); if ($stat_order) { foreach ($stat_order as $k => $v) { $stat_list[$v['monthval'] . '-' . $v['dayval']] = floatval($v['orderamount']); } } $stat_arr['legend']['enabled'] = false; $stat_arr['series'][0]['name'] = '下单金额'; $stat_arr['series'][0]['data'] = array_values($stat_list); //得到统计图数据 $stat_arr['title'] = '最近30天销售走势'; $stat_arr['yAxis'] = '下单金额'; $stattoday_json = getStatData_LineLabels($stat_arr); unset($stat_arr); /* * 7日内商品销售TOP30 */ $stime = $stat_time - 86400 * 6; //7天前0点 $etime = $stat_time + 86400 - 1; //今天24点 $where = array(); $where['order_isvalid'] = 1; //计入统计的有效订单 $where['store_id'] = $_SESSION['store_id']; $where['order_add_time'] = array('between', array($stime, $etime)); $field = ' sum(goods_num) as ordergoodsnum, goods_id, goods_name '; $goodstop30_arr = $model->statByStatordergoods($where, $field, 0, 30, 'ordergoodsnum desc', 'goods_id'); /** * 7日内同行热卖商品 */ $where = array(); $where['order_isvalid'] = 1; //计入统计的有效订单 $where['order_add_time'] = array('between', array($stime, $etime)); $where['store_id'] = array('neq', $_SESSION['store_id']); if (!checkPlatformStore()) { //如果不是平台店铺,则查询店铺经营类目的同行数据 //查询店铺经营类目 $store_bindclass = Model('store_bind_class')->getStoreBindClassList(array('store_id' => $_SESSION['store_id'])); $goodsclassid_arr = array(); foreach ((array) $store_bindclass as $k => $v) { if (intval($v['class_3']) > 0) { $goodsclassid_arr[3][] = intval($v['class_3']); } elseif (intval($v['class_2']) > 0) { $goodsclassid_arr[2][] = intval($v['class_2']); } elseif (intval($v['class_1']) > 0) { $goodsclassid_arr[1][] = intval($v['class_1']); } } //拼接商品分类条件 if ($goodsclassid_arr) { ksort($goodsclassid_arr); $gc_parentidwhere_keyarr = array(); $gc_parentidwhere_arr = array(); foreach ((array) $goodsclassid_arr as $k => $v) { $gc_parentidwhere_keyarr[] = 'gc_parentid_' . $k; $gc_parentidwhere_arr[] = array('in', $goodsclassid_arr[$k]); } if (count($gc_parentidwhere_keyarr) == 1) { $where[$gc_parentidwhere_keyarr[0]] = $gc_parentidwhere_arr[0]; } else { $gc_parentidwhere_arr['_multi'] = '1'; $where[implode('|', $gc_parentidwhere_keyarr)] = $gc_parentidwhere_arr; } } } $field = ' sum(goods_num) as ordergoodsnum, goods_id, goods_name '; $othergoodstop30_arr = $model->statByStatordergoods($where, $field, 0, 30, 'ordergoodsnum desc', 'goods_id'); Tpl::output('goodstop30_arr', $goodstop30_arr); Tpl::output('othergoodstop30_arr', $othergoodstop30_arr); Tpl::output('stattoday_json', $stattoday_json); Tpl::output('statnew_arr', $statnew_arr); Tpl::output('stat_time', $stat_time); Tpl::showpage('stat.general.index'); }
/** * 编辑商品页面 */ public function edit_goodsOp() { $common_id = $_GET['commonid']; if ($common_id <= 0) { showMessage(L('wrong_argument'), '', 'html', 'error'); } $model_goods = Model('goods'); $where = array('goods_commonid' => $common_id, 'store_id' => $_SESSION['store_id']); $goodscommon_info = $model_goods->getGoodeCommonInfo($where); if (empty($goodscommon_info)) { showMessage(L('wrong_argument'), '', 'html', 'error'); } $goodscommon_info['g_storage'] = $model_goods->getGoodsSum($where, 'goods_storage'); $goodscommon_info['spec_name'] = unserialize($goodscommon_info['spec_name']); Tpl::output('goods', $goodscommon_info); if (intval($_GET['class_id']) > 0) { $goodscommon_info['gc_id'] = intval($_GET['class_id']); } $goods_class = Model('goods_class')->getGoodsClassLineForTag($goodscommon_info['gc_id']); Tpl::output('goods_class', $goods_class); $model_type = Model('type'); // 获取类型相关数据 if ($goods_class['type_id'] > 0) { $typeinfo = $model_type->getAttr($goods_class['type_id'], $_SESSION['store_id'], $goodscommon_info['gc_id']); list($spec_json, $spec_list, $attr_list, $brand_list) = $typeinfo; Tpl::output('spec_json', $spec_json); Tpl::output('sign_i', count($spec_list)); Tpl::output('spec_list', $spec_list); Tpl::output('attr_list', $attr_list); Tpl::output('brand_list', $brand_list); } // 取得商品规格的输入值 $goods_array = $model_goods->getGoodsList($where, 'goods_id, goods_price,goods_storage,goods_serial,goods_spec'); $sp_value = array(); if (is_array($goods_array) && !empty($goods_array)) { // 取得已选择了哪些商品的属性 $attr_checked_l = $model_type->typeRelatedList('goods_attr_index', array('goods_id' => intval($goods_array[0]['goods_id'])), 'attr_value_id'); if (is_array($attr_checked_l) && !empty($attr_checked_l)) { $attr_checked = array(); foreach ($attr_checked_l as $val) { $attr_checked[] = $val['attr_value_id']; } } Tpl::output('attr_checked', $attr_checked); $spec_checked = array(); foreach ($goods_array as $k => $v) { $a = unserialize($v['goods_spec']); if (!empty($a)) { foreach ($a as $key => $val) { $spec_checked[$key]['id'] = $key; $spec_checked[$key]['name'] = $val; } $matchs = array_keys($a); sort($matchs); $id = str_replace(',', '', implode(',', $matchs)); $sp_value['i_' . $id . '|price'] = $v['goods_price']; $sp_value['i_' . $id . '|id'] = $v['goods_id']; $sp_value['i_' . $id . '|stock'] = $v['goods_storage']; $sp_value['i_' . $id . '|sku'] = $v['goods_serial']; } } Tpl::output('spec_checked', $spec_checked); } Tpl::output('sp_value', $sp_value); // 实例化店铺商品分类模型 $store_goods_class = Model('goods_class')->getClassTree(); Tpl::output('store_goods_class', $store_goods_class); $goodscommon_info['goods_stcids'] = trim($goodscommon_info['goods_stcids'], ','); Tpl::output('store_class_goods', explode(',', $goodscommon_info['goods_stcids'])); // 是否能使用编辑器 if (checkPlatformStore()) { // 平台店铺可以使用编辑器 $editor_multimedia = true; } else { // 三方店铺需要 $editor_multimedia = false; if ($this->store_grade['sg_function'] == 'editor_multimedia') { $editor_multimedia = true; } } Tpl::output('editor_multimedia', $editor_multimedia); // 小时分钟显示 $hour_array = array('00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23'); Tpl::output('hour_array', $hour_array); $minute_array = array('05', '10', '15', '20', '25', '30', '35', '40', '45', '50', '55'); Tpl::output('minute_array', $minute_array); // 关联版式 $plate_list = Model('store_plate')->getPlateList(array('store_id' => $_SESSION['store_id']), 'plate_id,plate_name,plate_position'); $plate_list = array_under_reset($plate_list, 'plate_position', 2); Tpl::output('plate_list', $plate_list); $this->profile_menu('edit_detail', 'edit_detail'); Tpl::output('edit_goods_sign', true); Tpl::showpage('store_goods_add.step2'); }
/** * 商户中心首页 * */ public function indexOp() { Language::read('member_home_index'); // 店铺信息 $store_info = $this->store_info; if (intval($store_info['store_end_time']) > 0) { $store_info['store_end_time_text'] = date('Y-m-d', $store_info['store_end_time']); $reopen_time = $store_info['store_end_time'] - 3600 * 24 + 1 - TIMESTAMP; if (!checkPlatformStore() && $store_info['store_end_time'] - TIMESTAMP >= 0 && $reopen_time < 2592000) { //到期续签提醒(<30天) $store_info['reopen_tip'] = true; } } else { $store_info['store_end_time_text'] = L('store_no_limit'); } // 店铺等级信息 $store_info['grade_name'] = $this->store_grade['sg_name']; $store_info['grade_goodslimit'] = $this->store_grade['sg_goods_limit']; $store_info['grade_albumlimit'] = $this->store_grade['sg_album_limit']; Tpl::output('store_info', $store_info); // 商家帮助 $model_help = Model('help'); $condition = array(); $condition['help_show'] = '1'; //是否显示,0为否,1为是 $help_list = $model_help->getStoreHelpTypeList($condition, '', 6); Tpl::output('help_list', $help_list); // 销售情况统计 $field = ' COUNT(*) as ordernum,SUM(order_amount) as orderamount '; $where = array(); $where['store_id'] = $_SESSION['store_id']; $where['order_isvalid'] = 1; //计入统计的有效订单 // 昨日销量 $where['order_add_time'] = array('between', array(strtotime(date('Y-m-d', time() - 3600 * 24)), strtotime(date('Y-m-d', time())) - 1)); $daily_sales = Model('stat')->getoneByStatorder($where, $field); Tpl::output('daily_sales', $daily_sales); // 月销量 $where['order_add_time'] = array('gt', strtotime(date('Y-m', time()))); $monthly_sales = Model('stat')->getoneByStatorder($where, $field); Tpl::output('monthly_sales', $monthly_sales); unset($field, $where); //单品销售排行 //最近30天 $stime = strtotime(date('Y-m-d', time() - 3600 * 24)) - 86400 * 29; //30天前 $etime = strtotime(date('Y-m-d', time())) - 1; //昨天23:59 $where = array(); $where['store_id'] = $_SESSION['store_id']; $where['order_isvalid'] = 1; //计入统计的有效订单 $where['order_add_time'] = array('between', array($stime, $etime)); $field = ' goods_id,goods_name,SUM(goods_num) as goodsnum,goods_image '; $orderby = 'goodsnum desc,goods_id'; $goods_list = Model('stat')->statByStatordergoods($where, $field, 0, 8, $orderby, 'goods_id'); unset($stime, $etime, $where, $field, $orderby); Tpl::output('goods_list', $goods_list); if (!checkPlatformStore()) { if (C('groupbuy_allow') == 1) { // 抢购套餐 $groupquota_info = Model('groupbuy_quota')->getGroupbuyQuotaCurrent($_SESSION['store_id']); Tpl::output('groupquota_info', $groupquota_info); } if (intval(C('promotion_allow')) == 1) { // 限时折扣套餐 $xianshiquota_info = Model('p_xianshi_quota')->getXianshiQuotaCurrent($_SESSION['store_id']); Tpl::output('xianshiquota_info', $xianshiquota_info); // 满即送套餐 $mansongquota_info = Model('p_mansong_quota')->getMansongQuotaCurrent($_SESSION['store_id']); Tpl::output('mansongquota_info', $mansongquota_info); // 优惠套装套餐 $binglingquota_info = Model('p_bundling')->getBundlingQuotaInfoCurrent($_SESSION['store_id']); Tpl::output('binglingquota_info', $binglingquota_info); // 推荐展位套餐 $boothquota_info = Model('p_booth')->getBoothQuotaInfoCurrent($_SESSION['store_id']); Tpl::output('boothquota_info', $boothquota_info); } if (C('voucher_allow') == 1) { $voucherquota_info = Model('voucher')->getCurrentQuota($_SESSION['store_id']); Tpl::output('voucherquota_info', $voucherquota_info); } } else { Tpl::output('isOwnShop', true); } $phone_array = explode(',', C('site_phone')); Tpl::output('phone_array', $phone_array); Tpl::output('menu_sign', 'index'); Tpl::showpage('index'); }
/** * 验证是否为平台店铺 并且绑定了全部商品类目 * * @return boolean */ function checkPlatformStoreBindingAllGoodsClass() { return checkPlatformStore() && $_SESSION['bind_all_gc']; }
/** * 卖家店铺主题设置 * * @param string * @param string * @return */ public function themeOp() { /** * 店铺信息 */ $store_class = Model('store'); $store_info = $store_class->getStoreInfoByID($_SESSION['store_id']); /** * 主题配置信息 */ $style_data = array(); $style_configurl = BASE_ROOT_PATH . DS . DIR_SHOP . '/templates/' . TPL_SHOP_NAME . DS . 'store' . DS . 'style' . DS . "styleconfig.php"; if (file_exists($style_configurl)) { include_once $style_configurl; } /** * 转码 */ if (strtoupper(CHARSET) == 'GBK') { $style_data = Language::getGBK($style_data); } /** * 当前店铺主题 */ $curr_store_theme = !empty($store_info['store_theme']) ? $store_info['store_theme'] : 'default'; /** * 当前店铺预览图片 */ $curr_image = SHOP_TEMPLATES_URL . '/store/style/' . $curr_store_theme . '/images/preview.jpg'; $curr_theme = array('curr_name' => $curr_store_theme, 'curr_truename' => $style_data[$curr_store_theme]['truename'], 'curr_image' => $curr_image); // 自营店全部可用 if (checkPlatformStore()) { $themes = array_keys($style_data); } else { /** * 店铺等级 */ $grade_class = Model('store_grade'); $grade = $grade_class->getOneGrade($store_info['grade_id']); /** * 可用主题 */ $themes = explode('|', $grade['sg_template']); } /** * 可用主题预览图片 */ foreach ($style_data as $key => $val) { if (in_array($key, $themes)) { $theme_list[$key] = array('name' => $key, 'truename' => $val['truename'], 'image' => SHOP_TEMPLATES_URL . '/store/style/' . $key . '/images/preview.jpg'); } } /** * 页面输出 */ self::profile_menu('store_theme', 'store_theme'); Tpl::output('store_info', $store_info); Tpl::output('curr_theme', $curr_theme); Tpl::output('theme_list', $theme_list); Tpl::showpage('store_theme'); }
/** * 编辑商品保存 */ 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_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_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_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_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_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')); } }