|
@@ -152,12 +152,19 @@ class OrderInv extends BaseController{
|
|
|
"totalPrice"=>$value['inv_fee'],
|
|
|
"tax"=>$good_info['inv_tax']??$qrd['tax'],
|
|
|
"is_discount"=>$good_info['is_discount']??0,
|
|
|
- "addTax"=>$good_info['addTax']??'',
|
|
|
- "inv_tag"=>$good_info['inv_tag']??"",
|
|
|
+// "addTax"=>$good_info['addTax']??'',
|
|
|
+// "inv_tag"=>$good_info['inv_tag']??"",
|
|
|
"taxPrice"=>round($value['inv_fee']*($good_info['inv_tax']??$qrd['tax']),2),
|
|
|
"addtime"=>date("Y-m-d H:i:s"),
|
|
|
"updatetime"=>date("Y-m-d H:i:s")
|
|
|
];
|
|
|
+ if($invoice_good['tax']==0){
|
|
|
+ $invoice_good['addTax'] = $invoice_good['is_discount']==0?'': $good_info['addTax']??"";
|
|
|
+ $invoice_good['inv_tag'] = $invoice_good['is_discount']==0?3:$good_info['inv_tag']??'0';
|
|
|
+ }else{
|
|
|
+ $invoice_good['addTax'] = $invoice_good['is_discount']==0?'': $good_info['addTax']??"";
|
|
|
+ $invoice_good['inv_tag'] ='';
|
|
|
+ }
|
|
|
$update = [
|
|
|
"inv_fee"=>$qrd['inv_fee']+$value['inv_fee'],
|
|
|
"winv_fee"=>$qrd['winv_fee']-$value['inv_fee'],
|
|
@@ -753,9 +760,7 @@ class OrderInv extends BaseController{
|
|
|
if ($status==""){
|
|
|
return error_show(1005,"参数 status 不能为空");
|
|
|
}
|
|
|
-
|
|
|
$remark =isset($this->post['remark'])&&$this->post['remark']!="" ? trim($this->post['remark']):"";
|
|
|
-
|
|
|
$return_reason =isset($this->post['return_reason'])&&$this->post['return_reason']!="" ? trim($this->post['return_reason']):"";
|
|
|
$return= Db::name("invoice_return")->where(["returnCode"=>$returnCode])->find();
|
|
|
if($return==false){
|
|
@@ -819,18 +824,32 @@ class OrderInv extends BaseController{
|
|
|
if($up){
|
|
|
if($status==1){
|
|
|
if($return_type==1){
|
|
|
+ $discard=0;
|
|
|
if(date("Y-m",strtotime($ticket["open_date"]))==date("Y-m")){
|
|
|
//当月纸质普通发票+纸质专用发票 作废
|
|
|
- if(in_array($ticket['inv_type'],['004','007']))$this->addDiscard($ticket,$returnCode);
|
|
|
+ if(in_array($ticket['inv_type'],['004','007'])){
|
|
|
+ $discard=1;
|
|
|
+ $result= $this->addDiscard($ticket,$returnCode);
|
|
|
+ }
|
|
|
+
|
|
|
//当月电子普票红冲
|
|
|
- if($ticket['inv_type']=='026') $this->addRedOpen($ticket,$return_reason,$invinfo['company_type'], $returnCode);
|
|
|
+ if($ticket['inv_type']=='026')$result= $this->addRedOpen($ticket,$return_reason,$invinfo['company_type'], $returnCode);
|
|
|
//当月电子专票红冲
|
|
|
- if($ticket['inv_type']=='028') $this->addApplyRed($ticket,$returnCode);
|
|
|
+ if($ticket['inv_type']=='028')$result= $this->addApplyRed($ticket,$returnCode);
|
|
|
}else{
|
|
|
//跨月票都走红冲
|
|
|
- if(in_array($ticket['inv_type'],['007','026'])) $this->addRedOpen($ticket,$return_reason,$invinfo['company_type'], $returnCode);
|
|
|
- if(in_array($ticket['inv_type'],['004','028'])) $this->addApplyRed($ticket,$returnCode);
|
|
|
+ if(in_array($ticket['inv_type'],['007','026'])) $result= $this->addRedOpen($ticket,$return_reason,$invinfo['company_type'], $returnCode);
|
|
|
+ if(in_array($ticket['inv_type'],['004','028'])) $result= $this->addApplyRed($ticket,$returnCode);
|
|
|
}
|
|
|
+ if($result['code']==0){
|
|
|
+ if($discard==1){
|
|
|
+ $status=2;
|
|
|
+ }
|
|
|
+ if(isset($result['data']) &&$result['data']['invRed']!='' ){
|
|
|
+ Db::name("invoice_return")->where(["returnCode"=>$returnCode])->update(['red_inv'=>$result['data']['invRed']]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}else{
|
|
|
$invpool=[
|
|
|
"invNo"=>$invinfo['invNo'],
|
|
@@ -1960,14 +1979,14 @@ class OrderInv extends BaseController{
|
|
|
if($upred==false){
|
|
|
throw new Exception("红冲提交失败",1006);
|
|
|
}
|
|
|
- return app_show(0,"红冲已提交");
|
|
|
+ return app_show(0,"红冲已提交",["invRed"=>$invRed]);
|
|
|
}
|
|
|
|
|
|
private function addDiscard($ticket=[],$returnCode){
|
|
|
$invoice=Config::get("invoice");
|
|
|
$tax =new \TaxInvoice($invoice['appKey'],$invoice['appSecret'],$invoice['entCode']);
|
|
|
$result=$tax->DeprecateInvoices($ticket['seller_id'],$ticket['inv_type'],$ticket['inv_code'],$ticket['inv_number'],1);
|
|
|
- if(isset($result['ZTDM']) && $result['ZTDM']=='050000'){
|
|
|
+ if(isset($result['ZTDM']) && ($result['ZTDM']=='050000' || $result['ZTDM']=='053000')){
|
|
|
Db::name("invoice_return")->where(['returnCode'=>$returnCode])->update(["status"=>2,"updatetime"=>date("Y-m-d H:i:s")]);
|
|
|
$up =Db::name("invoice_pool")->where(['invNo'=>$ticket['invNo']])->update(["status"=>6,"updatetime"=>date("Y-m-d H:i:s")]);
|
|
|
if($up){
|