Compare commits

..

216 Commits
master ... gyj

Author SHA1 Message Date
yijiegong 3ae12ce04d PC 最新版本下载链接 2024-09-19 15:32:04 +08:00
yijiegong a84f3f39b3 请求员工权限 2024-09-14 18:04:47 +08:00
SongZhang 89ac3c9e25 单元测试 2024-09-14 17:50:21 +08:00
SongZhang 808d363daa Merge remote-tracking branch 'origin/test' into test 2024-09-14 17:50:01 +08:00
SongZhang eb8a53718d 单元测试 2024-09-14 17:49:49 +08:00
wangw 8ed1b242ff Merge branch 'ww' into test 2024-09-14 17:41:54 +08:00
wangw 04718abc01 增加sql记录 2024-09-14 17:40:43 +08:00
SongZhang ba54bf9967 Merge remote-tracking branch 'origin/test' into test 2024-09-14 11:50:17 +08:00
SongZhang b74441a62e 打印整合修改 2024-09-14 11:49:56 +08:00
牛叉闪闪 dbb66f93fa 添加pcpay 支付 2024-09-14 09:18:57 +08:00
SongZhang 5c0adcbe37 飞鹅打印折扣空值判断 2024-09-13 15:59:33 +08:00
SongZhang 92008db954 创建订单打包费默认值 2024-09-13 15:50:22 +08:00
SongZhang eb0139282b Merge remote-tracking branch 'origin/test' into test 2024-09-13 15:32:21 +08:00
SongZhang 9a07219470 飞鹅打印机退单小票功能放开 2024-09-13 15:32:12 +08:00
牛叉闪闪 51b66652d4 Merge remote-tracking branch 'origin/hph' into test 2024-09-13 11:09:25 +08:00
牛叉闪闪 074cc5374d 添加pcpay 支付 2024-09-13 11:08:33 +08:00
牛叉闪闪 0775b09c77 添加pcpay 支付 2024-09-13 11:06:36 +08:00
wangw 2d6c02cfd5 Merge branch 'ww' into test 2024-09-13 10:47:36 +08:00
wangw 724d5fc2da 店铺信息
运营模式
restaurant 餐饮版 先下单后支付
munchies   快餐版(先支付后下单)
是否开启桌位费 0否1是
桌位费
就餐模式  堂食 dine-in  外带 take-out
2024-09-13 10:45:03 +08:00
SongZhang 3029e6c8be 飞鹅打印机打印菜品小票根据使用类型区分type 2024-09-13 10:10:43 +08:00
牛叉闪闪 50041dc1cc Merge remote-tracking branch 'origin/test' into hph 2024-09-12 14:34:47 +08:00
牛叉闪闪 6a9f084df1 添加pcpay 支付 2024-09-12 14:34:19 +08:00
牛叉闪闪 73bad5713a 添加pcpay 支付 2024-09-12 14:08:19 +08:00
牛叉闪闪 2695748ab7 添加pcpay 支付 2024-09-12 14:08:03 +08:00
SongZhang 668edeb23c 添加单独打票相关mq处理 2024-09-12 11:20:31 +08:00
牛叉闪闪 77fa9ac80f 修改退款判断值 2024-09-09 09:50:31 +08:00
yijiegong 71b6cfe95c 退款密码校验修改 2024-09-07 00:19:49 +08:00
yijiegong a9d0810d1a Merge branch 'test' into dev
# Conflicts:
#	src/main/java/com/chaozhanggui/system/cashierservice/controller/MemberController.java
2024-09-06 23:53:05 +08:00
牛叉闪闪 7d713a0a50 修改 2024-09-06 17:38:19 +08:00
牛叉闪闪 4e2da5c676 修改 2024-09-06 17:23:52 +08:00
SongZhang 0d5dec10c6 Merge remote-tracking branch 'origin/test' into test 2024-09-06 11:37:32 +08:00
SongZhang 106c89ec58 1.生成取餐码redis报错修复 2024-09-06 11:37:22 +08:00
牛叉闪闪 781570e2bf 修改 2024-09-06 11:09:57 +08:00
SongZhang b88c269a1a Merge remote-tracking branch 'origin/test' into test 2024-09-06 10:38:21 +08:00
SongZhang eb1603a4ee 1.创建订单普通下单不沿用上笔 2024-09-06 10:38:10 +08:00
牛叉闪闪 f96c64f343 Merge remote-tracking branch 'origin/hph' into test 2024-09-06 10:23:53 +08:00
牛叉闪闪 c2555d890f 修改 2024-09-06 10:23:21 +08:00
牛叉闪闪 4bc2ed0bfd Merge remote-tracking branch 'origin/hph' into test 2024-09-05 17:39:54 +08:00
牛叉闪闪 9be00af38c 修改 2024-09-05 17:39:16 +08:00
牛叉闪闪 ffa9bab489 Merge remote-tracking branch 'origin/hph' into test 2024-09-05 17:34:41 +08:00
牛叉闪闪 b8f04c65c0 修改 2024-09-05 17:34:14 +08:00
SongZhang e086c4df95 Merge remote-tracking branch 'origin/dev' into test
# Conflicts:
#	src/main/resources/application-pre.yml
2024-09-05 17:07:52 +08:00
牛叉闪闪 09a4918e13 修改 2024-09-05 17:06:51 +08:00
SongZhang 20d86c6a75 1.支付完成清除缓存 2024-09-05 16:14:00 +08:00
SongZhang a3956663d7 1.支付完成清除缓存 2024-09-05 16:11:19 +08:00
SongZhang b8b8ee2bf2 Merge remote-tracking branch 'origin/test' into test 2024-09-05 16:06:32 +08:00
SongZhang c7626c352a 1.支付完成清除缓存 2024-09-05 16:06:22 +08:00
牛叉闪闪 d13d16238e 修改 2024-09-05 15:45:12 +08:00
牛叉闪闪 13fedb841b 修改 2024-09-05 15:24:49 +08:00
SongZhang e1bd478ae5 1.添加购物车逻辑修改 2024-09-05 11:43:22 +08:00
SongZhang 8eab206fff 1.添加购物车逻辑修改 2024-09-05 11:34:14 +08:00
SongZhang 0600a1d90e 1.添加购物车逻辑修改 2024-09-05 11:28:56 +08:00
SongZhang 6360d01041 1.添加购物车逻辑修改 2024-09-05 11:24:42 +08:00
SongZhang 39fb09e99a Merge remote-tracking branch 'origin/test' into test 2024-09-05 11:13:52 +08:00
SongZhang fc00b49806 1.打票添加日志 2024-09-05 11:13:40 +08:00
牛叉闪闪 3234ba957f Merge remote-tracking branch 'origin/hph' into test 2024-09-05 11:07:13 +08:00
牛叉闪闪 bca3381ec3 修改 2024-09-05 11:06:36 +08:00
SongZhang af78237806 Merge remote-tracking branch 'origin/test' into test 2024-09-05 10:42:06 +08:00
SongZhang 01df55d60b 1.代客下单 创建订单查询条件修改 2024-09-05 10:41:56 +08:00
wangw 3b3eda15ef pre 内网访问数据库 2024-09-05 10:09:47 +08:00
牛叉闪闪 92d0fb23c8 Merge remote-tracking branch 'origin/hph' into test 2024-09-05 10:00:20 +08:00
牛叉闪闪 9f62cd4165 修改 2024-09-05 09:59:19 +08:00
wangw 6acd14da8a 1 2024-09-04 14:20:56 +08:00
wangw 3528ebb0c4 测试环境 修改数据连接地址
新增 pre 预发布配置
2024-09-04 11:31:32 +08:00
wangw 15ef38936b 测试环境 修改数据连接地址
新增 pre 预发布配置
2024-09-04 11:29:27 +08:00
SongZhang 1d644bc232 1.代客下单 打票未清空缓存修复 2024-09-03 11:09:12 +08:00
SongZhang f3ad47f0f3 1.代客下单 加入购物车同步保存小程序缓存 2024-09-03 10:39:39 +08:00
牛叉闪闪 3e3a23becd Merge remote-tracking branch 'origin/hph' into test 2024-09-02 10:59:37 +08:00
牛叉闪闪 2985ae0f14 修改 2024-09-02 10:58:59 +08:00
牛叉闪闪 a5046976c5 Merge remote-tracking branch 'origin/hph' into test 2024-09-02 10:56:28 +08:00
牛叉闪闪 637a0cf315 修改 2024-09-02 10:55:37 +08:00
SongZhang 040db99d86 1.打票逻辑修改 2024-09-02 10:32:55 +08:00
SongZhang 4101c5235b 1.获取桌码通过tableId获取 2024-08-31 16:45:08 +08:00
SongZhang ed78691326 1.退款下票数量错误fix 2024-08-30 16:45:19 +08:00
SongZhang cff864f2da 1.退款下票数量错误fix 2024-08-30 15:47:38 +08:00
SongZhang f857715b0f 1.代客下单 商品数量减少增加打印退单票据 2024-08-30 15:15:54 +08:00
SongZhang 83d3aa444f 1.代客下单 商品数量减少增加打印退单票据 2024-08-30 15:06:56 +08:00
牛叉闪闪 e0b62b66d4 修改 2024-08-30 14:40:43 +08:00
yijiegong 187a757575 密码校验修改 2024-08-30 11:16:36 +08:00
SongZhang 32590bb35a Merge remote-tracking branch 'origin/test' into test 2024-08-30 10:42:28 +08:00
SongZhang 4bea33ff3e 1.代客下单退款单打印 2024-08-30 10:42:17 +08:00
yijiegong bf18452189 查询店铺操作密码设置 2024-08-30 10:34:45 +08:00
SongZhang 0172bd0478 1.打印折扣值为空报错修复 2024-08-30 09:59:33 +08:00
牛叉闪闪 203332e232 修改 2024-08-29 17:31:20 +08:00
牛叉闪闪 84e4a21064 Merge remote-tracking branch 'origin/test' into test 2024-08-29 16:52:23 +08:00
牛叉闪闪 adb1c28bb8 修改 2024-08-29 16:51:15 +08:00
SongZhang e504c26978 1.代客下单 会员余额支付明细不匹配修复 2024-08-29 16:47:55 +08:00
牛叉闪闪 40b8198c7e 修改 2024-08-29 16:37:14 +08:00
SongZhang 8c18cb1347 1.代客下单 已出餐商品支持操作 2024-08-29 16:23:13 +08:00
牛叉闪闪 860211489e Merge remote-tracking branch 'origin/test' into test 2024-08-29 16:13:02 +08:00
牛叉闪闪 36c3c2e04b 修改 2024-08-29 16:12:46 +08:00
SongZhang 8b56b21021 Merge remote-tracking branch 'origin/test' into test 2024-08-29 16:09:11 +08:00
SongZhang dd26e7873b 1.代客下单 已出餐商品支持操作 2024-08-29 16:09:02 +08:00
牛叉闪闪 864793949b 修改 2024-08-29 16:04:30 +08:00
SongZhang ac82a2e447 1.代客下单 已出餐商品不支持操作 2024-08-29 16:00:12 +08:00
SongZhang 0facce27aa Merge remote-tracking branch 'origin/test' into test 2024-08-29 15:55:06 +08:00
SongZhang ee5cb7d4ba 1.代客下单 已出餐商品不支持操作 2024-08-29 15:54:26 +08:00
牛叉闪闪 d76558cce2 修改 2024-08-29 15:54:11 +08:00
牛叉闪闪 92c4f1ca3a Merge remote-tracking branch 'origin/test' into test 2024-08-29 15:52:30 +08:00
牛叉闪闪 35b9132eda 修改 2024-08-29 15:52:13 +08:00
SongZhang 12b87312fd Merge remote-tracking branch 'origin/test' into test 2024-08-29 15:49:39 +08:00
SongZhang c9b3cea5cd 1.代客下单 已出餐商品不支持操作 2024-08-29 15:49:28 +08:00
牛叉闪闪 08a9a26f2d 修改 2024-08-29 15:43:12 +08:00
牛叉闪闪 2f6a3d9c16 Merge remote-tracking branch 'origin/test' into test 2024-08-29 15:10:45 +08:00
牛叉闪闪 88526e0dd9 修改 2024-08-29 15:10:31 +08:00
SongZhang cf4116e4b9 Merge remote-tracking branch 'origin/test' into test 2024-08-29 14:52:11 +08:00
SongZhang bfca837e78 1.代客下单 查询购物车校验状态 2024-08-29 14:52:01 +08:00
牛叉闪闪 ad0c743ae4 Merge remote-tracking branch 'origin/test' into test 2024-08-29 14:46:31 +08:00
牛叉闪闪 445551f0d5 修改 2024-08-29 14:45:45 +08:00
SongZhang c1df28b929 1.代客下单 台桌状态同时校验detail和购物车数据 2024-08-29 14:29:15 +08:00
SongZhang 1dba8819b9 Merge remote-tracking branch 'origin/test' into test 2024-08-29 14:25:03 +08:00
SongZhang 3829685b58 1.代客下单 台桌状态同时校验detail和购物车数据 2024-08-29 14:24:54 +08:00
牛叉闪闪 3a185c4d59 Merge remote-tracking branch 'origin/hph' into test 2024-08-29 14:07:40 +08:00
牛叉闪闪 525c56f30c 修改 2024-08-29 14:04:04 +08:00
SongZhang 0bdbd07555 1.修改会员余额支付备注 2024-08-29 13:45:26 +08:00
牛叉闪闪 4ea005d132 修改打印小票 2024-08-29 10:30:11 +08:00
牛叉闪闪 6e5866e46e 修改打印小票 2024-08-29 10:24:15 +08:00
牛叉闪闪 3a7468af91 修改打印小票 2024-08-29 10:16:21 +08:00
牛叉闪闪 b18ab44412 修改打印小票 2024-08-29 10:14:20 +08:00
牛叉闪闪 1192f454aa Merge remote-tracking branch 'origin/test' into test 2024-08-29 09:58:57 +08:00
牛叉闪闪 d94d89fe78 修改打印小票 2024-08-29 09:56:43 +08:00
SongZhang 95965f8a3c 1.打印折扣值为空报错修复 2024-08-29 09:46:02 +08:00
牛叉闪闪 7b0e91e4b4 添加会员充值退款 2024-08-29 09:44:45 +08:00
牛叉闪闪 f01391014a 添加会员变动与通知 2024-08-28 17:18:41 +08:00
牛叉闪闪 e49e72e088 Merge remote-tracking branch 'origin/hph' into test 2024-08-28 16:51:44 +08:00
牛叉闪闪 9a70e49663 添加会员变动与通知 2024-08-28 16:51:00 +08:00
wangw ae3d77e8c3 PC 版本管理 2024-08-28 16:20:04 +08:00
wangw 15c09f9666 退单 扣除销量 2024-08-28 16:19:52 +08:00
牛叉闪闪 c82b340d30 添加会员变动与通知 2024-08-28 11:27:14 +08:00
牛叉闪闪 acf7e71769 添加会员变动与通知 2024-08-28 09:57:23 +08:00
SongZhang 6dcd8368a0 1.代客下单 结算单打印 2024-08-27 14:53:34 +08:00
SongZhang fbe7b72e4b 1.代客下单 结算单打印 2024-08-27 11:41:52 +08:00
SongZhang 9942bc6de6 Merge remote-tracking branch 'origin/test' into dkxd2 2024-08-27 10:59:37 +08:00
SongZhang 838351f279 1.代客下单 结算单打印 2024-08-27 10:57:45 +08:00
SongZhang d8bac55fb0 1.代客下单 结算单打印 2024-08-27 10:57:29 +08:00
牛叉闪闪 6e5216192d 修改支付逻辑 2024-08-27 10:48:37 +08:00
SongZhang 35e039a530 1.代客下单 已下单商品不支持删除 2024-08-27 10:36:05 +08:00
牛叉闪闪 2461e5d808 修改支付逻辑 2024-08-27 09:45:03 +08:00
SongZhang 6705689d34 Merge remote-tracking branch 'origin/test' into dkxd2 2024-08-27 09:12:11 +08:00
SongZhang f585a4f46a 1.代客下单 2024-08-27 09:11:55 +08:00
牛叉闪闪 253e2f9c0b 修改支付逻辑 2024-08-27 09:11:14 +08:00
牛叉闪闪 a1d0fa1a7f 修改支付逻辑 2024-08-26 18:27:12 +08:00
牛叉闪闪 bc5bdf1421 修改支付逻辑 2024-08-26 18:22:52 +08:00
牛叉闪闪 cf2dfc295c 修改支付逻辑 2024-08-26 18:02:06 +08:00
牛叉闪闪 ddf9af76b5 修改支付逻辑 2024-08-26 17:31:27 +08:00
牛叉闪闪 0f74c30e58 修改支付逻辑 2024-08-26 17:00:38 +08:00
牛叉闪闪 651f2c1427 修改支付逻辑 2024-08-26 16:25:00 +08:00
牛叉闪闪 d3b3fe2492 修改支付逻辑 2024-08-26 15:49:19 +08:00
牛叉闪闪 ed5bb107d0 添加员工折扣 2024-08-26 15:42:21 +08:00
wangw 42e6b3a689 充值报错问题 2024-08-26 15:27:55 +08:00
SongZhang 6f93900c2a 1.代客下单 打印菜品小票,以及结算小票 2024-08-26 15:14:57 +08:00
牛叉闪闪 b0f62d3dad 添加员工折扣 2024-08-26 15:03:35 +08:00
牛叉闪闪 a7263f85e7 Merge remote-tracking branch 'origin/hph' into test
# Conflicts:
#	src/main/java/com/chaozhanggui/system/cashierservice/service/MemberService.java
2024-08-26 15:01:32 +08:00
牛叉闪闪 fdfeb5701a 添加员工折扣 2024-08-26 14:58:29 +08:00
SongZhang 6a6ce8ef1c 1.代客下单 打印菜品小票 2024-08-26 14:23:56 +08:00
SongZhang 5e6c6284ed 1.代客下单 打印菜品小票 2024-08-26 13:57:41 +08:00
SongZhang 5d74f104b2 1.代客下单 台桌最新订单号查询问题fix 2024-08-26 13:45:11 +08:00
SongZhang 1cff6fffcc 1.代客下单 台桌最新订单号查询问题fix 2024-08-26 13:38:26 +08:00
SongZhang 3794cd5540 1.代客下单 台桌最新订单号查询问题fix 2024-08-26 13:36:42 +08:00
SongZhang 02be5222b5 1.代客下单 台桌最新订单号查询问题fix 2024-08-26 13:33:25 +08:00
SongZhang 8f4e56f889 1.代客下单 台桌最新订单号查询问题fix 2024-08-26 11:28:00 +08:00
SongZhang abdefe6932 1.代客下单 会员支付,支付修改台桌状态 2024-08-23 17:07:43 +08:00
SongZhang baf91df968 1.代客下单 无法下单fix 2024-08-23 13:47:07 +08:00
牛叉闪闪 86ae5f962b 添加员工折扣 2024-08-22 15:11:27 +08:00
牛叉闪闪 b5daf8aef1 Merge remote-tracking branch 'origin/test' into test
# Conflicts:
#	src/main/java/com/chaozhanggui/system/cashierservice/controller/PayController.java
2024-08-22 15:09:46 +08:00
yijiegong f2b32671b8 查询台桌携带订单信息 + 订单金额 2024-08-22 11:03:53 +08:00
yijiegong 8b657fdc8a 查询台桌携带订单信息 2024-08-22 10:57:19 +08:00
yijiegong 1e66c99606 购物车加入bug fix 2024-08-22 10:37:15 +08:00
yijiegong 1a968775ff 商品列表角标 2024-08-22 09:56:19 +08:00
yijiegong 2ae71952de Merge remote-tracking branch 'origin/test' into test 2024-08-22 09:38:56 +08:00
yijiegong 24586d3b13 修改查询购物车信息出错 2024-08-22 09:38:42 +08:00
SongZhang 0e2c0a9604 1.代客下单会员余额支付 2024-08-21 17:45:16 +08:00
SongZhang da54cc30b7 1.打票增加代客下单重复校验 2024-08-21 17:00:08 +08:00
SongZhang 6f3dcca911 1.打票增加代客下单重复校验 2024-08-21 16:47:44 +08:00
SongZhang fbea2c6670 1.代客下单先付款后付款操作 2024-08-21 14:56:08 +08:00
SongZhang b7708d82e1 1.代客下单后选择会员修改 2024-08-21 10:23:24 +08:00
SongZhang e04c3ee084 1.增加台桌会员id 2024-08-21 09:49:24 +08:00
SongZhang 2b7ca62abf 1.增加台桌状态 2024-08-21 09:21:07 +08:00
SongZhang da9f1ab68f 1.增加台桌状态 2024-08-21 09:12:52 +08:00
SongZhang eb424d8eb4 Merge remote-tracking branch 'origin/test' into dkxd2
# Conflicts:
#	src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java
2024-08-21 09:11:59 +08:00
SongZhang a12a1d2e1f 1.增加台桌状态 2024-08-21 09:09:44 +08:00
牛叉闪闪 d0cb517e23 Merge remote-tracking branch 'origin/hph' into test 2024-08-20 17:26:43 +08:00
牛叉闪闪 fd45264b0d 添加员工折扣 2024-08-20 17:26:20 +08:00
牛叉闪闪 af3ea12121 Merge remote-tracking branch 'origin/hph' into test 2024-08-20 17:18:26 +08:00
牛叉闪闪 653254f9f3 添加员工折扣 2024-08-20 17:17:55 +08:00
SongZhang d8027c92b2 1.增加mybatisplus依赖 2024-08-20 17:03:51 +08:00
SongZhang 8d9deb43a3 Merge remote-tracking branch 'origin/hph' into zs 2024-08-20 14:30:24 +08:00
牛叉闪闪 6b436da4d3 加入购物车取消耗材控制 2024-08-20 14:06:06 +08:00
SongZhang 796f43299f 1.代客下单相关接口修改 2024-08-20 13:23:13 +08:00
SongZhang 46133d7d16 1.查询商品返回规格上下架信息字段 2024-08-19 14:35:55 +08:00
SongZhang 61157d730c 1.耗材check值错误修复 2024-08-17 15:00:46 +08:00
牛叉闪闪 563541d929 Merge remote-tracking branch 'origin/dev' into hph 2024-08-16 15:39:01 +08:00
牛叉闪闪 8f7ea02d06 加入购物车添加耗材控制 2024-08-16 15:38:47 +08:00
SongZhang cee4643925 1.修改库存增加库存记录 2024-08-16 14:46:30 +08:00
牛叉闪闪 4d462a1d3e 加入购物车添加耗材控制 2024-08-16 14:16:15 +08:00
牛叉闪闪 397c1b4df3 Merge remote-tracking branch 'origin/dev' into hph 2024-08-16 14:15:51 +08:00
SongZhang 38b03b556c 1.推送校验耗材是否开启check 2024-08-16 13:51:06 +08:00
牛叉闪闪 178f3c0831 加入购物车添加耗材控制 2024-08-14 16:01:11 +08:00
SongZhang df75a74822 1.推送 2024-08-14 15:48:39 +08:00
SongZhang dad47eb0c8 1.商品查询库存不准确问题 2024-08-14 15:41:49 +08:00
SongZhang b0243a9ddd 1.推送校验状态 2024-08-14 14:58:50 +08:00
SongZhang 5a0112132d Merge remote-tracking branch 'origin/dev' into zs
# Conflicts:
#	src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java
2024-08-14 14:11:53 +08:00
牛叉闪闪 4a0a548565 加入购物车添加耗材控制 2024-08-14 11:35:39 +08:00
牛叉闪闪 6c6a447a5e 加入购物车添加耗材控制 2024-08-14 11:16:28 +08:00
SongZhang 146cb0f00b Merge remote-tracking branch 'origin/dev' into zs
# Conflicts:
#	src/main/java/com/chaozhanggui/system/cashierservice/rabbit/ConsMsgConsumer.java
2024-08-14 09:44:53 +08:00
牛叉闪闪 dc6df17a3f 修改商品规格加入购物车 2024-08-14 09:43:56 +08:00
牛叉闪闪 780707e55c 修改商品规格加入购物车 2024-08-14 09:40:41 +08:00
牛叉闪闪 b5bc0f2e0a 修改商品规格加入购物车 2024-08-14 09:38:44 +08:00
SongZhang e640226629 1.推送 2024-08-13 14:36:16 +08:00
SongZhang 148440cb31 1.无法修改库存fix 2024-08-13 14:33:12 +08:00
牛叉闪闪 d93bfd24a1 添加获取最大折扣接口 2024-08-13 14:30:22 +08:00
SongZhang f7b845201c 1.无法修改库存fix 2024-08-13 09:06:07 +08:00
SongZhang a8b9223454 Merge remote-tracking branch 'origin/zs2' into dev 2024-08-12 15:13:43 +08:00
SongZhang 22eadf7193 1.推送增加店铺开关校验 2024-08-12 14:35:27 +08:00
SongZhang 923ee6f1cb 1.上下架售罄接口 2024-08-12 14:25:14 +08:00
SongZhang 86df7addd6 1.代客下单相关接口 2024-08-09 16:07:00 +08:00
138 changed files with 6899 additions and 709 deletions

100
pom.xml
View File

@ -21,6 +21,10 @@
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
@ -48,11 +52,11 @@
<artifactId>hutool-all</artifactId>
<version>4.5.18</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.alibaba</groupId>-->
<!-- <artifactId>fastjson</artifactId>-->
<!-- <version>1.2.9</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.alibaba</groupId>-->
<!-- <artifactId>fastjson</artifactId>-->
<!-- <version>1.2.9</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
@ -185,30 +189,70 @@
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus</artifactId>
<version>3.3.1</version>
<exclusions>
<exclusion>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>p6spy</groupId>
<artifactId>p6spy</artifactId>
<version>3.8.2</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.3.1</version>
<exclusions>
<exclusion>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- alipay -->
<dependency>
<groupId>com.alipay.sdk</groupId>
<artifactId>alipay-sdk-java</artifactId>
<version>4.39.208.ALL</version>
</dependency>
</dependencies>
<!-- <profiles>-->
<!-- <profile>-->
<!-- <id>dev</id>-->
<!-- <properties>-->
<!-- <env>dev</env>-->
<!-- </properties>-->
<!-- <activation>-->
<!-- <activeByDefault>true</activeByDefault>-->
<!-- </activation>-->
<!-- </profile>-->
<!-- <profile>-->
<!-- <id>test</id>-->
<!-- <properties>-->
<!-- <env>test</env>-->
<!-- </properties>-->
<!-- </profile>-->
<!-- <profile>-->
<!-- <id>pro</id>-->
<!-- <properties>-->
<!-- <env>pro</env>-->
<!-- </properties>-->
<!-- </profile>-->
<!-- </profiles>-->
<!-- <profiles>-->
<!-- <profile>-->
<!-- <id>dev</id>-->
<!-- <properties>-->
<!-- <env>dev</env>-->
<!-- </properties>-->
<!-- <activation>-->
<!-- <activeByDefault>true</activeByDefault>-->
<!-- </activation>-->
<!-- </profile>-->
<!-- <profile>-->
<!-- <id>test</id>-->
<!-- <properties>-->
<!-- <env>test</env>-->
<!-- </properties>-->
<!-- </profile>-->
<!-- <profile>-->
<!-- <id>pro</id>-->
<!-- <properties>-->
<!-- <env>pro</env>-->
<!-- </properties>-->
<!-- </profile>-->
<!-- </profiles>-->
<build>
<plugins>

View File

@ -1,7 +1,6 @@
package com.chaozhanggui.system.cashierservice;
import com.chaozhanggui.system.cashierservice.task.ConsInfoTask;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -45,7 +44,6 @@ public class Shell {
@Bean
public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
return (args) -> {
// ctx.getBean(ConsInfoTask.class).init();
logger.info("=========================启动完成==========================");
};
}

View File

