| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- /*
- * @Author: your name
- * @Date: 2021-04-26 13:35:02
- * @LastEditTime: 2021-05-20 15:27:11
- * @LastEditors: Please set LastEditors
- * @Description: In User Settings Edit
- * @FilePath: \admin_php\modules\client\controllers\v1\ShopController.php
- */
- namespace app\modules\client\controllers\v1;
- use app\models\Cash;
- use app\models\District;
- use app\models\Option;
- use app\models\Shop;
- use app\models\User;
- use app\modules\client\behaviors\Auth;
- use app\modules\client\controllers\BaseController;
- use app\modules\client\models\v1\CashForm;
- use app\modules\client\models\v1\ShopAdminForm;
- use app\modules\client\models\v1\ShopApplyForm;
- use app\modules\client\models\v1\ShopClerkForm;
- use app\modules\client\models\v1\ShopListForm;
- use app\utils\Notice\NoticeAction;
- use yii\helpers\Json;
- class ShopController extends BaseController
- {
- public function behaviors()
- {
- return parent::behaviors();
- }
- /**
- * 获取自提点审核状态
- */
- public function actionApply()
- {
- $shop = Shop::findOne(['user_id' => get_user_id(), 'store_id' => get_store_id(), 'is_delete' => 0]);
- if (empty($shop)) {
- $shop = new Shop();
- } else {
- $shop = $shop->toArray();
- $shop['province_name'] = District::findOne($shop['province'])->name;
- $shop['city_name'] = District::findOne($shop['city'])->name;
- $shop['district_name'] = District::findOne($shop['district'])->name;
- }
- return $this->asJson([
- 'code' => 0,
- 'data' => [
- 'shop' => $shop
- ]
- ]);
- }
- /**
- * 保存审核数据
- */
- public function actionApplySubmit()
- {
- $form = new ShopApplyForm();
- $form->attributes = post_params();
- return $this->asJson($form->search());
- }
-
- /**
- * 后台数据
- */
- public function actionAdmin()
- {
- $form = new ShopAdminForm();
- return $this->asJson($form->search());
- }
- /**
- * 订单数据
- */
- public function actionOrder()
- {
- $form = new ShopAdminForm();
- $form->status = get_params('status', -1);
- $form->page = get_params('page', 1);
- return $this->asJson($form->order());
- }
- /**
- * 附近门店
- */
- public function actionNearby()
- {
- $form = new ShopListForm();
- $form->page = get_params('page', 1);
- $form->longitude = get_params('longitude', 1);
- $form->latitude = get_params('latitude', 1);
- return $this->asJson($form->search());
- }
- /**
- * 附近门店
- */
- public function actionInfo()
- {
- $id = get_params('id', 0);
- $shop = Shop::findOne([
- 'id' => $id,
- 'shop_audit' => 1
- ]);
- return $this->asJson([
- 'code' => 0,
- 'data' => [
- 'shop' => $shop
- ]
- ]);
- }
- /**
- * 订单确认收货
- */
- public function actionConfirm()
- {
- $form = new ShopAdminForm();
- return $this->asJson($form->confirm(get_params('order_id')));
- }
- /**
- * 订单确认收货
- */
- public function actionClerk()
- {
- $form = new ShopClerkForm();
- $form->attributes = get_params();
- return $this->asJson($form->search());
- }
- /**
- * 核销卡预览
- */
- public function actionCardInfo()
- {
- $form = new ShopClerkForm();
- return $this->asJson($form->cardInfo(get_params('id', 0)));
- }
- /**
- * 核销卡核销
- */
- public function actionCardClerk()
- {
- $form = new ShopClerkForm();
- $form->num = get_params('num', 1);
- return $this->asJson($form->cardClerk(get_params('id', 0)));
- }
- /**
- * 提现预览
- */
- public function actionCash()
- {
- $cash_type = get_params('cash_type', 1);
- $cash = Cash::findOne(['status' => 0, 'user_id' => get_user_id(), 'cash_type' => $cash_type]);
- $user = User::findOne(get_user_id());
- $resInfo = CashForm::getPayTyle();
- if ($cash_type == 0) {
- // 分销商提现
- $resInfo['cash_price'] = $user->price;
- } else {
- // 自提点提现
- $resInfo['cash_price'] = $user->tuan_price;
- }
- $setting = Option::get('share_basic_setting', $this->store_id);
- $setting = $setting ? Json::decode($setting['value']) : [];
- $resInfo['cash_max_day'] = floatval($setting['cash_max_day']['value']);
- $res = [
- 'code' => 0,
- 'data' => $resInfo,
- 'is_exist' => $cash ? 1 : 0,
- 'template_id' => NoticeAction::getSendTamplateId(['cash_success', 'cash_fail'])
- ];
- return $this->asJson($res);
- }
- /**
- * 提交提现
- */
- public function actionCashSubmit()
- {
- $form = new CashForm();
- $form->user_id = get_user_id();
- $form->store_id = get_store_id();
- $form->cash_type = get_params('cash_type', 1); // 0: 分销商提现, 1:自提点提现
- $form->attributes = get_params();
- return $this->asJson($form->save());
- }
- /**
- * 通知取货
- */
- public function actionSmsSend()
- {
- $form = new ShopAdminForm();
- return $this->asJson($form->smsSend());
- }
- }
|