Пример #1
0
 public function run()
 {
     //         $cri = new CDbCriteria(array(
     //             'condition'=>'is_show = 1',
     //             'order'=>'sort_order asc, id desc'
     //         ));
     //         $CustomerService = CustomerService::model()->findAll($cri);
     //         $this->render('customerService', array(
     //             'CustomerService'=>$CustomerService
     //         ));
     $dealerid = Yii::app()->request->getParam('dealerid') ? Yii::app()->request->getParam('dealerid') : Yii::app()->request->getParam('dealer');
     if ($dealerid) {
         $csparams['organID'] = $dealerid;
         $csparams['type'] = 1;
         $csinfo = CsService::getcslists($csparams);
         $seller = DefaultService::sellerstore($dealerid);
     }
     if (Yii::app()->request->getParam('goods')) {
         $goodsid = Yii::app()->request->getParam('goods');
         $criteria = new CDbCriteria();
         $criteria->condition = " t.OrganID!=''";
         // 上架的和没有删除的商品
         $model = PapGoods::model()->findByPk($goodsid, $criteria);
         if ($model['OrganID']) {
             $csparams['organID'] = $model['OrganID'];
             $csparams['type'] = 1;
             $csinfo = CsService::getcslists($csparams);
             $seller = DefaultService::sellerstore($model['OrganID']);
         }
     }
     $this->render('customerService', array('csinfo' => $csinfo, 'seller' => $seller));
 }
Пример #2
0
 public function run($args)
 {
     Yii::app()->getComponent('log');
     Yii::log(date('Y-m-d H:i:s') . " [DealerPromotion] start", 'info', 'command');
     //所要执行的任务,如数据符合某条件更新,删除,修改
     $Times = time() - 24 * 60 * 60 * 7 * 2;
     $count = PapGoods::model()->updateAll(array('IsPro' => 0, 'UpdateTime' => time(), 'ProTime' => '', 'ProPrice' => NULL), "ProTime < {$Times}");
     Yii::log(date('Y-m-d H:i:s') . " [DealerPromotion] end \n", 'info', 'command');
     echo date('Y-m-d H:i:s') . " [DealerPromotion] result:" . $count . "\n";
 }
Пример #3
0
 public static function getsubgoods($params)
 {
     if (!isset($params['subid']) || empty($params['subid'])) {
         return null;
     }
     $subid = $params['subid'];
     $organID = $params['organID'];
     $code = self::getCode($subid);
     $cri = new CDbCriteria();
     $cri->addInCondition('StandCode', $code);
     $cri->addCondition('IsSale=1');
     $cri->addCondition('ISdelete=1');
     $goods = PapGoods::model()->findAll($cri);
     //$goods=PapGoodsGcategory::model()->findAll('SubParts=:sub',array(':sub'=>$subid));
     $result = array();
     if ($goods) {
         foreach ($goods as $key => $val) {
             $res = PapGoods::model()->findByPk($val['ID'], 'IsSale=1 and ISdelete=1');
             //获取商品首张图片
             if (isset($res['ID']) && !is_null($res['ID'])) {
                 $result[$key] = $res->attributes;
                 $price = MallService::getContactprice($res['OrganID'], $organID);
                 $result[$key]['PriceRatio'] = $price['PriceRatio'] ? $price['PriceRatio'] : "100%";
                 $result[$key]['Price'] = sprintf("%.2f", $res['Price'] * $result[$key]['PriceRatio'] / 100);
                 if ($res['IsPro'] == 1) {
                     if (!is_null($res['ProPrice']) && $res['ProPrice']) {
                         $result[$key]['Price'] = $res['ProPrice'];
                     }
                 }
                 $image = PapGoodsImageRelation::model()->find('GoodsID=:goodsID', array(':goodsID' => $res['ID']));
                 if (empty($image['ImageUrl'])) {
                     $result[$key]['imageurl'] = 'dealer/default-goods.png';
                 } else {
                     $result[$key]['imageurl'] = $image['ImageUrl'];
                 }
             }
         }
         return $result;
     }
 }
