|
@@ -13,7 +13,7 @@ class InvoiceItem extends \think\Model {
|
|
|
protected $deleteTime="delete_time";
|
|
|
|
|
|
public function OrderInfo(){
|
|
|
- return $this->hasMany(InvoiceOrder::class,"itemId","id");
|
|
|
+ return $this->hasMany(InvoiceOrder::class,"itemId","id")->whereIn('status', [1, 2]);
|
|
|
}
|
|
|
|
|
|
public static function getNumAttr($val){
|
|
@@ -29,7 +29,7 @@ class InvoiceItem extends \think\Model {
|
|
|
$change = $model->getChangedData();
|
|
|
Log::info("修改发票明细状态:".json_encode($change,JSON_UNESCAPED_UNICODE));
|
|
|
Log::info("跟后数据:".json_encode($model->toArray(),JSON_UNESCAPED_UNICODE));
|
|
|
- if(in_array($change["status"],[0,1,2])){
|
|
|
+ if(isset($change['status'])&&in_array($change["status"],[0,1,2])){
|
|
|
Log::info('跟后数据:'.json_encode($model->toArray(),JSON_UNESCAPED_UNICODE));
|
|
|
$num = self::where(['invoiceCode'=>$code,'order_type'=>$orderType,'status'=>0])->count();
|
|
|
// if($orderType==1){
|
|
@@ -85,12 +85,12 @@ class InvoiceItem extends \think\Model {
|
|
|
unset($temp['id']);
|
|
|
$up = self::create($temp);
|
|
|
if($up->id>0){
|
|
|
- $orders = InvoiceOrder::where(['itemId'=>$item->id])->select();
|
|
|
+ $orders = InvoiceOrder::where(['itemId'=>$item->id,"status"=>[1,2]])->select();
|
|
|
if(!$orders->isEmpty()){
|
|
|
InvoiceOrder::create(array_map(function ($items)use ($up){
|
|
|
$items['itemId']=$up->id;
|
|
|
unset($items['id']);
|
|
|
- return $item;
|
|
|
+ return $items;
|
|
|
},$orders->toArray()));
|
|
|
}
|
|
|
}
|