public static function &getInstance() { if (self::$_instance === null) { self::$_instance = new self(); } return self::$_instance; }
public function handle_request_internal() { $brokerId = $this->_params['brokerId']; $mobile = $this->_params['mobile']; $address = $this->_params['address']; $amount = $this->_params['amount']; $type = $this->_params['type']; $createTime = time(); $insertData = array('brokerId' => $brokerId, 'type' => $type, 'amount' => $amount, 'mobile' => $mobile, 'address' => $address, 'createTime' => $createTime); if (!$amount) { return array('status' => 'error', 'message' => '发票金额为0'); } if (!preg_match("/^\\d{11}\$/", $mobile)) { return array('status' => 'error', 'message' => '不是11位纯数字手机号'); } if ($type == self::TYPE_COMPANY) { if (!isset($this->_params['companyName']) || empty($this->_params['companyName'])) { return array('status' => 'error', 'message' => '公司名称不能为空'); } else { $insertData['companyName'] = $this->_params['companyName']; } } //发票金额与从Order表中的得到的进行比较 $invoiceAmountArr = Bll_CustomerRush_Order::getInstance()->getInvoiceAmount($brokerId, Model_Mobile_CustomerOrder::STATUS_OK, Model_Mobile_CustomerOrder::IS_INVOICED_NO); $realAmount = $invoiceAmountArr['amount']; if ($realAmount != $amount) { return array('status' => 'error', 'message' => '此金额与发票的实际可开金额不符'); } $invoiceId = Bll_CustomerRush_Invoice::getInstance()->insertData($insertData); if (empty($invoiceId)) { return array('status' => 'error', 'message' => '插入失败'); } $keyData = array('brokerId' => $brokerId, 'status' => Model_Mobile_CustomerOrder::STATUS_OK, 'isInvoiced' => Model_Mobile_CustomerOrder::IS_INVOICED_NO); $updateData = array('isInvoiced' => Model_Mobile_CustomerOrder::IS_INVOICED_YES); Bll_CustomerRush_Order::getInstance()->updateData($keyData, $updateData); $result = array('status' => 'ok', 'data' => array('msg' => '我们会在7个工作日之内寄送发票')); return $result; }