Exemple #1
0
 public static function cancelquo($params)
 {
     $quoid = $params['quoid'];
     if ($params['inqid']) {
         //查询询价单状态
         $sta = 'select Status from pap_inquiry where InquiryID=' . $params['inqid'];
         $r = Yii::app()->papdb->createCommand($sta)->queryRow();
         if ($r['Status'] > 1) {
             echo json_encode(array('count' => -1, 'msg' => '只能取消待报价或待确认的询价单'));
             die;
         }
     } else {
         //查询报价单状态
         $sta = 'select Status from pap_quotation where QuoID=' . $quoid;
         $r = Yii::app()->papdb->createCommand($sta)->queryRow();
         if ($r['Status'] != '1') {
             echo json_encode(array('count' => -1, 'msg' => '只能取消待确认的报价单'));
             die;
         }
     }
     $sql = 'select SchID from pap_quotation_scheme where QuoID=' . $quoid;
     $result = Yii::app()->papdb->createCommand($sql)->queryAll();
     $schids = array();
     foreach ($result as $r) {
         $schids[] = $r['SchID'];
     }
     $schstr = implode(',', $schids);
     if ($schids) {
         $goods = PapQuotationGoods::model()->deleteAll('SchID in (' . $schstr . ')');
     }
     $sch = PapQuotationScheme::model()->deleteAll('QuoID=' . $quoid);
     $quo = PapQuotation::model()->deleteByPk($quoid);
     if ($params['inqid']) {
         //查询询价单是否报价
         $quosql = 'select QuoID from pap_quotation where IfSend="2" and InquiryID=' . $params['inqid'];
         $quos = Yii::app()->papdb->createCommand($quosql)->queryRow();
         if (!$quos) {
             $update = 'update pap_inquiry set Status=0 where InquiryID=' . $params['inqid'];
             Yii::app()->papdb->createCommand($update)->execute();
         }
     }
     echo json_encode(array('count' => $quo + $sch + $goods));
 }
Exemple #2
0
 public static function editscheme($params)
 {
     $organID = Yii::app()->user->getOrganID();
     $time = $_SERVER['REQUEST_TIME'];
     //更新报价单
     $quoID = self::ifsendquo(array('inqid' => $params['inqid']));
     $quodatas['UpdateTime'] = $time;
     $quodatas['Title'] = $params['quoname'];
     $result = Yii::app()->papdb->createCommand()->update('pap_quotation', $quodatas, 'QuoID=' . $quoID);
     $SchID = $params['schid'];
     $datas['TotalFee'] = $params['quoprices'];
     $datas['GoodFee'] = $params['totalprices'];
     $datas['ShipFee'] = $params['shipprices'];
     $datas['ShipFee'] = $params['shipprices'];
     $datas['UpdateTime'] = $time;
     //保存附件
     if ($params['fileurl']) {
         $datas['FileName'] = $params['filename'];
         $datas['FileUrl'] = $params['fileurl'];
         //删除之前附件
         $quo_data = PapQuotationScheme::model()->findByPk($SchID);
         if (!empty($quo_data['FileName'])) {
             $ftp = new Ftp();
             $res = $ftp->delete_file($quo_data->FileUrl);
             $ftp->close();
         }
     }
     $result = Yii::app()->papdb->createCommand()->update('pap_quotation_scheme', $datas, 'SchID=:SchID', array(':SchID' => $SchID));
     //获取商品信息
     $goodsinfo = array();
     $goodsids = explode(',', $params['quoids']);
     $goodsnum = explode(',', $params['quonum']);
     $goodsprice = explode(',', $params['quoprice']);
     //获取以前的商品信息
     $oldgoodsinfo = PapQuotationGoods::model()->findAll('SchID=' . $SchID);
     $newgoodsinfo = array();
     foreach ($goodsids as $key => $v) {
         if ($v) {
             $newgoodsinfo[$key]['GoodsID'] = $goodsids[$key];
             $newgoodsinfo[$key]['Num'] = $goodsnum[$key];
             $newgoodsinfo[$key]['Price'] = $goodsprice[$key];
             $version = QuotationService::getgoodsversion($goodsids[$key]);
             $newgoodsinfo[$key]['Version'] = $version ? $version : 0;
         }
     }
     $insertid = array();
     //将报价单商品插入报价单商品表中
     if ($SchID) {
         foreach ($newgoodsinfo as $nkey => $new) {
             $newids[] = $new['GoodsID'];
         }
         if ($oldgoodsinfo) {
             foreach ($oldgoodsinfo as $okey => $old) {
                 $oldids[] = $old['GoodsID'];
             }
         } else {
             $oldids = array();
         }
         foreach ($oldids as $id) {
             if (!in_array($id, $newids)) {
                 //删除商品
                 $delcount = Yii::app()->papdb->createCommand()->delete('pap_quotation_goods', 'SchID=:SchID and GoodsID=:goodsid', array(':SchID' => $SchID, ':goodsid' => $id));
             }
         }
         foreach ($newids as $key => $id) {
             if (in_array($id, $oldids)) {
                 //更新商品
                 $update['Num'] = $newgoodsinfo[$key]['Num'];
                 $update['Price'] = $newgoodsinfo[$key]['Price'];
                 $update['Version'] = $newgoodsinfo[$key]['Version'];
                 $result = Yii::app()->papdb->createCommand()->update('pap_quotation_goods', $update, 'SchID=:SchID and GoodsID=:goodsid', array(':SchID' => $SchID, ':goodsid' => $id));
                 if ($result == 1) {
                     $res = 1;
                 }
             } else {
                 //插入商品
                 $goodsdatas['SchID'] = $SchID;
                 $goodsdatas['GoodsID'] = $newgoodsinfo[$key]['GoodsID'];
                 $goodsdatas['Num'] = $newgoodsinfo[$key]['Num'];
                 $goodsdatas['Price'] = $newgoodsinfo[$key]['Price'];
                 $goodsdatas['Version'] = $newgoodsinfo[$key]['Version'];
                 $result = Yii::app()->papdb->createCommand()->insert('pap_quotation_goods', $goodsdatas);
                 $insertid[] = Yii::app()->papdb->getLastInsertID();
             }
         }
     }
     if ($res = 1 || count($insertid) > 0 || $delcount > 0) {
         echo json_encode(array('count' => 1, 'schid' => $SchID, 'success' => true));
     } else {
         echo json_encode(array('count' => 0));
     }
 }
