虚心使人进步

虚心学习,天天向上......
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

ecshopx开发步骤及常见问题

Posted on 2022-05-17 09:35  Showker  阅读(142)  评论(0编辑  收藏  举报

开发步骤

本地调试
1、companys和operators表、resources 3个表清空,用线上的
2、license.zl用线上的
3、本地修改resources表里的expired_at
4、清空redis里这2个键名

 5、执行以下sql语句创建管理员

--
-- 表的结构 `companys`
--

DROP TABLE IF EXISTS `companys`;
CREATE TABLE IF NOT EXISTS `companys` (
  `company_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '公司id',
  `company_name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '公司名称',
  `eid` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `passport_uid` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `company_admin_operator_id` bigint(20) NOT NULL COMMENT '公司管理员id',
  `created` int(11) NOT NULL,
  `updated` int(11) DEFAULT NULL,
  `expiredAt` bigint(20) DEFAULT NULL COMMENT '过期时间',
  `deleted_at` datetime DEFAULT NULL,
  `industry` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '所属行业',
  `is_disabled` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否禁用',
  `third_params` json DEFAULT NULL COMMENT '第三方特殊字段存储(DC2Type:json_array)',
  `salesman_limit` int(11) NOT NULL DEFAULT '20' COMMENT '导购员数量',
  `is_open_pc_template` int(11) DEFAULT '2' COMMENT '是否开启pc模板 1 开启 2不开启',
  `pc_domain` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'PC域名',
  `h5_domain` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'H5域名',
  `is_open_domain_setting` int(11) DEFAULT '2' COMMENT '是否开启域名配置 1 开启 2不开启',
  PRIMARY KEY (`company_id`),
  UNIQUE KEY `idx_passportuid` (`passport_uid`),
  KEY `idx_pc_domain` (`pc_domain`),
  KEY `idx_h5_domain` (`h5_domain`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=18 ;

--
-- 转存表中的数据 `companys`
--

INSERT INTO `companys` (`company_id`, `company_name`, `eid`, `passport_uid`, `company_admin_operator_id`, `created`, `updated`, `expiredAt`, `deleted_at`, `industry`, `is_disabled`, `third_params`, `salesman_limit`, `is_open_pc_template`, `pc_domain`, `h5_domain`, `is_open_domain_setting`) VALUES
(1, NULL, '66200701709062', '88200702317791', 1, 1650768579, 1652077874, 1683613874, NULL, NULL, 0, '[]', 20, 2, NULL, NULL, 2);

-- --------------------------------------------------------

--
-- 表的结构 `operators`
--

DROP TABLE IF EXISTS `operators`;
CREATE TABLE IF NOT EXISTS `operators` (
  `operator_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '账号id',
  `mobile` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '手机号',
  `password` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
  `eid` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
  `passport_uid` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
  `created` int(11) NOT NULL,
  `updated` int(11) DEFAULT NULL,
  `operator_type` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 'admin' COMMENT '操作员类型类型。admin:超级管理员;staff:员工;distributor:店铺管理员;dealer:经销商',
  `login_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '员工账号名',
  `company_id` bigint(20) DEFAULT NULL COMMENT '公司id',
  `distributor_ids` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci COMMENT '员工管理的店铺id集合',
  `shop_ids` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci COMMENT '员工管理的门店id集合',
  `lastloginip` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '添加时候的ip',
  `username` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '名称',
  `head_portrait` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci COMMENT '头像',
  `regionauth_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '区域id',
  `contact` varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '联系人姓名',
  `split_ledger_info` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '分账信息',
  `is_disable` int(11) DEFAULT '0' COMMENT '是否禁用 1:是 0:否',
  `adapay_open_account_time` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'adapay子商户开户时间',
  `dealer_parent_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '经销商子账号父级id',
  `is_dealer_main` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '1' COMMENT '是否是经销商主账号  1:是   0:不是',
  PRIMARY KEY (`operator_id`),
  UNIQUE KEY `idx_passportuid` (`passport_uid`),
  KEY `idx_eid` (`eid`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=11 ;

--
-- 转存表中的数据 `operators`
--

INSERT INTO `operators` (`operator_id`, `mobile`, `password`, `eid`, `passport_uid`, `created`, `updated`, `operator_type`, `login_name`, `company_id`, `distributor_ids`, `shop_ids`, `lastloginip`, `username`, `head_portrait`, `regionauth_id`, `contact`, `split_ledger_info`, `is_disable`, `adapay_open_account_time`, `dealer_parent_id`, `is_dealer_main`) VALUES
(1, 'AAA改成手机号', 'admin88需要修改密码', '66200701709062', '88200702317791', 1650768579, 1650768579, 'admin', NULL, 1, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0, NULL, NULL, '1'),
(2, 'BBB改成手机号', 'admin88需要修改密码', '66200701709062', '', 1650768579, 1650768579, 'staff', NULL, 1, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0, NULL, NULL, '1');

-- --------------------------------------------------------

--
-- 表的结构 `resources`
--

DROP TABLE IF EXISTS `resources`;
CREATE TABLE IF NOT EXISTS `resources` (
  `resource_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '资源包id',
  `resource_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '资源包名称',
  `company_id` bigint(20) NOT NULL COMMENT '公司id',
  `eid` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '企业id',
  `passport_uid` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `shop_num` int(11) NOT NULL COMMENT '资源门店数',
  `left_shop_num` int(11) NOT NULL COMMENT '可用门店数',
  `source` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '资源来源。demo:开通试用,purchased:购买,gift:赠品',
  `available_days` int(11) NOT NULL COMMENT '可用天数',
  `active_at` bigint(20) NOT NULL COMMENT '激活时间',
  `expired_at` bigint(20) NOT NULL COMMENT '过期时间',
  `active_code` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '激活码',
  `issue_id` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '在线开通工单号',
  `goods_code` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '商品code',
  `product_code` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '基础系统code',
  PRIMARY KEY (`resource_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=5 ;

--
-- 转存表中的数据 `resources`
--

INSERT INTO `resources` (`resource_id`, `resource_name`, `company_id`, `eid`, `passport_uid`, `shop_num`, `left_shop_num`, `source`, `available_days`, `active_at`, `expired_at`, `active_code`, `issue_id`, `goods_code`, `product_code`) VALUES
(1, '1店版', 1, '66200701709062', '88200702317791', 1, 1, 'demo', 365, 1650768579, 1683613874, 'VyBWNlI5W21XcgExBDcFOlRrUzgIblllAnVWOQ==', NULL, NULL, NULL),
(2, '200店版', 1, '66200701709062', '88200702317791', 200, 200, 'purchased', 365, 1652077874, 1683613874, 'C3xXNwBtX2UJNFQiXUVaUVc2UDwGZwwxUDUGZQNjUDZQZANvB2gOOlNgUj4BdVM6', NULL, NULL, NULL),
(3, '1店版', 1, '66221001778930', '88221002387671', 1, 1, 'demo', 15, 1673341427, 1674637427, 'ViFbO1Y9CT8DJgk5BzQHOAE+UzhRN1llUiUHaA==', NULL, NULL, NULL),
(4, '1店版', 1, '66221101780516', '88221102389257', 1, 1, 'demo', 15, 1673341450, 1674637450, 'Cn0HZwRvWmwAJQc3UmEGOQE+UzhVM15iUyQGaQ==', NULL, NULL, NULL);



--
-- 表的结构 `companys_employee_rel_roles`
--

DROP TABLE IF EXISTS `companys_employee_rel_roles`;
CREATE TABLE IF NOT EXISTS `companys_employee_rel_roles` (
  `company_id` bigint(20) NOT NULL COMMENT '公司id',
  `role_id` varchar(32) COLLATE utf8_unicode_ci NOT NULL COMMENT '角色id',
  `operator_id` varchar(32) COLLATE utf8_unicode_ci NOT NULL COMMENT '员工id',
  PRIMARY KEY (`company_id`,`role_id`,`operator_id`),
  KEY `idx_company_id` (`company_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- 转存表中的数据 `companys_employee_rel_roles`
--

INSERT INTO `companys_employee_rel_roles` (`company_id`, `role_id`, `operator_id`) VALUES
(1, '1', '11'),
(1, '1', '2');

-- --------------------------------------------------------

--
-- 表的结构 `companys_roles`
--

DROP TABLE IF EXISTS `companys_roles`;
CREATE TABLE IF NOT EXISTS `companys_roles` (
  `role_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '角色id',
  `company_id` bigint(20) NOT NULL COMMENT '公司id',
  `role_name` varchar(32) COLLATE utf8_unicode_ci NOT NULL COMMENT '角色名称',
  `permission` longtext COLLATE utf8_unicode_ci NOT NULL COMMENT '权限,json数据',
  `created` int(11) NOT NULL,
  `updated` int(11) DEFAULT NULL,
  `role_source` varchar(32) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'platform' COMMENT '角色平台来源,platform: 平台角色,distributor:店铺管理角色',
  PRIMARY KEY (`role_id`),
  KEY `idx_company_id` (`company_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=2 ;

--
-- 转存表中的数据 `companys_roles`
--

INSERT INTO `companys_roles` (`role_id`, `company_id`, `role_name`, `permission`, `created`, `updated`, `role_source`) VALUES
(1, 1, '运营', '{"shopmenu_alias_name":["index","goodsphysical","goodscategory","goodsattributes","goodsparams","goodsmaincategory","goodsbrand","itemtags","itemstagupload","rate","brandmaterial","arrivalnotice","tradenormalorders","aftersaleslist","shippingtemplates","normalordersupload","wl-logistics","servicepayment","aftersalesrefundlist","order-Refunderrorlogs","tradeservice","tradeverification","mallreservation","reservationsetting","reservationorder","ordersetting","kdniao","sfbsp","aftersalesreason","tradesetting","memberlist","member-list-view","member-export","member-guide","member-vip-delay","member-add-rights","member-send-coupons","member-send-sms","member-tag","member-modify-phone-number","managecard","managecardorder","whitelistlist","whitelistuploade","pointrule","pointoverview","analysisrights","member-rights-list","member-rights-delay","member-right-transfer","member-rights-export","Managetag","smssend","closeAccount","manageinfomation","mallrecharge","managecustomer","trustlogin","wxapp-template-list","wxapp-template-edit","wxapp-authorized","wxapp-data-analysis","wxapp-editsourcemanagement","wxapp-editcategory","wxapp-custompage","noticemessage","colorstyle","membercentersetting","searchrecommend","cartrecommend","cartremind","salespersonshelfindex","shopwxshop","membermarketing","couponspackage","coupongive","couponsend","pointupvaluation","extrapoint","Registrationactivity","Registrationrecord","ugcindex","ugcflags","ugctags","ugctopic","ugcreview","ugcpoint","ugctpos","wheel","recommendlike","SpecificCrowdDiscount","marketingindex","liveroomlist","marketingspluspricebuy","marketingpackage","limitedtimesale","memberpreference","goodslimit","marketingseckill","marketingsfulldiscount","marketingsfullminus","marketingsfullgift","marketingactivity","groupsindex","marketingbargain","popularizesetting","promotersetting","popularizelist","popularizedata","popularizewithdraw","popularizegoods","taskbrokerage","taskbrokeragecount","financialManageservicepayment","financialFinancialManageAftersalesrefundlist","financialFinancialManageRefunderrorlogs","financialFinancialManageAftersaleslist","financialFinancialManageSalesreportlist","dada","goodsstatistics","orderstatistics","member-statistics","distributordata","selformelementsetting","selformtempsetting","planting","shopscreen_category","bigScreenAd","homeCarousel","searchKeyWords","articlecolumns","basearticle","Articlegeneralcolumns","sharesetting","wxshopsetting","wxaindex","brand","brandmenu","brandfans","brandreply","EChat","meiqia","extminilink","staffleader","merchantstaff","platformstaff","platformstaffroles","adapay_merchant","approveDataPass","applyDataPass","assetpayment","shopexerp","dataAnalysis","regionauth","openapi","workwechat","publicsetting","GoodsShareSetting","certificate","baseexport","datamessage","assetaccountactivation","mallcoologs","operator-logs","mpsgoodslogs","privacylogs","omsqueuelog","shopmenu","openscreenad","agreement"],"version":"1"}', 1675320895, 1675320895, 'platform');

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

  

 

 
 
1、建立数据表entity
2、执行数据库迁移
	php artisan doctrine:migrations:migrate

生成数据库迁移文件(差异)

	php artisan doctrine:migrations:diff

diff完成后,database/migrations 下回生成一个Version***.php的迁移文件

修改迁移文件名称和最新的一个格式保持一致,序号+1,然后执行migrate

================================

	php artisan doctrine:migrations:migrate

 

3、建立router

相关目录

bootstrap/route.php
routes/

首先在routers/frontapi里新建一个wsugc.php文件,里面写好路由定义

然后bootstrap/route.php里 

case 'h5app' :

分支最后

require这个新的wsugc.php文件

 

 

4、增加api(后台api),frontapi(小程序api),adminapi(导购api)
5、bash api 生成文档,根据文档在线调试
bash api
5、建立service
6、建立观察者监听模式

 

常见问题

1、bash api后文档里没有新的api。

   需要修改根目录下的名称为api的文件,把新的接口路径加进去。

 

 

2、修改了某个api里的参数定义,bash api后api-doc文档页面对应的接口内容不更新

 

   Swagger生成的文档有缓存,如果多次刷新还不生效,修改此api对应的Swagger/Info.php里version版本号(比如1.0改成2.0),文档首页左侧分类里,会增加一个新的以此版本号命名的api分类

 

执行生成文档名单后,生成如下图

 

 

3、frontapi没有小程序端传过来的Authorization,怎么调试?

首先注释掉routers文件里的身份验证

'middleware' => ['dingoguard:h5app', 'api.auth'], 'providers' => 'jwt'

 

 

 

然后在frontapi接口文件代码里,需要用到user_id的地方,判断一下是否有auth,没有用请求参数里的user_id(swagger注释里,当然也就要定义一个user_id参数,这样api-doc里才有user_id可以传,方便调试)

$authInfo = $request->get('auth');

修改为

$authInfo = $request->get('auth');
$allParams = $request->all('imei_sn','user_id');
$user_id= $authInfo['user_id']??$allParams['user_id'];

 

swagger注释里,在Authorization下增加一个user_id参数

 

 

生产环境下,再还原:

 

  去掉代码里的从params里取user_id的逻辑

	$user_id= $authInfo['user_id'];

 

swagger注释里去掉user_id参数的定义