public static function Getsumprices($schID, $factdiscount, $dealerID) { $sql = 'select * from pap_quotation_goods where SchID=' . $schID; $goodsinfo = Yii::app()->papdb->createCommand($sql)->queryAll(); $total = 0; $totalnum = 0; foreach ($goodsinfo as $kk => $value) { $total += round($value['Price'] * $value['Num'] * $factdiscount / 100, 2); $totalnum += $value['Num']; } //获取经销商最小价格 $min_price = PapOrderMinTurnover::model()->find('OrganID=:OrganID', array(':OrganID' => $dealerID)); $min_price = $min_price['MinTurnover']; //生成平摊金额 $amountlist = 0; $minus = 0; if ($min_price && $min_price > $total) { $minus = round(($min_price - $total) / $totalnum, 2); $amountlist = $total + $minus * $totalnum; if ($amountlist < $min_price) { $amountlist = $min_price; } } else { $amountlist += $total; } return $amountlist; }
public static function createorder($quoID, $schID, $payment, $address, $ordertype, $goodsids, $nums, $CouponSn) { $opration = array(); //错误时执行操作 $sql_findQuo = 'select * from pap_quotation where QuoID=' . $quoID; $Quoinfo = Yii::app()->papdb->createCommand($sql_findQuo)->queryRow(); //获取方案对应的商品 $sql_goods = 'select * from pap_quotation_goods where SchID=' . $schID . ' and GoodsID in(' . $goodsids . ') '; $goodsinfo = self::excutesql(array('sql' => $sql_goods, 'db' => 'pap')); //获取经销商最小价格 $min_price = PapOrderMinTurnover::model()->find('OrganID=:OrganID', array(':OrganID' => $Quoinfo['DealerID'])); $min_price = $min_price['MinTurnover']; //获取经销商信息 $sql_dealer = 'select ID,OrganName from jpd_organ where ID=' . $Quoinfo['DealerID']; $dealerinfo = Yii::app()->jpdb->createCommand($sql_dealer)->queryRow(); //获取修理厂信息 $find_lsm_orgname = 'select OrganName from jpd_organ where ID=' . $Quoinfo['ServiceID']; $serviceinfo = Yii::app()->jpdb->createCommand($find_lsm_orgname)->queryRow(); //调用商城生成订单方法 $carts = array(); $carts['SellerID'] = $Quoinfo['DealerID']; $carts['BuyerID'] = $Quoinfo['ServiceID']; $carts['SellerName'] = $dealerinfo['OrganName']; $carts['BuyerName'] = $serviceinfo['OrganName']; $carts['MinTurnover'] = $min_price ? $min_price : '0'; //获取经销商订单折扣率--询报价订单 $dis = 100; $discount = PapOrderDiscount::model()->find(array("condition" => " OrderType = 2")); if ($discount) { if ($payment == 1 && $discount['OrderAlipay']) { $dis = $discount['OrderAlipay']; } else { if ($payment == 2 && $discount['OrderLogis']) { $dis = $discount['OrderLogis']; } else { $dis = 100; } } } else { $dis = 100; } $carts['discount'] = $dis; $totalgoods; $nums = explode(',', $nums); foreach ($goodsinfo as $kk => $value) { $goodsbyid = DealergoodsService::getmongoversion($value['GoodsID'], $value['Version']); if ($goodsbyid) { $totalgoods[$kk] = array('BuyerID' => $Quoinfo['ServiceID'], 'BuyerName' => $serviceinfo['OrganName'], 'SellerID' => $dealerinfo['ID'], 'SellerName' => $dealerinfo['OrganName'], "GoodsID" => $value['GoodsID'], "GoodsNum" => $goodsbyid['GoodsInfo']['GoodsNO'], "GoodsOE" => is_array($goodsbyid['GoodsInfo']['oeno']) ? implode(',', $goodsbyid['GoodsInfo']['oeno']) : (is_string($goodsbyid['GoodsInfo']['oeno']) ? ['GoodsInfo']['oeno'] : ''), "GoodsName" => $goodsbyid['GoodsInfo']['Name'], "CpName" => $goodsbyid['GoodsInfo']['StandCode'] ? self::getCpName($goodsbyid['GoodsInfo']['StandCode']) : '', "Brand" => $goodsbyid['GoodsInfo']['Brand'], "Price" => $goodsbyid['GoodsInfo']['Price'], "ProPrice" => $value['Price'], "Quantity" => $nums[$kk], "ShipCost" => null, "CreateTime" => time(), "UpdateTime" => time(), "Version" => $goodsbyid['Version']); } } $carts['GoodsList'] = $totalgoods; if ($ordertype == 2) { //如果是由询价单生成的订单 //获取询价单信息 $sql = 'select * from pap_inquiry where InquiryID=' . $Quoinfo['InquiryID']; $Inquiryinfo = Yii::app()->papdb->createCommand($sql)->queryRow(); if (!$Inquiryinfo) { return json_encode(array('success' => false, 'message' => '确认失败,该询价单不存在')); } if ($Inquiryinfo['Status'] == 2) { return json_encode(array('success' => false, 'message' => '确认失败,该询价单已确认')); } if ($Inquiryinfo['Status'] == 3) { return json_encode(array('success' => false, 'message' => '确认失败,该询价单已撤销')); } // 修改询价单状态 $updateinquiry = PapInquiry::model()->updateByPK($Quoinfo['InquiryID'], array('Status' => 2)); if ($updateinquiry != 1) { return json_encode(array('success' => false, 'message' => '确认询价单失败', 'msg' => 'check inquiry fail', 'QuoID' => $quoID, 'data' => '确认询价单失败')); } else { //成功时插入return的SQL $opration[1] = 'update pap_inquiry set Status=1 where InquiryID=' . $Quoinfo['InquiryID']; } } //修改方案状态 $updateschem = InquiryorderService::changeschstatus(array('status' => 2, 'SchID' => $schID)); if ($updateschem != 1) { self::returnint($opration); return json_encode(array('success' => false, 'message' => '确认方案失败', 'msg' => 'check scheme fail', 'QuoID' => $quoID, 'data' => '确认方案失败')); } else { $opration[2] = 'update pap_quotation_scheme set Status="1" where SchID=' . $schID; } // 修改报价单状态 $discountdesc = QuotationService::getpriceratio($Quoinfo['DealerID'], $Quoinfo['ServiceID']); $updateQuo = PapQuotation::model()->updateByPK($quoID, array('Status' => '2', 'Discount' => $discountdesc['type'] . ',' . $discountdesc['discount'])); if ($updateQuo != 1) { self::returnint($opration); return json_encode(array('success' => false, 'message' => '确认报价单失败', 'msg' => 'check quo scheme fail', 'QuoID' => $quoID, 'data' => '确认报价单方案失败')); } else { $opration[3] = 'update pap_quotation set Status=1 where QuoID=' . $quoID; } $adressinfo = self::getaddressbypk($address); $params = array('payment' => $payment, 'ship' => $adressinfo, 'ordertype' => $ordertype, 'cartsGoods' => array($carts)); //根据优惠券编号查询优惠券金额 if ($CouponSn) { $copinfo = BuyGoodsService::couponbysn(array('couponsn' => $CouponSn)); if ($copinfo) { $params['coupon'] = $copinfo['Amount']; $params['couponsn'] = $copinfo['CouponSn']; $params['usecouponID'] = $copinfo['CouponID']; } } //self::returnint($opration); $orderID = BuyGoodsService::createorder($params); // exit; $orderID = intval($orderID); //获取订单编号 $sql_order = 'select OrderSN from pap_order where ID=' . $orderID; $res = Yii::app()->papdb->createCommand($sql_order)->queryRow(); $order_sn = $res['OrderSN']; if (!$orderID) { self::returnint($opration); return json_encode(array('success' => false, 'message' => '生成订单失败', 'msg' => 'create order fail', 'QuoID' => $quoID, 'data' => '创建订单失败')); } //保存订单编号到询价单表 if ($ordertype == 2) { PapInquiry::model()->updateByPK($Quoinfo['InquiryID'], array('OrderSn' => $order_sn)); } //保存订单ID到报价单表 PapQuotation::model()->updateByPK($quoID, array('OrderID' => $orderID)); //更改报价单待确认状态为已处理 $sql = 'update pap_remind_business set HandleStatus=2 where HandleID=' . $quoID . ' and OrganID=' . $Quoinfo['ServiceID']; Yii::app()->papdb->createCommand($sql)->execute(); return json_encode(array('success' => true, 'message' => '生成订单成功,点击跳转', 'msg' => 'carate order success', 'QuoID' => $quoID, 'data' => '创建订单成功', 'orderID' => $orderID, 'ordersn' => $order_sn)); }
public static function createbuynoworder($params) { $goods = $params['goods']; $payment = $params['payment']; $ShipLogis = $params['shiplogis']; $ship = $params['ship']; $quantity = $params['quantity']; $locate = $params['locate']; $BuyerID = Yii::app()->user->getOrganID(); $organ = Organ::model()->findByPk($BuyerID)->attributes; $BuyName = $organ['OrganName']; $usecouponID = $params['usecouponID']; //获取订单最小交易额 $turnover = PapOrderMinTurnover::model()->find("OrganID=:ID", array(":ID" => $goods['SellerID'])); $min_price = $turnover['MinTurnover'] ? $turnover['MinTurnover'] : 0; //获取经销商订单折扣率--商城订单 $discount = PapOrderDiscount::model()->find(array("condition" => " OrderType = 1")); if ($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(); $order_sn = self::gen_order_sn(); //array("order"=>array(),"goodsList"=> array()) $orderArr["order"] = array("OrderSN" => "DD" . $order_sn, "OrderName" => "嘉配订单:DD" . $order_sn, "SellerID" => $goods["SellerID"], "SellerName" => $goods["OrganName"], "BuyerID" => $BuyerID, "BuyerName" => $BuyName, "Payment" => $payment, "OrderType" => 1, "Discount" => $dis, "ShipLogis" => $ShipLogis['0'], "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()); $SellPrice = $goods["ProPrice"] ? $goods["ProPrice"] : $goods["DisPrice"]; //生成平摊金额 $amount = round($SellPrice * $dis / 100, 2) * $quantity; $GoodsAmount = $amount; //$GoodsAmount = round($amount * $dis / 100, 2); $avg = 0; $SellPrice = round($SellPrice * $dis / 100, 2); //定位车系 $locate = explode('_', $locate); $data[] = array("GoodsID" => $goods['GoodsID'], "GoodsNum" => $goods['GoodsNO'], "GoodsOE" => $goods['OENO'], "GoodsName" => $goods['Name'], "CpName" => $goods['CpName'], "Brand" => $goods['BrandName'], "Price" => $goods['Price'], "ProPrice" => $SellPrice, "Quantity" => $quantity, "ShipCost" => $goods['LogisticsPrice'] * $quantity, "GoodsAmount" => $GoodsAmount, "Version" => $goods['Version'], "CreateTime" => time(), "UpdateTime" => time(), "MakeID" => $locate[0], "CarID" => $locate[1], "Year" => $locate[2], "ModelID" => $locate[3]); $goodsPrice = $data['0']["GoodsAmount"]; $shipCost = $data['0']["ShipCost"]; $totalPrice = $goodsPrice + $shipCost; //订单总价 //订单实付金额折扣率 $amountPrice = $GoodsAmount; //商品总价 $realPrice = $amountPrice + $shipCost; //实付金额:折后价+物流费 $orderArr["goodsList"] = $data; $orderArr["order"]["GoodsAmount"] = $goodsPrice; $orderArr["order"]["ShipCost"] = $shipCost; $orderArr["order"]["TotalAmount"] = $totalPrice; //实付金额 $orderArr["order"]["RealPrice"] = $realPrice; $actparam = array('total' => $totalPrice, 'payment' => $payment); $act_res = self::activedecre($actparam); if (!empty($act_res) && is_array($act_res)) { $orderArr["order"]['PromoID'] = intval($act_res['PromoID']); $orderArr["order"]['DecrAmount'] = floatval($act_res["DecrAmount"]); $orderArr["order"]['DecrTotal'] = floatval($act_res["DecrTotal"]); $orderArr['order']['Type'] = $act_res['Type']; $orderArr["order"]["RealPrice"] = floatval($act_res['RealPrice']); $orderArr["order"]["TotalAmount"] = floatval($act_res['RealPrice']); $orderArr["order"]['CouponID'] = $act_res['CouponID']; } /*优惠活动 使用优惠券 * params $decoupon 优惠券内容,$totalPrice订单金额 $orderArr订单数组 */ if (isset($usecouponID) && !empty($usecouponID)) { $decoupon = self::couponbyID($usecouponID); $orderArr = self::usecoupon($decoupon, $totalPrice, $orderArr); } $orderId = OrderService::create($orderArr); return $orderId; }
public static function checkmin($params) { $str = rtrim($params['key'], ','); $sql = "SELECT a.ID, a.Num, b.OrganID, b.Price, b.ProPrice, b.IsPro, c.OrganName \n FROM pap_reserve_purchase AS a LEFT JOIN pap_goods AS b ON a.GoodsID = b.ID \n LEFT JOIN jpd.jpd_organ AS c ON b.OrganID = c.ID \n WHERE b.IsSale =1 AND a.ID IN ({$str})"; $result = Yii::app()->papdb->CreateCommand($sql)->queryAll(); $data = array(); foreach ($result as $val) { $data[$val['OrganID']][] = $val; } foreach ($data as $key => $val) { $min = PapOrderMinTurnover::model()->find("OrganID = {$key}")->MinTurnover; $sum = 0; foreach ($val as $v) { if ($v['IsPro']) { $sum += $v['ProPrice'] * $v['Num']; } else { $price = self::getContactprice($key, Yii::app()->user->getOrganID()); $PriceRatio = $price['PriceRatio'] ? $price['PriceRatio'] : "100"; $DisPrice = sprintf("%.2f", $v['Price'] * $PriceRatio / 100); // 折扣价,小数点后面保留两位 $sum += $DisPrice * $v['Num']; } } if ($min > $sum) { $strarr = explode(",", $str); foreach ($val as $v) { $index = array_keys($strarr, $v['ID']); unset($strarr[$index[0]]); } $ID = implode(",", $strarr); $arr['result'] = 1; $arr['ID'] = $ID; $arr['min'] = $min; $arr['sum'] = $sum; $arr['OrganName'] = $val[0]['OrganName']; return $arr; } } return array('result' => 0); }
/** * 立即购买 */ public function actionBuynow() { $goodsId = Yii::app()->request->getParam('goodsid'); if (!$goodsId) { $this->redirect(array('/pap/home/index')); } $this->pageTitle = Yii::app()->name . '-收货地址'; $organID = Yii::app()->user->getOrganID(); $payment = Yii::app()->request->getParam("payment"); if ($payment) { $payment = Yii::app()->request->getParam("payment"); } else { $payment = 1; } //获取商品信息 $goods = MallService::getGoodByID($goodsId, $payment); if (!$goods) { $this->redirect(array('/pap/home/index')); } //获取该商品经销商订单最小交易额 $turnover = PapOrderMinTurnover::model()->find("OrganID=:ID", array(":ID" => $goods['OrganID'])); if ($turnover) { $goods["MinTurnover"] = $turnover['MinTurnover']; } //获取我的优惠券 $dataProvider = BuyGoodsService::mycoupon(); $model = new JpdReceiveAddress(); $address = JpdReceiveAddress::model()->findAll('OrganID=:organID order by CreateTime DESC', array(':organID' => $organID)); $amount = intval(Yii::app()->request->getParam("goods_amout")) > 0 ? intval(Yii::app()->request->getParam("goods_amout")) : 1; $data = array('goods' => $goods, 'address' => $address, "amount" => $amount, 'model' => $model, 'dataProvider' => $dataProvider); $this->render('buynow', $data); }
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); }
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)); }
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)); }
public static function getDealerGoodByID($id) { $criteria = new CDbCriteria(); $criteria->condition = " t.ISdelete = 1"; // 没有删除的商品 $criteria->with = array("img", 'PapJpbrand', 'spec', 'pack'); $model = PapGoods::model()->findByPk($id, $criteria); //return $model; if (!$model) { return false; } $data = array(); //获取该经销商最小交易额 $turnover = PapOrderMinTurnover::model()->find("OrganID=:ID", array(":ID" => $model['OrganID'])); if ($turnover) { $data["MinTurnover"] = $turnover['MinTurnover']; } //商品基本信息 $data['GoodsID'] = $id; $data['Version'] = $model['Version']; $data['Name'] = $model['Name']; $data['GoodsNO'] = $model['GoodsNO']; $data['CommentNo'] = $model['CommentNo']; $data['Info'] = $model['Info']; $data['Memo'] = $model['Memo']; $data['PartsLevel'] = $model['PartsLevel']; $data['code'] = $model['StandCode']; $organID = Yii::app()->user->getOrganID(); //商品价格 $price = self::getContactprice($model['OrganID'], $organID); $data['Price'] = $model['Price']; //$data['ListPrice'] = $model['Price']; $data['LogisticsPrice'] = 0; $data['PriceRatio'] = $price['PriceRatio'] ? $price['PriceRatio'] : "100%"; if ($data['PriceRatio'] > 0) { $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['BrandName'] = $model->PapJpbrand->BrandName ? $model->PapJpbrand->BrandName : ''; //商品OE号 $data['OENO'] = PapGoods::model()->getOENOSByGoodsID($id); // $data['LogisticsPrice'] = $goods['LogisticsPrice']; //商品大类、子类、标准名称 $cpArr = self::getCategory($model['StandCode'], $id); $data['BigParts'] = $cpArr['BigParts']; $data['SubParts'] = $cpArr['SubParts']; $data['CpName'] = $cpArr['CpName']; $data['sub'] = $cpArr['sub']; $data['BganCompany'] = $model->spec->BganCompany ? $model->spec->BganCompany : ''; //标品 $data['BganGoodsNO'] = $model->spec->BganGoodsNO ? $model->spec->BganGoodsNO : ''; //标商 $data['Unit'] = $model->spec->Unit ? $model->spec->Unit : ''; //单位 $data['MinQuantity'] = $model->pack->MinQuantity ? $model->pack->MinQuantity : ''; //最小包装 // $data['pLength'] = $model->pack->Volume ? $model->pack->Volume : ''; //体积 // $data['Weight'] = $model->pack->Weight ? $model->pack->Weight : ''; //重量 // 图片 if (!$model->img) { $data['Images'][0]['ImageUrl'] = 'dealer/goods-img-big.jpg'; } else { foreach ($model->img as $v) { $data['Images'][] = $v->attributes; } } return $data; }
public function actionEditturnover() { $this->pageTitle = Yii::app()->name . '-' . "修改订单最小金额"; $id = Yii::app()->request->getParam('id'); //获取要修改的ID if ($id) { $model = PapOrderMinTurnover::model()->findByPk($id); } else { $model = new PapOrderMinTurnover(); } $this->performAjaxValidation($model); if (isset($_POST['PapOrderMinTurnover'])) { $model->MinTurnover = $_POST['PapOrderMinTurnover']['MinTurnover']; $model->UpdateTime = time(); if ($model->save()) { $this->redirect(array('turnover')); } } $this->render('editturnover', array('model' => $model)); }