Exemple #1
0
 /**
  * 获取商品价格
  * @param int $goods_id 商品ID
  * @param float $sell_price 商品销售价
  */
 public static function price($goods_id, $sell_price)
 {
     if (self::$countsumInstance == null) {
         self::$countsumInstance = new CountSum();
     }
     $price = self::$countsumInstance->getGroupPrice($goods_id);
     return $price ? $price : $sell_price;
 }
Exemple #2
0
 /**
  * @brief 商品检索,可以直接读取 $_GET 全局变量:attr,order,brand,min_price,max_price
  *        在检索商品过程中计算商品结果中的进一步属性和规格的筛选
  * @param mixed $defaultWhere string(条件) or array('search' => '模糊查找','category_extend' => '商品分类ID','字段' => 对应数据)
  * @param int $limit 读取数量
  * @param bool $isCondition 是否筛选出商品的属性,价格等数据
  * @return IQuery
  */
 public static function find($defaultWhere = '', $limit = 21, $isCondition = true)
 {
     //获取配置信息
     $siteConfigObj = new Config("site_config");
     $site_config = $siteConfigObj->getInfo();
     $orderArray = array();
     //排序
     //开始查询
     $goodsObj = new IQuery("goods as go");
     $goodsObj->page = isset($_GET['page']) ? intval($_GET['page']) : 1;
     $goodsObj->fields = ' go.* ';
     $goodsObj->pagesize = $limit;
     /*where条件拼接*/
     //(1),当前产品分类
     $where = ' go.is_del = 0 ';
     //(2),商品属性,规格筛选
     $attrCond = array();
     $childSql = '';
     $attrArray = IReq::get('attr') ? IFilter::act(IReq::get('attr')) : array();
     foreach ($attrArray as $key => $val) {
         if ($key && $val) {
             $attrCond[] = ' attribute_id = ' . intval($key) . ' and FIND_IN_SET("' . $val . '",attribute_value)';
         }
     }
     //合并规格与属性的值,并且生成SQL查询语句
     $GoodsId = null;
     if ($attrCond) {
         $tempArray = array();
         foreach ($attrCond as $key => $cond) {
             $tempArray[] = '(' . $cond . ')';
         }
         $childSql = join(' or ', $tempArray);
         $goodsAttrObj = new IQuery('goods_attribute');
         $goodsAttrObj->fields = 'goods_id';
         $goodsAttrObj->where = $childSql;
         $goodsAttrObj->group = 'goods_id';
         $goodsAttrObj->having = 'count(goods_id) >= ' . count($attrCond);
         //每个子条件都有一条记录,则存在几个count(条件)必须包含count(goods_id)条数量
         $goodsIdArray = $goodsAttrObj->find();
         $goodsIds = array();
         foreach ($goodsIdArray as $key => $val) {
             $goodsIds[] = $val['goods_id'];
         }
         $GoodsId = $GoodsId === null ? array_unique($goodsIds) : array_unique(array_intersect($goodsIds, $GoodsId));
     }
     //(3),处理defaultWhere条件 goods, category_extend
     if ($defaultWhere) {
         //兼容array 和 string 数据类型的goods条件筛选
         $goodsCondArray = array();
         if (is_string($defaultWhere)) {
             $goodsCondArray[] = $defaultWhere;
         } else {
             if (is_array($defaultWhere)) {
                 foreach ($defaultWhere as $key => $val) {
                     if (!$val) {
                         continue;
                     }
                     //商品分类检索
                     if ($key == 'category_extend') {
                         $currentCatGoods = array();
                         $categoryExtendObj = new IModel('category_extend');
                         $categoryExtendList = $categoryExtendObj->query("category_id in (" . $val . ")", 'goods_id', 'id', 'desc');
                         foreach ($categoryExtendList as $key => $val) {
                             $currentCatGoods[] = $val['goods_id'];
                         }
                         $GoodsId = $GoodsId === null ? array_unique($currentCatGoods) : array_unique(array_intersect($currentCatGoods, $GoodsId));
                     } else {
                         if ($key == 'search') {
                             $wordWhere = array();
                             $wordLikeOrder = array();
                             //检查输入的内容是否为分词形式
                             if (preg_match("#\\s+#", $defaultWhere['search']) == false) {
                                 $wordWhere[] = ' name like "%' . $defaultWhere['search'] . '%" or find_in_set("' . $defaultWhere['search'] . '",search_words) ';
                                 $wordLikeOrder[] = $defaultWhere['search'];
                             }
                             //进行分词
                             if (IString::getStrLen($defaultWhere['search']) >= 4 || IString::getStrLen($defaultWhere['search']) <= 100) {
                                 $wordData = words_facade::run($defaultWhere['search']);
                                 if (isset($wordData['data']) && count($wordData['data']) >= 2) {
                                     foreach ($wordData['data'] as $word) {
                                         $wordWhere[] = ' name like "%' . $word . '%" ';
                                         $wordLikeOrder[] = $word;
                                     }
                                 }
                             }
                             //分词排序
                             if (count($wordLikeOrder) > 1) {
                                 $orderTempArray = array();
                                 foreach ($wordLikeOrder as $key => $val) {
                                     $orderTempArray[] = "(CASE WHEN name LIKE '%" . $val . "%' THEN " . $key . " ELSE 100 END)";
                                 }
                                 $orderArray[] = " (" . join('+', $orderTempArray) . ") asc ";
                             }
                             $goodsCondArray[] = join(' or ', $wordWhere);
                         } else {
                             $goodsCondArray[] = $key . ' = "' . $val . '"';
                         }
                     }
                 }
             }
         }
         //goods 条件
         if ($goodsCondArray) {
             $goodsDB = new IModel('goods as go');
             $goodsCondData = $goodsDB->query(join(" and ", $goodsCondArray), "id");
             $goodsCondId = array();
             foreach ($goodsCondData as $key => $val) {
                 $goodsCondId[] = $val['id'];
             }
             $GoodsId = $GoodsId === null ? array_unique($goodsCondId) : array_unique(array_intersect($goodsCondId, $GoodsId));
         }
     }
     //过滤商品ID被删除的情况
     if ($GoodsId) {
         if (!isset($goodsDB)) {
             $goodsDB = new IModel("goods as go");
         }
         $goodsCondData = $goodsDB->query("go.id in (" . join(',', $GoodsId) . ") and go.is_del = 0 ", "id");
         $GoodsId = array();
         foreach ($goodsCondData as $key => $val) {
             $GoodsId[] = $val['id'];
         }
     }
     $GoodsId = $GoodsId === array() || $GoodsId === null ? array(0) : array_unique($GoodsId);
     //存在商品ID数据
     if ($GoodsId) {
         $GoodsId = array_slice($GoodsId, 0, search_goods::MAX_GOODSID);
         $where .= " and go.id in (" . join(',', $GoodsId) . ") ";
         //商品属性进行检索
         if ($isCondition == true) {
             /******属性 开始******/
             $attrTemp = array();
             $goodsAttrDB = new IModel('goods_attribute');
             $attrData = $goodsAttrDB->query("goods_id in (" . join(',', $GoodsId) . ")");
             foreach ($attrData as $key => $val) {
                 //属性
                 if ($val['attribute_id']) {
                     if (!isset($attrTemp[$val['attribute_id']])) {
                         $attrTemp[$val['attribute_id']] = array();
                     }
                     $checkSelectedArray = explode(",", $val['attribute_value']);
                     foreach ($checkSelectedArray as $k => $v) {
                         if (!in_array($v, $attrTemp[$val['attribute_id']])) {
                             $attrTemp[$val['attribute_id']][] = $v;
                         }
                     }
                 }
             }
             //属性的数据拼接
             if ($attrTemp) {
                 $attrDB = new IModel('attribute');
                 $attrData = $attrDB->query("id in (" . join(',', array_keys($attrTemp)) . ") and search = 1", "*", "id", "asc", 8);
                 foreach ($attrData as $key => $val) {
                     self::$attrSearch[] = array('id' => $val['id'], 'name' => $val['name'], 'value' => $attrTemp[$val['id']]);
                 }
             }
             /******属性 结束******/
             /******品牌 开始******/
             $brandQuery = new IModel('brand as b,goods as go');
             self::$brandSearch = $brandQuery->query("go.brand_id = b.id and go.id in (" . join(',', $GoodsId) . ")", "distinct b.id,b.name", "b.sort", "asc", 10);
             /******品牌 结束******/
             /******价格 开始******/
             self::$priceSearch = goods_class::getGoodsPrice(join(',', $GoodsId));
             /******价格 结束******/
         }
     }
     //(4),商品价格
     $where .= floatval(IReq::get('min_price')) ? ' and go.sell_price >= ' . floatval(IReq::get('min_price')) : '';
     $where .= floatval(IReq::get('max_price')) ? ' and go.sell_price <= ' . floatval(IReq::get('max_price')) : '';
     //(5),商品品牌
     $where .= intval(IReq::get('brand')) ? ' and go.brand_id = ' . intval(IReq::get('brand')) : '';
     //排序类别
     $order = IFilter::act(IReq::get('order'), 'url');
     if ($order == null) {
         $order = isset($site_config['order_by']) ? $site_config['order_by'] : 'new';
         $asc = isset($site_config['order_type']) ? $site_config['order_type'] : 'desc';
     } else {
         if (stripos($order, '_toggle')) {
             $order = str_replace('_toggle', '', $order);
             $asc = 'asc';
         } else {
             $asc = 'desc';
         }
     }
     switch ($order) {
         //销售量
         case "sale":
             $orderArray[] = ' go.sale ' . $asc;
             break;
             //评分
         //评分
         case "cpoint":
             $orderArray[] = ' go.grade ' . $asc;
             break;
             //最新上架
         //最新上架
         case "new":
             $orderArray[] = ' go.id ' . $asc;
             break;
             //价格
         //价格
         case "price":
             $orderArray[] = ' go.sell_price ' . $asc;
             break;
             //根据排序字段
         //根据排序字段
         default:
             $orderArray[] = ' go.sort asc ';
     }
     //设置IQuery类的各个属性
     $goodsObj->where = $where;
     $goodsObj->order = join(',', $orderArray);
     return $goodsObj;
 }
