Activitydetail.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. * ============================================================================
  6. *
  7. * ============================================================================
  8. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  9. * 网站地址: https://www.valimart.net/
  10. * ----------------------------------------------------------------------------
  11. *
  12. * ============================================================================
  13. * 数据层模型
  14. */
  15. class Activitydetail extends BaseModel
  16. {
  17. public $page_info;
  18. /**
  19. * 添加
  20. * @author csdeshang
  21. * @param array $data
  22. * @return bool
  23. */
  24. public function addActivitydetail($data){
  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. return Db::name('activitydetail')->where($condition)->update($data);
  36. }
  37. /**
  38. * 根据条件删除
  39. * @author csdeshang
  40. * @param array $condition 条件数组
  41. * @return bool
  42. */
  43. public function delActivitydetail($condition){
  44. return Db::name('activitydetail')->where($condition)->delete();
  45. }
  46. /**
  47. * 根据条件查询活动内容信息
  48. * @author csdeshang
  49. * @param array $condition 查询条件数组
  50. * @param obj $pagesize 分页页数
  51. * @param string $order 排序
  52. * @return array 二维数组
  53. */
  54. public function getActivitydetailList($condition,$pagesize='',$order='activitydetail_sort desc'){
  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. $field = 'activitydetail.*,goods.*';
  73. $res=Db::name('activitydetail')->alias('activitydetail')->join('goods goods','activitydetail.item_id=goods.goods_id')->field($field)->where($condition)->order($order);
  74. if($group){
  75. $res=$res->group($group);
  76. }
  77. if ($pagesize) {
  78. $res=$res->paginate(['list_rows'=>$pagesize,'query' => request()->param()],false);
  79. $this->page_info=$res;
  80. return $res->items();
  81. }else{
  82. return $res->select()->toArray();
  83. }
  84. }
  85. }