Пример #4
0
 public function run($args)
 {
     Yii::app()->getComponent('log');
     Yii::log(date('Y-m-d H:i:s') . " [AutoEvaluation] start", 'info', 'command');
     //所要执行的任务,如数据符合某条件更新,删除,修改
     $Timeeva = time() - 24 * 60 * 60 * 10;
     //定义时间  收货15天后自动评价
     //服务店评价
     $model = PapOrder::model()->findAll("Status=9 and (EvaStatus = 0 or EvaStatus = 16)");
     //查询符合要求的已收货订单
     foreach ($model as $value) {
         if ($value['ReceiptTime'] < $Timeeva) {
             //已经收货订单执行下面代码
             $modelg = PapOrderGoods::model()->findAll("OrderID=:ID", array(":ID" => $value['ID']));
             //获得订单的商品
             $gbool = 1;
             foreach ($modelg as $valueg) {
                 //获得机构ID
                 $goodsinfo = PapGoods::model()->find("ID=:ID", array(":ID" => $valueg['GoodsID']));
                 $gevaluation = new PapEvaluationGoods();
                 $gevaluation->OrganID = $goodsinfo->OrganID;
                 $gevaluation->OrderID = $value['ID'];
                 $gevaluation->GoodsID = $goodsinfo->ID;
                 $gevaluation->BuyerID = $value['BuyerID'];
                 $gevaluation->CreateTime = time();
                 $gevaluation->Status = 1;
                 $model = $gevaluation->save();
                 //插入对单个商品的评价
                 if ($model) {
                     $m = PapGoods::model()->findByPk($goodsinfo->ID);
                     if ($m['CommentNo']) {
                         PapGoods::model()->updateByPk($goodsinfo->ID, array('CommentNo' => $m['CommentNo'] + 1));
                     } else {
                         PapGoods::model()->updateByPk($goodsinfo->ID, array('CommentNo' => 1));
                     }
                 } else {
                     $gbool = 0;
                 }
             }
             $oevaluation = new PapEvaluationDealer();
             $oevaluation->OrganID = $value['BuyerID'];
             $oevaluation->SellerID = $value['SellerID'];
             $ID = $oevaluation->OrderID = $value['ID'];
             $oevaluation->SellerBusiness = 5;
             $oevaluation->SellerService = 5;
             $oevaluation->SellerExact = 5;
             $oevaluation->SellerSpeed = 5;
             $oevaluation->ItemDescription = 5;
             $oevaluation->SellerPrice = 5;
             $oevaluation->SellerScore = 5;
             $oevaluation->CreateTime = time();
             $obool = $oevaluation->save();
             //插入对商家的评价
             if ($obool && $gbool) {
                 //评价插入成功后,修改订单的状态
                 if ($value['EvaStatus'] == 0) {
                     $EvaStatus = 15;
                     //如果该订单服务店先评价,把状态改为15
                 } elseif ($value['EvaStatus'] == 16) {
                     $EvaStatus = 20;
                     //如果该订单之前经销商评价过一次,则服务店此时评价状态改为20
                 }
                 PapOrder::model()->updateByPK($ID, array('EvaStatus' => $EvaStatus));
             }
         }
     }
     //经销商评价
     $modeld = PapOrder::model()->findAll("Status=9 and (EvaStatus = 0 or EvaStatus = 15)");
     //查询符合要求的已收货订单
     foreach ($modeld as $value) {
         if ($value['ReceiptTime'] < $Timeeva) {
             $model = new PapEvaluationService();
             $model->BuyerID = $value['BuyerID'];
             $ID = $model->OrderID = $value['ID'];
             $model->OrganID = $value['SellerID'];
             $model->BuyerFamily = 5;
             $model->BuyerAccept = 5;
             $model->BuyerBusiness = 5;
             $model->BuyerSpeed = 5;
             $model->BuyerCommunication = 5;
             $model->BuyerScore = 5;
             $model->CreateTime = time();
             $bool = $model->insert();
             if ($bool) {
                 if ($value['EvaStatus'] == 0) {
                     $EvaStatus = 16;
                     //如果该订单经销商先评价,把状态改为16
                 } else {
                     if ($value['EvaStatus'] == 15) {
                         $EvaStatus = 20;
                         //如果该订单之前服务店评价过一次,则经销商此时评价状态改为20
                     }
                 }
                 PapOrder::model()->updateByPK($ID, array('EvaStatus' => $EvaStatus));
             }
         }
     }
     Yii::log(date('Y-m-d H:i:s') . " [AutoEvaluation] end \n", 'info', 'command');
     echo date('Y-m-d H:i:s') . " [AutoEvaluation] end \n";
 }
Пример #5
0
 public function actionPriceupdate()
 {
     if (!isset($_GET['do']) || $_GET['do'] != 'unipei') {
         echo '你没有权限访问!';
         return;
     }
     $goods = PapGoodsUpdateprice::model()->findAll();
     foreach ($goods as $goodsk => $goodsv) {
         $goodsinfo = PapGoods::model()->findBypk($goodsv->GoodsID);
         $oldprice = $goodsinfo->Price;
         $goodsinfo->Price = $goodsv->GoodsPrice;
         $updatetime = time();
         $goodsinfo->UpdateTime = $updatetime;
         if ($goodsinfo->save()) {
             $editarr = array('GoodsID' => (int) $goodsv->GoodsID, 'UpdateTime' => (int) $updatetime, 'EditInfo' => array('Price' => array('old' => (string) $oldprice, 'news' => $goodsv->GoodsPrice)), 'type' => 'edit');
             Yii::app()->mongodb->getDbInstance()->goods_log->insert($editarr);
             PapGoods::model()->updateBypk($goodsv->GoodsID, array('Version' => $updatetime));
             $redis = $version = DealergoodsService::newgoodsxinfo($goodsv->GoodsID);
             $Goodsarr = array('GoodsID' => (int) $goodsv->GoodsID, 'GoodsInfo' => $version, 'Version' => (int) $updatetime, 'VehVersion' => (int) $goodsinfo->VehVersion);
             Yii::app()->mongodb->getDbInstance()->goods_version->insert($Goodsarr);
             Yii::app()->redis->set('GoodsID' . $goodsv->GoodsID, json_encode($redis));
             $result = PapGoodsUpdateprice::model()->findByPk($goodsv->ID)->delete();
         }
     }
 }
