Good.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 GetCgdInvCatCodeAttr($v){
  36. return $v.' ';
  37. } public function GetInvCatCodeAttr($v){
  38. return $v." ";
  39. }
  40. public function export($where,$field){
  41. $list= $this->where($where)->field($field)->cursor();
  42. foreach ($list as $item){
  43. $item->append();
  44. if(isset($item['cat_diff'])){
  45. $item['cat_diff']=self::$diff[$item['cat_diff']];
  46. }
  47. if(isset($item['tax_diff'])){
  48. $item['tax_diff']=self::$diff[$item['tax_diff']];
  49. }
  50. if(isset($item['isZx'])){
  51. $item['isZx']=self::$Zx[$item['isZx']];
  52. }
  53. if(isset($item['status'])){
  54. $item['status']=self::$status[$item['status']];
  55. }
  56. yield $item;
  57. }
  58. }
  59. }