|
|
@@ -10,6 +10,7 @@ use biz\base\services\BaseService;
|
|
|
use biz\merchant\classes\MerchantClass;
|
|
|
use biz\merchant\services\MerchantService;
|
|
|
use biz\saas\classes\ApplyClass;
|
|
|
+use biz\saas\classes\ApplyExtendClass;
|
|
|
use biz\user\classes\UserClass;
|
|
|
use biz\user\services\UserService;
|
|
|
use common\components\noticeUtil;
|
|
|
@@ -19,98 +20,105 @@ use common\services\xhMerchantService;
|
|
|
|
|
|
class ApplyService extends BaseService
|
|
|
{
|
|
|
-
|
|
|
- public static $baseFile = '\biz\saas\classes\ApplyClass';
|
|
|
-
|
|
|
- //申请列表 shish 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');
|
|
|
- $merchantIdList = array_column($list, 'merchantId');
|
|
|
- $idList = array_merge($merchantIdList, $oldList);
|
|
|
- $idList = array_unique(array_filter($idList));
|
|
|
- $merchant = [];
|
|
|
- $merchant = MerchantService::getMerchantByIds($idList);
|
|
|
- foreach ($list as $key => $val) {
|
|
|
- $adminId = $val['adminId'];
|
|
|
- $introSjId = $val['introSjId'];
|
|
|
- }
|
|
|
- $data['list'] = $list;
|
|
|
- $data['balance'] = 0.00;
|
|
|
- $data['invitedNum'] = 10;
|
|
|
- $data['payNum'] = 5;
|
|
|
- $data['income'] = 100;
|
|
|
- return $data;
|
|
|
- }
|
|
|
-
|
|
|
- //审核通过
|
|
|
- public static function pass($id)
|
|
|
- {
|
|
|
- $apply = ApplyClass::getById($id);
|
|
|
- if (empty($apply)) {
|
|
|
- util::fail('没有找到申请记录');
|
|
|
- }
|
|
|
- $apply['merchantName'] = isset($apply['name']) ? $apply['name'] : '';
|
|
|
- $adminId = $apply['adminId'];
|
|
|
- $admin = AdminClass::getById($adminId);
|
|
|
- $apply['adminName'] = isset($admin['adminName']) ? $admin['adminName'] : '';
|
|
|
- return MerchantClass::generateMerchant($apply);
|
|
|
- }
|
|
|
-
|
|
|
- //申请开店 shish 2021.01.28
|
|
|
- public static function addApply($data)
|
|
|
- {
|
|
|
- $style = $data['style'] ?? 0;
|
|
|
- if (in_array($style, [MerchantClass::STYLE_RETAIL, MerchantClass::STYLE_SUPPLIER]) == false) {
|
|
|
- util::fail('请确认开店资料');
|
|
|
- }
|
|
|
- $mobile = $data['mobile'] ?? 0;
|
|
|
- if (empty($mobile)) {
|
|
|
- util::fail('请填写手机号');
|
|
|
- }
|
|
|
- if (stringUtil::isMobile($mobile) == false) {
|
|
|
- util::fail('请填写正确手机号');
|
|
|
- }
|
|
|
- $adminId = $data['adminId'] ?? 0;
|
|
|
- $apply = ApplyClass::getByCondition(['mobile' => $mobile, 'style' => $style]);
|
|
|
- if (!empty($apply)) {
|
|
|
- util::fail('手机号已被使用');
|
|
|
- }
|
|
|
- $from = $data['from'] ?? 0;
|
|
|
- if (in_array($from, [ApplyClass::FROM_GHS, ApplyClass::FROM_RETAIL]) == false) {
|
|
|
- util::fail('请确认开店资料是否完整!');
|
|
|
- }
|
|
|
- $apply = ApplyClass::getByCondition(['adminId' => $adminId, 'from' => $from, 'style' => $style]);
|
|
|
- if (!empty($apply)) {
|
|
|
- util::fail('您已经申请过了');
|
|
|
- }
|
|
|
- $prefix = $data['province'] == $data['city'] ? $data['province'] : $data['province'] . $data['city'];
|
|
|
- $dist = $data['dist'] ?? '';
|
|
|
- $floor = $data['floor'] ?? '';
|
|
|
- $address = $data['address'] ?? '';
|
|
|
- $data['fullAddress'] = $prefix . $dist . $address . $floor;
|
|
|
- ApplyClass::addApply($data);
|
|
|
- $mobile = $data['mobile'];
|
|
|
- if ($style == MerchantClass::STYLE_RETAIL) {
|
|
|
- $text = "零售申请开店,";
|
|
|
- } else {
|
|
|
- $text = "供货商申请开店,";
|
|
|
- }
|
|
|
- $text .= '客户(' . $mobile . ')已提交资料,';
|
|
|
- $introSjId = $data['introSjId'] ?? 0;
|
|
|
- if (!empty($introSjId)) {
|
|
|
- $merchant = MerchantClass::getMerchantById($introSjId);
|
|
|
- $name = $merchant['merchantName'] ?? '';
|
|
|
- $text .= "介绍人:{$name},";
|
|
|
- }
|
|
|
- $text .= "请及时跟进";
|
|
|
- noticeUtil::push($text, '15280215347');
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
+ public static $baseFile = '\biz\saas\classes\ApplyClass';
|
|
|
+
|
|
|
+ //申请列表 shish 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');
|
|
|
+ $merchantIdList = array_column($list, 'merchantId');
|
|
|
+ $ids = array_merge($merchantIdList, $oldList);
|
|
|
+ $ids = array_unique(array_filter($ids));
|
|
|
+ $merchant = MerchantClass::getMerchantByIds($ids);
|
|
|
+
|
|
|
+ $applyIds = array_unique(array_filter(array_column($list, 'id')));
|
|
|
+ $extend = ApplyExtendClass::getExtendByIds($applyIds);
|
|
|
+
|
|
|
+ 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 = $merchant[$introSjId]['merchantName'] ?? '';
|
|
|
+ $list[$key]['introSjName'] = $introSjName;
|
|
|
+ }
|
|
|
+ $data['list'] = $list;
|
|
|
+ $data['balance'] = 0.00;
|
|
|
+ $data['invitedNum'] = 10;
|
|
|
+ $data['payNum'] = 5;
|
|
|
+ $data['income'] = 100;
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
+ //审核通过
|
|
|
+ public static function pass($id)
|
|
|
+ {
|
|
|
+ $apply = ApplyClass::getById($id);
|
|
|
+ if (empty($apply)) {
|
|
|
+ util::fail('没有找到申请记录');
|
|
|
+ }
|
|
|
+ $apply['merchantName'] = isset($apply['name']) ? $apply['name'] : '';
|
|
|
+ $adminId = $apply['adminId'];
|
|
|
+ $admin = AdminClass::getById($adminId);
|
|
|
+ $apply['adminName'] = isset($admin['adminName']) ? $admin['adminName'] : '';
|
|
|
+ return MerchantClass::generateMerchant($apply);
|
|
|
+ }
|
|
|
+
|
|
|
+ //申请开店 shish 2021.01.28
|
|
|
+ public static function addApply($data)
|
|
|
+ {
|
|
|
+ $style = $data['style'] ?? 0;
|
|
|
+ if (in_array($style, [MerchantClass::STYLE_RETAIL, MerchantClass::STYLE_SUPPLIER]) == false) {
|
|
|
+ util::fail('请确认开店资料');
|
|
|
+ }
|
|
|
+ $mobile = $data['mobile'] ?? 0;
|
|
|
+ if (empty($mobile)) {
|
|
|
+ util::fail('请填写手机号');
|
|
|
+ }
|
|
|
+ if (stringUtil::isMobile($mobile) == false) {
|
|
|
+ util::fail('请填写正确手机号');
|
|
|
+ }
|
|
|
+ $adminId = $data['adminId'] ?? 0;
|
|
|
+ $apply = ApplyClass::getByCondition(['mobile' => $mobile, 'style' => $style]);
|
|
|
+ if (!empty($apply)) {
|
|
|
+ util::fail('手机号已被使用');
|
|
|
+ }
|
|
|
+ $from = $data['from'] ?? 0;
|
|
|
+ if (in_array($from, [ApplyClass::FROM_GHS, ApplyClass::FROM_RETAIL]) == false) {
|
|
|
+ util::fail('请确认开店资料是否完整!');
|
|
|
+ }
|
|
|
+ $apply = ApplyClass::getByCondition(['adminId' => $adminId, 'from' => $from, 'style' => $style]);
|
|
|
+ if (!empty($apply)) {
|
|
|
+ util::fail('您已经申请过了');
|
|
|
+ }
|
|
|
+ $prefix = $data['province'] == $data['city'] ? $data['province'] : $data['province'] . $data['city'];
|
|
|
+ $dist = $data['dist'] ?? '';
|
|
|
+ $floor = $data['floor'] ?? '';
|
|
|
+ $address = $data['address'] ?? '';
|
|
|
+ $data['fullAddress'] = $prefix . $dist . $address . $floor;
|
|
|
+ ApplyClass::addApply($data);
|
|
|
+ $mobile = $data['mobile'];
|
|
|
+ if ($style == MerchantClass::STYLE_RETAIL) {
|
|
|
+ $text = "零售申请开店,";
|
|
|
+ } else {
|
|
|
+ $text = "供货商申请开店,";
|
|
|
+ }
|
|
|
+ $text .= '客户(' . $mobile . ')已提交资料,';
|
|
|
+ $introSjId = $data['introSjId'] ?? 0;
|
|
|
+ if (!empty($introSjId)) {
|
|
|
+ $merchant = MerchantClass::getMerchantById($introSjId);
|
|
|
+ $name = $merchant['merchantName'] ?? '';
|
|
|
+ $text .= "介绍人:{$name},";
|
|
|
+ }
|
|
|
+ $text .= "请及时跟进";
|
|
|
+ noticeUtil::push($text, '15280215347');
|
|
|
+ }
|
|
|
+
|
|
|
}
|