CardController.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. namespace app\modules\admin\controllers\wechat_mp;
  8. use app\modules\admin\models\wechat_mp\CardForm;
  9. use app\models\Store;
  10. use app\models\Option;
  11. use app\constants\OptionSetting;
  12. use EasyWeChat\Factory;
  13. /**
  14. * Class GoodsController
  15. * @package app\modules\admin\controllers
  16. */
  17. class CardController extends BaseController
  18. {
  19. //用户信息
  20. public function actionUser(){
  21. $params = post_params();
  22. $form = new CardForm();
  23. $res = $form->getUser($params['code'], $params['card_id']);
  24. return $this->asJson($res);
  25. }
  26. //获取开卡插件参数
  27. public function actionUrl(){
  28. $params = post_params();
  29. $form = new CardForm();
  30. $res = $form->getUrl($params['card_id']);
  31. return $this->asJson($res);
  32. }
  33. //卡券列表
  34. public function actionList(){
  35. $params = post_params();
  36. $form = new CardForm();
  37. $store_id = get_store_id();
  38. $res = $form->getCardList($params, $store_id);
  39. return $this->asJson($res);
  40. }
  41. //卡券详情
  42. public function actionInfo(){
  43. $params = post_params();
  44. $form = new CardForm();
  45. $store_id = get_store_id();
  46. $res = $form->getCardInfo($params['card_id']);
  47. return $this->asJson($res);
  48. }
  49. //创建卡券
  50. public function actionCreate(){
  51. $params = post_params();
  52. $form = new CardForm();
  53. $store_id = get_store_id();
  54. $res = $form->addCard($params, $store_id);
  55. return $this->asJson($res);
  56. }
  57. //修改卡券
  58. public function actionUpdate(){
  59. $params = post_params();
  60. $form = new CardForm();
  61. $store_id = get_store_id();
  62. $res = $form->updateCard($params, $store_id);
  63. return $this->asJson($res);
  64. }
  65. //删除卡券
  66. public function actionDelete(){
  67. $params = post_params();
  68. $form = new CardForm();
  69. $res = $form->deleteCard($params['card_id']);
  70. return $this->asJson($res);
  71. }
  72. //绑卡列表
  73. public function actionBindList(){
  74. $params = post_params();
  75. $form = new CardForm();
  76. $store_id = get_store_id();
  77. $res = $form->getBindList($params, $store_id);
  78. return $this->asJson($res);
  79. }
  80. //修改会员信息
  81. public function actionUpdateUserBonus() {
  82. $record_bonus = post_params('record_bonus', '');
  83. $add_bonus = post_params('add_bonus', 1);
  84. $bind_ids = post_params('bind_ids', []);
  85. $form = new CardForm();
  86. $res = $form->batchUpdateUserBonus($bind_ids, [
  87. "record_bonus" => $record_bonus,
  88. "add_bonus" => $add_bonus,
  89. ]);
  90. return $this->asJson($res);
  91. }
  92. //修改会员信息
  93. public function actionUpdateUserBonusByCond() {
  94. $record_bonus = post_params('record_bonus', '');
  95. $add_bonus = post_params('add_bonus', 1);
  96. $store_id = get_store_id();
  97. $cond = post_params('cond', []);
  98. $form = new CardForm();
  99. $res = $form->batchUpdateUserBonus($form->getBindIdList($cond, $store_id), [
  100. "record_bonus" => $record_bonus,
  101. "add_bonus" => $add_bonus,
  102. ]);
  103. return $this->asJson($res);
  104. }
  105. }