Activitydetail.php 3.0 KB

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