Marketmanage.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. *
  6. *
  7. * ----------------------------------------------------------------------------
  8. *
  9. * 刮刮卡模型层
  10. */
  11. class Marketmanage extends BaseModel
  12. {
  13. /**
  14. * 营销活动列表
  15. * @author csdeshang
  16. * @param array $condition 检索条件
  17. * @param array $pagesize 分页信息
  18. * @return array 数组类型的返回结果
  19. */
  20. public function getMarketmanageList($condition, $pagesize, $limit = 0, $order = 'marketmanage_id desc')
  21. {
  22. if ($pagesize) {
  23. $result = Db::name('marketmanage')->where($condition)->order($order)->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false);
  24. $this->page_info = $result;
  25. return $result->items();
  26. } else {
  27. $result = Db::name('marketmanage')->where($condition)->order($order)->limit($limit)->select()->toArray();
  28. return $result;
  29. }
  30. }
  31. /**
  32. * 取单个营销活动的内容
  33. * @author csdeshang
  34. * @param array $condition 检索条件
  35. * @return array 数组类型的返回结果
  36. */
  37. public function getOneMarketmanage($condition, $lock = false)
  38. {
  39. return Db::name('marketmanage')->where($condition)->lock($lock)->find();
  40. }
  41. /**
  42. * 新增
  43. * @author csdeshang
  44. * @param array $data 参数内容
  45. * @return bool 布尔类型的返回结果
  46. */
  47. public function addMarketmanage($data)
  48. {
  49. if (empty($data)) {
  50. return false;
  51. }
  52. return Db::name('marketmanage')->insertGetId($data);
  53. }
  54. /**
  55. * 更新信息
  56. * @author csdeshang
  57. * @param array $condition 条件
  58. * @param array $data 更新数据
  59. * @return bool 布尔类型的返回结果
  60. */
  61. public function editMarketmanage($condition, $data)
  62. {
  63. if (empty($data)) {
  64. return false;
  65. }
  66. return Db::name('marketmanage')->where($condition)->update($data);
  67. }
  68. /**
  69. * 删除
  70. * @author csdeshang
  71. * @param array $marketmanage_id 检索条件
  72. * @return array $rs_row 返回数组形式的查询结果
  73. */
  74. public function delMarketmanage($marketmanage_id)
  75. {
  76. //删除主表
  77. $result = Db::name('marketmanage')->where('marketmanage_id', $marketmanage_id)->delete();
  78. //删除奖品表
  79. Db::name('marketmanageaward')->where('marketmanage_id', $marketmanage_id)->delete();
  80. //删除领取记录表
  81. Db::name('marketmanagelog')->where('marketmanage_id', $marketmanage_id)->delete();
  82. return $result;
  83. }
  84. /**
  85. * 新增营销活动奖品信息
  86. * @author csdeshang
  87. * @param array $data 更新信息
  88. * @return array 数组类型的返回结果
  89. */
  90. public function addMarketmanageAward($data)
  91. {
  92. if (empty($data)) {
  93. return false;
  94. }
  95. $result = Db::name('marketmanageaward')->insertGetId($data);
  96. return $result;
  97. }
  98. /**
  99. * 更新营销活动奖品信息
  100. * @author csdeshang
  101. * @param array $condition 检索条件
  102. * @param array $data 更新信息
  103. * @return array 数组类型的返回结果
  104. */
  105. public function editMarketmanageAward($condition, $data)
  106. {
  107. if (empty($data)) {
  108. return false;
  109. }
  110. $result = Db::name('marketmanageaward')->where($condition)->update($data);
  111. return $result;
  112. }
  113. /**
  114. * 营销活动奖品记录
  115. * @author csdeshang
  116. * @param array $condition 检索条件
  117. * @param array $pagesize 分页信息
  118. * @return array 数组类型的返回结果
  119. */
  120. public function getMarketmanageAwardList($condition, $lock = false)
  121. {
  122. $result = Db::name('marketmanageaward')->where($condition)->order('marketmanageaward_level asc')->lock($lock)->select()->toArray();
  123. return $result;
  124. }
  125. /**
  126. * 新增营销活动参与记录
  127. * @author csdeshang
  128. * @param array $data 信息
  129. * @return array 数组类型的返回结果
  130. */
  131. public function addMarketmanageLog($data)
  132. {
  133. if (empty($data)) {
  134. return false;
  135. }
  136. $result = Db::name('marketmanagelog')->insertGetId($data);
  137. return $result;
  138. }
  139. /**
  140. * 营销活动参与记录列表
  141. * @author csdeshang
  142. * @param array $condition 检索条件
  143. * @param array $pagesize 分页信息
  144. * @return array 数组类型的返回结果
  145. */
  146. public function getMarketmanageLogList($condition, $pagesize = '', $limit = 0)
  147. {
  148. if ($pagesize) {
  149. $result = Db::name('marketmanagelog')->where($condition)->order('marketmanagelog_id desc')->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false);
  150. $this->page_info = $result;
  151. return $result->items();
  152. } else {
  153. $result = Db::name('marketmanagelog')->where($condition)->order('marketmanagelog_id desc')->limit($limit)->select()->toArray();
  154. return $result;
  155. }
  156. }
  157. //营销活动类型
  158. public function marketmanage_type_list()
  159. {
  160. return array(
  161. 1 => '刮刮卡',
  162. 2 => '大转盘',
  163. 3 => '砸金蛋',
  164. 4 => '生肖翻翻看',
  165. );
  166. }
  167. }