GoodsSpecPriceLists.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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 [
  41. '=' => ['g.id', 'g.category_id', 'g.status', 'g.supplier_id', 'g.goods_type'],
  42. 'like' => ['g.name', 'g.code', 'gi.bar_code'],
  43. 'between_time' => ['g.create_time'],
  44. ];
  45. }
  46. /**
  47. * @notes 获取商品规格价格列表
  48. * @return array
  49. * @author
  50. * @date 2024/01/01 00:00
  51. */
  52. public function lists(): array
  53. {
  54. $lists = GoodsItem::alias('gi')
  55. ->leftJoin('goods g', 'g.id = gi.goods_id')
  56. ->where($this->searchWhere)
  57. ->where('g.delete_time', null)
  58. ->field([
  59. 'g.id as goods_id',
  60. 'g.code as goods_code',
  61. 'g.name as goods_name',
  62. 'gi.id as item_id',
  63. 'gi.spec_value_str',
  64. 'gi.sell_price',
  65. 'gi.lineation_price',
  66. 'gi.cost_price',
  67. 'gi.stock',
  68. 'gi.weight',
  69. 'gi.volume'
  70. ])
  71. ->limit($this->limitOffset, $this->limitLength)
  72. ->order('g.id desc, gi.id asc')
  73. ->select()
  74. ->toArray();
  75. return $lists;
  76. }
  77. /**
  78. * @notes 获取数量
  79. * @return int
  80. * @author
  81. * @date 2024/01/01 00:00
  82. */
  83. public function count(): int
  84. {
  85. return GoodsItem::alias('gi')
  86. ->leftJoin('goods g', 'g.id = gi.goods_id')
  87. ->where($this->searchWhere)
  88. ->where('g.delete_time', null)
  89. ->count();
  90. }
  91. /**
  92. * @notes 设置导出字段
  93. * @return array
  94. * @author
  95. * @date 2024/01/01 00:00
  96. */
  97. public function setExcelFields(): array
  98. {
  99. return [
  100. 'goods_id' => '商品ID',
  101. 'goods_code' => '商品编码',
  102. 'goods_name' => '商品名称',
  103. 'item_id' => '规格ID',
  104. 'spec_value_str' => '规格名称',
  105. 'sell_price' => '销售价格',
  106. 'lineation_price' => '划线价格',
  107. 'cost_price' => '成本价格',
  108. 'stock' => '库存数量',
  109. 'weight' => '重量(kg)',
  110. 'volume' => '体积(m³)'
  111. ];
  112. }
  113. /**
  114. * @notes 设置文件名
  115. * @return string
  116. * @author
  117. * @date 2024/01/01 00:00
  118. */
  119. public function setFileName(): string
  120. {
  121. return '商品规格价格';
  122. }
  123. }