|
|
@@ -3,6 +3,10 @@
|
|
|
namespace bizHd\ghs\services;
|
|
|
|
|
|
use bizHd\base\services\BaseService;
|
|
|
+use bizHd\saas\classes\ApplyClass;
|
|
|
+use bizHd\saas\services\ApplyService;
|
|
|
+use bizHd\shop\classes\ShopClass;
|
|
|
+use common\components\dict;
|
|
|
use common\components\orderSn;
|
|
|
use common\components\util;
|
|
|
use Yii;
|
|
|
@@ -17,6 +21,51 @@ class GhsService extends BaseService
|
|
|
{
|
|
|
$mobile = orderSn::getMobileSn();
|
|
|
$name = $data['name'] ?? '';
|
|
|
+
|
|
|
+ $hasApply = ApplyClass::getByCondition(['mobile' => $mobile], true);
|
|
|
+ if (!empty($hasApply)) {
|
|
|
+ util::fail('手机号已存在,请和管理员联系');
|
|
|
+ }
|
|
|
+ $has = ShopClass::getByCondition(['mobile' => $mobile], true);
|
|
|
+ if (!empty($has)) {
|
|
|
+ util::fail('手机号已经存在,请跟管理联系');
|
|
|
+ }
|
|
|
+
|
|
|
+ //将下面的环境定义为批发环境,后继代码可能要用到,不确定,避免风险 ssh 20230306
|
|
|
+ Yii::$app->params['ptStyle'] = 2;
|
|
|
+
|
|
|
+ $adminInfo = ['name' => $name, 'mobile' => $mobile, 'style' => 2, 'ghsMiniOpenId' => ''];
|
|
|
+ $fromApp = dict::getDict('userSourceGetId', 'app', 'id');
|
|
|
+ $admin = \bizGhs\admin\classes\AdminClass::replaceAdmin($adminInfo, $fromApp);
|
|
|
+ $adminId = $admin['id'] ?? 0;
|
|
|
+ $applyData = [
|
|
|
+ 'mobile' => $mobile,
|
|
|
+ 'name' => $name,
|
|
|
+ 'from' => ApplyClass::FROM_GHS,
|
|
|
+ 'lat' => '40.023916',
|
|
|
+ 'long' => '116.298875',
|
|
|
+ 'live' => 0,
|
|
|
+ 'adminId' => $adminId,
|
|
|
+ 'province' => '北京市',
|
|
|
+ 'city' => '北京市',
|
|
|
+ 'address' => '上地',
|
|
|
+ 'showAddress' => '上地',
|
|
|
+ 'style' => 0,
|
|
|
+ ];
|
|
|
+ $apply = ApplyService::replaceGhs($applyData);
|
|
|
+ $applyId = $apply['id'] ?? 0;
|
|
|
+ if (empty($applyId)) {
|
|
|
+ util::fail('没有找到申请记录');
|
|
|
+ }
|
|
|
+ \bizGhs\apply\services\ApplyService::pass($applyId);
|
|
|
+
|
|
|
+ $ghsShop = ShopClass::getByCondition(['mobile' => $mobile, 'ptStyle' => dict::getDict('ptStyle', 'ghs')], true);
|
|
|
+ if (empty($ghsShop)) {
|
|
|
+ util::fail('供货商没有生成,请联系管理员');
|
|
|
+ }
|
|
|
+ $ghsShopId = $ghsShop->id ?? 0;
|
|
|
+ $hdShopId = $hdShop->id ?? 0;
|
|
|
+ \bizGhs\custom\classes\CustomClass::build($ghsShopId, $hdShopId);
|
|
|
}
|
|
|
|
|
|
}
|