|
|
@@ -3,14 +3,10 @@
|
|
|
namespace bizGhs\custom\classes;
|
|
|
|
|
|
use biz\ghs\classes\GhsClass;
|
|
|
-use biz\shop\classes\ShopClass;
|
|
|
use biz\sj\classes\MerchantClass;
|
|
|
-use biz\sj\classes\SjClass;
|
|
|
use common\components\business;
|
|
|
use common\components\imgUtil;
|
|
|
-use common\components\stringUtil;
|
|
|
use common\components\util;
|
|
|
-use Yii;
|
|
|
use bizHd\base\classes\BaseClass;
|
|
|
|
|
|
class CustomClass extends BaseClass
|
|
|
@@ -21,148 +17,10 @@ class CustomClass extends BaseClass
|
|
|
const IS_DEBT_NO = 0;
|
|
|
const IS_DEBT_YES = 1;
|
|
|
|
|
|
- //申请开店建立客户关系 ssh 2021.2.28
|
|
|
- //GhsClass::build()也有相似流程
|
|
|
- public static function buildCustom($applyData, $newSj, $newShop)
|
|
|
+ //建立客户和供货商关系
|
|
|
+ public static function build($ghsShopId, $hdShopId)
|
|
|
{
|
|
|
- $sjId = $newSj['id'] ?? 0;
|
|
|
- $shopId = $newShop['id'] ?? 0;
|
|
|
- $sjName = $newSj['name'] ?? '';
|
|
|
- $shopName = $newShop['shopName'] ?? '';
|
|
|
- $currentName = $sjName . ' ' . $shopName;
|
|
|
- $currentPy = stringUtil::py($currentName);
|
|
|
- if ($applyData['style'] == SjClass::STYLE_RETAIL) {
|
|
|
- if ($applyData['introStyle'] == SjClass::STYLE_SUPPLIER) {
|
|
|
- $custom = self::getByCondition(['ownShopId' => $applyData['introShopId'], 'shopId' => $shopId]);
|
|
|
- if (empty($custom)) {
|
|
|
- $customData = [
|
|
|
- 'sjId' => $sjId,//零售商家id
|
|
|
- 'shopId' => $shopId,//零售门店id
|
|
|
- 'ownSjId' => $applyData['introSjId'],//供货商id
|
|
|
- 'name' => $currentName,
|
|
|
- 'py' => $currentPy,
|
|
|
- 'mobile' => $applyData['mobile'],
|
|
|
- 'province' => $applyData['province'] ?? '',
|
|
|
- 'city' => $applyData['city'] ?? '',
|
|
|
- 'dist' => $applyData['dist'] ?? '',
|
|
|
- 'address' => $applyData['address'] ?? '',
|
|
|
- 'fullAddress' => $applyData['fullAddress'],
|
|
|
- 'long' => $applyData['long'],
|
|
|
- 'lat' => $applyData['lat'],
|
|
|
- ];
|
|
|
- $custom = self::addCustom($customData);
|
|
|
- }
|
|
|
- $customId = $custom['id'];
|
|
|
-
|
|
|
- $introShopId = $applyData['introShopId'] ?? 0;
|
|
|
- $ghsShop = ShopClass::getShopInfo($introShopId);
|
|
|
- if (empty($ghsShop)) {
|
|
|
- util::fail('没有找到门店');
|
|
|
- }
|
|
|
- $introSjId = $applyData['introSjId'] ?? 0;
|
|
|
- $ghsSj = SjClass::getById($introSjId);
|
|
|
- if (empty($ghsSj)) {
|
|
|
- util::fail('没有找到商家');
|
|
|
- }
|
|
|
- $ghs = GhsClass::getByCondition(['ownShopId' => $shopId, 'shopId' => $ghsShop['id']]);
|
|
|
- if (empty($ghs)) {
|
|
|
- $shopName = $ghsShop['shopName'] ?? '';
|
|
|
- $ghsSjName = $ghsSj['name'] ?? '';
|
|
|
- $name = $ghsSjName . ' ' . $shopName;
|
|
|
- $py = stringUtil::py($name);
|
|
|
- $mobile = $ghsShop['mobile'] ?? '';
|
|
|
- $ghsData = [
|
|
|
- 'sjId' => $ghsShop['merchantId'],
|
|
|
- 'customId' => $customId,
|
|
|
- 'shopId' => $ghsShop['id'],
|
|
|
- 'ownSjId' => $sjId,
|
|
|
- 'ownShopId' => $sjId,
|
|
|
- 'name' => $name,
|
|
|
- 'py' => $py,
|
|
|
- 'mobile' => $mobile,
|
|
|
- 'province' => $ghsShop['province'] ?? '',
|
|
|
- 'city' => $ghsShop['city'] ?? '',
|
|
|
- 'dist' => $ghsShop['dist'] ?? '',
|
|
|
- 'address' => $ghsShop['address'] ?? '',
|
|
|
- 'floor' => $ghsShop['floor'] ?? '',
|
|
|
- 'fullAddress' => $ghsShop['fullAddress'] ?? '',
|
|
|
- 'lat' => $ghsShop['lat'] ?? '',
|
|
|
- 'long' => $ghsShop['long'] ?? '',
|
|
|
- ];
|
|
|
- $ghs = GhsClass::addGhs($ghsData);
|
|
|
- $ghsId = $ghs['id'] ?? 0;
|
|
|
- self::updateById($customId, ['ghsId' => $ghsId]);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if ($applyData['style'] == SjClass::STYLE_SUPPLIER) {
|
|
|
- if ($applyData['introStyle'] == SjClass::STYLE_RETAIL) {
|
|
|
- $has = self::getByCondition(['ownShopId' => $shopId, 'shopId' => $applyData['introShopId']]);
|
|
|
- $introSjId = $applyData['introSjId'] ?? 0;
|
|
|
- $introShopId = $applyData['introShopId'] ?? 0;
|
|
|
- if (empty($has)) {
|
|
|
- $shop = ShopClass::getShopInfo($introShopId);
|
|
|
- $thisSj = SjClass::getById($introSjId);
|
|
|
- if (empty($thisSj)) {
|
|
|
- util::fail('没有找到商家');
|
|
|
- }
|
|
|
- $shopName = $shop['shopName'] ?? '';
|
|
|
- $sjName = $thisSj['name'] ?? '';
|
|
|
- $name = $sjName . ' ' . $shopName;
|
|
|
- $py = stringUtil::py($name);
|
|
|
- $super = ShopClass::getSuper($introShopId);
|
|
|
- $mobile = $super['mobile'] ?? '';
|
|
|
- $customData = [
|
|
|
- 'sjId' => $introSjId,//零售商id
|
|
|
- 'shopId' => $introShopId,//零售门店id
|
|
|
- 'ownSjId' => $sjId,//供货商id
|
|
|
- 'name' => $name,
|
|
|
- 'py' => $py,
|
|
|
- 'mobile' => $mobile,
|
|
|
- 'isOpen' => 1,
|
|
|
- 'province' => $applyData['province'] ?? '',
|
|
|
- 'city' => $applyData['city'] ?? '',
|
|
|
- 'dist' => $applyData['dist'] ?? '',
|
|
|
- 'address' => $applyData['address'] ?? '',
|
|
|
- 'fullAddress' => $applyData['fullAddress'],
|
|
|
- 'long' => $applyData['long'],
|
|
|
- 'lat' => $applyData['lat'],
|
|
|
- ];
|
|
|
- $has = self::addCustom($customData);
|
|
|
- }
|
|
|
- $customId = $has['id'] ?? 0;
|
|
|
- $ghs = GhsClass::getByCondition(['ownShopId' => $introShopId, 'shopId' => $shopId]);
|
|
|
- if (empty($ghs)) {
|
|
|
- $shopName = $newShop['shopName'] ?? '';
|
|
|
- $sjName = $newSj['name'] ?? '';
|
|
|
- $name = $sjName . ' ' . $shopName;
|
|
|
- $py = stringUtil::py($name);
|
|
|
- $mobile = $newShop['mobile'] ?? '';
|
|
|
- $ghsData = [
|
|
|
- 'sjId' => $sjId,
|
|
|
- 'shopId' => $shopId,
|
|
|
- 'ownSjId' => $introSjId,
|
|
|
- 'ownShopId' => $introShopId,
|
|
|
- 'name' => $name,
|
|
|
- 'customId' => $customId,
|
|
|
- 'py' => $py,
|
|
|
- 'mobile' => $mobile,
|
|
|
- 'province' => $newShop['province'] ?? '',
|
|
|
- 'city' => $newShop['city'] ?? '',
|
|
|
- 'dist' => $newShop['dist'] ?? '',
|
|
|
- 'address' => $newShop['address'] ?? '',
|
|
|
- 'floor' => $newShop['floor'] ?? '',
|
|
|
- 'fullAddress' => $newShop['fullAddress'] ?? '',
|
|
|
- 'lat' => $newShop['lat'] ?? '',
|
|
|
- 'long' => $newShop['long'] ?? '',
|
|
|
- ];
|
|
|
- $ghs = GhsClass::addGhs($ghsData);
|
|
|
- $ghsId = $ghs['id'] ?? 0;
|
|
|
- self::updateById($customId, ['ghsId' => $ghsId]);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ return GhsClass::build($ghsShopId, $hdShopId);
|
|
|
}
|
|
|
|
|
|
//添加客户 ssh 2021.2.24
|