ActivityNewUserController.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. namespace app\modules\admin\controllers;
  8. use app\models\Goods;
  9. use app\models\Option;
  10. use app\constants\OptionSetting;
  11. use app\modules\admin\models\ActivityNewUserForm;
  12. class ActivityNewUserController extends BaseController
  13. {
  14. /**
  15. * @return \yii\web\Response
  16. * 获取列表
  17. */
  18. public function actionList()
  19. {
  20. $form = new ActivityNewUserForm();
  21. $form->attributes = get_params();
  22. $res = $form->search();
  23. return $this->asJson($res);
  24. }
  25. /**
  26. * @return \yii\web\Response
  27. * 保存信息
  28. */
  29. public function actionSave()
  30. {
  31. $form = new ActivityNewUserForm();
  32. $form->attributes = post_params();
  33. $res = $form->save();
  34. return $this->asJson($res);
  35. }
  36. /**
  37. * @return \yii\web\Response
  38. * 获取信息
  39. */
  40. public function actionGetInfo()
  41. {
  42. $form = new ActivityNewUserForm();
  43. $form->attributes = get_params();
  44. $res = $form->getInfo();
  45. return $this->asJson($res);
  46. }
  47. /**
  48. * @return \yii\web\Response
  49. * 获取普通商品
  50. */
  51. public function actionGetGoods()
  52. {
  53. $form = new ActivityNewUserForm();
  54. $form->attributes = get_params();
  55. $res = $form->getGoods();
  56. return $this->asJson($res);
  57. }
  58. /**
  59. * @return \yii\web\Response
  60. * 获取优惠券
  61. */
  62. public function actionGetCoupons()
  63. {
  64. $form = new ActivityNewUserForm();
  65. $form->attributes = get_params();
  66. $res = $form->getCoupons();
  67. return $this->asJson($res);
  68. }
  69. /**
  70. * @return \yii\web\Response
  71. * 修改状态
  72. */
  73. public function actionSetStatus()
  74. {
  75. $form = new ActivityNewUserForm();
  76. $form->attributes = post_params();
  77. $res = $form->setStatus();
  78. return $this->asJson($res);
  79. }
  80. public function actionPushGoods(){
  81. //{'conf':[{'tab':'推荐',goods_ids:[1,2,3],cat_ids:[5,6,7]}]}
  82. $conf = Option::get(OptionSetting::ACTIVITY_NEW_USER_GOODS_CONF, get_store_id(), 'store')['value'];
  83. if($conf){
  84. $conf = json_decode($conf, true);
  85. }else{
  86. $conf = ['conf' => []];
  87. }
  88. foreach($conf['conf'] as &$item){
  89. $item['goods_list'] = [];
  90. if($item['goods_ids'] && is_array($item['goods_ids'])){
  91. $goods_list = Goods::find()->where(['in', 'id', $item['goods_ids']])->all();
  92. $item['goods_list'] = $goods_list;
  93. }
  94. }
  95. return $this->asJson([
  96. 'code'=>0,
  97. 'msg'=>'ok',
  98. 'data' => $conf,
  99. ]);
  100. }
  101. public function actionPushGoodsSave(){
  102. //{'conf':[{'tab':'推荐',goods_ids:[1,2,3],cat_ids:[5,6,7]}]}
  103. $conf = input_params('conf');
  104. if(!is_array($conf)){
  105. $conf = json_decode($conf, true);
  106. }
  107. $data = ['conf' => $conf];
  108. Option::set(OptionSetting::ACTIVITY_NEW_USER_GOODS_CONF, json_encode($data), get_store_id(), 'store');
  109. return $this->asJson([
  110. 'code'=>0,
  111. 'msg'=>'保存成功'
  112. ]);
  113. }
  114. public function actionConf(){
  115. $conf = Option::get(OptionSetting::ACTIVITY_NEW_USER_CONF, get_store_id(), 'store')['value'];
  116. if($conf){
  117. $conf = json_decode($conf, true);
  118. }else{
  119. $conf = ['conf' => [
  120. 'head' => ['bg_color' => '#f00', 'bg_img' => ''],
  121. 'body' => ['bg_color' => '#f00', 'bg_img' => ''],
  122. ]];
  123. }
  124. return $this->asJson([
  125. 'code'=>0,
  126. 'msg'=>'ok',
  127. 'data' => $conf,
  128. ]);
  129. }
  130. public function actionConfSave(){
  131. $conf = input_params('conf');
  132. if(!is_array($conf)){
  133. $conf = json_decode($conf, true);
  134. }
  135. $data = ['conf' => $conf];
  136. Option::set(OptionSetting::ACTIVITY_NEW_USER_CONF, json_encode($data), get_store_id(), 'store');
  137. return $this->asJson([
  138. 'code'=>0,
  139. 'msg'=>'保存成功'
  140. ]);
  141. }
  142. /**
  143. * 联盟审核列表
  144. */
  145. public function actionGetAuditList() {
  146. $form = new ActivityNewUserForm();
  147. $form->attributes = get_params();
  148. $res = $form->auditList();
  149. return $this->asJson($res);
  150. }
  151. /**
  152. * 活动审核状态修改
  153. */
  154. public function actionAuditHandle() {
  155. $form = new ActivityNewUserForm();
  156. $form->attributes = post_params();
  157. $res = $form->auditHandle();
  158. return $this->asJson($res);
  159. }
  160. }