Пример #6
0
 public static function iddelbrand()
 {
     $OrganID = Yii::app()->user->getOrganID();
     $ID = Yii::app()->request->getParam('ID');
     $model = PapGoods::model()->findAll("OrganID=:OrganID and BrandID=:BrandID", array(':OrganID' => $OrganID, 'BrandID' => $ID));
     if ($model) {
         return 'nonull';
         exit;
     }
     $result = PapBrand::model()->deleteBypk($ID);
     return $result;
 }
Пример #7
0
 public static function editgoods($goods)
 {
     $organID = Yii::app()->user->getOrganID();
     $goodsID = $goods['GoodsID'];
     if ($goods) {
         $data['Name'] = trim($goods['Name']);
         if (trim($goods['Pinyin']) == "") {
             $pinyin = F::Pinyin1($goods['Name']);
             // 如果未输入拼音则自动添加拼音
         } else {
             $pinyin = trim($goods['Pinyin']);
         }
         $data['IsSale'] = 0;
         //商品默认不上架
         $data['Pinyin'] = $pinyin;
         $data['GoodsNO'] = trim($goods['GoodsNO']);
         // 商品编号
         $data['PartsLevel'] = trim($goods['PartsLevel']);
         $data['Memo'] = trim($goods['Memo']);
         $data['Price'] = trim($goods['Price']);
         if (!empty($goods['goodsBrand'])) {
             $data['BrandID'] = trim($goods['goodsBrand']);
             // id
         }
         $data['StandCode'] = $goods['StandCode'];
         // 标准名称txt
         $data['Info'] = $goods['Info'];
         $data['Provenance'] = $goods['Provenance'];
         $model = PapGoods::model()->findByPk($goodsID);
         $model->attributes = $data;
         $oenos = $goods['OENOS'] ? $goods['OENOS'] : $goods['OENO'];
         if ($oenos) {
             foreach ($oenos as $value) {
                 $oe .= $value . ' ';
             }
         } else {
             $oe = '';
         }
         $model->Title = $data['Name'] . ' ' . $data['GoodsNO'] . ' ' . $pinyin . ' ' . $data['Brand'] . ' ' . $oe . ' ' . $goods['cpname'];
         $edtitime = $model->UpdateTime = time();
         $goodsold = DealergoodsService::newgoodsxinfo($goodsID);
         if ($model->save()) {
             // 把主营车系添加到商品车系关系表
             if ($goods["make"]) {
                 DealergoodsService::editvehiclegoods($goodsID, $organID, $edtitime, $goods);
             }
             // 把OENO号添加到关系表里
             if ($goods['OENOS']) {
                 DealergoodsService::editoegoods($goodsID, $organID, $goods);
             }
             // 添加商品图片
             if ($goods['urlimg']) {
                 DealergoodsService::editimggoods($goodsID, $organID, $goods);
             }
             // 添加商品属性
             DealergoodsService::editspecgoods($goodsID, $goods);
             // 添加商品包装
             DealergoodsService::editpackgoods($goodsID, $goods);
             $goodsnew = DealergoodsService::newgoodsxinfo($goodsID);
             $edit = DealergoodsService::goodsversion($goodsnew, $goodsold);
             DealergoodsService::editgoodslog($edit);
             $rs = array('success' => 1, 'errorMsg' => '修改数据成功', 'status' => 'save');
         } else {
             foreach ($model->errors as $key => $value) {
                 if ($key == 0) {
                     $errorMsg = $value['0'];
                 }
             }
             $rs = array('success' => 0, 'errorMsg' => $errorMsg, 'status' => 'save');
         }
     }
 }
Пример #8
0
 public static function UgoodsSalesByGoodsID($goodsID, $quantity)
 {
     if (empty($goodsID) || empty($quantity)) {
         return;
     }
     $model = PapGoods::model()->findByPk($goodsID, array('select' => 'ID,Sales'))->attributes;
     $b = PapGoods::model()->updateByPk($goodsID, array('Sales' => $model['Sales'] + $quantity));
     return $b;
 }
Пример #9
0
    }
    .width125{
        width: 125px;
    }
</style>
<div id="layout-t4" class="tab-product tab-sub-3 ui-style-gradient" >
    <h2 class="tab-hd"> 
        <span class="tab-hd-con current"  style="margin-left:30px;border-right: 1px solid #e2e2e2"  key="promotionkey"><a href="javascript:;">促销商品管理</a></span>
        <!--<span class="tab-hd-con bor_right"><a href="javascript:;">业务联系人管理</a></span>--> 
    </h2>
    <div class="tab-bd dom-display dom-display8">
        <div class="tab-bd-con promotionkey" style="display:block"> 
            <div class="column ">
                <?php 
$organID = Yii::app()->user->getOrganID();
$progoods = PapGoods::model()->count(array("condition" => "IsPro = 1 and IsSale = 1 and ISdelete = 1 and t.OrganID = " . $organID));
?>
                <p class="txxx">促销中的商品(共<font style="color:#FB540E;font-size:14px;font-weight: bolder;padding:0 3px"><?php 
echo $progoods;
?>
</font>件商品)&nbsp;&nbsp;
                    您还可以添加<font style="color:#FB540E;font-size:14px;font-weight:bolder;padding: 0 3px"><?php 
