1, 'msg' => '', ]; } $query = Store::find()->where([ 'is_delete' => 0, ])->andWhere(['like', 'name',$name."%" , false]); $query->select("id,name,logo"); $pagination = pagination_make($query); return [ 'code' => 0, 'msg' => 'success', 'data' => [ 'data' => $pagination['list'], 'pageNo' => $pagination['pageNo'], 'totalCount' => $pagination['totalCount'] ], ]; } //商盟店铺列表 public function getAllianceList(){ $category_id = get_params('categoryId'); $name = get_params('name'); $query = Store::find()->where([ 'is_delete' => 0, ]); if($category_id){ $query->andWhere(['category_id'=>$category_id]); } if($name){ $query->andWhere(['like', 'name',$name."%" , false]); } $query->select("id,name,logo"); $pagination = pagination_make($query); if(isset($pagination['list']) && count($pagination['list']) > 0){ foreach($pagination['list'] as $key=>$val){ //获取6条商品记录 $goodsInfo = Goods::find()->where(['store_id'=>$val['id'],'is_delete'=>0,'status'=>1])->select("id,name,price,original_price,cover_pic")->limit(6)->asArray()->all(); if(count($goodsInfo) > 0){ $pagination['list'][$key]['goodsInfo'] = $goodsInfo; }else{ $pagination['list'][$key]['goodsInfo'] = []; } } } return [ 'code' => 0, 'msg' => 'success', 'data' => [ 'data' => $pagination['list'], 'pageNo' => $pagination['pageNo'], 'totalCount' => $pagination['totalCount'] ], ]; } public function getList($admin_id = null, $andWhere = null) { $id = $this->id; $name = $this->name; $user_name = $this->user_name; $status = $this->status; $mobile = $this->mobile; $start_time = $this->start_time; $end_time = $this->end_time; $query = Store::find()->where([ 's.is_delete' => 0, ]); if($andWhere){ $query->andWhere($andWhere); } if ($this->business_model > -1) { $query->andWhere(['s.business_model' => $this->business_model]); } if (!empty($id)) { $query->andWhere(['s.id' => $id]); } if (!empty($name)) { $query->andWhere(['LIKE', 's.name', $name]); } // if (!empty($mobile)) { // $query->andWhere(['LIKE', 's.contact_tel', $mobile]); // } if (!empty($this->province_id)) { $query->andWhere(['s.province_id' => $this->province_id]); } if (!empty($this->city_id)) { $query->andWhere(['s.city_id' => $this->city_id]); } if (!empty($this->district_id)) { $query->andWhere(['s.district_id' => $this->district_id]); } if ($start_time) { $start_time = strtotime($start_time); $query->andWhere(['>=', 's.created_at', $start_time]); } if ($end_time) { $end_time = strtotime($end_time); $query->andWhere(['<=', 's.created_at', $end_time]); } if ($this->integral_profit_status !== null && intval($this->integral_profit_status) !== -1 && in_array($this->integral_profit_status, [0, 1])) { $profit_where = ['>', 'value', 0]; $store_id_arr = Option::find()->where(['name' => ['face_pay_integral_profit', 'online_pay_integral_profit'], 'group' => 'saas']) ->andWhere($profit_where)->select('store_id')->column(); if (intval($this->integral_profit_status) === 1) { $query->andWhere(['in', 's.id', $store_id_arr]); } else { $query->andWhere(['NOT IN', 's.id', $store_id_arr]); } } if ($admin_id) { $ids = Salesman::find()->where(['admin_id' => $admin_id, 'is_delete' => 0])->select('saas_user_id, id')->asArray()->all(); $store_ids = SalesmanNewStore::find()->where(['salesman_saas_id' => array_column($ids, 'saas_user_id')]) ->andWhere(['>', 'store_id', 0])->select('store_id')->column(); $admin_model = Admin::findOne($admin_id); if ($admin_model->type === Admin::ADMIN_TYPE_DEFAULT) { //如果是区域代理 $area_level = $admin_model->area_level; if($area_level == 1){ $query->andWhere([ 'or', ['s.province_id' => $admin_model->province_id, 's.city_id' => $admin_model->city_id, 's.district_id' => $admin_model->district_id], ['s.admin_id' => $admin_id] ]); } elseif ($area_level == 2){ $query->andWhere([ 'or', ['s.province_id' => $admin_model->province_id, 's.city_id' => $admin_model->city_id], ['s.admin_id' => $admin_id] ]); } elseif ($area_level == 3){ $query->andWhere([ 'or', ['s.province_id' => $admin_model->province_id], ['s.admin_id' => $admin_id] ]); } else { $query->andWhere(['s.admin_id' => $admin_id]); } } elseif ($admin_model->type === Admin::ADMIN_TYPE_BD_AGENT) {//如果是推广代理 $query->andWhere([ 'or', ['s.admin_id' => $admin_id],//添加店铺时候修改的 ['in', 's.salesman_id', array_column($ids, 'id')],//修改店铺业务员时候修改的 ['in', 's.store_admin', array_column($ids, 'saas_user_id')],//修改店铺业务员时候修改的 ['in', 's.id', $store_ids]//业务员帮助店铺进件时候增加 ]); } } if ($this->category_id > 0) { // 筛选类目 $query->andWhere(['s.category_id' => $this->category_id]); } if ($this->mobile) { $query->andWhere(['su.mobile' => $this->mobile]); } if ($user_name) { $query->andWhere(['LIKE', 'su.name', $user_name]); } $query->leftJoin(['a' => Admin::tableName()], 'a.type = "store" AND a.type_id = s.id'); $query->leftJoin(['su' => SaasUser::tableName()], 'a.saas_user_id = su.id'); $query->alias('s')->leftJoin(['c_s'=>StoreCloud::tableName()],'s.id=c_s.store_id')->select('s.*,c_s.id is_cloud_store,c_s.is_delete cloud_is_delete')->orderBy('s.id DESC'); if ($this->status > -1) { $query->leftJoin(['m' => MerchantInfo::tableName()], 's.id=m.bind_store_id')->andWhere(['m.is_delete' => 0]); if ($this->status == 1) { $query->andWhere(['<', 'm.status', 3]); } if ($this->status == 2) { $query->andWhere(['m.status' => 3]); } } $query->groupBy('s.id'); $pagination = pagination_make($query); $list = $pagination['list']; $currentAdmin = get_admin(); $cache = cacheLock(); foreach ($list as &$item) { $bd_agent = null; $salesman = null; if (empty($item['logo'])) { $item['logo'] = Option::get('web_log', $item['id'], 'web', '')['value']; } // if ($item['admin_id']) { // $bd_agent = Admin::findOne(['id' => $item['admin_id'], 'type' => 'bd_agent', 'is_delete' => 0]); // } if ($item['salesman_id']) { $salesman = Salesman::findOne(['id' => $item['salesman_id'], 'is_delete' => 0]); } else { $salesmanNewStore = \app\models\SalesmanNewStore::findOne(['store_id' => $item['id']]); if ($salesmanNewStore) { $salesman = Salesman::findOne(['saas_user_id' => $salesmanNewStore->salesman_saas_id, 'is_delete' => 0]); } if (!$salesman) { $salesman = Salesman::findOne(['saas_user_id' => $item['store_admin'], 'is_delete' => 0]); } } $salesman_admin = null; if (!empty($salesman)) { $salesman_admin = [ 'name' => SaasUser::findOne(['id' => $salesman->saas_user_id])->name ?? '' ]; if ($salesman->admin_id && empty($bd_agent)) { $bd_agent = Admin::findOne($salesman->admin_id); } } // $salesman_admin = Admin::findOne($salesman->admin_id); $agent_admin = !empty($bd_agent) ? $bd_agent : ''; $item['agent_admin'] = ($agent_admin && $agent_admin->type == Admin::ADMIN_TYPE_BD_AGENT) ? $agent_admin : null; $item['salesman_admin'] = $salesman_admin ?? null; $self_mini = Option::get('self_mini', $item['id'], 'store', 0)['value']; $item['self_mini'] = $self_mini; $saasU = SaasUser::findOne($item['store_admin']); $item['contact_tel'] = $saasU->mobile ?? ''; $item['admin_user_name'] = Admin::findOne(['type' => 'store', 'type_id' => $item['id']])->username; $item['admin_name'] = Admin::findOne(['type' => 'store', 'type_id' => $item['id']])->name; $item['face_pay_integral_profit'] = Option::get('face_pay_integral_profit', $item['id'], 'saas', 0)['value']; $item['online_pay_integral_profit'] = Option::get('online_pay_integral_profit', $item['id'], 'saas', 0)['value']; $item['integral_profit_status'] = 0; if ($item['face_pay_integral_profit'] > 0 && $item['online_pay_integral_profit'] > 0) { $item['integral_profit_status'] = 1; } $merchant_info = MerchantInfo::findOne(['bind_store_id' => $item['id'], 'is_delete' => 0]); if (!$merchant_info) { $item['wechat_audit_text'] = '待进件'; } else { if ($merchant_info->status == 1) { $item['wechat_audit_text'] = '审核中'; } else if ($merchant_info->status == 2) { $item['wechat_audit_text'] = '已驳回'; } else if ($merchant_info->status == 3) { $item['wechat_audit_text'] = '已完成'; } else { $item['wechat_audit_text'] = '待审核'; } } if ($item['is_alliance'] === '1') { $item['is_alliance'] = true; } else { $item['is_alliance'] = false; } // $option = Option::get('name', $item['id'], 'store', '-'); $item['store_name'] = $item['name']; if (! $admin_id) { $admin = Admin::findOne([ 'type' => 'store', 'type_id' => $item['id'] ]); if (!$admin) { $admin = Admin::findOne($item['store_admin_id']); } $item['admin'] = $admin; $item['admin_saas_user'] = $admin? SaasUser::findOne($admin->saas_user_id) : ''; $item['username'] = 'admin'; } else { $item['username'] = $currentAdmin->username; } $item['cat_name'] = '-'; if ($item['category_id'] > 0) { $cat = SaasCategory::findOne($item['category_id']); if ($cat) { $item['cat_name'] = $cat->name; } } // 初始化diy模板 $is = NewDiyTemplate::find() ->where([ 'store_id' => $item['id'], 'is_delete' => 0, 'type' => 100 ])->asArray()->one(); if (!$is) { $this->initDiyTemplate($item['id']); } $key = 'store_' . $item['id']. '_version'; if (\Yii::$app->prod_is_dandianpu()) { $self_mini = Option::get('self_mini', $item['id'], 'store', 0)['value']; if (!$self_mini) { $key = 'store_dandianpu_version'; } } $item['version'] = $cache->get($key) ?: ''; } $currentAdmin = get_admin(); $count = Store::find()->where(['admin_id' => $currentAdmin->id])->count(); $canStoreCount = $currentAdmin->max_app_count - $count; return [ 'code' => 0, 'msg' => 'success', 'data' => [ 'is_super_admin' => $currentAdmin->username == 'admin', 'data' => $list, 'pageNo' => $pagination['pageNo'], 'totalCount' => $pagination['totalCount'], 'canStoreCount' => $canStoreCount < 0 ? 0 : $canStoreCount, 'saas' => get_saas_user() ], ]; } public function getStoreList() { try { $query = Store::find()->where(['s.is_delete' => 0, 'a.is_delete' => 0])->alias('s') ->leftJoin(['c_s'=>StoreCloud::tableName()],'s.id=c_s.store_id') ->leftJoin(['a'=>Admin::tableName()],'s.admin_id=a.id');//TODO 显示全部店铺 不去掉已经选择的店铺 $admin = get_admin(); $admin_id = $admin->id; if ($admin->username == 'admin') { $admin_id = null; }if ($admin_id) { $ids = Salesman::find()->where(['admin_id' => $admin_id, 'is_delete' => 0])->select('id')->asArray()->all(); $admin_model = Admin::findOne($admin_id); $area_level = $admin_model->area_level; if($area_level == 1){ $query->andWhere([ 'or', ['s.province_id' => $admin_model->province_id, 's.city_id' => $admin_model->city_id, 's.district_id' => $admin_model->district_id], ['s.admin_id' => $admin_id], ['in', 's.salesman_id', array_column($ids, 'id')] ]); } elseif ($area_level == 2){ $query->andWhere([ 'or', ['s.province_id' => $admin_model->province_id, 's.city_id' => $admin_model->city_id], ['s.admin_id' => $admin_id], ['in', 's.salesman_id', array_column($ids, 'id')] ]); } elseif ($area_level == 3){ $query->andWhere([ 'or', ['s.province_id' => $admin_model->province_id], ['s.admin_id' => $admin_id], ['in', 's.salesman_id', array_column($ids, 'id')] ]); } else { $query->andWhere([ 'or', ['s.admin_id' => $admin_id], ['in', 's.salesman_id', array_column($ids, 'id')] ]); } } $store = $query->select('s.id, s.logo, s.name')->all(); return [ 'code' => 0, 'msg' => "获取成功", 'data' => $store ]; } catch (\Exception $e) { return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } public function add($name, $password = "", $username = "", $area = [], $saas_user_id = 0, $logo = "", $end_time = 0) { $t = \Yii::$app->db->beginTransaction(); try { // 取消强制添加手机管理员功能 // if (!$saas_user_id) { // throw new Exception('请选择管理员用户!'); // } if (!$name) { throw new Exception('请输入商城名称!'); } //判断后台开启通联 // $oldConf = Option::get(OptionSetting::SAAS_YUNST_SETTING, 0, 'saas')['value']; // if ($oldConf) { // $oldConf = json_decode($oldConf, true); // if (!empty($oldConf) && !empty(trim($oldConf['appid']))) { // if (!$store_number) { // throw new Exception('请输入商城会员编号!'); // } // $store_info = Store::find()->where(['is_delete' => 0, 'store_number' => $store_number])->one(); // if ($store_info){ // throw new Exception('会员编号已存在'); // } // // //调用第三方会员创建接口 // $memberService = new MemberService(); // $res_member = $memberService->createMember($store_number,2); // debug_log($res_member); // if ($res_member['subCode'] == "FAIL"){ // throw new Exception($res_member['subMsg']); // } // } // } //判断如果是区域代理就直接使用区域代理的省市区地址 $area_admin = get_admin(); if ($area_admin->type === Admin::ADMIN_TYPE_DEFAULT && $area_admin->username !== "admin") { $area['province_id'] = $area_admin->province_id; $area['city_id'] = $area_admin->city_id; $area['district_id'] = $area_admin->district_id; } // 判断是否已经存在 $is = Admin::find()->where(['name' => $name, 'is_delete' => 0])->one(); if ($is) { throw new Exception('商城名称已经存在!请更换'); } if (empty($username)) { throw new Exception('请输入登陆账户'); } $is = Admin::find()->where(['username' => $username, 'is_delete' => 0])->one(); if ($is) { throw new Exception('账户名称已经存在!请更换'); } $admin = new Admin(); $admin->access_token = \Yii::$app->security->generateRandomString(); $admin->username = $username; $admin->password = \Yii::$app->security->generatePasswordHash($password ?: '123456'); $admin->name = $name; $admin->saas_user_id = $saas_user_id; $admin->type = 'store'; if (isset($area['province_id']) && isset($area['city_id']) && isset($area['district_id'])) { $admin->province_id = $area['province_id']; $admin->city_id = $area['city_id']; $admin->district_id = $area['district_id']; } if (!$admin->save()) { throw new Exception('添加失败!' . array_shift($admin->getFirstErrors())); } $store = new Store(); $store->logo = $logo; // $store->store_number = $store_number; // $store->yunst_user_id = $res_member['data']['userId'] ?? ''; $store->name = $name; $store->open_status = 0; $store->admin_id = get_admin()->id ?? 0; $store->end_time = $end_time ?: strtotime("+1 year"); if (isset($area['province_id']) && isset($area['city_id']) && isset($area['district_id'])) { $store->province_id = $area['province_id']; $store->city_id = $area['city_id']; $store->district_id = $area['district_id']; } if ($store->save()) { $this->initStorageConfig($store->id); $admin->type_id = $store->id; if (!$admin->save()) { throw new Exception('添加失败!' . array_shift($admin->getFirstErrors())); } // 设置商城名称 Option::set('name', $name, $store->id, 'store'); Option::set(OptionSetting::STORE_LOGO, $logo, $store->id, 'store'); Option::set(OptionSetting::WECHAT_IS_SHENHE, '0', $store->id, 'wechat'); Option::set(OptionSetting::WECHAT_ALI_IS_SHENHE, '0', $store->id, 'wechat'); // 初始化DIY页面 // 初始化diy模板 $is = NewDiyTemplate::find() ->where([ 'store_id' => $store->id, 'is_delete' => 0, 'type' => 100 ])->asArray()->one(); if (!$is) { $this->initDiyTemplate($store->id); $default = \app\models\Option::get('store_template_default', 0, 'saas', null)['value']; if($default){ $default = json_decode($default, true); $default_store_id = $default['store_id']; }else{ $default_store_id = Store::findOne(['is_delete' => 0])->id ?: 1; } try { $id = \queue_push(new StoreSyncJob(['type' => 1, 'to_id' => $store->id]), 0, 1); debug_log($id, 'queuePush.log'); // $res = \app\models\StoreCopy::doCopy($default_store_id, $store->id, $default['type']); } catch (\Exception $e) { debug_log(['message' => $e->getMessage(), 'line' => $e->getLine()], 'queuePush.log'); } } //安装完成后装修表中的store_id比本商城的store_id还大 导致订单提交装修无法新增 //解决一下这个问题 $system_diy = NewDiyTemplate::find() ->where([ 'store_id' => $store->id, 'is_delete' => 0, 'name' => 'system' ])->asArray()->all(); $is_order_diy = false; foreach ($system_diy as $diy_item) { $template_detail = json_decode($diy_item['template'], true); if (isset($template_detail['system_type']) && $template_detail['system_type'] === 'orderPreview') { $is_order_diy = true; } } if (!$is_order_diy) { $submit = new NewDiyTemplate(); $submit->store_id = $store->id; $submit->name = 'system'; $submit->template = '{"page_name":"订单提交","is_index":"0","page_type":1,"system_type":"orderPreview","page_link":"","theme":{"color":"#292929","time":1711097460417},"pageCss":{"margin":0,"padding":0,"vSpave":0,"hSpace":0,"borderRadius":0,"borderRaNum":0,"backgroundColor":"#fcfcfc","backgroundImage":"","bgImg":"","bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat"},"templates":[{"name":"订单预览页面-头部","type":"","comName":"orderPreviewHeader","icon":"","controlComName":"","params":[]},{"name":"订单预览页面-发货方式选择","type":"","comName":"orderPreviewDelivery","icon":"","controlComName":"orderPreviewDeliveryControl","params":{"type":"2","diy_express_name":"快递","diy_delivery_name":"同城","diy_shop_name":"自提"},"moduleCss":{"backgroundColor":"#ffffff","backgroundImage":"","bgImg":"","useBackground":true,"bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat","margin":0,"padding":0,"borderRadius":8}},{"name":"订单预览页面-订单主体信息","type":"","comName":"orderPreviewContent","icon":"","controlComName":"","params":[]}],"controlComName":"pageControl","id":"3395"}'; $submit->addtime = time(); $submit->type = 1; $submit->save(); } if (\Yii::$app->prod_is_dandianpu()) { $saas_user = SaasUser::findOne(['id' => $saas_user_id, 'is_delete' => 0]); if ($saas_user) { // $saas_user->store_id = $store->id; // $saas_user->save(); // 创建云仓账号 $this->createStoreCloud($saas_user->mobile, $store, $saas_user); } } $t->commit(); return [ 'code' => 0, 'msg' => '添加成功!', 'store' => $store, ]; } else { $t->rollBack(); \Yii::error($store->getFirstErrors()); debug_log([__METHOD__, __LINE__, $store->getFirstErrors()], __CLASS__ . '.log'); return [ 'code' => 1, 'msg' => '添加失败!' . array_shift($store->getFirstErrors()), ]; } } catch (\Exception $e) { $t->rollBack(); \Yii::error($e); debug_log([__METHOD__, __LINE__, $e->getMessage(), $e->getTrace()], __CLASS__ . '.log'); return [ 'code' => 1, 'msg' => $e->getMessage(), ]; } } public function initStorageConfig($store_id) { $model = new UploadConfig(); $model->store_id = $store_id; $model->storage_type = "local"; $model->qiniu = json_encode(["bucket" => "","domain" => "","access_key" => "","secret_key" => "","style_api" => ""]); $model->qcloud = json_encode(["bucket" => "","region" => "","domain" => "","secret_id" => "","secret_key" => ""]); $model->aliyun = json_encode(["bucket" => "","CNAME" => "","domain" => "","access_key" => "","secret_key" => "","style_api" => ""]); $model->created_at = time(); $model->save(); $this->initStoreData($store_id); } public function initStoreFacePayProfit() { Option::set('face_first_profit', 0, get_store_id(), 'store'); Option::set('face_second_profit', 0, get_store_id(), 'store'); Option::set('face_third_profit', 0, get_store_id(), 'store'); } public function initStoreLeague() { // Option::set('store_this_profit', 0, get_store_id(), 'store'); Option::set('goods_send_profit', 0, get_store_id(), 'store'); Option::set('goods_take_price', 0, get_store_id(), 'store'); } public function initStoreData($store_id = 0) { $this->initStoreFacePayProfit(); $this->initStoreLeague(); debug_log('开始获取设置项'); $setting = []; $settingDefault = OptionSetting::getOptionSetting(); $i = 0; foreach ($settingDefault as $index => $item) { foreach ($item['list'] as &$value) { $value['group'] = $index; $value['value'] = $value['default']; if ($index === 'store') { $store_id = $store_id ?: get_store_id(); $store = Store::findOne($store_id); $admin = Admin::findOne(['type_id' => $store_id, 'is_delete' => 0]); if ($value['name'] === 'name') { $value['value'] = $store->name; } if ($value['name'] === 'contact_tel') { $value['value'] = $admin->mobile; } } } $setting[$i] = $item; $setting[$i]['key'] = $index; $i++; } foreach ($setting as $k => $v) { $setting[] = [ 'name' => $v['name'], 'key' => $k, 'list' => Option::getGroup($k) ]; } $form = new SettingForm(); $form->data = $setting; $res = $form->save($store_id); } // 初始化diy页面 public function initDiyTemplate($store_id) { // 个人中心 $user = new NewDiyTemplate(); $user->store_id = $store_id; $user->name = 'system'; $user->template = '{"page_name":"我的","is_index":"0","page_type":1,"page_link":"","theme":{"color":""},"pageCss":{"margin":0,"padding":0,"vSpave":0,"hSpace":0,"borderRadius":0,"borderRaNum":0,"backgroundColor":"#f2f2f2","backgroundImage":"","bgImg":"","bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat"},"templates":[{"name":"头部导航","type":"pageHeader","comName":"pageHeader","controlComName":"pageHeaderControl","moduleCss":{"backgroundColor":"","backgroundImage":"url(https://chidian.cyyvip.com/web/uploads/images/store_1/2021-10-23/8212b4f5b2eebc593e503ada46a1336452129b0b.png)","bgImg":"https://chidian.cyyvip.com/web/uploads/images/store_1/2021-10-23/8212b4f5b2eebc593e503ada46a1336452129b0b.png","useBackground":true,"bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat"},"params":{"text":"页面标题","showText":0,"capsuleType":"2","css":{"color":"#000000","fontNum":"18","fontSize":"","fontStyle":"normal","fontWeight":"bold","textDecoration":"inherit","textAlign":"center"}}},{"name":"我的页面-会员模块","type":"","comName":"userMember","icon":"","controlComName":"userMemberControl","moduleCss":{"backgroundColor":"","backgroundImage":"url(https://chidian.cyyvip.com/web/uploads/images/store_1/2021-10-23/2e97892d4896b8cdbc17097521b6d763d0e3d8d8.png)","bgImg":"https://chidian.cyyvip.com/web/uploads/images/store_1/2021-10-23/2e97892d4896b8cdbc17097521b6d763d0e3d8d8.png","useBackground":true,"bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat","margin":10,"padding":0,"borderRadius":0},"params":{"styleType":"1","fontColor":"#FFFFFF","memberAdImg":"https://chidian.cyyvip.com/web/uploads/images/store_1/2021-10-23/fe6cbd7ea663aa37e2ff49a19704016d74649362.png","showModule":true,"beforeBuyText":"开通Super会员,领7张20元无门槛津贴","afterBuyText":"","memberCardCss":{"backgroundColor":"#303478","backgroundImage":"","bgImg":"","useBackground":true,"bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat","padding":10,"borderRadius":10},"memberCardLink":{},"memberTabGroup":[{"title":"会员专享","subtitle":"好物折扣价","link":{},"picImg":"https://chidian.cyyvip.com/web/uploads/images/store_1/2021-10-25/5ea9e3e86ac57f16f40f178bab3e7a1975833997.png","titleColor":"#262626","subtitleColor":"#B4853F","controlComName":"userMemberTabItemControl"},{"title":"Super会员","subtitle":"额外返优惠","link":{},"picImg":"https://chidian.cyyvip.com/web/uploads/images/store_1/2021-10-25/5dbcb1077bb59db13386f9b547da98ea0a59c4ce.png","titleColor":"#262626","subtitleColor":"#B4853F","controlComName":"userMemberTabItemControl"},{"title":"送2年Super","subtitle":"领200元支付券","link":{},"picImg":"https://chidian.cyyvip.com/web/uploads/images/store_1/2021-10-25/0664e1c403a5e8cbf39661f420b25f32c1cfe00a.png","titleColor":"#262626","subtitleColor":"#B4853F","controlComName":"userMemberTabItemControl"}],"memberTabNum":3,"memberTabCss":{"backgroundColor":"#FDEDCF","backgroundImage":"","bgImg":"","useBackground":true,"bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat","padding":9,"borderRadius":10}}},{"name":"我的页面-我的订单","type":"","comName":"userOrder","icon":"","controlComName":"userOrderControl","moduleCss":{"backgroundColor":"#ffffff","backgroundImage":"","bgImg":"","useBackground":true,"bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat","margin":10,"padding":10,"borderRadius":10},"params":{"moduleName":"我的订单","showText":1,"moduleNameCss":{"color":"#262626","fontNum":"14","fontSize":"14px","fontStyle":"normal","fontWeight":"bold","textDecoration":"inherit"},"moduleMoreCss":{"color":"#888888","fontNum":"12","fontSize":"12px","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"},"fontColor":"#414141","tabsList":[{"tabImg":"https://chidian.cyyvip.com/web/uploads/images/store_1/2021-10-25/8e6630802514bea7480079a7b5bd5490b65307c9.png","tabText":"待付款","link":{},"controlComName":"userOrderTabItemControl"},{"tabImg":"https://chidian.cyyvip.com/web/uploads/images/store_1/2021-10-25/2305cab5806a042a2768d22e8f0720b7df36db90.png","tabText":"待发货","link":{},"controlComName":"userOrderTabItemControl"},{"tabImg":"https://chidian.cyyvip.com/web/uploads/images/store_1/2021-10-25/a1d3f824ff9c4311bb5c41ea47816bbb6b648dac.png","tabText":"待收货","link":{},"controlComName":"userOrderTabItemControl"},{"tabImg":"https://chidian.cyyvip.com/web/uploads/images/store_1/2021-10-25/a0eee0c78a4040b04343466635d17cd0f62505fa.png","tabText":"已完成","link":{},"controlComName":"userOrderTabItemControl"},{"tabImg":"https://chidian.cyyvip.com/web/uploads/images/store_1/2021-10-25/ad8aaca1a0214adca4a238770e87a5a5575579f6.png","tabText":"退换售后","link":{},"controlComName":"userOrderTabItemControl"}]}},{"name":"我的钱包","type":"","comName":"userWallet","icon":"","controlComName":"userWalletControl","moduleCss":{"backgroundColor":"#ffffff","backgroundImage":"","bgImg":"","useBackground":true,"bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat","margin":10,"padding":10,"borderRadius":10},"params":{"showModule":true,"text":"我的钱包","useTitle":1,"showStyle":"1","moduleNameCss":{"color":"#262626","fontNum":"14","fontSize":"14px","fontStyle":"normal","fontWeight":"bold","textDecoration":"inherit"},"moduleMoreCss":{"color":"#888888","fontNum":"12","fontSize":"12px","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"},"list":[{"name":"积分","subName":"","controlComName":"walletItemControl","walletItemType":"walletIntegral","color":"#262626","subColor":"#bbbbbb"},{"name":"余额","subName":"","controlComName":"walletItemControl", "walletItemType": "walletBalance", "color":"#262626","subColor":"#bbbbbb"},{"name":"联盟券","subName":"","controlComName":"walletItemControl", "walletItemType": "walletLeaguePrice","color":"#262626","subColor":"#bbbbbb"}]},"showModule":true},{"name":"工具与服务","type":"","comName":"userTools","icon":"","controlComName":"userToolsControl","moduleCss":{"backgroundColor":"#ffffff","backgroundImage":"","bgImg":"","useBackground":true,"bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat","margin":10,"padding":10,"borderRadius":10},"params":{"showModule":true,"text":"工具与服务","useTitle":1,"showStyle":"1","list":[{"name":"自提点","link":{"name":"自提点后台","link":"/pages/shop/admin","open_type":"navigate","params":[]},"iconUrl":"https://chidian.cyyvip.com/web/uploads/images/store_1/2021-11-03/8104ce1b57b2c54c98a7e045a95c465a8610c221.png","controlComName":"userToolControl","css":{"color":"#242427","fontNum":"12","fontSize":"","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"}},{"name":"当面付","link":{"name":"当面付","link":"/face-pay/face-pay/payOut","open_type":"navigate","params":[]},"iconUrl":"https://chidian.cyyvip.com/web/uploads/images/store_1/2021-11-03/94053d9ae7dc802a88a054567652b7c5a29d305d.png","controlComName":"userToolControl","css":{"color":"#242427","fontNum":"12","fontSize":"","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"}},{"name":"充值","link":{"name":"充值","link":"/user/balance/recharge","open_type":"navigate","params":[]},"iconUrl":"https://chidian.cyyvip.com/web/uploads/images/store_1/2021-11-03/47ee3226d562aa1da8cc5b46afbc5cf8b45485c2.png","controlComName":"userToolControl","css":{"color":"#242427","fontNum":"12","fontSize":"","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"}},{"name":"客服","link":{"name":"客服","link":"contact","open_type":"contact","params":[]},"iconUrl":"https://chidian.cyyvip.com/web/uploads/images/store_1/2021-11-03/e2593e3e56a08818de608735b73588333d7edca6.png","controlComName":"userToolControl","css":{"color":"#242427","fontNum":"12","fontSize":"","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"}},{"name":"分销中心","link":{"name":"分销中心","link":"/user/share/index","open_type":"navigate","params":[]},"iconUrl":"https://chidian.cyyvip.com/web/uploads/images/store_1/2021-11-03/36dc2b4da21efa42ae420ed30bd9414ddbd493c3.png","controlComName":"userToolControl","css":{"color":"#242427","fontNum":"12","fontSize":"","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"}},{"name":"福利中心","link":{"name":"福利中心","link":"/integral/integral/integral","open_type":"navigate","params":[]},"iconUrl":"https://chidian.cyyvip.com/web/uploads/images/store_1/2021-11-03/e6aaa9b4b32ad3ec56b71892ab833e38eff53660.png","controlComName":"userToolControl","css":{"color":"#242427","fontNum":"12","fontSize":"","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"}},{"name":"会员中心","link":{"name":"会员中心","link":"/user/member/member_center","open_type":"navigate","params":[]},"iconUrl":"https://chidian.cyyvip.com/web/uploads/images/store_1/2021-11-03/adc5a6987dfb4d1adfb0f4b649d8facc758b6ff8.png","controlComName":"userToolControl","css":{"color":"#242427","fontNum":"12","fontSize":"","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"}},{"name":"地址管理","link":{"name":"地址管理","link":"/user/my/addressmanage","open_type":"navigate","params":[]},"iconUrl":"https://chidian.cyyvip.com/web/uploads/images/store_1/2021-11-03/705eee495b92cad924fc9c531a0795e9aaf73d5c.png","controlComName":"userToolControl","css":{"color":"#242427","fontNum":"12","fontSize":"","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"}},{"name":"关于我们","link":{"name":"关于我们","link":"/user/my/article-detail","open_type":"navigate","params":[]},"iconUrl":"https://chidian.cyyvip.com/web/uploads/images/store_1/2021-11-03/fdcfc884fa56cb8ff83baa0cec127320688c84ab.png","controlComName":"userToolControl","css":{"color":"#000000","fontNum":"12","fontSize":"","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"}},{"name":"我的优惠券","link":{"name":"我的优惠券","link":"/user/my_coupon/my_coupon","open_type":"navigate","params":[]},"iconUrl":"https://chidian.cyyvip.com/web/uploads/images/store_1/2021-11-03/e24914f07391982282adb5ca25b8f5b3a14bf2ad.png","controlComName":"userToolControl","css":{"color":"#000000","fontNum":"12","fontSize":"","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"}},{"name":"我的核销卡","link":{"name":"我的核销卡","link":"/user/write_off_card/write_off_card","open_type":"navigate","params":[]},"iconUrl":"https://chidian.cyyvip.com/web/uploads/images/store_1/2021-11-03/9b4e332a77d0eef15c24e8e09f3125a693db6d8a.png","controlComName":"userToolControl","css":{"color":"#000000","fontNum":"12","fontSize":"","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"}}]},"showModule":true}],"controlComName":"pageControl","id":"","system_type":"my"}'; $user->addtime = time(); $user->type = 1; $user->save(); // 购物车 $cart = new NewDiyTemplate(); $cart->store_id = $store_id; $cart->name = 'system'; $cart->template = '{"page_name":"购物车","is_index":"0","page_type":1,"system_type":"cart","page_link":"","theme":{"color":""},"pageCss":{"margin":0,"padding":0,"vSpave":0,"hSpace":0,"borderRadius":0,"borderRaNum":0,"backgroundColor":"","backgroundImage":"","bgImg":"","bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat"},"templates":[{"name":"购物车","type":"","comName":"shoppingCart","icon":"","controlComName":"shoppingCartControl","moduleCss":{},"params":{}}],"controlComName":"pageControl","id":""}'; $cart->addtime = time(); $cart->type = 1; $cart->save(); // 商品详情 $goods = new NewDiyTemplate(); $goods->store_id = $store_id; $goods->name = 'system'; $goods->template = '{"page_name":"商品详情","is_index":"0","page_type":1,"system_type":"goodsDetail","page_link":"","theme":{"color":""},"pageCss":{"margin":0,"padding":0,"vSpave":0,"hSpace":0,"borderRadius":0,"borderRaNum":0,"backgroundColor":"","backgroundImage":"","bgImg":"","bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat"},"templates":[{"name":"商品详情页面-头部商品轮播图","type":"","comName":"goodsSwiperImgs","icon":"","controlComName":"","params":{}},{"name":"商品详情页面-商品介绍","type":"","comName":"goodsIntroduce","icon":"","controlComName":"goodsIntroduceControl","params":{"showMemberPrice":true,"showOriginPrice":true},"moduleCss":{"backgroundColor":"#ffffff","backgroundImage":"","bgImg":"","useBackground":true,"bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat","margin":12,"padding":0,"borderRadius":0}},{"name":"商品详情页面-商品优惠活动","type":"","comName":"goodsDiscount","icon":"","controlComName":"goodsDiscountControl","params":{"showGoodsDiscount":true},"moduleCss":{"backgroundColor":"#ffffff","backgroundImage":"","bgImg":"","useBackground":true,"bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat","margin":12,"padding":0,"borderRadius":0}},{"name":"商品详情页面-商品sku属性选择","type":"","comName":"goodsAttribute","icon":"","controlComName":"goodsAttributeControl","params":{"showAddress":true,"showNearbyShop":true,"showFreight":true},"moduleCss":{"backgroundColor":"#ffffff","backgroundImage":"","bgImg":"","useBackground":true,"bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat","margin":12,"padding":0,"borderRadius":0}},{"name":"商品详情页面-商品评价","type":"","comName":"goodsEvaluate","icon":"","controlComName":"goodsEvaluateControl","params":{"showEvaluate":true},"moduleCss":{"backgroundColor":"#ffffff","backgroundImage":"","bgImg":"","useBackground":true,"bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat","margin":12,"padding":0,"borderRadius":0}},{"name":"商品详情页面-商品评价","type":"","comName":"goodsShopEntry","icon":"","controlComName":"goodsShopEntryControl","params":{"showGoodsShopEntry":false},"moduleCss":{"backgroundColor":"#ffffff","backgroundImage":"","bgImg":"","useBackground":true,"bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat","margin":12,"padding":0,"borderRadius":0}},{"name":"商品详情页面-底部导航","type":"","comName":"goodsFootNav","icon":"","controlComName":"goodsFootNavControl","params":{"styleType":"1","tabList":[{"text":"首页","icon":"https://chidian.cyyvip.com/web/uploads/images/store_1/2021-11-02/857370f6a7a788ff0674b4255dabc91974b402a0.png","link":{"name":"首页","link":"/pages/home/home","open_type":"switchtab","params":[]},"fontColor":"#262626","controlComName":"goodsFootNavItemControl"},{"text":"客服","icon":"https://chidian.cyyvip.com/web/uploads/images/store_1/2021-11-02/aa7a96931ae57b070af3bd38f9553a40b7d9bd4f.png","link":{"name":"客服","link":"contact","open_type":"contact","params":[]},"fontColor":"#262626","controlComName":"goodsFootNavItemControl"},{"text":"购物车","icon":"https://chidian.cyyvip.com/web/uploads/images/store_1/2021-11-02/5d156040e27daf1da32d3a4241355684f4708f7e.png","link":{"name":"购物车","link":"/pages/shoppingcart/shoppingcart","open_type":"switchtab","params":[],"id":"1313"},"fontColor":"#262626","controlComName":"goodsFootNavItemControl"}],"buyBtn":{"text":"立即购买","color":"#FFFFFF","bgColor":"#FBBA10"},"cartBtn":{"text":"加入购物车","color":"#FFFFFF","bgColor":"#F0250E"}},"moduleCss":{"backgroundColor":"#ffffff","backgroundImage":"","bgImg":"","useBackground":true,"bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat","borderRadius":0}}],"controlComName":"pageControl","id":""}'; $goods->addtime = time(); $goods->type = 1; $goods->save(); //分类 $cat = new NewDiyTemplate(); $cat->store_id = $store_id; $cat->name = 'system'; $cat->template = '{"page_name":"分类","is_index":"0","page_type":1,"system_type":"classify","page_link":"","theme":{"color":""},"pageCss":{"margin":0,"padding":0,"vSpave":0,"hSpace":0,"borderRadius":0,"borderRaNum":0,"backgroundColor":"","backgroundImage":"","bgImg":"","bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat"},"templates":[{"name":"分类页面-头部导航","type":"","comName":"classifyHeader","icon":"","controlComName":"","moduleCss":{"backgroundColor":"#ffffff","backgroundImage":"","bgImg":"","useBackground":true,"bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat"},"params":{}},{"name":"分类页面-分类左侧列表","type":"","comName":"classifyContent","icon":"","controlComName":"classifyContentControl","params":{"levelNum":"2","styleType":3,"goodsShowType":"1","showModule":true,"abConfig":{"isShow":true,"imgSrc":"","link":{}}}}],"controlComName":"pageControl","id":""}'; $cat->addtime = time(); $cat->type = 1; $cat->save(); //展示商品详情 $cat = new NewDiyTemplate(); $cat->store_id = $store_id; $cat->name = 'system'; $cat->template = '{"page_name":"展示商品详情","is_index":"0","page_type":1,"system_type":"showGoodsDetail","page_link":"","theme":{"color":""},"pageCss":{"margin":0,"padding":0,"vSpave":0,"hSpace":0,"borderRadius":0,"borderRaNum":0,"backgroundColor":"","backgroundImage":"","bgImg":"","bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat"},"templates":[{"name":"展示商品详情页面-头部商品轮播图","type":"","comName":"showGodsSwiperImgs","icon":"","controlComName":"showGoodsSwiperImgsControl","params":{"margin":0,"showFenxiao":true,"show":true}},{"name":"商品信息","type":"","comName":"showGodsInfo","icon":"","controlComName":"showGodsInfoControl","params":{"showPrice":true,"showOriginPrice":true,"showSales":true,"showGoodsName":true,"showCollect":true,"showShare":true,"margin":0}},{"name":"商品内容","type":"","comName":"showGoodsContent","icon":"","controlComName":"showGoodsContentControl","params":{"title":"详情","showTitle":true,"showContent":true,"margin":0}},{"name":"商品详情页面-底部导航","type":"","comName":"showGoodsFootNav","icon":"","controlComName":"showGoodsFootNavControl","params":{"showBtn":true,"styleType":"1","btnText":"进入抖音号","btnColor":"#F0250E","link":{"link":"","name":"","open_type":""}}}],"controlComName":"pageControl","id":""}'; $cat->addtime = time(); $cat->type = 1; $cat->save(); // 首页 $index = new NewDiyTemplate(); $index->store_id = $store_id; $index->name = 'DIY'; $index->template = '{"page_name":"首页","is_index":"1","page_type":0,"page_link":"","theme":{"color":"#FCBE40","time":1633765304209},"pageCss":{"margin":0,"padding":0,"vSpave":0,"hSpace":0,"borderRadius":0,"borderRaNum":0,"backgroundColor":"#f2f2f2","backgroundImage":"","bgImg":"","bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat"},"templates":[{"name":"头部导航","type":"pageHeader","comName":"pageHeader","controlComName":"pageHeaderControl","moduleCss":{"backgroundColor":"","backgroundImage":"url(https://chidian.cyyvip.com/web/uploads/images/store_84/2021-12-29/d3e747e32a87e8903f6a8acf7d452d5b4e948941.png)","bgImg":"https://chidian.cyyvip.com/web/uploads/images/store_84/2021-12-29/d3e747e32a87e8903f6a8acf7d452d5b4e948941.png","useBackground":true,"bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat"},"params":{"text":"赤店商城","showText":1,"capsuleType":"1","css":{"color":"#ffffff","fontNum":"16","fontSize":"16px","fontStyle":"normal","fontWeight":"bold","textDecoration":"inherit","textAlign":"center"},"styleType":"2","mdStyle":"1"}},{"name":"搜索框","type":"search","comName":"diySearch","controlComName":"diySearchControl","icon":"icon-sousuokuang","moduleCss":{"backgroundColor":"","backgroundImage":"url(https://chidian.cyyvip.com/web/uploads/images/store_84/2021-12-29/35708c731c112046320b2b55b69361289b3334f9.png)","bgImg":"https://chidian.cyyvip.com/web/uploads/images/store_84/2021-12-29/35708c731c112046320b2b55b69361289b3334f9.png","useBackground":true,"bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat","margin":0,"padding":0,"borderRadius":0},"params":{"placeholder":"请输入商品或店铺","fixedTop":0,"borderType":"1","styleType":"1","contentAlign":"","inputBgColor":"#ffffff","inputBorder":"#ffffff","inputTextColor":"#9B9B9B","searchBtnColor":"#FA2C1B","css":{"color":"#000000","fontNum":"14","fontSize":"","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit","textAlign":"inherit"}}},{"name":"门店信息","type":"shopInfoData","comName":"shopInfoData","controlComName":"shopInfoDataControl","icon":"icon-jiudian","moduleCss":{"backgroundColor":"#ffffff","backgroundImage":"","bgImg":"","useBackground":true,"bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat","margin":0,"padding":0,"borderRadius":0},"params":{"mainColor":"#191919","subColor":"#8C8C8C"}},{"name":"产品分类","type":"productClassify","comName":"productClassify","icon":"icon-chanpinfenlei","controlComName":"productClassifyControl","moduleCss":{"backgroundColor":"#FFFFFF","backgroundImage":"","bgImg":"","useBackground":true,"bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat","margin":0,"padding":0,"borderRadius":0},"params":{"type":"2","styleType":"2","tabStyle":"1","leftTabBg":"#ffffff","classifyList":[],"activeLineColor":"#FA2C1B","defaultTab":{"fontCss":{"color":"#262626","fontNum":"15","fontSize":"","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"},"activeColor":"#FA2C1B","activeStyle":"1"},"subtitleTab":{"color":"#FA2C1B","titleColor":"#FA2C1B","subTitleColor":"#ffffff","activeColor":"#FA2C1B","activeStyle":"1","defaultTitleColor":"#000000","defaultSubTitleColor":"#888888"},"showPrice":true,"showSales":true,"showBuyBtn":true,"producNameColor":"#1D1D1D","priceColor":"#FA2C1B","originPriceColor":"#9B9B9B","saleColor":"#9B9B9B","buyStyle":"add","buyBtnText":"购买","buyBtnImg":"","goodsType":"2","goodsItemOutSpace":0,"goodsItemInnerSpace":3,"goodsBgCss":{"backgroundColor":"#FFFFFF","backgroundImage":"","bgImg":"","useBackground":true,"bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat","margin":1,"padding":0,"borderRadius":0}}}],"controlComName":"pageControl","id":""}'; //$index->template = '{"page_name":"首页","is_index":"1","page_type":0,"page_link":"","theme":{"color":"#FCBE40","time":1633765304209},"pageCss":{"margin":0,"padding":0,"vSpave":0,"hSpace":0,"borderRadius":0,"borderRaNum":0,"backgroundColor":"#eb0000","backgroundImage":"","bgImg":"","bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat"},"templates":[{"name":"头部导航","type":"pageHeader","comName":"pageHeader","controlComName":"pageHeaderControl","moduleCss":{"backgroundColor":"#f82b1c","backgroundImage":"","bgImg":"","useBackground":true,"bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat"},"params":{"text":"赤店商城","showText":1,"capsuleType":"2","css":{"color":"#ffffff","fontNum":"18","fontSize":"","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit","textAlign":"center"}}},{"name":"搜索框","type":"search","comName":"diySearch","controlComName":"diySearchControl","icon":"icon-sousuokuang","moduleCss":{"backgroundColor":"#f82b1c","backgroundImage":"","bgImg":"","useBackground":true,"bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat","margin":0,"padding":0,"borderRadius":0},"params":{"placeholder":"请输入商品或店铺","fixedTop":0,"borderType":"1","styleType":"1","contentAlign":"","inputBgColor":"#ffffff","inputBorder":"#ffffff","inputTextColor":"#9B9B9B","searchBtnColor":"#FA2C1B","css":{"color":"#000000","fontNum":"14","fontSize":"","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit","textAlign":"inherit"}}},{"name":"快捷导航","type":"fastNav","comName":"fastNav","controlComName":"fastNavControl","icon":"icon-kuaijiedaohang","moduleCss":{"backgroundColor":"#fa2c1b","backgroundImage":"","bgImg":"","useBackground":true,"bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat","margin":5,"padding":0,"borderRadius":0},"params":{"text":"","css":{"color":"#ffffff","fontNum":"14","fontSize":"","fontStyle":"normal","fontWeight":"noraml","textDecoration":"inherit","textAlign":"inherit"},"list":[{"text":"首页","link":{}},{"text":"电脑办公","link":{}},{"text":"大家电","link":{}},{"text":"男装","link":{}},{"text":"精品服饰","link":{}},{"text":"潮流包包","link":{}},{"text":"选项卡","link":{}}],"choosedStyle":{"controlComName":"fastNavCurrentControl","style":1,"css":{"color":"#ffffff","fontNum":"16","fontSize":"16px","fontStyle":"normal","fontWeight":"bold","textDecoration":"inherit","textAlign":"inherit"},"lineColor":"#ffffff","backgroundColor":"#c2b3b3"}}},{"name":"图片轮播","type":"banner","comName":"swiperImg","icon":"icon-tupianlunbo","controlComName":"swiperImgControl","moduleCss":{"backgroundColor":"#eb2300","backgroundImage":"","bgImg":"","useBackground":true,"bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat","margin":0,"padding":0,"borderRadius":0},"params":{"bannerList":[{"picUrl":"http://tianxin100we10.cyyvip.com/web/uploads/images/store_1/2021-09-16/518bae500b54c86d38bcbdf123c2eb349bb3473d.jpeg","link":{}},{"picUrl":"http://tianxin100we10.cyyvip.com/web/uploads/images/store_1/2021-09-16/2c704ab8584b045d3b2f5669e48f05373adb8a11.jpeg","link":{}}],"dotsPosition":"center","swiperType":"1"}},{"name":"魔方导航","type":"cubeNav","comName":"cubeNav","controlComName":"cubeNavControl","icon":"icon-mofangdaohang","params":{"columnNumber":"5","numberOfLines":"2","drain":"1","list":[{"name":"附近超市","link":{},"iconUrl":"http://tianxin100we10.cyyvip.com/web/uploads/images/store_1/2021-09-16/dc27bfbd99e325625995c9f51abdbc51fe7e567a.png","controlComName":"cubeItemControl","css":{"color":"#ffffff","fontNum":"12","fontSize":"12px","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"}},{"name":"数码电器","link":{},"iconUrl":"http://tianxin100we10.cyyvip.com/web/uploads/images/store_1/2021-09-16/0512ae6ea7dd643d1e75354788f70feafb50ceb1.png","controlComName":"cubeItemControl","css":{"color":"#ffffff","fontNum":"12","fontSize":"12px","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"}},{"name":"精选服饰","link":{},"iconUrl":"http://tianxin100we10.cyyvip.com/web/uploads/images/store_1/2021-09-16/e510beed1bc1c004c6d918ed88735e367ec89b69.png","controlComName":"cubeItemControl","css":{"color":"#ffffff","fontNum":"12","fontSize":"12px","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"}},{"name":"赤店生鲜","link":{},"iconUrl":"http://tianxin100we10.cyyvip.com/web/uploads/images/store_1/2021-09-16/5f0a0b1aee4f26564d49d592fd15d4a121898e2f.png","controlComName":"cubeItemControl","css":{"color":"#ffffff","fontNum":"12","fontSize":"12px","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"}},{"name":"好货到家","link":{},"iconUrl":"http://tianxin100we10.cyyvip.com/web/uploads/images/store_1/2021-09-16/d148a57be780032fe34db4b1aa476d53733c598d.png","controlComName":"cubeItemControl","css":{"color":"#ffffff","fontNum":"12","fontSize":"12px","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"}},{"name":"充值缴费","link":{},"iconUrl":"http://tianxin100we10.cyyvip.com/web/uploads/images/store_1/2021-09-16/5eec9739affa05772bb13e9a9378a9c059fcce47.png","controlComName":"cubeItemControl","css":{"color":"#ffffff","fontNum":"12","fontSize":"12px","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"}},{"name":"物流查询","link":{},"iconUrl":"http://tianxin100we10.cyyvip.com/web/uploads/images/store_1/2021-09-16/c6ddd1298ea7f79490821feb6ce966137549a87e.png","controlComName":"cubeItemControl","css":{"color":"#ffffff","fontNum":"12","fontSize":"12px","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"}},{"name":"领券","link":{},"iconUrl":"http://tianxin100we10.cyyvip.com/web/uploads/images/store_1/2021-09-16/78149329d99b07edc79e8606d2cb56d0f0b3e22f.png","controlComName":"cubeItemControl","css":{"color":"#ffffff","fontNum":"12","fontSize":"12px","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"}},{"name":"领福利","link":{},"iconUrl":"http://tianxin100we10.cyyvip.com/web/uploads/images/store_1/2021-09-16/182f539eede0375db0ecbfc0693f20359bb240b9.png","controlComName":"cubeItemControl","css":{"color":"#ffffff","fontNum":"12","fontSize":"12px","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"}},{"name":"PLUS会员","link":{},"iconUrl":"http://tianxin100we10.cyyvip.com/web/uploads/images/store_1/2021-09-16/5c1d68c542e21ea3983d24eaa6347e0f1e26658a.png","controlComName":"cubeItemControl","css":{"color":"#ffffff","fontNum":"12","fontSize":"12px","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"}},{"name":"进口好货","link":{},"iconUrl":"http://tianxin100we10.cyyvip.com/web/uploads/images/store_1/2021-09-16/1441bc6d25c2c2519c4255864823386b8649ec8e.png","controlComName":"cubeItemControl","css":{"color":"#ffffff","fontNum":"12","fontSize":"12px","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"}},{"name":"拍卖众筹","link":{},"iconUrl":"http://tianxin100we10.cyyvip.com/web/uploads/images/store_1/2021-09-16/3a9fa5bb74c9bd0ed0a181b45cbc010392167050.png","controlComName":"cubeItemControl","css":{"color":"#ffffff","fontNum":"12","fontSize":"12px","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"}},{"name":"看病购药","link":{},"iconUrl":"http://tianxin100we10.cyyvip.com/web/uploads/images/store_1/2021-09-16/f1d1cef5b629251a1f68aea34cbc56dc363cec9f.png","controlComName":"cubeItemControl","css":{"color":"#ffffff","fontNum":"12","fontSize":"12px","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"}},{"name":"玩3C","link":{},"iconUrl":"http://tianxin100we10.cyyvip.com/web/uploads/images/store_1/2021-09-16/fef0351ce4c18e0cecbf498f7fbcf8d8acbd7c0c.png","controlComName":"cubeItemControl","css":{"color":"#ffffff","fontNum":"12","fontSize":"12px","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"}},{"name":"沃尔玛","link":{},"iconUrl":"http://tianxin100we10.cyyvip.com/web/uploads/images/store_1/2021-09-16/bf3fa385564a110407c5a8a0406dda6819b34b37.png","controlComName":"cubeItemControl","css":{"color":"#ffffff","fontNum":"12","fontSize":"12px","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"}},{"name":"美妆馆","link":{},"iconUrl":"http://tianxin100we10.cyyvip.com/web/uploads/images/store_1/2021-09-16/31966f5b658ca4cd560727141b8efecb9c775eec.png","controlComName":"cubeItemControl","css":{"color":"#ffffff","fontNum":"12","fontSize":"12px","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"}},{"name":"旅行","link":{},"iconUrl":"https://chidian.cyyvip.com/web/uploads/images/store_1/2021-10-08/29a3dac01190ac0d3b45e76ac8720a73f0e49837.png","controlComName":"cubeItemControl","css":{"color":"#ffffff","fontNum":"12","fontSize":"12px","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"}},{"name":"二手好货","link":{},"iconUrl":"http://tianxin100we10.cyyvip.com/web/uploads/images/store_1/2021-09-16/fa610cbc05534fb51fa52f7ba1be89ed2c9a4330.png","controlComName":"cubeItemControl","css":{"color":"#ffffff","fontNum":"12","fontSize":"12px","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"}},{"name":"9.9元拼","link":{},"iconUrl":"http://tianxin100we10.cyyvip.com/web/uploads/images/store_1/2021-09-16/33b028eb11eae036236449a6186f769ff2b4b4c3.png","controlComName":"cubeItemControl","css":{"color":"#ffffff","fontNum":"12","fontSize":"12px","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"}},{"name":"全部","link":{},"iconUrl":"http://tianxin100we10.cyyvip.com/web/uploads/images/store_1/2021-09-16/da56b1c2f037621494f8f9532a2198e3290105c0.png","controlComName":"cubeItemControl","css":{"color":"#ffffff","fontNum":"12","fontSize":"12px","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"}}]},"moduleCss":{"backgroundColor":"#eb2300","backgroundImage":"","bgImg":"","useBackground":true,"bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat","margin":0,"padding":0,"borderRadius":0}},{"name":"首页推荐","type":"indexRecommend","comName":"indexRecommend","controlComName":"indexRecommendControl","icon":"icon-shouyetuijian","moduleCss":{"backgroundColor":"#ffffff","backgroundImage":"","bgImg":"","useBackground":true,"bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat","margin":10,"padding":10,"borderRadius":10},"params":{"line":1,"text":"首页推荐","useTitle":2,"list":[{"title":{"controlComName":"indexRecommendTitleControl","useTitle":1,"text":"天天低价","css":{"color":"#000000","fontNum":"16","fontSize":"","fontStyle":"normal","fontWeight":"bold","textDecoration":"inherit","textAlign":"inherit"}},"subTitle":{"controlComName":"indexRecommendSubtitleControl","useTitle":1,"text":"人气好货限时抢","css":{"color":"#000000","fontNum":"14","fontSize":"","fontStyle":"normal","fontWeight":"noraml","textDecoration":"inherit","textAlign":"inherit"}},"type":{"controlComName":"indexRecommendTypeControl","style":1,"startTime":"2021-10-08 15:28:36","endTime":"2021-10-16 15:28:36","picUrl":""},"pics":{"controlComName":"indexRecommendPicsControl","link":{},"urls":[{"picUrl":"http://tianxin100we10.cyyvip.com/web/uploads/images/store_1/2021-04-29/27415a2cf5de636ac2dcaea2c52d3cab42d80b2a.png"},{"picUrl":"http://tianxin100we10.cyyvip.com/web/uploads/images/store_1/2021-04-29/f76a7194e8f9e1f53432b739d1fce8861f45a7cc.png"}]}},{"title":{"controlComName":"indexRecommendTitleControl","useTitle":1,"text":"天天低价","css":{"color":"#000000","fontNum":"16","fontSize":"","fontStyle":"normal","fontWeight":"bold","textDecoration":"inherit","textAlign":"inherit"}},"subTitle":{"controlComName":"indexRecommendSubtitleControl","useTitle":2,"text":"人气好货限时抢","css":{"color":"#000000","fontNum":"14","fontSize":"","fontStyle":"normal","fontWeight":"noraml","textDecoration":"inherit","textAlign":"inherit"}},"type":{"controlComName":"indexRecommendTypeControl","style":1,"startTime":"","endTime":"","picUrl":""},"pics":{"controlComName":"indexRecommendPicsControl","link":{},"urls":[{"picUrl":"http://tianxin100we10.cyyvip.com/web/uploads/images/store_1/2021-04-29/11be51b1bc735a7fd2af0d0aa19cd426c7a29f04.png"},{"picUrl":"http://tianxin100we10.cyyvip.com/web/uploads/images/store_1/2021-04-29/579a2232b29cdbb1e4ec82ca5d465026b25a5168.png"}]}},{"title":{"controlComName":"indexRecommendTitleControl","useTitle":1,"text":"天天低价","css":{"color":"#000000","fontNum":"16","fontSize":"","fontStyle":"normal","fontWeight":"noraml","textDecoration":"inherit","textAlign":"inherit"}},"subTitle":{"controlComName":"indexRecommendSubtitleControl","useTitle":1,"text":"人气好货限时抢","css":{"color":"#000000","fontNum":"14","fontSize":"","fontStyle":"normal","fontWeight":"noraml","textDecoration":"inherit","textAlign":"inherit"}},"type":{"controlComName":"indexRecommendTypeControl","style":1,"startTime":"","endTime":"","picUrl":""},"pics":{"controlComName":"indexRecommendPicsControl","link":{},"urls":[]}},{"title":{"controlComName":"indexRecommendTitleControl","useTitle":1,"text":"天天低价","css":{"color":"#000000","fontNum":"16","fontSize":"","fontStyle":"normal","fontWeight":"noraml","textDecoration":"inherit","textAlign":"inherit"}},"subTitle":{"controlComName":"indexRecommendSubtitleControl","useTitle":1,"text":"人气好货限时抢","css":{"color":"#000000","fontNum":"14","fontSize":"","fontStyle":"normal","fontWeight":"noraml","textDecoration":"inherit","textAlign":"inherit"}},"type":{"controlComName":"indexRecommendTypeControl","style":1,"startTime":"","endTime":"","picUrl":""},"pics":{"controlComName":"indexRecommendPicsControl","link":{},"urls":[]}},{"title":{"controlComName":"indexRecommendTitleControl","useTitle":1,"text":"天天低价","css":{"color":"#000000","fontNum":"16","fontSize":"","fontStyle":"normal","fontWeight":"noraml","textDecoration":"inherit","textAlign":"inherit"}},"subTitle":{"controlComName":"indexRecommendSubtitleControl","useTitle":1,"text":"人气好货限时抢","css":{"color":"#000000","fontNum":"14","fontSize":"","fontStyle":"normal","fontWeight":"noraml","textDecoration":"inherit","textAlign":"inherit"}},"type":{"controlComName":"indexRecommendTypeControl","style":1,"startTime":"","endTime":"","picUrl":""},"pics":{"controlComName":"indexRecommendPicsControl","link":{},"urls":[]}},{"title":{"controlComName":"indexRecommendTitleControl","useTitle":1,"text":"天天低价","css":{"color":"#000000","fontNum":"16","fontSize":"","fontStyle":"normal","fontWeight":"noraml","textDecoration":"inherit","textAlign":"inherit"}},"subTitle":{"controlComName":"indexRecommendSubtitleControl","useTitle":1,"text":"人气好货限时抢","css":{"color":"#000000","fontNum":"14","fontSize":"","fontStyle":"normal","fontWeight":"noraml","textDecoration":"inherit","textAlign":"inherit"}},"type":{"controlComName":"indexRecommendTypeControl","style":1,"startTime":"","endTime":"","picUrl":""},"pics":{"controlComName":"indexRecommendPicsControl","link":{},"urls":[]}}],"moduleNameCss":{"color":"#262626","fontNum":"16","fontSize":"","fontStyle":"normal","fontWeight":"bold","textDecoration":"inherit"},"moduleMoreCss":{"color":"#888888","fontNum":"12","fontSize":"","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit"}}},{"name":"公告","type":"notice","comName":"diyNotice","controlComName":"diyNoticeControl","icon":"icon-gonggao","moduleCss":{"backgroundColor":"#ffffff","backgroundImage":"","bgImg":"","useBackground":true,"bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat","margin":10,"padding":10,"borderRadius":10},"params":{"styleType":"2","noticeText":"新商城上线啦!欢迎您!!!!","noticeImg":""}},{"name":"倒计时","type":"marketCountDown","comName":"marketCountDown","icon":"icon-daojishi","controlComName":"marketCountDownControl","moduleCss":{"backgroundColor":"#ffffff","backgroundImage":"","bgImg":"","useBackground":true,"bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat","margin":10,"padding":10,"borderRadius":8},"params":{"styleType":"1","countDownImg":"http://tianxin100we10.cyyvip.com/web/uploads/images/store_1/2021-09-16/518bae500b54c86d38bcbdf123c2eb349bb3473d.jpeg","justifyContent":"flex-start","startTime":"2021-10-09 13:51:21","endTime":"2021-10-30 13:51:26","link":{},"countDownBgColor":"#FA2C1B","countDownFontColor":"#FFFFFF","css":{"color":"#e21818","fontNum":"16","fontSize":"","fontStyle":"normal","fontWeight":"normal","textDecoration":"inherit","textAlign":"inherit"}}}],"controlComName":"pageControl","id":""}'; $index->addtime = time(); $index->is_index = 1; $index->type = 1; $index->save(); //控件 $control = new NewDiyTemplate(); $control->store_id = $store_id; $control->name = 'controls'; $control->template = '[{"name":"导航","is_show":true,"controlComName":"widgetNavControl","show_type":"nav","params":{"defaultColor":"#2e2d2d","activeColor":"#FCBE40","navList":[{"pic_url":"https://chidian.cyyvip.com/web/uploads/images/store_1/2021-10-27/a94065d9bc45172db3df618616fa174e6908ad97.png","active_url":"https://chidian.cyyvip.com/web/uploads/images/store_1/2021-10-27/0e337d2c6c92e2bbac7b0e57dc022af250bd574e.png","nav_text":"首页","link":{"name":"首页","link":"/pages/home/home","open_type":"switchtab","params":[]}},{"pic_url":"https://chidian.cyyvip.com/web/uploads/images/store_257/2022-09-07/2e6400f46f235fa20731d8a18863330a550a1ef3.png","active_url":"https://chidian.cyyvip.com/web/uploads/images/store_257/2022-09-07/f417d3de37a1cba65a9290960900c96345670f1f.png","nav_text":"分类","link":{"name":"分类","link":"/pages/cat/cat?cat_id=","open_type":"switchtab","params":[{"key":"cat_id","value":"","desc":"cat_id请填写在商品分类中相关分类的ID"}],"id":""}},{"pic_url":"https://chidian.cyyvip.com/web/uploads/images/store_1/2021-10-27/c63e855f172c75d3a3533e6b706be245e81048c6.png","active_url":"https://chidian.cyyvip.com/web/uploads/images/store_1/2021-10-27/39dda53d348bc336e6f7a6a9da0fc34d341fe5df.png","nav_text":"购物车","link":{"name":"购物车","link":"/pages/shoppingcart/shoppingcart","open_type":"switchtab","params":[]}},{"pic_url":"https://chidian.cyyvip.com/web/uploads/images/store_1/2021-10-27/0f7048ecd1c7d0d30278ca9665beca219ff3e778.png","active_url":"https://chidian.cyyvip.com/web/uploads/images/store_1/2021-10-27/865006703b674a416be49169c691333ae210d055.png","nav_text":"我的","link":{"name":"用户中心","link":"/pages/my/my","id":375,"open_type":"switchtab","params":[]}}]},"moduleCss":{"backgroundColor":"#ffffff","backgroundImage":"","bgImg":"","useBackground":true,"backgroundSize":"100% 100%","backgroundRepeat":"no-repeat"}},{"name":"弹窗","is_show":false,"show_type":"window","controlComName":"widgetPopupControl","params":{"list":[],"rule":1}},{"name":"电话","is_show":true,"show_type":"list","controlComName":"widgetPhoneControl","params":{"phone":"","picUrl":""}},{"name":"微信客服","is_show":true,"show_type":"list","controlComName":"widgetWxControl","params":{"picUrl":""}}]'; $control->addtime = time(); $control->type = 100; $control->save(); // 订单提交 $submit = new NewDiyTemplate(); $submit->store_id = $store_id; $submit->name = 'system'; $submit->template = '{"page_name":"订单提交","is_index":"0","page_type":1,"system_type":"orderPreview","page_link":"","theme":{"color":"#292929","time":1711097460417},"pageCss":{"margin":0,"padding":0,"vSpave":0,"hSpace":0,"borderRadius":0,"borderRaNum":0,"backgroundColor":"#fcfcfc","backgroundImage":"","bgImg":"","bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat"},"templates":[{"name":"订单预览页面-头部","type":"","comName":"orderPreviewHeader","icon":"","controlComName":"","params":[]},{"name":"订单预览页面-发货方式选择","type":"","comName":"orderPreviewDelivery","icon":"","controlComName":"orderPreviewDeliveryControl","params":{"type":"2","diy_express_name":"快递","diy_delivery_name":"同城","diy_shop_name":"自提"},"moduleCss":{"backgroundColor":"#ffffff","backgroundImage":"","bgImg":"","useBackground":true,"bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat","margin":0,"padding":0,"borderRadius":8}},{"name":"订单预览页面-订单主体信息","type":"","comName":"orderPreviewContent","icon":"","controlComName":"","params":[]}],"controlComName":"pageControl","id":"3395"}'; $submit->addtime = time(); $submit->type = 1; $submit->save(); $this->initDiyTemplateType($store_id, self::diyTemplateTypeList()); } // 初始化diy页面 public static function diyTemplateTypeList() { return [ 'showGoodsDetail', ]; } // 初始化diy页面 public function initDiyTemplateType($store_id, $type = []) { $t = \Yii::$app->db->beginTransaction(); try { if(!array_intersect($type, self::diyTemplateTypeList())){ \Yii::error([__METHOD__, __LINE__, $type]); throw new \Exception('type参数错误!'); } $hasList = []; $list = NewDiyTemplate::find() ->where([ 'store_id' => $store_id, 'is_delete' => 0, 'name' => 'system' ])->orderBy(['id' => SORT_ASC])->asArray()->all(); foreach ($list as &$item) { if ($item['template']) { $template = json_decode($item['template'], true); $system_type = $template['system_type']; $hasList[] = $system_type; } } $type = array_diff($type, $hasList); // 展示商品详情 if(in_array('showGoodsDetail', $type)){ $model = new NewDiyTemplate(); $model->store_id = $store_id; $model->name = 'system'; $model->template = '{"page_name":"展示商品详情","is_index":"0","page_type":1,"system_type":"showGoodsDetail","page_link":"","theme":{"color":""},"pageCss":{"margin":0,"padding":0,"vSpave":0,"hSpace":0,"borderRadius":0,"borderRaNum":0,"backgroundColor":"","backgroundImage":"","bgImg":"","bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat"},"templates":[{"name":"展示商品详情页面-头部商品轮播图","type":"","comName":"showGodsSwiperImgs","icon":"","controlComName":"showGoodsSwiperImgsControl","params":{"margin":0,"showFenxiao":true,"show":true}},{"name":"商品信息","type":"","comName":"showGodsInfo","icon":"","controlComName":"showGodsInfoControl","params":{"showPrice":true,"showOriginPrice":true,"showSales":true,"showGoodsName":true,"showCollect":true,"showShare":true,"margin":0}},{"name":"商品内容","type":"","comName":"showGoodsContent","icon":"","controlComName":"showGoodsContentControl","params":{"title":"详情","showTitle":true,"showContent":true,"margin":0}},{"name":"商品详情页面-底部导航","type":"","comName":"showGoodsFootNav","icon":"","controlComName":"showGoodsFootNavControl","params":{"showBtn":true,"styleType":"1","btnText":"进入抖音号","btnColor":"#F0250E","link":{"link":"","name":"","open_type":""}}}],"controlComName":"pageControl","id":""}'; $model->addtime = time(); $model->type = 1; $model->save(); } $t->commit(); return [ 'code' => 0, 'msg' => '操作成功!', 'type' => $type, ]; } catch (\Exception $e) { $t->rollBack(); return [ 'code' => 1, 'msg' => '操作失败!' . $e->getMessage(), ]; } } public function delete($store_id) { $t = \Yii::$app->db->beginTransaction(); try { if (!$store_id) { throw new \Exception('store_id不能为空!'); } $store = Store::findOne($store_id); if (!$store) { throw new \Exception('未找到商城!'); } $store->is_delete = 1; $admin = Admin::findOne(['is_delete' => 0, 'type' => 'store', 'type_id' => $store_id]); if ($admin) { Admin::updateAll(['is_delete' => 1], ['is_delete' => 0, 'type' => 'store', 'type_id' => $store_id]); $saas_user_id = $admin->saas_user_id; if($saas_user_id){ StoreAudit::deleteAll(['saas_user_id' => $saas_user_id]); } } if (!$store->save()) { throw new \Exception('操作失败!' . json_encode($store->errors)); } $t->commit(); return [ 'code' => 0, 'msg' => '删除成功!', ]; } catch (\Exception $e) { return [ 'code' => 1, 'msg' => $e->getMessage(), ]; } } /** * 设置分销 * * @param int $store_id * @param array $params * @return array */ public function setShareParams($store_id, $params) { //默认配置 if(intval($store_id) === -1){ $params['level_one'] = number_format($params['level_one'], 2); $params['level_two'] = number_format($params['level_two'], 2); $params['level_three'] = number_format($params['level_three'], 2); $json = json_encode($params); $res = Option::set(OptionSetting::SHARE_SAAS_DEFAULT_SETTING, $json, $store_id, OptionSetting::SHARE_GROUP_NAME); if(!$res){ return [ 'code' => 1, 'msg' => '默认配置编辑失败', ]; } return [ 'code' => 0, 'msg' => '默认配置编辑成功', ]; } if (!$store_id) { return [ 'code' => 1, 'msg' => 'store_id不能为空!', ]; } $store = Store::findOne($store_id); if (!$store) { return [ 'code' => 1, 'msg' => '未找到商城!', ]; } $params['level_one'] = number_format($params['level_one'], 2); $params['level_two'] = number_format($params['level_two'], 2); $params['level_three'] = number_format($params['level_three'], 2); $store->share_setting = json_encode($params); if (!union_share_scale_check($store)) { return [ 'code' => 1, 'msg' => '保存失败,分销比例超过100%', ]; } if ($store->save()) { return [ 'code' => 0, 'msg' => '保存成功!', ]; } return [ 'code' => 1, 'msg' => '保存失败!', ]; } /** * 获取分销参数 * * @param int $store_id * @return array */ public function getShareParams($store_id) { if (!$store_id) { return [ 'code' => 1, 'msg' => 'store_id不能为空!', ]; } $store = Store::findOne($store_id); if (!$store) { return [ 'code' => 1, 'msg' => '未找到商城!', ]; } if (empty($store->share_setting)) { return [ 'code' => 0, 'msg' => 'success', 'data' => [ 'level' => 0, 'is_rebate' => 0, 'price_type' => 0, 'level_one' => 0, 'level_two' => 0, 'level_three' => 0 ], ]; } return [ 'code' => 0, 'msg' => 'success', 'data' => json_decode($store->share_setting, true), ]; } /** * 设置推荐人参数 * * @param int $store_id * @param array $params * @return array */ public function setReferralParams($store_id, $params) { if (!$store_id) { return [ 'code' => 1, 'msg' => 'store_id不能为空!', ]; } $store = Store::findOne($store_id); if (!$store) { return [ 'code' => 1, 'msg' => '未找到商城!', ]; } try { // 先删除,再添加 SaasStoreReferral::deleteAll(['store_id' => $store_id]); foreach ($params as $key => $value) { $obj = new SaasStoreReferral(); $obj->store_id = $store_id; $obj->referral_id = $value['referral_id']; $obj->referral_rebate = $value['referral_rebate']; $obj->save(); } return [ 'code' => 0, 'msg' => '保存成功!', ]; } catch (Exception $e) { return [ 'code' => 1, 'msg' => $e->getMessage(), ]; } } /** * 获取推荐人参数 * * @param int $store_id * @return array */ public function getReferralParams($store_id) { if (!$store_id) { return [ 'code' => 1, 'msg' => 'store_id不能为空!', ]; } $store = Store::findOne($store_id); if (!$store) { return [ 'code' => 1, 'msg' => '未找到商城!', ]; } $lists = SaasStoreReferral::find() ->where(['store_id' => $store->id]) ->select(['referral_id', 'referral_rebate']) ->asArray()->all(); return [ 'code' => 0, 'msg' => 'success', 'data' => $lists, ]; } /** * 设置商城让利比例 * * @param int $store_id * @param array $params * @return array */ public function setTransferProfitParams($store_id, $params) { if (!$store_id) { return [ 'code' => 1, 'msg' => 'store_id不能为空!', ]; } $store = Store::findOne($store_id); if (!$store) { return [ 'code' => 1, 'msg' => '未找到商城!', ]; } $transfer_profit = number_format($params['transfer_profit'], 2); $scan_transfer_profit = number_format($params['scan_transfer_profit'], 2); $food_transfer_profit = number_format($params['food_transfer_profit'], 2); $cashier_transfer_profit = number_format($params['cashier_transfer_profit'], 2); // $league_price = $params['league_price']; //取消商城最大让利比例 //$store_admin = get_admin(); //$max_price = $store_admin->max_price; // $admin_id = get_admin(); // if ($admin_id->username != 'admin' && $max_price < $transfer_profit) { // return [ // 'code' => 1, // 'msg' => '您的可设置佣金金额不足!', // ]; // } $store->transfer_profit = $transfer_profit; $store->scan_transfer_profit = $scan_transfer_profit; $store->food_transfer_profit = $food_transfer_profit; $store->cashier_transfer_profit = $cashier_transfer_profit; // $store->league_price = $league_price; if ($store->save()) { return [ 'code' => 0, 'msg' => '保存成功!', ]; } return [ 'code' => 1, 'msg' => '保存失败!', ]; } /** * 获取商城让利比例参数 * * @param int $store_id * @return array */ public function getTransferProfitParams($store_id) { if (!$store_id) { return [ 'code' => 1, 'msg' => 'store_id不能为空!', ]; } $store = Store::findOne($store_id); if (!$store) { return [ 'code' => 1, 'msg' => '未找到商城!', ]; } //获取代理商最大分佣金额 //获取代理商信息 $get_admin = get_admin(); $max_price = $get_admin->max_price; return [ 'code' => 0, 'msg' => 'success', 'data' => [ 'transfer_profit' => $store->transfer_profit, 'league_price' => $store->league_price, 'max_price' => $max_price, 'scan_transfer_profit' => $store->scan_transfer_profit, 'food_transfer_profit' => $store->food_transfer_profit, 'cashier_transfer_profit' => $store->cashier_transfer_profit ], ]; } /** * 获取商城经纬度等信息 * * @param int $store_id * @return array */ public function getStoreParams($store_id) { $admin = get_admin(); if (!$store_id) { return [ 'code' => 1, 'msg' => 'store_id不能为空!', ]; } $store = Store::findOne($store_id); if (!$store) { return [ 'code' => 1, 'msg' => '未找到商城!', ]; } $category_name = '-'; $category = SaasCategory::findOne($store->category_id); if ($category) { $category_name = $category->name; } $name = $store->name; $logo = $store->logo; if (empty($name)) { $name = Option::get('name', $store_id, 'store', '')['value']; } if (empty($logo)) { $logo = Option::get('web_log', $store_id, 'web', '')['value']; } $self_mini = Option::get('self_mini', $store_id, 'store', 0)['value']; $is_store_traffic_sharing = Option::get('is_store_traffic_sharing', $store_id, 'store', 1)['value']; $store_permission = []; $permission = []; $plugin = \Yii::$app->getAttr('plugin'); $store_permission = json_decode($store->auth); $permission = \Yii::$app->getPermission($store->business_model, $store_id); AuthRoleForm::formatPermission($permission); $is_duli_store_auth = false; if (in_array('duli_store', $plugin['union'])) { $is_duli_store_auth = true; } $salesman_id = $store->salesman_id; $md_id = -1; $page = ''; if ($store->business_model == 2) { //平台运营 $page = 'pages/shop/shopIndex'; $scene = "store_id:{$store_id}"; } elseif ($store->business_model == 3) { //当面付 $page = 'face-pay/face-pay/payOut'; $scene = "store_id:{$store_id}"; } elseif ($store->business_model == 4) { //点餐 $page = 'alipay-order/orderMeal/orderMeal'; $scene = "md_id:{$md_id},store_id:{$store_id}"; } if($page != '') { $qr_code_res = ShareQrcode::wxQrcode($page, $scene); } //是否允许添加产品 $is_add_goods = Option::get('is_add_goods', $store_id, 'store', 1)['value']; return [ 'code' => 0, 'msg' => 'success', 'data' => [ 'is_super_admin' => get_admin()->username == 'admin', 'name' => $name, 'logo' => $logo, 'qr_code_url' => $qr_code_res['url_path'], 'coordinate' => $store->coordinate, 'address' => $store->address, 'category_id' => $store->category_id, 'category_name' => $category_name, 'option' => is_array($store->info) ? $store->info : \json_decode($store->info, true), 'address_info' => [ 'province_id' => $store->province_id, 'city_id' => $store->city_id, 'district_id' => $store->district_id ], 'sales' => $store->sales, 'rank' => $store->rank, 'per_spend' => $store->per_spend, 'tags' => empty($store->tags) ? [] : json_decode($store->tags), 'contact_tel' => $store->contact_tel, 'user_name' => $store->user_name, 'open_status' => $store->open_status, 'shop_time_type' => $store->shop_time_type, 'is_time_forbid' => $store->is_time_forbid, 'is_set_distance' => $store->is_set_distance, 'distance' => $store->distance, 'start_time' => $store->s_time, 'end_time' => $store->e_time, 'store_admin' => $store->store_admin, 'business_model' => $store->business_model, 'self_mini' => $self_mini ? 1 : 0, 'permission' => $admin->type == Admin::ADMIN_TYPE_BD_AGENT ? [] : $permission, 'store_permission' => $admin->type == Admin::ADMIN_TYPE_BD_AGENT ? [] : $store_permission, 'prod_is_shangmeng' => \Yii::$app->prod_is_shangmeng(), 'prod_is_saas' => \Yii::$app->prod_is_saas(), 'cost_end_time' => date('Y-m-d', $store->end_time), 'is_duli_store_auth' => $is_duli_store_auth, 'salesman_id' => $salesman_id, 'is_add_goods' => (int)$is_add_goods, 'balance' => $store->balance, 'mini_auth_num' => $store->mini_auth_num, 'is_store_traffic_sharing' => isset($is_store_traffic_sharing)? (string)($is_store_traffic_sharing) : '1' ], ]; } /** * 设置商城经纬度信息 * * @param int $store_id * @param array $params * @return array */ public function setStoreParams($store_id, $params) { $admin = get_admin(); if (!$store_id) { return [ 'code' => 1, 'msg' => 'store_id不能为空!', ]; } $store = Store::findOne($store_id); if (!$store) { return [ 'code' => 1, 'msg' => '未找到商城!', ]; } if (isset($params['coordinate']) && !empty($params['coordinate'])) { if (strpos($params['coordinate'], ',') === false) { return [ 'code' => 1, 'msg' => '商城坐标信息格式不正确!', ]; } $store->coordinate = $params['coordinate']; Option::set('coordinate', $params['coordinate'], $store->id, 'store'); if ($params['coordinate']) { $coordinate = explode(',', $params['coordinate']); $store->longitude = $coordinate[1]; $store->latitude = $coordinate[0]; } } $store->name = $params['name']; $store->logo = $params['logo']; // 同步option表 Option::set('name', $params['name'], $store_id, 'store'); Option::set('logo', $params['logo'], $store_id, 'store'); Option::set('contact_tel', $params['contact_tel'], $store_id, 'store'); Option::set('web_log', $params['logo'], $store_id, 'web'); $store->address = $params['address']; Option::set('address', $params['address'], $store_id, 'store'); $store->category_id = $params['category_id']; $store->sales = $params['sales']; $store->rank = $params['rank']; $store->per_spend = $params['per_spend']; $store->user_name = $params['user_name']; $store->contact_tel = $params['contact_tel']; $store->tags = json_encode($params['tags'], JSON_UNESCAPED_UNICODE); $store->open_status = intval($params['open_status']); $shop_time_type = intval($params['shop_time_type']); // $store->store_admin = intval($params['store_admin']); $store->shop_time_type = $shop_time_type; $store->is_time_forbid = intval($params['is_time_forbid']); $is_set_distance = intval($params['is_set_distance']); $store->balance = intval($params['balance']); if ($params['salesman_id']) { $salesman = Salesman::findOne($params['salesman_id']); $store->salesman_id = $params['salesman_id']; $store->store_admin = $salesman->saas_user_id; } $params['cost_end_time'] && $store->end_time = strtotime($params['cost_end_time']); if ($is_set_distance) { if (empty($params['distance'])) { return [ 'code' => 1, 'msg' => '未设置距离范围' ]; } $store->distance = $params['distance']; } $store->is_set_distance = intval($params['is_set_distance']); if ($shop_time_type) { if (empty($params['start_time'] || empty($params['end_time']))) { return [ 'code' => 1, 'msg' => '请设置开始时间和结束时间' ]; } $store->s_time = $params['start_time']; $store->e_time = $params['end_time']; } if (!empty($params['category_option'])) { $store->info = json_encode($params['category_option']); } if ($params['address_info']) { Option::set('address_info', json_encode($params['address_info']), $store_id, 'store'); $store->province_id = $params['address_info']['province_id']; $store->city_id = $params['address_info']['city_id']; $store->district_id = $params['address_info']['district_id']; } $store->business_model = intval($params['business_model']); Option::set('self_mini', intval($params['self_mini']), $store_id, 'store'); Option::set('is_store_traffic_sharing', intval($params['is_store_traffic_sharing']), $store_id, 'store'); Option::set('is_add_goods', $params['is_add_goods'], $store_id, 'store'); // $plugin = \Yii::$app->getAttr('plugin'); // if (in_array('store_auth', $plugin['union']) && $store->business_model == 1) { if ($admin->type != Admin::ADMIN_TYPE_BD_AGENT) { if ($store->business_model == 1 || $store->business_model == 2) { $store->auth = json_encode($params['store_permission']); } else { $store->auth = json_encode([]); } } $store->mini_auth_num = $params['mini_auth_num']; if ($store->save()) { if ($store->balance == 1) { $option = Option::find()->where(["store_id" => get_store_id(), "name" => "combine_pay", "group" => "recharge"])->one(); if ($option !== null) { $option->value = '0'; if (!$option->save()) { $option->getErrors(); } } else { // 处理未找到记录的情况,可以抛出异常或者记录日志等 $option = Option::find()->where(["store_id" => get_store_id(), "name" => "combine_pay", "group" => "recharge"])->one(); $option = new Option(); $option->store_id = $store_id; $option->name = "combine_pay"; $option->group = "recharge"; $option->value = '0'; if (!$option->save()) { $option->getErrors(); } } } return [ 'code' => 0, 'msg' => '保存成功!', ]; } return [ 'code' => 1, 'msg' => $store->getErrorSummary(false), ]; } /** * 获取商城信息 */ public function getInfo($store_id) { if (!$store_id) { // return [ // 'code' => 1, // 'msg' => 'store_id不能为空!', // ]; } $store = Store::findOne($store_id); if (!$store) { // return [ // 'code' => 1, // 'msg' => '未找到商城!', // ]; } $path_h5 = path_h5(); $text = 'https://' . \Yii::$app->request->hostName . '/' . $path_h5 . '/#/?store_id=' . $store_id; $filename = md5('_' . $path_h5 . '_' . $store_id); $path = \Yii::$app->runtimePath . '/image/' . $filename . '.jpg'; if (!file_exists($path)) { QrCode::image($text, 500, false, 'L', 'JPEG', 0, ['255,255,255', '0,0,0'], 1, false, $path); } $path_url = str_replace('http://', 'https://', \Yii::$app->request->hostInfo . '/runtime/image/' . $filename . '.jpg'); return [ 'code' => 0, 'msg' => 'success', 'data' => $store, 'h5' => [ 'url' => $text, 'qrcode_url' => $path_url ] ]; } public function joinAlliance($store_id, $status) { if (!$store_id) { return [ 'code' => 1, 'msg' => 'store_id不能为空!', ]; } $store = Store::findOne($store_id); if (!$store) { return [ 'code' => 1, 'msg' => '未找到商城!', ]; } $store->is_alliance = $status; if ($store->save()) { return [ 'code' => 0, 'msg' => '操作成功!', ]; } return [ 'code' => 1, 'msg' => '操作失败!', ]; } /** * 获取待审核商城 */ public function getCheckList() { $query = Store::find()->where([ 'is_delete' => 0, 'is_alliance' => 2, ]); $pagination = pagination_make($query); $list = $pagination['list']; foreach ($list as &$item) { $option = Option::get('name', $item['id'], 'store', '-'); $item['store_name'] = $option['value']; } return [ 'code' => 0, 'msg' => 'success', 'data' => [ 'data' => $list, 'pageNo' => $pagination['pageNo'], 'totalCount' => $pagination['totalCount'], ], ]; } public function getDouyinInfo($store_id) { if (!$store_id) { return [ 'code' => 1, 'msg' => 'store_id不能为空!', ]; } $store = Store::findOne($store_id); if (!$store) { return [ 'code' => 1, 'msg' => '未找到商城!', ]; } $default_douyin_config = [ 'app_id' => '', 'app_secret' => '', 'salt' => '', 'token' => '' ]; $douyin_config = Option::get('douyin', $store_id, 'store', $default_douyin_config)['value']; $douyin_config = is_string($douyin_config) ? Json::decode($douyin_config) : $douyin_config; return [ 'code' => 0, 'msg' => 'success', 'data' => [ 'douyin_url' => $store->douyin_url, 'app_id' => $douyin_config['app_id'], 'app_secret' => $douyin_config['app_secret'], 'salt' => $douyin_config['salt'], 'token' => $douyin_config['token'], ], ]; } public function setDouyinInfo($store_id, $content, $params) { if (!$store_id) { return [ 'code' => 1, 'msg' => 'store_id不能为空!', ]; } $store = Store::findOne($store_id); if (!$store) { return [ 'code' => 1, 'msg' => '未找到商城!', ]; } $store->douyin_url = $content; if ($store->save()) { if (Option::set('douyin', Json::encode($params), $store_id, 'store')) { return [ 'code' => 0, 'msg' => '保存成功!', ]; } else { return [ 'code' => 1, 'msg' => '保存失败!', ]; } } return [ 'code' => 1, 'msg' => $store->errors[0], ]; } public function getCost($store_id){ if (!$store_id) { return false; } $store = Store::findOne($store_id); if (!$store) { return [ 'code' => 0, 'msg' => '未找到商城!', ]; } return [ 'code' => 0, 'msg' => "获取成功", 'data'=>[ "open_price" =>$store->open_price, "renew_price" =>$store->renew_price, "end_time" =>date("Y-m-d",$store->end_time), "profit" =>$store->profit, "is_end"=>$store->end_time ? ($store->end_time > time() || !\Yii::$app->isSaas()) : true, 'is_use_default' => $store->is_use_default ?? 1 ] ]; } public function setCost($store_id,$params){ if (!$store_id) { return [ 'code' => 1, 'msg' => 'store_id不能为空!', ]; } $store = Store::findOne($store_id); if (!$store) { return [ 'code' => 1, 'msg' => '未找到商城!', ]; } $store->open_price = $params['open_price']; $store->renew_price = $params['renew_price']; $store->end_time = $params['end_time']; $store->profit = $params['profit']; $store->is_use_default = $params['is_use_default']; $res = $store->save(); if ($res) { if (Option::set('store_save', Json::encode($params), $store_id, 'store')) { return [ 'code' => 0, 'msg' => "保存成功" ]; } }else{ return [ 'code' => 1, 'msg' => $store->errors[0], ]; } } public function payFee($store_id){ $t = \Yii::$app->db->beginTransaction(); try { $store = Store::find()->where(['id' => $store_id]) ->select("open_price, renew_price, end_time, profit, is_use_default")->one(); if ($store->end_time > 0 && $store->end_time < time() && \Yii::$app->isSaas()) { $admin = Admin::findOne(['type' => 'store', 'type_id' => $store_id]); $res = ShareQrcode::wxQrcode('admin/home/home', '0', 1000, 0, 1); if ($res['code'] === 0) { $array = [ 'code' => 0, 'url' => $res['url_path'], 'desc' => '', 'name' => '店铺续费' ]; if ($admin->saas_user_id) { $saas_user = SaasUser::findOne($admin->saas_user_id); $array['desc'] = '请使用管理员'. $saas_user->name .'('. $saas_user->mobile .')扫码续费,完成后刷新'; } else { $array['desc'] = '当前商城未添加管理员,请联系平台添加管理员后扫码续费'; } return $array; } return $res; } }catch (\Exception $e){ $t->rollBack(); return [ 'code' => 0, 'msg' => $e->getMessage() ]; } } public function isPay($order_id){ $order = StoreReOrder::findOne($order_id); if($order->is_pay == 1){ // $store = Store::findOne($order->store_id); // $store->end_time = strtotime('+1 year'); // $store->save(); return [ 'code'=>0, 'msg'=>"支付成功" ]; } } //修改密码 public function setPassword($id = 0, $password = "", $name = '', $user_name = '', $saas_user_id = ''){ $t = \Yii::$app->db->beginTransaction(); try { // $store = Store::find()->where(['id'=>$id])->select("id,admin_id")->one(); // if(empty($store) || empty($store->admin_id)){ // throw new Exception('获取商城信息失败'); // } $admin = Admin::findOne([ 'type' => 'store', 'type_id' => $id ]); if (!$admin) { if($id == 1){ $admin = new Admin(); $admin->access_token = \Yii::$app->security->generateRandomString(); $admin->type = 'store'; $admin->type_id = 1; $admin->name = ''; $admin->username = ''; $admin->mobile = ''; }else{ throw new Exception('该商城不可更改该信息'); } } if ($name) { $admin->name = $name; } if ($user_name) { $admin->username = $user_name; } if ($name && $user_name) { $search_admin = Admin::findOne([ // 'type' => 'store', 'username' => $user_name, 'is_delete' => 0 ]); if ($search_admin && ($search_admin->id !== $admin->id)) { throw new \Exception("用户名已经存在"); } } if ($password) { $admin->password = \Yii::$app->security->generatePasswordHash($password); } if ($saas_user_id) { $admin->saas_user_id = $saas_user_id; } $res = $admin->save(); if(!$res){ $err = ''; foreach($admin->errors as $k => $item){ $err .= $k . ':[' . implode('],[', $item) . '];'; } throw new \Exception($err); } $platForm = new PlatformForm(); $store_cloud = StoreCloud::findOne(['store_id' => $id, 'is_delete' => 0]); if ($store_cloud) { StoreCloud::updateAll(['store_id' => 0], ['store_id' => $id, 'is_delete' => 0]); // if (intval($store_cloud->saas_user_id) !== intval($saas_user_id) && $saas_user_id) { // $store_cloud = StoreCloud::findOne(['saas_user_id' => $saas_user_id, 'is_delete' => 0]); // if (!$store_cloud) { // $store_cloud->saas_user_id = $saas_user_id; // } // } $open = false; if ($saas_user_id && $store_cloud->saas_user_id !== $saas_user_id) { $store_cloud = StoreCloud::findOne(['saas_user_id' => $saas_user_id, 'is_delete' => 0]); if (!$store_cloud) { throw new \Exception('当前用户未绑定云仓'); } $open = true; } $old_store_id = $store_cloud->store_id; $store_cloud->store_id = $id; if ($store_cloud->save() && $open) { $platForm->delUserCloudGoodsBind($store_cloud->cloud_user_id, $old_store_id); }; } else { $store_cloud = StoreCloud::findOne(['saas_user_id' => $saas_user_id, 'is_delete' => 0]); if ($store_cloud) { $old_store_id = $store_cloud->store_id; $store_cloud->store_id = $id; if ($store_cloud->save()) { $platForm->delUserCloudGoodsBind($store_cloud->cloud_user_id, $old_store_id); } } } // $store_cloud = StoreCloud::find()->where(['OR', ['store_id' => $id], ['saas_user_id' => $saas_user_id]]) // ->andWhere(['is_delete' => 0])->asArray()->one(); if (!$store_cloud && get_platform_token()) { try { $store = Store::findOne($id); $saas_user = SaasUser::findOne(['id' => $saas_user_id, 'is_delete' => 0]); // 创建云仓账号 $this->createStoreCloud($saas_user->mobile, $store, $saas_user); } catch (\Exception $e) { throw new \Exception($e->getMessage()); } } $t->commit(); return [ 'code'=>0, 'msg'=>"修改成功" ]; }catch (\Exception $e){ $t->rollBack(); return [ 'code'=>1, 'msg'=>$e->getMessage() ]; } } public function reOrderList($store_id){ $query = StoreReOrder::find()->where(['store_id'=>$store_id,'is_delete'=>0,'is_pay'=>1]); $count = $query->count(); $pagination = new Pagination(['totalCount' => $count, 'page' =>$this->page - 1, 'pageSize' => $this->limit]); /* @var Order[] $list */ $data = $query->limit($pagination->limit)->offset($pagination->offset)->orderBy('created_at DESC')->asArray()->all(); foreach($data as &$item){ $item['pay_time'] = date("Y-m-d H:i:s",$item['pay_time']); $item['is_pay'] = $item['is_pay'] == 1?"已支付":"未支付"; } return [ 'code'=>0, 'msg'=>"获取成功", 'list'=>$data, 'count'=>$count ]; } /** * 获取商城审核列表 */ public function getAuditList() { try { //如果是代理商登陆 $admin = get_admin(); $admin_id = $admin->id; $salesman_id = $this->salesman_id; if ($admin->username == 'admin') { $admin_id = null; } $where = []; $query = Salesman::find()->alias('s')->leftJoin(['su' => SaasUser::tableName()], 's.saas_user_id = su.id'); if ($admin_id) { $data = []; $query->where(['s.admin_id' => $admin_id]); } else { $data = [0]; } $query->andWhere(['admin_id' => Admin::find()->where(['type' => Admin::ADMIN_TYPE_BD_AGENT])->select('id')]); //如果是搜索 // $admin_id = $this->admin_id; // if ($admin_id) { // $query->where(['s.admin_id' => $admin_id]); // } $salesmans = $query->andWhere(['su.is_delete' => 0, 's.is_delete' => 0, 's.status' => 1])->select('s.id, su.name, su.avatar')->asArray()->all(); $ids = []; if ($salesmans) { $ids = array_column($salesmans, 'id'); // $ids = array_merge($ids, $data); // $where['sa.salesman_id'] = $ids; } if ($salesman_id) { $where['sa.salesman_id'] = $salesman_id; } //正常流程开始 //$status = (int)$this->status; //if (in_array($status, [0, 1, 2], true)) { // $where['sa.status'] = $status; //} $admin = Admin::find()->where(['is_delete' => 0, 'type' => 'admin'])->andWhere(['<>', 'name', 'admin'])->select('id, name')->asArray()->all(); $query = StoreAudit::find()->alias('sa')->where($where) // ->andWhere(['!=', 'sa.status', 1]) ->leftJoin(['sc' => SaasCategory::tableName()], 'sa.cat_id = sc.id') ->leftJoin(['su' => SaasUser::tableName()], 'sa.saas_user_id = su.id') //->leftJoin(['s' => Salesman::tableName()], 's.saas_user_id = su.id') //->leftJoin(['a' => Admin::tableName()], 'a.id = s.admin_id') //->andWhere(['s.is_delete' => 0, 'a.is_delete' => 0, 'su.is_delete' => 0]) ->andWhere(['su.is_delete' => 0]) ->select('sa.id, sa.is_single_store, sa.saas_user_id, sa.salesman_id, sa.name, sa.logo, sa.mobile, sa.business_pic, sa.permit_pic, sa.status, sa.created_at, su.name username, sc.name category_name, sa.updated_at') ->orderBy(', sa.created_at desc, sa.updated_at desc'); // var_dump($query->createCommand()->getRawSql());die; $name = $this->name; if ($name) { $query->andWhere(['like', 'sa.name', $name]); } if ($admin_id) { $admin_model = Admin::findOne($admin_id); $area_level = $admin_model->area_level; if($area_level == 1){ $query->andWhere([ 'or', ['sa.province_id' => $admin_model->province_id, 'sa.city_id' => $admin_model->city_id, 'sa.district_id' => $admin_model->district_id], ['in', 'sa.salesman_id', array_column($salesmans, 'id')] ]); } elseif ($area_level == 2){ $query->andWhere([ 'or', ['sa.province_id' => $admin_model->province_id, 'sa.city_id' => $admin_model->city_id], ['in', 'sa.salesman_id', array_column($salesmans, 'id')] ]); } elseif ($area_level == 3){ $query->andWhere([ 'or', ['sa.province_id' => $admin_model->province_id], ['in', 'sa.salesman_id', array_column($salesmans, 'id')] ]); } else { $query->andWhere( ['in', 'sa.salesman_id', array_column($salesmans, 'id')] ); } } $status = (int)$this->status; if (in_array($status, [0, 1, 2], true)) { // if ($status === 1) { // $query->andWhere(['<>', 'sa.salesman_id', 0]); // } else { // $query->andWhere(['sa.salesman_id' => 0]); // } $query->andWhere(['sa.status' => $status]); } $pagination = pagination_make($query); $list = $pagination['list']; foreach ($list as &$item) { $Salesman = Salesman::find()->alias('s')->where(['s.id' => $item['salesman_id'], 's.is_delete' => 0]) ->leftJoin(['su' => SaasUser::tableName()], 's.saas_user_id = su.id') ->leftJoin(['a' => Admin::tableName()], 'a.id = s.admin_id')->select('su.name salesman, a.name')->asArray()->one(); // var_dump($Salesman);die; $item['admin_name'] = $Salesman ? $Salesman['name'] : ''; $item['salesman'] = $Salesman ? $Salesman['salesman'] : ''; $item['created_at'] = date('Y-m-d H:i:s', $item['created_at']); $item['updated_at'] = !empty($item['updated_at']) ? date('Y-m-d H:i:s', $item['updated_at']) : 0; $item['status'] *= 1; } return [ 'code' => 0, 'msg' => 'success', 'data' => [ 'data' => $list, 'pageNo' => $pagination['pageNo'], 'totalCount' => $pagination['totalCount'], 'salesman' => $salesmans, 'admin' => $admin ], ]; } catch (\Exception $e) { return [ 'code' => 1, 'msg' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine(), ]; } } public function bindSalesman() { try { $id = $this->id; $salesman_id = $this->salesman_id; $audit = StoreAudit::findOne($id); if (empty($audit)) { throw new \Exception("获取不到申请单信息"); } if ((int)$audit->status !== 0) { throw new \Exception("申请单已经被处理,不可更改"); } $salesman = Salesman::findOne(['id' => $salesman_id, 'is_delete' => 0]); if (empty($salesman)) { throw new \Exception("业务员信息未找到"); } if ((int)$salesman->status === 0) { throw new \Exception("业务员已经被禁用"); } $audit->salesman_id = $salesman->id; $audit->saas_user_id = $salesman->saas_user_id; if (!$audit->save()) { throw new \Exception("保存失败"); } return [ 'code' => 0, 'msg' => "操作成功" ]; } catch (\Exception $e) { return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } //申请 public function storeAudit() { $t = \Yii::$app->db->beginTransaction(); try { $id = $this->id; $status = (int)$this->status; $business_model = $this->business_model; $qrcode_id = $this->qrcode_id; $audit = StoreAudit::findOne($id); if (empty($audit)) { throw new \Exception("获取不到申请单信息"); } if ((int)$audit->status !== 0) { throw new \Exception("申请单已经被处理,请勿重复操作"); } if (!in_array($status, [1, 2])) { throw new \Exception("状态值错误"); } //同意申请 if ($status === 1) { if ($audit->is_single_store == 0) { // if (empty($qrcode_id)) { // throw new \Exception("请填写聚合码ID"); // } if (!in_array($business_model, [1, 2, 3, 4])) { throw new \Exception("请选择商城类型"); } // if ((int)$business_model === 1) { // $AggregateQrcode = AggregateQrcode::findOne($qrcode_id); // } else { // $AggregateQrcode = AggregateSaasQrcode::findOne($qrcode_id); // } // if (empty($AggregateQrcode)) { // throw new \Exception("对应的聚合码不存在,请重试"); // } // if ($AggregateQrcode->store_id) { // throw new \Exception("聚合码已经被使用"); // } } // 自动创建admin账号 $admin = new Admin(); $admin->access_token = \Yii::$app->security->generateRandomString(); $admin->saas_user_id = $audit->saas_user_id; $admin->username = $audit->name; // $admin->password = \Yii::$app->security->generatePasswordHash($audit->mobile); // 默认密码改为cyyvipcom 与后台添加商城统一 if (!empty($audit->password)) { $admin->password = $audit->password; } else { $admin->password = \Yii::$app->security->generatePasswordHash('123456'); }; $admin->mobile = $audit->mobile; $admin->name = $audit->name; $admin->type = 'store'; // $admin->saas_user_id = $audit->saas_user_id; // $file_name = \Yii::$app->runtimePath . '/logs/app_wechat.log'; //file_put_contents($file_name, "\r\n" . '[审核开始][' . date('Y-m-d H:i:s') . 1 . ']' , FILE_APPEND); if ($admin->save()) { //判断后台开启通联 // $oldConf = Option::get(OptionSetting::SAAS_YUNST_SETTING, 0, 'saas')['value']; // if ($oldConf) { // $oldConf = json_decode($oldConf, true); // if (!empty($oldConf) && !empty(trim($oldConf['appid']))) { // //调用第三方会员创建接口 // $memberService = new MemberService(); // $res_member = $memberService->createMember($audit->store_number,2); // if ($res_member['subCode'] == "FAIL"){ // throw new Exception($res_member['subMsg']); // } // } // } $salesman = null; if ($audit->salesman_id > 0) { $salesman = Salesman::findOne(['id' => $audit->salesman_id, 'is_delete' => 0]); } $store_apply_free = Option::get('store_apply_free', 0, 'saas', 0)['value']; $store_apply_free_days = Option::get('store_apply_free_days', 0, 'saas', 0)['value']; $end_time = time(); if ($store_apply_free) { $end_time = strtotime("+". $store_apply_free_days." day"); } $store = new Store(); $store->admin_id = $admin->id; $store->logo = $audit->logo; $store->created_at = time(); $store->end_time = $end_time; // $store->store_number = $audit->store_number; // $store->yunst_user_id = $res_member['data']['userId'] ?? ''; if ($audit->is_single_store == 0) { $store->business_model = $business_model; } else { $store->business_model = 1; } $store->open_status = 0; $store->store_admin = $audit->saas_user_id; $store->name = $audit->name; $store->salesman_id = $salesman ? $salesman->id : 0; $store->province_id = $audit->province_id; $store->city_id = $audit->city_id; $store->district_id = $audit->district_id; $admin->province_id = $audit->province_id; $admin->city_id = $audit->city_id; $admin->district_id = $audit->district_id; if ($store->save()) { $costParams = [ 'open_price' => 0, 'renew_price' => 0, 'end_time' => $end_time, 'profit' => 0, 'is_use_default' => 0, ]; $store_apply_free = Option::get('store_apply_free_start', $store->id, 'store', '')['value']; if($store_apply_free){ $store_apply_free_days = Option::get('store_apply_free_days', 0, 'saas', 5)['value']; $costParams['end_time'] = time() + $store_apply_free_days * 86400; } $store_apply_buy_type = Option::get('store_apply_buy_type', 0, 'saas', 'free')['value'];//free/once/renew Option::set('store_buy_type', $store_apply_buy_type, $store->id, 'store'); if($store_apply_buy_type == 'free'){ $costParams['open_price'] = 0; $costParams['renew_price'] = 0; $costParams['end_time'] = strtotime('2038-01-01 00:00:00'); } if($store_apply_buy_type == 'once'){ $store_apply_buy_money = Option::get('store_apply_buy_money', 0, 'saas', 0)['value']; $costParams['open_price'] = $store_apply_buy_money; $costParams['renew_price'] = 0; } if($store_apply_buy_type == 'renew'){ $costParams['open_price'] = 0; $costParams['renew_price'] = 0; } $this->setCost($store->id, $costParams); // file_put_contents($file_name, "\r\n" . '[审核开始][' . date('Y-m-d H:i:s') . 2 . ']' , FILE_APPEND); $admin->type_id = $store->id; $admin->save(); // 绑定关系 if ($audit->saas_user_id) { if (\Yii::$app->prod_is_dandianpu()) { $saas_user = SaasUser::findOne(['id' => $audit->saas_user_id, 'is_delete' => 0]); if ($saas_user) { // $saas_user->store_id = $store->id; // $saas_user->save(); } // 创建云仓账号 // $this->createStoreCloud($audit->mobile, $store, $saas_user); } else { // Todo //SaasStoreReferral::storeBindParent($saas_user->id, $store->id); } // if (!\Yii::$app->prod_is_dandianpu()) { // $saas_store_referral = new SaasStoreReferral(); // $saas_store_referral->store_id = $store->id; // $saas_store_referral->referral_id = $saas_user->id; // if (!$saas_store_referral->save()) { // $t->rollBack(); // \Yii::error("绑定关系失败"); // \Yii::error($saas_store_referral->errors); // throw new \Exception("绑定关系失败"); // } // } } // 初始化商城 $this->initStorageConfig($store->id); // 设置商城名称 Option::set('name', $store->name, $store->id, 'store'); Option::set('logo', $store->logo, $store->id, 'store'); Option::set(OptionSetting::WECHAT_IS_SHENHE, '0', $store->id, 'wechat'); Option::set(OptionSetting::WECHAT_ALI_IS_SHENHE, '0', $store->id, 'wechat'); // 初始化DIY页面 // 初始化diy模板 $is = NewDiyTemplate::find() ->where([ 'store_id' => $store->id, 'is_delete' => 0, 'type' => 100 ])->asArray()->one(); if (!$is) { $this->initDiyTemplate($store->id); } //安装完成后装修表中的store_id比本商城的store_id还大 导致订单提交装修无法新增 //解决一下这个问题 $system_diy = NewDiyTemplate::find() ->where([ 'store_id' => $store->id, 'is_delete' => 0, 'name' => 'system' ])->asArray()->all(); $is_order_diy = false; foreach ($system_diy as $diy_item) { $template_detail = json_decode($diy_item['template'], true); if (isset($template_detail['system_type']) && $template_detail['system_type'] === 'orderPreview') { $is_order_diy = true; } } if (!$is_order_diy) { $submit = new NewDiyTemplate(); $submit->store_id = $store->id; $submit->name = 'system'; $submit->template = '{"page_name":"订单提交","is_index":"0","page_type":1,"system_type":"orderPreview","page_link":"","theme":{"color":"#292929","time":1711097460417},"pageCss":{"margin":0,"padding":0,"vSpave":0,"hSpace":0,"borderRadius":0,"borderRaNum":0,"backgroundColor":"#fcfcfc","backgroundImage":"","bgImg":"","bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat"},"templates":[{"name":"订单预览页面-头部","type":"","comName":"orderPreviewHeader","icon":"","controlComName":"","params":[]},{"name":"订单预览页面-发货方式选择","type":"","comName":"orderPreviewDelivery","icon":"","controlComName":"orderPreviewDeliveryControl","params":{"type":"2","diy_express_name":"快递","diy_delivery_name":"同城","diy_shop_name":"自提"},"moduleCss":{"backgroundColor":"#ffffff","backgroundImage":"","bgImg":"","useBackground":true,"bgOpacity":100,"opacity":"100","backgroundSize":"100% 100%","backgroundRepeat":"no-repeat","margin":0,"padding":0,"borderRadius":8}},{"name":"订单预览页面-订单主体信息","type":"","comName":"orderPreviewContent","icon":"","controlComName":"","params":[]}],"controlComName":"pageControl","id":"3395"}'; $submit->addtime = time(); $submit->type = 1; $submit->save(); } try { $id = \queue_push(new StoreSyncJob(['type' => 1, 'to_id' => $store->id]), 0, 1); debug_log($id, 'queuePush.log'); // $res = \app\models\StoreCopy::doCopy($default_store_id, $store->id, $default['type']); } catch (\Exception $e) { debug_log(['message' => $e->getMessage(), 'line' => $e->getLine()], 'queuePush.log'); } //绑定二维码 if(isset($AggregateQrcode) && !empty($AggregateQrcode)){ $AggregateQrcode->store_id = $store->id; $AggregateQrcode->salesman_id = $salesman ? $salesman->id : 0; $AggregateQrcode->admin_id = $salesman ? $salesman->admin_id : 0; $AggregateQrcode->shop_bind_time = time(); $res = $AggregateQrcode->save(); if(!$res){ \Yii::error("聚合码绑定失败"); \Yii::error($AggregateQrcode->errors); throw new \Exception("聚合码绑定失败"); } } // if ($salesman) { // $sales_admin = Admin::findOne($salesman->admin_id); // $sales_saas_user_id = $sales_admin->saas_user_id; // if ($sales_saas_user_id) { // // 代理商绑定 // $saas_store_referral = new SaasStoreReferral(); // $saas_store_referral->store_id = $store->id; // $saas_store_referral->referral_id = $sales_saas_user_id; // if (!$saas_store_referral->save()) { // throw new \Exception("代理商绑定失败"); // } // } // } if ($audit->saas_user_id) { // 绑定上级关系 // if(!SaasStoreReferral::storeBindParent($salesman, $store->id)){ // $t->rollBack(); // \Yii::error("绑定上级关系失败"); // throw new \Exception("绑定上级关系失败"); // } } try { $merchant = new Merchant(); $merchant_info = new MerchantInfo(); $merchant_info->store_id = get_store_id(); $merchant_info->saas_user_id = $audit->saas_user_id; $merchant_info->business_code = $merchant->getBusinessCode(); $merchant_info->bind_store_id = $store->id; $merchant_info->app_status = "1,2"; $merchant_info->from = 1; if (!$merchant_info->save()) { \Yii::error($merchant_info->errors); throw new \Exception("保存进件信息失败"); } else { $audit->status = 1; $audit->merchant_info_id = $merchant_info->id; if (!$audit->save()) { \Yii::error($audit->errors); throw new \Exception("申请单修改失败"); } } } catch (\Exception $e) { // throw new \Exception($e->getMessage()); } // file_put_contents($file_name, "\r\n" . '[审核开始][' . date('Y-m-d H:i:s') . 3 . ']' , FILE_APPEND); } else { \Yii::error($store->errors); throw new \Exception("店铺新增失败." . array_shift($store->getFirstErrors())); } } else { \Yii::error($admin->errors); throw new \Exception("新增管理员失败." . array_shift($admin->getFirstErrors())); } } else { $audit->status = 2; if (!$audit->save()) { \Yii::error($audit->errors); throw new \Exception("申请单修改失败"); } } if (\Yii::$app->prod_is_dandianpu()) { if ($audit->saas_user_id) { // 创建云仓账号 if (isset($store) && isset($saas_user)) { $this->createStoreCloud($audit->mobile, $store, $saas_user); } } } $t->commit(); //申请通过发送短信 $str = ''; $res = NoticeSend::AgentExamine($id, 2); if (isset($res['code']) && $res['code'] !== 0) { // throw new \Exception('申请成功,短信发送失败'); $str = '短信发送失败'; } return [ 'code' => 0, 'store' => $store ? $store : null, 'msg' => "操作成功," . $str ]; } catch (\Exception $e) { $t->rollBack(); return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } // 创建云仓账号 public function createStoreCloud($mobile, $store, $saas_user){ try { $cloud_token = get_platform_token(); if (empty($cloud_token)) { throw new \Exception("获取云仓token失败"); } if (!$saas_user) { throw new \Exception("saas user不存在"); } $storeCloud = StoreCloud::findOne(['is_delete' => 0, 'saas_user_id' => $saas_user->id]); $purchase = Purchase::findOne(['saas_user_id' => $saas_user->id, 'is_delete' => 0]); if (empty($storeCloud)) { $domain = (new OptionSetting)->getCloudDomainName(); $url = "/cloud/purchase/createPurchase"; $data['access_token'] = $cloud_token; $data['name'] = $store->name; $data['logo'] = $saas_user->avatar; $data['tel'] = $mobile; $data['pwd'] = $mobile; $result = cloud_post($domain . $url, $data); $result = json_decode($result, true); if ((int)$result['code'] > 0) { throw new \Exception($result['msg']); } $mch_id = $result['data']['mch_id']; $user_id = $result['data']['user_id']; $storeCloud = new StoreCloud(); $storeCloud->store_id = 0; $storeCloud->cloud_user_id = $user_id; $storeCloud->cloud_store_id = $mch_id; $storeCloud->saas_user_id = $saas_user->id; $storeCloud->name = $store->name; $storeCloud->password = $mobile; $storeCloud->logo = $saas_user->avatar; $storeCloud->type = 0; $storeCloud->tel = $mobile; $storeCloud->created_at = time(); $storeCloud->store_id = $store->id; $storeCloud->province_id = $store->province_id; $storeCloud->city_id = $store->city_id; $storeCloud->district_id = $store->district_id; $storeCloud->save(); } else { // $storeCloud->name = $store->name; // $storeCloud->password = $mobile; $storeCloud->logo = $saas_user->avatar; $storeCloud->saas_user_id = $saas_user->id; $storeCloud->store_id = $store->id; $storeCloud->province_id = $store->province_id; $storeCloud->city_id = $store->city_id; $storeCloud->district_id = $store->district_id; $storeCloud->save(); } if (!$purchase) { $purchase = new \app\models\Purchase(); $purchase->store_cloud_id = $storeCloud->id; $purchase->name = $store->name; $purchase->mobile = $mobile; $purchase->saas_user_id = $saas_user->id; $purchase->status = 1; $purchase->province_id = $store->province_id; $purchase->city_id = $store->city_id; $purchase->district_id = $store->district_id; $purchase->save(); } } catch (\Exception $e) { return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } //获取收款码 public function getQrcode () { $business_model = (int)$this->business_model; if (in_array($business_model, [1, 2, 3, 4])) { if ($business_model === 1) { $query = AggregateQrcode::find(); } else { $query = AggregateSaasQrcode::find(); } $qrcode = $query->where(['is_use' => 1, 'store_id' => 0])->select('id')->column(); return [ 'code' => 0, 'msg' => "SUCCESS", 'data' => $qrcode ]; } return [ 'code' => 0, 'msg' => "SUCCESS", 'data' => [] ]; } }