Exemplo n.º 1
0
 public static function sendquo($inqid)
 {
     $time = $_SERVER['REQUEST_TIME'];
     //查看询价单是否是客服代发
     $inqsql = ' select InquiryID,`State`,OrganID,Payment,AddressID,DealerID  from `pap_inquiry` where InquiryID=' . $inqid;
     $res = Yii::app()->papdb->createCommand($inqsql)->queryRow();
     $quoid = self::ifsendquo(array('inqid' => $inqid));
     //更新报价单状态
     if ($res['State'] == 1) {
         //生成确认码
         $checksn = self::getCheckSn($res['OrganID']);
         $sql = 'update pap_quotation set Status="1",IfSend="2",CheckSn="' . $checksn . '",UpdateTime=' . $time . ' where QuoID=' . $quoid;
     } else {
         $sql = 'update pap_quotation set Status="1",IfSend="2",UpdateTime=' . $time . ' where QuoID=' . $quoid;
     }
     $count = Yii::app()->papdb->createCommand($sql)->execute();
     //更新询价单状态
     $inqsql = 'update pap_inquiry set Status=1,UpdateTime=' . $time . ' where InquiryID=' . $inqid . ' and Status=0';
     Yii::app()->papdb->createCommand($inqsql)->execute();
     if ($res['State'] == 1 && $count > 0) {
         //客服代发询价单制作报价单后用短信通知修理厂
         $sms = self::remindService(array_merge($res, array('quoID' => $quoid, 'checkSN' => $checksn)));
         if ($sms['code'] == 0) {
             $msg = '短信提醒发送失败';
         } else {
             $msg = '短信提醒发送失败!' . $sms['SMS'];
         }
         //给修理厂发送提醒  但是不发送短信
         $link = Yii::app()->createUrl('pap/inquiryorder/inquirydetail', array('inquiryID' => $inqid));
         $params = array('OrganID' => $res['OrganID'], 'OrganType' => 3, 'HandleID' => $quoid, 'link' => $link);
         $params['type'] = array('name' => 'BJD', 'key' => 3);
         $r = RemindService::sendRemind($params);
     } elseif ($count > 0) {
         //给修理厂发送提醒
         $link = Yii::app()->createUrl('pap/inquiryorder/inquirydetail', array('inquiryID' => $inqid));
         $params = array('OrganID' => $res['OrganID'], 'OrganType' => 3, 'HandleID' => $quoid, 'link' => $link);
         $params['type'] = array('name' => 'BJD', 'key' => 3);
         $r = RemindService::sendRemind($params);
     }
     if ($count > 0) {
         //更改询价单待报价状态为已处理
         $organID = Yii::app()->user->getOrganID();
         $sql = 'update pap_remind_business set HandleStatus=2 where HandleID=' . $inqid . ' and OrganID=' . $organID;
         Yii::app()->papdb->createCommand($sql)->execute();
     }
     echo json_encode(array('count' => $count, 'msg' => $msg));
 }
Exemplo n.º 2
0
 /**
  * 经销商物流退款-已收货
  */
 public function actionReturnpost()
 {
     $this->pageTitle = Yii::app()->name . '-' . "付款";
     $returnID = Yii::app()->request->getParam("returnID");
     $returninfo = PapReturnOrder::model()->findBypk($returnID);
     if ($returninfo->Status != 1) {
         $this->redirect(array('Index'));
         exit;
     }
     //添加收货地址
     $addressID = Yii::app()->request->getParam("addressID");
     if (!$addressID) {
         $this->redirect(array('/pap/dealerreturn/index'));
     }
     $ship = $this->getShip($addressID);
     if (!$ship) {
         $this->redirect(array('/pap/dealerreturn/index'));
     }
     OrderreturnService::savereturnaddress($ship);
     if ($returnID) {
         PapReturnOrder::model()->updateBypk($returnID, array('Status' => 2, 'PayMethod' => 2));
         //更改待审核提醒为已操作
         RemindService::updateRemindStatus($returnID, 4, $returninfo['DealerID']);
         //发送待发货提醒给修理厂
         $params = array('OrganID' => $returninfo['ServiceID'], 'OrganType' => 3, 'HandleID' => $returnID);
         $params['type'] = array('name' => 'THD', 'key' => 5);
         RemindService::sendRemind($params, $returninfo);
         $this->redirect(array('Index'));
     } else {
         throw new CHttpException(404, '页面不存在');
     }
 }
