Activitydetail.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. *
  6. *
  7. * ----------------------------------------------------------------------------
  8. *
  9. * 数据层模型
  10. */
  11. class Activitydetail extends BaseModel
  12. {
  13. public $page_info;
  14. /**
  15. * 添加
  16. * @author csdeshang
  17. * @param array $data
  18. * @return bool
  19. */
  20. public function addActivitydetail($data)
  21. {
  22. return Db::name('activitydetail')->insertGetId($data);
  23. }
  24. /**
  25. * 根据条件更新
  26. * @author csdeshang
  27. * @param array $data 更新内容
  28. * @param array $condition 更新条件
  29. * @return bool
  30. */
  31. public function editActivitydetail($data, $condition)
  32. {
  33. return Db::name('activitydetail')->where($condition)->update($data);
  34. }
  35. /**
  36. * 根据条件删除
  37. * @author csdeshang
  38. * @param array $condition 条件数组
  39. * @return bool
  40. */
  41. public function delActivitydetail($condition)
  42. {
  43. return Db::name('activitydetail')->where($condition)->delete();
  44. }
  45. /**
  46. * 根据条件查询活动内容信息
  47. * @author csdeshang
  48. * @param array $condition 查询条件数组
  49. * @param obj $pagesize 分页页数
  50. * @param string $order 排序
  51. * @return array 二维数组
  52. */
  53. public function getActivitydetailList($condition, $pagesize = '', $order = 'activitydetail_sort desc')
  54. {
  55. if ($pagesize) {
  56. $res = Db::name('activitydetail')->where($condition)->order($order)->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false);
  57. $this->page_info = $res;
  58. return $res->items();
  59. } else {
  60. return Db::name('activitydetail')->where($condition)->order($order)->select()->toArray();
  61. }
  62. }
  63. /**
  64. * 根据条件查询活动商品内容信息
  65. * @author csdeshang
  66. * @param array $condition 查询条件数组
  67. * @param obj $pagesize 分页页数
  68. * @param string $order 排序
  69. * @return array 二维数组
  70. */
  71. public function getGoodsJoinList($condition, $pagesize = '', $order = '', $group = '')
  72. {
  73. $field = 'activitydetail.*,goods.*';
  74. $res = Db::name('activitydetail')->alias('activitydetail')->join('goods goods', 'activitydetail.item_id=goods.goods_id')->field($field)->where($condition)->order($order);
  75. if ($group) {
  76. $res = $res->group($group);
  77. }
  78. if ($pagesize) {
  79. $res = $res->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false);
  80. $this->page_info = $res;
  81. return $res->items();
  82. } else {
  83. return $res->select()->toArray();
  84. }
  85. }
  86. }