GoodsGatherLog.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop开源商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | gitee下载:https://gitee.com/likeshop_gitee
  7. // | github下载:https://github.com/likeshop-github
  8. // | 访问官网:https://www.likeshop.cn
  9. // | 访问社区:https://home.likeshop.cn
  10. // | 访问手册:http://doc.likeshop.cn
  11. // | 微信公众号:likeshop技术社区
  12. // | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
  13. // | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
  14. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  15. // | likeshop团队版权所有并拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshop.cn.team
  18. // +----------------------------------------------------------------------
  19. namespace app\common\model;
  20. use app\common\enum\GoodsEnum;
  21. use app\common\enum\YesNoEnum;
  22. use think\model\concern\SoftDelete;
  23. class GoodsGatherLog extends BaseModel
  24. {
  25. use SoftDelete;
  26. protected $deleteTime = 'delete_time';
  27. /**
  28. * @notes 商品类型
  29. * @param $value
  30. * @param $data
  31. * @return array|mixed|string|string[]
  32. * @author ljj
  33. * @date 2023/3/13 3:12 下午
  34. */
  35. public function getGoodsTypeDescAttr($value,$data)
  36. {
  37. return GoodsEnum::getGoodsTypeDesc($data['goods_type']);
  38. }
  39. /**
  40. * @notes 商品分类
  41. * @param $value
  42. * @param $data
  43. * @return array|mixed|string|string[]
  44. * @author ljj
  45. * @date 2023/3/13 3:12 下午
  46. */
  47. public function getGoodsCategoryDescAttr($value,$data)
  48. {
  49. $result = GoodsCategory::where('id',$data['goods_category'])->findOrEmpty()->toArray();
  50. if (empty($result)) {
  51. return '';
  52. }
  53. $name_arr[] = $result['name'];
  54. if ($result['pid'] > 0) {
  55. $result = GoodsCategory::where('id',$result['pid'])->findOrEmpty()->toArray();
  56. $name_arr[] = $result['name'];
  57. if ($result['pid'] > 0) {
  58. $result = GoodsCategory::where('id',$result['pid'])->findOrEmpty()->toArray();
  59. $name_arr[] = $result['name'];
  60. }
  61. }
  62. return implode('/',$name_arr);
  63. }
  64. /**
  65. * @notes 采集数
  66. * @param $value
  67. * @param $data
  68. * @return int
  69. * @author ljj
  70. * @date 2023/3/13 3:20 下午
  71. */
  72. public function getGatherNumAttr($value,$data)
  73. {
  74. return GoodsGather::where(['log_id'=>$data['id']])->count();
  75. }
  76. /**
  77. * @notes 采集成功数
  78. * @param $value
  79. * @param $data
  80. * @return int
  81. * @author ljj
  82. * @date 2023/3/13 3:20 下午
  83. */
  84. public function getGatherSuccessNumAttr($value,$data)
  85. {
  86. return GoodsGather::where(['log_id'=>$data['id'],'gather_status'=>YesNoEnum::YES])->count();
  87. }
  88. /**
  89. * @notes 采集失败数
  90. * @param $value
  91. * @param $data
  92. * @return int
  93. * @author ljj
  94. * @date 2023/3/13 3:20 下午
  95. */
  96. public function getGatherFailNumAttr($value,$data)
  97. {
  98. return GoodsGather::where(['log_id'=>$data['id'],'gather_status'=>YesNoEnum::NO])->count();
  99. }
  100. }