123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- declare (strict_types = 1);
- namespace app\admin\model;
- use think\Model;
- /**
- * @mixin \think\Model
- */
- class Good extends Model
- {
- public static $status=["待采购设置税务类目","待财务设置税务类目","税务类目设置完成"];
- public static $Tax=['','免税','不征税','零税率'];
- public static $diff=['未设置','一致','不一致'];
- public static $Zx=['成本商品','咨询商品'];
- protected $createTime = "addtime";
- protected $updateTime = "updatetime";
- protected $append=["cgd_to_pay",'qrd_to_pay'];
- public function GetCgdToPayAttr($v,$row){
- $isT = CgdInfo::Where(["goodNo"=>$row["spuCode"],"status"=>1,"is_del"=>0])->findOrEmpty()->isEmpty();
- return $isT==false;
- }
-
- public function GetQrdToPayAttr($v,$row){
- $isT = InvoiceGood::Where([['goodNo',"=",$row['spuCode']],['goodNum','>',0]])->findOrEmpty()
- ->isEmpty();
- return $isT==false;
- }
- public function GetExamInfoAttr($v){
- return $v==""?[]:json_decode($v,true);
- }
-
- public function GetInvTaxAttr($v){
- return $v==''?"": strval($v*100)."%";
- }
- public function GetCgdInvTaxAttr($v){
- return $v==""?'': strval($v*100).'%';
- }
- public function GetCgdInvCatCodeAttr($v){
- return $v.' ';
- } public function GetInvCatCodeAttr($v){
- return $v." ";
- }
- public function export($where,$field){
-
- $list= $this->where($where)->field($field)->cursor();
- foreach ($list as $item){
- $item->append();
- if(isset($item['cat_diff'])){
- $item['cat_diff']=self::$diff[$item['cat_diff']];
- }
- if(isset($item['tax_diff'])){
- $item['tax_diff']=self::$diff[$item['tax_diff']];
- }
- if(isset($item['isZx'])){
- $item['isZx']=self::$Zx[$item['isZx']];
- }
- if(isset($item['status'])){
- $item['status']=self::$status[$item['status']];
- }
- yield $item;
- }
- }
- }
|