Esempio n. 1
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;
     }
 }
Esempio n. 2
0
 public function actionChangepay()
 {
     $data = array();
     //订单类别  商城订单、询价单订单、报价单订单---1/2/3
     $OrderType = Yii::app()->request->getParam("OrderType");
     if ($OrderType != 1) {
         $OrderType = 2;
     }
     //付款方式(支付宝担保交易/物流代收款--1/2)
     $Payment = Yii::app()->request->getParam("Payment");
     $SellerID = Yii::app()->request->getParam("SellerID");
     $BuyerID = Yii::app()->request->getParam("BuyerID");
     $IDArr = explode(',', Yii::app()->request->getParam("idArr"));
     $discount = PapOrderDiscount::model()->find(array("condition" => "OrderType = {$OrderType}"));
     if (isset($discount) && !empty($discount)) {
         if ($Payment == 1) {
             $dis = $discount['OrderAlipay'] / 100;
         } else {
             if ($Payment == 2) {
                 $dis = $discount['OrderLogis'] / 100;
             }
         }
     }
     //获取订单折扣率或促销价
     $price = MallService::getContactprice($SellerID, $BuyerID);
     $PriceRatio = $price['PriceRatio'] ? $price['PriceRatio'] : "100%";
     foreach ($IDArr as $key => $val) {
         $Price = 0;
         $model = PapGoods::model()->findByPk($val, array("condition" => "ISdelete=1"));
         if ($model['IsPro'] == 1) {
             //判断是否有促销价
             if (!is_null($model['ProPrice']) && $model['ProPrice']) {
                 $Price = $model['ProPrice'];
             }
         } else {
             if ($PriceRatio > 0) {
                 $Price = sprintf("%.2f", $model['Price'] * $PriceRatio / 100);
                 // 折扣价,小数点后面保留两位
             }
         }
         $data[$key] = sprintf("%.2f", $Price * $dis);
     }
     echo json_encode($data);
     die;
 }