GoodsSpecPriceLists.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop100%开源免费商用商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | 商业版本务必购买商业授权,以免引起法律纠纷
  8. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  9. // | gitee下载:https://gitee.com/likeshop_gitee
  10. // | github下载:https://github.com/likeshop-github
  11. // | 访问官网:https://www.likeshop.cn
  12. // | 访问社区:https://home.likeshop.cn
  13. // | 访问手册:http://doc.likeshop.cn
  14. // | 微信公众号:likeshop技术社区
  15. // | likeshop团队 版权所有 拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshopTeam
  18. // +----------------------------------------------------------------------
  19. namespace app\adminapi\lists\goods;
  20. use app\adminapi\lists\BaseAdminDataLists;
  21. use app\common\lists\ListsExcelInterface;
  22. use app\common\lists\ListsSearchInterface;
  23. use app\common\model\Goods;
  24. use app\common\model\GoodsItem;
  25. /**
  26. * 商品规格价格列表
  27. * Class GoodsSpecPriceLists
  28. * @package app\adminapi\lists\goods
  29. */
  30. class GoodsSpecPriceLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExcelInterface
  31. {
  32. /**
  33. * @notes 搜索条件
  34. * @return array
  35. * @author
  36. * @date 2024/01/01 00:00
  37. */
  38. public function setSearch(): array
  39. {
  40. return array_intersect(array_keys($this->params), [
  41. 'bar_code', 'keyword', 'category_id', 'supplier_id', 'goods_type', 'status'
  42. ]);
  43. }
  44. /**
  45. * @notes 获取商品规格价格列表
  46. * @return array
  47. * @author
  48. * @date 2024/01/01 00:00
  49. */
  50. public function lists(): array
  51. {
  52. $lists = Goods::alias('g')
  53. ->leftJoin('goods_item gi', 'g.id = gi.goods_id')
  54. ->withSearch($this->setSearch(), $this->params)
  55. ->where('g.delete_time', null)
  56. ->field([
  57. 'g.id as goods_id',
  58. 'g.code as goods_code',
  59. 'g.name as goods_name',
  60. 'gi.id as item_id',
  61. 'gi.spec_value_str',
  62. 'gi.sell_price',
  63. 'gi.lineation_price',
  64. 'gi.cost_price',
  65. 'gi.stock',
  66. 'gi.weight',
  67. 'gi.volume'
  68. ])
  69. ->limit($this->limitOffset, $this->limitLength)
  70. ->order('g.id desc, gi.id asc')
  71. ->select()
  72. ->toArray();
  73. return $lists;
  74. }
  75. /**
  76. * @notes 获取数量
  77. * @return int
  78. * @author
  79. * @date 2024/01/01 00:00
  80. */
  81. public function count(): int
  82. {
  83. return Goods::alias('g')
  84. ->leftJoin('goods_item gi', 'g.id = gi.goods_id')
  85. ->withSearch($this->setSearch(), $this->params)
  86. ->where('g.delete_time', null)
  87. ->count();
  88. }
  89. /**
  90. * @notes 设置导出字段
  91. * @return array
  92. * @author
  93. * @date 2024/01/01 00:00
  94. */
  95. public function setExcelFields(): array
  96. {
  97. return [
  98. 'goods_id' => '商品ID',
  99. 'goods_code' => '商品编码',
  100. 'goods_name' => '商品名称',
  101. 'item_id' => '规格ID',
  102. 'spec_value_str' => '规格名称',
  103. 'sell_price' => '销售价格',
  104. 'lineation_price' => '划线价格',
  105. 'cost_price' => '成本价格',
  106. 'stock' => '库存数量',
  107. 'weight' => '重量(kg)',
  108. 'volume' => '体积(m³)'
  109. ];
  110. }
  111. /**
  112. * @notes 设置文件名
  113. * @return string
  114. * @author
  115. * @date 2024/01/01 00:00
  116. */
  117. public function setFileName(): string
  118. {
  119. return '商品规格价格';
  120. }
  121. }