echo 50 - $progoods;
?>
</font>件促销商品
                </p>
                <p  style="margin-top:15px; margin-left: 40px;">
                    <input type="submit" onclick="addPromo()" value="添加促销"  class="submit" />
                    <input type="submit" onclick="delPromo()" value="编辑促销"  class="submit" />
                </p>  
            </div>
Пример #10
0
 public static function createorder($quoID, $schID, $payment, $address)
 {
     $sql_findQuo = 'select * from pap_quotation where QuoID=' . $quoID;
     $Quoinfo = self::excutesql(array('sql' => $sql_findQuo, 'db' => 'pap'));
     $Quoinfo = $Quoinfo[0];
     //获取方案信息
     $sql_findshem = 'select * from pap_quotation_scheme where SchID=' . $schID;
     $schemeinfo = self::excutesql(array('sql' => $sql_findshem, 'db' => 'pap'));
     $schemeinfo = $schemeinfo[0];
     //获取方案对应的商品
     $sql_goods = 'select * from pap_quotation_goods where SchID=' . $schID;
     $goodsinfo = self::excutesql(array('sql' => $sql_goods, 'db' => 'pap'));
     //获取商品数量,以便生成均价
     $totalnum = 0;
     //总数量
     $lmstotal = 0;
     //总价
     $factdiscount = 100;
     $discount = PapOrderDiscount::model()->find('OrderType=:OrderType', array(':OrderType' => 2));
     if ($discount) {
         if ($payment == 1) {
             $factdiscount = $discount['OrderAlipay'] ? $discount['OrderAlipay'] : 100;
         } else {
             if ($payment == 2) {
                 $factdiscount = $discount['OrderLogis'] ? $discount['OrderLogis'] : 100;
             }
         }
     } else {
         $factdiscount = 100;
     }
     $totalgoods;
     foreach ($goodsinfo as $kk => $value) {
         if (!empty($value['Version'])) {
             $_sql_find_version = 'select Info from pap_goods_version where GoodsID=' . $value['GoodsID'] . ' and Version=' . $value['Version'];
             $goods_versi = Yii::app()->papdb->createCommand($_sql_find_version)->queryRow();
             $goodsbyid = json_decode($goods_versi['Info'], true);
             $oes;
             if ($goodsbyid['oeno']) {
                 if (!is_array($goodsbyid['oeno'][0])) {
                     $oes = implode('、', $goodsbyid['oeno']);
                 }
             } else {
                 $oes = PapGoods::getOENOSByGoodsID($value['GoodsID']);
             }
         } else {
             $goodsbyid = PapGoods::model()->findByPK($value['GoodsID']);
             $oes = PapGoods::getOENOSByGoodsID($value['GoodsID']);
         }
         if ($goodsbyid) {
             $lmstotal += round($value['Price'] * $value['Num'] * $factdiscount / 100, 2);
             $ppprice = $value['Price'] * $factdiscount / 100;
             $totalnum += $value['Num'];
             $totalgoods[$kk] = array("GoodsID" => $value['GoodsID'], "GoodsNum" => $goodsbyid['GoodsNO'], "GoodsOE" => $oes ? $oes : '', "GoodsName" => $goodsbyid['Name'], "CpName" => $goodsbyid['StandCode'] ? self::getCpName($goodsbyid['StandCode']) : '', "Brand" => self::getBrand($goodsbyid['BrandID']), "Price" => $goodsbyid['Price'], "ProPrice" => round($ppprice, 2), "Quantity" => $value['Num'], "GoodsAmount" => round($value['Num'] * $ppprice, 2), "CreateTime" => time(), "UpdateTime" => time(), "Version" => $goodsbyid['Version']);
         }
     }
     //获取经销商最小价格
     $min_price = PapOrderMinTurnover::model()->find('OrganID=:OrganID', array(':OrganID' => $Quoinfo['DealerID']));
     $min_price = $min_price['MinTurnover'];
     //获取经销商信息
     $sql_dealer = 'select * from jpd_organ where ID=' . $Quoinfo['DealerID'];
     $dealerinfo = self::excutesql(array('sql' => $sql_dealer, 'db' => 'jpd'));
     $dealerinfo = $dealerinfo[0];
     //生成订单编号
     $order_sn = self::gen_order_sn();
     // 修改询价单状态
     $updateinquiry = PapInquiry::model()->updateByPK($Quoinfo['InquiryID'], array('Status' => 2));
     //修改别的报价单状态,改为已拒绝
     $sql_dppend = 'select * from pap_quotation where InquiryID=' . $Quoinfo['InquiryID'];
     $dppall = self::excutesql(array('sql' => $sql_dppend, 'db' => 'pap'));
     foreach ($dppall as $keyy => $valuee) {
         if ($valuee['QuoID'] != $quoID) {
             PapQuotation::model()->updateByPK($valuee['QuoID'], array('Status' => 4));
         }
     }
     if ($updateinquiry != 1) {
         //确认询价单失败
         return array('success' => false, 'msg' => 'check inquiry fail', 'QuoID' => $quoID, 'data' => '确认询价单失败');
         exit;
     }
     //修改方案状态
     $updateschemsql = 'update pap_quotation_scheme set Status="2" where SchID=' . $schID;
     $updateschem = Yii::app()->papdb->createCommand($updateschemsql)->execute();
     if ($updateschem != 1) {
         //确认报价单方案失败
         return array('success' => false, 'msg' => 'check quo scheme fail', 'QuoID' => $quoID, 'data' => '确认报价单方案失败');
         exit;
     }
     // 修改报价单状态
     $discountdesc = self::getpriceratio($Quoinfo['DealerID'], $Quoinfo['ServiceID']);
     $updateQuo = PapQuotation::model()->updateByPK($quoID, array('Status' => 2, 'Discount' => $discountdesc['type'] . ',' . $discountdesc['discount']));
     if ($updateQuo != 1) {
         //更新报价单状态失败
         return array('success' => false, 'msg' => 'update quo status fail', 'QuoID' => $quoID, 'data' => '更新报价单状态失败');
         exit;
     }
     //生成平摊金额
     $amountlist = 0;
     $minus = 0;
     if ($min_price && $min_price > $lmstotal) {
         $minus = round(($min_price - $lmstotal) / $totalnum, 2);
         $amountlist = $lmstotal + $minus * $totalnum;
         if ($amountlist < $min_price) {
             $amountlist = $min_price;
         }
     } else {
         $amountlist += $lmstotal;
     }
     $find_lsm_orgname = 'select OrganName from jpd_organ where ID=' . $Quoinfo['ServiceID'];
     $lms_orgname = Yii::app()->jpdb->createCommand($find_lsm_orgname)->queryRow();
     $params = array("OrderSN" => "DD" . $order_sn, "OrderName" => "嘉配订单:DD" . $order_sn, "SellerID" => $dealerinfo["ID"], "OrganID" => $dealerinfo["ID"], "SellerName" => $dealerinfo["OrganName"], "BuyerID" => $Quoinfo['ServiceID'], "BuyerName" => $lms_orgname['OrganName'], "Payment" => $payment, "OrderType" => 2, 'Discount' => $factdiscount, 'GoodsAmount' => $amountlist, 'ShipCost' => $schemeinfo['ShipFee'], 'TotalAmount' => $amountlist + $schemeinfo['ShipFee'], 'RealPrice' => $amountlist + $schemeinfo['ShipFee'], "Status" => $payment == 1 ? 1 : 2, "CreateTime" => time(), "UpdateTime" => time());
     $orderID = self::saveorderinfo($params);
     if (!$orderID) {
         //创建订单失败
         return array('success' => false, 'msg' => 'create order fail', 'QuoID' => $quoID, 'data' => '创建订单失败');
         exit;
     }
     //保存订单编号到询价单表
     PapInquiry::model()->updateByPK($Quoinfo['InquiryID'], array('OrderSn' => "DD" . $order_sn));
     //保存订单ID到报价单表
     PapQuotation::model()->updateByPK($quoID, array('OrderID' => $orderID));
     //保存订单商品
     self::saveordergoods($totalgoods, $orderID, $minus);
     //保存地址
     if ($orderID) {
         $adressinfo = self::getaddressbypk($address);
         $addr = array('OrderID' => $orderID, 'ShippingName' => $adressinfo['ContactName'], 'ZipCode' => $adressinfo['ZipCode'], 'Mobile' => $adressinfo['Phone'], 'TelePhone' => $adressinfo['TelPhone'], 'Province' => $adressinfo['State'], 'City' => $adressinfo['City'], 'Area' => $adressinfo['District'], 'Address' => $adressinfo['Address'], 'CreateTime' => time());
         self::saveinquiryaddress($addr);
     }
     //生成订单通知经销商
     if ($payment == 1) {
         //待付款
         $params = array('OrganID' => $Quoinfo['DealerID'], 'OrganType' => 2, 'HandleID' => $orderID);
         $params['type'] = array('name' => 'DD', 'key' => 1);
         RemindService::sendRemind($params);
     } elseif ($payment == 2) {
         //待发货
         $params = array('OrganID' => $Quoinfo['DealerID'], 'OrganType' => 2, 'HandleID' => $orderID);
         $params['type'] = array('name' => 'DD', 'key' => 2);
         //命令行链接
         $params['from'] = 'http://192.168.2.29:8000/pap/sellerorder/detail&ID=' . $orderID;
         RemindService::sendRemind($params);
     }
     //更改报价单待确认状态为已处理
     $sql = 'update pap_remind_business set HandleStatus=2 where HandleID=' . $quoID . ' and OrganID=' . $Quoinfo['ServiceID'];
     Yii::app()->papdb->createCommand($sql)->execute();
     //创建订单成功
     return array('success' => true, 'msg' => 'carate order success', 'QuoID' => $quoID, 'data' => '创建订单成功', 'orderID' => $orderID, 'ordersn' => $order_sn);
 }
