| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- <?php
- namespace hd\controllers;
- use biz\shop\classes\ShopClass;
- use biz\sj\services\MerchantExtendService;
- use bizHd\merchant\services\ShopService;
- use common\components\dirUtil;
- use common\components\util;
- use common\components\wxUtil;
- use Yii;
- class ShopController extends BaseController
- {
- //门店列表 shish 20202.2.29
- public function actionList()
- {
- $where = [];
- $where['merchantId'] = $this->sjId;
- $where['delStatus'] = 0;
- $list = ShopService::getShopList($where);
- util::success($list);
- }
- //更新门店 shish 2020.2.29
- public function actionUpdate()
- {
- $data = Yii::$app->request->post();
- $data['merchantId'] = $this->sjId;
- $id = isset($data['id']) ? $data['id'] : 0;
- unset($data['id']);
- $shop = ShopService::getById($id);
- ShopService::valid($shop, $this->sjId);
- ShopService::updateShop($id, $data);
- util::complete();
- }
- public function actionAdd()
- {
- $data = Yii::$app->request->post();
- $data['merchantId'] = $this->sjId;
- ShopService::addShop($data);
- util::complete();
- }
- //下载微信和支付宝收款码 shish 2020.2.29
- public function actionGatheringCode()
- {
- $id = Yii::$app->request->get('id', 0);
- $shop = ShopService::getById($id);
- ShopService::valid($shop, $this->sjId);
- $gatheringCode = ShopService::generateGatheringCode($this->sjId, $id);
- $file = dirUtil::getImgDir() . $gatheringCode;
- if (file_exists($file) == false) {
- util::fail('没有找到收款码');
- }
- $fileName = "门店({$id})收款码.jpg";
- $contentType = 'image/jpeg';
- header("Cache-control: private");
- header("Content-type: $contentType"); //设置要下载的文件类型
- header("Content-Length:" . filesize($file)); //设置要下载文件的文件大小
- header("Content-Disposition: attachment; filename=" . urldecode($fileName)); //设置要下载文件的文件名
- readfile($file);
- }
- //获取小程序的收款码 shish
- public function actionGatheringMiniCode()
- {
- $id = Yii::$app->request->get('id', 0);
- $extend = MerchantExtendService::getByMerchantId($this->sjId);
- if ($extend['miniAuth'] == 0) {
- util::fail('您的小程序还没有授权');
- }
- $shop = ShopService::getById($id);
- ShopService::valid($shop, $this->sjId);
- $applyMemberCode = wxUtil::generateGatheringMiniCode($this->sj, $id);
- $file = dirUtil::getImgDir() . $applyMemberCode;
- if (file_exists($file) == false) {
- util::fail('没有找到注册会员码');
- }
- $fileName = "门店({$id})小程序收款码.jpg";
- $contentType = 'image/jpeg';
- header("Cache-control: private");
- header("Content-type: $contentType"); //设置要下载的文件类型
- header("Content-Length:" . filesize($file)); //设置要下载文件的文件大小
- header("Content-Disposition: attachment; filename=" . urldecode($fileName)); //设置要下载文件的文件名
- readfile($file);
- }
- //下载会员注册码 shish 2020.2.29
- public function actionApplyMemberCode()
- {
- $id = Yii::$app->request->get('id', 0);
- $extend = MerchantExtendService::getByMerchantId($this->sjId);
- if ($extend['miniAuth'] == 0) {
- util::fail('您的小程序还没有授权');
- }
- $shop = ShopService::getById($id);
- ShopService::valid($shop, $this->sjId);
- $applyMemberCode = wxUtil::generateMemberCode($this->sj, $id);
- $file = dirUtil::getImgDir() . $applyMemberCode;
- if (file_exists($file) == false) {
- util::fail('没有找到注册会员码');
- }
- $fileName = "注册会员码{$id}.jpg";
- $contentType = 'image/jpeg';
- header("Cache-control: private");
- header("Content-type: $contentType"); //设置要下载的文件类型
- header("Content-Length:" . filesize($file)); //设置要下载文件的文件大小
- header("Content-Disposition: attachment; filename=" . urldecode($fileName)); //设置要下载文件的文件名
- readfile($file);
- }
- //删除门店 shish 2020.3.1
- public function actionDelete()
- {
- $id = Yii::$app->request->get('id', 0);
- util::fail('功能开发中');
- $shop = ShopService::getById($id);
- ShopService::valid($shop, $this->sjId);
- ShopService::deleteShop($shop);
- util::complete();
- }
- //获取商家的默认门店 shish 2019.12.6
- public function actionDetail()
- {
- $introUserId = Yii::$app->request->get('introUserId');
- //$merchant = $this->sj;
- //$shop = ShopService::getDefaultShop($merchant);
- //$ad = AdService::getValidAdList($this->sjId);
- //新人专享礼物
- $newUserGift = [
- [
- 'adImgUrl' => "https://img.huahb.com/uploads/12358/202006/03/20210120220152.jpg",
- 'adName' => '图片',
- ],
- ];
- if (!empty($introUserId)) {
- //$userInfo = UserService::getUserInfo($this->adminId);
- //$newUserGift = InviteService::hasNewGift($userInfo);
- }
- $ad = [];
- $shop = [
- 'address' => '福建省厦门市思明区后埭溪路128-5号',
- 'telephone' => '15280215347',
- 'openTime' => '09:00--18:00',
- 'shopName' => '国兰花尚',
- 'merchantName' => '国兰花尚2',
- 'introduction' => '门店介绍',
- ];
- util::success(['ad' => $ad, 'shop' => $shop, 'newUserGift' => $newUserGift]);
- }
- //提现信息更新 shish 2021.3.23
- public function actionCashUpdate()
- {
- $get = Yii::$app->request->get();
- $cashAccount = $get['cashAccount'] ?? '';
- $cashName = $get['cashName'] ?? '';
- if (empty($cashName)) {
- util::fail('请填写姓名');
- }
- if (empty($cashAccount)) {
- util::fail('请填写帐号');
- }
- $shopAdmin = $this->shopAdmin;
- $shopId = $shopAdmin['shopId'];
- if ($shopAdmin['super'] != 1) {
- util::fail('您没有权限修改');
- }
- ShopClass::updateById($shopId, ['cashAccount' => $cashAccount, 'cashName' => $cashName]);
- util::complete();
- }
- //获取所有门店linqh 2021.1.31
- public function actionAll()
- {
- $res = [];
- $shopAdmin = $this->shopAdmin;
- if ($shopAdmin['super'] == 1) {
- $res = ShopClass::getAllShop($this->sjId);
- }
- util::success($res);
- }
- }
|