mirror of
https://gitee.com/ShopeX/OMS
synced 2026-03-24 03:15:32 +08:00
92 lines
3.2 KiB
PHP
92 lines
3.2 KiB
PHP
<?php
|
|
/**
|
|
* Copyright 2012-2026 ShopeX (https://www.shopex.cn)
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
class ome_preprocess_invoice {
|
|
|
|
/**
|
|
* 处理一号店的发票抬头信息获取
|
|
*/
|
|
public function process($order_id,&$msg){
|
|
if(!$order_id){
|
|
$msg = '缺少处理参数';
|
|
return false;
|
|
}
|
|
|
|
$orderObj = app::get('ome')->model('orders');
|
|
$opinfo = kernel::single('ome_func')->get_system();
|
|
$operationLogObj = app::get('ome')->model('operation_log');
|
|
|
|
$orderInfo = $orderObj->dump(array('order_id'=>$order_id,'shop_type'=>array('yihaodian','vjia'),'is_tax'=>'true'),'order_bn,shop_id,tax_company,order_type');
|
|
if(!$orderInfo || (isset($orderInfo['tax_title']) && !empty($orderInfo['tax_title']) && !is_null($orderInfo['tax_title']))){
|
|
return true;
|
|
}
|
|
|
|
//补发订单
|
|
if ($orderInfo['order_type'] == 'bufa') {
|
|
$msg = '补发订单不需要执行开发票';
|
|
return true;
|
|
}
|
|
|
|
$invoiceInfo = $this->getInvoiceFromYiHaoDian($orderInfo['order_bn'],$orderInfo['shop_id']);
|
|
if($invoiceInfo && isset($invoiceInfo['invoice'][0]['invoice_title']) && !empty($invoiceInfo['invoice'][0]['invoice_title']) && !is_null($invoiceInfo['invoice'][0]['invoice_title']) && $invoiceInfo['invoice'][0]['invoice_title'] != 'null'){
|
|
$data['order_id'] = $order_id;
|
|
$data['tax_title'] = $invoiceInfo['invoice'][0]['invoice_title'];//暂时只取第一张发票抬头
|
|
$orderObj->save($data);
|
|
|
|
$operationLogObj->write_log('order_preprocess@ome',$order_id,'订单预处理获取发票信息',time(),$opinfo);
|
|
return true;
|
|
}else{
|
|
$msg = '没有找到发票详细信息';
|
|
$operationLogObj->write_log('order_preprocess@ome',$order_id,$msg,time(),$opinfo);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 根据订单号tid和shop_id获取发票详细信息
|
|
*/
|
|
private function getInvoiceFromYiHaoDian($tid,$shop_id){
|
|
if(!$tid || !$shop_id){
|
|
return false;
|
|
}
|
|
|
|
$rs = kernel::single('ome_service_order')->get_invoice($tid,$shop_id);
|
|
|
|
return $rs;
|
|
|
|
/*
|
|
$api_name ='store.trade.invoice.get';
|
|
$param = array(
|
|
'tid' => $tid,
|
|
);
|
|
$timeout = 5;
|
|
|
|
$result = kernel::single('ome_rpc_request')->call($api_name, $param, $shop_id, $timeout);
|
|
if($result){
|
|
if($result->rsp == 'succ'){
|
|
$tmp = json_decode($result->data,true);
|
|
return $tmp;
|
|
}else{
|
|
return false;
|
|
}
|
|
}else{
|
|
return false;
|
|
}*/
|
|
}
|
|
|
|
}
|