request->get(); $showStock = $get['showStock'] ?? 0; $mainId = $this->mainId; CustomClass::updateByCondition(['ownMainId' => $mainId], ['showStock' => $showStock]); \bizGhs\ghs\classes\GhsClass::updateByCondition(['mainId' => $mainId], ['showStock' => $showStock]); util::complete('设置成功'); } //批量设置是否可看销量 ssh 20251031 public function actionAllSetLookSale() { $get = Yii::$app->request->get(); $showSold = $get['showSold'] ?? 0; $shop = $this->shop; //没有配置到每个客户,只在总店有控制 $shop->showSold = $showSold; $shop->save(); util::complete('设置成功'); } //批量授信 ssh 20251031 public function actionAllCredit() { $staff = $this->shopAdmin; if ($staff->mobile != 15280215347) { util::fail('请管理员操作'); } $get = Yii::$app->request->get(); $amount = $get['amount'] ?? 0; $mainId = $this->mainId; CustomClass::updateByCondition(['ownMainId' => $mainId], ['debtLimit' => $amount]); util::complete('设置成功'); } //客户设置相关 ssh 20250310 public function actionSetChange() { $staff = $this->shopAdmin; if ($staff->founder != 2 && $staff->mobile != 15280215347) { util::fail('老板才能修改'); } $post['homeAmount'] = !empty($post['homeAmount']) && is_numeric($post['homeAmount']) ? $post['homeAmount'] : 0; $post = Yii::$app->request->post(); $shopId = $this->shopId; ShopClass::updateById($shopId, $post); $showStock = $post['showStock'] ?? 0; $arr = ['showStock' => $showStock]; //如果新客需要审核,老的全部要打开为已经审核通过了 $arr['passStatus'] = 1; CustomClass::updateByCondition(['ownShopId' => $shopId], $arr); GhsClass::updateByCondition(['shopId' => $shopId], $arr); util::complete('修改成功'); } //获取收款码 ssh 20240530 public function actionGetGatheringCode() { $get = Yii::$app->request->get(); $id = $get['id'] ?? 0; $custom = CustomClass::getById($id, true); if (empty($custom)) { util::fail('没有找到客户'); } if ($custom->ownMainId != $this->mainId) { util::fail('不是你的客户哈'); } $ghsId = $custom->ghsId ?? 0; $salt = $custom->salt ?? ''; //有多个地方要同步修改,关键词 custom_go_ghs_gathering_code if (getenv('YII_ENV') == 'production') { $url = "https://mall.huahb.cn/#/admin/ghs/pay?id={$ghsId}&salt={$salt}"; } else { $url = "https://mall.huaml.com/#/admin/ghs/pay?id={$ghsId}&salt={$salt}"; } $unique = "recharge_to_ghs_" . $id; $imgUrl = qrCodeUtil::generateRechargeQrCode($url, $unique); $imageUrl = imgUtil::groupImg($imgUrl); util::success(['imgUrl' => $imageUrl]); } //供货商给客户充值和结账 ssh 20240309 public function actionRecharge() { ini_set('memory_limit', '2045M'); set_time_limit(0); //避免重复提交 $staffId = $this->shopAdminId; util::checkRepeatCommit($staffId, 5); $staff = $this->shopAdmin; if (isset($staff->finance) == false || $staff->finance == 0) { if ($this->shopId == 17118) { //淘花里中山店,没有财务权限要能销账 if (!in_array($this->adminId, [17908])) { util::fail('你不能充值销账哦'); } } elseif ($this->shopId == 72366) { //淘花里小榄店,没有财务权限要能销账 if (!in_array($this->adminId, [69792])) { util::fail('你不能充值销账哦'); } } else { util::fail('无法充值销单。。。'); } } //多个地方需要同步修改 clear_order_power if (getenv('YII_ENV') == 'production') { //小向花卉 if (in_array($this->shopId, [23580, 24713])) { if (!in_array($this->adminId, [23960, 77951, 4])) { util::fail('不能销单哦!!'); } } //花样年华只有总控才能结账 if (in_array($this->shopId, [1585, 1596])) { if ($this->adminId != 2876) { util::fail('不能充值销单哦'); } } //花大苪 洋桔梗,只有叶荷姐才能销账 if (in_array($this->shopId, [16070])) { if (!in_array($this->adminId, [9303, 4])) { util::fail('不能充值销单哈'); } } //恋善好多花控制销账权限 if (in_array($this->shopId, [55238, 56609, 56611])) { if (!in_array($this->adminId, [43856, 54620])) { util::fail('暂无权限销单,请联系老板或财务'); } } //天天鲜花 陈江店 if (in_array($this->shopId, [763, 1405, 795])) { if (!in_array($this->adminId, [2094, 5959])) { util::fail('不能操作充值销单!'); } } //花儿好仙 if (in_array($this->shopId, [22666])) { if (!in_array($this->adminId, [12869, 23174])) { util::fail('不能充值销单哈'); } } //小丽鲜花 if (in_array($this->shopId, [11094])) { if (!in_array($this->adminId, [12073, 12296])) { util::fail('您不能充值销单哦'); } } //源花汇 if (in_array($this->shopId, [10649])) { if (!in_array($this->adminId, [11641, 11648, 4])) { util::fail('请闵总或小周操作'); } } //昱成 if (in_array($this->shopId, [8596])) { if (!in_array($this->adminId, [9303, 9601])) { util::fail('只能叶荷操作'); } } //花大苪,多处请搜索关键词 hdb_clear_control if (in_array($this->shopId, [8249])) { if (!in_array($this->adminId, [9303])) { util::fail('只能叶荷和财务操作'); } } //中山淘花里,销账权限控制,多处请搜索 thl_clear_control if (in_array($this->shopId, [17118])) { if (!in_array($this->adminId, [55494, 55445, 17908, 55459, 55707, 55709])) { util::fail('你不能销单哈。。'); } } //淘花里小榄店 thl_xl_clear if (in_array($this->shopId, [72366])) { if (!in_array($this->adminId, [69792, 55445, 55707, 69792])) { util::fail('你不能销单那,编号1956'); } } //淘花里珠海店 if (in_array($this->shopId, [78556])) { if (!in_array($this->adminId, [69132, 75771, 43732, 55734, 47775, 55711, 40678, 75798])) { util::fail('你不能销单哦,编号88831'); } } //小齐鲜花总店和出车,多处请搜索关键词 xq_clear_control if (in_array($this->shopId, [41467, 42946])) { if (!in_array($this->adminId, [40144, 42912, 42023])) { util::fail('您不能充值销单哦,编号956'); } } //泉城花卉批发,只有指定人才能结账 if (in_array($this->shopId, [447])) { if (!in_array($this->adminId, [1398, 2448, 2457, 2499, 82260])) { util::fail('不能充值销账,请联系小娟'); } } } else { if (in_array($this->shopId, [36523])) { if ($this->adminId != 919) { util::fail('暂不能操作充值销单哈'); } } } $get = Yii::$app->request->get(); $amount = $get['amount'] ?? 0; $customId = $get['customId'] ?? 0; $payWay = $get['payWay'] ?? -1; $remark = $get['remark'] ?? ''; $rechargeType = $get['rechargeType'] ?? 0; if ($rechargeType == 0 && $payWay < 0) { util::fail('请选择付款方式'); } if ($amount <= 0) { //util::fail('充值金额需要大于0'); } //解决重复充值问题 $cacheKey = 'help_custom_recharge_' . $customId; $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]); if (!empty($has)) { util::fail('已充值,请8秒后再操作'); return false; } Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 8, 'has']); $custom = CustomClass::getLockById($customId); if (empty($custom)) { util::fail('没有找到客户'); } if ($custom->ownMainId != $this->mainId) { util::fail('不是你的客户,无法充值'); } $customShopId = $custom->shopId ?? 0; $shop = $this->shop; if ($customShopId == $shop->lsShopId) { util::fail('不能给自己充值'); } $connection = Yii::$app->db; $transaction = $connection->beginTransaction(); try { $staff = $this->shopAdmin; $params = ['remark' => $remark, 'rechargeType' => $rechargeType]; $recharge = CustomService::rechargeClear($custom, $amount, $this->shop, $staff, $payWay, $params); $transaction->commit(); WxMessageClass::customRechargeClearInform($shop, $recharge); util::complete('充值成功'); } catch (\Exception $e) { Yii::info("充值失败原因:" . $e->getMessage()); $transaction->rollBack(); util::fail('充值失败'); } } /** * 手动减少客户净余额(财务权限,与充值销账同级)。 */ public function actionDeductAmount() { util::checkRepeatCommit($this->shopAdminId, 5); $staff = $this->shopAdmin; if (isset($staff->finance) == false || $staff->finance == 0) { if ($this->shopId == 17118) { if (!in_array($this->adminId, [17908])) { util::fail('你没有权限减少余额'); } } elseif ($this->shopId == 72366) { if (!in_array($this->adminId, [69792])) { util::fail('你没有权限减少余额'); } } else { util::fail('无法减少余额'); } } $post = Yii::$app->request->post(); $customId = intval($post['customId'] ?? 0); $amount = $post['amount'] ?? 0; $remark = $post['remark'] ?? ''; if (empty($customId)) { util::fail('请选择客户'); } if (empty($amount)) { util::fail('请填写金额'); } if ($amount < 0) { util::fail('金额要大于0'); } $cacheKey = 'help_custom_deduct_' . $customId; $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]); if (!empty($has)) { util::fail('已操作,请8秒后再试'); } Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 8, 'has']); $pair = GhsRechargeSettleService::lockAccountPair(['id' => $customId]); $custom = $pair['custom']; $ghs = $pair['ghs']; if (empty($custom)) { util::fail('没有找到客户'); } if ($custom->ownMainId != $this->mainId) { util::fail('不是你的客户,无法操作'); } $connection = Yii::$app->db; $transaction = $connection->beginTransaction(); try { $params = [ 'remark' => $remark, 'staffId' => $staff->id ?? 0, 'staffName' => $staff->name ?? '', ]; CustomClass::manualDeductBalance($this->shop, $custom, $ghs, $amount, $params); $transaction->commit(); util::complete('减少成功'); } catch (\Exception $e) { Yii::info('减少余额失败原因:' . $e->getMessage()); $transaction->rollBack(); util::fail($e->getMessage() ?: '减少失败'); } } //生成货位号 ssh 20231215 public function actionCreateSeatSn() { $get = Yii::$app->request->get(); $id = $get['id'] ?? 0; $custom = CustomClass::getById($id, true); if ($custom->ownMainId != $this->mainId) { util::fail('不是您的客户'); } $seatSn = $custom->seatSn ?? ''; if (!empty($seatSn)) { util::fail('已经有货位号了'); } $new = CustomClass::createSeatSn($this->mainId); $custom->seatSn = $new; $custom->save(); //预订相关表的货位同步 $shop = $this->shop; CustomClass::syncBookSeat($shop, $custom, $new); util::complete('已生成'); } //修改货位号 ssh 20231215 public function actionModifySeatSn() { $get = Yii::$app->request->get(); $id = $get['id'] ?? 0; $new = $get['seatSn'] ?? 0; $custom = CustomClass::getById($id, true); if ($custom->ownMainId != $this->mainId) { util::fail('不是您的客户'); } if (is_numeric($new) == false) { util::fail('请填写数字'); } $custom->seatSn = $new; $custom->save(); //预订相关表的货位同步 $shop = $this->shop; CustomClass::syncBookSeat($shop, $custom, $new); util::complete('修改成功'); } //修改客户地址 ssh 20230929 public function actionModifyAddress() { $post = Yii::$app->request->post(); $id = $post['id'] ?? 0; unset($post['id']); $custom = CustomClass::getById($id, true); if ($custom->ownMainId != $this->mainId) { util::fail('不是您的客户哦'); } $city = $post['city'] ?? ''; $dist = $post['dist'] ?? ''; $address = $post['address'] ?? ''; $floor = $post['floor'] ?? ''; $post['fullAddress'] = $city . $dist . $address . $floor; $shopId = $custom->shopId ?? 0; ShopClass::updateById($shopId, $post); CustomClass::updateByCondition(['shopId' => $shopId], $post); util::complete('修改成功'); } //修改花店散客身份 ssh 20230216 public function actionChangeIsHd() { $get = Yii::$app->request->get(); $id = $get['customId'] ?? 0; $isHd = $get['isHd'] ?? 1; $custom = CustomClass::getById($id, true); if (empty($custom)) { util::fail('没有找到客户'); } if ($custom->ownMainId != $this->mainId) { util::fail('没有权限'); } $ghsId = $custom->ghsId ?? 0; $ghs = GhsClass::getById($ghsId, true); if (empty($ghs)) { util::fail('修改失败了'); } $ghs->isHd = $isHd; $ghs->save(); $custom->isHd = $isHd; $custom->save(); util::complete('修改成功'); } //修改物流名称 ssh 20230112 public function actionChangeWlName() { $get = Yii::$app->request->get(); $id = $get['id'] ?? 0; $wlName = $get['wlName'] ?? 0; $custom = CustomClass::getById($id, true); if (empty($custom) || $custom->ownMainId != $this->mainId) { util::fail('修改失败'); } $ghsId = $custom->ghsId ?? 0; $ghs = GhsClass::getById($ghsId, true); if (empty($ghs)) { util::fail('修改失败'); } $ghs->customWlName = $wlName; $ghs->save(); $custom->wlName = $wlName; $custom->save(); util::complete('已修改'); } //修改短名 ssh 2025312 public function actionModifyShortName() { $get = Yii::$app->request->get(); $id = $get['id'] ?? 0; $shortName = $get['shortName'] ?? 0; $custom = CustomClass::getById($id, true); if (empty($custom) || $custom->ownMainId != $this->mainId) { util::fail('修改失败'); } $custom->shortName = $shortName; $custom->save(); util::complete('修改成功'); } //修改物流信息 ssh 20230105 public function actionChangeWl() { util::fail('修改失败'); } //修改名称 ssh 2022096 public function actionChangeName() { $get = Yii::$app->request->get(); $name = $get['name'] ?? ''; $id = $get['id'] ?? 0; if (empty($name)) { util::fail('请填写名称'); } $py = stringUtil::py($name); $custom = CustomClass::getById($id, true); CustomClass::valid($custom, $this->shopId); $custom->name = $name; $custom->py = $py; $custom->save(); OrderClass::updateByCondition(['customId' => $id], ['customName' => $name, 'customNamePy' => $py]); $customShopId = $custom->shopId ?? 0; //在首店修改客户名称,直营店自动同步 $masterShop = $this->shop; if (isset($masterShop->default) && $masterShop->default == 1) { $sjId = $masterShop->sjId ?? 0; $shopList = ShopClass::getAllByCondition(['sjId' => $sjId], null, '*', null, true); foreach ($shopList as $shop) { $shopId = $shop->id ?? 0; if (isset($shop->join) && $shop->join == 1) { //加盟店不同步修改 continue; } if ($shopId == $masterShop->id) { //前面已经同步修改过了 continue; } $custom = CustomClass::getByCondition(['ownShopId' => $shopId, 'shopId' => $customShopId], true); if (empty($custom)) { continue; } $custom->name = $name; $custom->py = $py; $custom->save(); } } util::complete('修改成功'); } //帮客户添加员工 ssh 20220613 public function actionAddStaff() { $post = Yii::$app->request->post(); $customId = $post['id'] ?? 0; $mobile = $post['mobile'] ?? 0; if (stringUtil::isMobile($mobile) == false) { util::fail('手机号填写错误'); } $info = CustomService::getById($customId, true); CustomClass::valid($info, $this->shopId); $connection = Yii::$app->db; $transaction = $connection->beginTransaction(); try { $shopId = $info->shopId ?? 0; $customShop = ShopClass::getById($shopId, true); if (empty($customShop)) { util::fail('没有找到客户的门店'); } $mainId = $customShop->mainId ?? 0; $ptStyle = dict::getDict('ptStyle', 'hd'); $adminInfo = ['name' => $mobile, 'mobile' => $mobile, 'style' => $ptStyle, 'currentShopId' => $shopId]; $fromApp = dict::getDict('userSourceGetId', 'app', 'id'); $admin = \bizGhs\admin\classes\AdminClass::replaceAdmin($adminInfo, $fromApp); $roleList = AdminRoleClass::getAllByCondition(['mainId' => $mainId], null, '*', null, true); if (empty($roleList)) { util::fail('客户门店没有员工角色'); } $currentRoleId = 0; foreach ($roleList as $role) { $roleId = $role->id ?? 0; $currentRoleId = $roleId; if ($role->roleName == '员工') { break; } } $params = [ 'shopId' => $shopId, 'mobile' => $mobile, 'roleId' => $currentRoleId, ]; \bizHd\staff\classes\StaffClass::appGenerateStaff($params, $admin); $transaction->commit(); util::complete('添加成功'); } catch (\Exception $e) { $transaction->rollBack(); util::fail('添加失败'); } } //添加新花店 ssh 2021.1.8 public function actionAdd() { $post = Yii::$app->request->post(); $post['style'] = SjClass::STYLE_RETAIL; $post['introSjId'] = $this->sjId; $post['introStyle'] = SjClass::STYLE_SUPPLIER; $mobile = $post['mobile'] ?? ''; $confirmMobile = $post['confirmMobile']; $address = $post['address'] ?? ''; util::fail('功能已停用'); if (stringUtil::isMobile($mobile) == false) { util::fail(' 请填写正确的手机号'); } if ($mobile != $confirmMobile) { util::fail('二次号码填写不一致'); } $name = $post['name'] ?? ''; if (empty($name)) { util::fail('名称不能为空'); } if (stringUtil::getWordNum($name) > 15) { util::fail('名称不能超过15个汉字'); } $has = SjClass::getByCondition(['name' => $name, 'style' => SjClass::STYLE_RETAIL]); if (!empty($has)) { util::fail('名称已经存在'); } $has = ApplyClass::getByCondition(['mobile' => $mobile, 'style' => SjClass::STYLE_RETAIL]); if (!empty($has)) { util::fail('手机号已经添加过'); } if (empty($address)) { util::fail('请填写地址'); } $connection = Yii::$app->db; $transaction = $connection->beginTransaction(); try { $shop = $this->shop; $sjId = $this->sjId; $shopId = $this->shopId; $sjName = $this->sj->name ?? ''; $city = $shop->city ?? ''; $dist = $shop->dist ?? ''; $applyData = [ 'name' => $name, 'licenseNo' => $mobile, 'certType' => ApplyClass::CERT_TYPE_MOBILE, 'mobile' => $mobile, 'introSjId' => $sjId, 'introSjName' => $sjName, 'introShopId' => $shopId, 'introStyle' => SjClass::STYLE_SUPPLIER, 'from' => ApplyClass::FROM_GHS, 'style' => SjClass::STYLE_RETAIL, 'province' => $shop->province ?? '', 'city' => $city, 'dist' => $dist, 'address' => $address, 'status' => ApplyClass::STATUS_PASS, 'replace' => 1,//1表示供货商添加的客户 ]; $apply = ApplyService::replaceRetail($applyData); $id = $apply['id'] ?? 0; $respond = ApplyService::pass($id); $shop = $respond['shop'] ?? []; $sj = $respond['sj'] ?? []; $hdSjId = $sj['id'] ?? 0; $hdShopId = $shop->id ?? 0; ApplyClass::updateById($id, ['sjId' => $hdSjId, 'shopId' => $hdShopId]); if (empty($hdShopId)) { util::fail('客户没有添加成功!'); } $custom = CustomClass::build($this->shopId, $hdShopId); $custom['avatar'] = imgUtil::groupImg($custom['avatar']); //客户欠款额度设置 $debt = isset($post['debt']) && $post['debt'] == CustomClass::IS_DEBT_YES ? CustomClass::IS_DEBT_YES : CustomClass::IS_DEBT_NO; $customId = $custom['id'] ?? 0; $debtLimit = isset($post['debtLimit']) && is_numeric($post['debtLimit']) ? $post['debtLimit'] : 0; CustomClass::updateById($customId, ['debtLimit' => $debtLimit, 'debt' => $debt]); $transaction->commit(); util::success($custom); } catch (\Exception $exception) { $transaction->rollBack(); Yii::info("添加客户没有成功:" . $exception->getMessage()); util::fail('添加客户没有成功'); } } //向队列写入新花店数据 shizhongqi 2022.6.8 public function actionCreateCustomers() { $post = Yii::$app->request->post(); $virtual = $post['virtual'] ?? 0; $arr = []; for ($i = 1; $i <= 5; $i++) { $name = $post['name' . $i] ?? ''; $mobile = $post['mobile' . $i] ?? ''; $confirmMobile = $post['confirmMobile' . $i] ?? ''; if (empty($name) && empty($mobile) && empty($confirmMobile)) { continue; } if (empty($name)) { util::fail('花店名称不能为空'); } if (stringUtil::getWordNum($name) > 15) { util::fail('名称不能超过15个汉字'); } if (empty($mobile)) { //添加虚拟客户 if ($virtual == 1) { $mobile = orderSn::getMobileSn(); $confirmMobile = $mobile; } else { util::fail($name . " 手机号不能为空"); } } if (stringUtil::isMobile($mobile) == false) { util::fail($name . " 手机号格式不正确"); } if ($mobile != $confirmMobile) { util::fail($name . " 二次手机号不一致"); } $hasShop = ShopClass::getByCondition(['mobile' => $mobile], true); if (!empty($hasShop)) { $shop = ShopClass::getByCondition(['mobile' => $mobile, 'ptStyle' => 1], true); if (!empty($shop)) { $ghsShopId = $this->shopId; $hdShopId = $shop->id; $custom = CustomClass::build($ghsShopId, $hdShopId); $customId = $custom['id'] ?? 0; $custom = CustomClass::getById($customId, true); if (!empty($custom)) { $custom->name = $name; $py = stringUtil::py($name); $custom->py = $py; $custom->save(); } util::success(['customId' => $customId], $shop->merchantName . ' 添加成功'); } util::fail($mobile . "手机号已经添加过了"); } $has = ApplyClass::getByCondition(['mobile' => $mobile]); if (!empty($has)) { util::fail($mobile . "手机号已经申请添加过了"); } $arr[] = ['name' => $name, 'mobile' => $mobile]; } if (empty($arr)) { util::fail('请填写客户'); } foreach ($arr as $item) { $name = $item['name'] ?? ''; $mobile = $item['mobile'] ?? ''; //使用消息队列处理 try { $producer = Yii::$app->rabbitmq->getProducer('customProducer'); $msg = serialize(['type' => 'add_custom', 'name' => $name, 'mobile' => $mobile, 'sjId' => $this->sjId, 'shopId' => $this->shop->id, 'sjName' => $this->sj->name, 'staffId' => $this->shopAdminId]); $producer->publish($msg, 'customExchange', 'customRoute', ['delivery_mode' => 2, 'content_type' => 'application/octet-stream']); } catch (\Exception $e) { $msg = $e->getMessage(); $remind = "供货商创建新客户,生产消息报错 {$name} {$mobile} {$this->sj->name} {$msg}"; noticeUtil::push($remind, '15280215347'); } } util::complete('已添加'); } //从其它店同步客户 shizhongqi 2022.6.9 public function actionCopyCustomers() { //限制请求次数 $shopId = $this->shopId; //util::perDayCommitTimeLimit($shopId, 3); //限制频繁请求 util::checkRepeatCommit($this->adminId, 6); $get = Yii::$app->request->get(); $fromShopId = $get['fromShopId'] ?? 0; $fromShop = ShopClass::getById($fromShopId, true); if (empty($fromShop)) { util::fail('门店不存在'); } $toShopId = $this->shopId; if ($fromShopId == $toShopId) { util::fail('本店无需同步'); } $fromShopName = $fromShop->shopName ?? ''; if ($fromShop->syncCustom == 0) { util::fail('不允许从' . $fromShopName . '同步客户'); } $toShop = $this->shop; $toShopName = $toShop->shopName ?? ''; if ($toShop->syncCustom == 0) { util::fail($toShopName . '已关闭同步功能'); } $toSjId = $toShop->sjId ?? 0; $fromSjId = $fromShop->sjId ?? 0; if ($toSjId != $fromSjId) { util::fail('不是您的门店'); } //使用消息队列处理 ssh 20251204 try { $producer = Yii::$app->rabbitmq->getProducer('customProducer'); $msg = serialize(['type' => 'pull_custom_from_other_shop', 'toShopId' => $toShopId, 'fromShopId' => $fromShopId]); $producer->publish($msg, 'customExchange', 'customRoute', ['delivery_mode' => 2, 'content_type' => 'application/octet-stream']); } catch (\Exception $e) { $msg = $e->getMessage(); $remind = "供货商拉取其他门店客户,生产消息报错 {$toShopId} {$fromShopId} {$msg}"; noticeUtil::push($remind, '15280215347'); } util::complete('已拉取'); } //客户列表 ssh 2021.7.8 public function actionList() { $staff = $this->shopAdmin; if (isset($staff->identity) && $staff->identity == 2) { util::success(['list' => []]); } $get = Yii::$app->request->get(); $type = $get['type'] ?? 0; $name = $get['name'] ?? ''; $export = $get['export'] ?? 0; $mainId = $this->mainId; $isCashier = $get['isCashier'] ?? 0; if ($isCashier == 1) { //去掉收银台提示价格更新 $staffId = $this->shopAdminId; Yii::$app->redis->executeCommand('DEL', ['ghs_cashier_' . $mainId . '_' . $staffId . '_may_refresh']); } $where = ['ownMainId' => $this->mainId]; $sort = 'visitTime DESC'; $filterDelStatus = isset($get['filterDelStatus']) && is_numeric($get['filterDelStatus']) ? (int)$get['filterDelStatus'] : -1; if ($filterDelStatus > -1) { $where['delStatus'] = $filterDelStatus; } else { $where['delStatus'] = 0; } if ($type == 1) { //消费排行 $sort = 'buyAmount DESC'; } else if ($type == 2) { //欠款客户 $where['isDebt'] = 1; // 欠款客户排序:净余额越小(越负)越靠前(原 (debtAmount-balance) DESC) $sort = 'balance ASC'; } else if ($type == 3) { //大客户 $where['level'] = 2; } else if ($type == 4) { //零售客户 $where['level'] = 0; } else if ($type == 5) { //休眠客户 $recentDay = isset($get['recentDay']) && is_numeric($get['recentDay']) ? (int)$get['recentDay'] : 30; $totalSecond = bcmul(86400, $recentDay); $currentSecond = bcsub(time(), $totalSecond); $currentDate = date("Y-m-d H:i:s", $currentSecond); $where['recentExpend<'] = $currentDate; $sort = 'recentExpend desc'; } else if ($type == 6) { //黑名单 $where['black'] = 2; } else if ($type == 7) { //已删除 $where['delStatus'] = 1; } $distId = $get['distId'] ?? 0; if (!empty($distId)) { $where['distId'] = $distId; } $filterDebt = isset($get['filterDebt']) && is_numeric($get['filterDebt']) ? (int)$get['filterDebt'] : -1; if ($filterDebt > -1) { if ($filterDebt == 0) { $where['debt'] = 0; } else { $where['debt>'] = 0; } } $level = isset($get['level']) && is_numeric($get['level']) ? (int)$get['level'] : -1; if ($level > -1) { $where['level'] = $level; } $filterBlack = isset($get['filterBlack']) && is_numeric($get['filterBlack']) ? (int)$get['filterBlack'] : -1; if ($filterBlack > -1) { $where['black'] = $filterBlack; } $overTimeUnExpend = isset($get['overTimeUnExpend']) && is_numeric($get['overTimeUnExpend']) ? (int)$get['overTimeUnExpend'] : -1; if ($overTimeUnExpend > -1) { if ($overTimeUnExpend == 10000) { $where['recentExpend'] = '0000-00-00 00:00:00'; } else if ($overTimeUnExpend == 7) { $where['recentExpend<'] = date('Y-m-d H:i:s', time() - 7 * 86400); $where['recentExpend>='] = date('Y-m-d H:i:s', time() - 30 * 86400); $where['recentExpend!='] = '0000-00-00 00:00:00'; } else if ($overTimeUnExpend == 30) { $where['recentExpend<'] = date('Y-m-d H:i:s', time() - 30 * 86400); $where['recentExpend>='] = date('Y-m-d H:i:s', time() - 180 * 86400); $where['recentExpend!='] = '0000-00-00 00:00:00'; } else if ($overTimeUnExpend == 180) { $where['recentExpend<'] = date('Y-m-d H:i:s', time() - 180 * 86400); $where['recentExpend>='] = date('Y-m-d H:i:s', time() - 365 * 86400); $where['recentExpend!='] = '0000-00-00 00:00:00'; } else if ($overTimeUnExpend == 365) { $where['recentExpend<'] = date('Y-m-d H:i:s', time() - 365 * 86400); $where['recentExpend!='] = '0000-00-00 00:00:00'; } } $name = trim($name); if (!empty($name)) { if (is_numeric($name)) { if (stringUtil::isMobile($name)) { $where['mobile'] = $name; } else { $shop = $this->shop; //如果花大苪,搜索数字还是优先搜索客户名称,因为客户名称经常会编号 if ($shop->id == 8249) { $where['name'] = ['like', $name]; } else { $where['mobile'] = ['like', $name]; } } } else if (stringUtil::isLetter($name)) { $where['py'] = ['like', $name]; } else { $where['name'] = ['like', $name]; } } if ($export == 1) { ini_set('memory_limit', '2045M'); set_time_limit(0); CustomClass::exportCustom($where, $sort, $this->mainId); util::stop(); } $respond = CustomService::getCustomSortList($where, $sort); if (getenv('YII_ENV') == 'production') { //源花汇,只有指定的人,才能看累计消费和挂账金额,有多处要同步修改 manage_custom_data $hideMainId = 10536; $hideAdminIds = [18505, 15187, 11961, 11648, 11644, 11641, 11976, 22534, 4]; } else { $hideMainId = 0; $hideAdminIds = [0]; } if ($this->mainId == $hideMainId) { if (!empty($respond['list'])) { foreach ($respond['list'] as $k => $v) { if (!in_array($this->adminId, $hideAdminIds)) { $respond['list'][$k]['buyAmount'] = 0; $respond['list'][$k]['remainDebtAmount'] = 0; $respond['list'][$k]['debtAmount'] = 0; $respond['list'][$k]['balance'] = 0; } } } } $main = $this->main; $respond['totalUser'] = $main->totalUser ?? 0; $respond['mayGatheringNum'] = $main->mayGatheringNum ?? 0; $respond['shopInfo'] = $this->shop; util::success($respond); } //今日访客 ssh 20211022 public function actionGetVisit() { $ids = StatVisitClass::getVisitCustomIds($this->shop); if (empty($ids)) { util::success(['list' => []]); } $sort = 'visitTime DESC'; $where = ['id' => ['in', $ids]]; $respond = CustomService::getCustomSortList($where, $sort); util::success($respond); } //客户详情 ssh 2021.1.8 public function actionDetail() { $get = Yii::$app->request->get(); $customId = $get['id'] ?? 0; $info = CustomService::getCustomInfo($customId); CustomClass::valid($info, $this->shopId); $mainId = $info['mainId'] ?? 0; //超管的信息 $superInfo = ShopAdminClass::getManager($mainId); $superName = $superInfo['name'] ?? ''; $currentSuper = ['name' => $superName]; $info['superInfo'] = $currentSuper; if (getenv('YII_ENV') == 'production') { //源花汇,只有指定的人,才能看累计消费和挂账金额,有多处要同步修改 manage_custom_data $hideMainId = 10536; $hideAdminIds = [18505, 15187, 11961, 11648, 11644, 11641, 11976, 22534, 4]; } else { $hideMainId = 0; $hideAdminIds = [0]; } if ($this->mainId == $hideMainId) { if (!in_array($this->adminId, $hideAdminIds)) { $info['buyAmount'] = 0; $info['debtAmount'] = 0; $info['remainDebtAmount'] = 0; $info['balance'] = 0; } } util::success($info); } //修改是否显示库存 ssh 20221022 public function actionChangeShowStock() { $get = Yii::$app->request->get(); $showStock = $get['showStock'] ?? 0; $customId = $get['customId'] ?? 0; $custom = CustomClass::getById($customId, true); CustomClass::valid($custom, $this->shopId); $ghsId = $custom->ghsId ?? 0; $ghs = GhsClass::getById($ghsId, true); if (empty($ghs)) { util::fail('没有找到供货商'); } $ghs->showStock = $showStock; $ghs->save(); $custom->showStock = $showStock; $custom->save(); util::complete(); } //修改状态 ssh 20240924 public function actionChangePassStatus() { $get = Yii::$app->request->get(); $passStatus = isset($get['passStatus']) ? $get['passStatus'] : 0; $customId = isset($get['customId']) ? $get['customId'] : 0; $custom = CustomClass::getById($customId, true); CustomClass::valid($custom, $this->shopId); $ghsId = $custom->ghsId ?? 0; $ghs = GhsClass::getById($ghsId, true); if (empty($ghs)) { util::fail('没有找到供货商'); } $ghs->passStatus = $passStatus; $ghs->save(); $custom->passStatus = $passStatus; $custom->save(); util::complete(); } public function actionChangeHome() { $get = Yii::$app->request->get(); $home = isset($get['home']) ? $get['home'] : 0; $customId = !empty($get['customId']) ? $get['customId'] : 0; $custom = CustomClass::getById($customId, true); if (empty($custom)) { util::fail('没有找到客户呢'); } if ($custom->ownShopId != $this->shopId) { util::fail('不是你的客户'); } $ghsId = $custom->ghsId ?? 0; $ghs = GhsClass::getById($ghsId, true); if (empty($ghs)) { util::fail('没有找到供货商'); } $ghs->home = $home; $ghs->save(); $custom->home = $home; $custom->save(); util::complete(); } /** * 上门最低消费设置 -- 单个修改 */ public function actionModifyHomeAmount() { $get = Yii::$app->request->get(); $id = $get['id'] ?? 0; $homeAmount = $get['homeAmount'] ?? 0; $homeNum = $get['homeNum'] ?? 0; $homeUnMeet = $get['homeUnMeet'] ?? 2; $homeUnFee = $get['homeUnFee'] ?? 0; $homeRule = $get['homeRule'] ?? 0; if (isset($get['homeType'])) { //早期系统有带这个参数,来判断 util::fail('请升级系统'); } $custom = CustomClass::getById($id, true); if (empty($custom)) { util::fail('没有找到客户'); } if ($custom->ownMainId != $this->mainId) { util::fail('不是你的客户'); } $ghsId = $custom->ghsId ?? 0; $ghs = GhsClass::getById($ghsId, true); if (empty($ghs)) { util::fail('没有找到供货商'); } if (isset($get['home'])) { $home = (int)$get['home']; $custom->home = $home; $ghs->home = $home; } $custom->homeAmount = $homeAmount; $custom->homeNum = $homeNum; $custom->homeUnMeet = $homeUnMeet; $custom->homeUnFee = $homeUnFee; $custom->homeRule = $homeRule; $custom->save(); $ghs->homeAmount = $homeAmount; $ghs->homeNum = $homeNum; $ghs->homeUnMeet = $homeUnMeet; $ghs->homeUnFee = $homeUnFee; $ghs->homeRule = $homeRule; $ghs->save(); util::complete('修改成功'); } public function actionChangeRiseRule() { $get = Yii::$app->request->get(); $id = $get['id'] ?? 0; $risePercent = isset($get['risePercent']) && is_numeric($get['risePercent']) ? $get['risePercent'] : 0; $riseRange = isset($get['riseRange']) && is_numeric($get['riseRange']) ? $get['riseRange'] : 0; $custom = CustomClass::getById($id, true); if (empty($custom)) { util::fail('没有找到客户呢'); } if ($custom->ownMainId != $this->mainId) { util::fail('不是你的客户呢'); } $ghsId = $custom->ghsId ?? 0; $ghs = GhsClass::getById($ghsId, true); if (empty($ghs)) { util::fail('没有找到供货商呢'); } $custom->risePercent = $risePercent; $custom->riseRange = $riseRange; $custom->save(); $ghs->risePercent = $risePercent; $ghs->riseRange = $riseRange; $ghs->save(); util::complete('修改成功'); } /** * 上门最低消费设置 -- 针对批发商客户进行批量修改 */ public function actionModifyAllHomeAmount() { $get = Yii::$app->request->get(); $homeAmount = $get['homeAmount'] ?? 0; $homeNum = $get['homeNum'] ?? 0; if (isset($get['homeType'])) { util::fail('请升级APP'); } $shopId = $this->shopId; ShopClass::updateById($shopId, ['homeAmount' => $homeAmount, 'homeNum' => $homeNum]); // 批量更新客户信息 CustomClass::updateByCondition(['ownMainId' => $this->mainId], ['homeAmount' => $homeAmount, 'homeNum' => $homeNum]); //批量更新供货商信息 GhsClass::updateByCondition(['shopId' => $shopId], ['homeAmount' => $homeAmount, 'homeNum' => $homeNum]); util::complete('修改成功'); } //允许月结开关 ssh 2021.1.8 public function actionDebt() { if (getenv('YII_ENV') == 'production') { if ($this->mainId == 4884) { if ($this->shopAdminId != 130738) { util::fail('只有倩姐才能修改'); } } } $get = Yii::$app->request->get(); $debt = $get['debt'] ?? 0; $customId = $get['customId'] ?? 0; $custom = CustomClass::getById($customId); CustomClass::valid($custom, $this->shopId); CustomClass::debt($custom, $debt); util::complete(); } //采购查看权限的黑白名单开关 shizhongqi 2021.08.08 public function actionSetBlack() { $black = Yii::$app->request->get('black', 2); $customId = Yii::$app->request->get('customId', 0); $custom = CustomClass::getById($customId, true); CustomClass::valid($custom, $this->shopId); $custom->black = $black; $custom->save(); $ghsId = $custom->ghsId ?? 0; $ghs = GhsClass::getById($ghsId, true); if (empty($ghs)) { util::fail('出错了'); } $ghs->black = $black; $ghs->save(); util::complete(); } //欠款客户 ssh 2021.2.4 public function actionDebtList() { $get = Yii::$app->request->get(); $where = ['ownShopId' => $this->shopId, 'isDebt' => 1]; if (isset($get['name']) && !empty($get['name'])) { $where['name'] = ['like', $get['name']]; } $list = CustomService::getDebtList($where); //共X个客户,合计欠款XXX元 $main = $this->main; $list['customNum'] = $main->mayGatheringNum ?? 0; $list['debtAmount'] = $main->mayGathering ?? 0.00; util::success($list); } //修改欠款额度 ssh 20210625 public function actionUpdateDebtLimit() { $shopAdmin = $this->shopAdmin; if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) { util::fail('管理员才能操作'); } if (getenv('YII_ENV') == 'production') { if ($this->mainId == 4884) { if ($this->shopAdminId != 130738) { util::fail('请倩姐修改'); } } if ($this->mainId == 10536) { if ($this->shopAdminId != 136416 && $this->shopAdminId != 136419) { util::fail('请闵总修改'); } } //惠雅6号线 if ($this->mainId == 2128) { if ($this->adminId == 3407) { util::fail('无法修改'); } } } $get = Yii::$app->request->get(); $id = $get['id'] ?? 0; $debtLimit = $get['debtLimit'] ?? 0; if (is_numeric($debtLimit) == false || $debtLimit < 0) { util::fail('请填写金额'); } $custom = CustomClass::getById($id, true); CustomClass::valid($custom, $this->shopId); $custom->debtLimit = $debtLimit; $custom->save(); util::complete(); } //修改货位名称 ssh 20241006 public function actionUpdateSeatSnName() { $get = Yii::$app->request->get(); $id = $get['id'] ?? 0; $seatSnName = $get['seatSnName'] ?? ''; $custom = CustomClass::getById($id, true); CustomClass::valid($custom, $this->shopId); $custom->seatSnName = $seatSnName; $custom->save(); util::complete(); } //修改折扣 ssh 20210913 public function actionChangeDiscount() { $shopAdmin = $this->shopAdmin; if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) { util::fail('管理员才能操作'); } $get = Yii::$app->request->get(); $id = $get['id'] ?? 0; $discount = $get['discount'] ?? 0; if (is_numeric($discount) == false || $discount > 1 || $discount == 0) { util::fail('请填写小数值'); } $custom = CustomClass::getById($id, true); CustomClass::valid($custom, $this->shopId); $custom->discount = $discount; $custom->save(); $ghsId = $custom->ghsId ?? 0; $ghs = GhsClass::getById($ghsId, true); $ghs->giveDiscount = $discount; $ghs->save(); util::complete(); } //修改客户等级 ssh 20211007 public function actionChangeLevel() { $shopAdmin = $this->shopAdmin; if (!isset($shopAdmin->super) || $shopAdmin->super != 1) { util::fail('超管才能修改'); } //泉城的只有苏小娟才能修改 if (getenv('YII_ENV') == 'production') { if ($this->mainId == 60) { if (!in_array($this->adminId, [2499, 4])) { util::fail('请小娟修改'); } } } $get = Yii::$app->request->get(); $customId = $get['customId'] ?? 0; $level = $get['level'] ?? 1; $custom = CustomClass::getById($customId, true); CustomClass::valid($custom, $this->shopId); $custom->level = $level; $custom->save(); $ghsId = $custom->ghsId ?? 0; $ghs = GhsClass::getById($ghsId, true); if (empty($ghs)) { util::fail('出错了'); } $ghs->giveLevel = $level; $ghs->save(); $map = CustomClass::$levelMap; $name = $map[$level] ?? ''; util::success(['levelName' => $name]); } //打印货位号 ssh 20241006 public function actionPrintSeatSn() { $get = Yii::$app->request->get(); $customId = $get['id'] ?? 0; $custom = CustomClass::getById($customId, true); CustomClass::valid($custom, $this->shopId); $seatSn = $custom->seatSn ?? 0; if ($seatSn == 0) { util::fail('没有货位'); } $customName = $custom->name ?? ''; if (isset($custom->seatSnName) && !empty($custom->seatSnName)) { $customName = $custom->seatSnName ?? ''; } $customName = stringUtil::subStringUtf8($customName, 7, '..'); $a4Print = [ 'customName' => $customName, 'seatSn' => $seatSn, ]; $info['printData'] = $a4Print; $template = '{"panels":[{"index":0,"name":1,"height":297,"width":210,"paperHeader":49.5,"paperFooter":780,"printElements":[{"options":{"left":12,"top":786,"height":49,"width":49},"printElementType":{"title":"html","type":"html"}},{"options":{"left":45,"top":52.5,"height":52,"width":128,"title":"文本","right":172.25,"bottom":104.5,"vCenter":108.25,"hCenter":78.5,"field":"seatSn","testData":"593","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":50,"fontWeight":"bold","textContentVerticalAlign":"middle","qrCodeLevel":0},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":148.5,"top":52.5,"height":52,"width":400,"title":"文本","field":"customName","testData":"小林","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":50,"fontWeight":"bolder","textAlign":"right","textContentVerticalAlign":"middle","qrCodeLevel":0,"right":566.5,"bottom":90.25,"vCenter":366.5,"hCenter":71.75},"printElementType":{"title":"文本","type":"text"}}],"paperNumberLeft":547.5,"paperNumberTop":786,"paperNumberDisabled":true,"paperNumberContinue":true,"fontFamily":"Microsoft YaHei","watermarkOptions":{"content":"","rotate":25,"timestamp":false,"format":"YYYY-MM-DD HH:mm","fillStyle":"rgba(184, 184, 184, 0.3)","fontSize":"14px","width":200,"height":200},"panelLayoutOptions":{"layoutType":"column","layoutRowGap":0,"layoutColumnGap":0}}]}'; $info['template'] = $template; $custom->printSeatSn = 1; $custom->save(); util::success($info); } //总挂账和总余额汇总 ssh 20250620 public function actionShowTotalBalance() { $lookMoney = \bizGhs\shop\classes\ShopAdminClass::lookMoneyPower($this->shopAdmin, $this->shop); if ($lookMoney == 0) { util::fail('无法查看哦'); } $pfShop = $this->shop; $lsShopId = $pfShop->lsShopId; $pfShopId = $this->shopId; $respond = CustomClass::showTotalBalance($pfShopId, $lsShopId); $respond['pfShopId'] = $pfShopId; $respond['lsShopId'] = $lsShopId; util::success($respond); } public function actionChangeDelStatus() { $get = Yii::$app->request->get(); $customId = $get['id'] ?? 0; $delStatus = $get['delStatus'] ?? 0; $custom = CustomClass::getById($customId, true); CustomClass::valid($custom, $this->shopId); $custom->delStatus = $delStatus; $custom->save(); util::complete('删除成功'); } public function actionChangeDebtLimitPay() { $get = Yii::$app->request->get(); $customId = $get['customId'] ?? 0; $debtLimitPay = $get['pay'] ?? 0; $custom = CustomClass::getById($customId, true); CustomClass::valid($custom, $this->shopId); $ghsId = $custom->ghsId ?? 0; $ghs = GhsClass::getById($ghsId, true); if (empty($ghs)) { util::fail('客户信息有问题'); } $custom->debtLimitPay = $debtLimitPay; $custom->save(); $ghs->debtLimitPay = $debtLimitPay; $ghs->save(); util::complete('修改成功'); } public function actionRefreshBuyamount() { $customId = intval(Yii::$app->request->get('customId')); if ($customId <= 0) { util::fail('客户ID参数错误'); } $custom = CustomClass::getById($customId, true); CustomClass::valid($custom, $this->shopId); $ghsId = $custom->ghsId ?? 0; $ghs = GhsClass::getById($ghsId, true); if (empty($ghs)) { util::fail('客户信息有问题'); } $orderList = OrderClass::getAllByCondition(['customId' => $customId], null, 'id, actPrice'); $buyAmount = 0; if (!empty($orderList)) { foreach ($orderList as $order) { $buyAmount = bcadd($buyAmount, $order['actPrice'], 2); } } $custom->buyAmount = $buyAmount; $custom->save(); $ghs->expendAmount = $buyAmount; $ghs->save(); util::success(['buyAmount' => $buyAmount]); } }