GoodsSpecPriceLists.php 4.0 KB

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