shop); } //门店列表 ssh 20202.2.29 public function actionList() { $where = []; $where['sjId'] = $this->sjId; $where['delStatus'] = 0; $list = \bizHd\shop\classes\ShopClass::getShopList($where); util::success($list); } //更新门店 ssh 2020.2.29 public function actionUpdate() { $data = Yii::$app->request->post(); $data['sjId'] = $this->sjId; $id = isset($data['id']) ? $data['id'] : 0; unset($data['id']); $shop = ShopService::getById($id); ShopService::valid($shop, $this->sjId); $data['img'] = isset($data['img']) && is_array($data['img']) ? json_encode($data['img']) : ''; ShopClass::updateShop($shop, $data); util::complete(); } public function actionAdd() { $data = Yii::$app->request->post(); $data['sjId'] = $this->sjId; $data['shopId'] = $this->shopId; if (isset($data['shopName']) == false || empty($data['shopName'])) { util::fail('请填写门店名称'); } $sj = $this->sj; $sjName = $sj->name ?? ''; $data['merchantName'] = $sjName; $ptStyle = $sj->style ?? dict::getDict('ptStyle', 'hd'); $data['ptStyle'] = $ptStyle; $connection = Yii::$app->db; $transaction = $connection->beginTransaction(); try { $mobile = $data['mobile'] ?? 0; if (stringUtil::isMobile($mobile) == false) { util::fail('请填写正确手机号'); } $adminInfo = ['name' => $mobile, 'mobile' => $mobile]; $fromApp = dict::getDict('userSourceGetId', 'app', 'id'); $admin = AdminClass::replaceAdmin($adminInfo, $fromApp); $adminId = $admin['id'] ?? 0; $data['adminId'] = $adminId; \bizHd\shop\classes\ShopClass::addMainShop($data, $this->shop, $this->sj); $transaction->commit(); util::complete(); } catch (\Exception $exception) { $transaction->rollBack(); util::fail(); } } //切换门店 lqh 2021.1.31 public function actionToggleShop() { $newShopId = Yii::$app->request->post('shopId', 0); $newShop = ShopClass::getById($newShopId, true); if (empty($newShop)) { util::fail('没有找到门店'); } $res = \bizHd\admin\classes\AdminClass::toggleShop($this->admin, $newShop, $this->sjId, $this->shopAdmin); util::success($res); } //下载微信和支付宝收款码 ssh 2020.2.29 public function actionGatheringCode() { $id = Yii::$app->request->get('id', 0); $shop = ShopService::getById($id, true); if (empty($shop)) { util::fail('没有找到门店'); } ShopClass::valid($shop->attributes, $this->sjId); $imgUrl = ShopClass::generateGatheringCode($this->sjId, $id); $shopName = $shop->shopName ?? ''; $file = fopen($imgUrl, "rb"); Header("Content-type: application/octet-stream "); Header("Accept-Ranges: bytes "); Header("Content-Disposition: attachment;filename={$shopName}收款码.jpg"); $contents = ""; while (!feof($file)) { $contents .= fread($file, 8192); } echo $contents; fclose($file); } //获取二维码 public function actionGetGatheringCodeUrl() { $id = Yii::$app->request->get('id', 0); $shop = ShopService::getById($id, true); if (empty($shop)) { util::fail('没有找到门店'); } ShopClass::valid($shop->attributes, $this->sjId); $imgUrl = Yii::$app->params['hdHost'] . '/auth/gathering-img-url?id=' . $id; util::success(['url' => $imgUrl]); } public function actionGatheringImgUrl() { $id = Yii::$app->request->get('id', 0); $shop = ShopService::getById($id, true); if (empty($shop)) { util::fail('没有找到门店'); } $sjId = $shop->sjId; $imgUrl = ShopClass::generateGatheringCode($sjId, $id); $fileResource = file_get_contents($imgUrl); header('Content-type: image/jpeg'); echo $fileResource; } //获取小程序的收款码 ssh public function actionGatheringMiniCode() { $id = Yii::$app->request->get('id', 0); $extend = MerchantExtendService::getBySjId($this->sjId); if ($extend['miniAuth'] == 0) { util::fail('您的小程序还没有授权'); } $shop = ShopService::getById($id); ShopService::valid($shop, $this->sjId); $applyMemberCode = wxUtil::generateGatheringMiniCode($this->sj->attributes, $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); } //下载会员注册码 ssh 2020.2.29 public function actionApplyMemberCode() { $id = Yii::$app->request->get('id', 0); $extend = MerchantExtendService::getBySjId($this->sjId); if ($extend['miniAuth'] == 0) { util::fail('您的小程序还没有授权'); } $shop = ShopService::getById($id); ShopService::valid($shop, $this->sjId); $applyMemberCode = wxUtil::generateMemberCode($this->sj->attributes, $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); } //删除门店 ssh 2020.3.1 public function actionDelete() { util::fail('禁止操作'); $id = Yii::$app->request->get('id', 0); util::fail('功能开发中'); $shop = ShopService::getById($id); ShopService::valid($shop, $this->sjId); ShopService::deleteShop($shop); util::complete(); } //获取门店详情 ssh 2021.4.23 public function actionDetail() { $shopId = Yii::$app->request->get('shopId'); if (empty($shopId)) { $shopId = $this->shopId; } $shop = ShopClass::getShopInfo($shopId); util::success(['info' => $shop]); } //提现信息更新 ssh 2021.3.23 public function actionCashUpdate() { $get = Yii::$app->request->get(); $cashAccount = $get['cashAccount'] ?? ''; $cashName = $get['cashName'] ?? ''; $cashBank = $get['cashBank'] ?? ''; if (empty($cashName)) { util::fail('请填写姓名'); } if (empty($cashAccount)) { util::fail('请填写银行卡号'); } if (empty($cashBank)) { util::fail('请输入开户行'); } $shopAdmin = $this->shopAdmin; $shopId = $shopAdmin->shopId ?? 0; if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) { util::fail('超管才能操作'); } ShopClass::updateById($shopId, ['cashAccount' => $cashAccount, 'cashName' => $cashName, 'cashBank' => $cashBank]); util::complete(); } //获取所有门店lqh 2021.1.31 public function actionAll() { $res = []; $shopAdmin = isset($this->shopAdmin) && !empty($this->shopAdmin) ? $this->shopAdmin->attributes : []; if (isset($shopAdmin['super']) && $shopAdmin['super'] == 1) { $res = ShopClass::getAllShop($this->sjId); } util::success($res); } //获取采购时的支付方式 ssh 20211004 public function actionGetCgPayWay() { $get = Yii::$app->request->get(); $id = $get['id'] ?? 0; $cg = PurchaseClass::getById($id, true); PurchaseClass::valid($cg, $this->shopId); $customId = $cg->customId ?? 0; $custom = CustomClass::getById($customId); $hasDebtPay = $custom['debt'] ?? 0; //预订单不能欠款 if ($cg->book == 1) { $hasDebtPay = 0; } $current = time(); $cgDeadTime = strtotime($cg->deadline); //让客户在失效前$aheadTime秒要支付,这样回调通知时订单才不会过期状态 $aheadTime = dict::getDict('order_online_pay_has_ahead_time'); $count = $cgDeadTime - $current - $aheadTime; $data = []; $data['balance'] = $this->shop->balance ?? 0; $data['count'] = $count; $data['hasDebtPay'] = $hasDebtPay; util::success($data); } //地区 ssh 20220606 public function actionRegion() { $regionTree = RegionService::tree(); util::success(['region' => $regionTree]); } }