Exemplo n.º 3
0
 /**
  *    响应嘉配订单支付通知
  *
  *    @author    Garbin
  *    @param     int    $order_id
  *    @param     array  $notify_result
  *    @return    bool
  */
 public static function respondNotify($order_id, $notify_result)
 {
     $where = "ID = {$order_id}";
     //$data = array('RefundStatus' => $notify_result['trade_status']);
     //   $orderdata=array('ReturnStatus'=>'1','Status' => $notify_result['target']);
     switch ($notify_result['target']) {
         case RORDER_READY:
             $where .= ' AND Status <= ' . RORDER_PENDING;
             $data['AlipayTN'] = $notify_result['trade_no'];
             $data['Status'] = RORDER_READY;
             break;
         case RORDER_PENDING:
             // 付款, 待发货
             $where .= ' AND Status <= ' . RORDER_PENDING;
             $data['AlipayTN'] = $notify_result['trade_no'];
             $data['Status'] = RORDER_PENDING;
             $data['CreateTime'] = time();
             //更改提醒状态为已操作
             $returninfo = PapReturnOrder::model()->findByPk($order_id);
             RemindService::updateRemindStatus($order_id, 4, $returninfo['DealerID']);
             //发送待发货提醒给修理厂
             $params = array('OrganID' => $returninfo['ServiceID'], 'OrganType' => 3, 'HandleID' => $order_id);
             $params['type'] = array('name' => 'THD', 'key' => 5);
             RemindService::sendRemind($params, $returninfo);
             break;
         case RORDER_ACCEPTED:
             // 待收货
             $where .= ' AND Status <= ' . RORDER_ACCEPTED;
             $where .= ' AND Status >= ' . RORDER_PENDING;
             $data['Status'] = RORDER_ACCEPTED;
             $data['DeliveryTime'] = time();
             break;
         case RORDER_ABNORMAL:
             //已收货,完成
             $where .= ' AND Status <= ' . RORDER_ABNORMAL;
             $where .= ' AND Status >= ' . RORDER_ACCEPTED;
             $data['Status'] = RORDER_ABNORMAL;
             $return = PapReturnGoods::model()->find('ReturnID=:returnID', array(':returnID' => $order_id));
             if ($return) {
                 $orderID = $return['OrderID'];
                 if ($orderID) {
                     $wheres = "ID = {$orderID}";
                     PapOrder::model()->updateAll(array('ReturnStatus' => 4), $wheres);
                 }
             }
             break;
             //            case RORDER_READY_PAYPAL://退款 待付款
             //                  $where .= ' AND Status = ' . RORDER_READY_PAYPA;
             //                  $data['Status']=RORDER_READY_PAYPAL;
             //                  break;
             //            case RORDER_PAYPAL_FINISHED://退款完成
             //                  $where .= ' AND Status =' .RORDER_PAYPAL_FINISHED;
             //                  $data['Status']=RORDER_PAYPAL_FINISHED;
             //                  break;
     }
     //PapReturnOrder::model()->updateByPk($order_id,$data)
     //PapReturnOrder::model()->updateAll($data, $where)
     if (PapReturnOrder::model()->updateAll($data, $where)) {
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 4
0
 public static function sendOrder($params, $ID, $OrganID)
 {
     $sql = "select * from pap_order t where t.SellerID = {$OrganID} and t.IsDelete=0 and Status=2 and t.ID in({$ID})";
     $model = Yii::app()->papdb->createCommand($sql)->queryAll();
     if (!$model) {
         return array('error' => 4, 'msg' => '发货失败,请稍后再试!');
     }
     $goodsid = explode(',', $params['goodsid']);
     $pn = explode('|', $params['PN']);
     $idarr = explode(',', $ID);
     if (count($model) != count($idarr)) {
         return array('error' => 1, 'msg' => '发货失败,请稍后再试!');
     }
     foreach ($model as $v) {
         // 如果是支付宝订单,则调用确认收货接口
         $isAlipay = false;
         $alipayResult = false;
         $alipayError = "";
         $paymentMethod = $v['Payment'];
         if ($paymentMethod == '1') {
             $isAlipay = true;
             // 订单交易号是否存在
             if (!$v['AlipayTN']) {
                 return array('error' => 2, 'msg' => '订单支付信息错误');
                 Yii::app()->end();
             }
             $payment = Yii::app()->alipay;
             // 确认收货请求参数
             $request = new AlipaySendConfirmRequest();
             $request->trade_no = $v['AlipayTN'];
             if ($params['ShipSn']) {
                 $request->invoice_no = $params['ShipSn'];
             }
             $request->logistics_name = $params['ShipLogis'];
             $request->transport_type = "EXPRESS";
             // var_dump($request).'<br>';
             //建立请求
             $html_text = $payment->buildRequestHttp($request);
             //解析XML
             //注意:该功能PHP5环境及以上支持,需开通curl、SSL等PHP配置环境。建议本地调试时使用PHP开发软件
             $doc = new DOMDocument();
             $doc->loadXML($html_text);
             if (!empty($doc->getElementsByTagName("alipay")->item(0)->nodeValue)) {
                 $alipay = $doc->getElementsByTagName("alipay")->item(0);
                 //echo $alipay->nodeValue;
                 $is_success = $alipay->getElementsByTagName("is_success")->item(0)->nodeValue;
                 if ($is_success == 'T') {
                     $alipayResult = true;
                 } else {
                     $alipayResult = false;
                     $alipayError = $alipay->getElementsByTagName("error")->item(0)->nodeValue;
                 }
             }
             // 记录日志
             $userId = Yii::app()->user->id;
             $payment->put_send_goods_log($v, $request->getParams(), $html_text, $alipayResult, $userId);
         }
         // 如果是支付宝,并且支付宝接口返回成功  或者 不是支付宝,保存物流信息
         $bool = false;
         if (!$isAlipay || $isAlipay && $alipayResult) {
             $bool = PapOrder::model()->updateByPk($v['ID'], array('Status' => 3, 'UpdateTime' => time(), 'DeliveryTime' => time(), 'ShipSn' => $params['ShipSn'], 'ShipLogis' => $params['ShipLogis'], 'PayStatus' => $isAlipay === true ? 'WAIT_BUYER_CONFIRM_GOODS' : ''));
             if ($bool) {
                 //更新待发货提醒状态
                 RemindService::updateRemindStatus($v['ID'], 2, $v['SellerID']);
                 //待收货提醒给修理厂
                 $params = array('OrganID' => $v['BuyerID'], 'OrganType' => 3, 'HandleID' => $v['ID']);
                 $params['type'] = array('name' => 'DD', 'key' => 2);
                 RemindService::sendRemind($params, $v);
             }
         } else {
             return array('error' => 3, 'msg' => '支付宝接口繁忙,请重新发货!');
         }
     }
     //订单商品
     if ($goodsid && $pn) {
         foreach ($goodsid as $k => $v) {
             if (preg_match('/^[A-Za-z0-9][A-Za-z0-9,,-]*$/', $pn[$k])) {
                 PapOrderGoods::model()->updateByPk($v, array('PN' => $pn[$k], 'UpdateTime' => time()));
             }
         }
     }
     return array('success' => 1);
     //$userid = RemindService::getUserID($model[0]['BuyerID']);
     // return array('success' => 1, 'userid' => $userid);
 }
Exemplo n.º 5
0
 public function actionSaveinquiry()
 {
     $type = Yii::app()->request->getParam('Type');
     $epc = Yii::app()->request->getParam('epc');
     $inquiry = array();
     //生成询价单编号
     $inquiry['InquirySn'] = RPCClient::call('InquiryorderService_setinquirysn');
     $inquiry['Make'] = $epc['make'];
     $inquiry['Car'] = !empty($epc['series']) ? $epc['series'] : '0';
     $inquiry['Year'] = !empty($epc['year']) ? $epc['year'] : '0';
     $inquiry['Model'] = !empty($epc['model']) ? $epc['model'] : '0';
     if (empty($inquiry['Make'])) {
         $inquiry['Make'] = '0';
         $inquiry['Car'] = '0';
         $inquiry['Year'] = '0';
         $inquiry['Model'] = '0';
     }
     $vin = Yii::app()->request->getParam('VIN');
     $inquiry['VIN'] = $vin == '请输入VIN码' ? '' : $vin;
     $inquiry['Describe'] = Yii::app()->request->getParam('Describe');
     $inquiry['CreateTime'] = time();
     $inquiry['DealerID'] = Yii::app()->request->getParam('DealerID');
     $inquiry['OrganID'] = Yii::app()->user->getOrganID();
     //InquirySn是否存在
     $ser = RPCClient::call('InquiryorderService_ifexitinquirysn', $inquiry['InquirySn']);
     if (!empty($ser)) {
         echo json_encode(array('success' => false, 'message' => '发送失败'));
     } else {
         //保存询价单返回inquiryid
         $saveinquiry = RPCClient::call('InquiryorderService_saveinquiry', $inquiry);
         if (!empty($saveinquiry)) {
             $picfiles = Yii::app()->request->getParam('inquiryImages');
             if ($picfiles) {
                 $picfilesname = Yii::app()->request->getParam('inquiryImagesname');
                 $params = array('inquiryID' => $saveinquiry, 'imgs' => $picfiles, 'imgsname' => $picfilesname);
                 //保存上传图片
                 RPCClient::call('InquiryorderService_savepic', $params);
             }
             $aps = Yii::app()->request->getParam('parts');
             if ($aps) {
                 $categorydata = array('part' => $aps, 'inquiryID' => $saveinquiry);
                 //保存配件信息
                 RPCClient::call('InquiryorderService_newPapInquiryCategory', $categorydata);
             }
             //询价单制作成功发送消息通知经销商
             $params = array('OrganID' => trim($inquiry['DealerID'], ','), 'OrganType' => 2, 'HandleID' => $saveinquiry);
             $params['type'] = array('name' => 'XJD', 'key' => 3);
             RemindService::sendRemind($params);
             echo json_encode(array('success' => true, 'message' => '发送成功'));
         }
     }
 }
Exemplo n.º 6
0
 public static function sendquo($params)
 {
     $time = $_SERVER['REQUEST_TIME'];
     $sql = ' select ServiceID,IfSend from pap_quotation where QuoID=' . $params['quoid'];
     $res = Yii::app()->papdb->createCommand($sql)->queryRow();
     $sql = 'update pap_quotation set IfSend="2",ServiceID=' . $params['sid'] . ',Status="1",UpdateTime=' . $time;
     //发送草稿箱内容
     if ($params['draft']) {
         $sql .= ',CreateTime=' . $time;
     }
     $sql .= ' where QuoID=' . $params['quoid'];
     $count = Yii::app()->papdb->createCommand($sql)->execute();
     if ($res['IfSend'] == 2 && $res['ServiceID'] != $params['sid']) {
         //删除业务提醒数据
         $delete = 'delete from pap_remind_business where HandleID=' . $params['quoid'] . ' and OrganID=' . $res['ServiceID'];
         Yii::app()->papdb->createCommand($delete)->execute();
     }
     if ($count > 0 && ($res['IfSend'] == 2 && $res['ServiceID'] != $params['sid'] || $res['IfSend'] == 1)) {
         //给修理厂发送提醒
         $params = array('OrganID' => $params['sid'], 'OrganType' => 3, 'HandleID' => $params['quoid']);
         $params['type'] = array('name' => 'BJD', 'key' => 3);
         $r = RemindService::sendRemind($params);
     }
     echo json_encode(array('count' => $count));
 }
Exemplo n.º 7
0
 /**
  *    响应嘉配订单支付通知
  *
  *    @author    Garbin
  *    @param     int    $order_id
  *    @param     array  $notify_result
  *    @return    bool
  */
 public static function respondNotify($order_id, $notify_result)
 {
     if ($notify_result['target'] == ORDER_PENDING) {
         return;
     }
     $where = "ID = {$order_id}";
     $data = array('Status' => $notify_result['target'], 'PayStatus' => $notify_result['trade_status']);
     $OrganID = Yii::app()->user->getOrganID();
     switch ($notify_result['target']) {
         case ORDER_ACCEPTED:
             $where .= ' AND Status=' . ORDER_PENDING;
             //只有待付款的订单才会被修改为已付款
             $data['AlipayTN'] = $notify_result['trade_no'];
             $data['PayTime'] = time();
             //更新待付款提醒状态
             RemindService::updateRemindStatus($order_id, 1, $OrganID);
             $sql = 'select SellerID from pap_order where ID=' . $order_id;
             $res = Yii::app()->papdb->createCommand($sql)->queryRow();
             //发送待发货提醒给经销商
             $params = array('OrganID' => $res['SellerID'], 'OrganType' => 2, 'HandleID' => $order_id, 'OrderID' => $order_id, 'TotalAmount' => $res['TotalAmount']);
             $params['type'] = array('name' => 'DD', 'key' => 2);
             RemindService::sendRemind($params);
             //赠送积分
             self::saveIntegral($params);
             break;
         case ORDER_SHIPPED:
             $where .= ' AND Status=' . ORDER_ACCEPTED;
             //只有等待发货的订单才会被修改为已发货
             $data['DeliveryTime'] = time();
             break;
         case ORDER_FINISHED:
             $where .= ' AND Status=' . ORDER_SHIPPED;
             //只有已发货的订单才会被自动修改为交易完成
             $data['ReceiptTime'] = time();
             break;
         case ORDER_CANCLED:
             //任何情况下都可以关闭
             /* 加回商品库存 */
             break;
     }
     switch ($notify_result['refund']) {
         case 'WAIT_SELLER_AGREE':
             //待审核
             $data['PayStatus'] = 'WAIT_SELLER_AGREE';
             $data['ReturnStatus'] = '1';
             //$data['AlipayTN'] = $notify_result['trade_no'];
             break;
         case 'WAIT_BUYER_RETURN_GOODS':
             //等待买家发货
             $data['PayStatus'] = 'WAIT_BUYER_RETURN_GOODS';
             //只有等待发货的订单才会被修改为已发货
             $data['ReturnStatus'] = '2';
             break;
         case 'WAIT_SELLER_CONFIRM_GOODS':
             //等待卖家收货
             $data['PayStatus'] = 'WAIT_SELLER_CONFIRM_GOODS';
             $data['ReturnStatus'] = '3';
             break;
         case 'REFUND_SUCCESS':
             //任何情况下都可以关闭
             /* 加回商品库存 */
             $where .= ' AND Status=' . ORDER_CANCLED;
             $data['PayStatus'] = 'REFUND_SUCCESS';
             $data['ReturnStatus'] = '4';
             break;
     }
     return PapOrder::model()->updateAll($data, $where);
 }
Exemplo n.º 8
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);
 }
