{"id":19676241,"url":"https://github.com/seth-shi/monday-shop","last_synced_at":"2025-04-14T11:24:50.173Z","repository":{"id":37519831,"uuid":"105542285","full_name":"seth-shi/monday-shop","owner":"seth-shi","description":"网上在线商城、综合网上购物平台","archived":false,"fork":false,"pushed_at":"2024-12-10T00:41:58.000Z","size":74730,"stargazers_count":646,"open_issues_count":5,"forks_count":186,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-04-07T03:11:14.680Z","etag":null,"topics":["b2c","e-shop","e-shopping","laravel","monday-shop","shop","shopping"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/seth-shi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-02T14:11:36.000Z","updated_at":"2025-04-02T02:31:57.000Z","dependencies_parsed_at":"2024-12-27T23:32:53.855Z","dependency_job_id":null,"html_url":"https://github.com/seth-shi/monday-shop","commit_stats":{"total_commits":608,"total_committers":4,"mean_commits":152.0,"dds":0.004934210526315819,"last_synced_commit":"e74782b31d029a26cdcaca69fbd951e946376580"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seth-shi%2Fmonday-shop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seth-shi%2Fmonday-shop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seth-shi%2Fmonday-shop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seth-shi%2Fmonday-shop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seth-shi","download_url":"https://codeload.github.com/seth-shi/monday-shop/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248870037,"owners_count":21174965,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["b2c","e-shop","e-shopping","laravel","monday-shop","shop","shopping"],"created_at":"2024-11-11T17:27:50.607Z","updated_at":"2025-04-14T11:24:50.140Z","avatar_url":"https://github.com/seth-shi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# seth-shi/monday-shop\n\n* !!! 非`Docker`运行请使用`v1`[https://github.com/seth-shi/monday-shop/tree/1.0](https://github.com/seth-shi/monday-shop/tree/1.0)\n\n## QQ 群\n* `584453488`\n\n## 部署(新新新)\n1. 下载源码(也可直接下载压缩包, 然后解压)\n    * `git clone https://github.com/seth-shi/monday-shop.git`\n2. 修改配置\n    * `cp .env.example .env`\n    * 修改`.env`文件中数据库,域名等配置信息\n3. 构建镜像\n    * `docker build . -t monday-shop`\n4. 运行\n    * `docker run -d --net=host --name monday-shop-service monday-shop`\n5. 执行安装命令\n    * `docker exec monday-shop-service php artisan moon:install`\n\n## 目录说明\n* [演示地址](#演示地址)\n* [页面展示](#页面展示)\n* [特色](#Feature)\n* [安装](#Installation)\n* [命令行功能](#Commands)\n* [秒杀处理逻辑](#秒杀处理逻辑)\n* [API文档(新)](#API)\n* [依赖的 Packages](#Packages)\n* [文章引用](#Reference)\n* [错误/注意点](#Notice)\n* [协议](#License)\n\n## 演示地址\n[演示地址：http://shop.shiguopeng.cn](http://shop.shiguopeng.cn)\n\n[后台地址：http://shop.shiguopeng.cn/admin](http://shop.shiguopeng.cn/admin)\n* 账号：`admin`\n* 密码：`admin`\n****\n* 测试支付功能\n    * 下载[支付宝沙箱](https://sandbox.alipaydev.com/user/downloadApp.htm)\n    * 账号：`eyxweq5099@sandbox.com`\n    * 密码：`111111`\n    * 支付密码：`111111`\n    * 当前账户余额：`9999999.99`\n    * 余额不足，请联系我及时充值\n\n## 页面展示\n![PC首页](public/media/pc_index.png)\n![支付](public/media/pay.gif)\n![个人设置](public/media/map_center.png)\n![个人中心](public/media/center.png)\n![积分详情](public/media/score_detail.png)\n![后台仪表盘](public/media/admin/dash_board.png)\n![后台订单列表](public/media/admin/orders.png)\n![用户喜好数据](public/media/admin/user_like.png)\n\n## Feature\n- [x] **库存问题**\n    * [x] 普通订单使用乐观锁防止超卖\n    * [X] 秒杀订单使用`Redis`队列防止超卖\n- [x] **首页数据全走缓存（推荐使用`Redis`驱动）**\n    * [x] 未登录的首页，零数据库查询，通过缓存驱动\n    * [x] 计划任务每分钟会更新一次首页数据\n    * [x] 开启秒杀模块，零数据库查询，通过`Redis`驱动\n    * [x] 登录之后首页零数据库查询，`Session`驱动数据\n- [x] **积分功能**\n    * [x] 每日首次登录(访问网站)得到积分(bitmap 计算)\n    * [x] 连续登录 n 天得到积分(bitmap 计算)\n    * [x] 当天浏览商品数量 n 个得到积分(bitmap 计算)\n    * [x] 后台可新增 n+ 积分种类\n    * [x] 完成订单可获得金钱等比例积分\n- [x] **优惠券功能**\n    * [x] 满减优惠\n    * [x] 积分兑换满减优惠券\n    * [x] 发放兑换码，兑换优惠券\n- [x] **物流功能**\n    * [x] 运费设置\n    * [x] 快递物流\n- [x] **秒杀功能**\n    * 秒杀过期，自动回退库存\n    * 使用延时队列，当订单超过三十分钟(可配置)未付款，自动取消订单\n    * 秒杀商品，如果用户收藏，发送邮件提醒活动\n    * 后台秒杀模块的开启关闭\n    * 秒杀的商品数量，皆通过`Redis`读取\n- [x] **第三方授权登录 + 登录回跳**\n    * `Github`\n    * `QQ`\n    * 微博 \n- [x] **第三方支付(支持自动适应手机，web 支付)**\n    - [x] 支付宝支付,退款\n    - [ ] 微信支付\n- [x] **购物车**\n    * 使用`H5`本地存储\n    * 登录之后同时显示本地购物车和数据库购物车数量\n    * 用户登录之后会询问是否需要持久化到数据库\n- [x] **商品搜索**\n    * 使用**ElasticSearch**全文索引\n    * 支持拼音首字母\n    * `AJAX`无刷新显示\n- [x] **订阅模块**\n    * 每周定时推送一封邮件包含最受欢迎，最新，最火卖商品\n- [x] **分类排序**\n    * 后台使用拖动排序，可以设置在商城首页优先展示的分类\n- [x] **订单模块**\n    * 订单下单\n        * 买家支付\n        * 后台发货 / 卖家申请退款\n        * 买确认收货 / 后台确认收货\n        * 买家确认订单获取积分\n    * 用户下订单之后可以评论\n- [x] **站内消息**\n    * 消息通知\n    * 多模板类型通知, 兑换码通知、文章通知等等\n    * 轮询通知消息，一点即达\n- [x] **数据统计**\n    * 每天晚上一点进行站点数据统计\n- [x] 全文搜索\n- [x] **响应式网站**\n\n\n## Commands\n| 命令  | 一句话描述 |\n| ----- | --- |\n|`php artisan moon:install`|安装应用程序|\n|`php artisan add:shop-to-search`|生成全文索引|\n|`php artisan moon:uninstall`|卸载网站(清空数据库，缓存，路由)|\n|`php artisan moon:cache`|执行缓存（缓存配置，路由，类映射）|\n|`php artisan moon:clear`|清除缓存|\n|`php artisan moon:copy`|复制项目内置的静态资源|\n|`php artisan moon:delete`|删除项目及上传的基本静态资源|\n|`php artisan moon:export`|导出用户数据到json文件|\n|`php artisan moon:count-site`|统计站点任务（每天夜里一点执行）|\n|`php artisan moon:del-seckills`|删除秒杀数据 (每小时自动执行一次)|\n|`php artisan moon:moon:del-score-data`|删除积分缓存数据 (每天夜里 0 点执行)|\n|`php artisan moon:update-home`|更新首页数据 (每分钟自动执行一次)|\n|`php artisan moon:send-subscribes`|发送订阅邮件 (每个礼拜六早上八点)|\n|`php artisan queue:work --tries=3`|监听队列(邮件发送，处理过期的秒杀数据 !!!|\n\n## 秒杀处理逻辑\n```php\n\n## 初始化抢购数据\n\u003c?php\n\n// 假设当前秒杀活动的 id 为 9\n// 可以在模型的 created 事件做这个事情\n$id = 9;\n\n// 填充一个 redis 队列，数量为抢购的数量，后面的 9 无意义\n\\Redis::lpush(\"seckills:{$id}:queue\", array_fill(0, $seckill-\u003enumber, 9));\n\n?\u003e\n\n## 抢购\n\u003c?php\n\n// 从路由或者参数中得到当前秒杀活动的 id\n$id = 9;\n$userId = auth()-\u003eid();\n\n// 判断是否已经开始了秒杀\n\n// 返回 0，代表当前用户已经抢购过了\nif (0 == Redis::hset(\"seckills:{$id}:users:{$userId}\", 'id', $userId)) {\n\n    return responseJson(403, '你已经抢购过了');\n}\n\n// 如果从队列中读取到了 null，代表已经没有库存\nif (is_null(Redis::lpop(\"seckills:{$id}:queue\"))) {\n\n    return responseJson(403, '已经抢购完了');\n}\n\n// 这里就可以开始入库订单\n\n?\u003e\n\n## 利用 crontab 定时扫描过期数据，回滚库存，删除过期 redis (可选)\n\u003c?php\n\n // 查出已经过期确没有回滚过的秒杀，\nSeckill::query()\n       -\u003ewhere('end_at', '\u003c', date('Y-m-d H:i:s'))\n       -\u003eget()\n       -\u003emap(function (Seckill $seckill) {\n           \n           // 先模糊查找到所有用户 key\n           $ids = Redis::keys(\"seckills:{$seckill-\u003eid}:*\");\n           Redis::del($ids);\n           \n           // 回滚库存\n           // 做更多的事\n       };\n       \n?\u003e\n\n```\n\n## API\n* 接口响应数据说明\n    * 响应的数据格式总是保证拥有基本元素(`code`, `msg`, `data`)\n    * `code` 请参考接口全局状态码说明\n    * `msg`  此次请求消息,如果返回状态码为非成功,可直接展示`msg`\n    * `data` 如果为列表页将会一个数组类型(如商品列表),否则为一个对象类型(商品详情)\n    * 如有额外扩展字段, 将于基本元素平级, 如分页的`count`\n```json\n{\n\t\"code\": 401,\n\t\"msg\": \"无效的token\",\n\t\"data\": []\n}\n```\n* 刷新`token`说明\n    * 为了保证安全性,`token`的有效时间为`60`分钟\n    * 当旧的`token`失效时,服务器会主动刷新,并在响应头加入`Authorization`\n    * 这时候旧的`token`将会加入黑名单不能再使用, 请将在响应头中新的`token`保存使用\n    * 当服务器主动刷新之后,会有一个期限(`2`周).服务器将无法再刷新,将返回`402`状态码,请重新登录账户\n* `token`使用流程说明\n```javascript\n// 全局请求类\nfunction request(_method, _url, _param, _func) {\n\n    $.ajax({\n        method: _method,\n        url: _url,\n        data: _param,\n        beforeSend: function (xhr) {\n            console.log(xhr);\n            xhr.setRequestHeader('Authorization', localStorage.getItem('api_token'))\n        },\n        complete: function (xhr, a, b) {\n\n            if (xhr.getResponseHeader('Authorization')) {\n                localStorage.setItem('api_token', xhr.getResponseHeader('Authorization'))\n            }\n        },\n        success: function (res) {\n\n            // token 永久过期\n            if (res.code === 402) {\n                // 跳去登录页面\n                return false;\n            }\n            // 更多状态码判断\n        }\n    });\n}\n\n// 第一次登录保存 token, 之后使用全局类请求数据即可\n\n```\n    \n* 接口全局状态码说明(建议封装一个全局请求类或者中间件,统一处理全局状态码)\n    * `200`\n        * 请求数据成功\n    * `401` \n        * 身份验证出错(未登录就请求数据)\n        * 非法无效的`token`\n        * `token`已被加入黑名单(一般不会出现这个问题,出现这个问题那么就是你刷新 token 的逻辑有问题)\n    * `402`\n        * `token`已完全失效,后台暂设为 2 周,再也无法刷新,请重新登录账户\n    * `500`\n        * 服务器出错,具体请参考响应的消息\n* __接口文档__(重要的事情说三遍)\n\n[接口文档](http://shop.shiguopeng.cn/docs.html)\n\n[接口文档](http://shop.shiguopeng.cn/docs.html)\n\n[接口文档](http://shop.shiguopeng.cn/docs.html)\n![](public/media/api_example.gif)\n\n## Packages\n| 扩展包 | 一句话描述 | 在本项目中的使用案例 |\n| --- | --- | --- |\n|[z-song/laravel-admin](https://github.com/z-song/laravel-admin)|后台|快速搭建后台系统|\n|[mews/captcha](https://github.com/mewebstudio/captcha)|验证码|登录注册功能使用验证码验证|\n|[overtrue/laravel-socialite](https://github.com/overtrue/laravel-socialite)|第三方登录|用户登录可以使用Github,QQ,新浪微博|\n|[intervention/image](https://github.com/Intervention/image)|图片处理|是为 Laravel 定制的图片处理工具，加水印|\n|[webpatser/laravel-uuid](https://github.com/webpatser/laravel-uuid)|uuid生成|商品添加增加一个uuid，订单号|\n|[renatomarinho/laravel-page-speed](https://github.com/renatomarinho/laravel-page-speed)|压缩页面DOM|打包优化您的网站自动导致35％以上的优化（已移除使用）|\n|[overtrue/laravel-pinyin](https://github.com/overtrue/laravel-pinyin)|汉语拼音翻译|分类首字母查询|\n|[acelaya/doctrine-enum-type](https://github.com/acelaya/doctrine-enum-type)|枚举|优化代码中的映射|\n\n## Reference\n* [Laravel 的中大型專案架構](https://old-oomusou.goodjack.tw/laravel/architecture/)\n* [十个 Laravel 5 程序优化技巧](https://laravel-china.org/articles/2020/ten-laravel-5-program-optimization-techniques)\n* [十个 Laravel 5 程序优化技巧](http://www.ruanyifeng.com/blog/2018/10/restful-api-best-practices.html)\n* [服务器做了两个优化 CPU 使用率减低 40%(使用缓存优化访问量不写数据库)](https://learnku.com/articles/13366/the-server-has-made-two-optimization-and-the-cpu-utilization-rate-has-been-reduced-by-40)\n\n## Notice\n* 建议开启`bcmath`扩展保证字符串数字运算正确\n* 监听队列如果长时间没反应，或者一直重复任务\n    * 数据库没配置好，导致队列任务表连接不上\n    * 邮件配置出错，导致发送邮件一直失败\n* `composer install`安装不上依赖\n    * 请删除`composer.lock`文件，重新运行`composer install`\n* `SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint`\n    * 数据库引擎切换到`InnoDB`\n* `composer install` 安装依赖错误\n    * `composer.lock`锁定了镜像源,删除`composer.lock`再执行即可\n## License\nThe MIT License (MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseth-shi%2Fmonday-shop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseth-shi%2Fmonday-shop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseth-shi%2Fmonday-shop/lists"}