" width="80" height="80"/></a> </div> <div class="gwc_spxx float_l width360" > <div class="name" > <a href="<?php echo $goodsurl; ?> " title="<?php echo $list['GoodsName']; ?> "style="color:#555;font-weight: bold;overflow: hidden; white-space: nowrap; text-overflow: ellipsis;display: block;width:120px;float:left"> <?php echo isset($list['GoodsName']) ? $list['GoodsName'] : ''; ?> </a> <?php $issale = BuyGoodsService::issale($list['GoodsID']); switch ($issale) { case 0: echo '<span style="color:red;display:block;float:left;width:80px" class="unsale">商品已经下架</span>'; break; } ?> <div style="clear: both"></div> </div> <p class="m-top5" style='margin-top:3px'>商品编号:<span><?php echo isset($list['GoodsNum']) ? $list['GoodsNum'] : ''; ?> </span></p> <p class="m-top5" style='margin-top:3px'>品牌:<span><?php echo isset($list['Brand']) ? $list['Brand'] : ''; ?>
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)); }
<input name="Version" type="hidden"> <input name="quo" type="hidden"> <input name="Order" type="hidden"> </form> <?php $this->renderPartial('/inquiryorder/address', array('model' => $model)); ?> <script type="text/javascript" src="<?php echo Yii::app()->theme->baseUrl; ?> /js/jpd/jquery.form.js"></script> <?php //我的优惠券 $this->beginWidget('zii.widgets.jui.CJuiDialog', array('id' => 'actpaper', 'options' => array('title' => '我的优惠券', 'width' => 500, 'height' => 260, 'autoOpen' => false, 'resizable' => false, 'modal' => true, 'overlay' => array('backgroundColor' => '#000', 'opacity' => '0.5'), 'buttons' => array('确定使用' => 'js:function(){ choosecoupon()}', '取消' => 'js:function(){ $(this).dialog("close");}')))); echo $this->renderPartial('/quotationlist/coupon', array('dataProvider' => BuyGoodsService::mycoupon())); $this->endWidget('zii.widgets.jui.CJuiDialog'); ?> <script> //计算报价 function counttotal(id) { //计算单个商品总价 if (id != undefined) { countgoods(id); } //计算总价 var totalprices = 0;
public function actionLott() { $organID = Yii::app()->user->getOrganID(); $coupon = BuyGoodsService::get_lott_value(); $promoid = Yii::app()->request->getParam('promoid'); if (!empty($coupon) && is_array($coupon)) { $minamount = $coupon['MinAmount']; $maxamount = $coupon['MaxAmount']; } $prize = mt_rand($minamount, $maxamount); if ($prize) { $organID = Yii::app()->user->getOrganID(); $cou_arr = array('CouponSn' => OrderService::gen_coupon_sn(), 'PromoID' => $promoid, 'OwnerID' => $organID, 'IsUse' => 0, 'CreateTime' => time(), 'Amount' => $prize, 'Valid' => $coupon['Valid']); //插入抽奖获得的优惠券金额信息 BuyGoodsService::insert_coupon_manage($cou_arr); } echo json_encode($prize); }
echo "<span style='color:#e97816'>参与促销优惠活动:-¥" . $act_res['DecrAmount'] . "<br>(单笔订单满 ¥" . $act_res['MinAmount'] . " 减¥" . $act_res['DecrAmount'] . ")</span>"; } } $order_decr = $act_res['DecrAmount']; break; case 2: //每满减 $act_res = BuyGoodsService::pperdecre($params); $order_decr = $act_res['DecrTotal']; if (!empty($order_decr)) { echo "<span style='color:#e97816'>参与促销优惠活动:-" . $act_res['DecrTotal'] . "<br>(单笔订单每满 ¥" . $act_res['MinAmount'] . " 减¥" . $act_res['DecrAmount'] . ")</span>"; } break; case 3: //优惠券; $act_res = BuyGoodsService::coupondecre($params); if ($counts >= $act_res['MinAmount'] && $num == 1) { echo "<div class='info'><input type='hidden' class='mina' name='minamount' value=" . $act_res['MinAmount'] . ">"; // echo "<span style='color:red'>单笔订单满".$act_res['MinAmount']."元,系统将赠送您价值".$act_res['DecrAmount']."元优惠券".$act_res['Num']."张</span><br>"; echo "<span style='color:#e97816'>您将有机会参与抽奖活动</span>"; echo "<input type='hidden' name='lott' value='1'>"; echo "<input type='hidden' name='PromoID' value=" . $act_res['PromoID'] . "></div>"; } break; } } } } if (!empty($coupon) && is_array($coupon)) { echo "<span class='cup' style='color:#e97816'><input type='checkbox' class='clpayper'><span class='payper' >使用我的优惠券</span><br>(您可以使用优惠券,减免订单金额,每次只限一张)</span>"; }
public function actionGetaction() { $html = ''; $order_decr = 0; $cop_amout = Yii::app()->request->getParam(cop_amout); $organID = Yii::app()->user->getOrganID(); $data = BuyGoodsService::activeorgan(); // var_dump($data);die; $params = array(); if (in_array($organID, $data)) { $act = BuyGoodsService::active(); if (!empty($act) && is_array($act)) { $payment = $act['Payment']; $params['PromoID'] = intval($act['ID']); $params['TotalAmount'] = Yii::app()->request->getParam('amount'); switch ($act['Type']) { case 1: //满多少减多少 $act_res = BuyGoodsService::decre($params); if (!empty($act_res) && is_array($act_res)) { if (!empty($act_res['DecrAmount'])) { $html = "<span style='color:red'>优惠:-¥" . $act_res['DecrAmount'] . "(单笔订单满 ¥" . $act_res['MinAmount'] . " 减¥" . $act_res['DecrAmount'] . ")</span>"; } else { $html = ''; } } $order_decr = $act_res['DecrAmount']; break; case 2: //每满减 $act_res = BuyGoodsService::pperdecre($params); $order_decr = $act_res['DecrTotal']; if (!empty($act_res['DecrAmount'])) { $html = "<span style='color:red'>优惠:-" . $act_res['DecrTotal'] . "(单笔订单每满 ¥" . $act_res['MinAmount'] . " 减¥" . $act_res['DecrAmount'] . ")</span>"; } break; case 3: //优惠券 $params['search'] = 'search'; $res = BuyGoodsService::mycoupon(); $act_res = BuyGoodsService::coupondecre($params); $coupon = $res->getData(); $html = ""; // "<span style='color:red'>单笔订单满" . $act_res['MinAmount'] . "元,系统将赠送您价值" . $act_res['DecrAmount'] . "元优惠券" . $act_res['Num'] . "张</span><br>"; if ($cop_amout) { $html .= '<span style="color:red">使用优惠券:-¥' . floatval($cop_amout); } elseif (!empty($coupon) && is_array($coupon)) { $html .= "<span class='cup' style='color:red'><span class='payper' style='color:blue'>使用我的优惠券</span>(您可以使用优惠券,减免订单金额,每次只限一张)</span>"; } break; } } } echo json_encode(array('html' => $html, 'order_decr' => $order_decr, 'payment' => isset($payment) ? $payment - 1 : '1')); }