Exemple #3
0
 public function actionOrderGoods()
 {
     $this->layout = '//layouts/base';
     $goodsid = Yii::app()->request->getParam('goods');
     $version = Yii::app()->request->getParam('Version');
     $order = Yii::app()->request->getParam('Order');
     $return = Yii::app()->request->getParam('return');
     $quo = Yii::app()->request->getParam('quo');
     //版本信息
     $good = DealergoodsService::getmongoversion($goodsid, $version);
     $result = $good['GoodsInfo'];
     $result['SellerID'] = $result['OrganID'];
     if ($order) {
         $model = PapOrderGoods::model()->find(array('select' => 'ProPrice as Price,Quantity,MakeID,CarID,Year,ModelID', 'condition' => "OrderID={$order} and GoodsID={$goodsid}"))->attributes;
         $result['Quantity'] = $model['Quantity'];
         $result['Price'] = $model['Price'];
         $car = array('make' => $model['MakeID'], 'series' => $model['CarID'], 'year' => $model['Year'], 'model' => $model['ModelID']);
     } else {
         if ($return) {
             $model = PapReturnGoods::model()->find(array('select' => 'Price,OrderID', 'condition' => "ReturnID='{$return}' and GoodsID='{$goodsid}'"))->attributes;
             $result['Quantity'] = $model['Quantity'];
             $result['Price'] = $model['Price'];
             $ordermodel = PapOrderGoods::model()->find(array('select' => 'MakeID,CarID,Year,ModelID', 'condition' => "OrderID={$model['OrderID']} and GoodsID={$goodsid}"))->attributes;
             $car = array('make' => $ordermodel['MakeID'], 'series' => $ordermodel['CarID'], 'year' => $ordermodel['Year'], 'model' => $ordermodel['ModelID']);
         } else {
             if ($quo) {
                 $model = PapQuotationGoods::model()->findByPk($quo, array('select' => 'Price,Num', 'condition' => "GoodsID='{$goodsid}'"))->attributes;
                 $result['Quantity'] = $model['Num'];
                 $result['Price'] = $model['Price'];
             } else {
                 $this->redirect(array('index'));
             }
         }
     }
     //发货公告
     $model = new PapGoodsSendnotice();
     $notice = $model->find("OrganID = {$result['SellerID']}");
     //商品基本信息
     $result['GoodsID'] = $goodsid;
     $result['BrandName'] = $result['Brand'];
     $goods = PapGoods::model()->findByPk($goodsid, array('select' => 'IsSale,CommentNo'));
     $result['IsSale'] = $goods->attributes['IsSale'];
     $result['CommentNo'] = $goods->attributes['CommentNo'];
     if ($result['oeno']) {
         $oe = '';
         foreach ($result['oeno'] as $v) {
             $oe .= $v . ',';
         }
         $result['OENO'] = substr($oe, 0, -1);
     } else {
         $result['OENO'] = '';
     }
     //最小交易金额
     $result['MinTurnover'] = PapOrderMinTurnover::model()->find("OrganID=:ID", array(":ID" => $result['SellerID']))->attributes['MinTurnover'];
     //店家积分
     $result['TotalScore'] = DefaultService::getrecord($result['SellerID']);
     //店家信息
     $organInfo = Organ::model()->findByPk($result['SellerID'])->attributes;
     $result['OrganName'] = $organInfo['OrganName'];
     $result['QQ'] = $organInfo['QQ'];
     $result['Phone'] = $organInfo['Phone'];
     $result['Address'] = array(Area::getCity($organInfo['Province']), Area::getCity($organInfo['City']), Area::getCity($organInfo['Area']));
     //大类子类标准名称
     $result['StandCodeName'] = Gcategory::model()->find(array('select' => 'Name', 'condition' => "Code='{$result['StandCode']}'"))->attributes['Name'];
     $cpArr = MallService::getCategory($result['StandCode']);
     $result['BigName'] = $cpArr['BigParts'];
     $result['SubName'] = $cpArr['SubParts'];
     $result['sub'] = $cpArr['sub'];
     $result['ValidityType'] = $result['spec']['ValidityType'];
     $result['ValidityDate'] = $result['spec']['ValidityDate'];
     $result['BganCompany'] = $result['spec']['BganCompany'] ? $result['spec']['BganCompany'] : '';
     //标品
     $result['BganGoodsNO'] = $result['spec']['BganGoodsNO'] ? $result['spec']['BganGoodsNO'] : '';
     //标商
     $result['Unit'] = $result['spec']['Unit'] ? $result['spec']['Unit'] : '';
     //单位ID
     $result['UnitName'] = GoodsUnit::model()->findByPk($result['Unit'])->attributes['UnitName'];
     //单位
     $result['MinQuantity'] = $result['pack']['MinQuantity'] ? $result['pack']['MinQuantity'] : '';
     //最小包装
     // 图片
     if (!$result['img']) {
         $result['Images'][0]['ImageUrl'] = 'dealer/goods-img-big.jpg';
         $result['Images'][0]['BigImage'] = 'dealer/goods-img-big.jpg';
     } else {
         foreach ($result['img'] as $k => $v) {
             $result['Images'][$k]['MallImage'] = $v['MallImage'];
             $result['Images'][$k]['ImageUrl'] = $v['ImageUrl'];
             if (!$v['BigImage']) {
                 $result['Images'][$k]['BigImage'] = $v['ImageUrl'];
             } else {
                 $result['Images'][$k]['BigImage'] = $v['BigImage'];
             }
         }
     }
     if (!$result) {
         $this->redirect(array('index'));
     }
     $carmodeltext = MallService::getCarmodeltxt($car);
     $carfit = $car;
     $carfit['goodsid'] = $goodsid;
     $fitres = MallService::checkCarfit($carfit);
     $rows = $this->Getmaincate($result['SellerID']);
     $cate = $this->findsub($rows);
     $this->pageTitle = Yii::app()->name . '-' . "订单商品详情";
     //获取经销商客服列表
     $csparams['organID'] = $result['SellerID'];
     $csparams['type'] = 1;
     $csinfo = CsService::getcslists($csparams);
     $this->render('ordergoods', array('r' => $result, 'cate' => $cate, 'carmodeltext' => $carmodeltext, 'fitres' => $fitres['success'] == 1 ? 1 : 0, 'csinfo' => $csinfo, 'car' => $car, 'data' => $notice, 'goodsid' => $goodsid));
 }