Marketmanage.php 5.6 KB

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