| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- <?php
- namespace bizHd\saas\services;
- use biz\shop\classes\MainClass;
- use biz\sj\classes\SjClass;
- use bizHd\ad\classes\AdClass;
- use bizHd\admin\classes\AdminClass;
- use bizHd\base\services\BaseService;
- use bizGhs\custom\classes\CustomClass;
- use biz\shop\classes\ShopAdminClass;
- use biz\sj\classes\MerchantClass;
- use bizHd\goods\classes\CategoryClass;
- use bizHd\goods\classes\GoodsSettingClass;
- use bizHd\item\services\ItemService;
- use bizHd\merchant\services\SjService;
- use bizHd\saas\classes\ApplyClass;
- use bizHd\saas\classes\ApplyExtendClass;
- use biz\sj\services\MerchantService;
- use common\components\dict;
- use common\components\imgUtil;
- use common\components\noticeUtil;
- use common\components\stringUtil;
- use common\components\util;
- class ApplyService extends BaseService
- {
- public static $baseFile = '\bizHd\saas\classes\ApplyClass';
- //申请列表 ssh 2021.1.28
- public static function getApplyList($where)
- {
- $data = ApplyClass::getList('*', $where, 'addTime DESC');
- $list = isset($data['list']) && !empty($data['list']) ? $data['list'] : [];
- if (empty($list)) {
- return $data;
- }
- //商家信息
- $oldList = array_column($list, 'introSjId');
- $sjIdList = array_column($list, 'sjId');
- $ids = array_merge($sjIdList, $oldList);
- $ids = array_unique(array_filter($ids));
- $sj = MerchantClass::getMerchantByIds($ids);
- $applyIds = array_unique(array_filter(array_column($list, 'id')));
- $extend = ApplyExtendClass::getExtendByIds($applyIds);
- $prefix = imgUtil::getPrefix();
- foreach ($list as $key => $val) {
- $currentId = $val['id'] ?? 0;
- $list[$key]['licenseNo'] = $extend[$currentId]['licenseNo'] ?? '';
- $list[$key]['license'] = $extend[$currentId]['license'] ?? '';
- $introSjId = $val['introSjId'];
- $introSjName = $sj[$introSjId]['name'] ?? '';
- $list[$key]['introSjName'] = $introSjName;
- $avatar = $prefix . 'hhb_small.png';
- if (isset($val['avatar']) && !empty($val['avatar'])) {
- $avatar = $prefix . $val['avatar'];
- }
- $list[$key]['fullAvatar'] = $avatar;
- }
- $data['list'] = $list;
- $data['invitedNum'] = 0;
- $data['payNum'] = 0;
- $data['income'] = 0;
- return $data;
- }
- //审核通过,商家初始化 ssh 2021.2.23
- public static function pass($id, $remark = '')
- {
- $apply = ApplyClass::getById($id);
- if (empty($apply)) {
- util::fail('没有找到申请记录');
- }
- $applyId = $apply['id'];
- ApplyClass::updateById($applyId, ['status' => ApplyClass::STATUS_PASS, 'remark' => $remark]);
- $apply['name'] = isset($apply['name']) ? $apply['name'] : '';
- $main = \bizHd\shop\classes\MainClass::addMainInitItem();
- $respond = SjService::initHdBaseInfo($apply, $main, true);
- return $respond;
- }
- //新增或修改申请开店 ssh 2021.2.27
- public static function replaceRetail($data)
- {
- $mobile = $data['mobile'] ?? 0;
- if (empty($mobile)) {
- util::fail('请填写手机号');
- }
- if (stringUtil::isMobile($mobile) == false) {
- util::fail('请填写正确手机号');
- }
- //引荐的员工
- $currentShopAdminId = 0;
- $ghsShopAdminId = $data['ghsShopAdminId'] ?? 0;
- if (!empty($ghsShopAdminId)) {
- $currentShopAdminId = $ghsShopAdminId;
- } else {
- $hdShopAdminId = $data['hdShopAdminId'] ?? 0;
- if (!empty($hdShopAdminId)) {
- $currentShopAdminId = $hdShopAdminId;
- }
- }
- if (!empty($currentShopAdminId)) {
- $shopAdmin = ShopAdminClass::getById($currentShopAdminId);
- if (!empty($shopAdmin)) {
- $sjId = $shopAdmin['sjId'] ?? 0;
- $sj = MerchantClass::getMerchantById($sjId);
- $data['introSjId'] = $sjId;
- $data['introStyle'] = $sj['style'] ?? SjClass::STYLE_SUPPLIER;
- $data['introSjName'] = $sj['name'] ?? '';
- $data['introShopId'] = $shopAdmin['shopId'] ?? 0;
- }
- }
- $mobile = $data['mobile'] ?? '';
- $data['licenseNo'] = $mobile;
- $adminId = $data['adminId'] ?? 0;
- $has = ApplyClass::getByCondition(['mobile' => $mobile]);
- if (!empty($has)) {
- //手机号开了零售店不能再开批发店,开了批发店不能再开零售店
- util::fail('您已经申请过了');
- }
- $respond = ApplyClass::addRetail($data);
- //已提交开店申请,待审核
- \biz\admin\classes\AdminClass::updateById($adminId, ['openShop' => 2]);
- return $respond;
- }
- //供货商申请开店 ssh 2021.01.28
- public static function replaceGhs($data)
- {
- $mobile = $data['mobile'] ?? 0;
- if (empty($mobile)) {
- util::fail('请填写手机号');
- }
- if (stringUtil::isMobile($mobile) == false) {
- util::fail('请填写正确手机号');
- }
- $from = $data['from'] ?? 0;
- if (in_array($from, [ApplyClass::FROM_GHS, ApplyClass::FROM_RETAIL]) == false) {
- util::fail('请填写来源');
- }
- //暂时不需要提供证件
- $data['hasLicense'] = 2;
- $data['licenseNo'] = $mobile;
- $adminId = $data['adminId'];
- $has = ApplyClass::getByCondition(['adminId' => $adminId, 'style' => ApplyClass::FROM_GHS]);
- if (!empty($has)) {
- util::fail('您已经申请过');
- }
- $has = ApplyClass::getByCondition(['mobile' => $mobile]);
- if (!empty($has)) {
- //手机号开了零售店不能再开批发店,开了批发店不能再开零售店
- util::fail('手机号已经使用过了');
- }
- //引荐的员工
- $currentShopAdminId = 0;
- $ghsShopAdminId = $data['ghsShopAdminId'] ?? 0;
- if (!empty($ghsShopAdminId)) {
- $currentShopAdminId = $ghsShopAdminId;
- } else {
- $hdShopAdminId = $data['hdShopAdminId'] ?? 0;
- if (!empty($hdShopAdminId)) {
- $currentShopAdminId = $hdShopAdminId;
- }
- }
- if (!empty($currentShopAdminId)) {
- $shopAdmin = ShopAdminClass::getById($currentShopAdminId);
- if (!empty($shopAdmin)) {
- $sjId = $shopAdmin['sjId'] ?? 0;
- $sj = MerchantClass::getMerchantById($sjId);
- $data['introSjId'] = $sjId;
- $data['introStyle'] = $sj['style'] ?? SjClass::STYLE_SUPPLIER;
- $data['introSjName'] = $sj['name'] ?? '';
- $data['introShopId'] = $shopAdmin['shopId'] ?? 0;
- }
- }
- $dist = $data['dist'] ?? '';
- $floor = $data['floor'] ?? '';
- $address = $data['address'] ?? '';
- $data['fullAddress'] = $data['city'] . $dist . $address . $floor;
- $respond = ApplyClass::addGhs($data);
- //已提交开店申请,待审核
- \biz\admin\classes\AdminClass::updateById($adminId, ['openShop' => 2]);
- return $respond;
- }
- //供货商申请开店 ssh 2021.01.28
- public static function replaceKmGhs($data)
- {
- $mobile = $data['mobile'] ?? 0;
- if (empty($mobile)) {
- util::fail('请填写手机号');
- }
- if (stringUtil::isMobile($mobile) == false) {
- util::fail('请填写正确手机号');
- }
- $from = $data['from'] ?? ApplyClass::FROM_GHS;
- if (in_array($from, [ApplyClass::FROM_GHS, ApplyClass::FROM_RETAIL]) == false) {
- util::fail('请填写来源');
- }
- $data['licenseNo'] = $mobile;
- $adminId = $data['adminId'] ?? 0;
- if (!empty($adminId)) {
- $has = ApplyClass::getByCondition(['adminId' => $adminId, 'style' => SjClass::STYLE_KM_SUPPLIER]);
- if (!empty($has)) {
- util::fail('您已经申请过');
- }
- }
- $has = ApplyClass::getByCondition(['mobile' => $mobile, 'style' => SjClass::STYLE_KM_SUPPLIER]);
- if (!empty($has)) {
- util::fail('手机号已经使用过了');
- }
- $respond = ApplyClass::addKmGhs($data);
- if (!empty($adminId)) {
- //已提交开店申请,待审核
- \biz\admin\classes\AdminClass::updateById($adminId, ['openShop' => 2]);
- }
- return $respond;
- }
- }
|