| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- namespace bizGhs\apply\services;
- use biz\cp\services\PtCpService;
- use biz\shop\classes\ShopClass;
- use biz\shop\classes\ShopExtClass;
- use bizGhs\apply\classes\ApplyClass;
- use bizGhs\item\classes\ItemClassClass;
- use bizGhs\merchant\services\MerchantService;
- use bizGhs\shop\classes\MainClass;
- use bizHd\merchant\services\SjService;
- use common\components\util;
- use bizGhs\base\services\BaseService;
- class ApplyService extends BaseService
- {
- public static $baseFile = '\bizGhs\apply\classes\ApplyClass';
- //审核通过,商家初始化 ssh 2021.2.23
- public static function pass($id, $remark = '')
- {
- $apply = ApplyClass::getById($id);
- if (empty($apply)) {
- util::fail('没有找到申请记录');
- }
- $applyId = $apply['id'];
- $live = isset($apply['live']) ? $apply['live'] : 1;
- $mobile = $apply['mobile'] ?? '';
- if (empty($mobile)) {
- util::fail('没有找到手机号');
- }
- $lsShop = ShopClass::getByCondition(['mobile' => $mobile, 'ptStyle' => 1], true);
- if (empty($lsShop)) {
- $main = MainClass::addMain();
- $ret = SjService::initHdBaseInfo($apply, $main);
- $lsShop = $ret['shop'] ?? [];
- } else {
- $mainId = $lsShop->mainId ?? 0;
- $lsShop->onlyCg = 0;
- $lsShop->save();
- $main = MainClass::getById($mainId, true);
- if (empty($main)) {
- util::fail('没有main信息21');
- }
- }
- //收款码要做成不算收入
- $lsShopId = $lsShop->id;
- $lsExt = ShopExtClass::getByCondition(['shopId' => $lsShopId], true);
- if (!empty($lsExt)) {
- $lsExt->gatherRepeat = 1;
- $lsExt->save();
- }
- ApplyClass::updateById($applyId, ['status' => ApplyClass::STATUS_PASS, 'remark' => $remark]);
- $apply['name'] = isset($apply['name']) ? $apply['name'] : '';
- //初始化或更新花材
- if (isset($apply['all']) && $apply['all'] == 1) {
- MainClass::addMainInitItem($main, $live);
- } else {
- //单品不需要导入花材
- $mainId = $main->id ?? 0;
- $classData = ['mainId' => $mainId, 'name' => '默认分类', 'inTurn' => -1, 'isDefault' => 1,];
- ItemClassClass::add($classData, true);
- }
- //初始化或更新产品
- //PtCpService::initMainCp($main);
- $respond = MerchantService::initGhsBaseInfo($apply, $main, true);
- $pfShop = $respond['shop'] ?? [];
- $lsShop->pfShopId = $pfShop->id ?? 0;
- $lsShop->save();
- $pfShop->lsShopId = $lsShop->id ?? 0;
- $pfShop->save();
- return $respond;
- }
- }
|