static function add($data) { if (!$data) { return false; } $model = new GoodsModel(); $result = $model->add($data); return $result; }
public function listAction() { $page = Framework::getNullRequrest('page', 1); $pagesize = Framework::getNullRequrest('pagesize', 10); $goods_model = new GoodsModel(); $list = $goods_model->getList($page, $pagesize); $this->view->assign('list', $list); $page_html = PageTool::show($page, $pagesize, $goods_model->autoTotalCount()); $this->view->assign('page_html', $page_html); $this->view->display('list.tpl'); }
public static function fillCartGoodsInfo($cartGoods) { $data = array(); $goodsInfo = GoodsModel::findGoodsById($cartGoods['goods_id']); if (empty($goodsInfo)) { return $data; } $data['goodsId'] = $cartGoods['goods_id']; $data['amount'] = $cartGoods['amount']; $data['salePrice'] = $goodsInfo['sale_price']; $data['goodsName'] = $goodsInfo['name']; $data['imageUrl'] = $goodsInfo['image_url']; return $data; }
/** * 增加商品 */ public function insertAction() { //获取添加的商品信息 $data['goods_name'] = $_POST['goods_name']; $data['goods_sn'] = $_POST['goods_sn']; $data['cat_id'] = $_POST['cat_id']; $data['shop_price'] = $_POST['shop_price']; $data['market_price'] = $_POST['market_price']; $data['goods_desc'] = $_POST['goods_desc']; $data['goods_number'] = $_POST['goods_number']; //商品状态 $is_best = isset($_POST['is_best']) ? $_POST['is_best'] : 0; $is_new = isset($_POST['is_new']) ? $_POST['is_new'] : 0; $is_hot = isset($_POST['is_hot']) ? $_POST['is_hot'] : 0; $data['goods_status'] = 0 | $is_best | $is_new | $is_hot; $data['is_on_sale'] = isset($_POST['is_on_sale']) ? $_POST['is_on_sale'] : '0'; $data['add_time'] = time(); $model_goods = new GoodsModel(); if ($model_goods->insertGoods($data)) { $this->jump('index.php?p=back&c=Goods&a=list'); } else { $this->jump('index.php?p=back&c=Goods&a=add', '失败原因'); } }
public function view_skuInfo() { $sku = isset($_GET['sku']) ? trim($_GET['sku']) : ""; //$spu = ExportsToXlsModel::getGoods($sku); $spu = GoodsModel::getSkuList($sku); $spu = $spu['spu']; $where = "where spu = '{$spu}'"; $skuinfo = OmAvailableModel::getTNameList("pc_goods", "*", $where); $skuStock = array(); foreach ($skuinfo as $key => $value) { $sku = $value['sku']; //获取库存 $skuStock = WarehouseAPIModel::getSkuStock($sku); //获取料号信息 //$skumsg = ExportsToXlsModel::getGoods($sku); $skumsg = GoodsModel::getSkuList($sku); //获取缓存表信息 $where = "where sku='{$sku}'"; $skuStatics = OmAvailableModel::getTNameList("om_sku_daily_status", "*", $where); $skuStockList = array(); $skuStockList['nums'] = $skuStock; $skuStockList['sku'] = $skumsg['sku']; $skuStockList['spu'] = $skumsg['spu']; $skuStockList['goodsName'] = $skumsg['goodsName']; $skuStockList['goodsCost'] = $skumsg['goodsCost']; $skuStockList['goodsWeight'] = $skumsg['goodsWeight']; $skuStockList['AverageDailyCount'] = $skuStatics['AverageDailyCount']; $skuStockList['waitingSendCount'] = $skuStatics['waitingSendCount']; $skuStockList['xuniCount'] = $skuStatics['waitingSendCount']; $skuStockList['goodsStatus'] = $skumsg['goodsStatus']; $path = $skumsg['goodsCategory']; $cateName = GoodsModel::getCategoryInfoByPath($path); $skuStockList['cateName'] = $cateName['name']; $skuStockList['isNew'] = $skumsg['isNew']; $skuStockList['pmId'] = $skumsg['pmId']; $pmName = GoodsModel::getMaterInfoById($skumsg['pmId']); $skuStockList['pmName'] = $pmName['pmName']; //print_r($pmName); $pName = $skumsg['purchaseId']; $skuStockList['pName'] = UserModel::getUsernameById($pName); $skuStockList['isPacking'] = $skumsg['isPacking']; $skuStockList['whName'] = "深圳A仓"; $skuStock_arr[] = $skuStockList; } $this->smarty->assign("skuStockList", $skuStock_arr); //print_r($skuStockList); $this->smarty->display("skuInfo.htm"); }
public function ajGetGoods() { if (IS_AJAX) { $page = I('get.p', '', 'intval'); $where['state'] = 1; $sort_id = I('get.id', '', 'intval'); if ($sort_id > 0) { $where['sort_id'] = $sort_id; } $once = I('get.once', '', 'intval'); $once = $once > 0 && $once <= 40 ? $once : 0; $count = M('goods')->where($where)->count(); $goods = GoodsModel::I()->_getGoodsList($this->iniPage($count), $where); if ($goods) { $this->assign('goods', $goods); $this->assign('page', $page + 1); } $this->d(); } }
<?php define('ACC', true); require '../system/init.php'; /* 接受ID model类声明 调用trash方法 */ $goods = new GoodsModel(); if (isset($_GET['act']) && $_GET['act'] == "showtrash") { //显示回收站 $goodslist = $goods->getGoodsVsTrash(1); $pageMenu = ''; include __ROOT__ . 'view/admin/templates/goodslist.html'; } else { $goods_id = $_GET['goods_id'] + 0; if ($goods->inTrash($goods_id)) { echo "goods was in Trash<br>"; } else { echo "goods was fail to put in trash<br>"; } }
public static function judge_contain_combinesku($omOrderId, $storeId = 1) { //判断订单是否包含组合料号 self::initDB(); $sql = "SELECT sku,amount FROM om_unshipped_order_detail WHERE omOrderId = '{$omOrderId}' and storeId = {$storeId} and is_delete = 0 "; $sql = self::$dbConn->query($sql); $orderdetaillist = self::$dbConn->fetch_array_all($sql); $iszuhe = false; foreach ($orderdetaillist as $orderdetail) { $sku = $orderdetail['sku']; if (GoodsModel::getCombineSkuinfo($sku)) { $iszuhe = true; break; } } return $iszuhe; }
<?php define('ACC', true); require '../system/init.php'; /* 接受goods ID 实例化 调用方法 显示在view上 */ $goods_id = $_GET['goods_id'] + 0; $goods = new GoodsModel(); $goods123 = $goods->find($goods_id); if (!empty($goods123)) { print_r($goods123); }
<?php /* 购物车控制器 */ define('ACC', true); require '../system/init.php'; //实例化购物车类和商品类 $cartObj = CartHelper::getCart(); $goods = new GoodsModel(); $act = isset($_GET['act']) ? $_GET['act'] : 'buy'; //购买商品,去结算 if ($act == 'buy') { if (isset($_GET['goods_id'])) { $goods_id = $_GET['goods_id']; $goods_info = $goods->find($goods_id); $num = isset($_GET['num']) ? $_GET['num'] + 0 : 1; //商品是否存在 if (!isset($goods_info)) { $msg = "The ware is not exist<br>"; include __ROOT__ . 'view/front/msg.html'; exit; } //商品是否上架或者删除 if ($goods_info['is_delete'] || !$goods_info['is_on_sale']) { $msg = "The ware is not available<br>"; include __ROOT__ . 'view/front/msg.html'; exit; } //商品是否有库存 if ($cartObj->getNoByID($goods_id) + $num > $goods_info['goods_number']) {
public static function getMaterInfo() { global $memc_obj; $cacheName = md5("om_pmInfo"); $list = $memc_obj->get_extral($cacheName); if ($list) { return $list; } else { require_once WEB_PATH . "api/include/functions.php"; $url = 'http://gw.open.valsun.cn:88/router/rest?'; $paramArr = array('method' => 'pc.getPmInfoAll', 'format' => 'json', 'v' => '1.0', 'username' => 'purchase'); $result = callOpenSystem($paramArr); $data = json_decode($result, true); if (!$data['data']) { self::$errCode = 101; self::$errMsg = "没取到值!"; return false; } else { $isok = $memc_obj->set_extral($cacheName, $data['data']); if (!$isok) { self::$errCode = 102; self::$errMsg = 'memcache缓存账号信息出错!'; return $data['data']; } return $data['data']; } } }
<?php define('ACC', true); require './include/init.php'; // 取出5条新品 $goods = new GoodsModel(); $newlist = $goods->getNew(5); /* 取出指定栏目的商品 */ // 女士大栏目下的商品 $female_id = 4; $felist = $goods->catGoods($female_id); // 男士大栏目下的商品,同学们自己来完成 include ROOT . 'view/front/index.html';
/** * 功能:通过sku获取spu * @param str $sku * @return void * @author wxb * @date 2013/11/15 */ public function getSpuBySku($sku) { $ret = GoodsModel::getSpuBySku($sku); if ($ret == false) { self::$errCode = GoodsModel::$errCode; self::$errMsg = GoodsModel::$errMsg; return false; } return $ret; }
public function view_createBill() { $id = $_POST['id'] ? post_check(trim($_POST['id'])) : ''; $whId = $_POST['wh'] ? post_check(trim($_POST['wh'])) : ''; $id = $_POST['id'] ? post_check(trim($_POST['id'])) : ''; $whId = $_POST['wh'] ? post_check(trim($_POST['wh'])) : ''; if (empty($id)) { $status = '未选择新品'; header("Location:index.php?mod=products&act=getNewGoodsList&status={$status}"); exit; } if (intval($whId) <= 0) { $status = '仓库有误'; header("Location:index.php?mod=products&act=getNewGoodsList&status={$status}"); exit; } $iostoreDetailArr = array(); $tmpArr = array_filter(explode(',', $id)); $iostoreDetailArr = array(); $tmpArr = array_filter(explode(',', $id)); if (empty($tmpArr)) { $status = '未选择新品'; header("Location:index.php?mod=products&act=getNewGoodsList&status={$status}"); exit; } foreach ($tmpArr as $value) { $sku = $value; if (!empty($sku)) { $iostoreDetailArr[] = $sku; } } if (empty($iostoreDetailArr)) { $status = '生成领料单异常'; header("Location:index.php?mod=products&act=getNewGoodsList&status={$status}"); exit; } //插入数据到单据表中 try { BaseModel::begin(); //先插入表头数据 $tName = 'pc_products_iostore'; $dataIostore = array(); $dataIostore['ordersn'] = "XPLQ" . date('Y') . date('m') . date('d') . date("H") . date('i') . date('s') . str_pad(rand(1, 9999), 4, '0', STR_PAD_LEFT); //默认领料单单号为前缀“PRODUCTOR”+年月日时分秒生成 $where = "WHERE ordersn='{$dataIostore['ordersn']}'"; $countIoStore = OmAvailableModel::getTNameCount($tName, $where); if ($countIoStore) { $status = '异常,请重试'; header("Location:index.php?mod=products&act=tmpReturnPros&status={$status}"); exit; } $dataIostore['addUserId'] = $_SESSION['userId']; //添加人 if (intval($dataIostore['addUserId']) <= 0) { $status = '登陆超时,请重试'; header("Location:index.php?mod=products&act=getNewGoodsList&status={$status}"); exit; } $dataIostore['createdTime'] = time(); //生成时间 $dataIostore['whId'] = $whId; $dataIostore['companyId'] = 1; $dataIostoreTowh = $dataIostore; $dataIostoreTowh['invoiceTypeId'] = 4; //产品部借用 $dataIostoreTowh['ioType'] = 1; //出库 $dataIostoreTowh['paymentMethodsId'] = 3; //无需付款 $whinsertid = OmAvailableModel::newData2ErpInterfOpen("wh.addWhIoStoreInWh", array("jsonArr" => json_encode($dataIostoreTowh)), '88', false); $insertIostoreId = OmAvailableModel::addTNameRow2arr($tName, $dataIostore); //下面插入表体 $tName = 'pc_products_iostore_detail'; foreach ($iostoreDetailArr as $value) { $dataIostoreDetail = array(); $dataIostoreDetailTowh = array(); $dataIostoreDetail['iostoreId'] = $insertIostoreId; $dataIostoreDetailTowh['iostoreId'] = $whinsertid['data']; $dataIostoreDetail['sku'] = $value; $dataIostoreDetailTowh['sku'] = $value; $dataIostoreDetail['addUserId'] = $dataIostore['addUserId']; $dataIostoreDetail['addTime'] = time(); $dataIostoreDetail['whId'] = $whId; $dataIostoreDetailTowh['whId'] = $whId; $dataIostoreDetailTowh['amount'] = 1; //默认数量为1 $dataIostoreDetailTowh['cost'] = GoodsModel::getCostBySku($value); $dataIostoreDetailTowh['purchaseId'] = GoodsModel::getpurchaseIdBySku($value); OmAvailableModel::addTNameRow2arr($tName, $dataIostoreDetail); $msgiostore = OmAvailableModel::newData2ErpInterfOpen("wh.addWhIoStoreDetailInWh", array("jsonArr" => json_encode($dataIostoreDetailTowh)), '88', false); } BaseModel::commit(); BaseModel::autoCommit(); $status = "领料单 {$dataIostore['ordersn']} 生成成功"; header("Location:index.php?mod=products&act=getOutStoreList&status={$status}"); } catch (Exception $e) { BaseModel::rollback(); BaseModel::autoCommit(); $status = "系统错误,生成失败"; header("Location:index.php?mod=products&act=getOutStoreList&status={$status}"); exit; } }
/** * 获取订单下的全部真实料号 * @param number $id * @param number $type * @param number $storeId * @return boolean|$skuinfos array * @author czq */ public function getRealskulist($id, $type = 1, $storeId = 1) { if ($type == 1) { $table = 'unshipped'; } else { if ($type == 2) { $table = 'shipped'; } else { return false; } } $orders = $this->getOrderById($table, array($id)); $order = $orders[$id]['order']; if ($order) { $skuinfos = array(); $omOrderId = $order['id']; $combinePackage = $order['combinePackage']; //获取订单明细 $orderdetails = $orders[$id]['detail']['base']; foreach ($orderdetails as $_k => $odlist) { $sku = trim($odlist['sku']); $amount = $odlist['amount']; /**预留,待实现**/ $sku_arr = GoodsModel::get_realskuinfo($sku); foreach ($sku_arr as $or_sku => $or_nums) { if (isset($skuinfos[$or_sku])) { $skuinfos[$or_sku] += $or_nums * $amount; } else { $skuinfos[$or_sku] = $or_nums * $amount; } } } if ($combinePackage == 1) { $sonCombineOrders = $this->selectSonOrder($id); foreach ($sonCombineOrders as $sonOrder) { $_skuinfos = $this->getRealskulist($sonOrder['split_order_id'], $type, $storeId); foreach ($_skuinfos as $_sku => $_nums) { if (isset($_skuinfos[$_sku])) { $skuinfos[$_sku] += $_nums; } else { $skuinfos[$_sku] = $_nums; } } } } return $skuinfos; } return false; }
@Descrition:查看商品详细信息 @Author:GongBiao @Date:2015/06/23 */ define('ACC', true); require('../include/init.php'); /* 思路: 接收goods_id 实例化goodsModel 调用find方法 展示商品信息 */ $goods_id = $_GET['goods_id']; $goods = new GoodsModel(); $g = $goods->find($goods_id); if(empty($g)){ echo '商品不存在'; exit; }else{ echo '<pre>'; print_r($g); //简单的处理商品详细查看 echo '<pre>'; } ?>
public function actionAddfrontmodel() { $year = Yii::app()->request->getParam('year'); $model = Yii::app()->request->GetParam('model'); $res = GoodsModel::model()->findByPk($model); $data['year'] = $res['year']; $data['model'] = $res['name']; echo json_encode($data); }
/** * 功能:通过sku获取spu * @param str $sku * @return void * @author wxb * @date 2013/11/15 */ public static function getSpuBySku($sku) { self::initDB(); $sql = "SELECT spu FROM " . self::$prefix . "goods WHERE sku = '{$sku}' LIMIT 1"; $query = self::$dbConn->query($sql); if ($query) { $ret = self::$dbConn->fetch_array($query); if (empty($ret)) { self::$errMsg = "mysql:" . $sql . " empty"; return false; } return $ret['spu']; } else { self::$errMsg = "mysql:" . $sql . " error"; return false; } }
<?php define('ACC', true); require '../include/init.php'; /*** * file goodstrash.php * 商品回收站页面控制器 * parm $GET['act'] * @author zhangyang */ $goods = new GoodsModel(); $goods_id = $_GET['goods_id'] + 0; /** * act=do, 表示是从goodslist发出的删除商品行为 */ if (isset($_GET['act']) && $_GET['act'] == 'do') { if ($goods->doDelete($goods_id)) { echo "<script>alert('商品删除成功');history.back();</script>"; exit; } else { echo "<script>alert('商品删除失败');history.back();</script>"; exit; } } else { $goodslist = $goods->getDelete(); include ROOT . 'view/admin/templates/goodslist.html'; }
public function view_modifyOrderList() { global $memc_obj; $sysUserId = $_SESSION['sysUserId']; $modify_showerrorinfo = ''; $OrderModifyAct = new OrderModifyAct(); $OrderindexAct = new OrderindexAct(); $UserCompetenceAct = new UserCompetenceAct(); //var_dump($_GET); exit; if (isset($_GET) && !empty($_GET)) { $orderid = isset($_GET['orderid']) ? $_GET['orderid'] : ''; $ostatus = isset($_GET['edit_ostatus']) ? $_GET['edit_ostatus'] : $_GET['ostatus']; $otype = isset($_GET['edit_otype']) ? $_GET['edit_otype'] : $_GET['otype']; } if (isset($_POST) && !empty($_POST)) { //var_dump($_POST); echo "<br>"; exit; $orderid = isset($_POST['orderid']) ? $_POST['orderid'] : ''; $ostatus = isset($_POST['edit_ostatus']) ? $_POST['edit_ostatus'] : $_POST['ostatus']; $otype = isset($_POST['edit_otype']) ? $_POST['edit_otype'] : $_POST['otype']; $update_order = array(); $update_userinfo = array(); $update_tracknumber = array(); //$orderid = $_POST['orderid']; //var_dump($_POST); exit; $updatestatus = false; if ($_POST['action'] == 'addDetail') { //var_dump($_GET); echo "<br>"; exit; $orderid = isset($_GET['orderid']) ? $_GET['orderid'] : ''; $ostatus = isset($_GET['edit_ostatus']) ? $_GET['edit_ostatus'] : $_GET['ostatus']; $otype = isset($_GET['edit_otype']) ? $_GET['edit_otype'] : $_GET['otype']; if ($OrderModifyAct->act_batchAdd($orderid, $_POST)) { $modify_showerrorinfo = "<font color='green'>添加成功</font>"; } else { $modify_showerrorinfo = "<font color='red'>添加失败</font>"; } } else { if ($_POST['action'] == 'addNote') { //var_dump($_GET); echo "<br>"; exit; $orderid = isset($_GET['orderid']) ? $_GET['orderid'] : ''; $ostatus = isset($_GET['edit_ostatus']) ? $_GET['edit_ostatus'] : $_GET['ostatus']; $otype = isset($_GET['edit_otype']) ? $_GET['edit_otype'] : $_GET['otype']; if ($OrderModifyAct->act_addNote($orderid, $_POST)) { $modify_showerrorinfo = "<font color='green'>添加成功</font>"; } else { $modify_showerrorinfo = "<font color='red'>添加失败</font>"; } } else { $visible_movefolder = $UserCompetenceAct->act_getInStatusIds($_POST['otype'], $sysUserId); if (!in_array($_POST['edit_otype'], $visible_movefolder)) { $modify_showerrorinfo = "<font color='red'>您没有改变订单状态的权限</font>"; } else { if ($_POST['username'] != $_POST['edit_username']) { $update_userinfo['username'] = $_POST['edit_username']; } if ($_POST['ostatus'] != $_POST['edit_ostatus']) { $update_order['orderStatus'] = $_POST['edit_ostatus']; } if ($_POST['otype'] != $_POST['edit_otype']) { $update_order['orderType'] = $_POST['edit_otype']; $updatestatus = true; } if ($_POST['street'] != $_POST['edit_street']) { $update_userinfo['street'] = $_POST['edit_street']; } if ($_POST['platformUsername'] != $_POST['edit_platformUsername']) { $update_userinfo['platformUsername'] = $_POST['edit_platformUsername']; } if ($_POST['address2'] != $_POST['edit_address2']) { $update_userinfo['address2'] = $_POST['edit_address2']; } if ($_POST['actualShipping'] != $_POST['edit_actualShipping']) { $update_order['actualShipping'] = $_POST['edit_actualShipping']; } if ($_POST['city'] != $_POST['edit_city']) { $update_userinfo['city'] = $_POST['edit_city']; } if ($_POST['state'] != $_POST['edit_state']) { $update_userinfo['state'] = $_POST['edit_state']; } if ($_POST['countryName'] != $_POST['edit_countryName']) { $update_userinfo['countryName'] = $_POST['edit_countryName']; } if ($_POST['zipCode'] != $_POST['edit_zipCode']) { $update_userinfo['zipCode'] = $_POST['edit_zipCode']; } if ($_POST['landline'] != $_POST['edit_landline']) { $update_userinfo['landline'] = $_POST['edit_landline']; } if ($_POST['phone'] != $_POST['edit_phone']) { $update_userinfo['phone'] = $_POST['edit_phone']; } if ($_POST['transportId'] != $_POST['edit_transportId']) { $update_order['transportId'] = $_POST['edit_transportId']; } if ($_POST['edit_tracknumber']) { $update_tracknumber['omOrderId'] = $orderid; $update_tracknumber['tracknumber'] = $_POST['edit_tracknumber']; $update_tracknumber['addUser'] = $sysUserId; $update_tracknumber['createdTime'] = time(); //var_dump($update_tracknumber); exit; } BaseModel::begin(); //开始事务 if ($update_order) { //$sql = "UPDATE om_unshipped_order set ".array2sql($update_order)." WHERE id = ".$orderid; //$msg = OrderLogModel::orderLog($orderid,$update_order['orderStatus'],$update_order['orderType'],$sql); if (OrderindexModel::updateOrder('om_unshipped_order', $update_order, ' WHERE id = ' . $orderid)) { if ($updatestatus) { $ProductStatus = new ProductStatus(); if (!$ProductStatus->updateSkuStatusByOrderStatus(array($orderid), $batch_ostatus_val, $batch_otype_val)) { BaseModel::rollback(); } } $modify_showerrorinfo = "<font color='green'>更新成功</font>"; } else { $modify_showerrorinfo = "<font color='red'>更新失败</font>"; BaseModel::rollback(); } } if ($update_userinfo) { //var_dump($update_userinfo); if (OrderindexModel::updateOrder('om_unshipped_order_userInfo', $update_userinfo, ' WHERE omOrderId = ' . $orderid)) { $modify_showerrorinfo = "<font color='green'>更新成功</font>"; } else { $modify_showerrorinfo = "<font color='red'>更新失败</font>"; BaseModel::rollback(); } } if ($update_tracknumber) { //echo $msg; if (!OrderAddModel::insertOrderTrackRow($update_tracknumber)) { /*self :: $errCode = "001"; self :: $errMsg = "跟踪号插入失败"; return false;*/ $modify_showerrorinfo = "<font color='red'>跟踪号插入失败</font>"; BaseModel::rollback(); } } BaseModel::commit(); BaseModel::autoCommit(); } } } } $this->smarty->assign('modify_showerrorinfo', $modify_showerrorinfo); $omAvailableAct = new OmAvailableAct(); //平台信息 $platform = $omAvailableAct->act_getTNameList('om_platform', 'id,platform', 'WHERE is_delete=0'); //var_dump($platform); $platformList = array(); foreach ($platform as $v) { $platformList[$v['id']] = $v['platform']; } $this->smarty->assign('platformList', $platformList); /**导航 start**/ $this->smarty->assign('ostatus', $ostatus); $this->smarty->assign('otype', $otype); //二级目录 $StatusMenuAct = new StatusMenuAct(); $ostatusList = $StatusMenuAct->act_getStatusMenuList('statusCode,statusName', 'WHERE groupId = 0 AND is_delete=0'); //var_dump($ostatusList); $this->smarty->assign('ostatusList', $ostatusList); $otypeList = $StatusMenuAct->act_getStatusMenuList('statusCode,statusName', 'WHERE groupId = "' . $ostatus . '" AND is_delete=0'); //var_dump($otypeList); $this->smarty->assign('otypeList', $otypeList); /*$o_secondlevel = $omAvailableAct->act_getTNameList('om_status_menu','*','WHERE is_delete=0 and groupId=0 order by sort asc'); $this->smarty->assign('o_secondlevel', $o_secondlevel);*/ $second_count = array(); $second_type = array(); foreach ($ostatusList as $o_secondinfo) { $orderStatus = $o_secondinfo['statusCode']; /*$accountacc = $_SESSION['accountacc']; $oc_where = " where orderStatus='$orderStatus' "; if($accountacc){ $oc_where .= ' AND ('.$accountacc.') '; }*/ $s_total = $OrderindexAct->act_showSearchOrderNum($orderStatus); //$s_total = $omAvailableAct->act_getTNameCount("om_unshipped_order", $oc_where); $second_count[$o_secondinfo['statusCode']] = $s_total; $s_type = $omAvailableAct->act_getTNameList("om_status_menu", "*", "WHERE is_delete=0 and groupId='{$orderStatus}' order by sort asc"); $second_type[$o_secondinfo['statusCode']] = $s_type[0]['statusCode']; } //var_dump($second_count); $this->smarty->assign('second_count', $second_count); $this->smarty->assign('second_type', $second_type); //退款数量 $refund_total = $omAvailableAct->act_getTNameCount("om_order_refund", " where is_delete=0"); $this->smarty->assign('refund_total', $refund_total); //三级目录 $o_threelevel = $omAvailableAct->act_getTNameList("om_status_menu", "*", "WHERE is_delete=0 and groupId='{$ostatus}' order by sort asc"); $this->smarty->assign('o_threelevel', $o_threelevel); $three_count = array(); foreach ($o_threelevel as $o_threeinfo) { $orderType = $o_threeinfo['statusCode']; $s_total = $OrderindexAct->act_showSearchOrderNum($ostatus, $orderType); //$s_total = $omAvailableAct->act_getTNameCount("om_unshipped_order"," where orderStatus='$ostatus' and orderType='$orderType' and storeId=1 and is_delete=0"); $three_count[$o_threeinfo['statusCode']] = $s_total; } $this->smarty->assign('three_count', $three_count); $toptitle = '订单显示页面'; //头部title $this->smarty->assign('toptitle', $toptitle); $this->smarty->assign('toplevel', 0); $threelevel = '1'; //当前的三级菜单 $this->smarty->assign('threelevel', $threelevel); $statusMenu = $omAvailableAct->act_getTNameList('om_status_menu', ' * ', 'WHERE is_delete=0 '); $this->smarty->assign('statusMenu', $statusMenu); $value = ''; $where = ''; switch ($searchTransportationType) { case '1': $transportation = CommonModel::getCarrierList(1); //快递 break; case '2': $transportation = CommonModel::getCarrierList(0); //平邮 break; default: $transportation = CommonModel::getCarrierList(); //所有的 break; } //var_dump($transportation); exit; $transportationList = array(); foreach ($transportation as $tranValue) { $transportationList[$tranValue['id']] = $tranValue['carrierNameCn']; } //var_dump($transportationList); exit; $this->smarty->assign('transportation', $transportation); $this->smarty->assign('transportationList', $transportationList); //var_dump($orderid, $ostatus,$otype); $omOrderList = $OrderModifyAct->act_getModifyOrderList($orderid, $ostatus, $otype, $storeId = 1); //var_dump($omOrderList); //$sku = array(); $account_where = ' WHERE is_delete = 0 '; if ($searchPlatformId) { $account_where .= ' AND platformId = ' . $searchPlatformId; } $accountList = $UserCompetenceAct->act_showGlobalUser(); if ($accountList) { $account_where .= ' AND id in ( ' . join(',', $accountList) . ' ) '; } //帐号信息 $accountList = $omAvailableAct->act_getTNameList('om_account', '*', $account_where); //var_dump($accountList); exit; $account = array(); foreach ($accountList as $v) { $account[$v['id']] = $v['account']; } //包材信息 $pm = GoodsModel::getMaterInfoByList(); //获取系统所有状态 $statusList = copyOrderModel::selectStatusList(); $CurrencyAct = new CurrencyAct(); $currencyList = $CurrencyAct->act_getCurrencyListById(); //echo "<pre>"; print_r($currencyList); exit; $this->smarty->assign('currencyList', $currencyList); $this->smarty->assign('statusList', $statusList); $this->smarty->assign('show_page', $show_page); $this->smarty->assign('account', $account); $this->smarty->assign('accountList', $accountList); $this->smarty->assign('pm', $pm); $this->smarty->assign('omOrderList', $omOrderList); $this->smarty->display('orderModify.htm'); }
<?php define('ACC', true); require '../include/init.php'; /*** * file goodslist.php * 商品列表显示控制器 * @author zhangyang */ $goods = new GoodsModel(); $goodslist = $goods->getList(); include ROOT . 'view/admin/templates/goodslist.html';
$data['goods_sn'] = trim($_POST['goods_sn']); $data['cat_id'] = $_POST['cat_id']+0; $data['shop_price'] = $_POST['shop_price']+0; $data['market_price'] = $_POST['market_price']+0; $data['goods_desc'] = trim($_POST['goods_desc']); $data['goods_weight'] = $_POST['goods_weight']*$_POST['weight_unit']; $data['is_best'] = isset($_POST['is_best'])? 1:0; $data['is_new'] = isset($_POST['is_new'])? 1:0; $data['is_hot'] = isset($_POST['is_hot'])? 1:0; $data['is_on_sale'] = isset($_POST['is_on_sale'])? 1:0; //$data['keywords'] = trim($_POST['keywords']); $data['goods_brief'] = trim($_POST['goods_brief']); $data['add_time'] = time(); */ $goods = new GoodsModel(); $data = array(); $goods->setField($goods->showField()); //自动格式化数据 $data = $goods->_facade($_POST); $data['goods_weight'] = $_POST['goods_weight'] * $_POST['weight_unit']; //自动填充 $data = $goods->_autofill($data); //自动校验 if (!$goods->_validate($data)) { echo $goods->getErr()[0]; exit; } //若没有goods_sn,自动生成 if (!$data['goods_sn']) { $data['goods_sn'] = $goods->snGenerator();
<?php /**** 燕十八 公益PHP讲堂 论 坛: http://www.zixue.it 微 博: http://weibo.com/Yshiba YY频道: 88354001 ****/ define('ACC', true); require "../include/init.php"; /* 实例化GoodsModel 调用select方法 循环显示在view上 */ $goods = new GoodsModel(); $goodslist = $goods->getGoods(); include ROOT . 'view/admin/templates/goodslist.html';
function _getConditions($conditions, $if_add_alias = false) { $alias = ''; if ($if_add_alias) { $alias = $this->alias . '.'; } $res = parent::_getConditions($conditions, $if_add_alias); return $res ? $res . " AND {$alias}store_id = '{$this->_store_id}'" : " WHERE {$alias}store_id = '{$this->_store_id}'"; }
<?php /**** 燕十八 公益PHP讲堂 论 坛: http://www.zixue.it 微 博: http://weibo.com/Yshiba YY频道: 88354001 ****/ define('ACC', true); require "../include/init.php"; /* 接收goods_id 调用trash方法 */ if (isset($_GET['act']) && $_GET['act'] == 'show') { // 这个部分是打印所有的回收商品 $goods = new GoodsModel(); $goodslist = $goods->getTrash(); include ROOT . 'view/admin/templates/goodslist.html'; } else { $goods_id = $_GET['goods_id'] + 0; $goods = new GoodsModel(); if ($goods->trash($goods_id)) { echo '已加入回收站'; } else { echo '加入回收站失败'; } }
<?php define('ACC', true); /*** * 所有由用户直接访问到的这些页面 * 都得现加载init.php */ require './include/init.php'; $goods = new GoodsModel(); $newList = $goods->getNew(); $appleList = $goods->getGoodsByCat(1); $samsungList = $goods->getGoodsByCat(2); include ROOT . 'view/front/index.html';
public function act_repeatShipments2() { date_default_timezone_set("Asia/Chongqing"); error_reporting(0); $currenctyList = CurrencyModel::getCurrencyList('currency,rates', 'where 1=1'); foreach ($currenctyList as $value) { $currenctys[$value['currency']] = $value['rates']; //汇率数组 } $packinglists = GoodsModel::getMaterInfo(); //获取全部包材记录 foreach ($packinglists as $packinglist) { $packings[$packinglist['id']]['pmName'] = $packinglist['pmName']; $packings[$packinglist['id']]['pmCost'] = $packinglist['pmCost']; } unset($packinglists); $carrierLists = CommonModel::getCarrierList(); //获取全部运输方式 foreach ($carrierLists as $carrierList) { $carriers[$carrierList['id']] = $carrierList['carrierNameCn']; } unset($carrierLists); $channelLists = CommonModel::getAllChannelList(); //获取全部运输方式下的渠道记录 foreach ($channelLists as $channelList) { $channels[$channelList['id']] = $channelList['channelName']; } unset($channelLists); $staffInfoLists = CommonModel::getStaffInfoList(); //获取全部人员 foreach ($staffInfoLists as $staffInfoList) { $staffLists[$staffInfoList['global_user_id']] = $staffInfoList['global_user_name']; } unset($staffInfoLists); //print_r($packings); // exit; $ebayaccount = omAccountModel::ebayaccountAllList(); //获取全部账号信息 foreach ($ebayaccount as $value) { $ebayaccounts[$value['ebay_platform']][] = $value['id']; //账号id对应名称 } unset($ebayaccount); $accountLists = omAccountModel::accountAllList(); //获取全部账号信息 foreach ($accountLists as $value) { $accounts[$value['id']] = $value['account']; //账号id对应名称 } $time1 = time(); $start = strtotime($_REQUEST['start']); $end = strtotime($_REQUEST['end']); $mailway = $_REQUEST['mailway']; $account = $_REQUEST['account']; /////////////////////////////////////////////// $accountStr = ''; if ($account != '') { //组合成sql 中accountId In() 语句 $account = explode("#", $account); foreach ($account as $value) { if ($value != '') { $accountStr .= " accountId='" . $value . "' or "; } } } $accountStr = substr($accountStr, 0, strlen($accountStr) - 3); if (empty($accountStr)) { $accountStr = ' 1=1'; } //$shipOrderList = OrderInfoModel :: getShipOrderList($start, $end, $accountStr); $tNameUnShipped = 'om_shipped_order'; //已發貨订单表 $where = " WHERE id IN ('8344971','8344971','8344971','8849112','9027686','9118441','9253209','9255395','9337524','9337524','9393954','9395762','9423987','9423987','9425121','9437038','9440042','9440042','9440042','9457399','9461841','9465559','9466929','9472244','9472244','9472244','9488351','9488351','9488479','9489408','9489408','9489408','9489408','9499144','9518194','9518200','9518866','9518866','9518866','9518866','9518898','9519076','9522183','9522183','9532719','9535192','9549634','9549634','9549634','9549643','9552004','9552004','9552004','9560244','9560244','9560244','9560244','9576989','9576989','9576989','9596753','9612887','9622477','9622500','9622512','9623276','9623276','9624016','9626076','9626076','9626076','9626076','9626316','9626385','9626385','9626385','9626403','9627404','9628837','9630913','9630913','9640585','9640585','9640585','9640604','9640770','9641002','9641274','9641274','9641274','9641395','9641529','9641529','9641744','9641829','9641829','9641892','9641892','9641946','9642205','9642205','9642380','9642780','9643939','9643939','9644644','9644644','9647186','9648475','9648478','9648478','9649284','9649286','9649649','9649649','9649649','9649652','9649652','9649652','9649885','9649909','9650192','9650192','9650198','9650198','9650241','9650322','9650322','9650322','9650322','9650380','9650381','9650388','9650571','9650571','9650571','9650612','9650615','9650637','9650649','9650673','9650673','9650681','9650685','9650696','9650704','9650704','9650726','9650741','9650741','9650761','9650785','9650826','9650834','9650834','9650834','9650834','9650838','9650841','9650841','9650914','9650937','9650937','9650958','9650958','9650989','9650995','9651008','9651120','9651151','9651333','9651351','9651351','9651351','9651363','9651618','9652039','9652041','9652172','9652197','9652294','9652355','9652355','9652365','9652547','9652570','9652815','9652829','9652829','9652830','9652830','9652830','9652834','9653349','9653350','9653677','9653677','9653784','9653786','9653790','9653790','9653826','9653866','9653866','9653866','9653866','9653868','9653869','9653869','9653869','9653870','9653870','9653871','9653874','9653878','9653878','9653878','9653878','9653879','9653884','9653884','9653959','9654059','9654071','9654332','9654572','9654572','9654572','9654573','9654573','9654778','9654778','9654784','9654792','9654961','9654964','9655556','9655630','9655630','9655643','9655643','9655643','9655646','9655734','9655775','9655777','9656086','9656208','9656209','9656210','9656529','9656529','9656593','9656629','9656634','9656746','9656983','9657511','9657566','9657566','9657566','9657566','9657641','9657641','9657677','9657678','9657680','9657802','9657802','9657803','9657985','9658074','9658081','9658321','9658337','9658449','9658458','9658501','9658501','9658840','9659006','9659144','9659726','9659726','9660877','9661308','9662160','9662162','9663236','9663236','9663236','9663236','9663236','9663236','9663254','9663408','9664335','9664335','9664335','9664335','9664335','9664335','9664335','9664335','9664335','9664338','9664338','9664341','9665707','9667826','9667826','9667826','9667826','9667826','9667826','9667826','9667826','9667835','9667843','9667849','9667849','9667849','9667849','9667849','9670393','9670393','9670393','9670393','9670393','9670393','9670407','9670407','9670407','9670407','9670407','9670417','9670426','9670683','9673777','9673777','9673777','9673777','9673777','9673778','9675229','9675242','9675595','9675595','9675595','8526402','8809110','8842096','8842096','8842096','8862631','8862631','8905974','8905974','8968635','9046612','9162772','9180940','9180940','9180940','9180940','9241329','9241329','9241329','9308486','9308486','9308486','9376347','9378671','9393969','9411833','9457216','9474385','9474385','9474385','9474385','9474603','9476126','9477416','9477416','9478721','9489020','9489608','9489608','9489608','9498874','9505075','9505075','9505075','9505075','9505151','9505151','9505151','9505151','9505733','9510621','9520197','9528779','9537456','9537668','9550596','9550596','9550596','9566234','9566234','9566248','9566248','9592573','9593512','9593512','9593512','9593512','9593512','9593512','9593512','9602420','9602420','9607647','9607647','9607647','9607647','9607647','9610633','9610776','9610776','9611433','9612362','9615401','9618958','9618958','9623437','9628510','9628510','9628655','9628655','9638991','9641400','9649804','9649855','9649855','9649855','9649855','9649894','9650472','9650472','9650552','9650556','9650583','9650585','9651279','9651509','9651712','9652013','9652013','9652273','9652273','9652274','9652274','9652274','9652441','9652483','9652513','9652523','9652523','9652929','9652929','9652929','9652929','9652929','9652929','9652929','9652929','9653014','9653027','9653027','9653027','9653027','9653103','9653345','9653345','9653345','9653345','9653345','9653489','9653567','9653637','9653938','9653938','9653938','9653938','9653938','9653941','9653941','9653941','9654055','9654055','9654055','9654055','9654061','9654075','9654084','9654323','9654641','9655179','9655255','9655255','9655506','9655506','9655538','9655671','9655835','9655967','9655967','9655967','9656198','9656251','9656251','9656251','9656277','9656279','9656329','9656329','9656329','9656329','9656522','9656541','9656541','9656655','9656921','9656921','9656942','9656942','9657107','9657174','9657174','9657175','9657175','9657175','9657345','9657860','9657860','9657994','9658000','9658000','9658004','9658004','9658012','9658030','9658030','9658030','9658030','9658114','9658141','9658141','9658156','9658209','9658286','9658286','9658295','9658295','9658295','9658295','9658296','9658296','9658595','9658595','9658649','9658691','9658784','9658784','9658784','9658784','9658798','9658809','9658834','9658845','9658852','9658852','9658852','9658914','9658914','9659007','9659009','9659083','9659084','9659148','9659151','9659151','9659355','9659378','9659401','9659451','9659451','9659594','9659804','9660076','9660076','9660393','9660399','9660399','9660406','9660453','9660453','9660453','9660453','9660460','9660603','9660603','9660603','9660862','9660862','9660864','9660864','9660864','9660864','9660864','9660864','9660864','9660864','9660864','9660942','9660952','9660952','9661096','9661096','9661156','9661187','9661292','9661481','9661622','9661850','9661890','9661890','9662030','9662113','9662113','9662146','9662146','9662249','9662249','9662343','9662457','9662471','9662471','9662502','9662696','9662732','9662732','9662732','9662733','9662733','9662733','9662832','9662908','9662908','9662909','9662971','9663010','9663010','9663010','9663014','9663380','9663380','9663380','9663386','9663386','9663692','9663693','9663754','9663754','9663826','9663826','9663894','9663998','9664012','9664080','9664090','9664093','9664112','9664112','9664112','9664112','9664175','9664191','9664191','9664192','9664192','9664196','9664554','9664554','9664968','9665016','9665209','9665222','9665222','9665309','9665392','9665396','9665667','9665667','9665667','9665668','9665668','9659581','9660388','9662117','9662117','9664751','9666120','9666124','9666258','9666258','9666262','9666264','9666344','9666377','9666383','9666383','9666383','9666383','9666384','9666384','9666384','9666384','9666828','9666828','9666947','9667031','9667031','9667206','9667206','9667206','9667206','9667332','9667564','9667564','9667564','9667564','9667567','9667567','9667567','9667567','9667567','9667567','9667580','9667580','9667581','9667597','9667754','9667802','9667802','9667802','9667802','9667949','9667949','9668151','9668151','9668683','9668685','9668773','9668802','9668802','9668802','9668808','9668808','9669255','9669262','9669265','9669268','9669268','9669273','9669285','9669541','9669883','9669964','9669964','9669964','9669964','9669964','9669972','9670114','9670129','9670129','9670286','9670338','9670338','9670411','9671287','9671290','9671452','9671531','9671634','9671634','9671634','9671680','9671680','9671693','9671896','9671934','9671973','9671988','9671988','9672000','9672194','9672194','9672339','9672362','9672362','9672698','9672735','9672743','9672751','9672790','9672911','9672911','9672911','9672993','9673004','9673004','9673101','9673218','9673319','9673323','9673380','9673421','9673452','9673475','9673516','9673643','9673643','9673643','9673668','9673747','9673749','9673753','9673753','9673760','9674395','9674395','9674419','9674419','9674848','9674848','9674850','9674850','9674850','9674850','9674852','9674854','9674854','9674854','9674885','9674899','9674899','9674899','9674899','9674899','9674899','9674908','9674913','9674913','9674913','9674920','9674920','9674920','9674920','9675055','9675087','9675087','9675087','9675137','9675137','9675137','9675137','9675137','9675157','9675157','9675157','9675271','9675583','9675584','9675586','9675586','9696845','9696880','9696880','9697073','9697082','9697092','9697095','9697095','9697095','9697095','9697105','9697110','9697110','9697110','9697115','9697115','9697115','9697254','9698356','9632026','9658246','9661119','9661119','9661119','9661119','9661119','9662121','9666751','9697750','9697750','9698264','9698805','9698808','9698810','9698810','9698810','9698810','9698813','9699173','9699175','9699179','9699179','9699179','9699182','9699184','9699267','9699267','9699267','9699821','9699821','9699892','9699900','9699908','9699923','9699924','9699924','9699924','9699927','9699930','9699930','9699976','9700235','9700312','9700333','9700357','9700357','9700399','9700399','9700931','9700973','9701169','9701449','9701648','9704135')"; //$where = " WHERE `paymentTime` > $start AND `paymentTime` < $end AND `accountId` = '336' LIMIT 1,100"; $shipOrderList = OrderindexModel::showOrderList($tNameUnShipped, $where); $fileName = "repeatShipments" . date('Y-m-d', $end) . ".xls"; $excel = new ExportDataExcel('browser', $fileName); $excel->initialize(); $row = array('日期', 'ebay store', '交易号', '客户ID', '仓位号', '料号', '数量', '料号重量', '成本', '国家', '包裹总价值', '邮费', '币种', '运输方式', '邮寄公司', '挂号条码', '是/否', '重量', '收件人姓名', '客户电话', '地址', '英文州名', '英文城市名', '邮编', '订单编号', '包装员', '配货员', '扫描员', '分区人员', '料号描述'); $excel->addRow($row); foreach ($shipOrderList as $key => $value) { //key代表最外层的维数 /*$value分别有7个对应的键,分别为 orderData,//订单表头数据记录 orderExtenData,//订单表扩展数据记录 orderUserInfoData,//订单表中客户的数据记录 orderWhInfoData,//物料对订单进行操作的数据记录 orderNote,//订单的备注(销售人员添加)记录 orderTracknumber,//订单的追踪号记录 orderAudit,//订单明细审核记录 orderDetail //订单明细记录 */ $orderData = $value['orderData']; //订单表头数据记录,为一维数组 $orderExtenData = $value['orderExtenData']; //扩展表头数据记录,为一维数组 $orderUserInfoData = $value['orderUserInfoData']; //订单客户数据记录,为一维数组 $orderWhInfoData = $value['orderWhInfoData']; //物料对订单进行操作的数据记录,为一维数组 $orderNote = $value['orderNote']; //订单备注记录,二维数组 $orderTracknumber = $value['orderTracknumber']; //订单跟踪号,二维数组 $orderAudit = $value['orderAudit']; //订单明细审核记录,二维数组 $orderDetail = $value['orderDetail']; //订单明细记录,三维数组 $orderId = $orderData['id']; //****订单编号 $ebay_id $orderPaidtime = @date('Y-m-d', $orderData['paymentTime']); //****订单付款时间 paidtime $orderUserInfoEmail = $orderUserInfoData['email']; //****客户邮箱 emial $platformUsername = $orderExtenData['platformUsername']; //****客户平台登录名称 $ebay_userid,用扩展表中的该字段 ebay_username $username = @html_entity_decode($orderUserInfoData['username'], ENT_QUOTES, 'UTF-8'); //****客户真实名称(收件人) username $orderUserInfoStreet1 = @$orderUserInfoData['street']; //**** 街道地址 street1 $orderUserInfoStreet2 = @$orderUserInfoData['address2']; //*** 街道地址2 steet2(一般订单会有两个街道地址) $orderUserInfoCity = $orderUserInfoData['city']; //**** 市 city $orderUserInfoState = $orderUserInfoData['state']; //**** 州 state $orderUserInfoCountryName = $orderUserInfoData['countryName']; //**** 国家全名 //客服部小霞提出 导出列 国家 显示英文 方便退款处理 //$cnname = $country[$countryname]; $orderUserInfoZip = $orderUserInfoData['zipCode']; //**** 邮编 zipCode $orderUserInfoTel = $orderUserInfoData['landline']; //**** 座机 landline $orderWhInfoActualShipping = $orderWhInfoData['actualShipping']; //****实际运费,warehouse表中,ebay_shipfee $orderExtenFeedback = $orderExtenData['feedback']; //****客户留言 ebay_note $OrderActualTotal = @round($orderData['actualTotal'], 2); //****实际收款总价 $ebay_total $orderTracknumberOne = @$orderTracknumber[0]['tracknumber']; //****追踪号,这里只读取记录数的第一条记录的追踪号 $ebay_tracknumber $accountName = @$accounts[$orderData['accountId']]; //****账号名称 $ebay_account $orderRecordnumber = @$orderData['recordNumber']; //****订单编码(对应平台上的编码) $recordnumber0?????? //$ebay_carrier = @$shipOrder['transportId'];//transportId ebay_carrier $orderUserInfoPhone = $orderUserInfoData['phone']; //****客户手机号码 $ebay_phone $orderExtenCurrency = $orderExtenData['currency']; //****币种 $ebay_currency $orderWhInfoPackersId = $orderWhInfoData['packersId']; //包装人员Id $packinguser = $staffLists[$orderWhInfoPackersId]; //对应包装人员姓名 //var_dump($packinguser); $OrderChannelId = $orderData['channelId']; //渠道Id $channelId $orderCalcShipping = $orderData['calcShipping']; //估算运费 $ordershipfee $orderExtenPayPalPaymentId = $orderExtenData['PayPalPaymentId']; //Paypal付款ID $ebay_ptid $orderExtenPayPalEmailAddress = $orderExtenData['PayPalEmailAddress']; //PayPal付款邮箱地址 $ebay_pp $isCopy = $orderData['isCopy']; //默认为0为原始订单,1为被复制订单,2为复制订单 $isCopy = $isCopy == '0' ? '' : ($isCopy == '1' ? '被复制订单' : '复制订单'); //$ebay_noteb = $is_main_order==2 ? '复制 订单' : ($is_main_order==1 ? '被复制 订单' : ''); $isBuji = $orderData['isBuji']; //是否补寄订单。默认0正常订单;1为被补寄的订单;2为补寄产生的新订单 $isBuji = $isBuji == '0' ? '' : ($isBuji == '1' ? '被补寄订单' : '补寄产生新订单'); //$isBuji = isset ($sendreplacement[$isBuji]) ? $sendreplacement[$isBuji] : ''; //$is_sendreplacement = $isBuji; $isSplit = $orderData['isSplit']; //默认0正常订单;1为被拆分的订单;2为拆分产生的订单 $isSplit = $isSplit == '0' ? '' : ($isSplit == '1' ? '被拆分订单' : '拆分产生新订单'); //$ebay_splitorder $isCombinePackage = $orderData['combinePackage']; //是否合并包裹。合并包裹状态,0为正常订单;1为合并包裹主订单;2为合并包裹子订单 $isCombinePackage = $isCombinePackage == '0' ? '' : ($isCombinePackage == '1' ? '合并包裹主订单' : '合并包裹子订单'); $weighStaffId = isset($orderWhInfoData[0]['weighStaffId']) ? $orderWhInfoData[0]['weighStaffId'] : ''; //扫描员ID//称重 $weighStaff = $weighStaffId != '' ? $staffLists[$weighStaffId] : ''; //扫描员 $districtStaffId = isset($orderWhInfoData[0]['districtStaffId']) ? $orderWhInfoData[0]['districtStaffId'] : ''; //分区人员ID $districtStaff = $districtStaffId != '' ? $staffLists[$districtStaffId] : ''; //分区人员 $OrderTransportId = $orderData['transportId']; //运输方式Id $transportId $carrierName = $carriers[$OrderTransportId]; //运输方式名称 $ebay_carrier $address = $orderUserInfoStreet1 . "\n" . $orderUserInfoStreet2 . "\n" . $orderUserInfoCity . "\n" . $orderUserInfoState . "\n" . $orderUserInfoZip . "\n" . $orderUserInfoCountryName; //字段拼接成地址 $orderWhInfoWeighTime = date('Y-m-d', $orderWhInfoData['weighTime']); //称重时间,亦可以当做发货时间 $scantime $OrderCalcWeight = $orderData['calcWeight']; //估算重量,单位是kg $calculate_weight $orderWhInfoActualWeight = number_format($orderWhInfoData['actualWeight'] / 1000, 3); //实际重量 $orderweight2 $totalweight = $orderWhInfoActualWeight; //总重量 $mailway_c = $channels[$OrderChannelId]; //根据运输管理系统的接口获取 $isContainCombineSku = CommonModel::judge_contain_combinesku($orderId); //$ebay_combineorder 判断订单是否包含组合料号,返回true or false if (count($orderDetail) == 1) { //订单明细中只有一条记录时,订单中只有一种料号 $orderDetailTotalData = array_pop($orderDetail); //取得orderDetail中的这条总记录数据,包括orderDetailData和orderDetailExtenData $orderDetailData = $orderDetailTotalData['orderDetailData']; //明细中的常用数据 $orderDetailExtenData = $orderDetailTotalData['orderDetailExtenData']; //明细中的扩展数据 $orderDetailSku = $orderDetailData['sku']; //该明细下的$sku $orderDetailExtenItemId = $orderDetailExtenData['itemId']; //itemId $ebay_itemid $orderDetailAmount = intval($orderDetailData['amount']); //$amount 该明细下的sku对应的数量 $orderDetailRecordnumber = $orderDetailData['recordNumber']; //该明细对应平台的recordnumber $recordnumber $orderDetailItemPrice = round($orderDetailData['itemPrice'], 2) * $orderDetailAmount; //itemPrice(平台对应的销售单价)*对应数量 $ebay_itemprice // $ebay_shipfee = round_num(($OrderActualTotal - $orderDetailItemPrice), 2); $ebay_shipfee = CommonModel::calcshippingfee($totalweight, $orderUserInfoCountryName, $OrderActualTotal, $OrderTransportId); //round_num(($OrderActualTotal - $orderDetailItemPrice), 2); //订单总价-sku对应的总价得出运费,$ebay_shipfee $ebay_shipfee = isset($ebay_shipfee['fee']) ? $ebay_shipfee['fee']['fee'] : ''; $skus = GoodsModel::get_realskuinfo($orderDetailSku); //获取该sku下对应的真实料号信息(包括料号转换及组合料号对应真实料号信息) $values_skus = array_values($skus); //得到sku的数量 $goods_location = CommonModel::getPositionBySku($orderDetailSku); //仓位 $goodsInfo = GoodsModel::getSkuinfo($orderDetailSku); //获取真实sku的详细信息,包括采购名称和可用库存 $goodsWeight = $goodsInfo['goodsWeight']; //料号重量 $goods_cost = isset($goodsInfo['goodsCost']) ? round($goodsInfo['goodsCost'], 2) : 0; //采购成本 $pmId = isset($goodsInfo['pmId']) ? $goodsInfo['pmId'] : ''; //包材Id $ebay_packingmaterial = $packings[$pmId]['pmName']; //包材名称 $ebay_packingCost = $packings[$pmId]['pmCost']; //包材成本 $purchaseId = isset($goodsInfo['purchaseId']) ? $goodsInfo['purchaseId'] : ''; $cguser = $staffLists[$purchaseId]; //采购名称 $combineSku = GoodsModel::getCombineSkuinfo($orderDetailSku); //判断该sku是否是组合料号,如果是返回combineSku,sku,count关系记录数据,不是则返回false if ($combineSku !== false) { //为组合订单 $goods_costs = 0; $combine_weight_list = array(); $goods_costs_list = array(); foreach ($skus as $k => $v) { $goodsInfo2 = GoodsModel::getSkuinfo($k); $combine_weight_list[$k] = $orderDetailAmount * $v * $goodsInfo2['goodsWeight']; //组合订单重量数组 $goods_costs_list[$k] = $orderDetailAmount * $v * $goodsInfo2['goodsCost']; //货本数组 $goods_costs += $orderDetailAmount * $v * $goodsInfo2['goodsCost']; } $row = array($orderWhInfoWeighTime, $accountName, $orderRecordnumber, $platformUsername, $goods_location, $orderDetailSku, $orderDetailAmount, $goodsWeight, $goods_cost, $orderUserInfoCountryName, $OrderActualTotal, $ebay_shipfee, $orderExtenCurrency, $carrierName, $mailway_c, '', validate_trackingnumber($orderTracknumberOne) ? '是' : '否', $totalweight, $username, $orderUserInfoPhone, $address, $orderUserInfoState, $orderUserInfoCity, $orderUserInfoZip, $orderId, $packinguser, '', $weighStaff, $districtStaff, ''); $excel->addRow($row); foreach ($skus as $k => $v) { $goodsInfo3 = GoodsModel::getSkuinfo($k); $goods_cost = isset($goodsInfo3['goodsCost']) ? round($goodsInfo3['goodsCost'], 2) : 0; $goods_weight = isset($goodsInfo3['goodsWeight']) ? $goodsInfo3['goodsWeight'] : 0; $goods_location2 = CommonModel::getPositionBySku($k); //仓位 $pmId = isset($goodsInfo3['pmId']) ? $goodsInfo3['pmId'] : ''; $ebay_packingmaterial = $packings[$pmId]['pmName']; $ebay_packingCost = $packings[$pmId]['pmCost']; $purchaseId = isset($goodsInfo3[0]['purchaseId']) ? $goodsInfo3[0]['purchaseId'] : ''; $cguser = $staffLists[$purchaseId]; $ishipfee = round_num($goods_costs_list[$k] / array_sum($goods_costs_list) * $ebay_shipfee, 2); //根据货本比ebay运费 $iorderweight2 = round($combine_weight_list[$k] / array_sum($combine_weight_list) * $orderWhInfoActualWeight, 3); $iordershipfee = round_num($combine_weight_list[$k] / array_sum($combine_weight_list) * $orderCalcShipping, 2); $iprice = round_num(($goods_costs_list[$k] + $iordershipfee) / (array_sum($goods_costs_list) + $orderCalcShipping) * $ebay_itemprice, 2); //根据货本比产品价格 last modified by herman.xi @20130916 $row = array('', '', '', '', $goods_location2, $k, $v, $goods_weight, $goods_cost, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''); $excel->addRow($row); } } else { //非组合订单 $row = array($orderWhInfoWeighTime, $accountName, $orderRecordnumber, $platformUsername, $goods_location, $orderDetailSku, $orderDetailAmount, $goodsWeight, $goods_cost, $orderUserInfoCountryName, $OrderActualTotal, $ebay_shipfee, $orderExtenCurrency, $carrierName, $mailway_c, '', validate_trackingnumber($orderTracknumberOne) ? '是' : '否', $totalweight, $username, $orderUserInfoPhone, $address, $orderUserInfoState, $orderUserInfoCity, $orderUserInfoZip, $orderId, $packinguser, '', $weighStaff, $districtStaff, ''); $excel->addRow($row); } unset($combine_weight_list); unset($goods_costs_list); } else { //订单详细记录>1 $cctotal = 0; $ebay_itemprice = 0; $goods_costs = 0; $goods_list = array(); $goods_lists = array(); $goods_weight_list = array(); $goods_costs_list = array(); $calculate_weight = 0; foreach ($orderDetail as $orderDetailTotalData) { //$orderDetailTotalData ,包括orderDetailData和orderDetailExtenData $orderDetailData = $orderDetailTotalData['orderDetailData']; //明细中的常用数据 $orderDetailExtenData = $orderDetailTotalData['orderDetailExtenData']; //明细中的扩展数据 $detail_id = $orderDetailData['id']; $sku = $orderDetailData['sku']; $skus = GoodsModel::get_realskuinfo($sku); $_ebay_itemprice = round($orderDetailData['itemPrice'], 2); $ebay_itemprice += $orderDetailData['amount'] * $_ebay_itemprice; foreach ($skus as $k => $v) { $goodsInfo3 = GoodsModel::getSkuinfo($k); $_ebay_amount = intval($orderDetailData['amount'] * $v); $cctotal += $_ebay_amount; $calculate_weight += $_ebay_amount * $goodsInfo3['goodsWeight']; $goods_weight_list[$detail_id . $sku][$k] = $_ebay_amount * $goodsInfo3['goodsWeight']; $goods_costs_list[$detail_id . $sku][$k] = round($goodsInfo3['goodsCost'], 2) * $_ebay_amount; $goods_costs += round($goodsInfo3['goodsCost'], 2) * $_ebay_amount; } } //echo "---------$ebay_itemprice--------"; $ebay_shipfee = CommonModel::calcshippingfee($totalweight, $orderUserInfoCountryName, $OrderActualTotal, $OrderTransportId); $ebay_shipfee = isset($ebay_shipfee['fee']) ? $ebay_shipfee['fee']['fee'] : ''; // $ebay_shipfee = round_num(($OrderActualTotal - $ebay_itemprice), 2); $row = array($orderWhInfoWeighTime, $accountName, $orderRecordnumber, $platformUsername, '', '', $cctotal, '', $ebay_itemprice, $orderUserInfoCountryName, $OrderActualTotal, $ebay_shipfee, $orderExtenCurrency, $carrierName, $mailway_c, '', validate_trackingnumber($orderTracknumberOne) ? '是' : '否', $totalweight, $username, $orderUserInfoPhone, $address, $orderUserInfoState, $orderUserInfoCity, $orderUserInfoZip, $orderId, $packinguser, '', $weighStaff, $districtStaff, ''); $excel->addRow($row); foreach ($orderDetail as $orderDetailTotalData) { //$orderDetailTotalData ,包括orderDetailData和orderDetailExtenData $orderDetailData = $orderDetailTotalData['orderDetailData']; //明细中的常用数据 $orderDetailExtenData = $orderDetailTotalData['orderDetailExtenData']; //明细中的扩展数据 $detail_id = $orderDetailData['id']; $skuDe = $orderDetailData['sku']; $recordnumber = $orderDetailData['recordNumber']; $orderDetailExtenItemId = $orderDetailExtenData['itemId']; //itemId $ebay_itemid //$ebay_itemid = $detail_array['ebay_itemid']; $amount = intval($orderDetailData['amount']); $dshipingfee = $orderDetailData['shippingFee']; $debay_itemprice = round($orderDetailData['itemPrice'], 2); $goods_location = CommonModel::getPositionBySku($skuDe); $goodsInfo3 = GoodsModel::getSkuinfo($skuDe); $goods_cost = isset($goodsInfo3['goodsCost']) ? round($goodsInfo3['goodsCost'], 2) : 0; $pmId = isset($goodsInfo3['pmId']) ? $goodsInfo3['pmId'] : 0; $ebay_packingmaterial = $packings[$pmId]['pmName']; $ebay_packingCost = $packings[$pmId]['pmCost']; $purchaseId = isset($goodsInfo3['purchaseId']) ? $goodsInfo3['purchaseId'] : ''; $cguser = $staffLists[$purchaseId]; $dordershipfee = round($orderCalcShipping * (array_sum($goods_weight_list[$detail_id . $skuDe]) / $calculate_weight), 2); $dorderweight2 = round($orderWhInfoActualWeight * (array_sum($goods_weight_list[$detail_id . $skuDe]) / $calculate_weight), 3); $combineSku = GoodsModel::getCombineSkuinfo($skuDe); //$is_combineSku = count($combineSku); if ($combineSku !== false) { //为组合料号 $skus = GoodsModel::get_realskuinfo($skuDe); foreach ($skus as $k => $v) { $goods_location = CommonModel::getPositionBySku($k); $goodsInfo3 = GoodsModel::getSkuinfo($k); $goods_cost = isset($goodsInfo3['goodsCost']) ? round($goodsInfo3['goodsCost'], 2) : 0; $goods_weight = isset($goodsInfo3['goodsWeight']) ? $goodsInfo3['goodsWeight'] : 0; $pmId = isset($goodsInfo3['pmId']) ? $goodsInfo3['pmId'] : ''; $ebay_packingmaterial = $packings[$pmId]['pmName']; $ebay_packingCost = $packings[$pmId]['pmCost']; $purchaseId = isset($goodsInfo3['purchaseId']) ? $goodsInfo3['purchaseId'] : ''; $cguser = $staffLists[$purchaseId]; //$iprice = round_num(($goods_costs_list[$detail_id.$k][$k]/array_sum($goods_costs_list[$detail_id.$k])) * $debay_itemprice * $amount,2); //根据货本比产品价格 $ishipfee = round_num($goods_costs_list[$detail_id . $skuDe][$k] / array_sum($goods_costs_list[$detail_id . $skuDe]) * $dshipingfee, 2); //根据货本比ebay运费 $iorderweight2 = round($goods_weight_list[$detail_id . $skuDe][$k] / array_sum($goods_weight_list[$detail_id . $skuDe]) * $dorderweight2, 3); $iordershipfee = round_num($goods_weight_list[$detail_id . $skuDe][$k] / array_sum($goods_weight_list[$detail_id . $skuDe]) * $dordershipfee, 2); $iprice = round_num(($goods_costs_list[$detail_id . $skuDe][$k] + $iordershipfee) / (array_sum($goods_costs_list[$detail_id . $skuDe]) + $dordershipfee) * $debay_itemprice * $amount, 2); //根据货本比产品价格 last modified by herman.xi @20130916 $row = array('', '', '', '', $goods_location, $k, $v, $goods_weight, $goods_cost, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''); $excel->addRow($row); } } else { $goods_location = CommonModel::getPositionBySku($skuDe); $goodsInfo3 = GoodsModel::getSkuinfo($skuDe); $goods_cost = isset($goodsInfo3['goodsCost']) ? round($goodsInfo3['goodsCost'], 2) : 0; $goods_weight = isset($goodsInfo3['goodsWeight']) ? $goodsInfo3['goodsWeight'] : 0; $row = array('', '', '', '', $goods_location, $skuDe, $amount, $goods_weight, $goods_cost, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''); $excel->addRow($row); } } unset($goods_weight_list); unset($goods_costs_list); } } $excel->finalize(); exit; }
public function act_getMaterInfoByList() { $ret = GoodsModel::getMaterInfoByList(); return $ret; }
public static function intercept_exception_orders($orderData) { global $SYSTEM_ACCOUNTS, $__liquid_items_fenmocsku, $__liquid_items_BuiltinBattery, $__liquid_items_SuperSpecific, $__liquid_items_Paste; global $GLOBAL_EBAY_ACCOUNT; global $express_delivery, $no_express_delivery; global $actualTotal0; if (!$SYSTEM_ACCOUNTS) { require_once WEB_PATH . "conf/scripts/script.ebay.config.php"; } self::initDB(); $log_data = ''; $orderStatus = empty($orderData['orderData']['orderStatus']) ? C('STATEPENDING') : $orderData['orderData']['orderStatus']; $orderType = empty($orderData['orderData']['orderType']) ? C('STATEPENDING_CONV') : $orderData['orderData']['orderType']; $isNote = $orderData['orderData']['isNote']; if ($isNote) { $orderType = C('STATEPENDING_MSG'); } $transportId = $orderData['orderData']['transportId']; $countryName = $orderData['orderUserInfoData']['countryName']; $accountId = $orderData['orderData']['accountId']; $paymentTime = $orderData['orderData']['paymentTime']; $actualTotal = $orderData['orderData']['actualTotal']; $ebay_username = $orderData['orderUserInfoData']['username']; $orderDataid = $orderData['orderExtenData']['orderId']; $ebay_usermail = $orderData['orderUserInfoData']['email']; $PayPalEmailAddress = $orderData['orderExtenData']['PayPalEmailAddress']; /*echo "<pre>"; echo "-----------------------------<br>"; var_dump($SYSTEM_ACCOUNTS['Amazon']);*/ if (in_array($GLOBAL_EBAY_ACCOUNT[$accountId], $SYSTEM_ACCOUNTS['Amazon'])) { //非线下amazon账号订单 //ebay 平台可以重新计算运输方式 @ 20130301 if (empty($countryName)) { $orderStatus = C('STATESYNCINTERCEPT'); $orderType = C('STATESYNCINTERCEPT_AB'); //$log_data .= "[".date("Y-m-d H:i:s")."]\t自动跳转的状态为--".$orderStatus."--".$orderType."!\n\n"; //CommonModel::write_scripts_log('auto_contrast_intercept', $GLOBAL_EBAY_ACCOUNT[$accountId], $log_data); return array('orderStatus' => $orderStatus, 'orderType' => $orderType); } } /*echo "<pre>"; echo "-----------------------------<br>"; var_dump($GLOBAL_EBAY_ACCOUNT[$accountId]); var_dump($SYSTEM_ACCOUNTS['ebay']); var_dump($GLOBAL_EBAY_ACCOUNT[$accountId]); var_dump($SYSTEM_ACCOUNTS['海外销售平台']); var_dump($orderDataid);*/ if (in_array($GLOBAL_EBAY_ACCOUNT[$accountId], $SYSTEM_ACCOUNTS['ebay']) && !empty($orderDataid)) { //非线下ebay账号订单 //ebay 平台可以重新计算运输方式 @ 20130301 if (empty($countryName)) { $orderStatus = C('STATESYNCINTERCEPT'); $orderType = C('STATESYNCINTERCEPT_AB'); return array('orderStatus' => $orderStatus, 'orderType' => $orderType); } if ($actualTotal != $actualTotal0) { $actualTotal0 = (string) $actualTotal0; } echo "[" . date("Y-m-d H:i:s") . "]\t总价记录---{$ebay_id}---系统总价{$actualTotal}---计算总价{$actualTotal0}\n"; if (in_array($ebay_usermail, array("", "Invalid Request")) && $ebay_carrier == 'EUB') { $orderStatus = C('STATESYNCINTERCEPT'); $orderType = C('STATESYNCINTERCEPT_AB'); return array('orderStatus' => $orderStatus, 'orderType' => $orderType); } else { if ($actualTotal != $actualTotal0 && $orderStatus == 1) { $orderStatus = C('STATESYNCINTERCEPT'); $orderType = C('STATESYNCINTERCEPT_AB'); return array('orderStatus' => $orderStatus, 'orderType' => $orderType); } else { if (!empty($PayPalEmailAddress) && !in_array(strtolower($PayPalEmailAddress), PaypalEmailModel::get_account_paypalemails($accountId)) && $orderStatus == 1) { $orderStatus = C('STATESYNCINTERCEPT'); $orderType = C('STATEPENDING_EXCPAY'); return array('orderStatus' => $orderStatus, 'orderType' => $orderType); } } } //$log_data .= "[".date("Y-m-d H:i:s")."]\t自动跳转的状态为--".$orderStatus."--".$orderType."!\n\n"; //CommonModel::write_scripts_log('auto_contrast_intercept', $GLOBAL_EBAY_ACCOUNT[$accountId], $log_data); } if ($orderStatus == C('STATEOUTOFSTOCK')) { //缺货和自动拦截判断 //ebay 线上订单EUB大于5天,平邮和挂号大于7天不发货,不包括快递 //海外销售十天 $timeout = false; //$orderDataid = isset($orderData['ebay_orderid']) ? $orderData['ebay_orderid'] : ''; //$ebay_paidtime = isset($orderData['ebay_paidtime']) ? $orderData['ebay_paidtime'] : ''; if (!empty($paymentTime)) { //线上订单,付款时间不能为空 $diff_time = ceil((time() - $paymentTime) / (3600 * 24)); if (in_array($GLOBAL_EBAY_ACCOUNT[$accountId], $SYSTEM_ACCOUNTS['ebay'])) { if ($ebay_carrier == 'EUB' && $diff_time > 5) { $timeout = true; } else { if ((strpos($ebay_carrier, '平邮') !== false || strpos($ebay_carrier, '挂号') !== false) && $diff_time > 7) { $timeout = true; } } } /*else if(in_array($GLOBAL_EBAY_ACCOUNT[$accountId],$SYSTEM_ACCOUNTS['海外销售平台'])){ if((strpos($ebay_carrier, '中国邮政平邮')!==false && $diff_time > 5) || $diff_time > 10){ $timeout = true; } }*/ } if ($timeout) { //$log_data .= "\n缺货订单={$ebay_id}======移动到缺货需退款中======\n"; $orderStatus = C('STATEREFUND'); $orderType = C('STATEREFUND_OUTSTOCK'); //$log_data .= "[".date("Y-m-d H:i:s")."]\t自动跳转的状态为--".$orderStatus."--".$orderType."!\n\n"; //CommonModel::write_scripts_log('auto_contrast_intercept', $GLOBAL_EBAY_ACCOUNT[$accountId], $log_data); return array('orderStatus' => $orderStatus, 'orderType' => $orderType); //continue; } } if (in_array($orderStatus, array(C('STATESTOCKEXCEPTION')))) { //缺货处理\合并包裹处理 $have_goodscount = true; foreach ($orderdetaillist as $orderdetail) { $sku_arr = GoodsModel::get_realskuinfo($orderdetail['sku']); foreach ($sku_arr as $or_sku => $or_nums) { $allnums = $or_nums * $orderdetail['ebay_amount']; $skuinfo = CommonModel::get_sku_info($or_sku); $salensend = CommonModel::getpartsaleandnosendall($or_sku); //$sql = "UPDATE ebay_sku_statistics SET salensend = $salensend WHERE sku = '$or_sku' "; //self::$dbConn->query($sql); //$log_data .= "[".date("Y-m-d H:i:s")."]\t---{$sql}\n\n"; //$log_data .= "订单===$ebay_id===料号==$or_sku===实际库存为{$skuinfo['realnums']}===需求量为{$allnums}===待发货数量为{$salensend}===\n"; if (!isset($skuinfo['realnums']) || empty($skuinfo['realnums']) || $skuinfo['realnums'] - $salensend < 0) { //缺货本身算待发货,不能重复扣除 $have_goodscount = false; break; } } } if ($have_goodscount) { /*$orderStatus = C('STATEPENDING'); $orderType = C('STATEPENDING_CONV');*/ $log_data .= "\n缺货订单={$ebay_id}======有货至待打印======\n"; //$final_status = 618; //$log_data .= "[".date("Y-m-d H:i:s")."]\t自动跳转的状态为--".$orderStatus."--".$orderType."!\n\n"; //CommonModel::write_scripts_log('auto_contrast_intercept', $GLOBAL_EBAY_ACCOUNT[$accountId], $log_data); return array('orderStatus' => $orderStatus, 'orderType' => $orderType); //continue; } } return false; }
function act_goodsAddXlsSave() { $uploadfile = date("Y") . date("m") . date("d") . rand(1, 3009) . ".xls"; if ($_FILES['upfile']['tmp_name'] == '') { echo "请选择上传的excel文件"; exit; } if (move_uploaded_file($_FILES['upfile']['tmp_name'], './upload/' . $uploadfile)) { echo "<font color=BLUE>文件上传成功!</font><br>"; } else { echo "<font color=red> 文件上传失败!</font><br>"; } echo $uploadfile; $fileName = 'upload/' . $uploadfile; $filePath = $fileName; $username = $_SESSION['userName']; $userId = $_SESSION['userId']; $stockdetailpower = UserModel::getUserPower($userId); $stockdetailpower = explode(',', $stockdetailpower[0]['powerName']); $PHPExcel = new PHPExcel(); $PHPReader = new PHPExcel_Reader_Excel2007(); if (!$PHPReader->canRead($filePath)) { $PHPReader = new PHPExcel_Reader_Excel5(); if (!$PHPReader->canRead($filePath)) { echo 'no Excel'; return; } } $PHPExcel = $PHPReader->load($filePath); $currentSheet = $PHPExcel->getSheet(0); $allRow = $currentSheet->getHighestRow(); for ($c = 2; $c <= $allRow; $c++) { $data = array(); $nowtime = time(); $storeid = ''; $aa = 'A' . $c; $bb = 'B' . $c; $cc = 'C' . $c; $dd = 'D' . $c; $ee = 'E' . $c; $ff = 'F' . $c; $gg = 'G' . $c; $hh = 'H' . $c; $ii = 'I' . $c; $jj = 'J' . $c; $kk = 'K' . $c; $ll = 'L' . $c; $mm = 'M' . $c; $nn = 'N' . $c; $oo = 'O' . $c; $pp = 'P' . $c; $qq = 'Q' . $c; $rr = 'R' . $c; $ss = 'S' . $c; $tt = 'T' . $c; $sku = post_check(trim($currentSheet->getCell($bb)->getValue())); if (!preg_match("/^[A-Z0-9]+(_[A-Z0-9]+)*\$/", $sku)) { if ($sku != '') { echo "数据料号:<font color='#FF0000'>" . $sku . "</font>书写不规范,请认真检查再提交..."; exit; } } //检测是否导入完成 if (empty($sku)) { $mask++; if ($mask > 9) { break; } continue; } else { $mask = 1; } // 过滤下数据 $goodsCost = trim($currentSheet->getCell($dd)->getValue()); $goodsWeight = trim($currentSheet->getCell($ff)->getValue()); if (!preg_match("/[\\d]/", $goodsCost) && $goodsCost != '') { echo "货品成本数据有误"; exit; } else { if (!preg_match("/[\\d]/", $goodsWeight) && $goodsWeight != '') { echo "货品重量数据有误"; exit; } } $spu = post_check(trim($currentSheet->getCell($aa)->getValue())); $goodsName = post_check(trim($currentSheet->getCell($cc)->getValue())); $goodsCost = empty($goodsCost) ? 0 : round_num($goodsCost, 2); //仓位号 $goods_location = post_check(trim($currentSheet->getCell($ee)->getValue())); $goodsWeight = empty($goodsWeight) ? 0 : number_format($goodsWeight, 3, '.', ''); $goodsNote = post_check(trim($currentSheet->getCell($gg)->getValue())); $goodsDecNameByEN = post_check(trim($currentSheet->getCell($hh)->getValue())); $goodsCustomsCode = post_check(trim($currentSheet->getCell($ii)->getValue())); $goodsDecNameByCN = post_check(trim($currentSheet->getCell($jj)->getValue())); $goodsDecWorth = post_check(trim($currentSheet->getCell($kk)->getValue())); $goodsLength = post_check(trim($currentSheet->getCell($ll)->getValue())); $goodsWidth = post_check(trim($currentSheet->getCell($mm)->getValue())); $goodsHeight = post_check(trim($currentSheet->getCell($nn)->getValue())); //类别 $goods_categoryname = post_check(trim($currentSheet->getCell($oo)->getValue())); $pid_name = post_check(trim($currentSheet->getCell($pp)->getValue())); //仓库 $warehouseName = post_check(trim($currentSheet->getCell($qq)->getValue())); //采购员 $purchaseName = post_check(trim($currentSheet->getCell($rr)->getValue())); //包装材料 $packingmaterial = post_check(trim($currentSheet->getCell($ss)->getValue())); //供应商 $capacity = post_check(trim($currentSheet->getCell($tt)->getValue())); if ($goodsLength == '') { $goodsLength = 0; } if ($goodsWidth == '') { $goodsWidth = 0; } if ($goodsHeight == '') { $goodsHeight = 0; } $spu = strpos($spu, '_') === false ? str_pad($spu, 3, '0', STR_PAD_LEFT) : $spu; $sku = strpos($sku, '_') === false ? str_pad($sku, 3, '0', STR_PAD_LEFT) : $sku; // if($department != '采购部' && $spu !=''){ // echo "<br/>非采购部人员不能导入或修改spu的值"; // exit(); // } /* 仓库对应的IDfactory */ if (!empty($warehouseName)) { /* $wh = RelationModel::getWarehouse("and warehouseName='{$warehouseName}'"); var_dump($wh);die; $storeid = $wh[0]['id']; */ $storeid = 1; } /* 货品类别 */ if (!empty($goods_categoryname) && !empty($pid_name)) { $pcate = CategoryModel::getCategoryList("id", "where name='{$pid_name}'"); if ($pcate) { $cate = CategoryModel::getCategoryList("path", "where pid='{$pcate[0]['id']}' and name='{$goods_categoryname}'"); if ($cate) { $goodsCategory = $cate[0]['path']; } else { echo "<br/>第<font color='red'>{$c}</font>条记录中<font color='orange'>货品类别或父类有误,</font>请检查后再提交...<br/>"; exit; } } else { echo "<br/>第<font color='red'>{$c}</font>条记录中<font color='orange'>货品类别或父类有误,</font>请检查后再提交...<br/>"; exit; } //$goodsCategory = "1-3-5"; //调用类别接口获取类别id } if ($purchaseName == "") { echo "有部分数据没填采购名字,请认真检查再提交..."; exit; } else { $purchaseId = 1; //需调用接口获取采购员id } /* 需要调接口获取用户部门 if($department == '采购部' && trim($goodsCategory) == ''){//采购部人员操作时,导入货品类别不能为空 echo "有部分数据没填货品类别,请认真检查再提交..."; exit(); } */ //统计供应商id if (!empty($capacity)) { $capacity_a = array(); $capacity_a = array_filter(explode(',', $capacity)); $capacityid = 1; //调用供应商接口获取id } $data = array('goodsName' => $goodsName, 'goodsDecNameByEN' => $goodsDecNameByEN, 'goodsDecNameByCN' => $goodsDecNameByCN, 'spu' => $spu, 'sku' => $sku, 'goodsCost' => $goodsCost, 'goodsWeight' => $goodsWeight, 'goodsNote' => $goodsNote, 'goodsLength' => $goodsLength, 'goodsWidth' => $goodsWidth, 'goodsHeight' => $goodsHeight, 'goodsCategory' => $goodsCategory, 'goodsCustomsCode' => $goodsCustomsCode, 'goodsDecWorth' => $goodsDecWorth, 'purchaseId' => $purchaseId); $result = GoodsModel::getGoodsList("id", "where sku='{$sku}'"); if (empty($result)) { $data['goodsCreatedTime'] = $nowtime; $data['isNew'] = 1; //默认是新品 /* if(empty($goodsCategory) && $department == '采购部'){//拦截错误的货品类别和父类记录 $cn = $c - 2; echo "<br/>第<font color='red'>$cn</font>条记录中<font color='orange'>货品类别或父类有误,</font>请检查后再提交...<br/>"; exit(); } */ //if(empty($spu) && $department == '采购部'){//首次插入数据时spu必须非空且要符合规范 if (empty($spu)) { //首次插入数据时spu必须非空且要符合规范 echo "spu存在为空的列,请认真检查再提交..."; exit; } //if(!preg_match("/^[A-Z0-9]+(_[A-Z0-9]+)*$/",$spu) && $department == '采购部'){ if (!preg_match("/^[A-Z0-9]+(_[A-Z0-9]+)*\$/", $spu)) { echo "SPU号:<font color='#FF0000'>" . $spu . "</font>书写不规范,请认真检查再提交..."; exit; } /* foreach($sqlnew as $arrnew){//如果在料号转换中存在和导入的sku相同的新料号,则认为该sku仍然是老品 if($arrnew['new_sku'] == $goods_sn){ $isNew = 0; break; } } */ $goodsid = GoodsModel::insertRow($data); if ($goodsid) { $goodsCode = $goodsid + 1000000; $u_data = array('goodsCode' => $goodsCode); $where = "AND id='{$goodsid}'"; if (GoodsModel::update($u_data, $where)) { //插入物品与仓位关联表 if (!empty($storeid)) { $good_wh_data = array('goodsId' => $goodsid, 'locationId' => $storeid); } //跟新sku自动表进入系统 $u_sku_data = array('status' => 2); SpuModel::update($u_sku_data, "AND sku='{$spu}'"); $status = " -[<font color='#33CC33'>物品编号:{$sku} 导入成功 </font>]"; echo $status . '<br>'; } else { $status = " -[<font color='#FF0000'>物品编号:{$sku} 导入失败<br/></font>]"; echo $status . '<br>'; } } /* if($goods_cost){ //增加价格变化到价格表 add by guanyongjun 2013-06-08 $sqlcost = "INSERT INTO ebay_goods_cost (goods_sn,goods_cost,add_time,cguser,storeid,mainsku) VALUES('{$goods_sn}','{$goods_cost}','{$nowtime}','{$cguser}','{$storeid}','".get_mainsku($goods_sn)."')"; echo $sqlcost."<br/>"; $dbcon->execute($sqlcost); } */ } else { if ($spu == '' || !in_array('stock_name', $stockdetailpower)) { unset($data['spu']); } if ($goodsName == '' || !in_array('stock_name', $stockdetailpower)) { unset($data['goodsName']); } if ($goodsDecNameByEN == '' || !in_array('stock_name', $stockdetailpower)) { unset($data['goodsDecNameByEN']); } if ($goodsDecNameByCN == '' || !in_array('stock_name', $stockdetailpower)) { unset($data['goodsDecNameByCN']); } if ($sku == '' || !in_array('stock_name', $stockdetailpower)) { unset($data['sku']); } if ($goodsCost == '' || !in_array('stock_name', $stockdetailpower)) { unset($data['goodsCost']); } if ($goodsWeight == '' || !in_array('stock_name', $stockdetailpower)) { unset($data['goodsWeight']); } if ($goodsNote == '' || !in_array('stock_name', $stockdetailpower)) { unset($data['goodsNote']); } if ($goodsLength == '' || !in_array('stock_name', $stockdetailpower)) { unset($data['goodsLength']); } if ($goodsWidth == '' || !in_array('stock_name', $stockdetailpower)) { unset($data['goodsWidth']); } if ($goodsHeight == '' || !in_array('stock_name', $stockdetailpower)) { unset($data['goodsHeight']); } if ($goodsCategory == '' || !in_array('stock_name', $stockdetailpower)) { unset($data['goodsCategory']); } if ($goodsCustomsCode == '' || !in_array('stock_name', $stockdetailpower)) { unset($data['goodsCustomsCode']); } if ($goodsDecWorth == '' || !in_array('stock_name', $stockdetailpower)) { unset($data['goodsDecWorth']); } if ($purchaseName == '' || !in_array('stock_name', $stockdetailpower)) { unset($data['purchaseId']); } $where = "AND sku='{$sku}'"; if (!empty($data)) { if (GoodsModel::update($data, $where)) { //插入物品与仓位关联表 if (!empty($storeid)) { $good_wh_data = array('goodsId' => $goodsid, 'locationId' => $storeid); RelationModel::insertGoodsWhRow($good_wh_data); } $status = " -[<font color='#FF0000'>物品编号:{$sku} 更新失败</font>]"; echo $status . '<br>'; } else { $status = " -[<font color='#FF0000'>物品编号:{$sku} 更新失败</font>]"; echo $status . '<br>'; } /* if($goods_cost != '' && $goods_cost && in_array('stock_cost', $stockdetailpower) ) { //增加价格变化到价格表 add by guanyongjun 2013-06-08 $sqlcost = "SELECT goods_cost FROM ebay_goods WHERE goods_sn = '{$goods_sn}' AND goods_cost = '{$goods_cost}'"; //echo $sqlcost; //exit; $sqlcost = $dbcon->execute($sqlcost); $sqlcost = $dbcon->getResultArray($sqlcost); if(!$sqlcost){ $costtime = time(); $sqlcost = "INSERT INTO ebay_goods_cost (goods_sn,goods_cost,add_time,cguser,storeid,mainsku) VALUES('{$goods_sn}','{$goods_cost}','{$costtime}','{$cguser}','{$storeid}','".get_mainsku($goods_sn)."')"; echo $sqlcost."<br/>"; $dbcon->execute($sqlcost); } } if($isuse!=='' && in_array('stock_status', $stockdetailpower) ){ //更新价格表状态 add by guanyongjun 2013-06-08 $sqlcost = "UPDATE ebay_goods_cost SET isuse = '".intval($isuse)."' WHERE goods_sn = '{$goods_sn}'"; $dbcon->execute($sqlcost); } */ } else { $status = " -[<font color='#FF0000'>物品编号:{$sku} 已经是最新</font>]"; echo $status . '<br>'; } } echo '<br>'; } }