id ?? 0; unset($applyData['id']); $ptStyle = dict::getDict('ptStyle', 'hd'); //生成商家 $applyData['accountStyle'] = 0; $applyData['status'] = 1; $applyData['lat'] = $applyData['lat'] ?? (string)0; $applyData['long'] = $applyData['long'] ?? (string)0; $applyData['precision'] = (string)0; $applyData['wxToken'] = stringUtil::buildWxToken(0); $applyData['photoList'] = $applyData['photoList'] ?? ''; $applyData['name'] = $applyData['name'] ?? ''; $applyData['province'] = $applyData['province'] ?? ''; $applyData['city'] = $applyData['city'] ?? ''; $applyData['dist'] = $applyData['dist'] ?? ''; $applyData['address'] = $applyData['address'] ?? ''; $applyData['agentLevel'] = 1; $deadline = time() + 365 * 86400 * 2; $applyData['deadline'] = date("Y-m-d H:i:s", $deadline); if ($applyOpen) { $applyData['parentId'] = $applyData['introSjId'] ?? 0; $applyData['parentShopId'] = $applyData['introShopId'] ?? 0; } $jsData = $applyData; $sjData['style'] = $ptStyle; $sjData['live'] = $live; $sj = self::add($jsData, true); $sjId = $sj->id; $sjName = $sj->name ?? 0; $mobile = $applyData['mobile'] ?? ''; if (!empty($applyId) && $applyOpen == true) { ApplyClass::updateById($applyId, ['sjId' => $sjId]); } //生成资产 $assetData = [ 'balance' => 0, 'totalVisit' => 0, 'totalUser' => 0, 'totalMember' => 0, 'totalFans' => 0, 'totalIntegral' => 0, 'totalPoint' => 0, 'totalGoods' => 0, 'totalRecharge' => 0, 'totalOrder' => 0, 'totalDeal' => 0, 'sjId' => $sjId, 'totalIncome' => 0, 'totalExpend' => 0, ]; SjAssetClass::add($assetData); //生成商家拓展信息 $extendData = [ 'sjId' => $sjId, 'wxAppId' => isset($applyData['wxAppId']) ? $applyData['wxAppId'] : '', 'webTitle' => isset($applyData['name']) ? $applyData['name'] : '', 'webKeyword' => isset($applyData['name']) ? $applyData['name'] : '', 'webDescription' => isset($applyData['name']) ? $applyData['name'] : '', 'wxMenuInit' => 0, 'wxTMessageInit' => 0, 'payment' => 0,//支付功能关闭 'recharge' => 0,//充值功能关闭 'giveCoupon' => 1,//默认赠送代金劵 'giveCouponPrice' => 5,//代金劵金额5元 'couponMeetPrice' => 180,//满足金额 'couponValidity' => 30,//代金劵有效期30天 'alipayAccount' => isset($applyData['alipayAccount']) ? $applyData['alipayAccount'] : '',//提现的支付宝帐号 'alipayAccountName' => isset($applyData['alipayAccountName']) ? $applyData['alipayAccountName'] : '',//提现支付宝帐号姓名 'gradeList' => '1_2000_0.9I2_5000_0.88I3_10000_0.85I4_20000_0.8',//1 级会员需要满 2000 积分 购物享9折;2 级会员需要满 5000 积分 购物享88折 ]; SjExtendClass::add($extendData); SjInitClass::add(['sjId' => $sjId]); $onlyCg = 1; //app注册的,打开全部功能 if (isset($applyData['appRegister']) && $applyData['appRegister'] == 1) { //$onlyCg = 0; } //给10天时间 $deadTime = time()+864000; //创建门店 $shopData = [ 'shopName' => '首店', 'sjId' => $sjId, 'merchantName' => $sjName, 'telephone' => $mobile, 'default' => 1, 'adminId' => $adminId, 'mainId' => $mainId, 'parentId' => $applyData['introSjId'] ?? 0, 'parentShopId' => $applyData['introShopId'] ?? 0, 'mobile' => $mobile, 'introduction' => '欢迎光临', 'province' => $applyData['province'] ?? '', 'city' => $applyData['city'] ?? '', 'dist' => $applyData['dist'] ?? '', 'address' => $applyData['address'] ?? '', 'floor' => $applyData['floor'] ?? '', 'fullAddress' => $applyData['fullAddress'] ?? '', 'showAddress' => $applyData['showAddress'] ?? '', 'open' => 1, 'lat' => $applyData['lat'] ?? '', 'long' => $applyData['long'] ?? '', 'img' => ['/example/shop/1.jpg'], 'ptStyle' => $ptStyle, 'live' => $live, 'onlyCg' => $onlyCg, 'deadline'=> date("Y-m-d H:i:s", $deadTime), 'beforeDeadline'=> date("Y-m-d H:i:s"), ]; $shopInfo = ShopClass::addShop($shopData); $shopId = $shopInfo->id; //变更状态和设置商家的默认门店 $sjData = []; $sjData['defaultShopId'] = $shopId; $sjStatus = SjClass::STATUS_HAS_CHECK; $sjData['status'] = $sjStatus; SjClass::updateById($sjId, $sjData); //建立供货商和客户关系 if ($applyOpen) { CustomService::shareBuildTrade($applyData, $shopInfo); } //生成保存默认客户 $user = UserClass::replaceUser(['mobile' => $mobile]); $result = CustomClass::buildRelation($shopInfo, $user); $custom = $result['custom']; $customId = $custom->id ?? 0; $shopInfo->defaultCustomId = $customId; $shopInfo->save(); if ($live == 1) { //初始化种类 $initKindData = ['mainId' => $mainId, 'sjId' => $sjId]; KindClass::initKind($initKindData); } //充值送钱初始化 RechargeSqClass::initData($shopInfo); //会员等级初始化 MemberLevelClass::initData($shopInfo); return ['sj' => $sj, 'shop' => $shopInfo]; } }