Exemple #3
0
 public function goods_del()
 {
     //post数据
     $id = IFilter::act(IReq::get('id'), 'int');
     //生成goods对象
     $goods = new goods_class();
     $goods->seller_id = $this->seller['seller_id'];
     if ($id) {
         if (is_array($id)) {
             foreach ($id as $key => $val) {
                 $goods->del($val);
             }
         } else {
             $goods->del($id);
         }
     }
     $this->redirect("goods_list");
 }
Exemple #4
0
 /**
  * @brief 商品分类列表
  */
 function category_list()
 {
     //加载分类
     $tb_category = new IModel('category');
     $goods = new goods_class();
     $this->data['category'] = $goods->sortdata($tb_category->query(false, '*', 'sort', 'asc'));
     $this->setRenderData($this->data);
     $this->redirect('category_list', false);
 }
Exemple #5
0
 /**
  * @brief 商品分类列表
  */
 function category_list()
 {
     $isCache = false;
     $tb_category = new IModel('category');
     $cacheObj = new ICache('file');
     $data = $cacheObj->get('sortdata');
     if (!$data) {
         $goods = new goods_class();
         $data = $goods->sortdata($tb_category->query(false, '*', 'sort', 'asc'));
         $isCache ? $cacheObj->set('sortdata', $data) : "";
     }
     $this->data['category'] = $data;
     $this->setRenderData($this->data);
     $this->redirect('category_list', false);
 }