Пример #11
0
 public function actionHaveversion()
 {
     $GoodsID = Yii::app()->request->getParam('GoodsID');
     $Goodsinfo = PapGoods::model()->findBypk($GoodsID);
     if ($Goodsinfo->attributes['Version']) {
         $arr['edit'] = DealergoodsService::goodseditinfo($GoodsID, $Goodsinfo->attributes['Version'], $Goodsinfo->attributes['VehVersion']);
         //组装返回值
         $arr['empty'] = 0;
     } else {
         $arr['empty'] = 1;
     }
     echo json_encode($arr);
 }
Пример #12
0
 public static function getGoodByID($id)
 {
     $criteria = new CDbCriteria();
     $criteria->condition = " t.IsSale = 1 and t.ISdelete = 1";
     // 上架的和没有删除的商品
     $criteria->with = "goodsimage";
     $model = PapGoods::model()->findByPk($id, $criteria);
     if (!$model) {
         return false;
         exit;
     }
     $data = array();
     //商品基本信息
     $data['GoodsID'] = $id;
     $data['Name'] = $model['Name'];
     $data['GoodsNO'] = $model['GoodsNO'];
     $organID = Yii::app()->user->getOrganID();
     //商品价格
     $price = self::getContactprice($model['OrganID'], $organID);
     $data['Price'] = $model['Price'];
     $data['PriceRatio'] = $price['PriceRatio'] ? $price['PriceRatio'] : "100%";
     if ($data['PriceRatio'] > 0 && $data['PriceRatio'] < '100%') {
         $data['DisPrice'] = sprintf("%.2f", $model['Price'] * $data['PriceRatio'] / 100);
         // 折扣价,小数点后面保留两位
     }
     if ($model['IsPro'] == 1) {
         if (!is_null($model['ProPrice']) && $model['ProPrice']) {
             $data['ProPrice'] = $model['ProPrice'];
         }
     }
     //店家信息
     $organInfo = Organ::model()->findByPk($model['OrganID'])->attributes;
     $data['OrganName'] = $organInfo['OrganName'];
     $data['SellerID'] = $model['OrganID'];
     $data['QQ'] = $organInfo['QQ'];
     $data['Phone'] = $organInfo['Phone'];
     $address = self::getOrganAddress($organInfo['Province'], $organInfo['City'], $organInfo['Area']);
     $data['Address'] = array($address[0]['Name'], $address[1]['Name'], $address[2]['Name']);
     //商品品牌
     // $data['goodsBrand'] = $goods['Brand'];
     //商品OE号
     //   $data['OENO'] = self::getOENOSByGoodID($id);
     //    $data['LogisticsPrice'] = $goods['LogisticsPrice'];    // 物流价
     $cpArr = self::getCategory($model['StandCode']);
     $data['BigParts'] = $cpArr['BigParts'];
     $data['SubParts'] = $cpArr['SubParts'];
     $data['CpName'] = $cpArr['CpName'];
     $data['sub'] = $cpArr['sub'];
     $data['code'] = $model['StandCode'];
     //            $vehs = self::getVehicleByGoodsID($id);
     //            $data['Vehicle'] = $vehs[0];
     //            $data['IsSale'] = $data['IsSale'] == 1 ? '已上架' : '已下架';
     //
     //            // 商品属性
     //            $data['Weight'] = $data->goodsspec->Weight;
     //            $data['Length'] = $data->goodsspec->Length;
     //            $data['Wide'] = $data->goodsspec->Wide;
     //            $data['Height'] = $data->goodsspec->Height;
     //            $data['Volume'] = $data->goodsspec->Volume;
     //            $data['ValidityDate'] = $data->goodsspec->ValidityDate;
     //            $data['ValidityType'] = $data->goodsspec->ValidityType;
     //            if ($data['ValidityType'] == 1) {
     //                $data['Validity'] = '不保修';
     //            }if ($data['ValidityType'] == 2) {
     //                $data['Validity'] = '保装车';
     //            }if ($data['ValidityType'] == 3) {
     //                $data['Validity'] = $data['ValidityDate'] . '个月';
     //            }
     //            $data['Specifica'] = $data->goodsspec->Specifica;
     //            $data['Unit'] = $data->goodsspec->Unit;
     //            $data['BganCompany'] = $data->goodsspec->BganCompany;
     //            $data['BganGoodsNO'] = $data->goodsspec->BganGoodsNO;
     //            $data['PartsNO'] = $data->goodsspec->PartsNO;
     //            $data['JiapartsNO'] = $data->goodsspec->JiapartsNO;    // 嘉配号
     //            $data['ImageUrl'] = $data->goodsspec->ImageUrl;        // 图像
     //            $data['DetectionImg'] = $data->goodsspec->DetectionImg; // 检测图像
     //            // 商品包装
     //            $data['pWeight'] = $data->goodspack->Weight;
     //            $data['pLength'] = $data->goodspack->Volume;
     //            $data['MinQuantity'] = $data->goodspack->MinQuantity;
     //
     //            // OE号
     //            $data['OENOS'] = self::getOENOSByGoodsID($id);
     //
     //            // 车型车系
     //            $data['Vehicles'] = self::getVehicleByGoodsID($id);
     // 图片
     if (!$model->goodsimage) {
         $data['Images'][0]['ImageUrl'] = 'dealer/goods-img-big.jpg';
     } else {
         foreach ($model->goodsimage as $v) {
             $data['Images'][] = $v->attributes;
         }
     }
     return $data;
 }
