GoodsSpecPriceLists.php 3.8 KB

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