Exemple #6
0
<?php

$goods_class = new goods_class();
$tb_category = new IModel('category');
$category = $goods_class->sortdata($tb_category->query(false, '*', 'sort', 'asc'), 0, '--');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理后台</title>
<link rel="stylesheet" href="<?php 
echo IUrl::creatUrl("") . "views/" . $this->theme . "/skin/" . $this->skin . "/css/admin.css";
?>
" />
<script type="text/javascript" charset="UTF-8" src="<?php 
echo BASE_URL;
?>
/runtime/_systemjs/jquery/jquery-1.11.3.min.js"></script><script type="text/javascript" charset="UTF-8" src="<?php 
echo BASE_URL;
?>
/runtime/_systemjs/jquery/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript" charset="UTF-8" src="<?php 
echo BASE_URL;
?>
/runtime/_systemjs/artdialog/artDialog.js"></script><script type="text/javascript" charset="UTF-8" src="<?php 
echo BASE_URL;
?>
/runtime/_systemjs/artdialog/plugins/iframeTools.js"></script><link rel="stylesheet" type="text/css" href="<?php 
echo BASE_URL;
?>
Exemple #7
0
				<tr>
					<td></td>
					<td><button class="submit" type="submit" onclick="return checkForm()"><span>发布商品</span></button></td>
				</tr>
			</table>
		</form>
	</div>