Пример #13
0
 public function actionDetail()
 {
     $serviceID = Yii::app()->user->getOrganID();
     $goodsid = Yii::app()->request->getParam('goods');
     $result = MallService::getredis($goodsid);
     //$payment = 1;
     //$result = MallService::getGoodByID($goodsid, $payment, 'mall');
     if ($result == 'null') {
         echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
         echo "<script>alert('该商品不存在!');window.location.href='" . Yii::app()->createUrl('pap/mall/index') . "'</script>";
         exit;
     } else {
         if ($result == 'nosale') {
             echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
             echo "<script>alert('该商品已下架!');window.location.href='" . Yii::app()->createUrl('pap/mall/index') . "'</script>";
             exit;
         }
     }
     $result['GoodsID'] = $result['ID'];
     $result['CommentNo'] = PapGoods::model()->findByPk($result['ID'])->attributes['CommentNo'];
     //商品折扣价
     if ($result['IsPro'] != 1) {
         $PriceRatio = MallService::getDisprice($result['OrganID'], $serviceID);
         if ($PriceRatio > 0 && $PriceRatio < 100) {
             $result['DisPrice'] = sprintf('%.2f', $result['Price'] * $PriceRatio / 100);
         }
     }
     $cookie = Yii::app()->request->getCookies();
     $car = array('make' => $cookie['mallmake']->value, 'series' => $cookie['mallseries']->value, 'year' => $cookie['mallyear']->value, 'model' => $cookie['mallmodel']->value);
     $carmodeltext = MallService::getCarmodeltxt($car);
     $res = array();
     if ($car['make'] && $car['series'] && $car['year'] && $car['model']) {
         $params = $car;
         $params['goodsid'] = $goodsid;
         $res = MallService::checkCarfit($params);
     }
     //店内分类
     $rows = $this->Getmaincate($result['OrganID']);
     $cate = $this->findsub($rows);
     //获取经销商客服列表
     $csparams['organID'] = $result['OrganID'];
     $csparams['type'] = 1;
     $csinfo = CsService::getcslists($csparams);
     //大类、子类、标准名称
     if (is_array($result['gcategory']) && !$result['gcategory']['BigName']) {
         $result['BigName'] = $result['gcategory']['BigName'];
         $result['SubName'] = $result['gcategory']['SubName'];
         $result['sub'] = $result['gcategory']['SubParts'];
     } else {
         $cpArr = MallService::getCategory($result['StandCode']);
         $result['BigName'] = $cpArr['BigParts'];
         $result['SubName'] = $cpArr['SubParts'];
         $result['sub'] = $cpArr['sub'];
     }
     //公告信息
     $model = new PapGoodsSendnotice();
     $sellerID = $result['OrganID'];
     $notice = $model->find("OrganID = {$sellerID}");
     //var_dump($data);die;
     //店家积分
     $result['TotalScore'] = DefaultService::getrecord($result['OrganID']);
     //店家信息
     $organInfo = Organ::model()->findByPk($result['OrganID'])->attributes;
     $result['Address'] = array(Area::getCity($organInfo['Province']), Area::getCity($organInfo['City']), Area::getCity($organInfo['Area']));
     $result['spec']['UnitName'] = GoodsUnit::model()->findByPk($result['spec']['Unit'])->attributes['UnitName'];
     //单位
     //最小交易金额
     $result['MinTurnover'] = PapOrderMinTurnover::model()->find("OrganID=:ID", array(":ID" => $result['OrganID']))->attributes['MinTurnover'];
     $this->pageTitle = Yii::app()->name . '-' . "商品详情";
     $this->render('detail', array('r' => $result, 'cate' => $cate, 'carmodeltext' => $carmodeltext, 'res' => $res, 'csinfo' => $csinfo, 'car' => $car, 'data' => $notice));
 }
