예제 #1
0
 public function actionGetservicer()
 {
     //订购平台
     $organID = Commonmodel::getOrganID();
     //待确认的报价单
     $result['dquotions'] = PapQuotation::model()->count(array('condition' => "status = 1 and ServiceID = {$organID}"));
     //待付款的订单
     $result['forder'] = PapOrder::model()->count(array('condition' => "Status = 1 and BuyerID = {$organID}"));
     //待收货的订单
     $result['torder'] = PapOrder::model()->count(array('condition' => "Status = 3 and BuyerID = {$organID}"));
     //异常订单
     $result['uorder'] = PapOrder::model()->count(array('condition' => "Payment=2 and Status not in (11,12,13,14) and IsUnusual!=0 and BuyerID = {$organID}"));
     //待买家退货的订单
     $ssorder1 = PapOrder::model()->count(array('condition' => "Payment=2 and Status = 12 and BuyerID = {$organID}"));
     $ssorder2 = PapOrder::model()->count(array('condition' => "Payment=1 and PayStatus = 'WAIT_BUYER_RETURN_GOODS' and BuyerID = {$organID}"));
     $result['sorder'] = $ssorder1 + $ssorder2;
     echo json_encode($result);
 }
예제 #2
0
파일: RemindService.php 프로젝트: zwq/unpei
 private static function sendServiceRemind($params, $model)
 {
     $set = array('DD' => 1, 'BJD' => 2, 'THD' => 3);
     $type = $set[$params['type']['name']];
     $remindSetService = PapRemindSet::model()->find("OrganID={$params['OrganID']} and Type={$type}")->attributes;
     if ($remindSetService) {
         $exist1 = in_array($params['type']['key'], explode(',', $remindSetService['RemindItem']));
     }
     switch ($type) {
         case 1:
             //$key值 1,2
             if (!$remindSetService && is_array(Yii::app()->params['ServiceRemind']['DD']['children'])) {
                 $exist2 = array_key_exists($params['type']['key'], Yii::app()->params['ServiceRemind']['DD']['children']);
             }
             break;
             // case 'XJD':
             //    break;
         // case 'XJD':
         //    break;
         case 2:
             //$key值 3
             if (!$remindSetService && is_array(Yii::app()->params['ServiceRemind']['BJD']['children'])) {
                 $exist2 = array_key_exists($params['type']['key'], Yii::app()->params['ServiceRemind']['BJD']['children']);
             }
             break;
         case 3:
             //$key值 4,5
             if (!$remindSetService && is_array(Yii::app()->params['ServiceRemind']['THD']['children'])) {
                 $exist2 = array_key_exists($params['type']['key'], Yii::app()->params['ServiceRemind']['THD']['children']);
             }
             break;
     }
     if ($exist1 || $exist2) {
         $params['HandleType'] = $params['type']['key'];
         switch ($params['HandleType']) {
             case '1':
             case '2':
                 $model = $model ? $model : PapOrder::model()->findByPk($params['HandleID']);
                 $params['No'] = $model['OrderSN'];
                 $params['PromoterID'] = $model['SellerID'];
                 break;
             case '3':
                 $model = $model ? $model : PapQuotation::model()->findByPk($params['HandleID']);
                 $params['PromoterID'] = $model['DealerID'];
                 $params['No'] = $model['QuoSn'];
                 break;
             case '4':
             case '5':
                 $model = $model ? $model : PapreturnOrder::model()->findByPk($params['HandleID']);
                 $params['PromoterID'] = $model['DealerID'];
                 $params['No'] = $model['ReturnNO'];
                 $params['THDStatus'] = $model['Status'];
                 break;
         }
         $params['PromoterType'] = 2;
         if ($params['nosms']) {
             if ($exist1) {
                 $method = explode(',', $remindSetService['Method']);
                 $params['Method'] = array_diff($method, array(2));
             } else {
                 $params['Method'] = array(1);
             }
         } else {
             $params['Method'] = $exist1 === true ? explode(',', $remindSetService['Method']) : array(1, 2);
         }
         RemindService::saveRemind($params, 3);
     }
 }
예제 #3
0
 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));
 }
예제 #4
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));
 }
예제 #5
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);
 }