@ -0,0 +1,26 @@
package com.chaozhanggui.system.cashierservice.annotation;
import com.chaozhanggui.system.cashierservice.bean.*;
import java.lang.annotation.*;
/**
* 日志注解
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface MyLog {
String value() default "未命名日志";
LogTag tag();
OperationLogType operationLogType() default OperationLogType.NULL;
boolean write() default false;
GetKeyWith getKeyWith() default GetKeyWith.WITH_NULL;
String keyName() default "";
OperationLogState operationLogstate() default OperationLogState.UN_HTTP_STATE;
ActionType actionType() default ActionType.SELECT;
LogType type() default LogType.INFO;
boolean showBody() default false;
}

View File

@ -0,0 +1,201 @@
package com.chaozhanggui.system.cashierservice.aop;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.text.StrFormatter;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.annotation.MyLog;
import com.chaozhanggui.system.cashierservice.bean.GetKeyWith;
import lombok.extern.log4j.Log4j2;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@Aspect
@Order
@Component
@Log4j2
public class LogAop {
@Pointcut("@annotation(com.chaozhanggui.system.cashierservice.annotation.MyLog)")
private void getLogPointCut() {
}
private String getRequestBodyInfo(HttpServletRequest request) {
try {
//利用InputStreamReader将字节流转换为字符流
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(request.getInputStream()));
String string;
StringBuilder stringBuffer=new StringBuilder();
//读取字符流的字符拼接在stringBufferStringBuffer在进行字符串处理时不生成新的对象在内存使用上要优于String类
while((string=bufferedReader.readLine())!=null){
stringBuffer.append(string);
}
return stringBuffer.toString();
}catch (Exception e) {
log.error(e);
}
return "";
}
@Async
public void writeLog(String remoteAddr, String url, MyLog logAnnotation, Map<String, String[]> parameterMap, String bodyInfo, Object resp, long duration) {
if (!logAnnotation.write()) return;
// 系统操作日志, 异步事件
String keyVal = null;
JSONObject jsonObject = JSON.parseObject(bodyInfo);
if (logAnnotation.keyName() != null && jsonObject != null) {
if (GetKeyWith.WITH_POST.equals(logAnnotation.getKeyWith())) {
keyVal = jsonObject.getString(logAnnotation.keyName());
}else if (GetKeyWith.WITH_GET.equals(logAnnotation.getKeyWith())) {
for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
if (entry.getKey().equals(logAnnotation.keyName())) {
keyVal = entry.getValue()[0];
}
}
}
}
// SystemOperationLog operationLog = new SystemOperationLog();
// operationLog.setMsg(logAnnotation.tag().getValue() + " " + logAnnotation.value())
// .setKeyValue(keyVal)
// .setKeyName(logAnnotation.keyName())
// .setState(logAnnotation.operationLogstate())
// .setType(logAnnotation.operationLogType())
// .setRespData(resp)
// .setDuration(duration)
// .setIp(remoteAddr)
// .setUrl(url)
// .setReqData(jsonObject);
// Utils.publishEvent(operationLog, OperationLogEvent.class);
}
/**
* 配置环绕通知,使用在方法logPointcut()上注册的切入点
*
* @param joinPoint join point for advice
*/
@Around("getLogPointCut()")
public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
String logInfo = "\033[34m请求地址: {}, 请求ip: {}, 请求方式: {}, GET参数: {}, POST参数: {}\033[0m";
String logStr = "";
String bodyInfo = "";
Map<String, String[]> parameterMap = new HashMap<>();
HttpServletRequest request = null;
String remoteAddr = "";
if (attributes != null) {
request = attributes.getRequest();
if (request.getHeader("X-Forwarded-For") != null) {
remoteAddr = request.getHeader("X-Forwarded-For").split(",")[0];
} else {
remoteAddr = request.getRemoteAddr();
}
parameterMap = request.getParameterMap();
bodyInfo = getRequestBodyInfo(request);
logStr = StrFormatter.format(logInfo,
request.getRequestURI(), remoteAddr, request.getMethod(), request.getQueryString(), bodyInfo);
log.info(logStr);
}
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
Method method = methodSignature.getMethod();
MyLog logAnnotation = method.getAnnotation(MyLog.class);
// 开始时间
long startTime = DateUtil.current(false);
Object result = null;
Exception error = null;
try {
result = joinPoint.proceed();
return result;
}catch (Exception e) {
error = e;
throw e;
}
finally {
long endTime = DateUtil.current(false);
writeLog(remoteAddr, request != null ? request.getRequestURI() : "", logAnnotation, parameterMap, bodyInfo, result == null ? Objects.requireNonNull(error).getCause() + error.getMessage(): result, endTime - startTime);
// 异步记录日志
if (logAnnotation.showBody()) {
logInfo = "\033[32;4m包名: {}, 方法名: {}, 描述: {}, 操作类型: {}, 执行结果: {}, 执行时间: {}ms\033[0m";
}else {
logInfo = "\033[32;4m包名: {}, 方法名: {}, 描述: {}, 操作类型: {}, 执行时间: {}ms\033[0m";
}
switch (logAnnotation.type()) {
case INFO:
if (logAnnotation.showBody()) {
log.info(logInfo,
joinPoint.getTarget().getClass().getPackage().getName(),
method.getName(), logAnnotation.value(), logAnnotation.actionType().getType(), result, endTime - startTime);
}else {
log.info(logInfo,
joinPoint.getTarget().getClass().getPackage().getName(),
method.getName(), logAnnotation.tag() + logAnnotation.value(), logAnnotation.actionType().getType(), endTime - startTime);
}
break;
case ERROR:
if (logAnnotation.showBody()) {
log.error(logInfo,
joinPoint.getTarget().getClass().getPackage().getName(),
method.getName(), logAnnotation.value(), logAnnotation.actionType().getType(), result, endTime - startTime);
}else {
log.error(logInfo,
joinPoint.getTarget().getClass().getPackage().getName(),
method.getName(), logAnnotation.tag() + logAnnotation.value(), logAnnotation.actionType().getType(), endTime - startTime);
}
break;
case WARN:
if (logAnnotation.showBody()) {
log.warn(logInfo,
joinPoint.getTarget().getClass().getPackage().getName(),
method.getName(), logAnnotation.value(), logAnnotation.actionType().getType(), result, endTime - startTime);
}else {
log.warn(logInfo,
joinPoint.getTarget().getClass().getPackage().getName(),
method.getName(), logAnnotation.tag() + logAnnotation.value(), logAnnotation.actionType().getType(), endTime - startTime);
}
break;
default:
if (logAnnotation.showBody()) {
log.debug(logInfo,
joinPoint.getTarget().getClass().getPackage().getName(),
method.getName(), logAnnotation.value(), logAnnotation.actionType().getType(), result, endTime - startTime);
}else {
log.debug(logInfo,
joinPoint.getTarget().getClass().getPackage().getName(),
method.getName(), logAnnotation.tag() + logAnnotation.value(), logAnnotation.actionType().getType(), endTime - startTime);
}
break;
}
}
}
}

View File