Пример #14
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));
 }
Пример #15
0
 public static function setEvalNum()
 {
     PapGoods::model()->updateAll(array('CommentNo' => 0));
     $sql = "SELECT GoodsID,count(ID) as count FROM `pap_evaluation_goods` group by GoodsID";
     $res = Yii::app()->papdb->createCommand($sql)->queryAll();
     foreach ($res as $v) {
         PapGoods::model()->updateByPk($v['GoodsID'], array('CommentNo' => $v['count'])) . '<br/>';
     }
 }
Пример #16
0
 public static function createorderFromPurchase($params)
 {
     $payment = $params['payment'];
     $ShipLogis = $params['ShipLogis'];
     $ship = $params['ship'];
     $orderIdArr = array();
     $kd = 0;
     foreach ($params['purchaseGoods'] as $k => $purchase) {
         $sellerID = $purchase['SellerID'];
         $min_price = isset($purchase['MinTurnover']) ? $purchase['MinTurnover'] : 0;
         //获取经销商订单折扣率--商城订单
         $discount = PapOrderDiscount::model()->find(array("condition" => " OrderType = 1"));
         if (!is_null($discount)) {
             if ($payment == 1) {
                 $dis = $discount['OrderAlipay'];
             } else {
                 if ($payment == 2) {
                     $dis = $discount['OrderLogis'];
                 }
             }
             if (isset($dis) && !empty($dis)) {
                 $dis = $dis;
             } else {
                 $dis = 100;
             }
         } else {
             $dis = 100;
         }
         $orderArr = array();
         $purchaseIdArr = array();
         $goodsPrice = 0;
         $shipCost = 0;
         $totalPrice = 0;
         $listCount = 0;
         $count = 0;
         $amountlist = 0;
         //循环获得商品总价
         foreach ($purchase["GoodsList"] as $list) {
             $listCount += $list['Quantity'];
             if ($list['ProPrice']) {
                 $count += $list['ProPrice'] * $list['Quantity'];
                 $counts += round($list['ProPrice'] * $purchase['discount'] / 100, 2) * $list['Quantity'];
             } else {
                 $count += $list['Price'] * $list['Quantity'];
                 $counts += round($list['Price'] * $purchase['discount'] / 100, 2) * $list['Quantity'];
             }
         }
         //生成平摊金额
         if ($min_price && round($count * $dis / 100, 2) < $min_price) {
             $minus = round(($min_price - $count) / $listCount, 2);
             //  $list['ProPrice']=$list['ProPrice']+$minus;
             $amountlist += $count + $minus * $listCount;
             if ($amountlist < $min_price) {
                 $amountlist = $min_price;
             }
         } else {
             $amountlist += round($count * $dis / 100, 2);
             //$list['ProPrice']=round(($list['ProPrice'] + $minus)*$dis/100,2);
             $minus = 0;
         }
         $order_sn = self::gen_order_sn();
         $orderArr["order"] = array("OrderSN" => "DD" . $order_sn, "OrderName" => "嘉配订单:DD" . $order_sn, "SellerID" => $purchase["SellerID"], "SellerName" => $purchase["SellerName"], "BuyerID" => Yii::app()->user->getOrganID(), "BuyerName" => $purchase["BuyerName"], "Payment" => $payment, "OrderType" => 1, 'Discount' => $dis, "ShipLogis" => $ShipLogis[$kd], "Status" => $payment == 1 ? 1 : 2, "CreateTime" => time(), "UpdateTime" => time());
         $orderArr["address"] = array("ShippingName" => $ship['ContactName'], "ZipCode" => $ship['ZipCode'], "Mobile" => $ship['Phone'], "Province" => $ship['State'], "City" => $ship['City'], "Area" => $ship['District'], "Address" => $ship['Address'], "CreateTime" => time());
         foreach ($purchase["GoodsList"] as $key => $list) {
             // $list = $list->getAttributes();
             if ($min_price && $counts < $min_price) {
                 $minus = round(($min_price - $count) / $listCount, 2);
                 $list['ProPrice'] = round($list['ProPrice'] * $dis / 100, 2);
                 //  $list['ProPrice'] = $list['ProPrice'] + $minus;
             } else {
                 $list['ProPrice'] = round(($list['ProPrice'] + $minus) * $dis / 100, 2);
             }
             //获取商品oe
             $oes = PapGoods::getOENOSByGoodsID($list['GoodsID']);
             $data = array("GoodsID" => $list['GoodsID'], "GoodsNum" => $list['GoodsNum'], "GoodsOE" => $oes ? $oes : $list['GoodsOE'], "GoodsName" => $list['GoodsName'], "CpName" => $list['CpName'], "Brand" => $list['Brand'], "Price" => $list['Price'], "ProPrice" => $list['ProPrice'], "Quantity" => $list['Quantity'], "ShipCost" => $list['ShipCost'] * $list['Quantity'], "GoodsAmount" => $list['ProPrice'] ? $list['ProPrice'] * $list['Quantity'] : $list['Price'] * $list['Quantity'], "Version" => $list['Version'], "CreateTime" => time(), "UpdateTime" => time());
             $goodsPrice += $data['GoodsAmount'];
             $shipCost += $data['ShipCost'];
             $totalPrice = $goodsPrice + $shipCost;
             //订单金额(商品总价+物流总价)
             //订单实付金额折扣率
             $amountPrice = $amountlist;
             //商品总价
             $orderArr['order']['Discount'] = '100%';
             if ($orderArr["goodsList"][$list['GoodsID']]) {
                 $orderArr["goodsList"][$list['GoodsID']]['GoodsAmount'] += $data['GoodsAmount'];
                 $orderArr["goodsList"][$list['GoodsID']]['Quantity'] += $data['Quantity'];
             } else {
                 $orderArr["goodsList"][$list['GoodsID']] = $data;
             }
             $purchaseIdArr[] = $list['purchaseID'];
         }
         $realPrice = $amountPrice + $shipCost;
         //实付金额:折后价+物流费
         $orderArr["order"]["GoodsAmount"] = $goodsPrice;
         $orderArr["order"]["ShipCost"] = $shipCost;
         $orderArr["order"]["TotalAmount"] = $totalPrice;
         //实付金额
         $orderArr["order"]["RealPrice"] = $realPrice;
         //订单金额
         $orderId = OrderService::create($orderArr);
         $orderIdArr[] = $orderId;
         if ($orderId) {
             //将订单号添加到purchase中
             self::addOrderToPurchase($orderId, $purchaseIdArr);
         }
         $kd++;
     }
     $orderIdStr = implode(',', $orderIdArr);
     return $orderIdStr;
 }
Пример #17
0
 private function noprocount()
 {
     $organID = Yii::app()->user->getOrganID();
     $noprogoods = PapGoods::model()->count(array("condition" => "IsPro = 0 and IsSale = 1 and ISdelete = 1 and t.OrganID = " . $organID));
     return $noprogoods;
 }