|
|
@@ -2,12 +2,12 @@
|
|
|
|
|
|
namespace ghs\controllers;
|
|
|
|
|
|
-use biz\shop\classes\ShopClass;
|
|
|
use biz\sj\classes\SjClass;
|
|
|
-use biz\sj\services\MerchantService;
|
|
|
use bizGhs\custom\classes\CustomClass;
|
|
|
use bizGhs\custom\services\CustomService;
|
|
|
use bizHd\saas\classes\ApplyClass;
|
|
|
+use bizHd\saas\services\ApplyService;
|
|
|
+use common\components\imgUtil;
|
|
|
use common\components\stringUtil;
|
|
|
use common\components\util;
|
|
|
use Yii;
|
|
|
@@ -45,68 +45,43 @@ class CustomController extends BaseController
|
|
|
if (!empty($has)) {
|
|
|
util::fail('手机号已经添加过');
|
|
|
}
|
|
|
-
|
|
|
- $data = [
|
|
|
- 'id' => 2,
|
|
|
- 'name' => '小石头',
|
|
|
- 'avatar' => 'https://img.huaml.com/ghs/home/deserve.png',
|
|
|
- ];
|
|
|
- util::success($data);
|
|
|
-
|
|
|
$connection = Yii::$app->db;
|
|
|
$transaction = $connection->beginTransaction();
|
|
|
try {
|
|
|
- $date = date("Y-m-d H:i:s");
|
|
|
$shop = $this->shop;
|
|
|
+ $sjId = $this->sjId;
|
|
|
+ $shopId = $this->shopId;
|
|
|
+ $sjName = $this->sj->name ?? '';
|
|
|
$city = $shop->city ?? '';
|
|
|
$dist = $shop->dist ?? '';
|
|
|
$address = $post['address'] ?? '';
|
|
|
- $fullAddress = $city . $dist . $address;
|
|
|
- $apply = [
|
|
|
- 'logo' => '',
|
|
|
- 'name' => '',
|
|
|
- 'hasLicense' => '',
|
|
|
- 'licenseNo' => '',
|
|
|
- 'certType' => '',
|
|
|
- 'adminId' => '',
|
|
|
- 'adminName' => '未命名',
|
|
|
+ $applyData = [
|
|
|
+ 'name' => $name,
|
|
|
+ 'licenseNo' => $mobile,
|
|
|
+ 'certType' => ApplyClass::CERT_TYPE_MOBILE,
|
|
|
'mobile' => $mobile,
|
|
|
- 'introSjId' => 0,
|
|
|
- 'introSjName' => '',
|
|
|
- 'introShopId' => 0,
|
|
|
- 'customId' => '',
|
|
|
- 'shopAdminId' => '',
|
|
|
- 'from' => '',
|
|
|
- 'fee' => '',
|
|
|
- 'income' => '',
|
|
|
- 'sjId' => '',
|
|
|
+ 'introSjId' => $sjId,
|
|
|
+ 'introSjName' => $sjName,
|
|
|
+ 'introShopId' => $shopId,
|
|
|
+ 'from' => ApplyClass::FROM_GHS,
|
|
|
'style' => SjClass::STYLE_RETAIL,
|
|
|
- 'main' => '',
|
|
|
- 'long' => '',
|
|
|
- 'lat' => '',
|
|
|
'province' => $shop->province ?? '',
|
|
|
'city' => $city,
|
|
|
'dist' => $dist,
|
|
|
'address' => $address,
|
|
|
- 'floor' => '',
|
|
|
- 'fullAddress' => $fullAddress,
|
|
|
- 'showAddress' => '',
|
|
|
- 'remark' => '',
|
|
|
- 'status' => 2,
|
|
|
- 'addTime' => $date,
|
|
|
- 'updateTime' => $date,
|
|
|
+ 'status' => ApplyClass::STATUS_PASS,
|
|
|
+ 'replace' => 1,//1表示供货商添加的客户
|
|
|
];
|
|
|
- $sj = MerchantService::initSjInfo($apply);
|
|
|
- $sjId = $sj['id'] ?? 0;
|
|
|
- if (empty($sjId)) {
|
|
|
- util::fail('添加客户没有成功');
|
|
|
- }
|
|
|
- $hdShop = ShopClass::getByCondition(['sjId' => $sjId], true);
|
|
|
- $hdShopId = $hdShop->id ?? 0;
|
|
|
+ $apply = ApplyService::replaceRetail($applyData);
|
|
|
+ $id = $apply['id'] ?? 0;
|
|
|
+ $respond = ApplyService::pass($id);
|
|
|
+ $shop = $respond['shop'];
|
|
|
+ $hdShopId = $shop->id ?? 0;
|
|
|
if (empty($hdShopId)) {
|
|
|
- util::fail('添加客户没有成功!');
|
|
|
+ util::fail('客户没有添加成功!');
|
|
|
}
|
|
|
$custom = CustomClass::build($this->shopId, $hdShopId);
|
|
|
+ $custom['avatar'] = imgUtil::groupImg($custom['avatar']);
|
|
|
$transaction->commit();
|
|
|
util::success($custom);
|
|
|
} catch (\Exception $exception) {
|