Exemplo n.º 9
0
 public function actionAddreturnorder2()
 {
     $goodsArr = explode(',', $_POST['Goods']);
     $sql = 'insert into `pap_return_goods` values';
     $idStr = '(';
     foreach ($goodsArr as $v) {
         $g = explode('-', $v);
         $idStr .= $g[0] . ',';
         if (!$g[6]) {
             //如果该商品版本就空
             $g[6] = 'NULL';
         }
         $sql .= "(NULL,{$g['0']},{$g['1']},'ReturnID',{$g['2']},{$g['3']},{$g['4']},'',{$g['5']},{$g['6']}),";
     }
     $idStr = substr($idStr, 0, -1) . ')';
     $c = new CDbCriteria();
     $c->addCondition("ID in {$idStr} and ReturnStatus=0", 'AND');
     $m = PapOrder::model()->findAll($c);
     if (!$m) {
         echo json_encode(array('error' => '提交退款单失败,请先刷新订单列表!'));
         exit;
     }
     $model = new PapReturnOrder();
     $model->ReturnNO = 'THD' . ReturnorderService::gen_order_sn();
     $model->DealerID = $m[0]['SellerID'];
     $model->ServiceID = Commonmodel::getOrganID();
     $model->Status = 11;
     //退款待审核
     $model->CreateTime = time();
     $model->Price = $_POST['Price'];
     $model->LogtigCompany = '顺丰';
     $model->Result = $_POST['Reseaon'];
     $model->Type = $m[0]['Status'] == 9 ? 2 : 1;
     $model->ReturnNumber = 11;
     $model->save();
     if (!$model->save()) {
         echo json_encode(array('error' => '提交退货单失败,请稍后再试!'));
         exit;
     }
     $id = $model->attributes['ID'];
     $editSql = "update `pap_order` set ReturnStatus=11 where ID in {$idStr}";
     $sql = str_replace('ReturnID', $id, substr($sql, 0, -1));
     $ins = Yii::app()->papdb->createCommand($sql)->execute();
     $edt = Yii::app()->papdb->createCommand($editSql)->execute();
     //发送待审核提醒给经销商
     $params = array('OrganID' => $model['DealerID'], 'OrganType' => 2, 'HandleID' => $id);
     $params['type'] = array('name' => 'THD', 'key' => 4);
     RemindService::sendRemind($params);
     if ($ins && $edt) {
         echo json_encode(array('success' => 1));
     }
 }