Good.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\admin\model;
  4. use think\Model;
  5. /**
  6. * @mixin \think\Model
  7. */
  8. class Good extends Model
  9. {
  10. public static $status=["待采购设置税务类目","待财务设置税务类目","税务类目设置完成"];
  11. public static $Tax=['','免税','不征税','零税率'];
  12. public static $diff=['未设置','一致','不一致'];
  13. public static $Zx=['成本商品','咨询商品'];
  14. protected $createTime = "addtime";
  15. protected $updateTime = "updatetime";
  16. protected $append=["cgd_to_pay",'qrd_to_pay'];
  17. public function GetCgdToPayAttr($v,$row){
  18. $isT = CgdInfo::Where(["goodNo"=>$row["spuCode"],"status"=>1,"is_del"=>0])->findOrEmpty()->isEmpty();
  19. return $isT==false;
  20. }
  21. public function GetQrdToPayAttr($v,$row){
  22. $isT = InvoiceGood::Where([['goodNo',"=",$row['spuCode']],['goodNum','>',0]])->findOrEmpty()
  23. ->isEmpty();
  24. return $isT==false;
  25. }
  26. public function GetExamInfoAttr($v){
  27. return $v==""?[]:json_decode($v,true);
  28. }
  29. public function GetInvTaxAttr($v){
  30. return $v==''?"": strval($v*100)."%";
  31. }
  32. public function GetCgdInvTaxAttr($v){
  33. return $v==""?'': strval($v*100).'%';
  34. }
  35. public function export($where,$field){
  36. $list= $this->where($where)->field($field)->cursor();
  37. foreach ($list as $item){
  38. $item->append();
  39. if(isset($item['cat_diff'])){
  40. $item['cat_diff']=self::$diff[$item['cat_diff']];
  41. }
  42. if(isset($item['tax_diff'])){
  43. $item['tax_diff']=self::$diff[$item['tax_diff']];
  44. }
  45. if(isset($item['isZx'])){
  46. $item['isZx']=self::$Zx[$item['isZx']];
  47. }
  48. yield $item;
  49. }
  50. }
  51. }