ShopController.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. /*
  8. * @Author: your name
  9. * @Date: 2021-04-26 13:35:02
  10. * @LastEditTime: 2021-05-20 15:27:11
  11. * @LastEditors: Please set LastEditors
  12. * @Description: In User Settings Edit
  13. * @FilePath: \admin_php\modules\client\controllers\v1\ShopController.php
  14. */
  15. namespace app\modules\client\controllers\v1;
  16. use app\models\Cash;
  17. use app\models\District;
  18. use app\models\Option;
  19. use app\models\Shop;
  20. use app\models\User;
  21. use app\modules\client\behaviors\Auth;
  22. use app\modules\client\controllers\BaseController;
  23. use app\modules\client\models\v1\CashForm;
  24. use app\modules\client\models\v1\ShopAdminForm;
  25. use app\modules\client\models\v1\ShopApplyForm;
  26. use app\modules\client\models\v1\ShopClerkForm;
  27. use app\modules\client\models\v1\ShopListForm;
  28. use app\utils\Notice\NoticeAction;
  29. use yii\helpers\Json;
  30. class ShopController extends BaseController
  31. {
  32. public function behaviors()
  33. {
  34. return parent::behaviors();
  35. }
  36. /**
  37. * 获取自提点审核状态
  38. */
  39. public function actionApply()
  40. {
  41. $shop = Shop::findOne(['user_id' => get_user_id(), 'store_id' => get_store_id(), 'is_delete' => 0]);
  42. if (empty($shop)) {
  43. $shop = new Shop();
  44. } else {
  45. $shop = $shop->toArray();
  46. $shop['province_name'] = District::findOne($shop['province'])->name;
  47. $shop['city_name'] = District::findOne($shop['city'])->name;
  48. $shop['district_name'] = District::findOne($shop['district'])->name;
  49. }
  50. return $this->asJson([
  51. 'code' => 0,
  52. 'data' => [
  53. 'shop' => $shop
  54. ]
  55. ]);
  56. }
  57. /**
  58. * 保存审核数据
  59. */
  60. public function actionApplySubmit()
  61. {
  62. $form = new ShopApplyForm();
  63. $form->attributes = post_params();
  64. return $this->asJson($form->search());
  65. }
  66. /**
  67. * 后台数据
  68. */
  69. public function actionAdmin()
  70. {
  71. $form = new ShopAdminForm();
  72. return $this->asJson($form->search());
  73. }
  74. /**
  75. * 订单数据
  76. */
  77. public function actionOrder()
  78. {
  79. $form = new ShopAdminForm();
  80. $form->status = get_params('status', -1);
  81. $form->page = get_params('page', 1);
  82. return $this->asJson($form->order());
  83. }
  84. /**
  85. * 附近门店
  86. */
  87. public function actionNearby()
  88. {
  89. $form = new ShopListForm();
  90. $form->page = get_params('page', 1);
  91. $form->longitude = get_params('longitude', 1);
  92. $form->latitude = get_params('latitude', 1);
  93. return $this->asJson($form->search());
  94. }
  95. /**
  96. * 附近门店
  97. */
  98. public function actionInfo()
  99. {
  100. $id = get_params('id', 0);
  101. $shop = Shop::findOne([
  102. 'id' => $id,
  103. 'shop_audit' => 1
  104. ]);
  105. return $this->asJson([
  106. 'code' => 0,
  107. 'data' => [
  108. 'shop' => $shop
  109. ]
  110. ]);
  111. }
  112. /**
  113. * 订单确认收货
  114. */
  115. public function actionConfirm()
  116. {
  117. $form = new ShopAdminForm();
  118. return $this->asJson($form->confirm(get_params('order_id')));
  119. }
  120. /**
  121. * 订单确认收货
  122. */
  123. public function actionClerk()
  124. {
  125. $form = new ShopClerkForm();
  126. $form->attributes = get_params();
  127. return $this->asJson($form->search());
  128. }
  129. /**
  130. * 核销卡预览
  131. */
  132. public function actionCardInfo()
  133. {
  134. $form = new ShopClerkForm();
  135. return $this->asJson($form->cardInfo(get_params('id', 0)));
  136. }
  137. /**
  138. * 核销卡核销
  139. */
  140. public function actionCardClerk()
  141. {
  142. $form = new ShopClerkForm();
  143. $form->num = get_params('num', 1);
  144. return $this->asJson($form->cardClerk(get_params('id', 0)));
  145. }
  146. /**
  147. * 提现预览
  148. */
  149. public function actionCash()
  150. {
  151. $cash_type = get_params('cash_type', 1);
  152. $cash = Cash::findOne(['status' => 0, 'user_id' => get_user_id(), 'cash_type' => $cash_type]);
  153. $user = User::findOne(get_user_id());
  154. $resInfo = CashForm::getPayTyle();
  155. if ($cash_type == 0) {
  156. // 分销商提现
  157. $resInfo['cash_price'] = $user->price;
  158. } else {
  159. // 自提点提现
  160. $resInfo['cash_price'] = $user->tuan_price;
  161. }
  162. $setting = Option::get('share_basic_setting', $this->store_id);
  163. $setting = $setting ? Json::decode($setting['value']) : [];
  164. $resInfo['cash_max_day'] = floatval($setting['cash_max_day']['value']);
  165. $res = [
  166. 'code' => 0,
  167. 'data' => $resInfo,
  168. 'is_exist' => $cash ? 1 : 0,
  169. 'template_id' => NoticeAction::getSendTamplateId(['cash_success', 'cash_fail'])
  170. ];
  171. return $this->asJson($res);
  172. }
  173. /**
  174. * 提交提现
  175. */
  176. public function actionCashSubmit()
  177. {
  178. $form = new CashForm();
  179. $form->user_id = get_user_id();
  180. $form->store_id = get_store_id();
  181. $form->cash_type = get_params('cash_type', 1); // 0: 分销商提现, 1:自提点提现
  182. $form->attributes = get_params();
  183. return $this->asJson($form->save());
  184. }
  185. /**
  186. * 通知取货
  187. */
  188. public function actionSmsSend()
  189. {
  190. $form = new ShopAdminForm();
  191. return $this->asJson($form->smsSend());
  192. }
  193. }