/** * 从字符串获取指定日期的结束时间(24:00) * * @author Garbin * @param string $str * @return int */ function gmstr2time_end($str) { return gmstr2time($str) + 86400; }
function edit() { $coupon_id = isset($_GET['id']) ? intval($_GET['id']) : 0; if (empty($coupon_id)) { echo Lang::get("no_coupon"); } if (!IS_POST) { header("Content-Type:text/html;charset=" . CHARSET); $coupon = $this->_coupon_mod->get_info($coupon_id); $this->assign('coupon', $coupon); $this->display('coupon.form.html'); } else { $coupon_value = floatval(trim($_POST['coupon_value'])); $use_times = intval(trim($_POST['use_times'])); $min_amount = floatval(trim($_POST['min_amount'])); if (empty($coupon_value) || $coupon_value < 0) { $this->pop_warning('coupon_value_not'); exit; } if (empty($use_times)) { $this->pop_warning('use_times_not_zero'); exit; } if ($min_amount < 0) { $this->pop_warning("min_amount_gt_zero"); exit; } $start_time = gmstr2time(trim($_POST['start_time'])); $end_time = gmstr2time_end(trim($_POST['end_time'])) - 1; //echo gmstr2time_end(trim($_POST['end_time'])) . '-------' .$end_time;exit; if ($end_time < $start_time) { $this->pop_warning('end_gt_start'); exit; } $coupon = array('coupon_name' => trim($_POST['coupon_name']), 'coupon_value' => $coupon_value, 'store_id' => $this->_store_id, 'use_times' => $use_times, 'start_time' => $start_time, 'end_time' => $end_time, 'min_amount' => $min_amount, 'if_issue' => trim($_POST['if_issue']) == 1 ? 1 : 0); $this->_coupon_mod->edit($coupon_id, $coupon); if ($this->_coupon_mod->has_error()) { $this->pop_warning($this->_coupon_mod->get_error()); exit; } $this->pop_warning('ok', 'coupon_edit'); } }
/** * 商品 * @return 成功返回true,失败返回错误信息 */ function process_goods() { global $db, $ecs; /* 清空商品、商品扩展分类、商品属性、商品相册、关联商品、组合商品、赠品 */ truncate_table('goods'); truncate_table('goods_cat'); truncate_table('goods_attr'); truncate_table('goods_gallery'); truncate_table('link_goods'); truncate_table('group_goods'); /* 查询品牌列表 name => id */ $brand_list = array(); $sql = "SELECT brand_id, brand_name FROM " . $ecs->table('brand'); $res = $db->query($sql); while ($row = $db->fetchRow($res)) { $brand_list[$row['brand_name']] = $row['brand_id']; } /* 取得商店设置 */ $sql = "SELECT offer_pointtype, offer_pointnum FROM ".$this->sprefix."mall_offer WHERE offerid = '1'"; $config = $this->sdb->getRow($sql); /* 取得商品分类对应的商品类型 */ $cat_type_list = array(); $sql = "SELECT catid, prop_cat_id FROM ".$this->sprefix."mall_offer_pcat"; $res = $this->sdb->query($sql); while ($row = $this->sdb->fetchRow($res)) { $cat_type_list[$row['catid']] = $row['prop_cat_id']; } /* 查询商品并处理 */ $sql = "SELECT * FROM ".$this->sprefix."mall_goods"; $res = $this->sdb->query($sql); while ($row = $this->sdb->fetchRow($res)) { $goods = array(); if ($row['ifobject'] == '0') { /* 虚拟商品 */ $goods['is_real'] = '0'; } elseif ($row['ifobject'] == '1') { /* 实体商品 */ $goods['is_real'] = '1'; } elseif ($row['ifobject'] == '2') { /* 数字文件,暂时无法转换 */ continue; } elseif ($row['ifobject'] == '3') { /* 捆绑销售,暂时无法转换 */ continue; } else { /* 未知,无法转换 */ continue; } $goods['goods_id'] = $row['gid']; $goods['cat_id'] = $row['catid']; $goods['goods_sn'] = ecs_iconv($this->scharset, $this->tcharset, addslashes($row['bn'])); $goods['goods_name'] = $row['goods']; $goods['brand_id'] = trim($row['brand']) == '' ? '0' : $brand_list[ecs_iconv($this->scharset, $this->tcharset, addslashes($row['brand']))]; $goods['goods_number'] = $row['storage']; $goods['goods_weight'] = $row['weight']; $goods['market_price'] = $row['priceintro']; $goods['shop_price'] = $row['ifdiscreteness'] == '1' ? $row['basicprice'] : $row['price']; if ($row['tejia2'] == '1') { $goods['promote_price'] = $goods['shop_price']; $goods['promote_start_date'] = gmtime(); $goods['promote_end_date'] = gmstr2time('+1 weeks'); } $goods['warn_number'] = $row['ifalarm'] == '1' ? $row['alarmnum'] : '0'; $goods['goods_brief'] = ecs_iconv($this->scharset, $this->tcharset, addslashes($row['intro'])); $goods['goods_desc'] = str_replace('pictures/newsimg/', $this->tdocroot . '/images/upload/Image/', ecs_iconv($this->scharset, $this->tcharset, addslashes($row['memo']))); $goods['is_on_sale'] = $row['shop_iffb']; $goods['is_alone_sale'] = $row['onsale']; $goods['add_time'] = $row['uptime']; $goods['sort_order'] = $row['offer_ord']; $goods['is_delete'] = '0'; $goods['is_best'] = $row['recommand2']; $goods['is_new'] = $row['new2']; $goods['is_hot'] = $row['hot2']; $goods['is_promote'] = $row['tejia2']; $goods['goods_type'] = isset($cat_type_list[$row['catid']]) ? $cat_type_list[$row['catid']] : 0; $goods['last_update'] = gmtime(); /* 图片:如果没有本地文件,取远程图片 */ $file = $this->troot . '/images/' . date('Ym') . '/small_' . $row['gid']; if (file_exists($file. '.jpg')) { $goods['goods_thumb'] = 'images/' . date('Ym') . '/small_' . $row['gid'] . '.jpg'; } elseif (file_exists($file. '.jpeg')) { $goods['goods_thumb'] = 'images/' . date('Ym') . '/small_' . $row['gid'] . '.jpeg'; } elseif (file_exists($file. '.gif')) { $goods['goods_thumb'] = 'images/' . date('Ym') . '/small_' . $row['gid'] . '.gif'; } elseif (file_exists($file. '.png')) { $goods['goods_thumb'] = 'images/' . date('Ym') . '/small_' . $row['gid'] . '.png'; } else { $goods['goods_thumb'] = $row['smallimgremote']; } $file = $this->troot . '/images/' . date('Ym') . '/big_' . $row['gid']; if (file_exists($file. '.jpg')) { $goods['goods_img'] = 'images/' . date('Ym') . '/big_' . $row['gid'] . '.jpg'; $goods['original_img'] = 'images/' . date('Ym') . '/original_' . $row['gid'] . '.jpg'; } elseif (file_exists($file. '.jpeg')) { $goods['goods_img'] = 'images/' . date('Ym') . '/big_' . $row['gid'] . '.jpeg'; $goods['original_img'] = 'images/' . date('Ym') . '/original_' . $row['gid'] . '.jpeg'; } elseif (file_exists($file. '.gif')) { $goods['goods_img'] = 'images/' . date('Ym') . '/big_' . $row['gid'] . '.gif'; $goods['original_img'] = 'images/' . date('Ym') . '/original_' . $row['gid'] . '.gif'; } elseif (file_exists($file. '.png')) { $goods['goods_img'] = 'images/' . date('Ym') . '/big_' . $row['gid'] . '.png'; $goods['orinigal_img'] = 'images/' . date('Ym') . '/original_' . $row['gid'] . '.png'; } else { $goods['goods_img'] = $row['bigimgremote']; } /* 积分:根据商店设置 */ if ($config['offer_pointtype'] == '0') { /* 不使用积分 */ $goods['integral'] = '0'; } elseif ($config['offer_pointtype'] == '1') { /* 按比例 */ $goods['integral'] = round($goods['shop_price'] * $config['offer_pointnum']); } else { /* 自定义 */ $goods['integral'] = $row['point']; } /* 插入 */ if (!$db->autoExecute($ecs->table('goods'), $goods, 'INSERT', '', 'SILENT')) { //return $db->error(); } /* 扩展分类 */ if ($row['linkclass'] != '') { $goods_cat = array(); $goods_cat['goods_id'] = $row['gid']; $cat_id_list = explode(',', trim($row['linkclass'], ',')); foreach ($cat_id_list as $cat_id) { $goods_cat['cat_id'] = $cat_id; if (!$db->autoExecute($ecs->table('goods_cat'), $goods_cat, 'INSERT', '', 'SILENT')) { //return $db->error(); } } } /* 取得该分类的所有属性 */ $sql = "SELECT DISTINCT pv.prop_id, pv.prop_value " . "FROM ".$this->sprefix."mall_goods_prop_grp_value AS gp, " . $this->sprefix."mall_prop_value AS pv " . "WHERE gp.prop_value_id = pv.prop_value_id " . "AND gp.gid = '$row[gid]'"; $res1 = $this->sdb->query($sql); while ($attr = $this->sdb->fetchRow($res1)) { $goods_attr = array(); $goods_attr['goods_id'] = $row['gid']; $goods_attr['attr_id'] = $attr['prop_id']; $goods_attr['attr_value'] = ecs_iconv($this->scharset, $this->tcharset, addslashes($attr['prop_value'])); $goods_attr['attr_price'] = '0'; if (!$db->autoExecute($ecs->table('goods_attr'), $goods_attr, 'INSERT', '', 'SILENT')) { //return $db->error(); } } /* 商品相册 */ if ($row['multi_image']) { $goods_gallery = array(); $goods_gallery['goods_id'] = $row['gid']; $img_list = explode('&&&', $row['multi_image']); foreach ($img_list as $img) { if (substr($img, 0, 7) == 'http://') { $goods_gallery['img_url'] = $img; } else { make_dir('images/' . date('Ym') . '/'); $goods_gallery['img_url'] = 'images/' . date('Ym') . '/big_' . $img; $goods_gallery['img_original'] = 'images/' . date('Ym') . '/original_' . $img; } if (!$db->autoExecute($ecs->table('goods_gallery'), $goods_gallery, 'INSERT', '', 'SILENT')) { //return $db->error(); } } } } /* 关联商品 */ $sql = "SELECT * FROM ".$this->sprefix."mall_offer_linkgoods"; $res = $this->sdb->query($sql); while ($row = $this->sdb->fetchRow($res)) { $link_goods = array(); $link_goods['goods_id'] = $row['pgid']; $link_goods['link_goods_id'] = $row['sgid']; $link_goods['is_double'] = $row['type']; if (!$db->autoExecute($ecs->table('link_goods'), $link_goods, 'INSERT', '', 'SILENT')) { //return $db->error(); } if ($row['type'] == '1') { $link_goods = array(); $link_goods['goods_id'] = $row['sgid']; $link_goods['link_goods_id'] = $row['pgid']; $link_goods['is_double'] = $row['type']; if (!$db->autoExecute($ecs->table('link_goods'), $link_goods, 'INSERT', '', 'SILENT')) { //return $db->error(); } } } /* 组合商品 */ $sql = "SELECT DISTINCT gid, prop_goods_id, price FROM ".$this->sprefix."mall_pcat_prop_has_goods"; $res = $this->sdb->query($sql); while ($row = $this->sdb->fetchRow($res)) { $group_goods = array(); $group_goods['parent_id'] = $row['gid']; $group_goods['goods_id'] = $row['prop_goods_id']; $group_goods['goods_price'] = $row['price']; if (!$db->autoExecute($ecs->table('group_goods'), $group_goods, 'INSERT', '', 'SILENT')) { //return $db->error(); } } /* 返回成功 */ return TRUE; }
$result['goods_id'] = stripslashes($goods->goods_id); if (is_array($goods->spec)) { $result['product_spec'] = implode(',', $goods->spec); } else { $result['product_spec'] = $goods->spec; } } } $result['confirm_type'] = !empty($_CFG['cart_confirm']) ? $_CFG['cart_confirm'] : 2; die($json->encode($result)); } elseif ($_REQUEST['step'] == 'checksendtime') { include_once 'includes/cls_json.php'; $sendtime = $_REQUEST['sendtime']; $result = array('error' => 0); $json = new JSON(); if ((int) local_date("H") >= 12 && local_date('Y-m-d', gmstr2time("1 day")) == $sendtime) { $result['error'] = 1; } die($json->encode($result)); } elseif ($_REQUEST['step'] == 'link_buy') { $goods_id = intval($_GET['goods_id']); if (!cart_goods_exists($goods_id, array())) { addto_cart($goods_id); } ecs_header("Location:./flow.php\n"); exit; } elseif ($_REQUEST['step'] == 'login') { include_once 'languages/' . $_CFG['lang'] . '/user.php'; /* * 用户登录注册 */
function _parse_taobao_csv($csv_string) { $records = explode("\n", trim($csv_string, "\n")); array_shift($records); // 去掉标题 foreach ($records as $key => $record) { // dump($records); $record = explode("\t", trim($record, "\t")); // 按制表符构建每一行数据 foreach ($record as $k => $col) { $col = trim($col); // 去掉数据两端的空格 $col = trim($col, "\\\""); // 去掉数据两端的\" $col = trim($col, "\""); // 去掉数据两端的" /* 对字段数据进行分别处理 */ switch ($k) { case FIELD_ADD_TIME: $record[$k] = $col == '1980-01-01 00:00:00' || $col == '' ? gmtime() : gmstr2time($col); break; case FIELD_LAST_UPDATE: $record[$k] = $col == '1980-01-01 00:00:00' || $col == '' ? $record[FIELD_ADD_TIME] : gmstr2time($col); break; case FIELD_DESCRIPTION: $record[$k] = str_replace(array("\\\"\\\"", "\"\""), array("\\\"", "\""), $col); break; case FIELD_GOODS_IMAGE: $record[$k] = substr($col, 0, strpos($col, ':')); break; case FIELD_IF_SHOW: $record[$k] = $col == 1 ? 0 : 1; break; case FIELD_GOODS_NAME: $record[$k] = $col; break; case FIELD_STOCK: $record[$k] = $col; break; case FIELD_PRICE: $record[$k] = $col; break; case FIELD_RECOMMENDED: $record[$k] = $col; break; case FIELD_GOODS_ATTR: $record[$k] = $col; break; case FIELD_SALE_ATTR: $record[$k] = $col; break; case FIELD_CID: $record[$k] = $col; break; default: unset($record[$k]); } } $records[$key] = $record; } return $records; }
function edit() { $coupon_id = isset($_GET['id']) ? intval($_GET['id']) : 0; $current_coupon = $this->_coupon_mod->get_info($coupon_id); if (empty($coupon_id)) { echo Lang::get("no_coupon"); } if (!IS_POST) { $this->import_resource(array('script' => array(array('path' => 'jquery.ui/jquery.ui.js', 'attr' => ''), array('path' => 'jquery.ui/i18n/' . i18n_code() . '.js', 'attr' => ''), array('path' => 'jquery.plugins/jquery.validate.js', 'attr' => '')), 'style' => 'jquery.ui/themes/ui-lightness/jquery.ui.css')); header("Content-Type:text/html;charset=" . CHARSET); $gcategory_mod =& bm('gcategory', array('store_id' => 0)); $this->assign('scategories', $this->_get_scategories()); $this->assign('sgrades', $this->_get_sgrade()); $this->assign('gcategories', $gcategory_mod->get_options(0)); $current_coupon['selected'] = array(); $current_coupon['selected'][$current_coupon['type']] = $current_coupon['type_content']; if ($current_coupon['coupon_image']) { $current_coupon['coupon_image'] = dirname(site_url()) . "/" . $current_coupon['coupon_image']; } $store_mod =& m('store'); $store = $store_mod->find(array('conditions' => 'state=1', 'fields' => 'store_name,store_id')); if ($current_coupon['type'] == 4) { $type_content = unserialize($current_coupon['type_content']); if (!empty($type_content)) { foreach ($type_content as $key => $val) { $store[$val]['selected'] = 1; } } } $this->assign('build_editor', $this->_build_editor(array('name' => 'tip', 'content_css' => SITE_URL . "/themes/mall/{$template_name}/styles/{$style_name}/css/ecmall.css"))); $this->assign('build_upload', $this->_build_upload(array('belong' => BELONG_ARTICLE, 'item_id' => 0))); // 构建swfupload上传组件 $this->assign('store', $store); $this->assign('coupon', $current_coupon); $this->display('coupon.form.html'); } else { if (!$current_coupon['if_issue']) { $coupon_value = floatval(trim($_POST['coupon_value'])); $use_times = intval(trim($_POST['use_times'])); $min_amount = floatval(trim($_POST['min_amount'])); if (empty($coupon_value) || $coupon_value < 0) { $this->show_warning('coupon_value_not'); exit; } if (empty($use_times)) { $this->show_warning('use_times_not_zero'); exit; } if ($min_amount < 0) { $this->show_warning("min_amount_gt_zero"); exit; } $start_time = gmstr2time(trim($_POST['start_time'])); $end_time = gmstr2time_end(trim($_POST['end_time'])) - 1; //echo gmstr2time_end(trim($_POST['end_time'])) . '-------' .$end_time;exit; if ($end_time < $start_time) { $this->show_warning('end_gt_start'); exit; } $coupon = array('coupon_name' => trim($_POST['coupon_name']), 'coupon_value' => $coupon_value, 'store_id' => 0, 'use_times' => $use_times, 'start_time' => $start_time, 'end_time' => $end_time, 'min_amount' => $min_amount, 'if_issue' => trim($_POST['if_issue']) == 1 ? 1 : 0, 'tip' => $_POST['tip'], 'open_agree_item' => $_POST['open_agree_item'], 'show_in_list' => $_POST['show_in_list']); if ($_POST['open_agree_item']) { $coupon['type_content'] = $_POST['type'] == 4 ? serialize($_POST['type_content'][$_POST['type']]) : $_POST['type_content'][$_POST['type']]; $coupon['type'] = $_POST['type']; } else { $coupon['type_content'] = ''; $coupon['type'] = ''; } /* 处理上传的图片 */ $coupon_image = $this->_upload_image($coupon_id); if ($coupon_image) { $coupon['coupon_image'] = $coupon_image; } if ($_POST['open_agree_item']) { $store_ids = $this->_save_store_coupon($_POST['type'], $_POST['type_content'][$_POST['type']], $coupon_id); if (trim($_POST['if_issue']) == 1) { if ($store_ids) { foreach ($store_ids as $key => $val) { $ms =& ms(); $content = get_msg(Lang::get('to_store_owner_who_can_use_coupon'), array('coupon_name' => $_POST['coupon_name'])); $ms->pm->send(MSG_SYSTEM, $val, '', $content); } } } } else { $store_coupon_mod =& m('store_coupon'); $store_coupon_mod->drop('coupon_id=' . $coupon_id); } } else { $coupon['if_issue'] = trim($_POST['if_issue']) == 1 ? 1 : 0; $coupon['tip'] = $_POST['tip']; } $this->_coupon_mod->edit($coupon_id, $coupon); if ($this->_coupon_mod->has_error()) { $this->show_warning($this->_coupon_mod->get_error()); exit; } $this->show_message('edit_coupon_success', 'back_list', 'index.php?app=coupon'); } }
/** * 检查提交的数据 */ function _handle_post_data($post, $id = 0) { if ($post['if_publish'] == 1 || gmstr2time($post['start_time']) <= gmtime()) { $post['start_time'] = gmtime(); //立即发布 $post['state'] = GROUP_ON; } else { $post['start_time'] = gmstr2time($post['start_time']); $post['state'] = GROUP_PENDING; } if (intval($post['end_time'])) { $post['end_time'] = gmstr2time_end($post['end_time']); } else { $this->_error('fill_end_time'); return false; } if ($post['end_time'] < $post['start_time']) { $this->_error('start_not_gt_end'); return false; } if (($post['goods_id'] = intval($post['goods_id'])) == 0) { $this->_error('fill_goods'); return false; } if (empty($post['spec_id']) || !is_array($post['spec_id'])) { $this->_error('fill_spec'); return false; } foreach ($post['spec_id'] as $key => $val) { if (empty($post['group_price'][$key])) { $this->_error('invalid_group_price'); return false; } $spec_price[$val] = array('price' => number_format($post['group_price'][$key], 2, '.', '')); } $data = array('group_name' => $post['group_name'], 'group_desc' => $post['group_desc'], 'start_time' => $post['start_time'], 'end_time' => $post['end_time'] - 1, 'goods_id' => $post['goods_id'], 'spec_price' => serialize($spec_price), 'min_quantity' => $post['min_quantity'], 'max_per_user' => $post['max_per_user'], 'state' => $post['state'], 'store_id' => $this->_store_id); if ($id > 0) { $this->_groupbuy_mod->edit($id, $data); if ($this->_groupbuy_mod->has_error()) { $this->_error($this->_groupbuy_mod->get_error()); return false; } } else { if (!($id = $this->_groupbuy_mod->add($data))) { $this->_error($this->_groupbuy_mod->get_error()); return false; } } $this->_last_update_id = $id; return true; }
/** * 获取订单列表信息 * * @access public * @param * * @return void */ function order_list() { $result = get_filter(); if ($result === false) { /* 过滤信息 */ $filter['order_sn'] = empty($_REQUEST['order_sn']) ? '' : trim($_REQUEST['order_sn']); if (!empty($_GET['is_ajax']) && $_GET['is_ajax'] == 1) { $_REQUEST['consignee'] = json_str_iconv($_REQUEST['consignee']); //$_REQUEST['address'] = json_str_iconv($_REQUEST['address']); } $filter['consignee'] = empty($_REQUEST['consignee']) ? '' : trim($_REQUEST['consignee']); $filter['email'] = empty($_REQUEST['email']) ? '' : trim($_REQUEST['email']); $filter['address'] = empty($_REQUEST['address']) ? '' : trim($_REQUEST['address']); $filter['zipcode'] = empty($_REQUEST['zipcode']) ? '' : trim($_REQUEST['zipcode']); $filter['tel'] = empty($_REQUEST['tel']) ? '' : trim($_REQUEST['tel']); $filter['mobile'] = empty($_REQUEST['mobile']) ? 0 : intval($_REQUEST['mobile']); $filter['country'] = empty($_REQUEST['country']) ? 0 : intval($_REQUEST['country']); $filter['province'] = empty($_REQUEST['province']) ? 0 : intval($_REQUEST['province']); $filter['city'] = empty($_REQUEST['city']) ? 0 : intval($_REQUEST['city']); $filter['district'] = empty($_REQUEST['district']) ? 0 : intval($_REQUEST['district']); $filter['shipping_id'] = empty($_REQUEST['shipping_id']) ? 0 : intval($_REQUEST['shipping_id']); $filter['pay_id'] = empty($_REQUEST['pay_id']) ? 0 : intval($_REQUEST['pay_id']); $filter['order_status'] = isset($_REQUEST['order_status']) ? intval($_REQUEST['order_status']) : -1; $filter['shipping_status'] = isset($_REQUEST['shipping_status']) ? intval($_REQUEST['shipping_status']) : -1; $filter['pay_status'] = isset($_REQUEST['pay_status']) ? intval($_REQUEST['pay_status']) : -1; $filter['user_id'] = empty($_REQUEST['user_id']) ? 0 : intval($_REQUEST['user_id']); $filter['user_name'] = empty($_REQUEST['user_name']) ? '' : trim($_REQUEST['user_name']); $filter['composite_status'] = isset($_REQUEST['composite_status']) ? intval($_REQUEST['composite_status']) : -1; $filter['group_buy_id'] = isset($_REQUEST['group_buy_id']) ? intval($_REQUEST['group_buy_id']) : 0; $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'add_time' : trim($_REQUEST['sort_by']); $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']); $filter['start_time'] = empty($_REQUEST['start_time']) ? '' : (strpos($_REQUEST['start_time'], '-') > 0 ? local_strtotime($_REQUEST['start_time']) : $_REQUEST['start_time']); $filter['end_time'] = empty($_REQUEST['end_time']) ? '' : (strpos($_REQUEST['end_time'], '-') > 0 ? local_strtotime($_REQUEST['end_time']) : $_REQUEST['end_time']); $filter['fahuostart_time'] = empty($_REQUEST['fahuostart_time']) ? '' : (strpos($_REQUEST['fahuostart_time'], '-') > 0 ? local_strtotime($_REQUEST['fahuostart_time']) : $_REQUEST['fahuostart_time']); $filter['fahuoend_time'] = empty($_REQUEST['fahuoend_time']) ? '' : (strpos($_REQUEST['fahuoend_time'], '-') > 0 ? local_strtotime($_REQUEST['fahuoend_time']) : $_REQUEST['fahuoend_time']); $filter['start_time2'] = empty($_REQUEST['start_time2']) ? '' : $_REQUEST['start_time2']; $filter['end_time2'] = empty($_REQUEST['end_time2']) ? '' : $_REQUEST['end_time2']; $filter['sameorder'] = empty($_REQUEST['sameorder']) ? 0 : intval($_REQUEST['sameorder']); $filter['second'] = empty($_REQUEST['second']) ? 0 : intval($_REQUEST['second']); $where = 'WHERE 1 '; if ($filter['sameorder']) { $where .= " AND o.consignee in\n (select consignee from " . $GLOBALS['ecs']->table('order_info') . " where order_status !=5 group by consignee having count(consignee) > 1) and o.order_status !=5"; } if ($filter['order_sn']) { $where .= " AND o.order_sn LIKE '%" . mysql_like_quote($filter['order_sn']) . "%'"; } if ($filter['consignee']) { $where .= " AND o.consignee LIKE '%" . mysql_like_quote($filter['consignee']) . "%'"; } if ($filter['email']) { $where .= " AND o.email LIKE '%" . mysql_like_quote($filter['email']) . "%'"; } if ($filter['address']) { $where .= " AND o.address LIKE '%" . mysql_like_quote($filter['address']) . "%'"; } if ($filter['zipcode']) { $where .= " AND o.zipcode LIKE '%" . mysql_like_quote($filter['zipcode']) . "%'"; } if ($filter['tel']) { $where .= " AND o.tel LIKE '%" . mysql_like_quote($filter['tel']) . "%'"; } if ($filter['mobile']) { $where .= " AND o.mobile LIKE '%" . mysql_like_quote($filter['mobile']) . "%'"; } if ($filter['country']) { $where .= " AND o.country = '{$filter['country']}'"; } if ($filter['province']) { $where .= " AND o.province = '{$filter['province']}'"; } if ($filter['city']) { $where .= " AND o.city = '{$filter['city']}'"; } if ($filter['district']) { $where .= " AND o.district = '{$filter['district']}'"; } if ($filter['shipping_id']) { $where .= " AND o.shipping_id = '{$filter['shipping_id']}'"; } if ($filter['pay_id']) { $where .= " AND o.pay_id = '{$filter['pay_id']}'"; } if ($filter['order_status'] != -1) { $where .= " AND o.order_status = '{$filter['order_status']}'"; } if ($filter['shipping_status'] != -1) { $where .= " AND o.shipping_status = '{$filter['shipping_status']}'"; } if ($filter['pay_status'] != -1) { $where .= " AND o.pay_status = '{$filter['pay_status']}'"; } if ($filter['user_id']) { $where .= " AND o.user_id = '{$filter['user_id']}'"; } if ($filter['user_name']) { $where .= " AND u.user_name LIKE '%" . mysql_like_quote($filter['user_name']) . "%'"; } if ($filter['start_time']) { $where .= " AND o.add_time >= '{$filter['start_time']}'"; } if ($filter['start_time2']) { $where .= " AND LEFT(o.best_time,10) >= '{$filter['start_time2']}'"; } if ($filter['end_time2']) { $where .= " AND LEFT(o.best_time,10) <= '{$filter['end_time2']}'"; } if ($filter['second']) { $where .= " AND LEFT(o.best_time,10) = '" . local_date('Y-m-d', gmstr2time("1 day")) . "'"; } if ($filter['end_time']) { $where .= " AND o.add_time <= '{$filter['end_time']}'"; } if ($filter['fahuostart_time']) { $where .= " AND o.shipping_time >= '{$filter['fahuostart_time']}'"; } if ($filter['fahuoend_time']) { $where .= " AND o.shipping_time <= '{$filter['fahuoend_time']}'"; } //综合状态 switch ($filter['composite_status']) { case CS_AWAIT_PAY: $where .= order_query_sql('await_pay'); break; case CS_AWAIT_SHIP: $where .= order_query_sql('await_ship'); break; case CS_FINISHED: $where .= order_query_sql('finished'); break; case PS_PAYING: if ($filter['composite_status'] != -1) { $where .= " AND o.pay_status = '{$filter['composite_status']}' "; } break; case OS_SHIPPED_PART: if ($filter['composite_status'] != -1) { $where .= " AND o.shipping_status = '{$filter['composite_status']}'-2 "; } break; default: if ($filter['composite_status'] != -1) { $where .= " AND o.order_status = '{$filter['composite_status']}' "; } } /* 团购订单 */ if ($filter['group_buy_id']) { $where .= " AND o.extension_code = 'group_buy' AND o.extension_id = '{$filter['group_buy_id']}' "; } /* 如果管理员属于某个办事处,只列出这个办事处管辖的订单 */ $sql = "SELECT agency_id FROM " . $GLOBALS['ecs']->table('admin_user') . " WHERE user_id = '{$_SESSION['admin_id']}'"; $agency_id = $GLOBALS['db']->getOne($sql); if ($agency_id > 0) { $where .= " AND o.agency_id = '{$agency_id}' "; } /* 分页大小 */ $filter['page'] = empty($_REQUEST['page']) || intval($_REQUEST['page']) <= 0 ? 1 : intval($_REQUEST['page']); if (isset($_REQUEST['page_size']) && intval($_REQUEST['page_size']) > 0) { $filter['page_size'] = intval($_REQUEST['page_size']); } elseif (isset($_COOKIE['ECSCP']['page_size']) && intval($_COOKIE['ECSCP']['page_size']) > 0) { $filter['page_size'] = intval($_COOKIE['ECSCP']['page_size']); } else { $filter['page_size'] = 15; } /* 记录总数 */ if ($filter['user_name']) { $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('order_info') . " AS o ," . $GLOBALS['ecs']->table('users') . " AS u " . $where; } else { $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('order_info') . " AS o " . $where; } //echo $sql; $filter['record_count'] = $GLOBALS['db']->getOne($sql); $filter['page_count'] = $filter['record_count'] > 0 ? ceil($filter['record_count'] / $filter['page_size']) : 1; /* 查询 */ $sql = "SELECT o.order_id, o.order_sn, o.add_time, o.order_status, o.shipping_status, o.order_amount, o.money_paid," . "o.pay_status, o.consignee, o.address, o.email, o.tel, o.extension_code, o.extension_id, " . "(" . order_amount_field('o.') . ") AS total_fee, " . "IFNULL(u.user_name, '" . $GLOBALS['_LANG']['anonymous'] . "') AS buyer " . " FROM " . $GLOBALS['ecs']->table('order_info') . " AS o " . " LEFT JOIN " . $GLOBALS['ecs']->table('users') . " AS u ON u.user_id=o.user_id " . $where . " ORDER BY {$filter['sort_by']} {$filter['sort_order']} " . " LIMIT " . ($filter['page'] - 1) * $filter['page_size'] . ",{$filter['page_size']}"; foreach (array('order_sn', 'consignee', 'email', 'address', 'zipcode', 'tel', 'user_name') as $val) { $filter[$val] = stripslashes($filter[$val]); } set_filter($filter, $sql); } else { $sql = $result['sql']; $filter = $result['filter']; } $row = $GLOBALS['db']->getAll($sql); /* 格式话数据 */ foreach ($row as $key => $value) { $row[$key]['formated_order_amount'] = price_format($value['order_amount']); $row[$key]['formated_money_paid'] = price_format($value['money_paid']); $row[$key]['formated_total_fee'] = price_format($value['total_fee']); $row[$key]['short_order_time'] = local_date('m-d H:i', $value['add_time']); if ($value['order_status'] == OS_INVALID || $value['order_status'] == OS_CANCELED) { /* 如果该订单为无效或取消则显示删除链接 */ $row[$key]['can_remove'] = 1; } else { $row[$key]['can_remove'] = 0; } } $arr = array('orders' => $row, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']); return $arr; }
function edit() { $id = empty($_GET['id']) ? 0 : intval($_GET['id']); if (!IS_POST) { /* 是否存在 */ $store = $this->_store_mod->get_info($id); if (!$store) { $this->show_warning('store_empty'); return; } if ($store['certification']) { $certs = explode(',', $store['certification']); foreach ($certs as $cert) { $store['cert_' . $cert] = 1; } } $this->assign('store', $store); $sgrade_mod =& m('sgrade'); $this->assign('sgrades', $sgrade_mod->get_options()); $this->assign('states', array(STORE_OPEN => Lang::get('open'), STORE_CLOSED => Lang::get('close'))); $this->assign('recommended_options', array('1' => Lang::get('yes'), '0' => Lang::get('no'))); $region_mod =& m('region'); $this->assign('regions', $region_mod->get_options(0)); $this->assign('scategories', $this->_get_scategory_options()); $scates = $this->_store_mod->getRelatedData('has_scategory', $id); $this->assign('scates', array_values($scates)); /* 导入jQuery的表单验证插件 */ $this->import_resource(array('script' => 'jquery.plugins/jquery.validate.js,mlselection.js')); $this->assign('enabled_subdomain', ENABLED_SUBDOMAIN); $this->display('store.form.html'); } else { /* 检查名称是否已存在 */ if (!$this->_store_mod->unique(trim($_POST['store_name']), $id)) { $this->show_warning('name_exist'); return; } $store_info = $this->_store_mod->get_info($id); $domain = empty($_POST['domain']) ? '' : trim($_POST['domain']); if ($domain && $domain != $store_info['domain']) { if (!$this->_store_mod->check_domain($domain, Conf::get('subdomain_reserved'), Conf::get('subdomain_length'))) { $this->show_warning($this->_store_mod->get_error()); return; } } $data = array('store_name' => $_POST['store_name'], 'owner_name' => $_POST['owner_name'], 'owner_card' => $_POST['owner_card'], 'region_id' => $_POST['region_id'], 'region_name' => $_POST['region_name'], 'address' => $_POST['address'], 'zipcode' => $_POST['zipcode'], 'tel' => $_POST['tel'], 'sgrade' => $_POST['sgrade'], 'end_time' => empty($_POST['end_time']) ? 0 : gmstr2time(trim($_POST['end_time'])), 'state' => $_POST['state'], 'sort_order' => $_POST['sort_order'], 'recommended' => $_POST['recommended'], 'domain' => $domain); $data['state'] == STORE_CLOSED && ($data['close_reason'] = $_POST['close_reason']); $certs = array(); isset($_POST['autonym']) && ($certs[] = 'autonym'); isset($_POST['material']) && ($certs[] = 'material'); $data['certification'] = join(',', $certs); $old_info = $this->_store_mod->get_info($id); // 修改前的店铺信息 $this->_store_mod->edit($id, $data); $this->_store_mod->unlinkRelation('has_scategory', $id); $cate_id = intval($_POST['cate_id']); if ($cate_id > 0) { $this->_store_mod->createRelation('has_scategory', $id, $cate_id); } /* 如果修改了店铺状态,通知店主 */ if ($old_info['state'] != $data['state']) { $ms =& ms(); if ($data['state'] == STORE_CLOSED) { // 关闭店铺 $subject = Lang::get('close_store_notice'); //$content = sprintf(Lang::get(), $data['close_reason']); $content = get_msg('toseller_store_closed_notify', array('reason' => $data['close_reason'])); } else { // 开启店铺 $subject = Lang::get('open_store_notice'); $content = Lang::get('toseller_store_opened_notify'); } $ms->pm->send(MSG_SYSTEM, $old_info['store_id'], '', $content); $this->_mailto($old_info['email'], $subject, $content); } $ret_page = isset($_GET['ret_page']) ? intval($_GET['ret_page']) : 1; $this->show_message('edit_ok', 'back_list', 'index.php?app=store&page=' . $ret_page, 'edit_again', 'index.php?app=store&act=edit&id=' . $id); } }
$goodslist = $db->getAll("select g.goods_name,g.shop_price,g.goods_sn,g.goods_id from " . $ecs->table("goods") . " g where g.goods_id " . db_create_in($goodsid) . " "); $ngoodslist = array(); $gnums = unserialize($taocan['gnums']); foreach ($goodslist as $n) { foreach ($goodsid as $j => $id) { if ($n['goods_id'] == $id) { $n['goods_num'] = $gnums[$j]; $ngoodslist[] = $n; } } } $totalprice = 0; foreach ($goodslist as $g) { $totalprice += $g['shop_price']; } $order = array('order_sn' => get_order_sn(), 'user_id' => $taocan['user_id'], 'shipping_name' => '黑猫宅急便', 'shipping_id' => 2, 'order_status' => OS_CONFIRMED, 'shipping_status' => SS_UNSHIPPED, 'pay_status' => PS_PAYED, 'consignee' => $taocan['consignee'], 'country' => $taocan['country'], 'province' => $taocan['province'], 'city' => $taocan['city'], 'district' => $taocan['district'], 'address' => $taocan['address'], 'zipcode' => $taocan['zipcode'], 'tel' => '', 'mobile' => $taocan['mobile'], 'email' => $taocan['email'], 'best_time' => local_date('Y-m-d', gmstr2time("1 day")) . " " . $taocan['halfday'], 'sign_building' => '', 'email' => $taocan['email'], 'pay_id' => '4', 'pay_name' => '余额支付', 'goods_amount' => $totalprice, 'money_paid' => $ordertotalprice, 'order_amount' => $ordertotalprice, 'referer' => '用户套餐自动生成', 'add_time' => gmtime(), 'confirm_time' => gmtime(), 'pay_time' => gmtime(), 'shipping_time' => gmtime(), 'discount' => $totalprice - $ordertotalprice); // Add by Edward //fwrite($james,"订单号:".get_order_sn()."--用户ID:".$taocan['user_id']."——收货人:".$taocan['consignee']."\n"); $GLOBALS['db']->autoExecute($GLOBALS['ecs']->table('order_info'), $order, 'INSERT'); $new_order_id = $db->insert_id(); foreach ($ngoodslist as $goods) { $ogoods = array('order_id' => $new_order_id, 'goods_id' => $goods['goods_id'], 'goods_name' => $goods['goods_name'], 'goods_sn' => $goods['goods_sn'], 'product_id' => '0', 'goods_number' => $goods['goods_num'], 'goods_price' => $goods['shop_price'], 'goods_attr' => '', 'send_number' => '0', 'is_real' => '1', 'extension_code' => '', 'parent_id' => '', 'is_gift' => '0', 'goods_attr_id' => ''); $GLOBALS['db']->autoExecute($GLOBALS['ecs']->table('order_goods'), $ogoods, 'INSERT'); } //添加日志 order_action($order['order_sn'], OS_CONFIRMED, SS_UNSHIPPED, PS_PAYED, '', '套餐自动生成订单'); log_account_change($order['user_id'], -$ordertotalprice, 0, 0, 0, '用户套餐自动生成订单:' . $order['order_sn'] . ',自动扣除', ACT_OTHER); $db->query("update " . $ecs->table("user_tc_goods") . " set weeks = " . $weeks . " where id=" . $taocan['tid']); } $db->query("update " . $ecs->table("taocan_job") . " set last_date='" . gmtime() . "', weeks = " . $weeks . ""); }
/** * 检查提交的数据 */ function _handle_post_data($post, $id = 0) { if (gmstr2time($post['start_time']) <= gmtime()) { $post['start_time'] = gmtime(); } else { $post['start_time'] = gmstr2time($post['start_time']); } if (intval($post['end_time'])) { $post['end_time'] = gmstr2time_end($post['end_time']); } else { $this->_error('fill_end_time'); return false; } if ($post['end_time'] < $post['start_time']) { $this->_error('start_not_gt_end'); return false; } if (($post['goods_id'] = intval($post['goods_id'])) == 0) { $this->_error('fill_goods'); return false; } if ($id == 0 && $this->_promotion_mod->get(array('conditions' => 'goods_id=' . $post['goods_id']))) { $this->_error('goods_has_set_promotion'); return false; } if (empty($post['spec_id']) || !is_array($post['spec_id'])) { $this->_error('fill_spec'); return false; } $spec_id_yx = array(); //print_r($post['spec_id']);exit; foreach ($post['spec_id'] as $key => $val) { if (empty($post['pro_price' . $val])) { $this->_error('invalid_pro_price'); return false; } $spec_id_yx[] = $val; $spec_price[$val] = array('price' => $post['pro_price' . $val], 'pro_type' => $post['pro_type' . $val], 'is_pro' => 1); } // 取得所有 spec_id,对未设置的进行处理 $goods_info = $this->_query_goods_info($post['goods_id']); foreach ($goods_info['_specs'] as $spec) { if (!in_array($spec['spec_id'], $spec_id_yx)) { $spec_price[$spec['spec_id']] = array('is_pro' => 0); // 设置未选中的 spec_id } } //print_r($spec_price);exit; $data = array('pro_name' => $post['pro_name'], 'pro_desc' => $post['pro_desc'], 'start_time' => $post['start_time'], 'end_time' => $post['end_time'] - 1, 'goods_id' => $post['goods_id'], 'spec_price' => serialize($spec_price), 'store_id' => $this->_store_id); if ($id > 0) { $this->_promotion_mod->edit($id, $data); if ($this->_promotion_mod->has_error()) { $this->_error($this->_promotion_mod->get_error()); return false; } } else { if (!($id = $this->_promotion_mod->add($data))) { $this->_error($this->_promotion_mod->get_error()); return false; } } $this->_last_update_id = $id; return true; }