wugg пре 1 година
родитељ
комит
c69b0aebac

+ 14 - 0
app/report/model/Brand.php

@@ -0,0 +1,14 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\report\model;
+
+use think\Model;
+
+/**
+ * @mixin \think\Model
+ */
+class Brand extends Model
+{
+    //
+}

+ 51 - 0
app/report/model/GoodBasic.php

@@ -0,0 +1,51 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\report\model;
+
+use think\facade\Db;use think\Model;
+
+/**
+ * @mixin \think\Model
+ */
+class GoodBasic extends Model
+{
+	protected $append=["spec_info","cat_info","usable_stock","total_stock","wait_in_stock","wait_out_stock","child"];
+	
+	public function unit(){
+		return $this->belongsTo(Unit::class,"good_unit")->bind(["unit_name"=>"unit"]);
+	}
+	
+	public function brand(){
+		return $this->belongsTo(Brand::class,'brand_id')->bind(['brand_name']);
+	}
+	
+	public function getSpecInfoAttr($v,$row){
+		return (new GoodSpec())->with(["spec","specinfo"])->where(["spuCode"=>$row['spuCode']])->field("spec_id,spec_value_id")->select();
+		
+	}
+	public function getCatInfoAttr($v,$row){
+		
+		return made($row['cat_id']);
+	}
+	
+	public function getTotalStockAttr($v,$row){
+		return	(new GoodStock())->withJoin(['WareInfo'],"left")->where(['spuCode'=>$row['spuCode'],"wsm_type"=>[5,4]])
+		->sum(Db::raw("usable_stock+wait_out_stock"));
+	}
+	
+	public function getUsableStockAttr($v,$row){
+		return	(new GoodStock())->withJoin(['WareInfo'],'left')->where(['spuCode'=>$row['spuCode'],'wsm_type'=>[5,4]])
+	->sum("usable_stock");
+	}
+	
+	public function getWaitInStockAttr($v,$row){
+		return	(new GoodStock())->withJoin(['WareInfo'],'left')->where(['spuCode'=>$row['spuCode'],'wsm_type'=>[5,4]])
+	->sum('wait_in_stock');
+	}
+	
+	public function getWaitOutStockAttr($v,$row){
+		return	(new GoodStock())->withJoin([' WareInfo'],'left')->where(['spuCode'=>$row['spuCode'],'wsm_type'=>[5,4]])
+	->sum('wait_out_stock');
+	}
+}

+ 22 - 0
app/report/model/GoodSpec.php

@@ -0,0 +1,22 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\report\model;
+
+use think\Model;
+
+/**
+ * @mixin \think\Model
+ */
+class GoodSpec extends Model
+{
+//    protected $append=["spec_name",'spec_value_name'];
+
+	public function spec(){
+		return $this->belongsTo(Specs::class,"spec_id")->bind(["spec_name"]);
+	}
+	
+	public function SpecInfo(){
+		return $this->belongsTo(SpecValue::class,'spec_value_id')->bind(['spec_value_name'=>'spec_value']);
+	}
+}

+ 16 - 0
app/report/model/GoodStock.php

@@ -0,0 +1,16 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\report\model;
+
+use think\Model;
+
+/**
+ * @mixin \think\Model
+ */
+class GoodStock extends Model
+{
+    public function WareInfo(){
+    	return $this->belongsTo(Ware::class,"wsm_code","wsm_code");
+    }
+}

+ 14 - 0
app/report/model/OrderAddr.php

@@ -0,0 +1,14 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\report\model;
+
+use think\Model;
+
+/**
+ * @mixin \think\Model
+ */
+class OrderAddr extends Model
+{
+    //
+}

+ 14 - 0
app/report/model/SpecValue.php

@@ -0,0 +1,14 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\report\model;
+
+use think\Model;
+
+/**
+ * @mixin \think\Model
+ */
+class SpecValue extends Model
+{
+    //
+}

+ 14 - 0
app/report/model/Specs.php

@@ -0,0 +1,14 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\report\model;
+
+use think\Model;
+
+/**
+ * @mixin \think\Model
+ */
+class Specs extends Model
+{
+    //
+}

+ 14 - 0
app/report/model/Unit.php

@@ -0,0 +1,14 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\report\model;
+
+use think\Model;
+
+/**
+ * @mixin \think\Model
+ */
+class Unit extends Model
+{
+    //
+}