</div>

<script language="javascript">
//创建表单实例
var formObj = new Form('goodsForm');

//默认货号
var defaultProductNo = '<?php 
echo goods_class::createGoodsNo();
?>
';

$(function()
{
	initProductTable();

	//存在商品信息
	<?php 
if (isset($form)) {
    ?>
	var goods = <?php 
    echo JSON::encode($form);
    ?>
;
Exemple #8
0
 » <a href="<?php 
    echo IUrl::creatUrl("/site/pro_list/cat/" . $item['id'] . "");
    ?>
"><?php 
    echo isset($item['name']) ? $item['name'] : "";
    ?>
</a><?php 
}
?>
</div>

<div class="wrapper clearfix container_2">
	<div class="sidebar f_l">
		<!--侧边栏分类-->
		<?php 
$catSide = goods_class::catTree($this->catId);
?>
		<?php 
if ($catSide) {
    ?>
		<div class="box_2 m_10">
			<div class="title"><?php 
    echo isset($this->catRow['name']) ? $this->catRow['name'] : "";
    ?>
</div>
			<div class="content">
				<?php 
    foreach ($catSide as $key => $first) {
        ?>
				<dl class="clearfix">
					<dt><a href="<?php 
Exemple #9
0
?>
<script type="text/javascript" charset="UTF-8" src="<?php 
echo BASE_URL;
?>
/runtime/_systemjs/artTemplate/artTemplate.js"></script><script type="text/javascript" charset="UTF-8" src="<?php 
echo BASE_URL;
?>
/runtime/_systemjs/artTemplate/artTemplate-plugin.js"></script>
<script type="text/javascript" charset="UTF-8" src="<?php 
echo BASE_URL;
?>
/runtime/_systemjs/cookie/jquery.cookie.js"></script>
<?php 
$shareInstance = new Share();
$shareInstance->show();
$breadGuide = goods_class::catRecursion($category);
?>

<link rel="stylesheet" type="text/css" href="<?php 
echo IUrl::creatUrl("") . "views/" . $this->theme . "/javascript/jquery.jqzoom/css/jquery.jqzoom.css";
?>
" />
<script type="text/javascript" src="<?php 
echo IUrl::creatUrl("") . "views/" . $this->theme . "/javascript/jquery.jqzoom/js/jquery.jqzoom-core-pack.js";
?>
"></script>

<link rel="stylesheet" type="text/css" href="<?php 
echo IUrl::creatUrl("") . "views/" . $this->theme . "/javascript/jquery.bxSlider/jquery.bxslider.css";
?>
" />
Exemple #10
0
 /**
  * @brief 获取订单中的支付信息 M:必要信息; R表示店铺; P表示用户;
  * @param $payment_id int    支付方式ID
  * @param $type       string 信息获取方式 order:订单支付;recharge:在线充值;
  * @param $argument   mix    参数
  * @return array 支付提交信息
  */
 public static function getPaymentInfo($payment_id, $type, $argument)
 {
     //最终返回值
     $payment = array();
     //初始化配置参数
     $paymentInstance = Payment::createPaymentInstance($payment_id);
     $configParam = $paymentInstance->configParam();
     foreach ($configParam as $key => $val) {
         $payment[$key] = '';
     }
     //获取公共信息
     $paymentRow = self::getPaymentById($payment_id, 'config_param');
     if ($paymentRow) {
         $paymentRow = JSON::decode($paymentRow);
         foreach ($paymentRow as $key => $item) {
             $payment[$key] = $item;
         }
     }
     if ($type == 'order') {
         $orderIdArray = $argument;
         $M_Amount = 0;
         $M_OrderNO = array();
         foreach ($orderIdArray as $key => $order_id) {
             //获取订单信息
             $orderObj = new IModel('order');
             $orderRow = $orderObj->getObj('id = ' . $order_id . ' and status = 1');
             if (empty($orderRow)) {
                 IError::show(403, '订单信息不正确,不能进行支付');
             }
             //判断商品库存
             $orderGoodsDB = new IModel('order_goods');
             $orderGoodsList = $orderGoodsDB->query('order_id = ' . $order_id);
             foreach ($orderGoodsList as $key => $val) {
                 if (!goods_class::checkStore($val['goods_nums'], $val['goods_id'], $val['product_id'])) {
                     IError::show(403, '商品库存不足无法支付,请重新下单');
                 }
             }
             $M_Amount += $orderRow['order_amount'];
             $M_OrderNO[] = $orderRow['order_no'];
         }
         $payment['M_Remark'] = $orderRow['postscript'];
         $payment['M_OrderId'] = $orderRow['id'];
         $payment['M_OrderNO'] = $orderRow['order_no'];
         $payment['M_Amount'] = $M_Amount;
         //用户信息
         $payment['P_Mobile'] = $orderRow['mobile'];
         $payment['P_Name'] = $orderRow['accept_name'];
         $payment['P_PostCode'] = $orderRow['postcode'];
         $payment['P_Telephone'] = $orderRow['telphone'];
         $payment['P_Address'] = $orderRow['address'];
         //订单批量结算缓存机制
         $cacheObj = new ICache('file');
         $cacheObj->set($payment['M_OrderNO'], join(",", $M_OrderNO));
     } else {
         if ($type == 'recharge') {
             if (ISafe::get('user_id') == null) {
                 IError::show(403, '请登录系统');
             }
             if (!isset($argument['account']) || $argument['account'] <= 0) {
                 IError::show(403, '请填入正确的充值金额');
             }
             $rechargeObj = new IModel('online_recharge');
             $reData = array('user_id' => ISafe::get('user_id'), 'recharge_no' => Order_Class::createOrderNum(), 'account' => $argument['account'], 'time' => ITime::getDateTime(), 'payment_name' => $argument['paymentName']);
             $rechargeObj->setData($reData);
             $r_id = $rechargeObj->add();
             //充值时用户id跟随交易号一起发送,以"_"分割
             $payment['M_OrderNO'] = 'recharge' . $reData['recharge_no'];
             $payment['M_OrderId'] = $r_id;
             $payment['M_Amount'] = $reData['account'];
         }
     }
     $siteConfigObj = new Config("site_config");
     $site_config = $siteConfigObj->getInfo();
     //交易信息
     $payment['M_Time'] = time();
     $payment['M_Paymentid'] = $payment_id;
     //店铺信息
     $payment['R_Address'] = isset($site_config['address']) ? $site_config['address'] : '';
     $payment['R_Name'] = isset($site_config['name']) ? $site_config['name'] : '';
     $payment['R_Mobile'] = isset($site_config['mobile']) ? $site_config['mobile'] : '';
     $payment['R_Telephone'] = isset($site_config['phone']) ? $site_config['phone'] : '';
     return $payment;
 }
Exemple #11
0
 /**
  * @brief 商品分类列表
  */
 function category_list()
 {
     //加载模型
     $tb_model = new IModel('model');
     $models = $tb_model->query();
     $model_info = array();
     foreach ($models as $value) {
         $model_info[$value['id']] = $value['name'];
     }
     $this->data['models'] = $model_info;
     //加载分类
     $tb_category = new IModel('category');
     $goods = new goods_class();
     $this->data['category'] = $goods->sortdata($tb_category->query(false, '*', 'sort', 'asc'));
     $this->setRenderData($this->data);
     $this->redirect('category_list', false);
 }
Exemple #12
0
						<dt>价格:</dt>
						<dd id='price_dd'>
							<p class="f_r"><input type="text" class="mini" name="min_price" value="<?php 
echo IReq::get('min_price');
?>
" onchange="checkPrice(this);"> 至 <input type="text" class="mini" name="max_price" onchange="checkPrice(this);" value="<?php 
echo IReq::get('max_price');
?>
"> 元
							<label class="btn_gray_s"><input type="button" onclick="priceLink();" value="确定"></label></p>
							<a class="nolimit current" href="<?php 
echo block::searchUrl(array('min_price', 'max_price'), '');
?>
">不限</a>
							<?php 
$goodsPrice = goods_class::getGoodsPrice($this->childId);
?>
							<?php 
foreach ($goodsPrice as $key => $item) {
    ?>
								<?php 
    $priceZone = explode('-', $item);
    ?>
								<a href="<?php 
    echo block::searchUrl(array('min_price', 'max_price'), array($priceZone[0], $priceZone[1]));
    ?>
" id="<?php 
    echo isset($priceZone[0]) ? $priceZone[0] : "";
    ?>
-<?php 
    echo isset($priceZone[1]) ? $priceZone[1] : "";
Exemple #13
0
 function pro_list()
 {
     $this->catId = IFilter::act(IReq::get('cat'), 'int');
     //分类id
     if ($this->catId == 0) {
         IError::show(403, '缺少分类ID');
     }
     //查找分类信息
     $catObj = new IModel('category');
     $this->catRow = $catObj->getObj('id = ' . $this->catId);
     if ($this->catRow == null) {
         IError::show(403, '此分类不存在');
     }
     //获取子分类
     $this->childId = goods_class::catChild($this->catId);
     $this->redirect('pro_list');
 }
Exemple #14
0
 /**
  * @brief 开始运行
  */
 public static function run()
 {
     set_time_limit(0);
     ini_set("max_execution_time", 0);
     $csvType = IReq::get('csvType');
     $category = IFilter::act(IReq::get('category'), 'int');
     $pluginDir = IWeb::$app->getBasePath() . 'plugins/csvPacketHelper/';
     if (!file_exists($pluginDir)) {
         die('此功能仅供授权版本使用,请您购买商业授权');
     }
     if (!class_exists('ZipArchive')) {
         die('服务器环境中没有安装zip扩展,无法使用此功能');
     }
     if (extension_loaded('mbstring') == false) {
         die('服务器环境中没有安装mbstring扩展,无法使用此功能');
     }
     //处理上传
     $uploadInstance = new IUpload(9999999, array('zip'));
     $uploadCsvDir = 'runtime/cvs/' . date('YmdHis');
     $uploadInstance->setDir($uploadCsvDir);
     $result = $uploadInstance->execute();
     if (!isset($result['csvPacket'])) {
         die('请上传指定大小的csv数据包');
     }
     if (($packetData = current($result['csvPacket'])) && $packetData['flag'] != 1) {
         $message = $uploadInstance->errorMessage($packetData['flag']);
         die($message);
     }
     $zipPath = $packetData['fileSrc'];
     $zipDir = dirname($zipPath);
     $imageDir = IWeb::$app->config['upload'] . '/' . date('Y/m/d');
     file_exists($imageDir) ? '' : IFile::mkdir($imageDir);
     //解压缩包
     $zipObject = new ZipArchive();
     $zipObject->open($zipPath);
     $isExtract = $zipObject->extractTo($zipDir);
     $zipObject->close();
     if ($isExtract == false) {
         $message = '解压缩到目录' . $zipDir . '失败!';
         die($message);
     }
     //实例化商品
     $goodsObject = new IModel('goods');
     $photoRelationDB = new IModel('goods_photo_relation');
     $photoDB = new IModel('goods_photo');
     $cateExtendDB = new IModel('category_extend');
     //获得配置文件中的数据
     $config = new Config("site_config");
     $dirHandle = opendir($zipDir);
     while ($fileName = readdir($dirHandle)) {
         if (strpos($fileName, '.csv') !== false) {
             //创建解析对象
             switch ($csvType) {
                 case "taobao":
                     include_once $pluginDir . 'taoBaoPacketHelper.php';
                     $helperInstance = new taoBaoPacketHelper($zipDir . '/' . $fileName, $imageDir);
                     $titleToCols = taoBaoTitleToColsMapping::$mapping;
                     break;
                 default:
                     $message = "请选择csv数据包的格式";
                     die($message);
             }
             //从csv中解析数据
             $collectData = $helperInstance->collect();
             //插入商品表
             foreach ($collectData as $key => $val) {
                 $collectImage = isset($val[$titleToCols['img']]) ? $val[$titleToCols['img']] : '';
                 //有图片处理
                 if ($collectImage) {
                     //图片拷贝
                     $_FILES = array();
                     foreach ($collectImage as $image) {
                         foreach ($image as $from => $to) {
                             if (!is_file($from)) {
                                 continue;
                             }
                             IFile::xcopy($from, $to);
                             //构造$_FILES全局数组
                             $_FILES[] = array('size' => 100, 'tmp_name' => $to, 'name' => basename($to), 'error' => 0);
                         }
                     }
                     //调用文件上传类
                     $photoObj = new PhotoUpload();
                     $uploadImg = $photoObj->run(true);
                     $showImg = current($uploadImg);
                 }
                 //处理商品详情图片
                 $toDir = IUrl::creatUrl() . dirname($to);
                 $goodsContent = preg_replace("|src=\".*?(?=/contentPic/)|", "src=\"{$toDir}", trim($val[$titleToCols['content']], "'\""));
                 $insertData = array('name' => IFilter::act(trim($val[$titleToCols['name']], '"\'')), 'goods_no' => goods_class::createGoodsNo(), 'sell_price' => IFilter::act($val[$titleToCols['sell_price']], 'float'), 'market_price' => IFilter::act($val[$titleToCols['sell_price']], 'float'), 'up_time' => ITime::getDateTime(), 'create_time' => ITime::getDateTime(), 'store_nums' => IFilter::act($val[$titleToCols['store_nums']], 'int'), 'content' => IFilter::addSlash($goodsContent), 'img' => isset($showImg['img']) ? $showImg['img'] : '', 'seller_id' => self::$seller_id);
                 $goodsObject->setData($insertData);
                 $goods_id = $goodsObject->add();
                 //处理商品分类
                 if ($category) {
                     foreach ($category as $catId) {
                         $cateExtendDB->setData(array('goods_id' => $goods_id, 'category_id' => $catId));
                         $cateExtendDB->add();
                     }
                 }
                 //处理商品图片
                 if ($uploadImg) {
                     $imgArray = array();
                     foreach ($uploadImg as $temp) {
                         if (isset($temp['img']) && $temp['img']) {
                             $imgArray[] = $temp['img'];
                         }
                     }
                     if ($imgArray) {
                         $photoData = $photoDB->query('img in ("' . join('","', $imgArray) . '")', 'id');
                         if ($photoData) {
                             foreach ($photoData as $item) {
                                 $photoRelationDB->setData(array('goods_id' => $goods_id, 'photo_id' => $item['id']));
                                 $photoRelationDB->add();
                             }
                         }
                     }
                 }
             }
         }
     }
     //清理csv文件数据
     IFile::rmdir($uploadCsvDir, true);
     die('<script type="text/javascript">parent.artDialogCallback();</script>');
 }
Exemple #15
0
    echo join(',', $catName);
    ?>
					</td>
					<td><?php 
    echo isset($item['sell_price']) ? $item['sell_price'] : "";
    ?>
</td>
					<td><?php 
    echo isset($item['store_nums']) ? $item['store_nums'] : "";
    ?>
</td>
					<td class="<?php 
    echo $item['is_del'] == 0 ? "green" : "red";
    ?>
"><?php 
    echo goods_class::statusText($item['is_del']);
    ?>
</td>
					<td><input class="tiny" type="text" value="<?php 
    echo isset($item['sort']) ? $item['sort'] : "";
    ?>
" onchange="changeSort(<?php 
    echo isset($item['id']) ? $item['id'] : "";
    ?>
,this);" /></td>
					<td>
						<a href="<?php 
    echo IUrl::creatUrl("/seller/goods_edit/id/" . $item['id'] . "");
    ?>
"><img src="<?php 
    echo IUrl::creatUrl("") . "views/" . $this->theme . "/skin/" . $this->skin . "/images/main/icn_edit.png";
<script type="text/javascript">
//完整分类数据
<?php 
$query = new IQuery("category");
$query->order = "sort asc";
$categoryData = $query->find();
foreach ($categoryData as $key => $item) {
}
?>
art.dialog.data('categoryWhole',<?php 
echo JSON::encode($categoryData);
?>
);
categoryParentData = <?php 
echo JSON::encode(goods_class::categoryParentStruct($categoryData));
?>
;

//初始化被选中的分类ID
checkedCategory = art.dialog.data('categoryValue') ? art.dialog.data('categoryValue') : [];

$(function()
{
	//生成顶级分类信息
	var templateHtml = template.render('categoryListTemplate',{'templateData':categoryParentData[0],'level':0,'checkedCategory':checkedCategory});
	$('#categoryBox').append(templateHtml);
})

//显示分类数据信息
function showCategory(categoryId,level)