Ejemplo n.º 1
0
 public function actionSurequotation()
 {
     if (Yii::app()->request->isAjaxRequest) {
         $quoID = Yii::app()->request->getParam('quoID');
         $address = Yii::app()->request->getParam('addressID');
         $payment = Yii::app()->request->getParam('payment');
         $schID = Yii::app()->request->getParam('SchID');
         $goodsids = Yii::app()->request->getParam('goodsid');
         $nums = Yii::app()->request->getParam('num');
         $CouponSn = Yii::app()->request->getParam('CouponSn');
         if ($quoID && $address && $payment && $schID) {
             //InquiryorderService::createorder(报价单ID,方案ID,支付方式,地址ID,'类型')
             $ordertype = 2;
             $result = InquiryorderService::createorder($quoID, $schID, $payment, $address, $ordertype, $goodsids, $nums, $CouponSn);
             echo $result;
         } else {
         }
     }
 }
Ejemplo n.º 2
0
 public static function QuoCreateOrder($params)
 {
     $sql = ' select QuoID,InquiryID from `pap_quotation` where CheckSn="' . $params['msg'] . '" and ServiceID=' . $params['ID'] . ' and Status="1"';
     $res = Yii::app()->papdb->createCommand($sql)->queryRow();
     if (!$res) {
         //没有符合条件的报价单  短信回复内容无效
         $msg = $params['ID'] . '  ' . $params['content'] . '  checksn void!';
         return array('success' => false, 'msg' => $msg);
     } else {
         //获取生成订单需要的参数
         $msg = $params['ID'] . '  ' . $params['content'] . '  checksn valid! start create order';
         $schemesql = ' select SchID from `pap_quotation_scheme` where  QuoID=' . $res['QuoID'];
         $scheme = Yii::app()->papdb->createCommand($schemesql)->queryRow();
         $inqsql = ' select AddressID,Payment,Status from `pap_inquiry` where InquiryID=' . $res['InquiryID'];
         $inqres = Yii::app()->papdb->createCommand($inqsql)->queryRow();
         if ($scheme && $inqres['Status'] == 1 && $params['operate'] == 'Y') {
             //创建订单
             $orderres = InquiryorderService::createorder($res['QuoID'], $scheme['SchID'], $inqres['Payment'], $inqres['AddressID'], 2);
             $orderres = json_decode($orderres, true);
             $orderres['msg'] = $params['ID'] . '  ' . $params['content'] . '  ' . $orderres['msg'];
             if ($orderres['success']) {
                 //                    $smsmsg='尊敬的'.$params['OrganName'].'客户,您短信确认的报价单方案生成订单成功,订单号为:'.$orderres['ordersn'].'!';
                 //                    $sms = F::sendSMS(array(
                 //                                'msg' => $smsmsg,
                 //                                'phone' => $params['Phone'])
                 //                    );
                 Yii::log(date('Y-m-d H:i:s') . " [SMSReply]  order create success", 'info', 'command');
             }
             //更改报价单确认表内容
             $order = $orderres['orderID'] ? $orderres['orderID'] : 0;
             $update = ' update pap_quotation_confirm set ReplyTime=' . $params['time'] . ',ReplyContent="' . $params['content'] . '",`Status`=1,`Desc`="' . $orderres['data'] . '",OrderID=' . $order . ' where QuoID=' . $res['QuoID'];
             Yii::app()->papdb->createCommand($update)->execute();
             return $orderres;
         } else {
             if ($scheme && $inqres['Status'] == 1 && $params['operate'] == 'N') {
                 //拒绝报价单
                 $updatesql = 'update pap_quotation set Status="4" where QuoID=' . $res['QuoID'];
                 $count = Yii::app()->papdb->createCommand($updatesql)->execute();
                 $updatesql = 'update pap_inquiry set Status="4" where InquiryID=' . $res['InquiryID'];
                 $count = Yii::app()->papdb->createCommand($updatesql)->execute();
                 $data = '修理厂拒绝';
                 //更改报价单确认表内容
                 $update = ' update pap_quotation_confirm set ReplyTime=' . $params['time'] . ',ReplyContent="' . $params['content'] . '",`Status`=2, `Desc`="' . $data . '" where QuoID=' . $res['QuoID'];
                 Yii::app()->papdb->createCommand($update)->execute();
                 $msg = $params['ID'] . '  ' . $params['content'] . ' refuse quotation';
                 return array('success' => false, 'msg' => $msg, 'QuoID' => $res['QuoID']);
             } else {
                 if (!$scheme) {
                     $msg = $params['ID'] . '  ' . $params['content'] . '  scheme not exist!';
                     $data = '报价单方案不存在';
                 }
                 $status = array('待报价', '已报价待确认', '已确认', '已撤销', '已拒绝');
                 if ($inqres['Status'] != 1) {
                     $msg = $params['ID'] . '  ' . $params['content'] . '  inquiry status is' . $status[$inqres['Status']];
                     $data = '询价单是' . $status[$inqres['Status']] . '状态';
                 }
                 if ($inqres['Status'] != 1 && !$scheme) {
                     $msg = $params['ID'] . '  ' . $params['content'] . '  scheme not exist! inquiry inquiry status is' . $status[$inqres['Status']];
                     $data = '报价单方案不存在,询价单是' . $status[$inqres['Status']] . '状态';
                 }
                 //更改报价单确认表内容
                 $update = ' update pap_quotation_confirm set ReplyTime=' . $params['time'] . ',ReplyContent="' . $params['content'] . '",`Status`=2,`Desc`="' . $data . ' where QuoID=' . $res['QuoID'];
                 Yii::app()->papdb->createCommand($update)->execute();
                 return array('success' => false, 'msg' => $msg, 'QuoID' => $res['QuoID']);
             }
         }
     }
 }
Ejemplo n.º 3
0
 public function actionSurequotation()
 {
     if (Yii::app()->request->isAjaxRequest) {
         $quoID = Yii::app()->request->getParam('quoID');
         $address = Yii::app()->request->getParam('addressID');
         $payment = Yii::app()->request->getParam('payment');
         $schID = Yii::app()->request->getParam('SchID');
         $goodsids = Yii::app()->request->getParam('goodsid');
         $nums = Yii::app()->request->getParam('num');
         $CouponSn = Yii::app()->request->getParam('CouponSn');
         if ($quoID && $address && $payment && $schID) {
             $sql_inquiry = 'select InquiryID from pap_quotation where QuoID=' . $quoID;
             $result_inquiry = Yii::app()->papdb->createCommand($sql_inquiry)->queryRow();
             //              InquiryorderService::createorder(报价单ID,方案ID,支付方式,地址ID,'类型')
             if ($result_inquiry && $result_inquiry['InquiryID'] > 0) {
                 $ordertype = 2;
             } else {
                 $ordertype = 3;
             }
             $result = InquiryorderService::createorder($quoID, $schID, $payment, $address, $ordertype, $goodsids, $nums, $CouponSn);
             echo $result;
         }
     }
 }