@ -0,0 +1,25 @@
package com.chaozhanggui.system.cashierservice.bean;
/**
* 日志操作活动枚举
*/
public enum ActionType {
SELECT("查询操作"),
UPDATE("修改操作"),
DELETE("删除操作"),
ADD("新增操作");
private String type;
ActionType(String type) {
this.type = type;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}

View File

@ -0,0 +1,20 @@
package com.chaozhanggui.system.cashierservice.bean;
import lombok.Getter;
/**
* @author: ZhangSong
* @create: 2024-05-15 17:01
*/
@Getter
public enum GetKeyWith {
WITH_GET(0),
WITH_POST(1),
WITH_NULL(-1);
private final Integer value;
GetKeyWith(Integer value) {
this.value = value;
}
}

View File

@ -0,0 +1,19 @@
package com.chaozhanggui.system.cashierservice.bean;
import lombok.Getter;
/**
* 日志标签
* @author: ZhangSong
* @create: 2024-05-15 16:32
*/
@Getter
public enum LogTag {
JPUSH("极光"), CLIENT("安卓"),
LOGIN("登录"), SYSTEM("系统"), CART("订单购物车"), PLACE("下单");
private final String value;
LogTag(String value) {
this.value = value;
}
}

View File

@ -0,0 +1,21 @@
package com.chaozhanggui.system.cashierservice.bean;
public enum LogType {
INFO("INFO"),
ERROR("ERROR"),
WARN("WARN"),
DEBUG("DEBUG");
private String value;
LogType(String value) {
this.value = value;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}

View File

@ -0,0 +1,24 @@
package com.chaozhanggui.system.cashierservice.bean;
/**
* 操作日志所有状态
* @author: ZhangSong
* @create: 2024-04-28 11:06
*/
public enum OperationLogState {
UN_HTTP_STATE(-1),
HTTP_FAIL_STATE(0),
HTTP_SUCCESS_STATE(1),
SQL_EXE_FAIL_STATE(2),
SQL_EXE_SUCCESS_STATE(3);
private Integer state;
OperationLogState(Integer state) {
this.state = state;
}
public Integer getState() {
return state;
}
}

View File

@ -0,0 +1,43 @@
package com.chaozhanggui.system.cashierservice.bean;
/**
* 操作日志所有操作类型
* @author: ZhangSong
* @create: 2024-04-28 11:04
*/
public enum OperationLogType {
UM_API_QUERY_CITY_CALL(1000),
UM_API_UPDATE_ORDER_PHONE(1010),
UM_API_QUERY_DRIVER_LOCATION(1020),
UM_API_CANCEL_ORDER(1030),
UM_API_CANCEL_ORDER_SUCCESS(1040),
UM_API_PAY_ORDER_CALL(1050),
UM_API_CREATE_INVOICE_CALL(1060),
UM_API_QUERY_INVOICE_CALL(1070),
UM_API_RED_REVERSE_CALL(1080),
UM_API_RED_REVERSE_CALL_SUCCESS(1081),
UM_API_PUSH_ORDER_STATE_CALL(1090),
UM_API_PUSH_ORDER_STATE_CALL_GET_HL_STATE_FAIL(1091),
UM_API_PUSH_DRIVER_CALL(1100),
UM_API_PUSH_DRIVER_CALL_API_FAIL(1101),
UM_API_QUERY_PRICE_CALL(1110),
UM_API_CREATE_ORDER_CALL(1120),
UM_API_QUERY_ORDER_DETAIL_CALL(1130),
JPUSH_API_CALL(1140),
UM_CONTROLLER_MAKE_INVOICE_CALL(1150), UM_API_PUSH_TEMP_DRIVER_CALL(1160),
ENUOYUN_INVOICE_CALL(1170),
UM_API_CALL_UM_CHANGE_ORDER_STATE(1180),
API_CHARGEBACK_CALL(1190),
API_REDISTRIBUTE_CALL(1200), API_DRIVER_LOGIN_CALL(1210), NULL(-1),
API_CHANGXING_HANGLV_CHONGXIN_SHANGCHUAN(1220),
API_CHANGXING_HANGLV_FAPIAO_ZUOFEI(1230);
private final Integer value;
OperationLogType(Integer value) {
this.value = value;
}
public Integer getValue() {
return value;
}
}

View File

@ -0,0 +1,23 @@
package com.chaozhanggui.system.cashierservice.bean;
import lombok.Getter;
/**
* @author: ZhangSong
* @create: 2024-05-23 19:01
*/
@Getter
public enum Plat {
TT(1),
CX(2),
RZ(3),
JS(5),
UNDEFINED(-1);
private final Integer value;
Plat(Integer value) {
this.value = value;
}
}

View File

@ -0,0 +1,6 @@
package com.chaozhanggui.system.cashierservice.bean;
public class PrintProductInfo {
private Integer orderDetailId;
private Integer num;
}

View File

@ -0,0 +1,17 @@
package com.chaozhanggui.system.cashierservice.bean;
public enum ShopWxMsgTypeEnum {
ALL_MSG(-1),
STOCK_MSG(0),
CONSUMABLES_MSG(1),
OPERATION_MSG(2);
private final Integer type;
ShopWxMsgTypeEnum(Integer type) {
this.type = type;
}
public Integer getType() {
return type;
}
}

View File

@ -0,0 +1,15 @@
package com.chaozhanggui.system.cashierservice.bean;
public enum TableStateEnum {
IDLE("idle"),
CLOSED("closed"), PAYING("paying"), PENDING("pending"), USING("using");
private String state = "closed";
TableStateEnum(String state) {
this.state = state;
}
public String getState() {
return state;
}
}

View File

@ -23,6 +23,8 @@ public class LoginContoller {
@Autowired
LoginService loginService;
@RequestMapping(value = "login",method = RequestMethod.POST)
public Result login(@RequestBody LoginReq loginReq, HttpServletRequest request){
try {
@ -34,6 +36,11 @@ public class LoginContoller {
return Result.fail(CodeEnum.FAIL);
}
@RequestMapping(value = "findVersion",method = RequestMethod.POST)
public Result findVersion() {
return loginService.findVersion();
}
@RequestMapping("logout")
public Result logout( @RequestHeader("token") String token,
@ -51,4 +58,13 @@ public class LoginContoller {
@RequestHeader("clientType") String clientType){
return loginService.getShopInfo(token);
}
@RequestMapping(value = "getStaffDiscount")
public Result getStaffDiscount(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType){
return loginService.getStaffDiscount(token);
}
}

View File

@ -1,12 +1,12 @@
package com.chaozhanggui.system.cashierservice.controller;
import com.chaozhanggui.system.cashierservice.service.MemberService;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
@CrossOrigin(origins = "*")
@ -26,10 +26,11 @@ public class MemberController {
@RequestHeader("clientType") String clientType,
@RequestParam("shopId") String shopId,
@RequestParam("phone") String phone,
@RequestParam(value = "isFlag",required = false,defaultValue = "0") String isFlag,
@RequestParam("page") int page,
@RequestParam("pageSize") int pageSize
){
return memberService.queryMember(shopId,phone,page,pageSize);
) {
return memberService.queryMember(shopId, phone, isFlag,page, pageSize);
}
@ -37,8 +38,8 @@ public class MemberController {
public Result createMember(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType,
@RequestBody Map<String,Object> map
){
@RequestBody Map<String, Object> map
) {
return memberService.createMember(map);
}
@ -48,32 +49,35 @@ public class MemberController {
@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType,
@RequestBody Map<String,Object> map
@RequestBody Map<String, Object> map
){
return memberService.memberScanPay(map,token);
) {
return memberService.memberScanPay(map, token);
}
@GetMapping("queryScanPay")
public Result queryScanPay(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType,
@RequestParam("flowId") String flowId
){
return memberService.queryScanPay(flowId,token);
) {
return memberService.queryScanPay(flowId, token);
}
@RequestMapping("accountPay")
public Result accountPay( @RequestHeader("token") String token,
public Result accountPay(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType,
@RequestBody Map<String,Object> map
){
return memberService.memberAccountPay(map,token);
@RequestBody Map<String, Object> map
) {
try {
return memberService.memberAccountPay(map, token);
} catch (Exception e) {
e.printStackTrace();
}
return Result.fail(CodeEnum.SYS_EXCEPTION);
}
@ -85,7 +89,20 @@ public class MemberController {
@RequestParam("page") int page,
@RequestParam("pageSize") int pageSize
) {
return memberService.queryMemberAccount(memberId, page, pageSize);
}
@RequestMapping("returnFlow")
public Result returnFlow(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType,
@RequestParam("flowId") String flowId,
@RequestParam("remark") String remark,
@RequestParam("amount") String amount,
@RequestParam("pwd") String pwd
){
return memberService.queryMemberAccount(memberId,page,pageSize);
return memberService.returnAccount(token, flowId,remark,amount, pwd);
}
}

View File

@ -1,19 +1,22 @@
package com.chaozhanggui.system.cashierservice.controller;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.annotation.MyLog;
import com.chaozhanggui.system.cashierservice.bean.LogTag;
import com.chaozhanggui.system.cashierservice.entity.OrderVo;
import com.chaozhanggui.system.cashierservice.entity.dto.UpdateVipDTO;
import com.chaozhanggui.system.cashierservice.entity.vo.CartVo;
import com.chaozhanggui.system.cashierservice.service.OrderService;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.chaozhanggui.system.cashierservice.util.TokenUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.sql.Timestamp;
import java.util.Date;
@CrossOrigin(origins = "*")
@RestController
@Slf4j
@ -24,6 +27,14 @@ public class OrderController {
@Autowired
private OrderService orderService;
@PutMapping("/updateVip")
@MyLog(value = "代客下单 修改会员", tag = LogTag.PLACE)
public ResponseEntity<Object> updateVip(
@Validated @RequestBody UpdateVipDTO updateVipDTO
) {
return ResponseEntity.ok(orderService.updateVip(updateVipDTO));
}
@PostMapping("/createCart")
public Result createCart(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@ -34,22 +45,31 @@ public class OrderController {
String userId = jsonObject.getString("accountId");
return orderService.createCart(cartVo.getMasterId(),cartVo.getProductId(),cartVo.getShopId(),
cartVo.getSkuId(),cartVo.getNumber(),userId,clientType,cartVo.getCartId(),cartVo.getIsGift(),
cartVo.getIsPack(),cartVo.getUuid(),cartVo.getType());
cartVo.getIsPack(),cartVo.getUuid(),cartVo.getType(), cartVo.getTableId());
}
@MyLog(value = "查询购物车信息", tag = LogTag.CART)
@GetMapping("/queryCart")
public Result queryCart(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType,
@RequestParam("masterId") String masterId,
@RequestParam(value = "masterId", required = false) String masterId,
@RequestParam(required = false) String tableId,
@RequestParam("shopId") String shopId
){
return orderService.queryCart(masterId,shopId);
if (tableId == null && StrUtil.isBlank(masterId)) {
return Result.fail("masterId和tableId不能同时为空");
}
return orderService.queryCart(masterId,shopId, tableId);
}
@GetMapping("/delCart")
public Result delCart(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType,
@RequestParam("masterId") String masterId,
@RequestParam(required = false) String tableId,
@RequestParam(value = "masterId", required = false) String masterId,
@RequestParam("cartId") Integer cartId
){
return orderService.delCart(masterId,cartId);
@ -59,11 +79,12 @@ public class OrderController {
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType,
@RequestParam("shopId") String shopId,
@RequestParam(required = false) String tableId,
String type
){
JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
String userId = jsonObject.getString("accountId");
return orderService.createCode(shopId,clientType,userId,type);
return orderService.createCode(shopId,clientType,userId,type, tableId);
}
@GetMapping("/getCartList")
public Result getCart(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName,
@ -81,7 +102,8 @@ public class OrderController {
JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
String userId = jsonObject.getString("accountId");
String code = jsonObject.getString("code");
return orderService.cartStatus(Integer.valueOf(cartVo.getShopId()),cartVo.getMasterId(),cartVo.getStatus(),userId,cartVo.getUuid(),clientType);
return orderService.cartStatus(Integer.valueOf(cartVo.getShopId()),cartVo.getMasterId(),
cartVo.getStatus(),userId,cartVo.getUuid(),clientType, cartVo.getVipUserId(), cartVo.getTableId());
}
@PostMapping("/createOrder")
public Result createOrder(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName,
@ -90,7 +112,7 @@ public class OrderController {
String userId = jsonObject.getString("accountId");
orderVo.setMerchantId(Integer.valueOf(userId));
orderVo.setUserId(jsonObject.getString("staffId"));
return orderService.createOrder(orderVo,clientType,token);
return orderService.createOrder(orderVo,clientType,token, null, orderVo.getType() != null && orderVo.getType().equals(0));
}
@PostMapping("/createBackOrder")
public Result createBackOrder(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName,
@ -130,7 +152,9 @@ public class OrderController {
public Result orderDetail(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType, @RequestParam("shopId") Integer shopId,
@RequestParam("id") Integer id){
return orderService.orderDetail(shopId,id);
JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
String userId = jsonObject.getString("accountId");
return orderService.orderDetail(shopId,id, clientType, token, userId, jsonObject.getString("staffId"));
}

View File

@ -1,19 +1,39 @@
package com.chaozhanggui.system.cashierservice.controller;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.AlipayConfig;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipaySystemOauthTokenRequest;
import com.alipay.api.request.AlipayUserInfoShareRequest;
import com.alipay.api.response.AlipaySystemOauthTokenResponse;
import com.alipay.api.response.AlipayUserInfoShareResponse;
import com.chaozhanggui.system.cashierservice.annotation.LimitSubmit;
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
import com.chaozhanggui.system.cashierservice.entity.dto.ReturnGroupOrderDto;
import com.chaozhanggui.system.cashierservice.entity.dto.VipPayDTO;
import com.chaozhanggui.system.cashierservice.model.PaymentReq;
import com.chaozhanggui.system.cashierservice.service.PayService;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.chaozhanggui.system.cashierservice.util.IpUtil;
import com.chaozhanggui.system.cashierservice.util.JSONUtil;
import com.chaozhanggui.system.cashierservice.util.RedisCst;
import com.chaozhanggui.system.cashierservice.util.WechatUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;
import java.util.Objects;
@CrossOrigin(origins = "*")
@RestController
@ -44,8 +64,6 @@ public class PayController {
* @param token
* @param loginName
* @param clientType
* @param orderId
* @param authCode
* @return
*/
@RequestMapping("scanpay")
@ -54,11 +72,9 @@ public class PayController {
@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType,
@RequestParam("orderId") String orderId,
@RequestParam("authCode") String authCode
@RequestBody PaymentReq paymentReq
) {
return payService.scanPay(orderId,authCode, IpUtil.getIpAddr(request),token);
return payService.scanPay(paymentReq.getOrderId(),paymentReq.getAuthCode(), IpUtil.getIpAddr(request),token,paymentReq.getPayAmount(),paymentReq.getDiscountAmount());
}
@ -67,21 +83,17 @@ public class PayController {
* @param token
* @param loginName
* @param clientType
* @param orderId
* @param memberId
* @return
*/
@GetMapping("accountPay")
@RequestMapping("accountPay")
@LimitSubmit(key = "accountPay:%s")
public Result accountPay(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType,
@RequestParam("orderId") String orderId,
@RequestParam("memberId") String memberId,
@RequestParam("memberAccount") String memberAccount
@RequestBody PaymentReq paymentReq
){
return payService.accountPay(orderId,memberId,token,memberAccount);
return payService.accountPay(paymentReq.getOrderId(),paymentReq.getMemberId(),token,paymentReq.getMemberAccount(),paymentReq.getPayAmount(),paymentReq.getDiscountAmount());
}
@ -154,19 +166,16 @@ public class PayController {
* @param token
* @param loginName
* @param clientType
* @param orderId
* @param memberCode
* @return
*/
@GetMapping("memberScanPay")
@RequestMapping("memberScanPay")
@LimitSubmit(key = "memberScanPay:%s")
public Result memberScanPay(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType,
@RequestParam("orderId") String orderId,
@RequestParam("memberCode") String memberCode
@RequestBody PaymentReq paymentReq
){
return payService.memberScanPay(orderId,memberCode,token);
return payService.memberScanPay(paymentReq.getOrderId(),paymentReq.getMemberCode(),token,paymentReq.getPayAmount(),paymentReq.getDiscountAmount());
}
@ -176,19 +185,48 @@ public class PayController {
* @param token
* @param loginName
* @param clientType
* @param orderId
* @return
*/
@GetMapping("cashPay")
@RequestMapping("cashPay")
@LimitSubmit(key = "cashPay:%s")
public Result cashPay(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType,
@RequestParam("orderId") String orderId){
return payService.cashPay(orderId,token);
@RequestBody PaymentReq paymentReq){
Result result = payService.cashPay(paymentReq.getOrderId(), token, paymentReq.getPayAmount(), paymentReq.getDiscountAmount());
return result;
}
/**
* 会员支付
* @param token
* @param loginName
* @param clientType
* @return
*/
@PostMapping("vipPay")
@LimitSubmit(key = "vipPay:%s")
public Result vipPay(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType,
@RequestBody VipPayDTO vipPayDTO
){
if (vipPayDTO.getOrderId() == null || vipPayDTO.getVipUserId() == null) {
return Result.fail("参数缺失");
}
if (
(vipPayDTO.getPayAmount() != null && vipPayDTO.getPayAmount().compareTo(BigDecimal.ZERO) <= 0) ||
(vipPayDTO.getDiscountAmount() != null && vipPayDTO.getDiscountAmount().compareTo(BigDecimal.ZERO) <= 0)
) {
return Result.fail("折扣金额必须大于0");
}
return payService.vipPay(vipPayDTO.getOrderId(),token, vipPayDTO.getVipUserId(), vipPayDTO.getPayAmount(), vipPayDTO.getDiscountAmount());
}
/**
@ -196,16 +234,15 @@ public class PayController {
* @param token
* @param loginName
* @param clientType
* @param orderId
* @return
*/
@GetMapping("bankPay")
@RequestMapping("bankPay")
@LimitSubmit(key = "bankPay:%s")
public Result bankPay(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType,
@RequestParam("orderId") String orderId){
return payService.bankPay(orderId,token);
@RequestBody PaymentReq paymentReq){
return payService.bankPay(paymentReq.getOrderId(),token,paymentReq.getPayAmount(),paymentReq.getDiscountAmount());
}
@ -221,7 +258,8 @@ public class PayController {
){
return payService.returnOrder(list,token,null, isOnline);
return payService.returnOrder(list,token,pwd, isOnline);
}
@ -244,4 +282,155 @@ public class PayController {
public Result testOrder( @RequestParam("orderId") String orderId){
return Result.success(CodeEnum.SUCCESS);
}
@RequestMapping("getOrderDiscount")
public Result getOrderDiscount(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType,
@RequestParam("orderId") String orderId,
@RequestParam("staffId") String staffId
){
return payService.getOrderDiscount(staffId, orderId, token);
}
@RequestMapping("pcscanpay")
@LimitSubmit(key = "pcscanpay:%s")
public Result pcscanpay(HttpServletRequest request,@RequestBody PaymentReq paymentReq){
try {
return payService.pcscanpay(paymentReq.getOrderId(),IpUtil.getIpAddr(request),paymentReq.getUserId(),paymentReq.getPayType());
} catch (Exception e) {
e.printStackTrace();
}
return Result.fail(CodeEnum.FAIL);
}
@RequestMapping("createOrder")
public Result createOrder(HttpServletRequest request,@RequestBody PaymentReq paymentReq){
try {
return payService.createOrder(IpUtil.getIpAddr(request),paymentReq.getUserId(),paymentReq.getPayType(),paymentReq.getShopId(),paymentReq.getPayAmount());
} catch (JsonProcessingException e) {
e.printStackTrace();
}
return Result.fail(CodeEnum.FAIL);
}
@GetMapping("queryOrderPay")
public Result queryOrderPay(String orderId){
return payService.queryOrderPay(orderId);
}
@Value("${wx.ysk.appId}")
private String appId;
@Value("${wx.ysk.secrete}")
private String secrete;
@Value("${ali.appId}")
private String aliAppId;
@Value("${ali.privateKey}")
private String privateKey;
@Value("${ali.publicKey}")
private String publicKey;
/**
* 获取支付宝或微信openId
* @param code
* @return
*/
@GetMapping("/openId")
public Result getOpenId(
@RequestParam String code,
@RequestParam String payType
) throws AlipayApiException {
if("WECHAT".equals(payType)){
JSONObject SessionKeyOpenId = WechatUtil.getSessionKeyOrOpenId(code, appId, secrete);
log.info("SessionKeyOpenId:{}",SessionKeyOpenId.toString());
String openid = SessionKeyOpenId.getString("openid");
if(Objects.isNull(openid)){
return Result.fail("获取微信id失败");
}
return Result.success(CodeEnum.SUCCESS,openid);
}else if("ALIPAY".equals(payType)){
// 初始化SDK
AlipayClient alipayClient = new DefaultAlipayClient(getAlipayConfig());
// 构造请求参数以调用接口
AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest();
// 设置刷新令牌
// request.setRefreshToken("201208134b203fe6c11548bcabd8da5bb087a83b");
// 设置授权码
request.setCode(code);
// 设置授权方式
request.setGrantType("authorization_code");
AlipaySystemOauthTokenResponse response = alipayClient.execute(request);
log.info("AlipaySystemOauthTokenResponse:{}", JSONUtil.toJSONString(response));
response.setAccessToken(response.getRefreshToken());
if (!response.isSuccess()) {
return Result.fail("获取支付宝userId失败");
}
return Result.success(CodeEnum.SUCCESS, ObjectUtil.isNull(response.getUserId())?response.getOpenId():response.getUserId());
}
return Result.fail(CodeEnum.FAIL);
}
private AlipayConfig getAlipayConfig() {
AlipayConfig alipayConfig = new AlipayConfig();
alipayConfig.setServerUrl("https://openapi.alipay.com/gateway.do");
alipayConfig.setAppId(aliAppId);
alipayConfig.setPrivateKey(privateKey);
alipayConfig.setFormat("json");
alipayConfig.setAlipayPublicKey(publicKey);
alipayConfig.setCharset("UTF-8");
alipayConfig.setSignType("RSA2");
return alipayConfig;
}
public static void main(String[] args){
LocalDate date=LocalDate.now();
if(date.isLeapYear()){
System.out.println();
}
}
}

View File

@ -1,13 +1,18 @@
package com.chaozhanggui.system.cashierservice.controller;
import com.chaozhanggui.system.cashierservice.entity.dto.ProductStatusDTO;
import com.chaozhanggui.system.cashierservice.entity.dto.ProductStockDTO;
import com.chaozhanggui.system.cashierservice.entity.dto.QuerySpecDTO;
import com.chaozhanggui.system.cashierservice.service.ProductService;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.Map;
@CrossOrigin(origins = "*")
@ -21,6 +26,23 @@ public class ProductController {
private ProductService productService;
@PutMapping("/productStatus")
public Result productStatus(
@Valid @RequestBody ProductStatusDTO productStatusDTO
) {
productService.updateState(productStatusDTO);
return Result.success(CodeEnum.SUCCESS);
}
@PutMapping("/productStock")
public Result productStock(
@Valid @RequestBody ProductStockDTO productStockDTO
) {
productService.updateStock(productStockDTO);
return Result.success(CodeEnum.SUCCESS);
}
@GetMapping(value = "queryCommodityInfo")
public Result queryCommodityInfo(
@RequestHeader("token") String token,
@ -37,6 +59,15 @@ public class ProductController {
return productService.queryCommodityInfo(shopId,categoryId,commdityName,page,pageSize,masterId);
}
@GetMapping("querySpec")
public Result querySpec(
@RequestParam Integer shopId,
@RequestParam Integer productId
) {
return Result.success(CodeEnum.SUCCESS, productService.querySpec(shopId, productId));
}
@GetMapping(value = "queryNewCommodityInfo")
public Result queryNewCommodityInfo(
@RequestHeader("token") String token,
@ -46,11 +77,12 @@ public class ProductController {
@RequestParam("categoryId") String categoryId,
@RequestParam("commdityName") String commdityName,
@RequestParam("masterId") String masterId,
@RequestParam(value = "tableId", required = false) String tableId,
@RequestParam("page") int page,
@RequestParam("pageSize") int pageSize
){
return productService.queryNewCommodityInfo(shopId,categoryId,commdityName,page,pageSize,masterId);
return productService.queryNewCommodityInfo(shopId,categoryId,commdityName, tableId,page,pageSize,masterId);
}
@GetMapping(value = "queryCategory")

View File

@ -17,6 +17,11 @@ public class ShopInfoController {
@Autowired
ShopInfoService shopInfoService;
@GetMapping("/queryShopInfo")
public Result queryShopInfo(@RequestParam Integer shopId){
return shopInfoService.queryShopInfo(shopId);
}
@GetMapping("queryShopArea")
public Result queryShopArea(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@ -59,4 +64,9 @@ public class ShopInfoController {
) {
return shopInfoService.queryDutyFlow(token, shopId, page,pageSize);
}
@GetMapping("queryPwdInfo")
public Result queryPwdInfo(@RequestParam("shopId") String shopId) {
return shopInfoService.queryShopPwdInfo(shopId);
}
}

View File

@ -0,0 +1,25 @@
package com.chaozhanggui.system.cashierservice.controller;
import com.chaozhanggui.system.cashierservice.service.TbShopPermissionService;
import com.chaozhanggui.system.cashierservice.service.TbShopStaffPermissionService;
import com.chaozhanggui.system.cashierservice.sign.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@Slf4j
@RequestMapping("staffPermission")
public class StaffPermissionController {
@Autowired
private TbShopPermissionService permissionService;
@GetMapping
public Result getStaffPermission(String staffId, String code) {
return permissionService.getStaffPermission(staffId, code);
}
}

View File

@ -0,0 +1,40 @@
package com.chaozhanggui.system.cashierservice.controller;
import com.chaozhanggui.system.cashierservice.entity.TbVersion;
import com.chaozhanggui.system.cashierservice.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* @author yijiegong
*/
@RestController
@RequestMapping("/version")
public class VersionController {
@Autowired
LoginService loginService;
@GetMapping("pcDownload")
public ResponseEntity<Void> pcDownload(HttpServletRequest request, HttpServletResponse response) {
TbVersion pcVersion = loginService.getCurrentPcVersion();
if (pcVersion == null) {
throw new RuntimeException("未找到PC版本信息");
}
// 重定向到下载地址
HttpHeaders headers = new HttpHeaders();
headers.setLocation(java.net.URI.create(pcVersion.getUrl()));
return new ResponseEntity<>(headers, HttpStatus.FOUND);
}
}

View File

@ -3,8 +3,10 @@ package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
import com.chaozhanggui.system.cashierservice.entity.po.CartPo;
import com.chaozhanggui.system.cashierservice.entity.po.QueryCartPo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;
import java.util.List;
@ -28,11 +30,14 @@ public interface TbCashierCartMapper {
List<TbCashierCart> selectALlByMasterId(@Param("masterId") String masterId,@Param("status") String status);
TbCashierCart selectByDetail(@Param("masterId") String masterId, @Param("productId") String productId,
@Param("shopId") String shopId, @Param("skuId") String skuId, @Param("day") String day,@Param("uuid") String uuid);
@Param("shopId") String shopId, @Param("skuId") String skuId, @Param("day") String day,@Param("uuid") String uuid, @Param("tableId") String tableId);
TbCashierCart selectDetailByQrcode(@Param("tableId") String tableId, @Param("productId") String productId,
@Param("shopId") String shopId, @Param("skuId") String skuId, @Param("uuid") String uuid);
List<TbCashierCart> selectByMaskerId(@Param("masterId")String masterId, @Param("shopId")Integer shopId,@Param("status") String status,@Param("day") String day);
void deleteByCartId(@Param("masterId") String masterId, @Param("cartId")Integer cartId);
void deleteByCartIdOrTableId(@Param("masterId") String masterId, @Param("cartId")Integer cartId, @Param("qrcode") String qrcode);
void updateStatus(@Param("masterId") Integer id,@Param("status") String status);
@ -60,4 +65,17 @@ public interface TbCashierCartMapper {
List<TbCashierCart> selectByOrderId(@Param("orderId") String orderId,@Param("status") String status);
List<TbCashierCart> selectActivateByQrcode(@Param("tableId") String tableId, @Param("shopId") Integer shopId);
QueryCartPo selectProductNumByQrcode(@Param("qrcode") String qrcode, @Param("shopId") Integer shopId);
@Delete("delete from tb_cashier_cart where master_id=#{masterId} and id=#{cartId}")
int deleteByCartId(@Param("masterId") String masterId, @Param("cartId")Integer cartId);
@Select("select count(*) from tb_cashier_cart where shop_id=#{shopId} and `status`='create' and table_id=#{qrcode} and order_id is not null")
int countTable(@Param("qrcode") String qrcode, @Param("shopId") Integer shopId);
@Select("select count(*) from tb_order_detail where shop_id=#{shopId} and `status`='unpaid' and order_id=#{orderId} and order_id is not null")
int countTableByDetail(@Param("orderId") Integer orderId, @Param("shopId") Integer shopId);
}

View File

@ -25,7 +25,7 @@ public interface TbOrderDetailMapper {
int updateByPrimaryKey(TbOrderDetail record);
void updateStatusByOrderId(@Param("orderId") int orderId,@Param("status") String status);
void updateStatusByOrderId(@Param("orderId") int orderId,@Param("status") String status,@Param("radio") BigDecimal radio);
void updateStatusByOrderIdAndStatus(@Param("orderId") int orderId,@Param("status") String status);
void deleteByOUrderId(@Param("orderId") int orderId);

View File

@ -52,4 +52,6 @@ public interface TbOrderInfoMapper {
TbOrderInfo selectById(Integer id);
List<TbOrderInfo> selectActivateOrder(@Param("shopId") String shopId, @Param("tableId") String qrcodeId);
}

View File

@ -5,6 +5,7 @@ import com.chaozhanggui.system.cashierservice.entity.TbProductWithBLOBs;
import com.chaozhanggui.system.cashierservice.entity.po.ProConsSkuInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;
@ -35,10 +36,11 @@ public interface TbProductMapper {
List<TbProductWithBLOBs> selectByShopIdAndShopType(@Param("shopId") String shopId, @Param("categoryId") String categoryId,@Param("commdityName") String commdityName);
List<TbProductWithBLOBs> selectByShopIdAndShopTypeCheckGrounding(@Param("shopId") String shopId, @Param("categoryId") String categoryId,@Param("commdityName") String commdityName);
List<TbProductWithBLOBs> selectByShopIdAndShopTypeUnGrounding(@Param("shopId") String shopId,@Param("commdityName") String commdityName);
Integer countOrderByshopIdAndProductId(@Param("shopId") String shopId, @Param("productId") String productId, @Param("masterId") String masterId,@Param("day") String day);
Integer countOrderByshopIdAndProductId(@Param("shopId") String shopId, @Param("productId") String productId, @Param("masterId") String masterId,@Param("day") String day, @Param("tableId") String tableId);
void updateStockById(@Param("productId")Integer productId, @Param("num")Integer num);
@ -53,4 +55,24 @@ public interface TbProductMapper {
@Update("update tb_product set stock_number=stock_number-#{num} WHERE id=#{id}")
int decrStockUnCheck(String id, int num);
@Select("select * from tb_product product where product.id=#{productId} and product.shop_id=#{shopId} and product.is_del=0")
TbProduct selectByShopIdAndId(@Param("productId") Integer productId, @Param("shopId") Integer shopId);
@Update("update tb_product_sku set is_grounding=#{isGrounding} where product_id=#{productId}")
int updateGroundingByProId(@Param("productId") Integer productId, @Param("isGrounding") int isGrounding);
@Update("update tb_product_sku set is_grounding=#{status} where id=#{skuId}")
int updateGrounding(@Param("skuId") Integer skuId, @Param("status") int status);
@Update("update tb_product set is_pause_sale=#{state} where id=#{id} and shop_id=#{shopId}")
int pauseSale(@Param("id") Integer id, @Param("shopId") Integer shopId, @Param("state") Integer state);
@Update("update tb_product_sku set is_pause_sale=#{state} where product_id=#{id} and shop_id=#{shopId}")
int pauseSkuSale(@Param("id") Integer proId, @Param("shopId") Integer shopId, @Param("state") Integer state);
@Update("update tb_product set stock_number=#{stock} where id=#{productId} and shop_id=#{shopId}")
int updateStock(@Param("shopId") Integer shopId, @Param("productId") Integer productId, @Param("stock") Integer stock);
}

View File

@ -48,12 +48,24 @@ public interface TbProductSkuMapper {
@Update("update tb_product_sku set stock_number=stock_number-#{num} WHERE id=#{id} and stock_number-#{num} >= 0")
int decrStock(String id, int num);
@Update("update tb_product_sku set real_sales_number=real_sales_number-#{num} WHERE id=#{skuId}")
int decrRealSalesNumber(@Param("skuId") Integer skuId, @Param("num") Integer num);
@Update("update tb_product_sku set stock_number=stock_number-#{num} WHERE id=#{id} ")
int decrStockUnCheck(String id, int num);
@Select("select * from tb_product_sku where is_grounding=1 and product_id=#{id}")
@Select("select * from tb_product_sku where is_grounding=1 and product_id=#{id} and is_del=0")
List<TbProductSku> selectByProductCheckGrounding(@Param("id") Integer id);
@Select("select * from tb_product_sku where is_grounding=1 and is_del=0 and product_id=#{id}")
List<TbProductSku> selectGroundingByProId(Integer id);
List<TbProductSku> selectGroundingByProId(@Param("id") Integer id);
@Update("update tb_product_sku set is_pause_sale=#{state} where id=#{skuId} and shop_id=#{shopId}")
int pauseSale(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId, @Param("state") Integer state);
@Update("update tb_product_sku set stock_number=#{stock} where product_id=#{skuId} and shop_id=#{shopId}")
int updateStock(@Param("shopId") Integer shopId, @Param("skuId") Integer skuId, @Param("stock") Integer stock);
@Select("select * from tb_product_sku where product_id=#{id} and is_del=0")
List<TbProductSku> selectByProductId(Integer id);
}

View File

@ -24,11 +24,13 @@ public interface TbProskuConMapper {
List<TbProskuCon> selectBySkuIdAndShopId(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId);
List<TbProskuCon> selectBySkuIdAndShopIdAngCheck(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId);
List<Integer> selectIdBySkuIdAndShopId(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId);
List<TbProskuCon> selectByShopIdAndSkuIdAndProductId(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId,@Param("productId") Integer productId);
List<TbProskuCon> selectByShopIdAndSkuIdAndProductIdAndCheck(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId,@Param("productId") Integer productId);

View File

@ -1,6 +1,7 @@
package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.TbShopOpenId;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
@ -27,4 +28,7 @@ public interface TbShopOpenIdMapper {
@Select("select * from tb_shop_open_id where shop_id=#{shopId} and status=1")
List<TbShopOpenId> selectByShopId(Integer integer);
@Select("select * from tb_shop_open_id where shop_id=#{shopId} and status=1 and (type=#{type} or type=-1) group by open_id;")
List<TbShopOpenId> selectStateByShopIdAndType(@Param("shopId") String shopId, @Param("type") int type);
}

View File

@ -0,0 +1,15 @@
package com.chaozhanggui.system.cashierservice.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chaozhanggui.system.cashierservice.entity.TbShopPermission;
/**
* (TbShopPermission)表数据库访问层
*
* @author makejava
* @since 2024-09-14 17:08:48
*/
public interface TbShopPermissionDao extends BaseMapper<TbShopPermission> {
}

View File

@ -0,0 +1,15 @@
package com.chaozhanggui.system.cashierservice.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chaozhanggui.system.cashierservice.entity.TbShopStaffPermission;
/**
* 店铺员工权限关联表(TbShopStaffPermission)表数据库访问层
*
* @author makejava
* @since 2024-09-14 17:07:33
*/
public interface TbShopStaffPermissionDao extends BaseMapper<TbShopStaffPermission> {
}

View File

@ -1,6 +1,7 @@
package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.TbShopTable;
import com.chaozhanggui.system.cashierservice.entity.vo.TbShopTableVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
@ -23,4 +24,5 @@ public interface TbShopTableMapper {
int updateByPrimaryKey(TbShopTable record);
List<TbShopTable> selectByShopIdAndStatus(@Param("shopId") String shopId,@Param("areaId") String areaId,@Param("status") String status);
List<TbShopTableVO> selectTableInfo(@Param("shopId") String shopId, @Param("areaId") String areaId, @Param("status") String status, @Param("day") String day);
}

View File

@ -22,7 +22,7 @@ public interface TbShopUserMapper {
int updateByPrimaryKey(TbShopUser record);
List<TbShopUser> selectByShopId(@Param("shopId") String shopId,@Param("phone") String phone);
List<TbShopUser> selectByShopId(@Param("shopId") String shopId,@Param("phone") String phone,@Param("isFlag") String isFlag);
List<TbShopUser> selectByShopIdAndPhone(@Param("shopId") String shopId,@Param("phone") String phone);

View File

@ -12,4 +12,9 @@ public class OrderVo {
private Integer shopId;
private String userId;
private Integer merchantId;
private String tableId;
private Integer vipUserId;
private Integer type;
private String sendType;
}

View File

@ -1,5 +1,6 @@
package com.chaozhanggui.system.cashierservice.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import java.io.Serializable;
@ -57,7 +58,11 @@ public class TbCashierCart implements Serializable {
private Long updatedAt;
private Integer userId;
private String tableId;
@TableField(exist = false)
private TbProductSpec tbProductSpec;
@TableField(exist = false)
private String selectSpec="";
private static final long serialVersionUID = 1L;

View File

@ -35,6 +35,8 @@ public class TbConsInfo implements Serializable {
private Date updateTime;
private String isCheck;
private static final long serialVersionUID = 1L;
public Integer getId() {
@ -156,4 +158,12 @@ public class TbConsInfo implements Serializable {
public void setPrice(BigDecimal price) {
this.price = price;
}
public String getIsCheck() {
return isCheck;
}
public void setIsCheck(String isCheck) {
this.isCheck = isCheck;
}
}

View File

@ -1,5 +1,6 @@
package com.chaozhanggui.system.cashierservice.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import java.io.Serializable;
@ -37,6 +38,7 @@ public class TbOrderDetail implements Serializable {
private BigDecimal priceAmount;
private BigDecimal packAmount;
@TableField(exist = false)
private String remark;
private static final long serialVersionUID = 1L;

View File

@ -100,6 +100,10 @@ public class TbOrderInfo implements Serializable {
private String outNumber;
private Integer staffId;
private String useType;
private static final long serialVersionUID = 1L;
public TbOrderInfo(){
super();

View File

@ -14,6 +14,8 @@ public class TbPlussShopStaff implements Serializable {
private String password;
private String discountType;
private BigDecimal maxDiscountAmount;
private Boolean status;
@ -72,6 +74,14 @@ public class TbPlussShopStaff implements Serializable {
this.password = password == null ? null : password.trim();
}
public String getDiscountType() {
return discountType;
}
public void setDiscountType(String discountType) {
this.discountType = discountType;
}
public BigDecimal getMaxDiscountAmount() {
return maxDiscountAmount;
}

View File

@ -1,7 +1,10 @@
package com.chaozhanggui.system.cashierservice.entity;
import lombok.ToString;
import java.io.Serializable;
@ToString
public class TbPrintMachine implements Serializable {
private Integer id;
@ -34,6 +37,15 @@ public class TbPrintMachine implements Serializable {
private String vendorId;
private String productId;
private String config;
public String getConfig() {
return config;
}
public void setConfig(String config) {
this.config = config;
}
private static final long serialVersionUID = 1L;

View File

@ -1,7 +1,10 @@
package com.chaozhanggui.system.cashierservice.entity;
import lombok.ToString;
import java.io.Serializable;
@ToString
public class TbPrintMachineWithBLOBs extends TbPrintMachine implements Serializable {
private String config;

View File

@ -1,9 +1,13 @@
package com.chaozhanggui.system.cashierservice.entity;
import lombok.Getter;
import java.io.Serializable;
import java.util.List;
@Getter
public class TbProductWithBLOBs extends TbProduct implements Serializable {
private Object groundingSpecInfo;
private String images;
private String video;
@ -20,58 +24,34 @@ public class TbProductWithBLOBs extends TbProduct implements Serializable {
private static final long serialVersionUID = 1L;
public List<?> getSkuList() {
return skuList;
public void setGroundingSpecInfo(Object groundingSpecInfo) {
this.groundingSpecInfo = groundingSpecInfo;
}
public void setSkuList(List<?> skuList) {
this.skuList = skuList;
}
public String getImages() {
return images;
}
public void setImages(String images) {
this.images = images == null ? null : images.trim();
}
public String getVideo() {
return video;
}
public void setVideo(String video) {
this.video = video == null ? null : video.trim();
}
public String getNotice() {
return notice;
}
public void setNotice(String notice) {
this.notice = notice == null ? null : notice.trim();
}
public String getGroupSnap() {
return groupSnap;
}
public void setGroupSnap(String groupSnap) {
this.groupSnap = groupSnap == null ? null : groupSnap.trim();
}
public String getSpecInfo() {
return specInfo;
}
public void setSpecInfo(String specInfo) {
this.specInfo = specInfo == null ? null : specInfo.trim();
}
public String getSelectSpec() {
return selectSpec;
}
public void setSelectSpec(String selectSpec) {
this.selectSpec = selectSpec == null ? null : selectSpec.trim();
}

View File

@ -92,6 +92,31 @@ public class TbShopInfo implements Serializable {
private String view;
private String isCustom;
private String isReturn;
private String isMemberIn;
private String isMemberReturn;
//是否开启桌位费 0否1是
private Integer isTableFee;
//桌位费
private BigDecimal tableFee;
//就餐模式 堂食 dine-in 外带 take-out
private String eatModel;
//程序码(零点八零首页)
private String smallQrcode;
//店铺收款码
private String paymentQrcode;
private static final long serialVersionUID = 1L;
public Integer getId() {
@ -445,4 +470,76 @@ public class TbShopInfo implements Serializable {
public void setView(String view) {
this.view = view == null ? null : view.trim();
}
public String getIsCustom() {
return isCustom;
}
public void setIsCustom(String isCustom) {
this.isCustom = isCustom;
}
public String getIsReturn() {
return isReturn;
}
public void setIsReturn(String isReturn) {
this.isReturn = isReturn;
}
public String getIsMemberIn() {
return isMemberIn;
}
public void setIsMemberIn(String isMemberIn) {
this.isMemberIn = isMemberIn;
}
public String getIsMemberReturn() {
return isMemberReturn;
}
public void setIsMemberReturn(String isMemberReturn) {
this.isMemberReturn = isMemberReturn;
}
public Integer getIsTableFee() {
return isTableFee;
}
public void setIsTableFee(Integer isTableFee) {
this.isTableFee = isTableFee;
}
public BigDecimal getTableFee() {
return tableFee;
}
public void setTableFee(BigDecimal tableFee) {
this.tableFee = tableFee;
}
public String getEatModel() {
return eatModel;
}
public void setEatModel(String eatModel) {
this.eatModel = eatModel;
}
public String getSmallQrcode() {
return smallQrcode;
}
public void setSmallQrcode(String smallQrcode) {
this.smallQrcode = smallQrcode;
}
public String getPaymentQrcode() {
return paymentQrcode;
}
public void setPaymentQrcode(String paymentQrcode) {
this.paymentQrcode = paymentQrcode;
}
}

View File

@ -0,0 +1,176 @@
package com.chaozhanggui.system.cashierservice.entity;
import java.io.Serializable;
import java.util.Date;
/**
*
* @TableName tb_shop_msg_state
*/
public class TbShopMsgState implements Serializable {
/**
*
*/
private Integer id;
/**
*
*/
private Integer shopId;
/**
*
*/
private Integer type;
/**
*
*/
private Integer state;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
private static final long serialVersionUID = 1L;
/**
*
*/
public Integer getId() {
return id;
}
/**
*
*/
public void setId(Integer id) {
this.id = id;
}
/**
*
*/
public Integer getShopId() {
return shopId;
}
/**
*
*/
public void setShopId(Integer shopId) {
this.shopId = shopId;
}
/**
*
*/
public Integer getType() {
return type;
}
/**
*
*/
public void setType(Integer type) {
this.type = type;
}
/**
*
*/
public Integer getState() {
return state;
}
/**
*
*/
public void setState(Integer state) {
this.state = state;
}
/**
*
*/
public Date getCreateTime() {
return createTime;
}
/**
*
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/**
*
*/
public Date getUpdateTime() {
return updateTime;
}
/**
*
*/
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
TbShopMsgState other = (TbShopMsgState) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getShopId() == null ? other.getShopId() == null : this.getShopId().equals(other.getShopId()))
&& (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()))
&& (this.getState() == null ? other.getState() == null : this.getState().equals(other.getState()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getShopId() == null) ? 0 : getShopId().hashCode());
result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
result = prime * result + ((getState() == null) ? 0 : getState().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", shopId=").append(shopId);
sb.append(", type=").append(type);
sb.append(", state=").append(state);
sb.append(", createTime=").append(createTime);
sb.append(", updateTime=").append(updateTime);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}

View File

@ -0,0 +1,129 @@
package com.chaozhanggui.system.cashierservice.entity;
import java.util.Date;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.io.Serializable;
/**
* (TbShopPermission)表实体类
*
* @author makejava
* @since 2024-09-14 17:08:48
*/
@SuppressWarnings("serial")
public class TbShopPermission extends Model<TbShopPermission> {
private Integer id;
//权限类型staff 员工
private String type;
//权限名称
private String label;
//权限code为了区分采用汉语拼音
private String code;
//层级
private Integer level;
//上级ID
private Integer parentId;
//是否重要 重要对应页面红色
private Integer isImportant;
//排序
private Integer sort;
private Date createTime;
private Date updateTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public Integer getLevel() {
return level;
}
public void setLevel(Integer level) {
this.level = level;
}
public Integer getParentId() {
return parentId;
}
public void setParentId(Integer parentId) {
this.parentId = parentId;
}
public Integer getIsImportant() {
return isImportant;
}
public void setIsImportant(Integer isImportant) {
this.isImportant = isImportant;
}
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
/**
* 获取主键值
*
* @return 主键值
*/
@Override
protected Serializable pkVal() {
return this.id;
}
}

View File

@ -0,0 +1,77 @@
package com.chaozhanggui.system.cashierservice.entity;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.io.Serializable;
/**
* 店铺员工权限关联表(TbShopStaffPermission)表实体类
*
* @author makejava
* @since 2024-09-14 17:07:33
*/
@SuppressWarnings("serial")
public class TbShopStaffPermission extends Model<TbShopStaffPermission> {
private Integer id;
//权限ID
private Integer permissionId;
//员工ID
private Integer staffId;
//店铺ID
private Integer shopId;
//用户ID
private Integer userId;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getPermissionId() {
return permissionId;
}
public void setPermissionId(Integer permissionId) {
this.permissionId = permissionId;
}
public Integer getStaffId() {
return staffId;
}
public void setStaffId(Integer staffId) {
this.staffId = staffId;
}
public Integer getShopId() {
return shopId;
}
public void setShopId(Integer shopId) {
this.shopId = shopId;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
/**
* 获取主键值
*
* @return 主键值
*/
@Override
protected Serializable pkVal() {
return this.id;
}
}

View File

@ -34,6 +34,16 @@ public class TbShopTable implements Serializable {
private Long updatedAt;
private String qrcode;
public String getQrcode() {
return qrcode;
}
public void setQrcode(String qrcode) {
this.qrcode = qrcode;
}
private static final long serialVersionUID = 1L;
public Integer getId() {

View File

@ -21,6 +21,10 @@ public class TbShopUserFlow implements Serializable {
private String type;
private String isReturn;
private String remark;
private static final long serialVersionUID = 1L;
public Integer getId() {
@ -86,4 +90,20 @@ public class TbShopUserFlow implements Serializable {
public void setType(String type) {
this.type = type == null ? null : type.trim();
}
public String getIsReturn() {
return isReturn;
}
public void setIsReturn(String isReturn) {
this.isReturn = isReturn;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}

View File

@ -0,0 +1,115 @@
package com.chaozhanggui.system.cashierservice.entity;
import com.baomidou.mybatisplus.extension.activerecord.Model;
/**
* 版本管理(TbVersion)表实体类
*
* @author ww
* @since 2024-08-28 11:22:09
*/
@SuppressWarnings("serial")
public class TbVersion extends Model<TbVersion> {
private Integer id;
//PCAPP;
private String source;
//ios;android;
private String type;
//版本号
private String version;
//是否强制更新 0 1
private Integer isUp;
//更新提示内容
private String message;
//下载地址
private String url;
//选中 0否 1是
private Integer sel;
//创建时间
private Long createdAt;
//更新时间
private Long updatedAt;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public Integer getIsUp() {
return isUp;
}
public void setIsUp(Integer isUp) {
this.isUp = isUp;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public Integer getSel() {
return sel;
}
public void setSel(Integer sel) {
this.sel = sel;
}
public Long getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Long createdAt) {
this.createdAt = createdAt;
}
public Long getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(Long updatedAt) {
this.updatedAt = updatedAt;
}
}

View File

@ -0,0 +1,22 @@
package com.chaozhanggui.system.cashierservice.entity.dto;
import lombok.Data;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.NotNull;
@Data
public class ProductStatusDTO {
@NotNull
private Integer productId;
@NotNull
private Integer shopId;
@NotNull
@Range(min = 0, max = 1)
private Integer state;
// 0上下架 1售罄
@Range(min = 0, max = 1)
@NotNull
private Integer type;
}

View File

@ -0,0 +1,18 @@
package com.chaozhanggui.system.cashierservice.entity.dto;
import lombok.Data;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
@Data
public class ProductStockDTO {
@NotNull
private Integer shopId;
@NotNull
private Integer productId;
@NotNull
@Min(0)
private Integer stock;
}

View File

@ -0,0 +1,12 @@
package com.chaozhanggui.system.cashierservice.entity.dto;
import lombok.Data;
import javax.validation.constraints.NotNull;
@Data
public class QuerySpecDTO {
@NotNull
private Integer shopId;
private Integer productId;
}

View File

@ -0,0 +1,23 @@
package com.chaozhanggui.system.cashierservice.entity.dto;
import lombok.Data;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
@Data
public class UpdateVipDTO {
@NotNull
private Integer shopId;
@NotEmpty
private String tableId;
@NotNull
private String masterId;
private Integer vipUserId;
@NotNull
@Range(min = 0, max = 1)
private Integer type;
}

View File

@ -0,0 +1,14 @@
package com.chaozhanggui.system.cashierservice.entity.dto;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class VipPayDTO {
private Integer orderId;
private Integer vipUserId;
private BigDecimal payAmount;
private BigDecimal discountAmount;
}

View File

@ -28,4 +28,9 @@ public class OrderPo {
private String remark;
private BigDecimal discountRatio;
private BigDecimal discountAmount;
}

View File

@ -5,7 +5,6 @@ import lombok.Data;
@Data
public class CartVo {
private String productId;
private String masterId;
private String shopId;
private Integer skuId;
private Integer number;
@ -15,4 +14,7 @@ public class CartVo {
private String uuid;
private String type;
private Integer cartId;
private String masterId;
private String tableId;
private Integer vipUserId;
}

View File

@ -0,0 +1,17 @@
package com.chaozhanggui.system.cashierservice.entity.vo;
import com.chaozhanggui.system.cashierservice.entity.TbShopTable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
@EqualsAndHashCode(callSuper = true)
@Data
public class TbShopTableVO extends TbShopTable {
private Integer userId;
private String masterId;
private Integer orderId;
private String orderNo;
private BigDecimal orderAmount;
}

View File

@ -1,7 +1,10 @@
package com.chaozhanggui.system.cashierservice.interceptor;
import com.chaozhanggui.system.cashierservice.annotation.LimitSubmit;
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
import com.chaozhanggui.system.cashierservice.entity.dto.VipPayDTO;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.model.PaymentReq;
import com.chaozhanggui.system.cashierservice.util.RedisUtils;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
@ -13,6 +16,7 @@ import org.springframework.core.LocalVariableTableParameterNameDiscoverer;
import org.springframework.stereotype.Component;
import java.lang.reflect.Method;
import java.util.List;
@Component
@Aspect
@ -36,6 +40,7 @@ public class LimitSubmitAspect {
Method method = ((MethodSignature) joinPoint.getSignature()).getMethod();
Object[] args= joinPoint.getArgs();
String orderId=orderId(method,args);
//获取注解信息
LimitSubmit limitSubmit = method.getAnnotation(LimitSubmit.class);
@ -44,7 +49,7 @@ public class LimitSubmitAspect {
int submitTimeLimiter = limitSubmit.limit();
String key = getRedisKey(joinPoint, redisKey, String.valueOf(args[0]));
String key = getRedisKey(joinPoint, redisKey, orderId);
Object result = redisUtil.get(key);
log.info("开始锁定资源信息" + key);
@ -79,9 +84,11 @@ public class LimitSubmitAspect {
Method method = ((MethodSignature) joinPoint.getSignature()).getMethod();
Object[] args= joinPoint.getArgs();
String orderId=orderId(method,args);
LimitSubmit limitSubmit = method.getAnnotation(LimitSubmit.class);
String redisKey = limitSubmit.key();
String key = getRedisKey1(joinPoint, redisKey, String.valueOf(args[0]));
String key = getRedisKey1(joinPoint, redisKey,orderId);
log.info("正常释放了锁资源" + key);
// 延时 1s 释放
try {
@ -104,7 +111,8 @@ public class LimitSubmitAspect {
LimitSubmit limitSubmit = method.getAnnotation(LimitSubmit.class);
String redisKey = limitSubmit.key();
Object[] args= joinPoint.getArgs();
String key = getRedisKey1(joinPoint, redisKey, String.valueOf(args[0]));
String orderId=orderId(method,args);
String key = getRedisKey1(joinPoint, redisKey, orderId);
log.info("发生异常释放了锁资源" + key);
// 延时 1s 释放
try {
@ -158,4 +166,47 @@ public class LimitSubmitAspect {
}
return key.toString();
}
private String orderId(Method method,Object[] args){
String orderId=null;
if("scanpay".equals(method.getName())||
"accountPay".equals(method.getName())||
"memberScanPay".equals(method.getName())||
"cashPay".equals(method.getName())||
"bankPay".equals(method.getName())){
Object o=args[3];
if(o instanceof PaymentReq){
orderId=((PaymentReq)o).getOrderId();
}
}else if("vipPay".equals(method.getName())){
Object o=args[3];
if(o instanceof VipPayDTO){
orderId=((VipPayDTO)o).getOrderId().toString();
}
}else if("quickPay".equals(method.getName())) {
Object o=args[4];
if(o instanceof String){
orderId=o.toString();
}
}else if ("returnOrder".equals(method.getName())) {
Object o=args[3];
if(o instanceof List){
orderId= ((List<TbOrderDetail>)o).get(0).getOrderId().toString();
}
}else if("pcscanpay".equals(method.getName())){
Object o=args[1];
if(o instanceof PaymentReq){
orderId=((PaymentReq)o).getOrderId();
}
}
return orderId;
}
}

View File

@ -37,7 +37,7 @@ public class SignInterceptor implements HandlerInterceptor {
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
String requestURI = request.getRequestURI();
String requestUri = request.getRequestURI();
if (HttpMethod.OPTIONS.toString().equals(request.getMethod())) {
response.setStatus(HttpServletResponse.SC_OK);
@ -45,6 +45,10 @@ public class SignInterceptor implements HandlerInterceptor {
return true;
}
if (requestUri.contains("/version/pcDownload")) {
return true;
}
String token=request.getHeader("token");
String loginName=request.getHeader("loginName");
String clientType=request.getHeader("clientType");

View File

@ -18,6 +18,7 @@ public class WebAppConfigurer implements WebMvcConfigurer {
.addPathPatterns("/**")
.excludePathPatterns("/login/login")
.excludePathPatterns("/login/getPhone")
.excludePathPatterns("/login/findVersion")
.excludePathPatterns("/cloudPrinter/print")
.excludePathPatterns("/cloudPrinter/handoverPrint")
.excludePathPatterns("/data/handoverData")
@ -26,6 +27,13 @@ public class WebAppConfigurer implements WebMvcConfigurer {
.excludePathPatterns("/qrcode/getscanCode")
.excludePathPatterns("/order/sendMessage")
.excludePathPatterns("/order/getOrderById")
.excludePathPatterns("/data/handoverprint");
.excludePathPatterns("/data/handoverprint")
.excludePathPatterns("/pay/pcscanpay")
.excludePathPatterns("/pay/openId")
.excludePathPatterns("/pay/createOrder")
.excludePathPatterns("/pay/queryOrderPay")
;
}
}

View File

@ -0,0 +1,29 @@
package com.chaozhanggui.system.cashierservice.mapper;
import com.chaozhanggui.system.cashierservice.entity.TbShopMsgState;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
/**
* @author Administrator
* @description 针对表tb_shop_msg_state的数据库操作Mapper
* @createDate 2024-08-12 14:27:26
* @Entity com.chaozhanggui.system.cashierservice.entity.TbShopMsgState
*/
public interface TbShopMsgStateMapper {
int deleteByPrimaryKey(Long id);
int insert(TbShopMsgState record);
int insertSelective(TbShopMsgState record);
TbShopMsgState selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(TbShopMsgState record);
int updateByPrimaryKey(TbShopMsgState record);
@Select("select * from tb_shop_msg_state where shop_id=#{shopId} and type=#{type};")
TbShopMsgState selectByType(@Param("type") Integer type, @Param("shopId") Integer shopId);
}

View File

@ -35,6 +35,10 @@ public class OrderDetailPO implements Serializable {
private String outNumber;
private String discountAmount;
private String discountAdio;
@Data
public static class Detail implements Serializable{
@ -55,7 +59,9 @@ public class OrderDetailPO implements Serializable {
}
public OrderDetailPO(String merchantName, String printType, String masterId, String orderNo, String tradeDate, String operator, String receiptsAmount, String balance, String payType, String integral, List<Detail> detailList, String remark) {
public OrderDetailPO(String merchantName, String printType, String masterId, String orderNo, String tradeDate, String operator, String receiptsAmount, String balance, String payType, String integral, List<Detail> detailList, String remark,
String discountAmount,String discountAdio
) {
this.merchantName = merchantName;
this.printType = printType;
this.masterId = masterId;
@ -68,5 +74,7 @@ public class OrderDetailPO implements Serializable {
this.integral = integral;
this.detailList = detailList;
this.remark = remark;
this.discountAmount=discountAmount;
this.discountAdio=discountAdio;
}
}

View File

@ -0,0 +1,33 @@
package com.chaozhanggui.system.cashierservice.model;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
public class PaymentReq implements Serializable {
private String orderId;
private BigDecimal payAmount;
private BigDecimal discountAmount;
private String authCode;
private String memberId;
private String memberAccount;
private String memberCode;
private String payType;
private String userId;
private String shopId;
}

View File

@ -0,0 +1,7 @@
package com.chaozhanggui.system.cashierservice.mybatis;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
public interface MPCashierCartMapper extends BaseMapper<TbCashierCart> {
}

View File

@ -0,0 +1,8 @@
package com.chaozhanggui.system.cashierservice.mybatis;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
public interface MPOrderDetailMapper extends BaseMapper<TbOrderDetail> {
}

View File

@ -0,0 +1,8 @@
package com.chaozhanggui.system.cashierservice.mybatis;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
import com.chaozhanggui.system.cashierservice.entity.TbPrintMachine;
public interface MpPrintMachineMapper extends BaseMapper<TbPrintMachine> {
}

View File

@ -0,0 +1,8 @@
package com.chaozhanggui.system.cashierservice.mybatis;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
import com.chaozhanggui.system.cashierservice.entity.TbShopTable;
public interface MpShopTableMapper extends BaseMapper<TbShopTable> {
}

View File

@ -0,0 +1,7 @@
package com.chaozhanggui.system.cashierservice.mybatis;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chaozhanggui.system.cashierservice.entity.TbShopUserFlow;
public interface MpShopUserFlowMapper extends BaseMapper<TbShopUserFlow> {
}

View File

@ -0,0 +1,13 @@
package com.chaozhanggui.system.cashierservice.mybatis;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chaozhanggui.system.cashierservice.entity.TbShopUser;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import java.math.BigDecimal;
public interface MpShopUserMapper extends BaseMapper<TbShopUser> {
@Update("update tb_shop_user set amount=amount-#{orderAmount}, consume_amount=consume_amount+#{orderAmount} where id=#{vipUserId} and amount-#{orderAmount} >= 0")
long decrBalance(@Param("vipUserId") Integer vipUserId, @Param("orderAmount") BigDecimal orderAmount);
}

View File

@ -0,0 +1,15 @@
package com.chaozhanggui.system.cashierservice.mybatis;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chaozhanggui.system.cashierservice.entity.TbVersion;
/**
* 版本管理(TbVersion)表数据库访问层
*
* @author ww
* @since 2024-08-28 11:22:09
*/
public interface TbVersionMapper extends BaseMapper<TbVersion> {
}

View File

@ -0,0 +1,179 @@
package com.chaozhanggui.system.cashierservice.rabbit;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.dao.TbShopInfoMapper;
import com.chaozhanggui.system.cashierservice.dao.TbUserInfoMapper;
import com.chaozhanggui.system.cashierservice.entity.TbShopInfo;
import com.chaozhanggui.system.cashierservice.entity.TbUserInfo;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
@Slf4j
@Component
@RabbitListener(queues = {RabbitConstants.BALANCE_QUEUE_PUT})
@Service
public class BalanceConsumer {
// @Value("${wx.balance.appId}")
private static String appId="wxd88fffa983758a30" ;
// @Value("${wx.balance.secrete}")
private static String secrete="a34a61adc0602118b49400baa8812454" ;
// @Value("${wx.balance.warnMsgTmpId}")
private static String msgTmpId = "AV-KybUHaK3KtFVLqpy6PHccHBS7XeX__mOM4RbufnQ";
static LinkedHashMap<String,String> linkedHashMap=new LinkedHashMap<>();
static {
linkedHashMap.put("40001","获取 access_token 时 AppSecret 错误,或者 access_token 无效。请开发者认真比对 AppSecret 的正确性,或查看是否正在为恰当的公众号调用接口");
linkedHashMap.put("40003","不合法的 OpenID ,请开发者确认 OpenID (该用户)是否已关注公众号,或是否是其他公众号的 OpenID");
linkedHashMap.put("40014","不合法的 access_token ,请开发者认真比对 access_token 的有效性(如是否过期),或查看是否正在为恰当的公众号调用接口");
linkedHashMap.put("40037","不合法的 template_id");
linkedHashMap.put("43101","用户未订阅消息");
linkedHashMap.put("43107","订阅消息能力封禁");
linkedHashMap.put("43108","并发下发消息给同一个粉丝");
linkedHashMap.put("45168","命中敏感词");
linkedHashMap.put("47003","参数错误");
}
@Autowired
TbUserInfoMapper tbUserInfoMapper;
@Autowired
TbShopInfoMapper tbShopInfoMapper;
public static String getAccessToken() {
String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET";
url = url.replace("APPID", appId).replace("APPSECRET", secrete);
// url = url.replace("APPID", "wxd88fffa983758a30").replace("APPSECRET", "a34a61adc0602118b49400baa8812454");
String result = HttpUtil.get(url);
JSONObject jsonObject = JSON.parseObject(result);
return jsonObject.getString("access_token");
}
public static JSONObject sendTemplateMsg(String templateId, String toUserOpenId,String shopName,String amount,String balance,String type,String date ) {
log.info("开始发送微信模板消息, 接收用户openId: {},templateId:{},shopName:{},amount:{},balance:{},type:{},date:{}", toUserOpenId,templateId, shopName,amount,balance,type,date);
String accessToken = getAccessToken();
JSONObject data = new JSONObject();
data.put("touser", toUserOpenId);
data.put("template_id", templateId);
data.put("page", "index");
// 设置消息内容
JSONObject thing3 = new JSONObject();
thing3.put("value",shopName );
JSONObject amount1=new JSONObject();
amount1.put("value",amount);
JSONObject amount2=new JSONObject();
amount2.put("value",balance);
JSONObject thing4=new JSONObject();
thing4.put("value",type);
JSONObject time5=new JSONObject();
time5.put("value",date);
data.put("data", new JSONObject().fluentPut("thing3", thing3).fluentPut("amount1", amount1).fluentPut("amount2",amount2).fluentPut("thing4",thing4).fluentPut("time5",time5));
log.info("微信模板消息请求参数 request:{}",data.toString());
String response= HttpRequest.post("https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=".concat(accessToken)).body(data.toString()).execute().body();
log.info("微信模板消息发送成功,响应内容:{}",response);
JSONObject resObj=JSONObject.parseObject(response);
if(ObjectUtil.isNotEmpty(resObj)&&ObjectUtil.isNotNull(resObj)&&"0".equals(resObj.get("errcode")+"")){
return resObj;
}
throw new RuntimeException(linkedHashMap.getOrDefault(resObj.get("errcode") + "", "未知错误"));
}
@RabbitHandler
public void listener(String message) {
try {
JSONObject object=JSONObject.parseObject(message);
String shopId=object.getString("shopId");
BigDecimal amount=object.getBigDecimal("amount").setScale(2, RoundingMode.DOWN);
BigDecimal balance=object.getBigDecimal("balance").setScale(2, RoundingMode.DOWN);
String type=object.getString("type");
Date time=object.getDate("time");
String userId=object.getString("userId");
TbShopInfo shopInfo= tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(shopId));
if(ObjectUtil.isNull(shopInfo)){
log.info("没有对应的店铺信息");
return;
}
TbUserInfo userInfo= tbUserInfoMapper.selectByPrimaryKey(Integer.valueOf(userId));
if(ObjectUtil.isNull(userInfo)||ObjectUtil.isNull(userInfo.getMiniAppOpenId())){
log.info("没有对应的openId");
return;
}
String toUserOpenId=userInfo.getMiniAppOpenId();
try {
JSONObject resObj=sendTemplateMsg(msgTmpId, toUserOpenId, shopInfo.getShopName(),amount.toPlainString(),balance.toPlainString(),type,convertDate(time));
log.info("会员变动消息发送返回:{}",resObj.toString());
}catch (Exception e) {
log.error("发送失败, openId:{}, msg: {}", toUserOpenId, e.getMessage());
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static String convertDate(Date date){
SimpleDateFormat sdf4 = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
return sdf4.format(new Date());
}
public static void main(String[] args) {
//
sendTemplateMsg("AV-KybUHaK3KtFVLqpy6PHccHBS7XeX__mOM4RbufnQ","or1l862a5N_W6eoL1-sJeewpOjZw","测试店铺",new BigDecimal(0.01).toPlainString(),new BigDecimal(6.21).toPlainString(),"充值",convertDate(new Date()));
}
}

View File

@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.bean.ShopWxMsgTypeEnum;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.util.*;
@ -93,9 +94,10 @@ public class ConsMsgConsumer {
}
List<TbProskuCon> tbProskuCons = tbProskuConMapper.selectBySkuIdAndShopId(skuId, shopId);
// List<TbProskuCon> tbProskuCons = tbProskuConMapper.selectBySkuIdAndShopId(skuId, shopId);
List<TbProskuCon> tbProskuCons = tbProskuConMapper.selectBySkuIdAndShopIdAngCheck(skuId, shopId);
if (Objects.isNull(tbProskuCons) || tbProskuCons.size() <= 0) {
log.info("耗材信息未配置");
log.info("耗材信息未配置或未开启校验");
return;
}
@ -122,7 +124,8 @@ public class ConsMsgConsumer {
log.info("耗材名称: {}, conwarning:{},stockNumber:{}",tbConsInfo.getConName(),
tbConsInfo.getConWarning(),tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume()));
if (N.egt(tbConsInfo.getConWarning(), tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume()))) {
List<TbUserShopMsg> tbUserShopMsgs = tbUserShopMsgMapper.selectAllByShopId(tbConsInfo.getShopId());
List<TbShopOpenId> tbUserShopMsgs = shopOpenIdMapper
.selectStateByShopIdAndType(product.getShopId(), ShopWxMsgTypeEnum.CONSUMABLES_MSG.getType());
log.info("待推送openId列表: {}", tbUserShopMsgs);
if (Objects.nonNull(tbUserShopMsgs) && tbUserShopMsgs.size()>0) {
tbUserShopMsgs.parallelStream().forEach(tbUserShopMsg->{
@ -132,7 +135,8 @@ public class ConsMsgConsumer {
log.info("开始推送耗材模板消息rediskey{}", value);
if (Objects.isNull(value)) {
JSONObject jsonObject = wxAccountUtil.sendStockWarnMsg("耗材库存不足", tbConsInfo.getConName(),
tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume()).toBigInteger().intValue(), tbUserShopMsg.getOpenId());
tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume()).toBigInteger().intValue(), tbUserShopMsg.getOpenId(),
ShopWxMsgTypeEnum.CONSUMABLES_MSG, shopId);
if (jsonObject != null) {
log.info("写入redis:{}",key);
redisUtil.saveMessage(key, "1", 30 * 60);

View File

@ -0,0 +1,460 @@
package com.chaozhanggui.system.cashierservice.rabbit;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.model.CategoryInfo;
import com.chaozhanggui.system.cashierservice.model.OrderDetailPO;
import com.chaozhanggui.system.cashierservice.mybatis.MPOrderDetailMapper;
import com.chaozhanggui.system.cashierservice.mybatis.MpPrintMachineMapper;
import com.chaozhanggui.system.cashierservice.rabbit.print.PrinterHandler;
import com.chaozhanggui.system.cashierservice.util.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
@Slf4j
@Component
@Service
public class PrintConsumer {
@Autowired
TbShopUserMapper tbShopUserMapper;
@Autowired
private TbOrderInfoMapper tbOrderInfoMapper;
@Autowired
private TbPrintMachineMapper tbPrintMachineMapper;
@Autowired
private TbCashierCartMapper tbCashierCartMapper;
@Autowired
private TbProductSkuMapper tbProductSkuMapper;
@Autowired
private TbShopInfoMapper tbShopInfoMapper;
@Autowired
private TbProductMapper tbProductMapper;
@Autowired
private TbOrderDetailMapper tbOrderDetailMapper;
@Autowired
private RedisUtil redisUtils;
private final RedisTemplate<String, Object> redisTemplate;
@Autowired
private MpPrintMachineMapper mpPrintMachineMapper;
@Autowired
private MPOrderDetailMapper mPOrderDetailMapper;
private final PrinterHandler printerHandler;
public PrintConsumer(RedisTemplate<String, Object> redisTemplate, PrinterHandler printerHandler) {
this.redisTemplate = redisTemplate;
this.printerHandler = printerHandler;
}
@RabbitListener(queues = {RabbitConstants.QUEUE_PRINT_DISHES})
public void printDishesListener(String msg) {
try {
log.info("打印消息mq 接收到打印菜品消息,消息内容: {}", msg);
JSONObject jsonObject = JSONObject.parseObject(msg);
Integer orderId = jsonObject.getInteger("orderId");
JSONArray orderDetailIds = jsonObject.getJSONArray("orderDetailIds");
Boolean isReturn = jsonObject.getBoolean("isReturn");
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(orderId);
Utils.checkValueUnReturn(orderInfo, "订单信息不存在");
List<TbOrderDetail> orderDetails = new ArrayList<>();
for (Object orderDetail : orderDetailIds) {
orderDetails.add(JSONObject.parseObject(orderDetail.toString(), TbOrderDetail.class));
}
if (orderDetails.isEmpty()) {
return;
}
getPrintMachine(Integer.valueOf(orderInfo.getShopId()), "cash").forEach(machine -> {
log.info("打印机信息: {}", machine);
printerHandler.handleRequest(machine, isReturn, orderInfo, orderDetails);
});
} catch (Exception e) {
log.warn("打印菜品失败", e);
}
}
@RabbitListener(queues = {RabbitConstants.QUEUE_PRINT_PLACE})
public void printPlaceListener(JSONObject jsonObject) {
try {
log.info("打印消息mq 接收到打印结算单消息,消息内容: {}", jsonObject);
Integer orderId = jsonObject.getInteger("orderId");
Boolean isReturn = jsonObject.getBoolean("isReturn");
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(orderId);
Utils.checkValueUnReturn(orderInfo, "订单信息不存在");
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getShopId()));
Utils.checkValueUnReturn(shopInfo, "店铺信息不存在");
getPrintMachine(shopInfo.getId(), "cash").forEach(machine -> {
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(orderInfo.getId());
printerHandler.handleRequest(machine, isReturn, orderInfo, tbOrderDetails);
// printPlaceTicket(isReturn, machine, orderInfo, shopInfo);
});
} catch (Exception e) {
log.warn("打印菜品失败", e);
}
}
private boolean checkMachineModel(String type, TbPrintMachine machine) {
Utils.checkValueUnReturn(machine, "打印机为null");
JSONObject config = JSONObject.parseObject(machine.getConfig());
String model = config.getString("model");
return type.equals(model);
}
private List<TbPrintMachine> getPrintMachine(Integer shopId, String subType) {
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(shopId);
if (ObjectUtil.isEmpty(shopInfo)) {
log.error("店铺信息不存在");
return new ArrayList<>();
}
List<TbPrintMachine> list = mpPrintMachineMapper.selectList(new LambdaQueryWrapper<TbPrintMachine>()
.eq(TbPrintMachine::getStatus, 1)
.eq(TbPrintMachine::getShopId, shopId)
.eq(TbPrintMachine::getSubType, subType)
.eq(TbPrintMachine::getConnectionType, "network"));
if (list.isEmpty()) {
log.error("店铺未配置打印机店铺id: {}", shopId);
return list;
}
log.info("打印机列表: {}", list);
return list;
}
/**
* 打印菜品单
*
* @param isReturn 是否退款单
*/
private void printDishesTicket(boolean isReturn, TbPrintMachine tbPrintMachineWithBLOBs, TbOrderDetail item, TbOrderInfo orderInfo, List<CategoryInfo> categoryInfos) {
log.info("开始打印一菜一品票据,商品名:{}", item.getProductName());
if (item.getProductId().equals(-999)) {
return;
}
String categoryId = tbProductMapper.selectByPrimaryKey(item.getProductId()).getCategoryId();
TbProductSkuWithBLOBs sku = tbProductSkuMapper.selectByPrimaryKey(item.getProductSkuId());
if (sku == null) {
log.error("商品不存在, id: {}", item.getProductSkuId());
return;
}
long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
if (count == 0) {
log.warn("分类未添加菜品: {} : {}", item.getProductName(), sku.getSpecSnap());
return;
}
String remark = StrUtil.isNotBlank(sku.getSpecSnap()) ? sku.getSpecSnap() : "";
item.setRemark(remark);
String data;
String voiceJson;
if (isReturn) {
data = PrinterUtils.getPrintData("return",
StrUtil.isBlank(orderInfo.getTableName()) ? orderInfo.getMasterId() : orderInfo.getTableName(),
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), item.getProductName(), Math.abs(item.getNum()), remark);
voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
} else {
data = PrinterUtils.getPrintData("", orderInfo.getMasterId(),
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), item.getProductName(),
item.getNum(), remark);
voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
}
}
/**
* 打印结算单
*/
private void printPlaceTicket(boolean isReturn, TbPrintMachine printMachine, TbOrderInfo orderInfo, TbShopInfo shopInfo) {
log.info("打印机信息: {}", printMachine);
JSONObject config = JSONObject.parseObject(printMachine.getConfig());
String model = config.getString("model");
if (!"normal".equals(model)) {
log.info("当前打印机非小票打印机, {}", printMachine);
return;
}
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(orderInfo.getId());
if (!tbOrderDetails.isEmpty()) {
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
tbOrderDetails.parallelStream().forEach(it -> {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap();
}
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), it.getPriceAmount().toPlainString(), remark);
detailList.add(detail);
});
String balance = "0";
if ("deposit".equals(orderInfo.getPayType())) {
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMemberId()));
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
balance = user.getAmount().toPlainString();
}
}
if (!detailList.isEmpty()) {
if (isReturn) {
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印",
ObjectUtil.isEmpty(orderInfo.getMasterId()) ||
ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(),
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
"【POS-1】001", orderInfo.getPayAmount().toPlainString(), balance, orderInfo.getPayType(),
"0", detailList, orderInfo.getRemark(), null, null);
String printType = "退款单";
String data = PrinterUtils.getCashPrintData(detailPO, printType, "return");
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 1, 1, printMachine.getAddress(), data);
} else {
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印",
orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(),
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
"【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance,
(ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()),
"0", detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount() != null ? orderInfo.getDiscountAmount().toPlainString() : null,
orderInfo.getDiscountRatio() != null ? orderInfo.getDiscountRatio().toPlainString() : null);
detailPO.setOutNumber(orderInfo.getOutNumber());
String printType = "结算单";
String data = PrinterUtils.getCashPrintData(detailPO, printType, orderInfo.getOrderType());
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, 1, printMachine.getAddress(), data);
}
}
}
}
private void fePrinter(TbPrintMachine tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
String orderId = orderInfo.getId().toString();
switch (tbPrintMachineWithBLOBs.getSubType()) {
case "label": //标签打印机
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
cashierCarts.parallelStream().forEach(it -> {
String categoryId;
if (ObjectUtil.isEmpty(it.getCategoryId())) {
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
} else {
categoryId = it.getCategoryId();
}
Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
log.info("获取当前类别是否未打印类别:{}", count);
if (count > 0) {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap();
}
for (int i = 0; i < it.getNumber(); i++) {
FeieyunPrintUtil.printLabelMsg(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getTableName(), it.getName(), 1, DateUtils.getTimes(new Date(orderInfo.getCreatedAt())), it.getSalePrice().toPlainString(), remark);
}
}
});
}
break;
case "cash": //小票打印机
switch (model) {
case "normal": //普通出单
if ("return".equals(orderInfo.getOrderType())) {
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
tbOrderDetails.parallelStream().forEach(it -> {
String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
log.info("获取当前类别是否未打印类别:{}", count);
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap();
}
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), it.getPriceAmount().toPlainString(), remark);
detailList.add(detail);
});
String balance = "0";
if ("deposit".equals(orderInfo.getPayType())) {
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMemberId()));
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
balance = user.getAmount().toPlainString();
}
}
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
// OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList);
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount().toPlainString(), orderInfo.getDiscountRatio().toPlainString());
String printType = "退款单";
String data = PrinterUtils.getCashPrintData(detailPO, printType, "return");
// String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
// PrinterUtils.printTickets(voiceJson,1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
}
}
} else {
cashierCarts = cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
cashierCarts.parallelStream().forEach(it -> {
String categoryId;
if (ObjectUtil.isEmpty(it.getCategoryId())) {
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
} else {
categoryId = it.getCategoryId();
}
Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
if (count > 0) {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap();
}
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark);
detailList.add(detail);
}
});
String balance = "0";
if ("deposit".equals(orderInfo.getPayType())) {
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMemberId()));
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
balance = user.getAmount().toPlainString();
}
}
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), "0", detailList, orderInfo.getRemark(), null, null);
String printType = "结算单";
if ("return".equals(orderInfo.getOrderType())) {
printType = "退款单";
}
FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType);
}
}
}
break;
case "one": //一菜一品
if (!orderInfo.getStatus().equals("unpaid")) {
return;
}
cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
cashierCarts.parallelStream().forEach(it -> {
String categoryId;
if (ObjectUtil.isEmpty(it.getCategoryId())) {
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
} else {
categoryId = it.getCategoryId();
}
Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
if (count > 0) {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap();
}
FeieyunPrintUtil.getPrintData(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
}
});
}
break;
case "category": //分类出单
break;
}
break;
case "kitchen": //出品打印机
break;
}
}
}

View File

@ -1,28 +1,29 @@
package com.chaozhanggui.system.cashierservice.rabbit;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.model.CategoryInfo;
import com.chaozhanggui.system.cashierservice.model.OrderDetailPO;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.chaozhanggui.system.cashierservice.util.DateUtils;
import com.chaozhanggui.system.cashierservice.util.FeieyunPrintUtil;
import com.chaozhanggui.system.cashierservice.util.JSONUtil;
import com.chaozhanggui.system.cashierservice.util.PrinterUtils;
import com.chaozhanggui.system.cashierservice.mybatis.MpPrintMachineMapper;
import com.chaozhanggui.system.cashierservice.util.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.annotation.RabbitListeners;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
@Slf4j
@Component
@ -49,11 +50,23 @@ public class PrintMechineConsumer {
@Autowired
private TbOrderDetailMapper tbOrderDetailMapper;
@Autowired
private RedisUtil redisUtils;
private final RedisTemplate<String, Object> redisTemplate;
@Autowired
private MpPrintMachineMapper mpPrintMachineMapper;
public PrintMechineConsumer(RedisTemplate<String, Object> redisTemplate) {
this.redisTemplate = redisTemplate;
}
@RabbitHandler
public void listener(String message) {
String orderId = message;
log.info("接收到打印mq消息: {}", message);
try {
@ -79,15 +92,15 @@ public class PrintMechineConsumer {
}
list.parallelStream().forEach(it->{
list.forEach(it -> {
if (!"network".equals(it.getConnectionType())) {
log.error("非网络打印机:{},{}",it.getAddress(),it.getConnectionType());
log.error("非网络打印机:{},{}", it.getAddress(), it.getConnectionType());
return;
}
if (!"1".equals(it.getStatus().toString())) {
log.error("打印机状态异常:{},{}",it.getAddress(),it.getStatus());
log.error("打印机状态异常:{},{}", it.getAddress(), it.getStatus());
return;
}
@ -99,21 +112,20 @@ public class PrintMechineConsumer {
String feet = config.getString("feet");
String autoCut = config.getString("autoCut");
List<CategoryInfo> categoryInfos=JSONUtil.parseJSONStr2TList(config.getJSONArray("categoryList").toString(),CategoryInfo.class);
List<CategoryInfo> categoryInfos = JSONUtil.parseJSONStr2TList(config.getJSONArray("categoryList").toString(), CategoryInfo.class);
switch (it.getContentType()){
switch (it.getContentType()) {
case "yxyPrinter":
yxyPrinter(it,model,orderInfo,shopInfo,printerNum,categoryInfos);
yxyPrinter(it, model, orderInfo, shopInfo, printerNum, categoryInfos);
break;
case "fePrinter":
fePrinter(it,model,orderInfo,shopInfo,printerNum,categoryInfos);
fePrinter(it, model, orderInfo, shopInfo, printerNum, categoryInfos);
break;
}
});
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
@ -121,14 +133,16 @@ public class PrintMechineConsumer {
/**
* 博时结云打印机
*
* @param tbPrintMachineWithBLOBs
* @param model
* @param orderInfo
* @param shopInfo
* @param printerNum
*/
private void yxyPrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs,String model,TbOrderInfo orderInfo,TbShopInfo shopInfo,String printerNum, List<CategoryInfo> categoryInfos){
String orderId=orderInfo.getId().toString();
private void yxyPrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model,
TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
String orderId = orderInfo.getId().toString();
switch (tbPrintMachineWithBLOBs.getSubType()) {
@ -139,17 +153,17 @@ public class PrintMechineConsumer {
case "normal": //普通出单
if("return".equals(orderInfo.getOrderType())){
List<TbOrderDetail> tbOrderDetails=tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
if(ObjectUtil.isNotEmpty(tbOrderDetails)&&tbOrderDetails.size()>0){
if ("return".equals(orderInfo.getOrderType())) {
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
tbOrderDetails.parallelStream().forEach(it->{
String categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
tbOrderDetails.parallelStream().forEach(it -> {
String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
Long count= categoryInfos.stream().filter(c->
Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
log.info("获取当前类别是否未打印类别:{}",count);
log.info("获取当前类别是否未打印类别:{}", count);
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
@ -171,23 +185,25 @@ public class PrintMechineConsumer {
}
if(ObjectUtil.isNotEmpty(detailList)&&detailList.size()>0){
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId())||ObjectUtil.isNull(orderInfo.getMasterId())?orderInfo.getTableName():orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList,orderInfo.getRemark());
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getPayAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark(), null, null);
String printType="退款单";
String printType = "退款单";
String data= PrinterUtils.getCashPrintData(detailPO,printType,"return");
String data = PrinterUtils.getCashPrintData(detailPO, printType, "return");
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson,1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
PrinterUtils.printTickets(voiceJson, 1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
}
}
return;
}
List<TbOrderDetail> tbOrderDetails=tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
if(ObjectUtil.isNotEmpty(tbOrderDetails)&&tbOrderDetails.size()>0) {
if ((!orderInfo.getStatus().equals("closed"))) {
return;
}
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
tbOrderDetails.stream().forEach(it -> {
String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
@ -215,71 +231,40 @@ public class PrintMechineConsumer {
balance = user.getAmount().toPlainString();
}
}
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), "0", detailList, orderInfo.getRemark());
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印",
orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(),
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
"【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance,
(ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()),
"0", detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount() != null ? orderInfo.getDiscountAmount().toPlainString() : null,
orderInfo.getDiscountRatio() != null ? orderInfo.getDiscountRatio().toPlainString() : null);
// OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList);
detailPO.setOutNumber(orderInfo.getOutNumber());
String printType = "结算单";
String data = PrinterUtils.getCashPrintData(detailPO, printType, orderInfo.getOrderType());
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
}
}
break;
case "one": //一菜一品
if("return".equals(orderInfo.getOrderType())){
List<TbOrderDetail> details= tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
if(ObjectUtil.isNotEmpty(details)&&details.size()>0){
details.parallelStream().forEach(it->{
String categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
Long count= categoryInfos.stream().filter(c->
c.getId().toString().equals(categoryId)
).count();
if(count>0){
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap();
}
String data = PrinterUtils.getPrintData("return",orderInfo.getPayType().equals("wx_lite")?orderInfo.getTableName():orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(), it.getNum(), remark);
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson,3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
}
});
}
// if (StrUtil.isNotBlank(orderInfo.getUseType()) && orderInfo.getUseType().equals("postPay")
// && (!orderInfo.getStatus().equals("unpaid"))) {
// return;
// }
if ("return".equals(orderInfo.getOrderType())) {
printReturnTicket(tbPrintMachineWithBLOBs, orderInfo, printerNum, categoryInfos, orderId);
return;
}else {
tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
tbOrderDetails.parallelStream().forEach(it -> {
String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
log.info("获取当前类别是否未打印类别:{}", count);
if(count>0){
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap();
}
String data = PrinterUtils.getPrintData("",orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(), it.getNum(), remark);
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson,3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
}
});
}
} else {
printTicket(Integer.valueOf(orderId), categoryInfos, tbPrintMachineWithBLOBs, orderInfo);
// printNormalTicket(tbPrintMachineWithBLOBs, orderInfo, printerNum, categoryInfos, orderId);
}
break;
case "category": //分类出单
@ -292,39 +277,291 @@ public class PrintMechineConsumer {
}
}
private void printTicket(Integer orderId, List<CategoryInfo> categoryInfos, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, TbOrderInfo orderInfo) {
String printKey = RedisCst.ORDER_PRINT_PRO + orderId;
AtomicReference<Set<Object>> printProductSet = new AtomicReference<>(redisTemplate.opsForSet().members(printKey));
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(orderId);
// 重置打印数据
redisTemplate.delete(printKey);
if (!tbOrderDetails.isEmpty()) {
tbOrderDetails.forEach(it -> {
log.info("开始打印一菜一品票据,:{}", it.getProductName());
String categoryId = tbProductMapper.selectByPrimaryKey(it.getProductId()).getCategoryId();
long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
log.info("获取当前类别是否未打印类别:{}", count);
if (count > 0) {
// 统计已打数量
int printerNum = 0;
boolean isReturn = false;
String key = RedisCst.ORDER_PRINT + orderId + ":" + it.getProductId() + ":" + it.getProductSkuId();
String info = redisUtils.getMessage(key);
redisUtils.saveMessage(key, String.valueOf(it.getNum()), 60 * 60 * 24);
// 删除已打印数据
if (printProductSet.get() != null) {
printProductSet.set(printProductSet.get().stream().filter(r -> {
TbOrderDetail detail = (TbOrderDetail) r;
return !detail.getProductSkuId().equals(it.getProductSkuId()) || !detail.getProductId().equals(it.getProductId());
}).collect(Collectors.toSet()));
}
if (info != null) {
isReturn = it.getNum() - Integer.parseInt(info) < 0;
printerNum = it.getNum() - Integer.parseInt(info);
}else {
printerNum = it.getNum();
}
private void fePrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs,String model,TbOrderInfo orderInfo,TbShopInfo shopInfo,String printerNum, List<CategoryInfo> categoryInfos){
String orderId=orderInfo.getId().toString();
log.info("已打印数量, {}, 未打印数量: {}", info, printerNum);
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(it.getProductSkuId());
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap();
}
// 将已打印信息加入redis
it.setRemark(remark);
redisTemplate.opsForSet().add(printKey, it);
redisTemplate.expire(printKey, 24, TimeUnit.HOURS);
// 已打印不再打印
if (info != null && it.getNum() - Integer.parseInt(info) == 0) {
return;
}
String data;
String voiceJson;
if (isReturn) {
data = PrinterUtils.getPrintData("return",
StrUtil.isBlank(orderInfo.getTableName()) ? orderInfo.getMasterId() : orderInfo.getTableName(),
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(), Math.abs(printerNum), remark);
voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
} else {
data = PrinterUtils.getPrintData("", orderInfo.getMasterId(),
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(),
printerNum, remark);
voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
}
}
});
}
// 已删除的商品打印退款信息
if (printProductSet.get() != null) {
printProductSet.get().forEach(item -> {
log.info("已删除订单,打印退款票据, {}", item);
TbOrderDetail orderDetail = (TbOrderDetail) item;
String data = PrinterUtils.getPrintData("return",
StrUtil.isBlank(orderInfo.getTableName()) ? orderInfo.getMasterId() : orderInfo.getTableName(),
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), orderDetail.getProductName(), orderDetail.getNum(), orderDetail.getRemark());
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
String key = RedisCst.ORDER_PRINT + orderId + ":" + orderDetail.getProductId() + ":" + orderDetail.getProductSkuId();
log.info("删除商品数量记录key, {}", key);
redisUtils.deleteByKey(key);
});
}
}
/**
* 打印退款订单
* @param orderId 订单id
* @param tbOrderDetails 现有订单
*/
public void printReturnTicket(Integer orderId, List<TbOrderDetail> tbOrderDetails) {
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(orderId);
List<TbPrintMachine> list = mpPrintMachineMapper.selectList(new LambdaUpdateWrapper<TbPrintMachine>()
.eq(TbPrintMachine::getContentType, "yxyPrinter")
.eq(TbPrintMachine::getConnectionType, "network")
.eq(TbPrintMachine::getSubType, "cash")
.eq(TbPrintMachine::getStatus, 1)
.eq(TbPrintMachine::getShopId, orderInfo.getShopId()));
String printKey = RedisCst.ORDER_PRINT_PRO + orderId;
Set<Object> printProductSet = redisTemplate.opsForSet().members(printKey);
Set<Object> printProductSetCopy = redisTemplate.opsForSet().members(printKey);
log.info("-------------------开始打印退款订单,打印机列表: {}", list);
log.info("-------------------待打印数据: {}", printProductSet);
if (printProductSet != null && !printProductSet.isEmpty()) {
// 过滤出已经删除的订单
if (tbOrderDetails != null && !tbOrderDetails.isEmpty()) {
for (TbOrderDetail it : tbOrderDetails) {
printProductSet = printProductSet.stream().filter(r -> {
TbOrderDetail detail = (TbOrderDetail) r;
return !detail.getProductSkuId().equals(it.getProductSkuId()) || !detail.getProductId().equals(it.getProductId());
}).collect(Collectors.toSet());
printProductSetCopy = printProductSet.stream().filter(r -> {
TbOrderDetail detail = (TbOrderDetail) r;
return detail.getProductSkuId().equals(it.getProductSkuId()) && detail.getProductId().equals(it.getProductId());
}).collect(Collectors.toSet());
}
redisTemplate.delete(printKey);
for (Object o : printProductSetCopy) {
redisTemplate.opsForSet().add(printKey, o);
}
}else if (tbOrderDetails != null) {
redisTemplate.delete(printKey);
}
log.info("-------------------打印机数量{}", list.size());
for (TbPrintMachine machine : list) {
String config = machine.getConfig();
if (config != null) {
JSONObject jsonObject = JSONObject.parseObject(config);
if (!"one".equals(jsonObject.getString("model"))) {
continue;
}
}
log.info("-------------------商品数量{}", printProductSet.size());
printProductSet.forEach(item -> {
log.info("已删除订单,打印退款票据, {}", item);
TbOrderDetail orderDetail = (TbOrderDetail) item;
String data = PrinterUtils.getPrintData("return",
StrUtil.isBlank(orderInfo.getTableName()) ? orderInfo.getMasterId() : orderInfo.getTableName(),
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), orderDetail.getProductName(), orderDetail.getNum(), orderDetail.getRemark());
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, 1, machine.getAddress(), data);
String key = RedisCst.ORDER_PRINT + orderId + ":" + orderDetail.getProductId() + ":" + orderDetail.getProductSkuId();
log.info("删除商品数量记录key, {}", key);
redisUtils.deleteByKey(key);
});
}
}
}
/**
* 普通出菜单打印
*/
private void printNormalTicket(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, TbOrderInfo orderInfo, String printerNum, List<CategoryInfo> categoryInfos, String orderId) {
List<TbOrderDetail> tbOrderDetails;
tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
if (ObjectUtil.isNotEmpty(tbOrderDetails) && !tbOrderDetails.isEmpty()) {
tbOrderDetails.parallelStream().forEach(it -> {
// 已经打印过的菜品不再打印
if ("postPay".equals(orderInfo.getUseType()) && isPrint(it, orderInfo.getId())) {
return;
}
String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
log.info("获取当前类别是否未打印类别:{}", count);
if (count > 0) {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap();
}
String data = PrinterUtils.getPrintData("", orderInfo.getMasterId(),
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(),
it.getNum(), remark);
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
}
});
}
}
/**
* 退款单打印
*/
private void printReturnTicket(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, TbOrderInfo orderInfo, String printerNum, List<CategoryInfo> categoryInfos, String orderId) {
List<TbOrderDetail> details = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
if (ObjectUtil.isNotEmpty(details) && details.size() > 0) {
details.parallelStream().forEach(it -> {
String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
if (count > 0) {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap();
}
String data = PrinterUtils.getPrintData("return", orderInfo.getPayType().equals("wx_lite") ? orderInfo.getTableName() : orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(), it.getNum(), remark);
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
}
});
}
}
/**
* 判断商品是否已打票
*
* @return true 已打 false 未打
*/
private boolean isPrint(TbOrderDetail orderDetail, Integer orderId) {
String key = RedisCst.ORDER_PRINT + orderId + ":" + orderDetail.getProductId() + ":" + orderDetail.getProductSkuId();
String info = redisUtils.getMessage(key);
redisUtils.saveMessage(key, String.valueOf(orderDetail.getNum()), 60 * 60 * 24);
if (info == null) {
return false;
}
orderDetail.setNum(orderDetail.getNum() - Integer.parseInt(info));
return true;
}
private void fePrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
String orderId = orderInfo.getId().toString();
switch (tbPrintMachineWithBLOBs.getSubType()) {
case "label": //标签打印机
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(),"final");
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
cashierCarts.parallelStream().forEach(it->{
cashierCarts.parallelStream().forEach(it -> {
String categoryId;
if(ObjectUtil.isEmpty(it.getCategoryId())){
categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
if (ObjectUtil.isEmpty(it.getCategoryId())) {
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
} else {
categoryId = it.getCategoryId();
}
Long count= categoryInfos.stream().filter(c->
Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
log.info("获取当前类别是否未打印类别:{}",count);
log.info("获取当前类别是否未打印类别:{}", count);
if(count>0) {
if (count > 0) {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap();
}
for(int i=0;i<it.getNumber();i++){
for (int i = 0; i < it.getNumber(); i++) {
FeieyunPrintUtil.printLabelMsg(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getTableName(), it.getName(), 1, DateUtils.getTimes(new Date(orderInfo.getCreatedAt())), it.getSalePrice().toPlainString(), remark);
}
}
@ -336,17 +573,17 @@ public class PrintMechineConsumer {
switch (model) {
case "normal": //普通出单
if("return".equals(orderInfo.getOrderType())){
List<TbOrderDetail> tbOrderDetails=tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
if(ObjectUtil.isNotEmpty(tbOrderDetails)&&tbOrderDetails.size()>0){
if ("return".equals(orderInfo.getOrderType())) {
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
tbOrderDetails.parallelStream().forEach(it->{
String categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
tbOrderDetails.parallelStream().forEach(it -> {
String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
Long count= categoryInfos.stream().filter(c->
Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
log.info("获取当前类别是否未打印类别:{}",count);
log.info("获取当前类别是否未打印类别:{}", count);
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
@ -368,20 +605,27 @@ public class PrintMechineConsumer {
}
if(ObjectUtil.isNotEmpty(detailList)&&detailList.size()>0){
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
// OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList);
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId())||ObjectUtil.isNull(orderInfo.getMasterId())?orderInfo.getTableName():orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList,orderInfo.getRemark());
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(),
"普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId())
? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(),
DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
"【POS-1】001", orderInfo.getOrderAmount().toPlainString(),
balance, orderInfo.getPayType(), "0",
detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount() == null ? null : orderInfo.getDiscountAmount().toPlainString(),
orderInfo.getDiscountRatio() == null ? null : orderInfo.getDiscountRatio().toPlainString());
String printType="退款单";
String printType = "退款单";
String data= PrinterUtils.getCashPrintData(detailPO,printType,"return");
// String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
// PrinterUtils.printTickets(voiceJson,1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
String data = PrinterUtils.getCashPrintData(detailPO, printType, "return");
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson,1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
}
}
}else {
} else {
cashierCarts = cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
@ -420,7 +664,7 @@ public class PrintMechineConsumer {
}
}
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), "0", detailList, orderInfo.getRemark());
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), "0", detailList, orderInfo.getRemark(), null, null);
String printType = "结算单";
if ("return".equals(orderInfo.getOrderType())) {
@ -437,30 +681,38 @@ public class PrintMechineConsumer {
break;
case "one": //一菜一品
cashierCarts = tbCashierCartMapper.selectByOrderId(orderId,"final");
if (orderInfo.getPayType() != null
&& "postPay".equals(orderInfo.getPayType())
&& !orderInfo.getStatus().equals("unpaid")) {
return;
}
cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
cashierCarts.parallelStream().forEach(it -> {
String categoryId;
if(ObjectUtil.isEmpty(it.getCategoryId())){
categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
if (ObjectUtil.isEmpty(it.getCategoryId())) {
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
} else {
categoryId = it.getCategoryId();
}
Long count= categoryInfos.stream().filter(c->
Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
if(count>0){
if (count > 0) {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap();
}
FeieyunPrintUtil.getPrintData(tbPrintMachineWithBLOBs.getAddress(),orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
FeieyunPrintUtil.getPrintData(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
}
});
}

View File

@ -126,5 +126,44 @@ public class RabbitConfig {
@Bean
public DirectExchange balance_msg_Exchange_Register() {
return new DirectExchange(RabbitConstants.BALANCE_PUT);
}
@Bean
public Queue queuebalance_msg_Register() {
return new Queue(RabbitConstants.BALANCE_QUEUE_PUT, true); //队列持久
}
@Bean
public Binding bindingbalance_msg_Register() {
return BindingBuilder.bind(queuebalance_msg_Register()).to(balance_msg_Exchange_Register()).with(RabbitConstants.BALANCE_ROUTINGKEY_PUT);
}
// 打印出票
@Bean
DirectExchange printExchange() {
return new DirectExchange(RabbitConstants.EXCHANGE_PRINT);
}
@Bean
Queue printDishesQueue() {
return new Queue(RabbitConstants.QUEUE_PRINT_DISHES);
}
@Bean
Binding bindingDishedPrint(Queue printDishesQueue, DirectExchange printExchange) {
return BindingBuilder.bind(printDishesQueue).to(printExchange).with(RabbitConstants.ROUTING_KEY_PRINT_DISHES);
}
@Bean
Queue printPlaceQueue() {
return new Queue(RabbitConstants.QUEUE_PRINT_PLACE);
}
@Bean
Binding bindingPlacePrint(Queue printPlaceQueue, DirectExchange printExchange) {
return BindingBuilder.bind(printPlaceQueue).to(printExchange).with(RabbitConstants.ROUTING_KEY_PRINT_PLACE);
}
}

View File

@ -47,4 +47,24 @@ public interface RabbitConstants {
String EXCHANGE_STOCK_RECORD = "exchange.stock.record";
String ROUTING_STOCK_RECORD_SALE = "routing.stock.record.sale";
// 库存记录
public static final String QUEUE_STOCK_RECORD = "queue.stock.record";
public static final String ROUTING_STOCK_RECORD= "routing.stock.record";
public static final String BALANCE_PUT="balance_put";
public static final String BALANCE_QUEUE_PUT="balance_queue_put";
public static final String BALANCE_ROUTINGKEY_PUT="balance_routingkey_put";
// 打印出票
String EXCHANGE_PRINT = "exchange.print";
// 菜品打印
String QUEUE_PRINT_DISHES = "queue.dishes.print";
String ROUTING_KEY_PRINT_DISHES = "routing.dishes.print";
// 下单打印
String QUEUE_PRINT_PLACE = "queue.place.order.print";
String ROUTING_KEY_PRINT_PLACE = "routing.place.order.print";
}

View File

@ -37,8 +37,6 @@ public class RabbitProducer implements RabbitTemplate.ConfirmCallback {
public void cons(String content){
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
rabbitTemplate.convertAndSend(RabbitConstants.CONS_COLLECT_PUT, RabbitConstants.CONS_COLLECT_ROUTINGKEY_PUT, content, correlationId);
@ -52,6 +50,14 @@ public class RabbitProducer implements RabbitTemplate.ConfirmCallback {
}
public void balance(String content){
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
rabbitTemplate.convertAndSend(RabbitConstants.BALANCE_PUT, RabbitConstants.BALANCE_ROUTINGKEY_PUT, content, correlationId);
}
@Override
public void confirm(CorrelationData correlationData, boolean ack, String cause) {
logger.info(" 回调id:" + correlationData);
@ -71,4 +77,9 @@ public class RabbitProducer implements RabbitTemplate.ConfirmCallback {
public <T> void sendStockSaleMsg(T data) {
sendMsg(RabbitConstants.EXCHANGE_STOCK_RECORD, RabbitConstants.ROUTING_STOCK_RECORD_SALE, data, "商品售出增加库存记录");
}
public <T> void sendStockRecordMsg(T data) {
sendMsg(RabbitConstants.EXCHANGE_STOCK_RECORD, RabbitConstants.ROUTING_STOCK_RECORD, data, "增加库存记录");
}
}

View File

@ -0,0 +1,40 @@
package com.chaozhanggui.system.cashierservice.rabbit.print;
import com.chaozhanggui.system.cashierservice.dao.TbProductMapper;
import com.chaozhanggui.system.cashierservice.dao.TbProductSkuMapper;
import com.chaozhanggui.system.cashierservice.dao.TbShopUserMapper;
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
import com.chaozhanggui.system.cashierservice.entity.TbOrderInfo;
import com.chaozhanggui.system.cashierservice.entity.TbPrintMachine;
import com.chaozhanggui.system.cashierservice.model.OrderDetailPO;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public class FeiPrinter extends PrinterHandler{
public FeiPrinter(TbProductMapper productMapper, TbProductSkuMapper tbProductSkuMapper, TbShopUserMapper tbShopUserMapper) {
super("Feie", productMapper, tbProductSkuMapper, tbShopUserMapper);
}
@Override
protected void returnDishesPrint(TbOrderInfo orderInfo, TbOrderDetail orderDetail, TbPrintMachine machine) {
}
@Override
protected void normalDishesPrint(TbOrderInfo orderInfo, TbOrderDetail orderDetail, TbPrintMachine machine) {
}
@Override
protected void returnOrderPrint(TbOrderInfo orderInfo, TbPrintMachine machine, String balance, List<OrderDetailPO.Detail> detailList) {
}
@Override
protected void normalOrderPrint(TbOrderInfo orderInfo, TbPrintMachine machine, String balance, List<OrderDetailPO.Detail> detailList) {
}
}

View File

@ -0,0 +1,35 @@
package com.chaozhanggui.system.cashierservice.rabbit.print;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import javax.annotation.PostConstruct;
import java.util.List;
@Configuration
public class PrintConfig {
private final YxyPrinter yxyPrinter;
private final FeiPrinter feiPrinter;
public PrintConfig(YxyPrinter yxyPrinter, FeiPrinter feiPrinter) {
this.yxyPrinter = yxyPrinter;
this.feiPrinter = feiPrinter;
}
// 初始化责任链
@PostConstruct
public void initChain() {
yxyPrinter.setNextPrinter(feiPrinter);
feiPrinter.setNextPrinter(null);
}
@Bean
@Primary
public PrinterHandler printerHandler() {
return yxyPrinter;
}
}

View File

@ -0,0 +1,153 @@
package com.chaozhanggui.system.cashierservice.rabbit.print;
import cn.hutool.core.lang.func.Func0;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.dao.TbProductMapper;
import com.chaozhanggui.system.cashierservice.dao.TbProductSkuMapper;
import com.chaozhanggui.system.cashierservice.dao.TbShopUserMapper;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.model.CategoryInfo;
import com.chaozhanggui.system.cashierservice.model.OrderDetailPO;
import com.chaozhanggui.system.cashierservice.util.DateUtils;
import com.chaozhanggui.system.cashierservice.util.JSONUtil;
import com.chaozhanggui.system.cashierservice.util.PrinterUtils;
import com.chaozhanggui.system.cashierservice.util.Utils;
import lombok.Setter;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Slf4j
@ToString
public abstract class PrinterHandler {
@Setter
protected PrinterHandler nextPrinter;
protected String printerBrand;
private final TbProductMapper tbProductMapper;
private final TbProductSkuMapper tbProductSkuMapper;
private final TbShopUserMapper tbShopUserMapper;
public PrinterHandler(String printerBrand, TbProductMapper productMapper, TbProductSkuMapper tbProductSkuMapper, TbShopUserMapper tbShopUserMapper) {
this.printerBrand = printerBrand;
this.tbProductMapper = productMapper;
this.tbProductSkuMapper = tbProductSkuMapper;
this.tbShopUserMapper = tbShopUserMapper;
}
protected void print(TbPrintMachine machine, boolean isReturn, TbOrderInfo orderInfo, List<TbOrderDetail> tbOrderDetailList) {
String configStr = machine.getConfig();
Utils.checkValueUnReturn(configStr, "打印机配置为空");
JSONObject config = JSONObject.parseObject(configStr);
String model = JSONObject.parseObject(configStr).getString("model");
List<CategoryInfo> categoryInfos = JSONUtil.parseJSONStr2TList(config.getJSONArray("categoryList").toString(), CategoryInfo.class);
switch (model) {
case "one":
tbOrderDetailList.forEach(item -> {
log.info("开始打印退单菜品,商品名:{}", item.getProductName());
// 台位费不打印
if (item.getProductId().equals(-999)) {
log.info("台位费商品,不打印");
return;
}
String categoryId = tbProductMapper.selectByPrimaryKey(item.getProductId()).getCategoryId();
TbProductSkuWithBLOBs sku = tbProductSkuMapper.selectByPrimaryKey(item.getProductSkuId());
if (sku == null) {
log.error("商品不存在, id: {}", item.getProductSkuId());
return;
}
long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
if (count == 0) {
log.warn("分类未添加菜品: {} : {}", item.getProductName(), sku.getSpecSnap());
return;
}
String remark = StrUtil.isNotBlank(sku.getSpecSnap()) ? sku.getSpecSnap() : "";
item.setRemark(remark);
String data;
String voiceJson;
if (isReturn) {
returnDishesPrint(orderInfo, item, machine);
} else {
normalDishesPrint(orderInfo, item, machine);
}
});
break;
case "normal":
if (tbOrderDetailList.isEmpty()) {
log.info("待打印列表为空");
return;
}
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
tbOrderDetailList.forEach(it -> {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(it.getProductSkuId());
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap();
}
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), it.getPriceAmount().toPlainString(), remark);
detailList.add(detail);
});
String balance = "0";
if ("deposit".equals(orderInfo.getPayType())) {
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMemberId()));
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
balance = user.getAmount().toPlainString();
}
}
if (!detailList.isEmpty()) {
if (isReturn) {
returnOrderPrint(orderInfo, machine, balance, detailList);
} else {
normalOrderPrint(orderInfo, machine, balance, detailList);
}
}
default:
log.warn("未知打印类型: {}", model);
}
}
public void handleRequest(TbPrintMachine machine, boolean isReturn, TbOrderInfo orderInfo, List<TbOrderDetail> tbOrderDetailList) {
if (canHandleRequest(machine.getContentType(), machine.getConnectionType())) {
log.info("打印机: {}, 是否退款单: {}, 订单信息: {}, 订单详情信息: {}", machine, isReturn, orderInfo, tbOrderDetailList);
print(machine, isReturn, orderInfo, tbOrderDetailList);
} else if (nextPrinter != null) {
log.info("当前打印机无法处理: {},将请求传递给下一个打印机:{}...", this, nextPrinter);
nextPrinter.handleRequest(machine, isReturn, orderInfo, tbOrderDetailList);
} else {
log.warn("未找到匹配打印机");
}
}
protected abstract void returnDishesPrint(TbOrderInfo orderInfo, TbOrderDetail orderDetail, TbPrintMachine machine);
protected abstract void normalDishesPrint(TbOrderInfo orderInfo, TbOrderDetail orderDetail, TbPrintMachine machine);
protected abstract void returnOrderPrint(TbOrderInfo orderInfo, TbPrintMachine machine, String balance, List<OrderDetailPO.Detail> detailList);
protected abstract void normalOrderPrint(TbOrderInfo orderInfo, TbPrintMachine machine, String balance, List<OrderDetailPO.Detail> detailList);
// 抽象方法子类实现判断能否处理请求
boolean canHandleRequest(String currentBrand, String connectType) {
log.info("handle判断是否可处理: {}, 连接类型: {}, handler类型: {}", currentBrand, connectType, printerBrand);
Utils.checkValueUnReturn(printerBrand, "打印机品牌未赋值");
return printerBrand.equals(currentBrand) && "network".equals(connectType);
}
}

View File

@ -0,0 +1,86 @@
package com.chaozhanggui.system.cashierservice.rabbit.print;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.chaozhanggui.system.cashierservice.dao.TbProductMapper;
import com.chaozhanggui.system.cashierservice.dao.TbProductSkuMapper;
import com.chaozhanggui.system.cashierservice.dao.TbShopInfoMapper;
import com.chaozhanggui.system.cashierservice.dao.TbShopUserMapper;
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
import com.chaozhanggui.system.cashierservice.entity.TbOrderInfo;
import com.chaozhanggui.system.cashierservice.entity.TbPrintMachine;
import com.chaozhanggui.system.cashierservice.entity.TbShopInfo;
import com.chaozhanggui.system.cashierservice.model.OrderDetailPO;
import com.chaozhanggui.system.cashierservice.util.DateUtils;
import com.chaozhanggui.system.cashierservice.util.PrinterUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
@Slf4j
@Component
public class YxyPrinter extends PrinterHandler{
private final TbShopInfoMapper shopInfoMapper;
public YxyPrinter(TbShopInfoMapper shopInfoMapper, TbProductMapper productMapper, TbProductSkuMapper productSkuMapper, TbShopUserMapper shopUserMapper) {
super("yxyPrinter", productMapper, productSkuMapper, shopUserMapper);
this.shopInfoMapper = shopInfoMapper;
}
@Override
protected void returnDishesPrint(TbOrderInfo orderInfo, TbOrderDetail orderDetail, TbPrintMachine machine) {
String data = PrinterUtils.getPrintData("return",
StrUtil.isBlank(orderInfo.getTableName()) ? orderInfo.getMasterId() : orderInfo.getTableName(),
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), orderDetail.getProductName(), Math.abs(orderDetail.getNum()), orderDetail.getRemark());
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, 1, machine.getAddress(), data);
}
@Override
protected void normalDishesPrint(TbOrderInfo orderInfo, TbOrderDetail orderDetail, TbPrintMachine machine) {
String data = PrinterUtils.getPrintData("", orderInfo.getMasterId(),
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), orderDetail.getProductName(),
orderDetail.getNum(), orderDetail.getRemark());
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, 1, machine.getAddress(), data);
}
@Override
protected void returnOrderPrint(TbOrderInfo orderInfo, TbPrintMachine machine, String balance, List<OrderDetailPO.Detail> detailList) {
TbShopInfo shopInfo = shopInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getShopId()));
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印",
ObjectUtil.isEmpty(orderInfo.getMasterId()) ||
ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(),
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
"【POS-1】001", orderInfo.getPayAmount().toPlainString(), balance, orderInfo.getPayType(),
"0", detailList, orderInfo.getRemark(), null, null);
String printType = "退款单";
String data = PrinterUtils.getCashPrintData(detailPO, printType, "return");
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 1, 1, machine.getAddress(), data);
}
@Override
protected void normalOrderPrint(TbOrderInfo orderInfo, TbPrintMachine machine, String balance, List<OrderDetailPO.Detail> detailList) {
TbShopInfo shopInfo = shopInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getShopId()));
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印",
orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(),
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
"【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance,
(ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()),
"0", detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount() != null ? orderInfo.getDiscountAmount().toPlainString() : null,
orderInfo.getDiscountRatio() != null ? orderInfo.getDiscountRatio().toPlainString() : null);
detailPO.setOutNumber(orderInfo.getOutNumber());
String printType = "结算单";
String data = PrinterUtils.getCashPrintData(detailPO, printType, orderInfo.getOrderType());
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, 1, machine.getAddress(), data);
}
}

View File

@ -189,7 +189,11 @@ public class CloudPrinterService {
if(ObjectUtil.isNotEmpty(detailList)&&detailList.size()>0){
// OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList);
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId())||ObjectUtil.isNull(orderInfo.getMasterId())?orderInfo.getTableName():orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList,orderInfo.getRemark());
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印",
ObjectUtil.isEmpty(orderInfo.getMasterId())||ObjectUtil.isNull(orderInfo.getMasterId())?orderInfo.getTableName():orderInfo.getMasterId(),
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
"【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0",
detailList,orderInfo.getRemark(),null,null);
detailPO.setOutNumber(orderInfo.getOutNumber());
String printType="退款单";
@ -251,7 +255,12 @@ public class CloudPrinterService {
}
if(ObjectUtil.isNotEmpty(detailList)&&detailList.size()>0){
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp")?orderInfo.getTableName():orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance,(ObjectUtil.isEmpty(orderInfo.getPayType())||ObjectUtil.isNull(orderInfo.getPayType())?"":orderInfo.getPayType() ), "0", detailList,orderInfo.getRemark());
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印",
orderInfo.getOrderType().equals("miniapp")?orderInfo.getTableName():orderInfo.getMasterId(),
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
"【POS-1】001", orderInfo.getOrderAmount().toPlainString(),
balance, (ObjectUtil.isEmpty(orderInfo.getPayType())||ObjectUtil.isNull(orderInfo.getPayType())?"":orderInfo.getPayType() ), "0",
detailList,orderInfo.getRemark(),orderInfo.getDiscountAmount() != null ? orderInfo.getDiscountAmount().toPlainString() : null,orderInfo.getDiscountRatio() != null ? orderInfo.getDiscountRatio().toPlainString() : null);
String printType="结算单";
detailPO.setOutNumber(orderInfo.getOutNumber());
@ -439,7 +448,7 @@ public class CloudPrinterService {
if(ObjectUtil.isNotEmpty(detailList)&&detailList.size()>0){
// OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList);
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId())||ObjectUtil.isNull(orderInfo.getMasterId())?orderInfo.getTableName():orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList,orderInfo.getRemark());
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId())||ObjectUtil.isNull(orderInfo.getMasterId())?orderInfo.getTableName():orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList,orderInfo.getRemark(),null,null);
String printType="退款单";
@ -495,7 +504,12 @@ public class CloudPrinterService {
}
}
if(ObjectUtil.isNotEmpty(detailList)&&detailList.size()>0){
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp")?orderInfo.getTableName():orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance,(ObjectUtil.isEmpty(orderInfo.getPayType())||ObjectUtil.isNull(orderInfo.getPayType())?"":orderInfo.getPayType() ), "0", detailList,orderInfo.getRemark());
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印",
orderInfo.getOrderType().equals("miniapp")?orderInfo.getTableName():orderInfo.getMasterId(),
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
"【POS-1】001", orderInfo.getOrderAmount().toPlainString(),
balance,(ObjectUtil.isEmpty(orderInfo.getPayType())||ObjectUtil.isNull(orderInfo.getPayType())?"":orderInfo.getPayType() ),
"0", detailList,orderInfo.getRemark(),null,null);
String printType="结算单";
if(ispre){
printType="预结算单";

View File

@ -66,11 +66,13 @@ public class ConsService {
List<TbConsInfoFlow> consInfoFlows=new ArrayList<>();
for (TbOrderDetail orderDetail : orderDetails) {
List<TbProskuCon> proskuCons= tbProskuConMapper.selectByShopIdAndSkuIdAndProductId(orderDetail.getProductSkuId(),orderDetail.getShopId(),orderDetail.getProductId());
// List<TbProskuCon> proskuCons= tbProskuConMapper.selectByShopIdAndSkuIdAndProductId(orderDetail.getProductSkuId(),orderDetail.getShopId(),orderDetail.getProductId());
List<TbProskuCon> proskuCons= tbProskuConMapper.selectByShopIdAndSkuIdAndProductIdAndCheck(orderDetail.getProductSkuId(),orderDetail.getShopId(),orderDetail.getProductId());
if(Objects.isNull(proskuCons)||proskuCons.size()<=0){
log.info("不存在的耗材信息配置:orderId:{},skuId:{},shopId:{},productId:{}",orderDetail.getOrderId(),orderDetail.getProductSkuId(),orderDetail.getShopId(),orderDetail.getProductId());
log.info("耗材信息配置或未开启校验:orderId:{},skuId:{},shopId:{},productId:{}",orderDetail.getOrderId(),orderDetail.getProductSkuId(),orderDetail.getShopId(),orderDetail.getProductId());
continue;
}
for (TbProskuCon proskuCon : proskuCons) {
TbConsInfo tbConsInfo= tbConsInfoMapper.selectByPrimaryKey(proskuCon.getConInfoId());
if(Objects.nonNull(tbConsInfo)&&"1".equals(tbConsInfo.getStatus())){

View File

@ -273,6 +273,12 @@ public class DataService {
JSONObject config = JSONObject.parseObject(it.getConfig());
String model = config.getString("model");
if(!"normal".equals(model)){
log.error("打印机类型错误");
return;
}
List<HandoverInfo.PayInfo> list = null;
List<HandoverInfo.MemberData> memberData = null;
List<HandoverInfo.ProductCategory> productCategories = null;

View File

@ -3,9 +3,11 @@ package com.chaozhanggui.system.cashierservice.service;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.model.LoginReq;
import com.chaozhanggui.system.cashierservice.mybatis.TbVersionMapper;
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
@ -14,6 +16,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Objects;
import java.util.UUID;
@ -47,6 +50,8 @@ public class LoginService {
@Autowired
TbTokenMapper tbTokenMapper;
@Autowired
TbVersionMapper versionMapper;
@Autowired
RabbitProducer rabbitProducer;
@ -140,6 +145,17 @@ public class LoginService {
return Result.success(CodeEnum.SUCCESS, accountMap);
}
public Result findVersion() {
TbVersion pcVersion = getCurrentPcVersion();
return new Result(SUCCESS, pcVersion);
}
public TbVersion getCurrentPcVersion() {
LambdaQueryWrapper<TbVersion> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(TbVersion::getSource,"PC");
queryWrapper.eq(TbVersion::getSel,1);
return versionMapper.selectOne(queryWrapper);
}
public Result logout(String loginName, String clientType, String token, String status) {
@ -191,4 +207,23 @@ public class LoginService {
return Result.success(SUCCESS,shopInfo);
}
public Result getStaffDiscount(String token){
JSONObject jsonObject= TokenUtil.parseParamFromToken(token);
if(Objects.isNull(jsonObject)){
return Result.fail(CodeEnum.TOKENTERROR);
}
Integer staffId=Integer.valueOf(jsonObject.getString("staffId"));
TbPlussShopStaff staff= tbPlussShopStaffMapper.selectByPrimaryKey(staffId);
if(Objects.nonNull(staff)&&Objects.nonNull(staff.getMaxDiscountAmount())){
return Result.success(SUCCESS,staff.getMaxDiscountAmount());
}
return Result.success(SUCCESS, BigDecimal.ZERO);
}
}

View File

@ -5,21 +5,23 @@ import cn.hutool.core.util.RandomUtil;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.model.ScanPayReq;
import com.chaozhanggui.system.cashierservice.model.TradeQueryReq;
import com.chaozhanggui.system.cashierservice.mybatis.MpShopTableMapper;
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.chaozhanggui.system.cashierservice.thirdpay.resp.MainScanResp;
import com.chaozhanggui.system.cashierservice.thirdpay.resp.OrderReturnResp;
import com.chaozhanggui.system.cashierservice.thirdpay.resp.OrderStatusQueryResp;
import com.chaozhanggui.system.cashierservice.thirdpay.resp.PublicResp;
import com.chaozhanggui.system.cashierservice.thirdpay.service.ThirdPayService;
import com.chaozhanggui.system.cashierservice.util.*;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
@ -65,6 +67,10 @@ public class MemberService {
RestTemplate restTemplate;
@Autowired
TbActivateMapper tbActivateMapper;
@Autowired
TbmerchantAccountMapper tbmerchantAccountMapper;
@Autowired
RabbitProducer producer;
@Value("${gateway.url}")
private String gateWayUrl;
@Value("${thirdPay.payType}")
@ -74,13 +80,21 @@ public class MemberService {
@Value("${thirdPay.callBack}")
private String callBack;
@Qualifier("tbOrderInfoMapper")
@Autowired
TbmerchantAccountMapper tbmerchantAccountMapper;
private TbOrderInfoMapper tbOrderInfoMapper;
private MpShopTableMapper mpShopTableMapper;
public Result queryMember(String shopId, String phone, int page, int pageSize) {
public Result queryMember(String shopId, String phone,String isFlag, int page, int pageSize) {
PageHelperUtil.startPage(page, pageSize);
List<TbShopUser> tbShopUsers = tbShopUserMapper.selectByShopId(shopId, phone);
if(!"1".equals(isFlag)){
isFlag=null;
}
List<TbShopUser> tbShopUsers = tbShopUserMapper.selectByShopId(shopId, phone,isFlag);
PageInfo pageInfo = new PageInfo(tbShopUsers);
return Result.success(CodeEnum.SUCCESS, pageInfo);
}
@ -103,12 +117,12 @@ public class MemberService {
List<TbShopUser> tbShopUsers = tbShopUserMapper.selectByShopIdAndPhone(shopId, phone);
if (ObjectUtil.isNotEmpty(tbShopUsers)&&tbShopUsers.stream().filter(it->"1".equals(it.getIsVip().toString())).count()>0) {
if (ObjectUtil.isNotEmpty(tbShopUsers) && tbShopUsers.stream().filter(it -> "1".equals(it.getIsVip().toString())).count() > 0) {
return Result.fail(CodeEnum.MEMBERHAVED);
}
if(tbUserInfoMapper.selectCountByPhone(phone)>1){
if (tbUserInfoMapper.selectCountByPhone(phone) > 1) {
return Result.fail(CodeEnum.SAMEUSER);
}
@ -135,7 +149,7 @@ public class MemberService {
TbShopUser tbShopUser = new TbShopUser();
TbUserInfo tbUserInfo = tbUserInfoMapper.selectByPhone(phone);
if(tbUserInfo!=null){
if (tbUserInfo != null) {
tbShopUser.setUserId(tbUserInfo.getId().toString());
}
tbShopUser.setAmount(BigDecimal.ZERO);
@ -158,23 +172,19 @@ public class MemberService {
return Result.success(CodeEnum.SUCCESS);
}
@Autowired
RabbitProducer producer;
@Transactional(rollbackFor = Exception.class)
public Result memberScanPay(Map<String, Object> map,String token) {
public Result memberScanPay(Map<String, Object> map, String token) {
if (ObjectUtil.isEmpty(map) || map.size() <= 0
|| !map.containsKey("shopId") || ObjectUtil.isEmpty(map.get("shopId"))
|| !map.containsKey("memberId") || ObjectUtil.isEmpty(map.get("memberId"))
|| !map.containsKey("amount") || ObjectUtil.isEmpty(map.get("amount"))
|| !map.containsKey("authCode") || ObjectUtil.isEmpty(map.get("authCode"))
) {
return Result.fail(CodeEnum.PARAM);
}
String memberId = String.valueOf(map.get("memberId"));
String shopId = String.valueOf(map.get("shopId"));
@ -184,6 +194,32 @@ public class MemberService {
if (ObjectUtil.isEmpty(shopInfo) || shopInfo == null) {
return Result.fail(CodeEnum.SHOPINFONOEXIST);
}
// if ("1".equals(shopInfo.getIsMemberIn())) {
// if (!map.containsKey("pwd") || ObjectUtil.isEmpty(map.get("pwd"))) {
// return Result.fail(CodeEnum.PARAM);
// }
// String pwd = map.get("pwd").toString();
// String accountId = TokenUtil.parseParamFromToken(token).getString("accountId");
//
//
// TbmerchantAccount account = tbmerchantAccountMapper.selectByPrimaryKey(Integer.valueOf(accountId));
// if (Objects.isNull(account)) {
// return Result.fail(CodeEnum.ACCOUNTEIXST);
// }
//
//
// if (Objects.isNull(account.getPwd()) || ObjectUtil.isEmpty(account.getPwd())) {
// return Result.fail(CodeEnum.PWDNOSET);
// }
//
// if (!account.getPwd().equals(MD5Util.encrypt(pwd.concat(account.getAccount()).concat(account.getId().toString())))) {
// return Result.fail(CodeEnum.PWDERROE);
// }
// }
TbShopUser shopUser = tbShopUserMapper.selectByPrimaryKey(Integer.valueOf(memberId));
if (ObjectUtil.isEmpty(shopUser) || !"1".equals(shopUser.getIsVip().toString())) {
return Result.fail(CodeEnum.MEMBERNOEXIST);
@ -193,25 +229,23 @@ public class MemberService {
String qpay = null;
String payTypeCode = authCode.substring(0, 2);// 判断收款码
String wechatpay="";
String wechatpay = "";
if(Integer.valueOf(payTypeCode)>=25&&Integer.valueOf(payTypeCode)<=30){
if (Integer.valueOf(payTypeCode) >= 25 && Integer.valueOf(payTypeCode) <= 30) {
qpay = "scanCode";
}else if(Integer.valueOf(payTypeCode)>=10&&Integer.valueOf(payTypeCode)<=19){
} else if (Integer.valueOf(payTypeCode) >= 10 && Integer.valueOf(payTypeCode) <= 19) {
qpay = "scanCode";
wechatpay="wxpay";
}else if("62".equals(payTypeCode)){
wechatpay = "wxpay";
} else if ("62".equals(payTypeCode)) {
return Result.fail(CodeEnum.ERRORQR);
}else if("01".equals(payTypeCode)){
} else if ("01".equals(payTypeCode)) {
return Result.fail(CodeEnum.ERRORQR);
}else {
} else {
return Result.fail(CodeEnum.ERRORQR);
}
int count = tbShopPayTypeMapper.countSelectByShopIdAndPayType(shopId, qpay);
if (count < 1) {
return Result.fail(CodeEnum.PAYTYPENOEXIST);
@ -273,6 +307,7 @@ public class MemberService {
flow.setAmount(amount);
flow.setBalance(shopUser.getAmount());
flow.setCreateTime(new Date());
flow.setIsReturn("0");
tbShopUserFlowMapper.insert(flow);
@ -284,7 +319,6 @@ public class MemberService {
producer.putOrderCollect(jsonObject.toJSONString());
return Result.success(CodeEnum.SUCCESS, memberIn);
} else {
String status = ObjectUtil.isNotEmpty(object.getJSONObject("data")) ? object.getJSONObject("data").getString("status") : null;
@ -302,7 +336,7 @@ public class MemberService {
String orderNo = DateUtils.getSsdfTimes();
PublicResp<MainScanResp> publicResp = thirdPayService.mainScan(url, thirdApply.getAppId(), "会员充值", "会员充值", amount.setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(), wechatpay.equals("wxpay") ? thirdApply.getSmallAppid() : null, authCode, DateUtils.getSsdfTimes(), thirdApply.getStoreId(), callBack, thirdApply.getAppToken());
PublicResp<MainScanResp> publicResp = thirdPayService.mainScan(url, thirdApply.getAppId(), "会员充值", "会员充值", amount.setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(), wechatpay.equals("wxpay") ? thirdApply.getSmallAppid() : null, authCode, orderNo, thirdApply.getStoreId(), callBack, thirdApply.getAppToken());
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
if ("000000".equals(publicResp.getCode())) {
MainScanResp mainScanResp = publicResp.getObjData();
@ -326,9 +360,11 @@ public class MemberService {
flow.setAmount(amount);
flow.setBalance(shopUser.getAmount());
flow.setCreateTime(new Date());
flow.setRemark(orderNo);
flow.setIsReturn("0");
tbShopUserFlowMapper.insert(flow);
BigDecimal fl = null;
TbActivate activate = tbActivateMapper.selectByAmount(shopInfo.getId().toString(), memberIn.getAmount());
if (ObjectUtil.isNotEmpty(activate) && ObjectUtil.isNotNull(activate)) {
BigDecimal awardAmount = BigDecimal.ZERO;
@ -353,15 +389,28 @@ public class MemberService {
flow.setAmount(awardAmount);
flow.setBalance(shopUser.getAmount());
flow.setCreateTime(new Date());
flow.setIsReturn("0");
tbShopUserFlowMapper.insert(flow);
fl = awardAmount;
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("token", token);
jsonObject.put("type", "memberIn");
jsonObject.put("amount",memberIn.getAmount());
jsonObject.put("amount", memberIn.getAmount());
producer.putOrderCollect(jsonObject.toJSONString());
JSONObject baObj = new JSONObject();
baObj.put("userId", shopUser.getUserId());
baObj.put("shopId", shopInfo.getId());
baObj.put("amount", ObjectUtil.isNull(fl) ? amount : amount.add(fl));
baObj.put("balance", shopUser.getAmount());
baObj.put("type", "扫码充值");
baObj.put("time", flow.getCreateTime());
producer.balance(baObj.toString());
return Result.success(CodeEnum.SUCCESS, memberIn);
} else if ("TRADE_AWAIT".equals(mainScanResp.getState())) {
@ -382,8 +431,7 @@ public class MemberService {
}
public Result queryScanPay(String flowId,String token) {
public Result queryScanPay(String flowId, String token) {
if (ObjectUtil.isEmpty(flowId)) {
return Result.fail(CodeEnum.PARAM);
}
@ -438,6 +486,7 @@ public class MemberService {
flow.setAmount(memberIn.getAmount());
flow.setBalance(shopUser.getAmount());
flow.setCreateTime(new Date());
flow.setIsReturn("0");
tbShopUserFlowMapper.insert(flow);
return Result.success(CodeEnum.SUCCESS, memberIn);
}
@ -465,6 +514,7 @@ public class MemberService {
flow.setBizName("线下充值");
flow.setAmount(memberIn.getAmount());
flow.setBalance(shopUser.getAmount());
flow.setIsReturn("0");
flow.setCreateTime(new Date());
tbShopUserFlowMapper.insert(flow);
@ -492,6 +542,7 @@ public class MemberService {
flow.setBizName("充值活动奖励");
flow.setAmount(awardAmount);
flow.setBalance(shopUser.getAmount());
flow.setIsReturn("0");
flow.setCreateTime(new Date());
@ -502,6 +553,16 @@ public class MemberService {
producer.putOrderCollect(jsonObject.toJSONString());
JSONObject baObj = new JSONObject();
baObj.put("userId", shopUser.getUserId());
baObj.put("shopId", shopUser.getShopId());
baObj.put("amount", memberIn.getAmount().add(awardAmount));
baObj.put("balance", shopUser.getAmount());
baObj.put("type", "充值");
baObj.put("time", flow.getCreateTime());
producer.balance(baObj.toString());
tbShopUserFlowMapper.insert(flow);
}
return Result.success(CodeEnum.SUCCESS, memberIn);
@ -516,34 +577,16 @@ public class MemberService {
return Result.success(CodeEnum.SUCCESS, memberIn);
}
@Transactional(rollbackFor = Exception.class)
public Result memberAccountPay(Map<String, Object> map,String token) {
if (ObjectUtil.isEmpty(map) || map.size() <= 0
public Result memberAccountPay(Map<String, Object> map, String token) throws Exception {
if (ObjectUtil.isEmpty(map) || map.isEmpty()
|| !map.containsKey("shopId") || ObjectUtil.isEmpty(map.get("shopId"))
|| !map.containsKey("memberId") || ObjectUtil.isEmpty(map.get("memberId"))
|| !map.containsKey("amount") || ObjectUtil.isEmpty(map.get("amount"))
||!map.containsKey("pwd")||ObjectUtil.isEmpty(map.get("pwd"))
) {
return Result.fail(CodeEnum.PARAM);
}
String accountId= TokenUtil.parseParamFromToken(token).getString("accountId");
TbmerchantAccount account= tbmerchantAccountMapper.selectByPrimaryKey(Integer.valueOf(accountId));
if(Objects.isNull(account)){
return Result.fail(CodeEnum.ACCOUNTEIXST);
}
if(Objects.isNull(account.getPwd())||ObjectUtil.isEmpty(account.getPwd())){
return Result.fail(CodeEnum.PWDNOSET);
}
if(!account.getPwd().equals(MD5Util.encrypt(map.get("pwd").toString().concat(account.getAccount()).concat(account.getId().toString())))){
return Result.fail(CodeEnum.PWDERROE);
}
String memberId = String.valueOf(map.get("memberId"));
@ -554,6 +597,31 @@ public class MemberService {
if (ObjectUtil.isEmpty(shopInfo) || shopInfo == null) {
return Result.fail(CodeEnum.SHOPINFONOEXIST);
}
if ("1".equals(shopInfo.getIsMemberIn())) {
if (!map.containsKey("pwd") || ObjectUtil.isEmpty(map.get("pwd"))) {
return Result.fail(CodeEnum.PARAM);
}
String accountId = TokenUtil.parseParamFromToken(token).getString("accountId");
TbmerchantAccount account = tbmerchantAccountMapper.selectByPrimaryKey(Integer.valueOf(accountId));
if (Objects.isNull(account)) {
return Result.fail(CodeEnum.ACCOUNTEIXST);
}
if (Objects.isNull(account.getPwd()) || ObjectUtil.isEmpty(account.getPwd())) {
return Result.fail(CodeEnum.PWDNOSET);
}
if (!account.getPwd().equals(MD5Util.encrypt(map.get("pwd").toString().concat(account.getAccount()).concat(account.getId().toString())))) {
return Result.fail(CodeEnum.PWDERROE);
}
}
TbShopUser shopUser = tbShopUserMapper.selectByPrimaryKey(Integer.valueOf(memberId));
if (ObjectUtil.isEmpty(shopUser) || !"1".equals(shopUser.getIsVip().toString())) {
return Result.fail(CodeEnum.MEMBERNOEXIST);
@ -595,7 +663,9 @@ public class MemberService {
flow.setAmount(amount);
flow.setBalance(shopUser.getAmount());
flow.setCreateTime(new Date());
flow.setIsReturn("0");
tbShopUserFlowMapper.insert(flow);
BigDecimal fl = null;
TbActivate activate = tbActivateMapper.selectByAmount(shopInfo.getId().toString(), memberIn.getAmount());
if (ObjectUtil.isNotEmpty(activate) && ObjectUtil.isNotNull(activate)) {
@ -621,8 +691,11 @@ public class MemberService {
flow.setAmount(awardAmount);
flow.setBalance(shopUser.getAmount());
flow.setCreateTime(new Date());
flow.setIsReturn("0");
tbShopUserFlowMapper.insert(flow);
fl = awardAmount;
}
@ -634,10 +707,20 @@ public class MemberService {
producer.putOrderCollect(jsonObject.toJSONString());
JSONObject baObj = new JSONObject();
baObj.put("userId", shopUser.getUserId());
baObj.put("shopId", shopInfo.getId());
baObj.put("amount", ObjectUtil.isNull(fl) ? amount : amount.add(fl));
baObj.put("balance", shopUser.getAmount());
baObj.put("type", "充值");
baObj.put("time", flow.getCreateTime());
producer.balance(baObj.toString());
return Result.success(CodeEnum.SUCCESS);
}
public Result queryMemberAccount(String memberId, int page, int pageSize) {
if (ObjectUtil.isEmpty(memberId)) {
return Result.fail(CodeEnum.PARAM);
@ -650,4 +733,117 @@ public class MemberService {
}
public Result returnAccount(String token, String flowId, String remark, String amount, String pwd) {
if (ObjectUtil.isEmpty(flowId) || ObjectUtil.isNull(flowId) || ObjectUtil.isNull(amount) || ObjectUtil.isEmpty(amount)) {
return Result.fail(CodeEnum.PARAM);
}
TbShopUserFlow flow = tbShopUserFlowMapper.selectByPrimaryKey(Integer.valueOf(flowId));
if (ObjectUtil.isNull(flow) || ObjectUtil.isEmpty(flow)) {
return Result.fail(CodeEnum.USERSHOPFLOWNOEXIST);
}
if (!"0".equals(flow.getIsReturn())) {
return Result.fail(CodeEnum.ORDERRETURN);
}
if (N.gt(new BigDecimal(amount), flow.getAmount())) {
return Result.fail(CodeEnum.INPURAMOUNTERROR);
}
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(flow.getShopUserId());
if (ObjectUtil.isEmpty(user) || ObjectUtil.isNull(user)) {
return Result.fail(CodeEnum.ACCOUNTEIXST);
}
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(user.getShopId()));
if (ObjectUtil.isEmpty(shopInfo) || shopInfo == null) {
return Result.fail(CodeEnum.SHOPINFONOEXIST);
}
if ("1".equals(shopInfo.getIsMemberReturn())) {
if (ObjectUtil.isEmpty(pwd)) {
return Result.fail(CodeEnum.PARAM);
}
String accountId = TokenUtil.parseParamFromToken(token).getString("accountId");
TbmerchantAccount account = tbmerchantAccountMapper.selectByPrimaryKey(Integer.valueOf(accountId));
if (Objects.isNull(account)) {
return Result.fail(CodeEnum.ACCOUNTEIXST);
}
if (Objects.isNull(account.getPwd()) || ObjectUtil.isEmpty(account.getPwd())) {
return Result.fail(CodeEnum.PWDNOSET);
}
if (!account.getPwd().equals(MD5Util.encrypt(pwd.concat(account.getAccount()).concat(account.getId().toString())))) {
return Result.fail(CodeEnum.PWDERROE);
}
}
if (N.gt(new BigDecimal(amount), user.getAmount())) {
return Result.fail(CodeEnum.ACCOUNTBALANCEERROR);
}
if ("scanMemberIn".equals(flow.getBizCode())) {
TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(Integer.valueOf(shopInfo.getMerchantId()));
if (ObjectUtil.isEmpty(thirdApply) || ObjectUtil.isNull(thirdApply)) {
return Result.fail(CodeEnum.NOCUSTOMER);
}
String no = DateUtils.getSsdfTimes();
PublicResp<OrderReturnResp> publicResp = thirdPayService.returnOrder(url, thirdApply.getAppId(), no, null, flow.getRemark(), "充值退款", new BigDecimal(amount).setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(), callBack, null, thirdApply.getAppToken());
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
if ("000000".equals(publicResp.getCode())) {
if (!"SUCCESS".equals(publicResp.getObjData().getState()) && !publicResp.getObjData().getState().equals("ING")) {
MsgException.check(true, publicResp.getMsg());
}
} else {
MsgException.check(true, "退款渠道调用失败");
}
}
} else if ("cashMemberIn".equals(flow.getBizCode())) {
} else {
return Result.fail(CodeEnum.OPARETIONERROR);
}
user.setAmount(user.getAmount().subtract(new BigDecimal(amount)));
user.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.updateByPrimaryKey(user);
flow.setIsReturn("1");
flow.setRemark(remark);
tbShopUserFlowMapper.updateByPrimaryKey(flow);
TbShopUserFlow userFlow = new TbShopUserFlow();
userFlow.setShopUserId(user.getId());
userFlow.setBizCode("memberReturn");
userFlow.setBizName("会员退款");
userFlow.setType("-");
userFlow.setAmount(new BigDecimal(amount));
userFlow.setBalance(user.getAmount());
userFlow.setCreateTime(new Date());
userFlow.setIsReturn("1");
userFlow.setRemark(flowId);
tbShopUserFlowMapper.insert(userFlow);
JSONObject baObj = new JSONObject();
baObj.put("userId", user.getUserId());
baObj.put("shopId", user.getId());
baObj.put("amount", amount);
baObj.put("balance", user.getAmount());
baObj.put("type", "退款");
baObj.put("time", new Date());
producer.balance(baObj.toString());
return Result.success(CodeEnum.SUCCESS);
}
}

View File

@ -1,16 +1,25 @@
package com.chaozhanggui.system.cashierservice.service;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.chaozhanggui.system.cashierservice.bean.ShopWxMsgTypeEnum;
import com.chaozhanggui.system.cashierservice.bean.TableStateEnum;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.entity.dto.UpdateVipDTO;
import com.chaozhanggui.system.cashierservice.entity.po.*;
import com.chaozhanggui.system.cashierservice.entity.vo.CartVo;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.mybatis.MPCashierCartMapper;
import com.chaozhanggui.system.cashierservice.mybatis.MpShopTableMapper;
import com.chaozhanggui.system.cashierservice.rabbit.PrintMechineConsumer;
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
@ -20,16 +29,17 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import static com.chaozhanggui.system.cashierservice.sign.CodeEnum.CARTEXIST;
@ -67,6 +77,7 @@ public class OrderService {
RedisUtil redisUtil;
private final WxAccountUtil wxAccountUtil;
private final MPCashierCartMapper mpCashierCartMapper;
@Autowired
RabbitProducer producer;
@ -76,23 +87,40 @@ public class OrderService {
private final TbUserShopMsgMapper tbUserShopMsgMapper;
private final TbShopOpenIdMapper shopOpenIdMapper;
private final MpShopTableMapper mpShopTableMapper;
@Autowired
private TbProskuConMapper tbProskuConMapper;
@Autowired
TbConsInfoMapper tbConsInfoMapper;
private final TbCashierCartMapper tbCashierCartMapper;
private static ConcurrentHashMap<String, HashSet<Integer>> codeMap = new ConcurrentHashMap<>();
private static ConcurrentHashMap<String, HashSet<String>> userMap = new ConcurrentHashMap<>();
@Autowired
private ProductService productService;
@Qualifier("printMechineConsumer")
@Autowired
private PrintMechineConsumer printMechineConsumer;
@Qualifier("tbOrderDetailMapper")
@Autowired
private TbOrderDetailMapper tbOrderDetailMapper;
public OrderService(WxAccountUtil wxAccountUtil, WechatUtil wechatUtil, TbUserShopMsgMapper tbUserShopMsgMapper, TbShopOpenIdMapper shopOpenIdMapper) {
public OrderService(WxAccountUtil wxAccountUtil, MPCashierCartMapper mpCashierCartMapper, WechatUtil wechatUtil, TbUserShopMsgMapper tbUserShopMsgMapper, TbShopOpenIdMapper shopOpenIdMapper, MpShopTableMapper mpShopTableMapper, TbCashierCartMapper tbCashierCartMapper) {
this.wxAccountUtil = wxAccountUtil;
this.mpCashierCartMapper = mpCashierCartMapper;
this.wechatUtil = wechatUtil;
this.tbUserShopMsgMapper = tbUserShopMsgMapper;
this.shopOpenIdMapper = shopOpenIdMapper;
this.mpShopTableMapper = mpShopTableMapper;
this.tbCashierCartMapper = tbCashierCartMapper;
}
@Transactional(rollbackFor = Exception.class)
public Result createCart(String masterId, String productId, String shopId, Integer skuId, Integer number,
String userId, String clientType, Integer cartId, String isGift, String isPack, String uuid, String type) {
String userId, String clientType, Integer cartId, String isGift, String isPack, String uuid, String type, String tableId) {
if (Objects.isNull(number) || number < 0) {
return Result.fail(CodeEnum.NUMBER);
}
@ -121,7 +149,35 @@ public class OrderService {
return Result.fail(CodeEnum.PRODUCTSKUERROR);
}
// 台桌点单
if ((StrUtil.isNotBlank(tableId))) {
TbShopTable shopTable = mpShopTableMapper.selectOne(new LambdaUpdateWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, tableId)
.in(TbShopTable::getStatus, "idle", "using", "pending"));
if (shopTable == null) {
return Result.fail("台桌不处于开台或空闲状态");
}
}
TbCashierCart cart = cashierCartMapper.selectByPrimaryKey(cartId);
// if (cart != null && cart.getNumber() > number && StrUtil.isNotBlank(cart.getOrderId()) && StrUtil.isNotBlank(cart.getTableId())) {
// return Result.fail("此商品已经出餐不支持减少操作");
// }
// List<TbProskuCon> proskuConList= tbProskuConMapper.selectByShopIdAndSkuIdAndProductId(skuId,shopInfo.getId(),product.getId());
// if(Objects.nonNull(proskuConList)&&proskuConList.size()>0){
// for (TbProskuCon proskuCon : proskuConList) {
// if("1".equals(proskuCon.getStatus())){
// TbConsInfo consInfo= tbConsInfoMapper.selectByPrimaryKey(proskuCon.getConInfoId());
// if("1".equals(consInfo.getIsCheck())){
// if(N.gt(proskuCon.getSurplusStock(),consInfo.getStockNumber().abs().subtract(consInfo.getStockConsume().abs()))){
// return Result.fail("商品:".concat(product.getName()).concat("对应的:").concat(consInfo.getConName()).concat("耗材不足"));
// }
// }
// }
// }
// }
String exists = redisUtil.getMessage(RedisCst.ORDER_CART_EXISTS + cartId);
@ -132,6 +188,38 @@ public class OrderService {
}else if (exists != null && skuWithBLOBs.getSuit() != null && skuWithBLOBs.getSuit() != 0 && number < skuWithBLOBs.getSuit()){
redisUtil.deleteByKey(RedisCst.ORDER_CART_EXISTS + cartId);
delCart(masterId, cartId);
if (StrUtil.isNotBlank(cart.getOrderId()) && StrUtil.isNotBlank(cart.getTableId())) {
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
.notIn(TbCashierCart::getStatus, "final", "refund", "closed", "pending")
.eq(TbCashierCart::getShopId, cart.getShopId());
TbCashierCart finalCart = cart;
queryWrapper.eq(TbCashierCart::getTableId, cart.getTableId())
.and(q -> {
q.or(
query -> {
query.eq(TbCashierCart::getMasterId, finalCart.getMasterId())
.or()
.isNull(TbCashierCart::getMasterId)
.or()
.eq(TbCashierCart::getMasterId, "");
}
)
.or(query -> {
query.eq(TbCashierCart::getOrderId, finalCart.getOrderId())
.or()
.isNull(TbCashierCart::getOrderId);
});
});
List<TbCashierCart> list = mpCashierCartMapper.selectList(queryWrapper.eq(TbCashierCart::getStatus, "create"));
if (list.isEmpty()) {
tbOrderInfoMapper.deleteByPrimaryKey(Integer.valueOf(finalCart.getOrderId()));
}
}
setRedisTableCartInfo(tableId, shopId, Collections.singletonList(cart), false);
return Result.success(CodeEnum.SUCCESS, masterId);
}
@ -160,12 +248,27 @@ public class OrderService {
masterId = "#" + String.format("%03d", 1);
}
}
TbCashierCart cart = cashierCartMapper.selectByPrimaryKey(cartId);
if (Objects.nonNull(cart)) {
//查询现有规格商品
if("edit".equals(type)&&!cart.getSkuId().equals(skuId.toString())){
TbCashierCart cashierCart = cashierCartMapper.selectByDetail(masterId, productId, shopId, skuId.toString(), DateUtils.getDay(), uuid, tableId);
if(Objects.nonNull(cashierCart)){
cashierCart.setNumber(cashierCart.getNumber()+number);
cashierCart.setTotalNumber(cashierCart.getNumber()+number);
cashierCart.setUpdatedAt(System.currentTimeMillis());
cashierCartMapper.updateByPrimaryKey(cashierCart);
cashierCartMapper.deleteByPrimaryKey(cart.getId());
redisUtil.deleteByKey(RedisCst.ORDER_CART_EXISTS + cart.getId());
cart=cashierCart;
}
}else {
cart.setSkuId(skuId.toString());
cart.setNumber(number);
cart.setIsGift(isGift);
cart.setIsPack(isPack);
if (isPack.equals("false")){
cart.setPackFee(BigDecimal.ZERO);
}else {
@ -180,10 +283,33 @@ public class OrderService {
cart.setTotalNumber(number);
cart.setUuid(uuid);
cashierCartMapper.updateByPrimaryKeySelective(cart);
}
} else {
List<TbCashierCart> list = cashierCartMapper.selectALlByMasterId(masterId, "create");
TbCashierCart cashierCart = cashierCartMapper.selectByDetail(masterId, productId, shopId, skuId.toString(), DateUtils.getDay(), uuid);
// TbCashierCart cashierCart = cashierCartMapper.selectByDetail(masterId, productId, shopId, skuId.toString(), DateUtils.getDay(), uuid, tableId);
String finalMasterId = masterId;
TbCashierCart cashierCart = mpCashierCartMapper.selectOne(new LambdaQueryWrapper<TbCashierCart>()
.eq(TbCashierCart::getShopId, shopId)
.eq(TbCashierCart::getSkuId, skuId)
.eq(TbCashierCart::getProductId, productId)
.eq(TbCashierCart::getTableId, tableId)
.in(TbCashierCart::getStatus, "create")
.and(query2 -> {
query2.and(query3 -> {
query3.eq(TbCashierCart::getTradeDay, DateUtils.getDay())
.eq(TbCashierCart::getMasterId, finalMasterId);
})
.or((query4 -> {
query4.isNull(TbCashierCart::getTradeDay)
.and(q -> {
q.eq(TbCashierCart::getMasterId, "")
.or()
.isNull(TbCashierCart::getMasterId);
});
}));
}));
if (number > 0) {
if (Objects.isNull(cashierCart)) {
cashierCart = new TbCashierCart();
@ -202,6 +328,7 @@ public class OrderService {
cashierCart.setStatus("create");
cashierCart.setIsPack(isPack);
cashierCart.setIsGift(isGift);
cashierCart.setSkuName(skuWithBLOBs.getSpecSnap());
if (isGift.equals("false")) {
cashierCart.setTotalAmount(new BigDecimal(number).multiply(skuWithBLOBs.getSalePrice()));
} else {
@ -219,6 +346,7 @@ public class OrderService {
cashierCart.setNumber(number);
cashierCart.setUuid(uuid);
cashierCart.setCategoryId(product.getCategoryId());
cashierCart.setTableId(tableId);
list.add(cashierCart);
cashierCartMapper.insert(cashierCart);
cart=cashierCart;
@ -235,7 +363,7 @@ public class OrderService {
cashierCart.setPackFee(new BigDecimal(number).multiply(product.getPackFee()));
}
cashierCart.setTotalAmount(new BigDecimal(cashierCart.getNumber()).multiply(skuWithBLOBs.getSalePrice()).add(cashierCart.getPackFee()));
cashierCartMapper.updateByPrimaryKeySelective(cashierCart);
mpCashierCartMapper.updateById(cashierCart);
}
} else {
cashierCartMapper.updateStatus(cashierCart.getId(), "close");
@ -255,17 +383,49 @@ public class OrderService {
redisUtil.saveMessage("SHOP:CODE:SET" + clientType + ":" + shopId + ":" + DateUtils.getDay(),masterId.substring(1,masterId.length()));
TbCashierCart finalCart1 = cart;
ThreadUtil.execute(() -> {
ThreadUtil.sleep(1, TimeUnit.SECONDS);
if (finalCart1.getOrderId() != null && finalCart1.getTableId() != null) {
log.info("购物车数量改变,开始校验订单是否为空");
printMechineConsumer.printReturnTicket(Integer.valueOf(finalCart1.getOrderId()), tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(finalCart1.getOrderId())));
}
});
setRedisTableCartInfo(tableId, shopId, Collections.singletonList(cart), true);
return Result.success(CodeEnum.SUCCESS, masterId);
}
private void setRedisTableCartInfo(String tableId, String shopId, List<TbCashierCart> tbCashierCartList, boolean isAdd) {
String tableCartKey = RedisCst.getTableCartKey(tableId, shopId);
String tableCart = redisUtil.getMessage(tableCartKey);
List<TbCashierCart> cartArrayList = new ArrayList<>();
if (tableCart != null) {
cartArrayList = JSONObject.parseArray(tableCart, TbCashierCart.class);
}
for (TbCashierCart cashierCart : tbCashierCartList) {
cartArrayList = cartArrayList.stream().filter(d -> !d.getId().equals(cashierCart.getId())).collect(Collectors.toList());
if (isAdd) {
cartArrayList.add(cashierCart);
}
}
List<TbCashierCart> finalCartArrayList = cartArrayList;
redisUtil.saveMessage(tableCartKey,
JSONObject.toJSONString(finalCartArrayList));
}
/**
* 校验商品库存警戒线并通知商户
*
* @param productSku sku
*/
private void checkWarnLineAndSendMsg(TbProductSku productSku, TbProduct product, Integer shopId, Integer num) {
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(shopId);
log.info("下单,开始校验库存预警,商品信息:{}, {}, {}", product, productSku, num);
if (productSku.getWarnLine() == null) {
return;
}
@ -285,47 +445,82 @@ public class OrderService {
(product.getIsDistribute() == 1 && product.getStockNumber() - num <= productSku.getWarnLine())
|| (product.getIsDistribute() != 1) && productSku.getStockNumber() - num <= productSku.getWarnLine()
) {
List<TbShopOpenId> shopOpenIds = shopOpenIdMapper.selectByShopId(Integer.valueOf(product.getShopId()));
List<TbShopOpenId> shopOpenIds = shopOpenIdMapper.selectStateByShopIdAndType(product.getShopId(), ShopWxMsgTypeEnum.STOCK_MSG.getType());
shopOpenIds.forEach(item -> {
wxAccountUtil.sendStockWarnMsg("商品库存不足", product.getName(),
product.getIsDistribute() == 1 ? product.getStockNumber()-num : (int) (productSku.getStockNumber() - num), item.getOpenId());
product.getIsDistribute() == 1 ? product.getStockNumber()-num : (int) (productSku.getStockNumber() - num), item.getOpenId(), ShopWxMsgTypeEnum.STOCK_MSG, shopId);
});
}
}
public Result queryCart(String masterId, String shopId) {
public Result queryCart(String masterId, String shopId, String tableId) {
if (StringUtils.isEmpty(shopId)) {
return Result.fail(CodeEnum.SHOPINFONOEXIST);
}
String day = DateUtils.getDay();
List<TbCashierCart> list = cashierCartMapper.selectByMaskerId(masterId, Integer.valueOf(shopId),"create",day);
if (list.size() < 1){
list = cashierCartMapper.selectByMaskerId(masterId, Integer.valueOf(shopId), "refund",day);
if (list.size() > 0){
if (list.size() < 1) {
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
.notIn(TbCashierCart::getStatus, "final", "refund", "closed", "pending")
.eq(TbCashierCart::getShopId, shopId);
// 普通点单
if (StrUtil.isBlank(tableId)) {
queryWrapper.eq(TbCashierCart::getMasterId, masterId)
.eq(TbCashierCart::getTradeDay, day)
.and(query -> {
query.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, "");
});
// 台桌点单
}else if (StrUtil.isNotBlank(tableId)) {
String finalMasterId = masterId;
queryWrapper.eq(TbCashierCart::getTableId, tableId)
.and(query -> {
query.eq(TbCashierCart::getMasterId, finalMasterId)
.or()
.isNull(TbCashierCart::getMasterId)
.or()
.eq(TbCashierCart::getMasterId, "");
});
}
// List<TbCashierCart> list = cashierCartMapper.selectByMaskerId(masterId, Integer.valueOf(shopId),"create",day);
List<TbCashierCart> list = mpCashierCartMapper.selectList(queryWrapper.eq(TbCashierCart::getStatus, "create"));
if (list.isEmpty()){
list = mpCashierCartMapper.selectList(queryWrapper.eq(TbCashierCart::getStatus, "refund"));
// list = cashierCartMapper.selectByMaskerId(masterId, Integer.valueOf(shopId), "refund",day);
if (!list.isEmpty()){
if (list.isEmpty()) {
return Result.fail(CodeEnum.CARTJH);
}
int orderId = 0;
String uuid = "";
ArrayList<Integer> ids = new ArrayList<>();
for (TbCashierCart cashierCart : list) {
if (StringUtils.isNotEmpty(cashierCart.getOrderId())) {
orderId = Integer.valueOf(cashierCart.getOrderId());
break;
orderId = Integer.parseInt(cashierCart.getOrderId());
}
cashierCart.setStatus("create");
ids.add(cashierCart.getId());
}
cashierCartMapper.updateStatusByMaster(Integer.valueOf(shopId), masterId, "create", day, uuid);
// mpCashierCartMapper.insertOrUpdate(list);
// cashierCartMapper.updateStatusByMaster(Integer.valueOf(shopId), masterId, "create", day, uuid);
mpCashierCartMapper.update(null, new LambdaUpdateWrapper<TbCashierCart>()
.set(TbCashierCart::getStatus, "create")
.in(TbCashierCart::getId, ids));
if (orderId > 0) {
tbOrderInfoMapper.updateStatusById(orderId, "cancelled");
orderDetailMapper.updateStatusByOrderId(orderId, "cancelled");
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",null);
}
}
}
Map<String, Object> map = new HashMap<>();
map.put("list", list);
map.put("masterId", masterId);
BigDecimal totalAmount = BigDecimal.ZERO;
BigDecimal packAmount = BigDecimal.ZERO;
for (TbCashierCart cashierCart : list) {
if (StrUtil.isNotBlank(cashierCart.getMasterId())) {
masterId = cashierCart.getMasterId();
}
totalAmount = totalAmount.add(cashierCart.getTotalAmount());
if (cashierCart.getIsPack().equals("true")) {
packAmount = packAmount.add(cashierCart.getPackFee());
@ -344,6 +539,9 @@ public class OrderService {
}
// TbProductSkuResult skuResult = tbProductSkuResultMapper.selectByPr imaryKey(Integer.valueOf(cashierCart.getProductId()));
}
map.put("masterId", masterId);
QueryCartPo queryCartPo = cashierCartMapper.selectProductNumByMarketId(day, shopId, masterId);
queryCartPo.setPackAmount(packAmount);
queryCartPo.setTotalAmount(totalAmount);
@ -354,7 +552,7 @@ public class OrderService {
return Result.success(CodeEnum.SUCCESS, map);
}
@Transactional(rollbackFor = Exception.class)
// @Transactional(rollbackFor = Exception.class)
public Result delCart(String masterId, Integer cartId) {
@ -363,6 +561,10 @@ public class OrderService {
return Result.fail(CodeEnum.CARTEXIST);
}
// if (cashierCart.getOrderId() != null) {
// return Result.success(CodeEnum.SUCCESS, "已打票商品不支持删除", null);
// }
TbProductWithBLOBs product= tbProductMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getProductId()));
if(ObjectUtil.isEmpty(product)){
return Result.fail(CodeEnum.PRODUCTINFOERROR);
@ -387,22 +589,119 @@ public class OrderService {
List<String> skuIds=new ArrayList<>();
skuIds.add(cashierCart.getSkuId());
cashierCartMapper.deleteByCartId(masterId, cartId);
cashierCartMapper.deleteByPrimaryKey(cartId);
if (StrUtil.isNotBlank(cashierCart.getOrderId()) && StrUtil.isNotBlank(cashierCart.getTableId())) {
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
.notIn(TbCashierCart::getStatus, "final", "refund", "closed", "pending")
.eq(TbCashierCart::getShopId, cashierCart.getShopId());
queryWrapper.eq(TbCashierCart::getTableId, cashierCart.getTableId())
.and(query -> {
query.eq(TbCashierCart::getMasterId, cashierCart.getMasterId())
.or()
.isNull(TbCashierCart::getMasterId)
.or()
.eq(TbCashierCart::getMasterId, "");
})
.and(query -> {
query.eq(TbCashierCart::getOrderId, cashierCart.getOrderId())
.or()
.isNull(TbCashierCart::getOrderId);
});
List<TbCashierCart> list = mpCashierCartMapper.selectList(queryWrapper.eq(TbCashierCart::getStatus, "create"));
if (list.isEmpty()) {
ThreadUtil.execute(() -> {
log.info("购物车数量改变,开始校验订单是否为空");
printMechineConsumer.printReturnTicket(Integer.valueOf(cashierCart.getOrderId()), null);
tbOrderInfoMapper.deleteByPrimaryKey(Integer.valueOf(cashierCart.getOrderId()));
});
}
}
if (StrUtil.isNotBlank(cashierCart.getTableId())) {
setRedisTableCartInfo(cashierCart.getTableId(), cashierCart.getShopId(), Collections.singletonList(cashierCart), false);
}
return Result.success(CodeEnum.SUCCESS);
}
@Transactional(rollbackFor = Exception.class)
public Result createOrder(OrderVo orderVo, String clientType, String token) {
public Result createOrder(OrderVo orderVo, String clientType, String token, Integer oldOrderId, boolean isPost) {
String day = DateUtils.getDay();
List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(orderVo.getMasterId(), orderVo.getShopId(), day, "create", orderVo.getUuid());
if (list.size() < 1) {
list = cashierCartMapper.selectAllCreateOrder(orderVo.getMasterId(), orderVo.getShopId(), day, "create", orderVo.getUuid());
TbShopTable shopTable = null;
String currentOrderKey = RedisCst.getCurrentOrderKey(orderVo.getTableId(),
orderVo.getShopId().toString());
String orderIdValue = redisUtil.getMessage(currentOrderKey);
Integer orderId = isPost ? orderIdValue == null ? 0 : Integer.parseInt(orderIdValue) : 0;
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
.eq(TbCashierCart::getShopId, orderVo.getShopId())
.eq(TbCashierCart::getStatus, "create");
// 普通点单
if (StrUtil.isBlank(orderVo.getTableId())) {
queryWrapper.eq(TbCashierCart::getMasterId, orderVo.getMasterId())
.eq(TbCashierCart::getTradeDay, day)
.and(query -> {
query.isNull(TbCashierCart::getTableId)
.or()
.eq(TbCashierCart::getTableId, "");
});
// 台桌点单
}else if (StrUtil.isNotBlank(orderVo.getTableId())) {
queryWrapper.eq(TbCashierCart::getTableId, orderVo.getTableId())
.and(query2 -> {
query2.or(query3 -> {
query3.eq(TbCashierCart::getTradeDay, DateUtils.getDay())
.eq(TbCashierCart::getMasterId, orderVo.getMasterId());
})
.or((query4 -> {
query4.isNull(TbCashierCart::getTradeDay)
.or()
.eq(TbCashierCart::getMasterId, "")
.or()
.isNull(TbCashierCart::getMasterId);
}));
});
shopTable = mpShopTableMapper.selectOne(new LambdaUpdateWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, orderVo.getTableId()));
if (shopTable == null) {
return Result.fail("台桌不存在");
}
}
List<TbCashierCart> list = mpCashierCartMapper.selectList(queryWrapper);
// List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(orderVo.getMasterId(), orderVo.getShopId(), day, "create", orderVo.getUuid());
if (list.isEmpty()) {
list = mpCashierCartMapper.selectList(queryWrapper);
// list = cashierCartMapper.selectAllCreateOrder(orderVo.getMasterId(), orderVo.getShopId(), day, "create", orderVo.getUuid());
}
if(ObjectUtil.isEmpty(list)||ObjectUtil.isNull(list)||list.size()<=0){
if (oldOrderId != null) {
orderDetailMapper.deleteByOUrderId(oldOrderId);
TbOrderInfo orderInfo = new TbOrderInfo();
orderInfo.setId(oldOrderId);
orderInfo.setOrderAmount(BigDecimal.ZERO);
orderInfo.setDiscountAmount(BigDecimal.ZERO);
orderInfo.setStatus("cancelled");
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
// tbOrderInfoMapper.deleteByPrimaryKey(oldOrderId);
}
return Result.fail(CARTEXIST);
}
BigDecimal totalAmount = BigDecimal.ZERO;
BigDecimal packAMount = BigDecimal.ZERO;
BigDecimal feeAmount = BigDecimal.ZERO;
@ -411,21 +710,34 @@ public class OrderService {
Map<Integer, TbProduct> productMap = new HashMap<>();
List<TbOrderDetail> orderDetails = new ArrayList<>();
String masterId = "";
int orderId = 0;
if (list.size()<1 || list.isEmpty()){
return Result.fail(CARTEXIST);
}
for (TbCashierCart cashierCart : list) {
TbOrderDetail orderDetail = new TbOrderDetail();
TbProductWithBLOBs product=tbProductMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getProductId()));
if("takeaway".equals(orderVo.getSendType())||"takeself".equals(orderVo.getSendType())){
if(Objects.nonNull(product.getPackFee())){
packAMount = packAMount.add(product.getPackFee());
orderDetail.setPackAmount(product.getPackFee());
}
}
TbProductSkuWithBLOBs tbProduct = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getSkuId()));
totalAmount = totalAmount.add(cashierCart.getTotalAmount());
packAMount = packAMount.add(cashierCart.getPackFee());
feeAmount = cashierCart.getPackFee();
if (Objects.nonNull(tbProduct)) {
saleAmount = saleAmount.add(tbProduct.getSalePrice());
}
skuMap.put(tbProduct.getId(), tbProduct);
TbOrderDetail orderDetail = new TbOrderDetail();
orderDetail.setCreateTime(new Date());
orderDetail.setNum(cashierCart.getNumber());
orderDetail.setPrice(cashierCart.getSalePrice());
@ -439,7 +751,6 @@ public class OrderService {
orderDetail.setProductSkuName(tbProduct.getSpecSnap());
orderDetail.setProductName(cashierCart.getName());
orderDetail.setShopId(orderVo.getShopId());
orderDetail.setPackAmount(cashierCart.getPackFee());
orderDetail.setStatus("unpaid");
orderDetail.setProductImg(cashierCart.getCoverImg());
masterId = cashierCart.getMasterId();
@ -451,10 +762,14 @@ public class OrderService {
String orderNo = generateOrderNumber();
TbToken tbToken = tokenMapper.selectByToken(token);
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(orderId);
if (orderId > 0) {
if (orderInfo == null || !"unpaid".equals(orderInfo.getStatus())) {
redisUtil.deleteByKey(currentOrderKey);
}
if (orderInfo != null && orderId > 0) {
// if (!orderInfo.getStatus().equals("unpaid")){
// return Result.fail(CodeEnum.ORDERCREATE);
// }
orderDetailMapper.deleteByOUrderId(orderId);
// orderInfo = tbOrderInfoMapper.selectByPrimaryKey(orderId);
orderInfo.setUpdatedAt(System.currentTimeMillis());
@ -469,14 +784,23 @@ public class OrderService {
orderInfo.setProductAmount(saleAmount);
orderInfo.setTradeDay(DateUtils.getDay());
orderInfo.setUserId(orderVo.getUserId());
orderInfo.setUseType(StrUtil.isNotBlank(orderVo.getTableId()) ? "postPay" : "afterPay");
orderInfo.setPackFee(packAMount);
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
} else {
orderInfo = new TbOrderInfo(orderNo, totalAmount, packAMount, totalAmount, saleAmount, totalAmount, feeAmount, "",
"table", "cash", orderVo.getMerchantId().toString(), orderVo.getShopId().toString(),
orderVo.getSendType(), "cash", orderVo.getMerchantId().toString(), orderVo.getShopId().toString(),
"", (byte) 1, day, masterId);
orderInfo.setMasterId(masterId);
orderInfo.setMasterId(orderVo.getMasterId());
orderInfo.setRemark(orderVo.getRemark());
orderInfo.setUserId(orderVo.getUserId());
orderInfo.setUseType(StrUtil.isNotBlank(orderVo.getTableId()) ? "postPay" : "afterPay");
orderInfo.setTableName(shopTable != null ? shopTable.getName() : null);
orderInfo.setPayAmount(BigDecimal.ZERO);
if (StrUtil.isNotBlank(orderVo.getTableId())) {
orderInfo.setTableId(orderVo.getTableId());
}
if (Objects.nonNull(tbToken)){
orderInfo.setTokenId(tbToken.getId());
}
@ -505,17 +829,26 @@ public class OrderService {
tbOrderInfoMapper.insert(orderInfo);
redisUtil.saveMessage(RedisCst.OUT_NUMBER.concat(orderInfo.getShopId()),object.toString());
orderId = orderInfo.getId();
if (isPost) {
redisUtil.saveMessage(currentOrderKey, orderInfo.getId().toString());
}
}
for (TbOrderDetail orderDetail : orderDetails) {
orderDetail.setOrderId(orderId);
if (orderDetail.getPackAmount() == null) {
orderDetail.setPackAmount(BigDecimal.ZERO);
}
orderDetailMapper.insert(orderDetail);
}
boolean flag = true;
for (TbCashierCart cashierCart : list) {
TbProductWithBLOBs product = tbProductMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getProductId()));
TbProductSkuWithBLOBs skuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getSkuId()));
log.info("下单,开始校验库存预警,购物车id:{}", cashierCart.getId());
CompletableFuture.runAsync(() -> checkWarnLineAndSendMsg(skuWithBLOBs, product, Integer.valueOf(cashierCart.getShopId()), cashierCart.getNumber()));
// 已经添加的商品修改数量
@ -546,6 +879,21 @@ public class OrderService {
}
if (flag) {
redisUtil.deleteByKey("SHOP:CODE:USER:" + clientType + ":" + orderVo.getShopId() + ":" + day + orderVo.getUserId());
// 代课下单
if (!StrUtil.isBlank(orderVo.getTableId())) {
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, orderInfo.getTableId())
.set(TbShopTable::getStatus, TableStateEnum.USING.getState()));
}
}
if (!StrUtil.isBlank(orderVo.getTableId())) {
if (isPost) {
producer.printMechine(String.valueOf(orderId));
}
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, orderInfo.getTableId())
.set(TbShopTable::getStatus, TableStateEnum.USING.getState()));
}
JSONObject object=new JSONObject();
@ -568,8 +916,6 @@ public class OrderService {
redisUtil.saveMessage(RedisCst.OUT_NUMBER.concat(orderInfo.getShopId().toString()),object.toString());
log.info("创建订单发送更新耗材消息订单id{}", orderInfo.getId());
//修改耗材数据
JSONObject jsonObject=new JSONObject();
@ -588,9 +934,25 @@ public class OrderService {
}
});
// 删除小程序购物车缓存
if (StrUtil.isNotBlank(orderInfo.getTableId())) {
String tableCartKey = RedisCst.getTableCartKey(orderVo.getTableId(), orderVo.getShopId().toString());
redisUtil.deleteByKey(tableCartKey);
}
return Result.success(CodeEnum.SUCCESS, orderInfo);
}
public synchronized void addGlobalCode(String day, String clientType, String shopId) {
String code = redisUtil.getMessage("SHOP:CODE:" + clientType + ":" + shopId + ":" + day);
if (StrUtil.isBlank(code)) {
redisUtil.saveMessage("SHOP:CODE:" + clientType + ":" + shopId + ":" + day, "1");
}else {
redisUtil.getMessage("SHOP:CODE:" + clientType + ":" + shopId + ":" + (Integer.parseInt(code) + 1));
}
redisUtil.execsSet("SHOP:CODE:SET" + clientType + ":" + shopId + ":" + day, "1");
}
public synchronized String generateOrderCode(String day, String clientType, String shopId) {
String code = redisUtil.getMessage("SHOP:CODE:" + clientType + ":" + shopId + ":" + day)+"";
// 使用顺序递增的计数器生成取餐码
@ -602,19 +964,20 @@ public class OrderService {
orderCode =String.valueOf(Integer.valueOf(code)+1);
}
redisUtil.getIncrNum("SHOP:CODE:" + clientType + ":" + shopId + ":" + day, "2");
boolean flag = redisUtil.execsSet("SHOP:CODE:SET" + clientType + ":" + shopId + ":" + day,orderCode);
if (flag){
return generateOrderCode(day,clientType,shopId);
}
// 增加计数器
// boolean flag = redisUtil.execsSet("SHOP:CODE:SET" + clientType + ":" + shopId + ":" + day,orderCode);
// if (flag){
// return generateOrderCode(day,clientType,shopId);
// }
// 增加计数器
return orderCode;
}
public Result createCode(String shopId, String clientType, String userId, String type) {
public Result createCode(String shopId, String clientType, String userId, String type, String tableId) {
String day = DateUtils.getDay();
JSONObject jsonObject = new JSONObject();
String key="SHOP:CODE:USER:" + clientType + ":" + shopId + ":" + day + userId;
// String key="SHOP:CODE:USER:" + clientType + ":" + shopId + ":" + day + userId;
String key="SHOP:CODE:USER:" + clientType + ":" + shopId + ":" + day + ":" + tableId;
String userCode = redisUtil.getMessage(key)+"";
if ("1".equals(type)) {
String code = "#" + generateOrderCode(day, clientType, shopId);
@ -685,11 +1048,34 @@ public class OrderService {
@Transactional(rollbackFor = Exception.class)
public Result cartStatus(Integer shopId, String masterId, String status, String userId, String uuid, String clientType) {
public Result cartStatus(Integer shopId, String masterId, String status, String userId, String uuid,
String clientType, Integer vipUserId, String tableId) {
String newUuid = redisUtil.getMessage("CART:UUID:" + shopId + userId)+"";
String day = DateUtils.getDay();
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
.eq(TbCashierCart::getShopId, shopId);
// 普通点单
if (StrUtil.isBlank(tableId)) {
queryWrapper.eq(TbCashierCart::getMasterId, masterId);
queryWrapper.isNull(TbCashierCart::getTableId);
// 台桌点单
}else if (StrUtil.isNotBlank(tableId) && vipUserId == null) {
queryWrapper.eq(TbCashierCart::getTableId, tableId)
.eq(TbCashierCart::getMasterId, masterId);
// 会员点单
}else {
queryWrapper
.eq(TbCashierCart::getTableId, tableId)
.eq(TbCashierCart::getUserId, vipUserId);
}
if ("true".equals(status)) {
List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(masterId, shopId, day, "create", uuid);
List<TbCashierCart> list = mpCashierCartMapper.selectList(queryWrapper);
// List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(masterId, shopId, day, "create", uuid);
if (list.size() < 1) {
return Result.fail(CodeEnum.CREATEORDER);
}
@ -760,35 +1146,48 @@ public class OrderService {
if (StringUtils.isNotEmpty(cashierCart.getOrderId())) {
flag = false;
}
cashierCart.setUserId(vipUserId);
cashierCart.setOrderId(orderId + "");
cashierCart.setUpdatedAt(System.currentTimeMillis());
cashierCart.setPendingAt(System.currentTimeMillis());
cashierCart.setStatus("refund");
cashierCart.setUuid(newUuid);
cashierCartMapper.updateByPrimaryKeySelective(cashierCart);
mpCashierCartMapper.updateById(cashierCart);
}
if (flag) {
redisUtil.deleteByKey("SHOP:CODE:USER:" + clientType + ":" + shopId + ":" + day + userId);
;
}
} else {
List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(masterId, shopId, "", "refund", uuid);
if (list.size() < 1) {
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, tableId)
.set(TbShopTable::getStatus, TableStateEnum.PENDING.getState()));
} else {
List<TbCashierCart> list = mpCashierCartMapper.selectList(queryWrapper
.eq(TbCashierCart::getStatus, "refund"));
// List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(masterId, shopId, "", "refund", uuid);
if (list.isEmpty()) {
return Result.fail(CodeEnum.CARTJH);
}
int orderId = 0;
ArrayList<Integer> ids = new ArrayList<>();
for (TbCashierCart cashierCart : list) {
if (StringUtils.isNotEmpty(cashierCart.getOrderId())) {
orderId = Integer.valueOf(cashierCart.getOrderId());
break;
orderId = Integer.parseInt(cashierCart.getOrderId());
}
ids.add(cashierCart.getId());
// cashierCart.setStatus("create");
// }
}
cashierCartMapper.updateStatusByMaster(shopId, masterId, "create", day, uuid);
mpCashierCartMapper.update(null, new LambdaUpdateWrapper<TbCashierCart>()
.set(TbCashierCart::getStatus, "create")
.in(TbCashierCart::getId, ids));
// cashierCartMapper.updateStatusByMaster(shopId, masterId, "create", day, uuid);
if (orderId > 0) {
tbOrderInfoMapper.updateStatusById(orderId, "cancelled");
orderDetailMapper.updateStatusByOrderId(orderId, "cancelled");
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",null);
}
}
return Result.success(CodeEnum.SUCCESS);
@ -832,11 +1231,44 @@ public class OrderService {
@Transactional(rollbackFor = Exception.class)
public Result clearCart(CartVo cartVo) {
String day = DateUtils.getDay();
List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(cartVo.getMasterId(), Integer.valueOf(cartVo.getShopId()), day, "create", cartVo.getUuid());
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
.eq(TbCashierCart::getShopId, cartVo.getShopId())
.eq(TbCashierCart::getStatus, "create");
// 普通点单
if (StrUtil.isBlank(cartVo.getTableId())) {
queryWrapper.eq(TbCashierCart::getMasterId, cartVo.getMasterId())
.eq(TbCashierCart::getTradeDay, day)
.and(query -> {
query.isNull(TbCashierCart::getTableId)
.or()
.eq(TbCashierCart::getTableId, "");
});
// 台桌点单
}else if (StrUtil.isNotBlank(cartVo.getTableId()) ) {
queryWrapper.eq(TbCashierCart::getTableId, cartVo.getTableId())
.and(query -> {
query.eq(TbCashierCart::getMasterId, cartVo.getMasterId())
.or()
.isNull(TbCashierCart::getMasterId)
.or()
.eq(TbCashierCart::getMasterId, "");
});
// 会员点单
}
List<TbCashierCart> list = mpCashierCartMapper.selectList(queryWrapper);
// List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(cartVo.getMasterId(), Integer.valueOf(cartVo.getShopId()), day, "create", cartVo.getUuid());
int orderId = 0;
List<ProductSkuPo> productSkuPos=new ArrayList<>();
List<String> skuIds=new ArrayList<>();
List<ProductSkuPo> productSkuPos = new ArrayList<>();
List<String> skuIds = new ArrayList<>();
ArrayList<Integer> ids = new ArrayList<>();
for (TbCashierCart cashierCart : list) {
if (StrUtil.isNotBlank(cashierCart.getOrderId())) {
orderId = Integer.parseInt(cashierCart.getOrderId());
}
ids.add(cashierCart.getId());
// 数量减少, 返还库存
String message = redisUtil.getMessage(RedisCst.ORDER_PRODUCT_NUM + cashierCart.getId());
redisUtil.deleteByKey(RedisCst.ORDER_PRODUCT_NUM + cashierCart.getId());
@ -844,10 +1276,7 @@ public class OrderService {
if (message != null) {
productService.incrStock(cashierCart.getProductId(), cashierCart.getSkuId(), Integer.parseInt(message));
}
if (StringUtils.isNotEmpty(cashierCart.getOrderId())) {
orderId = Integer.parseInt(cashierCart.getOrderId());
}
TbProductWithBLOBs product= tbProductMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getProductId()));
if(ObjectUtil.isNotEmpty(product)&&"1".equals(product.getIsStock().toString())){
ProductSkuPo skuPo=new ProductSkuPo(Integer.valueOf(cashierCart.getSkuId()),cashierCart.getTotalNumber());
@ -858,7 +1287,14 @@ public class OrderService {
}
if (orderId > 0) {
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(orderId);
if (ids.isEmpty() && "postPay".equals(orderInfo.getUseType())) {
return Result.success(CodeEnum.SUCCESS);
}
// 返还耗材
JSONObject jsonObject1=new JSONObject();
jsonObject1.put("orderId", orderId);
@ -866,20 +1302,41 @@ public class OrderService {
log.info("清空购物车 发送返还耗材mq消息订单id{},消息内容:{}", orderId, jsonObject1);
producer.cons(jsonObject1.toString());
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(orderId);
if (Objects.nonNull(orderInfo) && !orderInfo.getStatus().equals("pending")){
tbOrderInfoMapper.updateStatusById(orderId, "cancelled");
orderDetailMapper.updateStatusByOrderId(orderId, "cancelled");
// orderDetailMapper.updateStatusByOrderId(orderId, "cancelled");
orderDetailMapper.deleteByOUrderId(orderId);
}
if ("postPay".equals(orderInfo.getUseType())) {
tbOrderInfoMapper.deleteByPrimaryKey(orderId);
}
}
if (!ids.isEmpty()) {
mpCashierCartMapper.deleteBatchIds(ids);
}
// cashierCartMapper.deleteByPrimaryKey()
cashierCartMapper.deleteBymasterId(cartVo.getMasterId(), Integer.valueOf(cartVo.getShopId()), day, "create", cartVo.getUuid());
// if(ObjectUtil.isNotEmpty(productSkuPos)&&productSkuPos.size()>0){
// tbProductSkuMapper.batchStockNum(productSkuPos);
// }
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, cartVo.getTableId())
.set(TbShopTable::getStatus, TableStateEnum.IDLE.getState()));
// 打印退款票据
int finalOrderId = orderId;
ThreadUtil.execute(() -> {
printMechineConsumer.printReturnTicket(finalOrderId, null);
});
setRedisTableCartInfo(cartVo.getTableId(), cartVo.getShopId(), list, false);
return Result.success(CodeEnum.SUCCESS);
}
@ -939,8 +1396,18 @@ public class OrderService {
@Autowired
TbShopUserMapper tbShopUserMapper;
public Result orderDetail(Integer shopId, Integer id) {
public Result orderDetail(Integer shopId, Integer id, String clientType, String token, String userId, String staffId) {
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(id);
// OrderVo orderVo = new OrderVo();
// orderVo.setMasterId(orderInfo.getMasterId());
// orderVo.setShopId(Integer.valueOf(orderInfo.getShopId()));
// orderVo.setTableId(orderInfo.getTableId());
// orderVo.setMerchantId(Integer.valueOf(userId));
// createOrder(orderVo, clientType, token, id, false);
// orderInfo = tbOrderInfoMapper.selectByPrimaryKey(id);
if (Objects.nonNull(orderInfo)) {
List<TbOrderDetail> list = orderDetailMapper.selectAllByOrderId(id);
orderInfo.setDetailList(list);
@ -1330,4 +1797,19 @@ public class OrderService {
JSONObject jsonObject = JSON.parseObject(HttpClientUtil.doGet(requestUrl,requestUrlParam));
return jsonObject;
}
public Object updateVip(UpdateVipDTO updateVipDTO) {
LambdaUpdateWrapper<TbCashierCart> queryWrapper = new LambdaUpdateWrapper<>();
queryWrapper.eq(TbCashierCart::getTableId, updateVipDTO.getTableId())
.eq(TbCashierCart::getShopId, updateVipDTO.getShopId())
.eq(TbCashierCart::getMasterId, updateVipDTO.getMasterId());
if (updateVipDTO.getType().equals(0)) {
queryWrapper.set(TbCashierCart::getUserId, null);
queryWrapper.eq(TbCashierCart::getUserId, updateVipDTO.getVipUserId());
}else {
queryWrapper.set(TbCashierCart::getUserId, updateVipDTO.getVipUserId());
}
return mpCashierCartMapper.update(null, queryWrapper);
}
}

View File

@ -7,9 +7,13 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.entity.dto.ProductStatusDTO;
import com.chaozhanggui.system.cashierservice.entity.dto.ProductStockDTO;
import com.chaozhanggui.system.cashierservice.entity.dto.QuerySpecDTO;
import com.chaozhanggui.system.cashierservice.entity.vo.ShopCategoryVo;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.interceptor.LimitSubmitAspect;
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.chaozhanggui.system.cashierservice.util.DateUtils;
@ -44,6 +48,12 @@ public class ProductService {
@Autowired
private LimitSubmitAspect limitSubmitAspect;
private final RabbitProducer producer;
public ProductService(RabbitProducer producer) {
this.producer = producer;
}
public Result queryCategory(String shopId,Integer page,Integer pageSize){
PageHelperUtil.startPage(page, pageSize);
@ -71,7 +81,7 @@ public class ProductService {
String day = DateUtils.getDay();
if(ObjectUtil.isNotEmpty(tbProductWithBLOBs)){
tbProductWithBLOBs.parallelStream().forEach(it->{
Integer orderCount=tbProductMapper.countOrderByshopIdAndProductId(it.getShopId(),it.getId().toString(),masterId,day);
Integer orderCount=tbProductMapper.countOrderByshopIdAndProductId(it.getShopId(),it.getId().toString(),masterId,day, "");
it.setOrderCount((ObjectUtil.isNull(orderCount)||ObjectUtil.isEmpty(orderCount))?0:orderCount);
TbProductSpec tbProductSpec= tbProductSpecMapper.selectByPrimaryKey(it.getSpecId());
if(ObjectUtil.isEmpty(tbProductSpec)){
@ -100,19 +110,23 @@ public class ProductService {
}
public Result queryNewCommodityInfo(String shopId, String categoryId, String commdityName, int page, int pageSize, String masterId) {
public Result queryNewCommodityInfo(String shopId, String categoryId, String commdityName, String tableId, int page, int pageSize, String masterId) {
List<TbProductWithBLOBs> tbProductWithBLOBs=null;
PageHelperUtil.startPage(page,pageSize);
if(ObjectUtil.isEmpty(categoryId)){
tbProductWithBLOBs=tbProductMapper.selectByShopIdAndCheckGrounding(shopId,commdityName);
}else {
if (Integer.valueOf(categoryId).equals(-1)) {
tbProductWithBLOBs = tbProductMapper.selectByShopIdAndShopTypeUnGrounding(shopId,commdityName);
}else {
tbProductWithBLOBs=tbProductMapper.selectByShopIdAndShopTypeCheckGrounding(shopId,categoryId,commdityName);
}
}
String day = DateUtils.getDay();
if(ObjectUtil.isNotEmpty(tbProductWithBLOBs)){
tbProductWithBLOBs.parallelStream().forEach(it->{
Integer orderCount=tbProductMapper.countOrderByshopIdAndProductId(it.getShopId(),it.getId().toString(),masterId,day);
Integer orderCount=tbProductMapper.countOrderByshopIdAndProductId(it.getShopId(),it.getId().toString(),masterId,day, tableId);
it.setOrderCount((ObjectUtil.isNull(orderCount)||ObjectUtil.isEmpty(orderCount))?0:orderCount);
TbProductSpec tbProductSpec= tbProductSpecMapper.selectByPrimaryKey(it.getSpecId());
if(ObjectUtil.isEmpty(tbProductSpec)){
@ -121,72 +135,20 @@ public class ProductService {
it.setTbProductSpec(tbProductSpec);
TbProductSkuResult skuResult=tbProductSkuResultMapper.selectByPrimaryKey(it.getId());
// 上下架对应的sku
String selectSpec = it.getSelectSpec();
List<TbProductSku> tbProductSkus = tbProductSkuMapper.selectGroundingByProId(it.getId());
HashSet<String> specSet = new HashSet<>();
tbProductSkus.forEach(item -> {
String specSnap = item.getSpecSnap();
if (specSnap != null) {
specSet.addAll(Arrays.asList(specSnap.split(",")));
}
});
String tagSnap = skuResult != null ? skuResult.getTagSnap() : null;
if (tagSnap != null) {
JSONArray tagSnaps = JSONObject.parseArray(tagSnap);
JSONObject snapJSON;
JSONArray finalSnap = new JSONArray();
HashMap<String, String> snapMap = new HashMap<>();
for (Object snap : tagSnaps) {
StringBuilder finalValues = new StringBuilder();
snapJSON = (JSONObject) snap;
String values = snapJSON.getString("value");
if (StrUtil.isNotBlank(values)) {
String[] valueList = values.split(",");
for (String value : valueList) {
if (specSet.contains(value)) {
finalValues.append(value).append(",");
}
}
if (StrUtil.isNotBlank(finalValues.toString())) {
finalValues = new StringBuilder(StrUtil.removeSuffix(finalValues.toString(), ","));
snapJSON.put("value", finalValues.toString());
finalSnap.add(snapJSON);
snapMap.put(snapJSON.getString("name"), snapJSON.getString("value"));
}
}
}
if (selectSpec != null) {
JSONArray selectSpecJSON = JSONObject.parseArray(selectSpec);
for (Object selectSpecInfo : selectSpecJSON) {
JSONObject specInfo = (JSONObject) selectSpecInfo;
String name = snapMap.get(specInfo.getString("name"));
if (name != null) {
specInfo.put("value", name.split(","));
specInfo.put("selectSpecResult", name.split(","));
}
}
it.setSelectSpec(selectSpecJSON.toJSONString());
}
skuResult.setTagSnap(finalSnap.toJSONString());
}
it.setProductSkuResult(skuResult);
// 查询sku信息
List<TbProductSku> skuWithBLOBs = tbProductSkuMapper.selectByProductCheckGrounding(it.getId());
List<TbProductSku> skus = tbProductSkuMapper.selectByProductId(it.getId());
if (it.getIsDistribute() == 0) {
int num = 0;
for (TbProductSku item : skus) {
num += item.getStockNumber();
}
it.setStockNumber(num);
}
it.setSkuList(skuWithBLOBs);
it.setGroundingSpecInfo(querySpec(Integer.valueOf(shopId), it.getId()));
});
}
PageInfo pageInfo=new PageInfo(tbProductWithBLOBs);
@ -222,4 +184,115 @@ public class ProductService {
}
}
}
public void updateState(ProductStatusDTO productStatusDTO) {
TbProduct product = tbProductMapper.selectByShopIdAndId(productStatusDTO.getProductId(), productStatusDTO.getShopId());
if (productStatusDTO.getType().equals(0)) {
tbProductMapper.updateGroundingByProId(product.getId(), productStatusDTO.getState());
}else {
tbProductMapper.pauseSale(productStatusDTO.getProductId(), productStatusDTO.getShopId(), productStatusDTO.getState());
tbProductMapper.pauseSkuSale(productStatusDTO.getProductId(), productStatusDTO.getShopId(), productStatusDTO.getState());
}
}
public void updateStock(ProductStockDTO productStockDTO) {
TbProduct product = tbProductMapper.selectByShopIdAndId(productStockDTO.getProductId(), productStockDTO.getShopId());
if (product == null) {
throw new MsgException("商品不存在");
}
if (product.getIsDistribute() != 1 && product.getTypeEnum().equals("sku")) {
throw new MsgException("多规格非共享商品暂不支持修改库存");
}else {
tbProductMapper.updateStock(productStockDTO.getShopId(), productStockDTO.getProductId(), productStockDTO.getStock());
tbProductSkuMapper.updateStock(productStockDTO.getShopId(), productStockDTO.getProductId(), productStockDTO.getStock());
List<TbProductSku> tbProductSkus = tbProductSkuMapper.selectByProductId(product.getId());
JSONObject data = new JSONObject();
data.put("shopId", productStockDTO.getShopId());
data.put("skuId", tbProductSkus.isEmpty() ? null : tbProductSkus.get(0).getId());
data.put("productId", productStockDTO.getProductId());
data.put("type", "pc收银机修改库存");
data.put("subType", product.getStockNumber() > productStockDTO.getStock() ? -1 : 1);
data.put("number",productStockDTO.getStock() - product.getStockNumber());
producer.sendStockRecordMsg(data);
}
}
private static void generateCombinations(List<List<String>> valuesList, int index, List<String> current, List<String> result) {
if (index == valuesList.size()) {
result.add(String.join(",", current));
return;
}
for (String value : valuesList.get(index)) {
current.add(value);
generateCombinations(valuesList, index + 1, current, result);
current.remove(current.size() - 1); // 回溯
}
}
public Object querySpec(Integer shopId, Integer productId) {
TbProduct tbProduct = tbProductMapper.selectByPrimaryKey(productId);
if (tbProduct == null) {
throw new MsgException("商品不存在");
}
TbProductSkuResult skuResult = tbProductSkuResultMapper.selectByPrimaryKey(productId);
// 重组有效规格数据
String tagSnap = skuResult != null ? skuResult.getTagSnap() : null;
List<TbProductSku> tbProductSkus = tbProductSkuMapper.selectGroundingByProId(productId);
JSONArray finalSnap = new JSONArray();
List<String> result = new ArrayList<>();
if (tagSnap != null) {
JSONArray tagSnaps = JSONObject.parseArray(tagSnap);
List<List<String>> valuesList = new ArrayList<>();
// 提取所有 value 的列表
for (int i = 0; i < tagSnaps.size(); i++) {
JSONObject jsonObject = tagSnaps.getJSONObject(i);
if (jsonObject.containsKey("value")) {
String[] values = jsonObject.getString("value").split(",");
valuesList.add(Arrays.asList(values));
}
}
// 生成所有可能的排列组合
generateCombinations(valuesList, 0, new ArrayList<>(), result);
}
ArrayList<HashMap<String, Object>> specList = new ArrayList<>();
tbProductSkus.forEach(item -> {
HashMap<String, Object> itemMap = new HashMap<>();
itemMap.put("specSnap", item.getSpecSnap());
itemMap.put("skuId", item.getId());
specList.add(itemMap);
});
ArrayList<HashMap<String, Object>> otherVal = new ArrayList<>();
for (String res : result) {
boolean found = false;
for (HashMap<String, Object> spec : specList) {
if (res.equals(spec.get("specSnap").toString())) {
spec.put("isGrounding", true);
found = true;
break;
}
}
if (!found) {
HashMap<String, Object> itemMap = new HashMap<>();
itemMap.put("specSnap", res);
itemMap.put("skuId", null);
itemMap.put("isGrounding", false);
otherVal.add(itemMap);
}
}
specList.addAll(otherVal);
return specList;
}
}

View File

@ -1,9 +1,15 @@
package com.chaozhanggui.system.cashierservice.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.chaozhanggui.system.cashierservice.bean.TableStateEnum;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.entity.vo.TbShopTableVO;
import com.chaozhanggui.system.cashierservice.mybatis.MpShopTableMapper;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.chaozhanggui.system.cashierservice.util.DateUtils;
@ -12,6 +18,7 @@ import com.chaozhanggui.system.cashierservice.util.TokenUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
@ -20,7 +27,8 @@ import java.util.*;
@Service
public class ShopInfoService {
@Autowired
TbShopInfoMapper tbShopInfoMapper;
@Autowired
TbShopAreaMapper tbShopAreaMapper;
@ -33,6 +41,21 @@ public class ShopInfoService {
ShopUserDutyMapper shopUserDutyMapper;
@Autowired
ShopUserDutyDetailMapper shopUserDutyDetailMapper;
private final TbOrderInfoMapper orderInfoMapper;
@Qualifier("tbCashierCartMapper")
@Autowired
private TbCashierCartMapper tbCashierCartMapper;
@Autowired
private MpShopTableMapper mpShopTableMapper;
public ShopInfoService(TbOrderInfoMapper orderInfoMapper) {
this.orderInfoMapper = orderInfoMapper;
}
public Result queryShopInfo(Integer shopId) {
return new Result(CodeEnum.SUCCESS,tbShopInfoMapper.selectByPrimaryKey(shopId));
}
public Result queryShopArea(String shopId){
List<TbShopArea> list= tbShopAreaMapper.selectByShopId(shopId);
@ -46,8 +69,23 @@ public class ShopInfoService {
}
PageHelperUtil.startPage(page, pageSize);
List<TbShopTable> shopTables=tbShopTableMapper.selectByShopIdAndStatus(shopId,areaId,status);
PageInfo pageInfo=new PageInfo(shopTables);
// List<TbShopTable> shopTables=tbShopTableMapper.selectByShopIdAndStatus(shopId,areaId,status);
List<TbShopTableVO> tbShopTableVOList = tbShopTableMapper.selectTableInfo(shopId, areaId, status, DateUtils.getDay());
for (TbShopTableVO tbShopTableVO : tbShopTableVOList) {
if (StrUtil.isBlank(tbShopTableVO.getQrcode())) {
tbShopTableVO.setStatus("closed");
}else if (tbCashierCartMapper.countTable(tbShopTableVO.getQrcode(), tbShopTableVO.getShopId()) < 1 ||
tbCashierCartMapper.countTableByDetail(tbShopTableVO.getOrderId(), tbShopTableVO.getShopId()) < 1
) {
tbShopTableVO.setStatus("idle");
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, tbShopTableVO.getQrcode())
.set(TbShopTable::getStatus, TableStateEnum.IDLE.getState()));
}
}
PageInfo pageInfo=new PageInfo(tbShopTableVOList);
return Result.success(CodeEnum.SUCCESS,pageInfo);
}
@ -94,4 +132,13 @@ public class ShopInfoService {
map.put("amount",amount);
return Result.success(CodeEnum.SUCCESS,map);
}
public Result queryShopPwdInfo(String shopId){
TbShopInfo tbShopInfo= tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(shopId));
Map<String, String> data = new HashMap<>();
data.put("isMemberIn", tbShopInfo.getIsMemberIn());
data.put("isMemberReturn", tbShopInfo.getIsMemberReturn());
data.put("isReturn", tbShopInfo.getIsReturn());
return Result.success(CodeEnum.SUCCESS,data);
}
}

View File

@ -0,0 +1,21 @@
package com.chaozhanggui.system.cashierservice.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.chaozhanggui.system.cashierservice.entity.TbShopPermission;
import com.chaozhanggui.system.cashierservice.sign.Result;
/**
* (TbShopPermission)表服务接口
*
* @author makejava
* @since 2024-09-14 17:08:48
*/
public interface TbShopPermissionService extends IService<TbShopPermission> {
/**
* 查询员工是否拥有某个权限
*/
Result getStaffPermission(String staffId, String code);
}

View File

@ -0,0 +1,15 @@
package com.chaozhanggui.system.cashierservice.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.chaozhanggui.system.cashierservice.entity.TbShopStaffPermission;
/**
* 店铺员工权限关联表(TbShopStaffPermission)表服务接口
*
* @author makejava
* @since 2024-09-14 17:07:33
*/
public interface TbShopStaffPermissionService extends IService<TbShopStaffPermission> {
}

View File

@ -0,0 +1,46 @@
package com.chaozhanggui.system.cashierservice.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chaozhanggui.system.cashierservice.dao.TbShopPermissionDao;
import com.chaozhanggui.system.cashierservice.entity.TbShopPermission;
import com.chaozhanggui.system.cashierservice.entity.TbShopStaffPermission;
import com.chaozhanggui.system.cashierservice.service.TbShopPermissionService;
import com.chaozhanggui.system.cashierservice.service.TbShopStaffPermissionService;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
/**
* (TbShopPermission)表服务实现类
*
* @author makejava
* @since 2024-09-14 17:08:49
*/
@Service
@Primary
public class TbShopPermissionServiceImpl extends ServiceImpl<TbShopPermissionDao, TbShopPermission> implements TbShopPermissionService {
@Autowired
private TbShopStaffPermissionService shopStaffPermissionService;
@Override
public Result getStaffPermission(String staffId, String code) {
QueryWrapper<TbShopPermission> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("code", code);
TbShopPermission permission = this.getOne(queryWrapper);
if (permission == null) {
return Result.fail("权限不存在");
}
QueryWrapper<TbShopStaffPermission> staffPermissionQueryWrapper = new QueryWrapper<>();
staffPermissionQueryWrapper.eq("staff_id", staffId);
staffPermissionQueryWrapper.eq("permission_id", permission.getId());
TbShopStaffPermission staffPermission = shopStaffPermissionService.getOne(staffPermissionQueryWrapper);
return Result.success(CodeEnum.SUCCESS, staffPermission != null);
}
}

View File

@ -0,0 +1,21 @@
package com.chaozhanggui.system.cashierservice.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chaozhanggui.system.cashierservice.dao.TbShopStaffPermissionDao;
import com.chaozhanggui.system.cashierservice.entity.TbShopStaffPermission;
import com.chaozhanggui.system.cashierservice.service.TbShopStaffPermissionService;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
/**
* 店铺员工权限关联表(TbShopStaffPermission)表服务实现类
*
* @author makejava
* @since 2024-09-14 17:07:33
*/
@Service
@Primary
public class TbShopStaffPermissionServiceImpl extends ServiceImpl<TbShopStaffPermissionDao, TbShopStaffPermission> implements TbShopStaffPermissionService {
}

View File

@ -104,7 +104,25 @@ public enum CodeEnum {
PWDERROE("100038",false,"操作密码错误","fail"),
STAFFNOEXISTERROE("100039",false,"员工信息不存在","fail"),
STAFFDISCOUNTAMOUNTHIGHT("100040",false,"优惠金额不能大于员工授权额度","fail"),
USERSHOPFLOWNOEXIST("100041",false,"充值记录不存在","fail"),
OPARETIONERROR("100042",false,"操作错误","fail"),
ACCOUNTAMOUNT("100043",false,"账户余额不足","fail"),
INPURAMOUNTERROR("100044",false,"输入金额不允许大于订单原始金额","fail"),
ACCOUNTBALANCEERROR("100045",false,"账户余额不足","fail"),

View File

@ -0,0 +1,48 @@
package com.chaozhanggui.system.cashierservice.thirdpay.req;
import lombok.Data;
import java.io.Serializable;
@Data
public class ApppayReq implements Serializable {
private String subject;
private String body;
private Long amount;
private String currency="cny";
/**
* 微信 WECHAT
* 支付宝 ALIPAY
*/
private String payType;
private String clientIp;
private String mchOrderNo;
private String storeId;
private String notifyUrl;
private String returnUrl;
public ApppayReq(String subject, String body, Long amount, String currency, String payType, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl) {
this.subject = subject;
this.body = body;
this.amount = amount;
this.currency = currency;
this.payType = payType;
this.clientIp = clientIp;
this.mchOrderNo = mchOrderNo;
this.storeId = storeId;
this.notifyUrl = notifyUrl;
this.returnUrl = returnUrl;
}
}

View File

@ -0,0 +1,45 @@
package com.chaozhanggui.system.cashierservice.thirdpay.req;
import lombok.Data;
import java.io.Serializable;
@Data
public class ChrpayReq implements Serializable {
private String subject;
private String body;
private Long amount;
private String currency="cny";
private String payType;
private String clientIp;
private String mchOrderNo;
private String storeId;
private String notifyUrl;
private String returnUrl;
public ChrpayReq(String subject, String body, Long amount, String currency, String payType, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl) {
this.subject = subject;
this.body = body;
this.amount = amount;
this.currency = currency;
this.payType = payType;
this.clientIp = clientIp;
this.mchOrderNo = mchOrderNo;
this.storeId = storeId;
this.notifyUrl = notifyUrl;
this.returnUrl = returnUrl;
}
}

View File

@ -0,0 +1,47 @@
package com.chaozhanggui.system.cashierservice.thirdpay.req;
import lombok.Data;
import java.io.Serializable;
@Data
public class H5payReq implements Serializable {
private String subject;
private String body;
private Long amount;
private String currency="cny";
/**
* 微信 WECHAT
* 支付宝 ALIPAY
*/
private String payType;
private String clientIp;
private String mchOrderNo;
private String storeId;
private String notifyUrl;
private String returnUrl;
public H5payReq(String subject, String body, Long amount, String currency, String payType, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl) {
this.subject = subject;
this.body = body;
this.amount = amount;
this.currency = currency;
this.payType = payType;
this.clientIp = clientIp;
this.mchOrderNo = mchOrderNo;
this.storeId = storeId;
this.notifyUrl = notifyUrl;
this.returnUrl = returnUrl;
}
}

View File

@ -0,0 +1,53 @@
package com.chaozhanggui.system.cashierservice.thirdpay.req;
import lombok.Data;
import java.io.Serializable;
@Data
public class JspayReq implements Serializable {
private String subject;
private String body;
private Long amount;
private String currency="cny";
/**
* 微信 WECHAT
* 支付宝 ALIPAY
*/
private String payType;
private String subAppid;
private String userId;
private String clientIp;
private String mchOrderNo;
private String storeId;
private String notifyUrl;
private String returnUrl;
public JspayReq(String subject, String body, Long amount, String currency, String payType, String subAppid, String userId, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl) {
this.subject = subject;
this.body = body;
this.amount = amount;
this.currency = currency;
this.payType = payType;
this.subAppid = subAppid;
this.userId = userId;
this.clientIp = clientIp;
this.mchOrderNo = mchOrderNo;
this.storeId = storeId;
this.notifyUrl = notifyUrl;
this.returnUrl = returnUrl;
}
}

View File

@ -3,6 +3,7 @@ package com.chaozhanggui.system.cashierservice.thirdpay.req;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
@Data
public class MainScanReq implements Serializable {
@ -25,7 +26,13 @@ public class MainScanReq implements Serializable {
private String notifyUrl;
public MainScanReq(String subject, String body, Long amount, String subAppid, String currency, String authCode, String mchOrderNo, String storeId, String notifyUrl) {
private int divisionMode;
private ArrayList divList;
private String divTemplateNo;
public MainScanReq(String subject, String body, Long amount, String subAppid, String currency, String authCode, String mchOrderNo, String storeId, String notifyUrl,int divisionMode,String divTemplateNo,ArrayList divList) {
this.subject = subject;
this.body = body;
this.amount = amount;
@ -35,6 +42,9 @@ public class MainScanReq implements Serializable {
this.mchOrderNo = mchOrderNo;
this.storeId = storeId;
this.notifyUrl = notifyUrl;
this.divisionMode=divisionMode;
this.divList=divList;
this.divTemplateNo=divTemplateNo;
}

Some files were not shown because too many files have changed in this diff Show More