Marketmanage.php 5.7 KB

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