GoodsBrand.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
  9. * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
  10. * =========================================================
  11. */
  12. namespace app\model\goods;
  13. use app\model\BaseModel;
  14. /**
  15. * 商品品牌
  16. */
  17. class GoodsBrand extends BaseModel
  18. {
  19. /**
  20. * 添加品牌
  21. * @param array $data
  22. */
  23. public function addBrand($data)
  24. {
  25. $data[ 'create_time' ] = time();
  26. $brand_id = model('goods_brand')->add($data);
  27. return $this->success($brand_id);
  28. }
  29. /**
  30. * 修改品牌
  31. * @param $data
  32. * @param $condition
  33. * @return array
  34. */
  35. public function editBrand($data, $condition)
  36. {
  37. $res = model('goods_brand')->update($data, $condition);
  38. return $this->success($res);
  39. }
  40. /**
  41. * 删除品牌
  42. * @param array $condition
  43. */
  44. public function deleteBrand($condition)
  45. {
  46. $res = model('goods_brand')->delete($condition);
  47. return $this->success($res);
  48. }
  49. /**
  50. * 修改排序
  51. * @param int $sort
  52. * @param int $brand_id
  53. */
  54. public function modifyBrandSort($sort, $condition)
  55. {
  56. $res = model('goods_brand')->update([ 'sort' => $sort ], $condition);
  57. return $this->success($res);
  58. }
  59. /**
  60. * 获取品牌信息
  61. * @param array $condition
  62. * @param string $field
  63. */
  64. public function getBrandInfo($condition, $field = 'brand_id, brand_name, brand_initial, image_url, sort, create_time, is_recommend')
  65. {
  66. $res = model('goods_brand')->getInfo($condition, $field);
  67. return $this->success($res);
  68. }
  69. /**
  70. * 获取品牌列表
  71. * @param array $condition
  72. * @param string $field
  73. * @param string $order
  74. * @param string $limit
  75. */
  76. public function getBrandList($condition = [], $field = 'brand_id, brand_name, brand_initial, image_url, sort, create_time', $order = '', $limit = null)
  77. {
  78. $list = model('goods_brand')->getList($condition, $field, $order, '', '', '', $limit);
  79. return $this->success($list);
  80. }
  81. /**
  82. * 获取品牌分页列表
  83. * @param array $condition
  84. * @param number $page
  85. * @param string $page_size
  86. * @param string $order
  87. * @param string $field
  88. */
  89. public function getBrandPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'ngb.create_time desc', $field = 'ngb.brand_id,ngb.brand_name,ngb.brand_initial,ngb.image_url,ngb.sort,ngb.create_time,ngb.is_recommend,ngb.site_id,ns.site_name,nsp.title as supply_name')
  90. {
  91. $list = model('goods_brand')->pageList($condition, $field, $order, $page, $page_size, '', '');
  92. return $this->success($list);
  93. }
  94. }